|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "logger.h" |
|
20 #include "s60commonutils.h" |
|
21 #include "cmmsmessageattachment.h" |
|
22 |
|
23 using namespace java::util; |
|
24 |
|
25 namespace java |
|
26 { |
|
27 namespace wma |
|
28 { |
|
29 /////////////////////////////////////////////////////////////////////////////// |
|
30 // CMIDMessageAttachment class |
|
31 /////////////////////////////////////////////////////////////////////////////// |
|
32 /* ------------------------------------------------------------------------ |
|
33 * CMIDMessageAttachment(RFs& aRFs) |
|
34 * |
|
35 * ------------------------------------------------------------------------ |
|
36 */ |
|
37 CMMSMessageAttachment::CMMSMessageAttachment(RFs& aRFs) : mRFs(aRFs) |
|
38 { |
|
39 } |
|
40 /* ------------------------------------------------------------------------ |
|
41 * |
|
42 * const TDesC8& aContentId, const TDesC8& aLocation, TInt aValue) |
|
43 * |
|
44 * ------------------------------------------------------------------------ |
|
45 */ |
|
46 CMMSMessageAttachment* CMMSMessageAttachment::NewL(RFs& aRFs, |
|
47 const TDesC8& aDataArray, const TDesC8& aAttachmentType, |
|
48 const TDesC8& aContentId, const TDesC8& aLocation, |
|
49 TInt aAttachmentNameOrData) |
|
50 { |
|
51 JELOG2(EWMA); |
|
52 CMMSMessageAttachment* self = new(ELeave) CMMSMessageAttachment(aRFs); |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL(aDataArray, aAttachmentType, aContentId, aLocation, |
|
55 aAttachmentNameOrData); |
|
56 CleanupStack::Pop(self); |
|
57 return self; |
|
58 } |
|
59 /* ------------------------------------------------------------------------ |
|
60 * ConstructL(const TDesC8& aDataArray, const TDesC8& aAttachmentType, |
|
61 * const TDesC8& aContentId, const TDesC8& aLocation, TInt aValue) |
|
62 * ------------------------------------------------------------------------ |
|
63 */ |
|
64 void CMMSMessageAttachment::ConstructL(const TDesC8& aDataArray, |
|
65 const TDesC8& aAttachmentType, const TDesC8& aContentId, |
|
66 const TDesC8& aLocation, TInt aAttachmentNameOrData) |
|
67 { |
|
68 JELOG2(EWMA); |
|
69 mEncoding = -1; |
|
70 if (aAttachmentNameOrData) |
|
71 { |
|
72 S60CommonUtils::ConvertNarrowToWiderL(aDataArray, |
|
73 (TDesC*&) mAttachmentNameWithPath); |
|
74 } |
|
75 else |
|
76 { |
|
77 mAttachmentData8 = const_cast<TDesC8*>(&aDataArray); |
|
78 } |
|
79 SetAttchmentTypeLC(aAttachmentType); // copy the attachment type |
|
80 |
|
81 if ((NULL == &aContentId) || (aContentId.Length() < 1)) |
|
82 { |
|
83 SetContentIdLC(KNullDesC8); |
|
84 } |
|
85 else |
|
86 { |
|
87 SetContentIdLC(aContentId); // set the content ID |
|
88 } |
|
89 |
|
90 SetContentLocationLC(aLocation); // set content location |
|
91 CleanupStack::Pop(mContantLocation8); |
|
92 CleanupStack::Pop(mContantId8); |
|
93 CleanupStack::Pop(mAttachmentTypeBuf8); |
|
94 } |
|
95 /* ------------------------------------------------------------------------ |
|
96 * private SetAttchmentType |
|
97 * |
|
98 * ------------------------------------------------------------------------ |
|
99 */ |
|
100 void CMMSMessageAttachment::SetAttchmentTypeLC(const TDesC8& aAttachmentType) |
|
101 { |
|
102 JELOG2(EWMA); |
|
103 S60CommonUtils::CopyNarrowLC(aAttachmentType, (TDesC8*&)mAttachmentTypeBuf8); |
|
104 } |
|
105 /* ------------------------------------------------------------------------ |
|
106 * private void SetContentIdLC(const TDesC8& aContentId) |
|
107 * set content location |
|
108 * ------------------------------------------------------------------------ |
|
109 */ |
|
110 void CMMSMessageAttachment::SetContentIdLC(const TDesC8& aContentId) |
|
111 { |
|
112 JELOG2(EWMA); |
|
113 S60CommonUtils::CopyNarrowLC(aContentId, (TDesC8*&) mContantId8); |
|
114 } |
|
115 /* ------------------------------------------------------------------------ |
|
116 * void SetContentLocationLC(const TDesC8& aLocation) |
|
117 * private set contant location |
|
118 * ------------------------------------------------------------------------ |
|
119 */ |
|
120 void CMMSMessageAttachment::SetContentLocationLC(const TDesC8& aLocation) |
|
121 { |
|
122 JELOG2(EWMA); |
|
123 S60CommonUtils::CopyNarrowLC(aLocation, (TDesC8*&) mContantLocation8); |
|
124 } |
|
125 /* ------------------------------------------------------------------------ |
|
126 * public SetEncoding |
|
127 * ------------------------------------------------------------------------ |
|
128 */ |
|
129 void CMMSMessageAttachment::SetEncoding(TUint aEncoding) |
|
130 { |
|
131 JELOG2(EWMA); |
|
132 mEncoding = aEncoding; |
|
133 } |
|
134 /* ------------------------------------------------------------------------ |
|
135 * public TUint Encoding |
|
136 * ------------------------------------------------------------------------ |
|
137 */ |
|
138 TInt CMMSMessageAttachment::Encoding() |
|
139 { |
|
140 JELOG2(EWMA); |
|
141 return mEncoding; |
|
142 } |
|
143 /* ------------------------------------------------------------------------ |
|
144 * TDesC& AttachmentName() |
|
145 * public get attchment name to add in the message attachment |
|
146 * ------------------------------------------------------------------------ |
|
147 */ |
|
148 TDesC& CMMSMessageAttachment::AttachmentName() |
|
149 { |
|
150 JELOG2(EWMA); |
|
151 return *mAttachmentNameWithPath; |
|
152 } |
|
153 /* ------------------------------------------------------------------------ |
|
154 * |
|
155 * |
|
156 * ------------------------------------------------------------------------ |
|
157 */ |
|
158 CMMSMessageAttachment::~CMMSMessageAttachment() |
|
159 { |
|
160 JELOG2(EWMA); |
|
161 if (mAttachmentNameWithPath) |
|
162 { |
|
163 mRFs.Delete(*mAttachmentNameWithPath); |
|
164 delete mAttachmentNameWithPath; |
|
165 mAttachmentNameWithPath = NULL; |
|
166 } |
|
167 |
|
168 delete mAttachmentTypeBuf8; |
|
169 mAttachmentTypeBuf8 = NULL; |
|
170 delete mAttachmentData8; |
|
171 mAttachmentData8 = NULL; |
|
172 delete mContantId8; |
|
173 mContantId8 = NULL; |
|
174 delete mContantLocation8; |
|
175 mContantLocation8 = NULL; |
|
176 mEncoding = -1; |
|
177 } |
|
178 /* ------------------------------------------------------------------------ |
|
179 * public TDesC8& AttachmentType |
|
180 * we are passing reference to the private member. It is not that bad as |
|
181 * this method is not exported and there is only one user of it. |
|
182 * ------------------------------------------------------------------------ |
|
183 */ |
|
184 TDesC8& CMMSMessageAttachment::AttachmentType() |
|
185 { |
|
186 JELOG2(EWMA); |
|
187 return *mAttachmentTypeBuf8; |
|
188 } |
|
189 |
|
190 /* ------------------------------------------------------------------------ |
|
191 * public AttachmentData |
|
192 * get the attachment data |
|
193 * ------------------------------------------------------------------------ |
|
194 */ |
|
195 TDesC8& CMMSMessageAttachment::AttachmentData() |
|
196 { |
|
197 JELOG2(EWMA); |
|
198 return *mAttachmentData8; |
|
199 } |
|
200 |
|
201 /* ------------------------------------------------------------------------ |
|
202 * public TInt IsStarterContentId |
|
203 * get starter Id, If true then this message part is started Id |
|
204 * ------------------------------------------------------------------------ |
|
205 */ |
|
206 TInt CMMSMessageAttachment::IsStarterContentId() |
|
207 { |
|
208 JELOG2(EWMA); |
|
209 return mIsStarterContentId; |
|
210 } |
|
211 |
|
212 /* ------------------------------------------------------------------------ |
|
213 * public SetStarterContentId |
|
214 * by default it is true |
|
215 * ------------------------------------------------------------------------ |
|
216 */ |
|
217 void CMMSMessageAttachment::SetStarterContentId(TInt aValue) |
|
218 { |
|
219 JELOG2(EWMA); |
|
220 mIsStarterContentId = aValue; |
|
221 } |
|
222 |
|
223 /* ------------------------------------------------------------------------ |
|
224 * TDesC8& ContentIdL() |
|
225 * ------------------------------------------------------------------------ |
|
226 */ |
|
227 TDesC8& CMMSMessageAttachment::ContentIdL() |
|
228 { |
|
229 JELOG2(EWMA); |
|
230 return *mContantId8; |
|
231 } |
|
232 /* ------------------------------------------------------------------------ |
|
233 * TDesC8& ContentLocationL |
|
234 * ------------------------------------------------------------------------ |
|
235 */ |
|
236 TDesC8& CMMSMessageAttachment::ContentLocationL() |
|
237 { |
|
238 JELOG2(EWMA); |
|
239 return *mContantLocation8; |
|
240 } |
|
241 |
|
242 // end of the file |
|
243 } //namespace wma |
|
244 } //namespace java |
|
245 |