networkingtestandutils/ipanalyzer/src/iprotor.cpp
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // iprotor.cpp - protocol analyzer main module
       
    15 // This software has been implemented in the 6PACK
       
    16 // project at the Mobile Networks Laboratory (MNW)
       
    17 // http://www.research.nokia.com/projects/6pack/
       
    18 // This file contains the C++ source code for the iprotor
       
    19 // example program. This builds on the iprotor program, but has the 
       
    20 // following additions:
       
    21 // - the resource file, iprotor.rss, defines a toolbar for the
       
    22 // application
       
    23 // - the constructor for the App UI contains code that displays the
       
    24 // application name at the top of the toolbar
       
    25 // - the resource file defines an additional menu pane, labeled 
       
    26 // "Tools" and containing the four commands that can be invoked
       
    27 // from the toolbar 
       
    28 // - the .hrh file that defines the commands invoked by the Tools
       
    29 // menu/toolbar.
       
    30 // - HandleCommandL() is expanded to handle the additional commands
       
    31 // (they do nothing but print out an error message).
       
    32 //
       
    33 
       
    34 #include <basched.h>
       
    35 #include <e32math.h>
       
    36 
       
    37 #if EPOC_SDK < 0x06000000
       
    38 #include <eikenv.h>
       
    39 #include <coecntrl.h>
       
    40 #include <eikappui.h>
       
    41 #include <e32keys.h>
       
    42 #include <techview/eikmenup.h>
       
    43 #include <eikmenu.hrh>
       
    44 #include <eikdef.h>
       
    45 #include <techview/eikon.rsg>
       
    46 #include <techview/eikpgsel.h>
       
    47 
       
    48 #include <techview/eiklabel.h>
       
    49 #include <eikdialg.hrh>
       
    50 #endif
       
    51 
       
    52 #ifdef MAKE_EXE_APPLICATION
       
    53 #include <eikstart.h>
       
    54 #endif
       
    55 
       
    56 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    57 #include <s32stor.h>
       
    58 #endif
       
    59 
       
    60 #include <techview/eikfontd.h>
       
    61 #include <techview/eikchlst.h>
       
    62 #include "iprotor.h"
       
    63 
       
    64 
       
    65 #define PI 3.141592654
       
    66 #define KLabelHeight	25
       
    67 
       
    68 //
       
    69 // EXPORTed functions
       
    70 //
       
    71 
       
    72 EXPORT_C CApaApplication* NewApplication()
       
    73 	{
       
    74 	return new CRotorApplication;
       
    75 	}
       
    76 
       
    77 #ifdef MAKE_EXE_APPLICATION
       
    78 GLDEF_C TInt E32Main()
       
    79 	{
       
    80 	return EikStart::RunApplication(NewApplication);
       
    81 	}
       
    82 
       
    83 #else
       
    84 
       
    85 #ifndef EKA2
       
    86 GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
       
    87 
       
    88 	{
       
    89 	return KErrNone;
       
    90 	}
       
    91 #endif
       
    92 
       
    93 #endif // MAKE_EXE_APPLICATION
       
    94 
       
    95 
       
    96 //
       
    97 //
       
    98 // Application class, CRotorApplication
       
    99 //
       
   100 //
       
   101 
       
   102 TUid CRotorApplication::AppDllUid() const
       
   103 	{
       
   104 	return KUidRotorApp;
       
   105 	}
       
   106 
       
   107 CApaDocument* CRotorApplication::CreateDocumentL()
       
   108 	{
       
   109 	return new (ELeave) CRotorDocument(*this);
       
   110 	}
       
   111 
       
   112 
       
   113 //
       
   114 //
       
   115 // Document class, CRotorDocument
       
   116 //
       
   117 //
       
   118 
       
   119 CRotorDocument::CRotorDocument(CEikApplication& aApp)
       
   120 		: CEikDocument(aApp)
       
   121 	{
       
   122 	}
       
   123 
       
   124 CEikAppUi* CRotorDocument::CreateAppUiL()
       
   125 	{
       
   126     return new(ELeave) CRotorAppUi;
       
   127 	}
       
   128 
       
   129 
       
   130 //
       
   131 //
       
   132 // App UI class, CRotorAppUi
       
   133 //
       
   134 //
       
   135 
       
   136 void CRotorAppUi::ConstructL()
       
   137     {
       
   138     BaseConstructL();
       
   139 
       
   140     iAppView=new(ELeave) CRotorAppView;
       
   141 	CleanupStack::PushL(iAppView);
       
   142     iAppView->ConstructL(ClientRect(), this);
       
   143 	iAppView->SwitchRotorL();
       
   144 	CleanupStack::Pop();
       
   145 	//AddToStackL(iAppView->Console());
       
   146 	// Display the application name at the top of the toolbar
       
   147 	// First get the control to display it in.
       
   148 #if EPOC_SDK < 0x06000000
       
   149 	CEikFileNameLabel* filenameLabel=STATIC_CAST(CEikFileNameLabel*, iToolBar->ControlById(ERotorCmdFileName));
       
   150 	// Then display the application name. UpdateL() displays the application's 
       
   151 	// main document file name in the filename label control. However, in this
       
   152 	// application, there is no main document file (because the application is
       
   153 	// not file based). In this case, UpdateL() displays the application name by
       
   154 	// default.
       
   155 	filenameLabel->UpdateL();
       
   156 #endif	
       
   157     }
       
   158 
       
   159 
       
   160 CRotorAppUi::~CRotorAppUi()
       
   161 	{
       
   162 #ifndef CALYPSO
       
   163 	RemoveFromStack(iAppView);
       
   164 #endif
       
   165     delete iAppView;
       
   166 	}
       
   167 
       
   168 
       
   169 void CRotorAppUi::DynInitMenuPaneL(TInt aMenuId,CEikMenuPane* aMenuPane)
       
   170 {
       
   171 	iAppView->DynInitMenuPaneL(aMenuId, aMenuPane);
       
   172 }
       
   173 
       
   174 void CRotorAppUi::RestorePreferencesL(TPreferences &aPreferences) const
       
   175 {
       
   176 	CDictionaryStore *iniFile = Application()->OpenIniFileLC(iCoeEnv->FsSession());
       
   177 	TBool found = iniFile->IsPresentL(KUidRotorApp); //replace XXUid with uid of prefs - usually the UID of the main app
       
   178 	TInt error = KErrNone;
       
   179 
       
   180 	if (found) 
       
   181 	{
       
   182 		RDictionaryReadStream readStream;
       
   183 		readStream.OpenLC (*iniFile, KUidRotorApp);
       
   184 		// ignore any reads off the end of the file etc - clear later on
       
   185 
       
   186 		TRAP(error, aPreferences.iDumpIPv4 = readStream.ReadUint8L());
       
   187 		TRAP(error, aPreferences.iDumpIPv6 = readStream.ReadUint8L());
       
   188 		TRAP(error, aPreferences.iDumpIPSEC = readStream.ReadUint8L());
       
   189 		TRAP(error, aPreferences.iProtocol = readStream.ReadInt16L());
       
   190 		TRAP(error, aPreferences.iPort = readStream.ReadUint16L());
       
   191 		TRAP(error, aPreferences.iViewIPHdr = readStream.ReadUint8L());
       
   192 		TRAP(error, aPreferences.iNumBlades = readStream.ReadInt16L());
       
   193 
       
   194 		CleanupStack::PopAndDestroy(); // readStream
       
   195 	}
       
   196 
       
   197 	CleanupStack::PopAndDestroy(); // iniFile
       
   198 
       
   199 	if (error!=KErrNone || !found) 
       
   200 	{
       
   201 		// missing stream initialise
       
   202 		CRotorEngine::DefaultPreferences(aPreferences);
       
   203 
       
   204 		//.... // and whatever is appropriate for all the other fields
       
   205 		StorePreferencesL(aPreferences); // store the default ones - update inifile
       
   206 	}
       
   207 }
       
   208 
       
   209 void CRotorAppUi::StorePreferencesL(const TPreferences &aPreferences) const
       
   210 {
       
   211 	CDictionaryStore *iniFile = Application()->OpenIniFileLC(iCoeEnv->FsSession());
       
   212 	RDictionaryWriteStream writeStream;
       
   213 	writeStream.AssignLC(*iniFile, KUidRotorApp);
       
   214 
       
   215 	writeStream.WriteUint8L(aPreferences.iDumpIPv4);
       
   216 	writeStream.WriteUint8L(aPreferences.iDumpIPv6);
       
   217 	writeStream.WriteUint8L(aPreferences.iDumpIPSEC);
       
   218 	writeStream.WriteInt16L(aPreferences.iProtocol);
       
   219 	writeStream.WriteUint16L(aPreferences.iPort);
       
   220 	writeStream.WriteUint8L(aPreferences.iViewIPHdr);
       
   221 	writeStream.WriteInt16L(aPreferences.iNumBlades);
       
   222 	//.... // and whatever
       
   223 
       
   224 	writeStream.CommitL();
       
   225 	CleanupStack::PopAndDestroy(); // write stream
       
   226 
       
   227 	// in this replace XXVersionUid with another unique UID - usually the next one up from XXUid
       
   228 	writeStream.AssignLC(*iniFile, KUidRotorAppUid); // write version 1.0 (major.minor)
       
   229 	writeStream.WriteInt8L(1); // major
       
   230 	writeStream.WriteInt8L(0); // minor
       
   231 	writeStream.CommitL(); // flush
       
   232 	CleanupStack::PopAndDestroy(); // writeStream;
       
   233 
       
   234 	// commit changes to the store
       
   235 	if (iniFile->Commit()!=KErrNone)
       
   236 		iniFile->RevertL();
       
   237 
       
   238 	CleanupStack::PopAndDestroy();	//inifile
       
   239 }
       
   240 
       
   241 void CRotorAppUi::HandleCommandL(TInt aCommand)
       
   242 	{
       
   243 	TPreferences param;
       
   244 
       
   245 	switch (aCommand)
       
   246 		{
       
   247 	// Each command in the toolbar/Tools menu prints an info message
       
   248 	// using the EIKON InfoMsg() function.
       
   249 	case ERotorStart:
       
   250 		//iEikonEnv->InfoMsg(R_ROTOR_COMMAND_1);
       
   251 		iAppView->StartL();
       
   252 		break;
       
   253 	case ERotorStop:
       
   254 		iAppView->StopL();
       
   255 		//iEikonEnv->InfoMsg(R_EXAMPLE_COMMAND_2);
       
   256 		break;
       
   257 	case ERotorNoRotor:
       
   258 		iAppView->SwitchRotorL();
       
   259 		break;
       
   260 
       
   261 	case ERotorOptions:
       
   262 		//iEikonEnv->InfoMsg(R_NOT_IMPLEMENTED);
       
   263 		LaunchOptionsDialogL(iAppView->Model());
       
   264 		break;
       
   265 	case ERotorIPv4View:
       
   266 		LaunchIPv4ViewDialogL(iAppView->Model()->MonIPv4Info());
       
   267 		break;
       
   268 	case ERotorIPv6View:
       
   269 		LaunchIPv6ViewDialogL(iAppView->Model()->MonIPv6Info());
       
   270 		break;
       
   271 	case ERotorIPv6ExtView:
       
   272 		LaunchIPv6ExtViewDialogL(iAppView->Model()->MonIPv6Info());
       
   273 		break;
       
   274 /*	case ERotorAHPacketView:
       
   275 		LaunchAHPacketViewDialog(iAppView->Model()->MonInfo());
       
   276 		break;*/
       
   277 	case ERotorClearScreen:
       
   278 		//iConsole->ClearScreen();	//Only clears visible part of console
       
   279 		iAppView->ClearScreenL();
       
   280 		break;
       
   281 	case ERotorAbout:
       
   282 		LaunchAboutDialogL();
       
   283 		break;
       
   284 	case EEikCmdExit: 
       
   285 		iAppView->Model()->GetPreferences(param);
       
   286 		StorePreferencesL(param);
       
   287 		Exit();
       
   288 		break;
       
   289 	default:	//Console Specific Commands
       
   290 		iAppView->HandleCommandL(aCommand);
       
   291 		}
       
   292 	}
       
   293 
       
   294 
       
   295 
       
   296 // Launches a dialog to ask for new options
       
   297 TBool CRotorAppUi::LaunchOptionsDialogL(CRotorEngine* aModel) const
       
   298 {
       
   299 	COptionsDialog *dialog=new (ELeave) COptionsDialog(aModel);
       
   300 	TInt button=dialog->ExecuteLD(R_ROTOR_OPTIONS_DIALOG);	//Final D means the dialog is destructed by itself
       
   301 	return (button==EEikBidOk);	// If button is CANCEL then the algorithm is not added
       
   302 }
       
   303 
       
   304 // Launches a dialog to ask for IPv4 view options
       
   305 TBool CRotorAppUi::LaunchIPv4ViewDialogL(SMonIPv4Info *aMonInfo) const
       
   306 {
       
   307 	CIPv4ViewDialog *dialog=new (ELeave) CIPv4ViewDialog(aMonInfo);
       
   308 	TInt button=dialog->ExecuteLD(R_ROTOR_IPV4_VIEW_DIALOG);	//Final D means the dialog is destructed by itself
       
   309 	return (button==EEikBidOk);	// If button is CANCEL then the algorithm is not added
       
   310 }
       
   311 
       
   312 // Launches a dialog to ask for IPv6 view options
       
   313 TBool CRotorAppUi::LaunchIPv6ViewDialogL(SMonIPv6Info *aMonInfo) const
       
   314 {
       
   315 	CIPv6ViewDialog *dialog=new (ELeave) CIPv6ViewDialog(aMonInfo);
       
   316 	TInt button=dialog->ExecuteLD(R_ROTOR_IPV6_VIEW_DIALOG);	//Final D means the dialog is destructed by itself
       
   317 	return (button==EEikBidOk);	// If button is CANCEL then the algorithm is not added
       
   318 }
       
   319 
       
   320 // Launches a dialog to ask for IPv6 Extensions view options
       
   321 TBool CRotorAppUi::LaunchIPv6ExtViewDialogL(SMonIPv6Info *aMonInfo) const
       
   322 {
       
   323 	CIPv6ExtViewDialog *dialog=new (ELeave) CIPv6ExtViewDialog(aMonInfo);
       
   324 	TInt button=dialog->ExecuteLD(R_ROTOR_IPV6EXT_VIEW_DIALOG);	//Final D means the dialog is destructed by itself
       
   325 	return (button==EEikBidOk);	// If button is CANCEL then the algorithm is not added
       
   326 }
       
   327 
       
   328 
       
   329 // Launches a dialog to show an about box
       
   330 void CRotorAppUi::LaunchAboutDialogL() const
       
   331 	{
       
   332 	CEikDialog* dialog = new (ELeave) CEikDialog();
       
   333 	dialog->ExecuteLD(R_ROTOR_ABOUT);	//Final D means the dialog is destructed by itself
       
   334 	}
       
   335 //
       
   336 //
       
   337 // Application view class, CRotorAppView
       
   338 //
       
   339 //
       
   340 
       
   341 void CRotorAppView::ConstructL(const TRect& aRect, const CRotorAppUi *aRotorUi)
       
   342 {
       
   343     CreateWindowL();
       
   344 
       
   345 #if EPOC_SDK < 0x06000000
       
   346     SetRectL(aRect);
       
   347 #else
       
   348 	SetRect(aRect);
       
   349 #endif
       
   350     iContext=this;
       
   351 	iBrushStyle=CGraphicsContext::ESolidBrush;
       
   352     iBrushColor=KRgbWhite;
       
   353 
       
   354     //TFontSpec spec(_L("Swiss"),213);
       
   355     //iRotorFont=iCoeEnv->CreateScreenFontL(spec);
       
   356 	//iRotorText=iCoeEnv->AllocReadResourceL(R_EXAMPLE_TEXT);
       
   357 
       
   358 	// Component controls initialization
       
   359 	
       
   360 	
       
   361 	//CreateConsoleL(CEikConsoleScreen::ENoInitialCursor);
       
   362 	InitFontL();
       
   363 	CreateRotorL();
       
   364 	CreateFamilyLabelL();
       
   365 	CreateProtocolLabelL();
       
   366 	CreateNetLabelL();
       
   367 	CreateSpeedLabelL();
       
   368 	CreateStatLabelsL();
       
   369 	
       
   370 	iRunning=EFalse;	//engine NOT running
       
   371 	//Model or engine
       
   372 	TPreferences param;
       
   373 	aRotorUi->RestorePreferencesL(param);	//Reads the .ini file
       
   374 	iModel= new (ELeave) CRotorEngine(this);
       
   375 	iModel->ConstructL(param);
       
   376 	iModel->iShowPackets=EFalse;	//Tells the engine to avoid using the console
       
   377     ActivateL();
       
   378 }
       
   379 
       
   380 
       
   381 
       
   382 void CRotorAppView::InitFontL()
       
   383 {
       
   384 	//TFontSpec spec(_L("Swiss"),180);
       
   385 	TFontSpec spec(_L("Times"),175);
       
   386 	spec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
       
   387 	spec.iTypeface.SetIsProportional(EFalse);
       
   388 	spec.iTypeface.SetIsSerif(ETrue);
       
   389 	iFont=iCoeEnv->CreateScreenFontL(spec);
       
   390 }
       
   391 
       
   392 void CRotorAppView::CreateRotorL()
       
   393 {
       
   394 	
       
   395 	TRect rect=Rect();
       
   396 	iRotor = new(ELeave) CRotor(&iModel->iPref.iNumBlades);
       
   397 	CleanupStack::PushL(iRotor);
       
   398 	/*
       
   399 	rect.iTl.iX=4*rect.iBr.iX/6;	//  right 1/3 of the screen
       
   400 	rect.iTl.iY=KLabelHeight; // make it 20 pixels
       
   401 	rect.iBr.iY-=2*KLabelHeight;
       
   402 	*/
       
   403 	rect.iBr.iX=2*rect.iBr.iX/5;	//left 1/3 of the screen
       
   404 	rect.iTl.iY=KLabelHeight;		// make it 20 pixels
       
   405 	rect.iBr.iY-=KLabelHeight;
       
   406 
       
   407 	rect.Shrink(3,3);
       
   408 	iRotor->ConstructL(rect);
       
   409 	iRotor->SetContainerWindowL(*this);
       
   410 	CleanupStack::Pop();
       
   411 	
       
   412 }
       
   413 
       
   414 
       
   415 void CRotorAppView::CreateConsoleL(TInt aFlags)
       
   416 {
       
   417 	/*
       
   418 	iConsole=new(ELeave) CConsoleControl;
       
   419 	CleanupStack::PushL(iConsole);
       
   420 	TRect rect=Rect();
       
   421 	rect.iBr.iX=4*rect.iBr.iX/6 - 2;	//left 4/6 of screen -2 To put a separation on the right of the console
       
   422 	rect.Shrink(3,3);
       
   423 	//TSize size(rect.Size());
       
   424 	//size.iWidth-=50;
       
   425 	iConsole->SetRectL(rect);
       
   426 	iConsole->ConstructL(rect.iTl, rect.Size(),aFlags);
       
   427 	//iConsole->SetContainerWindowL(*this);
       
   428 	iConsole->SetRectL(rect);
       
   429 	iConsole->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOn);
       
   430 	CleanupStack::Pop();
       
   431 	TBool b=iConsole->UpdateScrollBars();
       
   432 	iConsole->ConsoleControl()->UpdateArea();
       
   433 	b=iConsole->UpdateScrollBars();
       
   434 	iConsole->DrawCursor();
       
   435 	*/
       
   436 	iConsole=new(ELeave) CConsoleControl;
       
   437 	//iConsole->ConstructL(aFlags);
       
   438 	TRect rect=Rect();
       
   439 	rect.iBr.iX=4*rect.iBr.iX/6 - 2;	//left 4/6 of screen -2 To put a separation on the right of the console
       
   440 	rect.Shrink(3,3);
       
   441 	//rect.iBr.iX=4*rect.iBr.iX/6 - 2;	//left 4/6 of screen -2 To put a separation on the right of the console
       
   442 	//iConsole->SetRect()
       
   443 	iConsole->ConstructL(rect.iTl,rect.Size(),aFlags);
       
   444 	iConsole->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
       
   445 	
       
   446 }
       
   447 
       
   448 
       
   449 void CRotorAppView::CreateBigConsoleL(TInt aFlags)
       
   450 {
       
   451 	/*
       
   452 	iConsole=new(ELeave) CConsoleControl;
       
   453 	CleanupStack::PushL(iConsole);
       
   454 	TRect rect=Rect();
       
   455 	rect.iBr.iX=4*rect.iBr.iX/6 - 2;	//left 4/6 of screen -2 To put a separation on the right of the console
       
   456 	rect.Shrink(3,3);
       
   457 	//TSize size(rect.Size());
       
   458 	//size.iWidth-=50;
       
   459 	iConsole->SetRectL(rect);
       
   460 	iConsole->ConstructL(rect.iTl, rect.Size(),aFlags);
       
   461 	//iConsole->SetContainerWindowL(*this);
       
   462 	iConsole->SetRectL(rect);
       
   463 	iConsole->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOn);
       
   464 	CleanupStack::Pop();
       
   465 	TBool b=iConsole->UpdateScrollBars();
       
   466 	iConsole->ConsoleControl()->UpdateArea();
       
   467 	b=iConsole->UpdateScrollBars();
       
   468 	iConsole->DrawCursor();
       
   469 	*/
       
   470 	iConsole=new(ELeave) CConsoleControl;
       
   471 	//iConsole->ConstructL(aFlags);
       
   472 	iConsole->ConstructL(Position(),Size(),aFlags);
       
   473 	iConsole->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
       
   474 	
       
   475 }
       
   476 
       
   477 void CRotorAppView::CreateProtocolLabelL()
       
   478 {
       
   479 	iProtocolLabel=new (ELeave) CEikLabel;
       
   480 	TRect rect=Rect();
       
   481 /*
       
   482 	rect.iTl.iX=4*rect.iBr.iX/6;	
       
   483 	rect.iBr.iY=KLabelHeight; // make it 20 pixels
       
   484 	
       
   485 */
       
   486 	rect.iBr.iX=rect.iBr.iX/5;	
       
   487 	rect.iBr.iY=KLabelHeight; // make it 20 pixels
       
   488 
       
   489 	rect.Shrink(3,3);
       
   490 	iProtocolLabel->SetContainerWindowL(*this);
       
   491 #if EPOC_SDK < 0x06000000
       
   492     iProtocolLabel->SetRectL(rect);
       
   493 #else
       
   494 	iProtocolLabel->SetRect(rect);
       
   495 #endif
       
   496 	iProtocolLabel->SetAlignment(EHCenterVCenter); // center text
       
   497 	iProtocolLabel->SetBufferReserveLengthL(26);
       
   498 	iProtocolLabel->SetTextL(_L("Not Active\n")); // nice long buffer
       
   499 
       
   500 	/*
       
   501 	CFont *font;
       
   502 	TFontSpec fontSpec=iTypeLabel->Font()->FontSpecInTwips();
       
   503 	//CTypefaceStore *faceStore= new CTypefaceStore();
       
   504 	//faceStore->ConstructL();
       
   505 	//TInt err=GetNearestFontInTwips(font,fontSpec);
       
   506 	CGraphicsDevice* screenDevice=(iCoeEnv->ScreenDevice());
       
   507     screenDevice->GetNearestFontInTwips(font,fontSpec);
       
   508 	iTypeLabel->SetFont(font);
       
   509 */
       
   510 	//iTypeLabel->SetFontL(); // nice long buffer
       
   511 	
       
   512 	//iTypeLabel->ActivateL(); // now ready
       
   513 }
       
   514 
       
   515 void CRotorAppView::CreateNetLabelL()
       
   516 {
       
   517 	iNetLabel=new (ELeave) CEikLabel;
       
   518 	TRect rect=Rect();
       
   519 /*
       
   520 	rect.iTl.iX=4*rect.iBr.iX/6;	
       
   521 	rect.iBr.iY=KLabelHeight; // make it 20 pixels
       
   522 	
       
   523 */
       
   524 	rect.iTl.iX+=rect.iBr.iX/5;		
       
   525 	rect.iBr.iX=2*rect.iBr.iX/5;	
       
   526 	rect.iBr.iY=KLabelHeight; // make it 20 pixels
       
   527 
       
   528 	rect.Shrink(3,3);
       
   529 	iNetLabel->SetContainerWindowL(*this);
       
   530 #if EPOC_SDK < 0x06000000
       
   531     iNetLabel->SetRectL(rect);
       
   532 #else
       
   533 	iNetLabel->SetRect(rect);
       
   534 #endif
       
   535 	iNetLabel->SetAlignment(EHCenterVCenter); // center text
       
   536 	iNetLabel->SetBufferReserveLengthL(26);
       
   537 	//iTypeLabel->SetFontL(); // nice long buffer
       
   538 	iNetLabel->SetTextL(_L("Net DOWN")); // nice long buffer
       
   539 	//iTypeLabel->ActivateL(); // now ready
       
   540 }
       
   541 
       
   542 
       
   543 void CRotorAppView::CreateFamilyLabelL()
       
   544 {
       
   545 	iFamilyLabel=new (ELeave) CEikLabel;
       
   546 	TRect rect=Rect();
       
   547 /*
       
   548 	rect.iTl.iX=4*rect.iBr.iX/6;	
       
   549 	rect.iBr.iY=KLabelHeight; // make it 20 pixels
       
   550 	
       
   551 */
       
   552 	rect.iTl.iX+=2*rect.iBr.iX/5;
       
   553 	rect.iBr.iY=KLabelHeight;
       
   554 
       
   555 	rect.Shrink(3,3);
       
   556 	iFamilyLabel->SetContainerWindowL(*this);
       
   557 #if EPOC_SDK < 0x06000000
       
   558     iFamilyLabel->SetRectL(rect);
       
   559 #else
       
   560 	iFamilyLabel->SetRect(rect);
       
   561 #endif
       
   562 	iFamilyLabel->SetAlignment(EHCenterVCenter); // center text
       
   563 	iFamilyLabel->SetBufferReserveLengthL(31);
       
   564 	iFamilyLabel->SetTextL(_L("---")); // nice long buffer
       
   565 	//iTypeLabel->SetFontL(); // nice long buffer
       
   566 	
       
   567 	//iTypeLabel->ActivateL(); // now ready
       
   568 }
       
   569 
       
   570 void CRotorAppView::CreateRecvPacketsLabelL()
       
   571 {
       
   572 	/*
       
   573 	iRecvPacketsLabel=new (ELeave) CEikLabel;
       
   574 	TRect rect=Rect();
       
   575 	
       
   576 	//rect.iTl.iX=3*rect.iBr.iX/5;	// Label is in right 1/3 of the screen
       
   577 	//rect.iTl.iY+=2*KLabelHeight;
       
   578 	//rect.iBr.iY=3*KLabelHeight; // make it 20 pixels
       
   579 	
       
   580 	rect.iBr.iX=2*rect.iBr.iX/5;	//left 1/3 of the screen
       
   581 	rect.iTl.iY=rect.iBr.iY-KLabelHeight;
       
   582 	rect.Shrink(3,3);
       
   583 	
       
   584 	iRecvPacketsLabel->SetContainerWindowL(*this);
       
   585 	iRecvPacketsLabel->SetRectL(rect);
       
   586 	iRecvPacketsLabel->SetAlignment(EHLeftVCenter); // center text
       
   587 	iRecvPacketsLabel->SetBufferReserveLengthL(26);
       
   588 	iRecvPacketsLabel->SetTextL(_L(" Packets received: 0")); // nice long buffer
       
   589 	*/
       
   590 
       
   591 	iRecvPacketsLabel=new (ELeave) CEikLabel;
       
   592 	TRect rect=Rect();
       
   593 
       
   594 	rect.iTl.iX+=2*rect.iBr.iX/5;	//left 1/3 of the screen
       
   595 	rect.iTl.iY=6*KLabelHeight;
       
   596 	rect.iBr.iY=7*KLabelHeight;
       
   597 	rect.Shrink(3,3);
       
   598 	
       
   599 	iRecvPacketsLabel->SetContainerWindowL(*this);
       
   600 #if EPOC_SDK < 0x06000000
       
   601     iRecvPacketsLabel->SetRectL(rect);
       
   602 #else
       
   603 	iRecvPacketsLabel->SetRect(rect);
       
   604 #endif
       
   605 	iRecvPacketsLabel->SetAlignment(EHLeftVCenter); // center text
       
   606 	iRecvPacketsLabel->SetBufferReserveLengthL(26);
       
   607 	iRecvPacketsLabel->SetFont(iFont);
       
   608 	iRecvPacketsLabel->SetTextL(_L(" Total:  0 packets")); // nice long buffer
       
   609 }
       
   610 
       
   611 void CRotorAppView::CreateIPv4PacketsLabelL()
       
   612 {
       
   613 	iIPv4PacketsLabel=new (ELeave) CEikLabel;
       
   614 	TRect rect=Rect();
       
   615 
       
   616 	rect.iTl.iX+=2*rect.iBr.iX/5;	//left 1/3 of the screen
       
   617 	rect.iTl.iY=KLabelHeight;
       
   618 	rect.iBr.iY=2*KLabelHeight;
       
   619 	rect.Shrink(3,3);
       
   620 	
       
   621 	iIPv4PacketsLabel->SetContainerWindowL(*this);
       
   622 #if EPOC_SDK < 0x06000000
       
   623     iIPv4PacketsLabel->SetRectL(rect);
       
   624 #else
       
   625 	iIPv4PacketsLabel->SetRect(rect);
       
   626 #endif
       
   627 	iIPv4PacketsLabel->SetAlignment(EHLeftVCenter); // center text
       
   628 	iIPv4PacketsLabel->SetBufferReserveLengthL(26);
       
   629 	iIPv4PacketsLabel->SetFont(iFont);
       
   630 	iIPv4PacketsLabel->SetTextL(_L(" IPv4 :  0 packets")); // nice long buffer
       
   631 }
       
   632 
       
   633 void CRotorAppView::CreateIPv6PacketsLabelL()
       
   634 {
       
   635 	iIPv6PacketsLabel=new (ELeave) CEikLabel;
       
   636 	TRect rect=Rect();
       
   637 
       
   638 	rect.iTl.iX+=2*rect.iBr.iX/5;	//left 1/3 of the screen
       
   639 	rect.iTl.iY=2*KLabelHeight;
       
   640 	rect.iBr.iY=3*KLabelHeight;
       
   641 	rect.Shrink(3,3);
       
   642 	
       
   643 	iIPv6PacketsLabel->SetContainerWindowL(*this);
       
   644 #if EPOC_SDK < 0x06000000
       
   645     iIPv6PacketsLabel->SetRectL(rect);
       
   646 #else
       
   647 	iIPv6PacketsLabel->SetRect(rect);
       
   648 #endif
       
   649 	iIPv6PacketsLabel->SetAlignment(EHLeftVCenter); // center text
       
   650 	iIPv6PacketsLabel->SetBufferReserveLengthL(26);
       
   651 	iIPv6PacketsLabel->SetFont(iFont);
       
   652 	iIPv6PacketsLabel->SetTextL(_L(" IPv6 :  0 packets")); // nice long buffer
       
   653 }
       
   654 
       
   655 void CRotorAppView::CreateTCPPacketsLabelL()
       
   656 {
       
   657 	iTCPPacketsLabel=new (ELeave) CEikLabel;
       
   658 	TRect rect=Rect();
       
   659 
       
   660 	rect.iTl.iX+=2*rect.iBr.iX/5;	//left 1/3 of the screen
       
   661 	rect.iTl.iY=3*KLabelHeight;
       
   662 	rect.iBr.iY=4*KLabelHeight;
       
   663 	rect.Shrink(3,3);
       
   664 	
       
   665 	iTCPPacketsLabel->SetContainerWindowL(*this);
       
   666 #if EPOC_SDK < 0x06000000
       
   667     iTCPPacketsLabel->SetRectL(rect);
       
   668 #else
       
   669 	iTCPPacketsLabel->SetRect(rect);
       
   670 #endif
       
   671 	iTCPPacketsLabel->SetAlignment(EHLeftVCenter); // center text
       
   672 	iTCPPacketsLabel->SetBufferReserveLengthL(26);
       
   673 	iTCPPacketsLabel->SetFont(iFont);
       
   674 	iTCPPacketsLabel->SetTextL(_L(" TCP  :  0 packets")); // nice long buffer
       
   675 }
       
   676 
       
   677 void CRotorAppView::CreateUDPPacketsLabelL()
       
   678 {
       
   679 	iUDPPacketsLabel=new (ELeave) CEikLabel;
       
   680 	TRect rect=Rect();
       
   681 
       
   682 	rect.iTl.iX+=2*rect.iBr.iX/5;	//left 1/3 of the screen
       
   683 	rect.iTl.iY=4*KLabelHeight;
       
   684 	rect.iBr.iY=5*KLabelHeight;
       
   685 	rect.Shrink(3,3);
       
   686 	
       
   687 	iUDPPacketsLabel->SetContainerWindowL(*this);
       
   688 #if EPOC_SDK < 0x06000000
       
   689     iUDPPacketsLabel->SetRectL(rect);
       
   690 #else
       
   691 	iUDPPacketsLabel->SetRect(rect);
       
   692 #endif
       
   693 	iUDPPacketsLabel->SetAlignment(EHLeftVCenter); // center text
       
   694 	iUDPPacketsLabel->SetBufferReserveLengthL(26);
       
   695 	iUDPPacketsLabel->SetFont(iFont);
       
   696 	iUDPPacketsLabel->SetTextL(_L(" UDP  :  0 packets")); // nice long buffer
       
   697 }
       
   698 
       
   699 void CRotorAppView::CreateICMPPacketsLabelL()
       
   700 {
       
   701 	iICMPPacketsLabel=new (ELeave) CEikLabel;
       
   702 	TRect rect=Rect();
       
   703 
       
   704 	rect.iTl.iX+=2*rect.iBr.iX/5;	//left 1/3 of the screen
       
   705 	rect.iTl.iY=5*KLabelHeight;
       
   706 	rect.iBr.iY=6*KLabelHeight;
       
   707 	rect.Shrink(3,3);
       
   708 	
       
   709 	iICMPPacketsLabel->SetContainerWindowL(*this);
       
   710 #if EPOC_SDK < 0x06000000
       
   711     iICMPPacketsLabel->SetRectL(rect);
       
   712 #else
       
   713 	iICMPPacketsLabel->SetRect(rect);
       
   714 #endif
       
   715 	iICMPPacketsLabel->SetAlignment(EHLeftVCenter); // center text
       
   716 	iICMPPacketsLabel->SetBufferReserveLengthL(26);
       
   717 	iICMPPacketsLabel->SetFont(iFont);
       
   718 	iICMPPacketsLabel->SetTextL(_L(" ICMP :  0 packets")); // nice long buffer
       
   719 }
       
   720 
       
   721 void CRotorAppView::CreateExtv6PacketsLabelL()
       
   722 {
       
   723 	iExtv6PacketsLabel=new (ELeave) CEikLabel;
       
   724 	TRect rect=Rect();
       
   725 
       
   726 	rect.iTl.iX+=2*rect.iBr.iX/5;	//left 1/3 of the screen
       
   727 	rect.iTl.iY=5*KLabelHeight;
       
   728 	rect.iBr.iY=6*KLabelHeight;
       
   729 	rect.Shrink(3,3);
       
   730 	
       
   731 	iExtv6PacketsLabel->SetContainerWindowL(*this);
       
   732 #if EPOC_SDK < 0x06000000
       
   733     iExtv6PacketsLabel->SetRectL(rect);
       
   734 #else
       
   735 	iExtv6PacketsLabel->SetRect(rect);
       
   736 #endif
       
   737 	iExtv6PacketsLabel->SetAlignment(EHLeftVCenter); // center text
       
   738 	iExtv6PacketsLabel->SetBufferReserveLengthL(26);
       
   739 	iExtv6PacketsLabel->SetFont(iFont);
       
   740 	iExtv6PacketsLabel->SetTextL(_L(" Extv6:  0 packets")); // nice long buffer
       
   741 }
       
   742 
       
   743 void CRotorAppView::CreateStatLabelsL()
       
   744 {
       
   745 	CreateRecvPacketsLabelL();
       
   746 	CreateIPv4PacketsLabelL();
       
   747 	CreateIPv6PacketsLabelL();
       
   748 	CreateTCPPacketsLabelL();
       
   749 	CreateUDPPacketsLabelL();
       
   750 	CreateICMPPacketsLabelL();
       
   751 	CreateExtv6PacketsLabelL();
       
   752 	//UpdateStatistics();
       
   753 }
       
   754 
       
   755 
       
   756 void CRotorAppView::CreateSpeedLabelL()
       
   757 {
       
   758 	iSpeedLabel=new (ELeave) CEikLabel;
       
   759 	TRect rect=Rect();
       
   760 	/*
       
   761 	rect.iTl.iX=3*rect.iBr.iX/5;	// Label is in right 1/3 of the screen
       
   762 	rect.iTl.iY+=2*KLabelHeight;
       
   763 	rect.iBr.iY=3*KLabelHeight; // make it 20 pixels
       
   764 	*/
       
   765 	rect.iBr.iX=2*rect.iBr.iX/5;	//left 1/3 of the screen
       
   766 	rect.iTl.iY=rect.iBr.iY-KLabelHeight;
       
   767 	//rect.iTl.iY=rect.iBr.iY-2*KLabelHeight;
       
   768 	//rect.iBr.iY-=KLabelHeight; // make it 20 pixels
       
   769 	rect.Shrink(3,3);
       
   770 	//rect.Move(0,-3);
       
   771 	iSpeedLabel->SetContainerWindowL(*this);
       
   772 #if EPOC_SDK < 0x06000000
       
   773     iSpeedLabel->SetRectL(rect);
       
   774 #else
       
   775 	iSpeedLabel->SetRect(rect);
       
   776 #endif
       
   777 	iSpeedLabel->SetAlignment(EHCenterVCenter); // center text
       
   778 	iSpeedLabel->SetBufferReserveLengthL(26);
       
   779 	iSpeedLabel->SetTextL(_L(" Speed: 0.00 (pack/s)")); // nice long buffer
       
   780 }
       
   781 
       
   782 
       
   783 
       
   784 void CRotorAppView::ActivateMonitoringL()
       
   785 {
       
   786 	iRunning=ETrue;
       
   787 
       
   788 	if (iRotor)
       
   789 	{
       
   790 		UpdateStatisticsL();
       
   791 		UpdateFamilyLabelL();
       
   792 		UpdateProtocolLabelL();
       
   793 	}
       
   794 	else
       
   795 	{
       
   796 		TBuf<50> msg;
       
   797 		switch (iModel->iPref.iProtocol)
       
   798 		{
       
   799 		case ICMP:
       
   800 			msg=_L("ICMP level");
       
   801 			break;
       
   802 		case IP:
       
   803 			msg=_L("IP level"); 
       
   804 			break;
       
   805 		case TCP:
       
   806 			msg=_L("TCP level");
       
   807 			break;
       
   808 		case UDP:
       
   809 			msg=_L("UDP level");
       
   810 			break;
       
   811 		case ESP:
       
   812 			msg=_L("ESP level");
       
   813 			break;
       
   814 		case AH:
       
   815 			msg=_L("AH level"); 
       
   816 			break;
       
   817 		default: 
       
   818 			msg=_L("Unknown type");
       
   819 		}
       
   820 
       
   821 		iConsole->ClearScreen();
       
   822 		if (iModel->iPref.iDumpIPv4)		//IPv4
       
   823 		{
       
   824 			msg.AppendFormat(_L(" (IPv4)"));
       
   825 		}
       
   826 		if (iModel->iPref.iDumpIPv6)		//IPv6
       
   827 		{
       
   828 			msg.AppendFormat(_L(" (IPv6)"));
       
   829 		}
       
   830 		if (iModel->iPref.iDumpIPSEC)		//IPSEC
       
   831 		{
       
   832 			msg.AppendFormat(_L(" (IPSEC)"));
       
   833 		}
       
   834 		msg.AppendFormat(_L("\n"));
       
   835 		iConsole->Write(msg);
       
   836 	}
       
   837 
       
   838 }
       
   839 
       
   840 void CRotorAppView::ResetMonitoringL()
       
   841 {
       
   842 	iRunning=EFalse;
       
   843 	if (iRotor)
       
   844 	{
       
   845 		UpdateProtocolLabelL();
       
   846 		UpdateFamilyLabelL();
       
   847 	}
       
   848 	else
       
   849 		iConsole->Write(_L("Not Active"));
       
   850 }
       
   851 
       
   852 
       
   853 CRotorAppView::~CRotorAppView()
       
   854 {
       
   855 
       
   856 	delete iModel;
       
   857 	DestroyControls();
       
   858 	iCoeEnv->ReleaseScreenFont(iFont);
       
   859 }
       
   860 
       
   861 
       
   862 // The following two functions have to be implemented for all compound controls.
       
   863 TInt CRotorAppView::CountComponentControls() const
       
   864 {
       
   865 	return (iRotor) ? 12 : 1;	//With or without rotor
       
   866 }
       
   867 
       
   868 CCoeControl* CRotorAppView::ComponentControl(TInt aIndex) const
       
   869 {
       
   870 	if (iRotor)
       
   871 	{
       
   872 		switch (aIndex)
       
   873 		{
       
   874 		case 0:
       
   875 			return iSpeedLabel;
       
   876 		case 1:
       
   877 			return iProtocolLabel;	//displays the protocol level scanned
       
   878 		case 2:
       
   879 			return iRotor;
       
   880 		case 3:
       
   881 			return iNetLabel;
       
   882 		case 4:
       
   883 			return iRecvPacketsLabel;
       
   884 		case 5:
       
   885 			return iIPv4PacketsLabel;	//displays the number of IPv4  packets received
       
   886 		case 6 :
       
   887 			return iIPv6PacketsLabel;	//displays the number of IPv6 packets received
       
   888 		case 7 :
       
   889 			return iTCPPacketsLabel;	//displays the number of TCP packets received
       
   890 		case 8 :
       
   891 			return iUDPPacketsLabel;	//displays the number of UDP packets received
       
   892 		case 9 :
       
   893 			return iICMPPacketsLabel;	//displays the number of ICMP packets received
       
   894 		case 10 :
       
   895 			return iICMPPacketsLabel;	//displays the number of ICMP packets received
       
   896 		case 11 :
       
   897 			return iFamilyLabel;		//Displays the families/sockets scanned
       
   898 		default:
       
   899 			return NULL;
       
   900 		}
       
   901 	}
       
   902 	else
       
   903 		return iConsole;
       
   904 }
       
   905 
       
   906 
       
   907 void CRotorAppView::Draw(const TRect& ) const
       
   908 {
       
   909 	CWindowGc& gc = SystemGc();
       
   910 	
       
   911 	gc.SetPenStyle(CGraphicsContext::ESolidPen);
       
   912 	TSize penSizeBold(3,3);
       
   913 	gc.SetPenSize(penSizeBold);
       
   914 	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   915 
       
   916 	TRect rect;
       
   917 	/*
       
   918 	TRect rect=iConsole->Rect();	//Lines around the Console
       
   919 	rect.Grow(3,3);
       
   920 	gc.DrawRect(rect);
       
   921 	*/
       
   922 	if (iRotor)	//Lines around the Rotor and Label
       
   923 	{
       
   924 		rect=iProtocolLabel->Rect();
       
   925 		rect.Grow(3,3);
       
   926 		gc.DrawRect(rect);
       
   927 
       
   928 		rect=iNetLabel->Rect();
       
   929 		rect.Grow(3,3);
       
   930 		gc.DrawRect(rect);
       
   931 
       
   932 		rect=iSpeedLabel->Rect();
       
   933 		rect.Grow(3,3);
       
   934 		gc.DrawRect(rect);
       
   935 
       
   936 		rect = iRotor->Rect();
       
   937 		rect.Grow(3,3);
       
   938 		gc.DrawRect(rect);
       
   939 
       
   940 		rect=Rect();	//around stats
       
   941 		rect.iTl.iX+=2*rect.iBr.iX/5;
       
   942 		gc.DrawRect(rect);
       
   943 
       
   944 		rect=iFamilyLabel->Rect();
       
   945 		rect.Grow(3,3);
       
   946 		gc.DrawRect(rect);
       
   947 
       
   948 	}
       
   949 	else
       
   950 	{
       
   951 		rect=iConsole->Rect();	//Lines around the Console
       
   952 		rect.Grow(3,3);
       
   953 		gc.DrawRect(rect);
       
   954 	}
       
   955 
       
   956 }
       
   957 
       
   958 
       
   959 void CRotorAppView::StartL()
       
   960 {
       
   961 	TBuf<50> msg;
       
   962 	TInt err;
       
   963 	if (iRunning)
       
   964 	{
       
   965 		if (!CEikonEnv::QueryWinL(_L("Already Running"),_L("Restart Monitoring?")))
       
   966 			return;
       
   967 		else
       
   968 			StopL();
       
   969 	}
       
   970 	
       
   971 	
       
   972 	CEikonEnv::Static()->BusyMsgL(R_BUSY);
       
   973 	
       
   974 	
       
   975 	ActivateMonitoringL();
       
   976 	
       
   977 	TRAP(err,iModel->StartL());
       
   978 	if (err!=KErrNone)
       
   979 	{
       
   980 		msg.Format(_L("Error initializing: %d"), err);
       
   981 		ShowError(msg);
       
   982 		StopL();
       
   983 	}
       
   984 	CEikonEnv::Static()->BusyMsgCancel();
       
   985 }
       
   986 
       
   987 void CRotorAppView::Status(TInt aId)
       
   988 {
       
   989 	iEikonEnv->InfoMsg(aId);
       
   990 }
       
   991 
       
   992 
       
   993 void CRotorAppView::Write(const TDesC &aMsg)
       
   994 {
       
   995 	if (!iRotor)	//If there's any console
       
   996 		iConsole->Write(aMsg);
       
   997 	
       
   998 }
       
   999 
       
  1000 void CRotorAppView::ShowError(TInt aId)
       
  1001 {
       
  1002 	iEikonEnv->InfoMsg(aId);
       
  1003 }
       
  1004 
       
  1005 void CRotorAppView::ShowError(const TDes& msg)
       
  1006 {
       
  1007 	iEikonEnv->InfoMsg(msg);
       
  1008 }
       
  1009 
       
  1010 void CRotorAppView::ShowError(const TDes& msg, TInt aErr)
       
  1011 {
       
  1012 	TBuf<100> txt;
       
  1013 	TBuf<100> txt2;
       
  1014 
       
  1015 	txt.Format(msg);
       
  1016 	iEikonEnv->GetErrorText(txt2,aErr);
       
  1017 	txt.AppendFormat(txt2);
       
  1018 	iEikonEnv->InfoMsg(txt);
       
  1019 }
       
  1020 
       
  1021 void CRotorAppView::StopL()
       
  1022 {
       
  1023 	if (iRunning)
       
  1024 	{
       
  1025 		iModel->Stop();
       
  1026 		ResetMonitoringL();
       
  1027 	}
       
  1028 }
       
  1029 
       
  1030 void CRotorAppView::UpdateRotor()
       
  1031 {
       
  1032 	if (iRotor)	//may be "Hidden" (Full screen console)
       
  1033 		iRotor->UpdateRotor();
       
  1034 }
       
  1035 
       
  1036 void CRotorAppView::UpdateNetworkL(TBool aUp)
       
  1037 {
       
  1038 	if (iRotor)
       
  1039 	{
       
  1040 		if (aUp)
       
  1041 			iNetLabel->SetTextL(_L("Net UP"));
       
  1042 		else
       
  1043 			iNetLabel->SetTextL(_L("Net DOWN"));
       
  1044 		
       
  1045 		iSpeedLabel->DrawNow();
       
  1046 	}
       
  1047 
       
  1048 }
       
  1049 
       
  1050 void CRotorAppView::UpdateSpeedL(TReal aSpeed)
       
  1051 {
       
  1052 	if (iRotor)	//may be "Hidden" (Full screen console)
       
  1053 	{
       
  1054 		TBuf<25> buf;
       
  1055 		buf.Format(_L(" Speed: %.2f (pack/s)"), aSpeed);
       
  1056 		iSpeedLabel->SetTextL(buf); 
       
  1057 		iSpeedLabel->DrawNow();
       
  1058 	}
       
  1059 
       
  1060 }
       
  1061 
       
  1062 
       
  1063 void CRotorAppView::UpdateFamilyLabelL()
       
  1064 {
       
  1065 	if (iRotor)	//may be "Hidden" (Full screen console)
       
  1066 	{
       
  1067 		TBuf<50> buf;
       
  1068 		TBool prev=EFalse;
       
  1069 		
       
  1070 		if (iRunning)
       
  1071 		{
       
  1072 			buf.Format(_L("Listening "));
       
  1073 			if (iModel->iPref.iDumpIPv4)
       
  1074 			{
       
  1075 				buf.AppendFormat(_L("IPv4"));
       
  1076 				prev=ETrue;
       
  1077 			}
       
  1078 
       
  1079 			if (iModel->iPref.iDumpIPv6)
       
  1080 			{
       
  1081 				if (prev)
       
  1082 					buf.AppendFormat(_L(" + "));
       
  1083 				buf.AppendFormat(_L("IPv6"));
       
  1084 				prev=ETrue;
       
  1085 			}
       
  1086 			if (iModel->iPref.iDumpIPSEC)
       
  1087 			{
       
  1088 				if (prev)
       
  1089 					buf.AppendFormat(_L(" + "));
       
  1090 				buf.AppendFormat(_L(" IPSEC"));
       
  1091 			}
       
  1092 			iFamilyLabel->SetTextL(buf); 
       
  1093 		}
       
  1094 		else
       
  1095 			iFamilyLabel->SetTextL(_L("---")); 
       
  1096 
       
  1097 		iFamilyLabel->DrawNow();
       
  1098 	}
       
  1099 }
       
  1100 
       
  1101 void CRotorAppView::UpdateProtocolLabelL()
       
  1102 {
       
  1103 	if (iRotor)	//may be "Hidden" (Full screen console)
       
  1104 	{
       
  1105 
       
  1106 		TBuf<50> msg;
       
  1107 		if (iRunning)
       
  1108 		{
       
  1109 			switch (iModel->iPref.iProtocol)
       
  1110 			{
       
  1111 			case ICMP:
       
  1112 				msg=_L("ICMP level");
       
  1113 				break;
       
  1114 			case IP:
       
  1115 				msg=_L("IP level"); // nice long buffer
       
  1116 				break;
       
  1117 			case TCP:
       
  1118 				msg=_L("TCP level"); // nice long buffer
       
  1119 				break;
       
  1120 			case UDP:
       
  1121 				msg=_L("UDP level"); // nice long buffer
       
  1122 				break;
       
  1123 			case ESP:
       
  1124 				msg=_L("ESP level"); // nice long buffer
       
  1125 				break;
       
  1126 			case AH:
       
  1127 				msg=_L("AH level"); // nice long buffer
       
  1128 				break;
       
  1129 			default: 
       
  1130 				msg=_L("Unknown type"); // nice long buffer
       
  1131 			}
       
  1132 		}
       
  1133 		else
       
  1134 			msg.Format(_L("Not Active"));
       
  1135 		iProtocolLabel->SetTextL(msg); 
       
  1136 		iProtocolLabel->DrawNow();
       
  1137 	}
       
  1138 }
       
  1139 
       
  1140 void CRotorAppView::UpdateStatisticsL()
       
  1141 {
       
  1142 	if (iRotor)	//Only Shown in the RotorView
       
  1143 	{
       
  1144 		TBuf<25> buf;
       
  1145 		buf.Format(_L(" Total:  %d packets"),iModel->iStatInfo.iTotalPackets);
       
  1146 		iRecvPacketsLabel->SetTextL(buf); 
       
  1147 		iRecvPacketsLabel->DrawNow();
       
  1148 
       
  1149 		buf.Format(_L(" IPv4 :  %d packets"),iModel->iStatInfo.iIPv4Packets);
       
  1150 		iIPv4PacketsLabel->SetTextL(buf); 
       
  1151 		iIPv4PacketsLabel->DrawNow();
       
  1152 
       
  1153 		buf.Format(_L(" IPv6 :  %d packets"),iModel->iStatInfo.iIPv6Packets);
       
  1154 		iIPv6PacketsLabel->SetTextL(buf); 
       
  1155 		iIPv6PacketsLabel->DrawNow();
       
  1156 
       
  1157 		buf.Format(_L(" TCP  :  %d packets"),iModel->iStatInfo.iTCPPackets);
       
  1158 		iTCPPacketsLabel->SetTextL(buf); 
       
  1159 		iTCPPacketsLabel->DrawNow();
       
  1160 
       
  1161 		buf.Format(_L(" UDP  :  %d packets"),iModel->iStatInfo.iUDPPackets);
       
  1162 		iUDPPacketsLabel->SetTextL(buf); 
       
  1163 		iUDPPacketsLabel->DrawNow();
       
  1164 
       
  1165 		buf.Format(_L(" ICMP :  %d packets"),iModel->iStatInfo.iICMPPackets);
       
  1166 		iICMPPacketsLabel->SetTextL(buf); 
       
  1167 		iICMPPacketsLabel->DrawNow();
       
  1168 
       
  1169 		buf.Format(_L(" Extv6:  %d packets"),iModel->iStatInfo.iICMPPackets);
       
  1170 		iICMPPacketsLabel->SetTextL(buf); 
       
  1171 		iICMPPacketsLabel->DrawNow();
       
  1172 		
       
  1173 	}
       
  1174 
       
  1175 }
       
  1176 
       
  1177 void CRotorAppView::DestroyControls()
       
  1178 {
       
  1179 	delete iRotor;
       
  1180 	iRotor=NULL;
       
  1181 	delete iFamilyLabel;
       
  1182 	iFamilyLabel=NULL;
       
  1183 	delete iNetLabel;
       
  1184 	iNetLabel=NULL;
       
  1185 	delete iSpeedLabel;
       
  1186 	iSpeedLabel=NULL;
       
  1187 	delete iProtocolLabel;
       
  1188 	iProtocolLabel=NULL;
       
  1189 	delete iRecvPacketsLabel;
       
  1190 	iRecvPacketsLabel=NULL;
       
  1191 	delete iIPv4PacketsLabel;
       
  1192 	iIPv4PacketsLabel=NULL;
       
  1193 	delete iIPv6PacketsLabel;
       
  1194 	iIPv6PacketsLabel=NULL;
       
  1195 	delete iTCPPacketsLabel;
       
  1196 	iTCPPacketsLabel=NULL;
       
  1197 	delete iUDPPacketsLabel;
       
  1198 	iUDPPacketsLabel=NULL;
       
  1199 	delete iICMPPacketsLabel;
       
  1200 	iICMPPacketsLabel=NULL;
       
  1201 	delete iExtv6PacketsLabel;
       
  1202 	iExtv6PacketsLabel=NULL;
       
  1203 
       
  1204 	delete iConsole;
       
  1205 	iConsole=NULL;
       
  1206 }
       
  1207 
       
  1208 void CRotorAppView::SwitchRotorL()
       
  1209 {
       
  1210 	if (iRotor)	//If initialized then is on the screen
       
  1211 	{
       
  1212 		DestroyControls();		
       
  1213 		CreateBigConsoleL(CEikConsoleScreen::ENoInitialCursor);	
       
  1214 		iModel->iShowPackets=ETrue;
       
  1215 	}
       
  1216 	else
       
  1217 	{
       
  1218 		DestroyControls();
       
  1219 		CreateRotorL();
       
  1220 		CreateProtocolLabelL();
       
  1221 		CreateNetLabelL();
       
  1222 		CreateFamilyLabelL();
       
  1223 		CreateStatLabelsL();
       
  1224 		CreateSpeedLabelL();
       
  1225 		UpdateStatisticsL();
       
  1226 		UpdateProtocolLabelL();
       
  1227 		UpdateFamilyLabelL();	
       
  1228 		iModel->iShowPackets=EFalse;
       
  1229 	}
       
  1230 	ActivateL();	//To reactivate all the controls ready to draw
       
  1231 	DrawDeferred();		//To draw the new configuration of the controls
       
  1232 }
       
  1233 
       
  1234 void CRotorAppView::ClearScreenL()
       
  1235 {
       
  1236 	if (!iRotor)	//If there's any console
       
  1237 	{
       
  1238 		delete iConsole;
       
  1239 		iConsole=NULL;
       
  1240 		CreateBigConsoleL(CEikConsoleScreen::ENoInitialCursor);	
       
  1241 	}
       
  1242 	
       
  1243 	/*
       
  1244 	if (iRotor)
       
  1245 		CreateConsoleL(CEikConsoleScreen::ENoInitialCursor);
       
  1246 	else
       
  1247 		CreateBigConsoleL(CEikConsoleScreen::ENoInitialCursor);	
       
  1248 	*/
       
  1249 
       
  1250 }
       
  1251 
       
  1252 void CRotorAppView::DynInitMenuPaneL(TInt aMenuId,CEikMenuPane* aMenuPane) const
       
  1253 {
       
  1254 	//if (!iRotor)
       
  1255 	//	aMenuPane
       
  1256 	if (aMenuId==R_ROTOR_CONSOLE_MENU)
       
  1257 	{
       
  1258 		if (!iRotor)
       
  1259 			aMenuPane->SetItemButtonState(ERotorNoRotor,EEikMenuItemSymbolOn);
       
  1260 			//aMenuPane->SetItemTextL(ERotorNoRotor,R_SHOW_ROTOR);
       
  1261 	}
       
  1262 }
       
  1263 
       
  1264 void CRotorAppView::HandleCommandL(TInt aCommand)
       
  1265 {
       
  1266 	if (iConsole)
       
  1267 		iConsole->HandleCommandL(aCommand);
       
  1268 }
       
  1269 
       
  1270 TSize CRotorAppView::ScreenSize() const
       
  1271 {
       
  1272 	__ASSERT_ALWAYS(iConsole != NULL, User::Panic(_L("iConsole"), 0));
       
  1273 	return iConsole->ScreenSize();
       
  1274 }
       
  1275 
       
  1276 //
       
  1277 //	CRotor
       
  1278 //
       
  1279 // A control for the Rotor. It'll be created from the main view (container)
       
  1280 // CRotor doesn't need a ConstructL() because it's a simple control.
       
  1281 
       
  1282 CRotor::CRotor(TInt *aNumBlades)
       
  1283 {
       
  1284 	iNumBlades=aNumBlades;
       
  1285 }
       
  1286 
       
  1287 
       
  1288 CRotor::~CRotor()
       
  1289 {
       
  1290 	
       
  1291 }
       
  1292 
       
  1293 
       
  1294 void CRotor::ConstructL(const TRect& aRect)
       
  1295 {
       
  1296 #if EPOC_SDK < 0x06000000
       
  1297     SetRectL(aRect);
       
  1298 #else
       
  1299 	SetRect(aRect);
       
  1300 #endif
       
  1301 	TRect rect=aRect;
       
  1302 	rect.Shrink(0,20);	//Shrink a little to fit better to the screen
       
  1303 	//rect.Heigth();
       
  1304 	//rect.Width();
       
  1305 	//Math::Int(iRadi,(rect.iBr.iY-rect.iTl.iY) / 2 );	//Pre calculates the radi to use it later
       
  1306 	iRadi = (rect.Height() > rect.Width()) ? rect.Width()/2 : rect.Height()/2;
       
  1307 
       
  1308 	iRotorRect=aRect;
       
  1309 	TPoint center(rect.Center());
       
  1310 	iRotorRect.iTl.iX=center.iX - iRadi;	//To minimize the redrawn part
       
  1311 	iRotorRect.iTl.iY=center.iY - iRadi;
       
  1312 	iRotorRect.iBr.iX=center.iX + iRadi;
       
  1313 	iRotorRect.iBr.iY=center.iY + iRadi;
       
  1314 }
       
  1315 
       
  1316 
       
  1317 void CRotor::DrawRotor() const
       
  1318 {
       
  1319 	CWindowGc& gc=SystemGc(); // graphics context we draw to
       
  1320 
       
  1321 	TRect rect=Rect();
       
  1322 	
       
  1323 	TPoint center=rect.Center();
       
  1324 	
       
  1325 
       
  1326 	TPoint start(center.iX,center.iY - iRadi );
       
  1327 	TPoint end(start);
       
  1328 	TRect arcRect(center.iX-iRadi, center.iY-iRadi, center.iX+iRadi, center.iY+iRadi);
       
  1329 	TSize penSizeBold(4,4);
       
  1330 	gc.SetPenSize(penSizeBold);
       
  1331 	//gc.SetPenColor(KRgbGray);
       
  1332 	gc.DrawArc(arcRect, start, end);
       
  1333 	gc.SetPenColor(KRgbBlack);
       
  1334 	penSizeBold.SetSize(10,10);
       
  1335 	gc.SetPenSize(penSizeBold);
       
  1336 	gc.Plot(center);
       
  1337 	DrawBlades();
       
  1338 
       
  1339 }
       
  1340 
       
  1341 
       
  1342 void CRotor::DrawBlades() const
       
  1343 {
       
  1344 	TReal angle=iAngle;	//in degrees
       
  1345 	TReal incr=2*PI / (*iNumBlades);	//radians between each blade
       
  1346 	for (TInt i=0; i< *iNumBlades; i++)
       
  1347 	{
       
  1348 		DrawBlade(Rect().Center(), angle);
       
  1349 		angle+=incr;
       
  1350 	}
       
  1351 }
       
  1352 
       
  1353 
       
  1354 void CRotor::DrawBlade(const TPoint& aCenter, TReal aAngle) const
       
  1355 {
       
  1356 	CWindowGc& gc=SystemGc(); // graphics context we draw to
       
  1357 	TReal lSin, lCos;
       
  1358 	TInt32 x,y;
       
  1359 	TSize penSizeBold(2,2);
       
  1360 	gc.SetPenSize(penSizeBold);
       
  1361 
       
  1362 	gc.SetBrushColor(KRgbBlack);
       
  1363 	
       
  1364 	Math::Sin(lSin,aAngle-0.12);
       
  1365 	Math::Cos(lCos,aAngle-0.12);
       
  1366 	Math::Int(x, iRadi*lCos);
       
  1367 	Math::Int(y, iRadi*lSin);
       
  1368 	TPoint end1(aCenter.iX + x, aCenter.iY + y); 
       
  1369 
       
  1370 	Math::Sin(lSin,aAngle+0.12);
       
  1371 	Math::Cos(lCos,aAngle+0.12);
       
  1372 	Math::Int(x, iRadi*lCos);
       
  1373 	Math::Int(y, iRadi*lSin);
       
  1374 	TPoint end2(aCenter.iX + x, aCenter.iY + y); 
       
  1375 
       
  1376 	TRect arcRect(aCenter.iX-iRadi, aCenter.iY-iRadi, aCenter.iX+iRadi, aCenter.iY+iRadi);
       
  1377 	gc.DrawPie(arcRect,end2,end1);
       
  1378 
       
  1379 	//gc.DrawLine(aCenter, end1);
       
  1380 	//gc.DrawLine(aCenter, end2);
       
  1381 	//gc.DrawLine(end1, end2);
       
  1382 	
       
  1383 	//gc.DrawArc(arcRect, start, end);
       
  1384 }
       
  1385 
       
  1386 
       
  1387 void CRotor::Draw(const TRect& /*aRect*/) const
       
  1388 {
       
  1389 	CWindowGc& gc=SystemGc(); // graphics context we draw to
       
  1390 	TSize penSizeBold(3,3);
       
  1391 	gc.SetPenSize(penSizeBold);
       
  1392 	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1393 	//gc.SetBrushColor(KRgbDitheredLightGray);
       
  1394 	//gc.SetBrushColor(TRgb(0xefefef));
       
  1395 	/*
       
  1396 	TRect rect = Rect();
       
  1397 	rect.Grow(3,3);
       
  1398 	gc.DrawRect(rect);
       
  1399 	*/
       
  1400 	DrawRotor();
       
  1401 
       
  1402 	/*
       
  1403 	CWindowGc& gc=SystemGc();
       
  1404 	if (IsFocused())
       
  1405 		{
       
  1406 		gc.SetPenColor(KRgbBlack);
       
  1407 		}
       
  1408 	else
       
  1409 		{
       
  1410 		gc.SetPenColor(KRgbWhite);
       
  1411 		}
       
  1412 	gc.DrawRect(Rect());
       
  1413 
       
  1414 	gc.SetClippingRect(aRect);
       
  1415 
       
  1416 	// Draw the smiley face, smiling or looking sad
       
  1417 	gc.SetPenColor(KRgbBlack);
       
  1418 	// Draw a circle for the face
       
  1419 	gc.DrawEllipse(iSmileyRect);
       
  1420 	// Draw the eyes
       
  1421 	TPoint leftEye(iSmileyWidth/3, iSmileyHeight/3);
       
  1422 	TPoint rightEye(iSmileyWidth*2/3, iSmileyHeight/3);
       
  1423 	gc.SetPenSize(TSize(5,5));
       
  1424 	gc.Plot(iSmileyRect.iTl+leftEye);
       
  1425 	gc.Plot(iSmileyRect.iTl+rightEye);
       
  1426 	//Draw the mouth, smiling or looking sad.
       
  1427 	gc.SetPenSize(TSize(1,1));
       
  1428 	gc.SetPenColor(KRgbWhite);
       
  1429 	if (iSmiling)
       
  1430 		gc.DrawArc(iFrownRect, iFrownRect.iTl+TPoint(iSmileyWidth/2,iFrownRect.Height()/2), 
       
  1431 							  iFrownRect.iTl+TPoint(0,iFrownRect.Height()/2));
       
  1432 	else
       
  1433 		gc.DrawArc(iSmileRect, iSmileRect.iTl+TPoint(0,iSmileRect.Height()/2), 
       
  1434 							  iSmileRect.iTl+TPoint(iSmileyWidth/2,iSmileRect.Height()/2));
       
  1435 	gc.SetPenColor(KRgbBlack);
       
  1436 	if (iSmiling)
       
  1437 		gc.DrawArc(iSmileRect, iSmileRect.iTl+TPoint(0,iSmileRect.Height()/2), 
       
  1438 							  iSmileRect.iTl+TPoint(iSmileyWidth/2,iSmileRect.Height()/2));
       
  1439 	else
       
  1440 		gc.DrawArc(iFrownRect, iFrownRect.iTl+TPoint(iSmileyWidth/2,iFrownRect.Height()/2), 
       
  1441 							  iFrownRect.iTl+TPoint(0,iFrownRect.Height()/2));
       
  1442 */
       
  1443 }
       
  1444 
       
  1445 
       
  1446 void CRotor::UpdateRotor()
       
  1447 {
       
  1448 	iAngle+=0.2;
       
  1449 	if (iAngle > 2 *PI)
       
  1450 		iAngle-= 2*PI;
       
  1451 	
       
  1452 	ActivateGc();
       
  1453 	CWindowGc& gc = SystemGc();
       
  1454 	gc.SetClippingRect(iRotorRect);
       
  1455 	//gc.Clear(rect); // clear to brush color
       
  1456 	DrawDeferred();
       
  1457 	//DrawBlades();
       
  1458 	DeactivateGc();
       
  1459 	
       
  1460 }
       
  1461 
       
  1462 
       
  1463 
       
  1464 
       
  1465 
       
  1466 
       
  1467 
       
  1468 // DIALOG CLASSES
       
  1469 
       
  1470 
       
  1471 COptionsDialog::COptionsDialog(CRotorEngine* aModel)
       
  1472 {
       
  1473 	iModel=aModel;
       
  1474 }
       
  1475 
       
  1476 COptionsDialog::~COptionsDialog()
       
  1477 {
       
  1478 
       
  1479 }
       
  1480 	//TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
       
  1481 	//void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
  1482 	//void ProcessPointerEventL(const TPointerEvent& aPointerEvent);
       
  1483 	//void ReportEventL(MCoeControlObserver::TCoeEvent aEvent);
       
  1484 	//void PrepareForFocusTransitionL();
       
  1485 	//void HandleControlStateChangeL(TInt aControlId);
       
  1486 
       
  1487 TBool COptionsDialog::OkToExitL(TInt)
       
  1488 {
       
  1489 	if ((CheckBoxState(ERotorDumpIPv4)==CEikButtonBase::EClear) && 
       
  1490 		(CheckBoxState(ERotorDumpIPv6)==CEikButtonBase::EClear) && 
       
  1491 		(CheckBoxState(ERotorDumpIPSEC)==CEikButtonBase::EClear))
       
  1492 	{
       
  1493 		CEikonEnv::Static()->InfoMsg(_L("Must dump some traffic"));
       
  1494 		TryChangeFocusToL(ERotorDumpIPv4);
       
  1495 		return EFalse;
       
  1496 	}
       
  1497 
       
  1498 	iModel->iPref.iProtocol = ChoiceListCurrentItem(ERotorProtocolChoiceList);
       
  1499 	iModel->iPref.iPort = NumberEditorValue(ERotorPortNumEd);
       
  1500 	iModel->iPref.iViewIPHdr = (CheckBoxState(ERotorViewIPHdr)==CEikButtonBase::ESet);
       
  1501 	iModel->iPref.iDumpIPv4 = (CheckBoxState(ERotorDumpIPv4)==CEikButtonBase::ESet);
       
  1502 	iModel->iPref.iDumpIPv6 = (CheckBoxState(ERotorDumpIPv6)==CEikButtonBase::ESet);
       
  1503 	iModel->iPref.iDumpIPSEC = (CheckBoxState(ERotorDumpIPSEC)==CEikButtonBase::ESet);
       
  1504 	iModel->iPref.iNumBlades = NumberEditorValue(ERotorBladesNumEd);
       
  1505 
       
  1506 	return ETrue;
       
  1507 }
       
  1508 
       
  1509 void COptionsDialog::PreLayoutDynInitL()
       
  1510 {
       
  1511 	if (!iModel->iIPv4Active)
       
  1512 	{
       
  1513 		SetCheckBoxState(ERotorDumpIPv4, CEikButtonBase::EClear);
       
  1514 		SetLineDimmedNow(ERotorDumpIPv4, ETrue);
       
  1515 	}
       
  1516 	else
       
  1517 	{
       
  1518 		if (iModel->iPref.iDumpIPv4)
       
  1519 			SetCheckBoxState(ERotorDumpIPv4, CEikButtonBase::ESet);
       
  1520 		else
       
  1521 			SetCheckBoxState(ERotorDumpIPv4, CEikButtonBase::EClear);
       
  1522 	}
       
  1523 	if (!iModel->iIPv6Active)
       
  1524 	{
       
  1525 		SetCheckBoxState(ERotorDumpIPv6, CEikButtonBase::EClear);
       
  1526 		SetLineDimmedNow(ERotorDumpIPv6, ETrue);
       
  1527 	}
       
  1528 	else
       
  1529 	{
       
  1530 		if (iModel->iPref.iDumpIPv6)
       
  1531 			SetCheckBoxState(ERotorDumpIPv6, CEikButtonBase::ESet);
       
  1532 		else
       
  1533 			SetCheckBoxState(ERotorDumpIPv6, CEikButtonBase::EClear);
       
  1534 	}
       
  1535 
       
  1536 	if (!iModel->iIPSECActive)
       
  1537 	{
       
  1538 		SetCheckBoxState(ERotorDumpIPSEC, CEikButtonBase::EClear);
       
  1539 		SetLineDimmedNow(ERotorDumpIPSEC, ETrue);
       
  1540 	}
       
  1541 	else
       
  1542 	{
       
  1543 		if (iModel->iPref.iDumpIPSEC)
       
  1544 			SetCheckBoxState(ERotorDumpIPSEC, CEikButtonBase::ESet);
       
  1545 		else
       
  1546 			SetCheckBoxState(ERotorDumpIPSEC, CEikButtonBase::EClear);
       
  1547 	}
       
  1548 	((CEikChoiceList *)Control(ERotorProtocolChoiceList))->SetArrayL(R_ROTOR_IPV4_HDR_LIST);
       
  1549 
       
  1550 	SetChoiceListCurrentItem(ERotorProtocolChoiceList,iModel->iPref.iProtocol);
       
  1551 	SetNumberEditorValue(ERotorPortNumEd, iModel->iPref.iPort);
       
  1552 
       
  1553 	if (iModel->iPref.iViewIPHdr)
       
  1554 		SetCheckBoxState(ERotorViewIPHdr, CEikButtonBase::ESet);
       
  1555 	else
       
  1556 		SetCheckBoxState(ERotorViewIPHdr, CEikButtonBase::EClear);
       
  1557 
       
  1558 	//SetChoiceListCurrentItem(ERotorMode,iModel->iMode);
       
  1559 
       
  1560 	SetNumberEditorValue(ERotorBladesNumEd, iModel->iPref.iNumBlades);
       
  1561 
       
  1562 	TBool b = ((iModel->iPref.iProtocol!=TCP) && (iModel->iPref.iProtocol!=UDP) && (iModel->iPref.iProtocol!=IP));
       
  1563 	SetLineDimmedNow(ERotorPortNumEd,b);
       
  1564 	MakeLineVisible(ERotorPortNumEd,!b);
       
  1565 }
       
  1566 
       
  1567 
       
  1568 void COptionsDialog::HandleControlStateChangeL(TInt aControlId)
       
  1569 {
       
  1570 	TInt protocol;	//,mode
       
  1571 	TBool b;
       
  1572 	switch (aControlId)
       
  1573 	{
       
  1574 	case ERotorProtocolChoiceList:
       
  1575 		//Dimms/Undimms the control PacketLimitNum if needed
       
  1576 		protocol=ChoiceListCurrentItem(ERotorProtocolChoiceList);
       
  1577 		b = ((protocol!=TCP) && (protocol!=UDP) && (protocol!=IP));
       
  1578 		SetLineDimmedNow(ERotorPortNumEd,b);	
       
  1579 		MakeLineVisible(ERotorPortNumEd,!b);
       
  1580 		break;
       
  1581 		/*
       
  1582 	case ERotorMode:
       
  1583 		mode=ChoiceListCurrentItem(ERotorMode);
       
  1584 		protocol=ChoiceListCurrentItem(ERotorProtocolChoiceList);
       
  1585 		if (mode==IPv4)	//To change the list of headers to sniff
       
  1586 		{
       
  1587 			((CEikChoiceList *)Control(ERotorProtocolChoiceList))->SetArrayL(R_ROTOR_IPV4_HDR_LIST);
       
  1588 			SetChoiceListCurrentItem(ERotorProtocolChoiceList,protocol);	//Set to the same protocol
       
  1589 		}
       
  1590 		else	//IPv6
       
  1591 		{	
       
  1592 			mode=((CEikChoiceList *)Control(ERotorProtocolChoiceList))->Array()->MdcaCount();
       
  1593 			((CEikChoiceList *)Control(ERotorProtocolChoiceList))->SetArrayL(R_ROTOR_IPV6_HDR_LIST);
       
  1594 			if (protocol>=((CEikChoiceList *)Control(ERotorProtocolChoiceList))->Array()->MdcaCount())
       
  1595 				protocol=0;	
       
  1596 			SetChoiceListCurrentItem(ERotorProtocolChoiceList,protocol);	//Set to the same protocol
       
  1597 		}
       
  1598 		break;
       
  1599 		*/
       
  1600 	default:
       
  1601 		break;
       
  1602 	}
       
  1603 }
       
  1604 
       
  1605 
       
  1606 //
       
  1607 //	CIPv4ViewDialog
       
  1608 //
       
  1609 
       
  1610 
       
  1611 CIPv4ViewDialog::CIPv4ViewDialog(SMonIPv4Info *aMonInfo)
       
  1612 {
       
  1613 	iMonInfo=aMonInfo;
       
  1614 }
       
  1615 
       
  1616 CIPv4ViewDialog::~CIPv4ViewDialog()
       
  1617 {
       
  1618 
       
  1619 }
       
  1620 	//TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
       
  1621 	//void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
  1622 	//void ProcessPointerEventL(const TPointerEvent& aPointerEvent);
       
  1623 	//void ReportEventL(MCoeControlObserver::TCoeEvent aEvent);
       
  1624 	//void PrepareForFocusTransitionL();
       
  1625 	//void HandleControlStateChangeL(TInt aControlId);
       
  1626 
       
  1627 void CIPv4ViewDialog::SetPage()
       
  1628 {
       
  1629 #if EPOC_SDK < 0x06000000
       
  1630 	switch (PageSelector()->CurrentPageControlId())
       
  1631 	{
       
  1632 	case ERotorIPPage:
       
  1633 		SetCheckBoxState(ERotorIPVersion, CEikButtonBase::ESet);
       
  1634 		SetCheckBoxState(ERotorIPHdrLen, CEikButtonBase::ESet);
       
  1635 		SetCheckBoxState(ERotorIPTOS, CEikButtonBase::ESet);
       
  1636 		SetCheckBoxState(ERotorIPTotalLen, CEikButtonBase::ESet);
       
  1637 		SetCheckBoxState(ERotorIPId, CEikButtonBase::ESet);
       
  1638 		SetCheckBoxState(ERotorIPFlags, CEikButtonBase::ESet);
       
  1639 		break;
       
  1640 	case ERotorIPPage2:
       
  1641 		SetCheckBoxState(ERotorIPOffset, CEikButtonBase::ESet);
       
  1642 		SetCheckBoxState(ERotorIPTTL, CEikButtonBase::ESet);
       
  1643 		SetCheckBoxState(ERotorIPProtocol, CEikButtonBase::ESet);
       
  1644 		SetCheckBoxState(ERotorIPChksum, CEikButtonBase::ESet);
       
  1645 		SetCheckBoxState(ERotorIPSrcAddr, CEikButtonBase::ESet);
       
  1646 		SetCheckBoxState(ERotorIPDstAddr, CEikButtonBase::ESet);
       
  1647 		break;
       
  1648 	case ERotorICMPPage:
       
  1649 		SetCheckBoxState(ERotorICMPType, CEikButtonBase::ESet);
       
  1650 		SetCheckBoxState(ERotorICMPCode, CEikButtonBase::ESet);
       
  1651 		SetCheckBoxState(ERotorICMPChksum, CEikButtonBase::ESet);
       
  1652 		break;
       
  1653 	case ERotorTCPPage:
       
  1654 		SetCheckBoxState(ERotorTCPSrcPort, CEikButtonBase::ESet);
       
  1655 		SetCheckBoxState(ERotorTCPDstPort, CEikButtonBase::ESet);
       
  1656 		SetCheckBoxState(ERotorTCPSeq, CEikButtonBase::ESet);
       
  1657 		SetCheckBoxState(ERotorTCPAckNum, CEikButtonBase::ESet);
       
  1658 		SetCheckBoxState(ERotorTCPHdrLen, CEikButtonBase::ESet);
       
  1659 		break;
       
  1660 	case ERotorTCPPage2:
       
  1661 		SetCheckBoxState(ERotorTCPFlags, CEikButtonBase::ESet);
       
  1662 		SetCheckBoxState(ERotorTCPHdrWinSize, CEikButtonBase::ESet);
       
  1663 		SetCheckBoxState(ERotorTCPChksum, CEikButtonBase::ESet);
       
  1664 		SetCheckBoxState(ERotorTCPHdrUrgPtr, CEikButtonBase::ESet);
       
  1665 		break;
       
  1666 	case ERotorUDPPage:
       
  1667 		SetCheckBoxState(ERotorUDPSrcPort, CEikButtonBase::ESet);
       
  1668 		SetCheckBoxState(ERotorUDPDstPort, CEikButtonBase::ESet);
       
  1669 		SetCheckBoxState(ERotorUDPLen, CEikButtonBase::ESet);
       
  1670 		SetCheckBoxState(ERotorUDPChksum, CEikButtonBase::ESet);
       
  1671 		break;
       
  1672 	case ERotorAHPage:
       
  1673 		SetCheckBoxState(ERotorAHProtocol, CEikButtonBase::ESet);
       
  1674 		SetCheckBoxState(ERotorAHHdrLen, CEikButtonBase::ESet);
       
  1675 		SetCheckBoxState(ERotorAHSPI, CEikButtonBase::ESet);
       
  1676 		SetCheckBoxState(ERotorAHSeq, CEikButtonBase::ESet);
       
  1677 		break;
       
  1678 	case ERotorESPPage:
       
  1679 		SetCheckBoxState(ERotorESPSPI, CEikButtonBase::ESet);
       
  1680 		SetCheckBoxState(ERotorESPSeq, CEikButtonBase::ESet);
       
  1681 		break;
       
  1682 	}
       
  1683 #endif
       
  1684 }	//lint !e1762 // could probably not made const for ER5
       
  1685 
       
  1686 void CIPv4ViewDialog::ClearPage()
       
  1687 {
       
  1688 #if EPOC_SDK < 0x06000000
       
  1689 	switch (PageSelector()->CurrentPageControlId())
       
  1690 	{
       
  1691 	case ERotorIPPage:
       
  1692 		SetCheckBoxState(ERotorIPVersion, CEikButtonBase::EClear);
       
  1693 		SetCheckBoxState(ERotorIPHdrLen, CEikButtonBase::EClear);
       
  1694 		SetCheckBoxState(ERotorIPTOS, CEikButtonBase::EClear);
       
  1695 		SetCheckBoxState(ERotorIPTotalLen, CEikButtonBase::EClear);
       
  1696 		SetCheckBoxState(ERotorIPId, CEikButtonBase::EClear);
       
  1697 		SetCheckBoxState(ERotorIPFlags, CEikButtonBase::EClear);
       
  1698 		break;
       
  1699 	case ERotorIPPage2:
       
  1700 		SetCheckBoxState(ERotorIPOffset, CEikButtonBase::EClear);
       
  1701 		SetCheckBoxState(ERotorIPTTL, CEikButtonBase::EClear);
       
  1702 		SetCheckBoxState(ERotorIPProtocol, CEikButtonBase::EClear);
       
  1703 		SetCheckBoxState(ERotorIPChksum, CEikButtonBase::EClear);
       
  1704 		SetCheckBoxState(ERotorIPSrcAddr, CEikButtonBase::EClear);
       
  1705 		SetCheckBoxState(ERotorIPDstAddr, CEikButtonBase::EClear);
       
  1706 		break;
       
  1707 	case ERotorICMPPage:
       
  1708 		SetCheckBoxState(ERotorICMPType, CEikButtonBase::EClear);
       
  1709 		SetCheckBoxState(ERotorICMPCode, CEikButtonBase::EClear);
       
  1710 		SetCheckBoxState(ERotorICMPChksum, CEikButtonBase::EClear);
       
  1711 		break;
       
  1712 	case ERotorTCPPage:
       
  1713 		SetCheckBoxState(ERotorTCPSrcPort, CEikButtonBase::EClear);
       
  1714 		SetCheckBoxState(ERotorTCPDstPort, CEikButtonBase::EClear);
       
  1715 		SetCheckBoxState(ERotorTCPSeq, CEikButtonBase::EClear);
       
  1716 		SetCheckBoxState(ERotorTCPAckNum, CEikButtonBase::EClear);
       
  1717 		SetCheckBoxState(ERotorTCPHdrLen, CEikButtonBase::EClear);
       
  1718 		break;
       
  1719 	case ERotorTCPPage2:
       
  1720 		SetCheckBoxState(ERotorTCPFlags, CEikButtonBase::EClear);
       
  1721 		SetCheckBoxState(ERotorTCPHdrWinSize, CEikButtonBase::EClear);
       
  1722 		SetCheckBoxState(ERotorTCPChksum, CEikButtonBase::EClear);
       
  1723 		SetCheckBoxState(ERotorTCPHdrUrgPtr, CEikButtonBase::EClear);
       
  1724 		break;
       
  1725 	case ERotorUDPPage:
       
  1726 		SetCheckBoxState(ERotorUDPSrcPort, CEikButtonBase::EClear);
       
  1727 		SetCheckBoxState(ERotorUDPDstPort, CEikButtonBase::EClear);
       
  1728 		SetCheckBoxState(ERotorUDPLen, CEikButtonBase::EClear);
       
  1729 		SetCheckBoxState(ERotorUDPChksum, CEikButtonBase::EClear);
       
  1730 		break;
       
  1731 	case ERotorAHPage:
       
  1732 		SetCheckBoxState(ERotorAHProtocol, CEikButtonBase::EClear);
       
  1733 		SetCheckBoxState(ERotorAHHdrLen, CEikButtonBase::EClear);
       
  1734 		SetCheckBoxState(ERotorAHSPI, CEikButtonBase::EClear);
       
  1735 		SetCheckBoxState(ERotorAHSeq, CEikButtonBase::EClear);
       
  1736 		break;
       
  1737 	case ERotorESPPage:
       
  1738 		SetCheckBoxState(ERotorESPSPI, CEikButtonBase::EClear);
       
  1739 		SetCheckBoxState(ERotorESPSeq, CEikButtonBase::EClear);
       
  1740 		break;
       
  1741 	}
       
  1742 #endif
       
  1743 }	//lint !e1762 // could probably not made const for ER5
       
  1744 
       
  1745 TBool CIPv4ViewDialog::OkToExitL(TInt aButton)
       
  1746 {	
       
  1747 	switch (aButton)
       
  1748 	{
       
  1749 	case ESetButton:
       
  1750 		SetPage();
       
  1751 		return EFalse;
       
  1752 	case EClearButton:
       
  1753 		ClearPage();
       
  1754 		return EFalse;
       
  1755 	case EEikBidOk:
       
  1756 	//IPFields
       
  1757 
       
  1758 	iMonInfo->iIPVersion =(CheckBoxState(ERotorIPVersion)==CEikButtonBase::ESet);
       
  1759 	iMonInfo->iIPHdrLen =(CheckBoxState(ERotorIPHdrLen)==CEikButtonBase::ESet);
       
  1760 	iMonInfo->iIPTOS =(CheckBoxState(ERotorIPTOS)==CEikButtonBase::ESet);
       
  1761 	iMonInfo->iIPTotalLen =(CheckBoxState(ERotorIPTotalLen)==CEikButtonBase::ESet);
       
  1762 	iMonInfo->iIPId =(CheckBoxState(ERotorIPId)==CEikButtonBase::ESet);
       
  1763 	iMonInfo->iIPFlags =(CheckBoxState(ERotorIPFlags)==CEikButtonBase::ESet);
       
  1764 	iMonInfo->iIPOffset =(CheckBoxState(ERotorIPOffset)==CEikButtonBase::ESet);
       
  1765 	iMonInfo->iIPTTL =(CheckBoxState(ERotorIPTTL)==CEikButtonBase::ESet);
       
  1766 	iMonInfo->iIPProtocol=(CheckBoxState(ERotorIPProtocol)==CEikButtonBase::ESet);
       
  1767 	iMonInfo->iIPChksum=(CheckBoxState(ERotorIPChksum)==CEikButtonBase::ESet);
       
  1768 	iMonInfo->iIPSrcAddr=(CheckBoxState(ERotorIPSrcAddr)==CEikButtonBase::ESet);
       
  1769 	iMonInfo->iIPDstAddr=(CheckBoxState(ERotorIPDstAddr)==CEikButtonBase::ESet);
       
  1770 
       
  1771 
       
  1772 	//ICMP Fields
       
  1773 
       
  1774 	iMonInfo->iICMPType=(CheckBoxState(ERotorICMPType)==CEikButtonBase::ESet);
       
  1775 	iMonInfo->iICMPCode=(CheckBoxState(ERotorICMPCode)==CEikButtonBase::ESet);
       
  1776 	iMonInfo->iICMPChksum=(CheckBoxState(ERotorICMPChksum)==CEikButtonBase::ESet);
       
  1777 
       
  1778 
       
  1779 	// TCP Fields
       
  1780 	iMonInfo->iTCPSrcPort=(CheckBoxState(ERotorTCPSrcPort)==CEikButtonBase::ESet);
       
  1781 	iMonInfo->iTCPDstPort=(CheckBoxState(ERotorTCPDstPort)==CEikButtonBase::ESet);
       
  1782 	iMonInfo->iTCPSeq=(CheckBoxState(ERotorTCPSeq)==CEikButtonBase::ESet);
       
  1783 	iMonInfo->iTCPAckNum=(CheckBoxState(ERotorTCPAckNum)==CEikButtonBase::ESet);
       
  1784 	iMonInfo->iTCPHdrLen=(CheckBoxState(ERotorTCPHdrLen)==CEikButtonBase::ESet);
       
  1785 	iMonInfo->iTCPFlags=(CheckBoxState(ERotorTCPFlags)==CEikButtonBase::ESet);
       
  1786 	iMonInfo->iTCPHdrWinSize=(CheckBoxState(ERotorTCPHdrWinSize)==CEikButtonBase::ESet);
       
  1787 	iMonInfo->iTCPChksum=(CheckBoxState(ERotorTCPChksum)==CEikButtonBase::ESet);
       
  1788 	iMonInfo->iTCPHdrUrgPtr=(CheckBoxState(ERotorTCPHdrUrgPtr)==CEikButtonBase::ESet);
       
  1789 
       
  1790 
       
  1791 	//UDP Fields
       
  1792 	iMonInfo->iUDPSrcPort=(CheckBoxState(ERotorUDPSrcPort)==CEikButtonBase::ESet);
       
  1793 	iMonInfo->iUDPDstPort=(CheckBoxState(ERotorUDPDstPort)==CEikButtonBase::ESet);
       
  1794 	iMonInfo->iUDPLen=(CheckBoxState(ERotorUDPLen)==CEikButtonBase::ESet);
       
  1795 	iMonInfo->iUDPChksum=(CheckBoxState(ERotorUDPChksum)==CEikButtonBase::ESet);	
       
  1796 	
       
  1797 	//AH Fields
       
  1798 	iMonInfo->iAHProtocol =(CheckBoxState(ERotorAHProtocol)==CEikButtonBase::ESet);
       
  1799 	iMonInfo->iAHHdrLen =(CheckBoxState(ERotorAHHdrLen)==CEikButtonBase::ESet);
       
  1800 	iMonInfo->iAHSPI =(CheckBoxState(ERotorAHSPI)==CEikButtonBase::ESet);
       
  1801 	iMonInfo->iAHSeq =(CheckBoxState(ERotorAHSeq)==CEikButtonBase::ESet);
       
  1802 
       
  1803 	//ESP Fields
       
  1804 	iMonInfo->iESPSPI =(CheckBoxState(ERotorESPSPI)==CEikButtonBase::ESet);
       
  1805 	iMonInfo->iESPSeq =(CheckBoxState(ERotorESPSeq)==CEikButtonBase::ESet);
       
  1806 	return ETrue;
       
  1807 
       
  1808 	case EEikBidCancel:
       
  1809 		return ETrue;
       
  1810 	default:
       
  1811 		return EFalse;
       
  1812 	}
       
  1813 }
       
  1814 
       
  1815 void CIPv4ViewDialog::PreLayoutDynInitL()
       
  1816 {
       
  1817 
       
  1818 	//IP Fields
       
  1819 
       
  1820 	if (iMonInfo->iIPVersion)
       
  1821 		SetCheckBoxState(ERotorIPVersion, CEikButtonBase::ESet);
       
  1822 	else
       
  1823 		SetCheckBoxState(ERotorIPVersion, CEikButtonBase::EClear);
       
  1824 
       
  1825 	if (iMonInfo->iIPHdrLen)
       
  1826 		SetCheckBoxState(ERotorIPHdrLen, CEikButtonBase::ESet);
       
  1827 	else
       
  1828 		SetCheckBoxState(ERotorIPHdrLen, CEikButtonBase::EClear);
       
  1829 
       
  1830 	if (iMonInfo->iIPTOS)
       
  1831 		SetCheckBoxState(ERotorIPTOS, CEikButtonBase::ESet);
       
  1832 	else
       
  1833 		SetCheckBoxState(ERotorIPTOS, CEikButtonBase::EClear);
       
  1834 
       
  1835 	if (iMonInfo->iIPTotalLen)
       
  1836 		SetCheckBoxState(ERotorIPTotalLen, CEikButtonBase::ESet);
       
  1837 	else
       
  1838 		SetCheckBoxState(ERotorIPTotalLen, CEikButtonBase::EClear);
       
  1839 
       
  1840 	if (iMonInfo->iIPId)
       
  1841 		SetCheckBoxState(ERotorIPId, CEikButtonBase::ESet);
       
  1842 	else
       
  1843 		SetCheckBoxState(ERotorIPId, CEikButtonBase::EClear);
       
  1844 	
       
  1845 	if (iMonInfo->iIPFlags)
       
  1846 		SetCheckBoxState(ERotorIPFlags, CEikButtonBase::ESet);
       
  1847 	else
       
  1848 		SetCheckBoxState(ERotorIPFlags, CEikButtonBase::EClear);
       
  1849 
       
  1850 	if (iMonInfo->iIPOffset)
       
  1851 		SetCheckBoxState(ERotorIPOffset, CEikButtonBase::ESet);
       
  1852 	else
       
  1853 		SetCheckBoxState(ERotorIPOffset, CEikButtonBase::EClear);
       
  1854 
       
  1855 	if (iMonInfo->iIPTTL)
       
  1856 		SetCheckBoxState(ERotorIPTTL, CEikButtonBase::ESet);
       
  1857 	else
       
  1858 		SetCheckBoxState(ERotorIPTTL, CEikButtonBase::EClear);
       
  1859 
       
  1860 	if (iMonInfo->iIPProtocol)
       
  1861 		SetCheckBoxState(ERotorIPProtocol, CEikButtonBase::ESet);
       
  1862 	else
       
  1863 		SetCheckBoxState(ERotorIPProtocol, CEikButtonBase::EClear);
       
  1864 
       
  1865 	if (iMonInfo->iIPChksum)
       
  1866 		SetCheckBoxState(ERotorIPChksum, CEikButtonBase::ESet);
       
  1867 	else
       
  1868 		SetCheckBoxState(ERotorIPChksum, CEikButtonBase::EClear);
       
  1869 
       
  1870 	if (iMonInfo->iIPSrcAddr)
       
  1871 		SetCheckBoxState(ERotorIPSrcAddr, CEikButtonBase::ESet);
       
  1872 	else
       
  1873 		SetCheckBoxState(ERotorIPSrcAddr, CEikButtonBase::EClear);
       
  1874 
       
  1875 	if (iMonInfo->iIPDstAddr)
       
  1876 		SetCheckBoxState(ERotorIPDstAddr, CEikButtonBase::ESet);
       
  1877 	else
       
  1878 		SetCheckBoxState(ERotorIPDstAddr, CEikButtonBase::EClear);
       
  1879 	
       
  1880 	//ICMP Fields
       
  1881 
       
  1882 	if (iMonInfo->iICMPType)
       
  1883 		SetCheckBoxState(ERotorICMPType, CEikButtonBase::ESet);
       
  1884 	else
       
  1885 		SetCheckBoxState(ERotorICMPType, CEikButtonBase::EClear);
       
  1886 
       
  1887 	if (iMonInfo->iICMPCode)
       
  1888 		SetCheckBoxState(ERotorICMPCode, CEikButtonBase::ESet);
       
  1889 	else
       
  1890 		SetCheckBoxState(ERotorICMPCode, CEikButtonBase::EClear);
       
  1891 	
       
  1892 	if (iMonInfo->iICMPChksum)
       
  1893 		SetCheckBoxState(ERotorICMPChksum, CEikButtonBase::ESet);
       
  1894 	else
       
  1895 		SetCheckBoxState(ERotorICMPChksum, CEikButtonBase::EClear);
       
  1896 
       
  1897 
       
  1898 	//TCP Fields
       
  1899 	
       
  1900 	if (iMonInfo->iTCPSrcPort)
       
  1901 		SetCheckBoxState(ERotorTCPSrcPort, CEikButtonBase::ESet);
       
  1902 	else
       
  1903 		SetCheckBoxState(ERotorTCPSrcPort, CEikButtonBase::EClear);
       
  1904 
       
  1905 	if (iMonInfo->iTCPDstPort)
       
  1906 		SetCheckBoxState(ERotorTCPDstPort, CEikButtonBase::ESet);
       
  1907 	else
       
  1908 		SetCheckBoxState(ERotorTCPDstPort, CEikButtonBase::EClear);
       
  1909 
       
  1910 	if (iMonInfo->iTCPSeq)
       
  1911 		SetCheckBoxState(ERotorTCPSeq, CEikButtonBase::ESet);
       
  1912 	else
       
  1913 		SetCheckBoxState(ERotorTCPSeq, CEikButtonBase::EClear);
       
  1914 
       
  1915 	if (iMonInfo->iTCPAckNum)
       
  1916 		SetCheckBoxState(ERotorTCPAckNum, CEikButtonBase::ESet);
       
  1917 	else
       
  1918 		SetCheckBoxState(ERotorTCPAckNum, CEikButtonBase::EClear);
       
  1919 	
       
  1920 	if (iMonInfo->iTCPHdrLen)
       
  1921 		SetCheckBoxState(ERotorTCPHdrLen, CEikButtonBase::ESet);
       
  1922 	else
       
  1923 		SetCheckBoxState(ERotorTCPHdrLen, CEikButtonBase::EClear);
       
  1924 	
       
  1925 	if (iMonInfo->iTCPFlags)
       
  1926 		SetCheckBoxState(ERotorTCPFlags, CEikButtonBase::ESet);
       
  1927 	else
       
  1928 		SetCheckBoxState(ERotorTCPFlags, CEikButtonBase::EClear);
       
  1929 
       
  1930 	if (iMonInfo->iTCPHdrWinSize)
       
  1931 		SetCheckBoxState(ERotorTCPHdrWinSize, CEikButtonBase::ESet);
       
  1932 	else
       
  1933 		SetCheckBoxState(ERotorTCPHdrWinSize, CEikButtonBase::EClear);
       
  1934 
       
  1935 	if (iMonInfo->iTCPChksum)
       
  1936 		SetCheckBoxState(ERotorTCPChksum, CEikButtonBase::ESet);
       
  1937 	else
       
  1938 		SetCheckBoxState(ERotorTCPChksum, CEikButtonBase::EClear);
       
  1939 
       
  1940 	if (iMonInfo->iTCPHdrUrgPtr)
       
  1941 		SetCheckBoxState(ERotorTCPHdrUrgPtr, CEikButtonBase::ESet);
       
  1942 	else
       
  1943 		SetCheckBoxState(ERotorTCPHdrUrgPtr, CEikButtonBase::EClear);
       
  1944 
       
  1945 
       
  1946 	//UDP Fields
       
  1947 
       
  1948 	if (iMonInfo->iUDPSrcPort)
       
  1949 		SetCheckBoxState(ERotorUDPSrcPort, CEikButtonBase::ESet);
       
  1950 	else
       
  1951 		SetCheckBoxState(ERotorUDPSrcPort, CEikButtonBase::EClear);
       
  1952 
       
  1953 	if (iMonInfo->iUDPDstPort)
       
  1954 		SetCheckBoxState(ERotorUDPDstPort, CEikButtonBase::ESet);
       
  1955 	else
       
  1956 		SetCheckBoxState(ERotorUDPDstPort, CEikButtonBase::EClear);
       
  1957 
       
  1958 	if (iMonInfo->iUDPLen)
       
  1959 		SetCheckBoxState(ERotorUDPLen, CEikButtonBase::ESet);
       
  1960 	else
       
  1961 		SetCheckBoxState(ERotorUDPLen, CEikButtonBase::EClear);
       
  1962 
       
  1963 	if (iMonInfo->iUDPChksum)
       
  1964 		SetCheckBoxState(ERotorUDPChksum, CEikButtonBase::ESet);
       
  1965 	else
       
  1966 		SetCheckBoxState(ERotorUDPChksum, CEikButtonBase::EClear);
       
  1967 	
       
  1968 	//AH Fields
       
  1969 	if (iMonInfo->iAHProtocol)
       
  1970 		SetCheckBoxState(ERotorAHProtocol, CEikButtonBase::ESet);
       
  1971 	else
       
  1972 		SetCheckBoxState(ERotorAHProtocol, CEikButtonBase::EClear);
       
  1973 
       
  1974 	if (iMonInfo->iAHHdrLen)
       
  1975 		SetCheckBoxState(ERotorAHHdrLen, CEikButtonBase::ESet);
       
  1976 	else
       
  1977 		SetCheckBoxState(ERotorAHHdrLen, CEikButtonBase::EClear);
       
  1978 
       
  1979 	if (iMonInfo->iAHSPI)
       
  1980 		SetCheckBoxState(ERotorAHSPI, CEikButtonBase::ESet);
       
  1981 	else
       
  1982 		SetCheckBoxState(ERotorAHSPI, CEikButtonBase::EClear);
       
  1983 
       
  1984 	if (iMonInfo->iAHSeq)
       
  1985 		SetCheckBoxState(ERotorAHSeq, CEikButtonBase::ESet);
       
  1986 	else
       
  1987 		SetCheckBoxState(ERotorAHSeq, CEikButtonBase::EClear);
       
  1988 
       
  1989 
       
  1990 	//ESP Fields
       
  1991 	if (iMonInfo->iESPSPI)
       
  1992 		SetCheckBoxState(ERotorESPSPI, CEikButtonBase::ESet);
       
  1993 	else
       
  1994 		SetCheckBoxState(ERotorESPSPI, CEikButtonBase::EClear);
       
  1995 
       
  1996 	if (iMonInfo->iESPSeq)
       
  1997 		SetCheckBoxState(ERotorESPSeq, CEikButtonBase::ESet);
       
  1998 	else
       
  1999 		SetCheckBoxState(ERotorESPSeq, CEikButtonBase::EClear);
       
  2000 }
       
  2001 
       
  2002 
       
  2003 //
       
  2004 //	CAHPacketViewDialog
       
  2005 //
       
  2006 
       
  2007 /*
       
  2008 CAHPacketViewDialog::CAHPacketViewDialog(SMonInfo *aMonInfo)
       
  2009 {
       
  2010 	iMonInfo=aMonInfo;
       
  2011 }
       
  2012 
       
  2013 CAHPacketViewDialog::~CAHPacketViewDialog()
       
  2014 {
       
  2015 
       
  2016 }
       
  2017 
       
  2018 TBool CAHPacketViewDialog::OkToExitL(TInt)
       
  2019 {	
       
  2020 	//AH Fields
       
  2021 
       
  2022 	iMonInfo->iAHProtocol =(CheckBoxState(ERotorAHProtocol)==CEikButtonBase::ESet);
       
  2023 	iMonInfo->iAHHdrLen =(CheckBoxState(ERotorAHHdrLen)==CEikButtonBase::ESet);
       
  2024 	iMonInfo->iAHSPI =(CheckBoxState(ERotorAHSPI)==CEikButtonBase::ESet);
       
  2025 	iMonInfo->iAHSeq =(CheckBoxState(ERotorAHSeq)==CEikButtonBase::ESet);
       
  2026 
       
  2027 	return ETrue;
       
  2028 }
       
  2029 
       
  2030 void CAHPacketViewDialog::PreLayoutDynInitL()
       
  2031 {
       
  2032 
       
  2033 	//AH Fields
       
  2034 
       
  2035 	if (iMonInfo->iAHProtocol)
       
  2036 		SetCheckBoxState(ERotorAHProtocol, CEikButtonBase::ESet);
       
  2037 	else
       
  2038 		SetCheckBoxState(ERotorAHProtocol, CEikButtonBase::EClear);
       
  2039 
       
  2040 	if (iMonInfo->iAHHdrLen)
       
  2041 		SetCheckBoxState(ERotorAHHdrLen, CEikButtonBase::ESet);
       
  2042 	else
       
  2043 		SetCheckBoxState(ERotorAHHdrLen, CEikButtonBase::EClear);
       
  2044 
       
  2045 	if (iMonInfo->iAHSPI)
       
  2046 		SetCheckBoxState(ERotorAHSPI, CEikButtonBase::ESet);
       
  2047 	else
       
  2048 		SetCheckBoxState(ERotorAHSPI, CEikButtonBase::EClear);
       
  2049 
       
  2050 	if (iMonInfo->iAHSeq)
       
  2051 		SetCheckBoxState(ERotorAHSeq, CEikButtonBase::ESet);
       
  2052 	else
       
  2053 		SetCheckBoxState(ERotorAHSeq, CEikButtonBase::EClear);
       
  2054 
       
  2055 }
       
  2056 */
       
  2057 
       
  2058 //
       
  2059 //	CIPv6ViewDialog
       
  2060 //
       
  2061 
       
  2062 
       
  2063 CIPv6ViewDialog::CIPv6ViewDialog(SMonIPv6Info *aMonInfo)
       
  2064 {
       
  2065 	iMonInfo=aMonInfo;
       
  2066 }
       
  2067 
       
  2068 CIPv6ViewDialog::~CIPv6ViewDialog()
       
  2069 {
       
  2070 
       
  2071 }
       
  2072 	//TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
       
  2073 	//void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
  2074 	//void ProcessPointerEventL(const TPointerEvent& aPointerEvent);
       
  2075 	//void ReportEventL(MCoeControlObserver::TCoeEvent aEvent);
       
  2076 	//void PrepareForFocusTransitionL();
       
  2077 	//void HandleControlStateChangeL(TInt aControlId);
       
  2078 
       
  2079 void CIPv6ViewDialog::SetPage()
       
  2080 {
       
  2081 #if EPOC_SDK < 0x06000000
       
  2082 	switch (PageSelector()->CurrentPageControlId())
       
  2083 	{
       
  2084 	case ERotorIPPage:
       
  2085 		SetCheckBoxState(ERotorIPVersion, CEikButtonBase::ESet);
       
  2086 		SetCheckBoxState(ERotorIPTraffic, CEikButtonBase::ESet);
       
  2087 		SetCheckBoxState(ERotorIPFlowLabel, CEikButtonBase::ESet);
       
  2088 		SetCheckBoxState(ERotorIPPayloadLen, CEikButtonBase::ESet);
       
  2089 		SetCheckBoxState(ERotorIPNextHdr, CEikButtonBase::ESet);
       
  2090 		break;
       
  2091 	case ERotorIPPage2:
       
  2092 		SetCheckBoxState(ERotorIPHopLimit, CEikButtonBase::ESet);
       
  2093 		SetCheckBoxState(ERotorIPSrcAddr, CEikButtonBase::ESet);
       
  2094 		SetCheckBoxState(ERotorIPDstAddr, CEikButtonBase::ESet);
       
  2095 		break;
       
  2096 	case ERotorICMPPage:
       
  2097 		SetCheckBoxState(ERotorICMPType, CEikButtonBase::ESet);
       
  2098 		SetCheckBoxState(ERotorICMPCode, CEikButtonBase::ESet);
       
  2099 		SetCheckBoxState(ERotorICMPChksum, CEikButtonBase::ESet);
       
  2100 		SetCheckBoxState(ERotorICMPParameter, CEikButtonBase::ESet);
       
  2101 		break;
       
  2102 	case ERotorTCPPage:
       
  2103 		SetCheckBoxState(ERotorTCPSrcPort, CEikButtonBase::ESet);
       
  2104 		SetCheckBoxState(ERotorTCPDstPort, CEikButtonBase::ESet);
       
  2105 		SetCheckBoxState(ERotorTCPSeq, CEikButtonBase::ESet);
       
  2106 		SetCheckBoxState(ERotorTCPAckNum, CEikButtonBase::ESet);
       
  2107 		SetCheckBoxState(ERotorTCPHdrLen, CEikButtonBase::ESet);
       
  2108 		break;
       
  2109 	case ERotorTCPPage2:
       
  2110 		SetCheckBoxState(ERotorTCPFlags, CEikButtonBase::ESet);
       
  2111 		SetCheckBoxState(ERotorTCPHdrWinSize, CEikButtonBase::ESet);
       
  2112 		SetCheckBoxState(ERotorTCPChksum, CEikButtonBase::ESet);
       
  2113 		SetCheckBoxState(ERotorTCPHdrUrgPtr, CEikButtonBase::ESet);
       
  2114 		SetCheckBoxState(ERotorTCPOptions, CEikButtonBase::ESet);
       
  2115 		break;
       
  2116 	case ERotorUDPPage:
       
  2117 		SetCheckBoxState(ERotorUDPSrcPort, CEikButtonBase::ESet);
       
  2118 		SetCheckBoxState(ERotorUDPDstPort, CEikButtonBase::ESet);
       
  2119 		SetCheckBoxState(ERotorUDPLen, CEikButtonBase::ESet);
       
  2120 		SetCheckBoxState(ERotorUDPChksum, CEikButtonBase::ESet);
       
  2121 		break;
       
  2122 	}
       
  2123 #endif
       
  2124 }	//lint !e1762 // could probably not made const for ER5
       
  2125 
       
  2126 void CIPv6ViewDialog::ClearPage()
       
  2127 {
       
  2128 #if EPOC_SDK < 0x06000000
       
  2129 	switch (PageSelector()->CurrentPageControlId())
       
  2130 	{
       
  2131 	case ERotorIPPage:
       
  2132 		SetCheckBoxState(ERotorIPVersion, CEikButtonBase::EClear);
       
  2133 		SetCheckBoxState(ERotorIPTraffic, CEikButtonBase::EClear);
       
  2134 		SetCheckBoxState(ERotorIPFlowLabel, CEikButtonBase::EClear);
       
  2135 		SetCheckBoxState(ERotorIPPayloadLen, CEikButtonBase::EClear);
       
  2136 		SetCheckBoxState(ERotorIPNextHdr, CEikButtonBase::EClear);
       
  2137 		break;
       
  2138 	case ERotorIPPage2:
       
  2139 		SetCheckBoxState(ERotorIPHopLimit, CEikButtonBase::EClear);
       
  2140 		SetCheckBoxState(ERotorIPSrcAddr, CEikButtonBase::EClear);
       
  2141 		SetCheckBoxState(ERotorIPDstAddr, CEikButtonBase::EClear);
       
  2142 		break;
       
  2143 	case ERotorICMPPage:
       
  2144 		SetCheckBoxState(ERotorICMPType, CEikButtonBase::EClear);
       
  2145 		SetCheckBoxState(ERotorICMPCode, CEikButtonBase::EClear);
       
  2146 		SetCheckBoxState(ERotorICMPChksum, CEikButtonBase::EClear);
       
  2147 		SetCheckBoxState(ERotorICMPParameter, CEikButtonBase::EClear);
       
  2148 		break;
       
  2149 	case ERotorTCPPage:
       
  2150 		SetCheckBoxState(ERotorTCPSrcPort, CEikButtonBase::EClear);
       
  2151 		SetCheckBoxState(ERotorTCPDstPort, CEikButtonBase::EClear);
       
  2152 		SetCheckBoxState(ERotorTCPSeq, CEikButtonBase::EClear);
       
  2153 		SetCheckBoxState(ERotorTCPAckNum, CEikButtonBase::EClear);
       
  2154 		SetCheckBoxState(ERotorTCPHdrLen, CEikButtonBase::EClear);
       
  2155 		break;
       
  2156 	case ERotorTCPPage2:
       
  2157 		SetCheckBoxState(ERotorTCPFlags, CEikButtonBase::EClear);
       
  2158 		SetCheckBoxState(ERotorTCPHdrWinSize, CEikButtonBase::EClear);
       
  2159 		SetCheckBoxState(ERotorTCPChksum, CEikButtonBase::EClear);
       
  2160 		SetCheckBoxState(ERotorTCPHdrUrgPtr, CEikButtonBase::EClear);
       
  2161 		SetCheckBoxState(ERotorTCPOptions, CEikButtonBase::EClear);
       
  2162 		break;
       
  2163 	case ERotorUDPPage:
       
  2164 		SetCheckBoxState(ERotorUDPSrcPort, CEikButtonBase::EClear);
       
  2165 		SetCheckBoxState(ERotorUDPDstPort, CEikButtonBase::EClear);
       
  2166 		SetCheckBoxState(ERotorUDPLen, CEikButtonBase::EClear);
       
  2167 		SetCheckBoxState(ERotorUDPChksum, CEikButtonBase::EClear);
       
  2168 		break;
       
  2169 	}
       
  2170 #endif
       
  2171 }	//lint !e1762 // could probably not made const for ER5
       
  2172 
       
  2173 TBool CIPv6ViewDialog::OkToExitL(TInt aButton)
       
  2174 {	
       
  2175 	switch (aButton)
       
  2176 	{
       
  2177 	case ESetButton:
       
  2178 		SetPage();
       
  2179 		return EFalse;
       
  2180 	case EClearButton:
       
  2181 		ClearPage();
       
  2182 		return EFalse;
       
  2183 	case EEikBidOk:
       
  2184 	//IPFields
       
  2185 
       
  2186 	iMonInfo->iIPVersion =(CheckBoxState(ERotorIPVersion)==CEikButtonBase::ESet);
       
  2187 	iMonInfo->iIPTraffic =(CheckBoxState(ERotorIPTraffic)==CEikButtonBase::ESet);
       
  2188 	iMonInfo->iIPFlowLabel =(CheckBoxState(ERotorIPFlowLabel)==CEikButtonBase::ESet);
       
  2189 	iMonInfo->iIPPayloadLen =(CheckBoxState(ERotorIPPayloadLen)==CEikButtonBase::ESet);
       
  2190 	iMonInfo->iIPNextHdr =(CheckBoxState(ERotorIPNextHdr)==CEikButtonBase::ESet);
       
  2191 	iMonInfo->iIPHopLimit =(CheckBoxState(ERotorIPHopLimit)==CEikButtonBase::ESet);
       
  2192 	iMonInfo->iIPSrcAddr =(CheckBoxState(ERotorIPSrcAddr)==CEikButtonBase::ESet);
       
  2193 	iMonInfo->iIPDstAddr=(CheckBoxState(ERotorIPDstAddr)==CEikButtonBase::ESet);
       
  2194 
       
  2195 
       
  2196 	//ICMP Fields
       
  2197 
       
  2198 	iMonInfo->iICMPType=(CheckBoxState(ERotorICMPType)==CEikButtonBase::ESet);
       
  2199 	iMonInfo->iICMPCode=(CheckBoxState(ERotorICMPCode)==CEikButtonBase::ESet);
       
  2200 	iMonInfo->iICMPChksum=(CheckBoxState(ERotorICMPChksum)==CEikButtonBase::ESet);
       
  2201 	iMonInfo->iICMPParameter=(CheckBoxState(ERotorICMPParameter)==CEikButtonBase::ESet);
       
  2202 	
       
  2203 
       
  2204 	// TCP Fields
       
  2205 	iMonInfo->iTCPSrcPort=(CheckBoxState(ERotorTCPSrcPort)==CEikButtonBase::ESet);
       
  2206 	iMonInfo->iTCPDstPort=(CheckBoxState(ERotorTCPDstPort)==CEikButtonBase::ESet);
       
  2207 	iMonInfo->iTCPSeq=(CheckBoxState(ERotorTCPSeq)==CEikButtonBase::ESet);
       
  2208 	iMonInfo->iTCPAckNum=(CheckBoxState(ERotorTCPAckNum)==CEikButtonBase::ESet);
       
  2209 	iMonInfo->iTCPHdrLen=(CheckBoxState(ERotorTCPHdrLen)==CEikButtonBase::ESet);
       
  2210 	iMonInfo->iTCPFlags=(CheckBoxState(ERotorTCPFlags)==CEikButtonBase::ESet);
       
  2211 	iMonInfo->iTCPHdrWinSize=(CheckBoxState(ERotorTCPHdrWinSize)==CEikButtonBase::ESet);
       
  2212 	iMonInfo->iTCPChksum=(CheckBoxState(ERotorTCPChksum)==CEikButtonBase::ESet);
       
  2213 	iMonInfo->iTCPHdrUrgPtr=(CheckBoxState(ERotorTCPHdrUrgPtr)==CEikButtonBase::ESet);
       
  2214 	iMonInfo->iTCPOptions=(CheckBoxState(ERotorTCPOptions)==CEikButtonBase::ESet);
       
  2215 
       
  2216 
       
  2217 	//UDP Fields
       
  2218 	iMonInfo->iUDPSrcPort=(CheckBoxState(ERotorUDPSrcPort)==CEikButtonBase::ESet);
       
  2219 	iMonInfo->iUDPDstPort=(CheckBoxState(ERotorUDPDstPort)==CEikButtonBase::ESet);
       
  2220 	iMonInfo->iUDPLen=(CheckBoxState(ERotorUDPLen)==CEikButtonBase::ESet);
       
  2221 	iMonInfo->iUDPChksum=(CheckBoxState(ERotorUDPChksum)==CEikButtonBase::ESet);
       
  2222 	return ETrue;
       
  2223 
       
  2224 	case EEikBidCancel:
       
  2225 		return ETrue;
       
  2226 	default:
       
  2227 		return EFalse;
       
  2228 	}
       
  2229 }
       
  2230 
       
  2231 void CIPv6ViewDialog::PreLayoutDynInitL()
       
  2232 {
       
  2233 
       
  2234 	//IP Fields
       
  2235 	if (iMonInfo->iIPVersion)
       
  2236 		SetCheckBoxState(ERotorIPVersion, CEikButtonBase::ESet);
       
  2237 	else
       
  2238 		SetCheckBoxState(ERotorIPVersion, CEikButtonBase::EClear);
       
  2239 
       
  2240 	if (iMonInfo->iIPTraffic)
       
  2241 		SetCheckBoxState(ERotorIPTraffic, CEikButtonBase::ESet);
       
  2242 	else
       
  2243 		SetCheckBoxState(ERotorIPTraffic, CEikButtonBase::EClear);
       
  2244 
       
  2245 	if (iMonInfo->iIPFlowLabel)
       
  2246 		SetCheckBoxState(ERotorIPFlowLabel, CEikButtonBase::ESet);
       
  2247 	else
       
  2248 		SetCheckBoxState(ERotorIPFlowLabel, CEikButtonBase::EClear);
       
  2249 
       
  2250 	if (iMonInfo->iIPPayloadLen)
       
  2251 		SetCheckBoxState(ERotorIPPayloadLen, CEikButtonBase::ESet);
       
  2252 	else
       
  2253 		SetCheckBoxState(ERotorIPPayloadLen, CEikButtonBase::EClear);
       
  2254 
       
  2255 	if (iMonInfo->iIPNextHdr)
       
  2256 		SetCheckBoxState(ERotorIPNextHdr, CEikButtonBase::ESet);
       
  2257 	else
       
  2258 		SetCheckBoxState(ERotorIPNextHdr, CEikButtonBase::EClear);
       
  2259 	
       
  2260 	if (iMonInfo->iIPHopLimit)
       
  2261 		SetCheckBoxState(ERotorIPHopLimit, CEikButtonBase::ESet);
       
  2262 	else
       
  2263 		SetCheckBoxState(ERotorIPHopLimit, CEikButtonBase::EClear);
       
  2264 
       
  2265 	if (iMonInfo->iIPSrcAddr)
       
  2266 		SetCheckBoxState(ERotorIPSrcAddr, CEikButtonBase::ESet);
       
  2267 	else
       
  2268 		SetCheckBoxState(ERotorIPSrcAddr, CEikButtonBase::EClear);
       
  2269 
       
  2270 	if (iMonInfo->iIPDstAddr)
       
  2271 		SetCheckBoxState(ERotorIPDstAddr, CEikButtonBase::ESet);
       
  2272 	else
       
  2273 		SetCheckBoxState(ERotorIPDstAddr, CEikButtonBase::EClear);
       
  2274 	
       
  2275 	//ICMP Fields
       
  2276 
       
  2277 	if (iMonInfo->iICMPType)
       
  2278 		SetCheckBoxState(ERotorICMPType, CEikButtonBase::ESet);
       
  2279 	else
       
  2280 		SetCheckBoxState(ERotorICMPType, CEikButtonBase::EClear);
       
  2281 
       
  2282 	if (iMonInfo->iICMPCode)
       
  2283 		SetCheckBoxState(ERotorICMPCode, CEikButtonBase::ESet);
       
  2284 	else
       
  2285 		SetCheckBoxState(ERotorICMPCode, CEikButtonBase::EClear);
       
  2286 	
       
  2287 	if (iMonInfo->iICMPChksum)
       
  2288 		SetCheckBoxState(ERotorICMPChksum, CEikButtonBase::ESet);
       
  2289 	else
       
  2290 		SetCheckBoxState(ERotorICMPChksum, CEikButtonBase::EClear);
       
  2291 
       
  2292 	if (iMonInfo->iICMPParameter)
       
  2293 		SetCheckBoxState(ERotorICMPParameter, CEikButtonBase::ESet);
       
  2294 	else
       
  2295 		SetCheckBoxState(ERotorICMPParameter, CEikButtonBase::EClear);
       
  2296 
       
  2297 	//TCP Fields
       
  2298 	
       
  2299 	if (iMonInfo->iTCPSrcPort)
       
  2300 		SetCheckBoxState(ERotorTCPSrcPort, CEikButtonBase::ESet);
       
  2301 	else
       
  2302 		SetCheckBoxState(ERotorTCPSrcPort, CEikButtonBase::EClear);
       
  2303 
       
  2304 	if (iMonInfo->iTCPDstPort)
       
  2305 		SetCheckBoxState(ERotorTCPDstPort, CEikButtonBase::ESet);
       
  2306 	else
       
  2307 		SetCheckBoxState(ERotorTCPDstPort, CEikButtonBase::EClear);
       
  2308 
       
  2309 	if (iMonInfo->iTCPSeq)
       
  2310 		SetCheckBoxState(ERotorTCPSeq, CEikButtonBase::ESet);
       
  2311 	else
       
  2312 		SetCheckBoxState(ERotorTCPSeq, CEikButtonBase::EClear);
       
  2313 
       
  2314 	if (iMonInfo->iTCPAckNum)
       
  2315 		SetCheckBoxState(ERotorTCPAckNum, CEikButtonBase::ESet);
       
  2316 	else
       
  2317 		SetCheckBoxState(ERotorTCPAckNum, CEikButtonBase::EClear);
       
  2318 	
       
  2319 	if (iMonInfo->iTCPHdrLen)
       
  2320 		SetCheckBoxState(ERotorTCPHdrLen, CEikButtonBase::ESet);
       
  2321 	else
       
  2322 		SetCheckBoxState(ERotorTCPHdrLen, CEikButtonBase::EClear);
       
  2323 	
       
  2324 	if (iMonInfo->iTCPFlags)
       
  2325 		SetCheckBoxState(ERotorTCPFlags, CEikButtonBase::ESet);
       
  2326 	else
       
  2327 		SetCheckBoxState(ERotorTCPFlags, CEikButtonBase::EClear);
       
  2328 
       
  2329 	if (iMonInfo->iTCPHdrWinSize)
       
  2330 		SetCheckBoxState(ERotorTCPHdrWinSize, CEikButtonBase::ESet);
       
  2331 	else
       
  2332 		SetCheckBoxState(ERotorTCPHdrWinSize, CEikButtonBase::EClear);
       
  2333 
       
  2334 	if (iMonInfo->iTCPChksum)
       
  2335 		SetCheckBoxState(ERotorTCPChksum, CEikButtonBase::ESet);
       
  2336 	else
       
  2337 		SetCheckBoxState(ERotorTCPChksum, CEikButtonBase::EClear);
       
  2338 
       
  2339 	if (iMonInfo->iTCPHdrUrgPtr)
       
  2340 		SetCheckBoxState(ERotorTCPHdrUrgPtr, CEikButtonBase::ESet);
       
  2341 	else
       
  2342 		SetCheckBoxState(ERotorTCPHdrUrgPtr, CEikButtonBase::EClear);
       
  2343 
       
  2344 	if (iMonInfo->iTCPOptions)
       
  2345 		SetCheckBoxState(ERotorTCPOptions, CEikButtonBase::ESet);
       
  2346 	else
       
  2347 		SetCheckBoxState(ERotorTCPOptions, CEikButtonBase::EClear);
       
  2348 
       
  2349 	//UDP Fields
       
  2350 
       
  2351 	if (iMonInfo->iUDPSrcPort)
       
  2352 		SetCheckBoxState(ERotorUDPSrcPort, CEikButtonBase::ESet);
       
  2353 	else
       
  2354 		SetCheckBoxState(ERotorUDPSrcPort, CEikButtonBase::EClear);
       
  2355 
       
  2356 	if (iMonInfo->iUDPDstPort)
       
  2357 		SetCheckBoxState(ERotorUDPDstPort, CEikButtonBase::ESet);
       
  2358 	else
       
  2359 		SetCheckBoxState(ERotorUDPDstPort, CEikButtonBase::EClear);
       
  2360 
       
  2361 	if (iMonInfo->iUDPLen)
       
  2362 		SetCheckBoxState(ERotorUDPLen, CEikButtonBase::ESet);
       
  2363 	else
       
  2364 		SetCheckBoxState(ERotorUDPLen, CEikButtonBase::EClear);
       
  2365 
       
  2366 	if (iMonInfo->iUDPChksum)
       
  2367 		SetCheckBoxState(ERotorUDPChksum, CEikButtonBase::ESet);
       
  2368 	else
       
  2369 		SetCheckBoxState(ERotorUDPChksum, CEikButtonBase::EClear);
       
  2370 
       
  2371 }
       
  2372 
       
  2373 
       
  2374 //
       
  2375 //	CIPv6ExtViewDialog:	IPv6 Extensions Monitoring Preferences Dialog
       
  2376 //
       
  2377 
       
  2378 
       
  2379 CIPv6ExtViewDialog::CIPv6ExtViewDialog(SMonIPv6Info *aMonInfo)
       
  2380 {
       
  2381 	iMonInfo=aMonInfo;
       
  2382 }
       
  2383 
       
  2384 CIPv6ExtViewDialog::~CIPv6ExtViewDialog()
       
  2385 {
       
  2386 
       
  2387 }
       
  2388 
       
  2389 void CIPv6ExtViewDialog::SetPage()
       
  2390 {
       
  2391 #if EPOC_SDK < 0x06000000
       
  2392 #define SETCHECKBOX(x) SetCheckBoxState(x, CEikButtonBase::ESet)
       
  2393 	switch (PageSelector()->CurrentPageControlId())
       
  2394 	{
       
  2395 	case ERotorHOPPage:
       
  2396 		SetCheckBoxState(ERotorHOPNextHdr, CEikButtonBase::ESet);
       
  2397 		SetCheckBoxState(ERotorHOPHdrExtLen, CEikButtonBase::ESet);
       
  2398 		SetCheckBoxState(ERotorHOPOptionType, CEikButtonBase::ESet);
       
  2399 		SetCheckBoxState(ERotorHOPOptionLen, CEikButtonBase::ESet);
       
  2400 		break;
       
  2401 	case ERotorDSTPage:
       
  2402 		SetCheckBoxState(ERotorDSTNextHdr, CEikButtonBase::ESet);
       
  2403 		SetCheckBoxState(ERotorDSTHdrExtLen, CEikButtonBase::ESet);
       
  2404 		SETCHECKBOX(ERotorDSTHomeAddr);
       
  2405 		SETCHECKBOX(ERotorDSTBindingUpdate);
       
  2406 		SETCHECKBOX(ERotorDSTBindingRequest);
       
  2407 		SETCHECKBOX(ERotorDSTBindingAck);
       
  2408 		SETCHECKBOX(ERotorDSTPad);
       
  2409 		SETCHECKBOX(ERotorDSTUnknown);
       
  2410 		break;
       
  2411 	case ERotorRTPage:
       
  2412 		SetCheckBoxState(ERotorRTNextHdr, CEikButtonBase::ESet);
       
  2413 		SetCheckBoxState(ERotorRTHdrExtLen, CEikButtonBase::ESet);
       
  2414 		SetCheckBoxState(ERotorRTRoutingType, CEikButtonBase::ESet);
       
  2415 		SetCheckBoxState(ERotorRTSegLeft, CEikButtonBase::ESet);
       
  2416 		SetCheckBoxState(ERotorRTSLBitMap, CEikButtonBase::ESet);
       
  2417 		SetCheckBoxState(ERotorRTAddresses, CEikButtonBase::ESet);
       
  2418 		break;
       
  2419 	case ERotorFRAGPage:
       
  2420 		SetCheckBoxState(ERotorFRAGNextHdr, CEikButtonBase::ESet);
       
  2421 		SetCheckBoxState(ERotorFRAGFragOffset, CEikButtonBase::ESet);
       
  2422 		SetCheckBoxState(ERotorFRAGMFlag, CEikButtonBase::ESet);
       
  2423 		SetCheckBoxState(ERotorFRAGId, CEikButtonBase::ESet);
       
  2424 		break;
       
  2425 	case ERotorAHPage:
       
  2426 		SetCheckBoxState(ERotorAHProtocol, CEikButtonBase::ESet);
       
  2427 		SetCheckBoxState(ERotorAHHdrLen, CEikButtonBase::ESet);
       
  2428 		SetCheckBoxState(ERotorAHSPI, CEikButtonBase::ESet);
       
  2429 		SetCheckBoxState(ERotorAHSeq, CEikButtonBase::ESet);
       
  2430 		break;
       
  2431 	case ERotorESPPage:
       
  2432 		SetCheckBoxState(ERotorESPSPI, CEikButtonBase::ESet);
       
  2433 		SetCheckBoxState(ERotorESPSeq, CEikButtonBase::ESet);
       
  2434 		break;
       
  2435 	}
       
  2436 #undef SETCHECKBOX
       
  2437 #endif
       
  2438 }	//lint !e1762 // could probably not made const for ER5
       
  2439 
       
  2440 void CIPv6ExtViewDialog::ClearPage()
       
  2441 {
       
  2442 #if EPOC_SDK < 0x06000000
       
  2443 #define CLEARCHECKBOX(x) SetCheckBoxState(x, CEikButtonBase::EClear)
       
  2444 	switch (PageSelector()->CurrentPageControlId())
       
  2445 	{
       
  2446 	case ERotorHOPPage:
       
  2447 		SetCheckBoxState(ERotorHOPNextHdr, CEikButtonBase::EClear);
       
  2448 		SetCheckBoxState(ERotorHOPHdrExtLen, CEikButtonBase::EClear);
       
  2449 		SetCheckBoxState(ERotorHOPOptionType, CEikButtonBase::EClear);
       
  2450 		SetCheckBoxState(ERotorHOPOptionLen, CEikButtonBase::EClear);
       
  2451 		break;
       
  2452 	case ERotorDSTPage:
       
  2453 		SetCheckBoxState(ERotorDSTNextHdr, CEikButtonBase::EClear);
       
  2454 		SetCheckBoxState(ERotorDSTHdrExtLen, CEikButtonBase::EClear);
       
  2455 		CLEARCHECKBOX(ERotorDSTHomeAddr);
       
  2456 		CLEARCHECKBOX(ERotorDSTBindingUpdate);
       
  2457 		CLEARCHECKBOX(ERotorDSTBindingRequest);
       
  2458 		CLEARCHECKBOX(ERotorDSTBindingAck);
       
  2459 		CLEARCHECKBOX(ERotorDSTPad);
       
  2460 		CLEARCHECKBOX(ERotorDSTUnknown);
       
  2461 		break;
       
  2462 	case ERotorRTPage:
       
  2463 		SetCheckBoxState(ERotorRTNextHdr, CEikButtonBase::EClear);
       
  2464 		SetCheckBoxState(ERotorRTHdrExtLen, CEikButtonBase::EClear);
       
  2465 		SetCheckBoxState(ERotorRTRoutingType, CEikButtonBase::EClear);
       
  2466 		SetCheckBoxState(ERotorRTSegLeft, CEikButtonBase::EClear);
       
  2467 		SetCheckBoxState(ERotorRTSLBitMap, CEikButtonBase::EClear);
       
  2468 		SetCheckBoxState(ERotorRTAddresses, CEikButtonBase::EClear);
       
  2469 		break;
       
  2470 	case ERotorFRAGPage:
       
  2471 		SetCheckBoxState(ERotorFRAGNextHdr, CEikButtonBase::EClear);
       
  2472 		SetCheckBoxState(ERotorFRAGFragOffset, CEikButtonBase::EClear);
       
  2473 		SetCheckBoxState(ERotorFRAGMFlag, CEikButtonBase::EClear);
       
  2474 		SetCheckBoxState(ERotorFRAGId, CEikButtonBase::EClear);
       
  2475 		break;
       
  2476 	case ERotorAHPage:
       
  2477 		SetCheckBoxState(ERotorAHProtocol, CEikButtonBase::EClear);
       
  2478 		SetCheckBoxState(ERotorAHHdrLen, CEikButtonBase::EClear);
       
  2479 		SetCheckBoxState(ERotorAHSPI, CEikButtonBase::EClear);
       
  2480 		SetCheckBoxState(ERotorAHSeq, CEikButtonBase::EClear);
       
  2481 		break;
       
  2482 	case ERotorESPPage:
       
  2483 		SetCheckBoxState(ERotorESPSPI, CEikButtonBase::EClear);
       
  2484 		SetCheckBoxState(ERotorESPSeq, CEikButtonBase::EClear);
       
  2485 		break;
       
  2486 	}
       
  2487 #undef CLEARCHECKBOX
       
  2488 #endif
       
  2489 }	//lint !e1762 // could probably not made const for ER5
       
  2490 
       
  2491 TBool CIPv6ExtViewDialog::OkToExitL(TInt aButton)
       
  2492 {	
       
  2493 	switch (aButton)
       
  2494 	{
       
  2495 	case ESetButton:
       
  2496 		SetPage();
       
  2497 		return EFalse;
       
  2498 	case EClearButton:
       
  2499 		ClearPage();
       
  2500 		return EFalse;
       
  2501 	case EEikBidOk:
       
  2502 	//Hop By Hop Fields
       
  2503 
       
  2504 	iMonInfo->iHOPNextHdr =(CheckBoxState(ERotorHOPNextHdr)==CEikButtonBase::ESet);
       
  2505 	iMonInfo->iHOPHdrExtLen =(CheckBoxState(ERotorHOPHdrExtLen)==CEikButtonBase::ESet);
       
  2506 	iMonInfo->iHOPOptionType =(CheckBoxState(ERotorHOPOptionType)==CEikButtonBase::ESet);
       
  2507 	iMonInfo->iHOPOptionLen =(CheckBoxState(ERotorHOPOptionLen)==CEikButtonBase::ESet);
       
  2508 
       
  2509 	// Destination Options Hdr
       
  2510 	iMonInfo->iDSTNextHdr =(CheckBoxState(ERotorDSTNextHdr)==CEikButtonBase::ESet);
       
  2511 	iMonInfo->iDSTHdrExtLen =(CheckBoxState(ERotorDSTHdrExtLen)==CEikButtonBase::ESet);
       
  2512 #define CHECKBOXSET(x) (iMonInfo->i##x = (CheckBoxState(ERotor##x)==CEikButtonBase::ESet))
       
  2513 	CHECKBOXSET(DSTHomeAddr);
       
  2514 	CHECKBOXSET(DSTBindingUpdate);
       
  2515 	CHECKBOXSET(DSTBindingRequest);
       
  2516 	CHECKBOXSET(DSTBindingAck);
       
  2517 	CHECKBOXSET(DSTPad);
       
  2518 	CHECKBOXSET(DSTUnknown);
       
  2519 #undef CHECKBOXSET
       
  2520 
       
  2521 	//Routing Hdr
       
  2522 	iMonInfo->iRTNextHdr =(CheckBoxState(ERotorRTNextHdr)==CEikButtonBase::ESet);
       
  2523 	iMonInfo->iRTHdrExtLen=(CheckBoxState(ERotorRTHdrExtLen)==CEikButtonBase::ESet);
       
  2524 	iMonInfo->iRTRoutingType=(CheckBoxState(ERotorRTRoutingType)==CEikButtonBase::ESet);
       
  2525 	iMonInfo->iRTSegLeft=(CheckBoxState(ERotorRTSegLeft)==CEikButtonBase::ESet);
       
  2526 	iMonInfo->iRTSLBitMap=(CheckBoxState(ERotorRTSLBitMap)==CEikButtonBase::ESet);
       
  2527 	iMonInfo->iRTAddresses=(CheckBoxState(ERotorRTAddresses)==CEikButtonBase::ESet);
       
  2528 
       
  2529 	// Fragment Hdr Fields
       
  2530 	iMonInfo->iFRAGNextHdr=(CheckBoxState(ERotorFRAGNextHdr)==CEikButtonBase::ESet);
       
  2531 	iMonInfo->iFRAGFragOffset=(CheckBoxState(ERotorFRAGFragOffset)==CEikButtonBase::ESet);
       
  2532 	iMonInfo->iFRAGMFlag=(CheckBoxState(ERotorFRAGMFlag)==CEikButtonBase::ESet);
       
  2533 	iMonInfo->iFRAGId=(CheckBoxState(ERotorFRAGId)==CEikButtonBase::ESet);
       
  2534 
       
  2535 	
       
  2536 	//AH Fields	
       
  2537 	iMonInfo->iAHProtocol =(CheckBoxState(ERotorAHProtocol)==CEikButtonBase::ESet);
       
  2538 	iMonInfo->iAHHdrLen =(CheckBoxState(ERotorAHHdrLen)==CEikButtonBase::ESet);
       
  2539 	iMonInfo->iAHSPI =(CheckBoxState(ERotorAHSPI)==CEikButtonBase::ESet);
       
  2540 	iMonInfo->iAHSeq =(CheckBoxState(ERotorAHSeq)==CEikButtonBase::ESet);
       
  2541 
       
  2542 	//ESP Fields
       
  2543 	iMonInfo->iESPSPI =(CheckBoxState(ERotorESPSPI)==CEikButtonBase::ESet);
       
  2544 	iMonInfo->iESPSeq =(CheckBoxState(ERotorESPSeq)==CEikButtonBase::ESet);
       
  2545 	return ETrue;
       
  2546 
       
  2547 	case EEikBidCancel:
       
  2548 		return ETrue;
       
  2549 	default:
       
  2550 		return EFalse;
       
  2551 	}
       
  2552 
       
  2553 }
       
  2554 
       
  2555 void CIPv6ExtViewDialog::PreLayoutDynInitL()
       
  2556 {
       
  2557 
       
  2558 	//HopByHop Fields
       
  2559 
       
  2560 	if (iMonInfo->iHOPNextHdr)
       
  2561 		SetCheckBoxState(ERotorHOPNextHdr, CEikButtonBase::ESet);
       
  2562 	else
       
  2563 		SetCheckBoxState(ERotorHOPNextHdr, CEikButtonBase::EClear);
       
  2564 
       
  2565 	if (iMonInfo->iHOPHdrExtLen)
       
  2566 		SetCheckBoxState(ERotorHOPHdrExtLen, CEikButtonBase::ESet);
       
  2567 	else
       
  2568 		SetCheckBoxState(ERotorHOPHdrExtLen, CEikButtonBase::EClear);
       
  2569 
       
  2570 	if (iMonInfo->iHOPOptionType)
       
  2571 		SetCheckBoxState(ERotorHOPOptionType, CEikButtonBase::ESet);
       
  2572 	else
       
  2573 		SetCheckBoxState(ERotorHOPOptionType, CEikButtonBase::EClear);
       
  2574 
       
  2575 	if (iMonInfo->iHOPOptionLen)
       
  2576 		SetCheckBoxState(ERotorHOPOptionLen, CEikButtonBase::ESet);
       
  2577 	else
       
  2578 		SetCheckBoxState(ERotorHOPOptionLen, CEikButtonBase::EClear);
       
  2579 
       
  2580 
       
  2581 	// Destination Options Hdr
       
  2582 
       
  2583 	if (iMonInfo->iDSTNextHdr)
       
  2584 		SetCheckBoxState(ERotorDSTNextHdr, CEikButtonBase::ESet);
       
  2585 	else
       
  2586 		SetCheckBoxState(ERotorDSTNextHdr, CEikButtonBase::EClear);
       
  2587 	
       
  2588 	if (iMonInfo->iDSTHdrExtLen)
       
  2589 		SetCheckBoxState(ERotorDSTHdrExtLen, CEikButtonBase::ESet);
       
  2590 	else
       
  2591 		SetCheckBoxState(ERotorDSTHdrExtLen, CEikButtonBase::EClear);
       
  2592 #define CHECKBOXSET(x) \
       
  2593 	if (iMonInfo->i##x) \
       
  2594 	SetCheckBoxState(ERotor##x, CEikButtonBase::ESet); \
       
  2595 	else \
       
  2596 	SetCheckBoxState(ERotor##x, CEikButtonBase::EClear)
       
  2597 
       
  2598 	CHECKBOXSET(DSTHomeAddr);
       
  2599 	CHECKBOXSET(DSTBindingUpdate);
       
  2600 	CHECKBOXSET(DSTBindingRequest);
       
  2601 	CHECKBOXSET(DSTBindingAck);
       
  2602 	CHECKBOXSET(DSTPad);
       
  2603 	CHECKBOXSET(DSTUnknown);
       
  2604 #undef CHECKBOXSET
       
  2605 
       
  2606 	//Routing Hdr
       
  2607 
       
  2608 	if (iMonInfo->iRTNextHdr)
       
  2609 		SetCheckBoxState(ERotorRTNextHdr, CEikButtonBase::ESet);
       
  2610 	else
       
  2611 		SetCheckBoxState(ERotorRTNextHdr, CEikButtonBase::EClear);
       
  2612 
       
  2613 	if (iMonInfo->iRTHdrExtLen)
       
  2614 		SetCheckBoxState(ERotorRTHdrExtLen, CEikButtonBase::ESet);
       
  2615 	else
       
  2616 		SetCheckBoxState(ERotorRTHdrExtLen, CEikButtonBase::EClear);
       
  2617 	
       
  2618 	if (iMonInfo->iRTRoutingType)
       
  2619 		SetCheckBoxState(ERotorRTRoutingType, CEikButtonBase::ESet);
       
  2620 	else
       
  2621 		SetCheckBoxState(ERotorRTRoutingType, CEikButtonBase::EClear);
       
  2622 
       
  2623 	if (iMonInfo->iRTSegLeft)
       
  2624 		SetCheckBoxState(ERotorRTSegLeft, CEikButtonBase::ESet);
       
  2625 	else
       
  2626 		SetCheckBoxState(ERotorRTSegLeft, CEikButtonBase::EClear);
       
  2627 	
       
  2628 	if (iMonInfo->iRTSLBitMap)
       
  2629 		SetCheckBoxState(ERotorRTSLBitMap, CEikButtonBase::ESet);
       
  2630 	else
       
  2631 		SetCheckBoxState(ERotorRTSLBitMap, CEikButtonBase::EClear);
       
  2632 	
       
  2633 	if (iMonInfo->iRTAddresses)
       
  2634 		SetCheckBoxState(ERotorRTAddresses, CEikButtonBase::ESet);
       
  2635 	else
       
  2636 		SetCheckBoxState(ERotorRTAddresses, CEikButtonBase::EClear);
       
  2637 
       
  2638 	// Fragment Hdr Fields
       
  2639 	if (iMonInfo->iFRAGNextHdr)
       
  2640 		SetCheckBoxState(ERotorFRAGNextHdr, CEikButtonBase::ESet);
       
  2641 	else
       
  2642 		SetCheckBoxState(ERotorFRAGNextHdr, CEikButtonBase::EClear);
       
  2643 
       
  2644 	if (iMonInfo->iFRAGFragOffset)
       
  2645 		SetCheckBoxState(ERotorFRAGFragOffset, CEikButtonBase::ESet);
       
  2646 	else
       
  2647 		SetCheckBoxState(ERotorFRAGFragOffset, CEikButtonBase::EClear);
       
  2648 
       
  2649 	if (iMonInfo->iFRAGMFlag)
       
  2650 		SetCheckBoxState(ERotorFRAGMFlag, CEikButtonBase::ESet);
       
  2651 	else
       
  2652 		SetCheckBoxState(ERotorFRAGMFlag, CEikButtonBase::EClear);
       
  2653 
       
  2654 	if (iMonInfo->iFRAGId)
       
  2655 		SetCheckBoxState(ERotorFRAGId, CEikButtonBase::ESet);
       
  2656 	else
       
  2657 		SetCheckBoxState(ERotorFRAGId, CEikButtonBase::EClear);
       
  2658 
       
  2659 
       
  2660 
       
  2661 
       
  2662 	//AH Fields
       
  2663 	if (iMonInfo->iAHProtocol)
       
  2664 		SetCheckBoxState(ERotorAHProtocol, CEikButtonBase::ESet);
       
  2665 	else
       
  2666 		SetCheckBoxState(ERotorAHProtocol, CEikButtonBase::EClear);
       
  2667 
       
  2668 	if (iMonInfo->iAHHdrLen)
       
  2669 		SetCheckBoxState(ERotorAHHdrLen, CEikButtonBase::ESet);
       
  2670 	else
       
  2671 		SetCheckBoxState(ERotorAHHdrLen, CEikButtonBase::EClear);
       
  2672 
       
  2673 	if (iMonInfo->iAHSPI)
       
  2674 		SetCheckBoxState(ERotorAHSPI, CEikButtonBase::ESet);
       
  2675 	else
       
  2676 		SetCheckBoxState(ERotorAHSPI, CEikButtonBase::EClear);
       
  2677 
       
  2678 	if (iMonInfo->iAHSeq)
       
  2679 		SetCheckBoxState(ERotorAHSeq, CEikButtonBase::ESet);
       
  2680 	else
       
  2681 		SetCheckBoxState(ERotorAHSeq, CEikButtonBase::EClear);
       
  2682 
       
  2683 
       
  2684 	//ESP Fields
       
  2685 	if (iMonInfo->iESPSPI)
       
  2686 		SetCheckBoxState(ERotorESPSPI, CEikButtonBase::ESet);
       
  2687 	else
       
  2688 		SetCheckBoxState(ERotorESPSPI, CEikButtonBase::EClear);
       
  2689 
       
  2690 	if (iMonInfo->iESPSeq)
       
  2691 		SetCheckBoxState(ERotorESPSeq, CEikButtonBase::ESet);
       
  2692 	else
       
  2693 		SetCheckBoxState(ERotorESPSeq, CEikButtonBase::EClear);
       
  2694 
       
  2695 }
       
  2696 
       
  2697 
       
  2698 CHistoryDialog::CHistoryDialog(TInt *aHistory)
       
  2699 {
       
  2700 	iHistory=aHistory;
       
  2701 }
       
  2702 /*
       
  2703 CHistoryDialog::~CHistoryDialog()
       
  2704 {
       
  2705 
       
  2706 }
       
  2707 */
       
  2708 TBool CHistoryDialog::OkToExitL(TInt)
       
  2709 {
       
  2710 	*iHistory=NumberEditorValue(ERotorHistory);	
       
  2711 	return ETrue;
       
  2712 }
       
  2713 
       
  2714 void CHistoryDialog::PreLayoutDynInitL()
       
  2715 {
       
  2716 	SetNumberEditorValue(ERotorHistory, *iHistory);
       
  2717 }
       
  2718 
       
  2719 // 
       
  2720 // CConsoleControl
       
  2721 //
       
  2722 
       
  2723 CConsoleControl::~CConsoleControl()
       
  2724 	{
       
  2725 	//delete iSelBufPtr; // forget selection
       
  2726 	delete iConsole;
       
  2727 	}
       
  2728 /*
       
  2729 void CConsoleControl::ConstructL(TInt aFlags)
       
  2730 	{
       
  2731 	*/
       
  2732 	/*
       
  2733     CreateWindowL();
       
  2734     Window().SetShadowDisabled(ETrue);
       
  2735     Window().SetBackgroundColor(KRgbGray);
       
  2736     EnableDragEvents();
       
  2737     SetExtentToWholeScreenL();
       
  2738 	SetBlank();
       
  2739 	*/
       
  2740 /*
       
  2741     iConsole=new(ELeave) CEikConsoleScreen;
       
  2742 	iConsole->ConstructL(_L("TEST"),aFlags);
       
  2743 	iConsole->SetHistorySizeL(100,0);
       
  2744 	iHistory=100;
       
  2745 	}
       
  2746 */
       
  2747 
       
  2748 void CConsoleControl::ConstructL(const TPoint& aTopLeft, const TSize& aSize, TInt aFlags)
       
  2749 	{
       
  2750 	/*
       
  2751     CreateWindowL();
       
  2752     Window().SetShadowDisabled(ETrue);
       
  2753     Window().SetBackgroundColor(KRgbGray);
       
  2754     EnableDragEvents();
       
  2755     SetExtentToWholeScreenL();
       
  2756 	SetBlank();
       
  2757 	*/
       
  2758 	TRect rect(aTopLeft,aTopLeft + aSize.AsPoint());
       
  2759 #if EPOC_SDK < 0x06000000
       
  2760     SetRectL(rect);
       
  2761 #else
       
  2762 	SetRect(rect);
       
  2763 #endif
       
  2764  	
       
  2765     iConsole=new(ELeave) CEikConsoleScreen;
       
  2766 	iConsole->ConstructL(_L("TEST"),aTopLeft,aSize,aFlags,EEikConsWinInPixels);
       
  2767 	iConsole->SetHistorySizeL(200,0);
       
  2768 	iHistory=200;
       
  2769 	}
       
  2770 
       
  2771 void CConsoleControl::ActivateL()
       
  2772 	{
       
  2773 	CCoeControl::ActivateL();
       
  2774 	iConsole->SetKeepCursorInSight(TRUE);
       
  2775 	iConsole->DrawCursor();
       
  2776 	iConsole->SetAtt(ATT_NORMAL);
       
  2777 	}
       
  2778 /*
       
  2779 void CConsoleControl::DynInitMenuPaneL(TInt aMenuId,CEikMenuPane* aMenuPane)
       
  2780 	{
       
  2781 	if (aMenuId==R_CONS_OPTIONS_MENU)
       
  2782 		{
       
  2783 		if ( iConsole->Att() & ATT_COLORMASK )
       
  2784 			aMenuPane->SetItemButtonState(EMenuCommandColor,EEikMenuItemSymbolOn);
       
  2785 		else
       
  2786 			{
       
  2787 			if ( iConsole->Att() & ATT_BOLD )
       
  2788 				aMenuPane->SetItemButtonState(EMenuCommandBold,EEikMenuItemSymbolOn);
       
  2789 			if ( iConsole->Att() & ATT_INVERSE )
       
  2790 				aMenuPane->SetItemButtonState(EMenuCommandInverse,EEikMenuItemSymbolOn);
       
  2791 			if ( iConsole->Att() & ATT_ITALIC )
       
  2792 				aMenuPane->SetItemButtonState(EMenuCommandItalic,EEikMenuItemSymbolOn);
       
  2793 			if ( iConsole->Att() & ATT_UNDERLINE )
       
  2794 				aMenuPane->SetItemButtonState(EMenuCommandUnderline,EEikMenuItemSymbolOn);
       
  2795 			}
       
  2796 		}
       
  2797 	
       
  2798 	if (aMenuId==R_CONS_SPECIAL_MENU)
       
  2799 		{
       
  2800 		if (iHighCursor)
       
  2801 			aMenuPane->SetItemButtonState(EMenuCursorSize,EEikMenuItemSymbolOn);
       
  2802 		if (iSmallScreen)
       
  2803 			aMenuPane->SetItemButtonState(EMenuScreenSize,EEikMenuItemSymbolOn);
       
  2804 		}
       
  2805 
       
  2806 	if (aMenuId==R_CONS_TOOLS_MENU)
       
  2807 		{
       
  2808 		if (iHideCursor)
       
  2809 			aMenuPane->SetItemButtonState(EMenuCommandHideCursor,EEikMenuItemSymbolOn);
       
  2810 		if (iIgnoreCursor)
       
  2811 			aMenuPane->SetItemButtonState(EMenuCommandIgnoreCursor,EEikMenuItemSymbolOn);
       
  2812 		if (iScrollLock)
       
  2813 			aMenuPane->SetItemButtonState(EMenuCommandScrollLock,EEikMenuItemSymbolOn);
       
  2814 		if (iAllPrintable)
       
  2815 			aMenuPane->SetItemButtonState(EMenuCommandPrintable,EEikMenuItemSymbolOn);
       
  2816 		}
       
  2817 
       
  2818 	}
       
  2819 */
       
  2820 void CConsoleControl::HandleCommandL(TInt aCommand)
       
  2821     {
       
  2822     switch (aCommand)
       
  2823         {
       
  2824 		/*
       
  2825 	case ERotorClearScreen:
       
  2826 		//iConsole->ClearScreen();	//Only clears visible part of console
       
  2827 
       
  2828 		break;
       
  2829 
       
  2830 	case EMenuCommandEditCopy			:
       
  2831 		{
       
  2832 		TRect range = iConsole->Selection();	// get current selected range		
       
  2833 		if (iSelBufPtr) delete iSelBufPtr;		// forget previous selection
       
  2834 		iSelBufPtr = iConsole->RetrieveL(range);
       
  2835 		if (iSelBufPtr)
       
  2836 			{
       
  2837 			TBuf<32> msg;
       
  2838 			msg.Format(_L("%d bytes copied"),iSelBufPtr->Length());
       
  2839 			iEikonEnv->InfoMsg(msg);
       
  2840 			}
       
  2841 		else 
       
  2842 			iEikonEnv->InfoMsg(_L("Nothing to copy..."));
       
  2843 		}
       
  2844 		break;
       
  2845 	case EMenuCommandEditPaste			:
       
  2846 		iConsole->SelectCursor(); // forget current selection...
       
  2847 		if (iSelBufPtr)
       
  2848 			{
       
  2849 			iConsole->Write(*iSelBufPtr);
       
  2850 			iConsole->FlushChars();
       
  2851 			TBuf<32> msg;
       
  2852 			msg.Format(_L("%d bytes pasted"),iSelBufPtr->Length());
       
  2853 			iEikonEnv->InfoMsg(msg);
       
  2854 			}
       
  2855 		else
       
  2856 			{
       
  2857 			iEikonEnv->InfoMsg(_L("Nothing to paste..."));
       
  2858 			}
       
  2859 		break;
       
  2860 		
       
  2861 	case EMenuCommandBold:
       
  2862     case EMenuCommandItalic:
       
  2863     case EMenuCommandUnderline:
       
  2864 	case EMenuCommandInverse:
       
  2865     case EMenuCommandColor:
       
  2866         ToggleFontStyleAndRedrawL((TMessageControlFontStyle)aCommand);
       
  2867         break;
       
  2868 
       
  2869 	case EMenuScreenSize:
       
  2870 		{
       
  2871 		iSmallScreen = !iSmallScreen;
       
  2872 		if (iSmallScreen)
       
  2873 			iConsole->ConsoleControl()->SetExtentL( TPoint(40,20), TSize(560,200) );
       
  2874 		else
       
  2875 			iConsole->ConsoleControl()->SetExtentL( TPoint(0,0), TSize(640,240) );
       
  2876 		}
       
  2877 		break;
       
  2878 	case EMenuCursorSize:
       
  2879 		{
       
  2880 		iHighCursor = !iHighCursor;
       
  2881 		if (iHighCursor)
       
  2882 			iConsole->SetCursorHeight(100);
       
  2883 		else
       
  2884 			iConsole->SetCursorHeight(20);
       
  2885 		}
       
  2886 		break;
       
  2887 */
       
  2888 #if EPOC_SDK < 0x06000000
       
  2889 	case ERotorFontDialog:
       
  2890 		{
       
  2891 		TCharFormat charFormat;
       
  2892 		charFormat.iFontSpec = iConsole->Font();
       
  2893 		TCharFormatMask dummy;
       
  2894 		CEikFontDialog* dialog=new(ELeave) CEikFontDialog(charFormat,dummy);
       
  2895 		if (dialog->ExecuteLD(R_EIK_DIALOG_FONT))
       
  2896 			{
       
  2897 			//charFormat.iFontSpec.iTypeface.SetIsProportional(EFalse);
       
  2898 			iConsole->SetFontL(charFormat.iFontSpec);
       
  2899 			}
       
  2900 		}
       
  2901         break;
       
  2902 #endif
       
  2903 
       
  2904 	case ERotorHistory:
       
  2905 		{
       
  2906 			CHistoryDialog* dialog2=new(ELeave) CHistoryDialog(&iHistory);
       
  2907 			if (dialog2->ExecuteLD(R_ROTOR_HISTORY_DIALOG))
       
  2908 			{
       
  2909 				iConsole->SetHistorySizeL(iHistory,0);
       
  2910 			}
       
  2911 		}
       
  2912         break;
       
  2913 
       
  2914 /*
       
  2915 	case EMenuCommandHideCursor:
       
  2916 		iHideCursor=!iHideCursor;
       
  2917 		if (iHideCursor)
       
  2918 			iConsole->HideCursor();
       
  2919 		else
       
  2920 			iConsole->DrawCursor();
       
  2921 		break;
       
  2922     case EMenuCommandIgnoreCursor:
       
  2923 		iConsole->SetKeepCursorInSight(iIgnoreCursor);
       
  2924 		iIgnoreCursor=!iIgnoreCursor;
       
  2925 		break;
       
  2926     case EMenuCommandScrollLock:
       
  2927 		iScrollLock=!iScrollLock;
       
  2928 		iConsole->SetScrollLock(iScrollLock);
       
  2929 		break;
       
  2930     case EMenuCommandPrintable:
       
  2931 		iAllPrintable=!iAllPrintable;
       
  2932 		iConsole->SetAllPrintable(iAllPrintable);
       
  2933 		break;
       
  2934 */		
       
  2935 
       
  2936     case ERotorScrollNone:
       
  2937 		iConsole->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOff);
       
  2938         break;
       
  2939     case ERotorScrollHor:
       
  2940 		iConsole->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto,CEikScrollBarFrame::EOff);
       
  2941         break;
       
  2942     case ERotorScrollVert:
       
  2943 		iConsole->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
       
  2944         break;
       
  2945    	case ERotorScrollBoth:
       
  2946 		iConsole->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto,CEikScrollBarFrame::EAuto);
       
  2947         break;
       
  2948 
       
  2949 /*
       
  2950 	case EMenuCommandLongLine			:
       
  2951 		TBuf<256> str;
       
  2952 		for (TInt i=0; i<9; i++)
       
  2953 			{
       
  2954 			TBuf<32> tmp;
       
  2955 			tmp.Format(_L("%d abcdefghijklmnopqrstuvwxyz"),i);
       
  2956 			str+=tmp;
       
  2957 			}
       
  2958 		iConsole->Write(str);
       
  2959 		iConsole->FlushChars();
       
  2960         break;
       
  2961 */
       
  2962 	default:
       
  2963 		break;
       
  2964 		}
       
  2965     }
       
  2966 
       
  2967 void CConsoleControl::FocusChanged(TDrawNow aDrawNow)
       
  2968 	{
       
  2969 	iConsole->ConsoleControl()->SetFocus(IsFocused(), aDrawNow); 
       
  2970 	}
       
  2971 
       
  2972 void CConsoleControl::ToggleFontStyleAndRedrawL(TMessageControlFontStyle aStyleElement)
       
  2973     {
       
  2974     switch (aStyleElement)
       
  2975         {
       
  2976     case EStyleElementColor:
       
  2977 		if ( iConsole->Att() & ATT_COLORMASK )	// color?
       
  2978 			iConsole->SetAtt(ATT_NORMAL);	// then set normal
       
  2979 		else								// else
       
  2980 			iConsole->SetAtt(4,11);			// set 4 (darkgray) on 11 (lightgray)
       
  2981         break;
       
  2982     case EStyleElementBold:
       
  2983 		// clear color flag (just to be sure) and switch bold flag
       
  2984 		iConsole->SetAtt( (iConsole->Att()&(~ATT_COLORMASK)) ^ ATT_BOLD );
       
  2985         break;
       
  2986     case EStyleElementItalic:
       
  2987 		// clear color flag (just to be sure) and switch italic flag
       
  2988 		iConsole->SetAtt( (iConsole->Att()&(~ATT_COLORMASK)) ^ ATT_ITALIC );
       
  2989         break;
       
  2990     case EStyleElementInverse:
       
  2991 		// clear color flag (just to be sure) and switch inverse flag
       
  2992 		iConsole->SetAtt( (iConsole->Att()&(~ATT_COLORMASK)) ^ ATT_INVERSE );
       
  2993         break;
       
  2994     case EStyleElementUnderline:
       
  2995 		// clear color flag (just to be sure) and switch underline flag
       
  2996 		iConsole->SetAtt( (iConsole->Att()&(~ATT_COLORMASK)) ^ ATT_UNDERLINE );
       
  2997         break;
       
  2998         }
       
  2999     }
       
  3000 /*
       
  3001 void CConsoleControl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
  3002     {
       
  3003 	TBuf<128> iMessage;
       
  3004     iEikonEnv->Format128(iMessage,R_CONS_POINTER_EVENT,aPointerEvent.iType,aPointerEvent.iPosition.iX,aPointerEvent.iPosition.iY);
       
  3005 	iConsole->Write(iMessage);
       
  3006 	iConsole->FlushChars();
       
  3007     }
       
  3008 */
       
  3009 /*
       
  3010 TKeyResponse CConsoleControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
  3011 {
       
  3012 	if (aType!=EEventKey)
       
  3013 		return(EKeyWasConsumed);
       
  3014     TInt modifiers=aKeyEvent.iModifiers;
       
  3015     TInt code=aKeyEvent.iCode;
       
  3016     if (code==CTRL('e'))
       
  3017         CBaActiveScheduler::Exit();
       
  3018 
       
  3019 
       
  3020 	TRect range = iConsole->Selection(); // get current selected range
       
  3021 	switch (code)
       
  3022 		{
       
  3023 		case EKeyUpArrow:
       
  3024 			iConsole->Up();
       
  3025 			if (modifiers & EModifierShift)
       
  3026 				{
       
  3027 				range.iTl = iConsole->CursorPos();
       
  3028 				iConsole->SetSelection(range); 
       
  3029 				}
       
  3030 			else
       
  3031 				iConsole->SelectCursor(); 
       
  3032 			break;
       
  3033 		case EKeyDownArrow:
       
  3034 			iConsole->Down();
       
  3035 			if (modifiers & EModifierShift)
       
  3036 				{
       
  3037 				range.iTl = iConsole->CursorPos();
       
  3038 				iConsole->SetSelection(range); 
       
  3039 				}
       
  3040 			else
       
  3041 				iConsole->SelectCursor(); 
       
  3042 			break;
       
  3043 		case EKeyLeftArrow:
       
  3044 			iConsole->Left();
       
  3045 			if (modifiers & EModifierShift)
       
  3046 				{
       
  3047 				range.iTl = iConsole->CursorPos();
       
  3048 				iConsole->SetSelection(range); 
       
  3049 				}
       
  3050 			else
       
  3051 				iConsole->SelectCursor(); 
       
  3052 			break;
       
  3053 		case EKeyRightArrow:
       
  3054 			iConsole->Right();
       
  3055 			if (modifiers & EModifierShift)
       
  3056 				{
       
  3057 				range.iTl = iConsole->CursorPos();
       
  3058 				iConsole->SetSelection(range); 
       
  3059 				}
       
  3060 			else
       
  3061 				iConsole->SelectCursor(); 
       
  3062 			break;
       
  3063 		case EKeyEnter: 
       
  3064 			if (!iAllPrintable)
       
  3065 				{
       
  3066 				iConsole->Cr();
       
  3067 				iConsole->Lf();
       
  3068 				}
       
  3069 			break;
       
  3070 		default:
       
  3071 			{
       
  3072 			iConsole->SelectCursor();	// forget previous selection
       
  3073 			TBuf<1> chr;
       
  3074 			chr.Format(_L("%c"),code);
       
  3075 			iConsole->Write(chr);
       
  3076 			iConsole->FlushChars();
       
  3077 			}
       
  3078 			break;
       
  3079 		}
       
  3080     return(EKeyWasConsumed);
       
  3081 }
       
  3082 */
       
  3083 
       
  3084 void CConsoleControl::SetScrollBarVisibilityL(CEikScrollBarFrame::TScrollBarVisibility aHBarVisibility, CEikScrollBarFrame::TScrollBarVisibility aVBarVisibility)
       
  3085 {
       
  3086 	iConsole->SetScrollBarVisibilityL(aHBarVisibility,aVBarVisibility);
       
  3087 	iConsole->ConsoleControl()->UpdateArea();
       
  3088 	iConsole->UpdateScrollBars();
       
  3089 	iConsole->ConsoleControl()->UpdateArea();
       
  3090 	//TBool b=iConsole->RecalculateSize();
       
  3091 }
       
  3092 
       
  3093 
       
  3094 void CConsoleControl::DrawCursor()
       
  3095 {
       
  3096 	iConsole->DrawCursor();
       
  3097 }
       
  3098 
       
  3099 
       
  3100 void CConsoleControl::Write(const TDesC &aMsg)
       
  3101 {
       
  3102 	iConsole->Write(aMsg);
       
  3103 	iConsole->FlushChars();
       
  3104 	/*
       
  3105 	iConsole->UpdateScrollBars();
       
  3106 	iConsole->ConsoleControl()->UpdateArea();
       
  3107 	iConsole->UpdateScrollBars();
       
  3108 	iConsole->Redraw(Rect());
       
  3109 	*/
       
  3110 }
       
  3111 
       
  3112 CEikConsoleControl *CConsoleControl::ConsoleControl() const
       
  3113 {
       
  3114 	return iConsole->ConsoleControl();
       
  3115 }
       
  3116 
       
  3117 TBool CConsoleControl::UpdateScrollBars()
       
  3118 {
       
  3119 	return iConsole->UpdateScrollBars();
       
  3120 }
       
  3121 
       
  3122 void CConsoleControl::ClearScreen()
       
  3123 {
       
  3124 	iConsole->ClearScreen();
       
  3125 }
       
  3126 
       
  3127 
       
  3128 void CConsoleControl::Redraw(const TRect &aRect)
       
  3129 {
       
  3130 	iConsole->Redraw(aRect);
       
  3131 }
       
  3132 
       
  3133 void CConsoleControl::Lf()
       
  3134 {
       
  3135 	iConsole->Lf();
       
  3136 }
       
  3137 
       
  3138 
       
  3139 TSize CConsoleControl::ScreenSize() const
       
  3140 {
       
  3141 	return iConsole->ScreenSize();
       
  3142 }