|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <mtmuids.h> |
|
17 #include <mtclbase.h> |
|
18 |
|
19 _LIT(KTestSendas2MtmDefaultsFolder, "c:\\test\\sendas2\\%08X.default"); |
|
20 |
|
21 class CSendMtm : public CBaseMtm |
|
22 { |
|
23 public: |
|
24 IMPORT_C static CSendMtm* NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aSession); |
|
25 ~CSendMtm(); |
|
26 // |
|
27 // from MMsvEntryObserver |
|
28 void HandleEntryEvent(TMsvEntryEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3); |
|
29 // |
|
30 // from CBaseMtm |
|
31 void SaveMessageL(); |
|
32 void LoadMessageL(); |
|
33 CMsvOperation* ReplyL (TMsvId aDestination, TMsvPartList aPartlist, TRequestStatus& aCompletionStatus); |
|
34 CMsvOperation* ForwardL(TMsvId aDestination, TMsvPartList aPartList, TRequestStatus& aCompletionStatus); |
|
35 TMsvPartList ValidateMessage(TMsvPartList aPartList); |
|
36 TMsvPartList Find(const TDesC& aTextToFind, TMsvPartList aPartList); |
|
37 //const CDesCArray& AddresseeList(); |
|
38 const CMsvRecipientList& AddresseeList(); |
|
39 void AddAddresseeL(const TDesC& aRealAddress); |
|
40 void AddAddresseeL(const TDesC& aRealAddress, const TDesC& aAlias); |
|
41 void RemoveAddressee(TInt aIndex); |
|
42 void InvokeSyncFunctionL(TInt aFunctionId,const CMsvEntrySelection& aSelection, TDes8& aParameter); |
|
43 CMsvOperation* InvokeAsyncFunctionL(TInt aFunctionId,const CMsvEntrySelection& aSelection, TDes8& aParameter, TRequestStatus& aCompletionStatus); |
|
44 // |
|
45 TInt QueryCapability(TUid aCapability, TInt& aResponse); |
|
46 virtual void SetSubjectL(const TDesC& aSubject); |
|
47 // |
|
48 virtual TMsvId DefaultServiceL() const; |
|
49 virtual void RemoveDefaultServiceL(); |
|
50 virtual void ChangeDefaultServiceL(const TMsvId& aService); |
|
51 // |
|
52 virtual void AddAddresseeL(TMsvRecipientType aType, const TDesC& aRealAddress); |
|
53 virtual void AddAddresseeL(TMsvRecipientType aType, const TDesC& aRealAddress, const TDesC& aAlias); |
|
54 protected: |
|
55 // |
|
56 // from CBaseMtm |
|
57 void ContextEntrySwitched(); |
|
58 // |
|
59 private: |
|
60 CSendMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aSession); |
|
61 // |
|
62 private: |
|
63 RFs& iFs; |
|
64 }; |
|
65 |
|
66 |
|
67 |
|
68 EXPORT_C CSendMtm* CSendMtm::NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aSession) |
|
69 { |
|
70 CSendMtm* myclntmtm=new(ELeave) CSendMtm(aRegisteredMtmDll, aSession); |
|
71 return myclntmtm; |
|
72 } |
|
73 |
|
74 CSendMtm::~CSendMtm() |
|
75 { |
|
76 } |
|
77 |
|
78 void CSendMtm::HandleEntryEvent(TMsvEntryEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/) |
|
79 { |
|
80 } |
|
81 |
|
82 void CSendMtm::SaveMessageL() |
|
83 { |
|
84 CMsvStore* store = iMsvEntry->EditStoreL(); |
|
85 CleanupStack::PushL(store); |
|
86 StoreBodyL(*store); |
|
87 store->CommitL(); |
|
88 CleanupStack::PopAndDestroy(); // store |
|
89 } |
|
90 |
|
91 void CSendMtm::LoadMessageL() |
|
92 { |
|
93 CMsvStore* store = iMsvEntry->ReadStoreL(); |
|
94 CleanupStack::PushL(store); |
|
95 RestoreBodyL(*store); |
|
96 CleanupStack::PopAndDestroy(); // store |
|
97 } |
|
98 |
|
99 CMsvOperation* CSendMtm::ReplyL(TMsvId /*aDestination*/, TMsvPartList /*aPartlist*/, TRequestStatus& /*aCompletionStatus*/) |
|
100 { |
|
101 return NULL; |
|
102 } |
|
103 |
|
104 CMsvOperation* CSendMtm::ForwardL(TMsvId /*aDestination*/, TMsvPartList /*aPartList*/, TRequestStatus& /*aCompletionStatus*/) |
|
105 { |
|
106 return NULL; |
|
107 } |
|
108 |
|
109 TMsvPartList CSendMtm::Find(const TDesC& /*aTextToFind*/, TMsvPartList /*aPartList*/) |
|
110 { |
|
111 return 0; |
|
112 } |
|
113 |
|
114 const CMsvRecipientList& CSendMtm::AddresseeList() |
|
115 { |
|
116 return *iAddresseeList; |
|
117 } |
|
118 |
|
119 void CSendMtm::AddAddresseeL(const TDesC& aRealAddress) |
|
120 { |
|
121 iAddresseeList->AppendL(aRealAddress); |
|
122 } |
|
123 |
|
124 void CSendMtm::AddAddresseeL(const TDesC& aRealAddress, const TDesC& aAlias) |
|
125 { |
|
126 TBuf<256> buf; |
|
127 buf.Copy(aAlias); |
|
128 buf.Append(_L(" <")); |
|
129 buf.Append(aRealAddress); |
|
130 buf.Append(_L(">")); |
|
131 iAddresseeList->AppendL(buf); |
|
132 } |
|
133 |
|
134 void CSendMtm::RemoveAddressee(TInt aIndex) |
|
135 { |
|
136 iAddresseeList->Delete(aIndex); |
|
137 } |
|
138 |
|
139 void CSendMtm::ContextEntrySwitched() |
|
140 { |
|
141 } |
|
142 |
|
143 void CSendMtm::InvokeSyncFunctionL(TInt /*aFunctionId*/,const CMsvEntrySelection& /*aSelection*/, TDes8& /*aParameter*/) |
|
144 { |
|
145 User::Leave(KErrNotSupported); |
|
146 } |
|
147 |
|
148 CMsvOperation* CSendMtm::InvokeAsyncFunctionL(TInt /*aFunctionId*/,const CMsvEntrySelection& /*aSelection*/, TDes8& /*aParameter*/, TRequestStatus& aCompletionStatus) |
|
149 { |
|
150 TRequestStatus* status=&aCompletionStatus; |
|
151 User::RequestComplete(status,KErrNotSupported); |
|
152 return NULL;; |
|
153 } |
|
154 |
|
155 TMsvId CSendMtm::DefaultServiceL() const |
|
156 { |
|
157 TFileName filename; |
|
158 filename.Format(KTestSendas2MtmDefaultsFolder, Type().iUid); |
|
159 TPckgBuf<TMsvId> msvbuf; |
|
160 RFile file; |
|
161 CleanupClosePushL(file); |
|
162 |
|
163 if (file.Open(iFs, filename, EFileRead) == KErrNone) |
|
164 { |
|
165 User::LeaveIfError(file.Read(msvbuf)); |
|
166 } |
|
167 else |
|
168 { |
|
169 User::Leave(KErrNotFound); |
|
170 } |
|
171 CleanupStack::PopAndDestroy(&file); |
|
172 return msvbuf(); |
|
173 } |
|
174 |
|
175 void CSendMtm::RemoveDefaultServiceL() |
|
176 { |
|
177 TFileName filename; |
|
178 filename.Format(KTestSendas2MtmDefaultsFolder, Type().iUid); |
|
179 iFs.Delete(filename); |
|
180 } |
|
181 |
|
182 void CSendMtm::ChangeDefaultServiceL(const TMsvId& aService) |
|
183 { |
|
184 TFileName filename; |
|
185 filename.Format(KTestSendas2MtmDefaultsFolder, Type().iUid); |
|
186 TPckgBuf<TMsvId> msvbuf; |
|
187 msvbuf() = aService; |
|
188 RFile file; |
|
189 CleanupClosePushL(file); |
|
190 iFs.MkDirAll(filename); |
|
191 User::LeaveIfError(file.Replace(iFs, filename, EFileRead) == KErrNone); |
|
192 User::LeaveIfError(file.Write(msvbuf)); |
|
193 CleanupStack::PopAndDestroy(&file); |
|
194 } |
|
195 |
|
196 CSendMtm::CSendMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aSession) : |
|
197 CBaseMtm(aRegisteredMtmDll, aSession), iFs(aSession.FileSession()) |
|
198 { |
|
199 __DECLARE_NAME(_S("CSendAs2Mtm")); |
|
200 } |
|
201 |
|
202 |