ncdengine/provider/protocol/inc/ncdsessionhandler.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 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:   MNcdSessionHandler interface
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_NCDSESSIONHANDLER_H
       
    20 #define C_NCDSESSIONHANDLER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 /**
       
    25  * Session handler interface
       
    26  */
       
    27 class MNcdSessionHandler
       
    28     {
       
    29 public:
       
    30     /**
       
    31      * Creates a session for the given server and namespace. If there is an
       
    32      * existing session for the server and namespace, it is overwritten.
       
    33      * 
       
    34      * @param aServerURI Server URI. Case insensitive!
       
    35      * @param aNamespace Name space of the session.
       
    36      * @param aSessionId Session id from server.
       
    37      */
       
    38     virtual void CreateSessionL( const TDesC& aServerUri,
       
    39         const TDesC& aNameSpace,
       
    40         const TDesC& aSessionId ) = 0;
       
    41     
       
    42     /**
       
    43      * Removes a session for a given server.
       
    44      *
       
    45      * @param aServerURI Server URI. Case insensitive!
       
    46      * @param aNamespace Name space of the session.
       
    47      */
       
    48     virtual void RemoveSession( const TDesC& aServerUri,
       
    49         const TDesC& aNameSpace ) = 0;
       
    50     
       
    51     /**
       
    52      * Removes all sessions.
       
    53      */
       
    54     virtual void RemoveAllSessions() = 0;
       
    55     
       
    56     /**
       
    57      * Returns the session ID for the server URI
       
    58      *
       
    59      * @param aServerUri Server URI
       
    60      * @param aNamespace Name space of the session.
       
    61      * @return Session ID
       
    62      */
       
    63     virtual const TDesC& Session( const TDesC& aServerUri,
       
    64         const TDesC& aNameSpace ) = 0;
       
    65     
       
    66     /**
       
    67      * Checks whether a session exists for a given server.
       
    68      *
       
    69      * @param aServerURI Server URI. Case insensitive!
       
    70      * @param aNamespace Name space of the session.
       
    71      * @return TBool ETrue if a session exists, EFalse otherwise.
       
    72      */
       
    73     virtual TBool DoesSessionExist( const TDesC& aServerUri,
       
    74         const TDesC& aNameSpace ) = 0;
       
    75     
       
    76 protected:
       
    77 
       
    78     virtual ~MNcdSessionHandler()
       
    79         {
       
    80         }
       
    81     };
       
    82 
       
    83 
       
    84 class CNcdKeyValuePair;
       
    85 
       
    86 /**
       
    87  * Server session handling interface.
       
    88  * This is used by the protocol parser.
       
    89  */
       
    90 class CNcdSessionHandler : public CBase,
       
    91     public MNcdSessionHandler
       
    92     {
       
    93 public:
       
    94 
       
    95     /**
       
    96      * Creates a new session handler
       
    97      * 
       
    98      * @return A new session handler
       
    99      */
       
   100     static CNcdSessionHandler* NewL();
       
   101 
       
   102 
       
   103     /**
       
   104      * Destructor
       
   105      */
       
   106     ~CNcdSessionHandler();
       
   107     
       
   108 public:
       
   109 
       
   110     /**
       
   111      * @see MNcdSessionHandler::CreateSessions()
       
   112      */
       
   113     void CreateSessionL( const TDesC& aServerUri, const TDesC& aNameSpace,
       
   114          const TDesC& aSessionId );
       
   115     
       
   116     /**
       
   117      * @see MNcdSessionHandler::RemoveSession()
       
   118      */
       
   119     void RemoveSession( const TDesC& aServerUri,
       
   120         const TDesC& aNameSpace  );
       
   121     
       
   122     /**
       
   123      * @see MNcdSessionHandler::RemoveAllSessions()
       
   124      */
       
   125     virtual void RemoveAllSessions();
       
   126     
       
   127     /**
       
   128      * @see MNcdSessionHandler::Session()
       
   129      */
       
   130     const TDesC& Session( const TDesC& aServerUri,
       
   131         const TDesC& aNameSpace );
       
   132     
       
   133     /**
       
   134      * @see MNcdSessionHandler::DoesSessionExist()
       
   135      */
       
   136     TBool DoesSessionExist( const TDesC& aServerUri,
       
   137         const TDesC& aNameSpace );
       
   138 
       
   139 private:
       
   140 
       
   141     // Search for the session
       
   142     TInt FindSession( const TDesC& aServerUri,
       
   143         const TDesC& aNameSpace );
       
   144         
       
   145 private:
       
   146     class CNcdServerSession : public CBase
       
   147         {
       
   148         
       
   149     public: // Constructor & destructor
       
   150         
       
   151         /**
       
   152          * Creates a new server session
       
   153          * 
       
   154          * @param aServerURI Server URI. Case insensitive!
       
   155          * @param aNamespace Name space of the session.
       
   156          * @param aSessionId Session id from server.
       
   157          * @return A new server session object.
       
   158          */
       
   159         static CNcdServerSession* NewL( const TDesC& aServerUri,
       
   160             const TDesC& aNameSpace,
       
   161             const TDesC& aSessionId );
       
   162         
       
   163         /**
       
   164          * Creates a new server session and leaves it on the cleanup stack.
       
   165          * 
       
   166          * @param aServerURI Server URI. Case insensitive!
       
   167          * @param aNamespace Name space of the session.
       
   168          * @param aSessionId Session id from server.
       
   169          * @return A new server session object.
       
   170          */
       
   171         static CNcdServerSession* NewLC( const TDesC& aServerUri,
       
   172             const TDesC& aNameSpace,
       
   173             const TDesC& aSessionId );
       
   174 
       
   175         /**
       
   176          * Destructor
       
   177          */
       
   178         ~CNcdServerSession();
       
   179         
       
   180     public: // New functions
       
   181     
       
   182         const TDesC& ServerUri();
       
   183         const TDesC& NameSpace();
       
   184         const TDesC& SessionId();
       
   185         
       
   186     private: // Constructors
       
   187     
       
   188         CNcdServerSession();
       
   189         
       
   190         void ConstructL( const TDesC& aServerUri,
       
   191             const TDesC& aNameSpace,
       
   192             const TDesC& aSessionId );
       
   193         
       
   194     private: // Member data
       
   195     
       
   196         HBufC* iServerUri;
       
   197         HBufC* iNameSpace;
       
   198         HBufC* iSessionId;
       
   199         
       
   200         };
       
   201     
       
   202 private:
       
   203     
       
   204     // Session array
       
   205     RPointerArray<CNcdServerSession> iSessions;
       
   206     };
       
   207 
       
   208 #endif // C_NCDSESSIONHANDLER_H