messagingappbase/mce/inc/MceSessionHolder.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002 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:  
       
    15 *     Keeps track on how many are using the same session to msgs.
       
    16 *     When no one is using the session then the object of this class is deleted.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 #ifndef MCESESSIONHOLDER_H
       
    23 #define MCESESSIONHOLDER_H
       
    24 
       
    25 //  INCLUDES
       
    26 
       
    27 #include <bldvariant.hrh>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CMsvSession;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35 *  Keeps track on how many are using the same session to msgs.
       
    36 *  When no one is using the session then the object of this class is deleted.
       
    37 */
       
    38 class CMceSessionHolder :
       
    39     public CBase
       
    40     {
       
    41     public:  // Constructors and destructor
       
    42         
       
    43         /**
       
    44         * Creates session holder and returns pointer to created object.
       
    45         * @param aSessionObserver: reference to session observer
       
    46         */
       
    47         static CMceSessionHolder* NewL( MMsvSessionObserver& aSessionObserver );
       
    48 
       
    49         /**
       
    50         * Destructor.
       
    51         */
       
    52         virtual ~CMceSessionHolder();
       
    53 
       
    54 
       
    55     public:
       
    56         /**
       
    57         * New object starts usign session so number of session users
       
    58         * is incremented by 1
       
    59         */
       
    60         void AddClient();
       
    61 
       
    62         /**
       
    63         * Number of session users is decremented by 1. If no one is using the 
       
    64         * session after decrement delete session and this object.
       
    65         */
       
    66         void RemoveClient();
       
    67 
       
    68         /**
       
    69         * Returns number of session users.
       
    70         * @return number of session users.
       
    71         */
       
    72         TInt ClientCount() const;
       
    73 
       
    74         /* 
       
    75         * @return pointer to session object
       
    76         */
       
    77         CMsvSession* Session() const;
       
    78 
       
    79         /* 
       
    80         * Sets new session pointer
       
    81         *  @param aSession                 session pointer       
       
    82         */
       
    83         void SetSession( CMsvSession* aSession );
       
    84 
       
    85     private:
       
    86         /**
       
    87         * Constructor.
       
    88         */
       
    89         CMceSessionHolder();
       
    90 
       
    91         /**
       
    92         * Symbian OS Constructor.
       
    93         */
       
    94         void ConstructL( MMsvSessionObserver& aSessionObserver );
       
    95 
       
    96 
       
    97 
       
    98     private:    // Data
       
    99         CMsvSession*    iSession;
       
   100         TInt            iClientCount;
       
   101     };
       
   102 
       
   103 #endif
       
   104 
       
   105 // End of file