mmsharing/mmshavailability/tsrc/ut_availability/Stubs/src/centralrepositorystub.cpp
changeset 0 f0cf47e981f9
equal deleted inserted replaced
-1:000000000000 0:f0cf47e981f9
       
     1 /*
       
     2 * Copyright (c) 2005 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "centralrepository.h"
       
    20 #include "mussettingskeys.h"
       
    21 #include "CSipSseTestTls.h"
       
    22 
       
    23 
       
    24 /// CenRep UIDs and keys
       
    25 const TUid KCRUidSIPClientResolverConfig = { 0x10282EE7 };
       
    26 
       
    27 const TUid KCRUidInCallVolume = {0x102828B1};
       
    28 const TUint32 KTelIncallEarVolume                           = 0x00000001;
       
    29 const TUint32 KTelIncallLoudspeakerVolume                   = 0x00000002;
       
    30 
       
    31 
       
    32 // Values for static variables
       
    33 MusSettingsKeys::TOperatorVariant CRepository::iOperatorVariant =
       
    34             MusSettingsKeys::EStandard;
       
    35 TBool CRepository::iEmulateSawfishRepository = EFalse;
       
    36 
       
    37 // STUB stuff
       
    38 /*
       
    39 void CCRepositoryBehaviorTls::OpenL()
       
    40 	{
       
    41     CCRepositoryBehaviorTls* self = new (ELeave) CCRepositoryBehaviorTls();
       
    42     Dll::SetTls( self );
       
    43     
       
    44     User::LeaveIfError( self->Set ( MusSettingsKeys::KActivation,
       
    45                             MusSettingsKeys::EAlwaysActive ) );
       
    46     User::LeaveIfError( self->Set ( MusSettingsKeys::KAuditoryNotification,
       
    47                             MusSettingsKeys::EAuditoryNotificationOff ) );
       
    48     User::LeaveIfError( self->Set ( MusSettingsKeys::KPopupNotification,
       
    49                             MusSettingsKeys::EPopupNotificationOff ) );
       
    50     User::LeaveIfError( self->Set ( MusSettingsKeys::KPopupNotificationType,
       
    51                             MusSettingsKeys::ENotificationTypeQueryUser ) );
       
    52     User::LeaveIfError( self->Set ( MusSettingsKeys::KEdgeDtmSupport,
       
    53                             MusSettingsKeys::EDtmModeNotAllowed ) );
       
    54     User::LeaveIfError( self->Set ( MusSettingsKeys::KForceInternetSignaling,
       
    55                             MusSettingsKeys::EFollowProfileConfiguration ) );
       
    56     User::LeaveIfError( self->Set ( MusSettingsKeys::KAutoRecord,
       
    57                             MusSettingsKeys::EAutoRecordOn ) );       
       
    58     User::LeaveIfError( self->Set ( MusSettingsKeys::KSipProfileId,
       
    59                             0  ) ); //default profile
       
    60     User::LeaveIfError( self->Set ( MusSettingsKeys::KUiOrientation,
       
    61                             MusSettingsKeys::EPortrait ) );                    
       
    62     User::LeaveIfError( self->Set ( MusSettingsKeys::KCapabilityQuery,
       
    63                             MusSettingsKeys::ENoOptions ) );
       
    64 	}
       
    65 
       
    66 void CCRepositoryBehaviorTls::Close ()
       
    67 	{
       
    68 	CCRepositoryBehaviorTls* self = Storage();
       
    69     delete self;
       
    70     Dll::SetTls( NULL );
       
    71 	}
       
    72 
       
    73 	
       
    74 CCRepositoryBehaviorTls* CCRepositoryBehaviorTls::Storage()
       
    75 	{
       
    76 	return static_cast<CCRepositoryBehaviorTls*>(Dll::Tls());
       
    77 	}
       
    78 
       
    79 void CCRepositoryBehaviorTls::Reset()
       
    80     {
       
    81     User::LeaveIfError( Storage()->Set ( MusSettingsKeys::KActivation,
       
    82                             MusSettingsKeys::EAlwaysActive ) );
       
    83     User::LeaveIfError( Storage()->Set ( MusSettingsKeys::KAuditoryNotification,
       
    84                             MusSettingsKeys::EAuditoryNotificationOff ) );
       
    85     User::LeaveIfError( Storage()->Set ( MusSettingsKeys::KPopupNotification,
       
    86                             MusSettingsKeys::EPopupNotificationOff ) );
       
    87     User::LeaveIfError( Storage()->Set ( MusSettingsKeys::KPopupNotificationType,
       
    88                             MusSettingsKeys::ENotificationTypeQueryUser ) );
       
    89     User::LeaveIfError( Storage()->Set ( MusSettingsKeys::KEdgeDtmSupport,
       
    90                             MusSettingsKeys::EDtmModeNotAllowed ) );
       
    91     User::LeaveIfError( Storage()->Set ( MusSettingsKeys::KForceInternetSignaling,
       
    92                             MusSettingsKeys::EFollowProfileConfiguration ) );
       
    93     User::LeaveIfError( Storage()->Set ( MusSettingsKeys::KAutoRecord,
       
    94                             MusSettingsKeys::EAutoRecordOn ) );       
       
    95     User::LeaveIfError( Storage()->Set ( MusSettingsKeys::KSipProfileId,
       
    96                             0  ) ); //default profile
       
    97     User::LeaveIfError( Storage()->Set ( MusSettingsKeys::KUiOrientation,
       
    98                             MusSettingsKeys::EPortrait ) );                    
       
    99     User::LeaveIfError( Storage()->Set ( MusSettingsKeys::KCapabilityQuery,
       
   100                             MusSettingsKeys::ENoOptions ) );
       
   101     }
       
   102     
       
   103 TInt CCRepositoryBehaviorTls::Set(TUint32 aKey, TInt aValue)
       
   104     {
       
   105     // Setting of any other value
       
   106     for ( TInt i = 0; i < iKeys.Count(); ++i )
       
   107         {
       
   108         if ( iKeys[i] == aKey )
       
   109             {
       
   110             iValues[i] = aValue;
       
   111             return KErrNone;
       
   112             }
       
   113         }
       
   114     
       
   115     // No wise error handling implemented
       
   116     TInt error = iKeys.Append( aKey );
       
   117     if ( error == KErrNone )
       
   118         {
       
   119         error = iValues.Append( aValue );
       
   120         }
       
   121         
       
   122     return error;
       
   123     }
       
   124     
       
   125 TInt CCRepositoryBehaviorTls::Get(TUint32 aKey, TInt& aValue)
       
   126     {
       
   127     for ( TInt i = 0; i < iKeys.Count(); ++i )
       
   128         {
       
   129         if ( iKeys[i] == aKey )
       
   130             {
       
   131             aValue = iValues[i];
       
   132             return KErrNone;
       
   133             }
       
   134         }
       
   135 
       
   136     return KErrNotFound;
       
   137     }
       
   138     
       
   139 CCRepositoryBehaviorTls::CCRepositoryBehaviorTls()
       
   140 	{
       
   141 	}
       
   142 	
       
   143 CCRepositoryBehaviorTls::~CCRepositoryBehaviorTls()
       
   144 	{
       
   145 	iKeys.Reset();
       
   146     iValues.Reset();
       
   147     }
       
   148 */	
       
   149    
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 // -----------------------------------------------------------------------------
       
   153 //
       
   154 EXPORT_C CRepository* CRepository::NewL( TUid aRepositoryUid )
       
   155     {
       
   156     CRepository* self = CRepository::NewLC( aRepositoryUid );
       
   157     CleanupStack::Pop( self );
       
   158     return self;
       
   159     }
       
   160     
       
   161     
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 // -----------------------------------------------------------------------------
       
   165 // 
       
   166 EXPORT_C CRepository* CRepository::NewLC( TUid aRepositoryUid )
       
   167     {
       
   168     
       
   169     CRepository* self = new( ELeave ) CRepository( aRepositoryUid );
       
   170     CleanupStack::PushL( self );
       
   171 
       
   172     // This UID cannot be used in normal variant
       
   173     if ( aRepositoryUid == KCRUidSIPClientResolverConfig &&
       
   174          !iEmulateSawfishRepository )
       
   175         {
       
   176         User::Leave( KErrNotFound );
       
   177         }
       
   178     
       
   179     // Add a few keys
       
   180     if ( self->iRepositoryUid == KCRUidInCallVolume )
       
   181         {
       
   182         User::LeaveIfError( self->Set ( KTelIncallEarVolume, 4 ) );
       
   183         User::LeaveIfError( self->Set ( KTelIncallLoudspeakerVolume, 4 ) );
       
   184         }
       
   185 /*    else if ( self->iRepositoryUid == MusSettingsKeys::KRepositoryUid )
       
   186         {
       
   187         // Set default values for numeric values which are not handled by static
       
   188         // variables
       
   189         User::LeaveIfError( 
       
   190                 self->Set ( MusSettingsKeys::KActivation,
       
   191                             MusSettingsKeys::EAlwaysActive ) );
       
   192         User::LeaveIfError( 
       
   193                 self->Set ( MusSettingsKeys::KAuditoryNotification,
       
   194                             MusSettingsKeys::EAuditoryNotificationOff ) );
       
   195         User::LeaveIfError( 
       
   196                 self->Set ( MusSettingsKeys::KPopupNotification,
       
   197                             MusSettingsKeys::EPopupNotificationOff ) );
       
   198         User::LeaveIfError( 
       
   199                 self->Set ( MusSettingsKeys::KPopupNotificationType,
       
   200                             MusSettingsKeys::ENotificationTypeQueryUser ) );
       
   201         User::LeaveIfError( 
       
   202                 self->Set ( MusSettingsKeys::KEdgeDtmSupport,
       
   203                             MusSettingsKeys::EDtmModeNotAllowed ) );
       
   204         User::LeaveIfError( 
       
   205                 self->Set ( MusSettingsKeys::KForceInternetSignaling,
       
   206                             MusSettingsKeys::EFollowProfileConfiguration ) );
       
   207         User::LeaveIfError( 
       
   208                 self->Set ( MusSettingsKeys::KAutoRecord,
       
   209                             MusSettingsKeys::EAutoRecordOn ) );       
       
   210         User::LeaveIfError( 
       
   211                 self->Set ( MusSettingsKeys::KSipProfileId,
       
   212                             0  ) ); //default profile
       
   213         User::LeaveIfError( 
       
   214                 self->Set ( MusSettingsKeys::KUiOrientation,
       
   215                             MusSettingsKeys::EPortrait ) );                    
       
   216         User::LeaveIfError( 
       
   217                 self->Set ( MusSettingsKeys::KCapabilityQuery,
       
   218                             MusSettingsKeys::ENoOptions ) );
       
   219         // No variation keys defined                         
       
   220         }
       
   221   */      
       
   222     return self;
       
   223     }
       
   224 
       
   225 
       
   226 // -----------------------------------------------------------------------------
       
   227 //
       
   228 // -----------------------------------------------------------------------------
       
   229 //
       
   230 EXPORT_C CRepository::~CRepository()
       
   231     {
       
   232 /*    iKeys.Reset();
       
   233     iValues.Reset();
       
   234 */    }
       
   235 
       
   236 
       
   237 // -----------------------------------------------------------------------------
       
   238 //
       
   239 // -----------------------------------------------------------------------------
       
   240 //
       
   241 EXPORT_C TInt CRepository::Create(TUint32 /*aKey*/, TInt /*aValue*/ )
       
   242     {
       
   243     return KErrNone;
       
   244     }
       
   245 
       
   246 
       
   247 // -----------------------------------------------------------------------------
       
   248 //
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 EXPORT_C TInt CRepository::Create(TUint32 /*aKey*/, const TDesC8& /*aValue*/)
       
   252     {
       
   253     return KErrNone;
       
   254     }
       
   255 
       
   256 
       
   257 // -----------------------------------------------------------------------------
       
   258 //
       
   259 // -----------------------------------------------------------------------------
       
   260 //
       
   261 EXPORT_C TInt CRepository::Delete( TUint32 /*aPartialKey*/, 
       
   262                                    TUint32 /*aMask*/, 
       
   263                                    TUint32& /*aErrorKey*/ ) 
       
   264     {
       
   265     return KErrNone;
       
   266     }
       
   267      
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 //
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 EXPORT_C TInt CRepository::Get(TUint32 aKey, TInt& aValue)
       
   274     {
       
   275     TInt error = KErrNone;
       
   276     
       
   277     if ( iRepositoryUid == MusSettingsKeys::KRepositoryUid &&
       
   278         aKey == MusSettingsKeys::KOperatorVariant )
       
   279         {
       
   280         aValue = CRepository::iOperatorVariant;
       
   281         return KErrNone;
       
   282         }
       
   283         
       
   284     CSipSseTestTls* repository = CSipSseTestTls::Storage();
       
   285     
       
   286     if ( repository )
       
   287         {
       
   288         error = repository->Get( aKey, aValue );
       
   289         }
       
   290     else
       
   291         {
       
   292         error = KErrNotFound;
       
   293         }
       
   294 
       
   295     return error;
       
   296     }
       
   297 
       
   298 
       
   299 // -----------------------------------------------------------------------------
       
   300 //
       
   301 // -----------------------------------------------------------------------------
       
   302 //
       
   303 EXPORT_C TInt CRepository::Get(TUint32 /*aKey*/, TDes8& /*aValue*/)
       
   304     {
       
   305     return KErrNotSupported;
       
   306     }
       
   307 
       
   308 
       
   309 // -----------------------------------------------------------------------------
       
   310 //
       
   311 // -----------------------------------------------------------------------------
       
   312 //
       
   313 EXPORT_C TInt CRepository::Set(TUint32 /*aKey*/, const TDesC8& /*aValue*/)
       
   314     {
       
   315     return KErrNotSupported;
       
   316     }
       
   317 
       
   318   
       
   319 // -----------------------------------------------------------------------------
       
   320 //
       
   321 // -----------------------------------------------------------------------------
       
   322 //
       
   323 EXPORT_C TInt CRepository::Get(TUint32 /*aKey*/, TDes& aValue)
       
   324     {
       
   325     _LIT( KSampleValue, "\\data\\videos\\");
       
   326     aValue.Append( KSampleValue() );
       
   327     return KErrNone;
       
   328     }
       
   329 
       
   330 
       
   331 // -----------------------------------------------------------------------------
       
   332 //
       
   333 // -----------------------------------------------------------------------------
       
   334 //
       
   335 EXPORT_C TInt CRepository::Set(TUint32 /*aKey*/, const TDesC& /*aValue*/)
       
   336     {
       
   337     return KErrNone;
       
   338     }
       
   339 
       
   340 
       
   341 // -----------------------------------------------------------------------------
       
   342 //
       
   343 // -----------------------------------------------------------------------------
       
   344 //
       
   345 EXPORT_C TInt CRepository::Set(TUint32 aKey, TInt aValue)
       
   346     {
       
   347     // Setting of operator variant value
       
   348     if ( iRepositoryUid == MusSettingsKeys::KRepositoryUid &&
       
   349         aKey == MusSettingsKeys::KOperatorVariant )
       
   350         {
       
   351         CRepository::iOperatorVariant =
       
   352                 ( MusSettingsKeys::TOperatorVariant ) aValue;
       
   353         return KErrNone;
       
   354         }
       
   355 /*
       
   356     // Setting of any other value
       
   357     for ( TInt i = 0; i < iKeys.Count(); ++i )
       
   358         {
       
   359         if ( iKeys[i] == aKey )
       
   360             {
       
   361             iValues[i] = aValue;
       
   362             return KErrNone;
       
   363             }
       
   364         }
       
   365     
       
   366     // No wise error handling implemented
       
   367     TInt error = iKeys.Append( aKey );
       
   368     if ( error == KErrNone )
       
   369         {
       
   370         error = iValues.Append( aValue );
       
   371         }
       
   372   */
       
   373     TInt error = KErrNone;
       
   374     //CCRepositoryBehaviorTls* repository = CCRepositoryBehaviorTls::Storage();
       
   375     CSipSseTestTls* repository = CSipSseTestTls::Storage();
       
   376     if ( repository )
       
   377         {
       
   378         error = repository->Set( aKey, aValue );
       
   379         }
       
   380     return error;
       
   381     }
       
   382 	
       
   383 
       
   384 // -----------------------------------------------------------------------------
       
   385 //
       
   386 // -----------------------------------------------------------------------------
       
   387 //
       
   388 EXPORT_C TInt CRepository::FindL( TUint32 /*aPartialKey*/, 
       
   389                                   TUint32 /*aMask*/,
       
   390 		                          RArray<TUint32>& /*aFoundKeys*/ )
       
   391     {
       
   392     return KErrNone;
       
   393     }
       
   394     
       
   395 
       
   396 // -----------------------------------------------------------------------------
       
   397 //
       
   398 // -----------------------------------------------------------------------------
       
   399 //
       
   400 EXPORT_C TInt CRepository::FindEqL( TUint32 /*aPartialKey*/, 
       
   401                                     TUint32 /*aMask*/,
       
   402 		                            const TDesC8& /*aValue*/, 
       
   403 		                            RArray<TUint32>& /*aFoundKeys*/ )
       
   404     {
       
   405     return KErrNone;
       
   406     }
       
   407     
       
   408 
       
   409 // -----------------------------------------------------------------------------
       
   410 //
       
   411 // -----------------------------------------------------------------------------
       
   412 //
       
   413 EXPORT_C TInt CRepository::StartTransaction( TTransactionMode /*aMode*/ )
       
   414     {
       
   415     return KErrNone;
       
   416     }
       
   417     
       
   418     
       
   419 /// -----------------------------------------------------------------------------
       
   420 //
       
   421 // -----------------------------------------------------------------------------
       
   422 //
       
   423 EXPORT_C TInt CRepository::CommitTransaction(TUint32& /*aKeyInfo*/)
       
   424     {
       
   425     return KErrNone;
       
   426     }
       
   427        
       
   428 
       
   429 
       
   430 // ------- Functions that are not present in real CRepository but are ----------
       
   431 // ------- defined here exclusively for stubbing purposes             ----------  
       
   432     
       
   433 // -----------------------------------------------------------------------------
       
   434 //
       
   435 // -----------------------------------------------------------------------------
       
   436 //
       
   437 void CRepository::ResetKeysAndValues()
       
   438     {
       
   439     CSipSseTestTls* repository = CSipSseTestTls::Storage();
       
   440     if ( repository )
       
   441         {
       
   442         repository->Reset();
       
   443         }
       
   444     }
       
   445   
       
   446     
       
   447 // -----------------------------------------------------------------------------
       
   448 //
       
   449 // -----------------------------------------------------------------------------
       
   450 //
       
   451 CRepository::CRepository( TUid aRepositoryUid )
       
   452     :iRepositoryUid( aRepositoryUid )
       
   453     {
       
   454     }    
       
   455 
       
   456