Beta merge 2
[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()
48 {
49     LogDebug("entered");
50 }
51
52 Attachment::Attachment(const string& fullPath,
53         bool isVirtualPath)
54 {
55     LogDebug("entered");
56     init(fullPath, isVirtualPath);
57 }
58
59 Attachment::Attachment(emf_attachment_info_t* att)
60 {
61     LogDebug("entered");
62
63     m_attachShortName = std::string(att->name); //set shot Name
64     m_isDownloaded = att->downloaded;
65     m_attachmentID = att->attachment_id;
66         
67     LogDebug(" showname = " << m_attachShortName << " isDownloaded = " << m_isDownloaded << " attachmentID = " << m_attachmentID);
68     LogDebug("save name is = " << att->savename);
69     if ( att->savename )
70     {
71         init( att->savename, false);
72     }
73 }
74
75 /*
76 Attachment::Attachment(const std::string& fullPath, bool isVirtualPath, 
77         const Api::Filesystem::INode& inode):
78         Api::Filesystem::INode(inode)
79 {
80         LogDebug("entered , inode");
81         init(fullPath, isVirtualPath);  
82 }
83 */
84
85 #if 0
86 Attachment::Attachment(const std::string& fullPath, bool isVirtualPath, const Api::Filesystem::INode& inode):
87         IAttachment(inode)
88 {
89         LogDebug("entered , inode");
90         init(fullPath, isVirtualPath);  
91 }
92 #endif 
93
94 std::string Attachment::getRealPath(const std::string &path) const
95 {
96
97 #if 0 // MESSAGING ATTACHMENT IS BLOCKED
98     Try
99     {
100         Api::Filesystem::IPathPtr currentPath = Api::Filesystem::IPath::create(
101                 path);
102         return currentPath->getFullPath();
103     }
104
105     Catch(WrtDeviceApis::Commons::Exception) {
106         LogError("invalid path");
107         ReThrow(WrtDeviceApis::Commons::InvalidArgumentException);
108     }
109 #endif
110
111         LogDebug(" path = " << path);
112
113         return path;
114
115 }
116
117 }
118 }
119 }
120