--- /dev/null
+Sunwook Bae <sunwook45.bae at samsung dot com>
+Kyeongwoo Lee <kyeongwoo.lee at samsung dot com>
+Seokpil Park <seokpil.park at samsung dot com>
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET (this_target osp-content)
+
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output)
+
+INCLUDE_DIRECTORIES(
+ inc
+ src
+ src/inc
+ /usr/include/appfw
+ /usr/include/curl
+ /usr/include/glib-2.0
+ /usr/lib/glib-2.0/include
+ /usr/include/content
+ /usr/include/media
+ /usr/include/media-content
+ /usr/include/osp
+ /usr/include/osp/base
+ /usr/include/osp/io
+ /usr/include/osp/media
+ /usr/include/osp/graphics
+ /usr/include/osp/net
+ /usr/include/osp/system
+ /usr/include/osp/app
+ /usr/include/osp/security
+ /usr/include/web
+ )
+
+SET (${this_target}_SOURCE_FILES
+ src/FCnt_AudioMetadataImpl.cpp
+ src/FCnt_ContentManagerImpl.cpp
+ src/FCnt_ContentManagerUtilImpl.cpp
+ src/FCnt_ContentUtility.cpp
+ src/FCnt_ContentSearchImpl.cpp
+ src/FCnt_ContentDirectoryImpl.cpp
+ src/FCnt_PlayListImpl.cpp
+ src/FCnt_PlayListManagerImpl.cpp
+ src/FCnt_ContentTransferImpl.cpp
+ src/FCnt_ImageMetadataImpl.cpp
+ src/FCnt_VideoMetadataImpl.cpp
+ src/FCnt_ContentTransferEvent.cpp
+ src/FCnt_ContentDownloadHandler.cpp
+ src/FCnt_ContentDownloadListener.cpp
+ src/FCnt_ContentDownloadUserData.cpp
+ src/FCnt_DownloadManagerImpl.cpp
+ src/FCnt_DownloadRequestImpl.cpp
+ src/FCntAudioContentInfo.cpp
+ src/FCntAudioMetadata.cpp
+ src/FCntContentInfo.cpp
+ src/FCntContentManager.cpp
+ src/FCntContentManagerUtil.cpp
+ src/FCntContentSearch.cpp
+ src/FCntContentDirectory.cpp
+ src/FCntPlayList.cpp
+ src/FCntPlayListManager.cpp
+ src/FCntContentSearchResult.cpp
+ src/FCntContentTransfer.cpp
+ src/FCntContentTransferInfo.cpp
+ src/FCntImageContentInfo.cpp
+ src/FCntImageMetadata.cpp
+ src/FCntOtherContentInfo.cpp
+ src/FCntVideoContentInfo.cpp
+ src/FCntVideoMetadata.cpp
+ src/FCntDownloadManager.cpp
+ src/FCntDownloadRequest.cpp
+)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall" )
+
+## SET C COMPILER FLAGS
+SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## SET CPP COMPILER FLAGS
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+
+## Create Library
+ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES})
+
+## SET LINKER FLAGS
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed")
+
+TARGET_LINK_LIBRARIES(${this_target} "-lchromium" )
+TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw" )
+TARGET_LINK_LIBRARIES(${this_target} "-losp-uifw" )
+TARGET_LINK_LIBRARIES(${this_target} "-losp-net" )
+TARGET_LINK_LIBRARIES(${this_target} "-losp-image" )
+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")
+TARGET_LINK_LIBRARIES(${this_target} "-lcapi-web-url-download")
+TARGET_LINK_LIBRARIES(${this_target} "-lpthread")
+
+SET_TARGET_PROPERTIES(${this_target}
+ PROPERTIES
+ VERSION ${FULLVER}
+ SOVERSION ${MAJORVER}
+ CLEAN_DIRECT_OUTPUT 1
+ )
+
+ADD_CUSTOM_COMMAND(TARGET ${this_target}
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER}
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${MAJORVER}
+ COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}
+ COMMENT "strip ${this_target}"
+ )
+
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/ DESTINATION lib/osp
+ FILES_MATCHING PATTERN "*.so*"
+ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
+ GROUP_EXECUTE GROUP_READ
+ WORLD_EXECUTE WORLD_READ)
+INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/debug/ DESTINATION lib/osp/debug
+ FILES_MATCHING PATTERN "*.so*"
+ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
+ GROUP_EXECUTE GROUP_READ
+ WORLD_EXECUTE WORLD_READ)
+
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/inc/ DESTINATION include/osp FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/inc/ DESTINATION include/osp/content FILES_MATCHING PATTERN "*.h")
+
+# pkgconfig file
+CONFIGURE_FILE(${this_target}.pc.in ${CMAKE_SOURCE_DIR}/${this_target}.pc @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/${this_target}.pc DESTINATION lib/pkgconfig)
--- /dev/null
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
--- /dev/null
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License terms and conditions.
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntAudioContentInfo.h
+ * @brief This is the header file for the %AudioContentInfo class.
+ *
+ * This header file contains the declarations of the %AudioContentInfo class.
+ */
+
+#ifndef _FCNT_AUDIO_CONTENT_INFO_H_
+#define _FCNT_AUDIO_CONTENT_INFO_H_
+
+#include <FCntContentInfo.h>
+
+namespace Tizen { namespace Content
+{
+
+class _AudioContentInfoImpl;
+
+/**
+ * @class AudioContentInfo
+ * @brief This class provides methods to access the audio content information.
+ *
+ * @since 2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ * The %AudioContentInfo class provides methods to access the audio content information that is extracted from a physical file. @n
+ * Before getting the audio content information, ContentManager must be used to create the content.
+ *
+ * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/content/device_content_attributes.htm#media">Device Content Attributes</a>.
+ *
+ * The following example demonstrates how to use the %AudioContentInfo class.
+ *
+ * @code
+ * result
+ * MyClass::TestAudioContentInfo(void)
+ * {
+ * result r = E_SUCCESS;
+ *
+ * ContentId contentId;
+ * ContentManager contentManager;
+ * r = contentManager.Construct();
+ * TryReturn(!IsFailed(r), r, "Construct failed.");
+ *
+ * AudioContentInfo audioContentInfo;
+ * r = audioContentInfo.Construct(null);
+ * TryReturn(!IsFailed(r), r, "Construct failed.");
+ *
+ * Tizen::Base::String sourcePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/flower.wma";
+ * Tizen::Base::String destPath = Tizen::System::Environment::GetMediaPath() + L"Sounds/flower.wma";
+ *
+ * contentId = contentManager.CreateContent(sourcePath, destPath, false, &audioContentInfo);
+ * TryReturn(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed.");
+ *
+ * return r;
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ AudioContentInfo
+ : public Tizen::Content::ContentInfo
+{
+public:
+ /**
+ * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+ *
+ * @since 2.0
+ *
+ * @remarks After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+ */
+ AudioContentInfo(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~AudioContentInfo(void);
+
+ /**
+ * Initializes this instance of %AudioContentInfo with the specified parameter.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @compatibility This method has compatibility issues with OSP compatible applications. @n
+ * For more information, see @ref CompAudioContentInfoConstructPage "here".
+ * @endif
+ *
+ * @return An error code
+ * @param[in] pContentPath The content path
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_IO An I/O error has occurred.
+ * @exception E_SYSTEM An internal error has occurred.
+ * @remarks The @c pContentPath should start with directory path returned by either Tizen::System::Environment::GetMediaPath() or Tizen::System::Environment::GetExternalStoragePath(). @n
+ * If @c pContentPath is @c null, use ContentManager::CreateContent(const Tizen::Base::ByteBuffer&, const Tizen::Base::String&, const ContentInfo*)
+ * or ContentManager::CreateContent(const Tizen::Base::String&, const Tizen::Base::String&, bool, const ContentInfo*).
+ */
+ result Construct(const Tizen::Base::String* pContentPath);
+
+ /**
+ * @if OSPCOMPAT
+ * @page CompAudioContentInfoConstructPage Compatibility for the file path.
+ * @section CompAudioContentInfoConstructPageIssueSection Issues
+ * The content path argument of this method in OSP compatible applications has the following issues: @n
+ * -# The content path should be a path that begins with an allowed path prefix. @n
+ * For example, L"/Media/Images/flower.jpg", L"/Storagecard/Media/Images/flower.jpg".
+ *
+ * @section CompAudioContentInfoConstructPageSolutionSection Resolutions
+ * This issue has been resolved in Tizen. @n
+ * -# The content path can be a path without a specific allowed path prefix. @n
+ * Application do not need to know the specific allowed path prefixes. @n
+ * To get the directory path, use the following methods: @n
+ * - For accessing the media directory, use Tizen::System::Environment::GetMediaPath().
+ * - For accessing the external storage, use Tizen::System::Environment::GetExternalStoragePath().
+ *
+ * @endif
+ */
+
+ /**
+ * @if OSPDEPREC
+ * Initializes this instance of %AudioContentInfo with the specified parameters.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This method is deprecated as there is a problem in managing the user-defined thumbnail and device coordinates. @n
+ * Instead of using this method, use Construct(const Tizen::Base::String*). @n
+ * To set the coordinates in the ContentInfo instance, use ContentInfo::SetCoordinates(const Tizen::Locations::Coordinates&).
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] contentPath The content path
+ * @param[in] thumbnailPath The thumbnail path
+ * @param[in] setGps Set to @c true to save the device's last known coordinates in the ContentInfo instance, @n
+ * else @c false @n
+ * The coordinate information may be incorrect if it is outdated or has never been updated. @n
+ * To update the coordinate information or to get the exact value,
+ * use Tizen::Locations::LocationProvider::RequestLocationUpdates() before calling this method.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_IO An I/O error has occurred.
+ * @remarks The content path must start with @c '/Media' or @c '/Storagecard/Media'. @n
+ * The thumbnail path must start with @c '/Home', @c '/Media', or @c '/Storagecard/Media'. @n
+ * The permitted format for a thumbnail image is Bitmap (bmp).
+ * @endif
+ */
+ virtual result Construct(const Tizen::Base::String& contentPath, const Tizen::Base::String& thumbnailPath = L"", bool setGps = false);
+
+ /**
+ * Gets the genre information of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The genre information of the audio file, @n
+ * else @c Unknown if the value is empty
+ */
+ Tizen::Base::String GetGenre(void) const;
+
+ /**
+ * Gets the artist information of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The artist information of the audio file, @n
+ * else @c Unknown if the value is empty
+ */
+ Tizen::Base::String GetArtist(void) const;
+
+ /**
+ * Gets the composer information of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The composer information of the audio file, @n
+ * else @c Unknown if the value is empty
+ */
+ Tizen::Base::String GetComposer(void) const;
+
+ /**
+ * Gets the album name of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The album name of the audio file, @n
+ * else @c Unknown if the value is empty
+ */
+ Tizen::Base::String GetAlbumName(void) const;
+
+ /**
+ * Gets the release year information of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The release year information of the audio file
+ */
+ int GetReleaseYear(void) const;
+
+ /**
+ * Gets the bit rate information of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The bit rate in bits per second (bps)
+ */
+ int GetBitrate(void) const;
+
+ /**
+ * Gets the title of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The title of the audio file, @n
+ * else @c Unknown if the value is empty
+ */
+ Tizen::Base::String GetTitle(void) const;
+
+ /**
+ * Gets the copyright of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The copyright of the audio file, @n
+ * else @c Unknown if the value is empty
+ */
+ Tizen::Base::String GetCopyright(void) const;
+
+ /**
+ * Gets the track information of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The track information of the audio file, @n
+ * else @c Unknown if the value is empty
+ */
+ Tizen::Base::String GetTrackInfo(void) const;
+
+ /**
+ * Gets the duration of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The duration of the audio file in milliseconds
+ */
+ long GetDuration(void) const;
+
+private:
+ class _AudioContentData
+ {
+ public:
+ _AudioContentData()
+ : bitrate(0)
+ , releaseYear(0)
+ , duration(0)
+ , pTitle(null)
+ , pAlbumName(null)
+ , pArtist(null)
+ , pComposer(null)
+ , pGenre(null)
+ , pCopyright(null)
+ , pTrackInfo(null) {}
+
+ int bitrate;
+ int releaseYear;
+ long duration;
+ Tizen::Base::String* pTitle;
+ Tizen::Base::String* pAlbumName;
+ Tizen::Base::String* pArtist;
+ Tizen::Base::String* pComposer;
+ Tizen::Base::String* pGenre;
+ Tizen::Base::String* pCopyright;
+ Tizen::Base::String* pTrackInfo;
+ };
+
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ AudioContentInfo(const AudioContentInfo& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ AudioContentInfo& operator =(const AudioContentInfo& rhs);
+
+ result SetAudioContentData(const _AudioContentData* pAudioContentData);
+
+ _AudioContentData* GetAudioContentData(void);
+
+private:
+ _AudioContentData* __pAudioContentData;
+
+ friend class _ContentManagerImpl;
+ friend class _ContentSearchImpl;
+ friend class _ContentDirectoryImpl;
+ friend class _ContentUtility;
+ friend class _PlayListManagerImpl;
+ friend class _PlayListImpl;
+
+ friend class _AudioContentInfoImpl;
+ _AudioContentInfoImpl* __pImpl;
+
+}; // Class AudioContentInfo
+
+}} // Tizen::Content
+
+#endif // _FCNT_AUDIO_CONTENT_INFO_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntAudioMetadata.h
+ * @brief This is the header file for the %AudioMetadata class.
+ *
+ * This header file contains the declarations of the %AudioMetadata class.
+ */
+
+#ifndef _FCNT_AUDIO_METADATA_H_
+#define _FCNT_AUDIO_METADATA_H_
+
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Graphics
+{
+class Bitmap;
+}}
+
+namespace Tizen { namespace Content
+{
+
+class _AudioMetadataImpl;
+
+/**
+ * @class AudioMetadata
+ * @brief This class provides methods to access the audio metadata.
+ *
+ * @since 2.0
+ *
+ * The %AudioMetadata class provides methods to access the audio metadata that contains audio content-specific attributes.
+ *
+ * The following example demonstrates how to use the %AudioMetadata class.
+ *
+ * @code
+ * result
+ * MyClass::TestAudioMetadata(void)
+ * {
+ * result r = E_SUCCESS;
+ *
+ * Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Sounds/hot.mp3";
+ * AudioMetadata* pAudioMeta = ContentManagerUtil::GetAudioMetaN(contentPath);
+ * TryReturn(pAudioMeta != null, GetLastResult(), "ContentManagerUtil::GetAudioMetaN failed.");
+ *
+ * // Title
+ * pAudioMeta->GetTitle();
+ *
+ * // Frequency
+ * pAudioMeta->GetFrequency();
+ *
+ * // Artist
+ * pAudioMeta->GetArtist();
+ *
+ * // Album name
+ * pAudioMeta->GetAlbumName();
+ *
+ * // Duration
+ * pAudioMeta->GetDuration();
+ *
+ * // Year
+ * pAudioMeta->GetYear();
+ *
+ * // Thumbnail
+ * Tizen::Media::Image image;
+ * r = image.Construct();
+ * if (IsFailed(r))
+ * {
+ * delete pAudioMeta;
+ * return r;
+ * }
+ *
+ * Tizen::Graphics::Bitmap* pBitmap = pAudioMeta->GetThumbnailN();
+ * if (pBitmap == null)
+ * {
+ * delete pAudioMeta;
+ * return GetLastResult();
+ * }
+ *
+ * Tizen::Base::String thumbnailPath = Tizen::System::Environment::GetMediaPath() + L"Images/audio.bmp";
+ * r = image.EncodeToFile(*pBitmap, Tizen::Media::IMG_FORMAT_BMP, thumbnailPath, false);
+ * if (IsFailed(r))
+ * {
+ * delete pAudioMeta;
+ * delete pBitmap;
+ * return r;
+ * }
+ *
+ * delete pAudioMeta;
+ * delete pBitmap;
+ *
+ * return r;
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ AudioMetadata
+ : virtual public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ AudioMetadata(void);
+
+ /**
+ * Copying of objects using this copy constructor is allowed.
+ *
+ * @since 2.0
+ *
+ * @param[in] rhs An instance of %AudioMetadata
+ */
+ AudioMetadata(const AudioMetadata& rhs);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~AudioMetadata(void);
+
+ /**
+ * Gets the title of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The title of the audio file
+ */
+ Tizen::Base::String GetTitle(void) const;
+
+ /**
+ * Gets the bit rate of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The audio bit rate in bits per second (bps)
+ */
+ int GetBitrate(void) const;
+
+ /**
+ * Gets the frequency of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The frequency in hertz (hz)
+ */
+ int GetFrequency(void) const;
+
+ /**
+ * Gets the artist information of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The artist information of the audio file
+ */
+ Tizen::Base::String GetArtist(void) const;
+
+ /**
+ * Gets the album name of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The album name of the audio file
+ */
+ Tizen::Base::String GetAlbumName(void) const;
+
+ /**
+ * Gets the comment of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The comment of the audio file
+ */
+ Tizen::Base::String GetComment(void) const;
+
+ /**
+ * Gets the track number of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The track number of the audio file
+ */
+ int GetTrack(void) const;
+
+ /**
+ * Gets the genre information of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The genre information of the audio file
+ */
+ Tizen::Base::String GetGenre(void) const;
+
+ /**
+ * Gets the composer information of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The composer information of the audio file
+ */
+ Tizen::Base::String GetComposer(void) const;
+
+ /**
+ * Gets the copyright information of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The copyright information of the audio file
+ */
+ Tizen::Base::String GetCopyright(void) const;
+
+ /**
+ * Gets the duration of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The duration in milliseconds
+ */
+ long GetDuration(void) const;
+
+ /**
+ * Gets the year information of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The year information of the audio file
+ */
+ int GetYear(void) const;
+
+ /**
+ * Gets the track information of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The track number/position in set
+ * @remarks This method returns track information that is embedded in the content metadata. @n
+ * The format returned can be like "4/9" or "4" (in case the position is not available).
+ */
+ Tizen::Base::String GetTrackInfo(void) const;
+
+ /**
+ * Gets the recording date of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The recording date of the audio file
+ */
+ Tizen::Base::String GetRecordingDate(void) const;
+
+ /**
+ * Gets the number of channels of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return The number of channels of the audio file
+ * @remarks A monophonic stream has one channel and a stereophonic stream has two channels. @n
+ * Valid values are either @c 1 or @c 2.
+ */
+ int GetChannelCount(void) const;
+
+ /**
+ * Gets the thumbnail of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return A pointer to the thumbnail image
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_DATA_NOT_FOUND The thumbnail image does not exist.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @remarks This method returns the thumbnail image that is resized to 80x60 pixels. @n
+ * The specific error code can be accessed using the GetLastResult() method.
+ */
+ Tizen::Graphics::Bitmap* GetThumbnailN(void) const;
+
+ /**
+ * Gets the album art of the audio file.
+ *
+ * @since 2.0
+ *
+ * @return A pointer to the album art
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_DATA_NOT_FOUND The album art does not exist.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @remarks GetThumbnailN() returns the thumbnail image that is resized to 80x60 pixels. @n
+ * GetAlbumArtN() returns the original album art that is embedded in the content metadata. @n
+ * The specific error code can be accessed using the GetLastResult() method.
+ */
+ Tizen::Graphics::Bitmap* GetAlbumArtN(void) const;
+
+ /**
+ * Compares the equality of values between two %AudioMetadata objects by overriding the Tizen::Base::Object::Equals() method.
+ *
+ * @since 2.0
+ *
+ * @return @c true if all the fields in the objects are equal, @n
+ * else @c false
+ * @param[in] rhs The Tizen::Base::Object with which the comparison is done
+ * @remarks An instance of Tizen::Graphics::Bitmap is not taken into account in the comparisons.
+ */
+ virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+ /**
+ * Gets the hash value of the current instance by overriding the Tizen::Base::Object::GetHashCode() method.
+ *
+ * @since 2.0
+ *
+ * @return The hash value of the current instance
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * Copying of objects using this copy assignment operator is allowed.
+ *
+ * @since 2.0
+ *
+ * @return A reference to this instance
+ * @param[in] rhs An instance of %AudioMetadata
+ */
+ AudioMetadata& operator =(const AudioMetadata& rhs);
+
+private:
+ friend class _AudioMetadataImpl;
+ _AudioMetadataImpl* __pImpl;
+
+}; // class AudioMetadata
+
+}} // Tizen::Content
+
+#endif // _FCNT_AUDIO_METADATA_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentDirectory.h
+ * @brief This is the header file for the %ContentDirectory class.
+ *
+ * This header file contains the declarations of the %ContentDirectory class.
+ */
+
+#ifndef _FCNT_CONTENT_DIRECTORY_H_
+#define _FCNT_CONTENT_DIRECTORY_H_
+
+#include <FBaseString.h>
+#include <FBaseColIListT.h>
+#include <FCntTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen { namespace Content
+{
+ static const int MAX_CONTENTTYPE_LIST_COUNT = 5;
+ static const int MIN_CONTENTTYPE_LIST_COUNT = 0;
+ static const int CONTENTTYPE_LIST_COUNT_ONE = 1;
+
+class _ContentDirectoryImpl;
+/**
+ * @class ContentDirectory
+ * @brief This class provides methods for the content directory.
+ * @since 2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ * The %ContentDirectory class provides methods to access a list of content directories
+ * and information of the content (specified content type) in the content directories.
+ *
+ * For more information on the database columns and their corresponding content types,
+ * see <a href="../org.tizen.native.appprogramming/html/guide/content/content_search_device.htm">Content Search on the Device</a>.
+ *
+ * The following example demonstrates how to use the %ContentDirectory class.
+ *
+ * @code
+ * #include <FContent.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Base::Collection;
+ * using namespace Tizen::Content;
+ *
+ * void
+ * MyClass::Test(void)
+ * {
+ * // Call Construct() of ContentDirectory
+ * ContentDirectory directory;
+ * const Tizen::Base::String contentDirectoryPath = L"";
+ * result r = directory.Construct(CONTENT_TYPE_AUDIO);
+ * if (IsFailed(r))
+ * {
+ * // Do something for an error
+ * }
+ *
+ * // Call GetContentDirectoryItemListN() of ContentDirectory as the first page
+ * int pageNo = 1;
+ * int countPerPage = 5;
+ * int totalPage = 0;
+ * int totalCount = 0;
+ * IList* pContentInfoList = directory.GetContentDirectoryItemListN(contentDirectoryPath, pageNo, countPerPage, L"Title", SORT_ORDER_ASCENDING);
+ *
+ * if (IsFailed(GetLastResult()))
+ * {
+ * // Do something for an error
+ * }
+ *
+ * // Delete resource
+ * pContentInfoList->RemoveAll(true);
+ * delete pContentInfoList;
+ * }
+ *
+ * @endcode
+ *
+ */
+
+class _OSP_EXPORT_ ContentDirectory
+ : public Tizen::Base::Object
+{
+
+public:
+
+ /**
+ * The object is not fully constructed after this constructor is called. @n
+ * For full construction, the Construct() method must be called right after calling this constructor.
+ *
+ * @since 2.0
+ */
+ ContentDirectory(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~ContentDirectory(void);
+
+ /**
+ * Initializes this instance of %ContentDirectory with the specified parameter.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param contentType The content type
+ * @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.
+ * @exception E_SYSTEM The method cannot connect to the database.
+ * @remarks This method is used to access only one type of content. @n
+ * If you want to access more than one type of content, use Construct(const Tizen::Base::Collection::IListT<ContentType>&).
+ * The allowed types are CONTENT_TYPE_OTHER, CONTENT_TYPE_IMAGE, CONTENT_TYPE_AUDIO, and CONTENT_TYPE_VIDEO.
+ */
+ result Construct(ContentType contentType);
+
+ /**
+ * Initializes this instance of %ContentDirectory with the specified parameter.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param contentTypeList The list of content types
+ * @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.
+ * @exception E_SYSTEM The method cannot connect to the database.
+ * @remarks This method is used to access more than one type of content. @n
+ * If you want to access only one type of content, use Construct(ContentType). @n
+ * Total count of @c contentTypeList should not be greater than @c 4. @n
+ * Any combination with CONTENT_TYPE_ALL is a invalid argument. @n
+ * The allowed types are CONTENT_TYPE_OTHER, CONTENT_TYPE_IMAGE, CONTENT_TYPE_AUDIO, and CONTENT_TYPE_VIDEO.
+ */
+ result Construct(const Tizen::Base::Collection::IListT<ContentType>& contentTypeList);
+
+ /**
+ * Gets the count of content directories that contains the content type that is passed as a parameter in Construct().
+ *
+ * @since 2.0
+ *
+ * @return The count of content directories
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_SYSTEM The method cannot access the database.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ int GetContentDirectoryCount(void) const;
+
+ /**
+ * Gets the list of content directory path that contains the content type that is passed as a parameter in Construct().
+ *
+ * @since 2.0
+ *
+ * @return A list of Tizen::Base::String values that contains content directory path
+ * @param sortOrder The sort order
+ * @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.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_SYSTEM The method cannot access the database.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ Tizen::Base::Collection::IList* GetContentDirectoryPathListN(Tizen::Base::SortOrder sortOrder) const;
+
+
+ /**
+ * Gets the count of files in a directory.
+ *
+ * @since 2.0
+ *
+ * @return The count of files
+ * @param contentDirectoryPath The content directory path @n
+ * The allowed directory path can be obtained by using
+ * Tizen::System::Environment::GetMediaPath() and Tizen::System::Environment::GetExternalStoragePath().
+ * @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.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_SYSTEM The method cannot access the database.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @see GetContentDirectoryPathListN()
+ */
+ int GetContentDirectoryItemCount(const Tizen::Base::String& contentDirectoryPath) const;
+
+ /**
+ * Gets the list of content information in a directory.
+ *
+ * @since 2.0
+ *
+ * @return A list of ContentInfo classes that contains content information
+ * @param contentDirectoryPath The content directory path @n
+ * The allowed directory path can be obtained by using
+ * Tizen::System::Environment::GetMediaPath() and Tizen::System::Environment::GetExternalStoragePath().
+ * @param pageNo The page number @n
+ * It must be equal to or greater than @c 1.
+ * @param countPerPage The count of the search results per page @n
+ * It must be equal to or greater than @c 1.
+ * @param column The sort column name
+ * @param sortOrder The sort order
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG A specified input parameter is invalid.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_SYSTEM The method cannot access the database.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @see GetContentDirectoryPathListN()
+ */
+ Tizen::Base::Collection::IList* GetContentDirectoryItemListN(const Tizen::Base::String& contentDirectoryPath, int pageNo, int countPerPage,
+ const Tizen::Base::String& column, Tizen::Base::SortOrder sortOrder) const;
+
+private:
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentDirectory(const ContentDirectory& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentDirectory& operator =(const ContentDirectory& rhs);
+
+ _ContentDirectoryImpl* __pImpl;
+
+ friend class _ContentDirectoryImpl;
+
+}; // class ContentDirectory
+
+}} // Tizen::Content
+
+#endif // _FCNT_CONTENT_DIRECTORY_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentInfo.h
+ * @brief This is the header file for the %ContentInfo class.
+ *
+ * This header file contains the declarations of the %ContentInfo class.
+ */
+
+#ifndef _FCNT_CONTENT_INFO_H_
+#define _FCNT_CONTENT_INFO_H_
+
+#include <FBaseUuId.h>
+#include <FBaseDateTime.h>
+#include <FCntTypes.h>
+#include <FLocCoordinates.h>
+
+namespace Tizen { namespace Locations
+{
+class Coordinates;
+}}
+
+namespace Tizen { namespace Graphics
+{
+class Bitmap;
+}}
+
+namespace Tizen { namespace Content
+{
+
+class _ContentInfoImpl;
+
+/**
+ * @class ContentInfo
+ * @brief This class provides methods to manage the content information.
+ *
+ * @since 2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ * The %ContentInfo class is an abstract base class. @n
+ * ImageContentInfo, AudioContentInfo, VideoContentInfo, and OtherContentInfo are derived from the %ContentInfo class.
+ *
+ * When a user creates content, its content information is created as a new pair. @n
+ * When a user deletes content, its content information is deleted from the content database. @n
+ * This class provides methods to get or to set the specific content information. @n
+ * The physical file is not updated even if the set methods are called.
+ *
+ * For more information on the different types of content information, see <a href="../org.tizen.native.appprogramming/html/guide/content/device_content_mgmt.htm">Device Content Management</a>.
+ *
+ * The following example demonstrates how to use the %ContentInfo class.
+ *
+ * @code
+ * result
+ * MyClass::TestContentInfo(void)
+ * {
+ * result r = E_SUCCESS;
+ *
+ * ContentId contentId;
+ * ContentManager contentManager;
+ * r = contentManager.Construct();
+ * TryReturn(!IsFailed(r), r, "Construct failed.");
+ *
+ * ImageContentInfo imageContentInfo;
+ * r = imageContentInfo.Construct(null);
+ * TryReturn(!IsFailed(r), r, "Construct failed.");
+ *
+ * Tizen::Base::String sourcePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/flower.jpg";
+ * Tizen::Base::String destPath = Tizen::System::Environment::GetMediaPath() + L"Images/flower.jpg";
+ *
+ * contentId = contentManager.CreateContent(sourcePath, destPath, false, &imageContentInfo);
+ * TryReturn(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed.");
+ *
+ * return r;
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ ContentInfo
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~ContentInfo(void);
+
+ /**
+ * @if OSPDEPREC
+ * Initializes this instance of %ContentInfo with the specified parameters.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This method is deprecated as there is a problem in managing the user-defined thumbnail and device coordinates.
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] contentPath The content path
+ * @param[in] thumbnailPath The thumbnail path
+ * @param[in] setGps Set to @c true to save the device's last known coordinates in the %ContentInfo instance, @n
+ * else @c false
+ * @endif
+ */
+ virtual result Construct(const Tizen::Base::String& contentPath, const Tizen::Base::String& thumbnailPath = L"", bool setGps = false) = 0;
+
+ /**
+ * Gets the content ID.
+ *
+ * @since 2.0
+ *
+ * @return The content ID
+ */
+ ContentId GetContentId(void) const;
+
+ /**
+ * Gets the content type.
+ *
+ * @since 2.0
+ *
+ * @return The content type
+ */
+ ContentType GetContentType(void) const;
+
+ /**
+ * Gets the mime type.
+ *
+ * @since 2.0
+ *
+ * @return The mime type
+ */
+ Tizen::Base::String GetMimeType(void) const;
+
+ /**
+ * Gets the date and time of the created content.
+ *
+ * @since 2.0
+ *
+ * @return The content's creation time (GMT)
+ */
+ Tizen::Base::DateTime GetDateTime(void) const;
+
+ /**
+ * Gets the file size of the content.
+ *
+ * @since 2.0
+ *
+ * @return The file size of the content
+ */
+ unsigned long GetContentSize(void) const;
+
+ /**
+ * Gets the content name.
+ *
+ * @since 2.0
+ *
+ * @return The content name
+ */
+ Tizen::Base::String GetContentName(void) const;
+
+ /**
+ * Gets the file path of the content.
+ *
+ * @since 2.0
+ *
+ * @return The file path of the content
+ */
+ Tizen::Base::String GetContentPath(void) const;
+
+ /**
+ * Gets the coordinates of the location.
+ *
+ * @since 2.0
+ *
+ * @return A reference to the coordinates
+ */
+ const Tizen::Locations::Coordinates& GetCoordinates(void) const;
+
+ /**
+ * Sets the coordinates of the location.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] coordinates The user-defined coordinates
+ * @exception E_SUCCESS The method is successful.
+ */
+ result SetCoordinates(const Tizen::Locations::Coordinates& coordinates);
+
+ /**
+ * Sets the location tag.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] locationTag The new location tag
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The length of the input data exceeds the maximum limit of 45 characters.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result SetLocationTag(const Tizen::Base::String& locationTag);
+
+ /**
+ * Gets the location tag.
+ *
+ * @since 2.0
+ *
+ * @return The location tag
+ */
+ Tizen::Base::String GetLocationTag(void) const;
+
+ /**
+ * Sets the rating.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] rating The new rating
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The length of the input data exceeds the maximum limit of 45 characters.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result SetRating(const Tizen::Base::String& rating);
+
+ /**
+ * Gets the rating.
+ *
+ * @since 2.0
+ *
+ * @return The rating
+ */
+ Tizen::Base::String GetRating(void) const;
+
+ /**
+ * Sets the category.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] category The new category
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The length of the input data exceeds the maximum limit of 45 characters.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result SetCategory(const Tizen::Base::String& category);
+
+ /**
+ * Gets the category.
+ *
+ * @since 2.0
+ *
+ * @return The category
+ */
+ Tizen::Base::String GetCategory(void) const;
+
+ /**
+ * Sets the description.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] description The new description
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The length of the input data exceeds the maximum limit of 140 characters.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result SetDescription(const Tizen::Base::String& description);
+
+ /**
+ * Gets the description.
+ *
+ * @since 2.0
+ *
+ * @return The description
+ */
+ Tizen::Base::String GetDescription(void) const;
+
+ /**
+ * Gets the thumbnail image.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @compatibility This method has compatibility issues with OSP compatible applications. @n
+ * For more information, see @ref CompContentInfoGetThumbnailNPage "here".
+ * @endif
+ *
+ * @return A pointer to the thumbnail image
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_DATA_NOT_FOUND The thumbnail image does not exist.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ Tizen::Graphics::Bitmap* GetThumbnailN(void) const;
+
+ /**
+ * @if OSPCOMPAT
+ * @page CompContentInfoGetThumbnailNPage Compatibility for GetThumbnailN().
+ * @section CompContentInfoGetThumbnailNPageIssueSection Issue
+ * The thumbnail size of this method in OSP compatible applications has the following issues: @n
+ * <DIV> The size is changed from 80x60 pixels to the size of image which is returned from the platform since %Tizen</DIV>
+ *
+ * @endif
+ */
+
+ /**
+ * Checks whether the content is DRM protected.
+ *
+ * @since 2.0
+ *
+ * @return @c true if this content has DRM, @n
+ * else @c false
+ */
+ bool IsDrmProtected(void) const;
+
+ /**
+ * Gets the keyword.
+ *
+ * @since 2.0
+ *
+ * @return The keyword
+ */
+ Tizen::Base::String GetKeyword(void) const;
+
+ /**
+ * Sets the content name.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] contentName The new content name
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The length of the input data exceeds the maximum limit of 45 characters.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result SetContentName(const Tizen::Base::String& contentName);
+
+ /**
+ * Sets the keyword.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] keyword The new keyword
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The length of the input data exceeds the maximum limit of 45 characters.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result SetKeyword(const Tizen::Base::String& keyword);
+
+ /**
+ * Sets the author.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] author The new author
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The length of the input data exceeds the maximum limit of 45 characters.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result SetAuthor(const Tizen::Base::String& author);
+
+ /**
+ * Gets the author.
+ *
+ * @since 2.0
+ *
+ * @return The author
+ */
+ Tizen::Base::String GetAuthor(void) const;
+
+ /**
+ * Sets the provider.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] provider The new content provider
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The length of the input data exceeds the maximum limit of 45 characters.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ */
+ result SetProvider(const Tizen::Base::String& provider);
+
+ /**
+ * Gets the provider.
+ *
+ * @since 2.0
+ *
+ * @return The content provider
+ */
+ Tizen::Base::String GetProvider(void) const;
+
+ /**
+ * Gets the media format.
+ *
+ * @since 2.0
+ *
+ * @return The media format
+ */
+ Tizen::Base::String GetMediaFormat(void) const;
+
+protected:
+ //
+ // This class is for internal use only.
+ // Using this class can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ class _ContentData
+ {
+ public:
+ _ContentData()
+ : contentId(Tizen::Base::UuId::GetInvalidUuId())
+ , storageType(0)
+ , contentType(CONTENT_TYPE_UNKNOWN)
+ , contentSize(0)
+ , latitude(-200.0)
+ , longitude(-200.0)
+ , altitude(-200.0)
+ , isDrm(false)
+ , pThumbnailPath(null)
+ , pAuthor(null)
+ , pCategory(null)
+ , pContentName(null)
+ , pDescription(null)
+ , pKeyword(null)
+ , pLocationTag(null)
+ , pProvider(null)
+ , pRating(null) {}
+
+ ContentId contentId;
+ int storageType;
+ ContentType contentType;
+ unsigned long contentSize;
+ Tizen::Base::DateTime dateTime;
+ double latitude;
+ double longitude;
+ double altitude;
+ bool isDrm;
+ Tizen::Base::String contentPath;
+ Tizen::Base::String mimeType;
+ Tizen::Base::String* pThumbnailPath;
+ Tizen::Base::String* pAuthor;
+ Tizen::Base::String* pCategory;
+ Tizen::Base::String* pContentName;
+ Tizen::Base::String* pDescription;
+ Tizen::Base::String* pKeyword;
+ Tizen::Base::String* pLocationTag;
+ Tizen::Base::String* pProvider;
+ Tizen::Base::String* pRating;
+ };
+
+ /**
+ * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+ *
+ * @since 2.0
+ */
+ ContentInfo(void);
+
+ //
+ // This method is for internal use only.
+ // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
+ //
+ // Sets the content data.
+ //
+ // @since 2.0
+ //
+ // @return An error code
+ // @param[in] pContentData The content data
+ // @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.
+ //
+ result SetContentData(const _ContentData* pContentData);
+
+private:
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentInfo(const ContentInfo& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentInfo& operator =(const ContentInfo& rhs);
+
+ _ContentData* GetContentData(void);
+
+private:
+ _ContentData* __pContentData;
+ mutable Tizen::Locations::Coordinates coordinates;
+
+ friend class _ContentManagerImpl;
+ friend class _ContentSearchImpl;
+ friend class _ContentDirectoryImpl;
+ friend class _ContentUtility;
+ friend class _PlayListManagerImpl;
+ friend class _PlayListImpl;
+
+ friend class _ContentInfoImpl;
+ _ContentInfoImpl* __pImpl;
+
+}; // class ContentInfo
+
+}} // Tizen::Content
+
+#endif // _FCNT_CONTENT_INFO_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentManager.h
+ * @brief This is the header file for the %ContentManager class.
+ *
+ * This header file contains the declarations of the %ContentManager class.
+ */
+
+#ifndef _FCNT_CONTENT_MANAGER_H_
+#define _FCNT_CONTENT_MANAGER_H_
+
+#include <FBaseObject.h>
+#include <FCntTypes.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+}}
+
+namespace Tizen { namespace Content
+{
+
+class ContentInfo;
+class _ContentManagerImpl;
+class _IContentScanListener;
+
+/**
+ * @class ContentManager
+ * @brief This class provides methods for local content management.
+ *
+ * @since 2.0
+ *
+ * The %ContentManager class manages the information stored locally on the device's content database. @n
+ * It also allows you to create, read, update, and delete specific content information in the database.
+ *
+ * For more information on managing content on the device, see <a href="../org.tizen.native.appprogramming/html/guide/content/device_content_mgmt.htm">Device Content Management</a>.
+ *
+ * The following example demonstrates how to use the %ContentManager class.
+ *
+ * @code
+ * result
+ * MyClass::TestContentManager(void)
+ * {
+ * result r = E_SUCCESS;
+ * ContentId contentId;
+ * ContentManager contentManager;
+ * r = contentManager.Construct();
+ * TryReturn(!IsFailed(r), r, "Construct failed.");
+ *
+ * // Creates
+ * ImageContentInfo imageContentInfo;
+ * r = imageContentInfo.Construct(null);
+ * TryReturn(!IsFailed(r), r, "Construct failed.");
+ *
+ * r = imageContentInfo.SetKeyword(L"platform, tizen");
+ * if (IsFailed(r))
+ * {
+ * return r;
+ * }
+ *
+ * r = imageContentInfo.SetLocationTag(L"seoul");
+ * if (IsFailed(r))
+ * {
+ * return r;
+ * }
+ *
+ * Tizen::Base::String sourcePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/flower.jpg";
+ * Tizen::Base::String destPath = Tizen::System::Environment::GetMediaPath() + L"Images/flower.jpg";
+ *
+ * contentId = contentManager.CreateContent(sourcePath, destPath, false, &imageContentInfo);
+ * TryReturn(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed.");
+ *
+ * // Gets
+ * ImageContentInfo* pImageContentInfo = null;
+ * pImageContentInfo = dynamic_cast<ImageContentInfo*>(contentManager.GetContentInfoN(contentId));
+ * TryReturn(pImageContentInfo != null, GetLastResult(), "GetContentInfoN failed.");
+ *
+ * pImageContentInfo->GetContentPath();
+ *
+ * // Updates
+ * r = pImageContentInfo->SetKeyword(L"apple, fruit");
+ * if (IsFailed(r))
+ * {
+ * delete pImageContentInfo;
+ * return r;
+ * }
+ * r = pImageContentInfo->SetProvider(L"kw1128");
+ * if (IsFailed(r))
+ * {
+ * delete pImageContentInfo;
+ * return r;
+ * }
+ * r = contentManager.UpdateContent(*pImageContentInfo);
+ * if (IsFailed(r))
+ * {
+ * delete pImageContentInfo;
+ * return r;
+ * }
+ *
+ * // Deletes
+ * r = contentManager.DeleteContent(contentId);
+ * if (IsFailed(r))
+ * {
+ * delete pImageContentInfo;
+ * return r;
+ * }
+ *
+ * delete pImageContentInfo;
+ * return r;
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ ContentManager
+ : virtual public Tizen::Base::Object
+{
+
+public:
+ /**
+ * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+ *
+ * @since 2.0
+ *
+ * @remarks After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+ */
+ ContentManager(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~ContentManager(void);
+
+ /**
+ * Initializes this instance of %ContentManager.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result Construct(void);
+
+ /**
+ * Creates the content information.
+ *
+ * @since 2.0
+ * @privilege %http://tizen.org/privilege/content.write
+ *
+ * @return The content ID
+ * @param[in] contentInfo An instance of ContentInfo
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid, or
+ * the specified format is invalid or not supported on the device.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_IO An I/O error has occurred.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @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 If the E_UNSUPPORTED_FORMAT exception is received from ContentManagerUtil::CheckContentType(),
+ * the file can be created as a content only using the OtherContentInfo class. @n
+ * The specific error code can be accessed using the GetLastResult() method.
+ */
+ ContentId CreateContent(const ContentInfo& contentInfo);
+
+ /**
+ * Writes the content in the byte buffer to the destination path and creates the content information.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @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
+ *
+ * @return The content ID
+ * @param[in] byteBuffer The @c byteBuffer of the content to create
+ * @param[in] destinationPath The destination file path formed by the @c byteBuffer
+ * @param[in] pContentInfo A pointer to the ContentInfo instance @n
+ * If the content path exists in %ContentInfo, it gets ignored.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
+ * - A specified input parameter is invalid. @n
+ * - There is a mismatch between the type specified in ContentInfo and the type specified in the actual content.
+ * @exception E_STORAGE_FULL The storage is full.
+ * @exception E_FILE_ALREADY_EXIST The specified file already exists.
+ * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
+ * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
+ * @exception E_IO An I/O error has occurred.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @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 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".
+ */
+ ContentId CreateContent(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Base::String& destinationPath, const ContentInfo* pContentInfo = null);
+
+ /**
+ * Copies or moves the actual content to the destination path and creates the content information.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @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
+ *
+ * @return The content ID
+ * @param[in] sourcePath The source file path
+ * @param[in] destinationPath The destination file path
+ * @param[in] deleteSource Set to @c true in order to delete the source file, @n
+ * else @c false
+ * @param[in] pContentInfo A pointer to the ContentInfo instance @n
+ * If the content path exists in %ContentInfo, it gets ignored.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
+ * - A specified input parameter is invalid. @n
+ * - There is a mismatch between the type of the source path and destination path. @n
+ * - There is a mismatch between the type specified in ContentInfo and the type specified in the actual content.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_STORAGE_FULL The storage is full.
+ * @exception E_FILE_ALREADY_EXIST The specified file already exists.
+ * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
+ * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
+ * @exception E_IO An I/O error has occurred.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @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
+ * 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".
+ */
+ ContentId CreateContent(const Tizen::Base::String& sourcePath, const Tizen::Base::String& destinationPath, bool deleteSource, const ContentInfo* pContentInfo = null);
+
+ /**
+ * @if OSPCOMPAT
+ * @page CompContentManagerCreateContentPage Compatibility for the file path.
+ * @section CompContentManagerCreateContentPageIssueSection Issues
+ * The content path argument of this method in OSP compatible applications has the following issues: @n
+ * -# The content path should be a path that begins with an allowed path prefix. @n
+ * For example, L"/Media/Images/flower.jpg", L"/Storagecard/Media/Images/flower.jpg".
+ *
+ * @section CompContentManagerCreateContentPageSolutionSection Resolutions
+ * This issue has been resolved in Tizen. @n
+ * -# The content path can be a path without a specific allowed path prefix. @n
+ * Application do not need to know the specific allowed path prefixes. @n
+ * To get the directory path, use the following methods: @n
+ * - For accessing the home directory, use Tizen::App::App::GetInstance()->GetAppRootPath().
+ * - For accessing the media directory, use Tizen::System::Environment::GetMediaPath().
+ * - For accessing the external storage, use Tizen::System::Environment::GetExternalStoragePath().
+ *
+ * @endif
+ */
+
+ /**
+ * @page CreateContentUsage How To Use CreateContent()
+ * @section CreateContentUsageFirst 1. CreateContent(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Base::String& destinationPath, const ContentInfo* pContentInfo = null)
+ *
+ * <b> // The first usage </b> @n
+ * result r = E_SUCCESS; @n
+ * Tizen::Base::ByteBuffer byteBuffer; @n
+ * byteBuffer.Construct(1024); @n
+ *
+ * // Set the data to byteBuffer @n
+ *
+ * ContentId contentId; @n
+ * ContentManager contentManager; @n
+ * r = contentManager.Construct(); @n
+ * TryReturn(!IsFailed(r), r, "Construct failed."); @n
+ *
+ * Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Images/flower.jpg"; @n
+ * contentId = contentManager.CreateContent(byteBuffer, contentPath); @n
+ * TryReturn(contentId != Tizen::Base::UuId::GetInvalidUuId(), GetLastResult(), "CreateContent failed."); @n
+ *
+ * @n <b> // The second usage </b> @n
+ * result r = E_SUCCESS; @n
+ * Tizen::Base::ByteBuffer byteBuffer; @n
+ * byteBuffer.Construct(1024); @n
+ *
+ * // Set the data to byteBuffer @n
+ *
+ * ContentId contentId; @n
+ * ContentManager contentManager; @n
+ * r = contentManager.Construct(); @n
+ * TryReturn(!IsFailed(r), r, "Construct failed."); @n
+ *
+ * ImageContentInfo imageContentInfo; @n
+ * r = imageContentInfo.Construct(null); @n
+ * TryReturn(!IsFailed(r), r, "Construct failed."); @n
+ *
+ * r = imageContentInfo.SetKeyword(L"apple, fruit"); @n
+ * TryReturn(!IsFailed(r), r, "SetKeyword failed."); @n
+ *
+ * r = imageContentInfo.SetProvider(L"kw1128"); @n
+ * TryReturn(!IsFailed(r), r, "SetProvider failed."); @n
+ *
+ * Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Images/flower.jpg"; @n
+ * contentId = contentManager.CreateContent(byteBuffer, contentPath, &imageContentInfo); @n
+ * TryReturn(contentId != Tizen::Base::UuId::GetInvalidUuId(), GetLastResult(), "CreateContent failed."); @n
+ *
+ * @section CreateContentUsageSecond 2. CreateContent(const Tizen::Base::String& sourcePath, const Tizen::Base::String& destinationPath, bool deleteSource, const ContentInfo* pContentInfo = null);
+ *
+ * <b> // The first usage </b> @n
+ * result r = E_SUCCESS; @n
+ * ContentId contentId; @n
+ * ContentManager contentManager; @n
+ * r = contentManager.Construct(); @n
+ * TryReturn(!IsFailed(r), r, "Construct failed."); @n
+ *
+ * Tizen::Base::String sourcePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/flower.jpg"; @n
+ * Tizen::Base::String destPath = Tizen::System::Environment::GetMediaPath() + L"Images/flower.jpg"; @n
+ *
+ * contentId = contentManager.CreateContent(sourcePath, destPath, false); @n
+ * TryReturn(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed."); @n
+ *
+ * @n <b> // The second usage </b> @n
+ * result r = E_SUCCESS; @n
+ * ContentId contentId; @n
+ * ContentManager contentManager; @n
+ * r = contentManager.Construct(); @n
+ * TryReturn(!IsFailed(r), r, "Construct failed."); @n
+ *
+ * ImageContentInfo imageContentInfo; @n
+ * r = imageContentInfo.Construct(null); @n
+ * TryReturn(!IsFailed(r), r, "Construct failed."); @n
+ *
+ * r = imageContentInfo.SetKeyword(L"apple, fruit"); @n
+ * TryReturn(!IsFailed(r), r, "SetKeyword failed."); @n
+ *
+ * r = imageContentInfo.SetProvider(L"kw1128"); @n
+ * TryReturn(!IsFailed(r), r, "SetProvider failed."); @n
+ *
+ * Tizen::Base::String sourcePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/flower.jpg"; @n
+ * Tizen::Base::String destPath = Tizen::System::Environment::GetMediaPath() + L"Images/flower.jpg"; @n
+ *
+ * contentId = contentManager.CreateContent(sourcePath, destPath, false, &imageContentInfo); @n
+ * TryReturn(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed."); @n
+ */
+
+ /**
+ * Gets the content information.
+ *
+ * @since 2.0
+ * @privilege %http://tizen.org/privilege/content.read
+ *
+ * @return A pointer to ContentInfo
+ * @param[in] contentId The content ID
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid, or
+ * the content information corresponding to @c contentId cannot be found.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @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 specific error code can be accessed using the GetLastResult() method.
+ */
+ ContentInfo* GetContentInfoN(const ContentId& contentId) const;
+
+ /**
+ * Updates the content information with the specified instance of ContentInfo.
+ *
+ * @since 2.0
+ * @privilege %http://tizen.org/privilege/content.write
+ *
+ * @return An error code
+ * @param[in] contentInfo An instance of ContentInfo
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @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.
+ */
+ result UpdateContent(const ContentInfo& contentInfo);
+
+ /**
+ * Deletes the content information with the specified content ID.
+ *
+ * @since 2.0
+ * @privilege %http://tizen.org/privilege/content.write
+ *
+ * @return An error code
+ * @param[in] contentId The content ID
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid, or
+ * the content information corresponding to @c contentId cannot be found.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @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 physical file corresponding to @c contentId is deleted.
+ */
+ result DeleteContent(const ContentId& contentId);
+
+ /*
+ * Requests to scan a file(for internal use)
+ */
+ result ScanFile(const Tizen::Base::String& contentPath);
+
+ /*
+ * Requests to scan directories(for internal use)
+ */
+ result ScanDirectory(const Tizen::Base::String& directoryPath, bool recursive, _IContentScanListener& listener);
+
+private:
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentManager(const ContentManager& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentManager& operator =(const ContentManager& rhs);
+
+private:
+ friend class _ContentManagerImpl;
+ _ContentManagerImpl* __pImpl;
+
+}; // Class ContentManager
+
+}} // Tizen::Content
+
+#endif // _FCNT_CONTENT_MANAGER_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentManagerUtil.h
+ * @brief This is the header file for the %ContentManagerUtil class.
+ *
+ * This header file contains the declarations of the %ContentManagerUtil class.
+ */
+
+#ifndef _FCNT_CONTENT_MANAGER_UTIL_H_
+#define _FCNT_CONTENT_MANAGER_UTIL_H_
+
+#include <FBaseObject.h>
+#include <FCntTypes.h>
+
+namespace Tizen { namespace Content
+{
+
+class ImageMetadata;
+class AudioMetadata;
+class VideoMetadata;
+
+/**
+ * @class ContentManagerUtil
+ * @brief This class provides methods for managing the content's utility.
+ *
+ * @since 2.0
+ *
+ * The %ContentManagerUtil class provides access to different local content types, such as image, audio, and video, and manages the content metadata.
+ *
+ * For more information on managing the content's utility on the device, see <a href="../org.tizen.native.appprogramming/html/guide/content/device_content_mgmt.htm">Device Content Management</a>.
+ *
+ * The following example demonstrates how to use the %ContentManagerUtil class.
+ *
+ * @code
+ * result
+ * MyClass::TestContentManagerUtil(void)
+ * {
+ * // Image
+ * Tizen::Base::String imagePath = Tizen::System::Environment::GetMediaPath() + L"Images/full_meta.jpg";
+ * ImageMetadata* pImageMeta = ContentManagerUtil::GetImageMetaN(imagePath);
+ * TryReturn(pImageMeta != null, GetLastResult(), "GetImageMetaN failed.");
+ *
+ * // Audio
+ * Tizen::Base::String audioPath = Tizen::System::Environment::GetMediaPath() + L"Sounds/hot.mp3";
+ * AudioMetadata* pAudioMeta = ContentManagerUtil::GetAudioMetaN(audioPath);
+ * if(pAudioMeta == null)
+ * {
+ * delete pImageMeta;
+ * return GetLastResult();
+ * }
+ *
+ * // Video
+ * Tizen::Base::String videoPath = Tizen::System::Environment::GetMediaPath() + L"Videos/video.mp4";
+ * VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(videoPath);
+ * if(pVideoMeta == null)
+ * {
+ * delete pImageMeta;
+ * delete pAudioMeta;
+ * return GetLastResult();
+ * }
+ *
+ * delete pImageMeta;
+ * delete pAudioMeta;
+ * delete pVideoMeta;
+ *
+ * return E_SUCCESS;
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ ContentManagerUtil
+{
+public:
+ /**
+ * Gets the metadata for an image.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @compatibility This method has compatibility issues with OSP compatible applications. @n
+ * For more information, see @ref CompContentManagerUtilPage "here".
+ * @endif
+ *
+ * @return A pointer to ImageMetadata, @n
+ * else @c null if an exception occurs
+ * @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.
+ */
+ static Tizen::Content::ImageMetadata* GetImageMetaN(const Tizen::Base::String& filePath);
+
+ /**
+ * Gets the metadata for an audio.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @compatibility This method has compatibility issues with OSP compatible applications. @n
+ * For more information, see @ref CompContentManagerUtilPage "here".
+ * @endif
+ *
+ * @return A pointer to AudioMetadata, @n
+ * else @c null if an exception occurs
+ * @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.
+ */
+ static Tizen::Content::AudioMetadata* GetAudioMetaN(const Tizen::Base::String& filePath);
+
+ /**
+ * Gets the metadata for a video.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @compatibility This method has compatibility issues with OSP compatible applications. @n
+ * For more information, see @ref CompContentManagerUtilPage "here".
+ * @endif
+ *
+ * @return A pointer to VideoMetadata, @n
+ * else @c null if an exception occurs
+ * @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.
+ */
+ static Tizen::Content::VideoMetadata* GetVideoMetaN(const Tizen::Base::String& filePath);
+
+ /**
+ * Checks the content type from the file path.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @compatibility This method has compatibility issues with OSP compatible applications. @n
+ * For more information, see @ref CompContentManagerUtilPage "here".
+ * @endif
+ *
+ * @return The content type
+ * @param[in] filePath The file path
+ * @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
+ * The specific error code can be accessed using the GetLastResult() method.
+ */
+ static Tizen::Content::ContentType CheckContentType(const Tizen::Base::String& filePath);
+
+ /**
+ * @if OSPDEPREC
+ * Copies an existing file to a new directory.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This method is deprecated because a new method has been added. @n
+ * Instead of using this method, use ContentManager::CreateContent(const Tizen::Base::String&, const Tizen::Base::String&, bool, const ContentInfo*).
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] srcFilePath The source file path
+ * @param[in] destFilePath The destination file path
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
+ * - The length of the specified path is equal to @c 0 or exceeds system limitations. @n
+ * - The specified path contains prohibited character(s). @n
+ * - The specified path is invalid.
+ * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_FILE_ALREADY_EXIST The specified file already exists.
+ * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
+ * @exception E_STORAGE_FULL The disk space is full.
+ * @exception E_IO Either of the following conditions has occurred: @n
+ * - An unexpected device failure has occurred as the media ejected suddenly. @n
+ * - File corruption is detected. @n
+ * - The volume or quota is no more available.
+ * @remarks The source file in the system region cannot be copied. @n
+ * The destination file path must start with @c '/Media' or @c '/Storagecard/Media'.
+ * @endif
+ */
+ static result CopyToMediaDirectory(const Tizen::Base::String& srcFilePath, const Tizen::Base::String& destFilePath);
+
+ /**
+ * @if OSPDEPREC
+ * Moves the file to a new directory.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This method is deprecated because a new method has been added. @n
+ * Instead of using this method, use ContentManager::CreateContent(const Tizen::Base::String&, const Tizen::Base::String&, bool, const ContentInfo*).
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] srcFilePath The source file path
+ * @param[in] destFilePath The destination file path
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
+ * - The length of the specified path is equal to @c 0 or exceeds system limitations. @n
+ * - The specified path contains prohibited character(s). @n
+ * - The specified path is invalid.
+ * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_FILE_ALREADY_EXIST The specified file already exists.
+ * @exception E_MAX_EXCEEDED The number of opened files has exceeded the maximum limit.
+ * @exception E_STORAGE_FULL The disk space is full.
+ * @exception E_IO Either of the following conditions has occurred: @n
+ * - An unexpected device failure has occurred as the media ejected suddenly. @n
+ * - File corruption is detected. @n
+ * - The volume or quota is no more available.
+ * @remarks The source file in the system region cannot be copied. @n
+ * The destination file path must start with @c '/Media' or @c '/Storagecard/Media'.
+ * @endif
+ */
+ static result MoveToMediaDirectory(const Tizen::Base::String& srcFilePath, const Tizen::Base::String& destFilePath);
+
+ /**
+ * @if OSPCOMPAT
+ * @page CompContentManagerUtilPage Compatibility for the file path.
+ * @section CompContentManagerUtilPageIssueSection Issues
+ * The file path argument of this method in OSP compatible applications has the following issues: @n
+ * -# The file path should be a path that begins with an allowed path prefix. @n
+ * For example, L"/Media/Images/flower.jpg", "/Storagecard/Media/Images/flower.jpg".
+ *
+ * @section CompContentManagerUtilPageSolutionSection Resolutions
+ * This issue has been resolved in Tizen. @n
+ * -# The file path can be a path without a specific allowed path prefix. @n
+ * Application do not need to know the specific allowed path prefixes. @n
+ * To get the directory path, use the following methods: @n
+ * - For accessing the home directory, use Tizen::App::App::GetInstance()->GetAppRootPath().
+ * - For accessing the media directory, use Tizen::System::Environment::GetMediaPath().
+ * - For accessing the external storage, use Tizen::System::Environment::GetExternalStoragePath().
+ *
+ * @endif
+ */
+
+private:
+ /**
+ * This default constructor is intentionally declared as private because this class cannot be constructed.
+ */
+ ContentManagerUtil(void);
+
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentManagerUtil(const ContentManagerUtil& rhs);
+
+ /**
+ * This destructor is intentionally declared as private because this class cannot be constructed.
+ */
+ virtual ~ContentManagerUtil(void);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentManagerUtil& operator =(const ContentManagerUtil& rhs);
+
+}; // class ContentManagerUtil
+
+}} // Tizen::Content
+
+#endif // _FCNT_CONTENT_MANAGER_UTIL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentSearch.h
+ * @brief This is the header file for the %ContentSearch class.
+ *
+ * This header file contains the declarations of the %ContentSearch class.
+ */
+
+#ifndef _FCNT_CONTENT_SEARCH_H_
+#define _FCNT_CONTENT_SEARCH_H_
+
+#include <FBaseString.h>
+#include <FCntTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen { namespace Content
+{
+
+class _ContentSearchImpl;
+
+/**
+ * @class ContentSearch
+ * @brief This class provides methods for the content search.
+ *
+ * @since 2.0
+ *
+ * The %ContentSearch class provides methods to search content based on conditions and to retrieve the results for a specific
+ * column. It enables searching for content stored on the Tizen device. The local content is stored in the form of database columns.
+ *
+ * For more information on the database columns and their corresponding content types, see <a href="../org.tizen.native.appprogramming/html/guide/content/content_search_device.htm">Content Search on the Device</a>.
+ *
+ * The following example demonstrates how to use the %ContentSearch class.
+ *
+ * @code
+ * #include <FContent.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Base::Collection;
+ * using namespace Tizen::Content;
+ *
+ * void
+ * MyClass::Test(void)
+ * {
+ * // Call Construct() of ContentSearch
+ * ContentSearch search;
+ * result r = search.Construct(CONTENT_TYPE_AUDIO);
+ * if (IsFailed(r))
+ * {
+ * // Do something for an error
+ * }
+ *
+ * // Call SearchN() of ContentSearch as the first page
+ * int pageNo = 1;
+ * int countPerPage = 5;
+ * int totalPage = 0;
+ * int totalCount = 0;
+ * IList* pContentInfoList = search.SearchN(pageNo, countPerPage, totalPage, totalCount,
+ * L"Artist='rain'", L"Title", SORT_ORDER_ASCENDING);
+ * if (IsFailed(GetLastResult()))
+ * {
+ * // Do something for an error
+ * }
+ *
+ * // Delete resource
+ * pContentInfoList->RemoveAll(true);
+ * delete pContentInfoList;
+ * }
+ *
+ * @endcode
+ *
+ */
+class _OSP_EXPORT_ ContentSearch
+ : virtual public Tizen::Base::Object
+{
+
+public:
+ /**
+ * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+ *
+ * @since 2.0
+ *
+ * @remarks After creating an instance of this class, one of the Construct() methods must be called explicitly to initialize this instance.
+ * @see Construct()
+ */
+ ContentSearch(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~ContentSearch(void);
+
+ /**
+ * Initializes this instance of %ContentSearch with the specified parameter.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] type The content type
+ * @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.
+ * @exception E_SYSTEM A system error has occurred.
+ *
+ * @remarks To search a specific type, use the content type as CONTENT_TYPE_OTHER, CONTENT_TYPE_IMAGE, CONTENT_TYPE_AUDIO, or CONTENT_TYPE_VIDEO.
+ *
+ * The following example demonstrates how to use the %Construct() method.
+ *
+ * @code
+ *
+ * // Call Construct() of ContentSearch
+ * ContentSearch search;
+ * result r = search.Construct(CONTENT_TYPE_IMAGE);
+ * if (IsFailed(r))
+ * {
+ * // Do something for an error
+ * }
+ *
+ * @endcode
+ */
+ result Construct(ContentType type);
+
+ /**
+ * Searches the content and returns the search result list according to the query.
+ *
+ * @since 2.0
+ * @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
+ * else @c null if an exception occurs.
+ * @param[in] pageNo The page number @n
+ * It must be equal to or greater than @c 1.
+ * @param[in] countPerPage The count of the search results per page @n
+ * It must be equal to or greater than @c 1.
+ * @param[out] totalPageCount The total page count of the search result
+ * @param[out] totalCount The total count of the search result
+ * @param[in] whereExpr The search condition like an sql "where" expression style @n
+ * If it uses the default value, L"", it searches for all the content of the content type set in the constructor. @n
+ * In case of the "DateTime" condition, the range starts from '01/01/1970 00:00:00'. @n
+ * Every type of value has to be covered with single quotation marks, even if it is a decimal type.
+ * @param[in] sortColumn The sort <a href="../org.tizen.native.appprogramming/html/guide/content/content_search_device.htm">column</a> @n
+ * The default value is @c L"".
+ * @param[in] sortOrder The sort order
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
+ * - The specified @c column is either invalid or empty. @n
+ * - The content is searched with @c type set as CONTENT_TYPE_UNKNOWN. @n
+ * - The length of the specified @c whereExpr parameter exceeds 512 characters.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @remarks The return value must be deleted. @n
+ * ContentType supports CONTENT_TYPE_OTHER, CONTENT_TYPE_IMAGE, CONTENT_TYPE_AUDIO, and CONTENT_TYPE_VIDEO.
+ * If %ContentType in Construct() uses CONTENT_TYPE_UNKNOWN or an invalid value, E_INVALID_ARG occurs.
+ *
+ * The following example demonstrates how to use the %SearchN() method.
+ *
+ * @code
+ *
+ * // Call Construct() of ContentSearch
+ * ContentSearch search;
+ * result r = search.Construct(CONTENT_TYPE_AUDIO);
+ * if (IsFailed(r))
+ * {
+ * // Do something for an error
+ * }
+ *
+ * // Call SearchN() of ContentSearch as the first page
+ * int pageNo = 1;
+ * int countPerPage = 5;
+ * int totalPage = 0;
+ * int totalCount = 0;
+ * IList* pContentInfoList = search.SearchN(pageNo, countPerPage, totalPage, totalCount,
+ * L"Artist='rain'", L"Title", SORT_ORDER_ASCENDING);
+ * if (IsFailed(GetLastResult()))
+ * {
+ * // Do something for an error
+ * }
+ *
+ * // Do something
+ *
+ * // Delete resource
+ * pContentInfoList->RemoveAll(true);
+ * delete pContentInfoList;
+ *
+ * @endcode
+ */
+ Tizen::Base::Collection::IList* SearchN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount, const Tizen::Base::String& whereExpr = L"", const Tizen::Base::String& sortColumn = L"", Tizen::Base::SortOrder sortOrder = Tizen::Base::SORT_ORDER_NONE) const;
+
+ /**
+ * Gets the value list of the specified column within a specified range.
+ *
+ * @since 2.0
+ * @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
+ * An empty list is returned if the specified column has no value and there is no error, @n
+ * else @c null if an exception occurs.
+ * @param[in] pageNo The page number @n
+ * It must be equal to or greater than @c 1.
+ * @param[in] countPerPage The count of the value list per page @n
+ * It must be equal to or greater than @c 1.
+ * @param[out] totalPageCount The total page count of the value list
+ * @param[out] totalCount The total count of the value list
+ * @param[in] column The <a href="../org.tizen.native.appprogramming/html/guide/content/content_search_device.htm">column</a> name
+ * @param[in] sortOrder The sort order
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_INVALID_ARG The specified @c column is either invalid or empty, or
+ * the content is searched with @c type set as CONTENT_TYPE_UNKNOWN.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @remarks The return value must be deleted. @n
+ * The result of GetValueListN() returns a distinct value. @n
+ * ContentType supports CONTENT_TYPE_OTHER, CONTENT_TYPE_IMAGE, CONTENT_TYPE_AUDIO, and CONTENT_TYPE_VIDEO.
+ * If %ContentType in Construct() uses CONTENT_TYPE_UNKNOWN or an invalid value, E_INVALID_ARG occurs.
+ *
+ * The following example demonstrates how to use the %GetValueListN() method.
+ *
+ * @code
+ *
+ * // Call Construct() of ContentSearch
+ * ContentSearch search;
+ * result r = search.Construct(CONTENT_TYPE_AUDIO);
+ * if (IsFailed(r))
+ * {
+ * // Do something for an error
+ * }
+ *
+ * // Call GetValueListN() of ContentSearch
+ * int pageNo = 1;
+ * int countPerPage = 10;
+ * int totalPage = 0;
+ * int totalCount = 0;
+ * IList* pValueList = search.GetValueListN(pageNo, countPerPage, totalPage, totalCount, L"Genre", SORT_ORDER_NONE);
+ *
+ * if (IsFailed(GetLastResult()))
+ * {
+ * // Do something for an error
+ * }
+ *
+ * // Do something
+ *
+ * // Delete resource
+ * pValueList->RemoveAll(true);
+ * delete pValueList;
+ *
+ * @endcode
+ */
+ Tizen::Base::Collection::IList* GetValueListN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount, const Tizen::Base::String& column, Tizen::Base::SortOrder sortOrder = Tizen::Base::SORT_ORDER_NONE) const;
+
+ /**
+ * @if OSPDEPREC
+ * Gets the list consisting of values of a specified column in the specified order.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @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
+ *
+ * @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
+ * An empty list is returned if the specified column has no value and there is no error, @n
+ * else @c null if an exception occurs.
+ * @param[in] column The <a href="../org.tizen.native.appprogramming/html/guide/content/content_search_device.htm">column</a> name
+ * @param[in] sortOrder The sort order
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_INVALID_ARG The specified @c column is either invalid or empty, or the content is searched with @c type set as CONTENT_TYPE_UNKNOWN.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ * @remarks The return value must be deleted. @n
+ * The result of GetValueListN() returns a distinct value. @n
+ * ContentType supports CONTENT_TYPE_OTHER, CONTENT_TYPE_IMAGE, CONTENT_TYPE_AUDIO, and CONTENT_TYPE_VIDEO.
+ * If %ContentType in Construct() uses CONTENT_TYPE_UNKNOWN or an invalid value, E_INVALID_ARG occurs.
+ *
+ * The following example demonstrates how to use the %GetValueListN() method.
+ *
+ * @code
+ *
+ * // Call Construct() of ContentSearch
+ * ContentSearch search;
+ * result r = search.Construct(CONTENT_TYPE_AUDIO);
+ * if (IsFailed(r))
+ * {
+ * // Do something for an error
+ * }
+ *
+ * // Call GetValueListN() of ContentSearch
+ * IList* pValueList = search.GetValueListN(L"Artist", SORT_ORDER_NONE);
+ *
+ * if (IsFailed(GetLastResult()))
+ * {
+ * // Do something for an error
+ * }
+ *
+ * // Do something
+ *
+ * // Delete resource
+ * pValueList->RemoveAll(true);
+ * delete pValueList;
+ *
+ * @endcode
+ * @endif
+ */
+ Tizen::Base::Collection::IList* GetValueListN(const Tizen::Base::String& column, Tizen::Base::SortOrder sortOrder = Tizen::Base::SORT_ORDER_NONE);
+private:
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentSearch(const ContentSearch& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentSearch& operator =(const ContentSearch& rhs);
+
+ _ContentSearchImpl* __pImpl;
+
+ friend class _ContentSearchImpl;
+}; // class ContentSearch
+
+}} // Tizen::Content
+
+#endif // _FCNT_CONTENT_SEARCH_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentSearchResult.h
+ * @brief This is the header file for the %ContentSearchResult class.
+ *
+ * This header file contains the declarations of the %ContentSearchResult class.
+ */
+
+#ifndef _FCNT_CONTENT_SEARCH_RESULT_H_
+#define _FCNT_CONTENT_SEARCH_RESULT_H_
+
+#include <FBaseObject.h>
+#include <FCntTypes.h>
+
+namespace Tizen { namespace Content
+{
+
+class _ContentSearchResultImpl;
+class ContentInfo;
+
+/**
+ * @class ContentSearchResult
+ * @brief This class represents the content search result.
+ *
+ * @since 2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ * The %ContentSearchResult class gets a pointer to the ContentInfo class and retrieves the content type.
+ *
+ * The search result list comprises of this class, and each node can have a different type of %ContentInfo (ImageContentInfo, AudioContentInfo, VideoContentInfo, or OtherContentInfo).
+ * You must cast the %ContentInfo class into the appropriate content type to use the %ContentSearchResult class.
+ */
+class _OSP_EXPORT_ ContentSearchResult
+ : public Tizen::Base::Object
+{
+
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ ContentSearchResult(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~ContentSearchResult(void);
+
+ /**
+ * Gets the content type of the ContentInfo class.
+ *
+ * @since 2.0
+ *
+ * @return The content type
+ */
+ ContentType GetContentType(void) const;
+
+ /**
+ * Gets the content information of the ContentInfo class.
+ *
+ * @since 2.0
+ *
+ * @return A pointer to the ContentInfo class
+ */
+ ContentInfo* GetContentInfo(void) const;
+
+private:
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentSearchResult(const ContentSearchResult& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentSearchResult& operator =(const ContentSearchResult& rhs);
+
+ void SetContentType(ContentType contentType);
+ void SetContentInfo(ContentInfo* pContentInfo);
+
+private:
+ ContentType __contentType;
+ ContentInfo* __pContentInfo;
+
+ _ContentSearchResultImpl* __pImpl; // pubonly - for ABC
+ friend class _ContentSearchResultImpl;
+ friend class _ContentSearchImpl;
+ friend class _ContentDirectoryImpl;
+
+}; // class ContentSearchResult
+
+}} // Tizen::Content
+
+#endif // _FCNT_CONTENT_SEARCH_RESULT_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentTransfer.h
+ * @brief This is the header file for the %ContentTransfer class.
+ *
+ * This header file contains the declarations of the %ContentTransfer class.
+ */
+
+#ifndef _FCNT_CONTENT_TRANSFER_H_
+#define _FCNT_CONTENT_TRANSFER_H_
+
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen { namespace Base { namespace Utility
+{
+class Uri;
+}}}
+
+namespace Tizen { namespace Content
+{
+
+class _ContentTransferImpl;
+class IContentTransferListener;
+
+/**
+ * @if OSPDEPREC
+ * @class ContentTransfer
+ * @brief <i> [Deprecated] </i> This class provides methods to download the content.
+ *
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * The %ContentTransfer class provides the following features:
+ * - Downloading the content from the servers that support HTTP access.
+ * - Cancelling a download operation.
+ *
+ * HTTP download (ContentTransfer::Download()) is a standard HTTP transaction using the HTTP GET request and response methods.
+ *
+ * The following example demonstrates how to use the %ContentTransfer class.
+ *
+ * @code
+ * class MyClass
+ * :public Tizen::Content::IContentTransferListener
+ * {
+ * public:
+ * MyClass(void);
+ * virtual ~MyClass(void);
+ *
+ * public:
+ * void OnContentTransferInProgress(RequestId requestID, int totalReceivedSize);
+ * void OnContentDownloadCompleted(RequestId requestID, ContentId contentID, result res, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMessage);
+ * void OnContentDownloadToBufferCompleted(RequestId reqId, Tizen::Base::ByteBuffer* pBuffer, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMessage);
+ * void OnContentTransferCanceled(RequestId reqId, result res, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMessage);
+ * };
+ *
+ * // Implementation for the listener function and Implementation of other listener function is
+ * void MyClass::OnContentDownloadCompleted(RequestId requestID, ContentId contentID, result res, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMessage)
+ * {
+ * result r = E_SUCCESS;
+ * ContentManager contentManager;
+ * ContentInfo* pContentInfo = null;
+ *
+ * // Error check
+ * TryCatch(!IsFailed(res), r, "Download Error [%s]", GetErrorMessage(res));
+ *
+ * // Do something
+ * r = contentManager.Construct();
+ * TryCatch(!IsFailed(r), r, "Construct failed.");
+ *
+ * // Get ContentInfo
+ * pContentInfo = contentManager.GetContentInfoN(contentID);
+ * CATCH:
+ * if (pContentInfo)
+ * delete pContentInfo;
+ * }
+ *
+ * result
+ * MyClass::RequestDownload(void)
+ * {
+ * ContentTransfer contentTransfer;
+ * RequestId requestId;
+ * Tizen::Base::Utility::Uri contentUri;
+ * int contentSize;
+ * Tizen::Base::String downloadPath;
+ *
+ * result r = contentTransfer.Construct(*this);
+ * TryReturn(!IsFailed(r), r, ("Construct is failed.\n"));
+ *
+ * // TODO: set uri and download path
+ *
+ * r = contentTransfer.Download(contentUri, downloadPath, requestId, false);
+ * TryReturn(!IsFailed(r), r, ("Download Request is failed.\n"));
+ * }
+ * @endcode
+ * @endif
+ */
+class _OSP_EXPORT_ ContentTransfer
+ : virtual public Tizen::Base::Object
+{
+public:
+ /**
+ * The object is not fully constructed after this constructor is called. For full construction, the Construct(IContentTransferListener&) method must be called right after calling this constructor.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @remarks After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+ */
+ ContentTransfer(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ *
+ * @since 2.0
+ */
+ virtual ~ContentTransfer(void);
+
+ /**
+ * Initializes this instance of %ContentTransfer with the specified parameter. @n
+ * This method should be called after every instance of %ContentTransfer is constructed.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] listener A reference to IContentTransferListener
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result Construct(IContentTransferListener& listener);
+
+ /**
+ * Downloads a content file from the content provider's server. @n
+ * The @c filesize parameter is used to check the limitation of the local volume. If this parameter is set to @c 0, this method will not check the volume. @n
+ * An application should set the full destination path for the downloaded contents. When the content is downloaded to one of the following paths, this method internally registers the content using ContentManager.
+ * - /Media/
+ * - /Storagecard/Media/ @n
+ *
+ * When the download is completed, the application is notified using the IContentTransferListener::OnContentDownloadCompleted() method. @n
+ * When the data is being downloaded, the application is notified of the progress using the IContentTransferListener::OnContentTransferInProgress() method.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @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
+ *
+ * @return An error code
+ * @param[in] uri The content URL
+ * @param[in] fileSize The content file size in bytes @n
+ * If set to @c 0, the method does not check the storage limitation.
+ * @param[in] destFilePath The full destination path
+ * @param[in] replace The replace option of the destination file @n
+ * Set to @c true to replace the file, @n
+ * else @c false.
+ * @param[out] reqId The request ID
+ * @param[in] pListener A pointer to the IContentTransferListener instance
+ * @param[in] sec The timeout period in seconds
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG A specified input parameter is invalid.
+ * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
+ * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
+ * @exception E_FILE_ALREADY_EXIST The specified file already exists.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_IN_PROGRESS A previous request is in progress.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @see IContentTransferListener::OnContentDownloadCompleted()
+ * @see IContentTransferListener::OnContentTransferInProgress()
+ */
+ result Download(const Tizen::Base::Utility::Uri& uri, int fileSize, const Tizen::Base::String& destFilePath, bool replace, RequestId& reqId, IContentTransferListener* pListener = null, int sec = 0);
+
+ /**
+ * Downloads a content file from the content provider's server. @n
+ * An application should set the destination path for the downloaded contents.
+ * The path of the downloaded file should use Tizen::System::Environment::GetMediaPath() or Tizen::System::Environment::GetExternalStoragePath().
+ *
+ * When the content is downloaded to the path using Tizen::System::Environment::GetMediaPath() or Tizen::System::Environment::GetExternalStoragePath(), this method internally registers the content in the content database. @n
+ * When the download is completed, the application is notified using the IContentTransferListener::OnContentDownloadCompleted() method. @n
+ * When the data is being downloaded, the application is notified of the progress using the IContentTransferListener::OnContentTransferInProgress() method.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @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
+ *
+ * @return An error code
+ * @param[in] uri The content URL
+ * @param[in] filePath The destination file path @n
+ * Use Tizen::System::Environment::GetMediaPath(), Tizen::System::Environment::GetExternalStoragePath() and Tizen::App::App::GetInstance()->GetAppRootPath().
+ * @param[out] reqId The request ID
+ * @param[in] replace The replace option of the destination file @n
+ * Set to @c true to replace the file, @n
+ * else @c false.
+ * @param[in] timeout The timeout period in seconds
+ * @param[in] progressInterval The progress period interval as a percentage value
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_INVALID_ARG A specified input parameter is invalid.
+ * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
+ * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
+ * @exception E_FILE_ALREADY_EXIST The specified file already exists.
+ * @exception E_IN_PROGRESS A previous request is in progress.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ * @remarks The @c progressInterval is the interval of the progress for each download request. If the value of the @c progressInterval is @c 0, the @c progressInterval uses the value set by the ContentTransfer::SetProgressIntervalByPercent(int). The @c progressInterval is a percentage value between @c 0 and @c 100.
+ * The @c timeout is the value of the response timeout for each download request. If the value of the @c timeout is @c 0, the value for the @c timeout uses the value set by the ContentTransfer::SetDefaultTimeout(int).
+ * @see IContentTransferListener::OnContentDownloadCompleted()
+ * @see IContentTransferListener::OnContentTransferInProgress()
+ */
+ result Download(const Tizen::Base::Utility::Uri& uri, const Tizen::Base::String& filePath, RequestId& reqId, bool replace = false, int timeout = 0, int progressInterval = 0);
+
+ /**
+ * @if OSPCOMPAT
+ * @page CompContentTransferDownloadPage3 Compatibility for the file path.
+ * @section CompContentTransferDownloadPageIssueSection Issues
+ * The content path argument of this method in OSP compatible applications has the following issues: @n
+ * -# The content path should be a path that begins with an allowed path prefix. @n
+ * For example, L"/Media/Images/flower.jpg", "/Storagecard/Media/Images/flower.jpg".
+ *
+ * @section CompImageContentInfoConstructPageSolutionSection Resolutions
+ * This issue has been resolved in Tizen. @n
+ * -# The content path can be a path without a specific allowed path prefix. @n
+ * Application do not need to know the specific allowed path prefixes. @n
+ * To get the directory path, use the following methods: @n
+ * - For accessing the media directory, use Tizen::System::Environment::GetMediaPath().
+ * - For accessing the external storage, use Tizen::System::Environment::GetExternalStoragePath().
+ *
+ * @endif
+ */
+
+ /**
+ * Downloads a content file to a buffer from the content provider's servers. @n
+ * This method does not register the content. @n
+ * When the download is completed, the application is notified using the IContentTransferListener::OnContentDownloadToBufferCompleted() method. @n
+ * When the data is being downloaded, the application is notified of the progress using the IContentTransferListener::OnContentTransferInProgress() method.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @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
+ *
+ * @return An error code
+ * @param[in] uri The content URL
+ * @param[in] fileSize The content file size in bytes @n
+ * If set to @c 0, the method does not check the storage limitation.
+ * @param[out] reqId The request ID
+ * @param[in] pListener A pointer to the IContentTransferListener instance
+ * @param[in] sec The timeout period in seconds
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG A specified input parameter is invalid.
+ * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @see IContentTransferListener::OnContentDownloadToBufferCompleted()
+ * @see IContentTransferListener::OnContentTransferInProgress()
+ */
+ result DownloadToBuffer(const Tizen::Base::Utility::Uri& uri, int fileSize, RequestId& reqId, IContentTransferListener* pListener = null, int sec = 0);
+
+ /**
+ * Downloads a content file to a buffer from the content provider's servers. @n
+ * This method does not register the content. @n
+ * When the download is completed, the application is notified using the IContentTransferListener::OnContentDownloadToBufferCompleted() method. @n
+ * When the data is being downloaded, the application is notified of the progress using the IContentTransferListener::OnContentTransferInProgress() method.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @return An error code
+ * @param[in] uri The content URL
+ * @param[out] reqId The request ID
+ * @param[in] timeout The timeout period in seconds
+ * @param[in] progressInterval The progress period interval as a percentage value
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_INVALID_ARG A specified input parameter is invalid.
+ * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
+ * @exception E_ILLEGAL_ACCESS Access is denied due to insufficient permission.
+ * @exception E_IN_PROGRESS A previous request is in progress.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @remarks The @c progressInterval is the interval of the progress for each download request. If the value of the @c progressInterval is @c 0, the @c progressInterval uses the value set by the ContentTransfer::SetProgressIntervalByPercent(int). The @c progressInterval is a percentage value between @c 0 and @c 100.
+ * The @c timeout is the value of the response timeout for each download request. If the value of the @c timeout is @c 0, the value for the @c timeout uses the value set by the ContentTransfer::SetDefaultTimeout(int).
+ * @see IContentTransferListener::OnContentDownloadToBufferCompleted()
+ * @see IContentTransferListener::OnContentTransferInProgress()
+ */
+ result DownloadToBuffer(const Tizen::Base::Utility::Uri& uri, RequestId& reqId, int timeout = 0, int progressInterval = 0);
+
+ /**
+ * Sets the default timeout period. @n
+ * If the server does not respond during the timeout period, the network connection is closed.
+ * @c 0 or minus second means unlimited period.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @param[in] sec The default timeout period in seconds @n
+ * The default value is @c 0.
+ */
+ void SetDefaultTimeout(int sec);
+
+ /**
+ * Gets the default timeout period.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @return The default timeout period
+ */
+ int GetDefaultTimeout(void) const;
+
+ /**
+ * Removes a transfer operation. @n
+ * This operation removes a request for multiple downloads.
+ * A download operation in progress is not removed by this operation.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] reqId The request ID
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_OBJ_NOT_FOUND The specified @c reqId is not found.
+ * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
+ * @remarks To stop an on-going transfer, use the Cancel() method.
+ */
+ result Remove(RequestId reqId);
+
+ /**
+ * Removes all the transfer operations. @n
+ * This operation removes all the requests for multiple downloads.
+ * The download operations in progress are not removed by this operation.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
+ * @remarks To stop an on-going transfer, use the Cancel() method.
+ */
+ result RemoveAll(void);
+
+ /**
+ * Cancels a transfer operation. @n
+ * The downloaded file is deleted from the file system. @n
+ * When a transfer download operation is canceled, the application is notified via the IContentTransferListener::OnContentTransferCanceled() method.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] reqId The request ID
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The specified @c reqId is not found.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
+ * @see IContentTransferListener::OnContentTransferCanceled()
+ */
+ result Cancel(RequestId reqId);
+
+ /**
+ * Cancels all the operations in progress.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
+ */
+ result CancelAll(void);
+
+ /**
+ * Gets the content transfer information list.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @return A pointer to a list containing the ContentTransferInfo instances, @n
+ * else an empty list if there is no result and no error
+ */
+ Tizen::Base::Collection::IList* GetContentTransferInfoListN(void) const;
+
+ /**
+ * Gets the list of transfers that are in progress.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @return A pointer to a list containing the ContentTransferInfo instances, @n
+ * else an empty list if there is no result and no error
+ */
+ Tizen::Base::Collection::IList* GetContentTransferInfoListInProgressN(void) const;
+
+ /**
+ * Sets the interval of the progress. @n
+ * The input is a percentage value between @c 0 and @c 100. The default value is @c 0.
+ * @c 0 means the application would not receive progress events.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @param[in] percent The progress period interval as a percentage value
+ * @remarks If a server does not provide the information about the content size, then the content module cannot verify the information. @n
+ * In that case, progress event will occur randomly.
+ */
+ void SetProgressIntervalByPercent(int percent);
+
+private:
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentTransfer(const ContentTransfer& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ContentTransfer& operator =(const ContentTransfer& rhs);
+
+private:
+ friend class _ContentTransferImpl;
+ _ContentTransferImpl* __pImpl;
+
+}; // class ContentTransfer
+
+}} // Tizen::Content
+
+#endif // _FCNT_CONTENT_TRANSFER_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentTransferInfo.h
+ * @brief This is the header file for the %ContentTransferInfo class.
+ *
+ * This header file contains the declarations of the %ContentTransferInfo class.
+ */
+
+#ifndef _FCNT_CONTENT_TRANSFER_INFO_H_
+#define _FCNT_CONTENT_TRANSFER_INFO_H_
+
+#include <FBaseUtilUri.h>
+
+namespace Tizen { namespace Content
+{
+
+class _ContentTransferInfoImpl;
+class IContentTransferListener;
+
+/**
+ * @if OSPDEPREC
+ * @class ContentTransferInfo
+ * @brief <i> [Deprecated] </i> This class contains methods that provide information about the content transfer.
+ *
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * The %ContentTransferInfo class provides information about the transfer of content between the device and servers.
+ * @endif
+ */
+
+/**
+ * @enum ContentTransferStatus
+ *
+ * Defines the content transfer status.
+ *
+ * @since 2.0
+ */
+enum ContentTransferStatus
+{
+ CONTENT_TRANSFER_STATUS_NONE, /**< None */
+ CONTENT_TRANSFER_STATUS_DOWNLOADING, /**< The Downloading status */
+ CONTENT_TRANSFER_STATUS_DOWNLOAD_COMPLETED, /**< The Download completed status */
+ CONTENT_TRANSFER_STATUS_DOWNLOAD_READY, /**< The Download ready status */
+};
+
+class _OSP_EXPORT_ ContentTransferInfo
+ : virtual public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the constructor for this class.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ */
+ ContentTransferInfo(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ */
+ virtual ~ContentTransferInfo(void);
+
+ /**
+ * Gets the requested Uniform Resource Identifier (URI).
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @return The requested URI
+ */
+ Tizen::Base::Utility::Uri GetUri(void) const;
+
+ /**
+ * Gets the request ID.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @return The request ID
+ *
+ */
+ RequestId GetRequestId(void) const;
+
+ /**
+ * Gets the destination file path.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @return The destination file path
+ *
+ */
+ Tizen::Base::String GetDestPath(void) const;
+
+ /**
+ * Gets the content transfer's status.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @return The content transfer's status
+ */
+ ContentTransferStatus GetContentTransferStatus(void) const;
+
+private:
+ void SetAllInfo(RequestId reqId, const Tizen::Base::Utility::Uri& uri, const Tizen::Base::String& destPath, const Tizen::Base::String& sourcePath, int sourceFileSize, ContentTransferStatus status);
+
+ void SetRestRequestId(RequestId reqId);
+
+ RequestId GetRestRequestId(void) const;
+
+ int GetSourceFileSize(void) const;
+
+ void SetSlotId(int slot);
+
+ int GetSlotId(void) const;
+
+ void SetTimeout(int sec);
+
+ int GetTimeout(void) const;
+
+ void SetListener(IContentTransferListener* pListener);
+
+ ContentTransferInfo* CopyN(void);
+
+ void SetIsBuffer(bool isBuffer);
+
+ bool GetIsBuffer(void) const;
+
+ void SetProgressInterval(int intervalValue);
+
+ int GetProgressInterval(void) const;
+
+ void SetDownloadStatus(ContentTransferStatus status);
+
+private:
+ RequestId __requestId;
+ RequestId __restRequestId;
+ ContentTransferStatus __status;
+ Tizen::Base::String __destPath;
+ Tizen::Base::Utility::Uri __uri;
+ Tizen::Base::String __sourcePath;
+ int __sourceFileSize;
+ int __slotId;
+ IContentTransferListener* __pListener;
+ int __timeout;
+ bool __isBuffer;
+ int __intervalValue;
+ _ContentTransferInfoImpl* __pImpl; // pubonly - for ABC
+ friend class _ContentTransferInfoImpl;
+ friend class _ContentTransferImpl;
+ friend class _ContentDownloadListener;
+
+}; // class ContentTransferInfo
+
+}} // Tizen::Content
+
+#endif // _FCNT_CONTENT_TRANSFER_INFO_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntDownloadManager.h
+ * @brief This is the header file for the %DownloadManager class.
+ *
+ * This header file contains the declarations of the %DownloadManager class.
+ */
+#ifndef _FCNT_DOWNLOAD_MANAGER_H_
+#define _FCNT_DOWNLOAD_MANAGER_H_
+
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FCntTypes.h>
+
+
+namespace Tizen { namespace Content
+{
+
+class DownloadRequest;
+class IDownloadListener;
+
+/**
+* @class DownloadManager
+* @brief This class provides methods to handle HTTP downloads.
+*
+* @since 2.0
+*
+* @final This class is not intended for extension.
+*
+* The %DownloadManager class provides methods to handle HTTP downloads. A download request consists of a URL and a destination path; of which the URL is mandatory for downloading content. If the destination path is not specified, the content is downloaded to a default download storage that can be obtained with the System::Environment::GetDownloadPath() method.
+* This class conducts the download in the background and calls the Start() method that takes care of HTTP connections. @n
+* The download operation can be:
+* - Paused by calling the Pause() method
+* - Resumed by calling the Resume() method
+* - Cancelled by calling the Cancel() method
+* Depending on how the download operation is terminated the following methods are called:
+* - IDownloadListener::OnDownloadCanceled() when the download is cancelled
+* - IDownloadListener::OnDownloadCompleted() when the download is completed without any errors
+* - IDownloadListener::OnDownloadFailed() when the download has been stopped because of an error
+*
+* The following example demonstrates how to use the %DownloadManager class.
+*
+* @code
+*
+* #include <FBase.h>
+* #include <FContent.h>
+*
+* using namespace Tizen::Base;
+* using namespace Tizen::Content;
+* using namespace Tizen::App;
+*
+* class MyAppClass
+* : public Tizen::Content::IDownloadListener
+* {
+* public:
+* result Download(const String& url);
+* virtual void OnDownloadCanceled(RequestId reqId) {}
+* virtual void OnDownloadCompleted(RequestId reqId, const Tizen::Base::String& path);
+* virtual void OnDownloadFailed(RequestId reqId, result r, const Tizen::Base::String& errorCode);
+* virtual void OnDownloadPaused(RequestId reqId) {}
+* virtual void OnDownloadInProgress(RequestId reqId, unsigned long long receivedSize, unsigned long long totalSize) {}
+*
+* };
+*
+* result
+* MyAppClass::Download(const String& url)
+* {
+* result r = E_SUCCESS;
+* RequestId reqId = 0;
+*
+* DownloadRequest request(url);
+* DownloadManager* pManager = DownloadManager::GetInstance();
+*
+* pManager->SetDownloadListener(this);
+* pManager->Start(request, reqId);
+*
+* return r;
+* }
+*
+* void
+* MyAppClass::void OnDownloadCompleted(RequestId reqId, const Tizen::Base::String& path)
+* {
+* AppLog("Download is completed.");
+* }
+*
+* void
+* MyAppClass::OnDownloadFailed(RequestId reqId, result r, const Tizen::Base::String& errorCode)
+* {
+* AppLog("Download failed.");
+* }
+*
+* @endcode
+*/
+
+class _OSP_EXPORT_ DownloadManager
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * Gets the download manager instance of an application.
+ *
+ * @since 2.0
+ *
+ * @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.
+ */
+ static DownloadManager* GetInstance(void);
+
+ /**
+ * Starts the download operation. @n
+ * If this operation succeeds, the IDownloadListener::OnDownloadInProgress() method is called. @n
+ *
+ * @since 2.0
+ * @privilege %http://tizen.org/privilege/download
+ *
+ * @return An error code
+ * @param[in] request The download request
+ * @param[out] reqId The request ID
+ * @exception E_SUCCESS The method is successful.
+ * @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);
+
+ /**
+ * Pauses the download operation of the specified request ID. @n
+ * If this operation succeeds, the IDownloadListener::OnDownloadPaused() method is called.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @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_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);
+
+ /**
+ * Resumes the download operation of the specified request ID. @n
+ * If this operation succeeds, the IDownloadListener::OnDownloadInProgress() method is called.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @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_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.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ */
+ result Resume(RequestId reqId);
+
+ /**
+ * Cancels the download operation of the specified request ID.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @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);
+
+ /**
+ * Gets the download request information of the specified request ID.
+ *
+ * @since 2.0
+ *
+ * @return The download request
+ * @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;
+
+ /**
+ * Gets the download state of the given request ID. @n
+ * If there is no download request for the request ID, DOWNLOAD_STATE_NONE will be returned.
+ *
+ * @since 2.0
+ *
+ * @return The download state
+ * @param[in] reqId The request ID returned by Start()
+ */
+ DownloadState GetState(RequestId reqId) const;
+
+ /**
+ * Gets the MIME type of a download request.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] reqId The request ID returned by Start()
+ * @param[out] mimeType The MIME type
+ * @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.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ */
+ result GetMimeType(RequestId reqId, Tizen::Base::String& mimeType) const;
+
+ /**
+ * Sets a download listener.
+ *
+ * @since 2.0
+ *
+ * @param[in] pListener The download listener @n
+ * If this is @c null, it unsets the download listener.
+ */
+ void SetDownloadListener(IDownloadListener* pListener);
+
+private:
+ /**
+ * This default constructor is intentionally declared as private to implement the Singleton semantic.
+ */
+ DownloadManager(void);
+
+ /**
+ * This destructor is intentionally declared as private to implement the Singleton semantic.
+ */
+ virtual ~DownloadManager(void);
+
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ DownloadManager(const DownloadManager& downloadManager);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ DownloadManager& operator =(const DownloadManager& downloadManager);
+
+ friend class _DownloadManagerImpl;
+ class _DownloadManagerImpl * __pDownloadManagerImpl;
+
+}; // DownloadManager
+
+} } // Tizen::Content
+
+#endif //_FCNT_DOWNLOAD_MANAGER_H_
+
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntDownloadRequest.h
+ * @brief This is the header file for the %DownloadRequest class.
+ *
+ * This header file contains the declarations of the %DownloadRequest class.
+ */
+#ifndef _FCNT_DOWNLOAD_REQUEST_H_
+#define _FCNT_DOWNLOAD_REQUEST_H_
+
+#include <FBaseResult.h>
+#include <FBaseString.h>
+
+namespace Tizen { namespace Content
+{
+
+/**
+* @class DownloadRequest
+* @brief This class provides information of a download request.
+*
+* @since 2.0
+*
+* @final This class is not intended for extension.
+*
+* The %DownloadRequest class provides information of a download request. It provides the URL of a download request, which is mandatory information. It also provides the destination directory path and the file name. The destination directory path and file name can be set by the SetDirectoryPath() and SetFileName() methods. @n
+* If the download path is not specified, the data will be downloaded to the default download directory returned by Tizen::System::Environment::GetDefaultDownloadPath().
+*
+*/
+
+class _OSP_EXPORT_ DownloadRequest
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * Initializes this instance of %DownloadRequest with the specified URL. @n
+ * The downloaded path is set to a default download directory returned by Tizen::System::Environment::GetDefaultDownloadPath().
+ *
+ * @since 2.0
+ *
+ * @param[in] url The URL of the download request
+ */
+ DownloadRequest(const Tizen::Base::String& url);
+
+ /**
+ * Initializes this instance of %DownloadRequest with the specified URL and directory path.
+ *
+ * @since 2.0
+ *
+ * @param[in] url The URL of the download request
+ * @param[in] dirPath The directory path of the data that will be downloaded
+ */
+ DownloadRequest(const Tizen::Base::String& url, const Tizen::Base::String& dirPath);
+
+ /**
+ * Copying of objects using this copy constructor is allowed.
+ *
+ * @since 2.0
+ *
+ * @param[in] rhs An instance of %DownloadRequest to copy
+ */
+ DownloadRequest(const DownloadRequest& rhs);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~DownloadRequest(void);
+
+ /**
+ * Copying of objects using this copy assignment operator is allowed.
+ *
+ * @return A reference to this instance
+ * @param[in] rhs An instance of %DownloadRequest
+ */
+ DownloadRequest& operator =(const DownloadRequest& rhs);
+
+ /**
+ * Checks whether the specified instance of Tizen::Base::Object is equivalent to the current instance of %DownloadRequest.
+ *
+ * @since 2.0
+ *
+ * @return @c true if the specified instance of Tizen::Base::Object is equivalent to the current instance of %DownloadRequest, @n
+ * else @c false
+ * @param[in] obj The object to compare with the current instance of %DownloadRequest
+ */
+ virtual bool Equals(const Tizen::Base::Object& obj) const;
+
+ /**
+ * Gets the hash value of the current instance.
+ *
+ * @since 2.0
+ *
+ * @return The hash value of the current instance
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * Sets the directory path of the data that will be downloaded.
+ *
+ * @since 2.0
+ *
+ * @param[in] dirPath The directory path
+ */
+ void SetDirectoryPath(const Tizen::Base::String& dirPath);
+
+ /**
+ * Sets the file name of the data to be downloaded.
+ *
+ * @since 2.0
+ *
+ * @param[in] fileName The file name
+ */
+ void SetFileName(const Tizen::Base::String& fileName);
+
+ /**
+ * Gets the URL of a download request.
+ *
+ * @since 2.0
+ *
+ * @return The URL of this download request
+ */
+ Tizen::Base::String GetUrl(void) const;
+
+ /**
+ * Gets the directory path of the data that will be downloaded.
+ *
+ * @since 2.0
+ *
+ * @return The directory path
+ */
+ Tizen::Base::String GetDirectoryPath(void) const;
+
+ /**
+ * Gets the file name of the data to be downloaded.
+ *
+ * @since 2.0
+ *
+ * @return The file name
+ */
+ Tizen::Base::String GetFileName(void) const;
+
+private:
+ /**
+ * This default constructor is intentionally declared as private so that only the platform can create an instance.
+ */
+ DownloadRequest(void);
+
+ friend class _DownloadRequestImpl;
+ class _DownloadRequestImpl * __pDownloadRequestImpl;
+
+}; // DownloadRequest
+
+} } // Tizen::Content
+
+#endif //_FCNT_DOWNLOAD_MANAGER_H_
+
--- /dev/null
+//
+// 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 FCntIContentScanListener.h
+ * @brief This is the header file for 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 <FBaseString.h>
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Content
+{
+
+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;
+
+protected:
+ virtual void _IContentScanListener_Reserved1(void) {}
+ virtual void _IContentScanListener_Reserved2(void) {}
+
+}; // class _IContentScanListener
+
+}}
+
+#endif // _FCNT_ICONTENT_SCAN_LISTENER_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntIContentTransferListener.h
+ * @brief This is the header file for the %IContentTransferListener interface.
+ *
+ * This header file contains the declarations of the %IContentTransferListener interface.
+ */
+
+#ifndef _FCNT_ICONTENT_TRANSFER_LISTENER_H_
+#define _FCNT_ICONTENT_TRANSFER_LISTENER_H_
+
+#include <FBaseRtIEventListener.h>
+#include <FCntTypes.h>
+
+namespace Tizen { namespace Base
+{
+class ByteBuffer;
+}}
+
+namespace Tizen { namespace Content
+{
+/**
+ * @if OSPDEPREC
+ * @interface IContentTransferListener
+ * @brief <i> [Deprecated] </i> This interface provides event handlers that receive the events associated with ContentTransfer.
+ *
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * The %IContentTransferListener interface handles the content download events.
+ * @endif
+ */
+class _OSP_EXPORT_ IContentTransferListener
+ : virtual public Tizen::Base::Runtime::IEventListener
+{
+public:
+ /**
+ * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ */
+ virtual ~IContentTransferListener(void) {}
+
+ /**
+ * Called when the content transfer is in progress.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @param[in] reqId The request ID
+ * @param[in] totalTransferedSize The total size of the data to transfer in bytes
+ */
+ virtual void OnContentTransferInProgress(RequestId reqId, int totalTransferedSize) = 0;
+
+ /**
+ * Called when a download operation is completed.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @param[in] reqId The request ID
+ * @param[in] contentId The registered content ID
+ * @param[in] r The result of the download
+ * @param[in] errorCode The error code from the server
+ * @param[in] errorMessage The error message from the server
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SERVER An error has occurred on the server side.
+ * @exception E_CONNECTION_FAILED The server connection has failed.
+ * @exception E_ILLEGAL_ACCESS The request to access a server is illegal.
+ * @exception E_STORAGE_FULL The storage is full.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ virtual void OnContentDownloadCompleted(RequestId reqId, ContentId contentId, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMessage) = 0;
+
+ /**
+ * Called when a download to buffer operation is completed.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @param[in] reqId The request ID
+ * @param[in] pBuffer The binary buffer that has been downloaded
+ * @param[in] r The result of the download
+ * @param[in] errorCode The error code from the server
+ * @param[in] errorMessage The error message from the server
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SERVER An error has occurred on the server side.
+ * @exception E_FILE_ALREADY_EXIST The specified file already exists.
+ * @exception E_STORAGE_FULL The storage is full.
+ * @exception E_CONNECTION_FAILED The server connection has failed.
+ * @exception E_ILLEGAL_ACCESS The request to access a server is illegal.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ virtual void OnContentDownloadToBufferCompleted(RequestId reqId, Tizen::Base::ByteBuffer* pBuffer, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMessage) = 0;
+
+ /**
+ * Called when a transfer operation is cancelled.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This class is deprecated. Instead of using this class, use DownloadManager class.
+ * @since 2.0
+ *
+ * @param[in] reqId The request ID
+ * @param[in] r The result of the transfer
+ * @param[in] errorCode The error code from the server
+ * @param[in] errorMessage The error message from the server
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SERVER An error has occurred on the server side.
+ */
+ virtual void OnContentTransferCanceled(RequestId reqId, result r, const Tizen::Base::String& errorCode, const Tizen::Base::String& errorMessage) = 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.0
+ //
+ virtual void IContentTransferListener_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.0
+ //
+ virtual void IContentTransferListener_Reserved2(void) {}
+
+}; // class IContentTransferListener
+
+}} // Tizen::Content
+
+#endif // _FCNT_ICONTENT_TRANSFER_LISTENER_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntIDownloadListener.h
+ * @brief This is the header file for the %IDownloadListener interface.
+ *
+ * This header file contains the declarations of the %IDownloadListener interface.
+ */
+
+#ifndef _FCNT_IDOWNLOAD_LISTENER_H_
+#define _FCNT_IDOWNLOAD_LISTENER_H_
+
+#include <FBaseString.h>
+#include <FBaseRtIEventListener.h>
+
+namespace Tizen { namespace Content
+{
+
+/**
+* @interface IDownloadListener
+* @brief This interface is used for receiving the download operation events.
+*
+* @since 2.0
+*
+* The %IDownloadListener interface is used for receiving the download operation events.
+*/
+class _OSP_EXPORT_ IDownloadListener
+ : 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.0
+ */
+ virtual ~IDownloadListener(void) {}
+
+ /**
+ * Called when a download operation is canceled.
+ *
+ * @since 2.0
+ *
+ * @param[in] reqId The request ID returned by DownloadManager::Start()
+ */
+ virtual void OnDownloadCanceled(RequestId reqId) = 0;
+
+ /**
+ * Called when a download operation is completed.
+ *
+ * @since 2.0
+ *
+ * @param[in] reqId The request ID returned by DownloadManager::Start()
+ * @param[in] path The path of the downloaded file
+ */
+ virtual void OnDownloadCompleted(RequestId reqId, const Tizen::Base::String& path) = 0;
+
+ /**
+ * Called when a download operation fails.
+ *
+ * @since 2.0
+ *
+ * @param[in] reqId The request ID returned by DownloadManager::Start()
+ * @param[in] r The error of a download operation @n The following error codes may be given through this argument.
+ * @param[in] errorCode The http error code from the server
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_URL The specified URL is invalid.
+ * @exception E_CONNECTION_FAILED The server connection fails.
+ * @exception E_TIMEOUT The connection has timed out.
+ * @exception E_MAX_EXCEEDED The request has exceeded the limit.
+ * @exception E_STORAGE_FULL The storage is full.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ */
+ virtual void OnDownloadFailed(RequestId reqId, result r, const Tizen::Base::String& errorCode) = 0;
+
+ /**
+ * Called when a download operation pauses.
+ *
+ * @since 2.0
+ *
+ * @param[in] reqId The request ID returned by DownloadManager::Start()
+ */
+ virtual void OnDownloadPaused(RequestId reqId) = 0;
+
+ /**
+ * Called when the progress of download operation is changed.
+ *
+ * @since 2.0
+ *
+ * @param[in] reqId The request ID
+ * @param[in] receivedSize The size of received data in bytes
+ * @param[in] totalSize The total size of data to receive in bytes
+ */
+ virtual void OnDownloadInProgress(RequestId reqId, unsigned long long receivedSize, unsigned long long totalSize) = 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.0
+ //
+ virtual void IDownloadListener_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.0
+ //
+ virtual void IDownloadListener_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.0
+ //
+ virtual void IDownloadListener_Reserved3(void) {}
+}; // IDownloadListener
+
+} } // Tizen::Content
+
+#endif // _FCNT_IDOWNLOAD_LISTENER_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntImageContentInfo.h
+ * @brief This is the header file for the %ImageContentInfo class.
+ *
+ * This header file contains the declarations of the %ImageContentInfo class.
+ */
+
+#ifndef _FCNT_IMAGE_CONTENT_INFO_H_
+#define _FCNT_IMAGE_CONTENT_INFO_H_
+
+#include <FCntContentInfo.h>
+
+namespace Tizen { namespace Content
+{
+
+class _ImageContentInfoImpl;
+
+/**
+ * @class ImageContentInfo
+ * @brief This class provides methods to access the image content information.
+ *
+ * @since 2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ * The %ImageContentInfo class provides methods to access the image content information that is extracted from a physical file. @n
+ * Before getting the image content information, ContentManager must be used to create the content.
+ *
+ * For more information on the different types of content information, see <a href="../org.tizen.native.appprogramming/html/guide/content/device_content_mgmt.htm">Device Content Management</a>.
+ *
+ * The following example demonstrates how to use the %ImageContentInfo class.
+ *
+ * @code
+ * result
+ * MyClass::TestImageContentInfo(void)
+ * {
+ * result r = E_SUCCESS;
+ *
+ * ContentId contentId;
+ * ContentManager contentManager;
+ * r = contentManager.Construct();
+ * TryReturn(!IsFailed(r), r, "Construct failed.");
+ *
+ * ImageContentInfo imageContentInfo;
+ * r = imageContentInfo.Construct(null);
+ * TryReturn(!IsFailed(r), r, "Construct failed.");
+ *
+ * Tizen::Base::String sourcePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/flower.jpg";
+ * Tizen::Base::String destPath = Tizen::System::Environment::GetMediaPath() + L"Images/flower.jpg";
+ *
+ * contentId = contentManager.CreateContent(sourcePath, destPath, false, &imageContentInfo);
+ * TryReturn(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed.");
+ *
+ * return r;
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ ImageContentInfo
+ : public Tizen::Content::ContentInfo
+{
+public:
+ /**
+ * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+ *
+ * @since 2.0
+ *
+ * @remarks After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+ */
+ ImageContentInfo(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~ImageContentInfo(void);
+
+ /**
+ * Initializes this instance of %ImageContentInfo with the specified parameter.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @compatibility This method has compatibility issues with OSP compatible applications. @n
+ * For more information, see @ref CompImageContentInfoConstructPage "here".
+ * @endif
+ *
+ * @return An error code
+ * @param[in] pContentPath The content path
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_IO An I/O error has occurred.
+ * @exception E_SYSTEM An internal error has occurred.
+ * @remarks The @c pContentPath should start with directory path returned by either Tizen::System::Environment::GetMediaPath() or Tizen::System::Environment::GetExternalStoragePath(). @n
+ * If @c pContentPath is @c null, use ContentManager::CreateContent(const Tizen::Base::ByteBuffer&, const Tizen::Base::String&, const ContentInfo*)
+ * or ContentManager::CreateContent(const Tizen::Base::String&, const Tizen::Base::String&, bool, const ContentInfo*). @n
+ * If the content has coordinates as metadata, they are automatically set.
+ */
+ result Construct(const Tizen::Base::String* pContentPath);
+
+ /**
+ * @if OSPCOMPAT
+ * @page CompImageContentInfoConstructPage Compatibility for the file path.
+ * @section CompImageContentInfoConstructPageIssueSection Issues
+ * The content path argument of this method in OSP compatible applications has the following issues: @n
+ * <UL><li> The content path should be a path that begins with an allowed path prefix.
+ * For example, L"/Media/Images/flower.jpg", L"/Storagecard/Media/Images/flower.jpg". </UL></li>
+ *
+ * @section CompImageContentInfoConstructPageSolutionSection Resolutions
+ * This issue has been resolved in Tizen. @n
+ * <UL><li> The content path can be a path without a specific allowed path prefix.
+ * Application do not need to know the specific allowed path prefixes.
+ * To get the directory path, use the following methods: </UL></li>
+ * - For accessing the media directory, use Tizen::System::Environment::GetMediaPath().
+ * - For accessing the external storage, use Tizen::System::Environment::GetExternalStoragePath().
+ *
+ * @endif
+ */
+
+ /**
+ * @if OSPDEPREC
+ * Initializes this instance of %ImageContentInfo with the specified parameters.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This method is deprecated as there is a problem in managing the user-defined thumbnail and device coordinates. @n
+ * Instead of using this method, use Construct(const Tizen::Base::String*). @n
+ * To set the coordinates in the ContentInfo instance, use ContentInfo::SetCoordinates(const Tizen::Locations::Coordinates&).
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] contentPath The content path
+ * @param[in] thumbnailPath The thumbnail path
+ * @param[in] setGps Set to @c true to save the device's last known coordinates in the ContentInfo instance, @n
+ * else @c false @n
+ * The coordinate information may be incorrect if it is outdated or has never been updated.
+ * To update the coordinate information or to get the exact value,
+ * use Tizen::Locations::LocationProvider::RequestLocationUpdates() before calling this method.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_IO An I/O error has occurred.
+ * @remarks The content path must start with @c '/Media' or @c '/Storagecard/Media'. @n
+ * The thumbnail path must start with @c '/Home', @c '/Media', or @c '/Storagecard/Media'. @n
+ * The permitted format for a thumbnail image is Bitmap (bmp).
+ * @endif
+ */
+ virtual result Construct(const Tizen::Base::String& contentPath, const Tizen::Base::String& thumbnailPath = L"", bool setGps = false);
+
+ /**
+ * Gets the width of the image file.
+ *
+ * @since 2.0
+ *
+ * @return The width of the image file
+ */
+ int GetWidth(void) const;
+
+ /**
+ * Gets the height of the image file.
+ *
+ * @since 2.0
+ *
+ * @return The height of the image file
+ */
+ int GetHeight(void) const;
+
+ /**
+ * Gets the title of the image file.
+ *
+ * @since 2.0
+ *
+ * @return The title of the image file, @n
+ * else @c Unknown if the value is empty
+ */
+ Tizen::Base::String GetTitle(void) const;
+
+ /**
+ * Gets the orientation of the image file.
+ *
+ * @since 2.0
+ *
+ * @return The orientation of the image file
+ */
+ ImageOrientationType GetOrientation(void) const;
+
+private:
+ class _ImageContentData
+ {
+ public:
+ _ImageContentData()
+ : width(0)
+ , height(0)
+ , orientationType(IMAGE_ORIENTATION_TYPE_UNKNOWN)
+ , title(L"") {}
+
+ int width;
+ int height;
+ ImageOrientationType orientationType;
+ Tizen::Base::String title;
+ };
+
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ImageContentInfo(const ImageContentInfo& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ ImageContentInfo& operator =(const ImageContentInfo& rhs);
+
+ result SetImageContentData(const _ImageContentData* pImageContentData);
+
+ _ImageContentData* GetImageContentData(void);
+
+private:
+ _ImageContentData* __pImageContentData;
+
+ friend class _ContentManagerImpl;
+ friend class _ContentSearchImpl;
+ friend class _ContentDirectoryImpl;
+ friend class _ContentUtility;
+ friend class _PlayListManagerImpl;
+ friend class _PlayListImpl;
+
+ friend class _ImageContentInfoImpl;
+ _ImageContentInfoImpl* __pImpl;
+
+}; // Class ImageContentInfo
+
+}} // Tizen::Content
+
+#endif // _FCNT_IMAGE_CONTENT_INFO_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntImageMetadata.h
+ * @brief This is the header file for the %ImageMetadata class.
+ *
+ * This header file contains the declarations of the %ImageMetadata class.
+ */
+
+#ifndef _FCNT_IMAGE_METADATA_H_
+#define _FCNT_IMAGE_METADATA_H_
+
+#include <FBaseObject.h>
+#include <FCntTypes.h>
+
+namespace Tizen { namespace Graphics
+{
+class Bitmap;
+}}
+
+namespace Tizen { namespace Content
+{
+
+class _ImageMetadataImpl;
+
+/**
+ * @class ImageMetadata
+ * @brief This class provides methods to access the image metadata.
+ *
+ * @since 2.0
+ *
+ * The %ImageMetadata class provides methods to access the image metadata that contains the image content-specific attributes.
+ *
+ * The following example demonstrates how to use the %ImageMetadata class.
+ *
+ * @code
+ * result
+ * MyClass::TestImageMetadata(void)
+ * {
+ * result r = E_SUCCESS;
+ *
+ * Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Images/full_meta.jpg";
+ * ImageMetadata* pImgMeta = ContentManagerUtil::GetImageMetaN(contentPath);
+ * TryReturn(pImgMeta != null, GetLastResult(), "ContentManagerUtil::GetImageMetaN failed.");
+ *
+ * // Width
+ * pImgMeta->GetWidth();
+ *
+ * // Height
+ * pImgMeta->GetHeight();
+ *
+ * // Camera
+ * pImgMeta->GetCameraManufacturer();
+ *
+ * // Model
+ * pImgMeta->GetCameraModel();
+ *
+ * // Software
+ * pImgMeta->GetSoftware();
+ *
+ * // Date time
+ * pImgMeta->GetDateTime();
+ *
+ * // Thumbnail
+ * Tizen::Media::Image image;
+ * r = image.Construct();
+ * if (IsFailed(r))
+ * {
+ * delete pImgMeta;
+ * return r;
+ * }
+ *
+ * Tizen::Graphics::Bitmap* pBitmap = pImgMeta->GetThumbnailN();
+ * if (pBitmap == null)
+ * {
+ * delete pImgMeta;
+ * return GetLastResult();
+ * }
+ *
+ * Tizen::Base::String thumbnailPath = Tizen::System::Environment::GetMediaPath() + L"Images/image.bmp";
+ * r = image.EncodeToFile(*pBitmap, Tizen::Media::IMG_FORMAT_BMP, thumbnailPath, false);
+ * if (IsFailed(r))
+ * {
+ * delete pImgMeta;
+ * delete pBitmap;
+ * return r;
+ * }
+ *
+ * delete pImgMeta;
+ * delete pBitmap;
+ *
+ * return r;
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ ImageMetadata
+ : virtual public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ ImageMetadata(void);
+
+ /**
+ * Copying of objects using this copy constructor is allowed.
+ *
+ * @since 2.0
+ *
+ * @param[in] rhs An instance of %ImageMetadata
+ */
+ ImageMetadata(const ImageMetadata& rhs);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~ImageMetadata(void);
+
+ /**
+ * Gets the width of the image.
+ *
+ * @since 2.0
+ *
+ * @return The width of the image
+ */
+ int GetWidth(void) const;
+
+ /**
+ * Gets the height of the image.
+ *
+ * @since 2.0
+ *
+ * @return The height of the image
+ */
+ int GetHeight(void) const;
+
+ /**
+ * Gets the name of the camera's manufacturer.
+ *
+ * @since 2.0
+ *
+ * @return The name of the camera's manufacturer
+ */
+ Tizen::Base::String GetCameraManufacturer(void) const;
+
+ /**
+ * Gets the model of the camera.
+ *
+ * @since 2.0
+ *
+ * @return The model of the camera
+ */
+ Tizen::Base::String GetCameraModel(void) const;
+
+ /**
+ * Gets the version of either the software or the firmware of the camera or the image input device
+ * used to generate the image.
+ *
+ * @since 2.0
+ *
+ * @return The version of either the software or the firmware of the camera or the image input device
+ * used to generate the image
+ */
+ Tizen::Base::String GetSoftware(void) const;
+
+ /**
+ * Gets the date and time of the created content.
+ *
+ * @since 2.0
+ *
+ * @return The date and time of the created content
+ */
+ Tizen::Base::String GetDateTime(void) const;
+
+ /**
+ * Gets the latitude of the image.
+ *
+ * @since 2.0
+ *
+ * @return The latitude of the image
+ * @remarks If there is no latitude in the image, @c -200.0 is returned.
+ */
+ double GetLatitude(void) const;
+
+ /**
+ * Gets the longitude of the image.
+ *
+ * @since 2.0
+ *
+ * @return The longitude of the image
+ * @remarks If there is no longitude in the image, @c -200.0 is returned.
+ */
+ double GetLongitude(void) const;
+
+ /**
+ * Gets the orientation of the image.
+ *
+ * @since 2.0
+ *
+ * @return The orientation of the image
+ */
+ ImageOrientationType GetOrientation(void) const;
+
+ /**
+ * Gets the white balance of the image.
+ *
+ * @since 2.0
+ *
+ * @return The white balance of the image
+ */
+ Tizen::Base::String GetWhiteBalance(void) const;
+
+ /**
+ * Gets the thumbnail image.
+ *
+ * @since 2.0
+ *
+ * @return A pointer to the thumbnail image
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_DATA_NOT_FOUND The thumbnail image does not exist.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ Tizen::Graphics::Bitmap* GetThumbnailN(void) const;
+
+ /**
+ * Compares the equality of values between two %ImageMetadata objects by overriding the Tizen::Base::Object::Equals() method.
+ *
+ * @since 2.0
+ *
+ * @return @c true if all the fields in the objects are equal, @n
+ * else @c false
+ * @param[in] rhs The Tizen::Base::Object with which the comparison is done
+ * @remarks An instance of Tizen::Graphics::Bitmap is not taken into account in the comparisons.
+ */
+ virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+ /**
+ * Gets the hash value of the current instance by overriding the Tizen::Base::Object::GetHashCode() method.
+ *
+ * @since 2.0
+ *
+ * @return The hash value of the current instance
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * Copying of objects using this copy assignment operator is allowed.
+ *
+ * @since 2.0
+ *
+ * @return A reference to this instance
+ * @param[in] rhs An instance of %ImageMetadata
+ */
+ ImageMetadata& operator =(const ImageMetadata& rhs);
+
+private:
+ friend class _ImageMetadataImpl;
+ _ImageMetadataImpl* __pImpl;
+
+}; // class ImageMetadata
+
+}} // Tizen::Content
+
+#endif // _FCNT_IMAGE_METADATA_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntOtherContentInfo.h
+ * @brief This is the header file for the %OtherContentInfo class.
+ *
+ * This header file contains the declarations of the %OtherContentInfo class.
+ */
+
+#ifndef _FCNT_OTHER_CONTENT_INFO_H_
+#define _FCNT_OTHER_CONTENT_INFO_H_
+
+#include <FCntContentInfo.h>
+
+namespace Tizen { namespace Content
+{
+
+class _OtherContentInfoImpl;
+
+/**
+ * @class OtherContentInfo
+ * @brief This class provides methods to access the other content information.
+ *
+ * @since 2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ * The %OtherContentInfo class provides methods to access the other content information. @n
+ * Before getting the other content information, the ContentManager class must be used to create the content. @n
+ * If the E_UNSUPPORTED_FORMAT exception is received from the ContentManagerUtil::CheckContentType() method, the file can only be created as %OtherContentInfo.
+ *
+ * For more information on the different types of content information, see <a href="../org.tizen.native.appprogramming/html/guide/content/device_content_mgmt.htm">Device Content Management</a>.
+ *
+ * The following example demonstrates how to use the %OtherContentInfo class.
+ *
+ * @code
+ * result
+ * MyClass::TestOtherContentInfo(void)
+ * {
+ * result r = E_SUCCESS;
+ *
+ * ContentId contentId;
+ * ContentManager contentManager;
+ * r = contentManager.Construct();
+ * TryReturn(!IsFailed(r), r, "Construct failed.");
+ *
+ * OtherContentInfo otherContentInfo;
+ * r = otherContentInfo.Construct(null);
+ * TryReturn(!IsFailed(r), r, "Construct failed.");
+ *
+ * Tizen::Base::String sourcePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/flower.doc";
+ * Tizen::Base::String destPath = Tizen::System::Environment::GetMediaPath() + L"Others/flower.doc";
+ *
+ * contentId = contentManager.CreateContent(sourcePath, destPath, false, &otherContentInfo);
+ * TryReturn(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed.");
+ *
+ * return r;
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ OtherContentInfo
+ : public Tizen::Content::ContentInfo
+{
+public:
+ /**
+ * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+ *
+ * @since 2.0
+ *
+ * @remarks After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+ */
+ OtherContentInfo(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~OtherContentInfo(void);
+
+ /**
+ * Initializes this instance of %OtherContentInfo with the specified parameter.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @compatibility This method has compatibility issues with OSP compatible applications. @n
+ * For more information, see @ref CompOtherContentInfoConstructPage "here".
+ * @endif
+ *
+ * @return An error code
+ * @param[in] pContentPath The content path
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_IO An I/O error has occurred.
+ * @exception E_SYSTEM An internal error has occurred.
+ * @remarks The @c pContentPath should start with directory path returned by either Tizen::System::Environment::GetMediaPath() or Tizen::System::Environment::GetExternalStoragePath(). @n
+ * If @c pContentPath is @c null, use ContentManager::CreateContent(const Tizen::Base::ByteBuffer&, const Tizen::Base::String&, const ContentInfo*)
+ * or ContentManager::CreateContent(const Tizen::Base::String&, const Tizen::Base::String&, bool, const ContentInfo*).
+ */
+ result Construct(const Tizen::Base::String* pContentPath);
+
+ /**
+ * @if OSPCOMPAT
+ * @page CompOtherContentInfoConstructPage Compatibility for the file path.
+ * @section CompOtherContentInfoConstructPageIssueSection Issues
+ * The content path argument of this method in OSP compatible applications has the following issues: @n
+ * -# The content path should be a path that begins with an allowed path prefix. @n
+ * For example, L"/Media/Images/flower.jpg", L"/Storagecard/Media/Images/flower.jpg".
+ *
+ * @section CompOtherContentInfoConstructPageSolutionSection Resolutions
+ * This issue has been resolved in Tizen. @n
+ * -# The content path can be a path without a specific allowed path prefix. @n
+ * Application do not need to know the specific allowed path prefixes. @n
+ * To get the directory path, use the following methods: @n
+ * - For accessing the media directory, use Tizen::System::Environment::GetMediaPath().
+ * - For accessing the external storage, use Tizen::System::Environment::GetExternalStoragePath().
+ * @endif
+ */
+
+ /**
+ * @if OSPDEPREC
+ * Initializes this instance of %OtherContentInfo with the specified parameters.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This method is deprecated as there is a problem in managing the user-defined thumbnail and device coordinates. @n
+ * Instead of using this method, use Construct(const Tizen::Base::String*). @n
+ * To set the coordinates in the ContentInfo instance, use ContentInfo::SetCoordinates(const Tizen::Locations::Coordinates&).
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] contentPath The content path
+ * @param[in] thumbnailPath The thumbnail path
+ * @param[in] setGps Set to @c true to save the device's last known coordinates in the ContentInfo instance, @n
+ * else @c false @n
+ * The coordinate information may be incorrect if it is outdated or has never been updated. @n
+ * To update the coordinate information or to get the exact value,
+ * use Tizen::Locations::LocationProvider::RequestLocationUpdates() before calling this method.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_IO An I/O error has occurred.
+ * @remarks The content path must start with @c '/Media' or @c '/Storagecard/Media'. @n
+ * The thumbnail path must start with @c '/Home', @c '/Media', or @c '/Storagecard/Media'. @n
+ * The permitted format for a thumbnail image is bitmap (bmp).
+ * @endif
+ */
+ virtual result Construct(const Tizen::Base::String& contentPath, const Tizen::Base::String& thumbnailPath = L"", bool setGps = false);
+
+private:
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ OtherContentInfo(const OtherContentInfo& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ OtherContentInfo& operator =(const OtherContentInfo& rhs);
+
+private:
+ bool __isCreated;
+
+ friend class _OtherContentInfoImpl;
+ _OtherContentInfoImpl* __pImpl;
+
+}; // class OtherContentInfo
+
+}} // Tizen::Content
+
+#endif // _FCNT_OTHER_CONTENT_INFO_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntPlayList.h
+ * @brief This is the header file for the %PlayList class.
+ *
+ * This header file contains the declarations of the %PlayList class.
+ */
+
+#ifndef _FCNT_CONTENT_PLAYLIST_H_
+#define _FCNT_CONTENT_PLAYLIST_H_
+
+#include <FBaseString.h>
+#include <FCntTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen { namespace Content
+{
+
+class _PlayListImpl;
+
+/**
+ * @class PlayList
+ * @brief This class provides methods for a playlist information.
+ *
+ * @since 2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ * The %PlayList class provides methods to access a playlist information.
+ * The methods of this class are immediately access to the database and update.
+ *
+ * The following example demonstrates how to use the %PlayList class.
+ *
+ * @code
+ * #include <FContent.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Base::Collection;
+ * using namespace Tizen::Content;
+ *
+ * void
+ * MyClass::Test(void)
+ * {
+ * // Get an instance of PlayList
+ * PlayList playList;
+ * result r = playList.Construct("my_playlist_1");
+ * if (IsFailed(r))
+ * {
+ *
+ * }
+ *
+ * IList* pList = playList.GetContentInfoListN();
+ * if (IsFailed(r))
+ * {
+ *
+ * }
+ *
+ * // Delete resource
+ * pList->RemoveAll(true);
+ * delete pList;
+ * }
+ *
+ * @endcode
+ *
+ */
+class _OSP_EXPORT_ PlayList
+ : public Tizen::Base::Object
+{
+
+public:
+
+ /**
+ * The object is not fully constructed after this constructor is called. @n
+ * For full construction, the Construct() method must be called right after calling this constructor.
+ *
+ * @since 2.0
+ */
+ PlayList(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~PlayList(void);
+
+ /**
+ * Initializes this instance of %PlayList with the specified parameter.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] playListName The playlist name
+ * @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.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_DATABASE The method cannot access the database.
+ */
+ result Construct(const Tizen::Base::String& playListName);
+
+ /**
+ * Gets the count of playlist items.
+ *
+ * @since 2.0
+ *
+ * @return The item count
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_DATABASE The method cannot access the database.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ int GetPlayListItemCount(void) const;
+
+ /**
+ * Gets the list of playlist items.
+ *
+ * @since 2.0
+ *
+ * @return The list that contains playlist items as ContentInfo class
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_DATABASE The method cannot access the database.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ Tizen::Base::Collection::IList* GetContentInfoListN(void) const;
+
+ /**
+ * Adds the item to the playlist.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] contentId The content 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_DATABASE The method cannot access the database.
+ * @see AddItems(const Tizen::Base::Collection::IList&)
+ */
+ result AddItem(const ContentId& contentId);
+
+ /**
+ * Adds the items to the playlist.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] contentIdList The list that contains ContentId
+ * @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_DATABASE The method cannot access the database.
+ * @see AddItem(const ContentId&)
+ */
+ result AddItems(const Tizen::Base::Collection::IList& contentIdList);
+
+ /**
+ * Removes the item from the playlist.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] contentId The content ID
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_OBJ_NOT_FOUND The specified @c contentId is not found.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_DATABASE The method cannot access the database.
+ * @see RemoveItems(const Tizen::Base::Collection::IList&)
+ */
+ result RemoveItem(const ContentId& contentId);
+
+ /**
+ * Removes the items from the playlist.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] contentIdList The list that contains ContentId
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_OBJ_NOT_FOUND The specified @c contentId in the list is not found.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_DATABASE The method cannot access the database.
+ * @see RemoveItem(const ContentId&)
+ */
+ result RemoveItems(const Tizen::Base::Collection::IList& contentIdList);
+
+ /**
+ * Gets the playlist name.
+ *
+ * @since 2.0
+ *
+ * @return The playlist name
+ */
+ Tizen::Base::String GetPlayListName(void) const;
+
+ /**
+ * Sets the playlist name.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] playListName The playlist name
+ * @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.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_DATABASE The method cannot access the database.
+ */
+ result SetPlayListName(const Tizen::Base::String& playListName);
+
+ /**
+ * Gets the play order.
+ *
+ * @since 2.0
+ *
+ * @return The play order
+ * @param[in] contentId The content ID
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_OBJ_NOT_FOUND The specified @c contentId is not found.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_DATABASE The method cannot access the database.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ int GetPlayOrder(const ContentId& contentId) const;
+
+private:
+
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ PlayList(const PlayList& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ PlayList& operator =(const PlayList& rhs);
+
+ friend class _PlayListImpl;
+ _PlayListImpl* __pImpl;
+
+ Tizen::Base::String __playListName;
+
+ friend class _PlayListManagerImpl;
+
+ result ConstructPlayList(const Tizen::Base::String& playListName);
+
+}; // class PlayList
+
+}} // Tizen::Content
+
+#endif // _FCNT_CONTENT_PLAYLIST_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntPlayListManager.h
+ * @brief This is the header file for the %PlayListManager class.
+ *
+ * This header file contains the declarations of the %PlayListManager class.
+ */
+
+#ifndef _FCNT_CONTENT_PLAYLIST_MANAGER_H_
+#define _FCNT_CONTENT_PLAYLIST_MANAGER_H_
+
+#include <FBaseString.h>
+#include <FCntTypes.h>
+
+namespace Tizen { namespace Base { namespace Collection
+{
+class IList;
+}}}
+
+namespace Tizen { namespace Content
+{
+
+class PlayList;
+class _PlayListManagerImpl;
+
+/**
+ * @class PlayListManager
+ * @brief This class provides methods to manage the playlist.
+ *
+ * @since 2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ * The %PlayListManager class provides methods to manage the playlist.
+ * The methods of this class are immediately access to the database and update.
+ *
+ * The following example demonstrates how to use the %PlayListManager class.
+ *
+ * @code
+ * #include <FContent.h>
+ *
+ * using namespace Tizen::Base;
+ * using namespace Tizen::Base::Collection;
+ * using namespace Tizen::Content;
+ *
+ * void
+ * MyClass::Test(void)
+ * {
+ * // Call an instance of PlayListManager
+ * PlayListManager* pManager = PlayListManager::GetInstance();
+ * if (IsFailed(GetLastResult()))
+ * {
+ *
+ * }
+ *
+ * IList* pList = pManager->GetAllPlayListNameN();
+ * if (IsFailed(GetLastResult()))
+ * {
+ *
+ * }
+ *
+ * // Delete resource
+ * pList->RemoveAll(true);
+ * delete pList;
+ * }
+ *
+ * @endcode
+ */
+class _OSP_EXPORT_ PlayListManager
+ : public Tizen::Base::Object
+{
+
+public:
+
+ /**
+ * Gets the playlist.
+ *
+ * @since 2.0
+ *
+ * @return A pointer to the PlayList instance
+ * @param[in] playListName The playlist name
+ * @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.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_DATABASE The method cannot access the database.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ PlayList* GetPlayListN(const Tizen::Base::String& playListName) const;
+
+ /**
+ * Removes the playlist.
+ *
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] playListName The playlist name
+ * @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_DATABASE The method cannot access the database.
+ */
+ result RemovePlayList(const Tizen::Base::String& playListName);
+
+ /**
+ * Gets the count of all playlists.
+ *
+ * @since 2.0
+ *
+ * @return The count of all playlists
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_DATABASE The method cannot access the database.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ int GetAllPlayListCount(void) const;
+
+ /**
+ * Gets all playlist names.
+ *
+ * @since 2.0
+ *
+ * @return The list that contains playlist names as Tizen::Base::String class
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_SERVICE_BUSY The database is busy.
+ * @exception E_DATABASE The method cannot access the database.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ Tizen::Base::Collection::IList* GetAllPlayListNameN(void) const;
+
+ /**
+ * Gets the playlist manager instance.
+ *
+ * @since 2.0
+ *
+ * @return A pointer to the %PlayListManager instance
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ static PlayListManager* GetInstance(void);
+
+private:
+
+ static PlayListManager* __pPlayListManager;
+
+ /**
+ * This default constructor is intentionally declared as private to implement the Singleton semantic.
+ */
+ PlayListManager(void);
+
+ /**
+ * This destructor is intentionally declared as private to implement the Singleton semantic.
+ */
+ virtual ~PlayListManager(void);
+
+ /**
+ * This constructor is intentionally declared as private so that only the platform can create an instance.
+ */
+ result Construct(void);
+
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ PlayListManager(const PlayListManager& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ PlayListManager & operator =(const PlayListManager& rhs);
+
+ friend class _PlayListManagerImpl;
+ _PlayListManagerImpl* __pImpl;
+
+ static void InitSingleton(void);
+ static void DestroySingleton(void);
+
+}; // class PlayListManager
+
+}} // Tizen::Content
+
+#endif // _FCNT_CONTENT_PLAYLIST_MANAGER_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntTypes.h
+ * @brief This is the header file for the definitions of constants and enumerators in the Tizen::Content namespace.
+ *
+ * This header file contains definitions for the constants and enumerators in the Tizen::Content namespace.
+ */
+
+#ifndef _FCNT_TYPES_H_
+#define _FCNT_TYPES_H_
+
+namespace Tizen { namespace Base
+{
+class UuId;
+}}
+
+namespace Tizen { namespace Base
+{
+class String;
+}}
+
+namespace Tizen { namespace Content
+{
+
+/**
+ * The content ID.
+ *
+ * @since 2.0
+ */
+typedef Tizen::Base::UuId ContentId;
+
+/**
+ * @enum ContentType
+ *
+ * Defines the content type.
+ *
+ * @since 2.0
+ */
+enum ContentType
+{
+ CONTENT_TYPE_OTHER = 0, /**< Other types */
+ CONTENT_TYPE_IMAGE, /**< An Image */
+ CONTENT_TYPE_AUDIO, /**< An Audio */
+ CONTENT_TYPE_VIDEO, /**< A Video */
+ CONTENT_TYPE_ALL, /**< @if OSPDEPREC The content type: all types @endif */ /**< @if OSPDEPREC @deprecated This enumeration field is deprecated as unified search will not be supported. @endif */
+ CONTENT_TYPE_UNKNOWN /**< An Unknown type */
+};
+
+/**
+ * @enum ImageOrientationType
+ *
+ * Defines the orientation type of an image
+ *
+ * @since 2.0
+ */
+enum ImageOrientationType
+{
+ IMAGE_ORIENTATION_TYPE_UNKNOWN = 0, /**< An Unknown type */
+ IMAGE_ORIENTATION_TYPE_NORMAL, /**< Normal */
+ IMAGE_ORIENTATION_TYPE_FLIP_HORIZONTAL, /**< Flip horizontal */
+ IMAGE_ORIENTATION_TYPE_ROTATE_180, /**< Rotate 180 degree */
+ IMAGE_ORIENTATION_TYPE_FLIP_VERTICAL, /**< Flip vertical */
+ IMAGE_ORIENTATION_TYPE_TRANSPOSE, /**< Transpose */
+ IMAGE_ORIENTATION_TYPE_ROTATE_90, /**< Rotate 90 degree */
+ IMAGE_ORIENTATION_TYPE_TRANSVERSE, /**< Transverse */
+ IMAGE_ORIENTATION_TYPE_ROTATE_270 /**< Rotate 270 degree */
+};
+
+/**
+ * @enum DownloadState
+ *
+ * Defines the download state.
+ *
+ * @since 2.0
+ */
+enum DownloadState
+{
+ DOWNLOAD_STATE_NONE = 0, /**< The download request does not exist */
+ DOWNLOAD_STATE_QUEUED, /**< The download request is listed in a download queue */
+ DOWNLOAD_STATE_DOWNLOADING, /**< The download request is in progress */
+ 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 */
+};
+
+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;
+
+} } // Tizen::Content
+
+#endif // _FCNT_TYPES_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntVideoContentInfo.h
+ * @brief This is the header file for the %VideoContentInfo class.
+ *
+ * This header file contains the declarations of the %VideoContentInfo class.
+ */
+
+#ifndef _FCNT_VIDEO_CONTENT_INFO_H_
+#define _FCNT_VIDEO_CONTENT_INFO_H_
+
+#include <FCntContentInfo.h>
+
+namespace Tizen { namespace Content
+{
+
+class _VideoContentInfoImpl;
+
+/**
+ * @class VideoContentInfo
+ * @brief This class provides methods to access the video content information.
+ *
+ * @since 2.0
+ *
+ * @final This class is not intended for extension.
+ *
+ * The %VideoContentInfo class provides methods to access the video content information that is extracted from a physical file. @n
+ * Before getting the video content information, the ContentManager class must be used to create the content.
+ *
+ * For more information on the different types of content information, see <a href="../org.tizen.native.appprogramming/html/guide/content/device_content_mgmt.htm">Device Content Management</a>.
+ *
+ * The following example demonstrates how to use the %VideoContentInfo class.
+ *
+ * @code
+ * result
+ * MyClass::TestVideoContentInfo(void)
+ * {
+ * result r = E_SUCCESS;
+ *
+ * ContentId contentId;
+ * ContentManager contentManager;
+ * r = contentManager.Construct();
+ * TryReturn(!IsFailed(r), r, "Construct failed.");
+ *
+ * VideoContentInfo videoContentInfo;
+ * r = videoContentInfo.Construct(null);
+ * TryReturn(!IsFailed(r), r, "Construct failed.");
+ *
+ * Tizen::Base::String sourcePath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/flower.wmv";
+ * Tizen::Base::String destPath = Tizen::System::Environment::GetMediaPath() + L"Videos/flower.wmv";
+ *
+ * contentId = contentManager.CreateContent(sourcePath, destPath, false, &videoContentInfo);
+ * TryReturn(Tizen::Base::UuId::GetInvalidUuId() != contentId, GetLastResult(), "CreateContent failed.");
+ *
+ * return r;
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ VideoContentInfo
+ : public Tizen::Content::ContentInfo
+{
+public:
+ /**
+ * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
+ *
+ * @since 2.0
+ *
+ * @remarks After creating an instance of this class, the Construct() method must be called explicitly to initialize this instance.
+ */
+ VideoContentInfo(void);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~VideoContentInfo(void);
+
+ /**
+ * Initializes this instance of %VideoContentInfo with the specified parameter.
+ *
+ * @if OSPCOMPAT
+ * @brief <i> [Compatibility] </i>
+ * @endif
+ * @since 2.0
+ * @if OSPCOMPAT
+ * @compatibility This method has compatibility issues with OSP compatible applications. @n
+ * For more information, see @ref CompVideoContentInfoConstructPage "here".
+ * @endif
+ *
+ * @return An error code
+ * @param[in] pContentPath The content path
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_IO An I/O error has occurred.
+ * @exception E_SYSTEM An internal error has occurred.
+ * @remarks The @c pContentPath should start with directory path returned by either Tizen::System::Environment::GetMediaPath() or Tizen::System::Environment::GetExternalStoragePath(). @n
+ * If @c pContentPath is @c null, use ContentManager::CreateContent(const Tizen::Base::ByteBuffer&, const Tizen::Base::String&, const ContentInfo*)
+ * or ContentManager::CreateContent(const Tizen::Base::String&, const Tizen::Base::String&, bool, const ContentInfo*).
+ */
+ result Construct(const Tizen::Base::String* pContentPath);
+
+ /**
+ * @if OSPCOMPAT
+ * @page CompVideoContentInfoConstructPage Compatibility for the file path.
+ * @section CompVideoContentInfoConstructPageIssueSection Issues
+ * The content path argument of this method in OSP compatible applications has the following issues: @n
+ * -# The content path should be a path that begins with an allowed path prefix. @n
+ * For example, L"/Media/Images/flower.jpg", L"/Storagecard/Media/Images/flower.jpg".
+ *
+ * @section CompVideoContentInfoConstructPageSolutionSection Resolutions
+ * This issue has been resolved in Tizen. @n
+ * -# The content path can be a path without a specific allowed path prefix. @n
+ * Application do not need to know the specific allowed path prefixes. @n
+ * To get the directory path, use the following methods: @n
+ * - For accessing the media directory, use Tizen::System::Environment::GetMediaPath().
+ * - For accessing the external storage, use Tizen::System::Environment::GetExternalStoragePath().
+ *
+ * @endif
+ */
+
+ /**
+ * @if OSPDEPREC
+ * Initializes this instance of %VideoContentInfo with the specified parameters.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This method is deprecated as there is a problem in managing the user-defined thumbnail and device coordinates. @n
+ * Instead of using this method, use Construct(const Tizen::Base::String*). @n
+ * To set the coordinates in the ContentInfo instance, use ContentInfo::SetCoordinates(const Tizen::Locations::Coordinates&).
+ * @since 2.0
+ *
+ * @return An error code
+ * @param[in] contentPath The content path
+ * @param[in] thumbnailPath The thumbnail path
+ * @param[in] setGps Set to @c true to save the device's last known coordinates in the ContentInfo instance, @n
+ * else @c false @n
+ * The coordinate information may be incorrect if it is outdated or has never been updated. @n
+ * To update the coordinate information or to get the exact value,
+ * use Tizen::Locations::LocationProvider::RequestLocationUpdates() before calling this method.
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @exception E_IO An I/O error has occurred.
+ * @remarks The content path must start with @c '/Media' or @c '/Storagecard/Media'. @n
+ * The thumbnail path must start with @c '/Home', @c '/Media', or @c '/Storagecard/Media'. @n
+ * The permitted format for a thumbnail image is bitmap (bmp).
+ * @endif
+ */
+ virtual result Construct(const Tizen::Base::String& contentPath, const Tizen::Base::String& thumbnailPath = L"", bool setGps = false);
+
+ /**
+ * Gets the genre of the video file.
+ *
+ * @since 2.0
+ *
+ * @return The genre of the video file, @n
+ * else @c Unknown if the value is empty
+ */
+ Tizen::Base::String GetGenre(void) const;
+
+ /**
+ * Gets the artist of the video file.
+ *
+ * @since 2.0
+ *
+ * @return The artist of the video file, @n
+ * else @c Unknown if the value is empty
+ */
+ Tizen::Base::String GetArtist(void) const;
+
+ /**
+ * @if OSPDEPREC
+ * Gets the bit rate of the video file.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This method is deprecated because a new method has been added. @n
+ * Instead of using this method, use GetAudioBitrate() or GetVideoBitrate().
+ * @since 2.0
+ *
+ * @return The bit rate in bits per second (bps)
+ * @remarks There are two kinds of bit rates in a video file: audio and video. @n
+ * The return value is the bit rate for the audio.
+ * @endif
+ */
+ int GetBitrate(void) const;
+
+ /**
+ * Gets the audio bit rate of the video file.
+ *
+ * @since 2.0
+ *
+ * @return The audio bit rate in bits per second (bps)
+ */
+ int GetAudioBitrate(void) const;
+
+ /**
+ * Gets the video bit rate of the video file.
+ *
+ * @since 2.0
+ *
+ * @return The video bit rate in bits per second (bps)
+ */
+ int GetVideoBitrate(void) const;
+
+ /**
+ * Gets the frame rate of the video file.
+ *
+ * @since 2.0
+ *
+ * @return The frame rate of the video file
+ */
+ int GetFramerate(void) const;
+
+ /**
+ * Gets the width of the video file.
+ *
+ * @since 2.0
+ *
+ * @return The width of the video file
+ */
+ int GetWidth(void) const;
+
+ /**
+ * Gets the height of the video file.
+ *
+ * @since 2.0
+ *
+ * @return The height of the video file
+ */
+ int GetHeight(void) const;
+
+ /**
+ * Gets the title of the video file.
+ *
+ * @since 2.0
+ *
+ * @return The title of the video file, @n
+ * else @c Unknown if the value is empty
+ */
+ Tizen::Base::String GetTitle(void) const;
+
+ /**
+ * Gets the album name of the video file.
+ *
+ * @since 2.0
+ *
+ * @return The album name of the video file, @n
+ * else @c Unknown if the value is empty
+ */
+ Tizen::Base::String GetAlbumName(void) const;
+
+ /**
+ * Gets the duration of the video file.
+ *
+ * @since 2.0
+ *
+ * @return The duration of the video file in milliseconds
+ */
+ long GetDuration(void) const;
+
+private:
+ class _VideoContentData
+ {
+ public:
+ _VideoContentData()
+ : width(0)
+ , height(0)
+ , framerate(0)
+ , audioBitrate(0)
+ , videoBitrate(0)
+ , duration(0)
+ , pArtist(null)
+ , pGenre(null)
+ , pTitle(null)
+ , pAlbumName(null) {}
+
+ int width;
+ int height;
+ int framerate;
+ int audioBitrate;
+ int videoBitrate;
+ long duration;
+ Tizen::Base::String* pArtist;
+ Tizen::Base::String* pGenre;
+ Tizen::Base::String* pTitle;
+ Tizen::Base::String* pAlbumName;
+ };
+
+ /**
+ * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ VideoContentInfo(const VideoContentInfo& rhs);
+
+ /**
+ * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
+ */
+ VideoContentInfo& operator =(const VideoContentInfo& rhs);
+
+ result SetVideoContentData(const _VideoContentData* pVideoContentData);
+
+ _VideoContentData* GetVideoContentData(void);
+
+ result GetVideoMetadata(void) const;
+
+private:
+ _VideoContentData* __pVideoContentData;
+
+ friend class _ContentManagerImpl;
+ friend class _ContentSearchImpl;
+ friend class _ContentDirectoryImpl;
+ friend class _ContentUtility;
+ friend class _PlayListManagerImpl;
+ friend class _PlayListImpl;
+
+ friend class _VideoContentInfoImpl;
+ _VideoContentInfoImpl* __pImpl;
+
+}; // Class VideoContentInfo
+
+}} // Tizen::Content
+
+#endif // _FCNT_VIDEO_CONTENT_INFO_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntVideoMetadata.h
+ * @brief This is the header file for the %VideoMetadata class.
+ *
+ * This header file contains the declarations of the %VideoMetadata class.
+ */
+
+#ifndef _FCNT_VIDEO_METADATA_H_
+#define _FCNT_VIDEO_METADATA_H_
+
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Graphics
+{
+class Bitmap;
+}}
+
+namespace Tizen { namespace Content
+{
+
+class _VideoMetadataImpl;
+
+/**
+ * @class VideoMetadata
+ * @brief This class provides methods to access the video metadata.
+ *
+ * @since 2.0
+ *
+ * The %VideoMetadata class provides methods to access the video metadata that contains video content-specific attributes.
+ *
+ * The following example demonstrates how to use the %VideoMetadata class.
+ *
+ * @code
+ * result
+ * MyClass::TestVideoMetadata(void)
+ * {
+ * Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Videos/video.mp4";
+ * VideoMetadata* pVideoMeta = ContentManagerUtil::GetVideoMetaN(contentPath);
+ * TryReturn(pVideoMeta != null, GetLastResult(), "ContentManagerUtil::GetVideoMetaN failed.");
+ *
+ * // Width
+ * pVideoMeta->GetWidth();
+ *
+ * // Height
+ * pVideoMeta->GetHeight();
+ *
+ * // Duration
+ * pVideoMeta->GetDuration();
+ *
+ * delete pVideoMeta;
+ *
+ * return E_SUCCESS;
+ * }
+ * @endcode
+ */
+class _OSP_EXPORT_ VideoMetadata
+ : virtual public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.0
+ */
+ VideoMetadata(void);
+
+ /**
+ * Copying of objects using this copy constructor is allowed.
+ *
+ * @since 2.0
+ *
+ * @param[in] rhs An instance of %VideoMetadata
+ */
+ VideoMetadata(const VideoMetadata& rhs);
+
+ /**
+ * This destructor overrides Tizen::Base::Object::~Object().
+ *
+ * @since 2.0
+ */
+ virtual ~VideoMetadata(void);
+
+ /**
+ * Gets the width.
+ *
+ * @since 2.0
+ *
+ * @return The width
+ */
+ int GetWidth(void) const;
+
+ /**
+ * Gets the height.
+ *
+ * @since 2.0
+ *
+ * @return The height
+ */
+ int GetHeight(void) const;
+
+ /**
+ * Gets the duration.
+ *
+ * @since 2.0
+ *
+ * @return The duration in milliseconds
+ */
+ long GetDuration(void) const;
+
+ /**
+ * Gets the frame rate.
+ *
+ * @since 2.0
+ *
+ * @return The frame rate
+ */
+ int GetFramerate(void) const;
+
+ /**
+ * @if OSPDEPREC
+ * Gets the bit rate.
+ *
+ * @brief <i> [Deprecated] </i>
+ * @deprecated This method is deprecated because a new method has been added. @n
+ * Instead of using this method, use GetAudioBitrate() or GetVideoBitrate().
+ * @since 2.0
+ * @endif
+ *
+ * @return The bit rate in bits per second (bps)
+ * @remarks There are two kinds of bit rates in a video file: audio and video. @n
+ * The return value is the bit rate for the audio.
+ */
+ int GetBitrate(void) const;
+
+ /**
+ * Gets the audio bit rate.
+ *
+ * @since 2.0
+ *
+ * @return The audio bit rate in bits per second (bps)
+ */
+ int GetAudioBitrate(void) const;
+
+ /**
+ * Gets the video bit rate.
+ *
+ * @since 2.0
+ *
+ * @return The video bit rate in bits per second (bps)
+ */
+ int GetVideoBitrate(void) const;
+
+ /**
+ * Gets the genre.
+ *
+ * @since 2.0
+ *
+ * @return The genre
+ */
+ Tizen::Base::String GetGenre(void) const;
+
+ /**
+ * Gets the album art of the video.
+ *
+ * @since 2.0
+ *
+ * @return A pointer to the album art
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_DATA_NOT_FOUND The album art does not exist.
+ * @exception E_OUT_OF_MEMORY The memory is insufficient.
+ * @remarks The specific error code can be accessed using the GetLastResult() method.
+ */
+ Tizen::Graphics::Bitmap* GetAlbumArtN(void) const;
+
+ /**
+ * Compares the equality of values between two %VideoMetadata objects by overriding the Tizen::Base::Object::Equals() method.
+ *
+ * @since 2.0
+ *
+ * @return @c true if all the fields in the objects are equal, @n
+ * else @c false
+ * @param[in] rhs The Tizen::Base::Object with which the comparison is done
+ * @remarks An instance of Tizen::Graphics::Bitmap is not taken into account in the comparisons.
+ */
+ virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+ /**
+ * Gets the hash value of the current instance by overriding the Tizen::Base::Object::GetHashCode() method.
+ *
+ * @since 2.0
+ *
+ * @return The hash value of the current instance
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * Copying of objects using this copy assignment operator is allowed.
+ *
+ * @since 2.0
+ *
+ * @return A reference to this instance
+ * @param[in] rhs An instance of %VideoMetadata
+ */
+ VideoMetadata& operator =(const VideoMetadata& rhs);
+
+private:
+ friend class _VideoMetadataImpl;
+ _VideoMetadataImpl* __pImpl;
+
+}; // Class VideoMetadata
+
+}} // Tizen::Content
+
+#endif // _FCNT_VIDEO_METADATA_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FContent.h
+ * @brief This is the header file for the %Tizen::Content namespace.
+ *
+ * This header file contains the declarations and descriptions of the %Tizen::Content namespace.
+ */
+
+#ifndef _FCNT_H_
+#define _FCNT_H_
+
+#include <FCntContentInfo.h>
+#include <FCntImageContentInfo.h>
+#include <FCntAudioContentInfo.h>
+#include <FCntVideoContentInfo.h>
+#include <FCntOtherContentInfo.h>
+#include <FCntContentManager.h>
+#include <FCntContentManagerUtil.h>
+#include <FCntImageMetadata.h>
+#include <FCntAudioMetadata.h>
+#include <FCntVideoMetadata.h>
+#include <FCntContentSearch.h>
+#include <FCntContentDirectory.h>
+#include <FCntPlayList.h>
+#include <FCntPlayListManager.h>
+#include <FCntContentSearchResult.h>
+#include <FCntContentTransfer.h>
+#include <FCntContentTransferInfo.h>
+#include <FCntIContentTransferListener.h>
+#include <FCntIContentScanListener.h>
+#include <FCntDownloadRequest.h>
+#include <FCntDownloadManager.h>
+#include <FCntIDownloadListener.h>
+
+namespace Tizen
+{
+
+/**
+ * @namespace Tizen::Content
+ * @brief This namespace contains classes and interfaces for content management and search services.
+ * @since 2.0
+ *
+ * @remarks @b Header @b %file: @b \#include @b <FContent.h> @n
+ * @b Library : @b osp-content
+ *
+ * The %Content namespace contains classes for managing the most common media data types, such as image, audio, and video on the device. This namespace also provides operations to search content and content information stored on the device, and to download content from servers through HTTP access.
+ *
+ * For more information on the %Content namespace features, see <a href="../org.tizen.native.appprogramming/html/guide/content/content_namespace.htm">Content Guide</a>.
+ *
+ * The following diagram illustrates the relationships between the classes belonging to the %Content namespace.
+ * @image html content_using_the_apis_classdiagram.png
+ */
+
+namespace Content
+{
+}} // Tizen::Content
+
+#endif // _FCNT_H_
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
\ No newline at end of file
--- /dev/null
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib/osp
+includedir=/usr/include/osp
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
+
--- /dev/null
+%define debug_package %{nil}
+%define __strip /bin/true
+
+Name: osp-content
+Summary: osp content library
+Version: 1.2.0.0
+Release: 2
+Group: System/Libraries
+License: Apache License, Version 2.0
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: cmake
+BuildRequires: pkgconfig(alarm-service)
+BuildRequires: pkgconfig(chromium)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(capi-content-media-content)
+BuildRequires: pkgconfig(capi-media-metadata-extractor)
+BuildRequires: pkgconfig(capi-content-mime-type)
+BuildRequires: pkgconfig(capi-web-url-download)
+BuildRequires: pkgconfig(osp-appfw)
+BuildRequires: osp-appfw-internal-devel
+BuildRequires: pkgconfig(osp-net)
+BuildRequires: osp-net-internal-devel
+BuildRequires: pkgconfig(osp-uifw)
+BuildRequires: osp-uifw-internal-devel
+BuildRequires: pkgconfig(osp-media)
+BuildRequires: osp-media-internal-devel
+BuildRequires: pkgconfig(osp-image-core)
+BuildRequires: osp-image-core-internal-devel
+BuildRequires: pkgconfig(osp-image)
+BuildRequires: osp-image-internal-devel
+BuildRequires: pkgconfig(osp-locations)
+BuildRequires: libexif-devel
+BuildRequires: libcurl-devel
+BuildRequires: openssl-devel
+
+# runtime requires
+Requires: osp-appfw
+Requires: osp-net
+Requires: osp-image
+Requires: osp-media
+Requires: osp-uifw
+Requires: osp-locations
+Requires: capi-web-url-download
+
+Requires(post): /sbin/ldconfig
+Requires(post): coreutils
+Requires(postun): /sbin/ldconfig
+
+%description
+osp content library
+
+%package devel
+Summary: osp content library (Development)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+osp content library (DEV)
+
+%package internal-devel
+Summary: osp content library (Internal)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description internal-devel
+osp content library (Internal-DEV)
+
+%package debug
+Summary: osp content library (Development)
+Group: TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description debug
+osp content library (DEV)
+
+%prep
+%setup -q
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%ifarch %{ix86}
+CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%else
+CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%endif
+
+# Call make instruction with smp support
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/usr/share/license
+cp %{_builddir}/%{name}-%{version}/LICENSE.APLv2 %{buildroot}/usr/share/license/%{name}
+
+%make_install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest osp-content.manifest
+/usr/share/license/%{name}
+%{_libdir}/osp/*.so*
+
+%files devel
+%{_includedir}/osp/*.h
+%{_libdir}/pkgconfig/osp-content.pc
+
+%files internal-devel
+%{_includedir}/osp/content/*.h
+
+%files debug
+%{_libdir}/osp/debug/*.so*
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntAudioContentInfo.cpp
+ * @brief This is the implementation file for the %AudioContentInfo class.
+ *
+ * This file contains implementation of the %AudioContentInfo class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FCntAudioContentInfo.h>
+#include <FIoFile.h>
+#include <FIoDirectory.h>
+#include <FSysEnvironment.h>
+//#include <FLocLocationProvider.h>
+//#include <FLocQualifiedCoordinates.h>
+#include <FIo_FileImpl.h>
+#include <FApp_AppInfo.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Locations;
+using namespace Tizen::App;
+using namespace Tizen::System;
+using namespace std;
+
+namespace Tizen { namespace Content
+{
+
+AudioContentInfo::AudioContentInfo(void)
+ : ContentInfo()
+ , __pAudioContentData(null)
+ , __pImpl(null)
+{
+
+}
+
+AudioContentInfo::~AudioContentInfo(void)
+{
+ if (__pAudioContentData != null)
+ {
+ if (__pAudioContentData->pTitle != null)
+ {
+ delete __pAudioContentData->pTitle;
+ __pAudioContentData->pTitle = null;
+ }
+ if (__pAudioContentData->pAlbumName != null)
+ {
+ delete __pAudioContentData->pAlbumName;
+ __pAudioContentData->pAlbumName = null;
+ }
+ if (__pAudioContentData->pArtist != null)
+ {
+ delete __pAudioContentData->pArtist;
+ __pAudioContentData->pArtist = null;
+ }
+ if (__pAudioContentData->pComposer != null)
+ {
+ delete __pAudioContentData->pComposer;
+ __pAudioContentData->pComposer = null;
+ }
+ if (__pAudioContentData->pGenre != null)
+ {
+ delete __pAudioContentData->pGenre;
+ __pAudioContentData->pGenre = null;
+ }
+ if (__pAudioContentData->pCopyright != null)
+ {
+ delete __pAudioContentData->pCopyright;
+ __pAudioContentData->pCopyright = null;
+ }
+ if (__pAudioContentData->pTrackInfo != null)
+ {
+ delete __pAudioContentData->pTrackInfo;
+ __pAudioContentData->pTrackInfo = null;
+ }
+
+ delete __pAudioContentData;
+ __pAudioContentData = null;
+ }
+}
+
+/**
+ * E_SUCCESS
+ * E_FILE_NOT_FOUND
+ * E_INVALID_ARG
+ * E_OUT_OF_MEMORY
+ * - E_IO
+ */
+result
+AudioContentInfo::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
+{
+ ClearLastResult();
+
+ SysAssertf(__pAudioContentData == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ result r = E_SUCCESS;
+ _ContentData contentData;
+ int contentLength = 0;
+ FileAttributes attribute;
+
+ // checks parameters
+ contentLength = contentPath.GetLength();
+ SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
+ "The contentPath should start with /Media or /Storagecard/Media(%ls).", contentPath.GetPointer());
+ SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
+ "The file corresponding to contentPath could not be found.");
+
+ if (!thumbnailPath.IsEmpty())
+ {
+ SysLog(NID_CNT,
+ "The thumbnailPath is not supported but you can get the thumbnail managed by Tizen from ContentInfo::GetThumbnailN().");
+ }
+
+ if (setGps)
+ {
+ SysLog(NID_CNT, "The setGps is not supported.");
+ }
+
+ // Sets the content path
+ contentData.contentPath = contentPath;
+
+ // Sets the content type
+ contentData.contentType = CONTENT_TYPE_AUDIO;
+
+ // E_INVALID_ARG, E_OUT_OF_MEMORY
+ r = SetContentData(&contentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");
+
+ _AudioContentData* pAudioContentData = new (nothrow) _AudioContentData();
+ SysTryReturnResult(NID_CNT, pAudioContentData != null, E_OUT_OF_MEMORY, "Construct() failed.");
+
+ __pAudioContentData = pAudioContentData;
+
+ return r;
+}
+
+/**
+ * E_SUCCESS
+ * E_FILE_NOT_FOUND
+ * E_INVALID_ARG
+ * E_OUT_OF_MEMORY
+ * - E_IO
+ * - E_SYSTEM
+ */
+result
+AudioContentInfo::Construct(const String* pContentPath)
+{
+ ClearLastResult();
+
+ SysAssertf(__pAudioContentData == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ result r = E_SUCCESS;
+ _ContentData contentData;
+
+ if (pContentPath != null)
+ {
+ if (!_AppInfo::IsOspCompat())
+ {
+ if (pContentPath->StartsWith(OSP_MEDIA_PHONE, 0) || pContentPath->StartsWith(OSP_MEDIA_MMC, 0))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] /Media/ and /Storagecard/Media/ are not supported from Tizen 2.0.");
+ return E_INVALID_ARG;
+ }
+ if (!(pContentPath->StartsWith(Environment::GetMediaPath(), 0)
+ || pContentPath->StartsWith(Environment::GetExternalStoragePath(), 0)))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] %ls is not supported.", pContentPath->GetPointer());
+ return E_INVALID_ARG;
+ }
+ }
+ else
+ {
+ // prior to 2.0
+ if (pContentPath->StartsWith(OSP_MEDIA_PHONE, 0))
+ {
+ // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
+ // it should be converted in 2.0.
+ r = (const_cast<String*>(pContentPath))->Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+ }
+ else if (pContentPath->StartsWith(OSP_MEDIA_MMC, 0))
+ {
+ r = (const_cast<String*>(pContentPath))->Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
+ return E_INVALID_ARG;
+ }
+ }
+
+ int length = pContentPath->GetLength();
+ SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG,
+ "The length of pContentPath is 0.");
+ SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND,
+ "The file corresponding to pContentPath could not be found.");
+
+ // Sets the content path
+ contentData.contentPath = *pContentPath;
+
+ // Sets the content type
+ contentData.contentType = CONTENT_TYPE_AUDIO;
+
+ r = SetContentData(&contentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");
+ }
+ else
+ {
+ contentData.contentType = CONTENT_TYPE_AUDIO;
+
+ r = SetContentData(&contentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");
+ }
+
+ _AudioContentData* pAudioContentData = new (nothrow) _AudioContentData();
+ SysTryReturnResult(NID_CNT, pAudioContentData != null, E_OUT_OF_MEMORY, "Construct() failed.");
+
+ __pAudioContentData = pAudioContentData;
+
+ return r;
+}
+
+/**
+ * E_SUCCESS
+ * E_INVALID_ARG
+ * E_OUT_OF_MEMORY
+ */
+result
+AudioContentInfo::SetAudioContentData(const _AudioContentData* pAudioContentData)
+{
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, pAudioContentData != null, E_INVALID_ARG, "pAudioContentData is null.");
+
+ if (__pAudioContentData == null)
+ {
+ __pAudioContentData = new (nothrow) _AudioContentData;
+ SysTryReturnResult(NID_CNT, __pAudioContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+
+ __pAudioContentData->bitrate = pAudioContentData->bitrate;
+ __pAudioContentData->releaseYear = pAudioContentData->releaseYear;
+ __pAudioContentData->duration = pAudioContentData->duration;
+
+ if (pAudioContentData->pTitle != null)
+ {
+ __pAudioContentData->pTitle = new (nothrow) String(*(pAudioContentData->pTitle));
+ SysTryReturnResult(NID_CNT, __pAudioContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioContentData->pAlbumName != null)
+ {
+ __pAudioContentData->pAlbumName = new (nothrow) String(*(pAudioContentData->pAlbumName));
+ SysTryReturnResult(NID_CNT, __pAudioContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioContentData->pArtist != null)
+ {
+ __pAudioContentData->pArtist = new (nothrow) String(*(pAudioContentData->pArtist));
+ SysTryReturnResult(NID_CNT, __pAudioContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioContentData->pComposer != null)
+ {
+ __pAudioContentData->pComposer = new (nothrow) String(*(pAudioContentData->pComposer));
+ SysTryReturnResult(NID_CNT, __pAudioContentData->pComposer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioContentData->pGenre != null)
+ {
+ __pAudioContentData->pGenre = new (nothrow) String(*(pAudioContentData->pGenre));
+ SysTryReturnResult(NID_CNT, __pAudioContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioContentData->pCopyright != null)
+ {
+ __pAudioContentData->pCopyright = new (nothrow) String(*(pAudioContentData->pCopyright));
+ SysTryReturnResult(NID_CNT, __pAudioContentData->pCopyright != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioContentData->pTrackInfo != null)
+ {
+ __pAudioContentData->pTrackInfo = new (nothrow) String(*(pAudioContentData->pTrackInfo));
+ SysTryReturnResult(NID_CNT, __pAudioContentData->pTrackInfo != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+
+ return E_SUCCESS;
+}
+
+AudioContentInfo::_AudioContentData*
+AudioContentInfo::GetAudioContentData(void)
+{
+ if (__pAudioContentData == null)
+ {
+ __pAudioContentData = new (nothrow) AudioContentInfo::_AudioContentData;
+ SysTryReturn(NID_CNT, __pAudioContentData != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ return __pAudioContentData;
+}
+
+String
+AudioContentInfo::GetGenre(void) const
+{
+ SysAssertf(__pAudioContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pAudioContentData->pGenre == null)
+ {
+ SysLog(NID_CNT, "GetGenre() failed.");
+ return String(L"Unknown");
+ }
+
+ return *(__pAudioContentData->pGenre);
+}
+
+String
+AudioContentInfo::GetArtist(void) const
+{
+ SysAssertf(__pAudioContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pAudioContentData->pArtist == null)
+ {
+ SysLog(NID_CNT, "GetArtist() failed.");
+ return String(L"Unknown");
+ }
+
+ return *(__pAudioContentData->pArtist);
+}
+
+String
+AudioContentInfo::GetComposer(void) const
+{
+ SysAssertf(__pAudioContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pAudioContentData->pComposer == null)
+ {
+ SysLog(NID_CNT, "GetComposer() failed.");
+ return String(L"Unknown");
+ }
+
+ return *(__pAudioContentData->pComposer);
+}
+
+String
+AudioContentInfo::GetAlbumName(void) const
+{
+ SysAssertf(__pAudioContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pAudioContentData->pAlbumName == null)
+ {
+ SysLog(NID_CNT, "GetAlbumName() failed.");
+ return String(L"Unknown");
+ }
+
+ return *(__pAudioContentData->pAlbumName);
+}
+
+int
+AudioContentInfo::GetReleaseYear(void) const
+{
+ SysAssertf(__pAudioContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pAudioContentData->releaseYear;
+}
+
+int
+AudioContentInfo::GetBitrate(void) const
+{
+ SysAssertf(__pAudioContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pAudioContentData->bitrate;
+}
+
+String
+AudioContentInfo::GetTitle(void) const
+{
+ SysAssertf(__pAudioContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pAudioContentData->pTitle == null)
+ {
+ SysLog(NID_CNT, "GetTitle() failed.");
+ return String(L"Unknown");
+ }
+
+ return *(__pAudioContentData->pTitle);
+}
+
+String
+AudioContentInfo::GetCopyright(void) const
+{
+ SysAssertf(__pAudioContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pAudioContentData->pCopyright == null)
+ {
+ SysLog(NID_CNT, "GetCopyright() failed.");
+ return String(L"Unknown");
+ }
+
+ return *(__pAudioContentData->pCopyright);
+}
+
+String
+AudioContentInfo::GetTrackInfo(void) const
+{
+ SysAssertf(__pAudioContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pAudioContentData->pTrackInfo == null)
+ {
+ SysLog(NID_CNT, "GetTrackInfo() failed.");
+ return String(L"Unknown");
+ }
+
+ return *(__pAudioContentData->pTrackInfo);
+}
+
+long
+AudioContentInfo::GetDuration(void) const
+{
+ SysAssertf(__pAudioContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pAudioContentData->duration;
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntAudioMetadata.cpp
+ * @brief This is the implementation file for the %AudioMetadata class.
+ *
+ * This file contains implementation of the %AudioMetadata class.
+ */
+
+// includes
+#include <FBaseSysLog.h>
+#include <FCntAudioMetadata.h>
+#include <FCnt_AudioMetadataImpl.h>
+
+// using namespaces
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Content
+{
+
+AudioMetadata::AudioMetadata(void)
+ : Object()
+ , __pImpl(new (std::nothrow) _AudioMetadataImpl())
+{
+
+}
+
+AudioMetadata::~AudioMetadata(void)
+{
+ if (__pImpl != null)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+AudioMetadata::AudioMetadata(const AudioMetadata& rhs)
+ : Tizen::Base::Object()
+ , __pImpl(new (std::nothrow) _AudioMetadataImpl(*rhs.__pImpl))
+{
+
+}
+
+AudioMetadata&
+AudioMetadata::operator =(const AudioMetadata& rhs)
+{
+ // check for self-assignment
+ if (this == &rhs)
+ {
+ return *this;
+ }
+
+ *__pImpl = *rhs.__pImpl;
+
+ return *this;
+}
+
+int
+AudioMetadata::GetHashCode(void) const
+{
+ return __pImpl->GetHashCode();
+}
+
+bool
+AudioMetadata::Equals(const Object& rhs) const
+{
+ const AudioMetadata* pRhs = dynamic_cast <const AudioMetadata*>(&rhs);
+ if (pRhs == null)
+ {
+ return false;
+ }
+
+ return __pImpl->Equals(*pRhs->__pImpl);
+}
+
+String
+AudioMetadata::GetTitle(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetTitle();
+}
+
+int
+AudioMetadata::GetBitrate(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetBitrate();
+}
+
+int
+AudioMetadata::GetFrequency(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetFrequency();
+}
+
+String
+AudioMetadata::GetArtist(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetArtist();
+}
+
+String
+AudioMetadata::GetAlbumName(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetAlbumName();
+}
+
+String
+AudioMetadata::GetComment(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetComment();
+}
+
+int
+AudioMetadata::GetTrack(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetTrack();
+}
+
+String
+AudioMetadata::GetGenre(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetGenre();
+}
+
+String
+AudioMetadata::GetComposer(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetComposer();
+}
+
+String
+AudioMetadata::GetCopyright(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetCopyright();
+}
+
+long
+AudioMetadata::GetDuration(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetDuration();
+}
+
+int
+AudioMetadata::GetYear(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetYear();
+}
+
+String
+AudioMetadata::GetTrackInfo(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetTrackInfo();
+}
+
+String
+AudioMetadata::GetRecordingDate(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetRecordingDate();
+}
+
+int
+AudioMetadata::GetChannelCount(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetChannelCount();
+}
+
+/**
+ * E_SUCCESS
+ * E_DATA_NOT_FOUND
+ * E_OUT_OF_MEMORY
+ */
+Bitmap*
+AudioMetadata::GetThumbnailN(void) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ Bitmap* pBitmap = null;
+ SysTryReturn(NID_CNT, __pImpl != null, null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] GetThumbnailN failed.");
+
+ pBitmap = __pImpl->GetThumbnailN();
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, pBitmap != null, null, r, "[%s] GetThumbnailN failed.", GetErrorMessage(r));
+
+ return pBitmap;
+}
+
+/**
+ * E_SUCCESS
+ * E_DATA_NOT_FOUND
+ * E_OUT_OF_MEMORY
+ */
+Bitmap*
+AudioMetadata::GetAlbumArtN(void) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ Bitmap* pBitmap = null;
+
+ SysTryReturn(NID_CNT, __pImpl != null, null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] GetAlbumArtN failed.");
+
+ pBitmap = __pImpl->GetAlbumArtN();
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, pBitmap != null, null, r, "[%s] GetAlbumArtN failed.", GetErrorMessage(r));
+
+ return pBitmap;
+}
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentDirectory.cpp
+ * @brief This is the implementation file for the %ContentDirectory class.
+ *
+ * This is the implementation file for %ContentDirectory class.
+ */
+
+// includes
+#include <FBaseSysLog.h>
+#include <FCntContentDirectory.h>
+#include <FBaseColIList.h>
+#include <FIoFile.h>
+#include <FCnt_ContentDirectoryImpl.h>
+
+using namespace Tizen::Io;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Content
+{
+
+ContentDirectory::ContentDirectory(void)
+ : Object()
+ , __pImpl(null)
+{
+}
+
+ContentDirectory::~ContentDirectory(void)
+{
+ if (__pImpl != null)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+result
+ContentDirectory::Construct(ContentType type)
+{
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ SysTryReturnResult(NID_CNT, type != CONTENT_TYPE_UNKNOWN && type != CONTENT_TYPE_ALL, E_INVALID_ARG, "Construct failed.");
+
+ _ContentDirectoryImpl* pContentDirectoryImpl = new (std::nothrow) _ContentDirectoryImpl();
+ SysTryReturnResult(NID_CNT, pContentDirectoryImpl != null, E_OUT_OF_MEMORY, "Construct failed.");
+
+ r = pContentDirectoryImpl->Construct(type);
+ SysTryCatch(NID_CNT, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Construct failed.");
+
+ __pImpl = pContentDirectoryImpl;
+
+ return E_SUCCESS;;
+
+CATCH:
+ if (pContentDirectoryImpl != NULL)
+ {
+ delete pContentDirectoryImpl;
+ pContentDirectoryImpl = null;
+ }
+ return r;
+}
+
+result
+ContentDirectory::Construct(const Tizen::Base::Collection::IListT<ContentType>& contentTypeList)
+{
+ result r = E_SUCCESS;
+ ContentType type = CONTENT_TYPE_UNKNOWN;
+ int listCount = contentTypeList.GetCount();
+
+ SysAssertf(__pImpl == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ SysTryReturnResult(NID_CNT, ((listCount > MIN_CONTENTTYPE_LIST_COUNT) && (listCount < MAX_CONTENTTYPE_LIST_COUNT)), E_INVALID_ARG, "Construct failed.");
+
+ for(int index = 0; index < listCount; index++)
+ {
+ contentTypeList.GetAt(index, type);
+ SysTryReturnResult(NID_CNT, type != CONTENT_TYPE_UNKNOWN && type != CONTENT_TYPE_ALL, E_INVALID_ARG, "Construct failed.");
+ }
+
+ _ContentDirectoryImpl* pContentDirectoryImpl = new (std::nothrow) _ContentDirectoryImpl();
+ SysTryReturnResult(NID_CNT, pContentDirectoryImpl != null, E_OUT_OF_MEMORY, "Construct failed.");
+
+ if (listCount == CONTENTTYPE_LIST_COUNT_ONE)
+ {
+ r = pContentDirectoryImpl->Construct(type);
+ SysTryCatch(NID_CNT, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Construct failed.");
+ }
+ else
+ {
+ r = pContentDirectoryImpl->Construct(contentTypeList);
+ SysTryCatch(NID_CNT, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Construct failed.");
+ }
+
+ __pImpl = pContentDirectoryImpl;
+
+ return E_SUCCESS;;
+
+CATCH:
+ if (pContentDirectoryImpl != NULL)
+ {
+ delete pContentDirectoryImpl;
+ pContentDirectoryImpl = null;
+ }
+ return r;
+}
+
+int
+ContentDirectory::GetContentDirectoryCount(void) const
+{
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->GetContentDirectoryCount();
+}
+
+IList*
+ContentDirectory::GetContentDirectoryPathListN(Tizen::Base::SortOrder sortOrder) const
+{
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->GetContentDirectoryPathListN(sortOrder);
+}
+
+int
+ContentDirectory::GetContentDirectoryItemCount(const Tizen::Base::String& contentDirectoryPath) const
+{
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ SysTryReturn(NID_CNT, !contentDirectoryPath.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The contentDirectoryPath is empty.");
+
+ SysTryReturn(NID_CNT, File::IsFileExist(contentDirectoryPath) == true, null, E_INVALID_ARG, "[E_INVALID_ARG] The contentDirectoryPath doesn't exist.");
+
+ return __pImpl->GetContentDirectoryItemCount(contentDirectoryPath);
+}
+
+IList*
+ContentDirectory::GetContentDirectoryItemListN(const Tizen::Base::String& contentDirectoryPath, int pageNo, int countPerPage,
+ const Tizen::Base::String& column, Tizen::Base::SortOrder sortOrder) const
+{
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ if(sortOrder != SORT_ORDER_NONE)
+ {
+ SysTryReturn(NID_CNT, !column.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The column name is empty.");
+ }
+
+ SysTryReturn(NID_CNT, pageNo > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] pageNo <=0: GetContentDirectoryItemListN failed.");
+
+ SysTryReturn(NID_CNT, countPerPage > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] countPerPage <=0: GetContentDirectoryItemListN failed.");
+
+ SysTryReturn(NID_CNT, !contentDirectoryPath.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The contentDirectoryPath is empty.");
+
+ SysTryReturn(NID_CNT, File::IsFileExist(contentDirectoryPath) == true, null, E_INVALID_ARG, "[E_INVALID_ARG] The contentDirectoryPath doesn't exist.");
+
+ return __pImpl->GetContentDirectoryItemListN(contentDirectoryPath, pageNo, countPerPage, column, sortOrder);
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentInfo.cpp
+ * @brief This is the implementation file for the %ContentInfo class.
+ *
+ * This file contains implementation of the %ContentInfo class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FCntContentInfo.h>
+#include <FCntAudioMetadata.h>
+#include <FCntContentManagerUtil.h>
+#include <FIoFile.h>
+#include <FGrpBitmap.h>
+#include <FMediaImage.h>
+#include <FApp_AppInfo.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Locations;
+using namespace Tizen::Graphics;
+using namespace Tizen::Media;
+using namespace Tizen::App;
+using namespace std;
+
+namespace Tizen { namespace Content
+{
+
+static const int THUMBNAIL_IMAGE_WIDTH = 80;
+static const int THUMBNAIL_IMAGE_HEIGHT = 60;
+static const int MAX_CUSTOM_FIELD_COMMON = 45;
+static const int MAX_CUSTOM_FIELD_DESCRIPTION = 140;
+static const double DEFAULT_COORDINATE = -200.0;
+
+ContentInfo::ContentInfo(void)
+ : Object()
+ , __pContentData(null)
+ , __pImpl(null)
+{
+
+}
+
+ContentInfo::~ContentInfo(void)
+{
+ if (__pContentData != null)
+ {
+ if (__pContentData->pThumbnailPath != null)
+ {
+ delete __pContentData->pThumbnailPath;
+ __pContentData->pThumbnailPath = null;
+ }
+ if (__pContentData->pAuthor != null)
+ {
+ delete __pContentData->pAuthor;
+ __pContentData->pAuthor = null;
+ }
+ if (__pContentData->pCategory != null)
+ {
+ delete __pContentData->pCategory;
+ __pContentData->pCategory = null;
+ }
+ if (__pContentData->pContentName)
+ {
+ delete __pContentData->pContentName;
+ __pContentData->pContentName = null;
+ }
+ if (__pContentData->pDescription != null)
+ {
+ delete __pContentData->pDescription;
+ __pContentData->pDescription = null;
+ }
+ if (__pContentData->pKeyword != null)
+ {
+ delete __pContentData->pKeyword;
+ __pContentData->pKeyword = null;
+ }
+ if (__pContentData->pLocationTag != null)
+ {
+ delete __pContentData->pLocationTag;
+ __pContentData->pLocationTag = null;
+ }
+ if (__pContentData->pProvider != null)
+ {
+ delete __pContentData->pProvider;
+ __pContentData->pProvider = null;
+ }
+ if (__pContentData->pRating != null)
+ {
+ delete __pContentData->pRating;
+ __pContentData->pRating = null;
+ }
+
+ delete __pContentData;
+ __pContentData = null;
+ }
+}
+
+result
+ContentInfo::SetContentData(const _ContentData* pContentData)
+{
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, pContentData != null, E_INVALID_ARG, "pContentData is null.");
+
+ if (__pContentData == null)
+ {
+ __pContentData = new (nothrow) _ContentData();
+ SysTryReturnResult(NID_CNT, __pContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+
+ __pContentData->contentId = pContentData->contentId;
+ __pContentData->storageType = pContentData->storageType;
+ __pContentData->contentType = pContentData->contentType;
+ __pContentData->contentSize = pContentData->contentSize;
+ __pContentData->contentPath = pContentData->contentPath;
+ __pContentData->dateTime = pContentData->dateTime;
+ __pContentData->latitude = pContentData->latitude;
+ __pContentData->longitude = pContentData->longitude;
+ __pContentData->altitude = pContentData->altitude;
+ __pContentData->isDrm = pContentData->isDrm;
+
+ if (pContentData->pThumbnailPath != null)
+ {
+ __pContentData->pThumbnailPath = new (nothrow) String(*(pContentData->pThumbnailPath));
+ SysTryReturnResult(NID_CNT, __pContentData->pThumbnailPath != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pContentData->pAuthor != null)
+ {
+ __pContentData->pAuthor = new (nothrow) String(*(pContentData->pAuthor));
+ SysTryReturnResult(NID_CNT, __pContentData->pAuthor != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pContentData->pCategory != null)
+ {
+ __pContentData->pCategory = new (nothrow) String(*(pContentData->pCategory));
+ SysTryReturnResult(NID_CNT, __pContentData->pCategory != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pContentData->pContentName != null)
+ {
+ __pContentData->pContentName = new (nothrow) String(*(pContentData->pContentName));
+ SysTryReturnResult(NID_CNT, __pContentData->pContentName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pContentData->pDescription != null)
+ {
+ __pContentData->pDescription = new (nothrow) String(*(pContentData->pDescription));
+ SysTryReturnResult(NID_CNT, __pContentData->pDescription != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pContentData->pKeyword != null)
+ {
+ __pContentData->pKeyword = new (nothrow) String(*(pContentData->pKeyword));
+ SysTryReturnResult(NID_CNT, __pContentData->pKeyword != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pContentData->pLocationTag != null)
+ {
+ __pContentData->pLocationTag = new (nothrow) String(*(pContentData->pLocationTag));
+ SysTryReturnResult(NID_CNT, __pContentData->pLocationTag != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pContentData->pProvider != null)
+ {
+ __pContentData->pProvider = new (nothrow) String(*(pContentData->pProvider));
+ SysTryReturnResult(NID_CNT, __pContentData->pProvider != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pContentData->pRating != null)
+ {
+ __pContentData->pRating = new (nothrow) String(*(pContentData->pRating));
+ SysTryReturnResult(NID_CNT, __pContentData->pRating != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+
+ return E_SUCCESS;
+}
+
+ContentInfo::_ContentData*
+ContentInfo::GetContentData(void)
+{
+ if (__pContentData == null)
+ {
+ __pContentData = new (nothrow) ContentInfo::_ContentData;
+ SysTryReturn(NID_CNT, __pContentData != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ return __pContentData;
+}
+
+ContentId
+ContentInfo::GetContentId(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pContentData->contentId == UuId::GetInvalidUuId())
+ {
+ SysLog(NID_CNT, "GetContentId() failed.");
+ return UuId::GetInvalidUuId();
+ }
+ return __pContentData->contentId;
+}
+
+ContentType
+ContentInfo::GetContentType(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pContentData->contentType;
+}
+
+DateTime
+ContentInfo::GetDateTime(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pContentData->dateTime;
+}
+
+String
+ContentInfo::GetMimeType(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pContentData->mimeType;
+}
+
+unsigned long
+ContentInfo::GetContentSize(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pContentData->contentSize;
+}
+
+String
+ContentInfo::GetContentName(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pContentData->pContentName == null)
+ {
+ SysLog(NID_CNT, "GetContentName() failed.");
+ return String();
+ }
+ return *(__pContentData->pContentName);
+}
+
+String
+ContentInfo::GetContentPath(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pContentData->contentPath;
+}
+
+const Coordinates&
+ContentInfo::GetCoordinates(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ result r = E_SUCCESS;
+
+ if (Double::Compare(__pContentData->latitude, DEFAULT_COORDINATE) == 0 ||
+ Double::Compare(__pContentData->longitude, DEFAULT_COORDINATE) == 0)
+ {
+ SysLog(NID_CNT, "Invalid latitude or longitude");
+ return coordinates;
+ }
+
+ if (Double::Compare(__pContentData->altitude, DEFAULT_COORDINATE) == 0)
+ {
+ r = coordinates.SetLatitude(__pContentData->latitude);
+ if (IsFailed(r))
+ {
+ SysLog(NID_CNT, "GetCoordinates() failed.");
+ return coordinates;
+ }
+
+ r = coordinates.SetLongitude(__pContentData->longitude);
+ if (IsFailed(r))
+ {
+ SysLog(NID_CNT, "GetCoordinates() failed.");
+ return coordinates;
+ }
+ }
+ else
+ {
+ r = coordinates.Set(__pContentData->latitude, __pContentData->longitude, __pContentData->altitude);
+ if (IsFailed(r))
+ {
+ SysLog(NID_CNT, "GetCoordinates() failed.");
+ return coordinates;
+ }
+ }
+
+ return coordinates;
+}
+
+result
+ContentInfo::SetCoordinates(const Coordinates& coordinates)
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ double latitude = coordinates.GetLatitude();
+ double longitude = coordinates.GetLongitude();
+ double altitude = coordinates.GetAltitude();
+
+ if (!Double::IsNaN(latitude))
+ {
+ __pContentData->latitude = latitude;
+ }
+ if (!Double::IsNaN(longitude))
+ {
+ __pContentData->longitude = longitude;
+ }
+ if (!Double::IsNaN(altitude))
+ {
+ __pContentData->altitude = altitude;
+ }
+
+ return E_SUCCESS;
+}
+
+result
+ContentInfo::SetLocationTag(const String& locationTag)
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, locationTag.GetLength() <= MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
+ "The max input length is 45 characters.");
+
+ if (__pContentData->pLocationTag != null)
+ {
+ // Deletes previous data
+ delete __pContentData->pLocationTag;
+ __pContentData->pLocationTag = null;
+ }
+
+ __pContentData->pLocationTag = new (nothrow) String(locationTag);
+ SysTryReturnResult(NID_CNT, __pContentData->pLocationTag != null, E_OUT_OF_MEMORY,
+ "The memory is insufficient.");
+
+ return E_SUCCESS;
+}
+
+String
+ContentInfo::GetLocationTag(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pContentData->pLocationTag == null)
+ {
+ SysLog(NID_CNT, "GetLocationTag() failed.");
+ return String();
+ }
+ return *(__pContentData->pLocationTag);
+}
+
+result
+ContentInfo::SetRating(const String& rating)
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, rating.GetLength() <= MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
+ "The max input length is 45 characters.");
+
+ if (__pContentData->pRating != null)
+ {
+ // Deletes previous data
+ delete __pContentData->pRating;
+ __pContentData->pRating = null;
+ }
+
+ __pContentData->pRating = new (nothrow) String(rating);
+ SysTryReturnResult(NID_CNT, __pContentData->pRating != null, E_OUT_OF_MEMORY,
+ "The memory is insufficient.");
+
+ return E_SUCCESS;
+}
+
+String
+ContentInfo::GetRating(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pContentData->pRating == null)
+ {
+ SysLog(NID_CNT, "GetRating() failed.");
+ return String();
+ }
+ return *(__pContentData->pRating);
+}
+
+result
+ContentInfo::SetCategory(const String& category)
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, category.GetLength() <= MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
+ "The max input length is 45 characters.");
+
+ if (__pContentData->pCategory != null)
+ {
+ // Deletes previous data
+ delete __pContentData->pCategory;
+ __pContentData->pCategory = null;
+ }
+
+ __pContentData->pCategory = new (nothrow) String(category);
+ SysTryReturnResult(NID_CNT, __pContentData->pCategory != null, E_OUT_OF_MEMORY,
+ "The memory is insufficient.");
+
+ return E_SUCCESS;
+}
+
+String
+ContentInfo::GetCategory(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pContentData->pCategory == null)
+ {
+ SysLog(NID_CNT, "GetCategory() failed.");
+ return String();
+ }
+ return *(__pContentData->pCategory);
+}
+
+result
+ContentInfo::SetDescription(const String& description)
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, description.GetLength() <= MAX_CUSTOM_FIELD_DESCRIPTION, E_INVALID_ARG,
+ "The max input length is 140 characters.");
+
+ if (__pContentData->pDescription != null)
+ {
+ // Deletes previous data
+ delete __pContentData->pDescription;
+ __pContentData->pDescription = null;
+ }
+
+ __pContentData->pDescription = new (nothrow) String(description);
+ SysTryReturnResult(NID_CNT, __pContentData->pDescription != null, E_OUT_OF_MEMORY,
+ "The memory is insufficient.");
+
+ return E_SUCCESS;
+}
+
+String
+ContentInfo::GetDescription(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pContentData->pDescription == null)
+ {
+ SysLog(NID_CNT, "GetDescription() failed.");
+ return String();
+ }
+ return *(__pContentData->pDescription);
+}
+
+Bitmap*
+ContentInfo::GetThumbnailN(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+ Image image;
+ Bitmap* pBitmap = null;
+
+ SysTryReturn(NID_CNT, __pContentData->pThumbnailPath != null, null, E_DATA_NOT_FOUND,
+ "[E_DATA_NOT_FOUND] GetThumbnailN() failed.");
+
+ if (__pContentData->contentType == CONTENT_TYPE_IMAGE || __pContentData->contentType == CONTENT_TYPE_AUDIO
+ || __pContentData->contentType == CONTENT_TYPE_VIDEO)
+ {
+ r = image.Construct();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] GetThumbnailN() failed.");
+
+ if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+ {
+ pBitmap = image.DecodeN(*(__pContentData->pThumbnailPath), BITMAP_PIXEL_FORMAT_ARGB8888, THUMBNAIL_IMAGE_WIDTH, THUMBNAIL_IMAGE_HEIGHT);
+ }
+ else
+ {
+ pBitmap = image.DecodeN(*(__pContentData->pThumbnailPath), BITMAP_PIXEL_FORMAT_ARGB8888);
+ }
+
+ if (pBitmap == null)
+ {
+ r = GetLastResult();
+
+ if (r == E_OUT_OF_MEMORY)
+ {
+ SysLogException(NID_CNT, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] GetThumbnailN() failed.");
+ return null;
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] GetThumbnailN() failed.");
+ return null;
+ }
+ }
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] GetThumbnailN() failed.");
+ return null;
+ }
+
+ return pBitmap;
+}
+
+bool
+ContentInfo::IsDrmProtected(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pContentData->isDrm;
+}
+
+String
+ContentInfo::GetKeyword(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pContentData->pKeyword == null)
+ {
+ SysLog(NID_CNT, "GetKeyword() failed.");
+ return String();
+ }
+ return *(__pContentData->pKeyword);
+}
+
+result
+ContentInfo::SetContentName(const String& contentName)
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, contentName.GetLength() <= MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
+ "The max input length is 45 characters.");
+
+ if (__pContentData->pContentName != null)
+ {
+ // Deletes previous data
+ delete __pContentData->pContentName;
+ __pContentData->pContentName = null;
+ }
+
+ __pContentData->pContentName = new (nothrow) String(contentName);
+ SysTryReturnResult(NID_CNT, __pContentData->pContentName != null, E_OUT_OF_MEMORY,
+ "The memory is insufficient.");
+
+ return E_SUCCESS;
+}
+
+result
+ContentInfo::SetKeyword(const String& keyword)
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, keyword.GetLength() <= MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
+ "The max input length is 45 characters.");
+
+ if (__pContentData->pKeyword != null)
+ {
+ // Deletes previous data
+ delete __pContentData->pKeyword;
+ __pContentData->pKeyword = null;
+ }
+
+ __pContentData->pKeyword = new (nothrow) String(keyword);
+ SysTryReturnResult(NID_CNT, __pContentData->pKeyword != null, E_OUT_OF_MEMORY,
+ "SetKeyword() failed.");
+
+ return E_SUCCESS;
+}
+
+result
+ContentInfo::SetAuthor(const String& author)
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, author.GetLength() <= MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
+ "The max input length is 45 characters.");
+
+ if (__pContentData->pAuthor != null)
+ {
+ // Deletes previous data
+ delete __pContentData->pAuthor;
+ __pContentData->pAuthor = null;
+ }
+
+ __pContentData->pAuthor = new (nothrow) String(author);
+ SysTryReturnResult(NID_CNT, __pContentData->pAuthor != null, E_OUT_OF_MEMORY,
+ "SetAuthor() failed.");
+
+ return E_SUCCESS;
+}
+
+String
+ContentInfo::GetAuthor(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pContentData->pAuthor == null)
+ {
+ SysLog(NID_CNT, "GetAuthor() failed.");
+ return String();
+ }
+ return *(__pContentData->pAuthor);
+}
+
+result
+ContentInfo::SetProvider(const String& provider)
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, provider.GetLength() <= MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
+ "The max input length is 45 characters.");
+
+ if (__pContentData->pProvider != null)
+ {
+ // Deletes previous data
+ delete __pContentData->pProvider;
+ __pContentData->pProvider = null;
+ }
+
+ __pContentData->pProvider = new (nothrow) String(provider);
+ SysTryReturnResult(NID_CNT, __pContentData->pProvider != null, E_OUT_OF_MEMORY,
+ "SetProvider() failed.");
+
+ return E_SUCCESS;
+}
+
+String
+ContentInfo::GetProvider(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pContentData->pProvider == null)
+ {
+ SysLog(NID_CNT, "GetProvider() failed.");
+ return String();
+ }
+ return *(__pContentData->pProvider);
+}
+
+String
+ContentInfo::GetMediaFormat(void) const
+{
+ SysAssertf(__pContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return File::GetFileExtension(__pContentData->contentPath);
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentManager.cpp
+ * @brief This is the implementation file for the %ContentManager class.
+ *
+ * This file contains implementation of the %ContentManager class.
+ */
+
+// includes
+#include <FBaseSysLog.h>
+#include <FBaseByteBuffer.h>
+#include <FCntContentManager.h>
+#include <FCntImageContentInfo.h>
+#include <FCntAudioContentInfo.h>
+#include <FCntVideoContentInfo.h>
+#include <FCntOtherContentInfo.h>
+#include <FCnt_ContentManagerImpl.h>
+#include <FSec_AccessController.h>
+
+// using namespaces
+using namespace Tizen::Base;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Content
+{
+
+ContentManager::ContentManager(void)
+ : Object()
+ , __pImpl(null)
+{
+
+}
+
+ContentManager::~ContentManager(void)
+{
+ if (__pImpl != null)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+result
+ContentManager::Construct(void)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ _ContentManagerImpl* pContentManagerImpl = new (std::nothrow) _ContentManagerImpl();
+ SysTryReturn(NID_CNT, pContentManagerImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
+
+ r = pContentManagerImpl->Construct();
+ SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%S] Propagating.", GetErrorMessage(r));
+
+ __pImpl = pContentManagerImpl;
+
+ return r;
+
+CATCH:
+ delete pContentManagerImpl;
+ pContentManagerImpl = null;
+
+ return r;
+}
+
+ContentId
+ContentManager::CreateContent(const ContentInfo& contentInfo)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ // Checks the privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_WRITE);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, UuId::GetInvalidUuId(), 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.");
+
+ ContentId contentId = __pImpl->CreateContent(contentInfo);
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), UuId::GetInvalidUuId(), r, "[%s] CreateContent failed.", GetErrorMessage(r));
+
+ return contentId;
+}
+
+ContentId
+ContentManager::CreateContent(const ByteBuffer& byteBuffer, const String& destinationPath, const ContentInfo* pContentInfo)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ // Checks the privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_WRITE);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, UuId::GetInvalidUuId(), 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.");
+
+ ContentId contentId = __pImpl->CreateContent(byteBuffer, destinationPath, pContentInfo);
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), UuId::GetInvalidUuId(), r, "[%s] CreateContent failed.", GetErrorMessage(r));
+
+ return contentId;
+}
+
+ContentId
+ContentManager::CreateContent(const String& sourcePath, const String& destinationPath, bool deleteSource,
+ const ContentInfo* pContentInfo)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ // Checks the privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_WRITE);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, UuId::GetInvalidUuId(), 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.");
+
+ ContentId contentId = __pImpl->CreateContent(sourcePath, destinationPath, deleteSource, pContentInfo);
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), UuId::GetInvalidUuId(), r, "[%s] CreateContent failed.", GetErrorMessage(r));
+
+ return contentId;
+}
+
+ContentInfo*
+ContentManager::GetContentInfoN(const ContentId& contentId) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ ContentInfo* pContentInfo = null;
+ ImageContentInfo* pImageContentInfo = null;
+ AudioContentInfo* pAudioContentInfo = null;
+ VideoContentInfo* pVideoContentInfo = null;
+ OtherContentInfo* pOtherContentInfo = null;
+ ContentType contentType;
+
+ // Checks the privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, null, 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.");
+
+ pContentInfo = __pImpl->GetContentInfoN(contentId);
+ r = GetLastResult();
+ SysTryCatch(NID_CNT, pContentInfo != null, , r, "[%s] GetContentInfoN failed.", GetErrorMessage(r));
+
+ contentType = pContentInfo->GetContentType();
+
+ if (contentType == CONTENT_TYPE_IMAGE)
+ {
+ pImageContentInfo = dynamic_cast <ImageContentInfo*>(pContentInfo);
+ SysTryCatch(NID_CNT, pImageContentInfo != null, , E_SYSTEM, "[E_SYSTEM] GetContentInfoN failed.");
+
+ return pImageContentInfo;
+ }
+ else if (contentType == CONTENT_TYPE_AUDIO)
+ {
+ pAudioContentInfo = dynamic_cast <AudioContentInfo*>(pContentInfo);
+ SysTryCatch(NID_CNT, pAudioContentInfo != null, , E_SYSTEM, "[E_SYSTEM] GetContentInfoN failed.");
+
+ return pAudioContentInfo;
+ }
+ else if (contentType == CONTENT_TYPE_VIDEO)
+ {
+ pVideoContentInfo = dynamic_cast <VideoContentInfo*>(pContentInfo);
+ SysTryCatch(NID_CNT, pVideoContentInfo != null, , E_SYSTEM, "[E_SYSTEM] GetContentInfoN failed.");
+
+ return pVideoContentInfo;
+ }
+ else if (contentType == CONTENT_TYPE_OTHER)
+ {
+ pOtherContentInfo = dynamic_cast <OtherContentInfo*>(pContentInfo);
+ SysTryCatch(NID_CNT, pOtherContentInfo != null, , E_SYSTEM, "[E_SYSTEM] GetContentInfoN failed.");
+
+ return pOtherContentInfo;
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_SYSTEM, "[E_SYSTEM] contentType is CONTENT_TYPE_UNKNOWN.");
+ goto CATCH;
+ }
+
+CATCH:
+ if (pContentInfo != null)
+ {
+ delete pContentInfo;
+ pContentInfo = null;
+ }
+
+ return null;
+}
+
+result
+ContentManager::UpdateContent(const ContentInfo& contentInfo)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ // Checks the privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_WRITE);
+ 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->UpdateContent(contentInfo);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] UpdateContent failed.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+ContentManager::DeleteContent(const ContentId& contentId)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ // Checks the privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_WRITE);
+ 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->DeleteContent(contentId);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] DeleteContent failed.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+ContentManager::ScanFile(const String& contentPath)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ // Checks the privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_WRITE);
+ 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);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] ScanFile failed.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+ContentManager::ScanDirectory(const String& directoryPath, bool recursive, _IContentScanListener& listener)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ // Checks the privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_WRITE);
+ 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);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] ScanDirectory failed.", GetErrorMessage(r));
+
+ return r;
+}
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentManagerUtil.cpp
+ * @brief This is the implementation file for the %ContentManagerUtil class.
+ *
+ * This file contains implementation of the %ContentManagerUtil class.
+ */
+
+// includes
+#include <FBaseSysLog.h>
+#include <FCntContentManagerUtil.h>
+#include <FCntImageMetadata.h>
+#include <FCntAudioMetadata.h>
+#include <FCntVideoMetadata.h>
+#include <FCnt_ContentManagerUtilImpl.h>
+
+// using namespace
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Content
+{
+
+ImageMetadata*
+ContentManagerUtil::GetImageMetaN(const String& filePath)
+{
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+ ImageMetadata* pImageMetadata = null;
+
+ pImageMetadata = _ContentManagerUtilImpl::GetImageMetaN(filePath);
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, pImageMetadata != null, null, r, "[%s] GetImageMetaN failed.", GetErrorMessage(r));
+
+ return pImageMetadata;
+}
+
+AudioMetadata*
+ContentManagerUtil::GetAudioMetaN(const String& filePath)
+{
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+ AudioMetadata* pAudioMetadata = null;
+
+ pAudioMetadata = _ContentManagerUtilImpl::GetAudioMetaN(filePath);
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, pAudioMetadata != null, null, r, "[%s] GetAudioMetaN failed.", GetErrorMessage(r));
+
+ return pAudioMetadata;
+}
+
+VideoMetadata*
+ContentManagerUtil::GetVideoMetaN(const String& filePath)
+{
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+ VideoMetadata* pVideoMetadata = null;
+
+ pVideoMetadata = _ContentManagerUtilImpl::GetVideoMetaN(filePath);
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, pVideoMetadata != null, null, r, "[%s] GetVideoMetaN failed.", GetErrorMessage(r));
+
+ return pVideoMetadata;
+}
+
+ContentType
+ContentManagerUtil::CheckContentType(const String& filePath)
+{
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+ ContentType contentType = CONTENT_TYPE_UNKNOWN;
+
+ contentType = _ContentManagerUtilImpl::CheckContentType(filePath);
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, contentType != CONTENT_TYPE_UNKNOWN, CONTENT_TYPE_UNKNOWN, r,
+ "[%s] CheckContentType failed.", GetErrorMessage(r));
+
+ return contentType;
+}
+
+result
+ContentManagerUtil::CopyToMediaDirectory(const String& srcFilePath, const String& destFilePath)
+{
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+
+ r = _ContentManagerUtilImpl::CopyToMediaDirectory(srcFilePath, destFilePath);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] CopyToMediaDirectory failed.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+ContentManagerUtil::MoveToMediaDirectory(const String& srcFilePath, const String& destFilePath)
+{
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+
+ r = _ContentManagerUtilImpl::MoveToMediaDirectory(srcFilePath, destFilePath);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] MoveToMediaDirectory failed.", GetErrorMessage(r));
+
+ return r;
+}
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentSearch.cpp
+ * @brief This is the implementation file for the %ContentSearch class.
+ *
+ * This is the implementation file for %ContentSearch class.
+ */
+
+// includes
+#include <FBaseSysLog.h>
+#include <FCntContentSearch.h>
+#include <FBaseColIList.h>
+#include <FCnt_ContentSearchImpl.h>
+#include <FSec_AccessController.h>
+
+using namespace Tizen::Io;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Content
+{
+
+static const int MAX_QUERY_PATH = 512;
+
+ContentSearch::ContentSearch(void)
+ : Object()
+ , __pImpl(null)
+{
+}
+
+ContentSearch::~ContentSearch(void)
+{
+ if (__pImpl != null)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+result
+ContentSearch::Construct(ContentType type)
+{
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ SysTryReturn(NID_CNT, type != CONTENT_TYPE_UNKNOWN, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Construct failed.");
+
+ _ContentSearchImpl* pContentSearchImpl = new (std::nothrow) _ContentSearchImpl();
+ SysTryReturn(NID_CNT, pContentSearchImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
+
+ r = pContentSearchImpl->Construct(type);
+ SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pImpl = pContentSearchImpl;
+
+ return E_SUCCESS;;
+
+CATCH:
+ delete pContentSearchImpl;
+ pContentSearchImpl = null;
+
+ return r;
+}
+
+IList*
+ContentSearch::SearchN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount, const String& whereExpr,
+const String& sortColumn, SortOrder sortOrder) const
+{
+ ClearLastResult();
+
+ totalPageCount = 0;
+ totalCount = 0;
+
+ // Checks the privilege
+ result r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, null, 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.");
+
+ SysTryReturn(NID_CNT, pageNo > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] pageNo <=0 : SearchN failed.");
+ SysTryReturn(NID_CNT, countPerPage > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] countPerPage <=0: SearchN failed.");
+ SysTryReturn(NID_CNT, whereExpr.GetLength() <= MAX_QUERY_PATH, null, E_INVALID_ARG, "[E_INVALID_ARG] Exceeds query max size : SearchN failed.");
+
+
+ return __pImpl->SearchN(pageNo, countPerPage, totalPageCount, totalCount, whereExpr, sortColumn, sortOrder);
+
+}
+
+IList*
+ContentSearch::GetValueListN(const String& column, SortOrder sortOrder)
+{
+ ClearLastResult();
+
+ // Checks the privilege
+ result r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, null, 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.");
+
+ SysTryReturn(NID_CNT, !column.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The column name is invalid.");
+
+ return __pImpl->GetValueListN(column, sortOrder);
+}
+
+IList*
+ContentSearch::GetValueListN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount,
+const String& column, SortOrder sortOrder) const
+{
+ ClearLastResult();
+
+ totalPageCount = 0;
+ totalCount = 0;
+
+ // Checks the privilege
+ result r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, null, 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.");
+
+ SysTryReturn(NID_CNT, !column.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The column name is invalid: GetValueListN failed.");
+ SysTryReturn(NID_CNT, pageNo > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] pageNo <=0: GetValueListN failed.");
+ SysTryReturn(NID_CNT, countPerPage > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] countPerPage <=0: GetValueListN failed.");
+
+ return __pImpl->GetValueListN(pageNo, countPerPage, totalPageCount, totalCount, column, sortOrder);
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentSearchResult.cpp
+ * @brief This is the implementation file for the %ContentSearchResult class.
+ *
+ * This file contains implementation of the %ContentSearchResult class.
+ */
+
+// includes
+#include <FCntContentSearchResult.h>
+#include <FCntContentInfo.h>
+
+// using namespace
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Content
+{
+ContentSearchResult::ContentSearchResult(void)
+ : Object()
+ , __contentType(CONTENT_TYPE_UNKNOWN)
+ , __pContentInfo(null)
+ , __pImpl(null)
+{
+
+}
+
+ContentSearchResult::~ContentSearchResult(void)
+{
+ if (__pContentInfo != null)
+ {
+ delete __pContentInfo;
+ __pContentInfo = null;
+ }
+}
+
+ContentType
+ContentSearchResult::GetContentType(void) const
+{
+ return __contentType;
+}
+
+ContentInfo*
+ContentSearchResult::GetContentInfo(void) const
+{
+ return __pContentInfo;
+}
+
+void
+ContentSearchResult::SetContentType(ContentType contentType)
+{
+ __contentType = contentType;
+}
+
+void
+ContentSearchResult::SetContentInfo(ContentInfo* pContentInfo)
+{
+ __pContentInfo = pContentInfo;
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentTransfer.cpp
+ * @brief This is the implementation file for the %ContentTransfer class.
+ *
+ * This file contains implementation of the %ContentTransfer class.
+ */
+
+// includes
+#include <FBaseSysLog.h>
+#include <FCntContentTransfer.h>
+#include <FBaseColIList.h>
+#include <FBaseUtilUri.h>
+#include <FCnt_ContentTransferImpl.h>
+#include <FSec_AccessController.h>
+
+// using namespace
+using namespace Tizen::Base;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Content
+{
+ContentTransfer::ContentTransfer(void)
+ : Object()
+ , __pImpl(null)
+{
+
+}
+
+ContentTransfer::~ContentTransfer(void)
+{
+ if (__pImpl != null)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+result
+ContentTransfer::Construct(IContentTransferListener& listener)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ _ContentTransferImpl* pContentTransferImpl = new (std::nothrow) _ContentTransferImpl();
+ SysTryReturn(NID_CNT, pContentTransferImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
+
+ r = pContentTransferImpl->Construct(listener);
+ SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%S] Propagating.", GetErrorMessage(r));
+
+ __pImpl = pContentTransferImpl;
+
+ return E_SUCCESS;
+
+CATCH:
+ delete pContentTransferImpl;
+ pContentTransferImpl = null;
+
+ return r;
+}
+
+result
+ContentTransfer::Cancel(RequestId reqId)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ r = __pImpl->Cancel(reqId);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Cancel failed.", GetErrorMessage(r));
+
+ return r;
+}
+
+void
+ContentTransfer::SetDefaultTimeout(int sec)
+{
+ if (__pImpl == null)
+ {
+ SysLog(NID_CNT, "__pImpl is null.");
+ return;
+ }
+ __pImpl->SetDefaultTimeout(sec);
+}
+
+int
+ContentTransfer::GetDefaultTimeout(void) const
+{
+ if (__pImpl == null)
+ {
+ SysLog(NID_CNT, "__pImpl is null.");
+ return 0;
+ }
+ return __pImpl->GetDefaultTimeout();
+}
+
+result
+ContentTransfer::Remove(RequestId reqId)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ r = __pImpl->Remove(reqId);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Remove failed.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+ContentTransfer::RemoveAll(void)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ r = __pImpl->RemoveAll();
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] RemoveAll failed.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+ContentTransfer::CancelAll(void)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ r = __pImpl->CancelAll();
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] CancelAll failed.", GetErrorMessage(r));
+
+ return r;
+}
+
+Collection::IList*
+ContentTransfer::GetContentTransferInfoListN(void) const
+{
+ if (__pImpl == null)
+ {
+ SysLog(NID_CNT, "__pImpl is null.");
+ return null;
+ }
+ return __pImpl->GetContentTransferInfoListN();
+}
+
+Collection::IList*
+ContentTransfer::GetContentTransferInfoListInProgressN(void) const
+{
+ if (__pImpl == null)
+ {
+ SysLog(NID_CNT, "__pImpl is null.");
+ return null;
+ }
+ return __pImpl->GetContentTransferInfoListInProgressN();
+}
+
+void
+ContentTransfer::SetProgressIntervalByPercent(int percent)
+{
+ if (__pImpl == null)
+ {
+ SysLog(NID_CNT, "__pImpl is null.");
+ return;
+ }
+ __pImpl->SetProgressIntervalByPercent(percent);
+}
+
+result
+ContentTransfer::Download(const Utility::Uri& uri, int fileSize, const String& destFilePath, bool replace,
+ RequestId& reqId, IContentTransferListener* pListener, int sec)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ // Checks the privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_DOWNLOAD);
+ 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->Download(uri, fileSize, destFilePath, replace, reqId, pListener, sec);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Download failed.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+ContentTransfer::Download(const Utility::Uri& uri, const String& filePath,
+ RequestId& reqId, bool replace, int timeout, int progressInterval)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ // Checks the privilege
+ r = _AccessController::CheckUserPrivilege(_PRV_DOWNLOAD);
+ 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->Download(uri, filePath, reqId, replace, timeout, progressInterval);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Download failed.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+ContentTransfer::DownloadToBuffer(const Utility::Uri& uri, int fileSize, RequestId& reqId,IContentTransferListener* pListener, int sec)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ r = _AccessController::CheckUserPrivilege(_PRV_DOWNLOAD);
+ 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->DownloadToBuffer(uri, fileSize, reqId, pListener, sec);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] DownloadToBuffer failed.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+ContentTransfer::DownloadToBuffer(const Utility::Uri& uri, RequestId& reqId, int timeout, int progressInterval)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ r = _AccessController::CheckUserPrivilege(_PRV_DOWNLOAD);
+ 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->DownloadToBuffer(uri, reqId, timeout, progressInterval);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] DownloadToBuffer failed.", GetErrorMessage(r));
+
+ return r;
+}
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentTransferInfo.cpp
+ * @brief This is the implementation file for the %ContentTransferInfo class.
+ *
+ * This file contains implementation of the %ContentTransferInfo class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FCntContentTransferInfo.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+
+namespace Tizen { namespace Content
+{
+
+static const int HASH_CODE_INITIAL_VALUE = 17;
+static const int HASH_CODE_COEFFICIENT_VALUE = 37;
+
+ContentTransferInfo::ContentTransferInfo(void)
+ : Object()
+ , __requestId(INVALID_REQUEST_ID)
+ , __restRequestId(INVALID_REQUEST_ID)
+ , __status(CONTENT_TRANSFER_STATUS_NONE)
+ , __destPath(L"")
+ , __uri()
+ , __sourcePath(L"")
+ , __sourceFileSize(-1)
+ , __slotId(-1)
+ , __pListener(null)
+ , __timeout(-1)
+ , __isBuffer(false)
+ , __intervalValue(-1)
+ , __pImpl(null)
+{
+
+}
+
+ContentTransferInfo::~ContentTransferInfo(void)
+{
+
+}
+
+Utility::Uri
+ContentTransferInfo::GetUri(void) const
+{
+ return __uri;
+}
+
+RequestId
+ContentTransferInfo::GetRequestId(void) const
+{
+ return __requestId;
+}
+
+String
+ContentTransferInfo::GetDestPath(void) const
+{
+ return __destPath;
+}
+
+ContentTransferStatus
+ContentTransferInfo::GetContentTransferStatus(void) const
+{
+ return __status;
+}
+
+void
+ContentTransferInfo::SetAllInfo(RequestId reqId, const Uri& uri, const String& destPath, const String& sourcePath,
+ int sourceFileSize, ContentTransferStatus status)
+{
+ __requestId = reqId;
+ __uri = uri;
+ __destPath = destPath;
+ __sourcePath = sourcePath;
+ __status = status;
+ __sourceFileSize = sourceFileSize;
+}
+
+void
+ContentTransferInfo::SetRestRequestId(RequestId reqId)
+{
+ __restRequestId = reqId;
+}
+
+RequestId
+ContentTransferInfo::GetRestRequestId(void) const
+{
+ return __restRequestId;
+}
+
+int
+ContentTransferInfo::GetSourceFileSize(void) const
+{
+ return __sourceFileSize;
+}
+
+void
+ContentTransferInfo::SetSlotId(int slot)
+{
+ __slotId = slot;
+}
+
+int
+ContentTransferInfo::GetSlotId(void) const
+{
+ return __slotId;
+}
+
+void
+ContentTransferInfo::SetTimeout(int sec)
+{
+ __timeout = sec;
+}
+
+int
+ContentTransferInfo::GetTimeout(void) const
+{
+ return __timeout;
+}
+
+
+void
+ContentTransferInfo::SetListener(IContentTransferListener* pListener)
+{
+ __pListener = pListener;
+}
+
+ContentTransferInfo*
+ContentTransferInfo::CopyN(void)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ ContentTransferInfo* pContentTransferInfoCopy = null;
+ pContentTransferInfoCopy = new (std::nothrow) ContentTransferInfo;
+ SysTryCatch(NID_CNT, pContentTransferInfoCopy != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Propagating.");
+
+ pContentTransferInfoCopy->SetAllInfo(__requestId, __uri, __destPath, __sourcePath, __sourceFileSize, __status);
+
+CATCH:
+ return pContentTransferInfoCopy;
+}
+
+void
+ContentTransferInfo::SetIsBuffer(bool isBuffer)
+{
+ __isBuffer = isBuffer;
+}
+
+bool
+ContentTransferInfo::GetIsBuffer(void) const
+{
+ return __isBuffer;
+}
+
+void
+ContentTransferInfo::SetProgressInterval(int intervalValue)
+{
+ __intervalValue = intervalValue;
+}
+
+int
+ContentTransferInfo::GetProgressInterval(void) const
+{
+ return __intervalValue;
+}
+
+void
+ContentTransferInfo::SetDownloadStatus(ContentTransferStatus status)
+{
+ __status = status;
+}
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntDownloadManager.cpp
+ * @brief This is the implementation file for the DownloadManager class.
+ *
+ */
+
+#include <FBaseSysLog.h>
+#include <FSec_AccessController.h>
+#include <FCntDownloadManager.h>
+#include <FCntDownloadRequest.h>
+#include <FCntIDownloadListener.h>
+
+#include "FCnt_DownloadManagerImpl.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Security;
+
+namespace Tizen { namespace Content
+{
+
+DownloadManager::DownloadManager(void)
+ : __pDownloadManagerImpl(null)
+{
+}
+
+DownloadManager::~DownloadManager(void)
+{
+ delete __pDownloadManagerImpl;
+}
+
+DownloadManager*
+DownloadManager::GetInstance(void)
+{
+ result r = E_SUCCESS;
+ static DownloadManager* pManager = null;
+
+ if (pManager == null)
+ {
+ pManager = new (std::nothrow) DownloadManager;
+ SysTryReturn(NID_CNT, pManager != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ _DownloadManagerImpl* pImpl = _DownloadManagerImpl::GetInstance();
+ SysTryCatch(NID_CNT, pImpl != null, , E_SYSTEM, "[E_SYSTEM] Failed to initialize download manager.");
+
+ pManager->__pDownloadManagerImpl = pImpl;
+ }
+
+ return pManager;
+
+CATCH:
+ delete pManager;
+ pManager = null;
+
+ return null;
+}
+
+result
+DownloadManager::Start(const DownloadRequest& request, RequestId& reqId)
+{
+ SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+
+ result r = _AccessController::CheckUserPrivilege(_PRV_DOWNLOAD);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_PRIVILEGE_DENIED,
+ "The application does not have the privilege to call this method.");
+
+ return __pDownloadManagerImpl->Start(request, reqId);
+}
+
+
+result
+DownloadManager::Pause(RequestId reqId)
+{
+ SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+
+ return __pDownloadManagerImpl->Pause(reqId);
+}
+
+result
+DownloadManager::Resume(RequestId reqId)
+{
+ SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+
+ return __pDownloadManagerImpl->Resume(reqId);
+}
+
+result
+DownloadManager::Cancel(RequestId reqId)
+{
+ SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+
+ return __pDownloadManagerImpl->Cancel(reqId);
+}
+
+
+DownloadRequest*
+DownloadManager::GetDownloadRequestN(RequestId reqId) const
+{
+ SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+
+ return __pDownloadManagerImpl->GetDownloadRequestN(reqId);
+}
+
+DownloadState
+DownloadManager::GetState(RequestId reqId) const
+{
+ SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+
+ return (DownloadState)__pDownloadManagerImpl->GetState(reqId);
+}
+
+result
+DownloadManager::GetMimeType(RequestId reqId, String& mimeType) const
+{
+ SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+
+ return __pDownloadManagerImpl->GetMimeType(reqId, mimeType);
+}
+
+/*
+result
+DownloadManager::SetAllowedNetwork(unsigned long flags)
+{
+ SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+
+ return __pDownloadManagerImpl->SetAllowedNetwork(flags);
+}
+
+result
+DownloadManager::GetProgress(RequestId reqId, int& progress) const
+{
+ SysAssertf(__pDownloadManagerImpl != null, "Not yet constructed. Construct() should be called before use.\n");
+
+ return __pDownloadManagerImpl->GetProgress(reqId, progress);
+}
+*/
+
+void
+DownloadManager::SetDownloadListener(IDownloadListener* pListener)
+{
+ __pDownloadManagerImpl->SetDownloadListener(pListener);
+}
+
+} } // Tizen::Content
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntDownloadRequest.cpp
+ * @brief This is the implementation file for the DownloadRequest class.
+ *
+ */
+
+#include <FBaseSysLog.h>
+#include <FCntDownloadRequest.h>
+#include "FCnt_DownloadRequestImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Content
+{
+
+DownloadRequest::DownloadRequest(void)
+ : __pDownloadRequestImpl(null)
+{
+ __pDownloadRequestImpl = new (std::nothrow) _DownloadRequestImpl();
+ SysTryReturnVoidResult(NID_CNT, __pDownloadRequestImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+}
+
+DownloadRequest::DownloadRequest(const String& url)
+{
+ __pDownloadRequestImpl = new (std::nothrow) _DownloadRequestImpl(url);
+ SysTryReturnVoidResult(NID_CNT, __pDownloadRequestImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+}
+
+DownloadRequest::DownloadRequest(const String& url, const String& dirPath)
+{
+ __pDownloadRequestImpl = new (std::nothrow) _DownloadRequestImpl(url, dirPath);
+ SysTryReturnVoidResult(NID_CNT, __pDownloadRequestImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+}
+
+DownloadRequest::DownloadRequest(const DownloadRequest& rhs)
+{
+ __pDownloadRequestImpl = new (std::nothrow) _DownloadRequestImpl(*rhs.__pDownloadRequestImpl);
+ SysTryReturnVoidResult(NID_CNT, __pDownloadRequestImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+}
+
+DownloadRequest::~DownloadRequest(void)
+{
+ delete __pDownloadRequestImpl;
+}
+
+
+DownloadRequest&
+DownloadRequest::operator =(const DownloadRequest& rhs)
+{
+ if (&rhs != this)
+ {
+ delete __pDownloadRequestImpl;
+
+ __pDownloadRequestImpl = new (std::nothrow) _DownloadRequestImpl(*rhs.__pDownloadRequestImpl);
+
+ SysTryReturn(NID_CNT, __pDownloadRequestImpl != null, *this, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+
+ return *this;
+}
+
+bool
+DownloadRequest::Equals(const Object& obj) const
+{
+ if (&obj == this)
+ {
+ return true;
+ }
+
+ const DownloadRequest* pOther = dynamic_cast< const DownloadRequest* >(&obj);
+ if (pOther == null)
+ {
+ return false;
+ }
+
+ return __pDownloadRequestImpl->Equals(*pOther->__pDownloadRequestImpl);
+}
+
+int
+DownloadRequest::GetHashCode(void) const
+{
+ return __pDownloadRequestImpl->GetHashCode();
+}
+
+void
+DownloadRequest::SetDirectoryPath(const String& dirPath)
+{
+ __pDownloadRequestImpl->SetDirectoryPath(dirPath);
+}
+
+void
+DownloadRequest::SetFileName(const String& fileName)
+{
+ __pDownloadRequestImpl->SetFileName(fileName);
+}
+
+String
+DownloadRequest::GetUrl(void) const
+{
+ return __pDownloadRequestImpl->GetUrl();
+}
+
+String
+DownloadRequest::GetDirectoryPath(void) const
+{
+ return __pDownloadRequestImpl->GetDirectoryPath();
+}
+
+String
+DownloadRequest::GetFileName(void) const
+{
+ return __pDownloadRequestImpl->GetFileName();
+}
+
+} } // Tizen::Content
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntImageContentInfo.cpp
+ * @brief This is the implementation file for the %ImageContentInfo class.
+ *
+ * This file contains implementation of the %ImageContentInfo class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FCntImageContentInfo.h>
+#include <FIoFile.h>
+#include <FIoDirectory.h>
+#include <FSysEnvironment.h>
+//#include <FLocLocationProvider.h>
+//#include <FLocQualifiedCoordinates.h>
+#include <FIo_FileImpl.h>
+#include <FApp_AppInfo.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Locations;
+using namespace Tizen::App;
+using namespace Tizen::System;
+using namespace std;
+
+namespace Tizen { namespace Content
+{
+
+ImageContentInfo::ImageContentInfo(void)
+ : ContentInfo()
+ , __pImageContentData(null)
+ , __pImpl(null)
+{
+
+}
+
+ImageContentInfo::~ImageContentInfo(void)
+{
+ if (__pImageContentData != null)
+ {
+ delete __pImageContentData;
+ __pImageContentData = null;
+ }
+}
+
+/**
+ * E_SUCCESS
+ * E_FILE_NOT_FOUND
+ * E_INVALID_ARG
+ * E_OUT_OF_MEMORY
+ * - E_IO
+ */
+result
+ImageContentInfo::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
+{
+ ClearLastResult();
+
+ SysAssertf(__pImageContentData == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ result r = E_SUCCESS;
+ _ContentData contentData;
+ int contentLength = 0;
+ FileAttributes attribute;
+
+ // checks parameters
+ contentLength = contentPath.GetLength();
+ SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
+ "The contentPath should start with /Media or /Storagecard/Media(%ls).", contentPath.GetPointer());
+ SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
+ "The file corresponding to contentPath could not be found.");
+
+ if (!thumbnailPath.IsEmpty())
+ {
+ SysLog(NID_CNT,
+ "The thumbnailPath is not supported but you can get the thumbnail managed by Tizen from ContentInfo::GetThumbnailN().");
+ }
+
+ if (setGps)
+ {
+ SysLog(NID_CNT, "The setGps is not supported.");
+ }
+
+ // Sets the content path
+ contentData.contentPath = contentPath;
+
+ // Sets the content type
+ contentData.contentType = CONTENT_TYPE_IMAGE;
+
+ // E_INVALID_ARG, E_OUT_OF_MEMORY
+ r = SetContentData(&contentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");
+
+ _ImageContentData* pImageContentData = new (nothrow) _ImageContentData();
+ SysTryReturnResult(NID_CNT, pImageContentData != null, E_OUT_OF_MEMORY, "Construct() failed.");
+
+ __pImageContentData = pImageContentData;
+
+ return r;
+}
+
+/**
+ * E_SUCCESS
+ * E_FILE_NOT_FOUND
+ * E_INVALID_ARG
+ * E_OUT_OF_MEMORY
+ * - E_IO
+ * - E_SYSTEM
+ */
+result
+ImageContentInfo::Construct(const String* pContentPath)
+{
+ ClearLastResult();
+
+ SysAssertf(__pImageContentData == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ result r = E_SUCCESS;
+ _ContentData contentData;
+
+ if (pContentPath != null)
+ {
+ if (!_AppInfo::IsOspCompat())
+ {
+ if (pContentPath->StartsWith(OSP_MEDIA_PHONE, 0) || pContentPath->StartsWith(OSP_MEDIA_MMC, 0))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] /Media/ and /Storagecard/Media/ are not supported from Tizen 2.0.");
+ return E_INVALID_ARG;
+ }
+ if (!(pContentPath->StartsWith(Environment::GetMediaPath(), 0)
+ || pContentPath->StartsWith(Environment::GetExternalStoragePath(), 0)))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] %ls is not supported.", pContentPath->GetPointer());
+ return E_INVALID_ARG;
+ }
+ }
+ else
+ {
+ // prior to 2.0
+ if (pContentPath->StartsWith(OSP_MEDIA_PHONE, 0))
+ {
+ // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
+ // it should be converted in 2.0.
+ r = (const_cast<String*>(pContentPath))->Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+ }
+ else if (pContentPath->StartsWith(OSP_MEDIA_MMC, 0))
+ {
+ r = (const_cast<String*>(pContentPath))->Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
+ return E_INVALID_ARG;
+ }
+ }
+
+ int length = pContentPath->GetLength();
+ SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG,
+ "The length of pContentPath is 0.");
+ SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND,
+ "The file corresponding to pContentPath could not be found.");
+
+ // Sets the content path
+ contentData.contentPath = *pContentPath;
+
+ // Sets the content type
+ contentData.contentType = CONTENT_TYPE_IMAGE;
+
+ r = SetContentData(&contentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");
+ }
+ else
+ {
+ contentData.contentType = CONTENT_TYPE_IMAGE;
+
+ r = SetContentData(&contentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");
+ }
+
+ _ImageContentData* pImageContentData = new (nothrow) _ImageContentData();
+ SysTryReturnResult(NID_CNT, pImageContentData != null, E_OUT_OF_MEMORY, "Construct() failed.");
+
+ __pImageContentData = pImageContentData;
+
+ return r;
+}
+
+result
+ImageContentInfo::SetImageContentData(const _ImageContentData* pImageContentData)
+{
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, pImageContentData != null, E_INVALID_ARG, "pImageContentData is null.");
+
+ // _ContentManagerImpl::GetContentInfoN makes an instance of this class. at that time it does not call Construct().
+ // Because __pImageContentData is created in Construct(), If there is no codes for allocation, crash will occur.
+ if (__pImageContentData == null)
+ {
+ __pImageContentData = new (nothrow) _ImageContentData;
+ SysTryReturnResult(NID_CNT, __pImageContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+
+ __pImageContentData->width = pImageContentData->width;
+ __pImageContentData->height = pImageContentData->height;
+ __pImageContentData->orientationType = pImageContentData->orientationType;
+ __pImageContentData->title = pImageContentData->title;
+
+ return E_SUCCESS;
+}
+
+ImageContentInfo::_ImageContentData*
+ImageContentInfo::GetImageContentData(void)
+{
+ if (__pImageContentData == null)
+ {
+ __pImageContentData = new (nothrow) ImageContentInfo::_ImageContentData;
+ SysTryReturn(NID_CNT, __pImageContentData != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ return __pImageContentData;
+}
+
+int
+ImageContentInfo::GetWidth(void) const
+{
+ SysAssertf(__pImageContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImageContentData->width;
+}
+
+int
+ImageContentInfo::GetHeight(void) const
+{
+ SysAssertf(__pImageContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImageContentData->height;
+}
+
+ImageOrientationType
+ImageContentInfo::GetOrientation(void) const
+{
+ SysAssertf(__pImageContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImageContentData->orientationType;
+}
+
+String
+ImageContentInfo::GetTitle(void) const
+{
+ SysAssertf(__pImageContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if ((__pImageContentData->title).IsEmpty())
+ {
+ return String(L"Unknown");
+ }
+
+ return __pImageContentData->title;
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntImageMetadata.cpp
+ * @brief This is the implementation file for the %ImageMetadata class.
+ *
+ * This file contains implementation of the %ImageMetadata class.
+ */
+
+// includes
+#include <FBaseSysLog.h>
+#include <FCntImageMetadata.h>
+#include <FCnt_ImageMetadataImpl.h>
+
+// using namespaces
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Content
+{
+
+ImageMetadata::ImageMetadata(void)
+ : Object()
+ , __pImpl(new (std::nothrow) _ImageMetadataImpl())
+{
+
+}
+
+ImageMetadata::~ImageMetadata(void)
+{
+ if (__pImpl != null)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+ImageMetadata::ImageMetadata(const ImageMetadata& rhs)
+ : Tizen::Base::Object()
+ , __pImpl(new (std::nothrow) _ImageMetadataImpl(*rhs.__pImpl))
+{
+
+}
+
+ImageMetadata&
+ImageMetadata::operator =(const ImageMetadata& rhs)
+{
+ // check for self-assignment
+ if (this == &rhs)
+ {
+ return *this;
+ }
+
+ *__pImpl = *rhs.__pImpl;
+
+ return *this;
+}
+
+int
+ImageMetadata::GetHashCode(void) const
+{
+ return __pImpl->GetHashCode();
+}
+
+bool
+ImageMetadata::Equals(const Object& rhs) const
+{
+ const ImageMetadata* pRhs = dynamic_cast <const ImageMetadata*>(&rhs);
+ if (pRhs == null)
+ {
+ return false;
+ }
+
+ return __pImpl->Equals(*pRhs->__pImpl);
+}
+
+int
+ImageMetadata::GetWidth(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetWidth();
+}
+
+int
+ImageMetadata::GetHeight(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetHeight();
+}
+
+String
+ImageMetadata::GetCameraManufacturer(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetCameraManufacturer();
+}
+
+String
+ImageMetadata::GetCameraModel(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetCameraModel();
+}
+
+String
+ImageMetadata::GetSoftware(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetSoftware();
+}
+
+String
+ImageMetadata::GetDateTime(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetDateTime();
+}
+
+double
+ImageMetadata::GetLatitude(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetLatitude();
+}
+
+double
+ImageMetadata::GetLongitude(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetLongitude();
+}
+
+ImageOrientationType
+ImageMetadata::GetOrientation(void) const
+{
+ if (__pImpl == null)
+ {
+ return IMAGE_ORIENTATION_TYPE_UNKNOWN;
+ }
+ return __pImpl->GetOrientation();
+}
+
+String
+ImageMetadata::GetWhiteBalance(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetWhiteBalance();
+}
+
+Bitmap*
+ImageMetadata::GetThumbnailN(void) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ Bitmap* pBitmap = null;
+
+ SysTryReturn(NID_CNT, __pImpl != null, null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] GetThumbnailN failed.");
+
+ pBitmap = __pImpl->GetThumbnailN();
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, pBitmap != null, null, r, "[%s] GetThumbnailN failed.", GetErrorMessage(r));
+
+ return pBitmap;
+}
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntOtherContentInfo.cpp
+ * @brief This is the implementation file for the %OtherContentInfo class.
+ *
+ * This file contains implementation of the %OtherContentInfo class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FCntOtherContentInfo.h>
+#include <FIoFile.h>
+#include <FIoDirectory.h>
+#include <FSysEnvironment.h>
+//#include <FLocLocationProvider.h>
+//#include <FLocQualifiedCoordinates.h>
+#include <FIo_FileImpl.h>
+#include <FApp_AppInfo.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Locations;
+using namespace Tizen::App;
+using namespace Tizen::System;
+
+namespace Tizen { namespace Content
+{
+
+OtherContentInfo::OtherContentInfo(void)
+ : ContentInfo()
+ , __isCreated(false)
+ , __pImpl(null)
+{
+
+}
+
+OtherContentInfo::~OtherContentInfo(void)
+{
+
+}
+
+/**
+ * E_SUCCESS
+ * E_FILE_NOT_FOUND
+ * E_INVALID_ARG
+ * E_OUT_OF_MEMORY
+ * - E_IO
+ */
+result
+OtherContentInfo::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
+{
+ ClearLastResult();
+
+ SysAssertf(!__isCreated, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ result r = E_SUCCESS;
+ _ContentData contentData;
+ int contentLength = 0;
+ FileAttributes attribute;
+
+ // checks parameters
+ contentLength = contentPath.GetLength();
+ SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
+ "The contentPath should start with /Media or /Storagecard/Media(%ls).", contentPath.GetPointer());
+ SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
+ "The file corresponding to contentPath could not be found.");
+
+ if (thumbnailPath.GetLength() > 0)
+ {
+ SysLog(NID_CNT, "The thumbnailPath is not supported.");
+ }
+
+ if (setGps)
+ {
+ SysLog(NID_CNT, "The setGps is not supported.");
+ }
+
+ // Sets the content path
+ contentData.contentPath = contentPath;
+
+ // Sets the content type
+ contentData.contentType = CONTENT_TYPE_OTHER;
+
+ // E_INVALID_ARG, E_OUT_OF_MEMORY
+ r = SetContentData(&contentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+
+ __isCreated = true;
+ return r;
+}
+
+/**
+ * E_SUCCESS
+ * E_FILE_NOT_FOUND
+ * E_INVALID_ARG
+ * E_OUT_OF_MEMORY
+ * - E_IO
+ * - E_SYSTEM
+ */
+result
+OtherContentInfo::Construct(const String* pContentPath)
+{
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+ _ContentData contentData;
+
+ SysAssertf(!__isCreated,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ if (pContentPath != null)
+ {
+ if (!_AppInfo::IsOspCompat())
+ {
+ if (pContentPath->StartsWith(OSP_MEDIA_PHONE, 0) || pContentPath->StartsWith(OSP_MEDIA_MMC, 0))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] /Media/ and /Storagecard/Media/ are not supported from Tizen 2.0.");
+ return E_INVALID_ARG;
+ }
+ if (!(pContentPath->StartsWith(Environment::GetMediaPath(), 0)
+ || pContentPath->StartsWith(Environment::GetExternalStoragePath(), 0)))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] %ls is not supported.", pContentPath->GetPointer());
+ return E_INVALID_ARG;
+ }
+ }
+ else
+ {
+ // prior to 2.0
+ if (pContentPath->StartsWith(OSP_MEDIA_PHONE, 0))
+ {
+ // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
+ // it should be converted in 2.0.
+ r = (const_cast<String*>(pContentPath))->Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+ }
+ else if (pContentPath->StartsWith(OSP_MEDIA_MMC, 0))
+ {
+ r = (const_cast<String*>(pContentPath))->Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
+ return E_INVALID_ARG;
+ }
+ }
+
+ int length = pContentPath->GetLength();
+ SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG, "The length of pContentPath is 0.");
+ SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND, "The file corresponding to pContentPath could not be found.");
+
+ // Sets the content path
+ contentData.contentPath = *pContentPath;
+
+ // Sets the content type
+ contentData.contentType = CONTENT_TYPE_OTHER;
+
+ r = SetContentData(&contentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");
+ }
+ else
+ {
+ contentData.contentType = CONTENT_TYPE_OTHER;
+
+ r = SetContentData(&contentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");
+ }
+
+ __isCreated = true;
+ return r;
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntPlayList.cpp
+ * @brief This is the implementation file for the %PlayList class.
+ *
+ * This is the implementation file for %PlayList class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FCntPlayList.h>
+#include <FBaseColIList.h>
+#include <FIoFile.h>
+#include <FSysEnvironment.h>
+#include <FCnt_PlayListImpl.h>
+
+using namespace Tizen::Io;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::System;
+
+namespace Tizen { namespace Content
+{
+
+PlayList::PlayList()
+ : Object()
+ , __pImpl(NULL)
+ , __playListName(L"")
+{
+}
+
+PlayList::~PlayList(void)
+{
+ delete __pImpl;
+}
+
+result
+PlayList::Construct(const Tizen::Base::String& playListName)
+{
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ SysTryReturn(NID_CNT, !playListName.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
+
+ _PlayListImpl* pPlayListImpl = new (std::nothrow) _PlayListImpl();
+ SysTryReturn(NID_CNT, pPlayListImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
+
+ r = pPlayListImpl->Construct(playListName);
+ SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pImpl = pPlayListImpl;
+
+ __playListName = playListName;
+
+ return r;
+
+CATCH:
+ delete pPlayListImpl;
+ return r;
+}
+
+result
+PlayList::ConstructPlayList(const Tizen::Base::String& playListName)
+{
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ SysTryReturn(NID_CNT, !playListName.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
+
+ _PlayListImpl* pPlayListImpl = new (std::nothrow) _PlayListImpl();
+ SysTryReturn(NID_CNT, pPlayListImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
+
+ r = pPlayListImpl->Construct(playListName, false);
+ SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pImpl = pPlayListImpl;
+
+ __playListName = playListName;
+
+ return r;
+
+CATCH:
+ delete pPlayListImpl;
+ return r;
+}
+
+int
+PlayList::GetPlayListItemCount(void) const
+{
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return (__pImpl->GetPlayListItemCount(__playListName));
+
+}
+
+Tizen::Base::Collection::IList*
+PlayList::GetContentInfoListN(void) const
+{
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return (__pImpl->GetContentInfoListN(__playListName));
+}
+
+result
+PlayList::AddItem(const ContentId& contentId)
+{
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
+
+ return (__pImpl->AddItem(__playListName, contentId));
+}
+
+result
+PlayList::AddItems(const Tizen::Base::Collection::IList& contentIdList)
+{
+ int listCount = contentIdList.GetCount();
+ ContentId *pContentId = NULL;
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ SysTryReturn(NID_CNT, listCount > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentIdList count is zero");
+
+ for (int index = 0; index < listCount; index++)
+ {
+ pContentId = (ContentId*)contentIdList.GetAt(index);
+ SysTryReturn(NID_CNT, *pContentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
+ }
+
+ return (__pImpl->AddItems(__playListName, contentIdList));
+}
+
+result
+PlayList::RemoveItem(const ContentId& contentId)
+{
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
+
+ return (__pImpl->RemoveItem(contentId));
+}
+
+result
+PlayList::RemoveItems(const Tizen::Base::Collection::IList& contentIdList)
+{
+ int listCount = contentIdList.GetCount();
+ ContentId *pContentId = NULL;
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ SysTryReturn(NID_CNT, listCount > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentIdList count is zero");
+
+ for (int index = 0; index < listCount; index++)
+ {
+ pContentId = (ContentId*)contentIdList.GetAt(index);
+ SysTryReturn(NID_CNT, *pContentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
+ }
+
+ return (__pImpl->RemoveItems(contentIdList));
+}
+
+Tizen::Base::String
+PlayList::GetPlayListName(void) const
+{
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+ return __playListName;
+}
+
+result
+PlayList::SetPlayListName(const Tizen::Base::String& playListName)
+{
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ 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));
+
+ __playListName = playListName;
+
+ return r;
+}
+
+int
+PlayList::GetPlayOrder(const ContentId& contentId) const
+{
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] contentId is not valid");
+
+ return (__pImpl->GetPlayOrder(contentId));
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntPlayListManager.cpp
+ * @brief This is the implementation file for the %PlayListManager class.
+ *
+ * This is the implementation file for %PlayListManager class.
+ */
+
+#include <memory>
+#include <pthread.h>
+#include <stdlib.h>
+#include <FBaseSysLog.h>
+#include <FCntPlayListManager.h>
+#include <FBaseColIList.h>
+#include <FIoFile.h>
+#include <FSysEnvironment.h>
+#include <FCnt_PlayListManagerImpl.h>
+
+using namespace Tizen::Io;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::System;
+
+namespace Tizen { namespace Content
+{
+
+PlayListManager* PlayListManager::__pPlayListManager = NULL;
+
+PlayListManager::PlayListManager(void)
+ : Object()
+ , __pImpl(null)
+{
+}
+
+PlayListManager::~PlayListManager(void)
+{
+ delete __pImpl;
+}
+
+PlayListManager*
+PlayListManager::GetInstance(void)
+{
+ static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+
+ if (!__pPlayListManager)
+ {
+ ClearLastResult();
+ pthread_once(&onceBlock, InitSingleton);
+ result r = GetLastResult();
+ if (IsFailed(r))
+ {
+ onceBlock = PTHREAD_ONCE_INIT;
+ }
+ }
+ return __pPlayListManager;
+}
+
+void
+PlayListManager::InitSingleton(void)
+{
+ __pPlayListManager = new (std::nothrow) PlayListManager();
+ SysTryReturnVoidResult(NID_CNT, __pPlayListManager, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
+ result r = __pPlayListManager->Construct();
+ SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating from PlayListManager Construct.", GetErrorMessage(r));
+
+ atexit(DestroySingleton);
+
+ return;
+
+CATCH:
+ delete __pPlayListManager;
+}
+
+void
+PlayListManager::DestroySingleton(void)
+{
+ delete __pPlayListManager;
+}
+
+result
+PlayListManager::Construct(void)
+{
+ result r = E_SUCCESS;
+
+ SysAssertf(__pImpl == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ _PlayListManagerImpl* pPlayListManagerImpl = new (std::nothrow) _PlayListManagerImpl();
+ SysTryReturn(NID_CNT, pPlayListManagerImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
+
+ r = pPlayListManagerImpl->Construct();
+ SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pImpl = pPlayListManagerImpl;
+
+ return E_SUCCESS;
+
+CATCH:
+ delete pPlayListManagerImpl;
+ return r;
+}
+
+PlayList*
+PlayListManager::GetPlayListN(const Tizen::Base::String& playListName) const
+{
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ SysTryReturn(NID_CNT, !playListName.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
+
+ return __pImpl->GetPlayListN(playListName);
+}
+
+result
+PlayListManager::RemovePlayList(const Tizen::Base::String& playListName)
+{
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ SysTryReturn(NID_CNT, !playListName.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
+
+ return __pImpl->RemovePlayList(playListName);
+}
+
+int
+PlayListManager::GetAllPlayListCount(void) const
+{
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->GetAllPlayListCount();
+}
+
+Tizen::Base::Collection::IList*
+PlayListManager::GetAllPlayListNameN(void) const
+{
+ ClearLastResult();
+
+ SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pImpl->GetAllPlayListNameN();
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntVideoContentInfo.cpp
+ * @brief This is the implementation file for the %VideoContentInfo class.
+ *
+ * This file contains implementation of the %VideoContentInfo class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FCntVideoContentInfo.h>
+#include <FCntContentManagerUtil.h>
+#include <FCntVideoMetadata.h>
+#include <FIoFile.h>
+#include <FIoDirectory.h>
+#include <FSysEnvironment.h>
+//#include <FLocLocationProvider.h>
+//#include <FLocQualifiedCoordinates.h>
+#include <FIo_FileImpl.h>
+#include <FApp_AppInfo.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Locations;
+using namespace Tizen::App;
+using namespace Tizen::System;
+using namespace std;
+
+namespace Tizen { namespace Content
+{
+
+VideoContentInfo::VideoContentInfo(void)
+ : ContentInfo()
+ , __pVideoContentData(null)
+ , __pImpl(null)
+{
+
+}
+
+VideoContentInfo::~VideoContentInfo(void)
+{
+ if (__pVideoContentData != null)
+ {
+ if (__pVideoContentData->pArtist != null)
+ {
+ delete __pVideoContentData->pArtist;
+ __pVideoContentData->pArtist = null;
+ }
+ if (__pVideoContentData->pGenre != null)
+ {
+ delete __pVideoContentData->pGenre;
+ __pVideoContentData->pGenre = null;
+ }
+ if (__pVideoContentData->pTitle != null)
+ {
+ delete __pVideoContentData->pTitle;
+ __pVideoContentData->pTitle = null;
+ }
+ if (__pVideoContentData->pAlbumName != null)
+ {
+ delete __pVideoContentData->pAlbumName;
+ __pVideoContentData->pAlbumName = null;
+ }
+ delete __pVideoContentData;
+ __pVideoContentData = null;
+ }
+}
+
+/**
+ * E_SUCCESS
+ * E_FILE_NOT_FOUND
+ * E_INVALID_ARG
+ * E_OUT_OF_MEMORY
+ * - E_IO
+ */
+result
+VideoContentInfo::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
+{
+ SysAssertf(__pVideoContentData == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+ _ContentData contentData;
+ int contentLength = 0;
+ FileAttributes attribute;
+
+ // checks parameters
+ contentLength = contentPath.GetLength();
+ SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
+ "The contentPath should start with /Media or /Storagecard/Media(%ls).", contentPath.GetPointer());
+ SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
+ "The file corresponding to contentPath could not be found.");
+
+ if (!thumbnailPath.IsEmpty())
+ {
+ SysLog(NID_CNT,
+ "The thumbnailPath is not supported but you can get the thumbnail managed by Tizen from ContentInfo::GetThumbnailN().");
+ }
+
+ if (setGps)
+ {
+ SysLog(NID_CNT, "The setGps is not supported.");
+ }
+
+ // Sets the content path
+ contentData.contentPath = contentPath;
+
+ // Sets the content type
+ contentData.contentType = CONTENT_TYPE_VIDEO;
+
+ // E_INVALID_ARG, E_OUT_OF_MEMORY
+ r = SetContentData(&contentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");
+
+ _VideoContentData* pVideoContentData = new (nothrow) _VideoContentData();
+ SysTryReturnResult(NID_CNT, pVideoContentData != null, E_OUT_OF_MEMORY, "Construct() failed.");
+
+ __pVideoContentData = pVideoContentData;
+
+ return r;
+}
+
+/**
+ * E_SUCCESS
+ * E_FILE_NOT_FOUND
+ * E_INVALID_ARG
+ * E_OUT_OF_MEMORY
+ * - E_IO
+ * - E_SYSTEM
+ */
+result
+VideoContentInfo::Construct(const String* pContentPath)
+{
+ SysAssertf(__pVideoContentData == null,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+ _ContentData contentData;
+
+ if (pContentPath != null)
+ {
+ if (!_AppInfo::IsOspCompat())
+ {
+ if (pContentPath->StartsWith(OSP_MEDIA_PHONE, 0) || pContentPath->StartsWith(OSP_MEDIA_MMC, 0))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] /Media/ and /Storagecard/Media/ are not supported from Tizen 2.0.");
+ return E_INVALID_ARG;
+ }
+ if (!(pContentPath->StartsWith(Environment::GetMediaPath(), 0)
+ || pContentPath->StartsWith(Environment::GetExternalStoragePath(), 0)))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] %ls is not supported.", pContentPath->GetPointer());
+ return E_INVALID_ARG;
+ }
+ }
+ else
+ {
+ // prior to 2.0
+ if (pContentPath->StartsWith(OSP_MEDIA_PHONE, 0))
+ {
+ // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
+ // it should be converted in 2.0.
+ r = (const_cast<String*>(pContentPath))->Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+ }
+ else if (pContentPath->StartsWith(OSP_MEDIA_MMC, 0))
+ {
+ r = (const_cast<String*>(pContentPath))->Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
+ return E_INVALID_ARG;
+ }
+ }
+
+ int length = pContentPath->GetLength();
+ SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG,
+ "The length of pContentPath is 0.");
+ SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND,
+ "The file corresponding to pContentPath could not be found.");
+
+ // Sets the content path
+ contentData.contentPath = *pContentPath;
+
+ // Sets the content type
+ contentData.contentType = CONTENT_TYPE_VIDEO;
+
+ r = SetContentData(&contentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");
+ }
+ else
+ {
+ contentData.contentType = CONTENT_TYPE_VIDEO;
+
+ r = SetContentData(&contentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");
+ }
+
+
+ _VideoContentData* pVideoContentData = new (nothrow) _VideoContentData();
+ SysTryReturnResult(NID_CNT, pVideoContentData != null, E_OUT_OF_MEMORY, "Construct() failed.");
+
+ __pVideoContentData = pVideoContentData;
+
+ return r;
+}
+
+result
+VideoContentInfo::SetVideoContentData(const _VideoContentData* pVideoContentData)
+{
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, pVideoContentData != null, E_INVALID_ARG, "pVideoContentData is null.");
+
+ if (__pVideoContentData == null)
+ {
+ __pVideoContentData = new (nothrow) _VideoContentData;
+ SysTryReturnResult(NID_CNT, __pVideoContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+
+ __pVideoContentData->width = pVideoContentData->width;
+ __pVideoContentData->height = pVideoContentData->height;
+ __pVideoContentData->framerate = pVideoContentData->framerate;
+ __pVideoContentData->audioBitrate = pVideoContentData->audioBitrate;
+ __pVideoContentData->videoBitrate = pVideoContentData->videoBitrate;
+ __pVideoContentData->duration = pVideoContentData->duration;
+
+ if (pVideoContentData->pArtist != null)
+ {
+ __pVideoContentData->pArtist = new (nothrow) String(*(pVideoContentData->pArtist));
+ SysTryReturnResult(NID_CNT, __pVideoContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pVideoContentData->pGenre != null)
+ {
+ __pVideoContentData->pGenre = new (nothrow) String(*(pVideoContentData->pGenre));
+ SysTryReturnResult(NID_CNT, __pVideoContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pVideoContentData->pTitle != null)
+ {
+ __pVideoContentData->pTitle = new (nothrow) String(*(pVideoContentData->pTitle));
+ SysTryReturnResult(NID_CNT, __pVideoContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pVideoContentData->pAlbumName != null)
+ {
+ __pVideoContentData->pAlbumName = new (nothrow) String(*(pVideoContentData->pAlbumName));
+ SysTryReturnResult(NID_CNT, __pVideoContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+
+ return E_SUCCESS;
+}
+
+VideoContentInfo::_VideoContentData*
+VideoContentInfo::GetVideoContentData(void)
+{
+ if (__pVideoContentData == null)
+ {
+ __pVideoContentData = new (nothrow) VideoContentInfo::_VideoContentData;
+ SysTryReturn(NID_CNT, __pVideoContentData != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ return __pVideoContentData;
+}
+
+String
+VideoContentInfo::GetGenre(void) const
+{
+ SysAssertf(__pVideoContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pVideoContentData->pGenre == null)
+ {
+ SysLog(NID_CNT, "GetGenre() failed.");
+ return String(L"Unknown");
+ }
+
+ return *(__pVideoContentData->pGenre);
+}
+
+String
+VideoContentInfo::GetArtist(void) const
+{
+ SysAssertf(__pVideoContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pVideoContentData->pArtist == null)
+ {
+ SysLog(NID_CNT, "GetArtist() failed.");
+ return String(L"Unknown");
+ }
+
+ return *(__pVideoContentData->pArtist);
+}
+
+int
+VideoContentInfo::GetBitrate(void) const
+{
+ SysAssertf(__pVideoContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pVideoContentData->audioBitrate == 0)
+ {
+ // The audio bitrate is not managed in video table.
+ if (this->GetVideoMetadata() != E_SUCCESS)
+ {
+ SysLog(NID_CNT, "GetBitrate() failed.");
+ return 0;
+ }
+ }
+
+ return __pVideoContentData->audioBitrate;
+}
+
+int
+VideoContentInfo::GetAudioBitrate(void) const
+{
+ SysAssertf(__pVideoContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pVideoContentData->audioBitrate == 0)
+ {
+ // The audio bitrate is not managed in video table.
+ if (this->GetVideoMetadata() != E_SUCCESS)
+ {
+ SysLog(NID_CNT, "GetAudioBitrate() failed.");
+ return 0;
+ }
+ }
+
+ return __pVideoContentData->audioBitrate;
+}
+
+int
+VideoContentInfo::GetVideoBitrate(void) const
+{
+ SysAssertf(__pVideoContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pVideoContentData->videoBitrate == 0)
+ {
+ // The video bitrate is not managed in video table.
+ if (this->GetVideoMetadata() != E_SUCCESS)
+ {
+ SysLog(NID_CNT, "GetVideoBitrate() failed.");
+ return 0;
+ }
+ }
+
+ return __pVideoContentData->videoBitrate;
+}
+
+int
+VideoContentInfo::GetFramerate(void) const
+{
+ SysAssertf(__pVideoContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pVideoContentData->framerate == 0)
+ {
+ // The framerate is not managed in video table.
+ if (this->GetVideoMetadata() != E_SUCCESS)
+ {
+ SysLog(NID_CNT, "GetFramerate() failed.");
+ return 0;
+ }
+ }
+
+ return __pVideoContentData->framerate;
+}
+
+int
+VideoContentInfo::GetWidth(void) const
+{
+ SysAssertf(__pVideoContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pVideoContentData->width;
+}
+
+int
+VideoContentInfo::GetHeight(void) const
+{
+ SysAssertf(__pVideoContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pVideoContentData->height;
+}
+
+String
+VideoContentInfo::GetTitle(void) const
+{
+ SysAssertf(__pVideoContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pVideoContentData->pTitle == null)
+ {
+ SysLog(NID_CNT, "GetTitle() failed.");
+ return String(L"Unknown");
+ }
+
+ return *(__pVideoContentData->pTitle);
+}
+
+String
+VideoContentInfo::GetAlbumName(void) const
+{
+ SysAssertf(__pVideoContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (__pVideoContentData->pAlbumName == null)
+ {
+ SysLog(NID_CNT, "GetAlbumName() failed.");
+ return String(L"Unknown");
+ }
+
+ return *(__pVideoContentData->pAlbumName);
+}
+
+long
+VideoContentInfo::GetDuration(void) const
+{
+ SysAssertf(__pVideoContentData != null, "Not yet constructed. Construct() should be called before use.");
+
+ return __pVideoContentData->duration;
+}
+
+result
+VideoContentInfo::GetVideoMetadata(void) const
+{
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+
+ VideoMetadata* pVideoMetadata = ContentManagerUtil::GetVideoMetaN(this->GetContentPath());
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, pVideoMetadata != null, r, r, "[%s] GetVideoMetadata() failed.", GetErrorMessage(r));
+
+ // framerate
+ __pVideoContentData->framerate = pVideoMetadata->GetFramerate();
+
+ // audioBitrate
+ __pVideoContentData->audioBitrate = pVideoMetadata->GetAudioBitrate();
+
+ // videoBitrate
+ __pVideoContentData->videoBitrate = pVideoMetadata->GetVideoBitrate();
+
+ delete pVideoMetadata;
+
+ return r;
+}
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntVideoMetadata.cpp
+ * @brief This is the implementation file for the %VideoMetadata class.
+ *
+ * This file contains implementation of the %VideoMetadata class.
+ */
+
+// includes
+#include <FBaseSysLog.h>
+#include <FCntVideoMetadata.h>
+#include <FCnt_VideoMetadataImpl.h>
+
+// using namespaces
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Content
+{
+
+VideoMetadata::VideoMetadata(void)
+ : Object()
+ , __pImpl(new (std::nothrow) _VideoMetadataImpl())
+{
+
+}
+
+VideoMetadata::~VideoMetadata(void)
+{
+ if (__pImpl != null)
+ {
+ delete __pImpl;
+ __pImpl = null;
+ }
+}
+
+VideoMetadata::VideoMetadata(const VideoMetadata& rhs)
+ : Tizen::Base::Object()
+ , __pImpl(new (std::nothrow) _VideoMetadataImpl(*rhs.__pImpl))
+{
+
+}
+
+VideoMetadata&
+VideoMetadata::operator =(const VideoMetadata& rhs)
+{
+ // check for self-assignment
+ if (this == &rhs)
+ {
+ return *this;
+ }
+
+ *__pImpl = *rhs.__pImpl;
+
+ return *this;
+}
+
+int
+VideoMetadata::GetHashCode(void) const
+{
+ return __pImpl->GetHashCode();
+}
+
+bool
+VideoMetadata::Equals(const Object& rhs) const
+{
+ const VideoMetadata* pRhs = dynamic_cast <const VideoMetadata*>(&rhs);
+ if (pRhs == null)
+ {
+ return false;
+ }
+
+ return __pImpl->Equals(*pRhs->__pImpl);
+}
+
+int
+VideoMetadata::GetWidth(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetWidth();
+}
+
+int
+VideoMetadata::GetHeight(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetHeight();
+}
+
+long
+VideoMetadata::GetDuration(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetDuration();
+}
+
+int
+VideoMetadata::GetFramerate(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetFramerate();
+}
+
+int
+VideoMetadata::GetBitrate(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetAudioBitrate();
+}
+
+int
+VideoMetadata::GetAudioBitrate(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetAudioBitrate();
+}
+
+int
+VideoMetadata::GetVideoBitrate(void) const
+{
+ if (__pImpl == null)
+ {
+ return 0;
+ }
+ return __pImpl->GetVideoBitrate();
+}
+
+String
+VideoMetadata::GetGenre(void) const
+{
+ if (__pImpl == null)
+ {
+ return String();
+ }
+ return __pImpl->GetGenre();
+}
+
+Bitmap*
+VideoMetadata::GetAlbumArtN(void) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ Bitmap* pBitmap = null;
+ SysTryReturn(NID_CNT, __pImpl != null, null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] GetAlbumArtN failed.");
+
+ pBitmap = __pImpl->GetAlbumArtN();
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, pBitmap != null, null, r, "[%s] GetAlbumArtN failed.", GetErrorMessage(r));
+
+ return pBitmap;
+}
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_AudioMetadataImpl.cpp
+ * @brief This is the implementation file for the %_AudioMetadataImpl class.
+ *
+ * This file contains implementation of the %_AudioMetadataImpl class.
+ */
+
+// includes
+#include <FBaseSysLog.h>
+#include <FCntAudioMetadata.h>
+#include <FCnt_AudioMetadataImpl.h>
+#include <FGrp_BitmapImpl.h>
+
+// using namespaces
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Content
+{
+
+_AudioMetadataImpl::_AudioMetadataImpl(void)
+ : Object()
+{
+ unique_ptr<AudioMeta, AudioMetaDeleter> pNewAudioMeta(new (nothrow) AudioMeta());
+ if (pNewAudioMeta != null)
+ {
+ __pAudioMeta = move(pNewAudioMeta);
+ }
+ else
+ {
+ __pAudioMeta = null;
+ SysLog(NID_CNT, "The memory is insufficient.");
+ }
+}
+
+_AudioMetadataImpl::~_AudioMetadataImpl(void)
+{
+
+}
+
+_AudioMetadataImpl*
+_AudioMetadataImpl::GetInstance(AudioMetadata& audioMetadata)
+{
+ return audioMetadata.__pImpl;
+}
+
+const _AudioMetadataImpl*
+_AudioMetadataImpl::GetInstance(const AudioMetadata& audioMetadata)
+{
+ return audioMetadata.__pImpl;
+}
+
+result
+_AudioMetadataImpl::SetAudioMetadata(const AudioMeta* pAudioMeta)
+{
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, pAudioMeta != null, E_INVALID_ARG, "pAudioMeta is null.");
+
+ __pAudioMeta->bitrate = pAudioMeta->bitrate;
+ __pAudioMeta->channelCount = pAudioMeta->channelCount;
+ __pAudioMeta->duration = pAudioMeta->duration;
+ __pAudioMeta->frequency = pAudioMeta->frequency;
+ __pAudioMeta->trackNum = pAudioMeta->trackNum;
+ __pAudioMeta->year = pAudioMeta->year;
+ __pAudioMeta->contentPath = pAudioMeta->contentPath;
+
+ if (pAudioMeta->pAlbumName != null)
+ {
+ __pAudioMeta->pAlbumName = new (nothrow) String(*(pAudioMeta->pAlbumName));
+ SysTryReturnResult(NID_CNT, __pAudioMeta->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioMeta->pArtist != null)
+ {
+ __pAudioMeta->pArtist = new (nothrow) String(*(pAudioMeta->pArtist));
+ SysTryReturnResult(NID_CNT, __pAudioMeta->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioMeta->pComment != null)
+ {
+ __pAudioMeta->pComment = new (nothrow) String(*(pAudioMeta->pComment));
+ SysTryReturnResult(NID_CNT, __pAudioMeta->pComment != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioMeta->pComposer != null)
+ {
+ __pAudioMeta->pComposer = new (nothrow) String(*(pAudioMeta->pComposer));
+ SysTryReturnResult(NID_CNT, __pAudioMeta->pComposer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioMeta->pCopyright != null)
+ {
+ __pAudioMeta->pCopyright = new (nothrow) String(*(pAudioMeta->pCopyright));
+ SysTryReturnResult(NID_CNT, __pAudioMeta->pCopyright != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioMeta->pGenre != null)
+ {
+ __pAudioMeta->pGenre = new (nothrow) String(*(pAudioMeta->pGenre));
+ SysTryReturnResult(NID_CNT, __pAudioMeta->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioMeta->pRecordingDate != null)
+ {
+ __pAudioMeta->pRecordingDate = new (nothrow) String(*(pAudioMeta->pRecordingDate));
+ SysTryReturnResult(NID_CNT, __pAudioMeta->pRecordingDate != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioMeta->pTitle != null)
+ {
+ __pAudioMeta->pTitle = new (nothrow) String(*(pAudioMeta->pTitle));
+ SysTryReturnResult(NID_CNT, __pAudioMeta->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioMeta->pTrackInfo != null)
+ {
+ __pAudioMeta->pTrackInfo = new (nothrow) String(*(pAudioMeta->pTrackInfo));
+ SysTryReturnResult(NID_CNT, __pAudioMeta->pTrackInfo != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pAudioMeta->pThumbnail != null)
+ {
+ __pAudioMeta->pThumbnail = _BitmapImpl::CloneN(*(pAudioMeta->pThumbnail));
+ if (__pAudioMeta->pThumbnail == null)
+ {
+ SysLog(NID_CNT, "_BitmapImpl::CloneN failed.");
+ // Because thumbnail is one of the metadata, it is not exception in this function but is exception in _AudioMetadataImpl::GetThumbnailN().
+ }
+ }
+ if (pAudioMeta->pAlbumArt != null)
+ {
+ __pAudioMeta->pAlbumArt = _BitmapImpl::CloneN(*(pAudioMeta->pAlbumArt));
+ if (__pAudioMeta->pAlbumArt == null)
+ {
+ SysLog(NID_CNT, "_BitmapImpl::CloneN failed.");
+ // Because album art is one of the metadata, it is not exception in this function but is exception in _AudioMetadataImpl::GetAlbumArtN().
+ }
+ }
+
+ return E_SUCCESS;
+}
+
+AudioMeta*
+_AudioMetadataImpl::GetAudioMetadata(void) const
+{
+ return __pAudioMeta.get();
+}
+
+_AudioMetadataImpl::_AudioMetadataImpl(const _AudioMetadataImpl& rhs)
+ : Object()
+{
+ unique_ptr<AudioMeta, AudioMetaDeleter> pNewAudioMeta(new (nothrow) AudioMeta());
+ if (pNewAudioMeta != null)
+ {
+ pNewAudioMeta->bitrate = (rhs.__pAudioMeta)->bitrate;
+ pNewAudioMeta->channelCount = (rhs.__pAudioMeta)->channelCount;
+ pNewAudioMeta->duration = (rhs.__pAudioMeta)->duration;
+ pNewAudioMeta->frequency = (rhs.__pAudioMeta)->frequency;
+ pNewAudioMeta->trackNum = (rhs.__pAudioMeta)->trackNum;
+ pNewAudioMeta->year = (rhs.__pAudioMeta)->year;
+ pNewAudioMeta->contentPath = (rhs.__pAudioMeta)->contentPath;
+
+ // pAlbumName
+ if ((rhs.__pAudioMeta)->pAlbumName != null)
+ {
+ pNewAudioMeta->pAlbumName = new (nothrow) String(*((rhs.__pAudioMeta)->pAlbumName));
+ if (pNewAudioMeta->pAlbumName == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ // pArtist
+ if ((rhs.__pAudioMeta)->pArtist != null)
+ {
+ pNewAudioMeta->pArtist = new (nothrow) String(*((rhs.__pAudioMeta)->pArtist));
+ if (pNewAudioMeta->pArtist == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ // pComment
+ if ((rhs.__pAudioMeta)->pComment != null)
+ {
+ pNewAudioMeta->pComment = new (nothrow) String(*((rhs.__pAudioMeta)->pComment));
+ if (pNewAudioMeta->pComment == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ // pComposer
+ if ((rhs.__pAudioMeta)->pComposer != null)
+ {
+ pNewAudioMeta->pComposer = new (nothrow) String(*((rhs.__pAudioMeta)->pComposer));
+ if (pNewAudioMeta->pComposer == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ // pCopyright
+ if ((rhs.__pAudioMeta)->pCopyright != null)
+ {
+ pNewAudioMeta->pCopyright = new (nothrow) String(*((rhs.__pAudioMeta)->pCopyright));
+ if (pNewAudioMeta->pCopyright == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ // pGenre
+ if ((rhs.__pAudioMeta)->pGenre != null)
+ {
+ pNewAudioMeta->pGenre = new (nothrow) String(*((rhs.__pAudioMeta)->pGenre));
+ if (pNewAudioMeta->pGenre == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ // pRecordingDate
+ if ((rhs.__pAudioMeta)->pRecordingDate != null)
+ {
+ pNewAudioMeta->pRecordingDate = new (nothrow) String(*((rhs.__pAudioMeta)->pRecordingDate));
+ if (pNewAudioMeta->pRecordingDate == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ // pTitle
+ if ((rhs.__pAudioMeta)->pTitle != null)
+ {
+ pNewAudioMeta->pTitle = new (nothrow) String(*((rhs.__pAudioMeta)->pTitle));
+ if (pNewAudioMeta->pTitle == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ // pTrackInfo
+ if ((rhs.__pAudioMeta)->pTrackInfo != null)
+ {
+ pNewAudioMeta->pTrackInfo = new (nothrow) String(*((rhs.__pAudioMeta)->pTrackInfo));
+ if (pNewAudioMeta->pTrackInfo == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ // pThumbnail
+ if ((rhs.__pAudioMeta)->pThumbnail != null)
+ {
+ pNewAudioMeta->pThumbnail = _BitmapImpl::CloneN(*((rhs.__pAudioMeta)->pThumbnail));
+ if (pNewAudioMeta->pThumbnail == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ // pAlbumArt
+ if ((rhs.__pAudioMeta)->pAlbumArt != null)
+ {
+ pNewAudioMeta->pAlbumArt = _BitmapImpl::CloneN(*((rhs.__pAudioMeta)->pAlbumArt));
+ if (pNewAudioMeta->pAlbumArt == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+
+ __pAudioMeta = move(pNewAudioMeta);
+ }
+ else
+ {
+ __pAudioMeta = null;
+ SysLog(NID_CNT, "The memory is insufficient.");
+ }
+}
+
+_AudioMetadataImpl&
+_AudioMetadataImpl::operator =(const _AudioMetadataImpl& rhs)
+{
+ // check for self-assignment
+ if (this == &rhs)
+ {
+ return *this;
+ }
+
+ // __pAudioMeta
+ if (__pAudioMeta != null && (rhs.__pAudioMeta) != null)
+ {
+ // DeleteMetadata(__pAudioMeta);
+ // __pAudioMeta = new (nothrow) AudioMeta;
+
+ __pAudioMeta.reset(new (nothrow) AudioMeta);
+ }
+ else if (__pAudioMeta != null)
+ {
+ //DeleteMetadata(__pAudioMeta);
+
+ __pAudioMeta.reset(null);
+ return *this;
+ }
+ else if ((rhs.__pAudioMeta) != null)
+ {
+ //__pAudioMeta = new (nothrow) AudioMeta;
+
+ __pAudioMeta.reset(new (nothrow) AudioMeta);
+ }
+ else
+ {
+ // __pAudioMeta and rhs.__pAudioMeta are null.
+ return *this;
+ }
+
+ __pAudioMeta->bitrate = (rhs.__pAudioMeta)->bitrate;
+ __pAudioMeta->channelCount = (rhs.__pAudioMeta)->channelCount;
+ __pAudioMeta->duration = (rhs.__pAudioMeta)->duration;
+ __pAudioMeta->frequency = (rhs.__pAudioMeta)->frequency;
+ __pAudioMeta->trackNum = (rhs.__pAudioMeta)->trackNum;
+ __pAudioMeta->year = (rhs.__pAudioMeta)->year;
+ __pAudioMeta->contentPath = (rhs.__pAudioMeta)->contentPath;
+
+ // pAlbumName
+ if (__pAudioMeta->pAlbumName != null && (rhs.__pAudioMeta)->pAlbumName != null)
+ {
+ // delete previous data
+ delete __pAudioMeta->pAlbumName;
+ __pAudioMeta->pAlbumName = null;
+
+ __pAudioMeta->pAlbumName = new (nothrow) String(*((rhs.__pAudioMeta)->pAlbumName));
+ }
+ else if (__pAudioMeta->pAlbumName != null)
+ {
+ delete __pAudioMeta->pAlbumName;
+ __pAudioMeta->pAlbumName = null;
+ }
+ else if ((rhs.__pAudioMeta)->pAlbumName != null)
+ {
+ __pAudioMeta->pAlbumName = new (nothrow) String(*((rhs.__pAudioMeta)->pAlbumName));
+ }
+
+ // pArtist
+ if (__pAudioMeta->pArtist != null && (rhs.__pAudioMeta)->pArtist != null)
+ {
+ // delete previous data
+ delete __pAudioMeta->pArtist;
+ __pAudioMeta->pArtist = null;
+
+ __pAudioMeta->pArtist = new (nothrow) String(*((rhs.__pAudioMeta)->pArtist));
+ }
+ else if (__pAudioMeta->pArtist != null)
+ {
+ delete __pAudioMeta->pArtist;
+ __pAudioMeta->pArtist = null;
+ }
+ else if ((rhs.__pAudioMeta)->pArtist != null)
+ {
+ __pAudioMeta->pArtist = new (nothrow) String(*((rhs.__pAudioMeta)->pArtist));
+ }
+
+ // pComment
+ if (__pAudioMeta->pComment != null && (rhs.__pAudioMeta)->pComment != null)
+ {
+ // delete previous data
+ delete __pAudioMeta->pComment;
+ __pAudioMeta->pComment = null;
+
+ __pAudioMeta->pComment = new (nothrow) String(*((rhs.__pAudioMeta)->pComment));
+ }
+ else if (__pAudioMeta->pComment != null)
+ {
+ delete __pAudioMeta->pComment;
+ __pAudioMeta->pComment = null;
+ }
+ else if ((rhs.__pAudioMeta)->pComment != null)
+ {
+ __pAudioMeta->pComment = new (nothrow) String(*((rhs.__pAudioMeta)->pComment));
+ }
+
+ // pComposer
+ if (__pAudioMeta->pComposer != null && (rhs.__pAudioMeta)->pComposer != null)
+ {
+ // delete previous data
+ delete __pAudioMeta->pComposer;
+ __pAudioMeta->pComposer = null;
+
+ __pAudioMeta->pComposer = new (nothrow) String(*((rhs.__pAudioMeta)->pComposer));
+ }
+ else if (__pAudioMeta->pComposer != null)
+ {
+ delete __pAudioMeta->pComposer;
+ __pAudioMeta->pComposer = null;
+ }
+ else if ((rhs.__pAudioMeta)->pComposer != null)
+ {
+ __pAudioMeta->pComposer = new (nothrow) String(*((rhs.__pAudioMeta)->pComposer));
+ }
+
+ // pCopyright
+ if (__pAudioMeta->pCopyright != null && (rhs.__pAudioMeta)->pCopyright != null)
+ {
+ // delete previous data
+ delete __pAudioMeta->pCopyright;
+ __pAudioMeta->pCopyright = null;
+
+ __pAudioMeta->pCopyright = new (nothrow) String(*((rhs.__pAudioMeta)->pCopyright));
+ }
+ else if (__pAudioMeta->pCopyright != null)
+ {
+ delete __pAudioMeta->pCopyright;
+ __pAudioMeta->pCopyright = null;
+ }
+ else if ((rhs.__pAudioMeta)->pCopyright != null)
+ {
+ __pAudioMeta->pCopyright = new (nothrow) String(*((rhs.__pAudioMeta)->pCopyright));
+ }
+
+ // pGenre
+ if (__pAudioMeta->pGenre != null && (rhs.__pAudioMeta)->pGenre != null)
+ {
+ // delete previous data
+ delete __pAudioMeta->pGenre;
+ __pAudioMeta->pGenre = null;
+
+ __pAudioMeta->pGenre = new (nothrow) String(*((rhs.__pAudioMeta)->pGenre));
+ }
+ else if (__pAudioMeta->pGenre != null)
+ {
+ delete __pAudioMeta->pGenre;
+ __pAudioMeta->pGenre = null;
+ }
+ else if ((rhs.__pAudioMeta)->pGenre != null)
+ {
+ __pAudioMeta->pGenre = new (nothrow) String(*((rhs.__pAudioMeta)->pGenre));
+ }
+
+ // pRecordingDate
+ if (__pAudioMeta->pRecordingDate != null && (rhs.__pAudioMeta)->pRecordingDate != null)
+ {
+ // delete previous data
+ delete __pAudioMeta->pRecordingDate;
+ __pAudioMeta->pRecordingDate = null;
+
+ __pAudioMeta->pRecordingDate = new (nothrow) String(*((rhs.__pAudioMeta)->pRecordingDate));
+ }
+ else if (__pAudioMeta->pRecordingDate != null)
+ {
+ delete __pAudioMeta->pRecordingDate;
+ __pAudioMeta->pRecordingDate = null;
+ }
+ else if ((rhs.__pAudioMeta)->pRecordingDate != null)
+ {
+ __pAudioMeta->pRecordingDate = new (nothrow) String(*((rhs.__pAudioMeta)->pRecordingDate));
+ }
+
+ // pTitle
+ if (__pAudioMeta->pTitle != null && (rhs.__pAudioMeta)->pTitle != null)
+ {
+ // delete previous data
+ delete __pAudioMeta->pTitle;
+ __pAudioMeta->pTitle = null;
+
+ __pAudioMeta->pTitle = new (nothrow) String(*((rhs.__pAudioMeta)->pTitle));
+ }
+ else if (__pAudioMeta->pTitle != null)
+ {
+ delete __pAudioMeta->pTitle;
+ __pAudioMeta->pTitle = null;
+ }
+ else if ((rhs.__pAudioMeta)->pTitle != null)
+ {
+ __pAudioMeta->pTitle = new (nothrow) String(*((rhs.__pAudioMeta)->pTitle));
+ }
+
+ // pTrackInfo
+ if (__pAudioMeta->pTrackInfo != null && (rhs.__pAudioMeta)->pTrackInfo != null)
+ {
+ // delete previous data
+ delete __pAudioMeta->pTrackInfo;
+ __pAudioMeta->pTrackInfo = null;
+
+ __pAudioMeta->pTrackInfo = new (nothrow) String(*((rhs.__pAudioMeta)->pTrackInfo));
+ }
+ else if (__pAudioMeta->pTrackInfo != null)
+ {
+ delete __pAudioMeta->pTrackInfo;
+ __pAudioMeta->pTrackInfo = null;
+ }
+ else if ((rhs.__pAudioMeta)->pTrackInfo != null)
+ {
+ __pAudioMeta->pTrackInfo = new (nothrow) String(*((rhs.__pAudioMeta)->pTrackInfo));
+ }
+
+ // pThumbnail
+ if (__pAudioMeta->pThumbnail != null && (rhs.__pAudioMeta)->pThumbnail != null)
+ {
+ // delete previous data
+ delete __pAudioMeta->pThumbnail;
+ __pAudioMeta->pThumbnail = null;
+
+ __pAudioMeta->pThumbnail = _BitmapImpl::CloneN(*((rhs.__pAudioMeta)->pThumbnail));
+ }
+ else if (__pAudioMeta->pThumbnail != null)
+ {
+ delete __pAudioMeta->pThumbnail;
+ __pAudioMeta->pThumbnail = null;
+ }
+ else if ((rhs.__pAudioMeta)->pThumbnail != null)
+ {
+ __pAudioMeta->pThumbnail = _BitmapImpl::CloneN(*((rhs.__pAudioMeta)->pThumbnail));
+ }
+
+ // pAlbumArt
+ if (__pAudioMeta->pAlbumArt != null && (rhs.__pAudioMeta)->pAlbumArt != null)
+ {
+ // delete previous data
+ delete __pAudioMeta->pAlbumArt;
+ __pAudioMeta->pAlbumArt = null;
+
+ __pAudioMeta->pAlbumArt = _BitmapImpl::CloneN(*((rhs.__pAudioMeta)->pAlbumArt));
+ }
+ else if (__pAudioMeta->pAlbumArt != null)
+ {
+ delete __pAudioMeta->pAlbumArt;
+ __pAudioMeta->pAlbumArt = null;
+ }
+ else if ((rhs.__pAudioMeta)->pAlbumArt != null)
+ {
+ __pAudioMeta->pAlbumArt = _BitmapImpl::CloneN(*((rhs.__pAudioMeta)->pAlbumArt));
+ }
+
+ SysLog(NID_CNT, "_AudioMetadataImpl::operator =(const _AudioMetadataImpl& rhs) is called.");
+ return *this;
+}
+
+bool
+_AudioMetadataImpl::Equals(const Tizen::Base::Object& rhs) const
+{
+ const _AudioMetadataImpl* pRhs = dynamic_cast <const _AudioMetadataImpl*>(&rhs);
+ if (pRhs == null)
+ {
+ return false;
+ }
+
+ if (!((this->GetAlbumName()).Equals(pRhs->GetAlbumName())))
+ {
+ return false;
+ }
+ if (!((this->GetArtist()).Equals(pRhs->GetArtist())))
+ {
+ return false;
+ }
+ if (this->GetBitrate() != pRhs->GetBitrate())
+ {
+ return false;
+ }
+ if (this->GetChannelCount() != pRhs->GetChannelCount())
+ {
+ return false;
+ }
+ if (!((this->GetComment()).Equals(pRhs->GetComment())))
+ {
+ return false;
+ }
+ if (!((this->GetComposer()).Equals(pRhs->GetComposer())))
+ {
+ return false;
+ }
+ if (!((this->GetCopyright()).Equals(pRhs->GetCopyright())))
+ {
+ return false;
+ }
+ if (this->GetDuration() != pRhs->GetDuration())
+ {
+ return false;
+ }
+ if (this->GetFrequency() != pRhs->GetFrequency())
+ {
+ return false;
+ }
+ if (!((this->GetGenre()).Equals(pRhs->GetGenre())))
+ {
+ return false;
+ }
+ if (!((this->GetRecordingDate()).Equals(pRhs->GetRecordingDate())))
+ {
+ return false;
+ }
+ if (!((this->GetTitle()).Equals(pRhs->GetTitle())))
+ {
+ return false;
+ }
+ if (this->GetTrack() != pRhs->GetTrack())
+ {
+ return false;
+ }
+ if (!((this->GetTrackInfo()).Equals(pRhs->GetTrackInfo())))
+ {
+ return false;
+ }
+ if (this->GetYear() != pRhs->GetYear())
+ {
+ return false;
+ }
+
+ return true;
+}
+
+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;
+}
+
+String
+_AudioMetadataImpl::GetTitle(void) const
+{
+ if (__pAudioMeta == null || __pAudioMeta->pTitle == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta or __pAudioMeta->pTitle is null.");
+ return String();
+ }
+ return *(__pAudioMeta->pTitle);
+}
+
+int
+_AudioMetadataImpl::GetBitrate(void) const
+{
+ if (__pAudioMeta == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta is null.");
+ return 0;
+ }
+ return __pAudioMeta->bitrate;
+}
+
+int
+_AudioMetadataImpl::GetFrequency(void) const
+{
+ if (__pAudioMeta == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta is null.");
+ return 0;
+ }
+ return __pAudioMeta->frequency;
+}
+
+String
+_AudioMetadataImpl::GetArtist(void) const
+{
+ if (__pAudioMeta == null || __pAudioMeta->pArtist == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta or __pAudioMeta->pArtist is null.");
+ return String();
+ }
+ return *(__pAudioMeta->pArtist);
+}
+
+String
+_AudioMetadataImpl::GetAlbumName(void) const
+{
+ if (__pAudioMeta == null || __pAudioMeta->pAlbumName == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta or __pAudioMeta->pAlbumName is null.");
+ return String();
+ }
+ return *(__pAudioMeta->pAlbumName);
+}
+
+String
+_AudioMetadataImpl::GetComment(void) const
+{
+ if (__pAudioMeta == null || __pAudioMeta->pComment == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta or __pAudioMeta->pComment is null.");
+ return String();
+ }
+ return *(__pAudioMeta->pComment);
+}
+
+int
+_AudioMetadataImpl::GetTrack(void) const
+{
+ if (__pAudioMeta == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta is null.");
+ return 0;
+ }
+ return __pAudioMeta->trackNum;
+}
+
+String
+_AudioMetadataImpl::GetGenre(void) const
+{
+ if (__pAudioMeta == null || __pAudioMeta->pGenre == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta or __pAudioMeta->pGenre is null.");
+ return String();
+ }
+ return *(__pAudioMeta->pGenre);
+}
+
+String
+_AudioMetadataImpl::GetComposer(void) const
+{
+ if (__pAudioMeta == null || __pAudioMeta->pComposer == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta or __pAudioMeta->pComposer is null.");
+ return String();
+ }
+ return *(__pAudioMeta->pComposer);
+}
+
+String
+_AudioMetadataImpl::GetCopyright(void) const
+{
+ if (__pAudioMeta == null || __pAudioMeta->pCopyright == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta or __pAudioMeta->pCopyright is null.");
+ return String();
+ }
+ return *(__pAudioMeta->pCopyright);
+}
+
+long
+_AudioMetadataImpl::GetDuration(void) const
+{
+ if (__pAudioMeta == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta is null.");
+ return 0;
+ }
+ return __pAudioMeta->duration;
+}
+
+int
+_AudioMetadataImpl::GetYear(void) const
+{
+ if (__pAudioMeta == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta is null.");
+ return 0;
+ }
+ return __pAudioMeta->year;
+}
+
+String
+_AudioMetadataImpl::GetTrackInfo(void) const
+{
+ if (__pAudioMeta == null || __pAudioMeta->pTrackInfo == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta or __pAudioMeta->pTrackInfo is null.");
+ return String();
+ }
+ return *(__pAudioMeta->pTrackInfo);
+}
+
+String
+_AudioMetadataImpl::GetRecordingDate(void) const
+{
+ if (__pAudioMeta == null || __pAudioMeta->pRecordingDate == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta or __pAudioMeta->pRecordingDate is null.");
+ return String();
+ }
+ return *(__pAudioMeta->pRecordingDate);
+}
+
+int
+_AudioMetadataImpl::GetChannelCount(void) const
+{
+ if (__pAudioMeta == null)
+ {
+ SysLog(NID_CNT, "__pAudioMeta is null.");
+ return 0;
+ }
+ return __pAudioMeta->channelCount;
+}
+
+//
+// E_SUCCESS
+// E_DATA_NOT_FOUND
+// - E_OUT_OF_MEMORY
+//
+Bitmap*
+_AudioMetadataImpl::GetThumbnailN(void) const
+{
+ ClearLastResult();
+
+ if (__pAudioMeta == null || __pAudioMeta->pThumbnail == null)
+ {
+ SysLogException(NID_CNT, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] __pAudioMeta or __pAudioMeta->pThumbnail is null.");
+ return null;
+ }
+
+ Bitmap* pBitmap = _BitmapImpl::CloneN(*(__pAudioMeta->pThumbnail));
+ SysTryReturn(NID_CNT, pBitmap != null, null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] _BitmapImpl::CloneN failed.");
+
+ return pBitmap;
+}
+
+//
+// E_SUCCESS
+// E_DATA_NOT_FOUND
+// - E_OUT_OF_MEMORY
+//
+Bitmap*
+_AudioMetadataImpl::GetAlbumArtN(void) const
+{
+ ClearLastResult();
+
+ if (__pAudioMeta == null || __pAudioMeta->pAlbumArt == null)
+ {
+ SysLogException(NID_CNT, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] __pAudioMeta or __pAudioMeta->pAlbumArt is null.");
+ return null;
+ }
+
+ Bitmap* pBitmap = _BitmapImpl::CloneN(*(__pAudioMeta->pAlbumArt));
+ SysTryReturn(NID_CNT, pBitmap != null, null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] _BitmapImpl::CloneN failed.");
+
+ return pBitmap;
+}
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentDirectoryImpl.cpp
+ * @brief This is the implementation file for the %_ContentDirectoryImpl class.
+ *
+ * This file contains implementation of the %_ContentDirectoryImpl class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FBaseInteger.h>
+#include <FBaseLongLong.h>
+#include <FBaseFloat.h>
+#include <FBaseColIList.h>
+#include <FBaseColIEnumeratorT.h>
+#include <FCntContentDirectory.h>
+#include <FCntContentSearchResult.h>
+#include <FSysEnvironment.h>
+#include <FBase_StringConverter.h>
+#include <FCnt_ContentUtility.h>
+#include <FCnt_ContentDirectoryImpl.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+using namespace Tizen::System;
+
+namespace Tizen { namespace Content
+{
+// Declaration for Callback function registered to each media info details
+bool MediaFoldersCb(media_folder_h folder, void* pUserdata);
+// Declaration for Callback function registered to each media info details
+bool MediaFolderItemsCb(media_info_h media, void* pUserdata);
+
+_ContentDirectoryImpl::_ContentDirectoryImpl(void)
+ : Object()
+ , __pFilterHandle(null)
+ , __pFinalOutList(null)
+ , __contentType(CONTENT_TYPE_UNKNOWN)
+ , __isMultiContentType(false)
+ , __multiContentTypeExpr(L"")
+{
+
+}
+
+// (disconnects the DB connection)
+_ContentDirectoryImpl::~_ContentDirectoryImpl(void)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ result r = E_SUCCESS;
+
+ ret = media_content_disconnect();
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryLog(NID_CNT, r == E_SUCCESS, "[%s] Propagating for media_content_disconnect.", GetErrorMessage(r));
+}
+
+ _ContentDirectoryImpl*
+ _ContentDirectoryImpl::GetInstance(ContentDirectory& contentDirectory)
+{
+ return (&contentDirectory != null) ? contentDirectory.__pImpl : null;
+}
+
+const _ContentDirectoryImpl*
+_ContentDirectoryImpl::GetInstance(const ContentDirectory& contentDirectory)
+{
+ return (&contentDirectory != null) ? contentDirectory.__pImpl : null;
+}
+
+//make a connection to DB
+result
+_ContentDirectoryImpl::Construct(ContentType type)
+{
+ result r = E_SUCCESS;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ ret = media_content_connect();
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Propagating for media_content_connect.");
+
+ __contentType = type;
+ __isMultiContentType = false;
+ __multiContentTypeExpr.Clear();
+
+ return r;
+}
+
+//make a connection to DB
+result
+_ContentDirectoryImpl::Construct(const Tizen::Base::Collection::IListT<ContentType>& contentTypeList)
+{
+ result r = E_SUCCESS;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ ContentType contentType = CONTENT_TYPE_UNKNOWN;
+
+ ret = media_content_connect();
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Propagating for media_content_connect.");
+
+ __multiContentTypeExpr.Clear();
+
+ std::unique_ptr<IEnumeratorT<ContentType> > pEnum(contentTypeList.GetEnumeratorN());
+
+ while ((pEnum.get() != NULL) && (pEnum->MoveNext() == E_SUCCESS))
+ {
+ if (!__multiContentTypeExpr.IsEmpty())
+ {
+ r = __multiContentTypeExpr.Append("OR ");
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation.");
+ }
+ pEnum->GetCurrent(contentType);
+ switch (contentType)
+ {
+ // Image-0,video-1,sound-2,music-3,other-4
+ case CONTENT_TYPE_OTHER:
+ r = __multiContentTypeExpr.Append("MEDIA_TYPE=4 ");
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation.");
+ break;
+ case CONTENT_TYPE_IMAGE:
+ r = __multiContentTypeExpr.Append("MEDIA_TYPE=0 ");
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation.");
+ break;
+ case CONTENT_TYPE_AUDIO:
+ r = __multiContentTypeExpr.Append("(MEDIA_TYPE=2 or MEDIA_TYPE=3) ");
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation.");;
+ break;
+ case CONTENT_TYPE_VIDEO:
+ r = __multiContentTypeExpr.Append("MEDIA_TYPE=1 ");
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation.");
+ break;
+ case CONTENT_TYPE_ALL:
+ //If content type is CONTENT_TYPE_ALL, then MEDIA_TYPE is empty
+ break;
+ default:
+ break;
+ }
+ }
+
+ r = __multiContentTypeExpr.Insert('(', 0);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation.");
+
+ r = __multiContentTypeExpr.Insert(')', __multiContentTypeExpr.GetLength());
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation.");
+
+ __isMultiContentType = true;
+
+ return r;
+}
+
+result
+_ContentDirectoryImpl::CreateFolderFilter(bool isMultiContentType, const Tizen::Base::String& inputFolderPath) const
+{
+ result r = E_SUCCESS;
+ std::unique_ptr<filter_h, FilterHandleDeleter> pFilterHandle(new (std::nothrow) filter_h);
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ String inputCondition = L"";
+ String folderPath(inputFolderPath);
+
+ ret = media_filter_create(pFilterHandle.get());
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, r, "Failed to perform media_filter_create operation.");
+
+ if (isMultiContentType)
+ {
+ r = inputCondition.Append(__multiContentTypeExpr);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation.");
+ }
+ else
+ {
+ switch (__contentType)
+ {
+ // Image-0,video-1,sound-2,music-3,other-4
+ case CONTENT_TYPE_OTHER:
+ inputCondition = "MEDIA_TYPE=4 ";
+ break;
+ case CONTENT_TYPE_IMAGE:
+ inputCondition = "MEDIA_TYPE=0 ";
+ break;
+ case CONTENT_TYPE_AUDIO:
+ inputCondition = "(MEDIA_TYPE=2 or MEDIA_TYPE=3) ";
+ break;
+ case CONTENT_TYPE_VIDEO:
+ inputCondition = "MEDIA_TYPE=1 ";
+ break;
+ case CONTENT_TYPE_ALL:
+ //If content type is CONTENT_TYPE_ALL, then MEDIA_TYPE is empty
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (!folderPath.IsEmpty())
+ {
+ if (!inputCondition.IsEmpty()) //For CONTENT_TYPE_ALL inputCondition is empty
+ {
+ r = inputCondition.Append("AND FOLDER_PATH = ");
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation.");
+ }
+ else
+ {
+ r = inputCondition.Append("FOLDER_PATH = ");
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation.");
+ }
+
+ r = folderPath.Insert('"', 0);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Insert operation.");
+ r = folderPath.Insert('"', folderPath.GetLength());
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Insert operation.");
+
+ r = inputCondition.Append(folderPath);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation.");
+ }
+
+ if (!inputCondition.IsEmpty())
+ {
+ //CopyToCharArrayN: utility function, converts a osp string to char*
+ std::unique_ptr<char[]> pInputCond(_StringConverter::CopyToCharArrayN(inputCondition));
+ SysTryReturnResult(NID_CNT, (pInputCond.get())[0] != null, E_SYSTEM, "pInputCond is NULL.");
+
+ SysLog(NID_CNT, "pInputCond is [%s].", pInputCond.get());
+
+ if ((pInputCond.get())[0] != null)
+ {
+ ret = media_filter_set_condition(*(pFilterHandle.get()), pInputCond.get(), MEDIA_CONTENT_COLLATE_DEFAULT);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, r, "Failed to perform media_filter_set_condition operation.");
+ }
+ }
+
+ __pFilterHandle.reset(pFilterHandle.release());
+
+ return r;
+}
+
+int
+_ContentDirectoryImpl::GetContentDirectoryCount(void) const
+{
+ int directoryCount = 0;
+ result r = E_SUCCESS;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ r = CreateFolderFilter(__isMultiContentType, L"");
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_SYSTEM, "Propagating for CreateFolderFilter.");
+
+ ret = media_folder_get_folder_count_from_db(*(__pFilterHandle.get()), &directoryCount);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, r, "Failed to perform media_folder_get_folder_count_from_db operation.");
+
+ SysLog(NID_CNT, "directoryCount is [%d].", directoryCount);
+
+ SetLastResult(r);
+ return directoryCount;
+}
+
+IList*
+_ContentDirectoryImpl::GetContentDirectoryPathListN(Tizen::Base::SortOrder sortOrder) const
+{
+ result r = E_SUCCESS;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ std::unique_ptr<GList, GListDeleter> pItemList;
+ GList* pTempList = null;
+ std::unique_ptr<char> pFolderPath;
+ char* pTempFolderPath = null;
+ std::unique_ptr<media_folder_s, FolderHandleDeleter> pFolderHandle;
+ std::unique_ptr<Object> pValue;
+
+ __pFinalOutList = std::unique_ptr<ArrayList, AllElementsDeleter>(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, L"");
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] Failed to perform CreateFolderFilter operation.");
+
+ if (sortOrder == SORT_ORDER_ASCENDING)
+ {
+ ret = media_filter_set_order(*(__pFilterHandle.get()), MEDIA_CONTENT_ORDER_ASC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_DEFAULT);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, null, r,
+ "[%s] Failed to perform media_filter_set_order operation.", GetErrorMessage(r));
+ }
+ else if (sortOrder == SORT_ORDER_DESCENDING)
+ {
+ ret = media_filter_set_order(*(__pFilterHandle.get()), MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_DEFAULT);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, null, r,
+ "[%s] Failed to perform media_filter_set_order operation.", GetErrorMessage(r));
+ }
+
+ pTempList = pItemList.get();
+ ret = media_folder_foreach_folder_from_db(*(__pFilterHandle.get()), MediaFoldersCb, &pTempList);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] Failed to perform media_folder_foreach_folder_from_db operation.", GetErrorMessage(r));
+
+ SysTryReturn(NID_CNT, pTempList != NULL, null, r, "[%s] pItemList for media_folder_foreach_folder_from_db is null.", GetErrorMessage(r));
+
+ for (int idx = 0; idx < (int)g_list_length(pTempList); idx++)
+ {
+ pFolderHandle.reset(static_cast<media_folder_h>(g_list_nth_data(pTempList, idx)));
+
+ if (pFolderHandle.get() != NULL)
+ {
+ pTempFolderPath = pFolderPath.get();
+ ret = media_folder_get_path(pFolderHandle.get(), &pTempFolderPath);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] Failed to perform media_folder_get_path operation.", GetErrorMessage(r));
+
+ if (pTempFolderPath != NULL)
+ {
+ SysLog(NID_CNT, "pFolderPath is [%s].", pTempFolderPath);
+
+ pValue = std::unique_ptr<Object>(new (std::nothrow) String(pTempFolderPath));
+ }
+ if (pValue != NULL)
+ {
+ r = __pFinalOutList->Add(*(pValue.release()));
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] Failed to perform Add operation to __pFinalOutList.", GetErrorMessage(r));
+ }
+ }
+ }
+
+ SetLastResult(r);
+ return __pFinalOutList.release();
+}
+
+int
+_ContentDirectoryImpl::GetContentDirectoryItemCount(const Tizen::Base::String& contentDirectoryPath) const
+{
+ SysLog(NID_CNT, "contentDirectoryPath is [%ls]", contentDirectoryPath.GetPointer());
+
+ int directoryItemCount = 0;
+ result r = E_SUCCESS;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ GList* pItemList = NULL;
+ std::unique_ptr<char> pFolderId;
+ char* pTempFolderId = null;
+ std::unique_ptr<media_folder_s, FolderHandleDeleter> pFolderHandle;
+
+ SysTryReturn(NID_CNT, CheckMediaPath(contentDirectoryPath), directoryItemCount, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to perform CheckMediaPath operation.");
+
+ r = CreateFolderFilter(__isMultiContentType, contentDirectoryPath);
+ 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);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, directoryItemCount, r,
+ "[%s] Failed to perform media_folder_foreach_folder_from_db operation.", GetErrorMessage(r));
+
+ SysTryReturn(NID_CNT, pItemList != NULL, directoryItemCount, r,
+ "[%s] pItemList for media_folder_foreach_folder_from_db is null.", GetErrorMessage(r));
+
+ for (int idx = 0; idx < (int)g_list_length(pItemList); idx++)
+ {
+ SysLog(NID_CNT, "idx is [%d] and (int)g_list_length(pItemList) is [%d].", idx, (int)g_list_length(pItemList));
+
+ pFolderHandle.reset(static_cast<media_folder_h>(g_list_nth_data(pItemList, idx)));
+
+ if (pFolderHandle.get() != NULL)
+ {
+ pTempFolderId = pFolderId.get();
+ ret = media_folder_get_folder_id(pFolderHandle.get(), &pTempFolderId);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), directoryItemCount, r,
+ "[%s] Failed to perform media_folder_get_folder_id operation.", GetErrorMessage(r));
+ }
+ else
+ {
+ r = E_SYSTEM;
+ SysTryReturn(NID_CNT, r != E_SUCCESS, directoryItemCount, r, "[E_SYSTEM] pFolderHandle is null.");
+ }
+ }
+
+ if (pTempFolderId != NULL)
+ {
+ r = CreateFolderFilter(__isMultiContentType, L"");
+ SysTryReturn(NID_CNT, !IsFailed(r), directoryItemCount, E_SYSTEM, "[E_SYSTEM] Failed to perform CreateFolderFilter operation.");
+
+ ret = media_folder_get_media_count_from_db(pTempFolderId, *(__pFilterHandle.get()), &directoryItemCount);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), directoryItemCount, r,
+ "[%s] Failed to perform media_folder_get_media_count_from_db operation.", GetErrorMessage(r));
+ }
+
+ SysLog(NID_CNT, "directoryItemCount is [%d].", directoryItemCount);
+
+ SetLastResult(r);
+ return directoryItemCount;
+}
+
+// Osp column names are mapped with slp column names
+// CONTENT_TYPE_OTHER and CONTENT_TYPE_IMAGE (0 - 13 ) are valid columns
+// CONTENT_TYPE_VIDEO (0 - 16 ) are valid columns
+// CONTENT_TYPE_ALL and CONTENT_TYPE_VIDEO (0 - 18 ) are valid columns
+// if the given osp column is out of the specified range of the type, E_INVALID_ARG is retuned.
+result
+_ContentDirectoryImpl::GetSlpColumnName(String& inputCol, String sortCol) const
+{
+ String ospColumnName(L"");
+ String slpColumnName(L"");
+ String columnName(sortCol);
+ result r = E_SUCCESS;
+ int maxCols = MAX_QUERY_COLUMNS;
+
+ if(!__isMultiContentType)
+ {
+ switch (__contentType)
+ {
+ case CONTENT_TYPE_OTHER:
+ //fall through
+ case CONTENT_TYPE_IMAGE:
+ maxCols = MAX_QUERY_COLUMNS_FOR_IMAGE_OTHERS;
+ break;
+ case CONTENT_TYPE_VIDEO:
+ maxCols = MAX_QUERY_COLUMNS_FOR_VIDEO;
+ break;
+ case CONTENT_TYPE_AUDIO:
+ //fall through
+ case CONTENT_TYPE_ALL:
+ maxCols = MAX_QUERY_COLUMNS;
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ if(!__multiContentTypeExpr.IsEmpty())
+ {
+ if(__multiContentTypeExpr.Contains("MEDIA_TYPE=2"))
+ {
+ maxCols = MAX_QUERY_COLUMNS;
+ }
+ else if(__multiContentTypeExpr.Contains("MEDIA_TYPE=1"))
+ {
+ maxCols = MAX_QUERY_COLUMNS_FOR_VIDEO;
+ }
+ else if(__multiContentTypeExpr.Contains("MEDIA_TYPE=0"))
+ {
+ maxCols = MAX_QUERY_COLUMNS_FOR_IMAGE_OTHERS;
+ }
+ }
+ }
+
+ for (int colIndex=0; colIndex < maxCols; colIndex++)
+ {
+ ospColumnName.Clear();
+ slpColumnName.Clear();
+
+ ospColumnName = dbfieldinfo[colIndex].dbFieldOspName ;
+ slpColumnName = dbfieldinfo[colIndex].dbFieldSlpName ;
+
+ ospColumnName.ToUpper();
+ columnName.ToUpper();
+
+ if (columnName == ospColumnName)
+ {
+ inputCol = slpColumnName;
+ return r;
+ }
+ }
+ return E_INVALID_ARG;
+}
+
+IList*
+_ContentDirectoryImpl::GetContentDirectoryItemListN(const Tizen::Base::String& contentDirectoryPath, int pageNo, int countPerPage,
+ const Tizen::Base::String& column, Tizen::Base::SortOrder sortOrder) const
+{
+ SysLog(NID_CNT, "contentDirectoryPath is [%ls].", contentDirectoryPath.GetPointer());
+
+ result r = E_SUCCESS;
+ int totalCount = 0;
+ int totalPageCount = 0;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ String slpColumn = L"";
+ std::unique_ptr<GList, GListDeleter> pItemList;
+ GList* pTempList = null;
+ std::unique_ptr<char> pFolderId;
+ char* pTempFolderId = null;
+ std::unique_ptr<media_folder_s, FolderHandleDeleter> pFolderHandle;
+ int offset = 0;
+
+ SysTryReturn(NID_CNT, CheckMediaPath(contentDirectoryPath), null, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to perform CheckMediaPath operation.");
+
+ __pFinalOutList = std::unique_ptr<ArrayList, AllElementsDeleter>(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);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] Failed to perform CreateFolderFilter operation.");
+
+ if ((!column.IsEmpty()) && (sortOrder != SORT_ORDER_NONE))
+ {
+ //__inputColumnName (osp column name) is replaced with slpColumn (slp column name).
+ r = GetSlpColumnName(slpColumn, column);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] Failed to perform GetSlpColumnName operation.", GetErrorMessage(r));
+
+ //CopyToCharArrayN: utility function, converts a osp string to char*
+ std::unique_ptr<char[]> pSortCol(_StringConverter::CopyToCharArrayN(slpColumn));
+ SysTryReturn(NID_CNT, pSortCol.get() != null, null, E_SYSTEM, "[E_SYSTEM] pFolderId is NULL.");
+
+ if (sortOrder == SORT_ORDER_ASCENDING)
+ {
+ ret = media_filter_set_order(*(__pFilterHandle.get()), MEDIA_CONTENT_ORDER_ASC, pSortCol.get(), MEDIA_CONTENT_COLLATE_DEFAULT);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, null, r,
+ "[%s] Failed to perform media_filter_set_order operation.", GetErrorMessage(r));
+ }
+ else if (sortOrder == SORT_ORDER_DESCENDING)
+ {
+ ret = media_filter_set_order(*(__pFilterHandle.get()), MEDIA_CONTENT_ORDER_DESC, pSortCol.get(), MEDIA_CONTENT_COLLATE_DEFAULT);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, null, r,
+ "[%s] Failed to perform media_filter_set_order operation.", GetErrorMessage(r));
+ }
+ }
+
+ pTempList = pItemList.get();
+ ret = media_folder_foreach_folder_from_db(*(__pFilterHandle.get()), MediaFoldersCb, &pTempList);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r,
+ "[%s] Failed to perform media_folder_foreach_folder_from_db operation.", GetErrorMessage(r));
+
+ if (pTempList != NULL)
+ {
+ for (int idx = 0; idx < (int)g_list_length(pTempList); idx++)
+ {
+ SysLog(NID_CNT, "idx is [%d] and (int)g_list_length(pItemList) is [%d].", idx, (int)g_list_length(pTempList));
+
+ pFolderHandle.reset(static_cast<media_folder_h>(g_list_nth_data(pTempList, idx)));
+
+ if (pFolderHandle.get() != NULL)
+ {
+ pTempFolderId = pFolderId.get();
+ ret = media_folder_get_folder_id(pFolderHandle.get(), &pTempFolderId);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r,
+ "[%s] Failed to perform media_folder_get_folder_id operation.", GetErrorMessage(r));
+ }
+ else
+ {
+ r = E_SYSTEM;
+ SysTryReturn(NID_CNT, r != E_SUCCESS, null, r, "[E_SYSTEM] pFolderHandle is null.");
+ }
+ }
+ }
+
+ if (pTempFolderId != NULL)
+ {
+ r = CreateFolderFilter(__isMultiContentType, L"");
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] Failed to perform CreateFolderFilter operation.");
+
+ ret = media_folder_get_media_count_from_db(pTempFolderId, *(__pFilterHandle.get()), &totalCount);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r,
+ "[%s] Failed to perform media_folder_get_media_count_from_db operation.", GetErrorMessage(r));
+
+ SysLog(NID_CNT, "totalCount is [%d].", totalCount);
+ }
+
+ if (totalCount > 0)
+ {
+ if ((totalCount % countPerPage) == 0)
+ {
+ totalPageCount = totalCount / countPerPage;
+ }
+ else
+ {
+ totalPageCount = (totalCount / countPerPage) + 1;
+ }
+
+ SysTryReturn(NID_CNT, ((pageNo >= 1) && (pageNo <= totalPageCount)) , NULL, E_INVALID_ARG, "[E_INVALID_ARG] (pageNo < 1) || (pageNo > totalPageCount).");
+
+ offset = (pageNo * countPerPage) - countPerPage;
+
+ SysLog(NID_CNT, "totalCount [%d] totalPageCount[%d] __countPerPage[%d] __pageNo[%d] offset[%d]",
+ totalCount, totalPageCount, countPerPage, pageNo, offset);
+
+ ret = media_filter_set_offset(*(__pFilterHandle.get()),offset,countPerPage);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] Failed to perform media_filter_set_offset operation.", GetErrorMessage(r));
+
+ r = FillFinalOutList(pTempFolderId);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_SYSTEM, "[E_SYSTEM] Failed to perform FillFinalOutList operation.");
+ }
+ else if (pageNo > 1)
+ {
+ r = E_INVALID_ARG;
+ SysTryReturn(NID_CNT, !(IsFailed(r)), null, r, "[E_INVALID_ARG] (pageNo > 1) and (totalcount = 0).");
+ }
+
+ SetLastResult(r);
+ return __pFinalOutList.release();
+}
+
+result
+_ContentDirectoryImpl::FillFinalOutList(char* pFolderId) const
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ result r = E_SUCCESS;
+ std::unique_ptr<GList, GListDeleter> pItemList;
+ GList* pTempList = NULL;
+ std::unique_ptr<media_info_s, MediaHandleDeleter> pMediaHandle;
+
+ ContentInfo::_ContentData* pContentData = null;
+ ImageContentInfo::_ImageContentData* pImageContentData = null;
+ AudioContentInfo::_AudioContentData* pAudioContentData = null;
+ VideoContentInfo::_VideoContentData* pVideoContentData = null;
+
+ std::unique_ptr<ImageContentInfo> pImageContentInfo;
+ std::unique_ptr<AudioContentInfo> pAudioContentInfo;
+ std::unique_ptr<VideoContentInfo> pVideoContentInfo;
+ std::unique_ptr<OtherContentInfo> pOtherContentInfo;
+
+ pTempList = pItemList.get();
+ ret = media_folder_foreach_media_from_db(pFolderId, *(__pFilterHandle.get()), MediaFolderItemsCb, &pTempList);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform media_folder_foreach_media_from_db operation.");
+
+ SysTryReturnResult(NID_CNT, pTempList != NULL, r, "pItemList for media_info_foreach_media_from_db is null.");
+
+ media_content_type_e mediaType;
+
+ for (int idx = 0; idx < (int)g_list_length(pTempList); idx++)
+ {
+ pMediaHandle.reset(static_cast<media_info_h>(g_list_nth_data(pTempList, idx)));
+
+ ret = media_info_get_media_type(pMediaHandle.get(), &mediaType);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform media_info_get_media_type operation.");
+
+ switch (mediaType)
+ {
+ case MEDIA_CONTENT_TYPE_OTHERS:
+ pOtherContentInfo = std::unique_ptr<OtherContentInfo>(new (std::nothrow) OtherContentInfo);
+ SysTryReturnResult(NID_CNT, pOtherContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pOtherContentInfo.");
+
+ pContentData = pOtherContentInfo->GetContentData();
+ SysTryReturnResult(NID_CNT, pContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ r = _ContentUtility::FillContentData(pMediaHandle.get(), pContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillContentData operation.");
+
+ // Shallow copy, adds just the pointer: not the element
+ r = __pFinalOutList->Add(*(pOtherContentInfo.release()));
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Add operation to pFinalOutList.");
+
+ break;
+ case MEDIA_CONTENT_TYPE_IMAGE:
+ pImageContentInfo = std::unique_ptr<ImageContentInfo>(new (std::nothrow) ImageContentInfo);
+ SysTryReturnResult(NID_CNT, pImageContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pImageContentInfo.");
+
+ pContentData = pImageContentInfo->GetContentData();
+ SysTryReturnResult(NID_CNT, pContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ pImageContentData = pImageContentInfo->GetImageContentData();
+ SysTryReturnResult(NID_CNT, pImageContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ r = _ContentUtility::FillContentData(pMediaHandle.get(), pContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillContentData operation.");
+
+ r = _ContentUtility::FillImageContentData(pMediaHandle.get(), pImageContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform GetDataFromImageTable operation.");
+
+ // Shallow copy, adds just the pointer: not the element
+ r = __pFinalOutList->Add(*(pImageContentInfo.release()));
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Add operation to __pFinalOutList.");
+
+ break;
+ case MEDIA_CONTENT_TYPE_MUSIC:
+ //fall through
+ case MEDIA_CONTENT_TYPE_SOUND:
+ pAudioContentInfo = std::unique_ptr<AudioContentInfo>(new (std::nothrow) AudioContentInfo);
+ SysTryReturnResult(NID_CNT, pAudioContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pAudioContentInfo.");
+
+ pContentData = pAudioContentInfo->GetContentData();
+ SysTryReturnResult(NID_CNT, pContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ pAudioContentData = pAudioContentInfo->GetAudioContentData();
+ SysTryReturnResult(NID_CNT, pAudioContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ r = _ContentUtility::FillContentData(pMediaHandle.get(), pContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillContentData operation.");
+
+ r = _ContentUtility::FillAudioContentData(pMediaHandle.get(), pAudioContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillAudioContentData operation.");
+
+ // Shallow copy, adds just the pointer: not the element
+ r = __pFinalOutList->Add(*(pAudioContentInfo.release()));
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Add operation to __pFinalOutList.");
+
+ break;
+ case MEDIA_CONTENT_TYPE_VIDEO:
+ pVideoContentInfo = std::unique_ptr<VideoContentInfo>(new (std::nothrow) VideoContentInfo);
+ SysTryReturnResult(NID_CNT, pVideoContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pVideoContentInfo.");
+
+ pContentData = pVideoContentInfo->GetContentData();
+ SysTryReturnResult(NID_CNT, pContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ pVideoContentData = pVideoContentInfo->GetVideoContentData();
+ SysTryReturnResult(NID_CNT, pVideoContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ r = _ContentUtility::FillContentData(pMediaHandle.get(), pContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillContentData operation.");
+
+ r = _ContentUtility::FillVideoContentData(pMediaHandle.get(), pVideoContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillVideoContentData operation.");
+
+ // Shallow copy, adds just the pointer: not the element
+ r = __pFinalOutList->Add(*(pVideoContentInfo.release()));
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Add operation to __pFinalOutList.");
+
+ break;
+ default:
+ break;
+ }
+ }
+
+ return r;
+}
+
+bool
+_ContentDirectoryImpl::CheckMediaPath(const Tizen::Base::String& directoryPath) const
+{
+ String phoneStr = Environment::GetMediaPath();
+ String mmcStr = Environment::GetExternalStoragePath();
+
+ if (!(directoryPath.StartsWith(phoneStr, 0) || directoryPath.StartsWith(mmcStr , 0)))
+ {
+ String checkPhone;
+ result r = phoneStr.SubString(0, (phoneStr.GetLength() - 1), checkPhone);
+ SysTryReturn(NID_CNT, !IsFailed(r), false, E_INVALID_ARG, "[E_INVALID_ARG] Failed to substring operation.");
+
+ String checkMmc;
+ r = mmcStr.SubString(0, (mmcStr.GetLength() - 1), checkMmc);
+ SysTryReturn(NID_CNT, !IsFailed(r), false, E_INVALID_ARG, "[E_INVALID_ARG] Failed to substring operation.");
+
+ SysTryReturn(NID_CNT, (directoryPath.Equals(checkPhone) || directoryPath.Equals(checkMmc)), false, E_INVALID_ARG,
+ "[E_INVALID_ARG] The contentDirectoryPath is not valid[%ls].", directoryPath.GetPointer());
+ }
+
+ return true;
+}
+
+result
+_ContentDirectoryImpl::MapCoreErrorToNativeResult(int reason) const
+{
+ result r = E_SUCCESS;
+
+ switch (reason)
+ {
+ case MEDIA_CONTENT_ERROR_NONE:
+ r = E_SUCCESS;
+ break;
+
+ case MEDIA_CONTENT_ERROR_DB_BUSY:
+ r = E_SERVICE_BUSY;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_BUSY");
+ break;
+
+ case MEDIA_CONTENT_ERROR_DB_FAILED:
+ r = E_SYSTEM;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_FAILED");
+ break;
+
+ case MEDIA_CONTENT_ERROR_OUT_OF_MEMORY:
+ r = E_OUT_OF_MEMORY;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_OUT_OF_MEMORY");
+ break;
+
+ default:
+ SysLog(NID_CNT, "default");
+ r = E_SYSTEM;
+ break;
+ }
+ return r;
+}
+
+// Callback function registered to each media info details
+// all items are appended to the list
+bool
+MediaFoldersCb(media_folder_h folder, void* pUserdata)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_folder_h new_folder = NULL;
+ ret = media_folder_clone(&new_folder, folder);
+ SysTryLog(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, "[E_SYSTEM] Propagating for media_folder_clone.");
+
+ GList** pList = (GList**)pUserdata;
+ *pList = g_list_append(*pList, new_folder);
+
+ return true;
+}
+
+// Callback function registered to each media info details
+// all items are appended to the list
+bool
+MediaFolderItemsCb(media_info_h media, void* pUserdata)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_info_h new_media = NULL;
+ ret = media_info_clone(&new_media, media);
+ SysTryLog(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, "[E_SYSTEM] Propagating for media_info_clone.");
+
+ GList** pList = (GList**)pUserdata;
+ *pList = g_list_append(*pList, new_media);
+
+ return true;
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentDownloadHandler.cpp
+ * @brief This is the implementation file for the %_ContentDownloadHandler class.
+ *
+ * This file contains implementation of the %_ContentDownloadHandler class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FCnt_ContentManagerImpl.h>
+#include <FCnt_ContentTransferImpl.h>
+#include <FIo_FileImpl.h>
+#include <FNetHttp_HttpSessionImpl.h>
+#include <FNetHttp_HttpTransactionImpl.h>
+#include <FSys_RuntimeInfoImpl.h>
+#include "FCnt_ContentDownloadHandler.h"
+
+using namespace Tizen;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Io;
+using namespace Tizen::Net;
+using namespace Tizen::Net::Http;
+using namespace Tizen::System;
+
+static RequestId restRequestId = 0;
+
+namespace Tizen { namespace Content
+{
+
+_ContentDownloadHandler::_ContentDownloadHandler(void)
+ : __requestId(INVALID_REQUEST_ID)
+ , __restRequestId(INVALID_REQUEST_ID)
+ , __timeout(-1)
+ , __percent(-1)
+ , __slot(-1)
+ , __destFilePath(L"")
+ , __sourceFilePath(L"")
+ , __pListener(null)
+ , __pSession(null)
+ , __pTransaction(null)
+{
+}
+
+result
+_ContentDownloadHandler::Construct(void)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ std::unique_ptr<_ContentDownloadListener> pListener(new (std::nothrow) _ContentDownloadListener);
+ SysTryReturn(NID_CNT, pListener != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ContentDownloadListener.");
+
+ __pListener = std::move(pListener);
+
+ return r;
+}
+
+_ContentDownloadHandler::~_ContentDownloadHandler(void)
+{
+
+}
+
+result
+_ContentDownloadHandler::Cancel(RequestId requestId, _ContentDownloadUserData* pContentDownloadUserDataSequence)
+{
+ SysLog(NID_CNT, "Cancel operation start with request ID(%d).", requestId);
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ _HttpSessionImpl* pSessionImpl = null;
+ HttpResponse* pHttpResponse = null;
+ String errorMsg(L"");
+ int statusCode = -1;
+
+ SysTryReturn(NID_CNT, pContentDownloadUserDataSequence != null, r = E_INVALID_ARG, r,
+ "[E_INVALID_ARG] ContentDownloadUserData instance must not be null.");
+ SysTryReturn(NID_CNT, __pSession != null, r = E_OBJ_NOT_FOUND, r, "[E_OBJ_NOT_FOUND] HttpSession instance must not be null.");
+ SysTryReturn(NID_CNT, __pTransaction != null, r = E_OBJ_NOT_FOUND, r, "[E_OBJ_NOT_FOUND] HttpTransaction instance must not be null.");
+
+
+ pSessionImpl = _HttpSessionImpl::GetInstance(*(__pSession.get()));
+ SysTryReturn(NID_CNT, pSessionImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to create the HTTP session impl object.");
+
+ pHttpResponse = __pTransaction->GetResponse();
+ r = GetLastResult();
+ if (IsFailed(r))
+ {
+ SysTryLog(NID_CNT, pHttpResponse != null, "[%s] Failed to get the Http transaction response.", GetErrorMessage(r));
+ }
+ else
+ {
+ statusCode = pHttpResponse->GetHttpStatusCode();
+ SysTryReturn(NID_CNT, statusCode == HTTP_STATUS_OK, r = E_SERVICE_UNAVAILABLE, E_SERVICE_UNAVAILABLE,
+ "[E_SERVICE_UNAVAILABLE] The server is unavailable.");
+
+ errorMsg = pHttpResponse->GetStatusText();
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_SERVICE_UNAVAILABLE, E_SERVICE_UNAVAILABLE,
+ "[E_SERVICE_UNAVAILABLE] The server is unavailable.");
+ }
+
+ if (__restRequestId == requestId)
+ {
+ r = pSessionImpl->CancelTransaction(*__pTransaction);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to cancel transaction.", GetErrorMessage(r));
+
+ __requestId = INVALID_REQUEST_ID;
+ }
+ else
+ {
+ SysTryReturn(NID_CNT, __restRequestId == requestId, r = E_INVALID_STATE, E_INVALID_STATE,
+ "[E_INVALID_STATE] Failed to find request ID.");
+ }
+
+ // delete downloaded file
+ if (_FileImpl::IsFileExist(pContentDownloadUserDataSequence->GetDestPath()))
+ {
+ r = _FileImpl::Remove(pContentDownloadUserDataSequence->GetDestPath());
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to remove the [%ls] file.",
+ GetErrorMessage(r), (pContentDownloadUserDataSequence->GetDestPath()).GetPointer());
+ }
+
+ __pListener->DownloadCanceled(pContentDownloadUserDataSequence, statusCode, errorMsg, E_SUCCESS);
+
+ return r;
+}
+
+RequestId
+_ContentDownloadHandler::HttpDownload(const String uri, int srcFileSize, const String destPath,
+ _ContentDownloadUserData* pContentDownloadUserDataSequence)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ bool check = false;
+
+ SysTryReturn(NID_CNT, pContentDownloadUserDataSequence != null, __restRequestId, E_INVALID_ARG,
+ "[E_INVALID_ARG] ContentDownloadUserData instance must not be null.");
+
+ check = CheckSystem(destPath, srcFileSize);
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, check == true, __restRequestId, r, "[%s] The result of system check is false.", GetErrorMessage(r));
+
+ __sourceFilePath = uri;
+ SysTryReturn(NID_CNT, !__sourceFilePath.IsEmpty(), __restRequestId, E_INVALID_ARG,
+ "[E_INVALID_ARG] The source URI is empty.");
+
+ pContentDownloadUserDataSequence->SetUrl(__sourceFilePath);
+ SysTryReturn(NID_CNT, !(pContentDownloadUserDataSequence->GetUrl().IsEmpty()), __restRequestId, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to set the source file path into ContentDownloadUserData.");
+
+ r = RequestDownload(__sourceFilePath, destPath, __timeout, __percent, pContentDownloadUserDataSequence);
+ SysTryReturn(NID_CNT, !IsFailed(r), __restRequestId, E_SYSTEM, "[E_SYSTEM] Failed to perform RequestDownload operation.");
+
+ return __restRequestId;
+}
+
+result
+_ContentDownloadHandler::RequestDownload(String& srcUrl, const String destFilePath, int timeout,
+ int percent, _ContentDownloadUserData* pUserData)
+{
+ SysLog(NID_CNT, "Download request operation start with URL(%ls) and destination path(%ls).", srcUrl.GetPointer(), destFilePath.GetPointer());
+
+ ClearLastResult();
+ result r = E_SUCCESS;
+ _HttpSessionImpl* pSessionImpl = null;
+ _HttpTransactionImpl* pTransactionImpl = null;
+ HttpRequest* pHttpRequest = null;
+ Uri uri;
+ String hostAddr(L"");
+
+ SysTryReturn(NID_CNT, pUserData != null, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] ContentDownloadUserData instance must not be null.");
+
+ r = uri.SetUri(srcUrl);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] [%ls] is an invalid URL.", srcUrl.GetPointer());
+
+ hostAddr = uri.GetHost();
+
+ // Create HTTP session
+ __pSession = std::unique_ptr<HttpSession>(new (std::nothrow) HttpSession);
+ SysTryReturn(NID_CNT, __pSession != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to create the HTTP session.");
+
+ r = __pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to construct HTTP session.");
+
+ pSessionImpl = _HttpSessionImpl::GetInstance(*(__pSession.get()));
+ SysTryReturn(NID_CNT, pSessionImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to create the HTTP session impl object.");
+
+ __pTransaction = std::unique_ptr<HttpTransaction>(pSessionImpl->OpenTransactionN());
+ SysTryReturn(NID_CNT, __pTransaction != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create the HTTP transaction.");
+
+ pTransactionImpl = _HttpTransactionImpl::GetInstance(*(__pTransaction.get()));
+ SysTryReturn(NID_CNT, pTransactionImpl != null, r = E_SYSTEM, E_SYSTEM,
+ "[E_SYSTEM] Failed to get HTTP transaction impl object.");
+
+ r = pTransactionImpl->SetTimeout(timeout);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, r, r, "[%s] Failed to set [%d] timeout.", GetErrorMessage(r), timeout);
+
+ r = pTransactionImpl->AddHttpTransactionListener(*(__pListener.get()));
+ SysTryReturn(NID_CNT, r == E_SUCCESS, r, r, "[%s] Failed to add listener into the HTTP transaction.", GetErrorMessage(r));
+
+ r = pTransactionImpl->SetHttpProgressListener(*(__pListener.get()));
+ SysTryReturn(NID_CNT, r == E_SUCCESS, r, r, "[%s] Failed to add listener into the HTTP transaction.", GetErrorMessage(r));
+
+ __destFilePath = destFilePath;
+ pUserData->SetDestPath(__destFilePath);
+ SysTryReturn(NID_CNT, !(pUserData->GetDestPath().IsEmpty()), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to set the destination path [%ls] into user data.", __destFilePath.GetPointer());
+
+ pHttpRequest = pTransactionImpl->GetRequest();
+ r = pHttpRequest->SetUri(srcUrl);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, r, r, "[%s] Failed to set uri into the HTTP request.", GetErrorMessage(r));
+
+ r = pHttpRequest->SetMethod(NET_HTTP_METHOD_GET);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, r, r, "[%s] Failed to set method into the HTTP request.", GetErrorMessage(r));
+
+ r = pTransactionImpl->SetUserObject(pUserData);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to set UserData for the HTTP transaction.", GetErrorMessage(r));
+
+ r = pTransactionImpl->Submit();
+ SysTryReturn(NID_CNT, r == E_SUCCESS, r, r, "[%s] Failed to submit the HTTP request.", GetErrorMessage(r));
+
+ ++restRequestId;
+ __restRequestId = restRequestId;
+
+ return r;
+}
+
+bool
+_ContentDownloadHandler::CheckSystem(const String& destPath, int srcFileSize)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ String key(L"AvailableMediaStorage");
+ long long availableSize = 0;
+ long long fileSize = 0;
+ fileSize = static_cast<long long>(srcFileSize);
+
+ // if existed duplicated file
+ if (_FileImpl::IsFileExist(destPath))
+ {
+ r = _FileImpl::Remove(destPath);
+ SysTryReturn(NID_CNT, !IsFailed(r), false, r,
+ "[%s] Failed to remove the duplicated file [%ls].", GetErrorMessage(r), destPath.GetPointer());
+ }
+
+ r = _RuntimeInfoImpl::GetValue(key, availableSize);
+ SysTryReturn(NID_CNT, !IsFailed(r), false, r, "[%s] Failed to get the available size.", GetErrorMessage(r));
+
+ if (fileSize > availableSize)
+ {
+ SysLogException(NID_CNT, E_INVALID_STATE, "[E_INVALID_STATE] File size exceeds the available disk quota.");
+ return false;
+ }
+
+ return true;
+}
+
+void
+_ContentDownloadHandler::SetTimeout(int sec)
+{
+ this->__timeout = sec;
+}
+
+void
+_ContentDownloadHandler::SetProgressIntervalByPercent(int percent)
+{
+ this->__percent = percent;
+}
+
+void
+_ContentDownloadHandler::SetDownloadPath(String destFilePath)
+{
+ this->__destFilePath = destFilePath;
+}
+
+void
+_ContentDownloadHandler::SetSlot(int slot)
+{
+ this->__slot = slot;
+}
+
+void
+_ContentDownloadHandler::SetRequestId(RequestId requestId)
+{
+ this->__requestId = requestId;
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentDownloadHandler.h
+ * @brief This is the header file for the %_ContentDownloadHandler class.
+ *
+ * This header file contains the declarations of the %_ContentDownloadHandler class.
+ */
+
+#ifndef _FCNT_INTERNAL_CONTENT_DOWNLOAD_HANDLER_H_
+#define _FCNT_INTERNAL_CONTENT_DOWNLOAD_HANDLER_H_
+
+#include "FCnt_ContentDownloadListener.h"
+
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpTransaction;
+}}}
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpSession;
+}}}
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpRequest;
+}}}
+
+namespace Tizen { namespace Content
+{
+
+class ContentTransferInfo;
+class _ContentDownloadUserData;
+class _ContentTransferEvent;
+
+class _ContentDownloadHandler
+ : public Tizen::Base::Object
+{
+public:
+ _ContentDownloadHandler(void);
+ virtual ~_ContentDownloadHandler(void);
+ result Construct(void);
+
+ result Cancel(RequestId requestId, _ContentDownloadUserData* pContentDownloadUserDataSequence);
+ RequestId HttpDownload(const Tizen::Base::String uri, int srcFileSize, const Tizen::Base::String destPath, _ContentDownloadUserData* pContentDownloadUserDataSequence);
+ result RequestDownload(Tizen::Base::String& srcUrl, const Tizen::Base::String destFilePath, int timeout, int percent, _ContentDownloadUserData* pUserData);
+ bool CheckSystem(const Tizen::Base::String& destPath, int srcFileSize);
+
+ void SetTimeout(int sec);
+ void SetProgressIntervalByPercent(int percent);
+ void SetDownloadPath(Tizen::Base::String destFilePath);
+ void SetSlot(int slot);
+ void SetRequestId(RequestId requestId);
+
+private:
+ _ContentDownloadHandler(const _ContentDownloadHandler& rhs);
+ _ContentDownloadHandler& operator =(const _ContentDownloadHandler& rhs);
+
+private:
+ RequestId __requestId;
+ RequestId __restRequestId;
+ int __timeout;
+ int __percent;
+ int __slot;
+ Tizen::Base::String __destFilePath;
+ Tizen::Base::String __sourceFilePath;
+ std::unique_ptr<_ContentDownloadListener> __pListener;
+ std::unique_ptr<Tizen::Net::Http::HttpSession> __pSession;
+ std::unique_ptr<Tizen::Net::Http::HttpTransaction> __pTransaction;
+}; // class _ContentDownloadHandler
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_CONTENT_DOWNLOAD_HANDLER_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentDownloadListener.cpp
+ * @brief This is the implementation file for the %_ContentDownloadListener class.
+ *
+ * This file contains implementation of the %_ContentDownloadListener class.
+ */
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FIoDirectory.h>
+#include <FSysEnvironment.h>
+#include <FCntContentManager.h>
+#include <FCntImageContentInfo.h>
+#include <FCntVideoContentInfo.h>
+#include <FCntAudioContentInfo.h>
+#include <FCntOtherContentInfo.h>
+#include <FApp_AppInfo.h>
+#include <FCnt_ContentManagerUtilImpl.h>
+#include <FIo_FileImpl.h>
+#include "FCnt_ContentDownloadListener.h"
+
+using namespace Tizen;
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Io;
+using namespace Tizen::System;
+using namespace Tizen::Net;
+using namespace Tizen::Net::Http;
+
+namespace Tizen { namespace Content
+{
+
+static const int INVALID_PROGRESS_INTERVAL = -1;
+static const int CONTENT_TRANSFER_COUNTER = 20;
+
+_ContentDownloadListener::_ContentDownloadListener(void)
+{
+}
+_ContentDownloadListener::~_ContentDownloadListener(void)
+{
+}
+
+void
+_ContentDownloadListener::OnTransactionReadyToRead(HttpSession& httpSession,
+ HttpTransaction& httpTransaction, int availableBodyLen)
+{
+ SysLog(NID_CNT, "OnTransactionReadyToRead event fired.");
+ ClearLastResult();
+ result r = E_SUCCESS;
+ std::unique_ptr<File> pFile;
+ std::unique_ptr<ByteBuffer> pBody;
+ HttpResponse* pHttpResponse = null;
+
+ _ContentDownloadUserData* pUserData = dynamic_cast<_ContentDownloadUserData*>(httpTransaction.GetUserObject());
+ SysTryReturnVoidResult(NID_CNT, pUserData != null, r = E_SYSTEM,
+ "[E_SYSTEM] ContentDownloadUserData instance must not be null.");
+
+ SysLog(NID_CNT, "##### Request ID : %d #####", pUserData->GetRequestId());
+ SysLog(NID_CNT, "##### Download path : %ls #####", pUserData->GetDestPath().GetPointer());
+ SysLog(NID_CNT, "##### Download URL : %ls #####", pUserData->GetUrl().GetPointer());
+ SysLog(NID_CNT, "##### Slot number : %d #####", pUserData->GetSlot());
+ SysLog(NID_CNT, "##### Total size : %lld #####", pUserData->GetTotalSize());
+ SysLog(NID_CNT, "##### Prev data size : %lld #####", pUserData->GetPrevData());
+
+ pHttpResponse = httpTransaction.GetResponse();
+ r = GetLastResult();
+ SysTryReturnVoidResult(NID_CNT, pHttpResponse != null, r, "[%s] Failed to get the HTTP transaction response.", GetErrorMessage(r));
+
+ if (pHttpResponse->GetHttpStatusCode() != HTTP_STATUS_OK)
+ {
+ SysLogException(NID_CNT, E_INVALID_STATE, "[E_INVALID_STATE] HTTP status code is not HTTP_STATUS_OK.");
+ return;
+ }
+
+ pBody = std::unique_ptr<ByteBuffer>(pHttpResponse->ReadBodyN());
+ SysTryReturnVoidResult(NID_CNT, pBody != null, r = E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform ReadBodyN operation to ByteBuffer.");
+
+ pFile = std::unique_ptr<File>(new (std::nothrow) File);
+ SysTryReturnVoidResult(NID_CNT, pFile != null, r = E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct File.");
+
+ r = pFile->Construct(pUserData->GetDestPath(), L"a+");
+ SysTryReturnVoidResult(NID_CNT, !IsFailed(r), r, "[%s] Failed to construct File.", GetErrorMessage(r));
+
+ r = pFile->Write(*(pBody.get()));
+ SysTryReturnVoidResult(NID_CNT, !IsFailed(r), r, "[%s] Failed to perform write operation to File.", GetErrorMessage(r));
+}
+
+void
+_ContentDownloadListener::OnTransactionAborted(HttpSession& httpSession, HttpTransaction& httpTransaction, result res)
+{
+ SysLog(NID_CNT, "OnTransactionAborted event fired.");
+
+ HttpResponse* pHttpResponse = null;
+ String errorMsg(L"");
+ int statusCode = -1;
+ result r = E_SUCCESS;
+
+ SysLog(NID_CNT, "Input result parameter of OnTransactionAborted is [%s]", GetErrorMessage(res));
+
+ _ContentDownloadUserData* pUserData = dynamic_cast<_ContentDownloadUserData*>(httpTransaction.GetUserObject());
+ SysTryReturnVoidResult(NID_CNT, pUserData != null, r = E_SYSTEM,
+ "[E_SYSTEM] ContentDownloadUserData instance must not be null.");
+
+ pHttpResponse = httpTransaction.GetResponse();
+ r = GetLastResult();
+ if (IsFailed(r))
+ {
+ SysLog(NID_CNT, "[%s] Failed to get the HTTP transaction response.", GetErrorMessage(r));
+ }
+ else
+ {
+ statusCode = pHttpResponse->GetHttpStatusCode();
+ SysTryReturnVoidResult(NID_CNT, statusCode == HTTP_STATUS_OK, r = E_INVALID_STATE,
+ "[E_INVALID_STATE] HTTP status code is not HTTP_STATUS_OK.");
+
+ errorMsg = pHttpResponse->GetStatusText();
+ r = GetLastResult();
+ SysTryReturnVoidResult(NID_CNT, !IsFailed(r), r = E_INVALID_STATE,
+ "[E_INVALID_STATE] The server is unavailable.");
+ }
+
+ // delete downloaded file because of error
+ if (_FileImpl::IsFileExist(pUserData->GetDestPath()))
+ {
+ r = _FileImpl::Remove(pUserData->GetDestPath());
+ SysTryReturnVoidResult(NID_CNT, !IsFailed(r), r,
+ "[%s] Failed to remove the downloaded file on OnTransactionAborted.", GetErrorMessage(r));
+ }
+
+ DownloadCanceled(pUserData, statusCode, errorMsg, E_SERVER);
+}
+
+void
+_ContentDownloadListener::OnTransactionCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction)
+{
+ SysLog(NID_CNT, "OnTransactionCompleted event fired.");
+
+ ClearLastResult();
+ result r = E_SUCCESS;
+ HttpResponse* pHttpResponse = null;
+ String errorMsg(L"");
+ int statusCode = 0;
+ String destPath(L"");
+
+ _ContentDownloadUserData* pUserData = dynamic_cast<_ContentDownloadUserData*>(httpTransaction.GetUserObject());
+ SysTryReturnVoidResult(NID_CNT, pUserData != null, r = E_SYSTEM,
+ "[E_SYSTEM] ContentDownloadUserData instance must not be null.");
+
+ pHttpResponse = httpTransaction.GetResponse();
+ SysTryCatch(NID_CNT, pHttpResponse != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to get the HTTP transaction response.");
+
+ pUserData->SetDownloadCount(0);
+
+ statusCode = pHttpResponse->GetHttpStatusCode();
+ SysTryCatch(NID_CNT, statusCode == HTTP_STATUS_OK, r = E_SERVER, E_SERVER, "[E_SERVER] HTTP status code is not HTTP_STATUS_OK.");
+
+ errorMsg = pHttpResponse->GetStatusText();
+ r = GetLastResult();
+ SysTryCatch(NID_CNT, !IsFailed(r), r = E_SERVER, E_SERVER, "[E_SERVER] The server is unavailable.");
+
+ if (!_AppInfo::IsOspCompat())
+ {
+ destPath = pUserData->GetDestPath();
+
+ // download success
+ // register content
+ if (destPath.StartsWith(Environment::GetMediaPath(), 0) || destPath.StartsWith(Environment::GetExternalStoragePath(), 0))
+ {
+ r = RegisterMediaFile(httpSession, httpTransaction, pUserData);
+ SysTryCatch(NID_CNT, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to perform RegisterMediaFile operation.");
+
+ DownloadCompleted(httpSession, httpTransaction, pUserData, statusCode, errorMsg, r);
+ }
+ else
+ {
+ DownloadCompleted(httpSession, httpTransaction, pUserData, statusCode, errorMsg, r);
+ }
+ }
+ else
+ {
+ if (_FileImpl::IsMediaPath(pUserData->GetDestPath()))
+ {
+ r = RegisterMediaFile(httpSession, httpTransaction, pUserData);
+ SysTryCatch(NID_CNT, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to perform RegisterMediaFile operation.");
+
+ DownloadCompleted(httpSession, httpTransaction, pUserData, statusCode, errorMsg, r);
+ }
+ else
+ {
+ DownloadCompleted(httpSession, httpTransaction, pUserData, statusCode, errorMsg, r);
+ }
+ }
+
+ return;
+
+CATCH:
+ statusCode = pHttpResponse->GetHttpStatusCode();
+ errorMsg = pHttpResponse->GetStatusText();
+
+ if (_FileImpl::IsFileExist(pUserData->GetDestPath()))
+ {
+ result res = _FileImpl::Remove(pUserData->GetDestPath());
+ SysTryLog(NID_CNT, !IsFailed(res), "[%s] Failed to remove the downloaded file on OnTransactionCompleted.", GetErrorMessage(res));
+ }
+
+ DownloadCompleted(httpSession, httpTransaction, pUserData, statusCode, errorMsg, r);
+}
+
+void
+_ContentDownloadListener::OnHttpDownloadInProgress(HttpSession& httpSession, HttpTransaction& httpTransaction,
+ long long currentLength, long long totalLength)
+{
+ SysLog(NID_CNT, "OnHttpDownloadInProgress event fired.");
+
+ ClearLastResult();
+ result r = E_SUCCESS;
+ int count = 0;
+ double currentData = 0.0;
+ double totalData = 0.0;
+
+ _ContentDownloadUserData* pUserData = dynamic_cast<_ContentDownloadUserData*>(httpTransaction.GetUserObject());
+ SysTryReturnVoidResult(NID_CNT, pUserData != null, r = E_SYSTEM,
+ "[E_SYSTEM] ContentDownloadUserData instance must not be null.");
+
+ count = pUserData->GetDownloadCount();
+ currentData = currentLength;
+ totalData = totalLength;
+
+ if (totalLength == 0)
+ {
+ count++;
+ pUserData->SetDownloadCount(count);
+
+ if (pUserData->GetDownloadCount() == CONTENT_TRANSFER_COUNTER)
+ {
+ TransferProgress(httpSession, httpTransaction, currentLength, totalLength, pUserData);
+ pUserData->SetDownloadCount(0);
+ }
+ }
+ else
+ {
+ int cmp = 0;
+ Double data1(totalData);
+ Double data2(currentData);
+ DoubleComparer comparer;
+
+ r = comparer.Compare(data1, data2, cmp);
+ SysTryReturnVoidResult(NID_CNT, !IsFailed(r), r,
+ "[%s] Failed to compare total size with current size for a content.", GetErrorMessage(r));
+
+ if ((pUserData->GetPercent() == INVALID_PROGRESS_INTERVAL)
+ || ((cmp == 0) && (pUserData->GetPrevData() != currentLength))
+ || (((currentData - pUserData->GetPrevData()) / totalData * 100) >= pUserData->GetPercent()))
+ {
+ pUserData->SetPrevData(currentLength);
+ pUserData->SetTotalSize(totalLength);
+ TransferProgress(httpSession, httpTransaction, currentLength, totalLength, pUserData);
+ }
+ }
+}
+
+void
+_ContentDownloadListener::OnTransactionCertVerificationRequiredN(HttpSession& httpSession,
+ HttpTransaction& httpTransaction, String* pCert)
+{
+ SysLog(NID_CNT, "OnTransactionCertVerificationRequiredN event fired.");
+}
+
+void
+_ContentDownloadListener::OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction,
+ int headerLen, bool bAuthRequired)
+{
+ SysLog(NID_CNT, "OnTransactionHeaderCompleted event fired.");
+}
+
+void
+_ContentDownloadListener::OnTransactionReadyToWrite(HttpSession& httpSession, HttpTransaction& httpTransaction,
+ int recommendedChunkSize)
+{
+ SysLog(NID_CNT, "OnTransactionReadyToWrite event fired.");
+}
+
+void
+_ContentDownloadListener::OnHttpUploadInProgress(HttpSession& httpSession, HttpTransaction& httpTransaction,
+ long long currentLength, long long totalLength)
+{
+ SysLog(NID_CNT, "OnHttpUploadInProgress event fired.");
+}
+
+void
+_ContentDownloadListener::DownloadCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction,
+ _ContentDownloadUserData* pUserData, int errorCode, String errorMsg, result res)
+{
+ SysLog(NID_CNT, "DownloadCompleted operation start after OnTransactionCompleted event fire.");
+
+ ClearLastResult();
+ result r = E_SUCCESS;
+ std::unique_ptr<_ContentTransferEventArg> pContentTransferEventArg;
+ ContentId contentId;
+ RequestId resultRequestId = INVALID_REQUEST_ID;
+ long long fileSize = 0;
+ std::unique_ptr<ByteBuffer> pBuffer;
+ File file;
+ FileAttributes attribute;
+ String destPath(L"");
+
+ pContentTransferEventArg = std::unique_ptr<_ContentTransferEventArg>(new (std::nothrow) _ContentTransferEventArg());
+ SysTryCatch(NID_CNT, pContentTransferEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ContentTrasnferEventArg.");
+
+ SysTryCatch(NID_CNT, pUserData != null, r = E_INVALID_STATE, E_INVALID_STATE,
+ "[E_INVALID_STATE] ContentDownloadUserData instance must not be null.");
+
+ resultRequestId = pUserData->GetRequestId();
+ destPath = pUserData->GetDestPath();
+ contentId = pUserData->GetContentId();
+
+ pUserData->SetRequestId(INVALID_REQUEST_ID);
+
+ if (!(pUserData->GetDownloadBufferFlag()))
+ {
+ if (pUserData->GetContentId() != UuId::GetInvalidUuId())
+ {
+ pUserData->SetContentId(UuId::GetInvalidUuId());
+ }
+ else
+ {
+ contentId = UuId::GetInvalidUuId();
+ }
+
+ pContentTransferEventArg->SetResult(res);
+ pContentTransferEventArg->SetErrorMsg(Integer::ToString(errorCode), errorMsg);
+ pContentTransferEventArg->SetEventType(Content::CONTENT_TRANSFER_EVENT_DOWNLOAD_COMPLETED);
+ pContentTransferEventArg->SetContentId(contentId);
+
+ // TODO : needs request ID mapping
+ pContentTransferEventArg->SetRequestId(resultRequestId);
+
+ SysTryCatch(NID_CNT, pUserData->GetContentTransferEvent() != null, r = E_INVALID_STATE, E_INVALID_STATE,
+ "[E_INVALID_STATE] ContentTransferEvent in UserData must not be null.");
+
+ r = pUserData->GetContentTransferEvent()->Fire(*(pContentTransferEventArg.release()));
+ SysTryCatch(NID_CNT, !IsFailed(r), , r, "[%s] Failed to perform fire operation on ContentTransferEvent.", GetErrorMessage(r));
+
+ pUserData->SetSlotFlag(false);
+
+ if (pUserData->GetContentTransferInfo() != null)
+ {
+ pUserData->GetContentTransferInfo()->SetDownloadStatus(Content::CONTENT_TRANSFER_STATUS_DOWNLOAD_COMPLETED);
+ }
+ }
+ else
+ {
+ pContentTransferEventArg->SetEventType(Content::CONTENT_TRANSFER_EVENT_DOWNLOAD_TO_BUFFER_COMPLETED);
+ pContentTransferEventArg->SetRequestId(resultRequestId);
+ pUserData->SetDownloadBufferFlag(false);
+
+ r = file.Construct(destPath, L"r");
+ SysTryCatch(NID_CNT, !IsFailed(r), , r, "[E_OUT_OF_MEMORY] Failed to construct File.");
+
+ r = _FileImpl::GetAttributes(destPath, attribute);
+ SysTryCatch(NID_CNT, !IsFailed(r), , r, "[%s] Failed to perform GetAttributes operation.", GetErrorMessage(r));
+
+ fileSize = attribute.GetFileSize();
+ SysTryCatch(NID_CNT, fileSize != 0, , r, "[%s] Failed to perform GetFileSize.", GetErrorMessage(r));
+
+ pBuffer = std::unique_ptr<ByteBuffer>(new (std::nothrow) ByteBuffer());
+ SysTryCatch(NID_CNT, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMROY] Failed to construct ByteBuffer.");
+
+ r = pBuffer->Construct(static_cast<int>(fileSize));
+ SysTryCatch(NID_CNT, !IsFailed(r), , r, "[E_OUT_OF_MEMORY] Failed to construct ByteBuffer.");
+
+ r = file.Read(*(pBuffer.get()));
+ SysTryCatch(NID_CNT, !IsFailed(r), , r, "[%s] Failed to perform Read operation from File to ByteBuffer.", GetErrorMessage(r));
+
+ r = pBuffer->SetPosition(fileSize);
+ SysTryCatch(NID_CNT, !IsFailed(r), , r, "[%s] Failed to perform SetPosition operation.", GetErrorMessage(r));
+
+ r = file.Remove(destPath);
+ SysTryCatch(NID_CNT, !IsFailed(r), , r, "[%s] Failed to perform Remove operation for download file.", GetErrorMessage(r));
+
+ pBuffer->Flip();
+ pContentTransferEventArg->SetBuffer(pBuffer.release());
+ pContentTransferEventArg->SetResult(res);
+ pContentTransferEventArg->SetErrorMsg(Integer::ToString(errorCode), errorMsg);
+
+ SysTryCatch(NID_CNT, pUserData->GetContentTransferEvent() != null, r = E_INVALID_STATE, E_INVALID_STATE,
+ "[E_INVALID_STATE] ContentTransferEvent in UserData must not be null.");
+
+ r = pUserData->GetContentTransferEvent()->Fire(*(pContentTransferEventArg.release()));
+ SysTryCatch(NID_CNT, !IsFailed(r), , r,
+ "[%s] Failed to perform fire operation on ContentTransferEvent.", GetErrorMessage(r));
+
+ pUserData->SetSlotFlag(false);
+
+ if (pUserData->GetContentTransferInfo() != null)
+ {
+ pUserData->GetContentTransferInfo()->SetDownloadStatus(Content::CONTENT_TRANSFER_STATUS_DOWNLOAD_COMPLETED);
+ }
+ }
+
+ return;
+
+CATCH:
+ ContentManager contentManager;
+
+ r = contentManager.Construct();
+ SysTryLog(NID_CNT, !IsFailed(r), "[%s] Failed to construct ContentManager.", GetErrorMessage(r));
+
+ r = contentManager.DeleteContent(contentId);
+ SysTryLog(NID_CNT, !IsFailed(r), "[%s] Failed to perform DeleteContent operation.", GetErrorMessage(r));
+
+ if (pContentTransferEventArg)
+ {
+ pContentTransferEventArg->SetResult(r);
+ pContentTransferEventArg->SetErrorMsg(Integer::ToString(errorCode), errorMsg);
+
+ r = pUserData->GetContentTransferEvent()->Fire(*(pContentTransferEventArg.release()));
+ SysTryLog(NID_CNT, !IsFailed(r), "[%s] Failed to perform fire operation on ContentTransferEvent.", GetErrorMessage(r));
+
+ pUserData->SetSlotFlag(false);
+ }
+
+ if (_FileImpl::IsFileExist(destPath))
+ {
+ r = file.Remove(destPath);
+ SysTryLog(NID_CNT, !IsFailed(r), "[%s] Failed to perform Remove operation for download file.", GetErrorMessage(r));
+ }
+
+ if (pUserData->GetContentTransferInfo() != null)
+ {
+ pUserData->GetContentTransferInfo()->SetDownloadStatus(Content::CONTENT_TRANSFER_STATUS_DOWNLOAD_COMPLETED);
+ }
+
+ return;
+}
+
+result
+_ContentDownloadListener::RegisterMediaFile(HttpSession& httpSession, HttpTransaction& httpTransaction,
+ _ContentDownloadUserData* pUserData)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ ContentId contentId;
+ ContentManager contentManager;
+ ContentType contentType = CONTENT_TYPE_UNKNOWN;
+ ImageContentInfo imageContentInfo;
+ AudioContentInfo audioContentInfo;
+ VideoContentInfo videoContentInfo;
+ OtherContentInfo otherContentInfo;
+ String contentPath(L"");
+
+ SysTryReturnResult(NID_CNT, pUserData != null, r = E_INVALID_STATE,
+ "ContentDownloadUserData instance must not be null.");
+
+ contentPath = pUserData->GetDestPath();
+
+ contentType = Content::_ContentManagerUtilImpl::CheckContentType(pUserData->GetDestPath());
+ r = GetLastResult();
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS || r == E_UNSUPPORTED_FORMAT, r,
+ "Failed to perform CheckContentType for [%ls].", (pUserData->GetDestPath()).GetPointer());
+
+ r = contentManager.Construct();
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to construct ContentManager.");
+
+ if (contentType == CONTENT_TYPE_IMAGE)
+ {
+ SysLog(NID_CNT, "Register the image type to database.");
+ r = imageContentInfo.Construct(&contentPath);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to construct ImageContentInfo.");
+
+ contentId = contentManager.CreateContent(imageContentInfo);
+ SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), GetLastResult(),
+ "Failed to perform CreateContent operation for image type.");
+ }
+ else if (contentType == CONTENT_TYPE_AUDIO)
+ {
+ SysLog(NID_CNT, "Register the audio type to database.");
+ r = audioContentInfo.Construct(&contentPath);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to construct AudioContentInfo.");
+
+ contentId = contentManager.CreateContent(audioContentInfo);
+ SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), GetLastResult(),
+ "Failed to perform CreateContent operation for audio type.");
+ }
+ else if (contentType == CONTENT_TYPE_VIDEO)
+ {
+ SysLog(NID_CNT, "Register the video type to database.");
+ r = videoContentInfo.Construct(&contentPath);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to construct VideoContentInfo.");
+
+ contentId = contentManager.CreateContent(videoContentInfo);
+ SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), GetLastResult(),
+ "Failed to perform CreateContent operation for video type.");
+ }
+ else if (contentType == CONTENT_TYPE_OTHER || contentType == CONTENT_TYPE_UNKNOWN)
+ {
+ SysLog(NID_CNT, "Register the other type to database.");
+ r = otherContentInfo.Construct(&contentPath);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to construct OtherContentInfo.");
+
+ contentId = contentManager.CreateContent(otherContentInfo);
+ SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), GetLastResult(),
+ "Failed to construct CreateContent operation for other type.");
+ }
+ else
+ {
+ r = E_SYSTEM;
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "contentType is CONTENT_TYPE_UNKNOWN.");
+ }
+
+ pUserData->SetContentId(contentId);
+
+ return r;
+}
+
+void
+_ContentDownloadListener::DownloadCanceled(_ContentDownloadUserData* pUserData, int statusCode, String errorMsg, result res)
+{
+ SysLog(NID_CNT, "Cancel the download operation with status code(%d).", statusCode);
+
+ ClearLastResult();
+ result r = E_SUCCESS;
+ std::unique_ptr<_ContentTransferEventArg> pTransferEventArg(new (std::nothrow) _ContentTransferEventArg);
+ SysTryReturnVoidResult(NID_CNT, pTransferEventArg != null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] pTransferEventArg construct failed.");
+
+ SysTryReturnVoidResult(NID_CNT, pUserData != null, r = E_INVALID_STATE,
+ "[E_INVALID_STATE] ContentDownloadUserData instance must not be null.");
+
+ pTransferEventArg->SetEventType(Content::CONTENT_TRANSFER_EVENT_CANCELED);
+ pTransferEventArg->SetRequestId(pUserData->GetRequestId());
+ pTransferEventArg->SetResult(res);
+ pTransferEventArg->SetErrorMsg(Integer::ToString(statusCode), errorMsg);
+
+ SysTryReturnVoidResult(NID_CNT, pUserData->GetContentTransferEvent() != null, r = E_INVALID_STATE,
+ "[E_INVALID_STATE] ContentTransferEvent in UserData must not be null.");
+
+ r = pUserData->GetContentTransferEvent()->Fire(*(pTransferEventArg.release()));
+ SysTryReturnVoidResult(NID_CNT, !IsFailed(r), r,
+ "[%s] Failed to perform fire operation on ContentTransferEvent.", GetErrorMessage(r));
+
+ if (pUserData->GetDownloadBufferFlag())
+ {
+ pUserData->SetDownloadBufferFlag(false);
+ }
+
+ pUserData->SetSlotFlag(false);
+
+ if (pUserData->GetContentTransferInfo() != null)
+ {
+ pUserData->GetContentTransferInfo()->SetDownloadStatus(Content::CONTENT_TRANSFER_STATUS_DOWNLOAD_COMPLETED);
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_INVALID_STATE, "[E_INVALID_STATE] ContentTransferInfo is not exist in UserData.");
+ }
+}
+
+void
+_ContentDownloadListener::TransferProgress(HttpSession& httpSession, HttpTransaction& httpTransaction,
+ long long currentLength, long long totalLength, _ContentDownloadUserData* pUserData)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ std::unique_ptr<_ContentTransferEventArg> pTransferEventArg(new (std::nothrow) _ContentTransferEventArg);
+ SysTryReturnVoidResult(NID_CNT, pTransferEventArg != null, r = E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ContentTransferEventArg.");
+
+ SysTryReturnVoidResult(NID_CNT, pUserData != null, r = E_INVALID_STATE,
+ "[E_INVALID_STATE] ContentDownloadUserData must not be null.");
+
+ pTransferEventArg->SetEventType(Content::CONTENT_TRANSFER_EVENT_TRANSFER_IN_PROGRESS);
+ pTransferEventArg->SetRequestId(pUserData->GetRequestId());
+ pTransferEventArg->SetTotalTransferedSize(currentLength);
+
+ SysTryReturnVoidResult(NID_CNT, pUserData->GetContentTransferEvent() != null, r = E_INVALID_STATE,
+ "[E_INVALID_STATE] ContentTransferEvent in UserData must not be null.");
+
+ r = pUserData->GetContentTransferEvent()->Fire(*(pTransferEventArg.release()));
+ SysTryReturnVoidResult(NID_CNT, !IsFailed(r), r = E_INVALID_STATE,
+ "[E_INVALID_STATE] Failed to perform fire operation on ContentTransferEvent.");
+}
+
+}}
+
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentDownloadListener.h
+ * @brief This is the header file for the %_ContentDownloadListener class.
+ *
+ * This header file contains the declarations of the %_ContentDownloadListener class.
+ */
+
+#ifndef _FCNT_INTERNAL_CONTENT_DOWNLOAD_LISTENER_H_
+#define _FCNT_INTERNAL_CONTENT_DOWNLOAD_LISTENER_H_
+
+#include <FNetHttpHttpSession.h>
+#include "FCnt_ContentDownloadUserData.h"
+
+namespace Tizen { namespace Io
+{
+class File;
+}}
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpTransaction;
+}}}
+namespace Tizen { namespace Net { namespace Http
+{
+class HttpRequest;
+}}}
+
+namespace Tizen { namespace Content
+{
+
+class _ContentDownloadListener
+ : public Tizen::Net::Http::IHttpTransactionEventListener
+ , public Tizen::Net::Http::IHttpProgressEventListener
+{
+public:
+ _ContentDownloadListener(void);
+ virtual ~_ContentDownloadListener(void);
+
+public:
+ virtual void OnTransactionReadyToRead(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, int availableBodyLen);
+ virtual void OnTransactionAborted(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, result r);
+ virtual void OnTransactionCompleted(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction);
+ virtual void OnTransactionCertVerificationRequiredN(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, Tizen::Base::String* pCert);
+ virtual void OnTransactionHeaderCompleted(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, int headerLen, bool bAuthRequired);
+ virtual void OnTransactionReadyToWrite(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, int recommendedChunkSize);
+
+ virtual void OnHttpDownloadInProgress(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, long long currentLength, long long totalLength);
+ virtual void OnHttpUploadInProgress(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, long long currentLength, long long totalLength);
+
+ void DownloadCompleted(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, _ContentDownloadUserData* pUserData, int errorCode, Tizen::Base::String errorMsg, result res);
+ void DownloadCanceled(_ContentDownloadUserData* pUserData, int statusCode, Tizen::Base::String errorMsg, result r);
+ void TransferProgress(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, long long currentLength, long long totalLength, _ContentDownloadUserData* pUserData);
+ result RegisterMediaFile(Tizen::Net::Http::HttpSession& httpSession, Tizen::Net::Http::HttpTransaction& httpTransaction, _ContentDownloadUserData* pUserData);
+
+
+private:
+ _ContentDownloadListener(const _ContentDownloadListener& rhs);
+ _ContentDownloadListener& operator =(const _ContentDownloadListener& rhs);
+}; // class _ContentDownloadListener
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_CONTENT_DOWNLOAD_LISTENER_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentDownloadUserData.cpp
+ * @brief This is the implementation file for the %_ContentDownloadUserData class.
+ *
+ * This file contains implementation of the %_ContentDownloadUserData class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FCntTypes.h>
+#include "FCnt_ContentDownloadUserData.h"
+
+using namespace Tizen;
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Content
+{
+
+_ContentDownloadUserData::_ContentDownloadUserData(void)
+ : __reqId(INVALID_REQUEST_ID)
+ , __contentId(UuId::GetInvalidUuId())
+ , __slot(-1)
+ , __downloadCount(-1)
+ , __maxDownloadCount(-1)
+ , __percent(-1)
+ , __totalSize(-1)
+ , __prevDownloadData(0)
+ , __isBuffer(false)
+ , __slotFlag(false)
+ , __pCheckDownloading(null)
+ , __pContentTransferEvent(null)
+ , __pContentTransferInfo(null)
+ , __url(L"")
+ , __destPath(L"")
+{
+}
+
+_ContentDownloadUserData::~_ContentDownloadUserData(void)
+{
+
+}
+
+RequestId
+_ContentDownloadUserData::GetRequestId(void) const
+{
+ return __reqId;
+}
+
+ContentId
+_ContentDownloadUserData::GetContentId(void) const
+{
+ return __contentId;
+}
+
+String
+_ContentDownloadUserData::GetUrl(void) const
+{
+ return __url;
+}
+
+String
+_ContentDownloadUserData::GetDestPath(void) const
+{
+ return __destPath;
+}
+
+bool
+_ContentDownloadUserData::GetDownloadBufferFlag(void) const
+{
+ return __isBuffer;
+}
+
+bool
+_ContentDownloadUserData::GetSlotFlag(void) const
+{
+ return __slotFlag;
+}
+
+int
+_ContentDownloadUserData::GetSlot(void) const
+{
+ return __slot;
+}
+
+int
+_ContentDownloadUserData::GetDownloadCount(void) const
+{
+ return __downloadCount;
+}
+
+int
+_ContentDownloadUserData::GetPercent(void) const
+{
+ return __percent;
+}
+
+_ContentTransferEvent*
+_ContentDownloadUserData::GetContentTransferEvent(void) const
+{
+ return __pContentTransferEvent;
+}
+
+ContentTransferInfo*
+_ContentDownloadUserData::GetContentTransferInfo(void) const
+{
+ return __pContentTransferInfo;
+}
+
+bool
+_ContentDownloadUserData::GetCheckDownloading(int slot) const
+{
+ return (__pCheckDownloading.get())[slot];
+}
+
+long long
+_ContentDownloadUserData::GetTotalSize(void) const
+{
+ return __totalSize;
+}
+
+long long
+_ContentDownloadUserData::GetPrevData(void) const
+{
+ return __prevDownloadData;
+}
+
+void
+_ContentDownloadUserData::SetRequestId(RequestId reqId)
+{
+ __reqId = reqId;
+}
+
+void
+_ContentDownloadUserData::SetContentId(const ContentId& contentId)
+{
+ __contentId = contentId;
+}
+
+void
+_ContentDownloadUserData::SetUrl(String& url)
+{
+ __url = url;
+}
+
+void
+_ContentDownloadUserData::SetDestPath(String& destPath)
+{
+ __destPath = destPath;
+}
+
+void
+_ContentDownloadUserData::SetDownloadBufferFlag(bool isBuffer)
+{
+ __isBuffer = isBuffer;
+}
+
+void
+_ContentDownloadUserData::SetSlotFlag(bool slotFlag)
+{
+ __slotFlag = slotFlag;
+}
+
+void
+_ContentDownloadUserData::SetSlot(int slot)
+{
+ __slot = slot;
+}
+
+void
+_ContentDownloadUserData::SetDownloadCount(int downloadCount)
+{
+ __downloadCount = downloadCount;
+}
+
+void
+_ContentDownloadUserData::SetMaxCount(int maxDownloadCount)
+{
+ __maxDownloadCount = maxDownloadCount;
+ std::unique_ptr<bool[]> pCheckDownloading(new (std::nothrow) bool[__maxDownloadCount]);
+ SysTryLog(NID_CNT, pCheckDownloading != null, "[E_OUT_OF_MEMORY] Failed to construct bool on SetMaxCount().");
+
+ __pCheckDownloading = std::move(pCheckDownloading);
+}
+
+void
+_ContentDownloadUserData::SetPercent(int percent)
+{
+ __percent = percent;
+}
+
+void
+_ContentDownloadUserData::SetContentTransferEvent(_ContentTransferEvent* transferEvent)
+{
+ __pContentTransferEvent = transferEvent;
+}
+
+void
+_ContentDownloadUserData::SetContentTransferInfo(ContentTransferInfo* transferInfo)
+{
+ __pContentTransferInfo = transferInfo;
+}
+
+void
+_ContentDownloadUserData::SetCheckDownloading(int slot, bool check)
+{
+ (__pCheckDownloading.get())[slot] = check;
+}
+
+void
+_ContentDownloadUserData::SetTotalSize(long long totalSize)
+{
+ __totalSize = totalSize;
+}
+
+void
+_ContentDownloadUserData::SetPrevData(long long data)
+{
+ __prevDownloadData = data;
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentDownloadUserData.h
+ * @brief This is the header file for the %_ContentDownloadUserData class.
+ *
+ * This header file contains the declarations of the %_ContentDownloadUserData class.
+ */
+
+#ifndef _FCNT_INTERNAL_CONTENT_DOWNLOAD_USERDATA_H_
+#define _FCNT_INTERNAL_CONTENT_DOWNLOAD_USERDATA_H_
+
+#include <FCntContentTransferInfo.h>
+#include <FIo_FileImpl.h>
+#include "FCnt_ContentTransferEvent.h"
+
+namespace Tizen { namespace Content
+{
+
+class _ContentDownloadUserData
+ : public Tizen::Base::Object
+{
+public:
+ _ContentDownloadUserData(void);
+ virtual ~_ContentDownloadUserData(void);
+
+ _ContentDownloadUserData(const _ContentDownloadUserData& userData);
+ _ContentDownloadUserData& operator =(const _ContentDownloadUserData& userData);
+
+ RequestId GetRequestId(void) const;
+ ContentId GetContentId(void) const;
+ Tizen::Base::String GetUrl(void) const;
+ Tizen::Base::String GetDestPath(void) const;
+ bool GetDownloadBufferFlag(void) const;
+ bool GetSlotFlag(void) const;
+ int GetSlot(void) const;
+ int GetDownloadCount(void) const;
+ int GetPercent(void) const;
+ _ContentTransferEvent* GetContentTransferEvent(void) const;
+ ContentTransferInfo* GetContentTransferInfo(void) const;
+ bool GetCheckDownloading(int slot) const;
+ long long GetTotalSize(void) const;
+ long long GetPrevData(void) const;
+
+ void SetRequestId(RequestId reqId);
+ void SetContentId(const ContentId& contentId);
+ void SetUrl(Tizen::Base::String& url);
+ void SetDestPath(Tizen::Base::String& destPath);
+ void SetDownloadBufferFlag(bool isBuffer);
+ void SetSlotFlag(bool slotFlag);
+ void SetSlot(int slot);
+ void SetDownloadCount(int downloadCount);
+ void SetMaxCount(int maxDownloadCount);
+ void SetPercent(int percent);
+ void SetContentTransferEvent(_ContentTransferEvent* transferEvent);
+ void SetContentTransferInfo(ContentTransferInfo* transferInfo);
+ void SetCheckDownloading(int slot, bool check);
+ void SetTotalSize(long long totalSize);
+ void SetPrevData(long long data);
+
+private:
+ RequestId __reqId;
+ ContentId __contentId;
+ int __slot;
+ int __downloadCount;
+ int __maxDownloadCount;
+ int __percent;
+ long long __totalSize;
+ long long __prevDownloadData;
+ bool __isBuffer;
+ bool __slotFlag;
+ std::unique_ptr<bool[]> __pCheckDownloading;
+ _ContentTransferEvent* __pContentTransferEvent;
+ ContentTransferInfo* __pContentTransferInfo;
+ Tizen::Base::String __url;
+ Tizen::Base::String __destPath;
+}; // _ContentDownloadUserData
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_CONTENT_DOWNLOAD_USERDATA_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentManagerImpl.cpp
+ * @brief This is the implementation file for the %_ContentManagerImpl class.
+ *
+ * This file contains implementation of the %_ContentManagerImpl class.
+ */
+
+#include <stdlib.h>
+#include <FBaseSysLog.h>
+#include <FAppApp.h>
+#include <FBaseInteger.h>
+#include <FBaseByteBuffer.h>
+#include <FCntContentManager.h>
+#include <FCntImageContentInfo.h>
+#include <FCntAudioContentInfo.h>
+#include <FCntVideoContentInfo.h>
+#include <FCntOtherContentInfo.h>
+#include <FCntImageMetadata.h>
+#include <FCntAudioMetadata.h>
+#include <FCntVideoMetadata.h>
+#include <FCntIContentScanListener.h>
+#include <FIoDirectory.h>
+#include <FSysEnvironment.h>
+#include <FCnt_ContentManagerImpl.h>
+#include <FCnt_ContentManagerUtilImpl.h>
+#include <FBase_StringConverter.h>
+#include <FIo_FileImpl.h>
+#include <FApp_AppInfo.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+using namespace Tizen::App;
+using namespace Tizen::System;
+using namespace std;
+
+namespace Tizen { namespace Content
+{
+
+static const int SYSTEM_TYPE_IMAGE = 0;
+static const int SYSTEM_TYPE_VIDEO = 1;
+static const int SYSTEM_TYPE_SOUND = 2;
+static const int SYSTEM_TYPE_MUSIC = 3;
+static const int SYSTEM_TYPE_OTHER = 4;
+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/";
+
+static void
+OnScanCompleted(media_content_error_e error, void *user_data)
+{
+ ClearLastResult();
+
+ SysLog(NID_CNT, "OnScanCompleted start.");
+
+ if (user_data == null)
+ {
+ SysLog(NID_CNT, "OnScanCompleted failed.");
+ return;
+ }
+
+ ScanResult* pScanResult = (ScanResult*)user_data;
+
+ if (pScanResult == null || pScanResult->pData == null || pScanResult->pContentPath == null)
+ {
+ SysLog(NID_CNT, "OnScanCompleted failed.");
+ return;
+ }
+
+ _ContentManagerImpl* __pManagerImpl = (_ContentManagerImpl*)pScanResult->pData;
+ String contentPath(pScanResult->pContentPath);
+
+ delete pScanResult;
+
+ result r = E_SUCCESS;
+ switch (error)
+ {
+ case MEDIA_CONTENT_ERROR_NONE:
+ r = E_SUCCESS;
+ break;
+
+ case MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT:
+ // fall through
+ case MEDIA_CONTENT_ERROR_INVALID_PARAMETER:
+ r = E_INVALID_ARG;
+ break;
+
+ case MEDIA_CONTENT_ERROR_DB_BUSY:
+ r = E_SERVICE_BUSY;
+ break;
+
+ default:
+ r = E_SYSTEM;
+ break;
+ }
+
+ (__pManagerImpl->GetListener())->OnContentScanCompleted(contentPath, r);
+
+ SysLog(NID_CNT, "OnScanCompleted end.");
+}
+
+_ContentManagerImpl::_ContentManagerImpl(void)
+ : Object()
+ , __isConnected(false)
+{
+
+}
+
+_ContentManagerImpl::~_ContentManagerImpl(void)
+{
+ int val = media_content_disconnect();
+ SysLog(NID_CNT, "media_content_disconnect result[%d].", val);
+
+ __isConnected = false;
+}
+
+_ContentManagerImpl*
+_ContentManagerImpl::GetInstance(ContentManager& contentManager)
+{
+ return contentManager.__pImpl;
+}
+
+const _ContentManagerImpl*
+_ContentManagerImpl::GetInstance(const ContentManager& contentManager)
+{
+ return contentManager.__pImpl;
+}
+
+//
+// E_SUCCESS
+// E_SYSTEM
+// E_OUT_OF_MEMORY(in public)
+//
+result
+_ContentManagerImpl::Construct(void)
+{
+ SysAssertf(!__isConnected,
+ "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
+
+ ClearLastResult();
+
+ int val = media_content_connect();
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM,
+ "The connection failed[%d].", val);
+
+ __isConnected = true;
+
+ return E_SUCCESS;
+}
+
+//
+// E_SUCCESS
+// E_INVALID_ARG
+// E_FILE_NOT_FOUND
+// E_OUT_OF_MEMORY
+// E_SYSTEM
+// E_SERVICE_BUSY
+// E_PRIVILEGE_DENIED(in public)
+// - E_IO
+//
+ContentId
+_ContentManagerImpl::CreateContent(const ContentInfo& contentInfo)
+{
+ SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ // Get common data from ContentInfo class
+ ContentInfo::_ContentData* pContentData = (const_cast <ContentInfo*>(&contentInfo))->GetContentData();
+ SysTryReturn(NID_CNT, pContentData != null, UuId::GetInvalidUuId(), E_INVALID_ARG,
+ "[E_INVALID_ARG] pContentData is null.");
+
+ SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(pContentData->contentPath, true), UuId::GetInvalidUuId(),
+ E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", (pContentData->contentPath).GetPointer());
+ SysTryReturn(NID_CNT, _FileImpl::IsFileExist(pContentData->contentPath), UuId::GetInvalidUuId(), E_FILE_NOT_FOUND,
+ "[E_FILE_NOT_FOUND] The file corresponding to contentInfo could not be found.");
+ SysTryReturn(NID_CNT, pContentData->contentId == UuId::GetInvalidUuId(), UuId::GetInvalidUuId(),
+ E_INVALID_ARG, "[E_INVALID_ARG] The contentId is not empty.");
+
+ // Compare the type of input parameter and system
+ ContentType inputType = pContentData->contentType;
+ ContentType sysType = _ContentManagerUtilImpl::CheckContentType(pContentData->contentPath, true);
+
+ if (inputType != sysType)
+ {
+ if (!(inputType == CONTENT_TYPE_OTHER && sysType == CONTENT_TYPE_UNKNOWN))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] The type is not match[%d, %d].", inputType, sysType);
+ return UuId::GetInvalidUuId();
+ }
+ }
+
+ // Save data to database with contentPath.
+ unique_ptr<char[]> pStr(_StringConverter::CopyToCharArrayN(pContentData->contentPath));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ media_info_h __pMediaInfo = null;
+ unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
+
+ // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
+ int val = media_info_insert_to_db(pStr.get(), &__pMediaInfo);
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "The registration to database failed[%d].", val);
+
+ pMediaInfo.reset(&__pMediaInfo);
+
+ // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
+ ContentId contentId = SaveDataToDatabase(*(pMediaInfo.get()), pContentData);
+ result r = GetLastResult();
+ SysTryCatch(NID_CNT, contentId != UuId::GetInvalidUuId(), , r,
+ "[%s] The registration to database failed.", GetErrorMessage(r));
+
+ return contentId;
+
+CATCH:
+ // There are two steps(insert and update) for content registration.
+ // If the update failed after inserting, the inserted data SHOULD be deleted from here.
+ val = media_info_delete_from_db(pStr.get());
+ SysLog(NID_CNT, "The result of deletion from database[%d].", val);
+
+ return UuId::GetInvalidUuId();
+}
+
+//
+// E_SUCCESS
+// E_INVALID_ARG
+// E_STORAGE_FULL
+// E_FILE_ALREADY_EXIST
+// E_ILLEGAL_ACCESS
+// E_MAX_EXCEEDED
+// E_IO
+// E_OUT_OF_MEMORY
+// E_SYSTEM
+// E_SERVICE_BUSY
+// E_PRIVILEGE_DENIED(in public)
+//
+ContentId
+_ContentManagerImpl::CreateContent(const ByteBuffer& byteBuffer, const String& destinationPath,
+ const ContentInfo* pContentInfo)
+{
+ SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ // Check parameters(for length)
+ SysTryReturn(NID_CNT, byteBuffer.GetRemaining() > 0, UuId::GetInvalidUuId(), E_INVALID_ARG,
+ "[E_INVALID_ARG] byteBuffer is invalid.");
+
+ // Check parameters(for path compatibility)
+ SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(destinationPath, false), UuId::GetInvalidUuId(),
+ E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", destinationPath.GetPointer());
+ SysTryReturn(NID_CNT, !_FileImpl::IsFileExist(destinationPath), UuId::GetInvalidUuId(), E_FILE_ALREADY_EXIST,
+ "[E_FILE_ALREADY_EXIST] The specified file already exists.");
+
+ // Create a file with bytebuffer
+ unique_ptr<File> pFile(new (nothrow) File);
+ SysTryReturn(NID_CNT, pFile != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ // Exception : E_SUCCESS, E_OUT_OF_MEMORY, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_MAX_EXCEEDED, E_STORAGE_FULL, E_IO, (E_FILE_NOT_FOUND), E_SYSTEM
+ result r = pFile->Construct(destinationPath, L"w+");
+ SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r,
+ "[%s] The destination file can not be created.", GetErrorMessage(r));
+
+ _FileImpl* pFileImpl = _FileImpl::GetInstance(*pFile);
+ SysTryReturn(NID_CNT, pFileImpl != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ // Exception : E_SUCCESS, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_STORAGE_FULL, E_IO
+ r = pFileImpl->Write(byteBuffer);
+ SysTryReturn(NID_CNT, !(IsFailed(r)), UuId::GetInvalidUuId(), r,
+ "[%s] The data can not be written in the destination file.", GetErrorMessage(r));
+
+ // for release file pointer
+ delete pFile.release();
+
+ int val = 0;
+ ContentId contentId;
+ ContentInfo::_ContentData contentData;
+ ContentInfo::_ContentData* pContentData = null;
+ media_info_h __pMediaInfo = null;
+ unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
+ unique_ptr<char[]> pStr(null);
+
+ if (pContentInfo != null)
+ {
+ pContentData = (const_cast <ContentInfo*>(pContentInfo))->GetContentData();
+ SysTryCatch(NID_CNT, pContentData != null, , E_INVALID_ARG, "[E_INVALID_ARG] GetContentData failed.");
+
+ SysTryCatch(NID_CNT, pContentData->contentId == UuId::GetInvalidUuId(), , E_INVALID_ARG,
+ "[E_INVALID_ARG] The content already exists in database.");
+
+ // Compare the type of input parameter and system
+ // CheckContentType() need actual file. so it should be checked after creating the file.
+ ContentType sysType = _ContentManagerUtilImpl::CheckContentType(destinationPath, true);
+ ContentType inputType = pContentData->contentType;
+
+ if (inputType != sysType)
+ {
+ if (!(inputType == CONTENT_TYPE_OTHER && sysType == CONTENT_TYPE_UNKNOWN))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] The type is not match[%d, %d].", inputType, sysType);
+ goto CATCH;
+ }
+ }
+
+ // Sets the content path
+ (pContentData->contentPath).Clear();
+ pContentData->contentPath = destinationPath;
+ }
+ else
+ {
+ // Set the content path
+ contentData.contentPath = destinationPath;
+
+ pContentData = &contentData;
+ }
+
+ // Register the content to database directly.
+ pStr.reset(_StringConverter::CopyToCharArrayN(destinationPath));
+ SysTryCatch(NID_CNT, pStr != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_insert_to_db(pStr.get(), &__pMediaInfo);
+ SysTryCatch(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, , ConvertError(val),
+ "media_info_insert_to_db failed[%d].", val);
+
+ pMediaInfo.reset(&__pMediaInfo);
+
+ // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
+ contentId = SaveDataToDatabase(*(pMediaInfo.get()), pContentData);
+ r = GetLastResult();
+ SysTryCatch(NID_CNT, contentId != UuId::GetInvalidUuId(), , r,
+ "[%s] SaveDataToDatabase failed.", GetErrorMessage(r));
+
+ return contentId;
+
+CATCH:
+ result saveResult = GetLastResult();
+
+ // If the destination file is made by this method, it should be deleted when error occurs.
+ r = _FileImpl::Remove(destinationPath);
+ SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
+
+ if (pMediaInfo != null)
+ {
+ val = media_info_delete_from_db(pStr.get());
+ SysLog(NID_CNT, "The result of deletion from database[%d].", val);
+ }
+
+ SetLastResult(saveResult);
+ return UuId::GetInvalidUuId();
+}
+
+//
+// E_SUCCESS
+// E_INVALID_ARG
+// E_FILE_NOT_FOUND
+// E_STORAGE_FULL
+// E_FILE_ALREADY_EXIST
+// E_ILLEGAL_ACCESS
+// E_MAX_EXCEEDED
+// E_IO
+// E_OUT_OF_MEMORY
+// E_SYSTEM
+// E_SERVICE_BUSY
+// E_PRIVILEGE_DENIED(in public)
+//
+ContentId
+_ContentManagerImpl::CreateContent(const String& sourcePath, const String& destinationPath, bool deleteSource,
+ const ContentInfo* pContentInfo)
+{
+ SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ // Check parameters(for type)
+ SysTryReturn(NID_CNT, _FileImpl::GetFileExtension(sourcePath) == _FileImpl::GetFileExtension(destinationPath),
+ UuId::GetInvalidUuId(), E_INVALID_ARG, "[E_INVALID_ARG] There is a mismatch between the type of source and dest path.");
+
+ // Check parameters(for path compatibility)
+ SysTryReturn(NID_CNT, VerifyHomeFilePathCompatibility(sourcePath), UuId::GetInvalidUuId(), E_INVALID_ARG,
+ "[E_INVALID_ARG] %ls is not compatible.", sourcePath.GetPointer());
+ SysTryReturn(NID_CNT, VerifyMediaFilePathCompatibility(destinationPath, false), UuId::GetInvalidUuId(),
+ E_INVALID_ARG, "[E_INVALID_ARG] %ls is not compatible.", destinationPath.GetPointer());
+
+ result r = E_SUCCESS;
+
+ if (deleteSource) // move
+ {
+ // Exception : E_SUCCESS, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_FILE_NOT_FOUND, E_FILE_ALREADY_EXIST, E_MAX_EXCEEDED, E_STORAGE_FULL, E_IO
+ r = _FileImpl::Move(sourcePath, destinationPath);
+ SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Moving the file failed.", GetErrorMessage(r));
+ }
+ else // copy
+ {
+ // Exception : E_SUCCESS, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_FILE_NOT_FOUND, E_FILE_ALREADY_EXIST, E_MAX_EXCEEDED, E_STORAGE_FULL, E_IO
+ r = _FileImpl::Copy(sourcePath, destinationPath, true);
+ SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), r, "[%s] Copying the file failed.", GetErrorMessage(r));
+ }
+
+ int val = 0;
+ ContentId contentId;
+ ContentInfo::_ContentData contentData;
+ ContentInfo::_ContentData* pContentData = null;
+ media_info_h __pMediaInfo = null;
+ unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
+ unique_ptr<char[]> pStr(null);
+
+ if (pContentInfo != null)
+ {
+ pContentData = (const_cast <ContentInfo*>(pContentInfo))->GetContentData();
+ SysTryCatch(NID_CNT, pContentData != null, , E_INVALID_ARG, "[E_INVALID_ARG] GetContentData failed.");
+
+ SysTryCatch(NID_CNT, pContentData->contentId == UuId::GetInvalidUuId(), , E_INVALID_ARG,
+ "[E_INVALID_ARG] The content already exists in database.");
+
+ // Compare the type of input parameter and system
+ // CheckContentType() need actual file. so it should be checked after creating the file.
+ ContentType sysType = _ContentManagerUtilImpl::CheckContentType(destinationPath, true);
+ ContentType inputType = pContentData->contentType;
+
+ if (inputType != sysType)
+ {
+ if (!(inputType == CONTENT_TYPE_OTHER && sysType == CONTENT_TYPE_UNKNOWN))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] The type is not match[%d, %d].", inputType, sysType);
+ goto CATCH;
+ }
+ }
+
+ // Set the content path
+ (pContentData->contentPath).Clear();
+ pContentData->contentPath = destinationPath;
+ }
+ else
+ {
+ // Set the content path
+ contentData.contentPath = destinationPath;
+
+ pContentData = &contentData;
+ }
+
+ pStr.reset(_StringConverter::CopyToCharArrayN(destinationPath));
+ SysTryCatch(NID_CNT, pStr != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_insert_to_db(pStr.get(), &__pMediaInfo);
+ SysTryCatch(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, , ConvertError(val),
+ "media_info_insert_to_db failed[%d].", val);
+
+ pMediaInfo.reset(&__pMediaInfo);
+
+ contentId = SaveDataToDatabase(*(pMediaInfo.get()), pContentData);
+ r = GetLastResult();
+ SysTryCatch(NID_CNT, contentId != UuId::GetInvalidUuId(), , r,
+ "[%s] SaveDataToDatabase failed.", GetErrorMessage(r));
+
+ return contentId;
+
+CATCH:
+ result saveResult = GetLastResult();
+
+ // If the destination file is made by this method, it should be deleted when error occurs.
+ r = _FileImpl::Remove(destinationPath);
+ SysLog(NID_CNT, "Remove[%s].", GetErrorMessage(r));
+
+ if (pMediaInfo != null)
+ {
+ val = media_info_delete_from_db(pStr.get());
+ SysLog(NID_CNT, "The result of deletion from database[%d].", val);
+ }
+
+ SetLastResult(saveResult);
+ return UuId::GetInvalidUuId();
+}
+
+//
+// E_SUCCESS
+// E_INVALID_ARG
+// E_FILE_NOT_FOUND
+// E_OUT_OF_MEMORY
+// E_SYSTEM
+// E_SERVICE_BUSY
+// E_PRIVILEGE_DENIED(in public)
+//
+ContentInfo*
+_ContentManagerImpl::GetContentInfoN(const ContentId& contentId) const
+{
+ SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ SysTryReturn(NID_CNT, contentId != UuId::GetInvalidUuId(), null, E_INVALID_ARG,
+ "[E_INVALID_ARG] The contentId is invalid.");
+
+ unique_ptr<char[]> pStr(_StringConverter::CopyToCharArrayN(contentId.ToString()));
+ SysTryReturn(NID_CNT, pStr != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ media_info_h __pMediaInfo = null;
+ unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
+ int val = media_info_get_media_from_db(pStr.get(), &__pMediaInfo);
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, null, ConvertError(val),
+ "media_info_get_media_from_db failed[%d].", val);
+
+ pMediaInfo.reset(&__pMediaInfo);
+
+ media_content_type_e systemType = MEDIA_CONTENT_TYPE_IMAGE;
+ val = media_info_get_media_type(*(pMediaInfo.get()), &systemType);
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, null, ConvertError(val),
+ "media_info_get_media_type failed[%d].", val);
+
+ char* __pFilePath = null;
+ val = media_info_get_file_path(*(pMediaInfo.get()), &__pFilePath);
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, null, ConvertError(val),
+ "media_info_get_file_path failed[%d].", val);
+
+ unique_ptr<char, CharDeleter> pFilePath(__pFilePath);
+
+ SysTryReturn(NID_CNT, _FileImpl::IsFileExist(String(pFilePath.get())), null, E_FILE_NOT_FOUND,
+ "[E_FILE_NOT_FOUND] The file corresponding to contentId could not be found.");
+
+ result r = E_SUCCESS;
+
+ if (systemType == SYSTEM_TYPE_IMAGE)
+ {
+ unique_ptr<ImageContentInfo> pImageContentInfo(new (nothrow) ImageContentInfo);
+ SysTryReturn(NID_CNT, pImageContentInfo != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ // Get custom data
+ ContentInfo::_ContentData* pContentData = pImageContentInfo->GetContentData();
+ SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ // Get image metadata
+ ImageContentInfo::_ImageContentData* pImageContentData = pImageContentInfo->GetImageContentData();
+ SysTryReturn(NID_CNT, pImageContentData != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ // Set data
+ // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SERVICE_BUSY, E_SYSTEM
+ r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, pImageContentData);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
+
+ return pImageContentInfo.release();
+ }
+ else if (systemType == SYSTEM_TYPE_SOUND || systemType == SYSTEM_TYPE_MUSIC)
+ {
+ unique_ptr<AudioContentInfo> pAudioContentInfo(new (nothrow) AudioContentInfo);
+ SysTryReturn(NID_CNT, pAudioContentInfo != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ ContentInfo::_ContentData* pContentData = pAudioContentInfo->GetContentData();
+ SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ AudioContentInfo::_AudioContentData* pAudioContentData = pAudioContentInfo->GetAudioContentData();
+ SysTryReturn(NID_CNT, pAudioContentData != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, pAudioContentData);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
+
+ return pAudioContentInfo.release();
+ }
+ else if (systemType == SYSTEM_TYPE_VIDEO)
+ {
+ unique_ptr<VideoContentInfo> pVideoContentInfo(new (nothrow) VideoContentInfo);
+ SysTryReturn(NID_CNT, pVideoContentInfo != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ ContentInfo::_ContentData* pContentData = pVideoContentInfo->GetContentData();
+ SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ VideoContentInfo::_VideoContentData* pVideoContentData = pVideoContentInfo->GetVideoContentData();
+ SysTryReturn(NID_CNT, pVideoContentData != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, pVideoContentData);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
+
+ return pVideoContentInfo.release();
+ }
+ else if (systemType == SYSTEM_TYPE_OTHER)
+ {
+ unique_ptr<OtherContentInfo> pOtherContentInfo(new (nothrow) OtherContentInfo);
+ SysTryReturn(NID_CNT, pOtherContentInfo != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ ContentInfo::_ContentData* pContentData = pOtherContentInfo->GetContentData();
+ SysTryReturn(NID_CNT, pContentData != null, null, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ r = MakeContentInfo(*(pMediaInfo.get()), pContentData, systemType, null);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] MakeContentInfo failed.", GetErrorMessage(r));
+
+ return pOtherContentInfo.release();
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] Unsupported type");
+ return null;
+ }
+}
+
+//
+// E_SUCCESS
+// E_INVALID_ARG
+// E_FILE_NOT_FOUND
+// E_OUT_OF_MEMORY
+// E_SYSTEM
+// E_SERVICE_BUSY
+// E_PRIVILEGE_DENIED(in public)
+//
+result
+_ContentManagerImpl::UpdateContent(const ContentInfo& contentInfo)
+{
+ SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ ContentId contentId = contentInfo.GetContentId();
+ SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, "The content id is invalid.");
+ SysTryReturnResult(NID_CNT, _FileImpl::IsFileExist(contentInfo.GetContentPath()), E_FILE_NOT_FOUND,
+ "The file corresponding to contentInfo could not be found.");
+
+ // Get common data from ContentInfo class
+ ContentInfo::_ContentData* pContentData = (const_cast <ContentInfo*>(&contentInfo))->GetContentData();
+ SysTryReturnResult(NID_CNT, pContentData != null, E_INVALID_ARG, "pContentData is null.");
+
+ // Exception : E_SUCCESS, E_INVALID_ARG, E_OUT_OF_MEMORY, E_SYSTEM, E_SERVICE_BUSY
+ result r = this->UpdateDataToDatabase(pContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "UpdateDataToDatabase failed.");
+
+ return r;
+}
+
+//
+// E_SUCCESS
+// E_INVALID_ARG
+// E_FILE_NOT_FOUND
+// E_OUT_OF_MEMORY
+// E_SYSTEM
+// E_SERVICE_BUSY
+// E_PRIVILEGE_DENIED(in public)
+// - E_ILLEGAL_ACCESS
+//
+result
+_ContentManagerImpl::DeleteContent(const ContentId& contentId)
+{
+ SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, "The contentId is invalid.");
+
+ unique_ptr<char[]> pContentId(_StringConverter::CopyToCharArrayN(contentId.ToString()));
+ SysTryReturnResult(NID_CNT, pContentId != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ result r = E_SUCCESS;
+ int val = 0;
+ media_info_h __pMediaInfo = null;
+ unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
+
+ val = media_info_get_media_from_db(pContentId.get(), &__pMediaInfo);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_media_from_db failed[%d].", val);
+
+ pMediaInfo.reset(&__pMediaInfo);
+
+ char* __pContentPath = null;
+
+ val = media_info_get_file_path(*(pMediaInfo.get()), &__pContentPath);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_file_path failed[%d].", val);
+
+ unique_ptr<char, CharDeleter> pContentPath(__pContentPath);
+
+ String contentPath = String(pContentPath.get());
+ SysTryReturnResult(NID_CNT, _FileImpl::IsFileExist(contentPath), E_FILE_NOT_FOUND,
+ "The file corresponding to contentId could not be found.");
+
+ val = media_info_delete_from_db(pContentId.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_delete_From_db failed[%d].", val);
+
+ r = _FileImpl::Remove(contentPath);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The file is not deleted.");
+
+ return r;
+}
+
+result
+_ContentManagerImpl::ScanFile(const String& contentPath)
+{
+ SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ unique_ptr<char[]> pContentPath(_StringConverter::CopyToCharArrayN(contentPath));
+
+ 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);
+
+ return E_SUCCESS;
+}
+
+result
+_ContentManagerImpl::ScanDirectory(const String& directoryPath, bool recursive, _IContentScanListener& listener)
+{
+ SysAssertf(__isConnected, "Not yet constructed. Construct() should be called before use.");
+
+ ClearLastResult();
+
+ unique_ptr<char[]> pDirPath(_StringConverter::CopyToCharArrayN(directoryPath));
+
+ SetListener(&listener);
+
+ ScanResult* pScanResult = new (nothrow) ScanResult;
+ SysTryReturnResult(NID_CNT, pScanResult != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ pScanResult->pData = this;
+ pScanResult->pContentPath = pDirPath.get();
+
+ 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);
+
+ return E_SUCCESS;
+}
+
+void
+_ContentManagerImpl::SetListener(_IContentScanListener* pListener)
+{
+ this->__pListener = pListener;
+}
+
+_IContentScanListener*
+_ContentManagerImpl::GetListener(void) const
+{
+ return this->__pListener;
+}
+
+//
+// E_SUCCESS
+// E_INVALID_ARG
+// E_OUT_OF_MEMORY
+// E_SYSTEM
+// E_SERVICE_BUSY
+//
+result
+_ContentManagerImpl::UpdateDataToDatabase(const ContentInfo::_ContentData* pContentData) const
+{
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, pContentData != null, E_INVALID_ARG, "pContentData is null.");
+
+ media_info_h __pMediaInfo = null;
+ unique_ptr<media_info_h, MediaInfoDeleter> pMediaInfo(null);
+ unique_ptr<char[]> pContentId(_StringConverter::CopyToCharArrayN((pContentData->contentId).ToString()));
+ SysTryReturnResult(NID_CNT, pContentId != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ int val = media_info_get_media_from_db(pContentId.get(), &__pMediaInfo);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_media_from_db failed[%d].", val);
+
+ pMediaInfo.reset(&__pMediaInfo);
+
+ result r = E_SUCCESS;
+ unique_ptr<char[]> pValue(null);
+
+ if (pContentData->pAuthor != null)
+ {
+ pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pAuthor)));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ val = media_info_set_author(*(pMediaInfo.get()), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_author failed[%d].", val);
+ }
+ if (pContentData->pCategory != null)
+ {
+ pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pCategory)));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ val = media_info_set_category(*(pMediaInfo.get()), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_category failed[%d].", val);
+ }
+ if (pContentData->pContentName != null)
+ {
+ pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pContentName)));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ val = media_info_set_content_name(*(pMediaInfo.get()), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_content_name failed[%d].", val);
+ }
+ if (pContentData->pDescription != null)
+ {
+ pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pDescription)));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ val = media_info_set_description(*(pMediaInfo.get()), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_description failed[%d].", val);
+ }
+ if (pContentData->pKeyword != null)
+ {
+ pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pKeyword)));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ val = media_info_set_keyword(*(pMediaInfo.get()), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_keyword failed[%d].", val);
+ }
+ if (pContentData->pLocationTag != null)
+ {
+ pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pLocationTag)));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ val = media_info_set_location_tag(*(pMediaInfo.get()), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_location_tag failed[%d].", val);
+ }
+ if (pContentData->pProvider != null)
+ {
+ pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pProvider)));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ val = media_info_set_provider(*(pMediaInfo.get()), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_provider failed[%d].", val);
+ }
+ if (pContentData->pRating != null)
+ {
+ pValue.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pRating)));
+ SysTryReturnResult(NID_CNT, pValue != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ val = media_info_set_age_rating(*(pMediaInfo.get()), pValue.get());
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_age_rating failed[%d].", val);
+ }
+ if (Double::Compare(pContentData->latitude, DEFAULT_COORDINATE) != 0 &&
+ Double::Compare(pContentData->longitude, DEFAULT_COORDINATE) != 0)
+ {
+ val = media_info_set_latitude(*(pMediaInfo.get()), pContentData->latitude);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_latitude failed[%d].", val);
+
+ val = media_info_set_longitude(*(pMediaInfo.get()), pContentData->longitude);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_longitude failed[%d].", val);
+
+ if (Double::Compare(pContentData->altitude, DEFAULT_COORDINATE) != 0)
+ {
+ val = media_info_set_altitude(*(pMediaInfo.get()), pContentData->altitude);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_set_altitude failed[%d].", val);
+ }
+ }
+
+ val = media_info_update_to_db(*(pMediaInfo.get()));
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_update_to_db failed[%d].", val);
+
+ return r;
+}
+
+//
+// E_SUCCESS
+// E_INVALID_ARG
+// E_OUT_OF_MEMORY
+// E_SERVICE_BUSY
+// E_SYSTEM
+//
+ContentId
+_ContentManagerImpl::SaveDataToDatabase(const media_info_h pMediaInfo,
+ ContentInfo::_ContentData* pContentData) const
+{
+ ClearLastResult();
+
+ SysTryReturn(NID_CNT, pContentData != null, UuId::GetInvalidUuId(), E_INVALID_ARG,
+ "[E_INVALID_ARG] pContentData is null.");
+
+ // Exception : E_SUCCESS, E_INVALID_ARG
+ String extension = _FileImpl::GetFileExtension(pContentData->contentPath);
+ result r = GetLastResult();
+ SysTryReturn(NID_CNT, !(IsFailed(r)), UuId::GetInvalidUuId(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+ // If the content format is JPG and it has GPS data, it will be saved in database automatically.
+ if (extension == L"jpg" || extension == L"jpeg" || extension == L"JPG" || extension == L"JPEG")
+ {
+ SysLog(NID_CNT, "The format of content is jpg.");
+
+ ImageMetadata* pImageMetadata = _ContentManagerUtilImpl::GetImageMetaN(pContentData->contentPath, true);
+ if (pImageMetadata != null)
+ {
+ pContentData->latitude = pImageMetadata->GetLatitude();
+ pContentData->longitude = pImageMetadata->GetLongitude();
+
+ delete pImageMetadata;
+ pImageMetadata = null;
+ }
+ }
+
+ int val = 0;
+ unique_ptr<char[]> pStr(null);
+
+ if (pContentData->pAuthor != null)
+ {
+ pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pAuthor)));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_set_author(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_author failed[%d].", val);
+ }
+ if (pContentData->pCategory != null)
+ {
+ pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pCategory)));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_set_category(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_category failed[%d].", val);
+ }
+ if (pContentData->pContentName != null)
+ {
+ pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pContentName)));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_set_content_name(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_content_name failed[%d].", val);
+ }
+ if (pContentData->pDescription != null)
+ {
+ pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pDescription)));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_set_description(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_description failed[%d].", val);
+ }
+ if (pContentData->pKeyword != null)
+ {
+ pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pKeyword)));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_set_keyword(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_keyword failed[%d].", val);
+ }
+ if (pContentData->pLocationTag != null)
+ {
+ pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pLocationTag)));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_set_location_tag(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_location_tag failed[%d].", val);
+ }
+ if (pContentData->pProvider != null)
+ {
+ pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pProvider)));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_set_provider(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_provider failed[%d].", val);
+ }
+ if (pContentData->pRating != null)
+ {
+ pStr.reset(_StringConverter::CopyToCharArrayN(*(pContentData->pRating)));
+ SysTryReturn(NID_CNT, pStr != null, UuId::GetInvalidUuId(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ val = media_info_set_age_rating(pMediaInfo, pStr.get());
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_age_rating failed[%d].", val);
+ }
+ if (Double::Compare(pContentData->latitude, DEFAULT_COORDINATE) != 0 &&
+ Double::Compare(pContentData->longitude, DEFAULT_COORDINATE) != 0)
+ {
+ val = media_info_set_latitude(pMediaInfo, pContentData->latitude);
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_latitude failed[%d].", val);
+
+ val = media_info_set_longitude(pMediaInfo, pContentData->longitude);
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_longitude failed[%d].", val);
+
+ if (Double::Compare(pContentData->altitude, DEFAULT_COORDINATE) != 0)
+ {
+ val = media_info_set_altitude(pMediaInfo, pContentData->altitude);
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_set_altitude failed[%d].", val);
+ }
+ }
+
+ val = media_info_update_to_db(pMediaInfo);
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_update_to_db failed[%d].", val);
+
+ char* __pMediaId = null;
+ unique_ptr<char, CharDeleter> pMediaId(null);
+
+ val = media_info_get_media_id(pMediaInfo, &__pMediaId);
+ if (__pMediaId != null)
+ {
+ pMediaId.reset(__pMediaId);
+ }
+ else
+ {
+ SysTryReturn(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, UuId::GetInvalidUuId(), ConvertError(val),
+ "media_info_get_media_id failed[%d].", val);
+ }
+
+ String contentId(pMediaId.get());
+
+ r = UuId::Parse(contentId, pContentData->contentId);
+ SysTryReturn(NID_CNT, !IsFailed(r), UuId::GetInvalidUuId(), E_INVALID_ARG,
+ "[E_INVALID_ARG] UuId::Parse failed.");
+
+ return pContentData->contentId;
+}
+
+//
+// E_SUCCESS
+// E_INVALID_ARG
+// E_OUT_OF_MEMORY
+// E_SERVICE_BUSY
+// E_SYSTEM
+//
+result
+_ContentManagerImpl::MakeContentInfo(const media_info_h pMediaInfo, ContentInfo::_ContentData* pContentData,
+ int systemType, void* pMetadata) const
+{
+ ClearLastResult();
+
+ if (systemType != SYSTEM_TYPE_OTHER)
+ {
+ SysTryReturnResult(NID_CNT, pMediaInfo != null && pContentData != null && pMetadata != null, E_INVALID_ARG,
+ "The specified parameter is invalid.");
+ }
+ else // There is no metadata in Other type
+ {
+ SysTryReturnResult(NID_CNT, pMediaInfo != null && pContentData != null, E_INVALID_ARG,
+ "The specified parameter is invalid.");
+ }
+
+ result r = E_SUCCESS;
+ char* __pStrValue = null;
+ unique_ptr<char, CharDeleter> pStrValue(null);
+
+ // contentId
+ int val = media_info_get_media_id(pMediaInfo, &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_media_id failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ String strContentId(pStrValue.get());
+
+ r = UuId::Parse(strContentId, pContentData->contentId);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The content id can not be parsed.");
+
+ SysLog(NID_CNT, "INFO: contentId[%ls]", strContentId.GetPointer());
+ }
+
+ // contentPath
+ val = media_info_get_file_path(pMediaInfo, &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_file_path failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ String strFilePath(pStrValue.get());
+
+ // If the api version is 2.0, the content path has to be changed.
+ if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+ {
+ if (strFilePath.StartsWith(Environment::GetMediaPath(), 0))
+ {
+ r = strFilePath.Replace(Environment::GetMediaPath(), OSP_MEDIA_PHONE);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The content path is not changed.");
+ }
+ else if (strFilePath.StartsWith(Environment::GetExternalStoragePath(), 0))
+ {
+ r = strFilePath.Replace(Environment::GetExternalStoragePath(), OSP_MEDIA_MMC);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Replace failed.");
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] The content path is not supported[%ls].", strFilePath.GetPointer());
+ return E_INVALID_ARG;
+ }
+ }
+
+ pContentData->contentPath = strFilePath;
+
+ SysLog(NID_CNT, "INFO: contentPath[%ls]", strFilePath.GetPointer());
+ }
+
+ // mimeType
+ val = media_info_get_mime_type(pMediaInfo, &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_mime_type failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ pContentData->mimeType = pStrValue.get();
+
+ SysLog(NID_CNT, "INFO: mimeType[%ls]", (pContentData->mimeType).GetPointer());
+ }
+
+ // contentSize
+ unsigned long long longlongValue = 0;
+ val = media_info_get_size(pMediaInfo, &longlongValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_size failed[%d].", val);
+ pContentData->contentSize = longlongValue;
+ SysLog(NID_CNT, "INFO: contentSize[%llu]", longlongValue);
+
+ // storageType
+ media_content_storage_e storageType;
+ val = media_info_get_storage_type(pMediaInfo, &storageType);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_storage_type failed[%d].", val);
+ pContentData->storageType = storageType;
+ SysLog(NID_CNT, "INFO: storageType[%d]", storageType);
+
+ // isDrm
+ val = media_info_is_drm(pMediaInfo, &(pContentData->isDrm));
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_is_drm failed[%d].", val);
+ SysLog(NID_CNT, "INFO: isDrm[%d]", pContentData->isDrm);
+
+ // dateTime
+ time_t time = 0;
+ val = media_info_get_added_time(pMediaInfo, &time);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_added_time failed[%d].", val);
+ r = (pContentData->dateTime).SetValue(1970, 1, 1);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "SetValue failed.");
+ r = (pContentData->dateTime).AddSeconds(time);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "AddSeconds failed.");
+ SysLog(NID_CNT, "INFO: dateTime[%ls]", ((pContentData->dateTime).ToString()).GetPointer());
+
+ // thumbnailPath
+ val = media_info_get_thumbnail_path(pMediaInfo, &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_thumbnail_path failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ pContentData->pThumbnailPath = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "INFO: thumbnailPath[%ls]", (*pContentData->pThumbnailPath).GetPointer());
+ }
+
+ // author
+ val = media_info_get_author(pMediaInfo, &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_author failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ pContentData->pAuthor = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "INFO: author[%ls]", (*pContentData->pAuthor).GetPointer());
+ }
+
+ // category
+ val = media_info_get_category(pMediaInfo, &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_category failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ pContentData->pCategory = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "INFO: category[%ls]", (*pContentData->pCategory).GetPointer());
+ }
+
+ // contentName
+ val = media_info_get_content_name(pMediaInfo, &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_content_name failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ pContentData->pContentName = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "INFO: contentName[%ls]", (*pContentData->pContentName).GetPointer());
+ }
+
+ // description
+ val = media_info_get_description(pMediaInfo, &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_description failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ pContentData->pDescription = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "INFO: description[%ls]", (*pContentData->pDescription).GetPointer());
+ }
+
+ // keyword
+ val = media_info_get_keyword(pMediaInfo, &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_keyword failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ pContentData->pKeyword = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "INFO: keyword[%ls]", (*pContentData->pKeyword).GetPointer());
+ }
+
+ // locationTag
+ val = media_info_get_location_tag(pMediaInfo, &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_location_tag failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ pContentData->pLocationTag = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "INFO: locationTag[%ls]", (*pContentData->pLocationTag).GetPointer());
+ }
+
+ // provider
+ val = media_info_get_provider(pMediaInfo, &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_provider failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ pContentData->pProvider = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "INFO: provider[%ls]", (*pContentData->pProvider).GetPointer());
+ }
+
+ // rating
+ val = media_info_get_age_rating(pMediaInfo, &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_age_rating failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ pContentData->pRating = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "INFO: rating[%ls]", (*pContentData->pRating).GetPointer());
+ }
+
+ // coordinates
+ double doubleValue = 0;
+ val = media_info_get_latitude(pMediaInfo, &doubleValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_latitude failed[%d].", val);
+
+ if (Double::Compare(doubleValue, DEFAULT_COORDINATE) != 0)
+ {
+ pContentData->latitude = doubleValue;
+ }
+ SysLog(NID_CNT, "INFO: latitude[%f]", pContentData->latitude);
+
+ val = media_info_get_longitude(pMediaInfo, &doubleValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_longitude failed[%d].", val);
+
+ if (Double::Compare(doubleValue, DEFAULT_COORDINATE) != 0)
+ {
+ pContentData->longitude = doubleValue;
+ }
+ SysLog(NID_CNT, "INFO: longitude[%f]", pContentData->longitude);
+
+ val = media_info_get_altitude(pMediaInfo, &doubleValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_altitude failed[%d].", val);
+
+ if (Double::Compare(doubleValue, DEFAULT_COORDINATE) != 0)
+ {
+ pContentData->altitude = doubleValue;
+ }
+ SysLog(NID_CNT, "INFO: altitude[%f]", pContentData->altitude);
+
+ int intValue = 0;
+
+ // contentType and metadata
+ if (systemType == SYSTEM_TYPE_IMAGE)
+ {
+ image_meta_h __pImageMeta = null;
+ unique_ptr<image_meta_h, ImageMetaDeleter> pImageMeta(null);
+
+ pContentData->contentType = CONTENT_TYPE_IMAGE;
+ SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
+
+ val = media_info_get_image(pMediaInfo, &__pImageMeta);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_image failed[%d].", val);
+
+ pImageMeta.reset(&__pImageMeta);
+
+ // width
+ val = image_meta_get_width(*(pImageMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "image_meta_get_width failed[%d].", val);
+
+ (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->width = intValue;
+ SysLog(NID_CNT, "META: width[%d]", intValue);
+
+ // height
+ val = image_meta_get_height(*(pImageMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "image_meta_get_height failed[%d].", val);
+
+ (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->height = intValue;
+ SysLog(NID_CNT, "META: height[%d]", intValue);
+
+ // orientation
+ media_content_orientation_e orientation;
+ val = image_meta_get_orientation(*(pImageMeta.get()), &orientation);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "image_meta_get_orientation failed[%d].", val);
+
+ (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->orientationType =
+ static_cast<ImageOrientationType>(orientation);
+ SysLog(NID_CNT, "META: orientation[%d]", orientation);
+
+ // title
+ val = media_info_get_display_name(pMediaInfo, &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_display_name failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ int pos = 0;
+ String fileName;
+ String strTitle(pStrValue.get());
+
+ r = strTitle.LastIndexOf(L'.', strTitle.GetLength() - 1, pos);
+ if (r == E_SUCCESS)
+ {
+ r = strTitle.SubString(0, pos, fileName);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "The title is invalid.");
+ }
+ else
+ {
+ // Without extension
+ r = E_SUCCESS;
+ fileName = strTitle;
+ }
+
+ (static_cast<ImageContentInfo::_ImageContentData*>(pMetadata))->title = fileName;
+
+ SysLog(NID_CNT, "META: title[%ls]", fileName.GetPointer());
+ }
+ }
+ else if (systemType == SYSTEM_TYPE_SOUND || systemType == SYSTEM_TYPE_MUSIC)
+ {
+ audio_meta_h __pAudioMeta = null;
+ unique_ptr<audio_meta_h, AudioMetaDeleter> pAudioMeta(null);
+
+ pContentData->contentType = CONTENT_TYPE_AUDIO;
+ SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
+
+ val = media_info_get_audio(pMediaInfo, &__pAudioMeta);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_audio failed[%d].", val);
+
+ pAudioMeta.reset(&__pAudioMeta);
+
+ // bitrate
+ val = audio_meta_get_bit_rate(*(pAudioMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_bit_rate failed[%d].", val);
+
+ (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->bitrate = intValue;
+ SysLog(NID_CNT, "META: bitrate[%d]", intValue);
+
+ // releaseYear
+ val = audio_meta_get_year(*(pAudioMeta.get()), &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_year failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ String strYear(pStrValue.get());
+
+ if (strYear.CompareTo(L"Unknown") != 0)
+ {
+ r = Integer::Parse(strYear, intValue);
+ if (IsFailed(r))
+ {
+ // It is one of the metadata. If error occurs, skip it for other metadata.
+ intValue = 0;
+ r = E_SUCCESS;
+ SysLog(NID_CNT, "META: releaseYear - invalid data[%ls]", strYear.GetPointer());
+ }
+
+ (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->releaseYear = intValue;
+ SysLog(NID_CNT, "META: releaseYear[%d]", intValue);
+ }
+ }
+
+ // title
+ val = audio_meta_get_title(*(pAudioMeta.get()), &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_title failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pTitle =
+ new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "META: title[%ls]", (String(pStrValue.get())).GetPointer());
+ }
+
+ // albumName
+ val = audio_meta_get_album(*(pAudioMeta.get()), &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_album failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pAlbumName =
+ new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "META: albumName[%ls]", (String(pStrValue.get())).GetPointer());
+ }
+
+ // artist
+ val = audio_meta_get_artist(*(pAudioMeta.get()), &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_artist failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pArtist =
+ new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "META: artist[%ls]", (String(pStrValue.get())).GetPointer());
+ }
+
+ // composer
+ val = audio_meta_get_composer(*(pAudioMeta.get()), &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_composer failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pComposer =
+ new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "META: composer[%ls]", (String(pStrValue.get())).GetPointer());
+ }
+
+ // genre
+ val = audio_meta_get_genre(*(pAudioMeta.get()), &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_genre failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pGenre =
+ new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "META: genre[%ls]", (String(pStrValue.get())).GetPointer());
+ }
+
+ // copyright
+ val = audio_meta_get_copyright(*(pAudioMeta.get()), &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_copyright failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pCopyright =
+ new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "META: copyright[%ls]", (String(pStrValue.get())).GetPointer());
+ }
+
+ // trackInfo
+ val = audio_meta_get_track_num(*(pAudioMeta.get()), &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_track_num failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->pTrackInfo
+ = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "META: trackInfo[%ls]", (String(pStrValue.get())).GetPointer());
+ }
+
+ // duration
+ val = audio_meta_get_duration(*(pAudioMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "audio_meta_get_duration failed[%d].", val);
+
+ (static_cast<AudioContentInfo::_AudioContentData*>(pMetadata))->duration = intValue;
+ SysLog(NID_CNT, "META: duration[%d]", intValue);
+
+ }
+ else if (systemType == MEDIA_CONTENT_TYPE_VIDEO)
+ {
+ video_meta_h __pVideoMeta = null;
+ unique_ptr<video_meta_h, VideoMetaDeleter> pVideoMeta(null);
+
+ pContentData->contentType = CONTENT_TYPE_VIDEO;
+ SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
+
+ val = media_info_get_video(pMediaInfo, &__pVideoMeta);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "media_info_get_video failed[%d].", val);
+
+ pVideoMeta.reset(&__pVideoMeta);
+
+ // width
+ val = video_meta_get_width(*(pVideoMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_width failed[%d].", val);
+
+ (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->width = intValue;
+ SysLog(NID_CNT, "META: width[%d]", intValue);
+
+ // height
+ val = video_meta_get_height(*(pVideoMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_height failed[%d].", val);
+
+ (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->height = intValue;
+ SysLog(NID_CNT, "META: height[%d]", intValue);
+
+ // Get from metadata extractor (framerate, audio bitrate, video bitrate)
+
+ // artist
+ val = video_meta_get_artist(*(pVideoMeta.get()), &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_artist failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pArtist
+ = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "META: artist[%ls]", (String(pStrValue.get())).GetPointer());
+ }
+
+ // genre
+ val = video_meta_get_genre(*(pVideoMeta.get()), &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_genre failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pGenre
+ = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "META: genre[%ls]", (String(pStrValue.get())).GetPointer());
+ }
+
+ // title
+ val = video_meta_get_title(*(pVideoMeta.get()), &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_title failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pTitle
+ = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "META: title[%ls]", (String(pStrValue.get())).GetPointer());
+ }
+
+ // albumName
+ val = video_meta_get_album(*(pVideoMeta.get()), &__pStrValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_album failed[%d].", val);
+
+ if (__pStrValue != null)
+ {
+ pStrValue.reset(__pStrValue);
+
+ (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->pAlbumName
+ = new (nothrow) String(pStrValue.get());
+
+ SysLog(NID_CNT, "META: albumName[%ls]", (String(pStrValue.get())).GetPointer());
+ }
+
+ // duration
+ val = video_meta_get_duration(*(pVideoMeta.get()), &intValue);
+ SysTryReturnResult(NID_CNT, val == MEDIA_CONTENT_ERROR_NONE, ConvertError(val),
+ "video_meta_get_duration failed[%d].", val);
+
+ (static_cast<VideoContentInfo::_VideoContentData*>(pMetadata))->duration = intValue;
+ SysLog(NID_CNT, "META: duration[%d]", intValue);
+ }
+ else if (systemType == SYSTEM_TYPE_OTHER)
+ {
+ pContentData->contentType = CONTENT_TYPE_OTHER;
+ SysLog(NID_CNT, "META: ContentType[%d]", pContentData->contentType);
+ }
+
+ 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
+{
+ if (!_AppInfo::IsOspCompat())
+ {
+ if (contentPath.StartsWith(OSP_HOME, 0) || contentPath.StartsWith(OSP_HOME_EXT, 0))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] /Home/ or /HomeExt/ is not supported from Tizen 2.0.");
+ return false;
+ }
+ if (!(contentPath.StartsWith(App::App::GetInstance()->GetAppRootPath(), 0) ||
+ contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] %ls is not supported.", contentPath.GetPointer());
+ return false;
+ }
+ }
+ else
+ {
+ SysTryReturn(NID_CNT, contentPath.StartsWith(OSP_HOME, 0) || contentPath.StartsWith(OSP_HOME_EXT, 0),
+ false, E_INVALID_ARG, "[E_INVALID_ARG] The path should start with /Home or /HomeExt.");
+ }
+
+ return true;
+}
+
+bool
+_ContentManagerImpl::VerifyMediaFilePathCompatibility(const String& contentPath, bool checkVersion) const
+{
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+
+ if (!_AppInfo::IsOspCompat())
+ {
+ if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0) || contentPath.StartsWith(OSP_MEDIA_MMC, 0))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] /Media or /Storagecard/Media is not supported.");
+ return false;
+ }
+ if (!(contentPath.StartsWith(Environment::GetMediaPath(), 0) ||
+ contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] %ls is not supported.", contentPath.GetPointer());
+ return false;
+ }
+ }
+ else
+ {
+ // prior to 2.0
+ if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
+ {
+ r = (const_cast<String*>(&contentPath))->Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
+ SysTryReturn(NID_CNT, !IsFailed(r), false, E_INVALID_ARG, "[E_INVALID_ARG] Replace failed.");
+ }
+ else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
+ {
+ r = (const_cast<String*>(&contentPath))->Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
+ SysTryReturn(NID_CNT, !IsFailed(r), false, E_INVALID_ARG, "[E_INVALID_ARG] Replace failed.");
+ }
+ else
+ {
+ // CreateContent(const ByteBuffer&, ...) and CreateContent (const Sring&, ...) can receive old path like /Media/.
+ // but CreateContent(const ContentInfo&) always receive new path like /opt/media/ because ContentInfo class convert the path from /Media/ to /opt/media.
+ if (!checkVersion)
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] The path should start with /Home, /Media, or /Storagecard/Media.");
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentManagerUtilImpl.cpp
+ * @brief This is the implementation file for the %_ContentManagerUtilImpl class.
+ *
+ * This file contains implementation of the %_ContentManagerUtilImpl class.
+ */
+
+#include <stdlib.h>
+#include <mime_type.h>
+#include <FBaseSysLog.h>
+#include <FIoDirectory.h>
+#include <FAppApp.h>
+#include <FSysEnvironment.h>
+#include <FMediaImage.h>
+#include <FMediaImageUtil.h>
+#include <FCntImageMetadata.h>
+#include <FCntAudioMetadata.h>
+#include <FCntVideoMetadata.h>
+#include <FCnt_ContentManagerUtilImpl.h>
+#include <FCnt_AudioMetadataImpl.h>
+#include <FCnt_VideoMetadataImpl.h>
+#include <FCnt_ImageMetadataImpl.h>
+#include <FBase_StringConverter.h>
+#include <FIo_FileImpl.h>
+#include <FGrp_BitmapImpl.h>
+#include <FMedia_ImageDecoder.h>
+#include <FMedia_ImageImpl.h>
+#include <FApp_AppInfo.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Media;
+using namespace Tizen::Graphics;
+using namespace Tizen::App;
+using namespace Tizen::System;
+using namespace std;
+
+namespace Tizen { namespace Content
+{
+// Types of content, format supported and default values
+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";
+
+//
+// E_SUCCESS
+// E_INVALID_ARG
+// E_OUT_OF_MEMORY
+//
+ImageMetadata*
+_ContentManagerUtilImpl::GetImageMetaN(const String& contentPath, bool internal)
+{
+ ClearLastResult();
+
+ if (!internal)
+ {
+ 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.(%ls)", contentPath.GetPointer());
+
+ // create object here as it needs to be passed to client in any case to make sure Get APIs do not crash
+ unique_ptr<ImageMetadata> 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;
+ Dimension dim(0,0);
+
+ result r = _ImageImpl::GetImageInfo(contentPath, imgType, dim);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_INVALID_ARG,
+ "[E_INVALID_ARG] GetImageInfo failed.");
+
+ pMetadata->width = dim.width;
+ pMetadata->height = dim.height;
+ pMetadata->contentPath = contentPath;
+
+ if (imgType == IMG_FORMAT_JPG)
+ {
+ unique_ptr<char[]> pFileName(_StringConverter::CopyToCharArrayN(contentPath));
+ SysTryReturn(NID_CNT, pFileName != null, pImageMetadata.release(), E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ unique_ptr<ExifData, ExifDataDeleter> pExifdata(exif_data_new_from_file(pFileName.get()));
+ 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<ImageOrientationType>(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();
+}
+
+void
+_ContentManagerUtilImpl::ParseBuffer(char* pBuffer, int& count)
+{
+ if ((*pBuffer != ',') && (*pBuffer != '\0')) // parse the buffer till ',' or '\0' and return the index
+ {
+ ParseBuffer(++pBuffer, ++count);
+ }
+}
+
+//
+// E_SUCCESS
+// E_INVALID_ARG
+// E_OUT_OF_MEMORY
+//
+AudioMetadata*
+_ContentManagerUtilImpl::GetAudioMetaN(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.");
+
+ // create here to make sure that get apis will not crash though the below API calls fails in case of invalid file.
+ unique_ptr<AudioMetadata> 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.");
+
+ pMetadata->contentPath = contentPath;
+
+ // Create the metadata extractor handle
+ unique_ptr<metadata_extractor_h, ExtractorDeleter> 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));
+
+ // Set file path of content to extract the metadata
+ unique_ptr<char[]> 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 audio metadata by passing relavent attirbutes
+ char* __pAudioMeta = null;
+ unique_ptr<char, CharDeleter> 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));
+ }
+
+ // description
+ retVal = metadata_extractor_get_metadata(*(pExtractor.get()), METADATA_DESCRIPTION, &__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(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<void, VoidDeleter> 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<VideoMetadata> 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<metadata_extractor_h, ExtractorDeleter> 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<char[]> 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<char, CharDeleter> 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));
+ }
+
+ // artwork
+ int size = 0;
+ void* __pArtwork = null;
+ unique_ptr<void, VoidDeleter> 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();
+}
+
+//
+// E_SUCCESS
+// E_INVALID_ARG
+// E_OUT_OF_MEMORY
+// E_FILE_NOT_FOUND
+// E_UNSUPPORTED_FORMAT
+//
+ContentType
+_ContentManagerUtilImpl::CheckContentType(const String& contentPath, bool internal)
+{
+ ClearLastResult();
+
+ ContentType contentType = CONTENT_TYPE_UNKNOWN;
+
+ if (!internal)
+ {
+ SysTryReturn(NID_CNT, VerifyFilePathCompatibility(contentPath), contentType, E_INVALID_ARG,
+ "[E_INVALID_ARG] %ls is not compatible.", contentPath.GetPointer());
+ }
+ SysTryReturn(NID_CNT, contentPath.GetLength() != 0, contentType, E_INVALID_ARG,
+ "[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;
+
+ 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;
+ }
+
+ String subStr;
+ int length = fileExt.GetLength();
+
+ r = String(CONTENT_FORMAT).SubString(index+length, 1, subStr);
+ SysTryReturn(NID_CNT, !(IsFailed(r)), contentType, E_INVALID_ARG, "[E_INVALID_ARG] SubString failed.");
+
+ SysLog(NID_CNT, "index = %d, length = %d, subStr = %ls", index, length, subStr.GetPointer());
+
+ 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");
+
+ if (subStr.CompareTo(image) == 0)
+ {
+ return CONTENT_TYPE_IMAGE;
+ }
+ else if (subStr.CompareTo(audio) == 0)
+ {
+ return CONTENT_TYPE_AUDIO;
+ }
+ else if (subStr.CompareTo(video) == 0)
+ {
+ return CONTENT_TYPE_VIDEO;
+ }
+ else if (subStr.CompareTo(other) == 0)
+ {
+ return CONTENT_TYPE_OTHER;
+ }
+ else if (subStr.CompareTo(audioOrVideo) == 0)
+ {
+ //Create metadata extractor handle
+ unique_ptr<metadata_extractor_h, ExtractorDeleter> 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));
+
+ //Set file path of content to extract metadata.
+ unique_ptr<char[]> pContentPath(_StringConverter::CopyToCharArrayN(contentPath));
+ SysTryReturn(NID_CNT, pContentPath != null, contentType, E_INVALID_ARG,
+ "[E_INVALID_ARG] The memory is insufficient.");
+
+ 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));
+
+ //Get the metadata info, to check whether audio or video present in the file
+ char* __pAudio = null;
+ unique_ptr<char> pAudio(null);
+
+ char* __pVideo = null;
+ unique_ptr<char> pVideo(null);
+
+ 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));
+ }
+
+ 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 (*(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.");
+ }
+ }
+ 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());
+ }
+
+ return contentType;
+}
+
+ContentType
+_ContentManagerUtilImpl::GetDrmFileType(const String& fileExt)
+{
+ ClearLastResult();
+
+ unique_ptr<char[]> 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<char, CharDeleter> pMimeType;
+ pMimeType.reset(__pMimeType);
+
+ SysLog(NID_CNT, "The MIME type for %ls is %s", fileExt.GetPointer(), __pMimeType);
+
+ String mimeType(pMimeType.get());
+
+ if (mimeType == L"audio/mp4")
+ {
+ return CONTENT_TYPE_AUDIO;
+ }
+ else if (mimeType == L"video/mp4")
+ {
+ return CONTENT_TYPE_VIDEO;
+ }
+ else if (mimeType == L"application/octet-stream")
+ {
+ return CONTENT_TYPE_OTHER;
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_UNSUPPORTED_FORMAT, "The MIME type is invalid.");
+ }
+
+ return CONTENT_TYPE_UNKNOWN;
+}
+
+bool
+_ContentManagerUtilImpl::VerifyFilePathCompatibility(const String& contentPath)
+{
+ if (!_AppInfo::IsOspCompat())
+ {
+ if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0) || contentPath.StartsWith(OSP_MEDIA_MMC, 0)
+ || contentPath.StartsWith(OSP_HOME, 0))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "/Home, /Media/, or /Storagecard/Media/ is not supported from Tizen 2.0.");
+ return false;
+ }
+ }
+ else
+ {
+ // prior to 2.0
+ if (!(contentPath.StartsWith(OSP_MEDIA_PHONE, 0) || contentPath.StartsWith(OSP_MEDIA_MMC, 0)
+ || contentPath.StartsWith(OSP_HOME, 0)))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "The contentPath should start with /Home, /Media, or /Storagecard/Media.");
+ return false;
+ }
+ }
+
+ return true;
+}
+
+result
+_ContentManagerUtilImpl::ErrorMapToRetVal(int retVal)
+{
+ result r = E_SUCCESS;
+
+ switch (retVal)
+ {
+ case METADATA_EXTRACTOR_ERROR_NONE:
+ r = E_SUCCESS;
+ break;
+ case METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER:
+ r = E_INVALID_ARG;
+ break;
+ case METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY:
+ r = E_OUT_OF_MEMORY;
+ break;
+ case METADATA_EXTRACTOR_ERROR_FILE_EXISTS:
+ r = E_INVALID_ARG;
+ break;
+ case METADATA_EXTRACTOR_ERROR_OPERATION_FAILED:
+ r = E_INVALID_ARG;
+ break;
+ }
+
+ return r;
+}
+
+/**
+ * deprecation
+ */
+result
+_ContentManagerUtilImpl::CopyToMediaDirectory(const String& srcContentPath, const String& destContentPath)
+{
+ ClearLastResult();
+
+ // For srcContentPath
+ SysTryReturn(NID_CNT, !_FileImpl::IsSystemPath(srcContentPath), E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Can not copy the file in the system region.");
+ SysTryReturn(NID_CNT, _FileImpl::IsFileExist(srcContentPath), E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Can not find the file.");
+
+ // For destContentPath
+ SysTryReturn(NID_CNT, _FileImpl::IsMediaPath(destContentPath), E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The destination path should start with /Media or /Storagecard/Media.");
+
+ // E_SUCCESS, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_FILE_NOT_FOUND, E_FILE_ALREADY_EXIST, E_MAX_EXCEEDED, E_STORAGE_FULL, E_IO
+ result r = E_SUCCESS;
+ r = _FileImpl::Copy(srcContentPath, destContentPath, true);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] CopyToMediaDirectory failed.", GetErrorMessage(r));
+
+ return r;
+}
+
+/**
+ * deprecation
+ */
+result
+_ContentManagerUtilImpl::MoveToMediaDirectory(const String& srcContentPath, const String& destContentPath)
+{
+ ClearLastResult();
+
+ // For srcContentPath
+ SysTryReturn(NID_CNT, !_FileImpl::IsSystemPath(srcContentPath), E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Can not copy the file in the system region.");
+ SysTryReturn(NID_CNT, _FileImpl::IsFileExist(srcContentPath), E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Can not find the file.");
+
+ // For destContentPath
+ SysTryReturn(NID_CNT, _FileImpl::IsMediaPath(destContentPath), E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The destination path should start with /Media or /Storagecard/Media.");
+
+ // E_SUCCESS, E_INVALID_ARG, E_ILLEGAL_ACCESS, E_FILE_NOT_FOUND, E_FILE_ALREADY_EXIST, E_MAX_EXCEEDED, E_STORAGE_FULL, E_IO
+ result r = E_SUCCESS;
+ r = _FileImpl::Move(srcContentPath, destContentPath);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] MoveToMediaDirectory failed.", GetErrorMessage(r));
+
+ return r;
+}
+}}
--- /dev/null
+//\r
+// Open Service Platform\r
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
+//\r
+// Licensed under the Apache License, Version 2.0 (the License);\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+//\r
+/**\r
+ * @file FCnt_ContentSearchImpl.cpp\r
+ * @brief This is the implementation file for the %_ContentSearchImpl class.\r
+ *\r
+ * This file contains implementation of the %_ContentSearchImpl class.\r
+ */\r
+\r
+// includes\r
+\r
+#include <time.h>\r
+#include <FBaseSysLog.h>\r
+#include <FBaseInteger.h>\r
+#include <FBaseLongLong.h>\r
+#include <FBaseFloat.h>\r
+#include <FBaseColIList.h>\r
+#include <FBaseUtilStringTokenizer.h>\r
+#include <FCntContentSearch.h>\r
+#include <FCntContentSearchResult.h>\r
+#include <FBase_StringConverter.h>\r
+#include <FCnt_ContentUtility.h>\r
+#include <FCnt_ContentSearchImpl.h>\r
+\r
+// using namespace\r
+using namespace Tizen::Base;\r
+using namespace Tizen::Base::Collection;\r
+using namespace Tizen::Base::Utility;\r
+using namespace Tizen::Io;\r
+\r
+namespace Tizen { namespace Content\r
+{\r
+\r
+static const int QUERY_LENGTH = 4096;\r
+\r
+// Declaration for Callback function registered to each media info details\r
+bool MediaItemCb(media_info_h media, void* pUserdata);\r
+// Declaration for Callback function registered to each column details\r
+bool GroupItemCb(const char* pGroupName, void* pUserdata);\r
+// Declaration for Callback function registered to each album details\r
+bool AlbumItemCb(media_album_h album, void* pUserdata);\r
+\r
+// Default constructor\r
+_ContentSearchImpl::_ContentSearchImpl(void)\r
+ : Object()\r
+ , __contentType(CONTENT_TYPE_UNKNOWN)\r
+ , __pFinalOutList(NULL)\r
+ , __inputExpr(L"")\r
+ , __inputColumnName(L"")\r
+ , __inputSortOrder(SORT_ORDER_NONE)\r
+ , __pFilterHandle(0)\r
+{\r
+ SysLog(NID_CNT, "Enter\n");\r
+}\r
+\r
+\r
+// Default destructor (disconnects the DB connection)\r
+_ContentSearchImpl::~_ContentSearchImpl(void)\r
+{\r
+ SysLog(NID_CNT, "Enter\n");\r
+\r
+ int ret = MEDIA_CONTENT_ERROR_NONE;\r
+ result r = E_SUCCESS;\r
+\r
+ ret = media_content_disconnect();\r
+ r = MapCoreErrorToNativeResult(ret);\r
+ SysTryLog(NID_CNT, r == E_SUCCESS, "[%s] Propagated in ~_ContentSearchImpl", GetErrorMessage(r));\r
+}\r
+\r
+ _ContentSearchImpl*\r
+ _ContentSearchImpl::GetInstance(ContentSearch& contentSearch)\r
+{\r
+ return contentSearch.__pImpl;\r
+}\r
+\r
+const _ContentSearchImpl*\r
+_ContentSearchImpl::GetInstance(const ContentSearch& contentSearch)\r
+{\r
+ return contentSearch.__pImpl;\r
+}\r
+\r
+//make a connection to DB\r
+result\r
+_ContentSearchImpl::Construct(ContentType type)\r
+{\r
+ SysLog(NID_CNT, "Enter\n");\r
+\r
+ result r = E_SUCCESS;\r
+ int ret = MEDIA_CONTENT_ERROR_NONE;\r
+\r
+ ret = media_content_connect();\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS , E_SYSTEM, "Failed to perform media_content_connect operation.");\r
+\r
+ __contentType = type;\r
+\r
+ return r;\r
+}\r
+\r
+// Creates a filter for the input query string along with content type\r
+// Initializes filter handle\r
+// Image - MEDIA_TYPE=0\r
+// Vide0 - MEDIA_TYPE=1\r
+// Audio - MEDIA_TYPE=2 or MEDIA_TYPE=3\r
+// Others - MEDIA_TYPE=4\r
+// All - none\r
+// Appends MEDIA_TYPE with "AND" (if the input expression is not empty and content type is not ALL) and input expression\r
+// Sets the condition and order.\r
+// If any argument is not proper E_INVALID_ARG is returned\r
+result\r
+_ContentSearchImpl::CreateQueryFilter(bool isAndAppendReq) const\r
+{\r
+ int ret = MEDIA_CONTENT_ERROR_NONE;\r
+ result r = E_SUCCESS;\r
+\r
+ std::unique_ptr<char[]> pInputCond;\r
+ std::unique_ptr<char[]> pSortCol;\r
+\r
+ String inputCondition;\r
+ String slpColumn;\r
+\r
+ std::unique_ptr<filter_h, SearchFilterHandleDeleter> pFilterHandle(new (std::nothrow) filter_h);\r
+\r
+ ret = media_filter_create(pFilterHandle.get());\r
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "Failed to perform media_filter_create operation.");\r
+\r
+ switch (__contentType)\r
+ {\r
+ // Image-0,video-1,sound-2,music-3,other-4\r
+ case CONTENT_TYPE_OTHER:\r
+ inputCondition = "MEDIA_TYPE=4 ";\r
+ break;\r
+ case CONTENT_TYPE_IMAGE:\r
+ inputCondition = "MEDIA_TYPE=0 ";\r
+ break;\r
+ case CONTENT_TYPE_AUDIO:\r
+ inputCondition = "(MEDIA_TYPE=2 or MEDIA_TYPE=3) ";\r
+ break;\r
+ case CONTENT_TYPE_VIDEO:\r
+ inputCondition = "MEDIA_TYPE=1 ";\r
+ break;\r
+ case CONTENT_TYPE_ALL:\r
+ //If content type is CONTENT_TYPE_ALL, then MEDIA_TYPE is empty\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+\r
+ if (!__inputExpr.IsEmpty())\r
+ {\r
+ if (isAndAppendReq && (!inputCondition.IsEmpty())) //For CONTENT_TYPE_ALL inputCondition is empty\r
+ {\r
+ r = inputCondition.Append("AND ");\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform append operation.");\r
+ }\r
+\r
+ r = inputCondition.Append(__inputExpr);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform append operation.");\r
+ }\r
+\r
+ if (!inputCondition.IsEmpty())\r
+ {\r
+ //CopyToCharArrayN: utility function, converts a osp string to char*\r
+ pInputCond = std::unique_ptr<char[]>(_StringConverter::CopyToCharArrayN(inputCondition));\r
+ SysTryReturnResult(NID_CNT, (pInputCond.get())[0], E_OUT_OF_MEMORY, "pInputCond is NULL.");\r
+\r
+ SysLog(NID_CNT, "pInputCond = %s", pInputCond.get());\r
+\r
+ if ((pInputCond.get())[0])\r
+ {\r
+ ret = media_filter_set_condition(*(pFilterHandle.get()), pInputCond.get(), MEDIA_CONTENT_COLLATE_DEFAULT);\r
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "Failed to perform media_filter_set_condition operation.");\r
+ }\r
+ }\r
+\r
+ if (!__inputColumnName.IsEmpty()) // SortColumn is optional in case of SearchN\r
+ {\r
+ //__inputColumnName (osp column name) is replaced with slpColumn (slp column name).\r
+ r = GetSlpColumnName(slpColumn);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform GetSlpColumnName operation.");\r
+\r
+ //CopyToCharArrayN: utility function, converts a osp string to char*\r
+\r
+ pSortCol = std::unique_ptr<char[]>(_StringConverter::CopyToCharArrayN(slpColumn));\r
+ SysTryReturnResult(NID_CNT, (pSortCol.get())[0], E_OUT_OF_MEMORY, "pSortCol is NULL.");\r
+\r
+ if (__inputSortOrder == SORT_ORDER_ASCENDING)\r
+ {\r
+ ret = media_filter_set_order(*(pFilterHandle.get()), MEDIA_CONTENT_ORDER_ASC, pSortCol.get(), MEDIA_CONTENT_COLLATE_DEFAULT);\r
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "Failed to perform media_filter_set_order operation.");\r
+ }\r
+ else if (__inputSortOrder == SORT_ORDER_DESCENDING)\r
+ {\r
+ ret = media_filter_set_order(*(pFilterHandle.get()), MEDIA_CONTENT_ORDER_DESC, pSortCol.get(), MEDIA_CONTENT_COLLATE_DEFAULT);\r
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, E_SYSTEM, "Failed to perform media_filter_set_order operation.");\r
+ }\r
+ }\r
+\r
+ __pFilterHandle.reset(pFilterHandle.release());\r
+\r
+ return r;\r
+}\r
+\r
+// Osp column names are mapped with slp column names\r
+// CONTENT_TYPE_OTHER and CONTENT_TYPE_IMAGE (0 - 13 ) are valid columns\r
+// CONTENT_TYPE_VIDEO (0 - 16 ) are valid columns\r
+// CONTENT_TYPE_ALL and CONTENT_TYPE_VIDEO (0 - 18 ) are valid columns\r
+// if the given osp column is out of the specified range of the type, E_INVALID_ARG is retuned.\r
+result\r
+_ContentSearchImpl::GetSlpColumnName(String& inputCol) const\r
+{\r
+ String ospColumnName(L"");\r
+ String slpColumnName(L"");\r
+ String columnName(__inputColumnName);\r
+ result r = E_SUCCESS;\r
+ int maxCols = 0;\r
+ switch (__contentType)\r
+ {\r
+ case CONTENT_TYPE_OTHER:\r
+ //fall through\r
+ case CONTENT_TYPE_IMAGE:\r
+ maxCols = MAX_QUERY_COLUMNS_FOR_IMAGE_OTHERS;\r
+ break;\r
+ case CONTENT_TYPE_VIDEO:\r
+ maxCols = MAX_QUERY_COLUMNS_FOR_VIDEO;\r
+ break;\r
+ case CONTENT_TYPE_AUDIO:\r
+ //fall through\r
+ case CONTENT_TYPE_ALL:\r
+ maxCols = MAX_QUERY_COLUMNS;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ for (int colIndex = 0; colIndex < maxCols; colIndex++)\r
+ {\r
+ ospColumnName.Clear();\r
+ slpColumnName.Clear();\r
+\r
+ ospColumnName = dbfieldinfo[colIndex].dbFieldOspName ;\r
+ slpColumnName = dbfieldinfo[colIndex].dbFieldSlpName ;\r
+\r
+ ospColumnName.ToUpper();\r
+ columnName.ToUpper();\r
+ if (columnName == ospColumnName)\r
+ {\r
+ inputCol = slpColumnName;\r
+ return r;\r
+ }\r
+ }\r
+ return E_INVALID_ARG;\r
+}\r
+\r
+//If the input expression contains any osp column name, it will be replaced with slp column name.\r
+// only CONTENT_TYPE_AUDIO and CONTENT_TYPE_ALL allowed to use all given columns\r
+// so, check for invalid column for CONTENT_TYPE_OTHER,CONTENT_TYPE_IMAGE and CONTENT_TYPE_VIDEO.\r
+// all the osp columns in the expression should be replaced with slp column names.\r
+// ' is used as a delimeter in parsing user query. so, \\' is saved as a special@apostrophe string.\r
+// \\' is replaced with '', which considers ' as normal character.\r
+\r
+result\r
+_ContentSearchImpl::ReplaceOspColumnNameWithSlp(void) const\r
+{\r
+ String ospColumnName(L"");\r
+ String slpColumnName(L"");\r
+ String splApostrophe(L"special@apostrophe");\r
+ result r = E_SUCCESS;\r
+ int maxCols = 0;\r
+\r
+ int indexOf = 0;\r
+ \r
+ String strToBeReplaced(L"\\'");\r
+ int strLen = strToBeReplaced.GetLength();\r
+ int startIndex = 0;\r
+\r
+ while(E_SUCCESS == __inputExpr.IndexOf(strToBeReplaced,startIndex,indexOf))\r
+ {\r
+ int lenAfterSubStr = indexOf + strLen;\r
+ while ((lenAfterSubStr < __inputExpr.GetLength()) && (__inputExpr[lenAfterSubStr] == ' '))\r
+ {\r
+ lenAfterSubStr++;\r
+ }\r
+ if ((lenAfterSubStr < __inputExpr.GetLength()) && ((__inputExpr[lenAfterSubStr] == '\'') ||\r
+ ((!__inputExpr.StartsWith(L"AND ", lenAfterSubStr)) && (!__inputExpr.StartsWith(L"OR ", lenAfterSubStr)))))\r
+ {\r
+ r = __inputExpr.Remove(indexOf,strLen);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "Failed to perform Remove operation.");\r
+ r = __inputExpr.Insert(splApostrophe,indexOf);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "Failed to perform Insert operation.");\r
+ startIndex = indexOf + splApostrophe.GetLength();\r
+ }\r
+ else\r
+ {\r
+ startIndex = lenAfterSubStr;\r
+ }\r
+ }\r
+\r
+ SysLog(NID_CNT, "__inputExpr after splApostrophe append = %ls", __inputExpr.GetPointer());\r
+\r
+ switch (__contentType)\r
+ {\r
+ case CONTENT_TYPE_OTHER:\r
+ //fall through\r
+ case CONTENT_TYPE_IMAGE:\r
+ r = CheckInvalidColumnInQuery();\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_INVALID_ARG, "Invalid Column In QueryString.");\r
+ maxCols = MAX_QUERY_COLUMNS_FOR_IMAGE_OTHERS;\r
+ break;\r
+ case CONTENT_TYPE_VIDEO:\r
+ r = CheckInvalidColumnInQuery();\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_INVALID_ARG, "Invalid Column In QueryString.");\r
+ maxCols = MAX_QUERY_COLUMNS_FOR_VIDEO;\r
+ break;\r
+ case CONTENT_TYPE_AUDIO:\r
+ //fall through\r
+ case CONTENT_TYPE_ALL:\r
+ maxCols = MAX_QUERY_COLUMNS;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ for (int colIndex = 0; colIndex < maxCols; colIndex++)\r
+ {\r
+ ospColumnName.Clear();\r
+ slpColumnName.Clear();\r
+\r
+ ospColumnName = dbfieldinfo[colIndex].dbFieldOspName ;\r
+ slpColumnName = dbfieldinfo[colIndex].dbFieldSlpName ;\r
+\r
+ ReplaceString(ospColumnName,slpColumnName);\r
+ }\r
+\r
+ // Append ESCAPE '\' for LIKE query\r
+ r = AppendEscapeKeywordForLikeQuery();\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "AppendEscapeKeywordForLikeQuery failed.");\r
+\r
+ r = ReplaceDateTimeStringWithInt();\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "ReplaceDateTimeStringWithInt failed.");\r
+\r
+ // replace splApostrophe string with actual\r
+ r = __inputExpr.Replace(splApostrophe, "''");\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string Replace failed.");\r
+\r
+ return r;\r
+}\r
+\r
+//This function is to appened ESCAPE keyword for _ and % special characters in LIKE query.\r
+\r
+result\r
+_ContentSearchImpl::AppendEscapeKeywordForLikeQuery(void) const\r
+{\r
+ String delim = L"'"; //Delimeters is ' .\r
+ result r = E_SUCCESS;\r
+ bool isCol = true;\r
+ bool isAppendEscape = false;\r
+ String token;\r
+ String tokenUpper;\r
+ String inputExpr = __inputExpr;\r
+\r
+ // Create a StringTokenizer instance\r
+ StringTokenizer strTok(inputExpr, delim);\r
+\r
+ inputExpr.Clear();\r
+\r
+ while (strTok.HasMoreTokens())\r
+ {\r
+ r = strTok.GetNextToken(token);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "GetNextToken failed.");\r
+ if (isCol) //column name\r
+ {\r
+ isCol = false;\r
+ tokenUpper = token;\r
+ tokenUpper.ToUpper();\r
+ if (tokenUpper.Contains(" LIKE"))\r
+ {\r
+ isAppendEscape = true;\r
+ }\r
+ else\r
+ {\r
+ isAppendEscape = false;\r
+ }\r
+ r = inputExpr.Append(token);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ }\r
+ else // value of the column\r
+ {\r
+ isCol = true;\r
+ r = inputExpr.Append("'");\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ r = inputExpr.Append(token);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ r = inputExpr.Append("'");\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+\r
+ if (isAppendEscape)\r
+ {\r
+ if (token.Contains("\\_") || token.Contains("\\%"))\r
+ {\r
+ r = inputExpr.Append("ESCAPE'\\' ");\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ __inputExpr.Clear();\r
+ r = __inputExpr.Insert(inputExpr, 0);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string insert failed.");\r
+\r
+ return r;\r
+}\r
+\r
+//This function is to replace DateTime value(osp datetime type is string) which is string with int.(SLP dateTime column type is int)\r
+\r
+result\r
+_ContentSearchImpl::ReplaceDateTimeStringWithInt(void) const\r
+{\r
+ String delim = L"'"; //Delimeters is ' .\r
+ result r = E_SUCCESS;\r
+ bool isCol = true;\r
+ bool isConvertReq = false;\r
+ bool isBetweenExistsInDateTimeQuery = false;\r
+ String token;\r
+ String tokenUpper;\r
+ String inputExpr = __inputExpr;\r
+\r
+ if(!inputExpr.Contains("MEDIA_ADDED_TIME"))\r
+ {\r
+ return r;\r
+ }\r
+\r
+ // Create a StringTokenizer instance\r
+ StringTokenizer strTok(inputExpr, delim);\r
+\r
+ inputExpr.Clear();\r
+\r
+ while (strTok.HasMoreTokens())\r
+ {\r
+ r = strTok.GetNextToken(token);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "GetNextToken failed.");\r
+ if (isCol) //column name\r
+ {\r
+ isCol = false;\r
+ tokenUpper = token;\r
+ tokenUpper.ToUpper();\r
+ if(isBetweenExistsInDateTimeQuery)\r
+ {\r
+ isBetweenExistsInDateTimeQuery = false;\r
+ isConvertReq = true;\r
+ }\r
+ else\r
+ {\r
+ if (tokenUpper.Contains("MEDIA_ADDED_TIME"))\r
+ {\r
+ if (tokenUpper.Contains("BETWEEN"))\r
+ {\r
+ isBetweenExistsInDateTimeQuery = true;\r
+ }\r
+ isConvertReq = true;\r
+ }\r
+ else\r
+ {\r
+ isConvertReq = false;\r
+ }\r
+ }\r
+ r = inputExpr.Append(token);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ }\r
+ else // value of the column\r
+ {\r
+ isCol = true;\r
+ r = inputExpr.Append("'");\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+\r
+ if (isConvertReq)\r
+ {\r
+ Tizen::Base::DateTime dt;\r
+ Tizen::Base::DateTime::Parse(token, dt);\r
+\r
+ int year = dt.GetYear();\r
+ int month = dt.GetMonth(); \r
+ int day = dt.GetDay();\r
+ int hour = dt.GetHour();\r
+ int minute = dt.GetMinute(); \r
+ int second = dt.GetSecond();\r
+ \r
+ time_t rawTime;\r
+ struct tm* timeInfo;\r
+\r
+ time(&rawTime);\r
+ timeInfo = localtime(&rawTime);\r
+ timeInfo->tm_year = year - 1900;\r
+ timeInfo->tm_mon = month - 1;\r
+ timeInfo->tm_mday = day;\r
+ timeInfo->tm_hour = hour;\r
+ timeInfo->tm_min = minute;\r
+ timeInfo->tm_sec = second;\r
+\r
+ time_t seconds = mktime(timeInfo);\r
+ long long ticksInSeconds = (long long)seconds;\r
+\r
+ r = inputExpr.Append(ticksInSeconds);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ }\r
+ else\r
+ {\r
+ r = inputExpr.Append(token);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ }\r
+ r = inputExpr.Append("'");\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ }\r
+ }\r
+\r
+ __inputExpr.Clear();\r
+ r = __inputExpr.Insert(inputExpr, 0);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string insert failed.");\r
+\r
+ return r;\r
+}\r
+\r
+// CONTENT_TYPE_OTHER and CONTENT_TYPE_IMAGE (0 - 13 ) are valid columns\r
+// CONTENT_TYPE_VIDEO (0 - 16 ) are valid columns\r
+// CONTENT_TYPE_ALL and CONTENT_TYPE_VIDEO (0 - 18 ) are valid columns\r
+// This functions checks for invalid column in the given input string (only allowed columns should be used by content type other wise\r
+// E_INVALID_ARG is returned)\r
+// StringTokenizer is used to parse input expression, by using delimater "'", to differentiate column and value.\r
+// As values may also contain column names\r
+// Ex: 1. where author = syam_author_01 2. where album = jalsa_album_name_01.\r
+\r
+result\r
+_ContentSearchImpl::CheckInvalidColumnInQuery(void) const\r
+{\r
+ result r = E_SUCCESS;\r
+ int tokenNo = 0;\r
+ String delim = L"'"; //Delimeters is ' .\r
+ bool isColReplaceReq = true;\r
+ String token;\r
+ String inputExpr = __inputExpr;\r
+\r
+ // Create a StringTokenizer instance\r
+ StringTokenizer strTok(inputExpr, delim);\r
+\r
+ inputExpr.Clear();\r
+\r
+ while (strTok.HasMoreTokens())\r
+ {\r
+ r = strTok.GetNextToken(token);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "strTok GetNextToken failed.");\r
+\r
+ SysLog(NID_CNT, "In CheckInvalidColumnInQuery token[%d] = %ls", ++tokenNo, token.GetPointer());\r
+\r
+ if (isColReplaceReq)\r
+ {\r
+ isColReplaceReq = false;\r
+ r = inputExpr.Append(token);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ token.ToUpper();\r
+ switch (__contentType)\r
+ {\r
+ case CONTENT_TYPE_OTHER:\r
+ //fall through\r
+ case CONTENT_TYPE_IMAGE:\r
+ if ((token.Contains("TITLE")) || (token.Contains("ARTIST")) || (token.Contains("GENRE")))\r
+ {\r
+ SysLog(NID_CNT, "Title or Artist or Genre are not valid cloumns for this content type");\r
+ return E_INVALID_ARG;\r
+ }\r
+ //fall through\r
+ case CONTENT_TYPE_VIDEO:\r
+ if ((token.Contains("COMPOSER")) || (token.Contains("ALBUM")))\r
+ {\r
+ SysLog(NID_CNT, "Composer or Album are not valid cloumns for this content type");\r
+ return E_INVALID_ARG;\r
+ }\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ isColReplaceReq = true;\r
+ r = inputExpr.Append("'");\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ r = inputExpr.Append(token);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ r = inputExpr.Append("'");\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ }\r
+ }\r
+ return r;\r
+}\r
+\r
+// It replaces osp column name with slp column name.\r
+// StringTokenizer is used to parse input expression, by using delimater "'", to differentiate column and value.\r
+// As values may also contain column names\r
+// Only column names are replaced but not values(values may contain column names)\r
+// Ex: 1. where author = syam_author_01 2. where album = jalsa_album_name_01.\r
+\r
+result\r
+_ContentSearchImpl::ReplaceString(String ospColumnName, String slpColumnName) const\r
+{\r
+ String delim = L"'"; //Delimeters is ' .\r
+ result r = E_SUCCESS;\r
+ bool isColReplaceReq = true;\r
+ String token;\r
+ String inputExpr = __inputExpr;\r
+\r
+ // Create a StringTokenizer instance\r
+ StringTokenizer strTok(inputExpr, delim);\r
+\r
+ inputExpr.Clear();\r
+\r
+ while (strTok.HasMoreTokens())\r
+ {\r
+ r = strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string GetNextToken() failed.");\r
+ if (isColReplaceReq) //column name\r
+ {\r
+ isColReplaceReq = false;\r
+ r = token.Replace(ospColumnName, slpColumnName);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string replace() failed.");\r
+ r = inputExpr.Append(token);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ }\r
+ else // value of the column\r
+ {\r
+ isColReplaceReq = true;\r
+ r = inputExpr.Append("'");\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ r = inputExpr.Append(token);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ r = inputExpr.Append("'");\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string append failed.");\r
+ }\r
+ }\r
+ __inputExpr.Clear();\r
+ r = __inputExpr.Insert(inputExpr, 0);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "string insert() failed.");\r
+\r
+ return r;\r
+}\r
+\r
+//Retuns list of search result for the given expression and content type.\r
+Collection::IList*\r
+_ContentSearchImpl::SearchN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount, const String& whereExpr, const String& sortColumn, SortOrder sortOrder) const\r
+{\r
+ SysLog(NID_CNT, "pageNo = %d, countPerPage = %d, whereExpr = %ls", pageNo, countPerPage, whereExpr.GetPointer());\r
+\r
+ ClearLastResult();\r
+\r
+ result r = E_SUCCESS;\r
+ int ret = MEDIA_CONTENT_ERROR_NONE;\r
+ int offset = 0;\r
+\r
+ __inputColumnName.Clear();\r
+ __inputExpr.Clear();\r
+ __inputColumnName = sortColumn;\r
+ __inputSortOrder = sortOrder;\r
+ totalPageCount = 0;\r
+ totalCount = 0;\r
+\r
+ if (!whereExpr.IsEmpty()) // copy whereExpr if not empty to class variable __inputExpr\r
+ {\r
+ //r = __inputExpr.Format(QUERY_LENGTH, L"%ls", whereExpr.GetPointer());\r
+ r = __inputExpr.Append(whereExpr);\r
+ SysTryReturn(NID_CNT, r == E_SUCCESS, NULL, r, "[%s] __inputExpr.Append Failed as whereExpr is not empty.", GetErrorMessage(r));\r
+\r
+ r = ReplaceOspColumnNameWithSlp();\r
+ SysTryReturn(NID_CNT, r == E_SUCCESS, NULL, r, "[%s] ReplaceOspColumnNameWithSlp for InputExpr Failed.", GetErrorMessage(r));\r
+\r
+ SysLog(NID_CNT, "After replace __inputExpr = %ls", __inputExpr.GetPointer());\r
+ }\r
+ if ((__inputColumnName.IsEmpty()) && ((__inputSortOrder == SORT_ORDER_ASCENDING) || (__inputSortOrder == SORT_ORDER_DESCENDING)))\r
+ {\r
+ SysLog(NID_CNT, "sort column name is empty and sort oder is not none. so,E_INVALID_ARG occured.");\r
+ SetLastResult(E_INVALID_ARG);\r
+ return null;\r
+ }\r
+ else\r
+ {\r
+ std::unique_ptr<ArrayList, AllElementsDeleter> pFinalOutList(new (std::nothrow) ArrayList());\r
+ SysTryReturn(NID_CNT, pFinalOutList.get() != null, NULL, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to construct ArrayList.");\r
+\r
+ r = pFinalOutList->Construct();\r
+ SysTryReturn(NID_CNT, !IsFailed(r), NULL, r, "[%s] Failed to construct ArrayList.", GetErrorMessage(r));\r
+\r
+ __pFinalOutList = std::move(pFinalOutList);\r
+\r
+ r = CreateQueryFilter(true);\r
+ SysTryReturn(NID_CNT, !IsFailed(r), NULL, r, "[%s] Failed to perform CreateQueryFilter operation.", GetErrorMessage(r));\r
+\r
+ ret = media_info_get_media_count_from_db(*(__pFilterHandle.get()), &totalCount);\r
+ r = MapCoreErrorToNativeResult(ret);\r
+ SysTryReturn(NID_CNT, r == E_SUCCESS , NULL, r, "[%s] Failed to perform media_info_get_media_count_from_db operation.", GetErrorMessage(r));\r
+\r
+ SysLog(NID_CNT, "totalCount is [%d] for media_info_get_media_count_from_db", totalCount);\r
+\r
+ if (totalCount > 0)\r
+ {\r
+ if ((totalCount % countPerPage) == 0)\r
+ {\r
+ totalPageCount = totalCount / countPerPage;\r
+ }\r
+ else\r
+ {\r
+ totalPageCount = (totalCount / countPerPage) + 1;\r
+ }\r
+\r
+ SysTryReturn(NID_CNT, ((pageNo >= 1) && (pageNo <= totalPageCount)) , NULL, E_INVALID_ARG, "[E_INVALID_ARG] (pageNo < 1) || (pageNo > totalPageCount).");\r
+\r
+ offset = (pageNo * countPerPage) - countPerPage;\r
+\r
+ SysLog(NID_CNT, " SearchN totalCount [%d] totalPageCount[%d] __countPerPage[%d] __pageNo[%d] offset[%d]",\r
+ totalCount, totalPageCount, countPerPage, pageNo, offset);\r
+\r
+ ret = media_filter_set_offset(*(__pFilterHandle.get()), offset, countPerPage);\r
+ r = MapCoreErrorToNativeResult(ret);\r
+ SysTryReturn(NID_CNT, r == E_SUCCESS, NULL, r,\r
+ "[%s] Failed to perform media_filter_set_offset operation.", GetErrorMessage(r));\r
+\r
+ r = ExecuteAndFillFinalOutList();\r
+ SysTryReturn(NID_CNT, r == E_SUCCESS, NULL, E_SYSTEM, "[E_SYSTEM] ExecuteAndFillFinalOutList Failed.");\r
+ }\r
+ else if (pageNo > 1)\r
+ {\r
+ r = E_INVALID_ARG;\r
+ SysTryReturn(NID_CNT, r == E_SUCCESS, NULL, r, "[E_INVALID_ARG] (pageNo > 1) and (totalcount = 0).");\r
+ }\r
+ }\r
+ SetLastResult(r);\r
+ return __pFinalOutList.release();\r
+}\r
+\r
+// Fills final result list\r
+result\r
+_ContentSearchImpl::ExecuteAndFillFinalOutList(void) const\r
+{\r
+ SysLog(NID_CNT, "Enter\n");\r
+\r
+ int ret = MEDIA_CONTENT_ERROR_NONE;\r
+ result r = E_SUCCESS;\r
+\r
+ std::unique_ptr<GList, SearchGListDeleter> pItemList;\r
+ GList* pTemp = NULL;\r
+ std::unique_ptr<media_info_s, SearchMediaHandleDeleter> pMediaHandle;\r
+\r
+ ContentInfo::_ContentData* pContentData = null;\r
+ ImageContentInfo::_ImageContentData* pImageContentData = null;\r
+ AudioContentInfo::_AudioContentData* pAudioContentData = null;\r
+ VideoContentInfo::_VideoContentData* pVideoContentData = null;\r
+\r
+ std::unique_ptr<ImageContentInfo> pImageContentInfo;\r
+ std::unique_ptr<AudioContentInfo> pAudioContentInfo;\r
+ std::unique_ptr<VideoContentInfo> pVideoContentInfo;\r
+ std::unique_ptr<OtherContentInfo> pOtherContentInfo;\r
+\r
+ std::unique_ptr<ContentSearchResult> pContentSearchResult;\r
+\r
+ pTemp = pItemList.get();\r
+\r
+ ret = media_info_foreach_media_from_db(*(__pFilterHandle.get()), MediaItemCb, &pTemp);\r
+ r = MapCoreErrorToNativeResult(ret);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform media_info_foreach_media_from_db operation.");\r
+\r
+ SysTryReturnResult(NID_CNT, pTemp != NULL, r, "media_info_foreach_media_from_db pTemp is null.");\r
+\r
+ media_content_type_e mediaType = MEDIA_CONTENT_TYPE_OTHERS;\r
+\r
+ for (int idx = 0; idx < (int)g_list_length(pTemp); idx++)\r
+ {\r
+ pMediaHandle.reset(static_cast<media_info_h>(g_list_nth_data(pTemp, idx)));\r
+\r
+ ret = media_info_get_media_type(pMediaHandle.get(), &mediaType);\r
+ r = MapCoreErrorToNativeResult(ret);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform media_info_get_media_type.");\r
+\r
+ switch (mediaType)\r
+ {\r
+ case MEDIA_CONTENT_TYPE_OTHERS:\r
+ //memset(&contentData, 0, sizeof(contentData));\r
+\r
+ pOtherContentInfo = std::unique_ptr<OtherContentInfo>(new (std::nothrow) OtherContentInfo);\r
+ SysTryReturnResult(NID_CNT, pOtherContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pOtherContentInfo.");\r
+\r
+ pContentData = pOtherContentInfo->GetContentData();\r
+ SysTryReturnResult(NID_CNT, pContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+ r = _ContentUtility::FillContentData(pMediaHandle.get(), pContentData);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillContentData operation.");\r
+\r
+\r
+ pContentSearchResult = std::unique_ptr<ContentSearchResult>(new (std::nothrow) ContentSearchResult);\r
+ SysTryReturnResult(NID_CNT, pContentSearchResult.get() != null, E_OUT_OF_MEMORY, "Failed to create pContentSearchResult.");\r
+\r
+ pContentSearchResult->SetContentType(CONTENT_TYPE_OTHER);\r
+ pContentSearchResult->SetContentInfo(pOtherContentInfo.release());\r
+\r
+ // Shallow copy, adds just the pointer: not the element\r
+\r
+ r = __pFinalOutList->Add(*(pContentSearchResult.release()));\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Add operation for ArrayList.");\r
+\r
+ //pOtherContentInfo = null;\r
+ //pContentSearchResult = null;\r
+ //_ContentUtility::DeleteContentData(&contentData);\r
+ break;\r
+ case MEDIA_CONTENT_TYPE_IMAGE:\r
+ //memset(&contentData, 0, sizeof(contentData));\r
+ //memset(&imageContentData, 0, sizeof(imageContentData));\r
+\r
+ pImageContentInfo = std::unique_ptr<ImageContentInfo>(new (std::nothrow) ImageContentInfo);\r
+ SysTryReturnResult(NID_CNT, pImageContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pImageContentInfo.");\r
+\r
+ pContentData = pImageContentInfo->GetContentData();\r
+ SysTryReturnResult(NID_CNT, pContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+ pImageContentData = pImageContentInfo->GetImageContentData();\r
+ SysTryReturnResult(NID_CNT, pImageContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+ r = _ContentUtility::FillContentData(pMediaHandle.get(), pContentData);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillContentData operation.");\r
+\r
+ r = _ContentUtility::FillImageContentData(pMediaHandle.get(), pImageContentData);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform GetDataFromImageTable operation.");\r
+\r
+ pContentSearchResult = std::unique_ptr<ContentSearchResult>(new (std::nothrow) ContentSearchResult);\r
+ SysTryReturnResult(NID_CNT, pContentSearchResult.get() != null, E_OUT_OF_MEMORY, "Failed to create pContentSearchResult.");\r
+\r
+ pContentSearchResult->SetContentType(CONTENT_TYPE_IMAGE);\r
+ pContentSearchResult->SetContentInfo(pImageContentInfo.release());\r
+\r
+ // Shallow copy, adds just the pointer: not the element\r
+\r
+ r = __pFinalOutList->Add(*(pContentSearchResult.release()));\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Add operation for ArrayList.");\r
+ //pImageContentInfo = null;\r
+ //pContentSearchResult = null;\r
+ //_ContentUtility::DeleteContentData(&contentData);\r
+ break;\r
+ case MEDIA_CONTENT_TYPE_MUSIC:\r
+ //fall through\r
+ case MEDIA_CONTENT_TYPE_SOUND:\r
+ //memset(&contentData, 0, sizeof(contentData));\r
+ //memset(&audioContentData, 0, sizeof(audioContentData));\r
+\r
+ pAudioContentInfo = std::unique_ptr<AudioContentInfo>(new (std::nothrow) AudioContentInfo);\r
+ SysTryReturnResult(NID_CNT, pAudioContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pAudioContentInfo.");\r
+\r
+ pContentData = pAudioContentInfo->GetContentData();\r
+ SysTryReturnResult(NID_CNT, pContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+ pAudioContentData = pAudioContentInfo->GetAudioContentData();\r
+ SysTryReturnResult(NID_CNT, pAudioContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+ r = _ContentUtility::FillContentData(pMediaHandle.get(), pContentData);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillContentData operation.");\r
+\r
+ r = _ContentUtility::FillAudioContentData(pMediaHandle.get(), pAudioContentData);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillAudioContentData operation.");\r
+\r
+ pContentSearchResult = std::unique_ptr<ContentSearchResult>(new (std::nothrow) ContentSearchResult);\r
+ SysTryReturnResult(NID_CNT, pContentSearchResult.get() != null, E_OUT_OF_MEMORY, "Failed to create pContentSearchResult.");\r
+\r
+ pContentSearchResult->SetContentType(CONTENT_TYPE_AUDIO);\r
+ pContentSearchResult->SetContentInfo(pAudioContentInfo.release());\r
+\r
+ // Shallow copy, adds just the pointer: not the element\r
+\r
+ r = __pFinalOutList->Add(*(pContentSearchResult.release()));\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Add operation for ArrayList.");\r
+\r
+ //pAudioContentInfo = null;\r
+ //pContentSearchResult = null;\r
+ //_ContentUtility::DeleteContentData(&contentData);\r
+ //_ContentUtility::DeleteAudioContentData(&audioContentData);\r
+ break;\r
+ case MEDIA_CONTENT_TYPE_VIDEO:\r
+ //memset(&contentData, 0, sizeof(contentData));\r
+ //memset(&videoContentData, 0, sizeof(videoContentData));\r
+\r
+ pVideoContentInfo = std::unique_ptr<VideoContentInfo>(new (std::nothrow) VideoContentInfo);\r
+ SysTryReturnResult(NID_CNT, pVideoContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pVideoContentInfo.");\r
+\r
+ pContentData = pVideoContentInfo->GetContentData();\r
+ SysTryReturnResult(NID_CNT, pContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+ pVideoContentData = pVideoContentInfo->GetVideoContentData();\r
+ SysTryReturnResult(NID_CNT, pVideoContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
+\r
+ r = _ContentUtility::FillContentData(pMediaHandle.get(), pContentData);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillContentData operation.");\r
+\r
+ r = _ContentUtility::FillVideoContentData(pMediaHandle.get(), pVideoContentData);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillVideoContentData operation.");\r
+\r
+ pContentSearchResult = std::unique_ptr<ContentSearchResult>(new (std::nothrow) ContentSearchResult);\r
+ SysTryReturnResult(NID_CNT, pContentSearchResult.get() != null, E_OUT_OF_MEMORY, "Failed to create pContentSearchResult.");\r
+\r
+ pContentSearchResult->SetContentType(CONTENT_TYPE_VIDEO);\r
+ pContentSearchResult->SetContentInfo(pVideoContentInfo.release());\r
+\r
+ // Shallow copy, adds just the pointer: not the element\r
+\r
+ r = __pFinalOutList->Add(*(pContentSearchResult.release()));\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Add operation for ArrayList.");\r
+\r
+ //pVideoContentInfo = null;\r
+ //pContentSearchResult = null;\r
+ //_ContentUtility::DeleteContentData(&contentData);\r
+ //_ContentUtility::DeleteVideoContentData(&videoContentData);\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ return r;\r
+}\r
+\r
+// returns given column value list in the requested order\r
+Collection::IList*\r
+_ContentSearchImpl::GetValueListN(const String& sortColumn, SortOrder sortOrder)\r
+{\r
+ SysLog(NID_CNT, "inputColumn = %ls", sortColumn.GetPointer());\r
+ ClearLastResult();\r
+\r
+ result r = E_SUCCESS;\r
+ int colIndex = 0;\r
+ int maxCols = 0;\r
+\r
+ __inputColumnName.Clear();\r
+ __inputExpr.Clear();\r
+\r
+ __inputColumnName = sortColumn;\r
+ __inputSortOrder = sortOrder;\r
+\r
+ String ospColumnName(L"");\r
+ String slpColumnName(L"");\r
+\r
+ String columnName(__inputColumnName);\r
+\r
+ if ((__inputColumnName.IsEmpty()) && ((__inputSortOrder == SORT_ORDER_ASCENDING) || (__inputSortOrder == SORT_ORDER_DESCENDING)))\r
+ {\r
+ SysLog(NID_CNT, "sort column name is empty and sort oder is not none. so,E_INVALID_ARG occured.");\r
+ SetLastResult(E_INVALID_ARG);\r
+ return null;\r
+ }\r
+ else\r
+ {\r
+ std::unique_ptr<ArrayList, AllElementsDeleter> pFinalOutList(new (std::nothrow) ArrayList());\r
+ SysTryReturn(NID_CNT, pFinalOutList.get() != null, NULL, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to construct ArrayList.");\r
+\r
+ r = pFinalOutList->Construct();\r
+ SysTryReturn(NID_CNT, !IsFailed(r), NULL, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to construct ArrayList.");\r
+\r
+ __pFinalOutList = std::move(pFinalOutList);\r
+\r
+ switch (__contentType)\r
+ {\r
+ case CONTENT_TYPE_OTHER:\r
+ //fall through\r
+ case CONTENT_TYPE_IMAGE:\r
+ maxCols = MAX_QUERY_COLUMNS_FOR_IMAGE_OTHERS;\r
+ break;\r
+ case CONTENT_TYPE_VIDEO:\r
+ maxCols = MAX_QUERY_COLUMNS_FOR_VIDEO;\r
+ break;\r
+ case CONTENT_TYPE_AUDIO:\r
+ //fall through\r
+ case CONTENT_TYPE_ALL:\r
+ maxCols = MAX_QUERY_COLUMNS;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+\r
+ for (colIndex = 0; colIndex < maxCols; colIndex++)\r
+ {\r
+ ospColumnName.Clear();\r
+ slpColumnName.Clear();\r
+\r
+ ospColumnName = dbfieldinfo[colIndex].dbFieldOspName ;\r
+ slpColumnName = dbfieldinfo[colIndex].dbFieldSlpName ;\r
+\r
+ ospColumnName.ToUpper();\r
+ columnName.ToUpper();\r
+ if (columnName == ospColumnName)\r
+ {\r
+ r = FillColumnsList(colIndex);\r
+ SysTryReturn(NID_CNT, r == E_SUCCESS, NULL, r, "[%s] FillColumnsList Failed.", GetErrorMessage(r));\r
+ break;\r
+ }\r
+ }\r
+ if (colIndex == maxCols)\r
+ {\r
+ r = E_INVALID_ARG;\r
+ SysTryReturn(NID_CNT, r == E_SUCCESS, NULL, r, "[E_INVALID_ARG] invalid column.");\r
+ }\r
+ }\r
+ SetLastResult(r);\r
+ return __pFinalOutList.release();\r
+}\r
+\r
+// returns given column value list in the requested order\r
+Collection::IList*\r
+_ContentSearchImpl::GetValueListN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount, const String& sortColumn, SortOrder sortOrder) const\r
+{\r
+ SysLog(NID_CNT, "pageNo = %d, countPerPage = %d, inputColumn = %ls", pageNo, countPerPage, sortColumn.GetPointer());\r
+\r
+ ClearLastResult();\r
+\r
+ result r = E_SUCCESS;\r
+ int colIndex = 0;\r
+ int maxCols = 0;\r
+\r
+ __inputColumnName.Clear();\r
+ __inputExpr.Clear();\r
+\r
+ __inputColumnName = sortColumn;\r
+ __inputSortOrder = sortOrder;\r
+\r
+ String ospColumnName(L"");\r
+ String slpColumnName(L"");\r
+\r
+ String columnName(__inputColumnName);\r
+\r
+ if ((__inputColumnName.IsEmpty()) && ((__inputSortOrder == SORT_ORDER_ASCENDING) || (__inputSortOrder == SORT_ORDER_DESCENDING)))\r
+ {\r
+ SysLog(NID_CNT, "sort column name is empty and sort oder is not none. so,E_INVALID_ARG occured.");\r
+ SetLastResult(E_INVALID_ARG);\r
+ return null;\r
+ }\r
+ else\r
+ {\r
+ std::unique_ptr<ArrayList, AllElementsDeleter> pFinalOutList(new (std::nothrow) ArrayList());\r
+ SysTryReturn(NID_CNT, pFinalOutList.get() != null, NULL, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to construct ArrayList.");\r
+\r
+ r = pFinalOutList->Construct();\r
+ SysTryReturn(NID_CNT, !IsFailed(r), NULL, r, "[%s] Failed to construct ArrayList.", GetErrorMessage(r));\r
+\r
+ __pFinalOutList = std::move(pFinalOutList);\r
+\r
+ switch (__contentType)\r
+ {\r
+ case CONTENT_TYPE_OTHER:\r
+ //fall through\r
+ case CONTENT_TYPE_IMAGE:\r
+ maxCols = MAX_QUERY_COLUMNS_FOR_IMAGE_OTHERS;\r
+ break;\r
+ case CONTENT_TYPE_VIDEO:\r
+ maxCols = MAX_QUERY_COLUMNS_FOR_VIDEO;\r
+ break;\r
+ case CONTENT_TYPE_AUDIO:\r
+ //fall through\r
+ case CONTENT_TYPE_ALL:\r
+ maxCols = MAX_QUERY_COLUMNS;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+\r
+ for (colIndex = 0; colIndex < maxCols; colIndex++)\r
+ {\r
+ ospColumnName.Clear();\r
+ slpColumnName.Clear();\r
+\r
+ ospColumnName = dbfieldinfo[colIndex].dbFieldOspName ;\r
+ slpColumnName = dbfieldinfo[colIndex].dbFieldSlpName ;\r
+\r
+ ospColumnName.ToUpper();\r
+ columnName.ToUpper();\r
+ if (columnName == ospColumnName)\r
+ {\r
+ r = FillColumnsList(pageNo, countPerPage, totalPageCount, totalCount, colIndex);\r
+ SysTryReturn(NID_CNT, r == E_SUCCESS, NULL, r, "[%s] FillColumnsList Failed.", GetErrorMessage(r));\r
+ break;\r
+ }\r
+ }\r
+ if (colIndex == maxCols)\r
+ {\r
+ r = E_INVALID_ARG;\r
+ SysTryReturn(NID_CNT, r == E_SUCCESS, NULL, r, "[E_INVALID_ARG] invalid column.");\r
+ }\r
+ }\r
+ SetLastResult(r);\r
+ return __pFinalOutList.release();\r
+}\r
+\r
+// prepares query expression to be used in group api. colIndex is mapped to actual group value.\r
+media_group_e\r
+_ContentSearchImpl::GetIndexAndCreateQueryExp(int colIndex) const\r
+{\r
+ media_group_e groupIndex = MEDIA_CONTENT_GROUP_DISPLAY_NAME;;\r
+ switch (colIndex)\r
+ {\r
+ case 0://"ContentType", "MEDIA_TYPE"\r
+ groupIndex = MEDIA_CONTENT_GROUP_TYPE;\r
+ __inputExpr = "MEDIA_TYPE IS NOT NULL";\r
+ break;\r
+ case 1://"ContentFileName", "MEDIA_DISPLAY_NAME"\r
+ groupIndex = MEDIA_CONTENT_GROUP_DISPLAY_NAME;\r
+ __inputExpr = "MEDIA_DISPLAY_NAME IS NOT NULL";\r
+ break;\r
+ case 2://"ContentName", "MEDIA_CONTENT_NAME"\r
+ groupIndex = MEDIA_CONTENT_GROUP_CONTENT_NAME;\r
+ __inputExpr = "MEDIA_CONTENT_NAME IS NOT NULL";\r
+ break;\r
+ case 3://"Category", "MEDIA_CATEGORY"\r
+ groupIndex = MEDIA_CONTENT_GROUP_CATEGORY;\r
+ __inputExpr = "MEDIA_CATEGORY IS NOT NULL";\r
+ break;\r
+ case 4://"Author", "MEDIA_AUTHOR"\r
+ groupIndex = MEDIA_CONTENT_GROUP_AUTHOR;\r
+ __inputExpr = "MEDIA_AUTHOR IS NOT NULL";\r
+ break;\r
+ case 5://"keyword", "MEDIA_KEYWORD"\r
+ groupIndex = MEDIA_CONTENT_GROUP_KEYWORD;\r
+ __inputExpr = "MEDIA_KEYWORD IS NOT NULL";\r
+ break;\r
+ case 6://"Provider", "MEDIA_PROVIDER"\r
+ groupIndex = MEDIA_CONTENT_GROUP_PROVIDER;\r
+ __inputExpr = "MEDIA_PROVIDER IS NOT NULL";\r
+ break;\r
+ case 7://"Rating", "MEDIA_AGE_RATING"\r
+ groupIndex = MEDIA_CONTENT_GROUP_AGE_RATING;\r
+ __inputExpr = "MEDIA_AGE_RATING IS NOT NULL";\r
+ break;\r
+ case 8://"LocationTag", "MEDIA_LOCATION_TAG"\r
+ groupIndex = MEDIA_CONTENT_GROUP_LOCATION_TAG;\r
+ __inputExpr = "MEDIA_LOCATION_TAG IS NOT NULL";\r
+ break;\r
+ case 9://"ContentSize", "MEDIA_SIZE"\r
+ groupIndex = MEDIA_CONTENT_GROUP_SIZE;\r
+ __inputExpr = "MEDIA_SIZE IS NOT NULL";\r
+ break;\r
+ case 10://"DateTime", "MEDIA_ADDED_TIME"\r
+ groupIndex = MEDIA_CONTENT_GROUP_ADDED_TIME;\r
+ __inputExpr = "MEDIA_ADDED_TIME IS NOT NULL";\r
+ break;\r
+ case 11://"Latitude", "MEDIA_LATITUDE"\r
+ groupIndex = MEDIA_CONTENT_GROUP_LATITUDE;\r
+ __inputExpr = "MEDIA_LATITUDE IS NOT NULL";\r
+ break;\r
+ case 12://"Longitude", "MEDIA_LONGITUDE"\r
+ groupIndex = MEDIA_CONTENT_GROUP_LONGITUDE;\r
+ __inputExpr = "MEDIA_LONGITUDE IS NOT NULL";\r
+ break;\r
+ case 13://"Altitude", "MEDIA_ALTITUDE"\r
+ groupIndex = MEDIA_CONTENT_GROUP_ALTITUDE;\r
+ __inputExpr = "MEDIA_ALTITUDE IS NOT NULL";\r
+ break;\r
+ case 14://"Title", "MEDIA_TITLE"\r
+ groupIndex = MEDIA_CONTENT_GROUP_TITLE;\r
+ __inputExpr = "MEDIA_TITLE IS NOT NULL";\r
+ break;\r
+ case 15://"Artist", "MEDIA_ARTIST"\r
+ groupIndex = MEDIA_CONTENT_GROUP_ARTIST;\r
+ __inputExpr = "MEDIA_ARTIST IS NOT NULL";\r
+ break;\r
+ case 16://"Genre", "MEDIA_GENRE"\r
+ groupIndex = MEDIA_CONTENT_GROUP_GENRE;\r
+ __inputExpr = "MEDIA_GENRE IS NOT NULL";\r
+ break;\r
+ case 17://"Year", "MEDIA_YEAR"\r
+ groupIndex = MEDIA_CONTENT_GROUP_YEAR;\r
+ __inputExpr = "MEDIA_YEAR IS NOT NULL";\r
+ break;\r
+ case 18://"Composer", "MEDIA_COMPOSER"\r
+ groupIndex = MEDIA_CONTENT_GROUP_COMPOSER;\r
+ __inputExpr = "MEDIA_COMPOSER IS NOT NULL";\r
+ break;\r
+ case 19://"Album", "MEDIA_ALBUM"\r
+ __inputExpr = "MEDIA_ALBUM IS NOT NULL";\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ return groupIndex;\r
+}\r
+\r
+// Fills given column value list and destroys filter handle\r
+result\r
+_ContentSearchImpl::FillColumnsList(int colIndex) const\r
+{\r
+ result r = E_SUCCESS;\r
+ int ret = MEDIA_CONTENT_ERROR_NONE;\r
+ int totalCount = 0;\r
+ media_group_e groupIndex = GetIndexAndCreateQueryExp(colIndex);\r
+\r
+ r = CreateQueryFilter(true);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "CreateQueryFilter Failed.");\r
+\r
+ if (colIndex == ALBUM_COLUMN_NUM)\r
+ {\r
+ ret = media_album_get_album_count_from_db(*(__pFilterHandle.get()), &totalCount);\r
+ }\r
+ else\r
+ {\r
+ ret = media_group_get_group_count_from_db(*(__pFilterHandle.get()), groupIndex, &totalCount);\r
+ }\r
+ r = MapCoreErrorToNativeResult(ret);\r
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, r, "Failed to perform media_album/group count_from_db operation.");\r
+\r
+ SysLog(NID_CNT, "totalCount = %d for media_album/group count_from_db", totalCount);\r
+\r
+ if (totalCount > 0)\r
+ {\r
+ if (colIndex == ALBUM_COLUMN_NUM)\r
+ {\r
+ r = ExecuteAndFillAlbumValues();\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "ExecuteAndFillAlbumValues Failed.");\r
+ }\r
+ else\r
+ {\r
+ r = ExecuteAndFillGetValueListN(groupIndex, colIndex);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "ExecuteAndFillGetValueListN Failed.");\r
+ }\r
+ }\r
+ return r;\r
+}\r
+\r
+// prepares input expression to be sent for create filter and fills given column value list\r
+result\r
+_ContentSearchImpl::FillColumnsList(int pageNo, int countPerPage, int& totalPageCount, int& totalCount, int colIndex) const\r
+{\r
+ result r = E_SUCCESS;\r
+ int ret = MEDIA_CONTENT_ERROR_NONE;\r
+ int offset = 0;\r
+ totalPageCount = 0;\r
+ totalCount = 0;\r
+ media_group_e groupIndex = GetIndexAndCreateQueryExp(colIndex);\r
+\r
+ r = CreateQueryFilter(true);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "CreateQueryFilter Failed.");\r
+\r
+ if (colIndex == ALBUM_COLUMN_NUM)\r
+ {\r
+ ret = media_album_get_album_count_from_db(*(__pFilterHandle.get()), &totalCount);\r
+ }\r
+ else\r
+ {\r
+ ret = media_group_get_group_count_from_db(*(__pFilterHandle.get()), groupIndex, &totalCount);\r
+ }\r
+ r = MapCoreErrorToNativeResult(ret);\r
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, r, "Failed to perform media_album/group count_from_db operation.");\r
+\r
+ SysLog(NID_CNT, "totalCount = %d for media_album/group count_from_db", totalCount);\r
+\r
+ if (totalCount > 0)\r
+ {\r
+ if ((totalCount % countPerPage) == 0)\r
+ {\r
+ totalPageCount = totalCount / countPerPage;\r
+ }\r
+ else\r
+ {\r
+ totalPageCount = (totalCount / countPerPage) + 1;\r
+ }\r
+\r
+ if ((pageNo < 1) || (pageNo > totalPageCount))\r
+ {\r
+ r = E_INVALID_ARG;\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "(pageNo < 1) || (pageNo > totalPageCount).");\r
+ }\r
+\r
+ offset = (pageNo * countPerPage) - countPerPage;\r
+\r
+ SysLog(NID_CNT, "GetValueListN totalCount [%d] totalPageCount[%d] __countPerPage[%d] __pageNo[%d] offset[%d]",\r
+ totalCount, totalPageCount, countPerPage, pageNo, offset);\r
+\r
+ ret = media_filter_set_offset(*(__pFilterHandle.get()),offset,countPerPage);\r
+ r = MapCoreErrorToNativeResult(ret);\r
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, r, "failed to perform media_filter_set_offset operation.");\r
+\r
+ if (colIndex == ALBUM_COLUMN_NUM)\r
+ {\r
+ r = ExecuteAndFillAlbumValues();\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "ExecuteAndFillAlbumValues Failed.");\r
+ }\r
+ else\r
+ {\r
+ r = ExecuteAndFillGetValueListN(groupIndex, colIndex);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "ExecuteAndFillGetValueListN Failed.");\r
+ }\r
+\r
+ }\r
+ else if (pageNo > 1)\r
+ {\r
+ r = E_INVALID_ARG;\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "(pageNo > 1) and (totalcount = 0).");\r
+ }\r
+\r
+ return r;\r
+}\r
+\r
+// fills given column value list for GetValuelistN api\r
+result\r
+_ContentSearchImpl::ExecuteAndFillGetValueListN(media_group_e groupIndex, int colIndex) const\r
+{\r
+ SysLog(NID_CNT, "Enter\n");\r
+\r
+ int ret = MEDIA_CONTENT_ERROR_NONE;\r
+ result r = E_SUCCESS;\r
+ result res = E_SUCCESS;\r
+ std::unique_ptr<GList, SearchGListDeleter> pItemList;\r
+ GList* pTemp = NULL;\r
+\r
+ std::unique_ptr<Object> pValue;\r
+\r
+ DateTime dateTime;\r
+\r
+ long long contentSize = 0;\r
+ long long addedTime = 0;\r
+\r
+ double dVal = 0;\r
+ char *pColumnVal = null;\r
+ int contentType = 0;\r
+\r
+ pTemp = pItemList.get();\r
+\r
+ ret = media_group_foreach_group_from_db(*(__pFilterHandle.get()), groupIndex, GroupItemCb, &pTemp);\r
+ r = MapCoreErrorToNativeResult(ret);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform media_group_foreach_group_from_db operation.");\r
+\r
+ SysTryReturnResult(NID_CNT, pTemp != NULL, r, "media_info_foreach_media_from_db pTemp is null.");\r
+\r
+ for (int idx = 0; idx < (int)g_list_length(pTemp); idx++)\r
+ {\r
+ SysLog(NID_CNT, "idx = %d and (int)g_list_length(pItemList) = %d", idx, (int)g_list_length(pTemp));\r
+\r
+ pColumnVal = (char *)g_list_nth_data(pTemp, idx);\r
+\r
+ String strColVal(pColumnVal);\r
+\r
+ _ContentUtility::DoSafeFree(pColumnVal);\r
+\r
+ SysLog(NID_CNT, "pColumnVal = %ls", strColVal.GetPointer());\r
+\r
+ switch (colIndex)\r
+ {\r
+ case 0://"ContentType", "MEDIA_TYPE"\r
+ if ((strColVal.CompareTo(L"Unknown") != 0) && (!strColVal.IsEmpty()))\r
+ {\r
+ res = Integer::Parse(strColVal, contentType);\r
+ SysTryLog(NID_CNT, res == E_SUCCESS, "[%s] Integer parse failed.", GetErrorMessage(res));\r
+ }\r
+ switch ((media_content_type_e)contentType)\r
+ {\r
+ case MEDIA_CONTENT_TYPE_OTHERS:\r
+ pValue.reset(new (std::nothrow) String(CONTENT_TYPE_OTHER));\r
+ SysLog(NID_CNT, "mediaType = CONTENT_TYPE_OTHER");\r
+ break;\r
+ case MEDIA_CONTENT_TYPE_IMAGE:\r
+ pValue.reset(new (std::nothrow) String(CONTENT_TYPE_IMAGE));\r
+ SysLog(NID_CNT, "mediaType = CONTENT_TYPE_IMAGE");\r
+ break;\r
+ case MEDIA_CONTENT_TYPE_SOUND:\r
+ //fall through\r
+ case MEDIA_CONTENT_TYPE_MUSIC:\r
+ pValue.reset(new (std::nothrow) String(CONTENT_TYPE_AUDIO));\r
+ SysLog(NID_CNT, "mediaType = CONTENT_TYPE_AUDIO");\r
+ break;\r
+ case MEDIA_CONTENT_TYPE_VIDEO:\r
+ pValue.reset(new (std::nothrow) String(CONTENT_TYPE_VIDEO));\r
+ SysLog(NID_CNT, "mediaType = CONTENT_TYPE_VIDEO");\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ break;\r
+ case 1://"ContentFileName", "MEDIA_DISPLAY_NAME"\r
+ //fall through\r
+ case 2://"ContentName", "MEDIA_CONTENT_NAME"\r
+ //fall through\r
+ case 3://"Category", "MEDIA_CATEGORY"\r
+ //fall through\r
+ case 4://"Author", "MEDIA_AUTHOR"\r
+ //fall through\r
+ case 5://"keyword", "MEDIA_KEYWORD"\r
+ //fall through\r
+ case 6://"Provider", "MEDIA_PROVIDER"\r
+ //fall through\r
+ case 7://"Rating", "MEDIA_AGE_RATING"\r
+ //fall through\r
+ case 8://"LocationTag", "MEDIA_LOCATION_TAG"\r
+ //fall through\r
+ case 14://"Title", "MEDIA_TITLE"\r
+ //fall through\r
+ case 15://"Artist", "MEDIA_ARTIST"\r
+ //fall through\r
+ case 16://"Genre", "MEDIA_GENRE"\r
+ //fall through\r
+ case 17://"Year", "MEDIA_YEAR"\r
+ //fall through\r
+ case 18://"Composer", "MEDIA_COMPOSER"\r
+\r
+ pValue.reset(new (std::nothrow) String(strColVal));\r
+ break;\r
+\r
+ case 9://"ContentSize", "MEDIA_SIZE" \r
+ if ((strColVal.CompareTo(L"Unknown") != 0) && (!strColVal.IsEmpty()))\r
+ {\r
+ res = LongLong::Parse(strColVal, contentSize);\r
+ SysTryLog(NID_CNT, res == E_SUCCESS, "[%s] LongLong parse failed.", GetErrorMessage(res));\r
+ }\r
+\r
+ pValue.reset(new (std::nothrow) LongLong(contentSize));\r
+ break;\r
+ case 10://"DateTime", "MEDIA_ADDED_TIME" \r
+ if ((strColVal.CompareTo(L"Unknown") != 0) && (!strColVal.IsEmpty()))\r
+ {\r
+ res = LongLong::Parse(strColVal, addedTime);\r
+ SysTryLog(NID_CNT, res == E_SUCCESS, "[%s] LongLong parse failed.", GetErrorMessage(res));\r
+ }\r
+\r
+ res = dateTime.SetValue(1970, 1, 1);\r
+ SysTryLog(NID_CNT, res == E_SUCCESS, "[%s] dateTime.SetValue failed.", GetErrorMessage(res));\r
+\r
+ res = dateTime.AddSeconds(addedTime);\r
+ SysTryLog(NID_CNT, res == E_SUCCESS, "[%s] dateTime.AddSeconds failed.", GetErrorMessage(res));\r
+\r
+ SysLog(NID_CNT, "DateTime : %ls", dateTime.ToString().GetPointer());\r
+\r
+ pValue.reset(new (std::nothrow) DateTime(dateTime));\r
+\r
+ break;\r
+ case 11://"Latitude", "MEDIA_LATITUDE"\r
+ //fall through\r
+ case 12://"Longitude", "MEDIA_LONGITUDE"\r
+ //fall through\r
+ case 13://"Altitude", "MEDIA_ALTITUDE"\r
+ if ((strColVal.CompareTo(L"Unknown") != 0) && (!strColVal.IsEmpty()))\r
+ {\r
+ res = Double::Parse(strColVal, dVal);\r
+ SysTryLog(NID_CNT, res == E_SUCCESS, "[%s] double parse failed.", GetErrorMessage(res));\r
+ }\r
+ pValue.reset(new (std::nothrow) Double(dVal));\r
+ break;\r
+\r
+ case 19://"Album", "MEDIA_ALBUM"\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ if (pValue.get() != NULL)\r
+ {\r
+ r = __pFinalOutList->Add(*(pValue.release()));\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform arraylist Add operation.");\r
+ }\r
+ }\r
+\r
+ return r;\r
+}\r
+\r
+result\r
+_ContentSearchImpl::ExecuteAndFillAlbumValues(void) const\r
+{\r
+ int ret = MEDIA_CONTENT_ERROR_NONE;\r
+ result r = E_SUCCESS;\r
+ std::unique_ptr<GList, SearchGListDeleter> pItemList;\r
+ GList* pTemp = NULL;\r
+ std::unique_ptr<media_album_s, AlbumHandleDeleter> pAlbumHandle;\r
+\r
+ Object* pValue = NULL;\r
+ char* __pAlbumName = NULL;\r
+ std::unique_ptr<char, CharDeleter> pAlbumName;\r
+\r
+ pTemp = pItemList.get();\r
+\r
+ ret = media_album_foreach_album_from_db(*(__pFilterHandle.get()), AlbumItemCb, &pTemp);\r
+ r = MapCoreErrorToNativeResult(ret);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform media_album_foreach_album_from_db operation.");\r
+ SysTryReturnResult(NID_CNT, pTemp != NULL, r, "media_info_foreach_media_from_db pTemp is null.");\r
+\r
+ for (int idx = 0; idx < (int)g_list_length(pTemp); idx++)\r
+ {\r
+ pAlbumHandle.reset(static_cast<media_album_h>(g_list_nth_data(pTemp, idx)));\r
+ ret = media_album_get_name(pAlbumHandle.get(), &__pAlbumName);\r
+ r = MapCoreErrorToNativeResult(ret);\r
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform media_album_get_name.");\r
+ \r
+ if (__pAlbumName != NULL)\r
+ {\r
+ SysLog(NID_CNT, "pColumnVal = %s", __pAlbumName);\r
+\r
+ pAlbumName.reset(__pAlbumName);\r
+\r
+ pValue = new (std::nothrow) String(pAlbumName.get());\r
+ SysTryReturnResult(NID_CNT, pValue != NULL, E_OUT_OF_MEMORY, "media_info_foreach_media_from_db pTemp is null.");\r
+ }\r
+\r
+ if (pValue != NULL)\r
+ {\r
+ r = __pFinalOutList->Add(*pValue);\r
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform arraylist Add operation.");\r
+ }\r
+\r
+ pValue = NULL;\r
+ }\r
+ return r;\r
+}\r
+\r
+result\r
+_ContentSearchImpl::MapCoreErrorToNativeResult(int reason) const\r
+{\r
+ result r = E_SUCCESS;\r
+\r
+ switch (reason)\r
+ {\r
+ case MEDIA_CONTENT_ERROR_NONE:\r
+ r = E_SUCCESS;\r
+ break;\r
+\r
+ case MEDIA_CONTENT_ERROR_INVALID_PARAMETER:\r
+ r = E_INVALID_ARG;\r
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_INVALID_PARAMETER");\r
+ break;\r
+\r
+ case MEDIA_CONTENT_ERROR_DB_FAILED:\r
+ r = E_SYSTEM;\r
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_FAILED");\r
+ break;\r
+\r
+ case MEDIA_CONTENT_ERROR_OUT_OF_MEMORY:\r
+ r = E_OUT_OF_MEMORY;\r
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_OUT_OF_MEMORY");\r
+ break;\r
+\r
+ default:\r
+ SysLog(NID_CNT, "default");\r
+ r = E_SYSTEM;\r
+ break;\r
+ }\r
+ return r;\r
+}\r
+\r
+//Callback function registered to each media info details\r
+// all items are appened to the list\r
+bool\r
+MediaItemCb(media_info_h media, void* pUserdata)\r
+{\r
+ int ret = MEDIA_CONTENT_ERROR_NONE;\r
+ media_info_h new_media = NULL;\r
+ ret = media_info_clone(&new_media, media);\r
+ SysTryLog(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, "[E_SYSTEM] Failed to perform media_info_clone");\r
+\r
+ GList** pList = (GList**)pUserdata;\r
+ *pList = g_list_append(*pList, new_media);\r
+\r
+ return true;\r
+}\r
+\r
+//Callback function registered for column values\r
+// all items are appened to the list\r
+bool\r
+GroupItemCb(const char* pGroupName, void* pUserdata)\r
+{\r
+ char* pGrpName = strdup(pGroupName);\r
+ GList** pList = (GList**)pUserdata;\r
+ *pList = g_list_append(*pList, pGrpName);\r
+\r
+ return true;\r
+}\r
+\r
+//Callback function registered to each media info details\r
+// all items are appened to the list\r
+bool\r
+AlbumItemCb(media_album_h album, void* pUserdata)\r
+{\r
+ int ret = MEDIA_CONTENT_ERROR_NONE;\r
+ media_album_h new_album = NULL;\r
+ ret = media_album_clone(&new_album, album);\r
+ SysTryLog(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, "[E_SYSTEM] Failed to perform media_album_clone");\r
+\r
+ GList** pList = (GList**)pUserdata;\r
+ *pList = g_list_append(*pList, new_album);\r
+\r
+ return true;\r
+}\r
+\r
+}}\r
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentTransferEvent.cpp
+ * @brief This is the implementation file for the %ContentTransferEvent and %ContentTransferEventArg class.
+ *
+ * This file contains implementation of the %ContentTransferEvent and %ContentTransferEventArg class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FCntIContentTransferListener.h>
+#include "FCnt_ContentTransferEvent.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Content
+{
+
+// ContentTransferEvent class
+_ContentTransferEvent::_ContentTransferEvent(void)
+{
+}
+
+_ContentTransferEvent::~_ContentTransferEvent(void)
+{
+
+}
+
+void
+_ContentTransferEvent::FireImpl(Runtime::IEventListener& listener, const Runtime::IEventArg& arg)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ IContentTransferListener* pIContentTransferListener = dynamic_cast<IContentTransferListener*>(&listener);
+ SysTryReturnVoidResult(NID_CNT, pIContentTransferListener != null, r = E_INVALID_STATE,
+ "[E_INVALID_STATE] IContentTransferListener interface must not be null.");
+
+ const _ContentTransferEventArg* pArg = dynamic_cast<const _ContentTransferEventArg*>(&arg);
+ SysTryReturnVoidResult(NID_CNT, pArg != null, r = E_INVALID_STATE, "[E_INVALID_STATE] ContentTransferEventArg must not be null.");
+
+ switch (pArg->GetEventType())
+ {
+ case CONTENT_TRANSFER_EVENT_DOWNLOAD_COMPLETED:
+ SysLog(NID_CNT, "Event fire after call DownloadComplete.");
+ pIContentTransferListener->OnContentDownloadCompleted(pArg->GetRequestId(), pArg->GetContentId(),
+ pArg->GetResult(), pArg->GetErrorCode(), pArg->GetErrorMsg());
+ break;
+
+ case CONTENT_TRANSFER_EVENT_CANCELED:
+ SysLog(NID_CNT, "Event fire after call DownloadCancel.");
+ pIContentTransferListener->OnContentTransferCanceled(pArg->GetRequestId(), pArg->GetResult(),
+ pArg->GetErrorCode(), pArg->GetErrorMsg());
+ break;
+
+ case CONTENT_TRANSFER_EVENT_DOWNLOAD_TO_BUFFER_COMPLETED:
+ SysLog(NID_CNT, "Event fire after call DownloadToBufferComplete.");
+ pIContentTransferListener->OnContentDownloadToBufferCompleted(pArg->GetRequestId(), pArg->GetBuffer(),
+ pArg->GetResult(), pArg->GetErrorCode(), pArg->GetErrorMsg());
+ break;
+
+ case CONTENT_TRANSFER_EVENT_TRANSFER_IN_PROGRESS:
+ SysLog(NID_CNT, "Event fire after call DownloadInProgress.");
+ pIContentTransferListener->OnContentTransferInProgress(pArg->GetRequestId(), pArg->GetTotalTransferedSize());
+ break;
+
+ default:
+ r = E_INVALID_STATE;
+ SysTryReturnVoidResult(NID_CNT, r == E_SUCCESS, r, "[E_INVALID_STATE] Event type is unknown.");
+ }
+
+ SetLastResult(r);
+}
+
+
+// ContentTransferEventArg class
+_ContentTransferEventArg::_ContentTransferEventArg(void)
+ : __requestId(INVALID_REQUEST_ID)
+ , __contentId()
+ , __contentTransferEventType(CONTENT_TRANSFER_EVENT_NONE)
+ , __totalSize(-1)
+ , __res(E_SUCCESS)
+ , __errorMsg(L"")
+ , __errorCode(L"")
+ , __pBuffer(null)
+{
+}
+
+_ContentTransferEventArg::~_ContentTransferEventArg(void)
+{
+
+}
+
+void
+_ContentTransferEventArg::SetEventType(ContentTransferEventType eType)
+{
+ __contentTransferEventType = eType;
+}
+
+void
+_ContentTransferEventArg::SetResult(result res)
+{
+ __res = res;
+}
+
+void
+_ContentTransferEventArg::SetErrorMsg(const String& ErrorCode, const String& ErrorMsg)
+{
+ __errorMsg = ErrorMsg;
+ __errorCode = ErrorCode;
+}
+
+void
+_ContentTransferEventArg::SetRequestId(RequestId requestId)
+{
+ __requestId = requestId;
+}
+
+void
+_ContentTransferEventArg::SetContentId(const ContentId& contentId)
+{
+ __contentId = contentId;
+}
+
+void
+_ContentTransferEventArg::SetTotalTransferedSize(int totalSize)
+{
+ __totalSize = totalSize;
+}
+
+
+ContentTransferEventType
+_ContentTransferEventArg::GetEventType(void) const
+{
+ return __contentTransferEventType;
+}
+
+result
+_ContentTransferEventArg::GetResult(void) const
+{
+ return __res;
+}
+
+String
+_ContentTransferEventArg::GetErrorMsg(void) const
+{
+ return __errorMsg;
+}
+
+String
+_ContentTransferEventArg::GetErrorCode(void) const
+{
+ return __errorCode;
+}
+
+RequestId
+_ContentTransferEventArg::GetRequestId(void) const
+{
+ return __requestId;
+}
+
+ContentId
+_ContentTransferEventArg::GetContentId(void) const
+{
+ return __contentId;
+}
+
+int
+_ContentTransferEventArg::GetTotalTransferedSize(void) const
+{
+ return __totalSize;
+}
+
+void
+_ContentTransferEventArg::SetBuffer(ByteBuffer* pBuffer)
+{
+ __pBuffer = std::unique_ptr<ByteBuffer>(pBuffer);
+}
+
+ByteBuffer*
+_ContentTransferEventArg::GetBuffer(void) const
+{
+ return __pBuffer.get();
+}
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCntContentTransferEvent.h
+ * @brief This is the header file for the %ContentTransferEvent class.
+ *
+ */
+#ifndef _FCNT_INTERNAL_CONTENT_TRANSFER_EVENT_H_
+#define _FCNT_INTERNAL_CONTENT_TRANSFER_EVENT_H_
+
+#include <unique_ptr.h>
+#include <FBaseRt_Event.h>
+#include <FBaseRtIEventArg.h>
+
+namespace Tizen { namespace Content
+{
+
+//
+// @enum ContentTransferEventType
+// @brief This represents ContentTransfer's event type.
+//
+enum ContentTransferEventType
+{
+ CONTENT_TRANSFER_EVENT_NONE, // Event None
+ CONTENT_TRANSFER_EVENT_DOWNLOAD_COMPLETED, // Event None
+ CONTENT_TRANSFER_EVENT_CANCELED,
+ CONTENT_TRANSFER_EVENT_DOWNLOAD_TO_BUFFER_COMPLETED,
+ CONTENT_TRANSFER_EVENT_TRANSFER_IN_PROGRESS
+};
+
+class _ContentTransferEvent
+ : public Tizen::Base::Runtime::_Event
+{
+public:
+ _ContentTransferEvent(void);
+ virtual ~_ContentTransferEvent(void);
+
+protected:
+ /**
+ * Finds out and invokes the method of listener corresponding to the specified event argument.
+ *
+ * @return The error code.
+ * @param[in] pListener An event listener to be invoked. This must be an instance of ICameraEventListener.
+ * @param[in] arg An argument to be fired.
+ * @exception E_SUCCESS - This method is successful.
+ * @exception E_OUT_OF_MEMORY - Failed to allocate the required/requested memory.
+ * @exception E_INVALID_STATE - The current state of the camera is inappropriate or invalid for this method.
+ * @exception E_INVALID_ARG - The argument passed to a method contains an invalid value.
+ */
+ virtual void FireImpl(Tizen::Base::Runtime::IEventListener& listener, const Tizen::Base::Runtime::IEventArg& arg);
+
+private:
+ _ContentTransferEvent(const _ContentTransferEvent& rhs);
+ _ContentTransferEvent& operator =(const _ContentTransferEvent& rhs);
+
+}; // class _ContentTransferEvent
+
+
+class _ContentTransferEventArg
+ : public Tizen::Base::Runtime::IEventArg
+{
+public:
+ _ContentTransferEventArg(void);
+ virtual ~_ContentTransferEventArg(void);
+
+public:
+ /**
+ * Get the event type.
+ *
+ * @return ContentTransfer Event type of this argument.
+ */
+ ContentTransferEventType GetEventType(void) const;
+
+ result GetResult(void) const;
+
+ Tizen::Base::String GetErrorMsg(void) const;
+
+ Tizen::Base::String GetErrorCode(void) const;
+
+ RequestId GetRequestId(void) const;
+
+ ContentId GetContentId(void) const;
+
+ int GetTotalTransferedSize(void) const;
+
+ Tizen::Base::ByteBuffer* GetBuffer(void) const;
+
+ /**
+ * Set the event type.
+ */
+ void SetEventType(ContentTransferEventType eType);
+
+ void SetResult(result res);
+
+ void SetErrorMsg(const Tizen::Base::String& ErrorCode, const Tizen::Base::String& ErrorMsg);
+
+ void SetRequestId(RequestId requestId);
+
+ void SetContentId(const ContentId& contentId);
+
+ void SetTotalTransferedSize(int totalSize);
+
+ void SetBuffer(Tizen::Base::ByteBuffer* pBuffer);
+
+private:
+ _ContentTransferEventArg(const _ContentTransferEventArg& rhs);
+ _ContentTransferEventArg& operator =(const _ContentTransferEventArg& rhs);
+
+private:
+ RequestId __requestId;
+ ContentId __contentId;
+ ContentTransferEventType __contentTransferEventType;
+ int __totalSize;
+ result __res;
+ Tizen::Base::String __errorMsg;
+ Tizen::Base::String __errorCode;
+ std::unique_ptr<Tizen::Base::ByteBuffer> __pBuffer;
+}; // class _ContentTransferEventArg
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_CONTENT_TRANSFER_EVENT_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentTransferImpl.cpp
+ * @brief This is the implementation file for the %_ContentTransferImpl class.
+ *
+ * This file contains implementation of the %_ContentTransferImpl class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FBaseString.h>
+#include <FBaseColIList.h>
+#include <FBaseUtilUri.h>
+#include <FIoDirectory.h>
+#include <FCntIContentTransferListener.h>
+#include <FCntContentTransfer.h>
+#include <FCntContentTransferInfo.h>
+#include <FIoRegistry.h>
+#include <FAppApp.h>
+#include <FSysEnvironment.h>
+#include <FApp_AppInfo.h>
+#include <FCnt_ContentTransferImpl.h>
+#include <FSys_EnvironmentImpl.h>
+#include <FIo_FileImpl.h>
+#include <FIo_FileAttributesImpl.h>
+#include <FSys_SystemTimeImpl.h>
+#include "FCnt_ContentDownloadHandler.h"
+#include "FCnt_ContentTransferEvent.h"
+
+using namespace Tizen;
+using namespace Tizen::App;
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Utility;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Io;
+using namespace Tizen::System;
+
+static RequestId downloadRequestId = 0;
+static bool initSlot = false;
+static const wchar_t CONTENT_DOWNLOAD[] = L"/usr/etc/content-download.ini";
+
+namespace Tizen { namespace Content
+{
+
+static const wchar_t CONTENT_DOWNLOAD_TEMP_DIRECTORY[] = L"/tmp/content/";
+static const wchar_t CONTENT_DOWNLOAD_TEMP_FILE_PATH[] = L"/tmp/content/downloadtempfile";
+static const wchar_t CONTENT_DOWNLOAD_PATH_MEDIA[] = L"/Media";
+static const wchar_t CONTENT_DOWNLOAD_PATH_MEDIA_MMC[] = L"/Storagecard/Media";
+static const wchar_t CONTENT_DOWNLOAD_PATH_HOME[] = L"/Home";
+static const wchar_t CONTENT_DOWNLOAD_PATH_HOME_MMC[] = L"/HomeExt";
+
+static const int CONTENT_TRANSFER_DEFAULT_PROGRESS_INTERVAL = 0;
+static const int CONTENT_DOWNLOAD_CHECKING_PERIOD = 1000;
+
+_ContentTransferImpl::_ContentTransferImpl(void)
+ : __requestId(INVALID_REQUEST_ID)
+ , __restRequestId(INVALID_REQUEST_ID)
+ , __maxDownloadCount(0)
+ , __timeout(0)
+ , __percent(CONTENT_TRANSFER_DEFAULT_PROGRESS_INTERVAL)
+ , __timerStarted(false)
+ , __isBuffer(false)
+ , __destFilePath(L"")
+ , __pContentDownloadUserData(null)
+ , __pContentDownloadUserDataSequence(null)
+ , __pContentDownloadHandler(null)
+ , __pContentDownloadHandlerSequence(null)
+ , __pTransferEvent(null)
+ , __pTransferInfoList(null)
+ , __pTimer(null)
+{
+
+}
+
+_ContentTransferImpl::~_ContentTransferImpl(void)
+{
+ initSlot = false;
+}
+
+_ContentTransferImpl*
+_ContentTransferImpl::GetInstance(ContentTransfer& contentTransfer)
+{
+ return contentTransfer.__pImpl;
+}
+
+const _ContentTransferImpl*
+_ContentTransferImpl::GetInstance(const ContentTransfer& contentTransfer)
+{
+ return contentTransfer.__pImpl;
+}
+
+result
+_ContentTransferImpl::Construct(IContentTransferListener& listener)
+{
+ // E_SUCCESS, E_OUT_OF_MEMORY, E_SYSTEM
+
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ __maxDownloadCount = GetMaxDownloadCount();
+ SysAssertf(__maxDownloadCount > 0, "The maximum download count is 0 or less than 0.");
+
+ std::unique_ptr<_ContentDownloadHandler> pContentDownloadHandler(new (std::nothrow) _ContentDownloadHandler);
+ SysTryReturn(NID_CNT, pContentDownloadHandler != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ContentDownloadHandler.");
+
+ r = pContentDownloadHandler->Construct();
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ContentDownloadHandler.");
+
+ std::unique_ptr<_ContentDownloadHandler[]> pContentDownloadHandlerSequence(new (std::nothrow) _ContentDownloadHandler[__maxDownloadCount]);
+ SysTryReturn(NID_CNT, pContentDownloadHandlerSequence != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ContentDownloadHandler array.");
+
+ for (int i = 0; i < __maxDownloadCount; i++)
+ {
+ r = (pContentDownloadHandlerSequence.get())[i].Construct();
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ContentDownloadHandler array.");
+ }
+
+ std::unique_ptr<_ContentDownloadUserData> pContentDownloadUserData(new (std::nothrow) _ContentDownloadUserData);
+ SysTryReturn(NID_CNT, pContentDownloadUserData != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ContentDownloadUserData.");
+
+ std::unique_ptr<_ContentDownloadUserData[]> pContentDownloadUserDataSequence(new (std::nothrow) _ContentDownloadUserData[__maxDownloadCount]);
+ SysTryReturn(NID_CNT, pContentDownloadUserDataSequence != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ContentDownloadUserData.");
+
+ std::unique_ptr<_ContentTransferEvent> pTransferEvent(new (std::nothrow) _ContentTransferEvent);
+ SysTryReturn(NID_CNT, pTransferEvent != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ContentTransferEvent.");
+
+ r = pTransferEvent->AddListener(listener, true);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to perform AddListener to ContentTransferEvent.");
+
+ std::unique_ptr<ArrayList, AllElementsDeleter> pTransferInfoList(new (std::nothrow) ArrayList());
+ SysTryReturn(NID_CNT, pTransferInfoList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ArrayList.");
+
+ r = pTransferInfoList->Construct();
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ArrayList.");
+
+ std::unique_ptr<Timer> pTimer(new (std::nothrow) Timer());
+ SysTryReturn(NID_CNT, pTimer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to construct Timer.");
+
+ r = pTimer->Construct(*this);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to construct Timer.", GetErrorMessage(r));
+
+ InitializeEmptySlotInternal(pContentDownloadUserData.get());
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to perform initiate the download slot.");
+
+ __pContentDownloadHandler = std::move(pContentDownloadHandler);
+ __pContentDownloadHandlerSequence = std::move(pContentDownloadHandlerSequence);
+
+ __pContentDownloadUserData = std::move(pContentDownloadUserData);
+ __pContentDownloadUserDataSequence = std::move(pContentDownloadUserDataSequence);
+
+ __pTransferEvent = std::move(pTransferEvent);
+
+ __pTransferInfoList = std::move(pTransferInfoList);
+
+ __pTimer = std::move(pTimer);
+
+ return r;
+}
+
+void
+_ContentTransferImpl::InitializeEmptySlotInternal(_ContentDownloadUserData* pUserData)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ bool check = false;
+ String tempPath(CONTENT_DOWNLOAD_TEMP_DIRECTORY);
+ int i = 0;
+
+ SysTryReturnVoidResult(NID_CNT, pUserData != null, r = E_SYSTEM,
+ "[E_SYSTEM] ContentDownloadUserData instance must not be null.");
+
+ pUserData->SetMaxCount(__maxDownloadCount);
+
+ if (!initSlot)
+ {
+ for (i = 0; i < __maxDownloadCount; i++)
+ {
+ pUserData->SetCheckDownloading(i, false);
+ }
+
+ // not exist
+ check = _FileImpl::IsFileExist(tempPath);
+ r = GetLastResult();
+ SysTryReturnVoidResult(NID_CNT, !IsFailed(r), r,
+ "[%s] Failed to perform IsFileExist operation for [%ls] path.", GetErrorMessage(r), tempPath.GetPointer());
+
+ if (!check)
+ {
+ r = Directory::Create(tempPath, false);
+ SysTryReturnVoidResult(NID_CNT, !IsFailed(r), r,
+ "[%s] Failed to perform Create operation for [%ls] path.", GetErrorMessage(r), tempPath.GetPointer());
+ }
+ initSlot = true;
+ }
+
+ return;
+}
+
+int
+_ContentTransferImpl::GetMaxDownloadCount(void) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ Registry reg;
+ String regPathName(CONTENT_DOWNLOAD);
+ String sect(L"DownloadCount");
+ String entry(L"Max");
+ int value = 0;
+
+ r = reg.Construct(regPathName, REG_OPEN_READ_ONLY, 0);
+ SysTryReturn(NID_CNT, !IsFailed(r), -1, r, "[%s] Failed to construct Registry.", GetErrorMessage(r));
+
+ r = reg.GetValue(sect, entry, value);
+ SysTryReturn(NID_CNT, !IsFailed(r), -1, r, "[%s] Failed to perform GetValue operation from ini file.", GetErrorMessage(r));
+
+ SysLog(NID_CNT, "Max download count is [%d].", value);
+
+ return value;
+}
+
+int
+_ContentTransferImpl::GetEmptySlotInternal(void) const
+{
+ int i = 0;
+ for (i = 0; i < __maxDownloadCount; i++)
+ {
+ if (!(__pContentDownloadUserData->GetCheckDownloading(i)))
+ {
+ return i;
+ }
+ }
+ return -1;
+}
+
+void
+_ContentTransferImpl::SetEmptySlotInternal(void)
+{
+ for (int i = 0; i < __maxDownloadCount; i++)
+ {
+ if (!((__pContentDownloadUserDataSequence.get())[i].GetSlotFlag()))
+ {
+ __pContentDownloadUserData->SetCheckDownloading(i, false);
+ }
+ }
+}
+
+void
+_ContentTransferImpl::SetUsedSlotInternal(int slot)
+{
+ // TODO : If the error is occured in this command, set the mutex.
+ if (slot >= 0 && slot < __maxDownloadCount)
+ {
+ __pContentDownloadUserData->SetCheckDownloading(slot, true);
+ (__pContentDownloadUserDataSequence.get())[slot].SetSlotFlag(true);
+ }
+}
+
+result
+_ContentTransferImpl::Cancel(RequestId reqId)
+{
+ // E_SUCCESS, E_OBJ_NOT_FOUND, E_INVALID_ARG, E_INVALID_STATE
+
+ SysLog(NID_CNT, "Cancel the request ID(%d) in download.", reqId);
+
+ ClearLastResult();
+ result r = E_SUCCESS;
+ String destFilePath = null;
+ ContentTransferInfo* pContentTransferInfo = null;
+ int slot = -1;
+
+ SysAssertf(__pContentDownloadHandler != null, "Not yet constructed. Construct() should be called before use.");
+
+ pContentTransferInfo = GetContentTransferInfoByRequestId(reqId);
+ SysTryReturn(NID_CNT, pContentTransferInfo != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+ "[E_OBJ_NOT_FOUND] Unable to find the current Download operation.");
+
+ if (pContentTransferInfo->GetContentTransferStatus() == CONTENT_TRANSFER_STATUS_DOWNLOADING)
+ {
+ slot = pContentTransferInfo->GetSlotId();
+ r = (__pContentDownloadHandlerSequence.get())[slot].Cancel(pContentTransferInfo->GetRestRequestId(),
+ &(__pContentDownloadUserDataSequence.get())[slot]);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Failed to perform Cancel operation.");
+ }
+ else
+ {
+ // TODO : check timing issue.
+ r = E_INVALID_STATE;
+ SysLogException(NID_CNT, E_INVALID_STATE, "[E_INVALID_STATE] This [%d] request isn't under download.", reqId);
+ }
+
+ return r;
+}
+
+void
+_ContentTransferImpl::SetDefaultTimeout(int sec)
+{
+ if (sec > 0)
+ {
+ __timeout = sec;
+ }
+ else
+ {
+ __timeout = 0;
+ }
+}
+
+int
+_ContentTransferImpl::GetDefaultTimeout(void) const
+{
+ return __timeout;
+}
+
+result
+_ContentTransferImpl::Remove(RequestId reqId)
+{
+ // E_SUCCESS, E_OBJ_NOT_FOUND, E_OUT_OF_MEMORY, E_INVALID_STATE
+
+ SysLog(NID_CNT, "Remove the download request ID(%d) in queue.", reqId);
+
+ ClearLastResult();
+ result r = E_SUCCESS;
+ ContentTransferInfo* pTransferInfo = null;
+ std::unique_ptr<IEnumerator> pEnum;
+ int idx = 0;
+ int findIdx = -1;
+
+ SysAssertf(__pTransferInfoList != null, "Not yet constructed. Construct() should be called before use.");
+
+ pEnum = std::unique_ptr<IEnumerator>(__pTransferInfoList->GetEnumeratorN());
+ SysTryReturn(NID_CNT, pEnum != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Remove operation can not perform for [%d] request ID.", reqId);
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pTransferInfo = dynamic_cast<ContentTransferInfo*>(pEnum->GetCurrent());
+ SysTryReturn(NID_CNT, pTransferInfo != null, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+ "[E_OBJ_NOT_FOUND] ContentTransferInfo instance must not be null.");
+
+ if (pTransferInfo->GetRequestId() == reqId)
+ {
+ ContentTransferStatus status = pTransferInfo->GetContentTransferStatus();
+ if (status == CONTENT_TRANSFER_STATUS_DOWNLOAD_READY ||
+ status == CONTENT_TRANSFER_STATUS_DOWNLOAD_COMPLETED)
+ {
+ findIdx = idx;
+ break;
+ }
+ else if (status == CONTENT_TRANSFER_STATUS_DOWNLOADING)
+ {
+ SysLogException(NID_CNT, E_INVALID_STATE, "[E_INVALID_STATE] This [%d] request operation is under download.", reqId);
+ return E_INVALID_STATE;
+ }
+ }
+ idx++;
+ }
+
+ if (findIdx == -1)
+ {
+ SysLogException(NID_CNT, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] [%d] request operation cannot found.", reqId);
+ return E_OBJ_NOT_FOUND;
+ }
+ else
+ {
+ __pTransferInfoList->RemoveAt(findIdx, true);
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND,
+ "[E_OBJ_NOT_FOUND] Failed to perform RemoveAt operation for a content in transfer info list.");
+ }
+
+ return r;
+}
+
+result
+_ContentTransferImpl::RemoveAll(void)
+{
+ // E_SUCCESS, E_OUT_OF_MEMORY, E_INVALID_STATE
+
+ SysLog(NID_CNT, "Remove all download request ID in queue.");
+
+ ClearLastResult();
+ result r = E_SUCCESS;
+ ContentTransferInfo* pTransferInfo = null;
+ std::unique_ptr<IEnumerator> pTransferEnum;
+ std::unique_ptr<IEnumerator> pDeleteEnum;
+ ArrayList deleteList;
+
+ SysAssertf(__pTransferInfoList != null, "Not yet constructed. Construct() should be called before use.");
+
+ pTransferEnum = std::unique_ptr<IEnumerator>(__pTransferInfoList->GetEnumeratorN());
+ SysTryReturn(NID_CNT, pTransferEnum != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform GetEnumeratorN operation.");
+
+ while (pTransferEnum->MoveNext() == E_SUCCESS)
+ {
+ pTransferInfo = dynamic_cast<ContentTransferInfo*>(pTransferEnum->GetCurrent());
+ SysTryReturn(NID_CNT, pTransferInfo != null, r = E_INVALID_STATE, r,
+ "[E_INVALID_STATE] ContentTransferInfo instance must not be null.");
+
+ ContentTransferStatus status = pTransferInfo->GetContentTransferStatus();
+ if (status == CONTENT_TRANSFER_STATUS_DOWNLOAD_READY || status == CONTENT_TRANSFER_STATUS_DOWNLOAD_COMPLETED)
+ {
+ deleteList.Add(*pTransferInfo);
+ }
+ }
+
+ pDeleteEnum = std::unique_ptr<IEnumerator>(deleteList.GetEnumeratorN());
+ SysTryReturn(NID_CNT, pDeleteEnum != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform GetEnumeratorN operation.");
+
+ while (pDeleteEnum->MoveNext() == E_SUCCESS)
+ {
+ pTransferInfo = dynamic_cast<ContentTransferInfo*>(pDeleteEnum->GetCurrent());
+ SysTryReturn(NID_CNT, pTransferInfo != null, r = E_INVALID_STATE, r,
+ "[E_INVALID_STATE] ContentTransferInfo instance must not be null.");
+
+ __pTransferInfoList->Remove(*pTransferInfo, true);
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_STATE, E_INVALID_STATE,
+ "[E_INVALID_STATE] Failed to perform Remove operation for a content in transfer info list.");
+ }
+
+ return r;
+}
+
+result
+_ContentTransferImpl::CancelAll(void)
+{
+ // E_SUCCESS, E_OUT_OF_MEMORY, E_INVALID_STATE
+
+ SysLog(NID_CNT, "Cancel the all request ID in download.");
+
+ ClearLastResult();
+ result r = E_SUCCESS;
+ std::unique_ptr<IEnumerator> pEnum;
+ ContentTransferInfo* pTransferInfo = null;
+
+ SysAssertf(__pTransferInfoList != null && __pContentDownloadUserDataSequence != null,
+ "Not yet constructed. Construct() should be called before use.");
+
+ pEnum = std::unique_ptr<IEnumerator>(__pTransferInfoList->GetEnumeratorN());
+ SysTryReturn(NID_CNT, pEnum != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform GetEnumeratorN operation.");
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pTransferInfo = dynamic_cast<ContentTransferInfo*>(pEnum->GetCurrent());
+ SysTryReturn(NID_CNT, pTransferInfo != null, r = E_INVALID_STATE, r,
+ "[E_INVALID_STATE] ContentTransferInfo instance must not be null.");
+
+ ContentTransferStatus status = pTransferInfo->GetContentTransferStatus();
+ if (status == CONTENT_TRANSFER_STATUS_DOWNLOADING)
+ {
+ SysLog(NID_CNT, "========== Canceled download slot : %d ==========", pTransferInfo->GetSlotId());
+
+ r = (__pContentDownloadHandlerSequence.get())[pTransferInfo->GetSlotId()].Cancel(
+ pTransferInfo->GetRestRequestId(), &(__pContentDownloadUserDataSequence.get())[pTransferInfo->GetSlotId()]);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_STATE, E_INVALID_STATE,
+ "[E_INVALID_STATE] Failed to perform Cancel operation.");
+ }
+ }
+
+ return r;
+}
+
+Collection::IList*
+_ContentTransferImpl::GetContentTransferInfoListN(void) const
+{
+ std::unique_ptr<ArrayList, AllElementsDeleter> pTransferInfoList;
+ std::unique_ptr<IEnumerator> pEnum;
+ ContentTransferInfo* pTransferInfoCopy = null;
+ ContentTransferInfo* pTransferInfo = null;
+
+ SysAssertf(__pTransferInfoList != null, "Not yet constructed. Construct() should be called before use.");
+
+ pTransferInfoList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
+ SysTryLogReturn(NID_CNT, pTransferInfoList != null, null, "Failed to construct ArrayList.");
+
+ pEnum = std::unique_ptr<IEnumerator>(__pTransferInfoList->GetEnumeratorN());
+ SysTryLogReturn(NID_CNT, pEnum != null, null, "Failed to perform GetEnumeratorN operation.");
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pTransferInfo = dynamic_cast<ContentTransferInfo*>(pEnum->GetCurrent());
+ SysTryLogReturn(NID_CNT, pTransferInfo != null, null, "ContentTransferInfo instance must not be null.");
+
+ pTransferInfoCopy = pTransferInfo->CopyN();
+
+ pTransferInfoList->Add(*pTransferInfoCopy);
+ }
+
+ return pTransferInfoList.release();
+}
+
+Collection::IList*
+_ContentTransferImpl::GetContentTransferInfoListInProgressN(void) const
+{
+ std::unique_ptr<ArrayList, AllElementsDeleter> pTransferInfoList;
+ std::unique_ptr<IEnumerator> pEnum;
+ ContentTransferInfo* pTransferInfoCopy = null;
+ ContentTransferInfo* pTransferInfo = null;
+
+ SysAssertf(__pTransferInfoList != null, "Not yet constructed. Construct() should be called before use.");
+
+ pTransferInfoList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
+ SysTryLogReturn(NID_CNT, pTransferInfoList != null, null, "Failed to construct ArrayList.");
+
+ pEnum = std::unique_ptr<IEnumerator>(__pTransferInfoList->GetEnumeratorN());
+ SysTryLogReturn(NID_CNT, pEnum != null, null, "Failed to perform GetEnumerator operation.");
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pTransferInfo = dynamic_cast<ContentTransferInfo*>(pEnum->GetCurrent());
+ SysTryLogReturn(NID_CNT, pTransferInfo != null, null, "ContentTransferInfo instance must not be null.");
+
+ ContentTransferStatus status = pTransferInfo->GetContentTransferStatus();
+ if (status == CONTENT_TRANSFER_STATUS_DOWNLOADING)
+ {
+ pTransferInfoCopy = pTransferInfo->CopyN();
+ pTransferInfoList->Add(*pTransferInfoCopy);
+ }
+ }
+
+ return pTransferInfoList.release();
+}
+
+void
+_ContentTransferImpl::SetProgressIntervalByPercent(int percent)
+{
+ if (percent > 0 && percent <= 100)
+ {
+ __percent = percent;
+ }
+ else
+ {
+ __percent = 0;
+ }
+}
+
+result
+_ContentTransferImpl::Download(const Utility::Uri& uri, int fileSize, const String& destFilePath, bool replace,
+ RequestId& requestID, IContentTransferListener* pListener, int sec)
+{
+ // E_SUCCESS, E_INVALID_ARG, E_INVALID_STATE, E_ILLEGAL_ACCESS, E_FILE_ALREADY_EXIST, E_PRIVILEGE_DENIED, E_IN_PROGRESS
+
+ SysLog(NID_CNT, "Download operation start with listener.");
+
+ ClearLastResult();
+ result r = E_SUCCESS;
+ String sourcePath(L"");
+ String destPath(L"");
+ String tempPath(L"");
+ String scheme(L"");
+ String checkName(L"");
+ String checkPath(L"");
+ int copySize = 0;
+ int maxSize = 1024;
+ int lengthString = 0;
+ FileAttributes fileAttr;
+
+ SysAssertf(__pContentDownloadHandler != null, "Not yet constructed. Construct() should be called before use.");
+
+ SysTryReturn(NID_CNT, fileSize >= 0, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The size of the source file is less than 0.");
+ SysTryReturn(NID_CNT, !destFilePath.IsEmpty(), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The destination file path is empty.");
+ SysTryReturn(NID_CNT, !uri.ToString().IsEmpty(), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The source URI is empty.");
+ SysTryReturn(NID_CNT, !uri.GetHost().IsEmpty() && !uri.GetPath().IsEmpty(), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The source URI is empty.");
+ SysTryReturn(NID_CNT, sec >= 0, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The timeout value is less than 0.");
+
+ destPath = destFilePath;
+
+ if (_FileImpl::IsSystemPath(destPath))
+ {
+ SysLogException(NID_CNT, E_ILLEGAL_ACCESS, "[E_ILLEGAL_ACCESS] [%ls] path isn't permitted.", destFilePath.GetPointer());
+
+ return E_ILLEGAL_ACCESS;
+ }
+
+ if (_FileImpl::IsFileExist(destPath))
+ {
+ if (replace != true)
+ {
+ SysLogException(NID_CNT, E_FILE_ALREADY_EXIST, "[E_FILE_ALREADY_EXIST] The download file is already exist.");
+
+ return E_FILE_ALREADY_EXIST;
+ }
+
+ SysTryReturn(NID_CNT, _FileImpl::IsMediaPath(destPath) == true || _FileImpl::IsAppPath(destPath) == true,
+ r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The file path is not a media or an app path.");
+
+ // read-only, directory or file
+ // check whether the destination file is read-only.
+ // check whether the destination path without the file extension is a directory or not.
+ r = _FileImpl::GetAttributes(destFilePath, fileAttr);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to perform GetAttributes operation for the destination path. ");
+ SysTryReturn(NID_CNT, !fileAttr.IsDirectory(), r = E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS,
+ "[E_ILLEGAL_ACCESS] The file path is directory.");
+ SysTryReturn(NID_CNT, !fileAttr.IsReadOnly(), r = E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS,
+ "[E_ILLEGAL_ACCESS] The file path is read only.");
+ }
+ else
+ {
+ // check the destination file path
+ // check the path
+ SysTryReturn(NID_CNT, _FileImpl::IsMediaPath(destPath) == true || _FileImpl::IsAppPath(destPath) == true,
+ r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The file path is not a media or an app path.");
+
+ // 1st: file name
+ // check whether the destination path includes the file name
+ checkName = _FileImpl::GetFileName(destPath);
+ SysTryReturn(NID_CNT, !checkName.IsEmpty(), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The file name is empty.");
+
+ // 2nd: parent directory
+ lengthString = destFilePath.String::GetLength();
+ r = destPath.String::LastIndexOf('/', lengthString - 1, copySize);
+ SysTryReturn(NID_CNT, copySize > 0 && copySize < maxSize, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The length of path is invalid size.");
+
+ // copy the parent path
+ r = destPath.SubString(0, copySize + 1, checkPath);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to perform SubString operation.");
+
+ // check the validation of the parent path
+ r = _FileImpl::GetAttributes(checkPath, fileAttr);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to perform GetAttributes operation.");
+ SysTryReturn(NID_CNT, fileAttr.IsDirectory(), r = E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS,
+ "[E_ILLEGAL_ACCESS] The path is not directory path.");
+ }
+
+ __destFilePath = destPath;
+ scheme = uri.GetScheme();
+
+ if (scheme.CompareTo(L"http") == 0 || scheme.CompareTo(L"https") == 0)
+ {
+ sourcePath = uri.GetEncodedString();
+
+ r = AddTransferItem(uri, destPath, sourcePath, fileSize, CONTENT_TRANSFER_STATUS_DOWNLOAD_READY,
+ pListener, sec, false, requestID);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to add a transfer item to queue.", GetErrorMessage(r));
+
+ // TODO : if timer is started, it doesn't need call it..
+ ContentTransferHandler();
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to handle the content transfer.", GetErrorMessage(r));
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] It is unsupported URI(%ls) address format.", uri.ToString().GetPointer());
+
+ return E_INVALID_ARG;
+ }
+
+ return r;
+}
+
+result
+_ContentTransferImpl::DownloadToBuffer(const Utility::Uri& uri, int fileSize, RequestId& reqId,
+ IContentTransferListener* pListener, int sec)
+{
+ // E_SUCCESS, E_INVALID_ARG, E_INVALID_STATE, E_PRIVILEGE_DENIED
+
+ SysLog(NID_CNT, "DownloadToBuffer operation start with listener.");
+
+ ClearLastResult();
+ result r = E_SUCCESS;
+ String tempFilePath(CONTENT_DOWNLOAD_TEMP_FILE_PATH);
+ String sourcePath(L"");
+ String scheme(L"");
+ long long ticks = 0;
+
+ SysAssertf(__pContentDownloadHandler != null, "Not yet constructed. Construct() should be called before use.");
+
+ SysTryReturn(NID_CNT, fileSize >= 0, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The size of the source file is less than 0.");
+ SysTryReturn(NID_CNT, !uri.ToString().IsEmpty(), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The source URI is empty.");
+ SysTryReturn(NID_CNT, !uri.GetHost().IsEmpty() && !uri.GetPath().IsEmpty(), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The source URI is empty.");
+ SysTryReturn(NID_CNT, sec >= 0, E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The timeout value is less than 0.");
+
+ scheme = uri.GetScheme();
+
+ if (scheme.CompareTo(L"http") == 0 || scheme.CompareTo(L"https") == 0)
+ {
+ r = _SystemTimeImpl::GetTicks(ticks);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_STATE, E_INVALID_STATE,
+ "[E_INVALID_STATE] Failed to perform GetTicks operation.");
+
+ r = tempFilePath.Append(ticks);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_STATE, E_INVALID_STATE,
+ "[E_INVALID_STATE] Failed to append long long type to temporary file path.");
+
+ r = tempFilePath.Append(downloadRequestId);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to append int type to temporary file path.");
+
+ sourcePath = uri.GetEncodedString();
+
+ r = AddTransferItem(uri, tempFilePath, sourcePath, fileSize,
+ CONTENT_TRANSFER_STATUS_DOWNLOAD_READY, pListener, sec, true, reqId);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to add a transfer item to queue.");
+
+ // TODO : if timer is started, it doesn't need call it..
+ __destFilePath = tempFilePath;
+ ContentTransferHandler();
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to handle the content transfer.", GetErrorMessage(r));
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] It is unsupported URI(%ls) address format.", uri.ToString().GetPointer());
+
+ return E_INVALID_ARG;
+ }
+
+ return r;
+}
+
+result
+_ContentTransferImpl::Download(const Utility::Uri& uri, const String& filePath,
+ RequestId& reqId, bool replace, int timeout, int progressInterval)
+{
+ // E_SUCCESS, E_PRIVILEGE_DENIED, E_INVALID_ARG, E_INVALID_STATE, E_ILLEGAL_ACCESS, E_FILE_ALREADY_EXIST, E_IN_PROGRESS, E_OUT_OF_MEMORY, E_SYSTEM
+
+ SysLog(NID_CNT, "Download operation start without listener.");
+
+ ClearLastResult();
+ result r = E_SUCCESS;
+ String srcFilePath(L"");
+ String scheme(L"");
+
+ SysAssertf(__pContentDownloadHandler != null, "Not yet constructed. Construct() should be called before use.");
+
+ SysTryReturn(NID_CNT, !filePath.IsEmpty(), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The destination file path is empty.");
+ SysTryReturn(NID_CNT, !uri.ToString().IsEmpty(), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The source URI is empty.");
+ SysTryReturn(NID_CNT, !uri.GetHost().IsEmpty() && !uri.GetPath().IsEmpty(), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The source URI is empty.");
+ SysTryReturn(NID_CNT, timeout >= 0, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The timeout value is less than 0.");
+ SysTryReturn(NID_CNT, progressInterval >= 0 && progressInterval <= 100, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The progress interval is less than 0.");
+
+ if (!_AppInfo::IsOspCompat())
+ {
+ if (filePath.StartsWith(CONTENT_DOWNLOAD_PATH_MEDIA, 0) || filePath.StartsWith(CONTENT_DOWNLOAD_PATH_MEDIA_MMC, 0) ||
+ filePath.StartsWith(CONTENT_DOWNLOAD_PATH_HOME, 0) || filePath.StartsWith(CONTENT_DOWNLOAD_PATH_HOME_MMC, 0))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] /Media/ , /Storagecard/Media/ , /Home/ , /HomeExt/ are not supported from Tizen 2.0.");
+
+ return E_INVALID_ARG;
+ }
+ if (!(filePath.StartsWith(Tizen::App::App::GetInstance()->GetAppRootPath(), 0) || filePath.StartsWith(Environment::GetMediaPath(), 0) ||
+ filePath.StartsWith(Environment::GetExternalStoragePath(), 0)))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] The [%ls] path is not supported.", filePath.GetPointer());
+
+ return E_INVALID_ARG;
+ }
+ }
+ else
+ {
+ // prior to 2.0
+ if (filePath.StartsWith(Tizen::App::App::GetInstance()->GetAppRootPath(), 0) || filePath.StartsWith(Environment::GetMediaPath(), 0) ||
+ filePath.StartsWith(Environment::GetExternalStoragePath(), 0))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] This [%ls] path can be used from Tizen 2.0.", filePath.GetPointer());
+
+ return E_INVALID_ARG;
+ }
+ if (!(filePath.StartsWith(CONTENT_DOWNLOAD_PATH_MEDIA, 0) || filePath.StartsWith(CONTENT_DOWNLOAD_PATH_MEDIA_MMC, 0) ||
+ filePath.StartsWith(CONTENT_DOWNLOAD_PATH_HOME, 0) || filePath.StartsWith(CONTENT_DOWNLOAD_PATH_HOME_MMC, 0)))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] The [%ls] is not supported.", filePath.GetPointer());
+
+ return E_INVALID_ARG;
+ }
+ }
+
+ __destFilePath = filePath;
+
+ r = CheckDestPath(__destFilePath, replace);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to perform CheckDestPath operation.", GetErrorMessage(r));
+
+ scheme = uri.GetScheme();
+
+ if (scheme.CompareTo(L"http") == 0 || scheme.CompareTo(L"https") == 0)
+ {
+ srcFilePath = uri.GetEncodedString();
+
+ r = AddTransferItem(uri, __destFilePath, srcFilePath, CONTENT_TRANSFER_STATUS_DOWNLOAD_READY,
+ timeout, progressInterval, false, reqId);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to add a transfer item to queue.", GetErrorMessage(r));
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] It is unsupported URI(%ls) address format.", uri.ToString().GetPointer());
+
+ return E_INVALID_ARG;
+ }
+
+ ContentTransferHandler();
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to handle the content transfer.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+_ContentTransferImpl::DownloadToBuffer(const Utility::Uri& uri, RequestId& reqId, int timeout, int progressInterval)
+{
+ // E_SUCCESS, E_PRIVILEGE_DENIED, E_INVALID_ARG, E_INVALID_STATE, E_ILLEGAL_ACCESS, E_IN_PROGRESS, E_OUT_OF_MEMORY
+
+ SysLog(NID_CNT, "DownloadToBuffer operation start without listener.");
+ ClearLastResult();
+ result r = E_SUCCESS;
+ String srcFilePath(L"");
+ String tempDestFilePath(CONTENT_DOWNLOAD_TEMP_FILE_PATH);
+ String scheme(L"");
+ long long ticks = 0;
+
+ SysAssertf(__pContentDownloadHandler != null, "Not yet constructed. Construct() should be called before use.");
+
+ SysTryReturn(NID_CNT, !uri.ToString().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The source URI is empty.");
+ SysTryReturn(NID_CNT, !uri.GetHost().IsEmpty() && !uri.GetPath().IsEmpty(), E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The source URI is empty.");
+ SysTryReturn(NID_CNT, timeout >= 0, E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The timeout value is less than 0.");
+ SysTryReturn(NID_CNT, progressInterval >= 0 && progressInterval <= 100, E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The progress interval is less than 0.");
+
+ scheme = uri.GetScheme();
+ if (scheme.CompareTo(L"http") == 0 || scheme.CompareTo(L"https") == 0)
+ {
+ r = _SystemTimeImpl::GetTicks(ticks);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to perform GetTicks operation.", GetErrorMessage(r));
+
+ r = tempDestFilePath.Append(ticks);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to append long long type to temporary file path.", GetErrorMessage(r));
+
+ r = tempDestFilePath.Append(downloadRequestId);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to append int type to temporary file path.", GetErrorMessage(r));
+
+ srcFilePath = uri.GetEncodedString();
+
+ r = AddTransferItem(uri, tempDestFilePath, srcFilePath, CONTENT_TRANSFER_STATUS_DOWNLOAD_READY,
+ timeout, progressInterval, true, reqId);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to add a transfer item to queue.", GetErrorMessage(r));
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG,
+ "[E_INVALID_ARG] It is unsupported URI(%ls) address format.", uri.ToString().GetPointer());
+
+ return E_INVALID_ARG;
+ }
+
+ ContentTransferHandler();
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to handle the content transfer.", GetErrorMessage(r));
+
+ return r;
+}
+
+void
+_ContentTransferImpl::OnTimerExpired(Runtime::Timer& timer)
+{
+ ClearLastResult();
+ bool check = false;
+ check = ContentTransferHandler();
+
+ SysAssertf(__pTimer != null, "Not yet constructed. Construct() should be called before use.");
+
+ if (check == true)
+ {
+ __pTimer->Start(CONTENT_DOWNLOAD_CHECKING_PERIOD);
+ __timerStarted = true;
+ }
+ else
+ {
+ __timerStarted = false;
+ }
+}
+
+RequestId
+_ContentTransferImpl::GetRequestId(void) const
+{
+ return ++downloadRequestId;
+}
+
+ContentTransferInfo*
+_ContentTransferImpl::GetContentTransferInfoByRequestId(RequestId requestId) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ std::unique_ptr<IEnumerator> pEnum;
+ ContentTransferInfo* pTransferInfo = null;
+
+ pEnum = std::unique_ptr<IEnumerator>(__pTransferInfoList->GetEnumeratorN());
+
+ if (pEnum == null)
+ {
+ r = GetLastResult();
+ SysLogException(NID_CNT, r, "[%s] Failed to perform GetEnumeratorN operation.", GetErrorMessage(r));
+ return null;
+ }
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pTransferInfo = dynamic_cast<ContentTransferInfo*>(pEnum->GetCurrent());
+ SysTryReturn(NID_CNT, pTransferInfo != null, null, E_INVALID_ARG,
+ "[E_INVALID_ARG] ContentTransferInfo instance must not be null.");
+
+ if (pTransferInfo->GetRequestId() == requestId)
+ {
+ break;
+ }
+ pTransferInfo = null;
+ }
+
+ return pTransferInfo;
+}
+
+void
+_ContentTransferImpl::StartTimer(void)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ if (!(__timerStarted))
+ {
+ r = __pTimer->Start(CONTENT_DOWNLOAD_CHECKING_PERIOD);
+ SysTryReturnVoidResult(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, "[E_INVALID_ARG] Failed to start timer.");
+
+ __timerStarted = true;
+ }
+}
+
+result
+_ContentTransferImpl::GetEmptySlot(int& slot) const
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+
+ slot = GetEmptySlotInternal();
+
+ if (slot < 0 || slot > __maxDownloadCount)
+ {
+ r = E_OBJ_NOT_FOUND;
+ SysLog(NID_CNT, "Failed to get empty slot for download.");
+ }
+
+ return r;
+}
+
+result
+_ContentTransferImpl::CheckDestPath(const String& destPath, bool replace)
+{
+ result r = E_SUCCESS;
+ String destFilePath(L"");
+ String checkName(L"");
+ String checkPath(L"");
+ FileAttributes fileAttr;
+ int copySize = 0;
+ int maxSize = 1024;
+ int lengthString = 0;
+ Directory dir;
+
+ destFilePath = destPath;
+ SysTryReturn(NID_CNT, !destFilePath.IsEmpty(), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] The destination file path is empty.");
+
+ if (!_AppInfo::IsOspCompat())
+ {
+ if (!(destFilePath.String::StartsWith(Environment::GetMediaPath(), 0) ||
+ destFilePath.String::StartsWith(Environment::GetExternalStoragePath(), 0) ||
+ destFilePath.String::StartsWith(Tizen::App::App::GetInstance()->GetAppRootPath(), 0)))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] The destination path is not allowed path.");
+ return E_INVALID_ARG;
+ }
+ }
+ else
+ {
+ // the allowed destination path
+ // /Media, /Storagecard/Media
+ // /Home, /HomeExt
+ if (!(destFilePath.String::StartsWith(CONTENT_DOWNLOAD_PATH_MEDIA, 0) ||
+ destFilePath.String::StartsWith(CONTENT_DOWNLOAD_PATH_MEDIA_MMC, 0) ||
+ destFilePath.String::StartsWith(CONTENT_DOWNLOAD_PATH_HOME, 0) ||
+ destFilePath.String::StartsWith(CONTENT_DOWNLOAD_PATH_HOME_MMC, 0)))
+ {
+ SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] The destination path is not allowed path.");
+ return E_INVALID_ARG;
+ }
+ }
+
+ //check overwrite
+ if (_FileImpl::IsFileExist(destFilePath) == true)
+ {
+ // not allowed overwrite
+ if (replace != true)
+ {
+ SysLogException(NID_CNT, E_FILE_ALREADY_EXIST, "[E_FILE_ALREADY_EXIST] The file already exists in destination path.");
+ return E_FILE_ALREADY_EXIST;
+ }
+
+ // allowed overwrite
+ r = _FileImpl::GetAttributes(destFilePath, fileAttr);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to perform GetAttributes operation. ");
+ SysTryReturn(NID_CNT, !(fileAttr.IsDirectory()), r = E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS,
+ "[E_ILLEGAL_ACCESS] The file path is directory path.");
+ SysTryReturn(NID_CNT, !(fileAttr.IsReadOnly()), r = E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS,
+ "[E_ILLEGAL_ACCESS] The file can only read.");
+ }
+ else
+ {
+
+ if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
+ {
+ // check the destination file path
+ // check the path
+ SysTryReturn(NID_CNT, _FileImpl::IsMediaPath(destFilePath) == true || _FileImpl::IsAppPath(destFilePath) == true,
+ r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The file path is not a media or an app path.");
+ }
+
+ // 1st: file name
+ // check whether the destination path includes the file name
+ checkName = _FileImpl::GetFileName(destFilePath);
+ SysTryReturn(NID_CNT, !checkName.IsEmpty(), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to get the file name from a path.");
+
+ // 2nd: parent directory
+ lengthString = destFilePath.String::GetLength();
+ r = destFilePath.String::LastIndexOf('/', lengthString - 1, copySize);
+ SysTryReturn(NID_CNT, copySize > 0 && copySize < maxSize, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to get the size of path.");
+
+ // copy the parent path
+ r = destFilePath.SubString(0, copySize + 1, checkPath);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to perform SubString operation.");
+
+ if (!_AppInfo::IsOspCompat())
+ {
+ SysTryReturn(NID_CNT, destFilePath.String::StartsWith(Environment::GetMediaPath(), 0) ||
+ destFilePath.String::StartsWith(Environment::GetExternalStoragePath(), 0) ||
+ _FileImpl::IsAppPath(destFilePath) == true,
+ r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The path is invalid media path.");
+
+ if (!(_FileImpl::IsFileExist(checkPath)))
+ {
+ r = dir.Create(checkPath);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to create the directory.");
+ }
+ }
+
+ // check the validation of the parent path
+ r = _FileImpl::GetAttributes(checkPath, fileAttr);
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to perform GetAttributes operation.");
+ SysTryReturn(NID_CNT, fileAttr.IsDirectory() == true, r = E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS,
+ "[E_ILLEGAL_ACCESS] The path is not a directory path.");
+ }
+
+ return r;
+}
+
+result
+_ContentTransferImpl::CheckDownloadStatus(const Uri& uri, const String& destPath)
+{
+ ClearLastResult();
+ std::unique_ptr<IEnumerator> pEnum;
+ ContentTransferInfo* pTransferInfoTemp = null;
+ ContentTransferStatus statusTemp = CONTENT_TRANSFER_STATUS_NONE;
+ result r = E_SUCCESS;
+
+ pEnum = std::unique_ptr<IEnumerator>(__pTransferInfoList->GetEnumeratorN());
+ SysTryReturn(NID_CNT, pEnum != null, r = E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS,
+ "[%s] Failed to perform GetEnumeratorN operation.", GetErrorMessage(r));
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pTransferInfoTemp = dynamic_cast<ContentTransferInfo*>(pEnum->GetCurrent());
+ SysTryReturn(NID_CNT, pTransferInfoTemp != null, r = E_INVALID_STATE, E_INVALID_STATE,
+ "[E_INVALID_STATE] ContentTransferInfo instance must not be null.");
+
+ statusTemp = pTransferInfoTemp->GetContentTransferStatus();
+
+ if (statusTemp == CONTENT_TRANSFER_STATUS_DOWNLOAD_READY ||
+ statusTemp == CONTENT_TRANSFER_STATUS_DOWNLOADING)
+ {
+ if (destPath.CompareTo(pTransferInfoTemp->GetDestPath()) == 0)
+ {
+ if (uri.CompareTo(pTransferInfoTemp->GetUri()) == 0)
+ {
+ SysLogException(NID_CNT, E_IN_PROGRESS, "[E_IN_PROGRESS] Transfer is in progress.");
+ return E_IN_PROGRESS;
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_ILLEGAL_ACCESS, "[E_ILLEGAL_ACCESS] Access to source is illegal access.");
+ return E_ILLEGAL_ACCESS;
+ }
+ }
+ }
+ }
+
+ return r;
+}
+
+result
+_ContentTransferImpl::AddTransferItem(const Uri& uri, const String& destPath, const String& sourcePath, int sourceFileSize,
+ ContentTransferStatus status, IContentTransferListener* pListener, int sec, bool isBuffer, RequestId& requestId)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ std::unique_ptr<IEnumerator> pEnum;
+ std::unique_ptr<ContentTransferInfo> pTransferInfo;
+ ContentTransferInfo* pTransferInfoTemp = null;
+ ContentTransferStatus statusTemp = CONTENT_TRANSFER_STATUS_NONE;
+ requestId = INVALID_REQUEST_ID;
+
+ SysAssertf(__pTransferInfoList != null, "Not yet constructed. Construct() should be called before use.");
+
+ pEnum = std::unique_ptr<IEnumerator>(__pTransferInfoList->GetEnumeratorN());
+ SysTryReturn(NID_CNT, pEnum != null, r = E_ILLEGAL_ACCESS, E_ILLEGAL_ACCESS,
+ "[E_ILLEGAL_ACCESS] Failed to perform GetEnumeratorN operation.");
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pTransferInfoTemp = dynamic_cast<ContentTransferInfo*>(pEnum->GetCurrent());
+ SysTryReturn(NID_CNT, pTransferInfoTemp != null, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] ContentTransferInfo instance must not be null.");
+
+ statusTemp = pTransferInfoTemp->GetContentTransferStatus();
+
+ if (statusTemp == CONTENT_TRANSFER_STATUS_DOWNLOAD_READY || statusTemp == CONTENT_TRANSFER_STATUS_DOWNLOADING)
+ {
+ if (destPath.CompareTo(pTransferInfoTemp->GetDestPath()) == 0)
+ {
+ if (uri.CompareTo(pTransferInfoTemp->GetUri()) == 0)
+ {
+ SysLogException(NID_CNT, E_IN_PROGRESS, "[E_IN_PROGRESS] The request is already in progress.");
+ return E_IN_PROGRESS;
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_ILLEGAL_ACCESS,
+ "[E_ILLEGAL_ACCESS] The destination path [%ls] is already in progress.", destPath.GetPointer());
+ return E_ILLEGAL_ACCESS;
+ }
+ }
+ }
+ }
+
+ pTransferInfo = std::unique_ptr<ContentTransferInfo>(new (std::nothrow) ContentTransferInfo);
+ SysTryReturn(NID_CNT, pTransferInfo != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ContentTransferInfo.");
+
+ requestId = GetRequestId();
+
+ pTransferInfo->SetAllInfo(requestId, uri, destPath, sourcePath, sourceFileSize, status);
+
+ if (pListener)
+ {
+ pTransferInfo->SetListener(pListener);
+ }
+
+ if (sec > 0)
+ {
+ __timeout = sec;
+ pTransferInfo->SetTimeout(sec);
+ }
+ else
+ {
+ __timeout = 0;
+ pTransferInfo->SetTimeout(0);
+ }
+
+ if (__percent > 0 && __percent <= 100)
+ {
+ pTransferInfo->SetProgressInterval(__percent);
+ }
+ else
+ {
+ pTransferInfo->SetProgressInterval(0);
+ }
+
+ if (isBuffer == true)
+ {
+ __isBuffer = isBuffer;
+ pTransferInfo->SetIsBuffer(true);
+ }
+
+ r = __pTransferInfoList->Add(*(pTransferInfo.release()));
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Failed to add item to info list.");
+
+ return r;
+}
+
+result
+_ContentTransferImpl::AddTransferItem(const Uri& uri, const String& destPath, const String& sourcePath,
+ ContentTransferStatus status, int timeout, int interval, bool isBuffer, RequestId& requestId)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ std::unique_ptr<ContentTransferInfo> pTransferInfo;
+ requestId = INVALID_REQUEST_ID;
+
+ r = CheckDownloadStatus(uri, destPath);
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to perform CheckDownloadStatus operation.", GetErrorMessage(r));
+
+ // pTransferInfo will be deallocated in the Response routine
+ pTransferInfo = std::unique_ptr<ContentTransferInfo>(new (std::nothrow) ContentTransferInfo);
+ SysTryReturn(NID_CNT, pTransferInfo != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[%s] Failed to construct ContentTransferInfo.", GetErrorMessage(r));
+
+ requestId = GetRequestId();
+
+ pTransferInfo->SetAllInfo(requestId, uri, destPath, sourcePath, 0, status);
+
+ if (timeout > 0)
+ {
+ __timeout = timeout;
+ pTransferInfo->SetTimeout(timeout);
+ }
+ else
+ {
+ __timeout = 0;
+ pTransferInfo->SetTimeout(0);
+ }
+
+ if (interval > 0 && interval <= 100)
+ {
+ __percent = interval;
+ pTransferInfo->SetProgressInterval(interval);
+ }
+ else
+ {
+ __percent = 0;
+ pTransferInfo->SetProgressInterval(0);
+ }
+
+ if (isBuffer == true)
+ {
+ __isBuffer = isBuffer;
+ pTransferInfo->SetIsBuffer(true);
+ }
+
+ r = __pTransferInfoList->Add(*(pTransferInfo.release()));
+ SysTryReturn(NID_CNT, !IsFailed(r), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Failed to add item to info list.");
+
+ return r;
+}
+
+result
+_ContentTransferImpl::SetDownloadSlotInfo(ContentTransferInfo* pTransferInfo, int& slot)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ String destPath(L"");
+
+ SysAssertf(__pContentDownloadHandler != null, "Not yet constructed. Construct() should be called before use.");
+
+ SysTryReturn(NID_CNT, pTransferInfo != null, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] ContentTransferInfo instance must not be null.");
+
+ destPath = pTransferInfo->GetDestPath();
+
+ r = GetEmptySlot(slot);
+ SysLog(NID_CNT, "Set the download slot [%d].", slot);
+ SysTryReturn(NID_CNT, !IsFailed(r) && slot != -1, r = E_INVALID_ARG, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to get the empty slot.");
+
+ SetUsedSlotInternal(slot);
+
+ (__pContentDownloadHandlerSequence.get())[slot].SetSlot(slot);
+ (__pContentDownloadHandlerSequence.get())[slot].SetRequestId(pTransferInfo->GetRequestId());
+ (__pContentDownloadHandlerSequence.get())[slot].SetTimeout(pTransferInfo->GetTimeout());
+ (__pContentDownloadHandlerSequence.get())[slot].SetProgressIntervalByPercent(pTransferInfo->GetProgressInterval());
+ (__pContentDownloadHandlerSequence.get())[slot].SetDownloadPath(destPath);
+
+ (__pContentDownloadUserDataSequence.get())[slot].SetSlot(slot);
+ (__pContentDownloadUserDataSequence.get())[slot].SetContentTransferInfo(pTransferInfo);
+ (__pContentDownloadUserDataSequence.get())[slot].SetRequestId(pTransferInfo->GetRequestId());
+ (__pContentDownloadUserDataSequence.get())[slot].SetPercent(pTransferInfo->GetProgressInterval());
+ (__pContentDownloadUserDataSequence.get())[slot].SetContentTransferEvent(__pTransferEvent.get());
+ (__pContentDownloadUserDataSequence.get())[slot].SetDestPath(destPath);
+
+ if (__isBuffer == true)
+ {
+ (__pContentDownloadUserDataSequence.get())[slot].SetDownloadBufferFlag(true);
+ }
+
+ pTransferInfo->SetSlotId(slot);
+
+ return r;
+}
+
+result
+_ContentTransferImpl::RequestErrorEvent(result requestErrorCode, ContentTransferInfo* pTransferInfo)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ std::unique_ptr<_ContentTransferEventArg> pTransferEventArg;
+
+ pTransferEventArg = std::unique_ptr<_ContentTransferEventArg>(new (std::nothrow) _ContentTransferEventArg);
+ SysTryReturn(NID_CNT, pTransferEventArg != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ContentTransferEventArg.");
+
+ pTransferEventArg->SetResult(requestErrorCode);
+
+ if (pTransferInfo->GetIsBuffer() == true)
+ {
+ pTransferEventArg->SetEventType(Content::CONTENT_TRANSFER_EVENT_DOWNLOAD_TO_BUFFER_COMPLETED);
+
+ }
+ else
+ {
+ pTransferEventArg->SetEventType(Content::CONTENT_TRANSFER_EVENT_DOWNLOAD_COMPLETED);
+ }
+
+ pTransferEventArg->SetRequestId(pTransferInfo->GetRequestId());
+
+ r = __pTransferEvent->Fire(*(pTransferEventArg.release()));
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to perform fire operation on ContentTransferEvent.", GetErrorMessage(r));
+
+ pTransferInfo->SetDownloadStatus(CONTENT_TRANSFER_STATUS_DOWNLOAD_COMPLETED);
+
+ return r;
+}
+
+result
+_ContentTransferImpl::RemoveCompletedTransferInfo(ArrayList* pTransferInfoList)
+{
+ ClearLastResult();
+ std::unique_ptr<IEnumerator> pEnum;
+ ContentTransferInfo* pTransferInfo = null;
+ result r = E_SUCCESS;
+
+ if (pTransferInfoList == null)
+ {
+ return r;
+ }
+
+ pEnum = std::unique_ptr<IEnumerator>(pTransferInfoList->GetEnumeratorN());
+ SysTryReturn(NID_CNT, pEnum != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to perform GetEnumeratorN operation.");
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pTransferInfo = dynamic_cast<ContentTransferInfo*>(pEnum->GetCurrent());
+ SysTryReturn(NID_CNT, pTransferInfo != null, r = E_INVALID_ARG, r,
+ "[E_INVALID_ARG] ContentTransferInfo instance must not be null.");
+
+ __pTransferInfoList->Remove(*pTransferInfo, true);
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] Failed to remove a item from transfer info list.", GetErrorMessage(r));
+ }
+
+ return r;
+}
+
+bool
+_ContentTransferImpl::ContentTransferHandler(void)
+{
+ ClearLastResult();
+ result r = E_SUCCESS;
+ std::unique_ptr<IEnumerator> pEnum;
+ std::unique_ptr<ArrayList> pDeleteList;
+ ContentTransferInfo* pTransferInfo = null;
+ ContentTransferStatus status = CONTENT_TRANSFER_STATUS_NONE;
+ int downloadCount = 0;
+ RequestId restRequestId = INVALID_REQUEST_ID;
+ bool full = false;
+ int idx = 0;
+ bool check = false;
+ int slot = 0;
+ String destPath(L"");
+ String sourcePath(L"");
+
+ pEnum = std::unique_ptr<IEnumerator>(__pTransferInfoList->GetEnumeratorN());
+ if (pEnum == null)
+ {
+ return false;
+ }
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pTransferInfo = dynamic_cast<ContentTransferInfo*>(pEnum->GetCurrent());
+ SysTryReturn(NID_CNT, pTransferInfo != null, check, E_INVALID_ARG,
+ "[E_INVALID_ARG] ContentTransferInfo instance must not be null.");
+
+ status = pTransferInfo->GetContentTransferStatus();
+
+ if (status == CONTENT_TRANSFER_STATUS_DOWNLOADING)
+ {
+ downloadCount++;
+ if (downloadCount == __maxDownloadCount)
+ {
+ full = true;
+ continue;
+ }
+ else
+ {
+ continue;
+ }
+ }
+ else if (status == CONTENT_TRANSFER_STATUS_DOWNLOAD_READY)
+ {
+ if (full == true)
+ {
+ StartTimer();
+ r = GetLastResult();
+ SysTryReturn(NID_CNT, !IsFailed(r), check, r, "[%s] Failed to perform StartTimer operation.", GetErrorMessage(r));
+
+ check = true;
+ break;
+ }
+
+ // get empty buffer slot from download buffer
+ // set slot information
+ r = SetDownloadSlotInfo(pTransferInfo, slot);
+ if (slot < 0)
+ {
+ SysLogException(NID_CNT, r, "[%s] Failed to find an empty slot.", GetErrorMessage(r));
+ check = true;
+ break;
+ }
+
+ if (IsFailed(r))
+ {
+ SysLogException(NID_CNT, r, "[%s] Propagating.", GetErrorMessage(r));
+ break;
+ }
+
+ destPath = pTransferInfo->GetDestPath();
+ sourcePath = pTransferInfo->GetUri().ToString();
+ (__pContentDownloadHandlerSequence.get())[slot].SetSlot(slot);
+
+ // request download
+ restRequestId = (__pContentDownloadHandlerSequence.get())[slot].HttpDownload(sourcePath,
+ pTransferInfo->GetSourceFileSize(), destPath, &(__pContentDownloadUserDataSequence.get())[slot]);
+ r = GetLastResult();
+ SysTryLog(NID_CNT, restRequestId != INVALID_REQUEST_ID,
+ "[%s] The rest request ID is invalid.", GetErrorMessage(r));
+
+ if (IsFailed(r))
+ {
+ r = RequestErrorEvent(r, pTransferInfo);
+ SysTryReturn(NID_CNT, !IsFailed(r), check, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to perform RequestErrorEvent operation.");
+
+ (__pContentDownloadUserDataSequence.get())[slot].SetSlotFlag(false);
+
+ continue;
+ }
+
+ sourcePath = null;
+ destPath = null;
+
+ pTransferInfo->SetRestRequestId(restRequestId);
+ pTransferInfo->SetDownloadStatus(CONTENT_TRANSFER_STATUS_DOWNLOADING);
+ downloadCount++;
+
+ if (downloadCount == __maxDownloadCount)
+ {
+ full = true;
+ }
+ else
+ {
+ continue;
+ }
+ }
+ else if (status == CONTENT_TRANSFER_STATUS_DOWNLOAD_COMPLETED)
+ {
+ SetEmptySlotInternal();
+
+ // TODO : should i check to sync
+ if (pDeleteList == null)
+ {
+ pDeleteList = std::unique_ptr<ArrayList>(new (std::nothrow) ArrayList());
+ SysTryReturn(NID_CNT, !IsFailed(r), check, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] Failed to construct ArrayList.");
+ }
+ pDeleteList->Add(*pTransferInfo);
+ }
+ idx++;
+ }
+
+ r = RemoveCompletedTransferInfo(pDeleteList.get());
+ SysTryReturn(NID_CNT, !IsFailed(r), check, E_INVALID_ARG,
+ "[E_INVALID_ARG] Failed to remove the completed transfer info.");
+
+ return check;
+}
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentUtility.cpp
+ * @brief This is the implementation file for the %_ContentUtility class.
+ *
+ * This file contains implementation of the %_ContentUtility class.
+ */
+
+// includes
+
+#include <unique_ptr.h>
+#include <FBaseSysLog.h>
+#include <FBaseInteger.h>
+#include <FBaseLongLong.h>
+#include <FBaseFloat.h>
+#include <FCnt_ContentUtility.h>
+
+// using namespace
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Content
+{
+
+static const double DEFAULT_COORDINATE = -200.0;
+
+// Default constructor
+_ContentUtility::_ContentUtility(void)
+ : Object()
+{
+ SysLog(NID_CNT, "Enter\n");
+}
+
+
+// Default destructor
+_ContentUtility::~_ContentUtility(void)
+{
+ SysLog(NID_CNT, "Enter\n");
+}
+
+void
+_ContentUtility::DoSafeFree(char* pSrc)
+{
+ if (pSrc != NULL)
+ {
+ free(pSrc);
+ pSrc = NULL;
+ }
+}
+
+void
+_ContentUtility::DoSafeDelete(String* pSrc)
+{
+ if (pSrc != NULL)
+ {
+ delete pSrc;
+ pSrc = NULL;
+ }
+}
+
+// fills contentinfo information in the content data object.
+result
+_ContentUtility::FillContentData(media_info_h mediaHandle, ContentInfo::_ContentData* pContentData)
+{
+
+ SysTryReturnResult(NID_CNT, mediaHandle != null && pContentData != null, E_INVALID_ARG, "mediaHandle or pContentData is null.");
+
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ result r = E_SUCCESS;
+
+ std::unique_ptr<char, UtilCharDeleter> pMediaId;
+ std::unique_ptr<char, UtilCharDeleter> pContentName;
+ std::unique_ptr<char, UtilCharDeleter> pMediaPath;
+ std::unique_ptr<char, UtilCharDeleter> pThumbnailPath;
+ std::unique_ptr<char, UtilCharDeleter> pAuthor;
+ std::unique_ptr<char, UtilCharDeleter> pCategory;
+ std::unique_ptr<char, UtilCharDeleter> pDescription;
+ std::unique_ptr<char, UtilCharDeleter> pLocationTag;
+ std::unique_ptr<char, UtilCharDeleter> pProvider;
+ std::unique_ptr<char, UtilCharDeleter> pKeyword;
+ std::unique_ptr<char, UtilCharDeleter> pContentRating;
+
+ media_content_type_e mediaType;
+ media_content_storage_e storageType;
+
+ unsigned long long contentSize = 0;
+ time_t addedTime = 0;
+ double latitude = 0;
+ double longitude = 0;
+ double altitude = 0;
+
+ char* pGetMediaValue = null;
+ ret = media_info_get_media_id(mediaHandle, &pGetMediaValue);
+ if (pGetMediaValue != null)
+ {
+ pMediaId.reset(pGetMediaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_media_id operation.");
+ }
+
+ ret = media_info_get_content_name(mediaHandle, &pGetMediaValue);
+ if (pGetMediaValue != null)
+ {
+ pContentName.reset(pGetMediaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_content_name operation.");
+ }
+
+ ret = media_info_get_file_path(mediaHandle, &pGetMediaValue);
+ if (pGetMediaValue != null)
+ {
+ pMediaPath.reset(pGetMediaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_file_path operation.");
+ }
+
+ ret = media_info_get_thumbnail_path(mediaHandle, &pGetMediaValue);
+ if (pGetMediaValue != null)
+ {
+ pThumbnailPath.reset(pGetMediaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_thumbnail_path operation.");
+ }
+
+ ret = media_info_get_author(mediaHandle, &pGetMediaValue);
+ if (pGetMediaValue != null)
+ {
+ pAuthor.reset(pGetMediaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_author operation.");
+ }
+
+ ret = media_info_get_category(mediaHandle, &pGetMediaValue);
+ if (pGetMediaValue != null)
+ {
+ pCategory.reset(pGetMediaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_category operation.");
+ }
+
+ ret = media_info_get_description(mediaHandle, &pGetMediaValue);
+ if (pGetMediaValue != null)
+ {
+ pDescription.reset(pGetMediaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_description operation.");
+ }
+
+ ret = media_info_get_location_tag(mediaHandle, &pGetMediaValue);
+ if (pGetMediaValue != null)
+ {
+ pLocationTag.reset(pGetMediaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_location_tag operation.");
+ }
+
+ ret = media_info_get_provider(mediaHandle, &pGetMediaValue);
+ if (pGetMediaValue != null)
+ {
+ pProvider.reset(pGetMediaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_provider operation.");
+ }
+
+ ret = media_info_get_size(mediaHandle, &contentSize);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_size operation.");
+
+
+ ret = media_info_get_latitude(mediaHandle, &latitude);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_latitude operation.");
+
+ ret = media_info_get_longitude(mediaHandle, &longitude);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_longitude operation.");
+
+ ret = media_info_get_altitude(mediaHandle, &altitude);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_altitude operation.");
+
+ ret = media_info_get_age_rating(mediaHandle, &pGetMediaValue);
+ if (pGetMediaValue != null)
+ {
+ pContentRating.reset(pGetMediaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_age_rating operation.");
+ }
+
+ ret = media_info_get_added_time(mediaHandle, &addedTime);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_added_time operation.");
+
+ ret = media_info_get_storage_type(mediaHandle, &storageType);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_storage_type operation.");
+
+ 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_keyword(mediaHandle, &pGetMediaValue);
+ if (pGetMediaValue != null)
+ {
+ pKeyword.reset(pGetMediaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_keyword operation.");
+ }
+
+ if (pMediaId.get() != null)
+ {
+ r = UuId::Parse(String(pMediaId.get()), pContentData->contentId);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform UuId::Parse operation.");
+ }
+
+ pContentData->contentSize = contentSize;
+ SysLog(NID_CNT, "pContentData->contentSize = %lu", pContentData->contentSize);
+
+ if (Double::Compare(latitude, DEFAULT_COORDINATE) != 0)
+ {
+ pContentData->latitude = latitude;
+ }
+ if (Double::Compare(longitude, DEFAULT_COORDINATE) != 0)
+ {
+ pContentData->longitude = longitude;
+ }
+ if (Double::Compare(altitude, DEFAULT_COORDINATE) != 0)
+ {
+ pContentData->altitude = altitude;
+ }
+
+ if (pMediaPath.get() != NULL)
+ {
+ pContentData->contentPath = String(pMediaPath.get());
+ SysLog(NID_CNT, "pContentData->contentPath = %ls", pContentData->contentPath.GetPointer());
+ }
+
+ if (pThumbnailPath.get() != NULL)
+ {
+ pContentData->pThumbnailPath = new (std::nothrow) String(pThumbnailPath.get());
+ SysTryReturnResult(NID_CNT, pContentData->pThumbnailPath != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pContentData->pThumbnailPath = %ls", pContentData->pThumbnailPath->GetPointer());
+ }
+
+ if (pAuthor.get() != NULL)
+ {
+ pContentData->pAuthor = new (std::nothrow) String(pAuthor.get());
+ SysTryReturnResult(NID_CNT, pContentData->pAuthor != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pContentData->pAuthor = %ls", pContentData->pAuthor->GetPointer());
+ }
+
+ if (pCategory.get() != NULL)
+ {
+ pContentData->pCategory = new (std::nothrow) String(pCategory.get());
+ SysTryReturnResult(NID_CNT, pContentData->pCategory != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pContentData->pCategory = %ls", pContentData->pCategory->GetPointer());
+ }
+
+ if (pContentName.get() != NULL)
+ {
+ pContentData->pContentName = new (std::nothrow) String(pContentName.get());
+ SysTryReturnResult(NID_CNT, pContentData->pContentName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pContentData->pContentName = %ls", pContentData->pContentName->GetPointer());
+ }
+
+ if (pDescription.get() != NULL)
+ {
+ pContentData->pDescription = new (std::nothrow) String(pDescription.get());
+ SysTryReturnResult(NID_CNT, pContentData->pDescription != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pContentData->pDescription = %ls", pContentData->pDescription->GetPointer());
+ }
+
+ if (pLocationTag.get() != NULL)
+ {
+ pContentData->pLocationTag = new (std::nothrow) String(pLocationTag.get());
+ SysTryReturnResult(NID_CNT, pContentData->pLocationTag != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pContentData->pLocationTag = %ls", pContentData->pLocationTag->GetPointer());
+ }
+
+ if (pProvider.get() != NULL)
+ {
+ pContentData->pProvider = new (std::nothrow) String(pProvider.get());
+ SysTryReturnResult(NID_CNT, pContentData->pProvider != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pContentData->pProvider = %ls", pContentData->pProvider->GetPointer());
+ }
+
+ if (pContentRating.get() != NULL)
+ {
+ pContentData->pRating = new (std::nothrow) String(pContentRating.get());
+ SysTryReturnResult(NID_CNT, pContentData->pRating != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pContentData->pRating = %ls", pContentData->pRating->GetPointer());
+ }
+
+ if (pKeyword.get() != NULL)
+ {
+ pContentData->pKeyword = new (std::nothrow) String(pKeyword.get());
+ SysTryReturnResult(NID_CNT, pContentData->pKeyword != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pContentData->pKeyword = %ls", pContentData->pKeyword->GetPointer());
+ }
+
+ switch (storageType)
+ {
+ case MEDIA_CONTENT_STORAGE_INTERNAL:
+ pContentData->storageType = 0;
+ break;
+ case MEDIA_CONTENT_STORAGE_EXTERNAL:
+ pContentData->storageType = 1;
+ break;
+ default:
+ break;
+ }
+ switch (mediaType)
+ {
+ case MEDIA_CONTENT_TYPE_OTHERS:
+ pContentData->contentType = CONTENT_TYPE_OTHER;
+ break;
+ case MEDIA_CONTENT_TYPE_IMAGE:
+ pContentData->contentType = CONTENT_TYPE_IMAGE;
+ break;
+ case MEDIA_CONTENT_TYPE_SOUND:
+ //fall through
+ case MEDIA_CONTENT_TYPE_MUSIC:
+ pContentData->contentType = CONTENT_TYPE_AUDIO;
+ break;
+ case MEDIA_CONTENT_TYPE_VIDEO:
+ pContentData->contentType = CONTENT_TYPE_VIDEO;
+ break;
+ default:
+ break;
+ }
+
+ r = (pContentData->dateTime).SetValue(1970, 1, 1);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.SetValue operation.");
+
+ r = (pContentData->dateTime).AddSeconds(addedTime);// need to check addedTime is secs/millisec
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform datetime.AddSeconds operation.");
+
+ SysLog(NID_CNT, "addedTime = %ld", addedTime);
+ SysLog(NID_CNT, "pContentData->dateTime : %ls", pContentData->dateTime.ToString().GetPointer());
+
+ return r;
+}
+
+// fills Imagecontentinfo information in the image content data object .
+result
+_ContentUtility::FillImageContentData(media_info_h mediaHandle, ImageContentInfo::_ImageContentData* pImageContentData)
+{
+ SysTryReturnResult(NID_CNT, mediaHandle != null && pImageContentData != null, E_INVALID_ARG, "mediaHandle or pImageContentData is null.");
+
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ result r = E_SUCCESS;
+ int width = 0;
+ int height = 0;
+ media_content_orientation_e orientation;
+ std::unique_ptr<char, UtilCharDeleter> pDisplayName;
+
+ char* pDisplayValue = null;
+ ret = media_info_get_display_name(mediaHandle, &pDisplayValue);
+ if (pDisplayValue != null)
+ {
+ pDisplayName.reset(pDisplayValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_display_name operation.");
+ }
+
+ std::unique_ptr<image_meta_h, ImageMetaHandleDeleter> pImageHandle(new (std::nothrow) image_meta_h);
+ ret = media_info_get_image(mediaHandle, pImageHandle.get());
+
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_image operation.");
+
+
+ ret = image_meta_get_width(*(pImageHandle.get()), &width);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_width operation.");
+
+ ret = image_meta_get_orientation(*(pImageHandle.get()), &orientation);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_orientation operation.");
+
+ ret = image_meta_get_height(*(pImageHandle.get()), &height);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform image_meta_get_height operation.");
+
+ pImageContentData->width = width;
+ pImageContentData->height = height;
+ pImageContentData->orientationType = static_cast<ImageOrientationType>(orientation);
+
+ if (pDisplayName != NULL)
+ {
+ int pos = 0;
+ String fileName = L"";
+ String strTitle(pDisplayName.get());
+
+ r = strTitle.LastIndexOf(L'.', strTitle.GetLength() - 1, pos);
+ if (r == E_SUCCESS)
+ {
+ r = strTitle.SubString(0, pos, fileName);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform string.SubString operation.");
+ }
+ else
+ {
+ // Without extension
+ r = E_SUCCESS;
+ fileName = strTitle;
+ }
+ pImageContentData->title = fileName;
+ SysLog(NID_CNT, "pImageContentData->title = %ls", pImageContentData->title.GetPointer());
+ }
+
+ return r;
+}
+
+// fills audio contentinfo information in the audio content data object.
+result
+_ContentUtility::FillAudioContentData(media_info_h mediaHandle, AudioContentInfo::_AudioContentData* pAudioContentData)
+{
+ SysTryReturnResult(NID_CNT, mediaHandle != null && pAudioContentData != null, E_INVALID_ARG, "mediaHandle or pAudioContentData is null.");
+
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ result r = E_SUCCESS;
+ int bitrate = 0;
+ int duration = 0;
+
+ std::unique_ptr<char, UtilCharDeleter> pTitle;
+ std::unique_ptr<char, UtilCharDeleter> pAlbumName;
+ std::unique_ptr<char, UtilCharDeleter> pArtistName;
+ std::unique_ptr<char, UtilCharDeleter> pGenreName;
+ std::unique_ptr<char, UtilCharDeleter> pComposerName;
+ std::unique_ptr<char, UtilCharDeleter> pYear;
+ std::unique_ptr<char, UtilCharDeleter> pCopyRight;
+ std::unique_ptr<char, UtilCharDeleter> pTrackNum;
+
+
+ std::unique_ptr<audio_meta_h, AudioMetaHandleDeleter> pAudioHandle(new (std::nothrow) audio_meta_h);
+ ret = media_info_get_audio(mediaHandle, pAudioHandle.get());
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_audio operation.");
+
+ ret = audio_meta_get_bit_rate(*(pAudioHandle.get()), &bitrate);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_bit_rate operation.");
+
+ char* pAudioMetaValue = null;
+ ret = audio_meta_get_title(*(pAudioHandle.get()), &pAudioMetaValue);
+ if (pAudioMetaValue != null)
+ {
+ pTitle.reset(pAudioMetaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_title operation.");
+ }
+
+ ret = audio_meta_get_album(*(pAudioHandle.get()), &pAudioMetaValue);
+ if (pAudioMetaValue != null)
+ {
+ pAlbumName.reset(pAudioMetaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_album operation.");
+ }
+
+ ret = audio_meta_get_artist(*(pAudioHandle.get()), &pAudioMetaValue);
+ if (pAudioMetaValue != null)
+ {
+ pArtistName.reset(pAudioMetaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_artist operation.");
+ }
+
+ ret = audio_meta_get_genre(*(pAudioHandle.get()), &pAudioMetaValue);
+ if (pAudioMetaValue != null)
+ {
+ pGenreName.reset(pAudioMetaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_genre operation.");
+ }
+
+ ret = audio_meta_get_composer(*(pAudioHandle.get()), &pAudioMetaValue);
+ if (pAudioMetaValue != null)
+ {
+ pComposerName.reset(pAudioMetaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_composer operation.");
+ }
+
+ ret = audio_meta_get_year(*(pAudioHandle.get()), &pAudioMetaValue);
+ if (pAudioMetaValue != null)
+ {
+ pYear.reset(pAudioMetaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_year operation.");
+ }
+
+ ret = audio_meta_get_copyright(*(pAudioHandle.get()), &pAudioMetaValue);
+ if (pAudioMetaValue != null)
+ {
+ pCopyRight.reset(pAudioMetaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_copyright operation.");
+ }
+
+ ret = audio_meta_get_track_num(*(pAudioHandle.get()), &pAudioMetaValue);
+ if (pAudioMetaValue != null)
+ {
+ pTrackNum.reset(pAudioMetaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_track_num operation.");
+ }
+
+ ret = audio_meta_get_duration(*(pAudioHandle.get()), &duration);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform audio_meta_get_duration operation.");
+
+ pAudioContentData->bitrate = bitrate;
+
+ if (pYear.get() != null)
+ {
+ SysLog(NID_CNT, "pAudioContentData->pYear = %s", pYear.get());
+
+ String strYear(pYear.get());
+ if (strYear.CompareTo(L"Unknown") != 0)
+ {
+ r = Integer::Parse(strYear, pAudioContentData->releaseYear);
+ if (IsFailed(r))
+ {
+ // It is one of the metadata. If error occurs, skip it for other metadata.
+ pAudioContentData->releaseYear = 0;
+ r = E_SUCCESS;
+ SysLog(NID_CNT, "pAudioContentData->pYear(invalid data) = %ls", strYear.GetPointer());
+ }
+ }
+ }
+
+ if (pTitle.get() != NULL)
+ {
+ pAudioContentData->pTitle = new (std::nothrow) String(pTitle.get());
+ SysTryReturnResult(NID_CNT, pAudioContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pAudioContentData->pTitle = %ls", pAudioContentData->pTitle->GetPointer());
+ }
+
+ if (pArtistName.get() != NULL)
+ {
+ pAudioContentData->pArtist = new (std::nothrow) String(pArtistName.get());
+ SysTryReturnResult(NID_CNT, pAudioContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pAudioContentData->pArtist = %ls", pAudioContentData->pArtist->GetPointer());
+ }
+
+ if (pGenreName.get() != NULL)
+ {
+ pAudioContentData->pGenre = new (std::nothrow) String(pGenreName.get());
+ SysTryReturnResult(NID_CNT, pAudioContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pAudioContentData->pGenre = %ls", pAudioContentData->pGenre->GetPointer());
+ }
+
+ if (pComposerName.get() != NULL)
+ {
+ pAudioContentData->pComposer = new (std::nothrow) String(pComposerName.get());
+ SysTryReturnResult(NID_CNT, pAudioContentData->pComposer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pAudioContentData->pComposer = %ls", pAudioContentData->pComposer->GetPointer());
+ }
+
+ if (pAlbumName.get() != NULL)
+ {
+ pAudioContentData->pAlbumName = new (std::nothrow) String(pAlbumName.get());
+ SysTryReturnResult(NID_CNT, pAudioContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pAudioContentData->pAlbumName = %ls", pAudioContentData->pAlbumName->GetPointer());
+ }
+
+ if (pCopyRight.get() != NULL)
+ {
+ pAudioContentData->pCopyright = new (std::nothrow) String(pCopyRight.get());
+ SysTryReturnResult(NID_CNT, pAudioContentData->pCopyright != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pAudioContentData->pCopyright = %ls", pAudioContentData->pCopyright->GetPointer());
+ }
+
+ if (pTrackNum.get() != NULL)
+ {
+ pAudioContentData->pTrackInfo = new (std::nothrow) String(pTrackNum.get());
+ SysTryReturnResult(NID_CNT, pAudioContentData->pTrackInfo != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pAudioContentData->pTrackInfo = %ls", pAudioContentData->pTrackInfo->GetPointer());
+ }
+
+ pAudioContentData->duration = duration;
+ SysLog(NID_CNT,"pAudioContentData->duration = %d", pAudioContentData->duration);
+
+ return r;
+}
+
+// fills video contentinfo information in the video content data object.
+result
+_ContentUtility::FillVideoContentData(media_info_h mediaHandle, VideoContentInfo::_VideoContentData* pVideoContentData)
+{
+ SysTryReturnResult(NID_CNT, mediaHandle != null && pVideoContentData != null, E_INVALID_ARG, "mediaHandle or pVideoContentData is null.");
+
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ result r = E_SUCCESS;
+ int width = 0;
+ int height = 0;
+ std::unique_ptr<char, UtilCharDeleter> pArtistName;
+ std::unique_ptr<char, UtilCharDeleter> pGenreName;
+ std::unique_ptr<char, UtilCharDeleter> pTitle;
+ std::unique_ptr<char, UtilCharDeleter> pAlbumName;
+ int duration = 0;
+
+ std::unique_ptr<video_meta_h, VideoMetaHandleDeleter> pVideoHandle(new (std::nothrow) video_meta_h);
+ ret = media_info_get_video(mediaHandle, pVideoHandle.get());
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform media_info_get_video operation.");
+
+ ret = video_meta_get_width(*(pVideoHandle.get()), &width);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_width operation.");
+
+ ret = video_meta_get_height(*(pVideoHandle.get()), &height);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_height operation.");
+
+ char* pVideoMetaValue = null;
+ ret = video_meta_get_artist(*(pVideoHandle.get()), &pVideoMetaValue);
+ if (pVideoMetaValue != null)
+ {
+ pArtistName.reset(pVideoMetaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_artist operation.");
+ }
+
+ ret = video_meta_get_genre(*(pVideoHandle.get()), &pVideoMetaValue);
+ if (pVideoMetaValue != null)
+ {
+ pGenreName.reset(pVideoMetaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_genre operation.");
+ }
+
+ ret = video_meta_get_title(*(pVideoHandle.get()), &pVideoMetaValue);
+ if (pVideoMetaValue != null)
+ {
+ pTitle.reset(pVideoMetaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_title operation.");
+ }
+
+ ret = video_meta_get_album(*(pVideoHandle.get()), &pVideoMetaValue);
+ if (pVideoMetaValue != null)
+ {
+ pAlbumName.reset(pVideoMetaValue);
+ }
+ else
+ {
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_album operation.");
+ }
+
+ ret = video_meta_get_duration(*(pVideoHandle.get()), &duration);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, MapCoreErrorToNativeResult(ret), "Failed to perform video_meta_get_duration operation.");
+
+ pVideoContentData->width = width;
+ pVideoContentData->height = height;
+
+ if (pTitle.get() != NULL)
+ {
+ pVideoContentData->pTitle = new (std::nothrow) String(pTitle.get());
+ SysTryReturnResult(NID_CNT, pVideoContentData->pTitle != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pVideoContentData->pTitle = %ls", pVideoContentData->pTitle->GetPointer());
+ }
+
+ if (pArtistName.get() != NULL)
+ {
+ pVideoContentData->pArtist = new (std::nothrow) String(pArtistName.get());
+ SysTryReturnResult(NID_CNT, pVideoContentData->pArtist != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pVideoContentData->pArtist = %ls", pVideoContentData->pArtist->GetPointer());
+ }
+
+ if (pGenreName.get() != NULL)
+ {
+ pVideoContentData->pGenre = new (std::nothrow) String(pGenreName.get());
+ SysTryReturnResult(NID_CNT, pVideoContentData->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pVideoContentData->pGenre = %ls", pVideoContentData->pGenre->GetPointer());
+ }
+
+ if (pAlbumName.get() != NULL)
+ {
+ pVideoContentData->pAlbumName = new (std::nothrow) String(pAlbumName.get());
+ SysTryReturnResult(NID_CNT, pVideoContentData->pAlbumName != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ SysLog(NID_CNT, "pVideoContentData->pAlbumName = %ls", pVideoContentData->pAlbumName->GetPointer());
+ }
+
+ pVideoContentData->duration = duration;
+ SysLog(NID_CNT,"pVideoContentData->duration = %d", pVideoContentData->duration);
+
+ return r;
+}
+
+// Convertion of system errors to osp errors
+result
+_ContentUtility::MapCoreErrorToNativeResult(int reason)
+{
+ result r = E_SUCCESS;
+ switch (reason)
+ {
+ case MEDIA_CONTENT_ERROR_NONE:
+ r = E_SUCCESS;
+ break;
+ case MEDIA_CONTENT_ERROR_DB_BUSY:
+ r = E_SERVICE_BUSY;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_BUSY");
+ break;
+ case MEDIA_CONTENT_ERROR_INVALID_PARAMETER:
+ r = E_INVALID_ARG;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_INVALID_PARAMETER");
+ break;
+ case MEDIA_CONTENT_ERROR_DB_FAILED:
+ r = E_DATABASE;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_FAILED");
+ break;
+ case MEDIA_CONTENT_ERROR_OUT_OF_MEMORY:
+ r = E_OUT_OF_MEMORY;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_OUT_OF_MEMORY");
+ break;
+ default:
+ SysLog(NID_CNT, "default");
+ r = E_SYSTEM;
+ break;
+ }
+ return r;
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_DownloadManagerImpl.cpp
+ * @brief This is the implementation file for the _DownloadManagerImpl class.
+ *
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <cstdlib>
+#include <pthread.h>
+#include <unique_ptr.h>
+
+#include <download.h>
+
+#include <FBaseSysLog.h>
+#include <FBase_StringConverter.h>
+#include <FBaseColIMap.h>
+#include <FApp_AppInfo.h>
+
+#include <FCntDownloadRequest.h>
+#include <FCntIDownloadListener.h>
+
+#include "FCnt_DownloadManagerImpl.h"
+
+using namespace std;
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Content
+{
+
+_DownloadManagerImpl* _DownloadManagerImpl::__pInstance = null;
+
+static void
+OnStateChanged(int download_id, download_state_e state, void* data)
+{
+ SysLog(NID_CNT, "OnStateChanged, id = %d, state = %d", download_id, state);
+
+ RequestId reqId = (long)download_id;
+
+ _DownloadManagerImpl* pDMImpl = (_DownloadManagerImpl*)data;
+
+ if (!data || !pDMImpl->__pListener)
+ {
+ return;
+ }
+
+ switch(state)
+ {
+ case DOWNLOAD_STATE_NONE:
+ case DOWNLOAD_STATE_QUEUED:
+ case DOWNLOAD_STATE_DOWNLOADING:
+ break;
+
+ case DOWNLOAD_STATE_PAUSED:
+ pDMImpl->__pListener->OnDownloadPaused(reqId);
+ break;
+
+ case DOWNLOAD_STATE_COMPLETED:
+ {
+ char* path = null;
+ download_get_downloaded_file_path(download_id, &path);
+ pDMImpl->__pListener->OnDownloadCompleted(reqId, path);
+
+ delete[] path;
+
+ // 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;
+
+ download_get_error(download_id, &error);
+ download_get_http_status(download_id, &http_status);
+ r = pDMImpl->ConvertToResult(error);
+
+ String errorCode;
+ pDMImpl->__pListener->OnDownloadFailed(reqId, r, http_status);
+
+ // Comment out due to resume the failed request
+ //pDMImpl->DestroyResources(reqId);
+ break;
+ }
+
+ case DOWNLOAD_STATE_CANCELED:
+ pDMImpl->__pListener->OnDownloadCanceled(reqId);
+
+ // Remove the resource from url_download
+ pDMImpl->DestroyResources(reqId);
+ break;
+
+ default:
+ break;
+ }
+
+}
+
+static void
+OnProgress(int download_id, unsigned long long received, void* data)
+{
+ RequestId reqId = (long)download_id;
+
+ _DownloadManagerImpl* pDMImpl = (_DownloadManagerImpl*)data;
+
+ if (data && pDMImpl->__pListener)
+ {
+ unsigned long long total = 0;
+ download_get_content_size(download_id, &total);
+
+ SysLog(NID_CNT, "OnProgress, id = %d, received = %lld, total = %lld", download_id, received, total);
+
+ pDMImpl->__pListener->OnDownloadInProgress(reqId, received, total);
+ }
+}
+
+
+_DownloadManagerImpl::_DownloadManagerImpl(void)
+ : __pListener(null)
+{
+}
+
+_DownloadManagerImpl::~_DownloadManagerImpl(void)
+{
+}
+
+result
+_DownloadManagerImpl::Construct(void)
+{
+ result r = E_SUCCESS;
+
+ r = __handleMap.Construct(100, 0);
+
+ return r;
+}
+
+void
+_DownloadManagerImpl::InitSingleton(void)
+{
+ unique_ptr<_DownloadManagerImpl> pImpl(new (std::nothrow) _DownloadManagerImpl);
+ SysTryReturnVoidResult(NID_CNT, pImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ result r = pImpl->Construct();
+ SysTryReturnVoidResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to initialize download manager.");
+
+ __pInstance = pImpl.release();
+
+ std::atexit(DestroySingleton);
+}
+
+void
+_DownloadManagerImpl::DestroySingleton(void)
+{
+ delete __pInstance;
+}
+
+_DownloadManagerImpl*
+_DownloadManagerImpl::GetInstance(void)
+{
+ static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
+ if (__pInstance == null)
+ {
+ ClearLastResult();
+
+ pthread_once(&onceBlock, InitSingleton);
+ result r = GetLastResult();
+ if(IsFailed(r))
+ {
+ onceBlock = PTHREAD_ONCE_INIT;
+ }
+ }
+
+ return __pInstance;
+}
+
+result
+_DownloadManagerImpl::Start(const DownloadRequest& request, RequestId& reqId)
+{
+ SysLog(NID_CNT, "Start a download from Url = %ls, Path = %ls", request.GetUrl().GetPointer(), request.GetDirectoryPath().GetPointer());
+
+ result r = E_SUCCESS;
+
+ int ret = 0;
+ int download_id = 0;
+
+ String url = request.GetUrl();
+ String dirPath = request.GetDirectoryPath();
+ String fileName = request.GetFileName();
+
+ 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.");
+
+ // Set the url
+ unique_ptr<char[]> 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.");
+
+ // Check the download path
+ if (!dirPath.IsEmpty())
+ {
+ unique_ptr<char[]> pStr(_StringConverter::CopyToCharArrayN(dirPath));
+
+ ret = access(pStr.get(), F_OK);
+ if (ret == 0)
+ {
+ ret = access(pStr.get(), W_OK);
+ SysTryReturnResult(NID_CNT, ret == 0, E_ILLEGAL_ACCESS, "Access to the requested path is denied due to insufficient permission.");
+ }
+
+ ret = download_set_destination(download_id, pStr.get());
+ SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available.");
+ }
+
+ // Set the file name
+ if (!fileName.IsEmpty())
+ {
+ unique_ptr<char[]> 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.");
+ }
+
+ // Set the callback functions
+ r = RegisterCallback((long)download_id);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "The internal system service is not available.");
+
+ // 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);
+
+ // Set a request Id
+ reqId = (long)download_id;
+
+ // Add a request Id to the handle map
+ __handleMap.Add(reqId, new DownloadRequest(request));
+
+ return E_SUCCESS;
+
+CATCH:
+ UnregisterCallback((long)download_id);
+
+ return r;
+}
+
+result
+_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);
+
+ // Check the pre-state
+ r = CheckPrestate(DOWNLOAD_OPERATION_PAUSE, state);
+ if(IsFailed(r))
+ {
+ SysPropagate(NID_CNT, r);
+ return r;
+ }
+
+ // Pause the download request
+ ret = download_pause((int)reqId);
+ SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available.");
+
+ return E_SUCCESS;
+}
+
+result
+_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);
+
+ // Check the pre-state
+ r = CheckPrestate(DOWNLOAD_OPERATION_RESUME, state);
+ if(IsFailed(r))
+ {
+ SysPropagate(NID_CNT, r);
+ return r;
+ }
+
+ // Resume the download request
+ ret = download_start((int)reqId);
+ SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available.");
+
+ return E_SUCCESS;
+}
+
+result
+_DownloadManagerImpl::Cancel(RequestId reqId)
+{
+ int ret = 0;
+
+ DownloadRequest* pRequest = null;
+
+ // Check the request Id
+ pRequest = GetDownloadRequestN(reqId);
+ if(pRequest == null)
+ {
+ result r = GetLastResult();
+ SysPropagate(NID_CNT, r);
+ return r;
+ }
+
+ delete pRequest;
+
+ // Stop the download request
+ ret = download_cancel((int)reqId);
+ SysTryReturnResult(NID_CNT, ret >= 0, E_SYSTEM, "The internal system service is not available.");
+
+ return E_SUCCESS;
+}
+
+DownloadRequest*
+_DownloadManagerImpl::GetDownloadRequestN(RequestId reqId)
+{
+ result r = E_SUCCESS;
+ 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");
+
+ pRequest = new (std::nothrow) DownloadRequest(*pRequest);
+ SysTryReturn(NID_CNT, pRequest != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]");
+
+ SetLastResult(E_SUCCESS);
+ return pRequest;
+}
+
+result
+_DownloadManagerImpl::GetMimeType(RequestId reqId, String& mimeType)
+{
+ result r = E_SUCCESS;
+ int ret = 0;
+
+ char* pStr = null;
+ DownloadRequest* pRequest = null;
+
+ // Check the request is valid
+ pRequest = GetDownloadRequestN(reqId);
+ if(pRequest == null)
+ {
+ r = GetLastResult();
+ SysPropagate(NID_CNT, r);
+ return r;
+ }
+
+ delete pRequest;
+
+ 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.");
+
+ mimeType = pStr;
+ delete[] pStr;
+
+ return E_SUCCESS;
+}
+
+_DownloadManagerImpl::State
+_DownloadManagerImpl::GetState(RequestId reqId) const
+{
+ int ret = 0;
+
+ download_state_e download_state = 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.");
+
+ switch(download_state)
+ {
+ case DOWNLOAD_STATE_NONE:
+ state = STATE_NONE;
+ break;
+
+ case DOWNLOAD_STATE_READY:
+ state = STATE_QUEUED;
+ break;
+
+ case DOWNLOAD_STATE_QUEUED:
+ state = STATE_QUEUED;
+ break;
+
+ case DOWNLOAD_STATE_DOWNLOADING:
+ state = STATE_DOWNLOADING;
+ break;
+
+ case DOWNLOAD_STATE_PAUSED:
+ state = STATE_PAUSED;
+ break;
+
+ case DOWNLOAD_STATE_COMPLETED:
+ state = STATE_COMPLETED;
+ break;
+
+ case DOWNLOAD_STATE_CANCELED:
+ state = STATE_CANCELLED;
+ break;
+
+ case DOWNLOAD_STATE_FAILED:
+ state = STATE_FAILED;
+ break;
+
+ default:
+ state = STATE_NONE;
+ break;
+ }
+
+ SysLog(NID_CNT, "download_state = %d, state = %d", download_state, state);
+
+ return state;
+}
+
+result
+_DownloadManagerImpl::GetProgress(RequestId reqId, int& progress)
+{
+ return E_SUCCESS;
+}
+
+result
+_DownloadManagerImpl::SetAllowedNetwork(unsigned long flags)
+{
+ return E_SUCCESS;
+}
+
+void
+_DownloadManagerImpl::SetDownloadListener(IDownloadListener* pListener)
+{
+ __pListener = pListener;
+}
+
+result
+_DownloadManagerImpl::CheckPrestate(DownloadOperation operation, State current)
+{
+ SysLog(NID_CNT, "Operation: %d, Current state: %d", operation, current);
+
+ switch(operation)
+ {
+ case DOWNLOAD_OPERATION_PAUSE:
+ // Check the pre-state: downloading
+ SysTryReturnResult(NID_CNT, current == STATE_DOWNLOADING, E_INVALID_OPERATION,
+ "The current download state is not STATE_DOWNLOADING.");
+ break;
+
+ case DOWNLOAD_OPERATION_RESUME:
+ // Check the pre-state: paused
+ 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:
+ break;
+ }
+
+ return E_SUCCESS;
+}
+
+void
+_DownloadManagerImpl::DestroyResources(RequestId reqId)
+{
+ int ret = 0;
+ result r = E_SUCCESS;
+ DownloadRequest* pRequest = null;
+
+ // Cancel the callback
+ UnregisterCallback(reqId);
+
+ // Remove the resource from url_download
+ ret = download_destroy((int)reqId);
+ SysTryLog(NID_CNT, ret >= 0, "url_download_destory fails %d", ret);
+
+ // Remove DownloadRequest from __handleMap
+ r = __handleMap.GetValue(reqId, pRequest);
+ SysTryLog(NID_CNT, r == E_SUCCESS, "[%s]", GetErrorMessage(r));
+
+ r = __handleMap.Remove(reqId);
+ SysTryLog(NID_CNT, r == E_SUCCESS, "[%s]", GetErrorMessage(r));
+
+ delete pRequest;
+}
+
+result
+_DownloadManagerImpl::RegisterCallback(RequestId reqId)
+{
+ int ret = 0;
+
+ ret = download_set_state_changed_cb(reqId, OnStateChanged, this);
+ SysTryCatch(NID_CNT, ret >= 0, , E_SYSTEM, "[E_SYSTEM] Fails to set state_changed_cb: %d, id = %d", ret, reqId);
+
+ ret = download_set_progress_cb(reqId, OnProgress, this);
+ SysTryCatch(NID_CNT, ret >= 0, , E_SYSTEM, "[E_SYSTEM] Fails to set progress_cb: %d, id = %d", ret, reqId);
+
+ return E_SUCCESS;
+
+CATCH:
+ UnregisterCallback(reqId);
+
+ return E_SYSTEM;
+}
+
+void
+_DownloadManagerImpl::UnregisterCallback(RequestId reqId)
+{
+ int ret = 0;
+
+ ret = download_unset_state_changed_cb(reqId);
+ SysTryLog(NID_CNT, ret >= 0, "download_unset_state_changed_cb fails %d, id = %d", ret, reqId);
+
+ ret = download_unset_progress_cb(reqId);
+ SysTryLog(NID_CNT, ret >= 0, "download_unset_progress_cb fails %d, id = %d", ret, reqId);
+}
+
+result
+_DownloadManagerImpl::ConvertToResult(int error)
+{
+ result r = E_SUCCESS;
+ download_error_e download_error = (download_error_e)error;
+
+ SysLog(NID_CNT, "Download error = %d", download_error);
+
+ switch(download_error)
+ {
+ case DOWNLOAD_ERROR_NONE:
+ r = E_SUCCESS;
+ break;
+
+ case DOWNLOAD_ERROR_OUT_OF_MEMORY:
+ r = E_OUT_OF_MEMORY;
+ break;
+
+ case DOWNLOAD_ERROR_IO_ERROR:
+ r = E_SYSTEM;
+ break;
+
+ case DOWNLOAD_ERROR_INVALID_URL:
+ r = E_INVALID_URL;
+ break;
+
+ case DOWNLOAD_ERROR_CONNECTION_FAILED:
+ case DOWNLOAD_ERROR_NETWORK_UNREACHABLE:
+ r = E_CONNECTION_FAILED;
+ break;
+
+ case DOWNLOAD_ERROR_CONNECTION_TIMED_OUT:
+ r = E_TIMEOUT;
+ break;
+
+ case DOWNLOAD_ERROR_TOO_MANY_DOWNLOADS:
+ r = E_MAX_EXCEEDED;
+ break;
+
+ case DOWNLOAD_ERROR_NO_SPACE:
+ r = E_STORAGE_FULL;
+ break;
+
+ case DOWNLOAD_ERROR_QUEUE_FULL:
+
+ //case URL_DOWNLOAD_ERROR_INVALID_STATE:
+ //case URL_DOWNLOAD_ERROR_INVALID_PARAMETER:
+ //case URL_DOWNLOAD_ERROR_INVALID_DESTINATION:
+ //case URL_DOWNLOAD_ERROR_ALREADY_COMPLETED:
+ default:
+ r = E_SYSTEM;
+ }
+
+ return r;
+}
+
+} } // Tizen::Content
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_DownloadRequestImpl.cpp
+ * @brief This is the implementation file for the _DownloadRequestImpl class.
+ *
+ */
+
+
+#include <FBaseLog.h>
+
+#include "FCnt_DownloadRequestImpl.h"
+
+using namespace Tizen::Base;
+
+namespace Tizen { namespace Content
+{
+
+_DownloadRequestImpl::_DownloadRequestImpl(void)
+{
+}
+
+_DownloadRequestImpl::_DownloadRequestImpl(const String& url)
+ : __url(url)
+{
+}
+
+_DownloadRequestImpl::_DownloadRequestImpl(const String& url, const String& dirPath)
+ : __url(url)
+ , __dirPath(dirPath)
+{
+}
+
+_DownloadRequestImpl::_DownloadRequestImpl(const _DownloadRequestImpl& rhs)
+ : __url(rhs.__url)
+ , __dirPath(rhs.__dirPath)
+ , __fileName(rhs.__fileName)
+{
+}
+
+_DownloadRequestImpl::~_DownloadRequestImpl(void)
+{
+}
+
+
+_DownloadRequestImpl&
+_DownloadRequestImpl::operator =(const _DownloadRequestImpl& rhs)
+{
+ __url = rhs.__url;
+ __dirPath = rhs.__dirPath;
+ __fileName = rhs.__fileName;
+
+ return *this;
+}
+
+bool
+_DownloadRequestImpl::operator ==(const _DownloadRequestImpl& rhs) const
+{
+ if (&rhs == this)
+ {
+ return true;
+ }
+
+ if (__url == rhs.__url
+ && __dirPath == rhs.__dirPath
+ && __fileName == rhs.__fileName)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+bool
+_DownloadRequestImpl::Equals(const Object& obj) const
+{
+ const _DownloadRequestImpl* pOther = dynamic_cast< const _DownloadRequestImpl* >(&obj);
+ if (pOther == null)
+ {
+ return false;
+ }
+
+ return (*this == *pOther);
+}
+
+int
+_DownloadRequestImpl::GetHashCode(void) const
+{
+ String hashCode;
+
+ hashCode.Append(__url);
+ hashCode.Append(__dirPath);
+ hashCode.Append(__fileName);
+
+ return hashCode.GetHashCode();
+}
+
+void
+_DownloadRequestImpl::SetDirectoryPath(const String& dirPath)
+{
+ __dirPath = dirPath;
+}
+
+void
+_DownloadRequestImpl::SetFileName(const String& fileName)
+{
+ __fileName = fileName;
+}
+
+String
+_DownloadRequestImpl::GetUrl(void) const
+{
+ return __url;
+}
+
+String
+_DownloadRequestImpl::GetDirectoryPath(void) const
+{
+ return __dirPath;
+}
+
+String
+_DownloadRequestImpl::GetFileName(void) const
+{
+ return __fileName;
+}
+
+} } // Tizen::Content
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ImageMetadataImpl.cpp
+ * @brief This is the implementation file for the %_ImageMetadataImpl class.
+ *
+ * This file contains implementation of the %_ImageMetadataImpl class.
+ */
+
+// includes
+#include <FBaseSysLog.h>
+#include <FMediaImage.h>
+#include <FGrpBitmap.h>
+#include <FCntImageMetadata.h>
+#include <FCnt_ImageMetadataImpl.h>
+#include <FIo_FileImpl.h>
+#include <FMedia_ImageImpl.h>
+
+// using namespaces
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Io;
+using namespace Tizen::Graphics;
+using namespace Tizen::Media;
+
+namespace Tizen { namespace Content
+{
+
+static const int THUMBNAIL_IMAGE_WIDTH = 320;
+static const int THUMBNAIL_IMAGE_HEIGHT = 240;
+static const double DEFAULT_COORDINATE = -200.0;
+
+_ImageMetadataImpl::_ImageMetadataImpl(void)
+ : Object()
+{
+ unique_ptr<ImageMeta, ImageMetaDeleter> pNewImageMeta(new (nothrow) ImageMeta());
+ if (pNewImageMeta != null)
+ {
+ __pImageMeta = move(pNewImageMeta);
+ }
+ else
+ {
+ __pImageMeta = null;
+ SysLog(NID_CNT, "The memory is insufficient.");
+ }
+}
+
+_ImageMetadataImpl::~_ImageMetadataImpl(void)
+{
+
+}
+
+_ImageMetadataImpl*
+_ImageMetadataImpl::GetInstance(ImageMetadata& imageMetadata)
+{
+ return imageMetadata.__pImpl;
+}
+
+const _ImageMetadataImpl*
+_ImageMetadataImpl::GetInstance(const ImageMetadata& imageMetadata)
+{
+ return imageMetadata.__pImpl;
+}
+
+result
+_ImageMetadataImpl::SetImageMetadata(const ImageMeta* pImageMeta)
+{
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, pImageMeta != null, E_INVALID_ARG, "pImageMeta is null.");
+
+ __pImageMeta->width = pImageMeta->width;
+ __pImageMeta->height = pImageMeta->height;
+ __pImageMeta->orientation = pImageMeta->orientation;
+ __pImageMeta->latitude = pImageMeta->latitude;
+ __pImageMeta->longitude = pImageMeta->longitude;
+ __pImageMeta->contentPath = pImageMeta->contentPath;
+
+ if (pImageMeta->pManufacturer != null)
+ {
+ __pImageMeta->pManufacturer = new (nothrow) String(*(pImageMeta->pManufacturer));
+ SysTryReturnResult(NID_CNT, __pImageMeta->pManufacturer != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pImageMeta->pModel != null)
+ {
+ __pImageMeta->pModel = new (nothrow) String(*(pImageMeta->pModel));
+ SysTryReturnResult(NID_CNT, __pImageMeta->pModel != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pImageMeta->pDateTime != null)
+ {
+ __pImageMeta->pDateTime = new (nothrow) String(*(pImageMeta->pDateTime));
+ SysTryReturnResult(NID_CNT, __pImageMeta->pDateTime != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pImageMeta->pSoftware != null)
+ {
+ __pImageMeta->pSoftware = new (nothrow) String(*(pImageMeta->pSoftware));
+ SysTryReturnResult(NID_CNT, __pImageMeta->pSoftware != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pImageMeta->pWhiteBalance != null)
+ {
+ __pImageMeta->pWhiteBalance = new (nothrow) String(*(pImageMeta->pWhiteBalance));
+ SysTryReturnResult(NID_CNT, __pImageMeta->pWhiteBalance != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+
+ return E_SUCCESS;
+}
+
+ImageMeta*
+_ImageMetadataImpl::GetImageMetadata(void) const
+{
+ return __pImageMeta.get();
+}
+
+_ImageMetadataImpl::_ImageMetadataImpl(const _ImageMetadataImpl& rhs)
+ : Object()
+{
+ unique_ptr<ImageMeta, ImageMetaDeleter> pNewImageMeta(new (nothrow) ImageMeta());
+ if (pNewImageMeta != null)
+ {
+ pNewImageMeta->width = (rhs.__pImageMeta)->width;
+ pNewImageMeta->height = (rhs.__pImageMeta)->height;
+ pNewImageMeta->orientation = (rhs.__pImageMeta)->orientation;
+ pNewImageMeta->latitude = (rhs.__pImageMeta)->latitude;
+ pNewImageMeta->longitude = (rhs.__pImageMeta)->longitude;
+ pNewImageMeta->contentPath = (rhs.__pImageMeta)->contentPath;
+
+ if ((rhs.__pImageMeta)->pManufacturer != null)
+ {
+ pNewImageMeta->pManufacturer = new (nothrow) String(*((rhs.__pImageMeta)->pManufacturer));
+ if (pNewImageMeta->pManufacturer == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ if ((rhs.__pImageMeta)->pModel != null)
+ {
+ pNewImageMeta->pModel = new (nothrow) String(*((rhs.__pImageMeta)->pModel));
+ if (pNewImageMeta->pModel == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ if ((rhs.__pImageMeta)->pDateTime != null)
+ {
+ pNewImageMeta->pDateTime = new (nothrow) String(*((rhs.__pImageMeta)->pDateTime));
+ if (pNewImageMeta->pDateTime == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ if ((rhs.__pImageMeta)->pSoftware != null)
+ {
+ pNewImageMeta->pSoftware = new (nothrow) String(*((rhs.__pImageMeta)->pSoftware));
+ if (pNewImageMeta->pSoftware == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ if ((rhs.__pImageMeta)->pWhiteBalance != null)
+ {
+ pNewImageMeta->pWhiteBalance = new (nothrow) String(*((rhs.__pImageMeta)->pWhiteBalance));
+ if (pNewImageMeta->pWhiteBalance == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+
+ __pImageMeta = move(pNewImageMeta);
+ }
+ else
+ {
+ __pImageMeta = null;
+ SysLog(NID_CNT, "The memory is insufficient.");
+ }
+}
+
+_ImageMetadataImpl&
+_ImageMetadataImpl::operator =(const _ImageMetadataImpl& rhs)
+{
+ // check for self-assignment
+ if (this == &rhs)
+ {
+ return *this;
+ }
+
+ // __pImageMeta
+ if (__pImageMeta != null && (rhs.__pImageMeta) != null)
+ {
+ // DeleteMetadata(__pImageMeta);
+ // __pImageMeta = new (nothrow) ImageMeta;
+
+ __pImageMeta.reset(new (nothrow) ImageMeta);
+ }
+ else if (__pImageMeta != null)
+ {
+ //DeleteMetadata(__pImageMeta);
+
+ __pImageMeta.reset(null);
+ return *this;
+ }
+ else if ((rhs.__pImageMeta) != null)
+ {
+ //__pImageMeta = new (nothrow) ImageMeta;
+
+ __pImageMeta.reset(new (nothrow) ImageMeta);
+ }
+ else
+ {
+ // __pImageMeta and rhs.__pImageMeta are null.
+ return *this;
+ }
+
+ __pImageMeta->width = (rhs.__pImageMeta)->width;
+ __pImageMeta->height = (rhs.__pImageMeta)->height;
+ __pImageMeta->orientation = (rhs.__pImageMeta)->orientation;
+ __pImageMeta->latitude = (rhs.__pImageMeta)->latitude;
+ __pImageMeta->longitude = (rhs.__pImageMeta)->longitude;
+ __pImageMeta->contentPath = (rhs.__pImageMeta)->contentPath;
+
+ // pManufacturer
+ if (__pImageMeta->pManufacturer != null && (rhs.__pImageMeta)->pManufacturer != null)
+ {
+ // delete previous data
+ delete __pImageMeta->pManufacturer;
+ __pImageMeta->pManufacturer = null;
+
+ __pImageMeta->pManufacturer = new (nothrow) String(*((rhs.__pImageMeta)->pManufacturer));
+ }
+ else if (__pImageMeta->pManufacturer != null)
+ {
+ delete __pImageMeta->pManufacturer;
+ __pImageMeta->pManufacturer = null;
+ }
+ else if ((rhs.__pImageMeta)->pManufacturer != null)
+ {
+ __pImageMeta->pManufacturer = new (nothrow) String(*((rhs.__pImageMeta)->pManufacturer));
+ }
+
+ // pModel
+ if (__pImageMeta->pModel != null && (rhs.__pImageMeta)->pModel != null)
+ {
+ // delete previous data
+ delete __pImageMeta->pModel;
+ __pImageMeta->pModel = null;
+
+ __pImageMeta->pModel = new (nothrow) String(*((rhs.__pImageMeta)->pModel));
+ }
+ else if (__pImageMeta->pModel != null)
+ {
+ delete __pImageMeta->pModel;
+ __pImageMeta->pModel = null;
+ }
+ else if ((rhs.__pImageMeta)->pModel != null)
+ {
+ __pImageMeta->pModel = new (nothrow) String(*((rhs.__pImageMeta)->pModel));
+ }
+
+ // pDateTime
+ if (__pImageMeta->pDateTime != null && (rhs.__pImageMeta)->pDateTime != null)
+ {
+ // delete previous data
+ delete __pImageMeta->pDateTime;
+ __pImageMeta->pDateTime = null;
+
+ __pImageMeta->pDateTime = new (nothrow) String(*((rhs.__pImageMeta)->pDateTime));
+ }
+ else if (__pImageMeta->pDateTime != null)
+ {
+ delete __pImageMeta->pDateTime;
+ __pImageMeta->pDateTime = null;
+ }
+ else if ((rhs.__pImageMeta)->pDateTime != null)
+ {
+ __pImageMeta->pDateTime = new (nothrow) String(*((rhs.__pImageMeta)->pDateTime));
+ }
+
+ // pSoftware
+ if (__pImageMeta->pSoftware != null && (rhs.__pImageMeta)->pSoftware != null)
+ {
+ // delete previous data
+ delete __pImageMeta->pSoftware;
+ __pImageMeta->pSoftware = null;
+
+ __pImageMeta->pSoftware = new (nothrow) String(*((rhs.__pImageMeta)->pSoftware));
+ }
+ else if (__pImageMeta->pSoftware != null)
+ {
+ delete __pImageMeta->pSoftware;
+ __pImageMeta->pSoftware = null;
+ }
+ else if ((rhs.__pImageMeta)->pSoftware != null)
+ {
+ __pImageMeta->pSoftware = new (nothrow) String(*((rhs.__pImageMeta)->pSoftware));
+ }
+
+ // pWhiteBalance
+ if (__pImageMeta->pWhiteBalance != null && (rhs.__pImageMeta)->pWhiteBalance != null)
+ {
+ // delete previous data
+ delete __pImageMeta->pWhiteBalance;
+ __pImageMeta->pWhiteBalance = null;
+
+ __pImageMeta->pWhiteBalance = new (nothrow) String(*((rhs.__pImageMeta)->pWhiteBalance));
+ }
+ else if (__pImageMeta->pWhiteBalance != null)
+ {
+ delete __pImageMeta->pWhiteBalance;
+ __pImageMeta->pWhiteBalance = null;
+ }
+ else if ((rhs.__pImageMeta)->pWhiteBalance != null)
+ {
+ __pImageMeta->pWhiteBalance = new (nothrow) String(*((rhs.__pImageMeta)->pWhiteBalance));
+ }
+
+ SysLog(NID_CNT, "_ImageMetadataImpl::operator =(const _ImageMetadataImpl& rhs) is called.");
+ return *this;
+}
+
+bool
+_ImageMetadataImpl::Equals(const Tizen::Base::Object& rhs) const
+{
+ const _ImageMetadataImpl* pRhs = dynamic_cast <const _ImageMetadataImpl*>(&rhs);
+ if (pRhs == null)
+ {
+ return false;
+ }
+
+ if (!((this->GetCameraManufacturer()).Equals(pRhs->GetCameraManufacturer())))
+ {
+ return false;
+ }
+ if (!((this->GetCameraModel()).Equals(pRhs->GetCameraModel())))
+ {
+ return false;
+ }
+ if (!((this->GetDateTime()).Equals(pRhs->GetDateTime())))
+ {
+ return false;
+ }
+ if (this->GetHeight() != pRhs->GetHeight())
+ {
+ return false;
+ }
+ if (Double::Compare(this->GetLatitude(), pRhs->GetLatitude()) != 0)
+ {
+ return false;
+ }
+ if (Double::Compare(this->GetLongitude(), pRhs->GetLongitude()) != 0)
+ {
+ return false;
+ }
+ if (this->GetOrientation() != pRhs->GetOrientation())
+ {
+ return false;
+ }
+ if (!((this->GetSoftware()).Equals(pRhs->GetSoftware())))
+ {
+ return false;
+ }
+ if (!((this->GetWhiteBalance()).Equals(pRhs->GetWhiteBalance())))
+ {
+ return false;
+ }
+ if (this->GetWidth() != pRhs->GetWidth())
+ {
+ return false;
+ }
+
+ return true;
+}
+
+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;
+}
+
+int
+_ImageMetadataImpl::GetWidth(void) const
+{
+ if (__pImageMeta == null)
+ {
+ SysLog(NID_CNT, "__pImageMeta is null.");
+ return 0;
+ }
+ return __pImageMeta->width;
+}
+
+int
+_ImageMetadataImpl::GetHeight(void) const
+{
+ if (__pImageMeta == null)
+ {
+ SysLog(NID_CNT, "__pImageMeta is null.");
+ return 0;
+ }
+ return __pImageMeta->height;
+}
+
+String
+_ImageMetadataImpl::GetCameraManufacturer(void) const
+{
+ if (__pImageMeta == null || __pImageMeta->pManufacturer == null)
+ {
+ SysLog(NID_CNT, "__pImageMeta or __pImageMeta->pManufacturer is null.");
+ return String();
+ }
+ return *(__pImageMeta->pManufacturer);
+}
+
+String
+_ImageMetadataImpl::GetCameraModel(void) const
+{
+ if (__pImageMeta == null || __pImageMeta->pModel == null)
+ {
+ SysLog(NID_CNT, "__pImageMeta or __pImageMeta->pModel is null.");
+ return String();
+ }
+ return *(__pImageMeta->pModel);
+}
+
+String
+_ImageMetadataImpl::GetSoftware(void) const
+{
+ if (__pImageMeta == null || __pImageMeta->pSoftware == null)
+ {
+ SysLog(NID_CNT, "__pImageMeta or __pImageMeta->pSoftware is null.");
+ return String();
+ }
+ return *(__pImageMeta->pSoftware);
+}
+
+String
+_ImageMetadataImpl::GetDateTime(void) const
+{
+ if (__pImageMeta == null || __pImageMeta->pDateTime == null)
+ {
+ SysLog(NID_CNT, "__pImageMeta or __pImageMeta->pDateTime is null.");
+ return String();
+ }
+ return *(__pImageMeta->pDateTime);
+}
+
+double
+_ImageMetadataImpl::GetLatitude(void) const
+{
+ if (__pImageMeta == null)
+ {
+ SysLog(NID_CNT, "__pImageMeta is null.");
+ return DEFAULT_COORDINATE;
+ }
+ return __pImageMeta->latitude;
+}
+
+double
+_ImageMetadataImpl::GetLongitude(void) const
+{
+ if (__pImageMeta == null)
+ {
+ SysLog(NID_CNT, "__pImageMeta is null.");
+ return DEFAULT_COORDINATE;
+ }
+ return __pImageMeta->longitude;
+}
+
+ImageOrientationType
+_ImageMetadataImpl::GetOrientation(void) const
+{
+ if (__pImageMeta == null)
+ {
+ SysLog(NID_CNT, "__pImageMeta is null.");
+ return IMAGE_ORIENTATION_TYPE_UNKNOWN;
+ }
+ return __pImageMeta->orientation;
+}
+
+String
+_ImageMetadataImpl::GetWhiteBalance(void) const
+{
+ if (__pImageMeta == null || __pImageMeta->pWhiteBalance == null)
+ {
+ SysLog(NID_CNT, "__pImageMeta or __pImageMeta->pWhiteBalance is null.");
+ return String();
+ }
+ return *(__pImageMeta->pWhiteBalance);
+}
+
+//
+// E_SUCCESS
+// E_DATA_NOT_FOUND
+// E_OUT_OF_MEMORY
+//
+Bitmap*
+_ImageMetadataImpl::GetThumbnailN(void) const
+{
+ ClearLastResult();
+
+ SysTryReturn(NID_CNT, __pImageMeta != null, null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] GetThumbnailN failed.");
+ SysTryReturn(NID_CNT, _FileImpl::IsFileExist(__pImageMeta->contentPath), null, E_DATA_NOT_FOUND,
+ "[E_DATA_NOT_FOUND] GetThumbnailN failed [%ls].", (__pImageMeta->contentPath).GetPointer());
+
+ Image image;
+ result r = image.Construct();
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] GetThumbnailN failed.");
+
+ Bitmap* pBitmap = image.DecodeN(__pImageMeta->contentPath, BITMAP_PIXEL_FORMAT_ARGB8888, THUMBNAIL_IMAGE_WIDTH, THUMBNAIL_IMAGE_HEIGHT);
+ if (pBitmap == null)
+ {
+ r = GetLastResult();
+
+ if (r == E_OUT_OF_MEMORY)
+ {
+ SysLogException(NID_CNT, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] GetThumbnailN failed.");
+ }
+ else
+ {
+ SysLogException(NID_CNT, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] GetThumbnailN failed.");
+ }
+
+ return null;
+ }
+
+ return pBitmap;
+}
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_PlayLisImpl.cpp
+ * @brief This is the implementation file for the %_PlayListImpl class.
+ *
+ * This file contains implementation of the %_PlayListImpl class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FBaseInteger.h>
+#include <FBaseLongLong.h>
+#include <FBaseFloat.h>
+#include <FCntPlayList.h>
+#include <FBase_StringConverter.h>
+#include <FCnt_PlayListImpl.h>
+#include <FCnt_ContentUtility.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Content
+{
+ // Declaration for Callback function registered to playlist details
+ bool MediaPlayListImplCb(media_playlist_h playlistHandle, void *pUserData);
+
+ // Declaration for Callback function registered to playlist items details
+ bool PlaylistImplItemCb(int playlistMemberId, media_info_h media, void *pUserData);
+
+ // Declaration for Callback function registered to playlist items details
+ bool PlaylistItemsCb(int playlistId, media_info_h media, void *pUserData);
+
+_PlayListImpl::_PlayListImpl(void)
+ : Object()
+ , __pFilterHandle(NULL)
+{
+
+}
+
+//(disconnects the DB connection)
+_PlayListImpl::~_PlayListImpl(void)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ result r = E_SUCCESS;
+
+ ret = media_content_disconnect();
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryLog(r == E_SUCCESS, "[%s] Propagating for media_content_disconnect", GetErrorMessage(r));
+}
+
+ _PlayListImpl*
+ _PlayListImpl::GetInstance(PlayList& playList)
+{
+ return (&playList != null) ? playList.__pImpl : null;
+}
+
+const _PlayListImpl*
+_PlayListImpl::GetInstance(const PlayList& playList)
+{
+ return (&playList != null) ? playList.__pImpl : null;
+}
+
+result
+_PlayListImpl::Construct(const Tizen::Base::String& playListName, bool isAdd)
+{
+ int ret = media_content_connect();
+ result r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS , r, "Propagating for media_content_connect");
+
+ if (isAdd == true)
+ {
+ std::unique_ptr<media_playlist_s, PlayListHandleDeleter> pPlaylistHandle;
+
+ std::unique_ptr<char[]> pInputCond(_StringConverter::CopyToCharArrayN(playListName));
+ SysTryReturnResult(NID_CNT, (pInputCond.get())[0], E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ media_playlist_h tempHandle = pPlaylistHandle.get();
+ ret = media_playlist_insert_to_db(pInputCond.get(), &tempHandle);
+ r = MapCoreErrorToNativeResult(ret);
+ }
+
+ return r;
+}
+
+result
+_PlayListImpl::CreateFilterUsingContentId(const ContentId& contentId) const
+{
+ std::unique_ptr<char[]> pInputCond;
+ std::unique_ptr<filter_h, FilterHandleDeleter> pFilterHandle(new (std::nothrow) filter_h);
+ String uuidStr = L"";
+ String inputCondition = L"MEDIA_ID = ";
+
+ int ret = media_filter_create(pFilterHandle.get());
+ result r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, r, "Failed to perform media_filter_create operation.");
+
+ uuidStr = contentId.ToString();
+ r = uuidStr.Insert('"', 0);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Insert operation for uuidStr.");
+ r = uuidStr.Insert('"', uuidStr.GetLength());
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Insert operation for uuidStr.");
+
+ r = inputCondition.Append(uuidStr);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation for inputCondition.");
+
+ if (!inputCondition.IsEmpty())
+ {
+ //CopyToCharArrayN: utility function, converts a osp string to char*
+ pInputCond = std::unique_ptr<char[]>(_StringConverter::CopyToCharArrayN(inputCondition));
+ SysTryReturnResult(NID_CNT, (pInputCond.get())[0], E_SYSTEM, "pInputCond is NULL.");
+
+ SysLog(NID_CNT, "pInputCond = %s", pInputCond.get());
+
+ if ((pInputCond.get())[0])
+ {
+ ret = media_filter_set_condition(*(pFilterHandle.get()), pInputCond.get(), MEDIA_CONTENT_COLLATE_DEFAULT);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, r, "Failed to perform media_filter_set_condition operation.");
+ }
+ }
+
+ __pFilterHandle.reset(pFilterHandle.release());
+
+ return r;
+}
+
+result
+_PlayListImpl::CreateFilter(const Tizen::Base::String& playListName)const
+{
+ std::unique_ptr<char[]> pInputCond;
+ String inputCondition = L"PLAYLIST_NAME = ";
+ String nameExpr(playListName);
+
+ std::unique_ptr<filter_h, FilterHandleDeleter> pFilterHandle(new (std::nothrow) filter_h);
+
+ int ret = media_filter_create(pFilterHandle.get());
+ result r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, r, "Failed to perform media_filter_create operation.");
+
+ if (!nameExpr.IsEmpty())
+ {
+ r = nameExpr.Insert('"', 0);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Insert operation for nameExpr.");
+ r = nameExpr.Insert('"', nameExpr.GetLength());
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Insert operation for nameExpr.");
+
+ r = inputCondition.Append(nameExpr);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation for inputCondition.");
+ }
+
+ if (!inputCondition.IsEmpty())
+ {
+ //CopyToCharArrayN: utility function, converts a osp string to char*
+ pInputCond = std::unique_ptr<char[]>(_StringConverter::CopyToCharArrayN(inputCondition));
+ SysTryReturnResult(NID_CNT, (pInputCond.get())[0], E_SYSTEM, "pInputCond is NULL.");
+
+ SysLog(NID_CNT, "pInputCond is [%s]", pInputCond.get());
+
+ if ((pInputCond.get())[0])
+ {
+ ret = media_filter_set_condition(*(pFilterHandle.get()), pInputCond.get(), MEDIA_CONTENT_COLLATE_DEFAULT);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, r, "Failed to perform media_filter_set_condition operation.");
+ }
+ }
+
+ __pFilterHandle.reset(pFilterHandle.release());
+
+ return r;
+}
+
+int
+_PlayListImpl::GetPlayListItemCount(const Tizen::Base::String& playlistName) const
+{
+ std::unique_ptr<GList, GListDeleter> pItemList;
+ GList* pTemp = NULL;
+ std::unique_ptr<media_playlist_s, PlayListHandleDeleter> pPlaylistHandle;
+ int playlistId = 0;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ int playlistItemCount = 0;
+
+ result r = CreateFilter(playlistName);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, 0, E_DATABASE, "[E_DATABASE] Failed to perform CreateFilter operation.");
+
+ pTemp = pItemList.get();
+ ret = media_playlist_foreach_playlist_from_db(*(__pFilterHandle.get()), MediaPlayListImplCb, &pTemp);
+ r = MapCoreDatabaseErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, r == E_SUCCESS , 0, r,
+ "[%s] Failed to perform media_playlist_foreach_playlist_from_db operation.", GetErrorMessage(r));
+
+ if (pTemp == NULL)
+ {
+ r = E_DATABASE; // No match found.
+ }
+ else
+ {
+ pPlaylistHandle.reset(static_cast<media_playlist_h>(g_list_nth_data(pTemp, 0)));
+ if (pPlaylistHandle.get() != NULL)
+ {
+ ret = media_playlist_get_playlist_id(pPlaylistHandle.get(), &playlistId);
+ r = MapCoreDatabaseErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), 0, r, "[%s] Failed to perform media_playlist_get_playlist_id operation.", GetErrorMessage(r));
+
+ ret = media_playlist_get_media_count_from_db(playlistId, NULL, &playlistItemCount);
+ r = MapCoreDatabaseErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), 0, r, "[%s] Failed to perform media_playlist_get_media_count_from_db operation.", GetErrorMessage(r));
+
+ SysLog(NID_CNT, "playlistItemCount is [%d] for media_playlist_get_media_count_from_db", playlistItemCount);
+ }
+ }
+
+ SetLastResult(r);
+ return playlistItemCount;
+}
+
+Tizen::Base::Collection::IList*
+_PlayListImpl::GetContentInfoListN(const Tizen::Base::String& playlistName) const
+{
+ std::unique_ptr<GList, GListDeleter> pItemList;
+ GList* pTemp = NULL;
+ std::unique_ptr<media_playlist_s, PlayListHandleDeleter> pPlaylistHandle;
+ std::unique_ptr<ArrayList, AllElementsDeleter> pPlayListItemList;
+ int playlistId = 0;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ result r = CreateFilter(playlistName);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, NULL, E_DATABASE, "[E_DATABASE] Failed to perform CreateFilter operation.");
+
+ pTemp = pItemList.get();
+ ret = media_playlist_foreach_playlist_from_db(*(__pFilterHandle.get()), MediaPlayListImplCb, &pTemp);
+ r = MapCoreDatabaseErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, r == E_SUCCESS , NULL, r,
+ "[%s] Failed to perform media_playlist_foreach_playlist_from_db operation.", GetErrorMessage(r));
+
+ if (pTemp == NULL)
+ {
+ r = E_DATABASE; // No match found.
+ }
+ else
+ {
+ pPlaylistHandle.reset(static_cast<media_playlist_h>(g_list_nth_data(pTemp, 0)));
+ if (pPlaylistHandle.get() != NULL)
+ {
+ int playlistItemCount = 0;
+
+ ret = media_playlist_get_playlist_id(pPlaylistHandle.get(), &playlistId);
+ r = MapCoreDatabaseErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), NULL, r,
+ "[%s] Failed to perform media_playlist_get_playlist_id operation.", GetErrorMessage(r));
+
+ ret = media_playlist_get_media_count_from_db(playlistId, NULL, &playlistItemCount);
+ r = MapCoreDatabaseErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), NULL, r,
+ "[%s] Failed to perform media_playlist_get_media_count_from_db operation.", GetErrorMessage(r));
+
+ SysLog(NID_CNT, "playlistItemCount is [%d] for media_playlist_get_media_count_from_db", playlistItemCount);
+
+ pPlayListItemList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
+ SysTryReturn(NID_CNT, pPlayListItemList != null, NULL, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] FinalOutList is null.");
+
+ r = pPlayListItemList->Construct();
+ SysTryReturn(NID_CNT, !IsFailed(r), NULL, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to construct pPlayListItemList ArrayList.");
+
+ if (playlistItemCount > 0)
+ {
+ r = FillPlayListInfo(playlistId, pPlayListItemList.get());
+ SysTryReturn(NID_CNT, !IsFailed(r), NULL, E_DATABASE, "Failed to perform FillPlayListInfo operation.");
+ }
+ }
+ }
+
+ SetLastResult(r);
+ return pPlayListItemList.release();
+}
+
+result
+_PlayListImpl::FillPlayListInfo(int playlistId, ArrayList* pPlayListItemList) const
+{
+ std::unique_ptr<GList, GListDeleter> pItemList;
+ GList* pTemp = NULL;
+ std::unique_ptr<media_info_s, MediaHandleDeleter> pMediaHandle;
+
+ ContentInfo::_ContentData* pContentData = null;
+ ImageContentInfo::_ImageContentData* pImageContentData = null;
+ AudioContentInfo::_AudioContentData* pAudioContentData = null;
+ VideoContentInfo::_VideoContentData* pVideoContentData = null;
+
+ std::unique_ptr<ImageContentInfo> pImageContentInfo;
+ std::unique_ptr<AudioContentInfo> pAudioContentInfo;
+ std::unique_ptr<VideoContentInfo> pVideoContentInfo;
+ std::unique_ptr<OtherContentInfo> pOtherContentInfo;
+
+ //SysTryReturn(NID_CNT, pPlayListItemList != NULL , r, r, "[E_SUCCESS] pPlayListItemList is null");
+
+ pTemp = pItemList.get();
+ int ret = media_playlist_foreach_media_from_db(playlistId, NULL, PlaylistItemsCb, &pTemp);
+ result r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform media_playlist_foreach_media_from_db operation.");
+
+ media_content_type_e mediaType = MEDIA_CONTENT_TYPE_OTHERS;
+
+ if (pTemp)
+ {
+ for (int idx = 0; idx < (int)g_list_length(pTemp); idx++)
+ {
+ pMediaHandle.reset(static_cast<media_info_h>(g_list_nth_data(pTemp, idx)));
+
+ ret = media_info_get_media_type(pMediaHandle.get(), &mediaType);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform media_info_get_media_type.");
+
+ switch (mediaType)
+ {
+ case MEDIA_CONTENT_TYPE_IMAGE:
+ pImageContentInfo = std::unique_ptr<ImageContentInfo>(new (std::nothrow) ImageContentInfo);
+ SysTryReturnResult(NID_CNT, pImageContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pImageContentInfo.");
+
+ pContentData = pImageContentInfo->GetContentData();
+ SysTryReturnResult(NID_CNT, pContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ pImageContentData = pImageContentInfo->GetImageContentData();
+ SysTryReturnResult(NID_CNT, pImageContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ r = _ContentUtility::FillContentData(pMediaHandle.get(), pContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillContentData operation.");
+
+ r = _ContentUtility::FillImageContentData(pMediaHandle.get(), pImageContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform GetDataFromImageTable operation.");
+
+ // Shallow copy, adds just the pointer: not the element
+ r = pPlayListItemList->Add(*(pImageContentInfo.release()));
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Add operation for ArrayList.");
+
+ break;
+ case MEDIA_CONTENT_TYPE_MUSIC:
+ //fall through
+ case MEDIA_CONTENT_TYPE_SOUND:
+ pAudioContentInfo = std::unique_ptr<AudioContentInfo>(new (std::nothrow) AudioContentInfo);
+ SysTryReturnResult(NID_CNT, pAudioContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pAudioContentInfo.");
+
+ pContentData = pAudioContentInfo->GetContentData();
+ SysTryReturnResult(NID_CNT, pContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ pAudioContentData = pAudioContentInfo->GetAudioContentData();
+ SysTryReturnResult(NID_CNT, pAudioContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ r = _ContentUtility::FillContentData(pMediaHandle.get(), pContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillContentData operation.");
+
+ r = _ContentUtility::FillAudioContentData(pMediaHandle.get(), pAudioContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillAudioContentData operation.");
+
+ // Shallow copy, adds just the pointer: not the element
+ r = pPlayListItemList->Add(*(pAudioContentInfo.release()));
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Add operation for __pFinalOutList.");
+
+ break;
+ case MEDIA_CONTENT_TYPE_VIDEO:
+ pVideoContentInfo = std::unique_ptr<VideoContentInfo>(new (std::nothrow) VideoContentInfo);
+ SysTryReturnResult(NID_CNT, pVideoContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pVideoContentInfo.");
+
+ pContentData = pVideoContentInfo->GetContentData();
+ SysTryReturnResult(NID_CNT, pContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ pVideoContentData = pVideoContentInfo->GetVideoContentData();
+ SysTryReturnResult(NID_CNT, pVideoContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ r = _ContentUtility::FillContentData(pMediaHandle.get(), pContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillContentData operation.");
+
+ r = _ContentUtility::FillVideoContentData(pMediaHandle.get(), pVideoContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillVideoContentData operation.");
+
+ // Shallow copy, adds just the pointer: not the element
+ r = pPlayListItemList->Add(*(pVideoContentInfo.release()));
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Add operation for ArrayList.");
+
+ break;
+ case MEDIA_CONTENT_TYPE_OTHERS:
+ pOtherContentInfo = std::unique_ptr<OtherContentInfo>(new (std::nothrow) OtherContentInfo);
+ SysTryReturnResult(NID_CNT, pOtherContentInfo.get() != null, E_OUT_OF_MEMORY, "Failed to create pOtherContentInfo.");
+
+ pContentData = pOtherContentInfo->GetContentData();
+ SysTryReturnResult(NID_CNT, pContentData != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ r = _ContentUtility::FillContentData(pMediaHandle.get(), pContentData);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform FillContentData operation.");
+
+ // Shallow copy, adds just the pointer: not the element
+ r = pPlayListItemList->Add(*(pOtherContentInfo.release()));
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform Add operation for ArrayList.");
+
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ return r;
+}
+
+result
+_PlayListImpl::AddItemInternal(media_playlist_h playListHandle, const ContentId& contentId)
+{
+ String uuidStr = L"";
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ result r = E_SUCCESS;
+
+ uuidStr = contentId.ToString();
+ std::unique_ptr<char[]> pInputCond(_StringConverter::CopyToCharArrayN(uuidStr));
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_SYSTEM, "Failed to perform CopyToCharArrayN operation.");
+
+ ret = media_playlist_add_media(playListHandle, pInputCond.get());
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform media_playlist_add_media operation.");
+
+ ret = media_playlist_update_to_db(playListHandle);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform media_playlist_update_to_db operation.");
+
+ return r;
+}
+
+result
+_PlayListImpl::AddItem(const Tizen::Base::String& playlistName, const ContentId& contentId)
+{
+ std::unique_ptr<media_playlist_s, PlayListHandleDeleter> pPlayListHandle;
+ media_playlist_h tempHandle = NULL;
+
+ result r = CreateFilter(playlistName);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_DATABASE, "Failed to perform CreateFilter operation.");
+
+ tempHandle = pPlayListHandle.get();
+ r = GetPlayListHandle(&tempHandle);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_DATABASE, "Failed to perform GetPlayListHandle operation.");
+
+ r = AddItemInternal(tempHandle, contentId);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform AddItemInternal operation.");
+
+ return r;
+}
+
+result
+_PlayListImpl::AddItems(const Tizen::Base::String& playlistName, const Tizen::Base::Collection::IList& contentIdList)
+{
+ int listCount = contentIdList.GetCount();
+ ContentId *pContentId = NULL;
+ std::unique_ptr<media_playlist_s, PlayListHandleDeleter> pPlayListHandle;
+ media_playlist_h tempHandle = NULL;
+
+ result r = CreateFilter(playlistName);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_DATABASE, "Failed to perform CreateFilter operation.");
+
+ tempHandle = pPlayListHandle.get();
+ r = GetPlayListHandle(&tempHandle);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_DATABASE, "Failed to perform GetPlayListHandle operation.");
+
+ for(int index = 0; index < listCount; index++)
+ {
+ pContentId = (ContentId*)contentIdList.GetAt(index);
+ r = AddItemInternal(tempHandle, *pContentId);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform AddItemInternal operation.");
+ }
+
+ return r;
+}
+
+result
+_PlayListImpl::RemoveItem(const ContentId& contentId)
+{
+ std::unique_ptr<media_playlist_s, PlayListHandleDeleter> pPlayListHandle;
+ media_playlist_h tempHandle = NULL;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ std::unique_ptr<GList, GListDeleter> pItemList;
+ GList* pTemp = NULL;
+
+ result r = CreateFilterUsingContentId(contentId);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_DATABASE, "Failed to perform CreateFilterUsingContentId operation.");
+
+ tempHandle = pPlayListHandle.get();
+ r = GetPlayListHandle(&tempHandle);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_DATABASE, "Failed to perform GetPlayListHandle operation.");
+
+ if (tempHandle != NULL)
+ {
+ int playlistId = 0;
+ int playlistMemberId = 0;
+
+ ret = media_playlist_get_playlist_id(tempHandle, &playlistId);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform media_playlist_get_playlist_id operation.");
+
+ pTemp = pItemList.get();
+ int ret = media_playlist_foreach_media_from_db(playlistId, *(__pFilterHandle.get()), PlaylistImplItemCb, &pTemp);
+ result r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS , r, "Failed to perform media_playlist_foreach_media_from_db operation.");
+
+ if (pTemp != NULL)
+ {
+ playlistMemberId = (int)g_list_nth_data(pTemp, 0);
+
+ ret = media_playlist_remove_media(tempHandle, playlistMemberId);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform media_playlist_remove_media operation.");
+
+ ret = media_playlist_update_to_db(tempHandle);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform media_playlist_update_to_db operation.");
+ }
+ }
+
+ return r;
+}
+
+result
+_PlayListImpl::RemoveItems(const Tizen::Base::Collection::IList& contentIdList)
+{
+ int listCount = contentIdList.GetCount();
+ ContentId *pContentId = NULL;
+ result r = E_SUCCESS;
+
+ for (int index = 0; index < listCount; index++)
+ {
+ pContentId = (ContentId*)contentIdList.GetAt(index);
+ r = RemoveItem(*pContentId);
+ }
+
+ return r;
+}
+
+result
+_PlayListImpl::SetPlalyListName(const Tizen::Base::String& oldName, const Tizen::Base::String& newName)
+{
+ std::unique_ptr<media_playlist_s, PlayListHandleDeleter> pPlayListHandle;
+ media_playlist_h tempHandle = NULL;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ result r = CreateFilter(oldName);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_DATABASE, "Failed to perform CreateFilter operation.");
+
+ tempHandle = pPlayListHandle.get();
+ r = GetPlayListHandle(&tempHandle);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_DATABASE, "Failed to perform GetPlayListHandle operation.");
+
+ std::unique_ptr<char[]> pInputCond(_StringConverter::CopyToCharArrayN(newName));
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_OUT_OF_MEMORY, "Failed to perform CopyToCharArrayN operation.");
+
+ ret = media_playlist_set_name(tempHandle, pInputCond.get());
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform media_playlist_set_name operation.");
+
+ ret = media_playlist_update_to_db(tempHandle);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform media_playlist_update_to_db operation.");
+
+ return r;
+}
+result
+_PlayListImpl::SetorGetPlayOrder(const ContentId& contentId, int& playOrder, bool isSet) const
+{
+ std::unique_ptr<media_playlist_s, PlayListHandleDeleter> pPlayListHandle;
+ media_playlist_h tempHandle = NULL;
+ std::unique_ptr<GList, GListDeleter> pItemList;
+ GList* pTemp = NULL;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ SysTryReturnResult(NID_CNT, contentId != UuId::GetInvalidUuId(), E_INVALID_ARG, "The specified parameter is invalid.");
+
+ result r = CreateFilterUsingContentId(contentId);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_DATABASE, "Failed to perform CreateFilterUsingContentId operation.");
+
+ tempHandle = pPlayListHandle.get();
+ r = GetPlayListHandle(&tempHandle);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_DATABASE, "Failed to perform GetPlayListHandle operation.");
+
+ if (tempHandle != NULL)
+ {
+ int playlistId = 0;
+ int playlistMemberId = 0;
+
+ ret = media_playlist_get_playlist_id(tempHandle, &playlistId);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform media_playlist_get_playlist_id operation.");
+
+ pTemp = pItemList.get();
+ int ret = media_playlist_foreach_media_from_db(playlistId, *(__pFilterHandle.get()), PlaylistImplItemCb, &pTemp);
+ result r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS , r, "media_playlist_foreach_media_from_db failed.");
+
+ if (pTemp != NULL)
+ {
+ playlistMemberId = (int)g_list_nth_data(pTemp, 0);
+
+ if (isSet == true)
+ {
+ ret = media_playlist_set_play_order(tempHandle, playlistMemberId, playOrder);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform media_playlist_set_play_order operation.");
+
+ ret = media_playlist_update_to_db(tempHandle);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform media_playlist_update_to_db operation.");
+ }
+ else
+ {
+ ret = media_playlist_get_play_order(tempHandle, playlistMemberId, &playOrder);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform media_playlist_set_play_order operation.");
+ }
+ }
+ }
+
+ return r;
+}
+result
+_PlayListImpl::SetPlayOrder(const ContentId& contentId, const ContentId& nextContentId)
+{
+ int playOrder = GetPlayOrder(contentId) + 1;
+ result r = GetLastResult();
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS , r, "Failed to perform GetPlayOrder operation.");
+
+ r = SetorGetPlayOrder(nextContentId, playOrder, true);
+
+ return r;
+}
+
+int
+_PlayListImpl::GetPlayOrder(const ContentId& contentId) const
+{
+ int playOrder = 0;
+
+ result r = SetorGetPlayOrder(contentId, playOrder, false);
+
+ SetLastResult(r);
+ return playOrder;
+}
+
+result
+_PlayListImpl::GetPlayListHandle(media_playlist_h* pPlayListHandle) const
+{
+ std::unique_ptr<GList, GListDeleter> pItemList;
+ GList* pTemp = NULL;
+
+ pTemp = pItemList.get();
+ int ret = media_playlist_foreach_playlist_from_db(*(__pFilterHandle.get()), MediaPlayListImplCb, &pTemp);
+ result r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS , r, "Failed to perform media_playlist_foreach_playlist_from_db operation.");
+
+ if (pTemp == NULL)
+ {
+ r = E_INVALID_ARG; // No match found.
+ }
+ else
+ {
+ *pPlayListHandle = (media_playlist_h)g_list_nth_data(pTemp, 0);
+ }
+
+ return r;
+}
+
+result
+_PlayListImpl::MapCoreErrorToNativeResult(int reason) const
+{
+ result r = E_SUCCESS;
+
+ switch (reason)
+ {
+ case MEDIA_CONTENT_ERROR_NONE:
+ r = E_SUCCESS;
+ break;
+
+ case MEDIA_CONTENT_ERROR_INVALID_PARAMETER:
+ r = E_INVALID_ARG;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_INVALID_PARAMETER");
+ break;
+
+ case MEDIA_CONTENT_ERROR_DB_FAILED:
+ r = E_DATABASE;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_FAILED");
+ break;
+
+ case MEDIA_CONTENT_ERROR_DB_BUSY:
+ r = E_SERVICE_BUSY;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_BUSY");
+ break;
+
+ default:
+ SysLog(NID_CNT, "default");
+ r = E_DATABASE;
+ break;
+ }
+ return r;
+}
+
+result
+_PlayListImpl::MapCoreDatabaseErrorToNativeResult(int reason) const
+{
+ result r = E_SUCCESS;
+
+ switch (reason)
+ {
+ case MEDIA_CONTENT_ERROR_NONE:
+ r = E_SUCCESS;
+ break;
+
+ case MEDIA_CONTENT_ERROR_DB_FAILED:
+ r = E_DATABASE;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_FAILED");
+ break;
+
+ case MEDIA_CONTENT_ERROR_DB_BUSY:
+ r = E_SERVICE_BUSY;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_BUSY");
+ break;
+
+ default:
+ SysLog(NID_CNT, "default");
+ r = E_DATABASE;
+ break;
+ }
+ return r;
+}
+
+bool
+MediaPlayListImplCb(media_playlist_h playlistHandle, void *pUserData)
+{
+ media_playlist_h newPlayListHandle = NULL;
+ media_playlist_clone(&newPlayListHandle, playlistHandle);
+
+ GList** pList = (GList**)pUserData;
+ *pList = g_list_append(*pList, newPlayListHandle);
+
+ return true;
+}
+
+// This callback appends List with playlistMemberId's
+bool
+PlaylistImplItemCb(int playlistMemberId, media_info_h media, void *pUserData)
+{
+ GList** pList = (GList**)pUserData;
+ *pList = g_list_append(*pList, (gpointer)playlistMemberId);
+
+ return true;
+}
+
+// This callback appends List with media handles
+bool
+PlaylistItemsCb(int playlistId, media_info_h media, void *pUserData)
+{
+ media_info_h new_media = NULL;
+ media_info_clone(&new_media, media);
+
+ GList** pList = (GList**)pUserData;
+ *pList = g_list_append(*pList, new_media);
+
+ return true;
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_PlayListStatisticsImpl.cpp
+ * @brief This is the implementation file for the %_PlayListStatisticsImpl class.
+ *
+ * This file contains implementation of the %_PlayListStatisticsImpl class.
+ */
+
+#include <FBaseSysLog.h>
+#include <FBaseInteger.h>
+#include <FBaseLongLong.h>
+#include <FBaseFloat.h>
+#include <FCntPlayList.h>
+#include <FCntPlayListManager.h>
+#include <FBase_StringConverter.h>
+#include <FCnt_PlayListImpl.h>
+#include <FCnt_PlayListManagerImpl.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace Content
+{
+
+// Declaration for Callback function registered to playlist details
+bool MediaPlayListCb(media_playlist_h playlistHandle, void *pUserData);
+
+_PlayListManagerImpl::_PlayListManagerImpl(void)
+ : Object()
+ , __pFilterHandle(NULL)
+{
+
+}
+
+
+//(disconnects the DB connection)
+_PlayListManagerImpl::~_PlayListManagerImpl(void)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ result r = E_SUCCESS;
+
+ ret = media_content_disconnect();
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryLog(r == E_SUCCESS, "[%s] Propagating for media_content_disconnect.", GetErrorMessage(r));
+}
+
+ _PlayListManagerImpl*
+ _PlayListManagerImpl::GetInstance(PlayListManager& playListManager)
+{
+ return (&playListManager != null) ? playListManager.__pImpl : null;
+}
+
+const _PlayListManagerImpl*
+_PlayListManagerImpl::GetInstance(const PlayListManager& playListManager)
+{
+ return (&playListManager != null) ? playListManager.__pImpl : null;
+}
+
+result
+_PlayListManagerImpl::Construct(void)
+{
+ result r = E_SUCCESS;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ ret = media_content_connect();
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS , r, "Propagating for media_content_disconnect.");
+
+ return r;
+}
+
+result
+_PlayListManagerImpl::CreateFilter(const Tizen::Base::String& playListName) const
+{
+ std::unique_ptr<char[]> pInputCond;
+ std::unique_ptr<filter_h, FilterDeleter> pFilterHandle(new (std::nothrow) filter_h);
+ String inputCondition = L"PLAYLIST_NAME = ";
+ String nameExpr(playListName);
+
+ int ret = media_filter_create(pFilterHandle.get());
+ result r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, r, "Failed to perform media_filter_create operation.");
+
+ if (!nameExpr.IsEmpty())
+ {
+ r = nameExpr.Insert('"', 0);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Insert operation for nameExpr.");
+ r = nameExpr.Insert('"', nameExpr.GetLength());
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Insert operation for nameExpr.");
+
+ r = inputCondition.Append(nameExpr);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, r, "Failed to perform Append operation for inputCondition.");
+ }
+
+ if (!inputCondition.IsEmpty())
+ {
+ //CopyToCharArrayN: utility function, converts a osp string to char*
+ pInputCond = std::unique_ptr<char[]>(_StringConverter::CopyToCharArrayN(inputCondition));
+ SysTryReturnResult(NID_CNT, (pInputCond.get())[0] != null, E_SYSTEM, "pInputCond is NULL.");
+
+ SysLog(NID_CNT, "pInputCond is [%s]", pInputCond.get());
+
+ if ((pInputCond.get())[0] != null)
+ {
+ ret = media_filter_set_condition(*(pFilterHandle.get()), pInputCond.get(), MEDIA_CONTENT_COLLATE_DEFAULT);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, ret == MEDIA_CONTENT_ERROR_NONE, r, "Failed to perform media_filter_set_condition operation.");
+ }
+ }
+
+ __pFilterHandle.reset(pFilterHandle.release());
+
+ return r;
+}
+
+PlayList*
+_PlayListManagerImpl::GetPlayListN(const Tizen::Base::String& playListName) const
+{
+ std::unique_ptr<GList, GListDeleter> pItemList;
+ GList* pTempList = null;
+ std::unique_ptr<media_playlist_s, PlayListHandleDeleter> playListHandle;
+ int playlistId = 0;
+ std::unique_ptr<PlayList> pFinalOutplayList;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ result r = CreateFilter(playListName);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_DATABASE, "[E_DATABASE] Failed to perform CreateFilter operation.");
+
+ pTempList = pItemList.get();
+ ret = media_playlist_foreach_playlist_from_db(*(__pFilterHandle.get()), MediaPlayListCb, &pTempList);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, r == E_SUCCESS , null, r, "[%s] Failed to perform media_playlist_foreach_playlist_from_db operation.", GetErrorMessage(r));
+
+ if (pTempList == NULL)
+ {
+ r = E_INVALID_ARG; // No match found.
+ }
+ else
+ {
+ playListHandle.reset(static_cast<media_playlist_h>(g_list_nth_data(pTempList, 0)));
+ if (playListHandle.get() != NULL)
+ {
+ ret = media_playlist_get_playlist_id(playListHandle.get(), &playlistId);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] Failed to perform media_playlist_get_playlist_id operation.", GetErrorMessage(r));
+
+ pFinalOutplayList = std::unique_ptr<PlayList>(new (std::nothrow) PlayList());
+ SysTryReturn(NID_CNT, pFinalOutplayList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] FinalOutList is null.");
+
+ r = pFinalOutplayList->ConstructPlayList(playListName);
+ SysTryReturn(NID_CNT, r == E_SUCCESS, null, r, "[%s] Failed to perform ConstructPlayList operation for pFinalOutplayList.", GetErrorMessage(r));
+ }
+ }
+
+ SetLastResult(r);
+ return pFinalOutplayList.release();
+}
+
+result
+_PlayListManagerImpl::RemovePlayList(const Tizen::Base::String& playListName)
+{
+ std::unique_ptr<GList, GListDeleter> pItemList;
+ GList* pTempList = null;
+ std::unique_ptr<media_playlist_s, PlayListHandleDeleter> playListHandle;
+ int playlistId = 0;
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ result r = CreateFilter(playListName);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS, E_DATABASE, "Failed to perform CreateFilter operation.");
+
+ pTempList = pItemList.get();
+ ret = media_playlist_foreach_playlist_from_db(*(__pFilterHandle.get()), MediaPlayListCb, &pTempList);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, r == E_SUCCESS , r, "Failed to perform media_playlist_foreach_playlist_from_db operation.");
+
+ if (pTempList == NULL)
+ {
+ r = E_INVALID_ARG; // No match found.
+ }
+ else
+ {
+ playListHandle.reset(static_cast<media_playlist_h>(g_list_nth_data(pTempList, 0)));
+
+ if (playListHandle.get() != NULL)
+ {
+ ret = media_playlist_get_playlist_id(playListHandle.get(), &playlistId);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform media_playlist_get_playlist_id operation.");
+
+ ret = media_playlist_delete_from_db(playlistId);
+ r = MapCoreErrorToNativeResult(ret);
+ SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Failed to perform media_playlist_delete_from_db operation.");
+ }
+ }
+
+ return r;
+}
+
+int
+_PlayListManagerImpl::GetAllPlayListCount(void) const
+{
+ int playlistCount = 0;
+
+ int ret = media_playlist_get_playlist_count_from_db(NULL, &playlistCount);
+ result r = MapCoreDatabaseErrorToNativeResult(ret);
+
+ SysLog(NID_CNT, "GetAllPlayListCount is [%d] and result is [%s]", playlistCount, GetErrorMessage(r));
+
+ SetLastResult(r);
+ return playlistCount;
+}
+
+Tizen::Base::Collection::IList*
+_PlayListManagerImpl::GetAllPlayListNameN(void) const
+{
+ std::unique_ptr<GList, GListDeleter> pItemList;
+ GList* pTempList = null;
+ std::unique_ptr<media_playlist_s, PlayListHandleDeleter> playListHandle;
+ std::unique_ptr<char> pPlayListName;
+ char* pTempListName = null;
+ std::unique_ptr<Object> pValue;
+ std::unique_ptr<ArrayList, AllElementsDeleter> pNamesList;
+
+ pTempList = pItemList.get();
+ int ret = media_playlist_foreach_playlist_from_db(NULL, MediaPlayListCb, &pTempList);
+ result r = MapCoreDatabaseErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, r == E_SUCCESS , null, r, "[%s] Failed to perform media_playlist_foreach_playlist_from_db operation.", GetErrorMessage(r));
+
+ pNamesList = std::unique_ptr<ArrayList, AllElementsDeleter>(new (std::nothrow) ArrayList());
+ SysTryReturn(NID_CNT, pNamesList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] FinalOutList is null.");
+
+ r = pNamesList->Construct();
+ SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ if (pTempList)
+ {
+ for (int idx = 0; idx < (int)g_list_length(pTempList); idx++)
+ {
+ playListHandle.reset(static_cast<media_playlist_h>(g_list_nth_data(pTempList, idx)));
+
+ if (playListHandle.get() != NULL)
+ {
+ pTempListName = pPlayListName.get();
+ ret = media_playlist_get_name(playListHandle.get(), &pTempListName);
+ r = MapCoreDatabaseErrorToNativeResult(ret);
+ SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] Failed to perform media_playlist_get_name operation.", GetErrorMessage(r));
+
+ if (pTempListName != null)
+ {
+ SysLog(NID_CNT, "pPlayListName is [%s]", pTempListName);
+
+ pValue = std::unique_ptr<Object>(new (std::nothrow) String(pTempListName));
+ SysTryReturn(NID_CNT, pValue != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ if (pValue.get() != NULL)
+ {
+ r = pNamesList->Add(*(pValue.release()));
+ SysTryReturn(NID_CNT, !IsFailed(r), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ }
+ }
+ }
+ }
+
+ SetLastResult(r);
+ return pNamesList.release();
+}
+
+result
+_PlayListManagerImpl::MapCoreErrorToNativeResult(int reason) const
+{
+ result r = E_SUCCESS;
+
+ switch (reason)
+ {
+ case MEDIA_CONTENT_ERROR_NONE:
+ r = E_SUCCESS;
+ break;
+
+ case MEDIA_CONTENT_ERROR_INVALID_PARAMETER:
+ r = E_INVALID_ARG;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_INVALID_PARAMETER");
+ break;
+
+ case MEDIA_CONTENT_ERROR_DB_FAILED:
+ r = E_DATABASE;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_FAILED");
+ break;
+
+ case MEDIA_CONTENT_ERROR_DB_BUSY:
+ r = E_SERVICE_BUSY;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_BUSY");
+ break;
+
+ default:
+ SysLog(NID_CNT, "default");
+ r = E_DATABASE;
+ break;
+ }
+ return r;
+}
+
+result
+_PlayListManagerImpl::MapCoreDatabaseErrorToNativeResult(int reason) const
+{
+ result r = E_SUCCESS;
+
+ switch (reason)
+ {
+ case MEDIA_CONTENT_ERROR_NONE:
+ r = E_SUCCESS;
+ break;
+
+ case MEDIA_CONTENT_ERROR_DB_FAILED:
+ r = E_DATABASE;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_FAILED");
+ break;
+
+ case MEDIA_CONTENT_ERROR_DB_BUSY:
+ r = E_SERVICE_BUSY;
+ SysLog(NID_CNT, "MEDIA_CONTENT_ERROR_DB_BUSY");
+ break;
+
+ default:
+ SysLog(NID_CNT, "default");
+ r = E_DATABASE;
+ break;
+ }
+ return r;
+}
+
+bool
+MediaPlayListCb(media_playlist_h playlistHandle, void *pUserData)
+{
+ media_playlist_h newPlayListHandle = NULL;
+ media_playlist_clone(&newPlayListHandle, playlistHandle);
+
+ GList** pList = (GList**)pUserData;
+ *pList = g_list_append(*pList, newPlayListHandle);
+
+ return true;
+}
+
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_VideoMetadataImpl.cpp
+ * @brief This is the implementation file for the %_VideoMetadataImpl class.
+ *
+ * This file contains implementation of the %_VideoMetadataImpl class.
+ */
+
+// includes
+#include <FBaseSysLog.h>
+#include <FCntVideoMetadata.h>
+#include <FCnt_VideoMetadataImpl.h>
+#include <FGrp_BitmapImpl.h>
+
+// using namespaces
+using namespace std;
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+
+namespace Tizen { namespace Content
+{
+
+_VideoMetadataImpl::_VideoMetadataImpl(void)
+ : Object()
+{
+ unique_ptr<VideoMeta, VideoMetaDeleter> pNewVideoMeta(new (nothrow) VideoMeta());
+ if (pNewVideoMeta != null)
+ {
+ __pVideoMeta = move(pNewVideoMeta);
+ }
+ else
+ {
+ __pVideoMeta = null;
+ SysLog(NID_CNT, "The memory is insufficient.");
+ }
+}
+
+_VideoMetadataImpl::~_VideoMetadataImpl(void)
+{
+
+}
+
+_VideoMetadataImpl*
+_VideoMetadataImpl::GetInstance(VideoMetadata& videoMetadata)
+{
+ return videoMetadata.__pImpl;
+}
+
+const _VideoMetadataImpl*
+_VideoMetadataImpl::GetInstance(const VideoMetadata& videoMetadata)
+{
+ return videoMetadata.__pImpl;
+}
+
+result
+_VideoMetadataImpl::SetVideoMetadata(const VideoMeta* pVideoMeta)
+{
+ ClearLastResult();
+
+ SysTryReturnResult(NID_CNT, pVideoMeta != null, E_INVALID_ARG, "pVideoMeta is null.");
+
+ __pVideoMeta->width = pVideoMeta->width;
+ __pVideoMeta->height = pVideoMeta->height;
+ __pVideoMeta->framerate = pVideoMeta->framerate;
+ __pVideoMeta->audioBitrate = pVideoMeta->audioBitrate;
+ __pVideoMeta->videoBitrate = pVideoMeta->videoBitrate;
+ __pVideoMeta->duration = pVideoMeta->duration;
+ __pVideoMeta->contentPath = pVideoMeta->contentPath;
+
+ if (pVideoMeta->pGenre != null)
+ {
+ __pVideoMeta->pGenre = new (nothrow) String(*(pVideoMeta->pGenre));
+ SysTryReturnResult(NID_CNT, __pVideoMeta->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
+ }
+ if (pVideoMeta->pAlbumArt != null)
+ {
+ __pVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*(pVideoMeta->pAlbumArt));
+ if (__pVideoMeta->pAlbumArt == null)
+ {
+ SysLog(NID_CNT, "_BitmapImpl::CloneN failed.");
+ // Because album art is one of the metadata, it is not exception in this function but is exception in _AudioMetadataImpl::GetAlbumArtN().
+ }
+ }
+
+ return E_SUCCESS;
+}
+
+VideoMeta*
+_VideoMetadataImpl::GetVideoMetadata(void) const
+{
+ return __pVideoMeta.get();
+}
+
+_VideoMetadataImpl::_VideoMetadataImpl(const _VideoMetadataImpl& rhs)
+ : Object()
+{
+ unique_ptr<VideoMeta, VideoMetaDeleter> pNewVideoMeta(new (nothrow) VideoMeta());
+ if (pNewVideoMeta != null)
+ {
+ pNewVideoMeta->width = (rhs.__pVideoMeta)->width;
+ pNewVideoMeta->height = (rhs.__pVideoMeta)->height;
+ pNewVideoMeta->framerate = (rhs.__pVideoMeta)->framerate;
+ pNewVideoMeta->audioBitrate = (rhs.__pVideoMeta)->audioBitrate;
+ pNewVideoMeta->videoBitrate = (rhs.__pVideoMeta)->videoBitrate;
+ pNewVideoMeta->duration = (rhs.__pVideoMeta)->duration;
+ pNewVideoMeta->contentPath = (rhs.__pVideoMeta)->contentPath;
+
+ if ((rhs.__pVideoMeta)->pGenre != null)
+ {
+ pNewVideoMeta->pGenre = new (nothrow) String(*((rhs.__pVideoMeta)->pGenre));
+ if (pNewVideoMeta->pGenre == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+ if ((rhs.__pVideoMeta)->pAlbumArt != null)
+ {
+ pNewVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*((rhs.__pVideoMeta)->pAlbumArt));
+ if (pNewVideoMeta->pAlbumArt == null)
+ {
+ SysLog(NID_CNT, "The memory is insufficient.");
+ return;
+ }
+ }
+
+ __pVideoMeta = move(pNewVideoMeta);
+ }
+ else
+ {
+ __pVideoMeta = null;
+ SysLog(NID_CNT, "The memory is insufficient.");
+ }
+}
+
+_VideoMetadataImpl&
+_VideoMetadataImpl::operator =(const _VideoMetadataImpl& rhs)
+{
+ // check for self-assignment
+ if (this == &rhs)
+ {
+ return *this;
+ }
+
+ // __pVideoMeta
+ if (__pVideoMeta != null && (rhs.__pVideoMeta) != null)
+ {
+ // DeleteMetadata(__pVideoMeta);
+ // __pVideoMeta = new (nothrow) VideoMeta;
+
+ __pVideoMeta.reset(new (nothrow) VideoMeta);
+ }
+ else if (__pVideoMeta != null)
+ {
+ //DeleteMetadata(__pVideoMeta);
+
+ __pVideoMeta.reset(null);
+ return *this;
+ }
+ else if ((rhs.__pVideoMeta) != null)
+ {
+ //__pVideoMeta = new (nothrow) VideoMeta;
+
+ __pVideoMeta.reset(new (nothrow) VideoMeta);
+ }
+ else
+ {
+ // __pVideoMeta and rhs.__pVideoMeta are null.
+ return *this;
+ }
+
+ __pVideoMeta->width = (rhs.__pVideoMeta)->width;
+ __pVideoMeta->height = (rhs.__pVideoMeta)->height;
+ __pVideoMeta->framerate = (rhs.__pVideoMeta)->framerate;
+ __pVideoMeta->audioBitrate = (rhs.__pVideoMeta)->audioBitrate;
+ __pVideoMeta->videoBitrate = (rhs.__pVideoMeta)->videoBitrate;
+ __pVideoMeta->duration = (rhs.__pVideoMeta)->duration;
+ __pVideoMeta->contentPath = (rhs.__pVideoMeta)->contentPath;
+
+ //pGenre
+ if (__pVideoMeta->pGenre != null && (rhs.__pVideoMeta)->pGenre != null)
+ {
+ // delete previous data
+ delete __pVideoMeta->pGenre;
+ __pVideoMeta->pGenre = null;
+
+ __pVideoMeta->pGenre = new String(*((rhs.__pVideoMeta)->pGenre));
+ }
+ else if (__pVideoMeta->pGenre != null)
+ {
+ delete __pVideoMeta->pGenre;
+ __pVideoMeta->pGenre = null;
+ }
+ else if ((rhs.__pVideoMeta)->pGenre != null)
+ {
+ __pVideoMeta->pGenre = new String(*((rhs.__pVideoMeta)->pGenre));
+ }
+
+ // pAlbumArt
+ if (__pVideoMeta->pAlbumArt != null && (rhs.__pVideoMeta)->pAlbumArt != null)
+ {
+ // delete previous data
+ delete __pVideoMeta->pAlbumArt;
+ __pVideoMeta->pAlbumArt = null;
+
+ __pVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*((rhs.__pVideoMeta)->pAlbumArt));
+ }
+ else if (__pVideoMeta->pAlbumArt != null)
+ {
+ delete __pVideoMeta->pAlbumArt;
+ __pVideoMeta->pAlbumArt = null;
+ }
+ else if ((rhs.__pVideoMeta)->pAlbumArt != null)
+ {
+ __pVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*((rhs.__pVideoMeta)->pAlbumArt));
+ }
+
+ SysLog(NID_CNT, "_VideoMetadataImpl::operator =(const _VideoMetadataImpl& rhs) is called.");
+ return *this;
+}
+
+bool
+_VideoMetadataImpl::Equals(const Tizen::Base::Object& rhs) const
+{
+ const _VideoMetadataImpl* pRhs = dynamic_cast <const _VideoMetadataImpl*>(&rhs);
+ if (pRhs == null)
+ {
+ return false;
+ }
+
+ if (this->GetAudioBitrate() != pRhs->GetAudioBitrate())
+ {
+ return false;
+ }
+ if (this->GetDuration() != pRhs->GetDuration())
+ {
+ return false;
+ }
+ if (this->GetFramerate() != pRhs->GetFramerate())
+ {
+ return false;
+ }
+ if (!((this->GetGenre()).Equals(pRhs->GetGenre())))
+ {
+ return false;
+ }
+ if (this->GetHeight() != pRhs->GetHeight())
+ {
+ return false;
+ }
+ if (this->GetVideoBitrate() != pRhs->GetVideoBitrate())
+ {
+ return false;
+ }
+ if (this->GetWidth() != pRhs->GetWidth())
+ {
+ return false;
+ }
+
+ return true;
+}
+
+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;
+}
+
+int
+_VideoMetadataImpl::GetWidth(void) const
+{
+ if (__pVideoMeta == null)
+ {
+ SysLog(NID_CNT, "__pVideoMeta is null.");
+ return 0;
+ }
+ return __pVideoMeta->width;
+}
+
+int
+_VideoMetadataImpl::GetHeight(void) const
+{
+ if (__pVideoMeta == null)
+ {
+ SysLog(NID_CNT, "__pVideoMeta is null.");
+ return 0;
+ }
+ return __pVideoMeta->height;
+}
+
+long
+_VideoMetadataImpl::GetDuration(void) const
+{
+ if (__pVideoMeta == null)
+ {
+ SysLog(NID_CNT, "__pVideoMeta is null.");
+ return 0;
+ }
+ return __pVideoMeta->duration;
+}
+
+int
+_VideoMetadataImpl::GetFramerate(void) const
+{
+ if (__pVideoMeta == null)
+ {
+ SysLog(NID_CNT, "__pVideoMeta is null.");
+ return 0;
+ }
+ return __pVideoMeta->framerate;
+}
+
+int
+_VideoMetadataImpl::GetAudioBitrate(void) const
+{
+ if (__pVideoMeta == null)
+ {
+ SysLog(NID_CNT, "__pVideoMeta is null.");
+ return 0;
+ }
+ return __pVideoMeta->audioBitrate;
+}
+
+int
+_VideoMetadataImpl::GetVideoBitrate(void) const
+{
+ if (__pVideoMeta == null)
+ {
+ SysLog(NID_CNT, "__pVideoMeta is null.");
+ return 0;
+ }
+ return __pVideoMeta->videoBitrate;
+}
+
+String
+_VideoMetadataImpl::GetGenre(void) const
+{
+ if (__pVideoMeta == null || __pVideoMeta->pGenre == null)
+ {
+ SysLog(NID_CNT, "__pVideoMeta or __pVideoMeta->pGenre is null.");
+ return String();
+ }
+ return *(__pVideoMeta->pGenre);
+}
+
+//
+// E_SUCCESS
+// E_DATA_NOT_FOUND
+// - E_OUT_OF_MEMORY
+//
+Bitmap*
+_VideoMetadataImpl::GetAlbumArtN(void) const
+{
+ // E_SUCCESS, E_DATA_NOT_FOUND, E_OUT_OF_MEMORY
+
+ ClearLastResult();
+
+ if (__pVideoMeta == null || __pVideoMeta->pAlbumArt == null)
+ {
+ SysLogException(NID_CNT, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] __pVideoMeta or __pVideoMeta->pAlbumArt is null.");
+ return null;
+ }
+
+ Bitmap* pBitmap = _BitmapImpl::CloneN(*(__pVideoMeta->pAlbumArt));
+ SysTryReturn(NID_CNT, pBitmap != null, null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] _BitmapImpl::CloneN failed.");
+
+ return pBitmap;
+}
+}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_AudioMetadataImpl.h
+ * @brief This is the header file for the %_AudioMetadataImpl class.
+ *
+ * This header file contains the declarations of the %_AudioMetadataImpl class.
+ */
+
+#ifndef _FCNT_INTERNAL_AUDIO_METADATA_IMPL_H_
+#define _FCNT_INTERNAL_AUDIO_METADATA_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FGrpBitmap.h>
+
+namespace Tizen { namespace Content
+{
+
+class AudioMetadata;
+
+struct AudioMeta
+{
+ AudioMeta()
+ : bitrate(0)
+ , channelCount(0)
+ , duration(0)
+ , frequency(0)
+ , trackNum(0)
+ , year(0)
+ , contentPath(L"")
+ , pAlbumName(null)
+ , pArtist(null)
+ , pComment(null)
+ , pComposer(null)
+ , pCopyright(null)
+ , pGenre(null)
+ , pRecordingDate(null)
+ , pTitle(null)
+ , pTrackInfo(null)
+ , pThumbnail(null)
+ , pAlbumArt(null) {}
+
+ int bitrate;
+ int channelCount;
+ long duration;
+ int frequency;
+ int trackNum;
+ int year;
+ Tizen::Base::String contentPath;
+ Tizen::Base::String* pAlbumName;
+ Tizen::Base::String* pArtist;
+ Tizen::Base::String* pComment;
+ Tizen::Base::String* pComposer;
+ Tizen::Base::String* pCopyright;
+ Tizen::Base::String* pGenre;
+ Tizen::Base::String* pRecordingDate;
+ Tizen::Base::String* pTitle;
+ Tizen::Base::String* pTrackInfo;
+ Tizen::Graphics::Bitmap* pThumbnail;
+ Tizen::Graphics::Bitmap* pAlbumArt;
+};
+
+struct AudioMetaDeleter
+{
+ void operator()(AudioMeta* pAudioMeta)
+ {
+ if (pAudioMeta != null)
+ {
+ if (pAudioMeta->pAlbumName)
+ {
+ delete pAudioMeta->pAlbumName;
+ pAudioMeta->pAlbumName = null;
+ }
+ if (pAudioMeta->pArtist)
+ {
+ delete pAudioMeta->pArtist;
+ pAudioMeta->pArtist = null;
+ }
+ if (pAudioMeta->pComment)
+ {
+ delete pAudioMeta->pComment;
+ pAudioMeta->pComment = null;
+ }
+ if (pAudioMeta->pComposer)
+ {
+ delete pAudioMeta->pComposer;
+ pAudioMeta->pComposer = null;
+ }
+ if (pAudioMeta->pCopyright)
+ {
+ delete pAudioMeta->pCopyright;
+ pAudioMeta->pCopyright = null;
+ }
+ if (pAudioMeta->pGenre)
+ {
+ delete pAudioMeta->pGenre;
+ pAudioMeta->pGenre = null;
+ }
+ if (pAudioMeta->pRecordingDate)
+ {
+ delete pAudioMeta->pRecordingDate;
+ pAudioMeta->pRecordingDate = null;
+ }
+ if (pAudioMeta->pTitle)
+ {
+ delete pAudioMeta->pTitle;
+ pAudioMeta->pTitle = null;
+ }
+ if (pAudioMeta->pTrackInfo)
+ {
+ delete pAudioMeta->pTrackInfo;
+ pAudioMeta->pTrackInfo = null;
+ }
+ if (pAudioMeta->pThumbnail)
+ {
+ delete pAudioMeta->pThumbnail;
+ pAudioMeta->pThumbnail = null;
+ }
+ if (pAudioMeta->pAlbumArt)
+ {
+ delete pAudioMeta->pAlbumArt;
+ pAudioMeta->pAlbumArt = null;
+ }
+
+ delete pAudioMeta;
+ pAudioMeta = null;
+ }
+ }
+};
+
+class _AudioMetadataImpl
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ */
+ _AudioMetadataImpl(void);
+
+ /**
+ * This is the copy constructor for this class.
+ *
+ * @since 2.1
+ */
+ _AudioMetadataImpl(const _AudioMetadataImpl& rhs);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ */
+ virtual ~_AudioMetadataImpl(void);
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetTitle()
+ */
+ Tizen::Base::String GetTitle(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetBitrate()
+ */
+ int GetBitrate(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetFrequency()
+ */
+ int GetFrequency(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetArtist()
+ */
+ Tizen::Base::String GetArtist(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetAlbumName()
+ */
+ Tizen::Base::String GetAlbumName(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetComment()
+ */
+ Tizen::Base::String GetComment(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetTrack()
+ */
+ int GetTrack(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetGenre()
+ */
+ Tizen::Base::String GetGenre(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetComposer()
+ */
+ Tizen::Base::String GetComposer(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetCopyright()
+ */
+ Tizen::Base::String GetCopyright(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetDuration()
+ */
+ long GetDuration(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetYear()
+ */
+ int GetYear(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetTrackInfo()
+ */
+ Tizen::Base::String GetTrackInfo(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetRecordingDate()
+ */
+ Tizen::Base::String GetRecordingDate(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetChannelCount()
+ */
+ int GetChannelCount(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetThumbnailN()
+ */
+ Tizen::Graphics::Bitmap* GetThumbnailN(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetAlbumArtN()
+ */
+ Tizen::Graphics::Bitmap* GetAlbumArtN(void) const;
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _AudioMetadataImpl
+ * @param[in] audioMetadata An instance of AudioMetadata
+ */
+ static _AudioMetadataImpl* GetInstance(AudioMetadata& audioMetadata);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _AudioMetadataImpl
+ * @param[in] audioMetadata An instance of AudioMetadata
+ */
+ static const _AudioMetadataImpl* GetInstance(const AudioMetadata& audioMetadata);
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::Equals()
+ */
+ virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::GetHashCode()
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * @see @ref Tizen::Content::AudioMetadata::operator =()
+ */
+ _AudioMetadataImpl& operator =(const _AudioMetadataImpl& rhs);
+
+private:
+ result SetAudioMetadata(const AudioMeta* pAudioMeta);
+ AudioMeta* GetAudioMetadata(void) const;
+
+private:
+ std::unique_ptr<AudioMeta, AudioMetaDeleter> __pAudioMeta;
+
+ friend class _ContentManagerUtilImpl;
+
+}; // class _AudioMetadataImpl
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_AUDIO_METADATA_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentDirectoryImpl.h
+ * @brief This is the header file for the %_ContentDirectoryImpl class.
+ *
+ * This header file contains the declarations of the %_ContentDirectoryImpl class.
+ */
+
+#ifndef _FCNT_INTERNAL_CONTENT_DIRECTORY_IMPL_H_
+#define _FCNT_INTERNAL_CONTENT_DIRECTORY_IMPL_H_
+
+#include <glib.h>
+#include <unique_ptr.h>
+#include <media_content.h>
+#include <FBaseColIListT.h>
+#include <FBaseColAllElementsDeleter.h>
+
+namespace Tizen { namespace Content
+{
+ static const int MAX_FIELD_LENGTH = 32;
+ static const int MAX_QUERY_COLUMNS = 23;
+ static const int MAX_QUERY_COLUMNS_FOR_IMAGE_OTHERS = 14;
+ static const int MAX_QUERY_COLUMNS_FOR_VIDEO = 21;
+ static const int ALBUM_COLUMN_NUM = 22;
+
+ typedef struct
+ {
+ char dbFieldOspName[MAX_FIELD_LENGTH];
+ char dbFieldSlpName[MAX_FIELD_LENGTH];
+ }DatabaseFieldInfo;
+
+ const static DatabaseFieldInfo dbfieldinfo[MAX_QUERY_COLUMNS] =
+ {
+ //for all types 0 -13
+ {"ContentType", "MEDIA_TYPE"},
+ {"ContentFileName", "MEDIA_DISPLAY_NAME"},
+ {"ContentName", "MEDIA_CONTENT_NAME"},
+ {"Category", "MEDIA_CATEGORY"},
+ {"Author", "MEDIA_AUTHOR"},
+ {"keyword", "MEDIA_KEYWORD"},
+ {"Provider", "MEDIA_PROVIDER"},
+ {"Rating", "MEDIA_AGE_RATING"},
+ {"LocationTag", "MEDIA_LOCATION_TAG"},
+ {"ContentSize", "MEDIA_SIZE"},
+ {"DateTime", "MEDIA_ADDED_TIME"},
+ {"Latitude", "MEDIA_LATITUDE"},
+ {"Longitude", "MEDIA_LONGITUDE"},
+ {"Altitude", "MEDIA_ALTITUDE"},
+ // for audio and video type 14 - 20
+ {"Title", "MEDIA_TITLE"},
+ {"Artist", "MEDIA_ARTIST"},
+ {"Genre", "MEDIA_GENRE"},
+ {"Year", "MEDIA_YEAR"},
+ {"MostPlayed", "MEDIA_PLAYED_COUNT"},
+ {"RecentlyAdded", "MEDIA_ADDED_TIME"},
+ {"RecentlyPlayed", "MEDIA_LAST_PLAYED_TIME"},
+ // for audio type 21 - 22
+ {"Composer", "MEDIA_COMPOSER"},
+ {"Album", "MEDIA_ALBUM"}
+ };
+
+class ContentSearchResult;
+class ContentDirectory;
+
+struct GListDeleter
+{
+ void operator()(GList* pGList)
+ {
+ g_list_free(pGList);
+ pGList = NULL;
+ }
+};
+
+struct FolderHandleDeleter
+{
+ void operator()(media_folder_h folderHandle)
+ {
+ media_folder_destroy(folderHandle);
+ folderHandle = NULL;
+ }
+};
+
+struct MediaHandleDeleter
+{
+ void operator()(media_info_h mediaHandle)
+ {
+ media_info_destroy(mediaHandle);
+ mediaHandle = NULL;
+ }
+};
+
+struct FilterHandleDeleter
+{
+ void operator()(filter_h* pFilterHandle)
+ {
+ media_filter_destroy(*pFilterHandle);
+ }
+};
+
+class _ContentDirectoryImpl
+ : public Tizen::Base::Object
+{
+public:
+
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ */
+ _ContentDirectoryImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ */
+ virtual ~_ContentDirectoryImpl(void);
+
+ /**
+ * @see @ref Tizen::Content::ContentDirectory::Construct()
+ */
+ result Construct(ContentType type);
+
+ /**
+ * @see @ref Tizen::Content::ContentDirectory::Construct()
+ */
+ result Construct(const Tizen::Base::Collection::IListT<ContentType>& contentTypeList);
+
+ /**
+ * @see @ref Tizen::Content::ContentDirectory::GetContentDirectoryCount()
+ */
+ int GetContentDirectoryCount(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ContentDirectory::GetContentDirectoryPathListN()
+ */
+ Tizen::Base::Collection::IList* GetContentDirectoryPathListN(Tizen::Base::SortOrder sortOrder) const;
+
+ /**
+ * @see @ref Tizen::Content::ContentDirectory::GetContentDirectoryItemCount()
+ */
+ int GetContentDirectoryItemCount(const Tizen::Base::String& contentDirectoryPath) const;
+
+ /**
+ * @see @ref Tizen::Content::ContentDirectory::GetContentDirectoryItemListN()
+ */
+ Tizen::Base::Collection::IList* GetContentDirectoryItemListN(const Tizen::Base::String& contentDirectoryPath, int pageNo, int countPerPage,
+ const Tizen::Base::String& column, Tizen::Base::SortOrder sortOrder) const;
+
+ static _ContentDirectoryImpl* GetInstance(ContentDirectory& contentDirectory);
+
+ static const _ContentDirectoryImpl* GetInstance(const ContentDirectory& contentDirectory);
+
+private:
+ _ContentDirectoryImpl(const _ContentDirectoryImpl& rhs);
+ _ContentDirectoryImpl& operator =(const _ContentDirectoryImpl& rhs);
+
+ result CreateFolderFilter(bool isMultiContentType, const Tizen::Base::String& folderPath) const;
+ result FillFinalOutList(char* pFolderId) const;
+ result GetSlpColumnName(Tizen::Base::String& inputCol, Tizen::Base::String sortCol) const;
+ result MapCoreErrorToNativeResult(int reason) const;
+ bool CheckMediaPath(const Tizen::Base::String& directoryPath) const;
+
+ mutable std::unique_ptr<filter_h, FilterHandleDeleter> __pFilterHandle;
+ mutable std::unique_ptr<Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter> __pFinalOutList;
+ ContentType __contentType;
+ bool __isMultiContentType;
+ Tizen::Base::String __multiContentTypeExpr;
+
+
+}; // class _ContentDirectoryImpl
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_CONTENT_DIRECTORY_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentManagerImpl.h
+ * @brief This is the header file for the %_ContentManagerImpl class.
+ *
+ * This header file contains the declarations of the %_ContentManagerImpl class.
+ */
+
+#ifndef _FCNT_INTERNAL_CONTENT_MANAGER_IMPL_H_
+#define _FCNT_INTERNAL_CONTENT_MANAGER_IMPL_H_
+
+#include <unique_ptr.h>
+#include <media_content.h>
+#include <FCntContentInfo.h>
+
+namespace Tizen { namespace Content
+{
+
+class ContentManager;
+class _IContentScanListener;
+typedef struct media_info_s* media_info_h;
+
+struct MediaInfoDeleter
+{
+ void operator()(media_info_h* pMediaInfo)
+ {
+ int val = media_info_destroy(*pMediaInfo);
+ SysLog(NID_CNT, "media_info_destroy result[%d].", val);
+ }
+};
+
+struct ImageMetaDeleter
+{
+ void operator()(image_meta_h* pImageMeta)
+ {
+ int val = image_meta_destroy(*pImageMeta);
+ SysLog(NID_CNT, "image_meta_destroy result[%d].", val);
+ }
+};
+
+struct AudioMetaDeleter
+{
+ void operator()(audio_meta_h* pAudioMeta)
+ {
+ int val = audio_meta_destroy(*pAudioMeta);
+ SysLog(NID_CNT, "audio_meta_destroy result[%d].", val);
+ }
+};
+
+struct VideoMetaDeleter
+{
+ void operator()(video_meta_h* pVideoMeta)
+ {
+ int val = video_meta_destroy(*pVideoMeta);
+ SysLog(NID_CNT, "video_meta_destroy result[%d].", val);
+ }
+};
+
+struct ScanResult
+{
+ void* pData;
+ char* pContentPath;
+};
+
+class _ContentManagerImpl
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ */
+ _ContentManagerImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ */
+ virtual ~_ContentManagerImpl(void);
+
+ /**
+ * @see @ref Tizen::Content::ContentManager::Construct()
+ */
+ result Construct(void);
+
+ /**
+ * @see @ref Tizen::Content::ContentManager::CreateContent(const ContentInfo&)
+ */
+ ContentId CreateContent(const ContentInfo& contentInfo);
+
+ /**
+ * @see @ref Tizen::Content::ContentManager::CreateContent(const Tizen::Base::ByteBuffer&, const Tizen::Base::String&, const ContentInfo*)
+ */
+ ContentId CreateContent(const Tizen::Base::ByteBuffer& byteBuffer, const Tizen::Base::String& destinationPath, const ContentInfo* pContentInfo = null);
+
+ /**
+ * @see @ref Tizen::Content::ContentManager::CreateContent(const Tizen::Base::String&, const Tizen::Base::String&, bool, const ContentInfo*)
+ */
+ ContentId CreateContent(const Tizen::Base::String& sourcePath, const Tizen::Base::String& destinationPath, bool deleteSource, const ContentInfo* pContentInfo = null);
+
+ /**
+ * @see @ref Tizen::Content::ContentManager::GetContentInfoN()
+ */
+ ContentInfo* GetContentInfoN(const ContentId& contentId) const;
+
+ /**
+ * @see @ref Tizen::Content::ContentManager::UpdateContent()
+ */
+ result UpdateContent(const ContentInfo& contentInfo);
+
+ /**
+ * @see @ref Tizen::Content::ContentManager::DeleteContent()
+ */
+ result DeleteContent(const ContentId& contentId);
+
+ /*
+ * @see @ref Tizen::Content::ContentManager::ScanFile()
+ */
+ result ScanFile(const Tizen::Base::String& contentPath);
+
+ /*
+ * @see @ref Tizen::Content::ContentManager::ScanDirectory()
+ */
+ result ScanDirectory(const Tizen::Base::String& directoryPath, bool recursive, _IContentScanListener& listener);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _ContentManagerImpl
+ * @param[in] contentManager An instance of ContentManager
+ */
+ static _ContentManagerImpl* GetInstance(ContentManager& contentManager);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _ContentManagerImpl
+ * @param[in] contentManager An instance of ContentManager
+ */
+ static const _ContentManagerImpl* GetInstance(const ContentManager& contentManager);
+
+ void SetListener(_IContentScanListener* pListener);
+
+ _IContentScanListener* 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;
+ friend class _ContentDownloadHandler;
+
+}; // class _ContentManagerImpl
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_CONTENT_MANAGER_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentManagerUtilImpl.h
+ * @brief This is the header file for the %_ContentManagerUtilImpl class.
+ *
+ * This header file contains the declarations of the %_ContentManagerUtilImpl class.
+ */
+
+#ifndef _FCNT_INTERNAL_CONTENT_MANAGER_UTIL_IMPL_H_
+#define _FCNT_INTERNAL_CONTENT_MANAGER_UTIL_IMPL_H_
+
+#include <unique_ptr.h>
+#include <libexif/exif-data.h>
+#include <metadata_extractor.h>
+
+namespace Tizen { namespace Content
+{
+
+class ImageMetadata;
+class AudioMetadata;
+class VideoMetadata;
+
+struct ExifDataDeleter
+{
+ void operator()(ExifData* pExifData)
+ {
+ exif_data_unref(pExifData);
+ }
+};
+
+struct ExtractorDeleter
+{
+ void operator()(metadata_extractor_h* pMetadataExtractor)
+ {
+ metadata_extractor_destroy(*pMetadataExtractor);
+ }
+};
+
+struct CharDeleter
+{
+ void operator()(char* pChar)
+ {
+ free(pChar);
+ pChar = null;
+ }
+};
+
+struct VoidDeleter
+{
+ void operator()(void* pVoid)
+ {
+ free(pVoid);
+ pVoid = null;
+ }
+};
+
+class _ContentManagerUtilImpl
+{
+public:
+ /**
+ * @see @ref Tizen::Content::ContentManagerUtil::GetImageMetaN()
+ */
+ static Tizen::Content::ImageMetadata* GetImageMetaN(const Tizen::Base::String& contentPath, bool internal = false);
+
+ /**
+ * @see @ref Tizen::Content::ContentManagerUtil::GetAudioMetaN()
+ */
+ static Tizen::Content::AudioMetadata* GetAudioMetaN(const Tizen::Base::String& contentPath);
+
+ /**
+ * @see @ref Tizen::Content::ContentManagerUtil::GetVideoMetaN()
+ */
+ static Tizen::Content::VideoMetadata* GetVideoMetaN(const Tizen::Base::String& contentPath);
+
+ /**
+ * @see @ref Tizen::Content::ContentManagerUtil::CheckContentType()
+ */
+ static Tizen::Content::ContentType CheckContentType(const Tizen::Base::String& contentPath, bool internal = false);
+
+ /**
+ * @see @ref Tizen::Content::ContentManagerUtil::CopyToMediaDirectory()
+ */
+ static result CopyToMediaDirectory(const Tizen::Base::String& srcContentPath, const Tizen::Base::String& destContentPath);
+
+ /**
+ * @see @ref Tizen::Content::ContentManagerUtil::MoveToMediaDirectory()
+ */
+ static result MoveToMediaDirectory(const Tizen::Base::String& srcContentPath, const Tizen::Base::String& destContentPath);
+
+private:
+ _ContentManagerUtilImpl(void);
+ _ContentManagerUtilImpl(const _ContentManagerUtilImpl& rhs);
+ virtual ~_ContentManagerUtilImpl(void);
+ static void ParseBuffer(char* pBuffer, int& count);
+ 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);
+
+}; // class _ContentManagerUtilImpl
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_CONTENT_MANAGER_UTIL_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentSearchImpl.h
+ * @brief This is the header file for the %_ContentSearchImpl class.
+ *
+ * This header file contains the declarations of the %_ContentSearchImpl class.
+ */
+
+#ifndef _FCNT_INTERNAL_CONTENT_SEARCH_IMPL_H_
+#define _FCNT_INTERNAL_CONTENT_SEARCH_IMPL_H_
+
+#include <glib.h>
+#include <unique_ptr.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <media_content.h>
+
+namespace Tizen { namespace Content
+{
+ static const int MAX_FIELD_LENGTH = 32;
+ static const int MAX_QUERY_COLUMNS = 20;
+ static const int MAX_QUERY_COLUMNS_FOR_IMAGE_OTHERS = 14;
+ static const int MAX_QUERY_COLUMNS_FOR_VIDEO = 18;
+ static const int ALBUM_COLUMN_NUM = 19;
+
+ typedef struct
+ {
+ char dbFieldOspName[MAX_FIELD_LENGTH];
+ char dbFieldSlpName[MAX_FIELD_LENGTH];
+ }DatabaseFieldInfo;
+
+ const static DatabaseFieldInfo dbfieldinfo[MAX_QUERY_COLUMNS] =
+ {
+ //for all types 0 -13
+ {"ContentType", "MEDIA_TYPE"},
+ {"ContentFileName", "MEDIA_DISPLAY_NAME"},
+ {"ContentName", "MEDIA_CONTENT_NAME"},
+ {"Category", "MEDIA_CATEGORY"},
+ {"Author", "MEDIA_AUTHOR"},
+ {"keyword", "MEDIA_KEYWORD"},
+ {"Provider", "MEDIA_PROVIDER"},
+ {"Rating", "MEDIA_AGE_RATING"},
+ {"LocationTag", "MEDIA_LOCATION_TAG"},
+ {"ContentSize", "MEDIA_SIZE"},
+ {"DateTime", "MEDIA_ADDED_TIME"},
+ {"Latitude", "MEDIA_LATITUDE"},
+ {"Longitude", "MEDIA_LONGITUDE"},
+ {"Altitude", "MEDIA_ALTITUDE"},
+ // for audio and video type 14 - 17
+ {"Title", "MEDIA_TITLE"},
+ {"Artist", "MEDIA_ARTIST"},
+ {"Genre", "MEDIA_GENRE"},
+ {"Year", "MEDIA_YEAR"},
+ // for audio type 18 - 19
+ {"Composer", "MEDIA_COMPOSER"},
+ {"Album", "MEDIA_ALBUM"}
+ };
+
+// forward declaration
+class ContentSearchResult;
+class ContentSearch;
+
+struct SearchMediaHandleDeleter
+{
+ void operator()(media_info_h mediaHandle)
+ {
+ media_info_destroy(mediaHandle);
+ mediaHandle = NULL;
+ }
+};
+
+struct SearchGListDeleter
+{
+ void operator()(GList* pGList)
+ {
+ g_list_free(pGList);
+ pGList = NULL;
+ }
+};
+
+struct SearchFilterHandleDeleter
+{
+ void operator()(filter_h* pFilterHandle)
+ {
+ media_filter_destroy(*pFilterHandle);
+ }
+};
+struct AlbumHandleDeleter
+{
+ void operator()(media_album_h albumHandle)
+ {
+ media_album_destroy(albumHandle);
+ albumHandle = NULL;
+ }
+};
+struct CharDeleter
+{
+ void operator()(char* pChar)
+ {
+ free(pChar);
+ pChar = null;
+ }
+};
+
+class _ContentSearchImpl
+ : public Tizen::Base::Object
+{
+public:
+
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ */
+ _ContentSearchImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ */
+ virtual ~_ContentSearchImpl(void);
+
+ /**
+ * @see @ref Tizen::Content::ContentSearch::Construct()
+ */
+ result Construct(ContentType type);
+
+ /**
+ * @see @ref Tizen::Content::ContentSearch::SearchN()
+ */
+ Tizen::Base::Collection::IList* SearchN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount,
+const Tizen::Base::String& whereExpr, const Tizen::Base::String& sortColumn, Tizen::Base::SortOrder sortOrder) const;
+
+ Tizen::Base::Collection::IList* GetValueListN(const Tizen::Base::String& sortColumn, Tizen::Base::SortOrder sortOrder);
+
+ /**
+ * @see @ref Tizen::Content::ContentManager::GetValueListN()
+ */
+ Tizen::Base::Collection::IList* GetValueListN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount,
+const Tizen::Base::String& sortColumn, Tizen::Base::SortOrder sortOrder) const;
+
+ static _ContentSearchImpl* GetInstance(ContentSearch& contentSearch);
+
+ static const _ContentSearchImpl* GetInstance(const ContentSearch& contentSearch);
+
+private:
+ _ContentSearchImpl(const _ContentSearchImpl& rhs);
+ _ContentSearchImpl& operator =(const _ContentSearchImpl& rhs);
+
+ result ReplaceString(Tizen::Base::String ospColumnName, Tizen::Base::String slpColumnName) const;
+ result ReplaceOspColumnNameWithSlp(void) const;
+
+ result CreateQueryFilter(bool isAndAppendReq) const;
+
+ result GetSlpColumnName(Tizen::Base::String& inputCol) const;
+
+ result ExecuteAndFillFinalOutList(void) const;
+
+ result ExecuteAndFillGetValueListN(media_group_e groupIndex, int colIndex) const;
+
+ result FillColumnsList(int pageNo, int countPerPage, int& totalPageCount, int& totalCount, int colIndex) const;
+ result FillColumnsList(int colIndex) const;
+
+ result CheckInvalidColumnInQuery(void) const;
+
+ media_group_e GetIndexAndCreateQueryExp(int colIndex) const;
+
+ result AppendEscapeKeywordForLikeQuery(void) const;
+
+ result ReplaceDateTimeStringWithInt(void) const;
+
+ result ExecuteAndFillAlbumValues(void) const;
+
+ result MapCoreErrorToNativeResult(int reason) const;
+
+ ContentType __contentType;
+ mutable std::unique_ptr<Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter> __pFinalOutList;
+ mutable Tizen::Base::String __inputExpr;
+ mutable Tizen::Base::String __inputColumnName;
+ mutable Tizen::Base::SortOrder __inputSortOrder;
+ mutable std::unique_ptr<filter_h, SearchFilterHandleDeleter> __pFilterHandle;
+
+}; // class _ContentSearchImpl
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_CONTENT_SEARCH_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentTransferImpl.h
+ * @brief This is the header file for the %_ContentTransferImpl class.
+ *
+ * This header file contains the declarations of the %_ContentTransferImpl class.
+ */
+
+#ifndef _FCNT_INTERNAL_CONTENT_TRANSFER_IMPL_H_
+#define _FCNT_INTERNAL_CONTENT_TRANSFER_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseRtITimerEventListener.h>
+#include <FBaseColAllElementsDeleter.h>
+#include <FCntContentTransferInfo.h>
+
+namespace Tizen { namespace Base { namespace Runtime
+{
+class Timer;
+}}}
+
+namespace Tizen { namespace Content
+{
+
+class IContentTransferListener;
+class ContentTransfer;
+class _ContentTransferEvent;
+class _ContentDownloadHandler;
+class _ContentDownloadUserData;
+
+class _ContentTransferImpl
+ : virtual public Tizen::Base::Runtime::ITimerEventListener
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ */
+ _ContentTransferImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ */
+ virtual ~_ContentTransferImpl(void);
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::Construct()
+ */
+ result Construct(IContentTransferListener& listener);
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::Download(const Tizen::Base::Utility::Uri&, int, const Tizen::Base::String&, bool, RequestId&, const IContentTransferListener*, int)
+ */
+ result Download(const Tizen::Base::Utility::Uri& uri, int fileSize, const Tizen::Base::String& destFilePath, bool replace, RequestId& requestID, IContentTransferListener* pListener = null, int sec = 0);
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::Download(const Tizen::Base::Utility::Uri&, const Tizen::Base::String&, RequestId&, bool, int, int)
+ */
+ result Download(const Tizen::Base::Utility::Uri& uri, const Tizen::Base::String& filePath, RequestId& reqId, bool replace = false, int timeout = 0, int progressInterval = 0);
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::DownloadToBuffer(const Tizen::Base::Utility::Uri&, int, RequestId&, const IContentTransferListener*, int)
+ */
+ result DownloadToBuffer(const Tizen::Base::Utility::Uri& uri, int fileSize, RequestId& reqId, IContentTransferListener* pListener = null, int sec = 0);
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::DownloadToBuffer(const Tizen::Base::Utility::Uri&, RequestId&, int, int)
+ */
+ result DownloadToBuffer(const Tizen::Base::Utility::Uri& uri, RequestId& reqId, int timeout = 0, int progressInterval = 0);
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::SetDefaultTimeout()
+ */
+ void SetDefaultTimeout(int sec);
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::GetDefaultTimeout()
+ */
+ int GetDefaultTimeout(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::Remove()
+ */
+ result Remove(RequestId reqId);
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::RemoveAll()
+ */
+ result RemoveAll(void);
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::Cancel()
+ */
+ result Cancel(RequestId reqId);
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::CancelAll()
+ */
+ result CancelAll(void);
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::GetContentTransferInfoListN()
+ */
+ Tizen::Base::Collection::IList* GetContentTransferInfoListN(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::GetContentTransferInfoListInProgressN()
+ */
+ Tizen::Base::Collection::IList* GetContentTransferInfoListInProgressN(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ContentTransfer::SetProgressIntervalByPercent()
+ */
+ void SetProgressIntervalByPercent(int percent);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _ContentTransferImpl
+ * @param[in] contentTransfer An instance of ContentTransfer
+ */
+ static _ContentTransferImpl* GetInstance(ContentTransfer& contentTransfer);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _ContentTransferImpl
+ * @param[in] contentTransfer An instance of ContentTransfer
+ */
+ static const _ContentTransferImpl* GetInstance(const ContentTransfer& contentTransfer);
+
+private:
+ _ContentTransferImpl(const _ContentTransferImpl& rhs);
+ virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
+
+ RequestId GetRequestId(void) const;
+ ContentTransferInfo* GetContentTransferInfoByRequestId(RequestId requestId) const;
+ void StartTimer(void);
+ result GetEmptySlot(int& slot) const;
+ void DeleteDownloadObj(void);
+ result CheckDestPath(const Tizen::Base::String& destPath, bool replace);
+ result CheckDownloadStatus(const Tizen::Base::Utility::Uri& uri, const Tizen::Base::String& destPath);
+ result AddTransferItem(const Tizen::Base::Utility::Uri& uri, const Tizen::Base::String& destPath,
+ const Tizen::Base::String& sourcePath, int sourceFileSize, ContentTransferStatus status,
+ IContentTransferListener* pListener, int sec, bool isBuffer, RequestId& requestId);
+ result AddTransferItem(const Tizen::Base::Utility::Uri& uri, const Tizen::Base::String& destPath,
+ const Tizen::Base::String& sourcePath, ContentTransferStatus status,
+ int timeout, int interval, bool isBuffer, RequestId& requestId);
+ result SetDownloadSlotInfo(ContentTransferInfo* pTransferInfo, int& slot);
+ result RequestErrorEvent(result requestErrorCode, ContentTransferInfo* pTransferInfo);
+ result RemoveCompletedTransferInfo(Tizen::Base::Collection::ArrayList* pTransferInfoList);
+ bool ContentTransferHandler(void);
+
+ void InitializeEmptySlotInternal(_ContentDownloadUserData* pUserData);
+ int GetEmptySlotInternal(void) const;
+ void SetUsedSlotInternal(int slot);
+ void SetEmptySlotInternal(void);
+ int GetMaxDownloadCount(void) const;
+
+ _ContentTransferImpl& operator =(const _ContentTransferImpl& rhs);
+
+private:
+ RequestId __requestId;
+ RequestId __restRequestId;
+ int __maxDownloadCount;
+ int __timeout;
+ int __percent;
+ bool __timerStarted;
+ bool __isBuffer;
+ Tizen::Base::String __destFilePath;
+ std::unique_ptr<_ContentDownloadUserData> __pContentDownloadUserData;
+ std::unique_ptr<_ContentDownloadUserData[]> __pContentDownloadUserDataSequence;
+ std::unique_ptr<_ContentDownloadHandler> __pContentDownloadHandler;
+ std::unique_ptr<_ContentDownloadHandler[]> __pContentDownloadHandlerSequence;
+ std::unique_ptr<_ContentTransferEvent> __pTransferEvent;
+ std::unique_ptr<Tizen::Base::Collection::ArrayList, Tizen::Base::Collection::AllElementsDeleter> __pTransferInfoList;
+ std::unique_ptr<Tizen::Base::Runtime::Timer> __pTimer;
+}; // class _ContentTransferImpl
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_CONTENT_TRANSFER_IMPL_H_
+
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ContentUtility.h
+ * @brief This is the header file for the %_ContentUtility class.
+ *
+ * This header file contains the declarations of the %_ContentUtility class.
+ */
+
+#ifndef _FCNT_INTERNAL_CONTENT_UTILITY_H_
+#define _FCNT_INTERNAL_CONTENT_UTILITY_H_
+
+
+#include <media_content.h>
+#include <FCntContentInfo.h>
+#include <FCntImageContentInfo.h>
+#include <FCntAudioContentInfo.h>
+#include <FCntVideoContentInfo.h>
+#include <FCntOtherContentInfo.h>
+
+namespace Tizen { namespace Content
+{
+
+struct UtilCharDeleter
+{
+ void operator()(char* pChar)
+ {
+ free(pChar);
+ pChar = null;
+ }
+};
+struct ImageMetaHandleDeleter
+{
+ void operator()(image_meta_h* pImageHandle)
+ {
+ image_meta_destroy(*pImageHandle);
+ pImageHandle = NULL;
+ }
+};
+struct AudioMetaHandleDeleter
+{
+ void operator()(audio_meta_h* pAudioHandle)
+ {
+ audio_meta_destroy(*pAudioHandle);
+ pAudioHandle = NULL;
+ }
+};
+struct VideoMetaHandleDeleter
+{
+ void operator()(video_meta_h* pVideoHandle)
+ {
+ video_meta_destroy(*pVideoHandle);
+ pVideoHandle = NULL;
+ }
+};
+
+class _ContentUtility
+ : public Tizen::Base::Object
+{
+public:
+
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ */
+ _ContentUtility(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ */
+ virtual ~_ContentUtility(void);
+
+ static void DoSafeFree(char* pSrc);
+
+ static void DoSafeDelete(Tizen::Base::String* pSrc);
+
+ static result FillContentData(media_info_h mediaHandle, ContentInfo::_ContentData* pContentData);
+
+ static result FillImageContentData(media_info_h media_handle, ImageContentInfo::_ImageContentData* pImageContentData);
+
+ static result FillAudioContentData(media_info_h media_handle, AudioContentInfo::_AudioContentData* pAudioContentData);
+
+ static result FillVideoContentData(media_info_h media_handle, VideoContentInfo::_VideoContentData* pVideoContentData);
+
+ static result MapCoreErrorToNativeResult(int reason);
+
+private:
+ _ContentUtility(const _ContentUtility& rhs);
+ _ContentUtility& operator =(const _ContentUtility& rhs);
+
+}; // class ContentUtility
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_CONTENT_UTILITY_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_DownloadManagerImpl.h
+ * @brief This is the header file for the %_DownloadManagerImpl class.
+ *
+ * This header file contains the declarations of the %_DownloadManagerImpl class.
+ */
+#ifndef _FCNT_DOWNLOAD_MANAGER_IMPL_H_
+#define _FCNT_DOWNLOAD_MANAGER_IMPL_H_
+
+#include <FBaseResult.h>
+#include <FBaseString.h>
+#include <FBaseColHashMapT.h>
+
+namespace Tizen { namespace Content
+{
+
+class DownloadRequest;
+class _DownloadRequestImpl;
+
+class IDownloadListener;
+
+class _OSP_EXPORT_ _DownloadManagerImpl
+ : public Tizen::Base::Object
+{
+public:
+ enum State
+ {
+ STATE_NONE = 0,
+ STATE_QUEUED,
+ STATE_DOWNLOADING,
+ STATE_PAUSED,
+ STATE_CANCELLED,
+ STATE_COMPLETED,
+ STATE_FAILED,
+ };
+
+public:
+ _DownloadManagerImpl(void);
+ virtual ~_DownloadManagerImpl(void);
+
+ result Construct(void);
+
+ result Start(const DownloadRequest& request, RequestId& reqId);
+ result Pause(RequestId reqId);
+ result Resume(RequestId reqId);
+ result Cancel(RequestId reqId);
+
+ DownloadRequest* GetDownloadRequestN(RequestId reqId);
+
+ State GetState(RequestId reqId) const;
+
+ result GetMimeType(RequestId reqId, Tizen::Base::String& mimeType);
+
+ result GetProgress(RequestId reqId, int& progress);
+
+ result SetAllowedNetwork(unsigned long flags);
+
+ void SetDownloadListener(IDownloadListener* pListener);
+
+ void DestroyResources(RequestId reqId);
+
+ static result ConvertToResult(int error);
+
+ static _DownloadManagerImpl* GetInstance(void);
+
+public:
+ IDownloadListener* __pListener;
+
+private:
+ _DownloadManagerImpl(const _DownloadManagerImpl& clientChannel);
+ _DownloadManagerImpl& operator =(const _DownloadManagerImpl& clientChannel);
+
+ static void InitSingleton(void);
+ static void DestroySingleton(void);
+
+ enum DownloadOperation
+ {
+ DOWNLOAD_OPERATION_START,
+ DOWNLOAD_OPERATION_PAUSE,
+ DOWNLOAD_OPERATION_RESUME,
+ DOWNLOAD_OPERATION_CANCEL,
+ };
+
+ result CheckPrestate(DownloadOperation operation, State current);
+
+ result RegisterCallback(RequestId reqId);
+ void UnregisterCallback(RequestId reqId);
+
+private:
+ Tizen::Base::Collection::HashMapT<RequestId, DownloadRequest*> __handleMap;
+
+ static _DownloadManagerImpl* __pInstance;
+}; // _DownloadManagerImpl
+
+} } // Tizen::Content
+
+#endif //_FCNT_DOWNLOAD_MANAGER_IMPL_H_
+
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_DownloadRequestImpl.h
+ * @brief This is the header file for the %_DownloadRequestImpl class.
+ *
+ * This header file contains the declarations of the %_DownloadRequestImpl class.
+ */
+#ifndef _FCNT_DOWNLOAD_MANAGER_IMPL_H_
+#define _FCNT_DOWNLOAD_MANAGER_IMPL_H_
+
+#include <FBaseResult.h>
+#include <FBaseString.h>
+
+namespace Tizen { namespace Content
+{
+
+class IDownloadEventListener;
+class IDownloadProgressListener;
+
+class _OSP_EXPORT_ _DownloadRequestImpl
+ : public Tizen::Base::Object
+{
+public:
+ _DownloadRequestImpl(void);
+ _DownloadRequestImpl(const Tizen::Base::String& url);
+ _DownloadRequestImpl(const Tizen::Base::String& url, const Tizen::Base::String& dirPath);
+ _DownloadRequestImpl(const _DownloadRequestImpl& rhs);
+
+ virtual ~_DownloadRequestImpl(void);
+
+ _DownloadRequestImpl& operator =(const _DownloadRequestImpl& rhs);
+ bool operator ==(const _DownloadRequestImpl& rhs) const;
+
+ virtual bool Equals(const Object& obj) const;
+ virtual int GetHashCode(void) const;
+
+ void SetDirectoryPath(const Tizen::Base::String& dirPath);
+ void SetFileName(const Tizen::Base::String& fileName);
+
+ Tizen::Base::String GetUrl(void) const;
+ Tizen::Base::String GetDirectoryPath(void) const;
+ Tizen::Base::String GetFileName(void) const;
+
+private:
+
+ Tizen::Base::String __url;
+ Tizen::Base::String __dirPath;
+ Tizen::Base::String __fileName;
+
+}; // _DownloadRequestImpl
+
+} } // Tizen::Content
+
+#endif //_FCNT_DOWNLOAD_MANAGER_IMPL_H_
+
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_ImageMetadataImpl.h
+ * @brief This is the header file for the %_ImageMetadataImpl class.
+ *
+ * This header file contains the declarations of the %_ImageMetadataImpl class.
+ */
+
+#ifndef _FCNT_INTERNAL_IMAGE_METADATA_IMPL_H_
+#define _FCNT_INTERNAL_IMAGE_METADATA_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+
+namespace Tizen { namespace Content
+{
+
+class ImageMetadata;
+
+struct ImageMeta
+{
+ ImageMeta()
+ : width(0)
+ , height(0)
+ , orientation(IMAGE_ORIENTATION_TYPE_UNKNOWN)
+ , latitude(-200.0)
+ , longitude(-200.0)
+ , contentPath(L"")
+ , pManufacturer(null)
+ , pModel(null)
+ , pDateTime(null)
+ , pSoftware(null)
+ , pWhiteBalance(null) {}
+
+ int width;
+ int height;
+ ImageOrientationType orientation;
+ double latitude;
+ double longitude;
+ Tizen::Base::String contentPath;
+ Tizen::Base::String* pManufacturer;
+ Tizen::Base::String* pModel;
+ Tizen::Base::String* pDateTime;
+ Tizen::Base::String* pSoftware;
+ Tizen::Base::String* pWhiteBalance;
+};
+
+struct ImageMetaDeleter
+{
+ void operator()(ImageMeta* pImageMeta)
+ {
+ if (pImageMeta != null)
+ {
+ if (pImageMeta->pManufacturer != null)
+ {
+ delete pImageMeta->pManufacturer;
+ pImageMeta->pManufacturer = null;
+ }
+ if (pImageMeta->pModel != null)
+ {
+ delete pImageMeta->pModel;
+ pImageMeta->pModel = null;
+ }
+ if (pImageMeta->pDateTime != null)
+ {
+ delete pImageMeta->pDateTime;
+ pImageMeta->pDateTime = null;
+ }
+ if (pImageMeta->pSoftware != null)
+ {
+ delete pImageMeta->pSoftware;
+ pImageMeta->pSoftware = null;
+ }
+ if (pImageMeta->pWhiteBalance != null)
+ {
+ delete pImageMeta->pWhiteBalance;
+ pImageMeta->pWhiteBalance = null;
+ }
+
+ delete pImageMeta;
+ pImageMeta = null;
+ }
+ }
+};
+
+class _ImageMetadataImpl
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ */
+ _ImageMetadataImpl(void);
+
+ /**
+ * This is the copy constructor for this class.
+ *
+ * @since 2.1
+ */
+ _ImageMetadataImpl(const _ImageMetadataImpl& rhs);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ */
+ virtual ~_ImageMetadataImpl(void);
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::GetWidth()
+ */
+ int GetWidth(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::GetHeight()
+ */
+ int GetHeight(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::GetCameraManufacturer()
+ */
+ Tizen::Base::String GetCameraManufacturer(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::GetCameraModel()
+ */
+ Tizen::Base::String GetCameraModel(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::GetSoftware()
+ */
+ Tizen::Base::String GetSoftware(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::GetDateTime()
+ */
+ Tizen::Base::String GetDateTime(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::GetLatitude()
+ */
+ double GetLatitude(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::GetLongitude()
+ */
+ double GetLongitude(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::GetOrientation()
+ */
+ ImageOrientationType GetOrientation(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::GetWhiteBalance()
+ */
+ Tizen::Base::String GetWhiteBalance(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::GetThumbnailN()
+ */
+ Tizen::Graphics::Bitmap* GetThumbnailN(void) const;
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _ImageMetadataImpl
+ * @param[in] imageMetadata An instance of ImageMetadata
+ */
+ static _ImageMetadataImpl* GetInstance(ImageMetadata& imageMetadata);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _ImageMetadataImpl
+ * @param[in] imageMetadata An instance of ImageMetadata
+ */
+ static const _ImageMetadataImpl* GetInstance(const ImageMetadata& imageMetadata);
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::Equals()
+ */
+ virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::GetHashCode()
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * @see @ref Tizen::Content::ImageMetadata::operator =()
+ */
+ _ImageMetadataImpl& operator =(const _ImageMetadataImpl& rhs);
+
+private:
+ result SetImageMetadata(const ImageMeta* pImageMeta);
+ ImageMeta* GetImageMetadata(void) const;
+
+private:
+ std::unique_ptr<ImageMeta, ImageMetaDeleter> __pImageMeta;
+
+ friend class _ContentManagerUtilImpl;
+
+}; // class _ImageMetadataImpl
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_IMAGE_METADATA_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_PlayListImpl.h
+ * @brief This is the header file for the %_PlayListImpl class.
+ *
+ * This header file contains the declarations of the %_PlayListImpl class.
+ */
+
+#ifndef _FCNT_INTERNAL_CONTENT_PLAYLIST_IMPL_H_
+#define _FCNT_INTERNAL_CONTENT_PLAYLIST_IMPL_H_
+
+#include <glib.h>
+#include <unique_ptr.h>
+#include <media_content.h>
+#include <FBaseColAllElementsDeleter.h>
+
+namespace Tizen { namespace Content
+{
+
+class PlayList;
+
+struct PlayListHandleDeleter
+{
+ void operator()(media_playlist_h playListHandle)
+ {
+ media_playlist_destroy(playListHandle);
+ playListHandle = NULL;
+ }
+};
+
+struct MediaHandleDeleter
+{
+ void operator()(media_info_h mediaHandle)
+ {
+ media_info_destroy(mediaHandle);
+ mediaHandle = NULL;
+ }
+};
+
+struct GListDeleter
+{
+ void operator()(GList* pGList)
+ {
+ g_list_free(pGList);
+ pGList = NULL;
+ }
+};
+
+struct FilterHandleDeleter
+{
+ void operator()(filter_h* pFilterHandle)
+ {
+ media_filter_destroy(*pFilterHandle);
+ }
+};
+
+class _PlayListImpl
+ : public Tizen::Base::Object
+{
+public:
+
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ */
+ _PlayListImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ */
+ virtual ~_PlayListImpl(void);
+
+ result Construct(const Tizen::Base::String& playListName, bool isAdd = true);
+
+ int GetPlayListItemCount(const Tizen::Base::String& playlistName) const;
+
+ Tizen::Base::Collection::IList* GetContentInfoListN(const Tizen::Base::String& playlistName) const;
+
+ result AddItem(const Tizen::Base::String& playlistName, const ContentId& contentId);
+
+ result AddItems(const Tizen::Base::String& playlistName, const Tizen::Base::Collection::IList& contentIdList);
+
+ result RemoveItem(const ContentId& contentId);
+
+ result RemoveItems(const Tizen::Base::Collection::IList& contentIdList);
+
+ result SetPlalyListName(const Tizen::Base::String& oldName, const Tizen::Base::String& newName);
+
+ result SetPlayOrder(const ContentId& contentId, const ContentId& nextContentId);
+
+ int GetPlayOrder(const ContentId& contentId) const;
+
+ static _PlayListImpl* GetInstance(PlayList& playList);
+
+ static const _PlayListImpl* GetInstance(const PlayList& playList);
+
+private:
+ _PlayListImpl(const _PlayListImpl& rhs);
+ _PlayListImpl& operator =(const _PlayListImpl& rhs);
+
+ mutable std::unique_ptr<filter_h, FilterHandleDeleter> __pFilterHandle;
+
+ result CreateFilterUsingContentId(const ContentId& contentId) const;
+ result CreateFilter(const Tizen::Base::String& playListName) const;
+ result GetPlayListHandle(media_playlist_h* playListHandle) const;
+ result AddItemInternal(media_playlist_h playListHandle, const ContentId& contentId);
+ result SetorGetPlayOrder(const ContentId& contentId, int& playOrder, bool isSet) const;
+ result FillPlayListInfo(int playlistId, Tizen::Base::Collection::ArrayList* pPlayListItemList) const;
+ result MapCoreErrorToNativeResult(int reason) const;
+ result MapCoreDatabaseErrorToNativeResult(int reason) const;
+
+}; // class _PlayListImpl
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_CONTENT_PLAYLIST_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_PlayListManagerImpl.h
+ * @brief This is the header file for the %_PlayListManagerImpl class.
+ *
+ * This header file contains the declarations of the %_PlayListManagerImpl class.
+ */
+
+#ifndef _FCNT_INTERNAL_CONTENT_PLAYLIST_MANAGER_IMPL_H_
+#define _FCNT_INTERNAL_CONTENT_PLAYLIST_MANAGER_IMPL_H_
+
+#include <unique_ptr.h>
+#include <media_content.h>
+#include <FBaseColAllElementsDeleter.h>
+
+namespace Tizen { namespace Content
+{
+
+class PlayListManager;
+class PlayList;
+
+struct FilterDeleter
+{
+ void operator()(filter_h* filterHandle)
+ {
+ media_filter_destroy(*filterHandle);
+ }
+};
+
+class _PlayListManagerImpl
+ : public Tizen::Base::Object
+{
+public:
+
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ */
+ _PlayListManagerImpl(void);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ */
+ virtual ~_PlayListManagerImpl(void);
+
+ result Construct(void);
+ PlayList* GetPlayListN(const Tizen::Base::String& playListName) const;
+ result RemovePlayList(const Tizen::Base::String& playListName);
+ int GetAllPlayListCount(void) const;
+ Tizen::Base::Collection::IList* GetAllPlayListNameN(void) const;
+
+ static _PlayListManagerImpl* GetInstance(PlayListManager& playListManager);
+
+ static const _PlayListManagerImpl* GetInstance(const PlayListManager& playListManager);
+
+private:
+ _PlayListManagerImpl(const _PlayListManagerImpl& rhs);
+ _PlayListManagerImpl& operator =(const _PlayListManagerImpl& rhs);
+
+ result CreateFilter(const Tizen::Base::String& playListName) const;
+
+ result MapCoreErrorToNativeResult(int reason) const;
+ result MapCoreDatabaseErrorToNativeResult(int reason) const;
+
+ mutable std::unique_ptr<filter_h, FilterDeleter> __pFilterHandle;
+
+}; // class _PlayListManagerImpl
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_CONTENT_PLAYLIST_MANAGER_IMPL_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 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 FCnt_VideoMetadataImpl.h
+ * @brief This is the header file for the %_VideoMetadataImpl class.
+ *
+ * This header file contains the declarations of the %_VideoMetadataImpl class.
+ */
+
+#ifndef _FCNT_INTERNAL_VIDEO_METADATA_IMPL_H_
+#define _FCNT_INTERNAL_VIDEO_METADATA_IMPL_H_
+
+#include <unique_ptr.h>
+#include <FBaseString.h>
+#include <FGrpBitmap.h>
+
+namespace Tizen { namespace Content
+{
+
+class VideoMetadata;
+
+struct VideoMeta
+{
+ VideoMeta()
+ : width(0)
+ , height(0)
+ , framerate(0)
+ , audioBitrate(0)
+ , videoBitrate(0)
+ , duration(0)
+ , contentPath(L"")
+ , pGenre(null)
+ , pAlbumArt(null) {}
+
+ int width;
+ int height;
+ int framerate;
+ int audioBitrate;
+ int videoBitrate;
+ long duration;
+ Tizen::Base::String contentPath;
+ Tizen::Base::String* pGenre;
+ Tizen::Graphics::Bitmap* pAlbumArt;
+};
+
+struct VideoMetaDeleter
+{
+ void operator()(VideoMeta* pVideoMeta)
+ {
+ if (pVideoMeta != null)
+ {
+ if (pVideoMeta->pGenre != null)
+ {
+ delete pVideoMeta->pGenre;
+ pVideoMeta->pGenre = null;
+ }
+ if (pVideoMeta->pAlbumArt != null)
+ {
+ delete pVideoMeta->pAlbumArt;
+ pVideoMeta->pAlbumArt = null;
+ }
+
+ delete pVideoMeta;
+ pVideoMeta = null;
+ }
+ }
+};
+
+class _VideoMetadataImpl
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @since 2.1
+ */
+ _VideoMetadataImpl(void);
+
+ /**
+ * This is the copy constructor for this class.
+ *
+ * @since 2.1
+ */
+ _VideoMetadataImpl(const _VideoMetadataImpl& rhs);
+
+ /**
+ * This is the destructor for this class.
+ *
+ * @since 2.1
+ */
+ virtual ~_VideoMetadataImpl(void);
+
+ /**
+ * @see @ref Tizen::Content::VideoMetadata::GetWidth()
+ */
+ int GetWidth(void) const;
+
+ /**
+ * @see @ref Tizen::Content::VideoMetadata::GetHeight()
+ */
+ int GetHeight(void) const;
+
+ /**
+ * @see @ref Tizen::Content::VideoMetadata::GetDuration()
+ */
+ long GetDuration(void) const;
+
+ /**
+ * @see @ref Tizen::Content::VideoMetadata::GetFramerate()
+ */
+ int GetFramerate(void) const;
+
+ /**
+ * @see @ref Tizen::Content::VideoMetadata::GetAudioBitrate()
+ */
+ int GetAudioBitrate(void) const;
+
+ /**
+ * @see @ref Tizen::Content::VideoMetadata::GetVideoBitrate()
+ */
+ int GetVideoBitrate(void) const;
+
+ /**
+ * @see @ref Tizen::Content::VideoMetadata::GetGenre()
+ */
+ Tizen::Base::String GetGenre(void) const;
+
+ /**
+ * @see @ref Tizen::Content::VideoMetadata::GetAlbumArtN()
+ */
+ Tizen::Graphics::Bitmap* GetAlbumArtN(void) const;
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _VideoMetadataImpl
+ * @param[in] videoMetadata An instance of VideoMetadata
+ */
+ static _VideoMetadataImpl* GetInstance(VideoMetadata& videoMetadata);
+
+ /**
+ * Gets the Impl instance.
+ *
+ * @since 2.1
+ * @return The pointer to _VideoMetadataImpl
+ * @param[in] videoMetadata An instance of VideoMetadata
+ */
+ static const _VideoMetadataImpl* GetInstance(const VideoMetadata& videoMetadata);
+
+ /**
+ * @see @ref Tizen::Content::VideoMetadata::Equals()
+ */
+ virtual bool Equals(const Tizen::Base::Object& rhs) const;
+
+ /**
+ * @see @ref Tizen::Content::VideoMetadata::GetHashCode()
+ */
+ virtual int GetHashCode(void) const;
+
+ /**
+ * @see @ref Tizen::Content::VideoMetadata::operator =()
+ */
+ _VideoMetadataImpl& operator =(const _VideoMetadataImpl& rhs);
+
+private:
+ result SetVideoMetadata(const VideoMeta* pVideoMeta);
+ VideoMeta* GetVideoMetadata(void) const;
+
+private:
+ std::unique_ptr<VideoMeta, VideoMetaDeleter> __pVideoMeta;
+
+ friend class _ContentManagerUtilImpl;
+
+}; // class _VideoMetadataImpl
+
+}} // Tizen::Content
+
+#endif // _FCNT_INTERNAL_VIDEO_METADATA_IMPL_H_