pnpmobileservices/pnpms/tsrc/src/TestPnpUtilBlocks.cpp
changeset 0 3ce708148e4d
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2 * Copyright (c) 2002 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:      TestPnPUtilBlocks.cpp
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // [INCLUDE FILES] - do not remove
       
    24 #include <e32svr.h>
       
    25 #include <StifParser.h>
       
    26 #include <Stiftestinterface.h>
       
    27 #include "TestPnpUtil.h"
       
    28 #include <ETELMM.H>
       
    29 #include <DocumentHandler.h>
       
    30 #include <e32std.h>
       
    31 
       
    32 // EXTERNAL DATA STRUCTURES
       
    33 //extern  ?external_data;
       
    34 
       
    35 // EXTERNAL FUNCTION PROTOTYPES  
       
    36 
       
    37 // CONSTANTS
       
    38 //const ?type ?constant_var = ?constant;
       
    39 
       
    40 // MACROS
       
    41 //#define ?macro ?macro_def
       
    42 
       
    43 // LOCAL CONSTANTS AND MACROS
       
    44 //#define ?macro_name ?macro_def
       
    45 
       
    46 // MODULE DATA STRUCTURES
       
    47 //enum ?declaration
       
    48 //typedef ?declaration
       
    49 
       
    50 // LOCAL FUNCTION PROTOTYPES
       
    51 
       
    52 // FORWARD DECLARATIONS
       
    53 //class ?FORWARD_CLASSNAME;
       
    54 
       
    55 const static TInt KMaxLength = 256;
       
    56 const static TInt KMinLength = 5;
       
    57 
       
    58 
       
    59 void CTestPnpUtil::Delete() 
       
    60     {
       
    61 
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CTestPnpUtil::RunMethodL
       
    66 // Run specified method. Contains also table of test mothods and their names.
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 TInt CTestPnpUtil::RunMethodL( 
       
    70     CStifItemParser& aItem ) 
       
    71     {
       
    72 
       
    73    TStifFunctionInfo const KFunctions[] =
       
    74         {  
       
    75         // Copy this line for every implemented function.
       
    76         // First string is the function name used in TestScripter script file.
       
    77         // Second is the actual implementation member function. 
       
    78         
       
    79         ENTRY( "PnPUtilNewL", CTestPnpUtil::PnPUtilNewL ),
       
    80         ENTRY( "PnPUtilNewLC", CTestPnpUtil::PnPUtilNewLC ),
       
    81         ENTRY( "PnPUtilVersionL", CTestPnpUtil::PnPUtilVersionL ),
       
    82         ENTRY( "PnPUtilCreateNewTokenL", CTestPnpUtil::PnPUtilCreateNewTokenL ),
       
    83         ENTRY( "PnPUtilGetTokenValidityTimeL", CTestPnpUtil::PnPUtilGetTokenValidityTimeL ),
       
    84         ENTRY( "PnPUtilGetTokenValueL", CTestPnpUtil::PnPUtilGetTokenValueL ),
       
    85         ENTRY( "PnPUtilCreateNewNonceL", CTestPnpUtil::PnPUtilCreateNewNonceL ),
       
    86         ENTRY( "PnPUtilGetNonceValidityTimeL", CTestPnpUtil::PnPUtilGetNonceValidityTimeL ),
       
    87         ENTRY( "PnPUtilGetNonceL", CTestPnpUtil::PnPUtilGetNonceL ),
       
    88         ENTRY( "PnPUtilGetKeyInfoL", CTestPnpUtil::PnPUtilGetKeyInfoL ),
       
    89         ENTRY( "PnPUtilImsiL", CTestPnpUtil::PnPUtilImsiL ),
       
    90         ENTRY( "PnPUtilFetchHomeNetworkInfoL", CTestPnpUtil::PnPUtilFetchHomeNetworkInfoL ),
       
    91         ENTRY( "PnPUtilFetchNetworkInfoL", CTestPnpUtil::PnPUtilFetchNetworkInfoL ),
       
    92         ENTRY( "GetAndSetHomeMccL", CTestPnpUtil::GetAndSetHomeMccL ),
       
    93         ENTRY( "GetAndSetHomeMncL", CTestPnpUtil::GetAndSetHomeMncL ),
       
    94 	ENTRY( "GetAndSetNetworkMccL", CTestPnpUtil::GetAndSetNetworkMccL ),
       
    95         ENTRY( "GetAndSetNetworkMncL", CTestPnpUtil::GetAndSetNetworkMncL ),
       
    96         ENTRY( "PnPUtilRegisteredInHomeNetworkL", CTestPnpUtil::PnPUtilRegisteredInHomeNetworkL ),
       
    97         ENTRY( "PnPUtilOperatorLongNameL", CTestPnpUtil::PnPUtilOperatorLongNameL ),
       
    98         ENTRY( "PnPUtilStoreAccessPointL", CTestPnpUtil::PnPUtilStoreAccessPointL ),
       
    99         ENTRY( "PnPUtilFormatMncCodeL", CTestPnpUtil::PnPUtilFormatMncCodeL ),
       
   100         ENTRY( "ProvNewLC", CTestPnpUtil::ProvNewLC ),
       
   101         ENTRY( "PnpSetApplicationUidL", CTestPnpUtil::PnpSetApplicationUidL ),
       
   102         ENTRY( "PnpGetApplicationUidL", CTestPnpUtil::PnpGetApplicationUidL ),
       
   103         ENTRY( "SetProvAdapvalueL", CTestPnpUtil::SetProvAdapvalueL ),
       
   104         ENTRY( "GetProvAdapvalueL", CTestPnpUtil::GetProvAdapvalueL ),
       
   105         ENTRY( "LaunchOnlineSupportTestL", CTestPnpUtil::LaunchOnlineSupportTestL ),
       
   106         ENTRY( "ConstructUriParamL", CTestPnpUtil::ConstructUriParamL ),
       
   107         ENTRY( "PnPUtilVerifySignatureL", CTestPnpUtil::PnPUtilVerifySignatureL ),
       
   108         ENTRY( "pnpDocHandlerL", CTestPnpUtil::pnpDocHandlerL)
       
   109 	        
       
   110                //ADD NEW ENTRY HERE
       
   111         // [test cases entries] - Do not remove
       
   112 
       
   113         };
       
   114 
       
   115     const TInt count = sizeof( KFunctions ) / 
       
   116                         sizeof( TStifFunctionInfo );
       
   117 
       
   118     return RunInternalL( KFunctions, count, aItem );
       
   119 
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CTestPnpUtil::PnPUtilNewL
       
   124 // (other items were commented in a header).
       
   125 // -----------------------------------------------------------------------------
       
   126 //  
       
   127 TInt CTestPnpUtil::PnPUtilNewL()
       
   128 {
       
   129     CPnpUtilImpl* pnptest = CPnpUtilImpl::NewLC();
       
   130     CleanupStack::PopAndDestroy(pnptest);
       
   131     
       
   132     return KErrNone;
       
   133 }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CTestPnpUtil::PnPUtilNewLC
       
   137 // (other items were commented in a header).
       
   138 // -----------------------------------------------------------------------------
       
   139 // 
       
   140 
       
   141 TInt CTestPnpUtil::PnPUtilNewLC()
       
   142 {
       
   143     CPnpUtilImpl* pnptest = CPnpUtilImpl::NewLC();
       
   144     CleanupStack::PopAndDestroy(pnptest);
       
   145     return KErrNone;
       
   146 }
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CTestPnpUtil::PnPUtilVersionL
       
   150 // (other items were commented in a header).
       
   151 // -----------------------------------------------------------------------------
       
   152 // 
       
   153 TInt CTestPnpUtil::PnPUtilVersionL()
       
   154 {
       
   155 
       
   156     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   157     
       
   158     TBuf<KMaxLength> bufversion;
       
   159     TInt err = pnputil -> Version(bufversion);
       
   160     
       
   161     TBuf<KMinLength> bufversionmin;
       
   162     TInt err1 = pnputil -> Version(bufversionmin);
       
   163     
       
   164     
       
   165     CleanupStack::PopAndDestroy(pnputil);
       
   166     
       
   167     if(err == KErrNone && err1 == KErrArgument)
       
   168     return KErrNone;
       
   169     else
       
   170     return KErrGeneral;
       
   171 }
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // CTestPnpUtil::PnPUtilCreateNewTokenL
       
   175 // (other items were commented in a header).
       
   176 // -----------------------------------------------------------------------------
       
   177 // 
       
   178 TInt CTestPnpUtil::PnPUtilCreateNewTokenL()
       
   179 {
       
   180 
       
   181 
       
   182     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   183     
       
   184     TInt timevalid = 0;
       
   185     TInt timeinvalid = 999999; 
       
   186     
       
   187     TInt token;
       
   188     TInt err = pnputil -> CreateNewToken(timevalid, token);
       
   189     
       
   190     TInt tokeninvalid;
       
   191     TInt err1 = pnputil -> CreateNewToken(timeinvalid, tokeninvalid);
       
   192     
       
   193     CleanupStack::PopAndDestroy(pnputil);
       
   194     
       
   195     if(err == KErrNone && err1 == KErrArgument)
       
   196     return KErrNone;
       
   197     else
       
   198     return KErrGeneral;
       
   199 }
       
   200 
       
   201 // -----------------------------------------------------------------------------
       
   202 // CTestPnpUtil::PnPUtilGetTokenValidityTimeL
       
   203 // (other items were commented in a header).
       
   204 // -----------------------------------------------------------------------------
       
   205 // 
       
   206 TInt CTestPnpUtil::PnPUtilGetTokenValidityTimeL()
       
   207 {
       
   208     
       
   209     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   210     
       
   211     const TInt KTokenValidityTime = 600;
       
   212     
       
   213     TInt tokenvalidaitytime = pnputil -> GetTokenValidityTime();
       
   214     
       
   215     CleanupStack::PopAndDestroy(pnputil);
       
   216     
       
   217     if(tokenvalidaitytime == KTokenValidityTime)
       
   218     return KErrNone;
       
   219     else
       
   220     return KErrGeneral;
       
   221     
       
   222     
       
   223 }
       
   224 
       
   225 
       
   226 // -----------------------------------------------------------------------------
       
   227 // CTestPnpUtil::PnPUtilGetTokenValueL
       
   228 // (other items were commented in a header).
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 TInt CTestPnpUtil::PnPUtilGetTokenValueL()
       
   232 {
       
   233 
       
   234 
       
   235     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   236     
       
   237     TInt tokenval;
       
   238     TInt timevalid = 600;
       
   239     TInt token;
       
   240     TInt err = pnputil -> CreateNewToken(timevalid, token);
       
   241     
       
   242     err = pnputil ->GetTokenValue(tokenval);
       
   243     
       
   244     CleanupStack::PopAndDestroy(pnputil);
       
   245     
       
   246     return err;  
       
   247 }
       
   248 
       
   249 // -----------------------------------------------------------------------------
       
   250 // CTestPnpUtil::PnPUtilCreateNewNonceL
       
   251 // (other items were commented in a header).
       
   252 // -----------------------------------------------------------------------------
       
   253 //
       
   254 TInt CTestPnpUtil::PnPUtilCreateNewNonceL()
       
   255 {
       
   256 
       
   257 
       
   258     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   259 
       
   260     TUint32 timeout =0;
       
   261     TBuf8<KMaxLength> bufversion;
       
   262     TRAPD( err, pnputil -> CreateNewNonceL(timeout, bufversion));
       
   263     
       
   264     TBuf8<KMinLength> bufversionmin;
       
   265     TRAPD (err1 , pnputil -> CreateNewNonceL(timeout, bufversionmin));
       
   266     
       
   267     
       
   268     CleanupStack::PopAndDestroy(pnputil);
       
   269     
       
   270     if(err == KErrNone && err1 == KErrArgument)
       
   271     return KErrNone;
       
   272     else
       
   273     return KErrGeneral;
       
   274 }
       
   275 
       
   276 // -----------------------------------------------------------------------------
       
   277 // CTestPnpUtil::PnPUtilGetNonceValidityTimeL
       
   278 // (other items were commented in a header).
       
   279 // -----------------------------------------------------------------------------
       
   280 //
       
   281 TInt CTestPnpUtil::PnPUtilGetNonceValidityTimeL()
       
   282 {
       
   283     
       
   284     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   285     
       
   286     TRAPD(err, pnputil->GetNonceValidityTimeL());
       
   287     
       
   288     CleanupStack::PopAndDestroy(pnputil);
       
   289     
       
   290     if(err == KErrNotSupported)
       
   291     return KErrNone;
       
   292     else
       
   293     return KErrGeneral;
       
   294     
       
   295     
       
   296 }
       
   297 
       
   298 // -----------------------------------------------------------------------------
       
   299 // CTestPnpUtil::PnPUtilGetNonceL
       
   300 // (other items were commented in a header).
       
   301 // -----------------------------------------------------------------------------
       
   302 //
       
   303 TInt CTestPnpUtil::PnPUtilGetNonceL()
       
   304 {
       
   305 
       
   306 
       
   307     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   308     
       
   309     TBuf8<KMaxLength> nonce;
       
   310     TRAPD(err, pnputil->GetNonceL(nonce));
       
   311     
       
   312     TBuf8<KMinLength> nonce1;
       
   313     TRAPD(err1, pnputil->GetNonceL(nonce1));
       
   314     
       
   315     CleanupStack::PopAndDestroy(pnputil);
       
   316     
       
   317     if(err==KErrNone && err1==KErrArgument)
       
   318     return KErrNone;
       
   319     else
       
   320     return KErrGeneral;
       
   321 }
       
   322 
       
   323 // -----------------------------------------------------------------------------
       
   324 // CTestPnpUtil::PnPUtilGetKeyInfoL
       
   325 // (other items were commented in a header).
       
   326 // -----------------------------------------------------------------------------
       
   327 //
       
   328 TInt CTestPnpUtil::PnPUtilGetKeyInfoL()
       
   329 {
       
   330 
       
   331     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   332     
       
   333     TBuf8<KMaxLength> key;
       
   334     TRAPD(err, pnputil->GetKeyInfoL(key));
       
   335     
       
   336     TBuf8<KMinLength> key1;
       
   337     TRAPD(err1, pnputil->GetKeyInfoL(key1));
       
   338     
       
   339     CleanupStack::PopAndDestroy(pnputil);
       
   340     
       
   341     if(err == KErrNone && err1 == KErrArgument)
       
   342     return KErrNone;
       
   343     else
       
   344     return KErrGeneral;
       
   345 }
       
   346 
       
   347 // -----------------------------------------------------------------------------
       
   348 // CTestPnpUtil::PnPUtilImsiL
       
   349 // (other items were commented in a header).
       
   350 // -----------------------------------------------------------------------------
       
   351 //
       
   352 TInt CTestPnpUtil::PnPUtilImsiL()
       
   353 {
       
   354     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   355     
       
   356     RMobilePhone::TMobilePhoneSubscriberId aImsi;
       
   357     
       
   358     TRAPD(err, pnputil->ImsiL(aImsi));
       
   359     
       
   360     CleanupStack::PopAndDestroy(pnputil);
       
   361     
       
   362     return err;
       
   363     
       
   364 }
       
   365 
       
   366 
       
   367 // -----------------------------------------------------------------------------
       
   368 // CTestPnpUtil::PnPUtilFetchHomeNetworkInfoL
       
   369 // (other items were commented in a header).
       
   370 // -----------------------------------------------------------------------------
       
   371 //
       
   372 TInt CTestPnpUtil::PnPUtilFetchHomeNetworkInfoL()
       
   373 {
       
   374     
       
   375     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   376     
       
   377     TRAPD(err, pnputil->FetchHomeNetworkInfoL());
       
   378     
       
   379     CleanupStack::PopAndDestroy(pnputil);
       
   380     
       
   381     return err;
       
   382 }
       
   383 
       
   384 
       
   385 // -----------------------------------------------------------------------------
       
   386 // CTestPnpUtil::PnPUtilFetchNetworkInfoL
       
   387 // (other items were commented in a header).
       
   388 // -----------------------------------------------------------------------------
       
   389 //
       
   390 TInt CTestPnpUtil::PnPUtilFetchNetworkInfoL()
       
   391 {
       
   392     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   393     
       
   394         TRAPD(err, pnputil->FetchNetworkInfoL());
       
   395     
       
   396     CleanupStack::PopAndDestroy(pnputil);
       
   397     return err;
       
   398  }
       
   399 
       
   400 
       
   401 // -----------------------------------------------------------------------------
       
   402 // CTestPnpUtil::GetAndSetHomeMccL
       
   403 // (other items were commented in a header).
       
   404 // -----------------------------------------------------------------------------
       
   405 //
       
   406 TInt CTestPnpUtil::GetAndSetHomeMccL()
       
   407 {
       
   408     
       
   409     
       
   410     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   411     
       
   412     RMobilePhone::TMobilePhoneNetworkInfoV1 info;
       
   413     RMobilePhone::TMobilePhoneNetworkInfoV1Pckg infoPckg( info );
       
   414 
       
   415     info.iCountryCode.Copy( _L("244") );
       
   416     
       
   417     TRAPD(err, pnputil->SetHomeMccL( info.iCountryCode ));
       
   418     if(err!=KErrNone)
       
   419     return err;
       
   420     
       
   421     RMobilePhone::TMobilePhoneNetworkCountryCode getmcc;
       
   422     
       
   423     TRAPD(err1, getmcc = pnputil->HomeMccL());    
       
   424     
       
   425     CleanupStack::PopAndDestroy(pnputil);
       
   426     
       
   427     if(err1!=KErrNone)
       
   428     return err1;
       
   429     
       
   430     if(info.iCountryCode == getmcc)
       
   431     return KErrNone;
       
   432     else
       
   433     return KErrGeneral;
       
   434 }
       
   435 
       
   436 
       
   437 // -----------------------------------------------------------------------------
       
   438 // CTestPnpUtil::GetAndSetHomeMncL
       
   439 // (other items were commented in a header).
       
   440 // -----------------------------------------------------------------------------
       
   441 //
       
   442 TInt CTestPnpUtil::GetAndSetHomeMncL()
       
   443 {
       
   444 
       
   445     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   446     
       
   447     RMobilePhone::TMobilePhoneNetworkInfoV1 info;
       
   448     RMobilePhone::TMobilePhoneNetworkInfoV1Pckg infoPckg( info );
       
   449 
       
   450     info.iNetworkId.Copy( _L("05") );
       
   451     
       
   452     TRAPD(err, pnputil->SetHomeMncL( info.iNetworkId));
       
   453     if(err!=KErrNone)
       
   454     return err;
       
   455     
       
   456     
       
   457     RMobilePhone::TMobilePhoneNetworkIdentity getmnc;
       
   458     TRAP(err, getmnc = pnputil->HomeMncL());    
       
   459     
       
   460     
       
   461     CleanupStack::PopAndDestroy(pnputil);
       
   462     
       
   463     if(err!=KErrNone)
       
   464     return err;
       
   465     
       
   466     if(info.iNetworkId == getmnc)
       
   467     return KErrNone;
       
   468     else
       
   469     return KErrGeneral;
       
   470 }
       
   471 
       
   472 // -----------------------------------------------------------------------------
       
   473 // CTestPnpUtil::GetAndSetNetworkMccL
       
   474 // (other items were commented in a header).
       
   475 // -----------------------------------------------------------------------------
       
   476 //
       
   477 TInt CTestPnpUtil::GetAndSetNetworkMccL()
       
   478 {
       
   479 
       
   480     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   481 
       
   482     RMobilePhone::TMobilePhoneNetworkInfoV1 info;
       
   483     RMobilePhone::TMobilePhoneNetworkInfoV1Pckg infoPckg( info );
       
   484 
       
   485     info.iCountryCode.Copy( _L("244") );
       
   486     
       
   487     TRAPD(err, pnputil->SetNetworkMccL( info.iCountryCode ));
       
   488     if(err!=KErrNone)
       
   489     return err;
       
   490     
       
   491     RMobilePhone::TMobilePhoneNetworkCountryCode getmcc;
       
   492     TRAP(err, getmcc = pnputil->NetworkMccL());    
       
   493     
       
   494     CleanupStack::PopAndDestroy(pnputil);
       
   495     
       
   496     if(err!=KErrNone)
       
   497     return err;
       
   498     
       
   499     if(info.iCountryCode == getmcc)
       
   500     return KErrNone;
       
   501     else
       
   502     return KErrGeneral;
       
   503 }
       
   504 
       
   505 // -----------------------------------------------------------------------------
       
   506 // CTestPnpUtil::GetAndSetNetworkMncL
       
   507 // (other items were commented in a header).
       
   508 // -----------------------------------------------------------------------------
       
   509 //
       
   510 TInt CTestPnpUtil::GetAndSetNetworkMncL()
       
   511 {
       
   512     
       
   513     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   514     
       
   515     RMobilePhone::TMobilePhoneNetworkInfoV1 info;
       
   516     RMobilePhone::TMobilePhoneNetworkInfoV1Pckg infoPckg( info );
       
   517 
       
   518     info.iNetworkId.Copy( _L("05") );
       
   519     
       
   520     TRAPD(err, pnputil->SetNetworkMncL( info.iNetworkId));
       
   521     if(err!=KErrNone)
       
   522     return err;
       
   523     
       
   524     RMobilePhone::TMobilePhoneNetworkIdentity getmnc;
       
   525     TRAP(err, getmnc = pnputil->NetworkMncL());   
       
   526     
       
   527     CleanupStack::PopAndDestroy(pnputil);
       
   528      
       
   529     if(err!=KErrNone)
       
   530     return err;
       
   531     
       
   532     if(info.iNetworkId == getmnc)
       
   533     return KErrNone;
       
   534     else
       
   535     return KErrGeneral;
       
   536 }
       
   537 
       
   538 // -----------------------------------------------------------------------------
       
   539 // CTestPnpUtil::GetAndSetNetworkMncL
       
   540 // (other items were commented in a header).
       
   541 // -----------------------------------------------------------------------------
       
   542 //
       
   543 TInt CTestPnpUtil::PnPUtilRegisteredInHomeNetworkL()
       
   544 {
       
   545 
       
   546     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   547 
       
   548     TRAPD(err, pnputil->RegisteredInHomeNetworkL());
       
   549     
       
   550     CleanupStack::PopAndDestroy(pnputil);
       
   551     
       
   552     if(err!=KErrNone)
       
   553     return err;
       
   554     
       
   555     return KErrNone;
       
   556 }
       
   557 
       
   558 // -----------------------------------------------------------------------------
       
   559 // CTestPnpUtil::OperatorLongNameL
       
   560 // (other items were commented in a header).
       
   561 // -----------------------------------------------------------------------------
       
   562 //
       
   563 TInt CTestPnpUtil::PnPUtilOperatorLongNameL()
       
   564 {
       
   565     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   566 
       
   567     RMobilePhone::TMobilePhoneNetworkLongName name(KNullDesC);
       
   568     TInt err = pnputil->OperatorLongName(name);
       
   569     
       
   570     CleanupStack::PopAndDestroy(pnputil);
       
   571     
       
   572     if(err!=KErrNone || name.Compare(KNullDesC)!=0)
       
   573     return err;
       
   574     
       
   575     return KErrNone;
       
   576 }
       
   577 
       
   578 // -----------------------------------------------------------------------------
       
   579 // CTestPnpUtil::OperatorLongNameL
       
   580 // (other items were commented in a header).
       
   581 // -----------------------------------------------------------------------------
       
   582 //
       
   583 TInt CTestPnpUtil::PnPUtilStoreAccessPointL()
       
   584 {
       
   585 
       
   586     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   587     
       
   588     TUint32 value =0;
       
   589     TInt err = pnputil->StoreAccessPoint(value);
       
   590     
       
   591     CleanupStack::PopAndDestroy(pnputil);
       
   592     
       
   593     if(err == KErrNotSupported)
       
   594     return KErrNone;
       
   595     else
       
   596     return err;
       
   597 }
       
   598 
       
   599 
       
   600 // -----------------------------------------------------------------------------
       
   601 // CTestPnpUtil::PnPUtilFormatMncCodeL
       
   602 // (other items were commented in a header).
       
   603 // -----------------------------------------------------------------------------
       
   604 //
       
   605 TInt CTestPnpUtil::PnPUtilFormatMncCodeL()
       
   606 {
       
   607    CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   608    
       
   609     RMobilePhone::TMobilePhoneNetworkInfoV1 info;
       
   610     RMobilePhone::TMobilePhoneNetworkInfoV1Pckg infoPckg( info );
       
   611 
       
   612     info.iCountryCode.Copy( _L("244") );
       
   613     info.iNetworkId.Copy( _L("05") );
       
   614 
       
   615 
       
   616     RMobilePhone::TMobilePhoneNetworkIdentity formattedMnc;
       
   617     TRAPD(err, pnputil->FormatMncCodeL( info.iCountryCode, info.iNetworkId, formattedMnc ));
       
   618     
       
   619     CleanupStack::PopAndDestroy(pnputil);
       
   620     
       
   621     if(err!=KErrNone)
       
   622     return err;
       
   623     
       
   624     return KErrNone;
       
   625 }
       
   626 
       
   627 // -----------------------------------------------------------------------------
       
   628 // CTestPnpUtil::ProvNewLC
       
   629 // (other items were commented in a header).
       
   630 // -----------------------------------------------------------------------------
       
   631 //
       
   632 
       
   633 TInt CTestPnpUtil::ProvNewLC()
       
   634     {
       
   635     CPnpProvUtil *prov = CPnpProvUtil::NewLC();
       
   636     CleanupStack::PopAndDestroy(prov);
       
   637 
       
   638     return KErrNone;
       
   639 
       
   640     }
       
   641     
       
   642     
       
   643 // -----------------------------------------------------------------------------
       
   644 // CTestPnpUtil::PnpSetApplicationUidL
       
   645 // (other items were commented in a header).
       
   646 // -----------------------------------------------------------------------------
       
   647 //
       
   648 
       
   649 
       
   650 TInt CTestPnpUtil::PnpSetApplicationUidL()
       
   651 {
       
   652     CPnpProvUtil *prov = CPnpProvUtil::NewLC();
       
   653     TUint32 value = 0x100058C5;
       
   654     
       
   655     prov->SetApplicationUidL(value);
       
   656 
       
   657     CleanupStack::PopAndDestroy(prov);
       
   658 
       
   659     return KErrNone;
       
   660     
       
   661 }
       
   662 
       
   663 
       
   664 // -----------------------------------------------------------------------------
       
   665 // CTestPnpUtil::PnpGetApplicationUidL
       
   666 // (other items were commented in a header).
       
   667 // -----------------------------------------------------------------------------
       
   668 //
       
   669 
       
   670 
       
   671 TInt CTestPnpUtil::PnpGetApplicationUidL()
       
   672 {
       
   673     CPnpProvUtil *prov = CPnpProvUtil::NewLC();
       
   674     TUint32 value = 0x100058C5;
       
   675     TUint32 valuezero = 0;
       
   676     
       
   677     prov->SetApplicationUidL(value);
       
   678 
       
   679     TUint32 retvalue = prov->GetApplicationUidL();
       
   680     
       
   681     prov->SetApplicationUidL(valuezero);
       
   682 
       
   683     TUint32 valueretzero = prov->GetApplicationUidL();
       
   684     
       
   685     
       
   686     CleanupStack::PopAndDestroy(prov);
       
   687 
       
   688     if(retvalue == value && valueretzero == valuezero)
       
   689      return KErrNone;
       
   690     else
       
   691      return KErrGeneral;
       
   692 
       
   693 }
       
   694 
       
   695 // -----------------------------------------------------------------------------
       
   696 // CTestPnpUtil::SetProvAdapvalue
       
   697 // (other items were commented in a header).
       
   698 // -----------------------------------------------------------------------------
       
   699 //
       
   700 
       
   701 
       
   702 
       
   703 TInt CTestPnpUtil::SetProvAdapvalueL()
       
   704 {
       
   705     CPnpProvUtil *prov = CPnpProvUtil::NewLC();
       
   706     
       
   707 
       
   708     _LIT(KNull, "");
       
   709     TBuf<2> buf(KNull);
       
   710 
       
   711     prov->SetProvAdapterAppIdL(buf);
       
   712         
       
   713     _LIT(KName1, "name1");
       
   714     TBuf<KMinLength> buf1(KName1);
       
   715     prov->SetProvAdapterAppIdL(buf1);
       
   716 
       
   717     _LIT(KName2, "name2");
       
   718     TBuf<KMinLength> buf2(KName2);
       
   719     prov->SetProvAdapterAppIdL(buf2);
       
   720 
       
   721     CleanupStack::PopAndDestroy(prov);
       
   722 
       
   723     return KErrNone;
       
   724 
       
   725 }
       
   726 
       
   727 
       
   728 // -----------------------------------------------------------------------------
       
   729 // CTestPnpUtil::GetProvAdapvalue
       
   730 // (other items were commented in a header).
       
   731 // -----------------------------------------------------------------------------
       
   732 //
       
   733 
       
   734 
       
   735 TInt CTestPnpUtil::GetProvAdapvalueL()
       
   736 {
       
   737 
       
   738     CPnpProvUtil *prov = CPnpProvUtil::NewLC();
       
   739     RPointerArray<HBufC> array;
       
   740 
       
   741     TInt flag =0;
       
   742     
       
   743     _LIT(KNull, "");
       
   744     TBuf<2> buf(KNull);
       
   745 
       
   746     prov->SetProvAdapterAppIdL(buf);
       
   747         
       
   748     _LIT(KName1, "name1");
       
   749     TBuf<KMinLength> buf1(KName1);
       
   750     prov->SetProvAdapterAppIdL(buf1);
       
   751 
       
   752     _LIT(KName2, "name2");
       
   753     TBuf<KMinLength> buf2(KName2);
       
   754     prov->SetProvAdapterAppIdL(buf2);
       
   755 
       
   756     prov->GetProvAdapterAppIdsL(array);
       
   757 
       
   758     if(array.Count() == 2)
       
   759     flag = 1;
       
   760 
       
   761     array.ResetAndDestroy();
       
   762     CleanupStack::PopAndDestroy(prov);
       
   763 
       
   764     if(flag == 1)
       
   765      return KErrNone;
       
   766     else
       
   767      return KErrGeneral;     
       
   768 
       
   769 }
       
   770 
       
   771 
       
   772 // -----------------------------------------------------------------------------
       
   773 // CTestPnpUtil::LaunchOnlineSupportTestL
       
   774 // (other items were commented in a header).
       
   775 // -----------------------------------------------------------------------------
       
   776 //
       
   777 
       
   778 
       
   779 TInt CTestPnpUtil::LaunchOnlineSupportTestL()
       
   780 {
       
   781 
       
   782     TBufC<1> Nullval(_L(""));
       
   783       
       
   784     CPnpProvUtil *prov = CPnpProvUtil::NewLC();
       
   785     TRAPD(err, prov->LaunchOnlineSupportL(Nullval, EUserTriggered, 
       
   786                      EStartInteractive,  EFalse, Nullval)); 
       
   787     CleanupStack::PopAndDestroy(prov);
       
   788     
       
   789     if(err!=KErrNone)
       
   790     return err;
       
   791       else
       
   792     return KErrNone;
       
   793 
       
   794 }
       
   795 
       
   796 // -----------------------------------------------------------------------------
       
   797 // CTestPnpUtil::ConstructUriParamL
       
   798 // (other items were commented in a header).
       
   799 // -----------------------------------------------------------------------------
       
   800 //
       
   801 
       
   802 TInt CTestPnpUtil::ConstructUriParamL()
       
   803 {
       
   804     TBuf<1> Nullval(_L(""));    
       
   805 
       
   806     CPnpProvUtil *prov = CPnpProvUtil::NewLC();
       
   807     TRAPD(err, prov->ConstructUriWithPnPUtilL(Nullval, EHelpPortal ));
       
   808 
       
   809     CleanupStack::PopAndDestroy(prov);
       
   810     if(err==KErrNotSupported || err == KErrNone)
       
   811     return KErrNone;
       
   812     else
       
   813     return err;
       
   814 }
       
   815 
       
   816 // -----------------------------------------------------------------------------
       
   817 // CTestPnpUtil::PnPUtilVerifySignatureL
       
   818 // (other items were commented in a header).
       
   819 // -----------------------------------------------------------------------------
       
   820 //
       
   821 
       
   822 
       
   823 TInt CTestPnpUtil::PnPUtilVerifySignatureL()
       
   824 {
       
   825      
       
   826     CPnpUtilImpl* pnputil = CPnpUtilImpl::NewLC();
       
   827    
       
   828    _LIT8(KDigestvalue,"S7jZw+uR9yT70PpcFehwmonmSBI=");
       
   829    _LIT8(KSignatureValue,"XnbpqUL6UPdxDOPJ3+htw1vBwKiND13ttYMdjWnUqC039ftsI3pFqbQkl017xJlw+3F00PHsyhtQkSGQAZFxrCNp9lIStAv1qjcfR3ltLBUcAuHNviAzC2qcnvjJ4gMNtgyrr8sE0IFRwHWV9sNRkqC0CGVmK6amUHFtuplZeLw=");
       
   830    _LIT8(KData,"");
       
   831    _LIT8(KNonce,"iP674Twe");
       
   832     
       
   833    TRAPD(err, pnputil->VerifySignatureL(KDigestvalue,KSignatureValue, KData, KNonce ));
       
   834    CleanupStack::PopAndDestroy();
       
   835    
       
   836    if(err!=KErrNone)
       
   837    return KErrGeneral;
       
   838    else
       
   839    return KErrNone;
       
   840    
       
   841 }
       
   842 
       
   843 // -----------------------------------------------------------------------------
       
   844 // CTestPnpUtil::pnpDocHandlerL
       
   845 // (other items were commented in a header).
       
   846 // -----------------------------------------------------------------------------
       
   847 //
       
   848 
       
   849 TInt CTestPnpUtil::pnpDocHandlerL() 
       
   850     
       
   851     {
       
   852      
       
   853     _LIT8(KPnPContentType, "application/vnd.nokia.headwrapper" );
       
   854     _LIT(Kfn,"C:\\data\\Pnpprovisioningfile");
       
   855 
       
   856     RFs fs;
       
   857     User::LeaveIfError(fs.Connect());
       
   858     CleanupClosePushL(fs);
       
   859     TInt err = fs.MkDir( Kfn);
       
   860 
       
   861     if( err != KErrNone && err != KErrAlreadyExists )
       
   862         {
       
   863         User::Leave( err ); 
       
   864         }
       
   865 
       
   866     RFile file;
       
   867     TPtrC8 dataChunk;
       
   868  
       
   869     TFileName fullPath(Kfn);
       
   870     RFile sharableFile;
       
   871     
       
   872     
       
   873     CDocumentHandler *iDocHandler = CDocumentHandler::NewLC();
       
   874      
       
   875     iDocHandler->OpenTempFileL(fullPath, sharableFile);
       
   876     
       
   877     TBool ret(EFalse);
       
   878     TDataType dataType(KPnPContentType);
       
   879     ret = iDocHandler->OpenFileEmbeddedL(sharableFile,dataType);
       
   880     
       
   881     CleanupClosePushL(file);
       
   882     CleanupClosePushL(sharableFile);
       
   883     
       
   884     
       
   885     CleanupStack::Pop(&sharableFile);
       
   886     CleanupStack::Pop(&file);
       
   887     CleanupStack::PopAndDestroy(iDocHandler);
       
   888     CleanupStack::Pop(&fs);
       
   889     
       
   890     
       
   891     if(ret==KErrNone)
       
   892     return KErrNone;
       
   893     else
       
   894     return KErrGeneral;
       
   895 }
       
   896