convergedconnectionhandler/cchclientapi/inc/cchserviceimpl.h
branchRCL_3
changeset 21 f742655b05bf
parent 20 65a3ef1d5bd0
child 22 d38647835c2e
equal deleted inserted replaced
20:65a3ef1d5bd0 21:f742655b05bf
     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:  cch client api implementation class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_CCHSERVICEIMPL_H
       
    21 #define C_CCHSERVICEIMPL_H
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <ccherror.h>
       
    25 #include <cchtypes.h>
       
    26 //from cchclient
       
    27 #include "cchimpl.h"
       
    28 #include "cch.h"
       
    29 
       
    30 
       
    31 class CCchClientObserver;
       
    32 class CCchImpl;
       
    33 class CCchServiceImplAsynchroniser;
       
    34 #ifdef CCHAPI_USE_CCHUI
       
    35 class CCchUiPrivateApi;
       
    36 #else 
       
    37 #define CCchUiPrivateApi TInt 
       
    38 #endif
       
    39 
       
    40 /**
       
    41  *  Class for basic cch functionality, getting services
       
    42  *
       
    43  *  @code
       
    44  *   ?good_class_usage_example(s)
       
    45  *  @endcode
       
    46  *
       
    47  *  @lib cch
       
    48  */
       
    49 class CCchServiceImpl : public CCchService
       
    50     {
       
    51 
       
    52 public:
       
    53 
       
    54     /**
       
    55      * Two-phased constructor.
       
    56      * 
       
    57      * @param aCch Cch service factory
       
    58      * @param aServiceId Id of the service
       
    59      * @param aCchUi CCH connectivity UI handling API
       
    60      */
       
    61     static CCchServiceImpl* NewL( CCchImpl& aCch, 
       
    62                                   TInt aServiceId,
       
    63                                   CCchUiPrivateApi& aCchUi );
       
    64     
       
    65     /**
       
    66      * Two-phased constructor.
       
    67      * 
       
    68      * @param aCch Cch service factory
       
    69      * @param aServiceId Id of the service
       
    70      * @param aCchUi CCH connectivity UI handling API
       
    71      */
       
    72     static CCchServiceImpl* NewLC( CCchImpl& aCch, 
       
    73                                    TInt aServiceId,
       
    74                                    CCchUiPrivateApi& aCchUi );
       
    75     
       
    76     /**
       
    77      * Destructor.
       
    78      */
       
    79     ~CCchServiceImpl();
       
    80 
       
    81 public: // from CCchService
       
    82 
       
    83     /**
       
    84      * Launches service enable. See CCchServiceObserver for status changes.
       
    85      *
       
    86      * @param aType Type of service
       
    87      * @return Symbian error
       
    88      */
       
    89     TInt Enable( TCCHSubserviceType aType );
       
    90     
       
    91     /**
       
    92      * Launches service disable. See CCchServiceObserver for status changes.
       
    93      *
       
    94      * @param aType Type of service
       
    95      * @return Symbian error
       
    96      */
       
    97     TInt Disable( TCCHSubserviceType aType );
       
    98     
       
    99     /**
       
   100      * Returns the current service state
       
   101      *
       
   102      * @param aType Type of service
       
   103      * @param aStatus Status of the service, return value
       
   104      * @return Symbian error code
       
   105      */
       
   106     TInt GetStatus( TCCHSubserviceType aType, TCchServiceStatus& aStatus ) const;
       
   107     
       
   108     /**
       
   109      * Returns the connection parameters
       
   110      *
       
   111      * @param aType Type of service
       
   112      * @param aParameter Connection parameter of the service
       
   113      * @param aValue value of the parameter
       
   114      * @return Symbian error code
       
   115      */
       
   116     TInt GetConnectionParameter( TCCHSubserviceType aType, TCchConnectionParameter aParameter, TInt& aValue ) const;
       
   117     
       
   118     /**
       
   119      * Returns the connection parameters
       
   120      *
       
   121      * @param aType Type of service
       
   122      * @param aParameter Connection parameter of the service
       
   123      * @param aValue value of the parameter
       
   124      * @return Symbian error code
       
   125      */
       
   126     TInt GetConnectionParameter( TCCHSubserviceType aType, 
       
   127                                  TCchConnectionParameter aParameter, 
       
   128                                  RBuf& aValue ) const;
       
   129     
       
   130     /**
       
   131      * Sets the connection parameters
       
   132      *
       
   133      * @param aType The type of service
       
   134      * @param aParameter Connection parameter of the service
       
   135      * @param aValue value of the parameter
       
   136      * @return Symbian error code
       
   137      */
       
   138     TInt SetConnectionParameter( TCCHSubserviceType aType, 
       
   139                                  TCchConnectionParameter aParameter, 
       
   140                                  TInt aValue );
       
   141     
       
   142     /**
       
   143      * Sets the connection parameters
       
   144      *
       
   145      * @param aType The type of service
       
   146      * @param aParameter Connection parameter of the service
       
   147      * @param aValue value of the parameter
       
   148      * @return Symbian error code
       
   149      */
       
   150     TInt SetConnectionParameter( TCCHSubserviceType aType, 
       
   151                                  TCchConnectionParameter aParameter, 
       
   152                                  const TDesC& aValue );
       
   153     
       
   154     /**
       
   155      * Reserves the service for exclusive usage
       
   156      *
       
   157      * @param aType Type of service
       
   158      * @return Symbian error code
       
   159      */
       
   160     TInt Reserve( TCCHSubserviceType aType );
       
   161     
       
   162     /**
       
   163      * Frees the service of exclusive usage
       
   164      *
       
   165      * @param aType Type of service
       
   166      * @return Symbian error code
       
   167      */
       
   168     TInt Free( TCCHSubserviceType aType );
       
   169     
       
   170     /**
       
   171      * Is the service reserved
       
   172      *
       
   173      * @param aType Type of service
       
   174      * @param aReserved True if the service is reserved
       
   175      * @return Symbian error code
       
   176      */
       
   177     TInt IsReserved( TCCHSubserviceType aType, 
       
   178                      TBool& aReserved ) const;
       
   179     
       
   180     /**
       
   181      * Returns the service id
       
   182      *
       
   183      * @return Service id
       
   184      */
       
   185     TInt ServiceId() const;
       
   186     
       
   187     /**
       
   188      * @deprecated Do not use this anymore, change to AddObserver!
       
   189      *
       
   190      * Adds observer for listening service events
       
   191      *
       
   192      * @param aObserver Event observing class
       
   193      */
       
   194     void SetObserver( MCchServiceStatusObserver& aObserver );
       
   195     
       
   196     /**
       
   197      * @deprecated Do not use this anymore, change to 
       
   198      * RemoveObserver method with paramater
       
   199      * 
       
   200      * Removes the observer of service events
       
   201      */
       
   202     void RemoveObserver( );
       
   203 
       
   204     /**
       
   205      * Adds observer for listening service events
       
   206      *
       
   207      * @param aObserver Event observing class
       
   208      * @return KErrAlreadyExist Observer already added
       
   209      *         KErrNone Observer was added
       
   210      */
       
   211     TInt AddObserver( MCchServiceStatusObserver& aObserver );
       
   212     
       
   213     /**
       
   214      * Removes the observer of service events
       
   215      *
       
   216      * @param aObserver Event observing class
       
   217      * @return KErrNotFound Observer was not found
       
   218      *         KErrNone Observer was removed
       
   219      */
       
   220     TInt RemoveObserver( MCchServiceStatusObserver& aObserver );
       
   221     
       
   222     /**
       
   223      * Checks if the type is supported
       
   224      *
       
   225      * @param aType Type of service
       
   226      * @param aSupported True if the service type is supported
       
   227      * @return Symbian error code
       
   228      */
       
   229     TInt IsSupported( TCCHSubserviceType aType, TBool& aSupported ) const;
       
   230     
       
   231 private:
       
   232     
       
   233     /**
       
   234      * The constructor
       
   235      * 
       
   236      * @param aCch Cch service factory
       
   237      * @param aServiceId The id of the service
       
   238      */
       
   239 	CCchServiceImpl( CCchImpl& aCch, 
       
   240 	                 TInt aServiceId, 
       
   241                      CCchUiPrivateApi& aCchUi );
       
   242     
       
   243     /**
       
   244      * By default Symbian 2nd phase constructor is private.
       
   245      */
       
   246     void ConstructL();
       
   247 
       
   248 public:
       
   249 
       
   250 	CCchImpl* CchImpl() const;
       
   251 	
       
   252 private: // data
       
   253 
       
   254 	/**
       
   255 	 * cch service factory, not own
       
   256 	 */
       
   257 	CCchImpl& iCch;
       
   258 	
       
   259 	/**
       
   260 	 * Service Id
       
   261 	 */
       
   262 	TInt iServiceId; 
       
   263 	
       
   264 	/**
       
   265 	 * Service observer
       
   266 	 */
       
   267 	CCchClientObserver* iObserver;
       
   268 	/**
       
   269 	 * CCH connectivity UI handling private API
       
   270 	 */	
       
   271 	CCchUiPrivateApi& iCchUi;
       
   272 	
       
   273 	/**
       
   274 	 * CCH server request handler
       
   275 	 */	
       
   276 	CCchServiceImplAsynchroniser* iAsynchroniser;
       
   277 
       
   278 #ifdef CCHUNITTEST
       
   279     friend class UT_CCchService;
       
   280 #endif
       
   281     };
       
   282 
       
   283 #endif // C_CCHSERVICEIMPL_H