messagingappbase/msgavkon/muiu_internal/servicesinternal/inc/MuiuLock.h
changeset 0 72b543305e3a
child 5 4697dfb2d7ad
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2007 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:   The global lock class for messaging components
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef MUIULOCK_H
       
    21 #define MUIULOCK_H
       
    22 
       
    23 class CRepository;
       
    24 
       
    25 #include "MessagingInternalCRKeys.h"
       
    26 
       
    27 
       
    28 // Lock identifier for messaging settings access
       
    29 //
       
    30 const TUid KMuiuLockSettings = { KCRUidMuiuVariationValue };
       
    31 
       
    32 /**
       
    33  *  The global lock class for messaging components
       
    34  *
       
    35  *  The service can be used for creating runtime "locks" for protecting
       
    36  *  the shared resources over the process boundaries; i.e.the locks can be 
       
    37  *  used for synchronisation between the processes.
       
    38  *
       
    39  *  The current implementation is based on the transaction mechanism of
       
    40  *  Central Repository. The lock ID is the identifier of the repository
       
    41  *  file. The "lock" is created by opening a write transaction to the
       
    42  *  repository. Thus, the repository cannot be modified while the lock is on.
       
    43  *
       
    44  *  @lib muiu_internal.lib
       
    45  *  @since S60 5.0
       
    46  */
       
    47 NONSHARABLE_CLASS( CMuiuLock ) : public CBase
       
    48     {
       
    49 public:
       
    50     /**
       
    51      * Creates a new instance of the class
       
    52      *
       
    53      * @since S60 5.0
       
    54      * @param aLockId    The lock identifier. Currently, this has to be the ID
       
    55      *                   of the existing central repository file that can be reserved
       
    56      *                   for a write transaction while the lock is used.
       
    57      * @return           New instance of the class
       
    58      */
       
    59      IMPORT_C static CMuiuLock* NewL( TUid aLockId );
       
    60 
       
    61     /**
       
    62      * Destructor. Releases the lock if not done explicitly.
       
    63      */
       
    64     virtual ~CMuiuLock();
       
    65 
       
    66     /**
       
    67      * Reserves the lock for the client.
       
    68      *
       
    69      * @since S60 5.0
       
    70      * @return           Operation status. KErrNone if successful. KErrGeneral, if the lock
       
    71      *                   is already reserved by the client. The error codes of the underlying
       
    72      *                   services forwarded as such.
       
    73      */
       
    74     IMPORT_C TInt Reserve();
       
    75 
       
    76     /**
       
    77      * Releases the lock
       
    78      *
       
    79      * @since S60 5.0
       
    80      */
       
    81     IMPORT_C void Release();
       
    82 
       
    83 private:
       
    84     /**
       
    85      * Default constructor
       
    86      *
       
    87      * @since S60 5.0
       
    88      */
       
    89     CMuiuLock();
       
    90     
       
    91     /**
       
    92      *  Second phase constructor
       
    93      *
       
    94      * @since S60 5.0
       
    95      * @param aLockId    See description of NewL() method
       
    96      */
       
    97     void ConstructL( TUid aLockId );
       
    98 private: // data
       
    99     /**
       
   100      * Central repository handle
       
   101      */
       
   102     CRepository* iRepository;
       
   103 
       
   104     /**
       
   105      * State flag indicating whether the lock is reserved or not
       
   106      */
       
   107     TBool iLocked;
       
   108     };
       
   109 
       
   110 #endif // MUIULOCK_H