uiservicetab/vimpstengine/tsrc/vimpstengine_ut/src/stubs/s_cch.cpp
branchRCL_3
changeset 29 9a48e301e94b
parent 0 5e5d6b214f4f
child 30 2b4be3554d30
equal deleted inserted replaced
28:3104fc151679 29:9a48e301e94b
       
     1 /*
       
     2 * s_cch.cpp : Copyright (c) 2009 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: s_cch.cpp
       
    15 *
       
    16 */
       
    17 //  EXTERNAL INCLUDES
       
    18 #include <CEUnitTestSuiteClass.h>
       
    19 #include <cch.h>
       
    20 
       
    21 #include "s_cch.h"
       
    22 
       
    23 MyCchService* myService = NULL;
       
    24 TBool createService = EFalse;
       
    25 TBool tryAllSubserviceAvailable = EFalse;
       
    26 TBool tryVoipSubServiceAvailable = EFalse;
       
    27 TBool tryPresenceSubServiceAvailable = EFalse;
       
    28 TBool tryIMSubServiceAvailable = EFalse;
       
    29 TBool tryConnParamLeaveWithNotSupported = EFalse;
       
    30 TBool tryConnParamWithSuccess = EFalse;
       
    31 TBool sendObserverEvent = EFalse;
       
    32 TBool getUserName = EFalse;
       
    33 TBool getPassword = EFalse;
       
    34 TBool tryParamTomatchOwnId =EFalse;
       
    35 TBool tryConnParamWithFailure = EFalse;
       
    36 
       
    37 
       
    38 
       
    39 /*************** Stubs ****************/
       
    40 CCchService* CCch::GetService( TInt /*aServiceId*/ )
       
    41 	{
       
    42 	if( createService && !myService )
       
    43 		{
       
    44 		myService = new ( ELeave ) MyCchService();
       
    45 		return myService;
       
    46 		}
       
    47 		
       
    48 	return myService;
       
    49 	}
       
    50 
       
    51 
       
    52 /************* End of Stubs ************/
       
    53 
       
    54 
       
    55 
       
    56 TInt MyCchService::Enable( TCCHSubserviceType aType )
       
    57 	{ 
       
    58 
       
    59 	if (sendObserverEvent)
       
    60 		{
       
    61 		if (iObserver)
       
    62 			{
       
    63 			TCchServiceStatus aStatus;
       
    64 			
       
    65 			aStatus.SetState(ECCHEnabled);	
       
    66 			aStatus.SetError(KErrNone);	
       
    67 			
       
    68 			if (tryPresenceSubServiceAvailable)
       
    69 				{		
       
    70 				iObserver->ServiceStatusChanged( 10, ECCHPresenceSub, aStatus );		
       
    71 				}
       
    72 			else
       
    73 				{
       
    74 				iObserver->ServiceStatusChanged( 10, aType, aStatus );			
       
    75 				}				
       
    76 			}
       
    77 		}
       
    78 	
       
    79 	return KErrNone; 
       
    80 	}
       
    81     
       
    82 /**
       
    83  * Launches service disable. See MCchServiceObserver for status changes.
       
    84  *
       
    85  * @param aType Type of service
       
    86  * @return Symbian error
       
    87  */
       
    88  TInt MyCchService::Disable( TCCHSubserviceType /*aType*/ ){ return KErrNone; }
       
    89 
       
    90 /**
       
    91  * Returns the current service state
       
    92  *
       
    93  * @param aType Type of service
       
    94  * @param aStatus Status of the service, return value
       
    95  * @return Symbian error code
       
    96  */
       
    97  TInt MyCchService::GetStatus( TCCHSubserviceType aType, 
       
    98 						TCchServiceStatus& aStatus ) const 
       
    99 						
       
   100 	{ 
       
   101 
       
   102 	if ( (ECCHVoIPSub == aType) && (tryVoipSubServiceAvailable || tryAllSubserviceAvailable) )
       
   103 		{		
       
   104 		aStatus.SetState(ECCHUninitialized);	
       
   105 		aStatus.SetError(KErrNone);	
       
   106 		return KErrNone; 		
       
   107 		}
       
   108 	
       
   109 	else if ( (ECCHPresenceSub == aType) && (tryPresenceSubServiceAvailable || tryAllSubserviceAvailable) )
       
   110 		{		
       
   111 		aStatus.SetState(ECCHUninitialized);	
       
   112 		aStatus.SetError(KErrNone);			
       
   113 		return KErrNone; 
       
   114 		}
       
   115 		
       
   116 	else if ( (ECCHIMSub == aType) && (tryIMSubServiceAvailable || tryAllSubserviceAvailable) )
       
   117 		{		
       
   118 		aStatus.SetState(ECCHUninitialized);	
       
   119 		aStatus.SetError(KErrNone);			
       
   120 		return KErrNone; 
       
   121 		}	
       
   122 					
       
   123 	return KErrNotFound	; 
       
   124 
       
   125 	}
       
   126 
       
   127 /**
       
   128  * Returns the connection parameters
       
   129  *
       
   130  * @param aType Type of service
       
   131  * @param aParameter Connection parameter of the service
       
   132  * @param aValue Value of the parameter
       
   133  * @return Symbian error code
       
   134  */
       
   135  TInt MyCchService::GetConnectionParameter( TCCHSubserviceType /*aType*/,
       
   136 					TCchConnectionParameter /*aParameter*/, TInt& /*aValue*/ ) const{ return KErrNone;}
       
   137 
       
   138 /**
       
   139  * Returns the connection parameters
       
   140  *
       
   141  * @param aType Type of service
       
   142  * @param aParameter Connection parameter of the service
       
   143  * @param aValue Value of the parameter
       
   144  * @return Symbian error code
       
   145  */
       
   146  TInt MyCchService::GetConnectionParameter( TCCHSubserviceType /*aType*/, 
       
   147 					TCchConnectionParameter /*aParameter*/, RBuf& aValue ) const
       
   148 					
       
   149 	{
       
   150 	if (tryConnParamLeaveWithNotSupported)
       
   151 		{
       
   152 		return KErrNotSupported;
       
   153 		}
       
   154 
       
   155 	if (tryConnParamWithSuccess)
       
   156 		{
       
   157 		aValue.Copy(KTestUserName);		
       
   158 		}
       
   159 	if (tryParamTomatchOwnId)
       
   160 	    {
       
   161 	    aValue.Copy(KOwnUserNameMatch);
       
   162 	    }
       
   163 	if ( getUserName )
       
   164 	    {
       
   165 	    aValue.Copy(KTestUserName);    
       
   166 	    }
       
   167 	if ( getPassword )
       
   168 	    {
       
   169 	    aValue.Copy(KTestPassword);    
       
   170 	    }
       
   171 	if(tryConnParamWithFailure)
       
   172 	    {
       
   173 	    return KErrNotFound;
       
   174 	    }
       
   175 
       
   176 	return KErrNone;
       
   177 	}
       
   178 
       
   179 /**
       
   180  * Sets the connection parameters
       
   181  *
       
   182  * @param aType The type of service
       
   183  * @param aParameter Connection parameter of the service
       
   184  * @param aValue Value of the parameter
       
   185  * @return Symbian error code
       
   186  */
       
   187  TInt MyCchService::SetConnectionParameter( TCCHSubserviceType /*aType*/, 
       
   188 					TCchConnectionParameter /*aParameter*/, TInt /*aValue*/ )
       
   189 					
       
   190 	{
       
   191 	return KErrNone;
       
   192 	}
       
   193 
       
   194 /**
       
   195  * Sets the connection parameters
       
   196  *
       
   197  * @param aType The type of service
       
   198  * @param aParameter Connection parameter of the service
       
   199  * @param aValue Value of the parameter
       
   200  * @return Symbian error code
       
   201  */
       
   202  TInt MyCchService::SetConnectionParameter( TCCHSubserviceType /*aType*/, 
       
   203 					TCchConnectionParameter /*aParameter*/, const TDesC& /*aValue*/ )
       
   204 	{
       
   205 	if (tryConnParamLeaveWithNotSupported)
       
   206 		{
       
   207 		return KErrNotSupported;
       
   208 		}
       
   209 
       
   210 	return KErrNone;	
       
   211 	}
       
   212 
       
   213 /**
       
   214  * Reserves the service for exclusive usage
       
   215  *
       
   216  * @param aType Type of service
       
   217  * @return Symbian error code
       
   218  */
       
   219  TInt MyCchService::Reserve( TCCHSubserviceType /*aType*/ ){ return KErrNone; }
       
   220 
       
   221 /**
       
   222  * Frees the service of exclusive usage
       
   223  *
       
   224  * @param aType Type of service
       
   225  * @return Symbian error code
       
   226  */
       
   227  TInt MyCchService::Free( TCCHSubserviceType /*aType*/ ){ return KErrNone; }
       
   228 
       
   229 /**
       
   230  * Is the service reserved
       
   231  *
       
   232  * @param aType Type of service
       
   233  * @param aReserved True if the service is reserved
       
   234  * @return Symbian error code
       
   235  */
       
   236  TInt MyCchService::IsReserved( TCCHSubserviceType /*aType*/, TBool& /*aReserved*/ ) const{ return KErrNone; }
       
   237 
       
   238 /**
       
   239  * Returns the service id
       
   240  *
       
   241  * @return The id of the service
       
   242  */
       
   243  TInt MyCchService::ServiceId() const{ return KErrNone; }
       
   244 
       
   245 /**
       
   246  * @deprecated Do not use this anymore, change to AddObserver!
       
   247  *
       
   248  * Adds observer for listening service events
       
   249  *
       
   250  * @param aObserver Event observing class
       
   251  */
       
   252  void MyCchService::SetObserver( MCchServiceStatusObserver& aObserver )
       
   253 	 {
       
   254 	 iObserver = &aObserver;
       
   255 	 }
       
   256 
       
   257 /**
       
   258  * @deprecated Do not use this anymore, change to 
       
   259  * RemoveObserver method with paramater
       
   260  * 
       
   261  * Removes the observer of service events
       
   262  */
       
   263  void MyCchService::RemoveObserver( )
       
   264  	{
       
   265 	 iObserver = NULL;
       
   266 	 }
       
   267 
       
   268  
       
   269 /**
       
   270  * Adds observer for listening service events
       
   271  *
       
   272  * @param aObserver Event observing class
       
   273  * @return KErrAlreadyExist Observer already added
       
   274  *         KErrNone Observer was added
       
   275  */
       
   276  TInt MyCchService::AddObserver( MCchServiceStatusObserver& /*aObserver*/ ){ return KErrNone; }
       
   277 
       
   278 /**
       
   279  * Removes the observer of service events
       
   280  *
       
   281  * @param aObserver Event observing class
       
   282  * @return KErrNotFound Observer was not found
       
   283  *         KErrNone Observer was removed
       
   284  */
       
   285  TInt MyCchService::RemoveObserver( MCchServiceStatusObserver& /*aObserver*/ ){ return KErrNone; }
       
   286 
       
   287 /**
       
   288  * Checks if the type is supported
       
   289  *
       
   290  * @param aType Type of service
       
   291  * @param aSupported True if the service type is supported
       
   292  * @return Symbian error code
       
   293  */
       
   294  TInt MyCchService::IsSupported( TCCHSubserviceType /*aType*/, TBool& /*aSupported*/ ) const{ return KErrNone; }
       
   295  
       
   296  
       
   297  //end of file
       
   298  
       
   299  
       
   300