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