realtimenetprots/sipfw/SampleApp/gameUI_techview/Src/SIPExProfileQueryDlg.cpp
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 
       
     2 // Copyright (c) 2005-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:
       
    15 //
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include    "SIPExProfileQueryDlg.h"
       
    21 #include    "SIPEx.hrh"
       
    22 #include    <sipex.rsg>
       
    23 #include    <eikenv.h>
       
    24 #include 	<eikchlst.h>
       
    25 #include    <uri8.h>
       
    26 #include    <commdb.h>
       
    27 #include    "ProfileUtil.h"
       
    28 
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CSIPExProfileQueryDlg::NewL
       
    32 // Creates the class instance and returns it.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CSIPExProfileQueryDlg* CSIPExProfileQueryDlg::NewL()
       
    36     {
       
    37     CSIPExProfileQueryDlg* self = NewLC();
       
    38     CleanupStack::Pop( self );
       
    39     return self;
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CSIPExProfileQueryDlg::NewLC
       
    44 // Creates the class instance and returns it.
       
    45 // On return the instance is left to the CleanupStack.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CSIPExProfileQueryDlg* CSIPExProfileQueryDlg::NewLC( )
       
    49     {
       
    50     CSIPExProfileQueryDlg* self = new (ELeave) CSIPExProfileQueryDlg();
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     return self;
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CSIPExProfileQueryDlg::CSIPExProfileQueryDlg
       
    58 // C++ default constructor.
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CSIPExProfileQueryDlg::CSIPExProfileQueryDlg()
       
    62     {
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CSIPExProfileQueryDlg::~CSIPExProfileQueryDlg
       
    67 // Desctructor.
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 CSIPExProfileQueryDlg::~CSIPExProfileQueryDlg()
       
    71     {
       
    72     delete iMProfileRegistry;
       
    73 	iAPsUIDs.Close();
       
    74 	
       
    75 	delete iNewProfile;
       
    76     }
       
    77     
       
    78 // -----------------------------------------------------------------------------
       
    79 // CSIPExProfileQueryDlg::ProfileRegistryEventOccurred
       
    80 // SIP profile event 
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 void CSIPExProfileQueryDlg::ProfileRegistryEventOccurred(TUint32 aProfileId, TEvent aEvent)
       
    84 	{
       
    85 	switch(aEvent)	
       
    86 		{
       
    87 		case EProfileCreated:
       
    88 			ProfileCreated(aProfileId);
       
    89 			break;
       
    90 		case EProfileUpdated:	
       
    91 		case EProfileRegistered:						
       
    92 		case EProfileDeregistered:
       
    93 		case EProfileDestroyed:
       
    94 		default:
       
    95 				//don't know what to do . Nothing can be done !!!
       
    96 			break;
       
    97 		}
       
    98 	}
       
    99     
       
   100 // -----------------------------------------------------------------------------
       
   101 // CSIPExProfileQueryDlg::ProfileRegistryErrorOccured
       
   102 // An asynchronous error has occurred related to SIP profile
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CSIPExProfileQueryDlg::ProfileRegistryErrorOccurred(				    
       
   106 	TUint32 /*aSIPProfileId*/,
       
   107 	TInt /*aError*/)
       
   108     {  
       
   109     //TInt err = aError;  
       
   110     //TUint32 profId = aSIPProfileId;
       
   111     }
       
   112 
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CSIPExProfileQueryDlg::ProfileCreated
       
   116 // SIP profile creation event 
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 void CSIPExProfileQueryDlg::ProfileCreated( TUint32 aSIPProfileId )
       
   120     {   
       
   121     CSIPManagedProfile* profile = NULL;
       
   122     TUint32 profileId = 0;
       
   123     if(iNewProfile)
       
   124     	{
       
   125     	TInt err= iNewProfile->GetParameter(KSIPProfileId,profileId);
       
   126     	if(err)	
       
   127     		{
       
   128     			//don't know what to do . perhaps nothing can be done 
       
   129     			return ;
       
   130     		}
       
   131     	}
       
   132     if ( iNewProfile && aSIPProfileId == profileId )
       
   133         {
       
   134         profile = iNewProfile;
       
   135         iNewProfile = NULL;
       
   136         }
       
   137     else
       
   138         {
       
   139         // Some other application has created a new profile
       
   140          TRAPD( err, profile = static_cast<CSIPManagedProfile*>( 
       
   141                         iMProfileRegistry->ProfileL( aSIPProfileId ) ) );
       
   142         if ( err )
       
   143             {
       
   144             // Can't fetch the new profile - nothing to do
       
   145             return;
       
   146             }
       
   147         }
       
   148 
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // CSIPExProfileQueryDlg::ConstructL
       
   153 // Symbian 2nd phase constructor that might leave.
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 void CSIPExProfileQueryDlg::ConstructL()
       
   157     {
       
   158    	iMProfileRegistry = CSIPManagedProfileRegistry::NewL( *this );
       
   159 
       
   160     FillDataStructWithDefaultValsL();
       
   161     }
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // CSIPExProfileQueryDlg::ProfileData
       
   165 // Saves profile to persistent storage
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 void CSIPExProfileQueryDlg::SaveProfileL()
       
   169     {
       
   170     // Need to create a new profile
       
   171     CSIPManagedProfile* profile = 
       
   172     				iMProfileRegistry->CreateL(iProfileData.iServiceProfile);
       
   173     CleanupStack::PushL( profile );
       
   174 
       
   175 	// Copy attributes to the new profile        
       
   176     iNewProfile = profile;
       
   177     profile = CopyDataToProfileL();
       
   178 
       
   179 	// Set the profile to be default and save sum' settings
       
   180     TInt err= profile->SetParameter(KSIPDefaultProfile,ETrue);
       
   181     User::LeaveIfError(err);
       
   182 
       
   183     // Save the profile to persistent storage                
       
   184     iMProfileRegistry->SaveL( *profile );
       
   185     
       
   186     HBufC* txt = iEikonEnv->AllocReadResourceLC( R_PROFILE_SAVED );
       
   187     CEikonEnv::Static()->InfoMsg( txt->Des() );
       
   188     CleanupStack::PopAndDestroy( txt );
       
   189             
       
   190     CleanupStack::Pop();    // profile
       
   191    	}
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CSIPExProfileQueryDlg::CopyDataToProfileL
       
   195 // Copies data from temporary settings structure to profile
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 CSIPManagedProfile* CSIPExProfileQueryDlg::CopyDataToProfileL()
       
   199     {
       
   200     CSIPManagedProfile* profile = iNewProfile;
       
   201         
       
   202 
       
   203     ProfileUtil::CopyProfileAttributesL( profile, iProfileData );
       
   204     ProfileUtil::CopyServerAttributesL( 
       
   205         profile, KSIPOutboundProxy, iProfileData.iProxy );
       
   206     ProfileUtil::CopyServerAttributesL( 
       
   207         profile, KSIPRegistrar, iProfileData.iRegistrar );
       
   208     
       
   209     return profile;
       
   210     }
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // CSIPExProfileQueryDlg::PreLayoutDynInitL
       
   214 // From CEikDialog. Initializes the dialog's text control with default address
       
   215 // if available.
       
   216 // -----------------------------------------------------------------------------
       
   217 //
       
   218 void CSIPExProfileQueryDlg::PreLayoutDynInitL()
       
   219     {
       
   220     if ( iProfileData.iUsername.Length() > 0 )
       
   221         {
       
   222         ( static_cast<CEikEdwin*>( 
       
   223             Control( EItemUsername ) ) )->SetTextL( &iProfileData.iUsername );
       
   224         }
       
   225     if ( iProfileData.iProxy.iAddress.Length() > 0 )
       
   226         {
       
   227         ( static_cast<CEikEdwin*>( 
       
   228             Control( EProxyServerItemAddr ) ) )->SetTextL( &iProfileData.iProxy.iAddress );
       
   229         }
       
   230     if ( iProfileData.iRegistrar.iAddress.Length() > 0 )
       
   231         {
       
   232         ( static_cast<CEikEdwin*>( 
       
   233             Control( ERegistrarServerItemAddr ) ) )->SetTextL( &iProfileData.iRegistrar.iAddress );
       
   234         }
       
   235     // create accesspointid list
       
   236     
       
   237     CEikChoiceList* choiceList = static_cast<CEikChoiceList*>(Control(EItemAccesspointid));
       
   238 	
       
   239 	GetAPListL();
       
   240 
       
   241     choiceList->SetArrayL(static_cast<MDesCArray*>(iAccesspointids));
       
   242     
       
   243     }
       
   244 
       
   245 // -----------------------------------------------------------------------------
       
   246 // CSIPExProfileQueryDlg::OkToExitL
       
   247 // From CEikDialog.
       
   248 // Validates the given address and if not correct notifies user with info
       
   249 // message.
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 TBool CSIPExProfileQueryDlg::OkToExitL( TInt aKeyCode )
       
   253     {
       
   254     TBool isOk( ETrue );
       
   255     
       
   256     if ( aKeyCode == EEikBidOk )
       
   257         {
       
   258         if ( !SetProfileUserNameL( ))
       
   259         	{
       
   260         	ShowErrorInfoL(EItemUsername);
       
   261         	isOk = EFalse;
       
   262         	}
       
   263     	if ( !SetProfileCompressionL())
       
   264     		{
       
   265         	ShowErrorInfoL(EItemCompression);
       
   266         	isOk = EFalse;
       
   267         	}
       
   268     	if ( !SetProfileSecurityL())
       
   269     		{
       
   270         	ShowErrorInfoL(EItemSecurity);
       
   271         	isOk = EFalse;
       
   272         	}
       
   273         if ( !SetProfileIAPIdL())
       
   274         	{
       
   275         	ShowErrorInfoL(EItemAccesspointid);
       
   276         	isOk = EFalse;
       
   277         	}
       
   278     	if ( !SetProfileProxyAddressL() || !SetProfileProxyRealmL()
       
   279     		|| !SetProfileProxyUNameL() || !SetProfileProxyPwL() )
       
   280     		{
       
   281         	ShowErrorInfoL(EItemProxyServer);
       
   282         	isOk = EFalse;
       
   283         	}
       
   284     	if ( !SetProfileRegistrarAddressL() || !SetProfileRegistrarRealmL()
       
   285     		|| !SetProfileRegistrarUNameL() || !SetProfileRegistrarPwL() )
       
   286     		{
       
   287         	ShowErrorInfoL(EItemRegistrarServer);
       
   288         	isOk = EFalse;
       
   289         	}
       
   290     	if (isOk)
       
   291     		{
       
   292     		SaveProfileL();	
       
   293     		}
       
   294     	}
       
   295     else //if (aKeyCode == EEikBidCancel )
       
   296     	{
       
   297     	}
       
   298        
       
   299     return isOk;
       
   300     }
       
   301     
       
   302 // -----------------------------------------------------------------------------
       
   303 // CSIPExProfileQueryDlg::FillDataStructWithDefaultValsL()
       
   304 // Fills the data structures fields with default values
       
   305 // -----------------------------------------------------------------------------
       
   306 //
       
   307 void CSIPExProfileQueryDlg::FillDataStructWithDefaultValsL()
       
   308 	{
       
   309     CEikonEnv* env = CEikonEnv::Static();
       
   310     
       
   311     iProfileData.iProviderName = 
       
   312         env->AllocReadResourceLC( R_SIP_EX_DEF_PROFILE_NAME )->Des();    
       
   313     CleanupStack::PopAndDestroy();  // providerName    
       
   314 	
       
   315 	iProfileData.iID = KUnknownProfileIndex;
       
   316     iProfileData.iAPIndex = KDefaultIAP;
       
   317     iProfileData.iCompression = KDefaultCompression;
       
   318     iProfileData.iRegistrationMode = KDefaultRegistration;
       
   319     iProfileData.iSecurity = KDefaultSecurity;
       
   320 
       
   321     iProfileData.iUsername = 
       
   322         env->AllocReadResourceLC( R_SIP_EX_DEF_USERNAME )->Des();     
       
   323     CleanupStack::PopAndDestroy();  // userName
       
   324     
       
   325     RArray<TSIPProfileTypeInfo> typeArray;
       
   326     CleanupClosePushL( typeArray );    
       
   327     // Get the supported profile types
       
   328     iMProfileRegistry->SupportedProfileTypesL( typeArray );
       
   329 
       
   330     if ( typeArray.Count() > 0 )
       
   331         {
       
   332         iProfileData.iServiceProfile = typeArray[0];
       
   333         }
       
   334     else
       
   335         {        
       
   336         User::Leave( KErrNotFound );
       
   337         }
       
   338     CleanupStack::PopAndDestroy();  // typeArray
       
   339     
       
   340     
       
   341     iProfileData.iProxy.iAddress = 
       
   342         env->AllocReadResourceLC( R_SIP_EX_DEF_SERVER_ADDRESS )->Des();
       
   343     CleanupStack::PopAndDestroy();  // addr               
       
   344     
       
   345     iProfileData.iProxy.iRealm = KEmptyString;
       
   346     
       
   347     iProfileData.iProxy.iUsername = KEmptyString;
       
   348 
       
   349     iProfileData.iProxy.iLooseRouting = KDefaultLooseRouting;
       
   350     iProfileData.iProxy.iPassword = KEmptyString;
       
   351     iProfileData.iProxy.iPortNumber = KDefaultPortNumber;
       
   352     iProfileData.iProxy.iTransportProtocol = KDefaultTranspProtocol;
       
   353 
       
   354     // Initial registrar server settings are the same than with proxy
       
   355     iProfileData.iRegistrar = iProfileData.iProxy;      
       
   356     iProfileData.iRegistrar.iLooseRouting = ELooseRoutingOff;  	
       
   357 	}
       
   358 		
       
   359 // -----------------------------------------------------------------------------
       
   360 // CSIPExProfileQueryDlg::SetProfileUserNameL
       
   361 // Sets iPublicUName from CEikDialog .
       
   362 // -----------------------------------------------------------------------------
       
   363 //
       
   364 TBool CSIPExProfileQueryDlg::SetProfileUserNameL( )
       
   365 	{
       
   366 	TBool isOk( ETrue );
       
   367     ( static_cast< CEikEdwin* >( 
       
   368     				Control( EItemUsername ) ) )->GetText( iProfileData.iUsername );
       
   369 
       
   370     // Check the validity of the given address
       
   371    // TInt err( KErrGeneral );
       
   372         
       
   373     HBufC8* address = HBufC8::NewLC( iProfileData.iUsername.Length() );
       
   374     address->Des().Copy( iProfileData.iUsername );
       
   375         
       
   376     CleanupStack::PopAndDestroy( address );
       
   377     return isOk;
       
   378 	}
       
   379 
       
   380 // -----------------------------------------------------------------------------
       
   381 // CSIPExProfileQueryDlg::SetProfileCompressionL
       
   382 // Sets iCompression from CEikDialog .
       
   383 // -----------------------------------------------------------------------------
       
   384 //
       
   385 TBool CSIPExProfileQueryDlg::SetProfileCompressionL( )
       
   386 	{
       
   387 	TBool isOk( ETrue );
       
   388     iProfileData.iCompression = ( static_cast< CEikChoiceList* >( 
       
   389     				Control( EItemCompression ) ) )->CurrentItem();
       
   390     return isOk;
       
   391 	}
       
   392 	
       
   393 // -----------------------------------------------------------------------------
       
   394 // CSIPExProfileQueryDlg::SetProfileIAPIdL
       
   395 // Sets access point Id.
       
   396 // -----------------------------------------------------------------------------
       
   397 //
       
   398 TBool CSIPExProfileQueryDlg::SetProfileIAPIdL( )
       
   399 	{
       
   400 	TBool isOk( ETrue );
       
   401     iProfileData.iAPIndex = iAPsUIDs[( static_cast< CEikChoiceList* >( 
       
   402     				Control( EItemAccesspointid ) ) )->CurrentItem()];
       
   403     return isOk;
       
   404 	}
       
   405 	
       
   406 // -----------------------------------------------------------------------------
       
   407 // CSIPExProfileQueryDlg::SetProfileSecurityL
       
   408 // Sets iSecurity from CEikDialog .
       
   409 // -----------------------------------------------------------------------------
       
   410 //
       
   411 TBool CSIPExProfileQueryDlg::SetProfileSecurityL( )
       
   412 	{
       
   413 	TBool isOk( ETrue );
       
   414     iProfileData.iSecurity = ( static_cast< CEikChoiceList* >( 
       
   415     				Control( EItemSecurity ) ) )->CurrentItem();
       
   416 	
       
   417 	return isOk;
       
   418 	}
       
   419 
       
   420 // -----------------------------------------------------------------------------
       
   421 // CSIPExProfileQueryDlg::SetProfileProxyAddressL
       
   422 // Sets iProxyAddress from CEikDialog .
       
   423 // -----------------------------------------------------------------------------
       
   424 //
       
   425 TBool CSIPExProfileQueryDlg::SetProfileProxyAddressL( )
       
   426 	{
       
   427 	TBool isOk( ETrue );
       
   428 
       
   429 	HBufC* defBuf = CEikonEnv::Static()->AllocReadResourceLC(
       
   430         R_SIP_EX_DEF_SERVER_ADDRESS );
       
   431 
       
   432 	( static_cast<CEikEdwin*>(Control( EProxyServerItemAddr ) ) )->GetText(
       
   433     											 iProfileData.iProxy.iAddress);
       
   434 		
       
   435     if (iProfileData.iProxy.iAddress == defBuf->Des())
       
   436     	{
       
   437     	iProfileData.iProxy.iAddress = KNullDesC;
       
   438     	}
       
   439     CleanupStack::PopAndDestroy(); // defBuf
       
   440     
       
   441 	return isOk;
       
   442 	}
       
   443 
       
   444 // -----------------------------------------------------------------------------
       
   445 // CSIPExProfileQueryDlg::SetProfileProxyRealmL
       
   446 // Sets iProxyRealm from CEikDialog .
       
   447 // -----------------------------------------------------------------------------
       
   448 //
       
   449 TBool CSIPExProfileQueryDlg::SetProfileProxyRealmL( )
       
   450 	{
       
   451 	TBool isOk( ETrue );
       
   452     ( static_cast< CEikEdwin* >( 
       
   453     				Control( EProxyServerItemRealm ) ) )->GetText( iProfileData.iProxy.iRealm );
       
   454 	
       
   455 	return isOk;
       
   456 	}
       
   457 
       
   458 // -----------------------------------------------------------------------------
       
   459 // CSIPExProfileQueryDlg::SetProfileProxyUNameL
       
   460 // Sets iProxyUName from CEikDialog .
       
   461 // -----------------------------------------------------------------------------
       
   462 //
       
   463 TBool CSIPExProfileQueryDlg::SetProfileProxyUNameL( )
       
   464 	{
       
   465 	TBool isOk( ETrue );
       
   466     ( static_cast< CEikEdwin* >( 
       
   467     				Control( EProxyServerItemUsername ) ) )->GetText( iProfileData.iProxy.iUsername );
       
   468 	
       
   469 	return isOk;
       
   470 	}
       
   471 
       
   472 // -----------------------------------------------------------------------------
       
   473 // CSIPExProfileQueryDlg::SetProfileProxyPwL
       
   474 // Sets iProxyPw from CEikDialog .
       
   475 // -----------------------------------------------------------------------------
       
   476 //
       
   477 TBool CSIPExProfileQueryDlg::SetProfileProxyPwL( )
       
   478 	{
       
   479 	TBool isOk( ETrue );
       
   480     ( static_cast< CEikEdwin* >( 
       
   481     				Control( EProxyServerItemPassword ) ) )->GetText( iProfileData.iProxy.iPassword );
       
   482 	
       
   483 	return isOk;
       
   484 	}
       
   485 
       
   486 // -----------------------------------------------------------------------------
       
   487 // CSIPExProfileQueryDlg::SetProfileRegistrarAddressL
       
   488 // Sets iRegistrarAddress from CEikDialog .
       
   489 // -----------------------------------------------------------------------------
       
   490 //
       
   491 TBool CSIPExProfileQueryDlg::SetProfileRegistrarAddressL( )
       
   492 	{
       
   493 	TBool isOk( ETrue );
       
   494 	HBufC* defBuf = CEikonEnv::Static()->AllocReadResourceLC(
       
   495         R_SIP_EX_DEF_SERVER_ADDRESS );
       
   496 
       
   497 
       
   498     ( static_cast< CEikEdwin* >( 
       
   499     				Control( ERegistrarServerItemAddr ) ) )->GetText( iProfileData.iRegistrar.iAddress );
       
   500 	
       
   501 	if (iProfileData.iRegistrar.iAddress == defBuf->Des())
       
   502     	{
       
   503     	iProfileData.iRegistrar.iAddress = KNullDesC;
       
   504     	}
       
   505     CleanupStack::PopAndDestroy(); // defBuf
       
   506 
       
   507 	return isOk;
       
   508 	}
       
   509 
       
   510 // -----------------------------------------------------------------------------
       
   511 // CSIPExProfileQueryDlg::SetProfileRegistrarRealmL
       
   512 // Sets iRegistrarRealm from CEikDialog .
       
   513 // -----------------------------------------------------------------------------
       
   514 //
       
   515 TBool CSIPExProfileQueryDlg::SetProfileRegistrarRealmL( )
       
   516 	{
       
   517 	TBool isOk( ETrue );
       
   518     ( static_cast< CEikEdwin* >( 
       
   519     				Control( ERegistrarServerItemRealm ) ) )->GetText( iProfileData.iRegistrar.iRealm );
       
   520 	
       
   521 	return isOk;
       
   522 	}
       
   523 
       
   524 // -----------------------------------------------------------------------------
       
   525 // CSIPExProfileQueryDlg::SetProfileRegistrarUNameL
       
   526 // Sets iRegistrarUName from CEikDialog .
       
   527 // -----------------------------------------------------------------------------
       
   528 //
       
   529 TBool CSIPExProfileQueryDlg::SetProfileRegistrarUNameL( )
       
   530 	{
       
   531 	TBool isOk( ETrue );
       
   532     ( static_cast< CEikEdwin* >( 
       
   533     				Control( ERegistrarServerItemUsername ) ) )->GetText( 
       
   534     				iProfileData.iRegistrar.iUsername );
       
   535 	
       
   536 	return isOk;
       
   537 	}
       
   538 
       
   539 // -----------------------------------------------------------------------------
       
   540 // CSIPExProfileQueryDlg::SetProfileRegistrarPwL
       
   541 // Sets iRegistrarPw from CEikDialog .
       
   542 // -----------------------------------------------------------------------------
       
   543 //
       
   544 TBool CSIPExProfileQueryDlg::SetProfileRegistrarPwL( )
       
   545 	{
       
   546 	TBool isOk( ETrue );
       
   547     ( static_cast< CEikEdwin* >( 
       
   548     				Control( ERegistrarServerItemPassword ) ) )->GetText( 
       
   549     				iProfileData.iRegistrar.iPassword );
       
   550 	
       
   551 	return isOk;
       
   552 	}
       
   553 
       
   554 // -----------------------------------------------------------------------------
       
   555 // CSIPExProfileQueryDlg::ShowErrorInfo
       
   556 // Informs which part is not valid
       
   557 // -----------------------------------------------------------------------------
       
   558 //
       
   559 void CSIPExProfileQueryDlg::ShowErrorInfoL(TProfileSettingItemListItems aItem)
       
   560 	{
       
   561 	HBufC* txt =0;
       
   562 	switch (aItem)
       
   563 		{
       
   564 		case EItemUsername:
       
   565 			txt = iEikonEnv->AllocReadResourceLC( R_ERROR_IN_USERNAME_TXT );
       
   566     		break;
       
   567 		case EItemCompression:
       
   568 			txt = iEikonEnv->AllocReadResourceLC( R_ERROR_IN_COMPRESSION_TXT );
       
   569     		break;
       
   570 		case EItemSecurity:
       
   571 			txt = iEikonEnv->AllocReadResourceLC( R_ERROR_IN_SECURITY_TXT );
       
   572     		break;
       
   573 		case EItemProxyServer:
       
   574 			txt = iEikonEnv->AllocReadResourceLC( R_ERROR_IN_PROXY_TXT );
       
   575     		break;
       
   576 		case EItemRegistrarServer:
       
   577 			txt = iEikonEnv->AllocReadResourceLC( R_ERROR_IN_REGISTRAR_TXT );
       
   578     		break;
       
   579     	default:
       
   580 			txt = iEikonEnv->AllocReadResourceLC( R_ERROR_IN_GENERAL_TXT );
       
   581     		break;
       
   582     	}
       
   583 
       
   584   		CEikonEnv::Static()->InfoMsg( txt->Des() );
       
   585    		CleanupStack::PopAndDestroy( txt );
       
   586 	}
       
   587 
       
   588 // -----------------------------------------------------------------------------
       
   589 // CSIPExAddrQueryDlg::AddressValid
       
   590 // Checks if user typed address is valid address.
       
   591 // -----------------------------------------------------------------------------
       
   592 //    
       
   593 TBool CSIPExProfileQueryDlg::AddressValid( const TDesC8& aAddr )
       
   594     {
       
   595     
       
   596     _LIT8( KTypeSIP, "sip" );
       
   597     
       
   598     TUriParser8 parser;
       
   599     User::LeaveIfError( parser.Parse( aAddr ) ); 
       
   600     CUri8* uri8 = CUri8::NewLC( parser );
       
   601     
       
   602     TBool valid( ETrue );
       
   603     
       
   604     if ( uri8->Uri().Extract( EUriScheme ).CompareF( KTypeSIP() ) != KErrNone )
       
   605         {
       
   606         valid = EFalse;
       
   607         }
       
   608     if ( uri8->Uri().Extract( EUriUserinfo ) == KNullDesC8 )
       
   609         {
       
   610         valid = EFalse;
       
   611         }
       
   612     if ( uri8->Uri().Extract( EUriHost ) == KNullDesC8 )
       
   613         {
       
   614         valid = EFalse;
       
   615         }
       
   616     CleanupStack::PopAndDestroy( uri8 );
       
   617         
       
   618     return valid;        
       
   619     }
       
   620     
       
   621 void CSIPExProfileQueryDlg::GetAPListL()
       
   622 	{
       
   623 	if (iAccesspointids)
       
   624 		{
       
   625     	iAccesspointids->Reset();
       
   626     	delete iAccesspointids;
       
   627  		}
       
   628 	iAccesspointids = new (ELeave) CDesCArraySeg(100);
       
   629 	
       
   630 	CCommsDatabase* db = CCommsDatabase::NewL();
       
   631     CleanupStack::PushL( db );
       
   632 //	TUint i( 0 );
       
   633     iAPsUIDs.Reset();
       
   634     CCommsDbTableView* comView = db->OpenTableLC( TPtrC( IAP ) );
       
   635     TInt error1 = comView->GotoFirstRecord();
       
   636     while ( error1 == KErrNone )
       
   637         {
       
   638         TUint32 id( 0 );
       
   639 
       
   640         TBuf< KCommsDbSvrMaxColumnNameLength > tmpName;
       
   641         
       
   642         comView->ReadUintL( TPtrC( COMMDB_ID ), id );
       
   643 		comView->ReadTextL( TPtrC( COMMDB_NAME ), tmpName);
       
   644 		
       
   645         iAccesspointids->AppendL(tmpName);
       
   646         
       
   647        // i++;    // To next enumeration   
       
   648         User::LeaveIfError( iAPsUIDs.Append( id ) );
       
   649         error1 = comView->GotoNextRecord();
       
   650         }
       
   651     CleanupStack::PopAndDestroy( comView );  // table
       
   652 	
       
   653 	//TInt apCount( iAPsUIDs.Count() );
       
   654     CleanupStack::PopAndDestroy( db );   // db
       
   655 
       
   656 	}
       
   657 
       
   658 // End of file