locationsystemui/locationsysui/locsuplsettingsui/src/locsuplservereditor.cpp
branchRCL_3
changeset 55 ea98413ce11f
parent 49 10852b179f64
equal deleted inserted replaced
49:10852b179f64 55:ea98413ce11f
    67 //
    67 //
    68 CLocSUPLServerEditor::CLocSUPLServerEditor( 
    68 CLocSUPLServerEditor::CLocSUPLServerEditor( 
    69         					TBool aIsEditable,
    69         					TBool aIsEditable,
    70                             CLocSUPLSettingsUiEngine&       aEngine,
    70                             CLocSUPLSettingsUiEngine&       aEngine,
    71         					TInt64 aSlpId
    71         					TInt64 aSlpId
    72 		):iIsEditMode( aIsEditable ), iEngine( aEngine ), iSlpId( aSlpId ), iIsAccessPointDefined(EFalse)
    72 		):iIsEditMode( aIsEditable ), iEngine( aEngine ), iSlpId( aSlpId )
    73     {
    73     {
    74     if( aIsEditable )
    74     if( aIsEditable )
    75     	{
    75     	{
    76     	iIsNewServer = ETrue;
    76     	iIsNewServer = ETrue;
    77     	iSlpId = NULL;
    77     	iSlpId = NULL;
   182 			switch( IdOfFocusControl() )
   182 			switch( IdOfFocusControl() )
   183 				{
   183 				{
   184 				case ELocSuplServerIdServerAddr:
   184 				case ELocSuplServerIdServerAddr:
   185 					{
   185 					{
   186 					aMenuPane->SetItemDimmed( ELocServerEditorDefine, 	ETrue );
   186 					aMenuPane->SetItemDimmed( ELocServerEditorDefine, 	ETrue );
       
   187 		       		aMenuPane->SetItemDimmed( ELocServerEditorChange, 	ETrue );   
   187 					break;
   188 					break;
   188 					}
   189 					}
   189 				case ELocSuplServerIdAccessPoint:
   190 				case ELocSuplServerIdAccessPoint:
   190 					{
   191 					{
       
   192 			       	TInt isIapChanged = EFalse;
       
   193 			        CEikEdwin* apSelector = 
       
   194 			        			static_cast < CEikEdwin* > ( ControlOrNull( IdOfFocusControl() ) );           
       
   195 			        if( apSelector )
       
   196 			            {  
       
   197 			            if( iIap->Length() > 0 ) 
       
   198 			            	isIapChanged = ETrue;
       
   199 			            } 
       
   200 			            
       
   201 			       	if( isIapChanged )
       
   202 			       		{
       
   203 			       		aMenuPane->SetItemDimmed( ELocServerEditorDefine, 	ETrue );
       
   204 			       		}
       
   205 			       	else
       
   206 			       		{
       
   207 			       		aMenuPane->SetItemDimmed( ELocServerEditorChange, 	ETrue );		       		
       
   208 			       		}				
   191 					break;
   209 					break;
   192 					}
   210 					}
   193 				case ELocSuplServerIdUsageInHomeNw:
   211 				case ELocSuplServerIdUsageInHomeNw:
   194 					{
   212 					{
   195 					aMenuPane->SetItemDimmed( ELocServerEditorDefine, 		ETrue );
   213 					aMenuPane->SetItemDimmed( ELocServerEditorDefine, 		ETrue );
   196 					
   214 					
   197 		        	TBool editableFlag = ETrue;
   215 		        	TBool editableFlag = ETrue;
   198 		        	if( iSlpId )
   216 		        	if( iSlpId )
   199 		        		TRAP_IGNORE( iEngine.GetEditableFlagL( iSlpId, editableFlag ) );        				        	
   217 		        		TRAP_IGNORE( iEngine.GetEditableFlagL( iSlpId, editableFlag ) );        				        	
       
   218 		        	if( editableFlag == EFalse )					
       
   219 						aMenuPane->SetItemDimmed( ELocServerEditorChange, 	ETrue );
   200 		        	
   220 		        	
   201 					break;
   221 					break;
   202 					}
   222 					}
   203 				default:
   223 				default:
   204 					break;
   224 					break;
   232 						break;
   252 						break;
   233 					}        		
   253 					}        		
   234         		}
   254         		}
   235 
   255 
   236 			aMenuPane->SetItemDimmed( ELocServerEditorDefine, 	ETrue );
   256 			aMenuPane->SetItemDimmed( ELocServerEditorDefine, 	ETrue );
       
   257        		aMenuPane->SetItemDimmed( ELocServerEditorChange, 	ETrue );		       			    	
   237        		aMenuPane->SetItemDimmed( ELocServerEditorRemove, 	ETrue );		       			    	
   258        		aMenuPane->SetItemDimmed( ELocServerEditorRemove, 	ETrue );		       			    	
   238 	    	}	        
   259 	    	}	        
   239         }
   260         }
   240 	DEBUG( - CLocSUPLServerEditor::DynInitMenuPaneL );
   261 	DEBUG( - CLocSUPLServerEditor::DynInitMenuPaneL );
   241     }
   262     }
   277         case ELocServerEditorEnable:
   298         case ELocServerEditorEnable:
   278             {
   299             {
   279             TRAP_IGNORE( iEngine.SetServerEnabledFlagL( iSlpId, ETrue ) );
   300             TRAP_IGNORE( iEngine.SetServerEnabledFlagL( iSlpId, ETrue ) );
   280             break;
   301             break;
   281             }
   302             }
       
   303         case ELocServerEditorDefine:
       
   304             {
       
   305             TRAP_IGNORE( iEngine.LaunchApConfiguratorL( iSlpId, this ) );
       
   306             break;
       
   307             }
       
   308         case ELocServerEditorChange:
   282         case ELocServerEditorMSKChange:
   309         case ELocServerEditorMSKChange:
   283             {
   310             {
   284             CEikEdwin* usageInHomeNWPopupFieldText = (CEikEdwin*) Control(
   311             CEikEdwin* usageInHomeNWPopupFieldText = (CEikEdwin*) Control(
   285                     ELocSuplServerIdUsageInHomeNw);
   312                     ELocSuplServerIdUsageInHomeNw);
       
   313             if (IdOfFocusControl() == ELocSuplServerIdAccessPoint)
       
   314                 {
       
   315                 TRAP_IGNORE( iEngine.LaunchApConfiguratorL( iSlpId, this ) );
       
   316                 }
       
   317             else
       
   318                 {
   286             HBufC* string;
   319             HBufC* string;
   287                             string = StringLoader::LoadLC(
   320                             string = StringLoader::LoadLC(
   288                                     R_LOC_SERVER_USAGEINHOMENETWORK_NO, iCoeEnv);
   321                                     R_LOC_SERVER_USAGEINHOMENETWORK_NO, iCoeEnv);
   289                 if (iIsNewServer)
   322                 if (iIsNewServer)
   290                     {
   323                     {
   314                         else
   347                         else
   315                             {
   348                             {
   316                             SetUsageinHomeNetwork(EFalse);
   349                             SetUsageinHomeNetwork(EFalse);
   317                             }
   350                             }
   318                         }
   351                         }
       
   352                     }
   319                 CleanupStack::PopAndDestroy(string);
   353                 CleanupStack::PopAndDestroy(string);
   320                     }
   354                 }
   321             break;
   355             break;
   322             }
   356             }
   323         case EAknCmdHelp:
   357         case EAknCmdHelp:
   324             {
   358             {
   325             HlpLauncher::LaunchHelpApplicationL(iCoeEnv->WsSession(),
   359             HlpLauncher::LaunchHelpApplicationL(iCoeEnv->WsSession(),
   427         	{
   461         	{
   428             //dont close editor            
   462             //dont close editor            
   429             retVal = EFalse;
   463             retVal = EFalse;
   430         	break;
   464         	break;
   431         	}
   465         	}
       
   466         case ELocServerEditorMSKDefine:
       
   467         	{
       
   468         	TRAP_IGNORE( iEngine.LaunchApConfiguratorL( iSlpId, this ) );
       
   469             //dont close editor            
       
   470             retVal = EFalse;
       
   471         	break;
       
   472         	}
   432         case ELocServerEditorMSKChange:
   473         case ELocServerEditorMSKChange:
   433         	{
   474         	{
   434         	ProcessCommandL( ELocServerEditorMSKChange );
   475         	ProcessCommandL( ELocServerEditorMSKChange );
   435             //dont close editor            
   476             //dont close editor            
   436             retVal = EFalse;
   477             retVal = EFalse;
   452             {
   493             {
   453 			if( SaveFormDataL() )
   494 			if( SaveFormDataL() )
   454 				{
   495 				{
   455             	if( iIsNewServer ) 
   496             	if( iIsNewServer ) 
   456             		{
   497             		{
   457                     // iap name is always set as KNullDesC since defining the access point is 
       
   458                     // not allowed while creating a new server manually
       
   459             		TRAPD( err, iEngine.AddNewServerL(
   498             		TRAPD( err, iEngine.AddNewServerL(
   460             								iServerAddress->Des(),
   499             								iServerAddress->Des(),
   461             								KNullDesC,
   500             								iIap->Des(),
   462             								iUsageInHomeNw ) );
   501             								iUsageInHomeNw ) );
   463             		if( err == KErrNone )
   502             		if( err == KErrNone )
   464             			{
   503             			{
   465             			iIsNewServer = EFalse;	
   504             			iIsNewServer = EFalse;	
   466             			}
   505             			}
   609                         string = StringLoader::LoadLC(
   648                         string = StringLoader::LoadLC(
   610                                 R_LOC_SERVER_USAGEINHOMENETWORK_NO, iCoeEnv);
   649                                 R_LOC_SERVER_USAGEINHOMENETWORK_NO, iCoeEnv);
   611         usageInHomeNWPopupFieldText->GetText(des);
   650         usageInHomeNWPopupFieldText->GetText(des);
   612         if (!des.CompareC(string->Des()))
   651         if (!des.CompareC(string->Des()))
   613             {
   652             {
       
   653             iUsageInHomeNw = ETrue;
       
   654             }
       
   655         else
       
   656             {
   614             iUsageInHomeNw = EFalse;
   657             iUsageInHomeNw = EFalse;
   615             }
       
   616         else
       
   617             {
       
   618             iUsageInHomeNw = ETrue;
       
   619             }
   658             }
   620         CleanupStack::PopAndDestroy(string);
   659         CleanupStack::PopAndDestroy(string);
   621         }
   660         }
   622 
   661 
   623     if( iServerAddress->Length() > 0 )
   662     if( iServerAddress->Length() > 0 )
   719 // CLocSUPLServerEditor::ExecuteLD
   758 // CLocSUPLServerEditor::ExecuteLD
   720 // Executes the Dialog
   759 // Executes the Dialog
   721 // -----------------------------------------------------------------------------
   760 // -----------------------------------------------------------------------------
   722 //
   761 //
   723 TInt CLocSUPLServerEditor::ExecuteLD()
   762 TInt CLocSUPLServerEditor::ExecuteLD()
   724     {
   763     {    
   725     if (!iIsAccessPointDefined)
   764 	return CAknForm::ExecuteLD( R_SUPLSERVER_EDITOR_FORM_DIALOG );    	
   726         {
   765     }
   727         return CAknForm::ExecuteLD(R_SUPLSERVER_EDITOR_FORM_DIALOG_NOAP);
       
   728         }
       
   729     else
       
   730         {
       
   731         return CAknForm::ExecuteLD(R_SUPLSERVER_EDITOR_FORM_DIALOG);
       
   732         }
       
   733     }
       
   734 
       
   735 
   766 
   736 // -----------------------------------------------------------------------------
   767 // -----------------------------------------------------------------------------
   737 // CLocSUPLServerEditor::HandleControlStateChangeL
   768 // CLocSUPLServerEditor::HandleControlStateChangeL
   738 // -----------------------------------------------------------------------------
   769 // -----------------------------------------------------------------------------
   739 //
   770 //
   783 void CLocSUPLServerEditor::LoadFormValuesFromDataL()
   814 void CLocSUPLServerEditor::LoadFormValuesFromDataL()
   784     {
   815     {
   785 	DEBUG( + CLocSUPLServerEditor::LoadFormValuesFromDataL );
   816 	DEBUG( + CLocSUPLServerEditor::LoadFormValuesFromDataL );
   786    	if( IsEditable() && iIsNewServer ) //if create new server
   817    	if( IsEditable() && iIsNewServer ) //if create new server
   787        	{
   818        	{
       
   819        	CEikEdwin* apSelector = 
       
   820         			static_cast < CEikEdwin* > ( ControlOrNull( ELocSuplServerIdAccessPoint ) );           
       
   821        	if( apSelector )
       
   822             {   
       
   823             HBufC* apString = StringLoader::LoadL( R_LOC_SERVER_NONE );   
       
   824             apSelector->SetTextL( apString );
       
   825             delete apString;
       
   826             }
       
   827         apSelector->DrawNow();
   788 
   828 
   789         CEikEdwin* usageInHNWPopupFieldText = (CEikEdwin*) Control(
   829         CEikEdwin* usageInHNWPopupFieldText = (CEikEdwin*) Control(
   790                 ELocSuplServerIdUsageInHomeNw);
   830                 ELocSuplServerIdUsageInHomeNw);
   791         if (usageInHNWPopupFieldText)
   831         if (usageInHNWPopupFieldText)
   792             {
   832             {
   828 	    						);
   868 	    						);
   829 	    if ( errParams != KErrNone )
   869 	    if ( errParams != KErrNone )
   830 	        {
   870 	        {
   831 	        // Error has occured 
   871 	        // Error has occured 
   832 	        }  
   872 	        }  
   833       
   873      	
   834         CEikEdwin* serverAddress = 
   874         CEikEdwin* serverAddress = 
   835         			static_cast < CEikEdwin* > ( ControlOrNull( ELocSuplServerIdServerAddr ) );           
   875         			static_cast < CEikEdwin* > ( ControlOrNull( ELocSuplServerIdServerAddr ) );           
   836         if( serverAddress )
   876         if( serverAddress )
   837             {   
   877             {   
   838             serverAddress->SetTextL( hslpAddr );
   878             serverAddress->SetTextL( hslpAddr );
   839             if( editFlag == EFalse )
   879             if( editFlag == EFalse )
   840             	serverAddress->SetReadOnly( ETrue );
   880             	serverAddress->SetReadOnly( ETrue );
   841         	serverAddress->DrawDeferred();
   881         	serverAddress->DrawDeferred();
   842         	iServerAddress->Des().Copy( hslpAddr->Des() );
   882         	iServerAddress->Des().Copy( hslpAddr->Des() );
   843             } 
   883             } 
   844         
   884 
   845             if (iIsAccessPointDefined)
   885         CEikEdwin* apSelector = 
   846             {
   886         			static_cast < CEikEdwin* > ( ControlOrNull( ELocSuplServerIdAccessPoint ) );           
   847             CEikEdwin* apSelector = static_cast<CEikEdwin*> (ControlOrNull(
   887         if( apSelector )
   848                     ELocSuplServerIdAccessPoint));
   888             {   
   849             if (apSelector)
   889             if( iapName->Length() > 0 )
   850                 {
   890             	{
   851                 apSelector->SetTextL(iapName);
   891             	apSelector->SetTextL( iapName );
   852                 apSelector->DrawNow();
   892             	}
   853                 iIap->Des().Copy(iapName->Des());
   893             else
   854                 }
   894             	{
   855             }
   895 	            HBufC* apString = StringLoader::LoadL( R_LOC_SERVER_NONE ); 
   856        
   896 	            apSelector->SetTextL( apString );
       
   897             	delete apString;
       
   898             	}
       
   899             	            
       
   900         	apSelector->DrawNow();
       
   901         	iIap->Des().Copy( iapName->Des() );
       
   902             } 
       
   903 
   857         CEikEdwin* usageInHNWPopupFieldText = (CEikEdwin*) Control(
   904         CEikEdwin* usageInHNWPopupFieldText = (CEikEdwin*) Control(
   858                 ELocSuplServerIdUsageInHomeNw);
   905                 ELocSuplServerIdUsageInHomeNw);
   859         if (usageInHNWPopupFieldText)
   906         if (usageInHNWPopupFieldText)
   860             {
   907             {
   861             if (!usageInHomeNwFlag)
   908             if (usageInHomeNwFlag)
   862                 SetUsageinHomeNetwork(EFalse);
   909                 SetUsageinHomeNetwork(EFalse);
   863             else
   910             else
   864                 SetUsageinHomeNetwork(ETrue);
   911                 SetUsageinHomeNetwork(ETrue);
   865 
   912 
   866             UpdatePageL(ETrue);
   913             UpdatePageL(ETrue);
   941 	       		cba->SetCommandSetL( R_SUPLSERVER_EDITOR_OPTIONS_NOMSK_DONE );
   988 	       		cba->SetCommandSetL( R_SUPLSERVER_EDITOR_OPTIONS_NOMSK_DONE );
   942 	       		break;
   989 	       		break;
   943 	       		}
   990 	       		}
   944 	       	case ELocSuplServerIdAccessPoint:
   991 	       	case ELocSuplServerIdAccessPoint:
   945 		       	{
   992 		       	{
       
   993 		       	TInt isIapChanged = EFalse;
       
   994 		        CEikEdwin* apSelector = 
       
   995 		        			static_cast < CEikEdwin* > ( ControlOrNull( IdOfFocusControl() ) );           
       
   996 		        if( apSelector && iIap )
       
   997 		            {   
       
   998 		            if( iIap->Length() > 0 )
       
   999 	            		isIapChanged = ETrue;
       
  1000 		            } 
       
  1001 		       	if( isIapChanged )
       
  1002 		       		{
       
  1003 		       		cba->SetCommandSetL( R_SUPLSERVER_EDITOR_OPTIONS_CHANGE_DONE );
       
  1004 		       		}
       
  1005 		       	else
       
  1006 		       		{
       
  1007 		       		cba->SetCommandSetL( R_SUPLSERVER_EDITOR_OPTIONS_DEFINE_DONE );		       		
       
  1008 		       		}
   946 		       	break;	
  1009 		       	break;	
   947 		       	}
  1010 		       	}
   948 	       	case ELocSuplServerIdUsageInHomeNw:
  1011 	       	case ELocSuplServerIdUsageInHomeNw:
   949 		       	{
  1012 		       	{
   950    	        	TBool editableFlag = ETrue;
  1013    	        	TBool editableFlag = ETrue;
  1082     TInt focusControl(IdOfFocusControl());
  1145     TInt focusControl(IdOfFocusControl());
  1083 
  1146 
  1084     if (!IsEditable())
  1147     if (!IsEditable())
  1085         {
  1148         {
  1086         if (focusControl == ELocSuplServerIdUsageInHomeNw
  1149         if (focusControl == ELocSuplServerIdUsageInHomeNw
  1087                 || focusControl == ELocSuplServerIdServerAddr)
  1150                 || ELocSuplServerIdServerAddr || ELocSuplServerIdAccessPoint)
  1088             {
  1151             {
  1089             ProcessCommandL(EAknFormCmdEdit);
  1152             ProcessCommandL(EAknFormCmdEdit);
  1090             }
  1153             }
  1091         else
       
  1092             return;
       
  1093         }
  1154         }
  1094     else if (aEventID == MEikDialogPageObserver::EDialogPageTapped)
  1155     else if (aEventID == MEikDialogPageObserver::EDialogPageTapped)
  1095         {
  1156         {
  1096         if (focusControl == ELocSuplServerIdUsageInHomeNw)
  1157         if (focusControl == ELocSuplServerIdUsageInHomeNw)
  1097             {
  1158             {
  1116                     }
  1177                     }
  1117                 CleanupStack::PopAndDestroy(string);
  1178                 CleanupStack::PopAndDestroy(string);
  1118                 }
  1179                 }
  1119             return;
  1180             return;
  1120             }
  1181             }
       
  1182         if (focusControl == ELocSuplServerIdAccessPoint)
       
  1183             {
       
  1184             if (iapEditor)
       
  1185                 {
       
  1186                 //Launch IAP Dialog
       
  1187                 TRAP_IGNORE( iEngine.LaunchApConfiguratorL( iSlpId, this ) );
       
  1188                 }
       
  1189             }
  1121         }DEBUG( -CLocSUPLServerEditor::HandleDialogPageEventL );
  1190         }DEBUG( -CLocSUPLServerEditor::HandleDialogPageEventL );
  1122     }
  1191     }
  1123 
  1192 
  1124 // -----------------------------------------------------------------------------
  1193 // -----------------------------------------------------------------------------
  1125 // CLocSUPLServerEditor::SetUsageinHomeNetwork
  1194 // CLocSUPLServerEditor::SetUsageinHomeNetwork
  1146     // set Usage in Network field string as 'ON'/'OFF'
  1215     // set Usage in Network field string as 'ON'/'OFF'
  1147     usageInHomeNWPopupFieldText->SetTextL(string);
  1216     usageInHomeNWPopupFieldText->SetTextL(string);
  1148     CleanupStack::PopAndDestroy(string);
  1217     CleanupStack::PopAndDestroy(string);
  1149     }
  1218     }
  1150 
  1219 
  1151 // -----------------------------------------------------------------------------
       
  1152 // CLocSUPLServerEditor::SetAccessPointEnabled
       
  1153 // 
       
  1154 // -----------------------------------------------------------------------------
       
  1155 //
       
  1156 void CLocSUPLServerEditor::SetAccessPointEnabled (TBool aEnabled)
       
  1157     {
       
  1158     iIsAccessPointDefined = aEnabled;
       
  1159     }
       
  1160 
       
  1161 
       
  1162 // End of file
  1220 // End of file