tsrc/cmusavainterfacestub/src/cmusavainterfacestub.cpp
changeset 0 f0cf47e981f9
child 22 73a1feb507fb
equal deleted inserted replaced
-1:000000000000 0:f0cf47e981f9
       
     1 /*
       
     2 * Copyright (c) 2004-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:  Stub class of CMusAvaInterface to support unit testing.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "cmusavainterfacestub.h"
       
    20 #include "musavaavailabilitystub.h"
       
    21 #include "mmusavasettingsstub.h"
       
    22 #include "musavaavailability.h"
       
    23 #include "musavaavailabilityobserverimp.h"
       
    24 
       
    25 const MMusAvaObserver::TAvailabilityName KMinimumAvailability
       
    26     = MMusAvaObserver::EMusAvaBearerStatus;
       
    27 
       
    28 const MMusAvaObserver::TAvailabilityName KMandatoryAvailability
       
    29     = MMusAvaObserver::EMusAvaNameRegistration;
       
    30 
       
    31 const MMusAvaObserver::TAvailabilityName KExtensionAvailability
       
    32     = MMusAvaObserver::EMusAvaOptionHandler;
       
    33     
       
    34 // ======== MEMBER FUNCTIONS ========
       
    35 
       
    36 
       
    37 CMusAvaInterface2* CMusAvaInterface2::NewL()
       
    38 	    {
       
    39 	    CMusAvaInterface2* self = new( ELeave ) CMusAvaInterface2();
       
    40 	    CleanupStack::PushL( self );
       
    41 	    self->ConstructL();
       
    42 	    CleanupStack::Pop( self );
       
    43 	    return self;
       
    44 	    }
       
    45 
       
    46 
       
    47 CMusAvaInterface2::~CMusAvaInterface2()
       
    48 	    {
       
    49 	    iAvailabilities.ResetAndDestroy();
       
    50 	    iAvailabilities.Close();
       
    51 	    delete iSettings;
       
    52 	    delete iMusAvailObs;
       
    53 	    }
       
    54 
       
    55 
       
    56 CMusAvaInterface2::CMusAvaInterface2()
       
    57     {
       
    58     }
       
    59 
       
    60 
       
    61 void CMusAvaInterface2::ConstructL()
       
    62     {
       
    63     iSettings = new(ELeave)CMusAvaSettings2();
       
    64     iSettings->ConstructL();
       
    65     // Create network availability stub
       
    66     iMusAvailObs = CMusAvaAvailabilityObserverImp::NewL();
       
    67     CMusAvaAvailabilityStub* stub = CMusAvaAvailabilityStub::NewLC( *iMusAvailObs, *iSettings );
       
    68     iAvailabilities.AppendL( stub );
       
    69     CleanupStack::Pop( stub );
       
    70     }
       
    71 
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // Requests the implementation to provide availabilites.
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void CMusAvaInterface2::Availability()
       
    78     {
       
    79 
       
    80     }
       
    81 
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // Called by the ECOM framework when MusAvailability Plug-in is request
       
    85 // retuns setting interface for the client.
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 MMusAvaSettings& CMusAvaInterface2::Settings()
       
    89     {
       
    90     return *iSettings;
       
    91     }
       
    92 
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // Called by the ECOM framework when MusAvailability Plug-in is for
       
    96 // setting Observer interface for the client.
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CMusAvaInterface2::SetObserver( MMusAvaObserver& aObserver )
       
   100     {
       
   101     iObserver = &aObserver;
       
   102     }
       
   103 
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // Called by the ECOM framework when MusAvailability Plug-in is request
       
   107 // to investigate availabilites for the client.
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 void CMusAvaInterface2::StartL()
       
   111     {
       
   112    
       
   113     }
       
   114 
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // Called by the ECOM framework when MusAvailability Plug-in is request
       
   118 // to stop investigate or monitoring availabilites for the client.
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 void CMusAvaInterface2::Stop()
       
   122     {
       
   123     }
       
   124 
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 //  tbd
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 MMusAvaObserver::TAvailabilityName CMusAvaInterface2::CurrentAvailability()
       
   131     {
       
   132     return iCurrentAvailability;
       
   133     }
       
   134 
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 //  tbd
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 MMusAvaObserver::TAvailabilityStatus CMusAvaInterface2::AvailabilityStatus()
       
   141     {
       
   142     return iAvailabilityStatus;
       
   143     }
       
   144 
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 //  tbd
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 TBool CMusAvaInterface2::MinimumAvailability()
       
   151     {
       
   152     return iCurrentAvailability > KMinimumAvailability;
       
   153     }
       
   154 
       
   155 
       
   156 // -----------------------------------------------------------------------------
       
   157 //  tbd
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 TBool CMusAvaInterface2::MandatoryAvailability()
       
   161     {
       
   162     return iCurrentAvailability > KMandatoryAvailability;
       
   163     }
       
   164 
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 //  tbd
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 TBool CMusAvaInterface2::ExtensionAvailability()
       
   171     {
       
   172     return iCurrentAvailability > KExtensionAvailability;
       
   173     }
       
   174 
       
   175 
       
   176 // -----------------------------------------------------------------------------
       
   177 //  tbd
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 TBool CMusAvaInterface2::Available(
       
   181     MMusAvaObserver::TAvailabilityName aAvailability )
       
   182     {
       
   183     return iCurrentAvailability > aAvailability
       
   184            || ( iCurrentAvailability == aAvailability
       
   185            && MMusAvaObserver::EMusAvaStatusAvailable == iAvailabilityStatus );
       
   186     }
       
   187 
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 //  tbd
       
   191 // -----------------------------------------------------------------------------
       
   192 //
       
   193 MMusAvaObserver::TAvailabilityStatus CMusAvaInterface2::AvailabilityState(
       
   194     MMusAvaObserver::TAvailabilityName aAvailability )
       
   195     {
       
   196     for ( TInt i = 0; i < iAvailabilities.Count(); i++ )
       
   197         {
       
   198         if ( iAvailabilities[i]->Name() == aAvailability )
       
   199             {
       
   200             return iAvailabilities[i]->State();
       
   201             }
       
   202         }
       
   203     return MMusAvaObserver::EMusAvaStatusNotExecuted;
       
   204     }
       
   205     
       
   206 void CMusAvaInterface2::AvailabilityChanged(
       
   207         TAvailabilityName aName,
       
   208         TAvailabilityStatus aStatus )
       
   209 	{
       
   210 		
       
   211 	}
       
   212 
       
   213 void CMusAvaInterface2::AvailabilityError(
       
   214         TAvailabilityName aName,
       
   215         TAvailabilityStatus aStatus )
       
   216 	{
       
   217 		
       
   218 	}
       
   219 	
       
   220 void CMusAvaInterface2::SetSettingsObserver( MMusAvaSettingsObserver& aObserver )
       
   221     {
       
   222     }
       
   223 
       
   224 // ======== GLOBAL FUNCTIONS ========
       
   225 
       
   226 
       
   227 CImplementationInformation::CImplementationInformation()
       
   228     {
       
   229 
       
   230     }
       
   231 
       
   232 CImplementationInformation::~CImplementationInformation()
       
   233     {
       
   234 
       
   235     }
       
   236 
       
   237 
       
   238 CImplementationInformation* CImplementationInformation::NewL(
       
   239     TUid	/*aUid*/,
       
   240 	TInt	/*aVersion*/,
       
   241 	HBufC*  /*aName*/,
       
   242 	HBufC8* /*aDataType*/,
       
   243 	HBufC8* /*aOpaqueData*/,
       
   244 	TDriveUnit /*aDrive*/,
       
   245 	TBool /*aRomOnly*/,
       
   246 	TBool /*aRomBased*/)
       
   247     {
       
   248     return new (ELeave) CImplementationInformation();
       
   249     }
       
   250 
       
   251 void REComSession::DestroyedImplementation( TUid )
       
   252     {
       
   253 
       
   254     }
       
   255 
       
   256 void REComSession::ListImplementationsL(
       
   257     TUid /*aInterfaceUid*/,
       
   258     RImplInfoPtrArray &aImplInfoArray )
       
   259     {
       
   260     TUid uid = { 0x10101010 };
       
   261     TDriveUnit drive;
       
   262     HBufC* name( NULL );
       
   263     HBufC8* type( NULL );
       
   264 
       
   265     CImplementationInformation* info = 
       
   266         CImplementationInformation::NewL( uid,
       
   267                                           1,
       
   268                                           name,
       
   269                                           type,
       
   270                                           type,
       
   271                                           drive,
       
   272                                           EFalse,
       
   273                                           EFalse );
       
   274     CleanupStack::PushL( info );
       
   275     
       
   276     aImplInfoArray.AppendL( info );
       
   277 
       
   278     CleanupStack::Pop( info );
       
   279     
       
   280     }
       
   281 
       
   282 
       
   283 TAny* REComSession::CreateImplementationL(
       
   284     TUid /*aImplementationUid*/,
       
   285     TInt32 /*aDtorIDKey*/ )
       
   286     {
       
   287     return CMusAvaInterface2::NewL();
       
   288     }
       
   289     
       
   290 
       
   291     
       
   292 
       
   293