|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Provides audioMessage document methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <MuiuMsvUiServiceUtilities.h> //Disk space check |
|
22 #include <centralrepository.h> |
|
23 #include <mmsclient.h> |
|
24 #include <MmsEngineInternalCRKeys.h> |
|
25 #include <mmsmsventry.h> |
|
26 #include <MuiuMsgEditorLauncher.h> |
|
27 #include <MsgMediaResolver.h> |
|
28 #include "audiomessageappui.h" |
|
29 #include "audiomessagedocument.h" |
|
30 #include "MsgMimeTypes.h" |
|
31 |
|
32 const TInt KAmsIndexEntryExtra = 2000; // space reserved for the index entry |
|
33 const TInt KDefaultMaxSize = 300 * 1024; |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // --------------------------------------------------------- |
|
38 // CAudioMessageDocument::Constructor |
|
39 // --------------------------------------------------------- |
|
40 // |
|
41 CAudioMessageDocument::CAudioMessageDocument( CEikApplication& aApp ) : |
|
42 CMsgEditorDocument( aApp ), |
|
43 iMaxMessageSize( KDefaultMaxSize ), |
|
44 iRecordIconStatus( EAudioInsert ) |
|
45 { |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------- |
|
49 // CAudioMessageDocument::Destructor |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 CAudioMessageDocument::~CAudioMessageDocument() |
|
53 { |
|
54 delete iMediaResolver; |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------- |
|
58 // CAudioMessageDocument::SetMessageType |
|
59 // --------------------------------------------------------- |
|
60 // |
|
61 void CAudioMessageDocument::SetMessageType() |
|
62 { |
|
63 const TInt flags = LaunchFlags(); |
|
64 TMmsMsvEntry tEntry = static_cast<TMmsMsvEntry>( Entry() ); |
|
65 |
|
66 if ( tEntry.Parent( ) == KMsvSentEntryId ) |
|
67 { |
|
68 iMessageType = EAmsSent; |
|
69 return; |
|
70 } |
|
71 |
|
72 if ( flags & EMsgCreateNewMessage ) |
|
73 { |
|
74 iMessageType = EAmsNewMessage; |
|
75 return; |
|
76 } |
|
77 else if ( flags & EMsgForwardMessage ) |
|
78 { |
|
79 iMessageType = EAmsForward; |
|
80 return; |
|
81 } |
|
82 else if ( flags & EMsgCreateDuplicate ) |
|
83 { |
|
84 iMessageType = EAmsEdit; |
|
85 return; |
|
86 } |
|
87 else if ( flags & EMsgEditNewMessage ) |
|
88 { |
|
89 iMessageType = EAmsSendAs; |
|
90 return; |
|
91 } |
|
92 else if ( flags & EMsgReadOnly && flags & EMsgLaunchEditorEmbedded ) |
|
93 { |
|
94 iMessageType = EAmsInbox; |
|
95 return; |
|
96 } |
|
97 |
|
98 // Either sendas or open from draft |
|
99 if ( tEntry.IsForwardedMessage() ) |
|
100 { |
|
101 // Forwarded message saved to draft |
|
102 iMessageType = EAmsForward; |
|
103 } |
|
104 else if ( tEntry.EditorOriented() ) |
|
105 { |
|
106 iMessageType = EAmsOpenFromDraft; |
|
107 } |
|
108 else |
|
109 { |
|
110 iMessageType = EAmsSendAs; |
|
111 } |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------- |
|
115 // CAudioMessageDocument::ConstructL |
|
116 // --------------------------------------------------------- |
|
117 // |
|
118 void CAudioMessageDocument::ConstructL() |
|
119 { |
|
120 CMsgEditorDocument::ConstructL(); |
|
121 |
|
122 CRepository* repository = CRepository::NewL( KCRUidMmsEngine ); |
|
123 TInt maxSendSize = 0; |
|
124 // value is returned as bytes now |
|
125 TInt err = repository->Get( KMmsEngineMaximumSendSize, maxSendSize ); |
|
126 if ( !err ) |
|
127 { |
|
128 iMaxMessageSize = maxSendSize; |
|
129 } |
|
130 delete repository; |
|
131 PrepareMtmL( KUidMsgTypeMultimedia ); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------- |
|
135 // CAudioMessageDocument::NewL |
|
136 // --------------------------------------------------------- |
|
137 // |
|
138 CAudioMessageDocument* CAudioMessageDocument::NewL(CEikApplication& aApp) |
|
139 { |
|
140 CAudioMessageDocument* med = new ( ELeave ) CAudioMessageDocument( aApp ); |
|
141 CleanupStack::PushL( med ); |
|
142 med->ConstructL(); |
|
143 CleanupStack::Pop( med ); |
|
144 return med; |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------- |
|
148 // CAudioMessageDocument::CreateAppUiL |
|
149 // --------------------------------------------------------- |
|
150 // |
|
151 CEikAppUi* CAudioMessageDocument::CreateAppUiL() |
|
152 { |
|
153 return new ( ELeave ) CAudioMessageAppUi; |
|
154 } |
|
155 |
|
156 |
|
157 // --------------------------------------------------------- |
|
158 // CAudioMessageDocument::CreateNewL |
|
159 // --------------------------------------------------------- |
|
160 // |
|
161 TMsvId CAudioMessageDocument::CreateNewL(TMsvId /* aServiceId */, TMsvId aDestFolder ) |
|
162 { |
|
163 // Can only create to draft |
|
164 if ( aDestFolder != KMsvDraftEntryIdValue ) |
|
165 { |
|
166 User::Leave( KErrNotSupported ); |
|
167 } |
|
168 |
|
169 // Don't allow creation if will go under CL |
|
170 if ( MsvUiServiceUtilities::DiskSpaceBelowCriticalLevelL( |
|
171 Session(), |
|
172 KAmsIndexEntryExtra ) ) |
|
173 { |
|
174 User::Leave( KErrDiskFull ); |
|
175 } |
|
176 |
|
177 CMmsClientMtm& clientMtm = Mtm(); |
|
178 |
|
179 // CREATE TO aDestFolder (DRAFT) |
|
180 CMsvOperationActiveSchedulerWait* wait = CMsvOperationActiveSchedulerWait::NewLC(); |
|
181 CMsvOperation* createOperation = clientMtm.CreateNewEntryL( aDestFolder, wait->iStatus ); |
|
182 CleanupStack::PushL( createOperation ); |
|
183 wait->Start(); |
|
184 |
|
185 if ( wait->iStatus.Int() != KErrNone ) |
|
186 { |
|
187 User::Leave( wait->iStatus.Int() ); |
|
188 } |
|
189 |
|
190 // Get the message id |
|
191 TPckgBuf<TMsvId> pkg; |
|
192 pkg.Copy( createOperation->ProgressL() ); |
|
193 TMsvId progress = 0; |
|
194 progress = pkg(); |
|
195 CleanupStack::PopAndDestroy( createOperation ); |
|
196 CleanupStack::PopAndDestroy( wait ); |
|
197 return progress; |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // CAudioMessageDocument::EntryChangedL |
|
202 // Intentionally empty implementation. |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 void CAudioMessageDocument::EntryChangedL() |
|
206 { |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------- |
|
210 // CAudioMessageDocument::InitializeL |
|
211 // --------------------------------------------------------- |
|
212 // |
|
213 TInt CAudioMessageDocument::InitializeL( ) |
|
214 { |
|
215 iMediaResolver = CMsgMediaResolver::NewL(); |
|
216 return KErrNone; |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------- |
|
220 // CAudioMessageDocument::Mtm |
|
221 // --------------------------------------------------------- |
|
222 // |
|
223 CMmsClientMtm& CAudioMessageDocument::Mtm() |
|
224 { |
|
225 return static_cast <CMmsClientMtm&> ( CMsgEditorDocument::Mtm() ); |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------- |
|
229 // CAudioMessageDocument::MessageType |
|
230 // --------------------------------------------------------- |
|
231 // |
|
232 TBool CAudioMessageDocument::IsAmrL( RFile& aFile, TDataType& aMimeType ) const |
|
233 { |
|
234 iMediaResolver->RecognizeL( aFile, aMimeType); |
|
235 TDataType testType( KMsgMimeAudioAmr ); |
|
236 if ( aMimeType != testType ) |
|
237 { |
|
238 return EFalse; |
|
239 } |
|
240 else |
|
241 { |
|
242 return ETrue; |
|
243 } |
|
244 |
|
245 } |
|
246 |
|
247 |