00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #if !defined(__MSVENTRY_H__)
00017 #include <msventry.h>
00018 #endif
00019
00020 #if !defined(__TXTRICH_H__)
00021 #include <txtrich.h>
00022 #endif
00023
00024 #if !defined(_TXTCMDS_H_)
00025 #include "TXTCMDS.H"
00026 #endif
00027 #if !defined(__TXUT_H__)
00028 #include "TXUT.H"
00029 #endif
00030
00031 #include "TXTSERV.H"
00032 #include "TXTSCPMV.H"
00033 #include "TXTMBOX.H"
00034
00035
00036
00037
00038
00039 EXPORT_C CTextServerMtm* CTextServerMtm::NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvServerEntry* aInitialEntry)
00040
00041 {
00042 CleanupStack::PushL(aInitialEntry);
00043 CTextServerMtm* self=new (ELeave) CTextServerMtm(aRegisteredMtmDll, aInitialEntry);
00044 CleanupStack::Pop();
00045
00046 CleanupStack::PushL(self);
00047 self->ConstructL();
00048 CleanupStack::Pop();
00049 return self;
00050 }
00051
00052 CTextServerMtm::CTextServerMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvServerEntry* aInitialEntry)
00053 : CBaseServerMtm(aRegisteredMtmDll, aInitialEntry),
00054 iCurrentOperation(ETxtOpIdle),
00055 iServiceEntryId(aInitialEntry->Entry().Id())
00056 {
00057 }
00058
00059 void CTextServerMtm::ConstructL()
00060 {
00061 iReportStatus=NULL;
00062 CActiveScheduler::Add(this);
00063 User::LeaveIfError(iFs.Connect());
00064 }
00065
00066 CTextServerMtm::~CTextServerMtm()
00067 {
00068 Cancel();
00069 delete iTxtCopyMove;
00070 delete iTxtSettings;
00071 }
00072
00073
00074
00075
00076
00077 void CTextServerMtm::CopyToLocalL(const CMsvEntrySelection& aSelection, TMsvId aDestination,
00078 TRequestStatus& aStatus)
00079
00080 {
00081 ConnectToServiceL();
00082 CTxtActiveOper* activeOperation = new (ELeave) CTxtCopyToLocalOp(iFs,*iServerEntry);
00083 DoOperationL(activeOperation, aSelection,aDestination, aStatus);
00084 }
00085
00086 void CTextServerMtm::CopyFromLocalL(const CMsvEntrySelection& aSelection, TMsvId aDestination,
00087 TRequestStatus& aStatus)
00088
00089 {
00090 ConnectToServiceL();
00091 CTxtActiveOper* activeOperation = new (ELeave) CTxtCopyFromLocalOp(iFs,*iServerEntry);
00092 DoOperationL(activeOperation, aSelection,aDestination, aStatus);
00093 }
00094
00095 void CTextServerMtm::CopyWithinServiceL(const CMsvEntrySelection& aSelection, TMsvId aDestination,
00096 TRequestStatus& aStatus)
00097
00098 {
00099 ConnectToServiceL();
00100 CTxtActiveOper* activeOperation = new (ELeave) CTxtCopyWithinServiceOp(iFs,*iServerEntry);
00101 DoOperationL(activeOperation, aSelection,aDestination, aStatus);
00102 }
00103
00104 void CTextServerMtm::MoveToLocalL(const CMsvEntrySelection& aSelection, TMsvId aDestination,
00105 TRequestStatus& aStatus)
00106
00107 {
00108 ConnectToServiceL();
00109 CTxtActiveOper* activeOperation = new (ELeave) CTxtMoveToLocalOp(iFs, *iServerEntry);
00110 DoOperationL(activeOperation, aSelection,aDestination, aStatus);
00111 }
00112
00113 void CTextServerMtm::MoveFromLocalL(const CMsvEntrySelection& aSelection, TMsvId aDestination,
00114 TRequestStatus& aStatus)
00115
00116 {
00117 ConnectToServiceL();
00118 CTxtActiveOper* activeOperation = new (ELeave) CTxtMoveFromLocalOp(iFs, *iServerEntry);
00119 DoOperationL(activeOperation, aSelection,aDestination, aStatus);
00120 }
00121
00122 void CTextServerMtm::MoveWithinServiceL(const CMsvEntrySelection& aSelection, TMsvId aDestination,
00123 TRequestStatus& aStatus)
00124
00125 {
00126 ConnectToServiceL();
00127 CTxtActiveOper* activeOperation = new (ELeave) CTxtMoveWithinServiceOp(iFs,*iServerEntry);
00128 DoOperationL(activeOperation, aSelection,aDestination, aStatus);
00129 }
00130
00131
00132
00133
00134
00135 void CTextServerMtm::DeleteAllL(const CMsvEntrySelection& aSelection, TRequestStatus& aStatus)
00136
00137 {
00138 ConnectToServiceL();
00139 CTxtActiveOper* activeOperation = new (ELeave) CTxtDeleteOp(iFs, *iServerEntry);
00140 DoOperationL(activeOperation, aSelection,KMsvNullIndexEntryId, aStatus);
00141 }
00142
00143 void CTextServerMtm::CreateL(TMsvEntry , TRequestStatus& aStatus)
00144
00145
00146 {
00147 TRequestStatus *sP = &aStatus;
00148 User::RequestComplete(sP, KErrNotSupported);
00149 }
00150
00151 void CTextServerMtm::ChangeL(TMsvEntry , TRequestStatus& aStatus)
00152
00153
00154
00155
00156
00157
00158 {
00159 TRequestStatus *sP = &aStatus;
00160 User::RequestComplete(sP, KErrNotSupported);
00161 }
00162
00163 void CTextServerMtm::ConnectToServiceL()
00164
00165 {
00166 iServerEntry->SetEntry(iServiceEntryId);
00167 __ASSERT_DEBUG(iServerEntry->Entry().iType == KUidMsvServiceEntry, gPanic(ETxtsInvalidService));
00168
00169 if (iTxtSettings == NULL) iTxtSettings = new (ELeave) TMTMTxtSettings;
00170 CMTMTxtSettings* settings = CMTMTxtSettings::NewL();
00171 CleanupStack::PushL(settings);
00172 settings->LoadSettingsL(iServerEntry->Entry().Id(), *iTxtSettings);
00173 CleanupStack::PopAndDestroy();
00174 }
00175
00176 void CTextServerMtm::DoOperationL(CTxtActiveOper* aActiveOperation, const CMsvEntrySelection& aSelection,
00177 TMsvId aDestination, TRequestStatus& aStatus)
00178
00179 {
00180 CleanupStack::PushL(aActiveOperation);
00181
00182 __ASSERT_DEBUG(aActiveOperation,gPanic(ETxtsInvalidNullOperation));
00183 AssertIdle();
00184 AssertConnected();
00185
00186 iReportStatus=&aStatus;
00187 iCurrentOperation=ETxtOpCopyMoveDel;
00188
00189 if (aDestination != KMsvNullIndexEntryId)
00190 {
00191
00192 iServerEntry->SetEntry(aDestination);
00193 TUid type = iServerEntry->Entry().iType;
00194 if (type == KUidMsvServiceEntry)
00195 {
00196 iParse.Set(KNullDesC,NULL,NULL);
00197 }
00198 else if (type == KUidMsvFolderEntry)
00199 {
00200 iParse.Set(iServerEntry->Entry().iDetails,NULL,NULL);
00201 iParse.AddDir(iServerEntry->Entry().iDescription);
00202 }
00203 else
00204 {
00205 gPanic(ETxtsInvalidDestination);
00206 }
00207 }
00208
00209 CleanupStack::Pop();
00210 iTxtCopyMove=CTxtCopyMoveBase::NewL(aActiveOperation,aSelection, *iServerEntry, iServiceEntryId, iParse);
00211 aStatus=iStatus = KRequestPending;
00212 iTxtCopyMove->Start(iStatus);
00213 SetActive();
00214 }
00215
00216
00217
00218
00219
00220 void CTextServerMtm::StartCommandL(CMsvEntrySelection& , TInt aCommand,
00221 const TDesC8& , TRequestStatus& aStatus)
00222
00223
00224 {
00225 AssertIdle();
00226
00227 switch (aCommand)
00228 {
00229 case KTXTMTMRefresh:
00230 {
00231 ConnectToServiceL();
00232 DoRefreshL();
00233 TRequestStatus* sP=&aStatus;
00234 User::RequestComplete(sP,KErrNone);
00235 }
00236 break;
00237 default:
00238 TRequestStatus* sP=&aStatus;
00239 User::RequestComplete(sP, KErrNotSupported);
00240 break;
00241 }
00242 }
00243
00244 TBool CTextServerMtm::CommandExpected()
00245
00246
00247 {
00248 return EFalse;
00249 }
00250
00251 const TDesC8& CTextServerMtm::Progress()
00252
00253 {
00254 switch (iCurrentOperation)
00255 {
00256 case ETxtOpCopyMoveDel:
00257 iProgressBuf() = iTxtCopyMove->Progress();
00258 break;
00259 default:
00260 break;
00261 }
00262 return iProgressBuf;
00263 }
00264
00265
00266
00267
00268
00269 void CTextServerMtm::DoCancel()
00270
00271 {
00272
00273
00274 switch (iCurrentOperation)
00275 {
00276 case ETxtOpCopyMoveDel:
00277 {
00278 delete iTxtCopyMove;
00279 iTxtCopyMove=NULL;
00280 }
00281 break;
00282 default:
00283 AssertIdle();
00284 break;
00285 }
00286 iCurrentOperation=ETxtOpIdle;
00287 TRequestStatus* pS=&iStatus;
00288 User::RequestComplete(pS, KErrCancel);
00289 }
00290
00291 void CTextServerMtm::DoComplete(TInt aError)
00292
00293
00294
00295
00296 {
00297 User::RequestComplete(iReportStatus,aError);
00298 iReportStatus=NULL;
00299 }
00300
00301 void CTextServerMtm::DoRunL()
00302
00303
00304
00305
00306 {
00307 __ASSERT_DEBUG(iReportStatus != NULL,gPanic(ETxtsStrayRequest));
00308
00309
00310
00311
00312
00313 if (iStatus!=KErrNone)
00314 iProgressBuf().iErrorCode=iStatus.Int();
00315
00316
00317 switch (iCurrentOperation)
00318 {
00319 case ETxtOpCopyMoveDel:
00320 {
00321 iProgressBuf() = iTxtCopyMove->Progress();
00322 delete iTxtCopyMove;
00323 iTxtCopyMove=NULL;
00324 }
00325 break;
00326 default:
00327 break;
00328 }
00329 iCurrentOperation=ETxtOpIdle;
00330
00331 User::RequestComplete(iReportStatus,KErrNone);
00332 iReportStatus=NULL;
00333 }
00334
00335
00336
00337
00338
00339
00340 void CTextServerMtm::DoRefreshL()
00341
00342 {
00343 AssertConnected();
00344 TFileName relativePath(KNullDesC);
00345
00346 CTxtRefreshMBox *folderSynchroniser = CTxtRefreshMBox::NewL(iFs, relativePath,
00347 iServiceEntryId, iServerEntry, iServiceEntryId, *iTxtSettings);
00348 CleanupStack::PushL(folderSynchroniser);
00349 while (!folderSynchroniser->DoStepL()) ;
00350 CleanupStack::PopAndDestroy();
00351 }
00352