videoutils_plat/videoconnutility_api/inc/ipvideo/vcxconnectionutility.h
changeset 35 381bc1d93c7b
parent 31 07dea94512a2
equal deleted inserted replaced
31:07dea94512a2 35:381bc1d93c7b
     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 the License "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:    Class to handle connection creation.*
       
    15 */
       
    16 
       
    17 
       
    18 #ifndef __VCX_CONNUTIL_H_
       
    19 #define __VCX_CONNUTIL_H_
       
    20 
       
    21 // INCLUDES
       
    22 #include <e32base.h>
       
    23 
       
    24 // FORWARD DECLARATIONS
       
    25 class CVcxConnUtilImpl;
       
    26 class MConnUtilEngineObserver;
       
    27 
       
    28 
       
    29 // CLASS DECLARATION
       
    30 /**
       
    31 * Class is the main interface class for the vcxconnectionutility.dll.
       
    32 * By using this class, client can fetch iap ID and maintain an active connection
       
    33 * for that iap.
       
    34 * Usage:
       
    35 *  @code
       
    36 *  #include <vcxconnectionutility.h>
       
    37 *  #include <vcxconnutilengineobserver.h> // for receiving events from ALR and iap changes
       
    38 *
       
    39 *  // Instantiation of connectionutility is done by Instance()
       
    40 *  // every Instance call increments internal reference count by 
       
    41 *  // one. When reference count is decremented to 0 deallocation
       
    42 *  // occurs. Client should make sure that it calls as many
       
    43 *  // DecreaseReferenceCount() as it calls InstanceL()
       
    44 *
       
    45 *  CVcxConnectionUtility* conUtil = CVcxConnectionUtility::InstanceL();
       
    46 * 
       
    47 *  // in case client is interested in events from ALR or from iap changes,
       
    48 *  // client must implement MConnUtilEngineObserver interface and register
       
    49 *  // as observer. See MConnUtilEngineObserver documentation for details 
       
    50 *  conUtil->RegisterObserverL( this );
       
    51 * 
       
    52 *  // getting the best possible iap is handled by the GetIap
       
    53 *  TInt err( KErrNone );
       
    54 *  TUint32 iapId( 0 );
       
    55 *  err = conUtil->GetIap( iapId, EFalse );
       
    56 *  // in case client does not want the "connecting" dialog  // shown, aSilent
       
    57 *  // parameter should be ETrue     
       
    58 *
       
    59 *  // client can try to explicitly disconnect connection, but if there are other references 
       
    60 *  // connection is not closed.
       
    61 *  // suggestion is to maintain connection at all time as long as vcxconnectionutility 
       
    62 *  // is being used and just react to notifications 
       
    63 *  conUtil->Disconnect();
       
    64 *  
       
    65 *  // when connectionutility is no longer needed, client must call DecreaseReferenceCount()
       
    66 *  // if there are no more references left, memory allocated for the library is deallocated
       
    67 *  // and possible active connection is closed
       
    68 *  // if client has registered as observer, it should deregister first 
       
    69 *  conUtil->RemoveObserver();
       
    70 *  conUtil->DecreaseReferenceCount();  
       
    71 *  conutil = NULL;
       
    72 * 
       
    73 *  @endcode
       
    74 * 
       
    75 *
       
    76 * @lib vcxconnectionutility.dll
       
    77 */
       
    78 NONSHARABLE_CLASS( CVcxConnectionUtility) : public CActive
       
    79     {
       
    80 
       
    81     public: // Constructors and destructor
       
    82 
       
    83         /**
       
    84          * returns instance of the singleton object. This increases
       
    85          * local reference count by one, so utility members should
       
    86          * not be called through this.
       
    87          *
       
    88          * @return Pointer to CVcxConnectionUtility object.
       
    89          */
       
    90         IMPORT_C static CVcxConnectionUtility* InstanceL();
       
    91         
       
    92         /**
       
    93         * Remove the reference to this connectionutility instance.
       
    94         * 
       
    95         * This should be called when client does not need 
       
    96         * utility anymore.
       
    97         *
       
    98         * Decreases the reference count by one. When
       
    99         * all references are removed, the ui engine is destructed.
       
   100         */
       
   101         IMPORT_C void DecreaseReferenceCount();
       
   102 
       
   103     private:
       
   104         /**
       
   105          * Destructor.
       
   106          */
       
   107         virtual ~CVcxConnectionUtility();
       
   108         
       
   109         /**
       
   110          * constructor.
       
   111          *
       
   112          */
       
   113         CVcxConnectionUtility( );
       
   114 
       
   115         /**
       
   116          * Private 2nd phase construction.
       
   117          */
       
   118         void ConstructL();
       
   119         
       
   120         /**
       
   121          * From CActive, handles an active object’s request completion event
       
   122          */
       
   123         void RunL();
       
   124 
       
   125         /**
       
   126          * From CActive, implements cancellation of an outstanding request.
       
   127          * This function is called as part of the active object’s Cancel().
       
   128          */
       
   129         void DoCancel();  
       
   130                  
       
   131     public: // New functions
       
   132        
       
   133         
       
   134         /**
       
   135         * Returns open IAP, if connection is not opened it is created
       
   136         *
       
   137         * @param aIapId     On return, IAP ID.
       
   138         * @param aSilent    If ETrue, tries to open connection silently (without dialogs)
       
   139         *                   In the 'Always ask' mode query dialog is always shown.
       
   140         *                    
       
   141         * @return KErrNone or one of the system wide error codes.
       
   142         */
       
   143         IMPORT_C TInt GetIap( TUint32& aIapId, TBool aSilent );
       
   144 
       
   145         /**
       
   146          * Gets WAP id from IAP id. Leaves with KErrNotFound if no record with given 
       
   147          * IAP id is found.
       
   148          * 
       
   149          * @param aIapId IAP id to match.
       
   150          * @return WAP id matching the given IAP id.
       
   151          */
       
   152         IMPORT_C TUint32 WapIdFromIapIdL( TUint32 aIapId );
       
   153 
       
   154         /**
       
   155         * Closes open connection.
       
   156         */
       
   157         IMPORT_C void DisconnectL();
       
   158         
       
   159         /**
       
   160          * Registers observer
       
   161          * 
       
   162          * @param MConnUtilEngineObserver
       
   163          */
       
   164         IMPORT_C void RegisterObserverL( MConnUtilEngineObserver* aObserver );
       
   165         
       
   166         /**
       
   167          * Removes observer from the array of observers
       
   168          * 
       
   169          * @param MConnUtilEngineObserver 
       
   170          */
       
   171         IMPORT_C void RemoveObserver( MConnUtilEngineObserver* aObserver );
       
   172            
       
   173         /**
       
   174          * Displays a wait note. Method calls notifier to show 
       
   175          * dialog and sets this active object active. If user cancels
       
   176          * dialog by pressing cancel, RunL is being called with KErrCancel.
       
   177          *   
       
   178          * @param aConnectionName name of connection to show on the dialog          
       
   179          */ 
       
   180         void DisplayWaitNote( const TDesC& aConnectionName = KNullDesC );
       
   181         
       
   182         /**
       
   183          * closes a wait note
       
   184          *           
       
   185          */
       
   186         void CloseWaitNote();
       
   187 
       
   188                                                                                 
       
   189     private: // Data
       
   190         
       
   191         /**
       
   192          * Count of references to this object.
       
   193          */ 
       
   194         TInt iReferenceCount;
       
   195         
       
   196         /**
       
   197          * Utility implementation object
       
   198          */
       
   199         CVcxConnUtilImpl* iUtilImpl;
       
   200                         
       
   201         /**
       
   202          * Notifier used for showing connecting dialogs
       
   203          */
       
   204         RNotifier iNotifier; 
       
   205                                             
       
   206     };
       
   207 #endif // __VCXNS_CONNUTIL_H_
       
   208 // End of File