locationsystemui/locationsysui/locsuplsettingsui/src/locsuplservereditor.cpp
changeset 18 3825cf2dc8c2
parent 0 667063e416a2
equal deleted inserted replaced
1:788b770ce3ae 18:3825cf2dc8c2
    44 #include <barsread.h>           // For TResourceReader
    44 #include <barsread.h>           // For TResourceReader
    45 #include <bautils.h> 
    45 #include <bautils.h> 
    46 #include <data_caging_path_literals.hrh>
    46 #include <data_caging_path_literals.hrh>
    47 #include <gulicon.h>            // Gul Icon
    47 #include <gulicon.h>            // Gul Icon
    48 #include <StringLoader.h>
    48 #include <StringLoader.h>
       
    49 #include <hlplch.h> 
    49 
    50 
    50 #include <epos_csuplsettingsconstants.h>
    51 #include <epos_csuplsettingsconstants.h>
    51 #include <epos_csuplsettingparams.h>
    52 #include <epos_csuplsettingparams.h>
    52 
    53 
    53 #include <locsuplsettingsui.rsg>
    54 #include <locsuplsettingsui.rsg>
   267 void CLocSUPLServerEditor::ProcessCommandL( TInt aCommandId )
   268 void CLocSUPLServerEditor::ProcessCommandL( TInt aCommandId )
   268 	{
   269 	{
   269 	DEBUG1( + CLocSUPLServerEditor::ProcessCommandL aCommandId=%d, aCommandId );
   270 	DEBUG1( + CLocSUPLServerEditor::ProcessCommandL aCommandId=%d, aCommandId );
   270 	CAknForm::ProcessCommandL( aCommandId );
   271 	CAknForm::ProcessCommandL( aCommandId );
   271 
   272 
   272 	switch ( aCommandId )
   273     switch (aCommandId)
   273        	{
   274         {
   274        	case EAknFormCmdEdit:
   275         case EAknFormCmdEdit:
   275        		{
   276             {
   276 			iIsEditMode = ETrue;
   277             iIsEditMode = ETrue;
   277 			SetCursorToEndL();
   278             SetCursorToEndL();
   278    			HandleMSKCaptionL();						
   279             HandleMSKCaptionL();
   279        		break;
   280             break;
   280        		}
   281             }
   281        	case ELocServerEditorDelete:
   282         case ELocServerEditorDelete:
   282        	case ELocServerEditorRemove:
   283         case ELocServerEditorRemove:
   283        		{
   284             {
   284        		if( DeleteConfirmationQueryL() )
   285             if (DeleteConfirmationQueryL())
   285        			{
   286                 {
   286        			TRAP_IGNORE( iEngine.RemoveServerL( iSlpId ) );
   287                 TRAP_IGNORE( iEngine.RemoveServerL( iSlpId ) );
   287         		// Return back to server view
   288                 // Return back to server view
   288 	       		TryExitL( EAknSoftkeyBack );
   289                 TryExitL(EAknSoftkeyBack);
   289       			}       			
   290                 }
   290        		break;
   291             break;
   291        		}
   292             }
   292        	case ELocServerEditorDisable:
   293         case ELocServerEditorDisable:
   293        		{
   294             {
   294        		TRAP_IGNORE( iEngine.SetServerEnabledFlagL( iSlpId, EFalse ) );
   295             TRAP_IGNORE( iEngine.SetServerEnabledFlagL( iSlpId, EFalse ) );
   295        		break;
   296             break;
   296        		}
   297             }
   297        	case ELocServerEditorEnable:
   298         case ELocServerEditorEnable:
   298        		{
   299             {
   299        		TRAP_IGNORE( iEngine.SetServerEnabledFlagL( iSlpId, ETrue ) );
   300             TRAP_IGNORE( iEngine.SetServerEnabledFlagL( iSlpId, ETrue ) );
   300       		break;
   301             break;
   301        		}
   302             }
   302        	case ELocServerEditorDefine:
   303         case ELocServerEditorDefine:
   303        		{
   304             {
   304         	TRAP_IGNORE( iEngine.LaunchApConfiguratorL( iSlpId, this ) );
   305             TRAP_IGNORE( iEngine.LaunchApConfiguratorL( iSlpId, this ) );
   305        		break;
   306             break;
   306        		}
   307             }
   307        	case ELocServerEditorChange:
   308         case ELocServerEditorChange:
   308        	case ELocServerEditorMSKChange:       	
   309         case ELocServerEditorMSKChange:
   309        		{
   310             {
   310 		    if ( IdOfFocusControl() == ELocSuplServerIdAccessPoint )
   311             CEikEdwin* usageInHomeNWPopupFieldText = (CEikEdwin*) Control(
   311 		    	{
   312                     ELocSuplServerIdUsageInHomeNw);
   312         		TRAP_IGNORE( iEngine.LaunchApConfiguratorL( iSlpId, this ) );
   313             if (IdOfFocusControl() == ELocSuplServerIdAccessPoint)
   313 		    	}
   314                 {
   314 		    else
   315                 TRAP_IGNORE( iEngine.LaunchApConfiguratorL( iSlpId, this ) );
   315 		    	{
   316                 }
   316 		    	if( iIsNewServer )
   317             else
   317 		    		{
   318                 {
   318 		    		TogglePopupFieldControlL( IdOfFocusControl() );
   319                 if (iIsNewServer)
   319 		    		}
   320                     {
   320 		    	else
   321                     TBuf<KMaxUsageTextSize> des;
   321 		    		{
   322                     usageInHomeNWPopupFieldText->GetText(des);
   322 			    	TBool editableFlag;
   323                     if (!des.Compare(KNoUsageInHomeNetork))
   323 			    	TRAP_IGNORE( iEngine.GetEditableFlagL( iSlpId, editableFlag ) );
   324                         {
   324 			    	if ( editableFlag )
   325                         SetUsageinHomeNetwork(ETrue);
   325 			    		TogglePopupFieldControlL( IdOfFocusControl() );		    		
   326                         }
   326 		    		}
   327                     else
   327 		    	}			    	
   328                         {
   328        		break;
   329                         SetUsageinHomeNetwork(EFalse);
   329        		}
   330                         }
   330        	case EAknCmdHelp:
   331                     }
   331        		{
   332                 else
   332        		break;
   333                     {
   333        		}
   334                     TBool editableFlag;
   334        	case EEikCmdExit:
   335                     TRAP_IGNORE( iEngine.GetEditableFlagL( iSlpId, editableFlag ) );
   335        		{
   336                     if (editableFlag)
   336        		// The Exit is handled by the Application UI
   337                         {
   337        		TryExitL( EEikCmdExit );
   338                         TBuf<KMaxUsageTextSize> des;
   338        		break;
   339                         usageInHomeNWPopupFieldText->GetText(des);
   339        		}
   340                         if (!des.Compare(KNoUsageInHomeNetork))
   340 		default:
   341                             {
   341 			break;
   342                             SetUsageinHomeNetwork(ETrue);
   342        	}
   343                             }
   343 	DEBUG( - CLocSUPLServerEditor::ProcessCommandL );
   344                         else
   344 	}
   345                             {
   345 	
   346                             SetUsageinHomeNetwork(EFalse);
       
   347                             }
       
   348                         }
       
   349                     }
       
   350                 }
       
   351             break;
       
   352             }
       
   353         case EAknCmdHelp:
       
   354             {
       
   355             HlpLauncher::LaunchHelpApplicationL(iCoeEnv->WsSession(),
       
   356                     iAvkonAppUi->AppHelpContextL());
       
   357             break;
       
   358             }
       
   359         case EEikCmdExit:
       
   360             {
       
   361             // The Exit is handled by the Application UI
       
   362             TryExitL(EEikCmdExit);
       
   363             break;
       
   364             }
       
   365         default:
       
   366             break;
       
   367         }DEBUG( - CLocSUPLServerEditor::ProcessCommandL );
       
   368     }
       
   369 
   346 // ---------------------------------------------------------------------------
   370 // ---------------------------------------------------------------------------
   347 // Derived from CEikDialog
   371 // Derived from CEikDialog
   348 // ---------------------------------------------------------------------------
   372 // ---------------------------------------------------------------------------
   349 
   373 
   350 // -----------------------------------------------------------------------------
       
   351 // CLocSUPLServerEditor::HandlePointerEventL
       
   352 // -----------------------------------------------------------------------------
       
   353 //  
       
   354 void CLocSUPLServerEditor::HandlePointerEventL(const TPointerEvent &aPointerEvent)
       
   355 	{	
       
   356     DEBUG( +CLocSUPLServerEditor::HandlePointerEventL );
       
   357     CEikEdwin* serverAddress = static_cast<CEikEdwin*> (ControlOrNull(
       
   358             ELocSuplServerIdServerAddr));
       
   359     CEikEdwin* iapEditor = static_cast<CEikEdwin*> (ControlOrNull(
       
   360             ELocSuplServerIdAccessPoint));
       
   361     CAknPopupFieldText* usageInHomeNWPopupFieldText =
       
   362             (CAknPopupFieldText*) Control(ELocSuplServerIdUsageInHomeNw);
       
   363 
       
   364     if (!IsEditable())
       
   365         {
       
   366         CAknForm::HandlePointerEventL(aPointerEvent);
       
   367     
       
   368         if(aPointerEvent.iType == TPointerEvent::EButton1Up)
       
   369             {
       
   370             // Opens the editor on Single Click on any of the controls. Click on rest of the click does not repond
       
   371             if (iapEditor->Rect().Contains(aPointerEvent.iPosition)
       
   372                     || usageInHomeNWPopupFieldText->Rect().Contains(
       
   373                             aPointerEvent.iPosition)
       
   374                     || serverAddress->Rect().Contains(aPointerEvent.iPosition))
       
   375                 {
       
   376                 ProcessCommandL(EAknFormCmdEdit);
       
   377                 }
       
   378             }
       
   379         }
       
   380     else if (IsEditable())
       
   381         {
       
   382         if (usageInHomeNWPopupFieldText )
       
   383             {
       
   384             if (usageInHomeNWPopupFieldText->Rect().Contains(
       
   385                     aPointerEvent.iPosition) )
       
   386                 {
       
   387                 if( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   388                     {
       
   389                       TogglePopupFieldControlL(IdOfFocusControl());
       
   390                       if (iIsNewServer)
       
   391                         {
       
   392                         iIsModified = ETrue;
       
   393                         }
       
   394                     } 
       
   395                 return;
       
   396                 }
       
   397             }
       
   398 
       
   399         CAknForm::HandlePointerEventL(aPointerEvent);
       
   400 
       
   401         //check if click is on IAP Editor control
       
   402         if (iapEditor)
       
   403             {
       
   404             if (iapEditor->Rect().Contains(aPointerEvent.iPosition) &&
       
   405                     aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   406                 {
       
   407                 //Launch IAP Dialog
       
   408                 TRAP_IGNORE( iEngine.LaunchApConfiguratorL( iSlpId, this ) );
       
   409                 return;
       
   410                 }
       
   411             }
       
   412         }
       
   413     DEBUG( - CLocSUPLServerEditor::HandlePointerEventL );
       
   414     }
       
   415 
       
   416         
       
   417 // -----------------------------------------------------------------------------
   374 // -----------------------------------------------------------------------------
   418 // CLocSUPLServerEditor::OfferKeyEventL
   375 // CLocSUPLServerEditor::OfferKeyEventL
   419 // Receives and handles key events
   376 // Receives and handles key events
   420 // -----------------------------------------------------------------------------
   377 // -----------------------------------------------------------------------------
   421 //
   378 //
   550 					    SetInitialCurrentLine();	            			
   507 					    SetInitialCurrentLine();	            			
   551 						SetCursorToEndL();
   508 						SetCursorToEndL();
   552 			            //dont close editor            
   509 			            //dont close editor            
   553 			            retVal = EFalse;	            		
   510 			            retVal = EFalse;	            		
   554             			}
   511             			}
       
   512             		else if( err == KErrArgument )
       
   513 	            		{
       
   514 	            		ShowServerValidationInfoNoteL( R_LOC_SERVER_INFO_NOTE );
       
   515 						iIsEditMode = ETrue;
       
   516 			    		SetEditableL( iIsEditMode );					
       
   517 						SetInitialCurrentLine();								
       
   518 						SetCursorToEndL();
       
   519 	            		//dont close editor            
       
   520 	            		retVal = EFalse;	
       
   521 	            		}
   555             		}
   522             		}
   556             	else
   523             	else
   557             		{ // save the existing slp entry info
   524             		{ // save the existing slp entry info
   558             		if( iSlpId )
   525             		if( iSlpId )
   559             			{
   526             			{
   574 							iIsEditMode = ETrue;
   541 							iIsEditMode = ETrue;
   575 						    SetEditableL( iIsEditMode );
   542 						    SetEditableL( iIsEditMode );
   576 						    SetInitialCurrentLine();	            			
   543 						    SetInitialCurrentLine();	            			
   577 							SetCursorToEndL();
   544 							SetCursorToEndL();
   578             				}
   545             				}
       
   546             			else if( err == KErrArgument )
       
   547             			    {
       
   548             			    ShowServerValidationInfoNoteL( R_LOC_SERVER_INFO_NOTE );
       
   549             			    iIsEditMode = ETrue;
       
   550             			    SetEditableL( iIsEditMode );                    
       
   551             			    SetInitialCurrentLine();                                
       
   552             			    SetCursorToEndL();
       
   553             			    //dont close editor            
       
   554             			    retVal = EFalse;    
       
   555             			    }
   579             			}
   556             			}
   580 	            	HandleMSKCaptionL();
   557 	            	HandleMSKCaptionL();
   581 		            //dont close editor            
   558 		            //dont close editor            
   582 		            retVal = EFalse;	            		
   559 		            retVal = EFalse;	            		
   583             		}
   560             		}
   653         if( apString->Compare( iIap->Des() ) == 0 ) 
   630         if( apString->Compare( iIap->Des() ) == 0 ) 
   654         	{
   631         	{
   655         	iIap->Des().Copy( KNullDesC );
   632         	iIap->Des().Copy( KNullDesC );
   656         	}
   633         	}
   657         delete apString;
   634         delete apString;
   658        	}
   635         }
   659 	
   636 
   660 	//Retrieve Usage In Home Nw Field value
   637     //Retrieve Usage In Home Nw Field value
   661    	CAknPopupFieldText* usageInHomeNWPopupFieldText =
   638     CEikEdwin* usageInHomeNWPopupFieldText = (CEikEdwin*) Control(
   662          	( CAknPopupFieldText* ) Control( ELocSuplServerIdUsageInHomeNw );
   639             ELocSuplServerIdUsageInHomeNw);
   663    	if( usageInHomeNWPopupFieldText )
   640     if (usageInHomeNWPopupFieldText)
   664        	{
   641         {
   665        	if( usageInHomeNWPopupFieldText->CurrentValueIndex() == 0 )
   642         TBuf<KMaxUsageTextSize> des;
   666        		{
   643         usageInHomeNWPopupFieldText->GetText(des);
   667        		iUsageInHomeNw = ETrue;
   644         if (!des.Compare(KNoUsageInHomeNetork))
   668        		}
   645             {
   669        	else
   646             iUsageInHomeNw = ETrue;
   670        		{
   647             }
   671         	iUsageInHomeNw = EFalse;      		
   648         else
   672        		}
   649             {
   673        	}
   650             iUsageInHomeNw = EFalse;
       
   651             }
       
   652         }
   674 
   653 
   675     if( iServerAddress->Length() > 0 )
   654     if( iServerAddress->Length() > 0 )
   676     	{
   655     	{
   677     	retVal = ETrue;
   656     	retVal = ETrue;
   678     	}       	       	    
   657     	}       	       	    
   834        	if( apSelector )
   813        	if( apSelector )
   835             {   
   814             {   
   836             HBufC* apString = StringLoader::LoadL( R_LOC_SERVER_NONE );   
   815             HBufC* apString = StringLoader::LoadL( R_LOC_SERVER_NONE );   
   837             apSelector->SetTextL( apString );
   816             apSelector->SetTextL( apString );
   838             delete apString;
   817             delete apString;
   839             } 
   818             }
   840        	apSelector->DrawNow();
   819         apSelector->DrawNow();
   841         
   820 
       
   821         CEikEdwin* usageInHNWPopupFieldText = (CEikEdwin*) Control(
       
   822                 ELocSuplServerIdUsageInHomeNw);
       
   823         if (usageInHNWPopupFieldText)
       
   824             {
       
   825             HBufC* usageString = StringLoader::LoadL(
       
   826                     R_LOC_SERVER_USAGEINHOMENETWORK_YES);
       
   827             usageInHNWPopupFieldText->SetTextL(usageString);
       
   828             delete usageString;
       
   829             }
       
   830         usageInHNWPopupFieldText->DrawNow();
       
   831 
   842         // update the title pane caption
   832         // update the title pane caption
   843        	HBufC* serverTitle = StringLoader::LoadL( R_LOC_SERVER_EDITOR_TITLE ); 
   833        	HBufC* serverTitle = StringLoader::LoadL( R_LOC_SERVER_EDITOR_TITLE ); 
   844        	if( serverTitle )
   834        	if( serverTitle )
   845             {
   835             {
   846         	ChangeTitlePaneTextL( *serverTitle ); 
   836         	ChangeTitlePaneTextL( *serverTitle ); 
   900             	            
   890             	            
   901         	apSelector->DrawNow();
   891         	apSelector->DrawNow();
   902         	iIap->Des().Copy( iapName->Des() );
   892         	iIap->Des().Copy( iapName->Des() );
   903             } 
   893             } 
   904 
   894 
   905         CAknPopupFieldText* usageInHNWPopupFieldText = 
   895         CEikEdwin* usageInHNWPopupFieldText = (CEikEdwin*) Control(
   906         			( CAknPopupFieldText* ) Control( ELocSuplServerIdUsageInHomeNw );
   896                 ELocSuplServerIdUsageInHomeNw);
   907         if( usageInHNWPopupFieldText )
   897         if (usageInHNWPopupFieldText)
   908             {  
   898             {
   909             if( usageInHomeNwFlag  )
   899             if (usageInHomeNwFlag)
   910             	usageInHNWPopupFieldText->SetCurrentValueIndex( 0 );                  	
   900                 SetUsageinHomeNetwork(EFalse);
   911             else
   901             else
   912             	usageInHNWPopupFieldText->SetCurrentValueIndex( 1 );                  	
   902                 SetUsageinHomeNetwork(ETrue);
   913             
   903 
   914             UpdatePageL( ETrue );
   904             UpdatePageL(ETrue);
   915             iUsageInHomeNw = usageInHomeNwFlag;
   905             iUsageInHomeNw = usageInHomeNwFlag;
   916             }            
   906             }            
   917             
   907             
   918 	    delete iapName;
   908 	    delete iapName;
   919 	    delete hslpAddr;	    
   909 	    delete hslpAddr;	    
   946     }     
   936     }     
   947 
   937 
   948 // ---------------------------------------------------------------------------
   938 // ---------------------------------------------------------------------------
   949 // CLocSUPLServerEditor::TogglePopupFieldControlL()
   939 // CLocSUPLServerEditor::TogglePopupFieldControlL()
   950 // it toggles  value of popupfield control
   940 // it toggles  value of popupfield control
       
   941 // This method is no longer in use since TB 9.2
   951 // ---------------------------------------------------------------------------
   942 // ---------------------------------------------------------------------------
   952 //
   943 //
   953 void CLocSUPLServerEditor::TogglePopupFieldControlL( TInt aControlId )
   944 void CLocSUPLServerEditor::TogglePopupFieldControlL( TInt aControlId )
   954     {
   945     {
   955 	DEBUG( + CLocSUPLServerEditor::TogglePopupFieldControlL );
   946 	DEBUG( + CLocSUPLServerEditor::TogglePopupFieldControlL );
  1127             	}
  1118             	}
  1128         	delete address;     			
  1119         	delete address;     			
  1129    			}
  1120    			}
  1130 		}
  1121 		}
  1131 	}
  1122 	}
       
  1123 // ----------------------------------------------------------------------------------
       
  1124 // CLocSUPLServerEditor::HandleDialogPageEventL
       
  1125 // ----------------------------------------------------------------------------------
       
  1126 //
       
  1127 void CLocSUPLServerEditor::HandleDialogPageEventL(TInt aEventID)
       
  1128     {
       
  1129     DEBUG( +CLocSUPLServerEditor::HandleDialogPageEventL );
       
  1130 
       
  1131     CAknForm::HandleDialogPageEventL(aEventID);
       
  1132     CEikEdwin* iapEditor = static_cast<CEikEdwin*> (ControlOrNull(
       
  1133             ELocSuplServerIdAccessPoint));
       
  1134     CEikEdwin* usageInHomeNWPopupFieldText = (CEikEdwin*) Control(
       
  1135             ELocSuplServerIdUsageInHomeNw);
       
  1136     TInt focusControl(IdOfFocusControl());
       
  1137 
       
  1138     if (!IsEditable())
       
  1139         {
       
  1140         if (focusControl == ELocSuplServerIdUsageInHomeNw
       
  1141                 || ELocSuplServerIdServerAddr || ELocSuplServerIdAccessPoint)
       
  1142             {
       
  1143             ProcessCommandL(EAknFormCmdEdit);
       
  1144             }
       
  1145         }
       
  1146     else if (aEventID == MEikDialogPageObserver::EDialogPageTapped)
       
  1147         {
       
  1148         if (focusControl == ELocSuplServerIdUsageInHomeNw)
       
  1149             {
       
  1150             if (usageInHomeNWPopupFieldText)
       
  1151                 {
       
  1152                 TBuf<KMaxUsageTextSize> des;
       
  1153                 usageInHomeNWPopupFieldText->GetText(des);
       
  1154                 if (!des.Compare(KNoUsageInHomeNetork))
       
  1155                     {
       
  1156                     SetUsageinHomeNetwork(ETrue);
       
  1157                     }
       
  1158                 else
       
  1159                     {
       
  1160                     SetUsageinHomeNetwork(EFalse);
       
  1161                     }
       
  1162                 if (iIsNewServer)
       
  1163                     {
       
  1164                     iIsModified = ETrue;
       
  1165                     }
       
  1166                 }
       
  1167             return;
       
  1168             }
       
  1169         if (focusControl == ELocSuplServerIdAccessPoint)
       
  1170             {
       
  1171             if (iapEditor)
       
  1172                 {
       
  1173                 //Launch IAP Dialog
       
  1174                 TRAP_IGNORE( iEngine.LaunchApConfiguratorL( iSlpId, this ) );
       
  1175                 }
       
  1176             }
       
  1177         }DEBUG( -CLocSUPLServerEditor::HandleDialogPageEventL );
       
  1178     }
       
  1179 
       
  1180 // -----------------------------------------------------------------------------
       
  1181 // CLocSUPLServerEditor::SetUsageinHomeNetwork
       
  1182 // Set usage in network field on or off
       
  1183 // -----------------------------------------------------------------------------
       
  1184 //
       
  1185 void CLocSUPLServerEditor::SetUsageinHomeNetwork(TBool aOnOff)
       
  1186     {
       
  1187     HBufC* string;
       
  1188     CEikEdwin* usageInHomeNWPopupFieldText = (CEikEdwin*) Control(
       
  1189             ELocSuplServerIdUsageInHomeNw);
       
  1190     if (aOnOff)
       
  1191         {
       
  1192         // load string 'ON'
       
  1193         string = StringLoader::LoadLC(R_LOC_SERVER_USAGEINHOMENETWORK_YES,
       
  1194                 iCoeEnv);
       
  1195         }
       
  1196     else
       
  1197         {
       
  1198         // load string 'OFF'
       
  1199         string = StringLoader::LoadLC(R_LOC_SERVER_USAGEINHOMENETWORK_NO,
       
  1200                 iCoeEnv);
       
  1201         }
       
  1202     // set Usage in Network field string as 'ON'/'OFF'
       
  1203     usageInHomeNWPopupFieldText->SetTextL(string);
       
  1204     CleanupStack::PopAndDestroy(string);
       
  1205     }
  1132 
  1206 
  1133 // End of file
  1207 // End of file