os/kernelhwsrv/userlibandfileserver/fileserver/sfile/sf_ext.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// f32\sfile\sf_ext.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
sl@0
    19
#include "sf_std.h"
sl@0
    20
sl@0
    21
typedef CProxyDriveFactory*(*TExtensionNew)();
sl@0
    22
typedef CExtProxyDriveFactory*(*TProxyDriveNew)();
sl@0
    23
sl@0
    24
sl@0
    25
/**
sl@0
    26
Constructor.
sl@0
    27
sl@0
    28
Initialises drive extension count to zero.
sl@0
    29
*/
sl@0
    30
TDriveExtInfo::TDriveExtInfo(){iCount=0;}
sl@0
    31
sl@0
    32
sl@0
    33
/**
sl@0
    34
Constructor.
sl@0
    35
sl@0
    36
Note that the class is intended only as an abstract base for other classes.
sl@0
    37
sl@0
    38
@panic FSERV 51 if the supplied CMountCB pointer is NULL.
sl@0
    39
*/
sl@0
    40
CProxyDrive::CProxyDrive(CMountCB* aMount)
sl@0
    41
:iMount(aMount)
sl@0
    42
	{
sl@0
    43
//	__ASSERT_DEBUG(iMount!=NULL,Fault(EProxyDriveConstruction));
sl@0
    44
	}
sl@0
    45
sl@0
    46
sl@0
    47
/**
sl@0
    48
Destructor.
sl@0
    49
sl@0
    50
Frees resources before destruction of the object.
sl@0
    51
*/
sl@0
    52
CProxyDrive::~CProxyDrive()
sl@0
    53
	{
sl@0
    54
	
sl@0
    55
	}
sl@0
    56
sl@0
    57
sl@0
    58
/**
sl@0
    59
An interface with which control commands can be passed to 
sl@0
    60
the appropriate driver layer.
sl@0
    61
sl@0
    62
This base implementation performs no operations.
sl@0
    63
sl@0
    64
@param aMessage Message to be sent.
sl@0
    65
@param aCommand Command type.
sl@0
    66
@param aParam1  1st parameter of control message.
sl@0
    67
@param aParam2  2nd parameter of control message.
sl@0
    68
sl@0
    69
@return KErrNone
sl@0
    70
*/
sl@0
    71
EXPORT_C TInt CProxyDrive::ControlIO(const RMessagePtr2& /*aMessage*/,TInt /*aCommand*/,TAny* /*aParam1*/,TAny* /*aParam2*/)
sl@0
    72
//
sl@0
    73
// General purpose function for use by specific file systems and extensions
sl@0
    74
//
sl@0
    75
	{
sl@0
    76
	return(KErrNone);
sl@0
    77
	}
sl@0
    78
sl@0
    79
/**
sl@0
    80
General purpose read function for use by specific file systems and extensions.
sl@0
    81
sl@0
    82
This base implementation performs no operations.
sl@0
    83
sl@0
    84
@param aPos    The address from where the read begins.
sl@0
    85
@param aLength The length of the read.
sl@0
    86
@param aTrg    A descriptor of the memory buffer from which to read.
sl@0
    87
@param aThreadHandle The handle-number representing the drive thread.
sl@0
    88
@param aOffset Offset into aTrg to read the data from.
sl@0
    89
@param aFlags  Flags to be passed into the driver.
sl@0
    90
sl@0
    91
@return KErrNone
sl@0
    92
*/
sl@0
    93
EXPORT_C TInt CProxyDrive::Read(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aTrg*/,TInt /*aThreadHandle*/,TInt /*aOffset*/, TInt /*aFlags*/)
sl@0
    94
	{
sl@0
    95
	return(KErrNone);
sl@0
    96
	}
sl@0
    97
sl@0
    98
/**
sl@0
    99
General purpose write function for use by specific file systems and extensions.
sl@0
   100
sl@0
   101
This base implementation performs no operations.
sl@0
   102
sl@0
   103
@param aPos    The address from where the write begins.
sl@0
   104
@param aLength The length of the write.
sl@0
   105
@param aSrc    A descriptor of the memory buffer from which to write.
sl@0
   106
@param aThreadHandle The handle-number representing the drive thread.
sl@0
   107
@param aOffset Offset into aSrc to write the data to.
sl@0
   108
@param aFlags  Flags to be passed into the driver.
sl@0
   109
sl@0
   110
@return KErrNone
sl@0
   111
*/
sl@0
   112
EXPORT_C TInt CProxyDrive::Write(TInt64 /*aPos*/,TInt /*aLength*/,const TAny* /*aSrc*/,TInt /*aThreadHandle*/,TInt /*aOffset*/, TInt /*aFlags*/)
sl@0
   113
	{
sl@0
   114
	return(KErrNone);
sl@0
   115
	}
sl@0
   116
sl@0
   117
sl@0
   118
/**
sl@0
   119
Issue a notification that a physical delete has occurred. 
sl@0
   120
For example a cluster or partition has been freed.
sl@0
   121
sl@0
   122
This base implementation performs no operations.
sl@0
   123
sl@0
   124
@param aPos    The position of the data which is being deleted.
sl@0
   125
@param aLength The length of the data which is being deleted.
sl@0
   126
sl@0
   127
@return KErrNone
sl@0
   128
*/
sl@0
   129
EXPORT_C TInt CProxyDrive::DeleteNotify(TInt64 /*aPos*/, TInt /*aLength*/)
sl@0
   130
	{
sl@0
   131
	return(KErrNone);
sl@0
   132
	}
sl@0
   133
	
sl@0
   134
/**
sl@0
   135
An interface with which information can be retrieved about disk errors.
sl@0
   136
sl@0
   137
This base implementation performs no operations.
sl@0
   138
sl@0
   139
@param aErrorInfo Reference to a descriptor containing disk error information.
sl@0
   140
sl@0
   141
@return KErrNone
sl@0
   142
*/	
sl@0
   143
EXPORT_C TInt CProxyDrive::GetLastErrorInfo(TDes8& /*aErrorInfo*/)
sl@0
   144
	{
sl@0
   145
	return(KErrNotSupported);
sl@0
   146
	}
sl@0
   147
	
sl@0
   148
EXPORT_C TInt CProxyDrive::GetLocalDrive(TBusLocalDrive*& aLocDrv)
sl@0
   149
	{
sl@0
   150
	return (GetInterface(EGetLocalDrive, (TAny*&)aLocDrv, (TAny*)this));	// this GetInterface does the dirty work for you...
sl@0
   151
	}
sl@0
   152
sl@0
   153
EXPORT_C TInt CProxyDrive::Finalise(TBool aIsFinalised)
sl@0
   154
	{
sl@0
   155
	TAny* dummyInterface;
sl@0
   156
	return (GetInterface(EFinalised, dummyInterface, (TAny*)aIsFinalised));
sl@0
   157
	}
sl@0
   158
sl@0
   159
sl@0
   160
/**
sl@0
   161
Called to get a Proxy drive interface.
sl@0
   162
sl@0
   163
@param aInterfaceId Interface identifier of the interface to be retrieved.
sl@0
   164
@param aInterface Address of variable that retrieves the specified interface.
sl@0
   165
@param aInput Data required for the instantiation of the interface.
sl@0
   166
sl@0
   167
This base implementation performs no operations.
sl@0
   168
sl@0
   169
@return KErrNotSupported
sl@0
   170
*/	
sl@0
   171
EXPORT_C TInt CProxyDrive::GetInterface(TInt /*aInterfaceId*/,TAny*& /*aInterface*/,TAny* /*aInput*/)
sl@0
   172
	{
sl@0
   173
	return(KErrNotSupported);
sl@0
   174
	}	
sl@0
   175
sl@0
   176
sl@0
   177
/**
sl@0
   178
Constructor.
sl@0
   179
*/
sl@0
   180
EXPORT_C CLocDrvMountCB::CLocDrvMountCB() {}
sl@0
   181
sl@0
   182
sl@0
   183
/**
sl@0
   184
Destructor.
sl@0
   185
sl@0
   186
Frees assigned Proxy drive before destruction of the object.
sl@0
   187
*/
sl@0
   188
EXPORT_C CLocDrvMountCB::~CLocDrvMountCB()
sl@0
   189
	{
sl@0
   190
	__PRINT1(_L("CLocDrvMountCB::~CLocDrvMountCB() 0x%x"),this);
sl@0
   191
	if(iProxyDrive && !LocalDrives::IsProxyDrive(Drive().DriveNumber()) && LocalDrives::IsValidDriveMapping(Drive().DriveNumber()))
sl@0
   192
		delete(iProxyDrive);
sl@0
   193
	}
sl@0
   194
sl@0
   195
sl@0
   196
/**
sl@0
   197
Creates and initialises the local drive.
sl@0
   198
sl@0
   199
@param aLocDrv The local drive to be created
sl@0
   200
sl@0
   201
@return System wide error code.
sl@0
   202
*/		
sl@0
   203
EXPORT_C TInt CLocDrvMountCB::CreateLocalDrive(TBusLocalDrive& aLocDrv)
sl@0
   204
	{
sl@0
   205
	__PRINT(_L("CLocDrvMountCB::CreateLocalDrive()"));
sl@0
   206
	if(iProxyDrive!=NULL)
sl@0
   207
		return(KErrNone);
sl@0
   208
	TInt r;
sl@0
   209
	CProxyDrive* pConcrete=CLocalProxyDrive::New(this,aLocDrv);
sl@0
   210
	if(pConcrete==NULL)
sl@0
   211
		{
sl@0
   212
		r=KErrNoMemory;
sl@0
   213
		}
sl@0
   214
	else
sl@0
   215
		{
sl@0
   216
		// if failure then pConcrete will be deleted by CreateProxyDriveL()
sl@0
   217
		TRAP(r,iProxyDrive=CreateProxyDriveL(pConcrete,this));	
sl@0
   218
		}
sl@0
   219
	if(r==KErrNone)
sl@0
   220
		r=InitLocalDrive();
sl@0
   221
	__PRINT1(_L("CreateLocalDrive r=%d"),r);
sl@0
   222
	return(r);
sl@0
   223
	}
sl@0
   224
sl@0
   225
EXPORT_C TInt CLocDrvMountCB::CreateDrive(TInt aDriveNumber)
sl@0
   226
/** Create drive
sl@0
   227
	Ascertain if the drive is mapped to a local drive or a proxy drive, and create the drive
sl@0
   228
	as appropriate
sl@0
   229
	@param aDriveNumer drive number
sl@0
   230
	@return KErrNone on success
sl@0
   231
		     KErrArgument is the drive is not mapped to a proxy or a local drive or if the number
sl@0
   232
		     is invalid
sl@0
   233
*/
sl@0
   234
	{
sl@0
   235
	// dunno why we are using TInts instead of TUints here
sl@0
   236
	__PRINT(_L("CLocDrvMountCB::CreateLocalDrive()"));
sl@0
   237
sl@0
   238
	if (aDriveNumber<0 || aDriveNumber>=KMaxDrives) return KErrArgument;
sl@0
   239
	TInt r = KErrNone;
sl@0
   240
	TInt aDriveLocal = LocalDrives::DriveNumberToLocalDriveNumber(aDriveNumber);
sl@0
   241
	if (aDriveLocal == KDriveInvalid) return KErrArgument;
sl@0
   242
	if (aDriveLocal < KMaxLocalDrives)
sl@0
   243
		{
sl@0
   244
		return CreateLocalDrive(LocalDrives::GetLocalDrive(aDriveNumber));	// drive is really local
sl@0
   245
		}
sl@0
   246
	else
sl@0
   247
		{
sl@0
   248
		CExtProxyDrive* pProxyDrive = LocalDrives::GetProxyDrive(aDriveNumber);
sl@0
   249
		__ASSERT_ALWAYS(pProxyDrive != NULL,User::Panic(_L("CreateDrive - pProxyDrive == NULL"), -999));
sl@0
   250
sl@0
   251
		iProxyDrive = CreateProxyDriveL(pProxyDrive, this);
sl@0
   252
		__ASSERT_ALWAYS(iProxyDrive != NULL,User::Panic(_L("CreateDrive - CreateProxyDrive returned NULL"), -999));
sl@0
   253
sl@0
   254
		r = InitLocalDrive();
sl@0
   255
		}
sl@0
   256
	
sl@0
   257
	return r;
sl@0
   258
	}
sl@0
   259
sl@0
   260
sl@0
   261
/**
sl@0
   262
Initialise the local drive
sl@0
   263
sl@0
   264
@panic FSERV 52 if initialise when no local drive exists.
sl@0
   265
sl@0
   266
@return system wide error code
sl@0
   267
*/
sl@0
   268
EXPORT_C TInt CLocDrvMountCB::InitLocalDrive()
sl@0
   269
	{
sl@0
   270
	__ASSERT_ALWAYS(iProxyDrive!=NULL,Fault(ELocDrvInitLocalDrive));
sl@0
   271
	iProxyDrive->SetMount(this);
sl@0
   272
	return(iProxyDrive->Initialise());
sl@0
   273
	}
sl@0
   274
sl@0
   275
/**
sl@0
   276
Dismount the local drive
sl@0
   277
sl@0
   278
@panic FSERV 53 if dismount when no local drive exists.
sl@0
   279
*/
sl@0
   280
EXPORT_C void CLocDrvMountCB::DismountedLocalDrive()
sl@0
   281
	{
sl@0
   282
	__ASSERT_ALWAYS(iProxyDrive!=NULL,Fault(ELocDrvDismountedLocalDrive));
sl@0
   283
	iProxyDrive->Dismounted();
sl@0
   284
	iProxyDrive->SetMount(NULL);
sl@0
   285
	}
sl@0
   286
sl@0
   287
sl@0
   288
/**
sl@0
   289
static constructor.
sl@0
   290
sl@0
   291
Instatiates a CLocalProxyDrive objects with the given arguments.
sl@0
   292
sl@0
   293
@param aMount The mount control block
sl@0
   294
@param aLocDrv The local drive.
sl@0
   295
sl@0
   296
@return pointer to instantiated CLocalProxyDrive object.
sl@0
   297
*/
sl@0
   298
CLocalProxyDrive* CLocalProxyDrive::New(CMountCB* aMount,TBusLocalDrive& aLocDrv)
sl@0
   299
	{
sl@0
   300
	TRACE2(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveNew, EF32TraceUidProxyDrive, 
sl@0
   301
		aMount, aMount->DriveNumber());
sl@0
   302
sl@0
   303
	CLocalProxyDrive* proxyDrive = new CLocalProxyDrive(aMount,aLocDrv);
sl@0
   304
	
sl@0
   305
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveNewRet, EF32TraceUidProxyDrive, proxyDrive);
sl@0
   306
	return proxyDrive;
sl@0
   307
	}
sl@0
   308
sl@0
   309
/**
sl@0
   310
Constructor.
sl@0
   311
sl@0
   312
@param aMount The mount control block.
sl@0
   313
@param aLocDrv The local drive.
sl@0
   314
*/
sl@0
   315
CLocalProxyDrive::CLocalProxyDrive(CMountCB* aMount,TBusLocalDrive& aLocDrv)
sl@0
   316
:CProxyDrive(aMount),iLocDrv(aLocDrv)
sl@0
   317
	{
sl@0
   318
	__PRINT(_L("CLocalProxyDrive::CLocalProxyDrive()"));
sl@0
   319
	}
sl@0
   320
sl@0
   321
sl@0
   322
/**
sl@0
   323
Initialise the connected drive.
sl@0
   324
sl@0
   325
This implementation performs no operations.
sl@0
   326
sl@0
   327
@return KErrNone.
sl@0
   328
*/
sl@0
   329
TInt CLocalProxyDrive::Initialise()
sl@0
   330
	{
sl@0
   331
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveInitialise, EF32TraceUidProxyDrive, this);
sl@0
   332
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveInitialiseRet, EF32TraceUidProxyDrive, KErrNone);
sl@0
   333
sl@0
   334
	return(KErrNone);
sl@0
   335
	}
sl@0
   336
sl@0
   337
sl@0
   338
/**
sl@0
   339
Ensures any cached data is flushed before unmounting drive.
sl@0
   340
sl@0
   341
This implementation performs no operations.
sl@0
   342
sl@0
   343
@return KErrNone.
sl@0
   344
*/
sl@0
   345
TInt CLocalProxyDrive::Dismounted()
sl@0
   346
	{
sl@0
   347
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveDismounted, EF32TraceUidProxyDrive, this);
sl@0
   348
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveDismountedRet, EF32TraceUidProxyDrive, KErrNone);
sl@0
   349
sl@0
   350
	return(KErrNone);
sl@0
   351
	}
sl@0
   352
sl@0
   353
sl@0
   354
/**
sl@0
   355
Increase the size of the connected drive by the specified length (in bytes).
sl@0
   356
sl@0
   357
@param aLength The length/size (in bytes) by which the drive is to be increased.
sl@0
   358
sl@0
   359
@return system wide error code.
sl@0
   360
*/
sl@0
   361
TInt CLocalProxyDrive::Enlarge(TInt aLength)
sl@0
   362
	{
sl@0
   363
	TRACE2(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveEnlarge, EF32TraceUidProxyDrive, this, aLength);
sl@0
   364
sl@0
   365
	TInt r = iLocDrv.Enlarge(aLength);
sl@0
   366
sl@0
   367
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveEnlargeRet, EF32TraceUidProxyDrive, r);
sl@0
   368
	return r;
sl@0
   369
	}
sl@0
   370
sl@0
   371
sl@0
   372
/**
sl@0
   373
Reduce the size of the connected drive by removing the specified length
sl@0
   374
(in bytes) starting at the specified position.
sl@0
   375
Refer to relevant media driver documentation for implementation/restriction 
sl@0
   376
notes.
sl@0
   377
sl@0
   378
@param aPos    The start position of area to be removed.
sl@0
   379
@param aLength The length of the data which is being removed.
sl@0
   380
sl@0
   381
@return system wide error code.
sl@0
   382
*/
sl@0
   383
TInt CLocalProxyDrive::ReduceSize(TInt aPos, TInt aLength)
sl@0
   384
	{
sl@0
   385
	TRACE3(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveReduceSize, EF32TraceUidProxyDrive, this, aPos, aLength);
sl@0
   386
sl@0
   387
	TInt r = iLocDrv.ReduceSize(aPos,aLength);
sl@0
   388
sl@0
   389
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveReduceSizeRet, EF32TraceUidProxyDrive, r);
sl@0
   390
	return r;
sl@0
   391
	}
sl@0
   392
sl@0
   393
sl@0
   394
/**
sl@0
   395
Read from the connected drive, and pass flags to driver.
sl@0
   396
sl@0
   397
@param aPos    The address from where the read begins.
sl@0
   398
@param aLength The length of the read.
sl@0
   399
@param aTrg    A descriptor of the memory buffer from which to read.
sl@0
   400
@param aThreadHandle The handle-number representing the drive thread.
sl@0
   401
@param aOffset Offset into aTrg to read the data from.
sl@0
   402
@param aFlags  Flags to be passed into the driver.
sl@0
   403
sl@0
   404
@return system wide error code.
sl@0
   405
*/
sl@0
   406
TInt CLocalProxyDrive::Read(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt aThreadHandle,TInt aOffset, TInt aFlags)
sl@0
   407
	{
sl@0
   408
	TRACETHREADIDH(aThreadHandle);
sl@0
   409
	TRACE8(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveRead1, EF32TraceUidProxyDrive, 
sl@0
   410
		this, I64LOW(aPos), I64HIGH(aPos), aLength, aTrg, threadId, aOffset, aFlags);
sl@0
   411
sl@0
   412
	TInt r = iLocDrv.Read(aPos,aLength,aTrg,aThreadHandle,aOffset,aFlags);
sl@0
   413
sl@0
   414
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveRead1Ret, EF32TraceUidProxyDrive, r);
sl@0
   415
	return r;
sl@0
   416
	}
sl@0
   417
sl@0
   418
/**
sl@0
   419
Read from the connected drive.
sl@0
   420
sl@0
   421
@param aPos    The address from where the read begins.
sl@0
   422
@param aLength The length of the read.
sl@0
   423
@param aTrg    A descriptor of the memory buffer from which to read.
sl@0
   424
@param aThreadHandle The handle-number representing the drive thread.
sl@0
   425
@param aOffset Offset into aTrg to read the data from.
sl@0
   426
sl@0
   427
@return system wide error code.
sl@0
   428
*/
sl@0
   429
TInt CLocalProxyDrive::Read(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt aThreadHandle,TInt anOffset)
sl@0
   430
	{
sl@0
   431
	TRACETHREADIDH(aThreadHandle);
sl@0
   432
	TRACE7(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveRead2, EF32TraceUidProxyDrive, 
sl@0
   433
		this, I64LOW(aPos), I64HIGH(aPos), aLength, aTrg, threadId, anOffset);
sl@0
   434
sl@0
   435
	TInt r = iLocDrv.Read(aPos,aLength,aTrg,aThreadHandle,anOffset);
sl@0
   436
sl@0
   437
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveRead2Ret, EF32TraceUidProxyDrive, r);
sl@0
   438
	return r;
sl@0
   439
	}
sl@0
   440
sl@0
   441
/**
sl@0
   442
Read from the connected drive.
sl@0
   443
sl@0
   444
@param aPos    The address from where the read begins.
sl@0
   445
@param aLength The length of the read.
sl@0
   446
@param aTrg    A descriptor of the memory buffer from which to read.
sl@0
   447
sl@0
   448
@return system wide error code.
sl@0
   449
*/
sl@0
   450
TInt CLocalProxyDrive::Read(TInt64 aPos,TInt aLength,TDes8& aTrg)
sl@0
   451
	{
sl@0
   452
	TRACE5(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveRead3, EF32TraceUidProxyDrive, 
sl@0
   453
		this, I64LOW(aPos), I64HIGH(aPos), aLength, &aTrg);
sl@0
   454
sl@0
   455
	TInt r = iLocDrv.Read(aPos,aLength,aTrg);
sl@0
   456
sl@0
   457
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveRead3Ret, EF32TraceUidProxyDrive, r);
sl@0
   458
	return r;
sl@0
   459
	}
sl@0
   460
sl@0
   461
sl@0
   462
/**
sl@0
   463
Write to the connected drive and pass flags to driver.
sl@0
   464
sl@0
   465
@param aPos    The address from where the write begins.
sl@0
   466
@param aLength The length of the write.
sl@0
   467
@param aSrc    A descriptor of the memory buffer from which to write.
sl@0
   468
@param aThreadHandle The handle-number representing the drive thread.
sl@0
   469
@param aOffset Offset into aSrc to write the data to.
sl@0
   470
@param aFlags  Flags to be passed into the driver.
sl@0
   471
sl@0
   472
@return system wide error code.
sl@0
   473
*/
sl@0
   474
TInt CLocalProxyDrive::Write(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt aThreadHandle,TInt aOffset,TInt aFlags)
sl@0
   475
	{
sl@0
   476
	TRACETHREADIDH(aThreadHandle);
sl@0
   477
	TRACE8(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveWrite1, EF32TraceUidProxyDrive, 
sl@0
   478
		this, I64LOW(aPos), I64HIGH(aPos), aLength, aSrc, threadId, aOffset, aFlags);
sl@0
   479
sl@0
   480
	TInt r = iLocDrv.Write(aPos,aLength,aSrc,aThreadHandle,aOffset,aFlags);
sl@0
   481
sl@0
   482
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveWrite1Ret, EF32TraceUidProxyDrive, r);
sl@0
   483
sl@0
   484
	return r;
sl@0
   485
	}
sl@0
   486
sl@0
   487
sl@0
   488
/**
sl@0
   489
Write to the connected drive.
sl@0
   490
sl@0
   491
@param aPos    The address from where the write begins.
sl@0
   492
@param aLength The length of the write.
sl@0
   493
@param aSrc    A descriptor of the memory buffer from which to write.
sl@0
   494
@param aThreadHandle The handle-number representing the drive thread.
sl@0
   495
@param aOffset Offset into aSrc to write the data to.
sl@0
   496
sl@0
   497
@return system wide error code.
sl@0
   498
*/
sl@0
   499
TInt CLocalProxyDrive::Write(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt aThreadHandle,TInt anOffset)
sl@0
   500
	{
sl@0
   501
	TRACETHREADIDH(aThreadHandle);
sl@0
   502
	TRACE7(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveWrite2, EF32TraceUidProxyDrive, 
sl@0
   503
		this, I64LOW(aPos), I64HIGH(aPos), aLength, aSrc, threadId, anOffset);
sl@0
   504
sl@0
   505
	TInt r = iLocDrv.Write(aPos,aLength,aSrc,aThreadHandle,anOffset);
sl@0
   506
sl@0
   507
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveWrite2Ret, EF32TraceUidProxyDrive, r);
sl@0
   508
	return r;
sl@0
   509
	}
sl@0
   510
sl@0
   511
sl@0
   512
/**
sl@0
   513
Write to the connected drive.
sl@0
   514
sl@0
   515
@param aPos    The address from where the write begins.
sl@0
   516
@param aSrc    A descriptor of the memory buffer from which to write.
sl@0
   517
sl@0
   518
@return system wide error code.
sl@0
   519
*/
sl@0
   520
TInt CLocalProxyDrive::Write(TInt64 aPos,const TDesC8& aSrc)
sl@0
   521
	{
sl@0
   522
	TRACE5(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveWrite3, EF32TraceUidProxyDrive, 
sl@0
   523
		this, I64LOW(aPos), I64HIGH(aPos), aSrc.Length(), &aSrc);
sl@0
   524
sl@0
   525
	TInt r = iLocDrv.Write(aPos,aSrc);
sl@0
   526
sl@0
   527
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveWrite3Ret, EF32TraceUidProxyDrive, r);
sl@0
   528
	return r;
sl@0
   529
	}
sl@0
   530
	
sl@0
   531
	
sl@0
   532
/**
sl@0
   533
Get the connected drive's capabilities information.
sl@0
   534
sl@0
   535
@param anInfo A descriptor of the connected drives capabilities.
sl@0
   536
sl@0
   537
@return system wide error code
sl@0
   538
*/
sl@0
   539
TInt CLocalProxyDrive::Caps(TDes8& anInfo)
sl@0
   540
	{
sl@0
   541
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveCaps, EF32TraceUidProxyDrive, this);
sl@0
   542
sl@0
   543
	TInt r = iLocDrv.Caps(anInfo);
sl@0
   544
sl@0
   545
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveCapsRet, EF32TraceUidProxyDrive, r);
sl@0
   546
	return r;
sl@0
   547
	}
sl@0
   548
sl@0
   549
sl@0
   550
/**
sl@0
   551
Format the connected drive.
sl@0
   552
sl@0
   553
@param anInfo Device specific format information.
sl@0
   554
sl@0
   555
@return system wide error code.
sl@0
   556
*/
sl@0
   557
TInt CLocalProxyDrive::Format(TFormatInfo& anInfo)
sl@0
   558
	{
sl@0
   559
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveFormat1, EF32TraceUidProxyDrive, this);
sl@0
   560
sl@0
   561
	TInt r = iLocDrv.Format(anInfo);
sl@0
   562
sl@0
   563
	TRACE4(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveFormat1Ret, EF32TraceUidProxyDrive, 
sl@0
   564
		r, anInfo.iFormatIsCurrent, anInfo.i512ByteSectorsFormatted, anInfo.iMaxBytesPerFormat);
sl@0
   565
	return r;
sl@0
   566
	}
sl@0
   567
sl@0
   568
sl@0
   569
/**
sl@0
   570
Format the connected drive.
sl@0
   571
sl@0
   572
@param aPos    The position of the data which is being formatted.
sl@0
   573
@param aLength The length of the data which is being formatted.
sl@0
   574
sl@0
   575
@return system wide error code.
sl@0
   576
*/
sl@0
   577
TInt CLocalProxyDrive::Format(TInt64 aPos,TInt aLength)
sl@0
   578
	{
sl@0
   579
	TRACE4(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveFormat2, EF32TraceUidProxyDrive, 
sl@0
   580
		this, I64LOW(aPos), I64HIGH(aPos), aLength);
sl@0
   581
sl@0
   582
	TInt r = iLocDrv.Format(aPos,aLength);
sl@0
   583
sl@0
   584
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveFormat2Ret, EF32TraceUidProxyDrive, r);
sl@0
   585
	return r;
sl@0
   586
	}
sl@0
   587
sl@0
   588
sl@0
   589
/**
sl@0
   590
Set the mount information on the local drive.
sl@0
   591
sl@0
   592
@param aMountInfo Information passed down to the media driver. The meaning of this information depends on the media driver.
sl@0
   593
@param aMountInfoThreadHandle  Message thread handle number.
sl@0
   594
sl@0
   595
@return system wide error code.
sl@0
   596
*/
sl@0
   597
TInt CLocalProxyDrive::SetMountInfo(const TDesC8* aMountInfo,TInt aMountInfoThreadHandle)
sl@0
   598
	{
sl@0
   599
	TRACE3(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveSetMountInfo, EF32TraceUidProxyDrive, this, aMountInfo, aMountInfoThreadHandle);
sl@0
   600
sl@0
   601
	TInt r = iLocDrv.SetMountInfo(aMountInfo,aMountInfoThreadHandle);
sl@0
   602
sl@0
   603
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveSetMountInfoRet, EF32TraceUidProxyDrive, r);
sl@0
   604
	return r;
sl@0
   605
	}
sl@0
   606
sl@0
   607
sl@0
   608
/**
sl@0
   609
Forces a remount on the local drive
sl@0
   610
sl@0
   611
@param aFlags Flags to be passed into the driver.
sl@0
   612
sl@0
   613
@return system wide error code.
sl@0
   614
*/
sl@0
   615
TInt CLocalProxyDrive::ForceRemount(TUint aFlags)
sl@0
   616
	{
sl@0
   617
	TRACE2(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveForceRemount, EF32TraceUidProxyDrive, this, aFlags);
sl@0
   618
sl@0
   619
	TInt r = iLocDrv.ForceRemount(aFlags);
sl@0
   620
sl@0
   621
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveForceRemountRet, EF32TraceUidProxyDrive, r);
sl@0
   622
	return r;
sl@0
   623
	}
sl@0
   624
sl@0
   625
/**
sl@0
   626
An interface with which control commands can be passed to 
sl@0
   627
the appropriate driver layer.
sl@0
   628
sl@0
   629
@param aMessage Message to be sent.
sl@0
   630
@param aCommand Command type.
sl@0
   631
@param aParam1  1st parameter of control message.
sl@0
   632
@param aParam2  2nd parameter of control message.
sl@0
   633
sl@0
   634
@return system wide error code.
sl@0
   635
*/
sl@0
   636
TInt CLocalProxyDrive::ControlIO(const RMessagePtr2& /*aMessage*/,TInt aCommand,TAny* aParam1,TAny* aParam2)
sl@0
   637
	{
sl@0
   638
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveControlIO, EF32TraceUidProxyDrive, this);
sl@0
   639
sl@0
   640
	TInt r = iLocDrv.ControlIO(aCommand,aParam1,aParam2);
sl@0
   641
sl@0
   642
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveControlIORet, EF32TraceUidProxyDrive, r);
sl@0
   643
	return r;
sl@0
   644
	}
sl@0
   645
	
sl@0
   646
	
sl@0
   647
/**
sl@0
   648
Unlocks a password-enabled device.
sl@0
   649
sl@0
   650
@param aPassword A descriptor containing the existing password.
sl@0
   651
@param aStorePassword If ETrue, the password is added to the password store.
sl@0
   652
sl@0
   653
@return system wide error code.
sl@0
   654
*/
sl@0
   655
TInt CLocalProxyDrive::Unlock(TMediaPassword &aPassword, TBool aStorePassword)
sl@0
   656
	{
sl@0
   657
	TRACE2(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveUnlock, EF32TraceUidProxyDrive, this, aStorePassword);
sl@0
   658
sl@0
   659
	TInt r = iLocDrv.Unlock(aPassword,aStorePassword);
sl@0
   660
sl@0
   661
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveUnlockRet, EF32TraceUidProxyDrive, r);
sl@0
   662
	return r;
sl@0
   663
	}
sl@0
   664
sl@0
   665
sl@0
   666
/**
sl@0
   667
Locks a password-enabled device with the new password.
sl@0
   668
sl@0
   669
@param aOldPassword A descriptor containing the existing password.
sl@0
   670
@param aNewPassword A descriptor containing the new password.
sl@0
   671
@param aStorePassword If ETrue, the password is added to the password store.
sl@0
   672
sl@0
   673
@return system wide error code.
sl@0
   674
*/
sl@0
   675
TInt CLocalProxyDrive::Lock(TMediaPassword &aOldPassword, TMediaPassword &aNewPassword, TBool aStorePassword)
sl@0
   676
	{
sl@0
   677
	TRACE2(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveLock, EF32TraceUidProxyDrive, this, aStorePassword);
sl@0
   678
sl@0
   679
	TInt r = iLocDrv.SetPassword(aOldPassword,aNewPassword,aStorePassword);
sl@0
   680
sl@0
   681
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveLockRet, EF32TraceUidProxyDrive, r);
sl@0
   682
	return r;
sl@0
   683
	}
sl@0
   684
sl@0
   685
sl@0
   686
/**
sl@0
   687
Clears a password from a device - controller sets password to null.
sl@0
   688
sl@0
   689
@param aPassword A descriptor containing the password.
sl@0
   690
sl@0
   691
@return system wide error code.
sl@0
   692
*/
sl@0
   693
TInt CLocalProxyDrive::Clear(TMediaPassword &aPassword)
sl@0
   694
	{
sl@0
   695
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveClear, EF32TraceUidProxyDrive, this);
sl@0
   696
sl@0
   697
	TInt r = iLocDrv.Clear(aPassword);
sl@0
   698
sl@0
   699
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveClearRet, EF32TraceUidProxyDrive, r);
sl@0
   700
	return r;
sl@0
   701
	}
sl@0
   702
sl@0
   703
/**
sl@0
   704
Forcibly unlock a password-enabled drive.
sl@0
   705
sl@0
   706
@return system wide error code.
sl@0
   707
*/
sl@0
   708
TInt CLocalProxyDrive::ErasePassword()
sl@0
   709
	{
sl@0
   710
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveErasePassword, EF32TraceUidProxyDrive, this);
sl@0
   711
sl@0
   712
	TInt r = iLocDrv.ErasePassword();
sl@0
   713
sl@0
   714
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveErasePasswordRet, EF32TraceUidProxyDrive, r);
sl@0
   715
	return r;
sl@0
   716
	}
sl@0
   717
sl@0
   718
/**
sl@0
   719
Notify the media driver that an area of the partition has been deleted.
sl@0
   720
Used by some media drivers (e.g. NAND flash) for garbage collection.
sl@0
   721
sl@0
   722
@param aPos    The position of the data which is being deleted.
sl@0
   723
@param aLength The length of the data which is being deleted.
sl@0
   724
sl@0
   725
@return System wide error code.
sl@0
   726
*/
sl@0
   727
TInt CLocalProxyDrive::DeleteNotify(TInt64 aPos, TInt aLength)
sl@0
   728
	{
sl@0
   729
	TRACE4(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveDeleteNotify, EF32TraceUidProxyDrive, 
sl@0
   730
		this, I64LOW(aPos), I64HIGH(aPos), aLength);
sl@0
   731
sl@0
   732
	TInt r = iLocDrv.DeleteNotify(aPos, aLength);
sl@0
   733
sl@0
   734
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveDeleteNotifyRet, EF32TraceUidProxyDrive, r);
sl@0
   735
	return r;
sl@0
   736
	}
sl@0
   737
sl@0
   738
sl@0
   739
/**
sl@0
   740
Retrieve disk error information.
sl@0
   741
sl@0
   742
@param aErrorInfo Reference to a descriptor containing disk error information.
sl@0
   743
sl@0
   744
@return System wide error code.
sl@0
   745
*/	
sl@0
   746
TInt CLocalProxyDrive::GetLastErrorInfo(TDes8 &aErrorInfo)
sl@0
   747
	{
sl@0
   748
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveGetLastErrorInfo, EF32TraceUidProxyDrive, this);
sl@0
   749
sl@0
   750
	TInt r = iLocDrv.GetLastErrorInfo(aErrorInfo);
sl@0
   751
sl@0
   752
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveGetLastErrorInfoRet, EF32TraceUidProxyDrive, r);
sl@0
   753
	return r;
sl@0
   754
	}
sl@0
   755
sl@0
   756
sl@0
   757
TInt CLocalProxyDrive::GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput)
sl@0
   758
	{
sl@0
   759
	TRACE3(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveGetInterface, EF32TraceUidProxyDrive, 
sl@0
   760
		this, aInterfaceId, aInput);
sl@0
   761
sl@0
   762
	TInt r;
sl@0
   763
	switch(aInterfaceId)
sl@0
   764
		{
sl@0
   765
		case EGetLocalDrive:
sl@0
   766
			__ASSERT_ALWAYS((CProxyDrive*)aInput==this,Fault(ELocDrvInvalidLocalDrive));
sl@0
   767
			(TBusLocalDrive*&)aInterface=&iLocDrv;
sl@0
   768
			r = KErrNone;
sl@0
   769
			break;
sl@0
   770
sl@0
   771
        case ELocalBufferSupport:
sl@0
   772
            aInterface = NULL;
sl@0
   773
			r = KErrNone;
sl@0
   774
			break;
sl@0
   775
sl@0
   776
		default:
sl@0
   777
			r= CProxyDrive::GetInterface(aInterfaceId,aInterface,aInput);
sl@0
   778
		}
sl@0
   779
sl@0
   780
	TRACERET2(UTF::EBorder, UTraceModuleProxyDrive::ECLocalProxyDriveGetInterfaceRet, EF32TraceUidProxyDrive, r, aInterface);
sl@0
   781
	return r;
sl@0
   782
	}
sl@0
   783
sl@0
   784
sl@0
   785
sl@0
   786
/**
sl@0
   787
Constructor.
sl@0
   788
sl@0
   789
@panic FSERV 54 if the supplied CMountCB pointer is NULL.
sl@0
   790
*/
sl@0
   791
EXPORT_C CBaseExtProxyDrive::CBaseExtProxyDrive(CProxyDrive* aProxyDrive, CMountCB* aMount)
sl@0
   792
:CProxyDrive(aMount),iProxy(aProxyDrive)
sl@0
   793
	{
sl@0
   794
	__ASSERT_DEBUG(iProxy!=NULL,Fault(EBaseExtConstruction));
sl@0
   795
	}	
sl@0
   796
	
sl@0
   797
/**
sl@0
   798
Destructor.
sl@0
   799
sl@0
   800
Frees resources before destruction of the object.
sl@0
   801
*/	
sl@0
   802
EXPORT_C CBaseExtProxyDrive::~CBaseExtProxyDrive()
sl@0
   803
	{
sl@0
   804
	delete(iProxy);
sl@0
   805
	}
sl@0
   806
sl@0
   807
sl@0
   808
/**
sl@0
   809
Initialise the proxy drive.
sl@0
   810
sl@0
   811
This implementation performs no operations.
sl@0
   812
sl@0
   813
@return system wide error code.
sl@0
   814
*/
sl@0
   815
EXPORT_C TInt CBaseExtProxyDrive::Initialise()
sl@0
   816
	{
sl@0
   817
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveInitialise, EF32TraceUidProxyDrive, this);
sl@0
   818
sl@0
   819
	TInt r = iProxy->Initialise();
sl@0
   820
sl@0
   821
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveInitialiseRet, EF32TraceUidProxyDrive, r);
sl@0
   822
	return r;
sl@0
   823
	}
sl@0
   824
sl@0
   825
sl@0
   826
/**
sl@0
   827
Calls Dismounted() on the proxy drive.
sl@0
   828
sl@0
   829
@return KErrNone.
sl@0
   830
*/
sl@0
   831
EXPORT_C TInt CBaseExtProxyDrive::Dismounted()
sl@0
   832
	{
sl@0
   833
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveDismounted, EF32TraceUidProxyDrive, this);
sl@0
   834
sl@0
   835
	TInt r = iProxy->Dismounted();
sl@0
   836
sl@0
   837
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveDismountedRet, EF32TraceUidProxyDrive, r);
sl@0
   838
	return r;
sl@0
   839
	}
sl@0
   840
sl@0
   841
/**
sl@0
   842
Increase the size of the proxy drive by the specified length (in bytes).
sl@0
   843
sl@0
   844
@param aLength The length (in bytes) of which the drive is to be increased by.
sl@0
   845
sl@0
   846
@return system wide error code.
sl@0
   847
*/
sl@0
   848
EXPORT_C TInt CBaseExtProxyDrive::Enlarge(TInt aLength)
sl@0
   849
	{
sl@0
   850
	TRACE2(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveEnlarge, EF32TraceUidProxyDrive, this, aLength);
sl@0
   851
sl@0
   852
	TInt r = iProxy->Enlarge(aLength);
sl@0
   853
sl@0
   854
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveEnlargeRet, EF32TraceUidProxyDrive, r);
sl@0
   855
	return r;
sl@0
   856
	}
sl@0
   857
sl@0
   858
sl@0
   859
/**
sl@0
   860
Reduce the size of the proxy drive by removing the specified length
sl@0
   861
(in bytes) starting at the specified position.
sl@0
   862
Refer to relevant media driver documentation for implementation/restriction 
sl@0
   863
notes.
sl@0
   864
sl@0
   865
@param aPos    The start position of area to be removed.
sl@0
   866
@param aLength The length/size (in bytes) by which the drive is to be reduced.
sl@0
   867
sl@0
   868
@return system wide error code.
sl@0
   869
*/
sl@0
   870
EXPORT_C TInt CBaseExtProxyDrive::ReduceSize(TInt aPos, TInt aLength)
sl@0
   871
	{
sl@0
   872
	TRACE3(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveReduceSize, EF32TraceUidProxyDrive, this, aPos, aLength);
sl@0
   873
sl@0
   874
	TInt r = iProxy->ReduceSize(aPos,aLength);
sl@0
   875
sl@0
   876
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveReduceSizeRet, EF32TraceUidProxyDrive, r);
sl@0
   877
	return r;
sl@0
   878
	}
sl@0
   879
sl@0
   880
sl@0
   881
/**
sl@0
   882
Read from the proxy drive, and pass flags to driver.
sl@0
   883
sl@0
   884
@param aPos    The address from where the read begins.
sl@0
   885
@param aLength The length of the read.
sl@0
   886
@param aTrg    A descriptor of the memory buffer from which to read.
sl@0
   887
@param aThreadHandle The handle-number representing the drive thread.
sl@0
   888
@param aOffset Offset into aTrg to read the data from.
sl@0
   889
@param aFlags  Flags to be passed into the driver.
sl@0
   890
sl@0
   891
@return system wide error code.
sl@0
   892
*/
sl@0
   893
EXPORT_C TInt CBaseExtProxyDrive::Read(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt aThreadHandle,TInt aOffset,TInt aFlags)
sl@0
   894
	{
sl@0
   895
	TRACETHREADIDH(aThreadHandle);
sl@0
   896
	TRACE8(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveRead1, EF32TraceUidProxyDrive, 
sl@0
   897
		this, I64LOW(aPos), I64HIGH(aPos), aLength, aTrg, threadId, aOffset, aFlags);
sl@0
   898
sl@0
   899
	TInt r = iProxy->Read(aPos,aLength,aTrg,aThreadHandle,aOffset,aFlags);
sl@0
   900
sl@0
   901
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveRead1Ret, EF32TraceUidProxyDrive, r);
sl@0
   902
sl@0
   903
	return r;
sl@0
   904
	}
sl@0
   905
sl@0
   906
sl@0
   907
/**
sl@0
   908
Read from the proxy drive.
sl@0
   909
sl@0
   910
@param aPos    The address from where the read begins.
sl@0
   911
@param aLength The length of the read.
sl@0
   912
@param aTrg    A descriptor of the memory buffer from which to read.
sl@0
   913
@param aThreadHandle The handle-number representing the drive thread.
sl@0
   914
@param aOffset Offset into aTrg to read the data from.
sl@0
   915
sl@0
   916
@return system wide error code.
sl@0
   917
*/
sl@0
   918
EXPORT_C TInt CBaseExtProxyDrive::Read(TInt64 aPos,TInt aLength,const TAny* aTrg,TInt aThreadHandle,TInt anOffset)
sl@0
   919
	{
sl@0
   920
	TRACETHREADIDH(aThreadHandle);
sl@0
   921
	TRACE7(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveRead2, EF32TraceUidProxyDrive, 
sl@0
   922
		this, I64LOW(aPos), I64HIGH(aPos), aLength, aTrg, threadId, anOffset);
sl@0
   923
sl@0
   924
	TInt r = iProxy->Read(aPos,aLength,aTrg,aThreadHandle,anOffset);
sl@0
   925
sl@0
   926
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveRead2Ret, EF32TraceUidProxyDrive, r);
sl@0
   927
	return r;
sl@0
   928
	}
sl@0
   929
sl@0
   930
sl@0
   931
/**
sl@0
   932
Read from the proxy drive.
sl@0
   933
sl@0
   934
@param aPos    The address from where the read begins.
sl@0
   935
@param aLength The length of the read.
sl@0
   936
@param aTrg    A descriptor of the memory buffer from which to read.
sl@0
   937
sl@0
   938
@return system wide error code.
sl@0
   939
*/
sl@0
   940
EXPORT_C TInt CBaseExtProxyDrive::Read(TInt64 aPos,TInt aLength,TDes8& aTrg)
sl@0
   941
	{
sl@0
   942
	TRACE5(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveRead3, EF32TraceUidProxyDrive, 
sl@0
   943
		this, I64LOW(aPos), I64HIGH(aPos), aLength, &aTrg);
sl@0
   944
sl@0
   945
	TInt r = iProxy->Read(aPos,aLength,aTrg);
sl@0
   946
sl@0
   947
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveRead3Ret, EF32TraceUidProxyDrive, r);
sl@0
   948
	return r;
sl@0
   949
	}
sl@0
   950
sl@0
   951
sl@0
   952
/**
sl@0
   953
Write to the proxy drive and pass flags to driver.
sl@0
   954
sl@0
   955
@param aPos    The address from where the write begins.
sl@0
   956
@param aLength The length of the write.
sl@0
   957
@param aSrc    A descriptor of the memory buffer from which to write.
sl@0
   958
@param aThreadHandle The handle-number representing the drive thread.
sl@0
   959
@param aOffset Offset into aSrc to write the data to.
sl@0
   960
@param aFlags  Flags to be passed into the driver.
sl@0
   961
sl@0
   962
@return system wide error code.
sl@0
   963
*/
sl@0
   964
EXPORT_C TInt CBaseExtProxyDrive::Write(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt aThreadHandle,TInt aOffset,TInt aFlags)
sl@0
   965
	{
sl@0
   966
	TRACETHREADIDH(aThreadHandle);
sl@0
   967
	TRACE8(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveWrite1, EF32TraceUidProxyDrive, 
sl@0
   968
		this, I64LOW(aPos), I64HIGH(aPos), aLength, aSrc, threadId, aOffset, aFlags);
sl@0
   969
sl@0
   970
	TInt r = iProxy->Write(aPos,aLength,aSrc,aThreadHandle,aOffset,aFlags);
sl@0
   971
sl@0
   972
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveWrite1Ret, EF32TraceUidProxyDrive, r);
sl@0
   973
	return r;
sl@0
   974
	}
sl@0
   975
sl@0
   976
sl@0
   977
/**
sl@0
   978
Write to the proxy drive.
sl@0
   979
sl@0
   980
@param aPos    The address from where the write begins.
sl@0
   981
@param aLength The length of the write.
sl@0
   982
@param aSrc    A descriptor of the memory buffer from which to write.
sl@0
   983
@param aThreadHandle The handle-number representing the drive thread.
sl@0
   984
@param aOffset Offset into aSrc to write the data to.
sl@0
   985
sl@0
   986
@return system wide error code.
sl@0
   987
*/
sl@0
   988
EXPORT_C TInt CBaseExtProxyDrive::Write(TInt64 aPos,TInt aLength,const TAny* aSrc,TInt aThreadHandle,TInt anOffset)
sl@0
   989
	{
sl@0
   990
	TRACETHREADIDH(aThreadHandle);
sl@0
   991
	TRACE7(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveWrite2, EF32TraceUidProxyDrive, 
sl@0
   992
		this, I64LOW(aPos), I64HIGH(aPos), aLength, aSrc, threadId, anOffset);
sl@0
   993
sl@0
   994
	TInt r = iProxy->Write(aPos,aLength,aSrc,aThreadHandle,anOffset);
sl@0
   995
sl@0
   996
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveWrite2Ret, EF32TraceUidProxyDrive, r);
sl@0
   997
	return r;
sl@0
   998
	}
sl@0
   999
sl@0
  1000
sl@0
  1001
/**
sl@0
  1002
Write to the proxy drive.
sl@0
  1003
sl@0
  1004
@param aPos    The address from where the write begins.
sl@0
  1005
@param aSrc    A descriptor of the memory buffer from which to write.
sl@0
  1006
sl@0
  1007
@return system wide error code.
sl@0
  1008
*/
sl@0
  1009
EXPORT_C TInt CBaseExtProxyDrive::Write(TInt64 aPos,const TDesC8& aSrc)
sl@0
  1010
	{
sl@0
  1011
	TRACE5(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveWrite3, EF32TraceUidProxyDrive, 
sl@0
  1012
		this, I64LOW(aPos), I64HIGH(aPos), aSrc.Length(), &aSrc);
sl@0
  1013
sl@0
  1014
	TInt r = iProxy->Write(aPos,aSrc);
sl@0
  1015
sl@0
  1016
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveWrite3Ret, EF32TraceUidProxyDrive, r);
sl@0
  1017
	return r;
sl@0
  1018
	}
sl@0
  1019
sl@0
  1020
sl@0
  1021
/**
sl@0
  1022
Get the proxy drive's capabilities information.
sl@0
  1023
sl@0
  1024
@param anInfo A descriptor of the connected drives capabilities.
sl@0
  1025
sl@0
  1026
@return system wide error code
sl@0
  1027
*/
sl@0
  1028
EXPORT_C TInt CBaseExtProxyDrive::Caps(TDes8& anInfo)
sl@0
  1029
	{
sl@0
  1030
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveCaps, EF32TraceUidProxyDrive, this);
sl@0
  1031
sl@0
  1032
	TInt r = iProxy->Caps(anInfo);
sl@0
  1033
sl@0
  1034
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveCapsRet, EF32TraceUidProxyDrive, r);
sl@0
  1035
	return r;
sl@0
  1036
	}
sl@0
  1037
sl@0
  1038
sl@0
  1039
/**
sl@0
  1040
Format the connected drive.
sl@0
  1041
sl@0
  1042
@param anInfo Device specific format information.
sl@0
  1043
sl@0
  1044
@return system wide error code.
sl@0
  1045
*/
sl@0
  1046
EXPORT_C TInt CBaseExtProxyDrive::Format(TFormatInfo& anInfo)
sl@0
  1047
	{
sl@0
  1048
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveFormat1, EF32TraceUidProxyDrive, this);
sl@0
  1049
sl@0
  1050
	TInt r = iProxy->Format(anInfo);
sl@0
  1051
sl@0
  1052
	TRACE4(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveFormat1Ret, EF32TraceUidProxyDrive, 
sl@0
  1053
		r, anInfo.iFormatIsCurrent, anInfo.i512ByteSectorsFormatted, anInfo.iMaxBytesPerFormat);
sl@0
  1054
	return r;
sl@0
  1055
	}
sl@0
  1056
sl@0
  1057
sl@0
  1058
/**
sl@0
  1059
Format the proxy drive.
sl@0
  1060
sl@0
  1061
@param aPos    The position of the data which is being formatted.
sl@0
  1062
@param aLength The length of the data which is being formatted.
sl@0
  1063
sl@0
  1064
@return system wide error code.
sl@0
  1065
*/
sl@0
  1066
EXPORT_C TInt CBaseExtProxyDrive::Format(TInt64 aPos,TInt aLength)
sl@0
  1067
	{
sl@0
  1068
	TRACE4(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveFormat2, EF32TraceUidProxyDrive, 
sl@0
  1069
		this, I64LOW(aPos), I64HIGH(aPos), aLength);
sl@0
  1070
sl@0
  1071
	TInt r = iProxy->Format(aPos,aLength);
sl@0
  1072
sl@0
  1073
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveFormat2Ret, EF32TraceUidProxyDrive, r);
sl@0
  1074
	return r;
sl@0
  1075
	}
sl@0
  1076
sl@0
  1077
sl@0
  1078
/**
sl@0
  1079
Set the mount information on the proxy drive.
sl@0
  1080
sl@0
  1081
@param aMountInfo Information passed down to the media driver. The meaning of this information depends on the media driver.
sl@0
  1082
@param aMountInfoThreadHandle  Message thread handle number.
sl@0
  1083
sl@0
  1084
@return system wide error code.
sl@0
  1085
*/
sl@0
  1086
EXPORT_C TInt CBaseExtProxyDrive::SetMountInfo(const TDesC8* aMountInfo,TInt aMountInfoThreadHandle)
sl@0
  1087
	{
sl@0
  1088
	TRACE3(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveSetMountInfo, EF32TraceUidProxyDrive, this, aMountInfo, aMountInfoThreadHandle);
sl@0
  1089
sl@0
  1090
	TInt r = iProxy->SetMountInfo(aMountInfo,aMountInfoThreadHandle);
sl@0
  1091
sl@0
  1092
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveSetMountInfoRet, EF32TraceUidProxyDrive, r);
sl@0
  1093
	return r;
sl@0
  1094
	}
sl@0
  1095
sl@0
  1096
sl@0
  1097
/**
sl@0
  1098
Forces a remount on the proxy drive
sl@0
  1099
sl@0
  1100
@param aFlags Flags to be passed into the driver.
sl@0
  1101
sl@0
  1102
@return system wide error code.
sl@0
  1103
*/
sl@0
  1104
EXPORT_C TInt CBaseExtProxyDrive::ForceRemount(TUint aFlags)
sl@0
  1105
	{
sl@0
  1106
	TRACE2(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveForceRemount, EF32TraceUidProxyDrive, this, aFlags);
sl@0
  1107
sl@0
  1108
	TInt r = iProxy->ForceRemount(aFlags);
sl@0
  1109
sl@0
  1110
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveForceRemountRet, EF32TraceUidProxyDrive, r);
sl@0
  1111
	return r;
sl@0
  1112
	}
sl@0
  1113
sl@0
  1114
sl@0
  1115
/**
sl@0
  1116
Unlocks a password-enabled proxy drive.
sl@0
  1117
sl@0
  1118
@param aPassword A descriptor containing the existing password.
sl@0
  1119
@param aStorePassword If ETrue, the password is added to the password store.
sl@0
  1120
sl@0
  1121
@return system wide error code.
sl@0
  1122
*/
sl@0
  1123
EXPORT_C TInt CBaseExtProxyDrive::Unlock(TMediaPassword &aPassword, TBool aStorePassword)
sl@0
  1124
	{
sl@0
  1125
	TRACE2(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveUnlock, EF32TraceUidProxyDrive, this, aStorePassword);
sl@0
  1126
sl@0
  1127
	TInt r = iProxy->Unlock(aPassword,aStorePassword);
sl@0
  1128
sl@0
  1129
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveUnlockRet, EF32TraceUidProxyDrive, r);
sl@0
  1130
	return r;
sl@0
  1131
	}
sl@0
  1132
sl@0
  1133
sl@0
  1134
/**
sl@0
  1135
Locks a password-enabled proxy drive with the new password.
sl@0
  1136
sl@0
  1137
@param aOldPassword A descriptor containing the existing password.
sl@0
  1138
@param aNewPassword A descriptor containing the new password.
sl@0
  1139
@param aStorePassword If ETrue, the password is added to the password store.
sl@0
  1140
sl@0
  1141
@return system wide error code.
sl@0
  1142
*/
sl@0
  1143
EXPORT_C TInt CBaseExtProxyDrive::Lock(TMediaPassword &aOldPassword, TMediaPassword &aNewPassword, TBool aStorePassword)
sl@0
  1144
	{
sl@0
  1145
	TRACE2(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveLock, EF32TraceUidProxyDrive, this, aStorePassword);
sl@0
  1146
sl@0
  1147
	TInt r = iProxy->Lock(aOldPassword,aNewPassword,aStorePassword);
sl@0
  1148
sl@0
  1149
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveLockRet, EF32TraceUidProxyDrive, r);
sl@0
  1150
	return r;
sl@0
  1151
	}
sl@0
  1152
sl@0
  1153
sl@0
  1154
/**
sl@0
  1155
Clears a password from a proxy drive - controller sets password to null.
sl@0
  1156
sl@0
  1157
@param aPassword A descriptor containing the password.
sl@0
  1158
sl@0
  1159
@return system wide error code.
sl@0
  1160
*/
sl@0
  1161
EXPORT_C TInt CBaseExtProxyDrive::Clear(TMediaPassword &aPassword)
sl@0
  1162
	{
sl@0
  1163
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveClear, EF32TraceUidProxyDrive, this);
sl@0
  1164
sl@0
  1165
	TInt r = iProxy->Clear(aPassword);
sl@0
  1166
sl@0
  1167
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveClearRet, EF32TraceUidProxyDrive, r);
sl@0
  1168
	return r;
sl@0
  1169
	}
sl@0
  1170
sl@0
  1171
/**
sl@0
  1172
Forcibly unlock a password-enabled proxy drive.
sl@0
  1173
sl@0
  1174
@return system wide error code.
sl@0
  1175
*/
sl@0
  1176
EXPORT_C TInt CBaseExtProxyDrive::ErasePassword()
sl@0
  1177
	{
sl@0
  1178
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveErasePassword, EF32TraceUidProxyDrive, this);
sl@0
  1179
sl@0
  1180
	TInt r = iProxy->ErasePassword();
sl@0
  1181
sl@0
  1182
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveErasePasswordRet, EF32TraceUidProxyDrive, r);
sl@0
  1183
	return r;
sl@0
  1184
	}
sl@0
  1185
sl@0
  1186
/**
sl@0
  1187
An interface with which control commands can be passed to 
sl@0
  1188
the appropriate driver layer.
sl@0
  1189
sl@0
  1190
@param aMessage Message to be sent.
sl@0
  1191
@param aCommand Command type.
sl@0
  1192
@param aParam1  1st parameter of control message.
sl@0
  1193
@param aParam2  2nd parameter of control message.
sl@0
  1194
sl@0
  1195
@return system wide error code.
sl@0
  1196
*/
sl@0
  1197
EXPORT_C TInt CBaseExtProxyDrive::ControlIO(const RMessagePtr2& aMessage,TInt aCommand,TAny* aParam1,TAny* aParam2)
sl@0
  1198
	{
sl@0
  1199
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveControlIO, EF32TraceUidProxyDrive, this);
sl@0
  1200
sl@0
  1201
	TInt r = iProxy->ControlIO(aMessage,aCommand,aParam1,aParam2);
sl@0
  1202
sl@0
  1203
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveControlIORet, EF32TraceUidProxyDrive, r);
sl@0
  1204
	return r;
sl@0
  1205
	}
sl@0
  1206
sl@0
  1207
sl@0
  1208
/**
sl@0
  1209
Initialise the provided interface extension.
sl@0
  1210
sl@0
  1211
@param aInterfaceId Interface identifier of the interface to be retrieved.
sl@0
  1212
@param aInterface Address of variable that retrieves the specified interface.
sl@0
  1213
@param aInput Data required for the instantiation of the interface.
sl@0
  1214
sl@0
  1215
@return system wide error code.
sl@0
  1216
*/	
sl@0
  1217
EXPORT_C TInt CBaseExtProxyDrive::GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput)
sl@0
  1218
	{
sl@0
  1219
	TRACE3(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveGetInterface, EF32TraceUidProxyDrive, 
sl@0
  1220
		this, aInterfaceId, aInput);
sl@0
  1221
sl@0
  1222
	TInt r;
sl@0
  1223
	if (aInterfaceId==EGetLocalDrive)
sl@0
  1224
		{
sl@0
  1225
		r = iProxy->GetLocalDrive((TBusLocalDrive*&)aInterface);		// iProxy is of type CLocalProxyDrive, so OK to reenter
sl@0
  1226
		}
sl@0
  1227
	else	
sl@0
  1228
		r = CProxyDrive::GetInterface(aInterfaceId,aInterface,aInput);
sl@0
  1229
sl@0
  1230
	TRACERET2(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveGetInterfaceRet, EF32TraceUidProxyDrive, r, aInterface);
sl@0
  1231
	return r;
sl@0
  1232
	}	
sl@0
  1233
sl@0
  1234
sl@0
  1235
/**
sl@0
  1236
Retrieve proxy drive disk error information.
sl@0
  1237
sl@0
  1238
@param aErrorInfo Reference to a descriptor containing disk error information.
sl@0
  1239
sl@0
  1240
@return System wide error code.
sl@0
  1241
*/
sl@0
  1242
EXPORT_C TInt CBaseExtProxyDrive::GetLastErrorInfo(TDes8 &aErrorInfo)
sl@0
  1243
	{
sl@0
  1244
	TRACE1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveGetLastErrorInfo, EF32TraceUidProxyDrive, this);
sl@0
  1245
sl@0
  1246
	TInt r = iProxy->GetLastErrorInfo(aErrorInfo);
sl@0
  1247
sl@0
  1248
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveGetLastErrorInfoRet, EF32TraceUidProxyDrive, r);
sl@0
  1249
	return r;
sl@0
  1250
	}
sl@0
  1251
sl@0
  1252
sl@0
  1253
/**
sl@0
  1254
Issue a notification that a physical delete has occurred. 
sl@0
  1255
For example a cluster or partition has been freed.
sl@0
  1256
sl@0
  1257
@param aPos    The position of the data which is being deleted.
sl@0
  1258
@param aLength The length of the data which is being deleted.
sl@0
  1259
sl@0
  1260
@return System wide error code.
sl@0
  1261
*/
sl@0
  1262
EXPORT_C TInt CBaseExtProxyDrive::DeleteNotify(TInt64 aPos, TInt aLength)
sl@0
  1263
    {
sl@0
  1264
	TRACE4(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveDeleteNotify, EF32TraceUidProxyDrive, 
sl@0
  1265
		this, I64LOW(aPos), I64HIGH(aPos), aLength);
sl@0
  1266
sl@0
  1267
    TInt r = iProxy->DeleteNotify(aPos, aLength);
sl@0
  1268
sl@0
  1269
	TRACERET1(UTF::EBorder, UTraceModuleProxyDrive::ECBaseExtProxyDriveDeleteNotifyRet, EF32TraceUidProxyDrive, r);
sl@0
  1270
	return r;
sl@0
  1271
    }
sl@0
  1272
sl@0
  1273
sl@0
  1274
/**
sl@0
  1275
Constructor.
sl@0
  1276
*/
sl@0
  1277
EXPORT_C CProxyDriveFactory::CProxyDriveFactory()
sl@0
  1278
	{}
sl@0
  1279
sl@0
  1280
sl@0
  1281
/**
sl@0
  1282
Remove the Proxy driver factory.
sl@0
  1283
sl@0
  1284
This implementation performs no operations.
sl@0
  1285
sl@0
  1286
@return KErrNone
sl@0
  1287
*/
sl@0
  1288
EXPORT_C TInt CProxyDriveFactory::Remove()
sl@0
  1289
	{
sl@0
  1290
	return(KErrNone);
sl@0
  1291
	}
sl@0
  1292
sl@0
  1293
GLDEF_C CExtProxyDriveFactory* GetProxyDriveFactory(const TDesC& aName)
sl@0
  1294
//
sl@0
  1295
// Lookup an extension by name.
sl@0
  1296
//
sl@0
  1297
	{
sl@0
  1298
sl@0
  1299
	TInt h=0;
sl@0
  1300
	TInt r=ProxyDrives->FindByName(h,aName);
sl@0
  1301
	if (r!=KErrNone)
sl@0
  1302
		return(NULL);
sl@0
  1303
	return((CExtProxyDriveFactory*)ProxyDrives->At(h));
sl@0
  1304
	}
sl@0
  1305
sl@0
  1306
sl@0
  1307
// construct a extension proxy drive device
sl@0
  1308
EXPORT_C CExtProxyDriveFactory::CExtProxyDriveFactory()
sl@0
  1309
	{
sl@0
  1310
	}
sl@0
  1311
sl@0
  1312
sl@0
  1313
EXPORT_C TInt CExtProxyDriveFactory::Remove()
sl@0
  1314
	{
sl@0
  1315
	return KErrNone;
sl@0
  1316
	}
sl@0
  1317
sl@0
  1318
sl@0
  1319
EXPORT_C void CExtProxyDriveFactory::AsyncEnumerate()
sl@0
  1320
	{
sl@0
  1321
	}
sl@0
  1322
sl@0
  1323
sl@0
  1324
/**
sl@0
  1325
Create a proxy drive using the local proxy drive passed in
sl@0
  1326
and any extensions that have been added to the drive.
sl@0
  1327
sl@0
  1328
@param aConcreteDrive local proxy drive
sl@0
  1329
@param aMount local proxy drive mount control block
sl@0
  1330
sl@0
  1331
@return pointer to instantiated CProxyDrive object.
sl@0
  1332
*/
sl@0
  1333
EXPORT_C CProxyDrive* CreateProxyDriveL(CProxyDrive* aConcreteDrive,CMountCB* aMount)
sl@0
  1334
	{
sl@0
  1335
	__PRINT(_L("CreateProxyDriveL()"));
sl@0
  1336
	__ASSERT_DEBUG(aMount!=NULL,Fault(ECreateProxyDriveL));
sl@0
  1337
	TDrive& drive=TheDrives[aMount->Drive().DriveNumber()];
sl@0
  1338
	if(drive.ExtInfo().iCount==0)
sl@0
  1339
		return(aConcreteDrive);
sl@0
  1340
sl@0
  1341
	TBool extSupported = drive.FSys().IsExtensionSupported();
sl@0
  1342
	TRACE1(UTF::EBorder, UTraceModuleFileSys::ECFileSystemIsExtensionSupported, EF32TraceUidProxyDrive, extSupported);
sl@0
  1343
	if(!extSupported)
sl@0
  1344
		{
sl@0
  1345
		delete(aConcreteDrive);
sl@0
  1346
		User::Leave(KErrAccessDenied);
sl@0
  1347
		}
sl@0
  1348
	CProxyDrive* pOrig=aConcreteDrive;
sl@0
  1349
	CProxyDrive* pFinal=NULL;
sl@0
  1350
	__ASSERT_DEBUG(drive.ExtInfo().iCount<=KMaxExtensionCount,Fault(EExtensionInfoCount2));
sl@0
  1351
	for(TInt i=0;i<drive.ExtInfo().iCount;++i)
sl@0
  1352
		{
sl@0
  1353
		__PRINT1TEMP(_L("adding extension %S"),drive.ExtInfo().iInfo[i].iFactory->Name());
sl@0
  1354
		__PRINT1(_L("extension is primary = %d"),drive.ExtInfo().iInfo[i].iIsPrimary);
sl@0
  1355
		TRAPD(r,pFinal=drive.ExtInfo().iInfo[i].iFactory->NewProxyDriveL(pOrig,aMount));
sl@0
  1356
		if(r!=KErrNone)
sl@0
  1357
			{
sl@0
  1358
			delete(pOrig);
sl@0
  1359
			User::Leave(r);
sl@0
  1360
			}
sl@0
  1361
		pOrig=pFinal;
sl@0
  1362
		}
sl@0
  1363
	return(pOrig);
sl@0
  1364
	}
sl@0
  1365
sl@0
  1366
/**
sl@0
  1367
Lookup a proxy drive extension by name.
sl@0
  1368
sl@0
  1369
@param aName name of extension to be found
sl@0
  1370
sl@0
  1371
@return system wide error code
sl@0
  1372
*/
sl@0
  1373
CProxyDriveFactory* GetExtension(const TDesC& aName)
sl@0
  1374
	{
sl@0
  1375
sl@0
  1376
	TInt h=0;
sl@0
  1377
	TInt r=Extensions->FindByName(h,aName);
sl@0
  1378
	if (r!=KErrNone)
sl@0
  1379
		return(NULL);
sl@0
  1380
	return((CProxyDriveFactory*)Extensions->At(h));
sl@0
  1381
	}
sl@0
  1382
sl@0
  1383
sl@0
  1384
// construct a extension proxy drive
sl@0
  1385
EXPORT_C CExtProxyDrive::CExtProxyDrive(CMountCB* aMount,CExtProxyDriveFactory* aDevice)
sl@0
  1386
  : CProxyDrive(aMount),
sl@0
  1387
	iFactory(aDevice)
sl@0
  1388
	{
sl@0
  1389
	}
sl@0
  1390
sl@0
  1391
// delete a extension proxy drive
sl@0
  1392
EXPORT_C CExtProxyDrive::~CExtProxyDrive()
sl@0
  1393
	{
sl@0
  1394
	if(iMediaChangeNotifier)
sl@0
  1395
		{
sl@0
  1396
		delete iMediaChangeNotifier;
sl@0
  1397
		}
sl@0
  1398
	}
sl@0
  1399
sl@0
  1400
sl@0
  1401
EXPORT_C TInt CExtProxyDrive::NotifyChange(TDes8 &/*aChanged*/, TRequestStatus* /*aStatus*/)
sl@0
  1402
	{
sl@0
  1403
	return KErrNotSupported;
sl@0
  1404
	}	
sl@0
  1405
sl@0
  1406
EXPORT_C void CExtProxyDrive::NotifyChangeCancel()
sl@0
  1407
	{
sl@0
  1408
	}	
sl@0
  1409
sl@0
  1410
EXPORT_C TInt CExtProxyDrive::SetInfo(const RMessage2& /*aMsg*/, TAny* /*aMessageParam2*/, TAny* /*aMessageParam3*/)
sl@0
  1411
    {
sl@0
  1412
	return KErrNone;
sl@0
  1413
    }
sl@0
  1414
sl@0
  1415
/**
sl@0
  1416
Initialise the provided interface extension.
sl@0
  1417
sl@0
  1418
@param aInterfaceId Interface identifier of the interface to be retrieved.
sl@0
  1419
@param aInterface Address of variable that retrieves the specified interface.
sl@0
  1420
@param aInput Data required for the instantiation of the interface.
sl@0
  1421
sl@0
  1422
@return system wide error code.
sl@0
  1423
*/	
sl@0
  1424
EXPORT_C TInt CExtProxyDrive::GetInterface(TInt aInterfaceId,TAny*& aInterface,TAny* aInput)
sl@0
  1425
	{
sl@0
  1426
	return(CProxyDrive::GetInterface(aInterfaceId,aInterface,aInput));
sl@0
  1427
	}	
sl@0
  1428
sl@0
  1429
TInt CExtProxyDrive::SetupMediaChange()
sl@0
  1430
	{
sl@0
  1431
	if(iMediaChangeNotifier)
sl@0
  1432
		{
sl@0
  1433
		TRAPD(err, iMediaChangeNotifier->RequestL());
sl@0
  1434
		return err;
sl@0
  1435
		}
sl@0
  1436
sl@0
  1437
	TRAPD(err, iMediaChangeNotifier = CExtNotifyMediaChange::NewL(this));	
sl@0
  1438
sl@0
  1439
	return(err == KErrNotSupported ? KErrNone : err);
sl@0
  1440
	}
sl@0
  1441
sl@0
  1442
TInt TFsAddExtension::DoRequestL(CFsRequest* aRequest)
sl@0
  1443
//
sl@0
  1444
// Add an extension
sl@0
  1445
//
sl@0
  1446
	{
sl@0
  1447
	__PRINT(_L("TFsAddExtension::DoRequestL(CFsRequest* aRequest)"));
sl@0
  1448
	
sl@0
  1449
	RLibrary lib;
sl@0
  1450
	// Get library handle
sl@0
  1451
	lib.SetHandle(aRequest->Message().Int0());
sl@0
  1452
	if (lib.Type()[1]!=TUid::Uid(KFileSystemUidValue))
sl@0
  1453
		return KErrNotSupported;
sl@0
  1454
sl@0
  1455
    TExtensionNew e=(TExtensionNew)lib.Lookup(1);
sl@0
  1456
	if (!e)
sl@0
  1457
		return KErrCorrupt;
sl@0
  1458
	CProxyDriveFactory* pP=(*e)();
sl@0
  1459
	if(!pP)
sl@0
  1460
		return KErrNoMemory;
sl@0
  1461
	TInt r=pP->Install();
sl@0
  1462
	__PRINT1TEMP(_L("InstallExtension %S"),pP->Name());
sl@0
  1463
	if (r==KErrNone)
sl@0
  1464
		{
sl@0
  1465
		__PRINT(_L("TRAP(r,Extensions->AddL(pP,ETrue))"));
sl@0
  1466
		TRAP(r,Extensions->AddL(pP,ETrue))
sl@0
  1467
		__PRINT1TEMP(_L("r == %d"), r);
sl@0
  1468
		if(r!=KErrNone)
sl@0
  1469
			pP->Remove();
sl@0
  1470
		}
sl@0
  1471
	__PRINT1TEMP(_L("r == %d"), r);
sl@0
  1472
	if (r==KErrNone)
sl@0
  1473
		pP->SetLibrary(lib);
sl@0
  1474
	else
sl@0
  1475
		pP->Close();
sl@0
  1476
	return(r);
sl@0
  1477
	}
sl@0
  1478
sl@0
  1479
sl@0
  1480
TInt TFsAddExtension::Initialise(CFsRequest* aRequest)
sl@0
  1481
//
sl@0
  1482
//
sl@0
  1483
//
sl@0
  1484
	{
sl@0
  1485
	TSecurityPolicy policy(RProcess().SecureId(), ECapabilityTCB);
sl@0
  1486
	if (!policy.CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Add File System Extension")))
sl@0
  1487
		return KErrPermissionDenied;
sl@0
  1488
	return KErrNone;
sl@0
  1489
	}
sl@0
  1490
sl@0
  1491
TInt TFsAddProxyDrive::DoRequestL(CFsRequest* aRequest)
sl@0
  1492
//
sl@0
  1493
// Load a proxy drive
sl@0
  1494
//
sl@0
  1495
	{
sl@0
  1496
	__PRINT(_L("TFsAddProxyDrive::DoRequestL(CFsRequest* aRequest)"));
sl@0
  1497
	
sl@0
  1498
	RLibrary lib;
sl@0
  1499
	// Get library handle
sl@0
  1500
	lib.SetHandle(aRequest->Message().Int0());
sl@0
  1501
	if (lib.Type()[1]!=TUid::Uid(KFileSystemUidValue))
sl@0
  1502
		return KErrNotSupported;
sl@0
  1503
sl@0
  1504
    TProxyDriveNew e=(TProxyDriveNew)lib.Lookup(1);
sl@0
  1505
	if (!e)
sl@0
  1506
		return KErrCorrupt;
sl@0
  1507
	CExtProxyDriveFactory* pP=(*e)();
sl@0
  1508
	if(!pP)
sl@0
  1509
		return KErrNoMemory;
sl@0
  1510
	TInt r=pP->Install();
sl@0
  1511
	__PRINT1TEMP(_L("Install Proxy Drive %S"),pP->Name());
sl@0
  1512
	if (r==KErrNone)
sl@0
  1513
		{
sl@0
  1514
		__PRINT(_L("TRAP(r,ProxyDrives->AddL(pP,ETrue))"));
sl@0
  1515
		TRAP(r,ProxyDrives->AddL(pP,ETrue))
sl@0
  1516
		__PRINT1TEMP(_L("r == %d"), r);
sl@0
  1517
		if(r!=KErrNone)
sl@0
  1518
			pP->Remove();
sl@0
  1519
		}
sl@0
  1520
	__PRINT1TEMP(_L("r == %d"), r);
sl@0
  1521
	if (r==KErrNone)
sl@0
  1522
		pP->SetLibrary(lib);
sl@0
  1523
	else
sl@0
  1524
		pP->Close();
sl@0
  1525
	return(r);
sl@0
  1526
	}
sl@0
  1527
sl@0
  1528
sl@0
  1529
TInt TFsAddProxyDrive::Initialise(CFsRequest* aRequest)
sl@0
  1530
//
sl@0
  1531
//
sl@0
  1532
//
sl@0
  1533
	{
sl@0
  1534
	TSecurityPolicy policy(RProcess().SecureId(), ECapabilityTCB);
sl@0
  1535
	if (!policy.CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Add File System Proxy Drive")))
sl@0
  1536
		return KErrPermissionDenied;
sl@0
  1537
	return KErrNone;
sl@0
  1538
	}
sl@0
  1539
sl@0
  1540
TInt TFsMountExtension::DoRequestL(CFsRequest* aRequest)
sl@0
  1541
//
sl@0
  1542
// Mount an extension
sl@0
  1543
//
sl@0
  1544
	{
sl@0
  1545
	TFullName name;
sl@0
  1546
	aRequest->ReadL(KMsgPtr0,name);
sl@0
  1547
	CProxyDriveFactory* pE=GetExtension(name);
sl@0
  1548
	if (pE==NULL)
sl@0
  1549
		return(KErrNotFound);
sl@0
  1550
	return(aRequest->Drive()->MountExtension(pE,EFalse));
sl@0
  1551
	}
sl@0
  1552
sl@0
  1553
TInt TFsMountExtension::Initialise(CFsRequest* aRequest)
sl@0
  1554
//
sl@0
  1555
//
sl@0
  1556
//
sl@0
  1557
	{
sl@0
  1558
	TInt r=ValidateDrive(aRequest->Message().Int1(),aRequest);
sl@0
  1559
	if(r!=KErrNone)
sl@0
  1560
		return(r);
sl@0
  1561
	if(aRequest->Drive()->IsSubsted())
sl@0
  1562
		return(KErrNotSupported);
sl@0
  1563
	return(r);
sl@0
  1564
	}
sl@0
  1565
sl@0
  1566
sl@0
  1567
TInt TFsDismountExtension::DoRequestL(CFsRequest* aRequest)
sl@0
  1568
//
sl@0
  1569
// Dismount extension
sl@0
  1570
//
sl@0
  1571
	{
sl@0
  1572
	TFullName name;
sl@0
  1573
	aRequest->ReadL(KMsgPtr0,name);
sl@0
  1574
	CProxyDriveFactory* pE=GetExtension(name);
sl@0
  1575
	if (pE==NULL)
sl@0
  1576
		return(KErrNotFound);
sl@0
  1577
	return(aRequest->Drive()->DismountExtension(pE,EFalse));
sl@0
  1578
	}
sl@0
  1579
sl@0
  1580
sl@0
  1581
TInt TFsDismountExtension::Initialise(CFsRequest* aRequest)
sl@0
  1582
//
sl@0
  1583
//
sl@0
  1584
//
sl@0
  1585
	{
sl@0
  1586
	if (!KCapFsDismountExtension.CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Dismount File Extension")))
sl@0
  1587
		return KErrPermissionDenied;
sl@0
  1588
	TInt r=ValidateDrive(aRequest->Message().Int1(),aRequest);
sl@0
  1589
	if(r!=KErrNone)
sl@0
  1590
		return(r);
sl@0
  1591
	if(aRequest->Drive()->IsSubsted())
sl@0
  1592
		return(KErrNotSupported);
sl@0
  1593
	return(r);
sl@0
  1594
	}
sl@0
  1595
sl@0
  1596
TInt TFsRemoveExtension::DoRequestL(CFsRequest* aRequest)
sl@0
  1597
//
sl@0
  1598
// Remove an extension
sl@0
  1599
//
sl@0
  1600
	{
sl@0
  1601
	TFullName name;
sl@0
  1602
	aRequest->ReadL(KMsgPtr0,name);
sl@0
  1603
	CProxyDriveFactory* pE=GetExtension(name);
sl@0
  1604
	if (pE==NULL)
sl@0
  1605
		return(KErrNotFound);
sl@0
  1606
	TInt r=pE->Remove();
sl@0
  1607
	if (r!=KErrNone)
sl@0
  1608
		return(r);
sl@0
  1609
	RLibrary lib=pE->Library();
sl@0
  1610
	pE->Close();
sl@0
  1611
	lib.Close();
sl@0
  1612
	return(KErrNone);
sl@0
  1613
	}
sl@0
  1614
sl@0
  1615
sl@0
  1616
TInt TFsRemoveExtension::Initialise(CFsRequest* aRequest)
sl@0
  1617
//
sl@0
  1618
//
sl@0
  1619
//
sl@0
  1620
	{
sl@0
  1621
	if (!KCapFsRemoveExtension.CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Remove File Extension")))
sl@0
  1622
		return KErrPermissionDenied;
sl@0
  1623
	return KErrNone;
sl@0
  1624
	}
sl@0
  1625
sl@0
  1626
TInt TFsRemoveProxyDrive::DoRequestL(CFsRequest* aRequest)
sl@0
  1627
//
sl@0
  1628
// Remove a proxy drive
sl@0
  1629
//
sl@0
  1630
	{
sl@0
  1631
	TFullName name;
sl@0
  1632
	aRequest->ReadL(KMsgPtr0,name);
sl@0
  1633
sl@0
  1634
	CExtProxyDriveFactory* pD=GetProxyDriveFactory(name);
sl@0
  1635
	// are there any mounted drives using this extension?
sl@0
  1636
	if (LocalDrives::IsProxyDriveInUse(pD)) return KErrInUse;
sl@0
  1637
	if (pD==NULL)
sl@0
  1638
		return(KErrNotFound);
sl@0
  1639
	TInt r=pD->Remove();
sl@0
  1640
	if (r!=KErrNone)
sl@0
  1641
		return(r);
sl@0
  1642
	RLibrary lib=pD->Library();
sl@0
  1643
	pD->Close();
sl@0
  1644
	lib.Close();
sl@0
  1645
sl@0
  1646
	return(KErrNone);
sl@0
  1647
	}
sl@0
  1648
sl@0
  1649
sl@0
  1650
TInt TFsRemoveProxyDrive::Initialise(CFsRequest* aRequest)
sl@0
  1651
//
sl@0
  1652
//
sl@0
  1653
//
sl@0
  1654
	{
sl@0
  1655
	if (!KCapFsRemoveProxyDrive.CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Remove Proxy Drive")))
sl@0
  1656
		return KErrPermissionDenied;
sl@0
  1657
	return KErrNone;
sl@0
  1658
	}
sl@0
  1659
sl@0
  1660
TInt TFsExtensionName::DoRequestL(CFsRequest* aRequest)
sl@0
  1661
//
sl@0
  1662
// Return the name of an extension for a given drive and extension chain position
sl@0
  1663
//
sl@0
  1664
	{
sl@0
  1665
	TFullName name;
sl@0
  1666
	TInt r=aRequest->Drive()->ExtensionName(name,aRequest->Message().Int2());
sl@0
  1667
	if(r==KErrNone)
sl@0
  1668
		aRequest->WriteL(KMsgPtr0,name);
sl@0
  1669
	return(r);
sl@0
  1670
	}
sl@0
  1671
sl@0
  1672
TInt TFsExtensionName::Initialise(CFsRequest* aRequest)
sl@0
  1673
//
sl@0
  1674
//
sl@0
  1675
//
sl@0
  1676
	{
sl@0
  1677
	TInt r=ValidateDrive(aRequest->Message().Int1(),aRequest);
sl@0
  1678
	if(r!=KErrNone)
sl@0
  1679
		return(r);
sl@0
  1680
	if(aRequest->Drive()->IsSubsted())
sl@0
  1681
		return(KErrNotSupported);
sl@0
  1682
	return(r);
sl@0
  1683
	}
sl@0
  1684
sl@0
  1685
TInt TFsDismountProxyDrive::DoRequestL(CFsRequest* aRequest)
sl@0
  1686
//
sl@0
  1687
// Dismount a proxy extension
sl@0
  1688
//
sl@0
  1689
	{
sl@0
  1690
sl@0
  1691
	__PRINT(_L("TFsDismountProxyDrive::DoRequestL"));
sl@0
  1692
sl@0
  1693
	return aRequest->Drive()->DismountProxyDrive();
sl@0
  1694
	}
sl@0
  1695
sl@0
  1696
sl@0
  1697
TInt TFsDismountProxyDrive::Initialise(CFsRequest* aRequest)
sl@0
  1698
//
sl@0
  1699
//
sl@0
  1700
//
sl@0
  1701
	{
sl@0
  1702
	if (!KCapFsDismountProxyDrive.CheckPolicy(aRequest->Message(), __PLATSEC_DIAGNOSTIC_STRING("Dismount Proxy Drive")))
sl@0
  1703
		return KErrPermissionDenied;
sl@0
  1704
sl@0
  1705
	TInt r=ValidateDrive(aRequest->Message().Int0(),aRequest);
sl@0
  1706
	if(r!=KErrNone)
sl@0
  1707
		return(r);
sl@0
  1708
sl@0
  1709
	return KErrNone;
sl@0
  1710
	}
sl@0
  1711