1ed0162c151a2512397c6bef5be8b913eb0f0849
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Messaging / Attachment.cpp
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
18 /**
19  * @file       Attachment.cpp
20  * @author     Pawel Misiak (p.misiak@samsung.com)
21  * @version    0.1
22  * @brief
23  */
24 #include <algorithm>
25 #include <dpl/log/log.h>
26 #include <Commons/Exception.h>
27 #include <Filesystem/Manager.h>
28 #include "Attachment.h"
29
30 #include <API/Filesystem/INode.h>
31 #include <Tizen/Filesystem/EventGetNodeData.h>
32 #include <API/Filesystem/IManager.h>
33
34 extern "C" {
35 #include <sys/stat.h>
36 #include <stdlib.h>
37 }
38
39 using namespace WrtDeviceApis::Commons;
40 using namespace std;
41
42 //--------------------------------------------------------------------------
43 namespace TizenApis {
44 namespace Platform {
45 namespace Messaging {
46         
47 Attachment::Attachment(const string& fullPath,
48         bool isVirtualPath)
49 {
50     LogDebug("entered");
51     init(fullPath, isVirtualPath);
52 }
53
54 Attachment::Attachment(emf_attachment_info_t* att)
55 {
56     LogDebug("entered");
57
58     m_attachShortName = std::string(att->name); //set shot Name
59     m_isDownloaded = att->downloaded;
60     m_attachmentID = att->attachment_id;
61         
62     LogDebug(" showname = " << m_attachShortName << " isDownloaded = " << m_isDownloaded << " attachmentID = " << m_attachmentID);
63     LogDebug("save name is = " << att->savename);
64     if ( att->savename )
65     {
66         init( att->savename, false);
67     }
68 }
69
70 /*
71 Attachment::Attachment(const std::string& fullPath, bool isVirtualPath, 
72         const Api::Filesystem::INode& inode):
73         Api::Filesystem::INode(inode)
74 {
75         LogDebug("entered , inode");
76         init(fullPath, isVirtualPath);  
77 }
78 */
79
80 #if 0
81 Attachment::Attachment(const std::string& fullPath, bool isVirtualPath, const Api::Filesystem::INode& inode):
82         IAttachment(inode)
83 {
84         LogDebug("entered , inode");
85         init(fullPath, isVirtualPath);  
86 }
87 #endif 
88
89 std::string Attachment::getRealPath(const std::string &path) const
90 {
91 #if 0 // MESSAGING ATTACHMENT IS BLOCKED
92     Try
93     {
94         Api::Filesystem::IPathPtr currentPath = Api::Filesystem::IPath::create(
95                 path);
96         return currentPath->getFullPath();
97     }
98
99     Catch(WrtDeviceApis::Commons::Exception) {
100         LogError("invalid path");
101         ReThrow(WrtDeviceApis::Commons::InvalidArgumentException);
102     }
103 #endif
104 }
105
106 }
107 }
108 }
109