remotestoragefw/remotefileengine/inc/rsfwlockmanager.h
changeset 13 6b4fc789785b
parent 2 c32dc0be5eb4
equal deleted inserted replaced
2:c32dc0be5eb4 13:6b4fc789785b
     1 /*
       
     2 * Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Lock manager for locked remote files
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_RSFWLOCKMANAGER_H
       
    20 #define C_RSFWLOCKMANAGER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "rsfwrfesession.h"
       
    25 #include "rsfwremoteaccess.h"
       
    26 
       
    27 class CRsfwFileEntry;
       
    28 class CRsfwRfeStateMachine;
       
    29 
       
    30 /** lock timeout in seconds */
       
    31 const TInt KDefaultLockTimeout              = 900;  
       
    32 
       
    33 /** KDefaultLockTimeout is the lock timeout requested from the server
       
    34  Our lock timer is set to value KDefaultLockTimeout / KLockRefreshAdjustment.
       
    35  It must be smaller, as it is started only when we receive the reply
       
    36  from the server, and when it expires we still must have time to sent the
       
    37  refresh request */
       
    38 const TInt KLockRefreshAdjustment           = 3;
       
    39 
       
    40 /** If lock refresh attempt results in an error from the protocol stack
       
    41  we use timeout mechanism to try again, but with a small timeout
       
    42  as we are not even sending packets to the server. */
       
    43 const TInt KMinLockRefreshAttempt           = 5;
       
    44 
       
    45 /**
       
    46  *  Pending lock renewal requests
       
    47  *
       
    48  *  @lib remotefe.exe
       
    49  *  @since Series 60 3.1
       
    50  */
       
    51 class TPendingLockRefreshContext
       
    52     {
       
    53 public: 
       
    54     // Lock refresh request transaction Id
       
    55     TUint                         iId;
       
    56     // Pointer to the file entry waiting for this refresh 
       
    57     CRsfwFileEntry*                   iFileEntry;
       
    58     };
       
    59 
       
    60 class CRsfwLockManager: public CBase, public MRsfwRemoteAccessResponseHandler
       
    61     {
       
    62 public:
       
    63     static CRsfwLockManager* NewL(CRsfwRemoteAccess* aRemoteAccess);
       
    64     static CRsfwLockManager* NewLC(CRsfwRemoteAccess* aRemoteAccess);
       
    65     ~CRsfwLockManager();
       
    66 
       
    67     void HandleRemoteAccessResponse(TUint aId, TInt aStatus);
       
    68     void ObtainLockL(CRsfwFileEntry*
       
    69                      aFileEntry,
       
    70                      TUint aLockFlags,
       
    71                      TDesC8*& aLockToken,
       
    72                      CRsfwRfeStateMachine* aOperation);
       
    73     void ReleaseLockL(CRsfwFileEntry* aFileEntry, CRsfwRfeStateMachine* aOperation);
       
    74     void RefreshLockL(CRsfwFileEntry* aFileEntry);
       
    75     TInt LockedCount();
       
    76     void AddLockedEntryL(CRsfwFileEntry* aEntry);
       
    77     void RemoveLockedEntry(CRsfwFileEntry* aEntry);
       
    78     void PopulateExternalLockTokenCacheL(CRsfwFileEntry* aRoot);
       
    79     
       
    80 private:
       
    81     void ConstructL(CRsfwRemoteAccess*) ;
       
    82 
       
    83 private:
       
    84     CRsfwRemoteAccess* iRemoteAccess;    // remote file transport module
       
    85     RArray<TPendingLockRefreshContext>  iLockRefreshContexts;
       
    86     RPointerArray<CRsfwFileEntry> iLockedEntries;
       
    87     };
       
    88 
       
    89 #endif // LOCKMANAGER_H
       
    90 
       
    91 // End of File