00001
00002
00003
00004
00005
00006
00007 #include "txclient.h"
00008
00009
00010 #include <e32std.h>
00011 #include <txtrich.h>
00012 #include <msvids.h>
00013 #include <msvreg.h>
00014 #include <msvstore.h>
00015 #include <msvuids.h>
00016 #include <mtmdef.h>
00017
00018
00019 #include "txtcmds.hrh"
00020 #include "txtcpan.h"
00021 #include "txtfwdop.h"
00022
00023 _LIT(KTxtGeneratedFilename, "C:\\data\\TextMTMService\\sentmsgbody.txt");
00024
00025 EXPORT_C CTextMtmClient* CTextMtmClient::NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession)
00026
00027 {
00028 CTextMtmClient* self = new (ELeave) CTextMtmClient(aRegisteredMtmDll,aMsvSession);
00029 CleanupStack::PushL(self);
00030 self->ConstructL();
00031 CleanupStack::Pop();
00032 return self;
00033 }
00034
00035
00036 CTextMtmClient::CTextMtmClient(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession)
00037 : CBaseMtm(aRegisteredMtmDll,aMsvSession)
00038 {
00039 __ASSERT_DEBUG(Type()==KUidMsgTypeText,gPanic(ETxtcBadMtmTypeUid));
00040 }
00041
00042 void CTextMtmClient::ConstructL()
00043 {
00044 iSettings = CMTMTxtSettings::NewL();
00045 SwitchCurrentEntryL(KMsvRootIndexEntryId);
00046 }
00047
00048 CTextMtmClient::~CTextMtmClient()
00049 {
00050 delete iSettings;
00051 }
00052
00053
00054 void CTextMtmClient::SaveMessageL()
00055
00056
00057
00058
00059 {
00060
00061 __ASSERT_DEBUG(iMsvEntry!=NULL,gPanic(ETxtcNoCMsvEntrySet));
00062 TMsvEntry entry=iMsvEntry->Entry();
00063
00064 switch (iMsvEntry->Entry().iType.iUid)
00065 {
00066 case KUidMsvServiceEntryValue:
00067
00068
00069 iSettings->SaveSettingsL(iMsvEntry->Entry().Id(), iTxtSettings);
00070 break;
00071 case KUidMsvMessageEntryValue:
00072
00073 CMsvStore* store = iMsvEntry->EditStoreL();
00074 CleanupStack::PushL(store);
00075 StoreBodyL(*store);
00076 store->CommitL();
00077 CleanupStack::PopAndDestroy(store);
00078
00079
00080 entry.SetVisible(ETrue);
00081 entry.SetInPreparation(EFalse);
00082 entry.iServiceId= KMsvLocalServiceIndexEntryId;
00083 _LIT(KNewFile,"message.txt");
00084 entry.iDescription.Set(KNewFile);
00085 iMsvEntry->ChangeL(entry);
00086 break;
00087
00088
00089
00090 default:
00091 __ASSERT_DEBUG(EFalse, gPanic(ETxtcEntryTypeNotSupported));
00092 break;
00093 }
00094
00095 }
00096
00097 void CTextMtmClient::LoadMessageL()
00098
00099
00100
00101 {
00102 __ASSERT_DEBUG(iMsvEntry!=NULL,gPanic(ETxtcNoCMsvEntrySet));
00103
00104
00105
00106 switch (iMsvEntry->Entry().iType.iUid)
00107 {
00108 case KUidMsvServiceEntryValue:
00109
00110 iSettings->LoadSettingsL(iMsvEntry->Entry().Id(), iTxtSettings);
00111 break;
00112 case KUidMsvMessageEntryValue:
00113
00114
00115 CMsvStore* store = iMsvEntry->HasStoreL() ? iMsvEntry->ReadStoreL() : NULL;
00116 if (store==NULL) return;
00117 CleanupStack::PushL(store);
00118 RestoreBodyL(*store);
00119 CleanupStack::PopAndDestroy();
00120 break;
00121 default:
00122 __ASSERT_DEBUG(EFalse, gPanic(ETxtcEntryTypeNotSupported));
00123 break;
00124 }
00125
00126 }
00127
00128
00129 CMsvOperation* CTextMtmClient::ReplyL (TMsvId , TMsvPartList ,
00130 TRequestStatus& )
00131
00132
00133
00134 {
00135 User::Leave(KErrNotSupported);
00136 return NULL;
00137 }
00138
00139
00140 CMsvOperation* CTextMtmClient::ForwardL(TMsvId aDestination, TMsvPartList , TRequestStatus& aCompletionStatus)
00141
00142
00143
00144 {
00145 __ASSERT_DEBUG(iMsvEntry!=NULL,gPanic(ETxtcNoCMsvEntrySet));
00146 __ASSERT_DEBUG(iMsvEntry->Entry().iType.iUid == KUidMsvMessageEntryValue, gPanic(ETxtcEntryTypeNotSupported));
00147 __ASSERT_DEBUG(iMsvEntry->Entry().iServiceId == KMsvLocalServiceIndexEntryId, gPanic(ETxtcInvalidServiceId));
00148
00149 return CTxtMtmForwardOperation::NewL(Entry().EntryId(), aDestination, Session(), aCompletionStatus);
00150 }
00151
00152
00153 TMsvPartList CTextMtmClient::ValidateMessage(TUint aPartList)
00154
00155
00156
00157
00158
00159
00160 {
00161 __ASSERT_DEBUG(iMsvEntry!=NULL,gPanic(ETxtcNoCMsvEntrySet));
00162 TInt retVal=0;
00163 if (aPartList & KMsvMessagePartDescription)
00164 {
00165 if (iMsvEntry->Entry().iDescription.Length() == 0)
00166 {
00167 retVal |= KMsvMessagePartDescription;
00168 }
00169 else if (iMsvEntry->Entry().iDescription.Locate( TChar('\\')) >= 0)
00170 {
00171 retVal |= KMsvMessagePartDescription;
00172 }
00173 }
00174 return retVal;
00175 }
00176
00177
00178 TMsvPartList CTextMtmClient::Find(const TDesC& aTextToFind, TMsvPartList aPartList)
00179
00180 {
00181 __ASSERT_DEBUG(iMsvEntry!=NULL, gPanic(ETxtcNoCMsvEntrySet));
00182 TMsvPartList retVal = KMsvMessagePartNone;
00183 if (aPartList & KMsvMessagePartBody)
00184 {
00185 CRichText& body = Body();
00186
00187 if (body.DocumentLength() > 0)
00188 {
00189
00190 TPtrC theText = body.Read(0);
00191 if(theText.FindF(aTextToFind) != KErrNone)
00192 retVal |= KMsvMessagePartBody;
00193 }
00194 }
00195
00196 if (aPartList & KMsvMessagePartOriginator)
00197 {
00198 if (iMsvEntry->Entry().iDetails.FindF( aTextToFind ) >= 0)
00199 {
00200 retVal |= KMsvMessagePartOriginator;
00201 }
00202 }
00203
00204 if (aPartList & KMsvMessagePartDescription)
00205 {
00206 if (iMsvEntry->Entry().iDescription.FindF( aTextToFind ) >= 0)
00207 {
00208 retVal |= KMsvMessagePartDescription;
00209 }
00210 }
00211
00212
00213
00214 return retVal;
00215 }
00216
00217 TInt CTextMtmClient::QueryCapability(TUid aCapability, TInt& aResponse)
00218
00219 {
00220 TInt error = KErrNone;
00221 switch (aCapability.iUid)
00222 {
00223 case KUidMtmQueryMaxBodySizeValue:
00224 case KUidMtmQueryMaxTotalMsgSizeValue:
00225 aResponse = KMaxTextMessageSize;
00226 break;
00227 case KUidMtmQuerySupportedBodyValue:
00228 aResponse = KMtm8BitBody + KMtm7BitBody;
00229 break;
00230 case KUidMtmQueryOffLineAllowedValue:
00231 case KUidMtmQueryCanReceiveMsgValue:
00232 aResponse = 0;
00233 break;
00234
00235 default:
00236 return KErrNotSupported;
00237 }
00238 return error;
00239 }
00240
00241 void CTextMtmClient::InvokeSyncFunctionL(TInt aFunctionId, const CMsvEntrySelection& aSelection, TDes8& aParameter)
00242
00243 {
00244 TInt error = KErrNone;
00245 CMsvOperationActiveSchedulerWait* wait=CMsvOperationActiveSchedulerWait::NewLC();
00246 CMsvOperation* operation = InvokeAsyncFunctionL(aFunctionId,aSelection, aParameter, wait->iStatus);
00247 if (operation != NULL)
00248 {
00249 wait->Start();
00250 error = wait->iStatus.Int();
00251 delete operation;
00252 }
00253 else
00254 {
00255 error=KErrNotSupported;
00256 }
00257 CleanupStack::PopAndDestroy();
00258
00259 }
00260
00261 CMsvOperation* CTextMtmClient::InvokeAsyncFunctionL(TInt aFunctionId,
00262 const CMsvEntrySelection& aSelection,
00263 TDes8& aParameter,
00264 TRequestStatus& aCompletionStatus)
00265
00266 {
00267 CMsvOperation* operation = NULL;
00268 switch (aFunctionId)
00269 {
00270 case KTXTMTMRefresh:
00271 {
00272 operation = (Entry().Session().TransferCommandL(aSelection, aFunctionId, aParameter, aCompletionStatus));
00273 }
00274 break;
00275 case KTXTMTMMessageCommand:
00276 {
00277 __ASSERT_DEBUG(EFalse,gPanic(ETxtcCommandNotSupported));
00278 break;
00279 }
00280 default:
00281 __ASSERT_DEBUG(EFalse,gPanic(ETxtcCommandNotSupported));
00282 break;
00283 }
00284 return operation;
00285 }
00286
00287
00288 void CTextMtmClient::ContextEntrySwitched()
00289
00290
00291
00292
00293 {
00294 }
00295
00296
00297 void CTextMtmClient::CreateAttachmentL(const TDesC& , const TDesC8& , TRequestStatus& )
00298 {
00299 User::Leave(KErrNotSupported);
00300 }
00301
00302 void CTextMtmClient::CreateAttachmentL(RFile& , const TDesC8& , TRequestStatus& )
00303 {
00304 User::Leave(KErrNotSupported);
00305 }
00306
00307 void CTextMtmClient::CreateLinkedAttachmentL(const TDesC& , const TDesC8& , TRequestStatus& )
00308 {
00309 User::Leave(KErrNotSupported);
00310 }
00311
00312 void CTextMtmClient::CreateMessageAttachmentL(TMsvId , TRequestStatus& )
00313 {
00314 User::Leave(KErrNotSupported);
00315 }
00316
00317
00318 TMsvId CTextMtmClient::DefaultServiceL() const
00319 {
00320 return iSettings->DefaultServiceL();
00321 }
00322
00323 void CTextMtmClient::RemoveDefaultServiceL()
00324 {
00325 iSettings->DeleteDefaultServiceSettingL();
00326 }
00327
00328 void CTextMtmClient::ChangeDefaultServiceL(const TMsvId& aService)
00329 {
00330 iSettings->SetDefaultServiceL(aService);
00331 }
00332
00333
00334
00335
00336
00337
00338
00339
00340 void CTextMtmClient::SetSubjectL(const TDesC&
00341 )
00342 {
00343 }
00344
00345 const TPtrC CTextMtmClient::SubjectL() const
00346 {
00347 return TPtrC(KNullDesC);
00348 }