Fix : Temporarily remove AlbumArtist information because of the build error
[platform/framework/native/content.git] / src / FCnt_OtherContentInfoImpl.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 /**
17  * @file                FCnt_OtherContentInfoImpl.cpp
18  * @brief               This is the implementation file for the %_OtherContentInfoImpl class.
19  *
20  * This file contains implementation of the %_OtherContentInfoImpl class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FIoDirectory.h>
25 #include <FIoFile.h>
26 #include <FSysEnvironment.h>
27 #include <FApp_AppInfo.h>
28 #include <FIo_FileImpl.h>
29 #include "FCnt_OtherContentInfoImpl.h"
30
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Io;
34 using namespace Tizen::System;
35
36 namespace Tizen { namespace Content
37 {
38
39 _OtherContentInfoImpl::_OtherContentInfoImpl(void)
40 {
41
42 }
43
44 _OtherContentInfoImpl::~_OtherContentInfoImpl(void)
45 {
46
47 }
48
49 _OtherContentInfoImpl*
50 _OtherContentInfoImpl::GetInstance(OtherContentInfo& otherContentInfo)
51 {
52         return otherContentInfo.__pOtherContentInfoImpl;
53 }
54
55 const _OtherContentInfoImpl*
56 _OtherContentInfoImpl::GetInstance(const OtherContentInfo& otherContentInfo)
57 {
58         return otherContentInfo.__pOtherContentInfoImpl;
59 }
60
61 result
62 _OtherContentInfoImpl::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
63 {
64         result r = E_SUCCESS;
65         String tempPath(contentPath);
66
67         if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
68         {
69                 if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
70                 {
71                         // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
72                         // it should be converted in 2.0.
73                         r = tempPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
74                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
75                 }
76                 else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
77                 {
78                         r = tempPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
79                         SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
80                 }
81                 else
82                 {
83                         SysLogException(NID_CNT, E_INVALID_ARG,
84                                         "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
85                         return E_INVALID_ARG;
86                 }
87         }
88
89         // checks parameters
90         SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
91                         "The contentPath should start with /Media or /Storagecard/Media.");
92         SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
93                         "The file corresponding to contentPath could not be found.");
94
95         if (thumbnailPath.GetLength() > 0)
96         {
97                 SysLog(NID_CNT, "The thumbnailPath is not supported.");
98         }
99
100         if (setGps)
101         {
102                 SysLog(NID_CNT, "The setGps is not supported.");
103         }
104
105         SetContentPath(tempPath);
106         SetContentType(CONTENT_TYPE_OTHER);
107
108         return r;
109 }
110
111 result
112 _OtherContentInfoImpl::Construct(const String* pContentPath)
113 {
114         result r = E_SUCCESS;
115
116         if (pContentPath != null)
117         {
118                 String contentPath(*pContentPath);
119
120                 if (!_AppInfo::IsOspCompat())
121                 {
122                         if (!(contentPath.StartsWith(Environment::GetMediaPath(), 0)
123                                 || contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
124                         {
125                                 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] The path is not supported.");
126                                 return E_INVALID_ARG;
127                         }
128                 }
129                 else
130                 {
131                         // prior to 2.0
132                         if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
133                         {
134                                 // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
135                                 // it should be converted in 2.0.
136                                 r = contentPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
137                                 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
138                         }
139                         else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
140                         {
141                                 r = contentPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
142                                 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
143                         }
144                         else
145                         {
146                                 SysLogException(NID_CNT, E_INVALID_ARG,
147                                                 "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
148                                 return E_INVALID_ARG;
149                         }
150                 }
151
152                 int length = contentPath.GetLength();
153                 SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG,
154                                 "The length of pContentPath is 0.");
155                 SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND,
156                                 "The file corresponding to pContentPath could not be found.");
157
158                 SetContentPath(contentPath);
159                 SetContentType(CONTENT_TYPE_OTHER);
160         }
161         else
162         {
163                 SetContentType(CONTENT_TYPE_OTHER);
164         }
165
166         return r;
167 }
168
169 }}