# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1261031965 -7200 # Node ID 857a3e953887a5951308df719d37e18826c1bf23 Revision: 200949 Kit: 200951 diff -r 000000000000 -r 857a3e953887 emulatorlan/data/EnableLanConnection.cmd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emulatorlan/data/EnableLanConnection.cmd Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,19 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: Command file for project emulatorlan +rem + +call configchange.pl --config ethernetWithCommDB --kernel EKA2 --target winscw --variant UDEB +call \epoc32\RELEASE\winscw\udeb\dbcreator.exe -dtextshell -Mconsole -- E +call \epoc32\RELEASE\winscw\udeb\dbcreator.exe -dtextshell -- f:c:\S60_32_default_snaps.xml diff -r 000000000000 -r 857a3e953887 emulatorlan/data/configchange.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emulatorlan/data/configchange.pl Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,272 @@ +# +# Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: The script can +# - create a working ethernet setup with "ethernet" config option +# - restore previous setup with "restore" config option +# + +use Getopt::Long; +use Cwd; + +my $config="default"; +my $target="default"; +my $kernel="default"; +my $showhelp='0'; + +my $etherNif; +my $etherMac; +my $etherSpeed; + +# this variable is passed as an argument to netcards.exe +# specifies which interface to use in case of multiple interfaces + +my $interface=0; + +$/ = "\n"; + +GetOptions('config=s' => \$config, 'kernel=s' => \$kernel, 'target=s' => \$target, 'variant=s' => \$variant, 'help' => \$showhelp, 'interface:i' => \$interface); + +$config = lc( $config ); +$kernel = lc( $kernel ); +$target = lc( $target ); +$variant = lc( $variant ); + + +if( $showhelp || ( $kernel ne "eka1" && $kernel ne "eka2" ) || + ( $target ne "wins" && $target ne "winscw" ) || + ( $config ne "ethernetwithcommdb" && $config ne "restorecommdb" && $config ne "ethernetnocommdb" ) || + ( $variant ne "udeb" && $variant ne "urel" ) ) + { + print "Command usage: configchange --config [ethernetWithCommDB|restoreCommDB|ethernetNoCommDB] --kernel [EKA1|EKA2] --target [wins|winscw] --variant [UDEB|UREL]\n"; + print "\t\t--config \tSelect required configuration\n"; + print "\t\t--kernel \tKernel variant\n"; + print "\t\t--target \tTarget emulator\n"; + print "\t\t--variant \tBuild type\n"; + print "\t\t--interface \tInterface Number\n"; + print "\t\t--help \tThis text\n"; + exit 0; + } + +my $epocroot = &getEpocroot; +my $drive = &getDrive; + +if( $config ne "restorecommdb" ) + { + # must be creating some ethernet setup + if( $config eq "ethernetwithcommdb" ) + { + # write an appropriate commDB setup + print( "Setting up CommDB for ethernet\n" ); + system( "$drive\\$epocroot\\epoc32\\release\\$target\\$variant\\ceddump -dtextshell --" ) == 0 + or die "Error running ceddump!\n"; + system( "move $drive\\$epocroot\\epoc32\\$target\\c\\cedout.cfg $drive\\$epocroot\\epoc32\\$target\\c\\nonethernetced.cfg" ) == 0 + or die "Failed to rename cedout.cfg!\n"; + system( "$drive\\$epocroot\\epoc32\\release\\$target\\$variant\\ced -dtextshell -- -i c:\\EthernetCed.xml") == 0 + or die "Error running ced!\n"; + } + print( "Running Netcards to obtain adapter info\n" ); + system( "$drive\\$epocroot\\epoc32\\tools\\netcards $interface" ) == 0 + or die "Error running netcards!\n"; + + open ( INFILE, "ethernet.ini" ) or die "Can't find netcards output file, ethernet.ini!\n"; # get from current directory where netcards wrote it to + + if ($kernel eq "eka1") + { + open ( ETHERMAC, ">$drive\\$epocroot\\epoc32\\$target\\c\\system\\data\\ethermac.dat" ) or die "Can't open $drive\\$epocroot\\epoc32\\$target\\c\\system\\data\\ethermac.dat!\n"; + open ( ETHERDRV, ">$drive\\$epocroot\\epoc32\\$target\\c\\system\\data\\etherdriver.dat" ) or die "Can't open $drive\\$epocroot\\epoc32\\$target\\c\\system\\data\\etherdriver.dat!\n"; + } + + while( ) + { + chomp; + my $sLine = $_; + + if( $sLine =~ /ETHER_NIF=(.*)/i ) + { + #print "Matched ETHER_NIF\n"; + if ($kernel eq "eka1") + { + print ETHERDRV "$1"; + } + else + { + $etherNif = $1; + } + } + elsif( $sLine =~ /ETHER_MAC=(.*)/i ) + { + #print "Matched ETHER_MAC\n"; + if ($kernel eq "eka1") + { + print ETHERMAC "$1"; + } + else + { + $etherMac = $1; + } + } + elsif( $sLine =~ /ETHER_SPEED=(.*)/i ) + { + #print "Matched ETHER_SPEED\n"; + if ($kernel eq "eka2") + { + $etherSpeed = $1; + } + } + #print "line: $sLine\n"; + } + if ($kernel eq "eka1") + { + close( ETHERDRV ); + close( ETHERMAC ); + } + else + { + # do the insertion to epoc.ini + &generateEpocIni; + } + close( INFILE ); + } +else + { + if( -f "$drive\\$epocroot\\epoc32\\$target\\c\\nonethernetced.cfg" ) + { + system( "$drive\\$epocroot\\epoc32\\release\\$target\\$variant\\ced -i c:\\nonethernetced.cfg" ) == 0 + or die "Can't find backup ced file!\n"; + system( "move $drive\\$epocroot\\epoc32\\$target\\c\\nonethernetced.cfg $drive\\$epocroot\\epoc32\\$target\\c\\cedout.cfg") == 0 + or die "Can't rename backup ced file!\n"; + } + else + { + print "No restore file found!\n"; + } + } + + + + +# +# Determines, validates, and returns EPOCROOT. +# +sub getEpocroot +{ + my $epocroot = $ENV{EPOCROOT}; + die "ERROR: Must set the EPOCROOT environment variable.\n" + if (!defined($epocroot)); + $epocroot =~ s-/-\\-go; # for those working with UNIX shells + die "ERROR: EPOCROOT must be an absolute path, " . + "not containing a drive letter.\n" if ($epocroot !~ /^\\/); + die "ERROR: EPOCROOT must not be a UNC path.\n" if ($epocroot =~ /^\\\\/); + die "ERROR: EPOCROOT must end with a backslash.\n" if ($epocroot !~ /\\$/); + die "ERROR: EPOCROOT must specify an existing directory.\n" + if (!-d $epocroot); + return $epocroot; +} + +# +# Determines and returns the current drive, if any. +# +sub getDrive +{ + my $wd = cwd; + my $drive; + if($wd =~ /^([a-zA-Z]:)/) { + $drive = $1; + } else { + # Perhaps we're on a machine that has no drives. + $drive = ""; + } + return $drive; +} + +# +# +# +sub generateEpocIni +{ + my @outLines; + my $length = 0; + my $needToAppend = TRUE; + my $epocIniAlreadyExists = FALSE; + my $finished = FALSE; + print "generating epoc ini\n"; + if ( -e "$drive\\$epocroot\\epoc32\\data\\epoc.ini" ) + { + $epocIniAlreadyExists = TRUE; + open( EPOCINI, "+<$drive\\$epocroot\\epoc32\\data\\epoc.ini" ); + seek( EPOCINI, 0, 0 ); + while( ) + { + chomp; + my $sLine = $_; + if( $sLine =~ /ETHER_NIF=(.*)/i ) + { + #print "matched etherNIF\n"; + $length = length( $etherNif ); + substr( $sLine, (index( $sLine, "=" )+1), $length ) = $etherNif; + $needToAppend = FALSE; + } + elsif( $sLine =~ /ETHER_MAC=(.*)/i ) + { + #print "Matched ETHER_MAC\n"; + $length = length( $etherMac ); + substr( $sLine, (index( $sLine, "=" )+1), $length ) = $etherMac; + $needToAppend = FALSE; + } + elsif( $sLine =~ /ETHER_SPEED=(.*)/i ) + { + #print "Matched etherSpeed\n"; + $length = length( $etherSpeed ); + substr( $sLine, (index( $sLine, "=" )+1), $length ) = $etherSpeed; + $needToAppend = FALSE; + } + push( @outLines, $sLine ); + push( @outLines, "\n" ); + } + if ( $needToAppend eq FALSE ) + { + print "Writing new settings into epoc.ini\n"; + # we have read the entire file and replaced what we need to + # now lets write it back to the file + seek( EPOCINI, 0, 0 ); + print EPOCINI @outLines; + $finished = TRUE; + } + close ( EPOCINI ); + } + + if ( $finished eq FALSE ) + { + if ( ($needToAppend eq TRUE) && ($epocIniAlreadyExists eq TRUE) ) + { + print "Appending settings to current epoc.ini\n"; + # we must append all the settings onto the end of the current epoc.ini + open( EPOCINI, ">>$drive\\$epocroot\\epoc32\\data\\epoc.ini" ) or die "Can't open epoc.ini!\n"; + } + elsif ( $epocIniAlreadyExists eq FALSE ) + { + print "Creating new epoc.ini\n"; + # create new file + open( EPOCINI, ">$drive\\$epocroot\\epoc32\\data\\epoc.ini" ); + } + + print EPOCINI "\nETHER_NIF="; + print EPOCINI "$etherNif\n"; + print EPOCINI "ETHER_MAC="; + print EPOCINI "$etherMac\n"; + print EPOCINI "ETHER_SPEED="; + print EPOCINI "$etherSpeed\n"; + close ( EPOCINI ); + } +} diff -r 000000000000 -r 857a3e953887 emulatorlan/data/ethernetced.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emulatorlan/data/ethernetced.xml Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,1897 @@ + + + + + + + + + + Intranet + + + mRouter + + + + + + Default Modem + CSD.agt + PPP + COMM::0 + MM + ECUART + 8 + 1 + NONE + 115200 + 0 + 0 + 0 + 0 + AUTO + NEVER + QUIET + AT + AT + AT + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 180 + 30 + 60 + 0 + 0 + + + Null Modem 115200bps + CSD.agt + PPP + COMM::0 + MM + ECUART + 8 + 1 + NONE + 115200 + 4 + 0 + 0 + 0 + AUTO + NEVER + QUIET + AT + AT + AT + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 180 + 30 + 60 + 0 + 0 + + + US Robotics Sportster + CSD.agt + PPP + COMM::0 + MM + ECUART + 8 + 1 + NONE + 57600 + 244 + 0 + 0 + 0 + AUTO + AFTERDIALUNTILANSWER + QUIET + AT&F1 + AT + AT&d2 + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 180 + 30 + 60 + 0 + 0 + + + Dacom Surfer + CSD.agt + PPP + COMM::0 + MM + ECUART + 8 + 1 + NONE + 57600 + 244 + 0 + 0 + 0 + AUTO + AFTERDIALUNTILANSWER + QUIET + AT&F + AT + AT&d2 + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 180 + 30 + 60 + 0 + 0 + + + GSM Mobile Phone via Infrared + CSD.agt + PPP + IRCOMM::0 + MM + IRCOMM + 8 + 1 + NONE + 115200 + 196 + 0 + 17 + 19 + AUTO + NEVER + QUIET + ATZ + AT + AT + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 180 + 30 + 60 + 0 + 0 + + + GSM Mobile Phone via Serial + CSD.agt + PPP + COMM::0 + MM + ECUART + 8 + 1 + NONE + 19200 + 196 + 0 + 17 + 19 + AUTO + NEVER + QUIET + ATZ + AT + AT + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 180 + 30 + 60 + 0 + 0 + + + GPRS Ericsson R520m via IR + PSD.agt + PPP + IRCOMM::0 + MM + IRCOMM + 8 + 1 + NONE + 115200 + 4 + 0 + 17 + 19 + AUTO + NEVER + QUIET + ATZ + AT + AT + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 180 + 30 + 60 + 0 + 0 + + + GPRS Ericsson R520m/T68i via Serial + PSD.agt + PPP + COMM::0 + MM + ECUART + 8 + 1 + NONE + 19200 + 4 + 0 + 17 + 19 + AUTO + NEVER + QUIET + ATZ + AT + AT + *99***1# + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 180 + 30 + 60 + 0 + 0 + + + GPRS Motorola Mobile Phone via Serial + PSD.agt + PPP + COMM::0 + MM + ECUART + 8 + 1 + NONE + 57600 + 4 + 0 + 17 + 19 + AUTO + NEVER + QUIET + ATZ + AT + AT + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 180 + 30 + 60 + 0 + 0 + + + WinTunnel Modem + null.agt + PPP + COMM::6 + MM + ECUART + 8 + 1 + NONE + 115200 + 4 + 0 + 0 + 0 + AUTO + NEVER + QUIET + AT + AT + AT + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 180 + 30 + 60 + 0 + 0 + + + mRouterWinsBearer + mRouterAgent.agt + PPP + WINS::0 + MM + WINSCSY + 8 + 1 + NONE + 115200 + 4 + 0 + 0 + 0 + AUTO + NEVER + QUIET + AT + AT + AT + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 9999 + 180 + 30 + 0 + 0 + + + mRouterRs232Bearer + mRouterAgent.agt + PPP + COMM::0 + MM + ECUART + 8 + 1 + NONE + 115200 + 4 + 0 + 0 + 0 + AUTO + NEVER + QUIET + AT + AT + AT + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 9999 + 180 + 30 + 0 + 0 + + + mRouterIrBearer + mRouterAgent.agt + PPP + IRCOMM::0 + MM + IRCOMM + 8 + 1 + NONE + 115200 + 4 + 0 + 0 + 0 + AUTO + NEVER + QUIET + AT + AT + AT + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 9999 + 180 + 30 + 0 + 0 + + + mRouterBtBearer + mRouterAgent.agt + PPP + BTCOMM::0 + MM + BTCOMM + 8 + 1 + NONE + 115200 + 4 + 0 + 0 + 0 + AUTO + NEVER + QUIET + AT + AT + AT + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 9999 + 180 + 30 + 0 + 0 + + + mRouterUsbBearer + mRouterAgent.agt + PPP + ACM::0 + MM + ECACM + 8 + 1 + NONE + 115200 + 4 + 0 + 0 + 0 + AUTO + NEVER + QUIET + AT + AT + AT + S8= + L0 + L1 + L2 + M0 + M1 + M2 + M3 + W + X1 + X2 + X3 + X4 + E0 + V1 + Q0 + Q1 + ; + O + Z + &F + &C1 + &D2 + &S0 + &K3 + &K4 + + + S12 + NO DIAL TONE + BUSY + NO ANSWER + CARRIER + CONNECT + COMPRESSION:CLASS 5 + COMPRESSION:V.42 bis + COMPRESSION:NONE + PROTOCOL:LAPD + PROTOCOL:ALT + PROTOCOL:ALT-CELLULAR + PROTOCOL:NONE + +44123456789 + 1440 + FALSE + 9905 + 9999 + 180 + 30 + 0 + 0 + + + + + + LANBearer + nullagt.agt + ethint + enet + =Ethernet + ethernet + Ethernet.Wins + EtherPkt.drv + -1 + -1 + -1 + + + + + + Default Dial In ISP + FALSE + TRUE + TRUE + Default Dial In ISP + TRUE + TRUE + TRUE + TRUE + TRUE + FALSE + FALSE + FALSE + FALSE + FALSE + + + Dial In ISP01 + FALSE + TRUE + TRUE + Dial In ISP01 + TRUE + TRUE + TRUE + TRUE + TRUE + FALSE + FALSE + FALSE + FALSE + FALSE + + + + + + Default Dial Out ISP + TRUE + FALSE + TRUE + TRUE + TRUE + TRUE + Default Dial Out ISP + Default Dial Out ISP + TRUE + TRUE + FALSE + FALSE + FALSE + TRUE + TRUE + FALSE + 0 + TRUE + TRUE + TRUE + TRUE + TRUE + FALSE + FALSE + FALSE + FALSE + 0 + UNSPECIFIED + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + FALSE + FALSE + + + NT RAS + TRUE + TRUE + FALSE + FALSE + TRUE + TRUE + Test + INTERNETONLY + INTERNETONLY + CHARMAP \[windows-1252\]\nLOOP 10\n{\nSEND "CLIENT"+<0x0d>\nWAIT 3\n{\n"SERVER" OK\n}\n}\nEXIT KErrNoAnswer$\n\nOK:\nEXIT\n + FALSE + FALSE + FALSE + FALSE + ip + RasUser + pass + 0 + FALSE + 0 + TRUE + TRUE + TRUE + TRUE + TRUE + FALSE + FALSE + FALSE + FALSE + 0 + UNSPECIFIED + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + FALSE + FALSE + + + ISP01 + TRUE + FALSE + FALSE + TRUE + TRUE + TRUE + PlaceHolder for ISP01 + INTERNETONLY + INTERNETONLY + FALSE + FALSE + FALSE + FALSE + ip + xxx + yyy + 0 + FALSE + 0 + TRUE + TRUE + TRUE + TRUE + TRUE + FALSE + FALSE + FALSE + FALSE + 0 + UNSPECIFIED + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + FALSE + FALSE + + + ISP02 + TRUE + FALSE + FALSE + TRUE + TRUE + TRUE + PlaceHolder for ISP02 + INTERNETONLY + INTERNETONLY + FALSE + FALSE + FALSE + FALSE + ip + xxx + yyy + 0 + FALSE + 0 + TRUE + TRUE + TRUE + TRUE + TRUE + FALSE + FALSE + FALSE + FALSE + 0 + UNSPECIFIED + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + FALSE + FALSE + + + ISP03 + TRUE + FALSE + FALSE + TRUE + TRUE + TRUE + PlaceHolder for ISP03 + INTERNETONLY + INTERNETONLY + FALSE + FALSE + FALSE + FALSE + ip + xxx + yyy + 0 + FALSE + 0 + TRUE + TRUE + TRUE + TRUE + TRUE + FALSE + FALSE + FALSE + FALSE + 0 + UNSPECIFIED + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + FALSE + FALSE + + + ISP04 + TRUE + FALSE + FALSE + TRUE + TRUE + TRUE + PlaceHolder for ISP04 + INTERNETONLY + INTERNETONLY + FALSE + FALSE + FALSE + FALSE + ip + xxx + yyy + 0 + FALSE + 0 + TRUE + TRUE + TRUE + TRUE + TRUE + FALSE + FALSE + FALSE + FALSE + 0 + UNSPECIFIED + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + FALSE + FALSE + + + ISP05 + TRUE + FALSE + FALSE + TRUE + TRUE + TRUE + PlaceHolder for ISP05 + INTERNETONLY + INTERNETONLY + FALSE + FALSE + FALSE + FALSE + ip + xxx + yyy + 0 + FALSE + 0 + TRUE + TRUE + TRUE + TRUE + TRUE + FALSE + FALSE + FALSE + FALSE + 0 + UNSPECIFIED + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + FALSE + FALSE + + + mRouterDialOutIsp + TRUE + FALSE + FALSE + FALSE + TRUE + TRUE + mRouterDialOutIsp + INTERNETONLY + INTERNETONLY + FALSE + FALSE + FALSE + FALSE + ip + IfAuthPass= + AuthRetries=0 + 0 + FALSE + 0 + TRUE + TRUE + TRUE + TRUE + TRUE + FALSE + FALSE + FALSE + FALSE + 0 + UNSPECIFIED + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + FALSE + FALSE + + + + + + + + + test name cdma2000 + Test2000 + HIGHSPEEDCDMA2000DATA + IPV4 + PRIORITY04 + PRIORITY04 + 32KBPS + 32KBPS + LOSS1 + LOSS1 + 40MS + 40MS + 32KBPS + 32KBPS + LOSS2 + LOSS2 + 120MS + 120MS + FALSE + FALSE + FALSE + ip + RasUser + pass + FALSE + 1 + 0.255.255.255 + 10.0.0.1 + TRUE + TRUE + TRUE + TRUE + 2 + 1000000 + TRANSPARENT + FALSE + 10000000 + + + + + + + + + Dummy BT Chargecard + 144,12345678 + 0000 + HG + HFG + HEFG + + + Dummy Mercury Chargecard + 0500800800,,12345678 + **** + HG + J,K,0FG + HEFG + + + + + + + + + GlobalSettingsTable1 + WAPAccessPoint.Default Dial In ISP + 3 + WAPSMSBearer.WAPSMSBearerTable1 + 2 + 1 + 1 + 2 + 2 + 2 + Location.Office + Location.Office + GSM + Network.Intranet + mm + + + + + + Incoming GPRS Settings PlaceHolder + Test + IPV4 + 0.0.0.0 + FALSE + TRUE + TRUE + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + FALSE + FALSE + FALSE + ip + RasUser + pass + 1 + 0.0.0.0 + 0.0.0.0 + FALSE + FALSE + FALSE + + + + + + GPRS01 + gprs01APNPlaceHolder + IPV4 + FALSE + TRUE + FALSE + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + FALSE + FALSE + FALSE + ip + 1 + FALSE + FALSE + FALSE + 0 + 0 + + + GPRS02 + gprs02APNPlaceHolder + IPV4 + FALSE + TRUE + FALSE + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + FALSE + FALSE + FALSE + ip + 1 + FALSE + FALSE + FALSE + 0 + 0 + + + GPRS03 + gprs03APNPlaceHolder + IPV4 + FALSE + TRUE + FALSE + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + FALSE + FALSE + FALSE + ip + 1 + FALSE + FALSE + FALSE + 0 + 0 + + + + + + Dummy Default GPRS Settings + Access point name + IPV6 + www.wid.com + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + TRUE + TRUE + FALSE + TRUE + + + + + + + + + Default Location + TRUE + FALSE + FALSE + 0 + + + 0 + 44 + 44 + 44 + 44 + + + Office + FALSE + FALSE + FALSE + 0 + 00 + 0 + 44 + 171 + 9, + 9, + + + Office Direct Dial + FALSE + FALSE + FALSE + 0 + 00 + 0 + 44 + 171 + 171 + 171 + + + Mobile + TRUE + FALSE + FALSE + 0 + + + 0 + 44 + 44 + 44 + 44 + + + Home + FALSE + TRUE + TRUE + 0 + 00 + 0 + 44 + 181 + 181 + 181 + + + + + + SecureSocketTable1 + ssl3.0 + ssladaptor.dll + + + SecureSocketTable2 + tls1.0 + ssladaptor.dll + + + + + + + + + + + + + + + + + + Default Dial In ISP + WAPIPBearer + + + Ethernet Static IP + WAPIPBearer + www.wapstart.com + + + Ethernet Dynamic IP + WAPIPBearer + www.wapstart.com + + + + + + WAPIPBearerTable1 + WAPAccessPoint.-1 + 0 + CONNECTIONLESS + FALSE + IAP.-1 + 0 + 0 + 0 + + + + + + WAPSMSBearerTable1 + WAPAccessPoint.-1 + 0 + CONNECTIONLESS + FALSE + 0 + + + WAPSMSBearerTable2 + WAPAccessPoint.Ethernet Dynamic IP + +4412345678901 + CONNECTIONORIENTED + FALSE + +442071234567 + + + + + + + + + + + diff -r 000000000000 -r 857a3e953887 emulatorlan/data/s60_32_default_snaps.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emulatorlan/data/s60_32_default_snaps.xml Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,159 @@ + + + + whenneeded + 11 + 0 + 1 + 2 + 3 + 4 + 5 + 7 + 8 + + + 9 + 0 + 8 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + Destination + Internet + + + + Incorrect ethernet setup 1 + No + No + No + No + ConfirmFirst + + 194.72.6.51 + 194.72.6.52 + + + + ip + 255.255.255.0 + 10.32.194.254 + 10.32.194.251 + False + True + NonExistingServ + NonExistingServ + + + Ethernet with Daemon Static IP + No + No + No + No + ConfirmFirst + + 194.72.6.51 + 194.72.6.52 + + + + ip + 255.255.255.0 + 192.168.20.2 + 192.168.20.13 + False + True + NetCfgExtnDhcp + !DhcpServ + + + Ethernet with Daemon Dynamic IP + No + No + No + No + ConfirmFirst + + 194.72.6.51 + 194.72.6.52 + + + + ip + 255.255.255.0 + 10.32.194.254 + 10.32.194.251 + True + True + NetCfgExtnDhcp + !DhcpServ + + + + + Internet + Internet + 2 + No + No + Yes + 0 + + + + + + + + + + + + + + MMS + MMS + 2 + No + Yes + No + 2 + + + + + + + + + + + + + + Operator + Operator + 2 + No + No + No + 4 + + + + + + + + + + + + + + diff -r 000000000000 -r 857a3e953887 emulatorlan/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emulatorlan/group/bld.inf Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file for project emulatorlan +* +*/ + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../data/configchange.pl /epoc32/tools/configchange.pl +../data/EnableLanConnection.cmd /epoc32/tools/EnableLanConnection.cmd +../data/ethernetced.xml /epoc32/winscw/c/ethernetced.xml +../data/s60_32_default_snaps.xml /epoc32/winscw/c/s60_32_default_snaps.xml + +PRJ_MMPFILES + +PRJ_TESTMMPFILES + +// End of File \ No newline at end of file diff -r 000000000000 -r 857a3e953887 group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/group/bld.inf Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file for conntools. +* +*/ + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +PRJ_MMPFILES +#include "../nettools/group/bld.inf" +#include "../emulatorlan/group/bld.inf" + +PRJ_TESTMMPFILES \ No newline at end of file diff -r 000000000000 -r 857a3e953887 layers.sysdef.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/layers.sysdef.xml Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,14 @@ + + +]> + + + + + + + + + + diff -r 000000000000 -r 857a3e953887 nettools/conntest/Engine/HttpHandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/Engine/HttpHandler.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,770 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: HttpHandler is used for HTTP connection components testing +* +*/ + +// INCLUDE FILES +#include + +#include "HttpHandler.h" +#include "uinotify.h" +#include "SettingData.h" +#include "Utils.h" +#include "ConnTest.pan" +#include "conntest.hrh" + +// CONSTANTS + +// Size of buffer used when submitting request bodies +//const TInt KMaxSubmitSize = 2048; +const TInt KMaxHeaderNameLen = 32; +const TInt KMaxHeaderValueLen = 128; + + + +// ================= MEMBER FUNCTIONS ======================= + + + +// Standard headers used by default +_LIT8(KUserAgent, "User-Agent: Nokia6600/1.0"); +_LIT8(KAccept, "*/*"); + + +enum THttpExampleClientPanics +{ + EReqBodySumitBufferNotAllocated, + KBodyWithInvalidSize, + KCouldntNotifyBodyDataPart +}; + + + +//============================================================ +// +// Implementation of CHttpClient +// +//============================================================ + + + +// ---------------------------------------------------------------------------- +// CHttpClient::CHttpClient(MUINotify& aConsole) +// Constructor +// ---------------------------------------------------------------------------- +// +CHttpClient::CHttpClient(MUINotify& aConsole) +: iReqBodySubmitBufferPtr(0,0), iConsole(aConsole) +{ +} + + +// ---------------------------------------------------------------------------- +// CHttpClient::~CHttpClient() +// Destructor +// ---------------------------------------------------------------------------- +// +CHttpClient::~CHttpClient() +{ + delete iReqBodySubmitBuffer; + delete iTransObs; + iHttpSession.Close(); +} + + +// ---------------------------------------------------------------------------- +// CHttpClient::NewLC(MUINotify& aConsole) +// Two-phase constructor +// ---------------------------------------------------------------------------- +// +CHttpClient* CHttpClient::NewLC(MUINotify& aConsole) +{ + CHttpClient* me = new(ELeave) CHttpClient(aConsole); + CleanupStack::PushL(me); + me->ConstructL(); + return me; +} + +// ---------------------------------------------------------------------------- +// CHttpClient::NewL(MUINotify& aConsole) +// Two-phase constructor +// ---------------------------------------------------------------------------- +// +CHttpClient* CHttpClient::NewL(MUINotify& aConsole) +{ + CHttpClient* me = NewLC(aConsole); + CleanupStack::Pop(me); + return me; +} + +// ---------------------------------------------------------------------------- +// CHttpClient::ConstructL() +// EPOC two-phased constructor +// ---------------------------------------------------------------------------- +// +void CHttpClient::ConstructL() +{ + iHttpSession.OpenL(); + + // Install this class as the callback for authentication requests + InstallAuthenticationL(iHttpSession); + + iTransObs = CHttpEventHandler::NewL(iConsole); +} + + +// ---------------------------------------------------------------------------- +// CHttpClient::SetHttpConnectionInfo() +// Set RConnection and RSocketServ as session properties, if +// http fw does not use it's own connection. +// ---------------------------------------------------------------------------- +// +void CHttpClient::SetHttpConnectionInfoL( TBool aUseOwnConnection, + RConnection& aConnection, + RSocketServ& aSocketServ ) +{ + TInt result; + TBuf<16> serviceType; + TUint32 serviceId; + TBuf<100> query; + TBuf<100> proxyAddr; + TBuf8<100> proxyAddr2; + TUint32 proxyPort; + TUint connCount; + CCommsDatabase* TheDb; + RStringF proxyName; + + // Trick to get new values into use + iHttpSession.Close(); + iHttpSession.OpenL(); + + RStringPool strPool = iHttpSession.StringPool(); + + // Remove first session properties just in case. + RHTTPConnectionInfo connInfo = iHttpSession.ConnectionInfo(); + + // Clear RConnection and Socket Server instances + connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketServ,RHTTPSession::GetTable())); + connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketConnection,RHTTPSession::GetTable())); + + // Clear the proxy settings + THTTPHdrVal proxyUsage(strPool.StringF(HTTP::EUseProxy,RHTTPSession::GetTable())); + connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyUsage,RHTTPSession::GetTable())); + connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyAddress,RHTTPSession::GetTable())); + + if(!aUseOwnConnection) + { + // RConnection has been started, set proxy (if defined) and RConnection and + // Socket Server session properties. + + // Proxy + result = aConnection.EnumerateConnections(connCount); + User::LeaveIfError(result); + + // + // Get service and service type for this connection + // + query.Format(_L("%s\\%s"), IAP, IAP_SERVICE); + result = aConnection.GetIntSetting(query, serviceId); + + query.Format(_L("%s\\%s"), IAP, IAP_SERVICE_TYPE); + result = aConnection.GetDesSetting(query, serviceType); + User::LeaveIfError(result); + + TheDb = CCommsDatabase::NewL(); + CleanupStack::PushL(TheDb); + + CCommsDbTableView* view = TheDb->OpenViewOnProxyRecordLC(serviceId, serviceType); + result = view->GotoFirstRecord(); + + if(result == KErrNone) + { + // This IAP uses proxy, set it to http session + view->ReadUintL(TPtrC(PROXY_PORT_NUMBER), proxyPort); + HBufC* k = view->ReadLongTextLC(TPtrC(PROXY_SERVER_NAME)); + proxyAddr.Copy(k->Des()); + proxyAddr.AppendFormat(_L(":%d"), proxyPort); + + proxyAddr2.Copy(proxyAddr); + + CleanupClosePushL(proxyName); + proxyName = iHttpSession.StringPool().OpenFStringL(proxyAddr2); + connInfo.SetPropertyL( strPool.StringF(HTTP::EProxyUsage,RHTTPSession::GetTable()), + proxyUsage ); + connInfo.SetPropertyL( strPool.StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()), + proxyName ); + CleanupStack::PopAndDestroy(&proxyName); // proxyName + CleanupStack::PopAndDestroy(k); //k + + RDebug::Print(_L("ConnTest: Proxy address: %S"), &proxyAddr); + } + CleanupStack::PopAndDestroy(view); // view + CleanupStack::PopAndDestroy(TheDb); // TheDb + + // RConnection and Socket Server + connInfo.SetPropertyL ( + strPool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), + THTTPHdrVal (aSocketServ.Handle()) ); + + TInt connPtr1 = REINTERPRET_CAST(TInt, &aConnection); + connInfo.SetPropertyL ( + strPool.StringF(HTTP::EHttpSocketConnection, + RHTTPSession::GetTable() ), THTTPHdrVal (connPtr1) ); + + } +} + + +// ---------------------------------------------------------------------------- +// CHttpClient::InvokeHttpMethodL() +// Create the transaction, set the headers and body and start the transaction +// ---------------------------------------------------------------------------- +// +void CHttpClient::InvokeHttpMethodL(const CSettingData* aData, TBool aHasBody, TBool aIsSecure) +{ + + iSettingData = (CSettingData*)aData; + + RStringPool strPool = iHttpSession.StringPool(); + RStringF method = strPool.StringF(HTTP::EGET,RHTTPSession::GetTable()); + + if(aHasBody) + { + method = strPool.StringF(HTTP::EPOST,RHTTPSession::GetTable()); + + delete iReqBodySubmitBuffer; + iReqBodySubmitBuffer = NULL; + iReqBodySubmitBuffer = HBufC8::NewMaxL(KSendDataSize); + iReqBodySubmitBufferPtr.Set(iReqBodySubmitBuffer->Des()); + + // Create body chunk + Utils::CreateDataChunk(iReqBodySubmitBufferPtr, aData->iPacketSize); + iDataChunkCount = 0; + } + else + { + method = strPool.StringF(HTTP::EGET,RHTTPSession::GetTable()); + } + + TBuf8<256> aUri; + + if(aIsSecure) + aUri.Copy(_L8("https://")); + else + aUri.Copy(_L8("http://")); + + aUri.Append(aData->iServerName); + + // Don't add the port for https + if(!aIsSecure) + aUri.AppendFormat(_L8(":%d"), aData->iPort); + + // Add '/' if it is not included in the given page name + if(!((TChar)aData->iHttpPage[0] == '/')) + { + aUri.Append(_L8("/")); + } + aUri.Append(aData->iHttpPage); + + TUriParser8 uri; + uri.Parse(aUri); + iTrans = iHttpSession.OpenTransactionL(uri, *iTransObs, method); + RHTTPHeaders hdr = iTrans.Request().GetHeaderCollection(); + + // Add headers appropriate to all methods + SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent); + SetHeaderL(hdr, HTTP::EAccept, KAccept); + + if (aHasBody) + { + // Content type header + TBuf8 contTypeBuf; + contTypeBuf.Copy(iReqBodyContentType); + RStringF contTypeStr = iHttpSession.StringPool().OpenFStringL(contTypeBuf); + THTTPHdrVal contType(contTypeStr); + hdr.SetFieldL( iHttpSession.StringPool().StringF( HTTP::EContentType, + RHTTPSession::GetTable() ), + contType ); + contTypeStr.Close(); + + MHTTPDataSupplier* dataSupplier = this; + iTrans.Request().SetBody(*dataSupplier); + } + + iTrans.SubmitL(); +} + + +// ---------------------------------------------------------------------------- +// CHttpClient::GetNextDataPart +// Return next data chunk to be posted. +// ---------------------------------------------------------------------------- +// +TBool CHttpClient::GetNextDataPart(TPtrC8& aDataPart) +{ + + aDataPart.Set(iReqBodySubmitBufferPtr); + + if(iDataChunkCount == 0) + { + iConsole.PrintNotify(_L("Sending body...\n")); + iLastTimeStamp.UniversalTime(); + } + + ++iDataChunkCount; + iNoMoreDate = iDataChunkCount < iSettingData->iPackets ? EFalse : ETrue; + + return iNoMoreDate; +} + + +// ---------------------------------------------------------------------------- +// CHttpClient::ReleaseData +// Data has been posted, release the data chunk. +// ---------------------------------------------------------------------------- +// +void CHttpClient::ReleaseData() +{ + if (iNoMoreDate==EFalse) + { + TRAPD(err, iTrans.NotifyNewRequestBodyPartL()); + if (err != KErrNone) + User::Panic(KPanicConnTest, KCouldntNotifyBodyDataPart); + } + else + { + DisplayTimeElapsed(); + } + return; +} + + +// ---------------------------------------------------------------------------- +// CHttpClient::OverallDataSize +// Return size of the data to be posted. +// ---------------------------------------------------------------------------- +// +TInt CHttpClient::OverallDataSize() +{ + TInt size = (iSettingData->iPackets)*(iSettingData->iPacketSize); + return size; +} + + +// ---------------------------------------------------------------------------- +// CHttpClient::Reset() +// Method from MHTTPDataSupplier +// ---------------------------------------------------------------------------- +// +TInt CHttpClient::Reset() +{ + return KErrNotSupported; +} + + +// ---------------------------------------------------------------------------- +// CHttpClient::DisplayTimeElapsed() +// Calculate and display throughput for POST. +// ---------------------------------------------------------------------------- +// +void CHttpClient::DisplayTimeElapsed() +{ + // Throughput calculation + TInt size = OverallDataSize(); + TBuf8<128> b(_L8("Body sent\n")); + Utils::CalculateThroughput(b, iLastTimeStamp, size); + + b.Append(_L("\n\n")); + iConsole.PrintNotify(b); +} + + +// ---------------------------------------------------------------------------- +// CHttpClient::SetHeaderL() +// Set HTTP request header for http fw. +// ---------------------------------------------------------------------------- +// +void CHttpClient::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue) +{ + RStringF valStr = iHttpSession.StringPool().OpenFStringL(aHdrValue); + THTTPHdrVal val(valStr); + aHeaders.SetFieldL(iHttpSession.StringPool().StringF(aHdrField,RHTTPSession::GetTable()), val); + valStr.Close(); +} + + +// ---------------------------------------------------------------------------- +// CHttpClient::SetPerformance +// Turn on/off performance measurement +// ---------------------------------------------------------------------------- +// +void CHttpClient::SetPerformance(const TBool aValue) +{ + iDoPerformance = aValue; + iTransObs->SetPerformance(aValue); +} + + +// ---------------------------------------------------------------------------- +// CHttpClient::GetCredentialsL() +// Called when a authenticated page is requested. Asks the user for a username +// and password that would be appropriate for the url that was supplied. +// ---------------------------------------------------------------------------- +// +TBool CHttpClient::GetCredentialsL(const TUriC8& aURI, RString aRealm, + RStringF aAuthenticationType, + RString& aUsername, + RString& aPassword) + +{ + TBuf<80> scratch; + TBuf8<80> scratch8; + scratch8.Format(_L8("Enter credentials for URL %S, realm %S"), &aURI.UriDes(), &aRealm.DesC()); + scratch.Copy(scratch8); + // iUtils->Test().Printf(_L("%S\n"), &scratch); + scratch.Copy(aAuthenticationType.DesC()); + // iUtils->Test().Printf(_L("Using %S authentication\n"), &scratch); + // iUtils->GetAnEntry(_L("Username (or QUIT to give up): "), scratch); + scratch8.Copy(scratch); + if (scratch8.CompareF(_L8("quit"))) + { + TRAPD(err, aUsername = aRealm.Pool().OpenStringL(scratch8)); + if (!err) + { + // iUtils->GetAnEntry(_L("Password: "), scratch); + scratch8.Copy(scratch); + TRAP(err, aPassword = aRealm.Pool().OpenStringL(scratch8)); + if (!err) + return ETrue; + } + } + return EFalse; +} + + + +//============================================================================= +// +// Implementation of class CHttpEventHandler +// +//============================================================================= + + + +// ---------------------------------------------------------------------------- +// CHttpEventHandler::NewLC(MUINotify& aConsole) +// Two-phase constructor +// ---------------------------------------------------------------------------- +// +CHttpEventHandler* CHttpEventHandler::NewLC(MUINotify& aConsole) +{ + CHttpEventHandler* me = new(ELeave)CHttpEventHandler(aConsole); + CleanupStack::PushL(me); + me->ConstructL(); + return me; +} + +// ---------------------------------------------------------------------------- +// CHttpEventHandler::NewL(MUINotify& aConsole) +// Two-phase constructor +// ---------------------------------------------------------------------------- +// +CHttpEventHandler* CHttpEventHandler::NewL(MUINotify& aConsole) +{ + CHttpEventHandler* me = NewLC(aConsole); + CleanupStack::Pop(me); + return me; +} + +// ---------------------------------------------------------------------------- +// CHttpEventHandler::ConstructL() +// EPOC two-phased constructor +// ---------------------------------------------------------------------------- +// +void CHttpEventHandler::ConstructL() +{ +} + +// ---------------------------------------------------------------------------- +// CHttpEventHandler::CHttpEventHandler(MUINotify& aConsole) +// Constructor +// ---------------------------------------------------------------------------- +// +CHttpEventHandler::CHttpEventHandler(MUINotify& aConsole) +: iConsole(aConsole) +{ +} + +// ---------------------------------------------------------------------------- +// CHttpEventHandler::~CHttpEventHandler() +// Destructor +// ---------------------------------------------------------------------------- +// +CHttpEventHandler::~CHttpEventHandler() +{ +} + + +// ---------------------------------------------------------------------------- +// CHttpEventHandler::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent) +// HTTP event receiver. +// ---------------------------------------------------------------------------- +// +void CHttpEventHandler::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent) +{ + switch (aEvent.iStatus) + { + case THTTPEvent::EGotResponseHeaders: + { + // HTTP response headers have been received. We can determine now if there is + // going to be a response body to save. + RHTTPResponse resp = aTransaction.Response(); + TInt status = resp.StatusCode(); + RStringF statusStr = resp.StatusText(); + TBuf<32> statusStr16; + statusStr16.Copy(statusStr.DesC()); + TBuf<64> st; + st.Format(_L("Status: %d (%S)\n"), status, &statusStr16); + iConsole.PrintNotify(st); + + + // Dump the headers + if(!iDoPerformance) + DumpRespHeadersL(aTransaction); + + // Note! For some reason resp.HasBody() returns False although + // there is body (Tomcat, index.jsp), so this doesn't work. + // Maybe it checks the Content-Length header? + if (resp.HasBody() && (status >= 200) && (status < 300) && (status != 204)) + { + TInt dataSize = resp.Body()->OverallDataSize(); + if (dataSize >= 0) + { + TBuf<64> st; + st.Format(_L("Response body size is %d\n"), dataSize); + iConsole.PrintNotify(st); + } + else + { + iConsole.PrintNotify(_L("Response body size is unknown\n")); + } + } + + if(iDoPerformance) + { + iConsole.PrintNotify(_L("Getting body...\n")); + iStartTime.UniversalTime(); + } + iBodySize = 0; + + } break; + case THTTPEvent::EGotResponseBodyData: + { + // Get the body data supplier + iRespBody = aTransaction.Response().Body(); + + TPtrC8 dataChunk; + iRespBody->GetNextDataPart(dataChunk); + iBodySize += dataChunk.Length(); + + if(!iDoPerformance) + DumpRespBody(aTransaction); + + iRespBody->ReleaseData(); + } break; + case THTTPEvent::EResponseComplete: + { + // The transaction's response is complete + + TBuf8<128> b(_L8("Got body\n")); + + if(iDoPerformance) + Utils::CalculateThroughput(b, iStartTime, iBodySize); + + iConsole.PrintNotify(b); + + } break; + case THTTPEvent::ESucceeded: + { + iConsole.PrintNotify(_L("Transaction Successful\n")); + aTransaction.Close(); + //CActiveScheduler::Stop(); + } break; + case THTTPEvent::EFailed: + { + iConsole.PrintNotify(_L("Transaction Failed\n")); + aTransaction.Close(); + //CActiveScheduler::Stop(); + } break; + case THTTPEvent::ERedirectedPermanently: + { + iConsole.PrintNotify(_L("Permanent Redirection\n")); + } break; + case THTTPEvent::ERedirectedTemporarily: + { + iConsole.PrintNotify(_L("Temporary Redirection\n")); + } break; + default: + { + TBuf<32> text; + text.Format(_L("\n"), aEvent.iStatus); + iConsole.PrintNotify(text); + // close off the transaction if it's an error + if (aEvent.iStatus < 0) + { + aTransaction.Close(); + //CActiveScheduler::Stop(); + } + } break; + } +} + + +// ---------------------------------------------------------------------------- +// CHttpEventHandler::MHFRunError(TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/) +// Error handler +// ---------------------------------------------------------------------------- +// +TInt CHttpEventHandler::MHFRunError(TInt aError, RHTTPTransaction /*aTransaction*/, const THTTPEvent& /*aEvent*/) +{ + TBuf<64> text; + text.Format(_L("MHFRunError fired with error code %d\n"), aError); + iConsole.PrintNotify(text); + return KErrNone; +} + + +// ---------------------------------------------------------------------------- +// CHttpEventHandler::DumpRespHeadersL(RHTTPTransaction& aTrans) +// Print HTTP headers on console. +// ---------------------------------------------------------------------------- +// +void CHttpEventHandler::DumpRespHeadersL(RHTTPTransaction& aTrans) +{ + RHTTPResponse resp = aTrans.Response(); + RStringPool strP = aTrans.Session().StringPool(); + RHTTPHeaders hdr = resp.GetHeaderCollection(); + THTTPHdrFieldIter it = hdr.Fields(); + + TBuf fieldName16; + TBuf fieldVal16; + + while (it.AtEnd() == EFalse) + { + RStringTokenF fieldName = it(); + RStringF fieldNameStr = strP.StringF(fieldName); + THTTPHdrVal fieldVal; + + //TPtrC8 rawField; + //if (hdr.GetRawField(fieldNameStr,rawField) == KErrNone) + + if (hdr.GetField(fieldNameStr,0,fieldVal) == KErrNone) + { + const TDesC8& fieldNameDesC = fieldNameStr.DesC(); + fieldName16.Copy(fieldNameDesC.Left(KMaxHeaderNameLen)); + switch (fieldVal.Type()) + { + case THTTPHdrVal::KTIntVal: + { + TBuf<200> a; + a.Format(_L("%S: %d\n"), &fieldName16, fieldVal.Int()); + iConsole.PrintNotify(a); + } + break; + case THTTPHdrVal::KStrFVal: + { + RStringF fieldValStr = strP.StringF(fieldVal.StrF()); + const TDesC8& fieldValDesC = fieldValStr.DesC(); + fieldVal16.Copy(fieldValDesC.Left(KMaxHeaderValueLen)); + TBuf<200> a; + a.Format(_L("%S: %S\n"), &fieldName16, &fieldVal16); + iConsole.PrintNotify(a); + } + break; + case THTTPHdrVal::KStrVal: + { + RString fieldValStr = strP.String(fieldVal.Str()); + const TDesC8& fieldValDesC = fieldValStr.DesC(); + fieldVal16.Copy(fieldValDesC.Left(KMaxHeaderValueLen)); + TBuf<200> a; + a.Format(_L("%S: %S\n"), &fieldName16, &fieldVal16); + iConsole.PrintNotify(a); + } + break; + case THTTPHdrVal::KDateVal: + { + _LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3"); + TDateTime date = fieldVal.DateTime(); + TBuf<40> dateTimeString; + TTime t(date); + t.FormatL(dateTimeString,KDateString); + TBuf<200> a; + a.Format(_L("%S: %S\n"), &fieldName16, &dateTimeString); + iConsole.PrintNotify(a); + } + break; + default: + { + TBuf<200> a; + a.Format(_L("%S: \n"), &fieldName16); + iConsole.PrintNotify(a); + } + break; + } + + // Display realm for WWW-Authenticate header + RStringF wwwAuth = strP.StringF(HTTP::EWWWAuthenticate,RHTTPSession::GetTable()); + if (fieldNameStr == wwwAuth) + { + // check the auth scheme is 'basic' + RStringF basic = strP.StringF(HTTP::EBasic,RHTTPSession::GetTable()); + RStringF realm = strP.StringF(HTTP::ERealm,RHTTPSession::GetTable()); + THTTPHdrVal realmVal; + if ((fieldVal.StrF() == basic) && + (!hdr.GetParam(wwwAuth, realm, realmVal))) + { + RStringF realmValStr = strP.StringF(realmVal.StrF()); + fieldVal16.Copy(realmValStr.DesC()); + TBuf<200> a; + a.Format(_L("Realm is: %S\n"), &fieldVal16); + iConsole.PrintNotify(a); + } + } + } + ++it; + } +} + +// ---------------------------------------------------------------------------- +// CHttpEventHandler::DumpRespBody(RHTTPTransaction& aTrans) +// Print body size on console. +// ---------------------------------------------------------------------------- +// +void CHttpEventHandler::DumpRespBody(RHTTPTransaction& aTrans) +{ + MHTTPDataSupplier* body = aTrans.Response().Body(); + TPtrC8 dataChunk; + TBool isLast = body->GetNextDataPart(dataChunk); + + TBuf<32> b; + b.Format(_L("-body size: %d\n"), dataChunk.Length()); + iConsole.PrintNotify(b); + //DumpIt(dataChunk); + if (isLast) + iConsole.PrintNotify(_L("Got last data chunk.\n")); +} + + + diff -r 000000000000 -r 857a3e953887 nettools/conntest/Engine/ProgressNotifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/Engine/ProgressNotifier.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,152 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CProgressNotifier is used to notify about +* the current state of the request +* +*/ + +// INCLUDE FILES +#include "ProgressNotifier.h" +#include "ProgressNotifyHandler.h" + + +// ================= MEMBER FUNCTIONS ========================================= + +// ---------------------------------------------------------------------------- +// CProgressNotifier::NewL(...) +// Two-phase constructor +// ---------------------------------------------------------------------------- +// +CProgressNotifier* CProgressNotifier::NewL(RConnection& aConnection, + MProgressNotifyHandler& aHandler) +{ + CProgressNotifier* self = CProgressNotifier::NewLC(aConnection, aHandler); + CleanupStack::Pop(self); + return self; +} + +// ---------------------------------------------------------------------------- +// CProgressNotifier::NewLC(...) +// Two-phase constructor +// ---------------------------------------------------------------------------- +// +CProgressNotifier* CProgressNotifier::NewLC(RConnection& aConnection, + MProgressNotifyHandler& aHandler) +{ + CProgressNotifier* self = new (ELeave) CProgressNotifier(aConnection, aHandler); + CleanupStack::PushL(self); + self->ConstructL(); + return self; +} + +// ---------------------------------------------------------------------------- +// CProgressNotifier::CProgressNotifier(...) +// First-phase constructor +// ---------------------------------------------------------------------------- +// +CProgressNotifier::CProgressNotifier(RConnection& aConnection, + MProgressNotifyHandler& aHandler) +: CActive(EPriorityStandard), +iConnection(aConnection), +iHandler(aHandler) +{ +} + +// ---------------------------------------------------------------------------- +// CProgressNotifier::~CProgressNotifier() +// Destructor +// ---------------------------------------------------------------------------- +// +CProgressNotifier::~CProgressNotifier() +{ + Cancel(); +} + +// ---------------------------------------------------------------------------- +// CProgressNotifier::ConstructL() +// Second-phase constructor +// ---------------------------------------------------------------------------- +// +void CProgressNotifier::ConstructL() +{ + CActiveScheduler::Add(this); +} + +// --------------------------------------------------------- +// Start waiting for the progress notifications. +// --------------------------------------------------------- +void CProgressNotifier::StartNotify() +{ + ASSERT(!IsActive()); + iConnection.ProgressNotification(iProgressBuf, iStatus); + SetActive(); +} + +// --------------------------------------------------------- +// CProgressNotifier::RunL() +// Called when request has completed. +// --------------------------------------------------------- +// +void CProgressNotifier::RunL() +{ + // Active object request complete handler. + if(iStatus == KErrNone) + { + NotifyL(); + } + else + { + iHandler.ProgressNotifyError(iStatus.Int()); + } +} + +// --------------------------------------------------------- +// CProgressNotifier::DoCancel() +// Cancel ongoing requests. +// --------------------------------------------------------- +// +void CProgressNotifier::DoCancel() +{ + iConnection.CancelProgressNotification(); +} + +// --------------------------------------------------------- +// CProgressNotifier::Notify() +// Get the current stage and issue a new request, unless +// the interface has gone down. Inform the progress +// notification handler about a new notification. +// --------------------------------------------------------- +// +void CProgressNotifier::NotifyL() +{ + // Store the values into temporary variables, otherwise we might send incorrect + // values to iHandler, because iProgressBuf might get immediately overwritten + // if progress notifications are already available. + // + // Note! This object is also sometimes deleted in iHandler.ProgressNotifyReceived + // call (not nice, but no other workaround possible), so order of following calls + // is crucial. + + TInt stage = iProgressBuf().iStage; + TInt error = iProgressBuf().iError; + + // Issue new notification + iConnection.ProgressNotification(iProgressBuf, iStatus); + SetActive(); + + // Inform handler about notification + iHandler.ProgressNotifyReceivedL(stage, error); +} + + diff -r 000000000000 -r 857a3e953887 nettools/conntest/Engine/QosObserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/Engine/QosObserver.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation of class CQosObserver. +* +*/ + +// INCLUDE FILES +#include "QosObserver.h" +#include "UINotify.h" + + +// ================= MEMBER FUNCTIONS ========================================= + + +// ---------------------------------------------------------------------------- +// CQosObserver::CQosObserver(...) +// Constructor +// ---------------------------------------------------------------------------- +// +CQosObserver::CQosObserver(MUINotify& aConsole) +: iConsole(aConsole) +{ +} + +// ---------------------------------------------------------------------------- +// CQosObserver::~CQosObserver() +// Destructor +// ---------------------------------------------------------------------------- +// +CQosObserver::~CQosObserver() +{ +} + + +// --------------------------------------------------------- +// CQosObserver::Event(const CQoSEventBase& aQosEvent) +// QoS event receiver. +// --------------------------------------------------------- +// +void CQosObserver::Event(const CQoSEventBase& aQosEvent) +{ + iConsole.PrintNotify(_L("KK")); +} + + diff -r 000000000000 -r 857a3e953887 nettools/conntest/Engine/SendTimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/Engine/SendTimer.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSendTimer is used for sending data at specified intervals +* +*/ + +#include "SendTimer.h" +#include "SocketsEngine.h" + +// --------------------------------------------------------- +// CSendTimer::NewL(const TInt aPriority, CSocketsEngine* aEngine) +// EPOC two phased constructor +// --------------------------------------------------------- +// +CSendTimer* CSendTimer::NewL(const TInt aPriority, CSocketsEngine* aEngine) +{ + CSendTimer* self = CSendTimer::NewLC(aPriority, aEngine); + CleanupStack::Pop(self); + return self; +} + + +// --------------------------------------------------------- +// CSendTimer::NewLC(const TInt aPriority, CConnTestView* aView) +// EPOC two phased constructor +// --------------------------------------------------------- +// +CSendTimer* CSendTimer::NewLC(const TInt aPriority, CSocketsEngine* aEngine) +{ + CSendTimer* self = new (ELeave) CSendTimer(aPriority, aEngine); + CleanupStack::PushL(self); + self->ConstructL(); + return self; +} + + +// --------------------------------------------------------- +// CSendTimer::CSendTimer(const TInt aPriority, CConnTestView* aView) +// Constructor +// --------------------------------------------------------- +// +CSendTimer::CSendTimer(const TInt aPriority, CSocketsEngine* aEngine) +: CTimer(aPriority), iEngine(aEngine) +{ +} + + +// --------------------------------------------------------- +// CSendTimer::~CSendTimer() +// Destructor +// --------------------------------------------------------- +// +CSendTimer::~CSendTimer() +{ + Cancel(); +} + + +// --------------------------------------------------------- +// CSendTimer::ConstructL() +// EPOC two-phased constructor +// --------------------------------------------------------- +// +void CSendTimer::ConstructL() +{ + CTimer::ConstructL(); + CActiveScheduler::Add(this); +} + +// --------------------------------------------------------- +// CSendTimer::RunL() +// Timer event has been generated and timer request completed. +// --------------------------------------------------------- +// +void CSendTimer::RunL() +{ + // Timer request has completed, so notify the timer's owner + iEngine->DoSendDataL(); +} + diff -r 000000000000 -r 857a3e953887 nettools/conntest/Engine/SocketsEngine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/Engine/SocketsEngine.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,2076 @@ +/* + * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: CSocketsEngine implements an engine for connection + * component checking: Interface opening/closing, connecting, + * sending/receiving data, etc. + * CSocketsEngine is an active object + * + */ + +// INCLUDE FILES +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS +#include +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SocketsEngine.h" +#include "TimeOutTimer.h" +#include "SocketsRead.h" +#include "SocketsWrite.h" +#include "ProgressNotifier.h" +#include "ConnTest.pan" +#include "uinotify.h" +#include "HttpHandler.h" +#include "SettingData.h" +#include "CustomPrefsData.h" +#include "Utils.h" +#include "SendTimer.h" +#include "alractiveobject.h" + +#include +#include + +#include +#include +#include + +// CONSTANTS +const TInt KTimeOut = 120000000; // 2 minutes time-out + +_LIT(KDefaultServerName, "127.0.0.1"); +const TInt KDefaultPortNumber = 25; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CSocketsEngine::NewL(MUINotify& aConsole) +// EPOC two phased constructor +// --------------------------------------------------------- +// +CSocketsEngine* CSocketsEngine::NewL( MUINotify& aConsole ) + { + CSocketsEngine* self = CSocketsEngine::NewLC( aConsole ); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------- +// CSocketsEngine::NewLC(MUINotify& aConsole) +// EPOC two phased constructor +// --------------------------------------------------------- +// +CSocketsEngine* CSocketsEngine::NewLC( MUINotify& aConsole ) + { + CSocketsEngine* self = new (ELeave) CSocketsEngine( aConsole ); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------- +// CSocketsEngine::CSocketsEngine(MUINotify& aConsole) +// EPOC constructor +// --------------------------------------------------------- +// +CSocketsEngine::CSocketsEngine( MUINotify& aConsole ) : + CActive( EPriorityStandard ), iConsole( aConsole ), iPort( + KDefaultPortNumber ), iServerName( KDefaultServerName ) + { + iStartTime = 0; + } + +// --------------------------------------------------------- +// CSocketsEngine::~CSocketsEngine() +// Destructor +// --------------------------------------------------------- +// +CSocketsEngine::~CSocketsEngine() + { + Cancel(); + if (iProgressNotifier) + { + iProgressNotifier->Cancel(); + } + + delete iSocketsRead; + iSocketsRead = NULL; + + delete iSocketsWrite; + iSocketsWrite = NULL; + + delete iProgressNotifier; + iProgressNotifier = NULL; + + delete iTimer; + iTimer = NULL; + + delete iSendTimer; + + delete iHttpClient; + iHttpClient = NULL; + + if (iData) + { + delete iData; + iData = NULL; + } + //delete pointer to mobility API + if (iMobility) + { + delete iMobility; + iMobility = NULL; + } + + delete iExtPrefs; + delete iPrefsList; + + // Note! Closing order matters. Panic occurs if the + // closing is made in different order. + + iConnection.Close(); + iSocket.Close(); + iSocketServ.Close(); + } + +// --------------------------------------------------------- +// CSocketsEngine::ConstructL() +// EPOC two phased constructor +// --------------------------------------------------------- +// +void CSocketsEngine::ConstructL() + { + ChangeStatus( EInterfaceDown ); + + iData = HBufC8::NewL( KMaxSendBuffer); + // Start a timer + iTimer = CTimeOutTimer::NewL( EPriorityHigh, *this ); + + CActiveScheduler::Add( this ); + + // Open channel to Socket Server + User::LeaveIfError( iSocketServ.Connect() ); + + // Open connection + User::LeaveIfError( iConnection.Open( iSocketServ ) ); + + // Create socket read and write active objects + iSocketsRead = CSocketsRead::NewL( iConsole, iSocket, *this ); + iSocketsWrite = CSocketsWrite::NewL( iConsole, iSocket, *this ); + + // Create interface notification active object + iProgressNotifier = CProgressNotifier::NewL( iConnection, *this ); + iProgressNotifier->StartNotify(); + + // + // HTTP framework initialization + // + iHttpClient = CHttpClient::NewL( iConsole ); + iHttpClient->SetHttpConnectionInfoL( ETrue, iConnection, iSocketServ ); + + // Timer for sending multiple packets + if (!iSendTimer) + { + iSendTimer = CSendTimer::NewL( EPriorityHigh, this ); + } + + iUseTTime = EFalse; + TInt freq; + TInt err = HAL::Get( HAL::EFastCounterFrequency, freq ); + if (err != KErrNone || freq == 0) + { + iUseTTime = ETrue; + } + + //set mobility API flag to false + iIsRegisteredToMobAPI = EFalse; + SetSocketEngineConnType( ETypeUnknown ); + + iExtPrefs = new (ELeave) TExtendedConnPref; + iPrefsList = TConnPrefList::NewL(); + } + +// --------------------------------------------------------- +// CSocketsEngine::GetSocketEngineState() +// Return the current state of the socket engine. +// --------------------------------------------------------- +// +CSocketsEngine::TSocketsEngineState CSocketsEngine::GetSocketEngineState() + { + return iEngineStatus; + } + +// --------------------------------------------------------- +// CSocketsEngine::GetSocketEngineRoamingState() +// --------------------------------------------------------- +// +CSocketsEngine::TRoamingUIState CSocketsEngine::GetSocketEngineRoamingState() + { + return iRoamingState; + } + +// --------------------------------------------------------- +// CSocketsEngine::GetMobilityAPI() +// --------------------------------------------------------- +// +CALRActiveObject* CSocketsEngine::GetMobilityAPI() + { + return iMobility; + } + +// --------------------------------------------------------- +// CSocketsEngine::GetSocketEngineConnType() +// Return the current connection type of the socket engine. +// --------------------------------------------------------- +// +CSocketsEngine::TSocketsEngineStartType CSocketsEngine::GetSocketEngineConnType() + { + return iSockEngineStartType; + } +// --------------------------------------------------------- +// CSocketsEngine::SetSocketEngineConnType() +// Set the current conn type of the socket engine. +// --------------------------------------------------------- +// +void CSocketsEngine::SetSocketEngineConnType( const CSocketsEngine::TSocketsEngineStartType aConnStartType ) + { + iSockEngineStartType = aConnStartType; + } + +// --------------------------------------------------------- +// CSocketsEngine::StartConnWithSnapL() +// Start the connection with snap +// --------------------------------------------------------- +// +void CSocketsEngine::StartConnWithSnapL( TBool aConnect ) + { + if (iEngineStatus == EConnected || iEngineStatus == EInterfaceUp) + { + return; + } + + //start the connection dialog + CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL(); + CleanupStack::PushL( settings ); + TCmSettingSelection selection; + settings->RunApplicationSettingsL( selection ); + CleanupStack::PopAndDestroy( settings ); + + switch (selection.iResult) + { + case CMManager::EConnectionMethod: + { + // start connection with Iap Id + iPrefs.SetIapId( selection.iId ); + iPrefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); + + StartTickCount(); + iConnection.Start( iPrefs, iStatus ); + break; + } + case CMManager::EDestination: + { + TConnSnapPref pref; + + pref.SetSnap( selection.iId ); + + StartTickCount(); + //start connection with snap Id + iConnection.Start( pref, iStatus ); + //Set connection type as Snap + SetSocketEngineConnType( ESnap ); + + break; + } + case CMManager::EAlwaysAsk: + { + // For testing start without preferences + StartTickCount(); + iConnection.Start( iStatus ); + ChangeStatus( EStartingInterface ); + iConnectAfterStartup = ETrue; + SetActive(); + return; + } + default: + { + RDebug::Print( _L("ConnTest: Invalid selection")); + return; + } + } + + ChangeStatus( EStartingInterface ); + //specify if a connection is needed after interface startup( + iConnectAfterStartup = aConnect; + SetActive(); + + } + +// --------------------------------------------------------- +// CSocketsEngine::StartInterfaceL(TBool aConnect) +// Start interface +// --------------------------------------------------------- +// +void CSocketsEngine::StartInterfaceL( TSocketsEngineStartType aStartType, + TBool aConnect ) + { + RDebug::Print( _L("ConnTest: StartInterfaceL( Start type = %d )"), aStartType ); + if (iEngineStatus == EConnected || iEngineStatus == EInterfaceUp) + { + RDebug::Print( _L("ConnTest: Selection cancelled!")); + return; + } + + SetSocketEngineConnType( aStartType ); + + if (aStartType == EAskIap) + { + // Get IAP id + TUint32 iapId; + TInt popupOk = Utils::AskIapIdL( iapId ); + + if (!popupOk) + { + RDebug::Print( _L("ConnTest: Selection cancelled!")); + return; + } + RDebug::Print( _L("ConnTest: Selected IAP id=%d"), iapId ); + + // Create overrides + iPrefs.SetIapId( iapId ); + iPrefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); + } + else if (aStartType == ENetworkId) + { + // Get network id + TUint32 nwkId; + TInt popupOk = Utils::AskNetworkIdL( nwkId ); + + if (!popupOk) + { + RDebug::Print( _L("ConnTest: Selection cancelled!")); + return; + } + RDebug::Print( _L("ConnTest: Selected Network id=%d"), nwkId ); + + // Create overrides + iPrefs.SetNetId( nwkId ); + iPrefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); + } + + // Start the timer after the dialogs + StartTickCount(); + + // ...And now there are few different kinds of iConnection.Start() functions to call... + if (aStartType == EExtPrefs) + { + iPrefsList->AppendL( iExtPrefs ); + iConnection.Start( *iPrefsList, iStatus ); + iPrefsList->Remove( 0 ); + } + else if (aStartType == EExtPrefsInternet) + { + TExtendedConnPref* tmpExtPrefs = new (ELeave) TExtendedConnPref; + tmpExtPrefs->SetSnapPurpose( CMManager::ESnapPurposeInternet ); + iPrefsList->AppendL( tmpExtPrefs ); + iConnection.Start( *iPrefsList, iStatus ); + iPrefsList->Remove( 0 ); + delete tmpExtPrefs; + } + else if (aStartType == ENoPrefs) + { + iConnection.Start( iStatus ); + } + else // (aStartType == EAskIap || aStartType == ENetworkId) - Other values aren't used. + { + iConnection.Start( iPrefs, iStatus ); + } + + ChangeStatus( EStartingInterface ); + iConnectAfterStartup = aConnect; + SetActive(); + } + +// --------------------------------------------------------- +// CSocketsEngine::RegisterToMobilityAPI(TBool aConnect) +// Register to mobility API +// --------------------------------------------------------- +// +void CSocketsEngine::RegisterToMobilityAPIL() + { + if (iEngineStatus == EConnected || iEngineStatus == EInterfaceUp) + { + if (!iIsRegisteredToMobAPI) + { + iConsole.PrintNotify( _L("RegisterToMobilityAPI\n")); + //create the listener active object + iMobility = CALRActiveObject::NewL( iConsole, + (MMobilityProtocolResp*)this ); + iMobility->OpenL( iConnection ); + iIsRegisteredToMobAPI = ETrue; + } + } + else + { + iConsole.PrintNotify( _L("Could not register\n")); + } + } + +// --------------------------------------------------------- +// CSocketsEngine::UnRegisterToMobilityAPI(TBool aConnect) +// UnRegister from mobility API +// --------------------------------------------------------- +// +void CSocketsEngine::UnRegisterFromMobilityAPI() + { + if (iIsRegisteredToMobAPI && iMobility) //&& + //(iEngineStatus == EConnected || iEngineStatus == EInterfaceUp || iEngineStatus == EConnecting)) + { + delete iMobility; + iMobility = NULL; + iConsole.PrintNotify( _L("Unregister MobilityAPI\n")); + } + iIsRegisteredToMobAPI = EFalse; + } + +// --------------------------------------------------------- +// CSocketsEngine::Error() +// --------------------------------------------------------- +// +void CSocketsEngine::Error( TInt aError ) + { + TBuf8<64> text; + text.AppendFormat( _L8("MobilityError: %d\n"), aError ); + iConsole.PrintNotify( text ); + UnRegisterFromMobilityAPI(); + iRoaming = ERoamingOff; + } + +// --------------------------------------------------------- +// CSocketsEngine::PreferredCarrierAvailable() +// --------------------------------------------------------- +// +void CSocketsEngine::PreferredCarrierAvailable( TAccessPointInfo aOldAP, + TAccessPointInfo aNewAP, + TBool aIsUpgrade, + TBool aIsSeamless ) + { + // silence warnings + aOldAP = aOldAP; + aIsUpgrade = aIsUpgrade; + aIsSeamless = aIsSeamless; + + TBuf8<64> text; + + if (iRoaming == ERoamingAutomatic) + { + text.AppendFormat( _L8("Migrating to %i\n"), aNewAP.AccessPoint() ); + iMobility->MigrateToPreferredCarrier(); + iRoamingState = EIdle; + } + else if (iRoaming == ERoamingManual) + { + text.AppendFormat( _L8("Preferred IAP %i Available\n"), aNewAP.AccessPoint() ); + iRoamingState = EPendingPreferredCarrier; + iConsole.PopupNotify( _L("Migrate or Ignore available")); + } + else + { + text.AppendFormat( _L8("Unexpected PreferrredCarrier %i\n"), aNewAP.AccessPoint() ); + iRoamingState = EIdle; + iMobility->IgnorePreferredCarrier(); + } + iConsole.PrintNotify( text ); + } +// --------------------------------------------------------- +// CSocketsEngine::NewCarrierActive() +// --------------------------------------------------------- +// +void CSocketsEngine::NewCarrierActive( TAccessPointInfo aNewAP, + TBool aIsSeamless ) + { + // silence warning + aIsSeamless = aIsSeamless; + + TBuf8<64> text; + + if (iRoaming == ERoamingAutomatic) + { + iRoamingState = EIdle; + iMobility->NewCarrierAccepted(); + } + else if (iRoaming == ERoamingManual) + { + text.AppendFormat( _L8("IAP %i pending accept\n"), aNewAP.AccessPoint() ); + iRoamingState = EPendingNewCarrierActive; + iConsole.PopupNotify( _L("Accept or Reject available")); + } + else + { + iRoamingState = EIdle; + text.AppendFormat( _L8("Unexpected NewCarrierActive %i\n"), aNewAP.AccessPoint() ); + iMobility->NewCarrierRejected(); + } + iConsole.PrintNotify( text ); + } + +// --------------------------------------------------------- +// CSocketsEngine:: +// --------------------------------------------------------- +// +void CSocketsEngine::Migrate() + { + if (iRoaming != ERoamingManual) + { + User::Panic( KPanicSocketsEngine, EConnTestBadRoamingStatus ); + } + iMobility->MigrateToPreferredCarrier(); + iConsole.PrintNotify( _L("Migration requested")); + iRoamingState = EIdle; + } + +// --------------------------------------------------------- +// CSocketsEngine:: +// --------------------------------------------------------- +// +void CSocketsEngine::Ignore() + { + if (iRoaming != ERoamingManual) + { + User::Panic( KPanicSocketsEngine, EConnTestBadRoamingStatus ); + } + iMobility->IgnorePreferredCarrier(); + iConsole.PrintNotify( _L("Ignored new carrier")); + iRoamingState = EIdle; + } + +// --------------------------------------------------------- +// CSocketsEngine:: +// --------------------------------------------------------- +// +void CSocketsEngine::AcceptCarrier() + { + if (iRoaming != ERoamingManual) + { + User::Panic( KPanicSocketsEngine, EConnTestBadRoamingStatus ); + } + iMobility->NewCarrierAccepted(); + iConsole.PrintNotify( _L("Accepted carrier")); + iRoamingState = EIdle; + } + +// --------------------------------------------------------- +// CSocketsEngine:: +// --------------------------------------------------------- +// +void CSocketsEngine::RejectCarrier() + { + if (iRoaming != ERoamingManual) + { + User::Panic( KPanicSocketsEngine, EConnTestBadRoamingStatus ); + } + iMobility->NewCarrierRejected(); + iConsole.PrintNotify( _L("Rejected carrier")); + iRoamingState = EIdle; + } + +// --------------------------------------------------------- +// CSocketsEngine::StartCloseInterfaceL() +// Start interface for testing RConnection::Close +// --------------------------------------------------------- +// +void CSocketsEngine::StartCloseInterfaceL() + { + if (iEngineStatus == EConnected || iEngineStatus == EInterfaceUp) + { + // Already started, simply return + return; + } + + // Get IAP id + TUint32 iapId; + TInt popupOk = Utils::AskIapIdL( iapId ); + + if (!popupOk) + { + // Selection cancelled + return; + } + RDebug::Print( _L("ConnTest: Selected IAP id=%d"), iapId ); + + iCloseConnection = new (ELeave) RConnection; + + User::LeaveIfError( iCloseConnection->Open( iSocketServ ) ); + + // Create overrides + iPrefs.SetIapId( iapId ); + iPrefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt ); + + ChangeStatus( EStartingInterface ); + + iCloseConnection->Start( iPrefs, iStatus ); + SetActive(); + + iTempProgressNotifier = CProgressNotifier::NewL( *iCloseConnection, *this ); + iTempProgressNotifier->StartNotify(); + + } + +// --------------------------------------------------------- +// CSocketsEngine::StopInterfaceL() +// Shutdown interface +// --------------------------------------------------------- +// +void CSocketsEngine::StopInterfaceL() + { + // Note! Socket is not closed here, because in connected + // state only Disconnect menu item is available. Therefore + // interface cannot be stopped when connection is open. + // + // iProgressNotifier->Cancel() is called in ProgressNotifyReceived + // method after KLinkLayerClosed has been received. + // + + //unregister from mobility API if registered + UnRegisterFromMobilityAPI(); + SetSocketEngineConnType( ETypeUnknown ); + + if (iEngineStatus == EConnected || iEngineStatus == EInterfaceUp) + { + iConnection.Stop(); + ChangeStatus( EInterfaceDown ); + iHttpClient->SetHttpConnectionInfoL( ETrue, iConnection, iSocketServ ); + + if (iCloseConnection) + { + // So if we are here, interface was started for testing RConnection::Close, + // and the corresponding RConnection instance needs to be deleted. + iCloseConnection->Close(); + delete iCloseConnection; + iCloseConnection = NULL; + } + } + } + +// --------------------------------------------------------- +// CSocketsEngine::CloseInterface() +// Close interface +// --------------------------------------------------------- +// +void CSocketsEngine::CloseInterface() + { + if (iCloseConnection) + { + iCloseConnection->Close(); + delete iCloseConnection; + iCloseConnection = NULL; + } + } + +// --------------------------------------------------------- +// CSocketsEngine::ConnectL() +// Check whether the address is valid IP address. If it's not +// calls DNS to solve the name. +// --------------------------------------------------------- +// +void CSocketsEngine::ConnectL() + { + // Just in case (does nothing if interface has already been started) + StartInterfaceL( EAskIap, ETrue ); + + // Initiate connection process + if ((iEngineStatus == EInterfaceUp) || (iEngineStatus == ETimedOut)) + { + TInetAddr addr; + if (addr.Input( iServerName ) == KErrNone) + { + // server name is already a valid ip address + ConnectL( addr ); + } + else // need to look up name using dns + { + // Initiate DNS + User::LeaveIfError( iResolver.Open( iSocketServ, KAfInet, + KProtocolInetUdp, iConnection ) ); + // DNS request for name resolution + StartTickCount(); + iResolver.GetByName( iServerName, iNameEntry, iStatus ); + + ChangeStatus( ELookingUp ); + // Request time out + iTimer->After( KTimeOut ); + SetActive(); + } + } + } + +// --------------------------------------------------------- +// CSocketsEngine::ConnectL() +// Connect to socket +// --------------------------------------------------------- +// +void CSocketsEngine::ConnectL( const TInetAddr& aAddr ) // + { + + // Initiate attempt to connect to a socket by IP address + if ((iEngineStatus == EInterfaceUp) || (iEngineStatus == ETimedOut)) + { + // Open a TCP socket + iSocket.Close(); // Just in case + User::LeaveIfError( iSocket.Open( iSocketServ, KAfInet, iSocketType, + iProtocol, iConnection ) ); + + // Set up address information + iAddress = aAddr; + iAddress.SetPort( iPort ); + + // Initiate socket connection + StartTickCount(); + iSocket.Connect( iAddress, iStatus ); + ChangeStatus( EConnecting ); + SetActive(); + + // Start a timeout + iTimer->After( KTimeOut ); + } + } + +// --------------------------------------------------------- +// CSocketsEngine::Disconnect() +// Shutdown socket +// --------------------------------------------------------- +// +void CSocketsEngine::Disconnect() + { + if (iEngineStatus == EListening && iProtocol == KProtocolInetTcp) + { + iListeningSocket.CancelAccept(); + iListeningSocket.Close(); + // Remember to close the socket on reader RunL() + } + if (iEngineStatus == EConnected || iEngineStatus == EListening) + { + iSocketsRead->Cancel(); + iSocketsWrite->Cancel(); + + // have to do this. + iTimer->Cancel(); + + // Use Close() instead of Shutdown(). This way we + // can handle the situation, where server initiates + // the closing process, and sends RST signal instead + // of FIN. If server sends RST and Shutdown() is used, + // engine stays in EDisconnecting state forever. + iSocket.Close(); + + ChangeStatus( EInterfaceUp ); + } + } + +// --------------------------------------------------------- +// CSocketsEngine::ListenL() +// Opens listening socket +// --------------------------------------------------------- +// +void CSocketsEngine::ListenL() + { + // Initiate attempt to connect to a socket by IP address + if ((iEngineStatus == EInterfaceUp) || (iEngineStatus == ETimedOut)) + { + // Open a TCP socket + iSocket.Close(); // Just in case + iListeningSocket.Close(); + + // Set up address information + iAddress.SetFamily( 0 ); + iAddress.SetPort( iPort ); + switch (iProtocol) + { + case KProtocolInetTcp: + User::LeaveIfError( iSocket.Open( iSocketServ ) ); + User::LeaveIfError( iListeningSocket.Open( iSocketServ, + KAfInet, iSocketType, iProtocol, iConnection ) ); + // Bind a port + iListeningSocket.Bind( iAddress ); + // Listens a socket + iListeningSocket.Listen( 1 ); // Only one connection allowed + // Accepts one connection + iListeningSocket.Accept( iSocket, iStatus ); + ChangeStatus( EListening ); + SetActive(); + break; + case KProtocolInetUdp: + User::LeaveIfError( iSocket.Open( iSocketServ, KAfInet, + iSocketType, iProtocol, iConnection ) ); + iSocket.Bind( iAddress ); + ChangeStatus( EListening ); + iStatus = KErrNone; + RunL(); // ugly. + break; + default: + User::Leave( KErrNotSupported ); + break; + } + } + } + +// --------------------------------------------------------- +// CSocketsEngine::Write() +// Write data to socket +// --------------------------------------------------------- +// +void CSocketsEngine::WriteL( const TDesC8& aData ) + { + RDebug::Print( _L("ConnTest: Sending data, length = %d"),aData.Length() ); + + iSocketsRead->SetPerformance( EFalse ); + + // Write data to socket + if (iEngineStatus == EConnected) + { + iSocketsWrite->IssueWriteL( aData, &iAddress, iProtocol ); + } + } + +// --------------------------------------------------------- +// CSocketsEngine::Write() +// Write data to socket aCount times +// --------------------------------------------------------- +// +void CSocketsEngine::WriteFloodL( const TDesC8& aData, TInt aCount ) + { + // Write data to socket + if (iEngineStatus == EConnected) + { + iThroughputStartTime.UniversalTime(); + iSocketsWrite->IssueWriteL( aData, &iAddress, iProtocol, aCount ); + } + } + +// --------------------------------------------------------- +// CSocketsEngine::SendHttpRequestOverSocketL(TBool aHasBody) +// Write HTTP request to socket +// --------------------------------------------------------- +// +void CSocketsEngine::SendHttpRequestOverSocketL( TBool aHasBody, + TBool aDoPerformance ) + { + iSocketsRead->SetPerformance( aDoPerformance ); + + TBuf8<256> req; + + if (aHasBody) + { + // Send HTTP POST + req.Copy( _L8("POST ")); + + // Add '/' if it is not included in the given page name + if (!((TChar)iSettingData->iHttpPage[0] == '/')) + { + req.Append( _L8("/")); + } + + req.Append( iSettingData->iHttpPage ); + req.Append( _L8(" HTTP/1.1\r\n")); + req.Append( _L8("Host: ")); + req.Append( iSettingData->iServerName ); + req.Append( _L8(":")); + req.AppendNum( iSettingData->iPort ); + req.AppendFormat( _L8("\r\nContent-Length: %d"), iSettingData->iPacketSize + * iSettingData->iPackets ); + req.Append( _L8("\r\n\r\n")); + + iSocketsWrite->IssueWriteL( req, &iAddress, iProtocol, + iSettingData->iPacketSize, iSettingData->iPackets ); + } + else + { + // Send HTTP GET + req.Copy( _L8("GET ")); + + // Add '/' if it is not included in the given page name + if (!((TChar)iSettingData->iHttpPage[0] == '/')) + { + req.Append( _L8("/")); + } + + req.Append( iSettingData->iHttpPage ); + req.Append( _L8(" HTTP/1.1\r\n")); + req.Append( _L8("Host: ")); + req.Append( iSettingData->iServerName ); + req.Append( _L8(":")); + req.AppendNum( iSettingData->iPort ); + req.Append( _L8("\r\n\r\n")); + + StartTickCount(); + iSocketsWrite->IssueWriteL( req, &iAddress, iProtocol ); + } + } + +// --------------------------------------------------------- +// CSocketsEngine::Read() +// Read data from socket +// --------------------------------------------------------- +// +void CSocketsEngine::Read() + { + // Initiate read of data from socket + if ((iEngineStatus == EConnected) && (!iSocketsRead->IsActive())) + { + iSocketsRead->Start( &iAddress, iProtocol ); + } + } + +// --------------------------------------------------------- +// CSocketsEngine::RunL() +// +// --------------------------------------------------------- +// +void CSocketsEngine::RunL() + { + // Active object request complete handler. + // iEngineStatus flags what request was made, so its + // completion can be handled appropriately + iTimer->Cancel(); // Cancel TimeOut timer before completion + TBuf<64> text( _L("")); + switch (iEngineStatus) + { + case EInterfaceDown: + // Just in case, if status is changed in ProgressNotifyReceived + // method before this method is called + break; + case EStartingInterface: + text.Format( _L("RConnection::Start()")); + StopTickCount( text ); + // Interface startup request + if (iStatus == KErrNone) + { + // Interface started successfully + ChangeStatus( EInterfaceUp ); + + if (iCloseConnection) + { + iHttpClient->SetHttpConnectionInfoL( EFalse, + *iCloseConnection, iSocketServ ); + } + else + { + iHttpClient->SetHttpConnectionInfoL( EFalse, iConnection, + iSocketServ ); + } + + if ( ( iSockEngineStartType == ESnap || + iSockEngineStartType == EExtPrefs || + iSockEngineStartType == EExtPrefsInternet ) && + ( iRoaming == ERoamingAutomatic || iRoaming == ERoamingManual ) ) + { + RegisterToMobilityAPIL(); + } + + if (iConnectAfterStartup) + { + ConnectL(); + } + } + else + { + iConsole.ErrorNotify( _L(" Startup failed"), iStatus.Int() ); + ChangeStatus( EInterfaceDown ); + SetSocketEngineConnType( ETypeUnknown ); + } + break; + + case EConnecting: + // IP connection request + text.Format( _L("RSocket::Connect()")); + StopTickCount( text ); + if (iStatus == KErrNone) + // Connection completed successfully + { + ChangeStatus( EConnected ); + Read(); //Start CSocketsRead Active object + } + else + { + iConsole.ErrorNotify( _L(" Conn. failed"), iStatus.Int() ); + ChangeStatus( EInterfaceUp ); + } + break; + + case ELookingUp: + text.Format( _L("RHostResolver::GetByName()")); + StopTickCount( text ); + iResolver.Close(); + if (iStatus == KErrNone) + { + // DNS look up successful + iNameRecord = iNameEntry(); + // Extract domain name and IP address from name record + PrintTextToConsole( _L("\r\nDomain name = ")); + PrintTextToConsole( iNameRecord.iName ); + TBuf<64> ipAddr; + TInetAddr::Cast( iNameRecord.iAddr ).Output( ipAddr ); + iConsole.PrintNotify( _L("\r\nIP address = ")); + PrintTextToConsole( ipAddr ); + PrintTextToConsole( _L("\r\n")); + // And connect to the IP address + ChangeStatus( EInterfaceUp ); + ConnectL( TInetAddr::Cast( iNameRecord.iAddr ) ); + } + else + { + // DNS lookup failed + iConsole.ErrorNotify( _L(" DNS lookup failed"), iStatus.Int() ); + ChangeStatus( EInterfaceUp ); + } + break; + case EListening: + // Listening socket accept returned + if (iStatus == KErrNone && !iSocketsRead->IsActive()) + // Connection established + { + //ChangeStatus(EConnected); Might as well be in listening state. + // This how we can keep accepting several connections + // Initiate read of data from socket + iSocketsRead->StartRAWRead( &iAddress, iProtocol ); + } + else + { + iConsole.ErrorNotify( _L(" Accept. failed"), iStatus.Int() ); + iListeningSocket.Close(); + iSocket.Close(); + ChangeStatus( EInterfaceUp ); + } + + break; + case EDisconnecting: + if (iStatus == KErrNone) + { + iSocket.Close(); + ChangeStatus( EInterfaceUp ); + } + break; + + default: + // Ignore the state check here, because it might happen that state + // has already been altered in ProgressNotifyReceived method. + break; + } + } + +// --------------------------------------------------------- +// CSocketsEngine::DoCancel() +// Cancel ongoing operations +// --------------------------------------------------------- +// +void CSocketsEngine::DoCancel() + { + iTimer->Cancel(); + + // Cancel ongoing operation + switch (iEngineStatus) + { + case EStartingInterface: + + if (iCloseConnection) + { + iCloseConnection->Close(); + delete iCloseConnection; + iCloseConnection = NULL; + } + else + { + iConnection.Stop(); + } + + UnRegisterFromMobilityAPI(); + SetSocketEngineConnType( ETypeUnknown ); + ChangeStatus( EInterfaceDown ); + + break; + case EConnecting: + iSocket.CancelConnect(); + iSocket.Close(); + ChangeStatus( EInterfaceUp ); + break; + case ELookingUp: + // Cancel look up attempt + iResolver.Cancel(); + iResolver.Close(); + ChangeStatus( EInterfaceUp ); + break; + case EDisconnecting: + ChangeStatus( EInterfaceUp ); + iSocket.Close(); + break; + case EListening: + ChangeStatus( EInterfaceUp ); + iListeningSocket.CancelAccept(); + iListeningSocket.Close(); + iSocket.Close(); + break; + default: + User::Panic( KPanicSocketsEngine, EConnTestBadStatus ); + break; + } + } + +// --------------------------------------------------------- +// CSocketsEngine::ChangeStatus(TSocketsEngineState aNewStatus) +// Set new status for socket engine and update the status +// line in console window. +// --------------------------------------------------------- +// +void CSocketsEngine::ChangeStatus( TSocketsEngineState aNewStatus ) + { + // Update the status (and the status display) + switch (aNewStatus) + { + case EInterfaceDown: + iConsole.SetStatus( _L("Interface stopped")); + break; + case EStartingInterface: + iConsole.SetStatus( _L("Starting interface...")); + break; + case EInterfaceUp: + iConsole.SetStatus( _L("Interface up")); + break; + case EConnecting: + iConsole.SetStatus( _L("Connecting...")); + break; + case EConnected: + iConsole.SetStatus( _L("Connected")); + break; + case EListening: + iConsole.SetStatus( _L("Listening")); + break; + case ETimedOut: + iConsole.SetStatus( _L("Timed out")); + break; + case ELookingUp: + iConsole.SetStatus( _L("Looking up...")); + break; + case ELookUpFailed: + iConsole.SetStatus( _L("Look up failed")); + break; + case EConnectFailed: + iConsole.SetStatus( _L("Failed")); + break; + case EDisconnecting: + iConsole.SetStatus( _L("Disconnecting...")); + break; + default: + User::Panic( KPanicSocketsEngine, EConnTestBadStatus ); + break; + } + iEngineStatus = aNewStatus; + } + +// --------------------------------------------------------- +// CSocketsEngine::PrintTextToConsole(const TDesC& aDes) +// Helper function for printing notifications, text +// formatting added. +// --------------------------------------------------------- +// +void CSocketsEngine::PrintTextToConsole( const TDesC& aDes ) + { + // Print some text on the console + iConsole.PrintNotify( aDes ); // Try if this works on real hw + } + +// --------------------------------------------------------- +// CSocketsEngine::SetConnectionData(const CSettingData* aData) +// Set connection information. +// --------------------------------------------------------- +// +void CSocketsEngine::SetConnectionData( const CSettingData* aData ) + { + iServerName.Copy( aData->iServerName ); + iPort = aData->iPort; + + switch (aData->iProtocol) + { + case 0: + iProtocol = KProtocolInetTcp; + iSocketType = KSockStream; + break; + case 1: + iProtocol = KProtocolInetUdp; + iSocketType = KSockDatagram; + break; + default: + iProtocol = KProtocolInetTcp; + iSocketType = KSockStream; + break; + } + + iRoaming = (TRoamingSetting)aData->iRoaming; + + iHttpPage = aData->iHttpPage; + + iSettingData = (CSettingData*)aData; + } + +// --------------------------------------------------------- +// CSocketsEngine::SetCustomPrefs(const CCustomPrefsData* aData) +// Set custom preferences information. +// --------------------------------------------------------- +// +void CSocketsEngine::SetCustomPrefsData( const CCustomPrefsData* aData ) + { + iCustomPrefsData = (CCustomPrefsData*)aData; + iExtPrefs->SetSnapPurpose( (CMManager::TSnapPurpose)aData->iSnapPurpose ); + iExtPrefs->SetSnapId( aData->iSnapId ); + iExtPrefs->SetIapId( aData->iIapId ); + iExtPrefs->SetBearerSet( aData->iBearerSet ); + iExtPrefs->SetNoteBehaviour( aData->iNoteBehaviour ); + iExtPrefs->SetDisconnectDialog( aData->iDisconnectDialog ); + iExtPrefs->SetConnSelectionDialog( aData->iConnSelectionDialog ); + iExtPrefs->SetForcedRoaming( aData->iForcedRoaming ); + } + +// --------------------------------------------------------- +// CSocketsEngine::ConnectionInfo() +// Display information about current connection and sockets +// --------------------------------------------------------- +// +void CSocketsEngine::ConnectionInfoL() + { + TInt result; + TBuf<40> val; + TBuf<40> network; + TBuf<20> query; + TName name; + TUint connCount; + TUint i, j; + TConnectionEnumArg args; + TUint32 networkId; + RApaLsSession appSess; + TApaAppInfo appInfo; + + User::LeaveIfError( appSess.Connect() ); + CleanupClosePushL( appSess ); + + HBufC* buf = HBufC::NewLC( 2048 ); + TPtr infoBuf = buf->Des(); + + infoBuf.AppendFormat( _L("===============\n")); + infoBuf.AppendFormat( _L("Connection info:\n")); + + // Connection name. + result = iConnection.Name( name ); + User::LeaveIfError( result ); + RDebug::Print( _L("ConnTest: Connection name: %S"), &name ); + + // Get connection info + result = iConnection.EnumerateConnections( connCount ); + User::LeaveIfError( result ); + RDebug::Print( _L("ConnTest: Number of connections: %d"), connCount ); + infoBuf.AppendFormat( _L("Connections: %d\n"), connCount ); + + if (connCount == 0) + { + infoBuf.AppendFormat( _L("---------------\n")); + PrintTextToConsole( infoBuf ); + CleanupStack::PopAndDestroy( buf ); // buf + CleanupStack::PopAndDestroy( &appSess ); + return; + } + + // + // Get active connection info + // + infoBuf.AppendFormat( _L("Active connection:\n")); + + // IAP name + query.Format( _L("%s\\%s"), IAP, COMMDB_NAME); + result = iConnection.GetDesSetting(query, val); + if(result == KErrNone) + { + RDebug::Print(_L("ConnTest: IAP/Name value: %S"), &val); + infoBuf.AppendFormat(_L("-IAP: %S\n"), &val); + } + + // Network id + query.Format(_L("%s\\%s"), IAP, IAP_NETWORK); + result = iConnection.GetIntSetting(query, networkId); + if(result == KErrNone) + { + // Get the corresponding network name for this id, + // it is user friendlier. + RDebug::Print(_L("ConnTest: NetworkId: %d"), networkId); + + // Network name + CCommsDatabase* TheDb; + + TheDb = CCommsDatabase::NewL(); + CleanupStack::PushL(TheDb); + + CCommsDbTableView* view = TheDb->OpenViewMatchingUintLC( TPtrC(NETWORK), + TPtrC(COMMDB_ID), + networkId ); + result = view->GotoFirstRecord(); + + if(result == KErrNone) + { + view->ReadTextL(TPtrC(COMMDB_NAME), network); + RDebug::Print(_L("ConnTest: Network name: %S"), &network); + infoBuf.AppendFormat(_L("-net: %S\n"), &network); + } + CleanupStack::PopAndDestroy(view); + CleanupStack::PopAndDestroy(TheDb); + } + + // Note! The following doesn't work, because NETWORK table + // is not among those tables where information can be + // fetched this way. (Perhaps in future.) + /* + // Network name + query.Format(_L("%s\\%s"), NETWORK, COMMDB_NAME); + result = iConnection.GetDesSetting(query, network); + RDebug::Print(_L("IAP/Name value: %S"), &val); + infoBuf.AppendFormat(_L("Network name: %S\n"), &network); + + // Network id + query.Format(_L("%s\\%s"), NETWORK, COMMDB_ID); + result = iConnection.GetIntSetting(query, networkId); + RDebug::Print(_L("IAP/Name value: %d"), networkId); + infoBuf.AppendFormat(_L("Network id: %d\n"), networkId); + */ + + // Print transferred data + TPckg uplinkVolume(0); + TPckg downlinkVolume(0); + TRequestStatus status; + iConnection.DataTransferredRequest(uplinkVolume, downlinkVolume, status); + User::WaitForRequest(status); + if(status.Int() == KErrNone) + { + infoBuf.AppendFormat(_L("-up=%d, down=%d\n"), uplinkVolume(), downlinkVolume()); + } + + for(i = 1; i <= connCount; i++) + { + infoBuf.AppendFormat(_L("\nConnection %d:\n"), i); + TPckgBuf connInfo; + result = iConnection.GetConnectionInfo(i, connInfo); + User::LeaveIfError(result); + RDebug::Print(_L("ConnTest: IapId: %d, NetId: %d"), connInfo().iIapId, connInfo().iNetId); + infoBuf.AppendFormat(_L(" -IapId=%d, NetId=%d\n"), connInfo().iIapId, connInfo().iNetId); + + // Get info about clients using this connection + args.iIndex = i; + TConnEnumArgBuf enumBuf(args); + + TConnectionGetClientInfoArg clientInfoArg; + clientInfoArg.iIndex = 1; + TConnGetClientInfoArgBuf clientInfoBuf(clientInfoArg); + + TConnectionClientInfo clientInfo; + + result = iConnection.Control(KCOLConnection, KCoEnumerateConnectionClients, enumBuf); + User::LeaveIfError(result); + infoBuf.AppendFormat(_L(" -clients: %d\n"), enumBuf().iCount); + + for(j = 1; j <= enumBuf().iCount; j++) + { + clientInfoBuf().iIndex = j; + result = iConnection.Control( KCOLConnection, + KCoGetConnectionClientInfo, + clientInfoBuf ); + User::LeaveIfError(result); + clientInfo = clientInfoBuf().iClientInfo; + + TInt id = clientInfo.iProcessId; + RDebug::Print(_L("ConnTest: ProcessId: %d"), id); + + // Get application name +#ifndef __WINS__ + result = appSess.GetAppInfo(appInfo, clientInfo.iUid); + if(result == KErrNone) + { + infoBuf.AppendFormat(_L(" client %d=%S\n"), j, &(appInfo.iCaption)); + } + else + { + // Servers don't have caption name (e.g. Connection Monitor server) + infoBuf.AppendFormat(_L(" client %d=%x\n"), j, clientInfo.iUid); + } +#else + infoBuf.AppendFormat(_L(" client %d=N/A in WINS\n"), j); +#endif + } + + // Get info about sockets using this connection + TConnectionGetSocketInfoArg socketInfoArg; + socketInfoArg.iIndex = i; + TConnGetSocketInfoArgBuf socketInfoBuf(socketInfoArg); + TConnectionSocketInfo socketInfo; + + result = iConnection.Control( KCOLConnection, + KCoEnumerateConnectionSockets, + enumBuf); + User::LeaveIfError(result); + infoBuf.AppendFormat(_L(" -sockets: %d\n"), enumBuf().iCount); + + for(j = 1; j <= enumBuf().iCount; j++) + { + socketInfoBuf().iIndex = j; + result = iConnection.Control( KCOLConnection, + KCoGetConnectionSocketInfo, + socketInfoBuf ); + User::LeaveIfError(result); + socketInfo = socketInfoBuf().iSocketInfo; + + TUint id = socketInfo.iAddressFamily; + TBuf<5> prot; + socketInfo.iProtocol == KProtocolInetTcp ? prot.Copy(_L("tcp")) : prot.Copy(_L("udp")); + + TSockAddr sa = socketInfo.iSourceAddress; + TSockAddr da = socketInfo.iDestinationAddress; + + TInetAddr& source = TInetAddr::Cast(sa); + TInetAddr& dest = TInetAddr::Cast(da); + + TBuf<20> a1; + source.Output(a1); + + TBuf<20> a2; + dest.Output(a2); + + RDebug::Print(_L("ConnTest: ProcessId: %d"), id); + infoBuf.AppendFormat(_L(" %d. socket: %S\n %S->\n %S\n"), j, &prot, &a1, &a2); + } + } // for (i... + infoBuf.AppendFormat(_L("---------------\n")); + PrintTextToConsole(infoBuf); + CleanupStack::PopAndDestroy(buf); + CleanupStack::PopAndDestroy(&appSess); + } + + // --------------------------------------------------------- + // CSocketsEngine::SendHttpFrameworkRequestL() + // Send HTTP request + // --------------------------------------------------------- + // +void CSocketsEngine::SendHttpFrameworkRequestL( TBool aHasBody, + TBool aDoPerformance, + TBool aIsSecure ) + { + iHttpClient->SetPerformance( aDoPerformance ); + iHttpClient->InvokeHttpMethodL( iSettingData, aHasBody, aIsSecure ); + } + +// --------------------------------------------------------- +// CSocketsEngine::ProgressNotifyReceivedL(TInt aStage) +// Progress notification has been received, display the +// stage in output window. +// --------------------------------------------------------- +// +void CSocketsEngine::ProgressNotifyReceivedL( TInt aStage, TInt aError ) + { + + TBuf8<64> text; + text.AppendFormat( _L8("Progress: %d, %d"), aStage, aError ); + + TBuf8<16> error; + error.Format( _L8(", %d"), aError ); + + switch (aStage) + { + case KConnectionUninitialised: // 0 + iConsole.PrintNotify( _L8("Connection uninit")); + iConsole.PrintNotify( error ); + break; + case KStartingSelection: // 1000 + iConsole.PrintNotify( _L8("Starting selection")); + iConsole.PrintNotify( error ); + break; + case KFinishedSelection: // 2000 + iConsole.PrintNotify( _L8("Finished selection")); + iConsole.PrintNotify( error ); + + if (iCloseConnection) + { + // We are starting RConnection instance for testing RConnection::Close. + // At this point we can attach the monitoring RConnection instance to + // interface, and delete the temporary progress notifier. + // + // We may loose few progress notifications at start up, that's small + // prize compared to advantages: we get correct notifications when + // interface goes down, which is the essential part of this test. + + TBuf<20> query; + TUint32 networkId; + TInt result; + TInt err( KErrNone ); + TConnectionInfo info; + TPckg pckgInfo( info ); + + // Network id + query.Format( _L("%s\\%s"), IAP, IAP_NETWORK); + result = iCloseConnection->GetIntSetting(query, networkId); + if(result == KErrNone) + { + info.iIapId = iPrefs.IapId(); + info.iNetId = networkId; + } + err = iConnection.Attach( pckgInfo, RConnection::EAttachTypeMonitor ); + if ( err != KErrNone ) + { + iConsole.ErrorNotify(_L("Attaching failed"), err); + } + iTempProgressNotifier->Cancel(); + delete iTempProgressNotifier; + iTempProgressNotifier = NULL; + } + break; + case KConnectionFailure: // 2001 + iConsole.PrintNotify(_L8("Connection failure")); + iConsole.PrintNotify(error); + break; + case KMinAgtProgress: // 2500 + iConsole.PrintNotify(_L8("Min agt progress")); + iConsole.PrintNotify(error); + break; + case KConnectionOpen: // 3500 + iConsole.PrintNotify(_L8("Connection open")); + iConsole.PrintNotify(error); + break; + case KConnectionClosed: // 4500 + iConsole.PrintNotify(_L8("Connection closed")); + iConsole.PrintNotify(error); + break; + case KMaxAgtProgress: // 5500 + iConsole.PrintNotify(_L8("Max agent progress")); + iConsole.PrintNotify(error); + break; + case KMinNifProgress: // 6000 + iConsole.PrintNotify(_L8("Min nif progress")); + iConsole.PrintNotify(error); + break; + case KLinkLayerOpen: // 7000 + iConsole.PrintNotify(_L8("Link layer open")); + iConsole.PrintNotify(error); + break; + case KLinkLayerClosed: // 8000 + iConsole.PrintNotify(_L8("Link layer closed")); + iConsole.PrintNotify(error); + iHttpClient->SetHttpConnectionInfoL(ETrue, iConnection, iSocketServ); + + switch (iEngineStatus) + { + case EStartingInterface: + // This case will occur, if username/password prompt dialog + // is used and cancel is selected in dialog, and when error + // occurs during interface startup. + break; + case EInterfaceDown: + // EInterfaceDown must be handled also, because this + // state has been set in StopInterface method. + break; + case EListening: + iListeningSocket.CancelAccept(); + iListeningSocket.Close(); + // FALLTHROUGH + case ELookingUp: + // Cancel everything depending on state. + iResolver.Cancel(); + iResolver.Close(); + // FALLTHROUGH + case EConnected: + iSocketsRead->Cancel(); + iSocketsWrite->Cancel(); + // FALLTHROUGH + case EConnecting: + // This looks awful, but is required because of the fall through + // and buggy implementation of the CancelConnect. + if( EConnecting == iEngineStatus ) + { + iSocket.CancelConnect(); + } + // FALLTHROUGH + case EDisconnecting: + iSocket.Close(); + // FALLTHROUGH + case EInterfaceUp: + if (iRoaming == ERoamingOff) + { + UnRegisterFromMobilityAPI(); + SetSocketEngineConnType(ETypeUnknown); + ChangeStatus(EInterfaceDown); + } + else + { + iConsole.PrintNotify(_L8("MobilitySession lost!\n")); + UnRegisterFromMobilityAPI(); + SetSocketEngineConnType(ETypeUnknown); + ChangeStatus(EInterfaceDown); + } + break; + default: + User::Panic(KPanicSocketsEngine, EConnTestBadStatus); + break; + } + + break; + case KMaxNifProgress: // 9000 + iConsole.PrintNotify(_L8("Max nif progress\n")); + break; + default: + iConsole.PrintNotify(text); + } + iConsole.PrintNotify(_L8("\f")); + } + + // --------------------------------------------------------- + // CSocketsEngine::ProgressNotifyError(TInt aStatus) + // Some error has occurred while receiving progress + // notifications. + // --------------------------------------------------------- + // +void CSocketsEngine::ProgressNotifyError( TInt aStatus ) + { + iConsole.ErrorNotify( _L(" Notify failed"), aStatus ); + } + +// --------------------------------------------------------- +// CSocketsEngine::TimerExpired() +// Cancel ongoing operations +// --------------------------------------------------------- +// +void CSocketsEngine::TimerExpired() + { + Cancel(); + iConsole.ErrorNotify( _L(" Timed out"), KErrTimedOut ); + } + +// --------------------------------------------------------- +// CSocketsEngine::InterfaceInfoL() +// Print information about interfaces. +// --------------------------------------------------------- +// +void CSocketsEngine::InterfaceInfoL() + { + TBuf<128> t; + TAutoClose ss; + User::LeaveIfError( ss.iObj.Connect() ); + ss.PushL(); + + TAutoClose sock; + User::LeaveIfError( sock.iObj.Open( ss.iObj, _L("udp")) ); + sock.PushL(); + + User::LeaveIfError( + sock.iObj.SetOpt( KSoInetEnumInterfaces, KSolInetIfCtrl ) ); + + TProtocolDesc in; + User::LeaveIfError( sock.iObj.Info( in ) ); + + TPckgBuf info, next; + + TInt res = sock.iObj.GetOpt( KSoInetNextInterface, KSolInetIfCtrl, info ); + if (res != KErrNone) + { + User::Leave( res ); + } + TInt count = 0; + while (res == KErrNone) + { + res = sock.iObj.GetOpt( KSoInetNextInterface, KSolInetIfCtrl, next ); + + if (info().iName != _L("") && info().iName != _L("loop6") && info().iName != _L("loop4")) + { + t.Format( _L("Interface %d\n"),count++ ); + PrintTextToConsole( t ); + t.Format( _L("Name \"%S\"\n"), &info().iName ); + PrintTextToConsole( t ); + + t.Format( _L("State ")); + switch (info().iState) + { + case EIfPending: + t.AppendFormat( _L("pending\n")); + break; + case EIfUp: + t.AppendFormat( _L("up\n")); + break; + case EIfBusy: + t.AppendFormat( _L("busy\n")); + break; + default: + t.AppendFormat( _L("down\n")); + break; + } + + t.AppendFormat( _L("Mtu %d\n"), info().iMtu ); + t.AppendFormat( _L("Speed Metric %d\n"), info().iSpeedMetric ); + + t.Format( _L("Features:")); + info().iFeatures & KIfIsLoopback ? t.AppendFormat( _L(" loopback")) : t.AppendFormat( _L("")); + info().iFeatures & KIfIsDialup ? t.AppendFormat( _L(" dialup")) : t.AppendFormat( _L("")); + info().iFeatures & KIfIsPointToPoint ? t.AppendFormat( _L(" pointtopoint")) : t.AppendFormat( _L("")); + info().iFeatures & KIfCanBroadcast ? t.AppendFormat( _L(" canbroadcast")) : t.AppendFormat( _L("")); + info().iFeatures & KIfCanMulticast ? t.AppendFormat( _L(" canmulticast")) : t.AppendFormat( _L("")); + info().iFeatures & KIfCanSetMTU ? t.AppendFormat( _L(" cansetmtu")) : t.AppendFormat( _L("")); + info().iFeatures & KIfHasHardwareAddr ? t.AppendFormat( _L(" hardwareaddr")) : t.AppendFormat( _L("")); + info().iFeatures & KIfCanSetHardwareAddr ? t.AppendFormat( _L(" cansethardwareaddr")) : t.AppendFormat( _L("")); + t.AppendFormat( _L("\n")); + + TName address; + info().iAddress.Output( address ); + t.Format( _L("Addr: %S\n"), &address ); + + if (info().iAddress.IsLinkLocal()) + { + t.AppendFormat( _L(" -link local\n")); + } + else if (info().iAddress.IsSiteLocal()) + { + t.AppendFormat( _L(" -site local\n")); + } + else + { + t.AppendFormat( _L(" -global\n")); + } + PrintTextToConsole( t ); + + info().iBrdAddr.Output( address ); + info().iDefGate.Output( address ); + t.Format( _L("Gatew: %S\n"), &address ); + info().iNameSer1.Output( address ); + t.AppendFormat( _L("DNS 1: %S\n"), &address ); + info().iNameSer2.Output( address ); + t.AppendFormat( _L("DNS 2: %S\n"), &address ); + PrintTextToConsole( t ); + + if (info().iHwAddr.Family() != KAFUnspec) + { + PrintTextToConsole( _L("Hardware address ")); + TUint j; + for (j = sizeof(SSockAddr); j < sizeof(SSockAddr) + 6; ++j) + { + if (j < (TUint)info().iHwAddr.Length()) + { + t.Format( _L("%02X"), info().iHwAddr[j] ); + PrintTextToConsole( t ); + } + else + { + PrintTextToConsole( _L("??")); + } + if (j < sizeof(SSockAddr) + 5) + { + PrintTextToConsole( _L("-")); + } + else + { + PrintTextToConsole( _L("\n")); + } + } + } + } + if (res == KErrNone) + { + info = next; + PrintTextToConsole( _L("\n")); + } + else + { + PrintTextToConsole( _L("\n")); + } + } + t.Format( _L("Total %d interfaces\n"),count ); + PrintTextToConsole( t ); + + sock.Pop(); + ss.Pop(); + } + +// --------------------------------------------------------- +// CSocketsEngine::SetWLANQoS() +// Set QoS for WLAN +// --------------------------------------------------------- +// +void CSocketsEngine::SetWLANQoS( TInt aClass ) + { + TInt opt; + TInt err; + TBuf<64> t; + + if (iEngineStatus != EConnected) + { + t.Copy( _L("\nConnect first!\n")); + PrintTextToConsole( t ); + return; + } + + err = iSocket.GetOpt( KSoIpTOS, KSolInetIp, opt ); + + opt = opt >> 2; + + if (err == KErrNone) + { + t.Format( _L("Old TOS: %x\n"), opt ); + } + else + { + t.Format( _L("Cannot get TOS opt\n")); + } + + PrintTextToConsole( t ); + + switch (aClass) + { + case 7: + err = iSocket.SetOpt( KSoIpTOS, KSolInetIp, 0xE0 ); + break; + case 5: + err = iSocket.SetOpt( KSoIpTOS, KSolInetIp, 0xA0 ); + break; + case 3: + err = iSocket.SetOpt( KSoIpTOS, KSolInetIp, 0x60 ); + break; + case 1: + err = iSocket.SetOpt( KSoIpTOS, KSolInetIp, 0x20 ); + break; + case 0: + err = iSocket.SetOpt( KSoIpTOS, KSolInetIp, 0x0 ); + break; + default: + break; + } + + err = iSocket.GetOpt( KSoIpTOS, KSolInetIp, opt ); + + opt = opt >> 2; + + if (err == KErrNone) + { + t.Format( _L("New TOS: %x\n"), opt ); + } + else + { + t.Format( _L("Cannot set TOS opt\n")); + } + + PrintTextToConsole( t ); + + } + +// --------------------------------------------------------- +// CSocketsEngine::QoS1() +// +// --------------------------------------------------------- +// +void CSocketsEngine::QoS1() + { + /*TQoSSelector selector; + selector.setAddr(iSocket); + + RQoSPolicy policy; + policy.Open(selector); + + CQosParameters* parameters = GetparametersL(); + policy.NotifyEvent(iObserver); + policy.SetQoS(*parameters); + + policy.GetQoS(); + policy.Close(); + */ + } + +// --------------------------------------------------------- +// CSocketsEngine::QoS2() +// +// --------------------------------------------------------- +// +void CSocketsEngine::QoS2() + { + /*CQosParameters* parameters = GetparametersL(); + + RQoSChannel channel; + + channel.Open(iSocket); + channel.NotifyEvent(iObserver); + channel.SetQoS(*parameters); + + channel.Join(iSocket2); + + channel.Leave(ISocket); + + channel.Close(); + */ + } +// ---------------------------------------------------------------------------- +// CSocketsEngine::SendDataL +// Start the sending of the data +// ---------------------------------------------------------------------------- +// +void CSocketsEngine::SendDataL( const TBuf8 aData ) + { + RDebug::Print( _L("ConnTest: SendDataL: size = %d"),aData.Length() ); + iSendCount = 0; + iData->Des().Copy( aData ); + iData->Des().ZeroTerminate(); + iSocket.SetOpt( KSoUdpSynchronousSend, KSolInetUdp, 1 ); + + iTroughputDataSize = 0; + iThroughputStartTime.UniversalTime(); + + DoSendDataL(); + } + +// ---------------------------------------------------------------------------- +// CSocketsEngine::DoSendDataL +// Do the actual sending of the data +// ---------------------------------------------------------------------------- +// +void CSocketsEngine::DoSendDataL() + { + if (iSendCount++ < (iSettingData->iPackets)) + { + // Delay is given in milliseconds, timer uses microseconds. + if (iSettingData->iDelay != 0) + { + if (iSettingData->iProtocol == 1) // 1 == UDP here. Only way to send udp is raw data + { + RDebug::Print( + _L("ConnTest: DoSendDataL: inserting seq number %d"),iSendCount ); + TUint32* seqNumberPointer = (TUint32*)(iData->Des().Ptr()); + *seqNumberPointer = ByteOrder::Swap32( iSendCount ); // put sequence number into to the packet + } + WriteL( *iData ); + iSendTimer->After( (iSettingData->iDelay) * 1000 ); + } + else + { + WriteFloodL( *iData, iSettingData->iPackets ); + } + } + } + +// --------------------------------------------------------- +// Notifys when a packet has been sent +// aAmount is th amount of data that has been sent +// --------------------------------------------------------- +// +void CSocketsEngine::NotifySend( TInt aAmount ) + { + if (iThroughputStartTime != 0) + { + + iTroughputDataSize += aAmount; + TInt size = iSettingData->iPacketSize; + if (iSettingData->iPacketSize > KSendDataSize) + { + size = KSendDataSize; + } + // We add 1 for each packet since the create packet appends an extra \n + // after each packet + if (iTroughputDataSize == (iSettingData->iPackets * size)) + // + iSettingData->iPackets) ) + { + TBuf8<256> text; + Utils::CalculateThroughput( text, iThroughputStartTime, + iTroughputDataSize ); + iThroughputStartTime = 0; + iConsole.PrintNotify( text ); + iTroughputDataSize = 0; + } + } + } + +// --------------------------------------------------------- +// Marks starting time into memory +// +// --------------------------------------------------------- +// +void inline CSocketsEngine::StartTickCount() + { + if (!iUseTTime) + { + iStartTime = User::FastCounter(); + } + else + { + iStartTTime.UniversalTime(); + iStartTime = 1; // Non null. iStartTime is also used as flag. + } + + } + +// --------------------------------------------------------- +// Calculates time interval using tick count and prints it +// +// --------------------------------------------------------- +// +void CSocketsEngine::StopTickCount( const TDesC& aComponentName ) + { + TBuf<128> text; + if (!iUseTTime) + { + TUint32 currentTime = User::FastCounter(); + currentTime = currentTime - iStartTime; + + if (iStartTime == 0) + { + return; //do not print if start time hasn't been initialized. + } + iStartTime = 0; + + TInt freq = 0; + TInt err = HAL::Get( HAL::EFastCounterFrequency, freq ); + if (err != KErrNone || freq == 0) + { + text.Format( _L("FastCounter error: %d \n"),err ); + } + else + { + currentTime = (currentTime * 1000.0) / freq; + text.Format( _L("%u ms by "), currentTime ); + text.Append( aComponentName ); + text.Append( _L("\n")); + } + } + else + { + TTime currentTime; + currentTime.UniversalTime(); + + if (iStartTime == 0) + { + return; //do not print if start time hasn't been initialized. + } + TTimeIntervalMicroSeconds interval = currentTime.MicroSecondsFrom( + iStartTTime ); + iStartTime = 0; + + TBuf<32> app; + app.Format( _L("%u ms by "), interval.Int64() / 1000 ); + text.Append( app ); + text.Append( aComponentName ); + } + + PrintTextToConsole( text ); + } + +// end of file diff -r 000000000000 -r 857a3e953887 nettools/conntest/Engine/SocketsRead.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/Engine/SocketsRead.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,349 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSocketsRead is an active obejct that reads data from +* an already open socket and calculates some metrics from the data read +* +*/ + +// INCLUDE FILES +#include "SocketsRead.h" +#include "SocketsEngine.h" +#include "uinotify.h" +#include "Utils.h" + + +// --------------------------------------------------------- +// CSocketsRead::NewL(MUINotify& aConsole, RSocket& aSocket) +// EPOC two phased constructor +// --------------------------------------------------------- +// +CSocketsRead* CSocketsRead::NewL(MUINotify& aConsole, RSocket& aSocket, CSocketsEngine& aEngine) +{ + CSocketsRead* self = CSocketsRead::NewLC(aConsole, aSocket, aEngine); + CleanupStack::Pop(self); + return self; +} + +// --------------------------------------------------------- +// CSocketsRead::NewLC(MUINotify& aConsole, RSocket& aSocket) +// EPOC two phased constructor +// --------------------------------------------------------- +// +CSocketsRead* CSocketsRead::NewLC(MUINotify& aConsole, RSocket& aSocket, CSocketsEngine& aEngine) +{ + CSocketsRead* self = new (ELeave) CSocketsRead(aConsole, aSocket, aEngine); + CleanupStack::PushL(self); + self->ConstructL(); + return self; +} + +// --------------------------------------------------------- +// CSocketsRead::CSocketsRead(MUINotify& aConsole, RSocket& aSocket) +// Constructor +// --------------------------------------------------------- +// +CSocketsRead::CSocketsRead(MUINotify& aConsole, RSocket& aSocket, CSocketsEngine& aEngine) +: CActive(/*EPriorityStandard*/EPriorityHigh), +iEngine(aEngine), +iSocket(aSocket), +iConsole(aConsole) +{ +} + +// --------------------------------------------------------- +// CSocketsRead::~CSocketsRead() +// Destructor +// --------------------------------------------------------- +// +CSocketsRead::~CSocketsRead() +{ + Cancel(); +} + +// --------------------------------------------------------- +// CSocketsRead::ConstructL() +// EPOC two-phased constructor +// --------------------------------------------------------- +// +void CSocketsRead::ConstructL() +{ + CActiveScheduler::Add(this); +} + + +// --------------------------------------------------------- +// CSocketsRead::Start(TInetAddr* aAddress, TUint aProtocol) +// Initiate a read from socket. +// --------------------------------------------------------- +// +void CSocketsRead::Start(TInetAddr* aAddress, TUint aProtocol) +{ + iAddress = aAddress; + iProtocol = aProtocol; + + // Initiate a new read from socket into iBuffer + if (!IsActive()) + { + IssueRead(); + } +} + +// --------------------------------------------------------- +// CSocketsRead::StartRAWRead() +// Start RAW read +// --------------------------------------------------------- +// + +void CSocketsRead::StartRAWRead(TInetAddr* aAddress, TUint aProtocol) + { + iAddress = aAddress; + iProtocol = aProtocol; + iBodySize = 0; // REMEMBER TO DO THIS, OR OTHERWISE WE THINK THIS IS HTTP TRAFFIC + iDoPerformance = ETrue; + iUdpPacketCounter = 0; + + // Initiate a new read from socket into iBuffer + iConsole.PrintNotify(_L("Getting data...\n")); + iDoCount = ETrue; + iStartTime.UniversalTime(); + iReceivedBytes = 0; + + if (!IsActive()) + { + IssueRead(); + } +} + + +// --------------------------------------------------------- +// CSocketsRead::IssueRead() +// Receive data. +// --------------------------------------------------------- +// +void CSocketsRead::IssueRead() +{ + // Initiate a new read from socket into iBuffer + ASSERT(!IsActive()); + + switch(iProtocol) + { + case KProtocolInetTcp: + iSocket.RecvOneOrMore(iBuffer, 0, iStatus, iDummyLength); + break; + case KProtocolInetUdp: + iBuffer.Zero(); + iSocket.RecvFrom(iBuffer, *iAddress, 0, iStatus/*, iDummyLength*/); + break; + } + SetActive(); +} + + +// --------------------------------------------------------- +// CSocketsRead::SetPerformance(const TBool aValue) +// Set performance calculation on/off +// --------------------------------------------------------- +// +void CSocketsRead::SetPerformance(const TBool aValue) +{ + iDoPerformance = aValue; + iReceivedBytes = 0; + iDoCount = EFalse; + + //TInt recBuf; + //iSocket.SetOpt(KSORecvBuf, KSOLSocket, 200000); + //iSocket.GetOpt(KSORecvBuf, KSOLSocket, recBuf); +} + + +// --------------------------------------------------------- +// CSocketsRead::RunL() +// Called when request has completed. +// --------------------------------------------------------- +// +void CSocketsRead::RunL() + { + // Active object request complete handler + if (iStatus == KErrNone) + { + // Character has been read from socket + if(iDoPerformance) + { + if(!iDoCount) + { + iHeaders.Append(iBuffer.Left(iHeaders.MaxLength() - iHeaders.Length())); + iHeaders.LowerCase(); + + TInt end = iHeaders.Find(_L8("\r\n\r\n")); + TInt emptyLine = iBuffer.Find(_L8("\r\n\r\n")); + + if(!(end == KErrNotFound)) + { + TInt cl = iHeaders.Find(_L8("content-length:")); + + if(!(cl == KErrNotFound)) + { + TBuf8<512> temp; + temp = iHeaders.Mid(cl, end - cl); + + TInt st = temp.Locate(':'); + TInt endcl = temp.Find(_L8("\r\n")); + + if ( endcl != KErrNotFound ) + { + // not the last line in headers. + temp = temp.Mid(st+1, endcl - st); + } + else + { + temp = temp.Mid(st+1); + } + + temp.Trim(); + + TLex8 lex(temp); + TInt err = lex.Val(iBodySize); + + if(err == KErrNone) + { + iConsole.PrintNotify(_L("Getting body...\n")); + iDoCount = ETrue; + iStartTime.UniversalTime(); + iReceivedBytes = iBuffer.Length() - emptyLine - 4; + } + } + } + } + else + { + iReceivedBytes += iBuffer.Length(); + if (iProtocol == KProtocolInetUdp) + { + if (iUdpPacketCounter == 0) + iStartTime.UniversalTime(); // Start time calculation from the first received packet. + iUdpPacketCounter++; + if (iUdpPacketCounter == KMaximumPacketCount) + { + TBuf8<128> b(_L8("Got data\n")); + TInt ploss = CalculatePacketLoss(); + Utils::CalculateThroughput(b, iStartTime, iReceivedBytes); + iEngine.Disconnect(); + b.AppendFormat(_L8("Ploss: %d %%\n"),ploss); + iConsole.PrintNotify(b); + return; // do not issue any request. + } + else if (iUdpPacketCounter > KMaximumPacketCount) + { + iConsole.PrintNotify(_L8("Unexpected state\n")); + iEngine.Disconnect(); + iSocket.Close(); + return; + } + + } + } + + // Check if all the data has been received + if(iReceivedBytes == iBodySize) + { + // Throughput calculation + TBuf8<128> b(_L8("Got body\n")); + Utils::CalculateThroughput(b, iStartTime, iReceivedBytes); + iConsole.PrintNotify(b); + iHeaders.Zero(); + iDoCount = EFalse; + } + } + else + { + iConsole.PrintNotify(iBuffer); + } + + IssueRead(); // Immediately start another read + } + else + { + if( iStatus.Int() == KErrEof || + iStatus.Int() == KErrDisconnected || + iStatus.Int() == KErrCancel ) + { + TBuf<64> text(_L("HTTP Get Completed")); + iEngine.StopTickCount(text); + // Remote server closed the socket + if (iBodySize == 0) // We don't know how much we are expecting data so we calculate throughput here + { + iReceivedBytes += iBuffer.Length(); + // Throughput calculation + TBuf8<128> b(_L8("Got body\n")); + Utils::CalculateThroughput(b, iStartTime, iReceivedBytes); + iConsole.PrintNotify(b); + } + TBuf<64> note; + note.Format(_L("\nSocket closed: (%d)\n"), iStatus.Int()); + iEngine.Disconnect(); + iConsole.PrintNotify(note); + } + else if(iStatus.Int() == KErrTimedOut) + { + // LastSocketActivityTimeout has been elapsed + TBuf<64> note; + note.Copy(_L("\nLastSocketActivityTimeOut elapsed\n\n")); + iEngine.Disconnect(); + iConsole.PrintNotify(note); + } + else + { + // Error: pass it up to user interface + TBuf<50> err; + err.Format(_L("\nCSocketsRead error %d\n"), iStatus.Int()); + iConsole.PrintNotify(err); + } + iSocket.Close(); // error is always fatal. + } + } + +// --------------------------------------------------------- +// CSocketsRead::DoCancel() +// Cancel ongoing requests. +// --------------------------------------------------------- +// +void CSocketsRead::DoCancel() +{ + // Cancel asychronous read request + iSocket.CancelRead(); + // If we were accepting raw UDP-traffic, we should stop and analyse. + if (iBodySize == 0 && iProtocol == KProtocolInetUdp && iReceivedBytes != 0) + { + TBuf8<128> b(_L8("Got body\n")); + Utils::CalculateThroughput(b, iStartTime, iReceivedBytes); + iConsole.PrintNotify(b); + } +} + +// --------------------------------------------------------- +// CSocketsRead::CalculatePacketLoss() +// Calculates packet loss rate +// @return ploss percentage +// --------------------------------------------------------- +// +TInt32 CSocketsRead::CalculatePacketLoss() +{ + TUint32* seqNumberPointer = (TUint32*)(iBuffer.Ptr()); + TUint32 sequenceNumberOfThisPacket = ByteOrder::Swap32( *seqNumberPointer ); + if(sequenceNumberOfThisPacket != 0) + return (100 - (100 * iUdpPacketCounter) / sequenceNumberOfThisPacket); + else return 100; +} + +// EOF diff -r 000000000000 -r 857a3e953887 nettools/conntest/Engine/SocketsWrite.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/Engine/SocketsWrite.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,414 @@ +/* + * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: CSocketsWrite is an active object which implements data + * sending through an already open socket using UDP or TCP + * + */ + +// INCLUDE FILES +#include + +#include "SocketsWrite.h" +#include "TimeOutTimer.h" +#include "ConnTest.pan" +#include "uinotify.h" +#include "Utils.h" +#include "conntest.hrh" +#include "datasendnotifyhandler.h" + +// CONSTANTS +static const TInt KTimeOut = 30000000; // 30 seconds time-out + + +// --------------------------------------------------------- +// CSocketsWrite::NewL(MUINotify& aConsole, RSocket& aSocket, MDataSendNotifyHandler& aSendHandler) +// EPOC two phased constructor +// --------------------------------------------------------- +// +CSocketsWrite* CSocketsWrite::NewL( MUINotify& aConsole, + RSocket& aSocket, + MDataSendNotifyHandler& aSendHandler ) + { + CSocketsWrite* self = CSocketsWrite::NewLC(aConsole, aSocket, aSendHandler); + CleanupStack::Pop(self); + return self; + } + + +// --------------------------------------------------------- +// CSocketsWrite::NewLC(MUINotify& aConsole, RSocket& aSocket, MDataSendNotifyHandler& aSendHandler) +// EPOC two phased constructor +// --------------------------------------------------------- +// +CSocketsWrite* CSocketsWrite::NewLC( MUINotify& aConsole, + RSocket& aSocket, + MDataSendNotifyHandler& aSendHandler ) + { + CSocketsWrite* self = new (ELeave) CSocketsWrite(aConsole, aSocket, aSendHandler); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + + +// --------------------------------------------------------- +// CSocketsWrite::CSocketsWrite(MUINotify& aConsole, RSocket& aSocket, MDataSendNotifyHandler& aSendHandler) +// Constructor +// --------------------------------------------------------- +// +CSocketsWrite::CSocketsWrite( MUINotify& aConsole, + RSocket& aSocket, + MDataSendNotifyHandler& aSendHandler ): + CActive(EPriorityStandard), + iSocket(aSocket), + iConsole(aConsole), + iPackets(0), + iPacketSize(0), + iReqBodySubmitBufferPtr(0,0), + iSendHandler(aSendHandler) + { + } + + +// --------------------------------------------------------- +// CSocketsWrite::~CSocketsWrite() +// Destructor +// --------------------------------------------------------- +// +CSocketsWrite::~CSocketsWrite() + { + Cancel(); + delete iReqBodySubmitBuffer; + delete iTimer; + iTimer = NULL; + if(iTransferBuffer) + { + delete iTransferBuffer; + iTransferBuffer = NULL; + } + if(iWriteBuffer) + { + delete iWriteBuffer; + iWriteBuffer = NULL; + } + } + + +// --------------------------------------------------------- +// CSocketsWrite::ConstructL() +// EPOC two-phased constructor +// --------------------------------------------------------- +// +void CSocketsWrite::ConstructL() + { + CActiveScheduler::Add(this); + + iTransferBuffer = HBufC8::NewL(KMaxSendBuffer); + iWriteBuffer = HBufC8::NewL(KMaxSendBuffer); + + iTimeOut = KTimeOut; + iTimer = CTimeOutTimer::NewL(10, *this); + iWriteStatus = EWaiting; + } + + +// --------------------------------------------------------- +// CSocketsWrite::RunL() +// Called when request has completed. +// --------------------------------------------------------- +// +void CSocketsWrite::RunL() + { + if(!iFlood) + { + RDebug::Print(_L("ConnTest: CSocketsWrite::RunL - iStatus = %d"), iStatus.Int()); + } + // Active object request complete handler + if (iStatus == KErrNone) + { + switch(iWriteStatus) + { + // Character has been written to socket + case ESending: + if(!iFlood) + SendNextPacket(); + else + DoFloodWrite(); + break; + default: + User::Panic(KPanicSocketsWrite, EConnTestBadStatus); + break; + }; + } + else + { + // Error: pass it up to user interface + iTimer->Cancel(); + TBuf<50> err; + err.Format(_L("\nCSocketsWrite error %d\n"), iStatus.Int()); + //iConsole.ErrorNotify(_L("\nCSocketsWrite error"), iStatus.Int()); + iConsole.PrintNotify(err); + iWriteStatus = ECommsFailed; + } + } + + +// --------------------------------------------------------- +// CSocketsWrite::DoCancel() +// Cancel ongoing requests. +// --------------------------------------------------------- +// +void CSocketsWrite::DoCancel() + { + RDebug::Print(_L("CSocketsWrite::DoCancel")); + + // Cancel asychronous write request + iSocket.CancelWrite(); + + iTimer->Cancel(); + } + + +// --------------------------------------------------------- +// CSocketsWrite::IssueWriteL() +// Add data into buffer for sending. +// --------------------------------------------------------- +// +void CSocketsWrite::IssueWriteL(const TDesC8& aData, TInetAddr* aAddress, TUint aProtocol) + { + RDebug::Print(_L("ConnTest: CSocketsWrite::IssueWriteL - aData.Length = %d"), aData.Length()); + + iFlood = EFalse; + iAddress = aAddress; + iProtocol = aProtocol; + + // Write data to a stream socket + if ((aData.Length() + iTransferBuffer->Length()) > iTransferBuffer->Des().MaxLength()) + { + RDebug::Print(_L("ConnTest: CSocketsWrite::IssueWriteL - data doesn't fit in the transferbuffer")); + RDebug::Print( _L( + "ConnTest: CSocketsWrite::IssueWriteL - data length = %d, buffer length = %d, buffer max length = %d"), + aData.Length(), iTransferBuffer->Length(), iTransferBuffer->Des().MaxLength() ); + // Not enough space in buffer + User::Leave(KErrOverflow); + } + + // Add new data to buffer + iTransferBuffer->Des().Append(aData); + + if (!IsActive()) + { + SendNextPacket(); + } + } + +// --------------------------------------------------------- +// CSocketsWrite::IssueWriteL() +// Flood data over socket +// --------------------------------------------------------- +// +void CSocketsWrite::IssueWriteL( const TDesC8& aData, + TInetAddr* aAddress, + TUint aProtocol, + TInt aCount ) + { + RDebug::Print(_L("ConnTest: CSocketsWrite::IssueWriteL - flood, packet count=%d"), aCount); + RDebug::Print(_L("ConnTest: CSocketsWrite::IssueWriteL - aData.Length = %d"), aData.Length()); + iFlood = ETrue; + iCount = 0; + iPackets = aCount; + iPacketSize = aData.Length(); + + iAddress = aAddress; + iProtocol = aProtocol; + + // Write data to a stream socket + if (aData.Length() > iTransferBuffer->Des().MaxLength()) + { + // Not enough space in buffer + User::Leave(KErrOverflow); + } + + // Add new data to buffer + iTransferBuffer->Des().Zero(); + iTransferBuffer->Des().Append(aData); + iWriteBuffer->Des().Copy(*iTransferBuffer); + if (!IsActive()) + { + DoFloodWrite(); + } + } + +// ------------------------------------------------------------------------- +// CSocketsWrite::IssueWriteL() +// Add data into buffer for sending POST request, initializes body data. +// ------------------------------------------------------------------------- +// +void CSocketsWrite::IssueWriteL( const TDesC8& aData, + TInetAddr* aAddress, + TUint aProtocol, + TInt aPacketSize, + TInt aPackets ) + { + RDebug::Print(_L("ConnTest: CSocketsWrite::IssueWriteL - aData.Length = %d"), aData.Length()); + iFlood = EFalse; + + iPackets = aPackets; + iPacketSize = aPacketSize; + + delete iReqBodySubmitBuffer; + iReqBodySubmitBuffer = NULL; + iReqBodySubmitBuffer = HBufC8::NewMaxL(KSendDataSize); + iReqBodySubmitBufferPtr.Set(iReqBodySubmitBuffer->Des()); + + // Create body chunk + Utils::CreateDataChunk(iReqBodySubmitBufferPtr, iPacketSize); + iDataChunkCount = 0; + + IssueWriteL(aData, aAddress, aProtocol); + } + +// --------------------------------------------------------- +// CSocketsWrite::SendNextPacket() +// Write data from buffer to socket. +// --------------------------------------------------------- +// +void CSocketsWrite::SendNextPacket() + { + RDebug::Print(_L("ConnTest: CSocketsWrite::SendNextPacket - iTransferBuffer.Length = %d, iPackets = %d"), iTransferBuffer->Length(), iPackets); + + iTimer->Cancel(); // Cancel TimeOut timer + iWriteStatus = EWaiting; + + if (iTransferBuffer->Length() > 0) + { + // Move data from transfer buffer to actual write buffer + iWriteBuffer->Des().Copy(*iTransferBuffer); + iTransferBuffer->Des().Zero(); + + switch(iProtocol) + { + case KProtocolInetTcp: + iSocket.Write(*iWriteBuffer, iStatus); // Initiate actual write + break; + + case KProtocolInetUdp: + iSocket.SendTo(*iWriteBuffer, *iAddress, 0, iStatus); + break; + } + iSendHandler.NotifySend(iWriteBuffer->Length()); + // Request timeout + iTimer->After(iTimeOut); + SetActive(); + iWriteStatus = ESending; + } + else if(iPackets) + { + // We are sending body data, i.e. this is POST request + if(iDataChunkCount == 0) + { + iConsole.PrintNotify(_L("Sending body...\n")); + iSentBytes = 0; + iStartTime.UniversalTime(); + } + + TBool noMoreData = iDataChunkCount < iPackets ? EFalse : ETrue; + ++iDataChunkCount; + + if(noMoreData) + { + // Throughput calculation + TBuf8<128> b(_L8("Body sent\n")); + Utils::CalculateThroughput(b, iStartTime, iSentBytes); + + b.Append(_L("\n\n")); + iConsole.PrintNotify(b); + + iPackets = 0; + iPacketSize = 0; + iSentBytes = 0; + + return; + } + + iSentBytes += iReqBodySubmitBufferPtr.Length(); + iSocket.Write(iReqBodySubmitBufferPtr, iStatus); + SetActive(); + iWriteStatus = ESending; + + } + } + +// --------------------------------------------------------- +// CSocketsWrite::DoFloodWrite() +// Floods the data to the socket +// --------------------------------------------------------- +// +void CSocketsWrite::DoFloodWrite() + { + //RDebug::Print(_L("ConnTest: CSocketsWrite::DoFloodWrite: %d"),iCount); // eats CPU + iTimer->Cancel(); // Cancel TimeOut timer + iWriteStatus = EWaiting; + if (iCount != iPackets) + { + if( iTransferBuffer->Length() > 0) + { + switch(iProtocol) + { + case KProtocolInetTcp: + iSocket.Write(*iWriteBuffer, iStatus); // Initiate actual write + break; + + case KProtocolInetUdp: + { + TUint32* seqNumberPointer = (TUint32*)(iTransferBuffer->Des().Ptr()); + *seqNumberPointer = ByteOrder::Swap32( iCount ); // put sequence number into to the packet + iSocket.SendTo(*iTransferBuffer, *iAddress, 0, iStatus); + break; + } + default: + iConsole.ErrorNotify(_L("Unsupproted protocol\n\n"),KErrNotSupported ); + return; + } + + iCount++; + iTimer->After(iTimeOut); + SetActive(); + iWriteStatus = ESending; + } + } + else + { + iTransferBuffer->Des().Zero(); + iWriteBuffer->Des().Zero(); + iSendHandler.NotifySend(iPacketSize*iPackets); + iFlood = EFalse; + iCount = 0; + iPackets = 0; + iPacketSize = 0; + } + } + +// --------------------------------------------------------- +// CSocketsWrite::TimerExpired() +// Timeout, show error notification. +// --------------------------------------------------------- +// +void CSocketsWrite::TimerExpired() + { + Cancel(); + iWriteStatus = ECommsFailed; + iConsole.ErrorNotify(_L("Write operation timed out\n"), KErrTimedOut); + } + diff -r 000000000000 -r 857a3e953887 nettools/conntest/Engine/TimeOutTimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/Engine/TimeOutTimer.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CTimeOutTimer is used to generate time out events +* +*/ + +#include "TimeOutTimer.h" +#include "TimeOutNotify.h" + + +// --------------------------------------------------------- +// CTimeOutTimer::NewL(const TInt aPriority, MTimeOutNotify& aTimeOutNotify) +// EPOC two phased constructor +// --------------------------------------------------------- +// +CTimeOutTimer* CTimeOutTimer::NewL(const TInt aPriority, MTimeOutNotify& aTimeOutNotify) +{ + CTimeOutTimer* self = CTimeOutTimer::NewLC(aPriority, aTimeOutNotify); + CleanupStack::Pop(self); + return self; +} + + +// --------------------------------------------------------- +// CTimeOutTimer::NewLC(const TInt aPriority, MTimeOutNotify& aTimeOutNotify) +// EPOC two phased constructor +// --------------------------------------------------------- +// +CTimeOutTimer* CTimeOutTimer::NewLC(const TInt aPriority, MTimeOutNotify& aTimeOutNotify) +{ + CTimeOutTimer* self = new (ELeave) CTimeOutTimer(aPriority, aTimeOutNotify); + CleanupStack::PushL(self); + self->ConstructL(); + return self; +} + +// --------------------------------------------------------- +// CTimeOutTimer::CTimeOutTimer(const TInt aPriority, MTimeOutNotify& aTimeOutNotify) +// Constructor +// --------------------------------------------------------- +// +CTimeOutTimer::CTimeOutTimer(const TInt aPriority, MTimeOutNotify& aTimeOutNotify) +: CTimer(aPriority), iNotify(aTimeOutNotify) +{ +} + +// --------------------------------------------------------- +// CTimeOutTimer::~CTimeOutTimer() +// Destructor +// --------------------------------------------------------- +// +CTimeOutTimer::~CTimeOutTimer() +{ + Cancel(); +} + +// --------------------------------------------------------- +// CTimeOutTimer::ConstructL() +// EPOC two-phased constructor +// --------------------------------------------------------- +// +void CTimeOutTimer::ConstructL() +{ + CTimer::ConstructL(); + CActiveScheduler::Add(this); +} + +// --------------------------------------------------------- +// CTimeOutTimer::RunL() +// Timer event has been generated and timer request completed. +// --------------------------------------------------------- +// +void CTimeOutTimer::RunL() +{ + // Timer request has completed, so notify the timer's owner + iNotify.TimerExpired(); +} + diff -r 000000000000 -r 857a3e953887 nettools/conntest/Engine/alractiveobject.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/Engine/alractiveobject.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,204 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: conntest application +* +*/ + +/** +@file alractiveobject.cpp +ALR application active object. +*/ + +// INCLUDE FILES +#include +#include +#include +#include "alractiveobject.h" +#include "uinotify.h" + +using namespace ESock; + +const TInt KCommsMobilityMaxMsgLength = 256; //Max mobility message size is much less than that + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CALRActiveObject::NewL +// ----------------------------------------------------------------------------- +// +CALRActiveObject* CALRActiveObject::NewL( + MUINotify& aConsole, + MMobilityProtocolResp* aApplication) + { + CALRActiveObject* self = + new ( ELeave ) CALRActiveObject(aConsole, aApplication); + CleanupStack::PushL( self ); + self->ConstructL(aConsole); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CALRActiveObject::ConstructL +// ----------------------------------------------------------------------------- +// +void CALRActiveObject::ConstructL(MUINotify& /*aConsole*/) + { + iResponseBuf.CreateL( KCommsMobilityMaxMsgLength ); + } + +// ----------------------------------------------------------------------------- +// CALRActiveObject::CALRActiveObject +// ----------------------------------------------------------------------------- +// +CALRActiveObject::CALRActiveObject(MUINotify& aConsole, MMobilityProtocolResp* aApplication ) + : CActive( CActive::EPriorityStandard ), + iConsole(aConsole), iApplication(aApplication) + { + CActiveScheduler::Add( this ); + } + +// ----------------------------------------------------------------------------- +// CALRActiveObject::~CALRActiveObject +// ----------------------------------------------------------------------------- +// +CALRActiveObject::~CALRActiveObject() + { + Cancel(); + iExtApi.Close(); + iResponseBuf.Close(); + } + +// ----------------------------------------------------------------------------- +// CALRActiveObject::OpenL +// ----------------------------------------------------------------------------- +// +void CALRActiveObject::OpenL( RCommsSubSession& aExtensionProvider ) + { + User::LeaveIfError( iExtApi.Open( aExtensionProvider ) ); + + //iConsole.PrintNotify(_L("\r\nRegister for mobility notification ")); + + iExtApi.RegisterForMobilityNotification( iResponseBuf, iStatus ); + + //iConsole.PrintNotify(_L("\r\nRegistration successful ")); + + SetActive(); + } + +// ----------------------------------------------------------------------------- +// CALRActiveObject::MigrateToPreferredCarrier +// ----------------------------------------------------------------------------- +// +void CALRActiveObject::MigrateToPreferredCarrier() + { + iExtApi.MigrateToPreferredCarrier(); + } + +// ----------------------------------------------------------------------------- +// CALRActiveObject::IgnorePreferredCarrier +// ----------------------------------------------------------------------------- +// +void CALRActiveObject::IgnorePreferredCarrier() + { + iExtApi.IgnorePreferredCarrier(); + } + +// ----------------------------------------------------------------------------- +// CALRActiveObject::NewCarrierAccepted +// ----------------------------------------------------------------------------- +// +void CALRActiveObject::NewCarrierAccepted() + { + iExtApi.NewCarrierAccepted(); + } + +// ----------------------------------------------------------------------------- +// CALRActiveObject::NewCarrierRejected +// ----------------------------------------------------------------------------- +// +void CALRActiveObject::NewCarrierRejected() + { + iExtApi.NewCarrierRejected(); + } + +// ----------------------------------------------------------------------------- +// CALRActiveObject::RunL +// ----------------------------------------------------------------------------- +// +void CALRActiveObject::RunL() + { + if( iStatus != KErrNone ) + { + // iConsole.Printf(_L("\niStatus: %i\n"), iStatus.Int() ); + iApplication->Error( iStatus.Int() ); +// virtual void Error(TInt aError) = 0; + + return; + } + + //iConsole.PrintNotify(_L("\r\nReceived notification")); + CCommsApiExtensionMsg* msg = CCommsApiExtensionMsg::NewL( iResponseBuf ); + + //check types + STypeId preferredCarrierAvailableTID = STypeId::CreateSTypeId( ESock::KMobilityMessagesImplementationUid, ESock::EPreferredCarrierAvailable ); + STypeId newCarrierActiveTID = STypeId::CreateSTypeId( ESock::KMobilityMessagesImplementationUid, ESock::ENewCarrierActive ); + + if (msg->IsTypeOf(preferredCarrierAvailableTID)) + { + CPreferredCarrierAvailable& pca = reinterpret_cast( *msg ); + iApplication->PreferredCarrierAvailable( pca.OldAPInfo(), + pca.NewAPInfo(), + pca.IsUpgrade(), + pca.IsSeamless() ); +// virtual void PreferredCarrierAvailable(TAccessPointInfo aOldAP, TAccessPointInfo aNewAP, TBool aIsUpgrade, TBool aIsSeamless) = 0; + + //MigrateToPreferredCarrier(); + } + else if (msg->IsTypeOf(newCarrierActiveTID)) + { + CNewCarrierActive& nca = reinterpret_cast( *msg ); + iApplication->NewCarrierActive( nca.NewAPInfo(), nca.IsSeamless() ); +// virtual void NewCarrierActive(TAccessPointInfo aNewAP, TBool aIsSeamless) = 0; + //NewCarrierAccepted(); + } + + delete msg; + + iExtApi.RegisterForMobilityNotification( iResponseBuf, iStatus ); + + SetActive(); + } + +// ----------------------------------------------------------------------------- +// CALRActiveObject::DoCancel +// ----------------------------------------------------------------------------- +// +void CALRActiveObject::DoCancel() + { + iExtApi.CancelMobilityNotification(); + } + +// ----------------------------------------------------------------------------- +// CALRActiveObject::RunError +// ----------------------------------------------------------------------------- +// +TInt CALRActiveObject::RunError(TInt aError) + { + //The notification has not been sent to the client because of KErrNoMemory + //We may need to provide an inplace construction for the messages to exclude this possibility. + return aError; + } + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/Engine/ipdumpengine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/Engine/ipdumpengine.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,167 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CIpdumpEngine is used to control the ip logging protocol +* +*/ + +#include +#include +#include "ipdumpengine.h" + + +// +// CIpdumpEngine. +// + +CIpdumpEngine* CIpdumpEngine::NewL() +{ + CIpdumpEngine* self = new (ELeave) CIpdumpEngine(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; +} + +CIpdumpEngine::CIpdumpEngine() +: iLoggingEnabled(EFalse) +{ + // If changed change the filename also + // in the ip logging protocol to match + _LIT(KLogFilePath, "c:\\logs\\tcpdump\\probe.cap"); + iLogFileName.Append(KLogFilePath); +} + +// This is to get around of the restrictions of the secure file system, +// when the conntest and the probe are installed from a sis +// You cannot install the esk to the right place directly, so copy it here +// Requires all files capability +_LIT(KIpDumpEskImport, "\\private\\101f7989\\import\\esock\\ip.probe.esk"); +_LIT(KIpDumpEskEsock, "\\private\\101f7989\\esock\\ip.probe.esk"); + +void AttemptToCopyEskFile() + { + RFs fs; + TInt err = fs.Connect(); + + if (err) + { + return; + } + + CFileMan* fileman = NULL; + TRAP(err, fileman = CFileMan::NewL(fs)); + + if (err) + { + fs.Close(); + return; + } + + (void)fileman->Copy(KIpDumpEskImport, KIpDumpEskEsock, CFileMan::ERecurse); + + delete fileman; + fs.Close(); + } + +void CIpdumpEngine::ConstructL() +{ + AttemptToCopyEskFile(); +} + + +CIpdumpEngine::~CIpdumpEngine() +{ + DisableLogging(); +} + + + +TInt CIpdumpEngine::CreateLogDirectory() +{ + + RFs fs; + TInt r; + + r = fs.Connect(); + + if(r==KErrNone) + { + + // Delete the old log file. After disabling the logging the file + // is in use for short period of time, therefore doing the deletion + // in loop to avoid error message in UI. + while((r = fs.Delete(iLogFileName)) == KErrInUse) + User::After(1); + + if(r == KErrNotFound || r == KErrPathNotFound) + { + r = fs.MkDirAll(iLogFileName); + r = (r==KErrAlreadyExists) ? KErrNone : r; + } + } + + fs.Close(); + return r; +} + + + + +void CIpdumpEngine::EnableLoggingL() +{ + + if(iLoggingEnabled) + { + return; + } + + User::LeaveIfError(CreateLogDirectory()); + + User::LeaveIfError(iSocketServ.Connect()); + + TProtocolDesc protocol; + TProtocolName name(_S("probe")); + + User::LeaveIfError(iSocketServ.FindProtocol(name, protocol)); + + User::LeaveIfError(iSocket.Open(iSocketServ, name)); + + iLoggingEnabled = ETrue; + + return; +} + +void CIpdumpEngine::DisableLogging() +{ + if(iLoggingEnabled) + { + iSocket.Close(); + iSocketServ.Close(); + + iLoggingEnabled = EFalse; + } +} + +TBool CIpdumpEngine::LoggingEnabled() const +{ + + return iLoggingEnabled; +} + +const TDesC& CIpdumpEngine::LogFileName() const +{ + return iLogFileName; +} + + diff -r 000000000000 -r 857a3e953887 nettools/conntest/aif/ConnTestaif.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/aif/ConnTestaif.rss Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Resource file to create the ConnTest aif file +* +*/ + +#include + +RESOURCE AIF_DATA + { + app_uid=0x101F6D2B; + num_icons=2; + embeddability=KAppNotEmbeddable; + //newfile=KAppDoesNotSupportNewFile; + newfile=KAppSupportsNewFile; + } + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/aif/context_pane_icon.bmp Binary file nettools/conntest/aif/context_pane_icon.bmp has changed diff -r 000000000000 -r 857a3e953887 nettools/conntest/aif/context_pane_icon_mask.bmp Binary file nettools/conntest/aif/context_pane_icon_mask.bmp has changed diff -r 000000000000 -r 857a3e953887 nettools/conntest/aif/list_icon.bmp Binary file nettools/conntest/aif/list_icon.bmp has changed diff -r 000000000000 -r 857a3e953887 nettools/conntest/aif/list_icon_mask.bmp Binary file nettools/conntest/aif/list_icon_mask.bmp has changed diff -r 000000000000 -r 857a3e953887 nettools/conntest/data/ConnTest.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/data/ConnTest.rss Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,1109 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The resource for ConnTest +* +*/ + +// RESOURCE IDENTIFIER +NAME AWIZ // 4 letter ID + +// INCLUDES +#include +#include "ConnTest.rh" +#include "conntest.hrh" +#include "conntest.loc" +#include +#include +#include +#include + +#include + +// CONSTANTS + +// for Text Setting Page +#define TEXT_SETTING_PAGE_NUMBER 1 +#define TEXT_SETTING_PAGE_WIDTH 9 +#define TEXT_SETTING_PAGE_LINES 5 +#define TEXT_SETTING_PAGE_MAXLENGTH 50 + + +// MACROS +//#define ?macro + + +// RESOURCE DEFINITIONS + +RESOURCE RSS_SIGNATURE { } + +RESOURCE TBUF { buf="\\private\\101F6D2B\\ConnTest"; } + +RESOURCE EIK_APP_INFO + { + status_pane = r_conntest_status_pane; + } + +//---------------------------------------------------- +// +// r_conntest_hotkeys +// ?description +// +//---------------------------------------------------- +// +RESOURCE HOTKEYS r_conntest_hotkeys + { + control= + { + HOTKEY { command=EAknCmdExit; key='e'; } + }; + } + +//---------------------------------------------------- +// +// r_conntest_view1 +// ?description +// +//---------------------------------------------------- +// +RESOURCE AVKON_VIEW r_conntest_view1 + { + hotkeys=r_conntest_hotkeys; + menubar=r_conntest_menubar_view1; + //cba=R_AVKON_SOFTKEYS_SELECTION_LIST; + cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT; + } + + +//---------------------------------------------------- +// +// r_conntest_menubar_view1 +// ?description +// +//---------------------------------------------------- +// +RESOURCE MENU_BAR r_conntest_menubar_view1 + { + titles= + { + MENU_TITLE { menu_pane=r_conntest_app_menu; txt="App"; }, + MENU_TITLE { menu_pane=r_conntest_view1_menu; txt="View"; } + }; + } + +//---------------------------------------------------- +// +// r_conntest_view1_menu +// ?description +// +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_conntest_view1_menu + { + items= + { + MENU_ITEM { command=EConnTestCmdMigrate; txt = "Migrate"; }, + + MENU_ITEM { command=EConnTestCmdIgnore; txt = "Ignore"; }, + + MENU_ITEM { command=EConnTestCmdAccept; txt = "Accept"; }, + + MENU_ITEM { command=EConnTestCmdReject; txt = "Reject"; }, + + MENU_ITEM { command=EConnTestCmdCancel; txt = "Cancel"; }, + + MENU_ITEM { command=EConnTestCmdStartInterface; txt = "Start interface";}, + + MENU_ITEM { command=EConnTestCmdStopInterface; txt = "Stop interface"; }, + + MENU_ITEM { command=EConnTestCmdStartInternet; txt = "Start Internet";}, + + MENU_ITEM { command=EConnTestCmdConnect; txt = "Connect"; }, + + MENU_ITEM { command=EConnTestCmdListen; txt = "Listen"; }, + + MENU_ITEM { command=EConnTestCmdDisconnect; txt = "Disconnect"; }, + + MENU_ITEM { command = EConnTestCmdClearOutputWindow; txt = "Clear output"; }, + + MENU_ITEM { command=EConnTestCmdSendRawData; txt = "Send"; + cascade=r_conntest_sub_menu_send; }, + + MENU_ITEM { command=EConnTestWlanDir; txt = "WLAN"; cascade=r_conntest_sub_menu_wlan;}, + + MENU_ITEM { command=EConnTestCmdConnectionInfo; txt = "Info"; + cascade=r_conntest_sub_menu_info;}, + + MENU_ITEM { command=EConnTestCmdHttpFrameworkGet; txt = "HTTP framework"; + cascade=r_conntest_sub_menu_http_fw; }, + + MENU_ITEM { command=EConnTestCmdAdvanced; txt = "Advanced"; + cascade=r_conntest_sub_menu_advanced;}, + + MENU_ITEM { command = EConnTestCmdIpLog; txt = "IP packet logging"; + cascade=r_conntest_sub_menu_ipdump;}, + + MENU_ITEM { command=EConnTestCmdSettings; txt = "Settings"; } + }; + } + +RESOURCE MENU_PANE r_conntest_sub_menu_wlan + { + items= + { + MENU_ITEM { command=EConnTestWlanAvailableIaps; txt = "Available IAPs"; }, + + MENU_ITEM { command=EConnTestWlanScan; txt = "Scan"; }, + + MENU_ITEM { command=EConnTestWlanGetSsid; txt = "Get SSID"; }, + + MENU_ITEM { command=EConnTestWlanGetBssid; txt = "Get BSSID"; }, + + MENU_ITEM { command=EConnTestWlanGetRssi; txt = "Get RSSI"; }, + + MENU_ITEM { command=EConnTestWlanGetConnMode; txt = "Get Mode"; }, + + MENU_ITEM { command=EConnTestWlanGetSecurityMode; txt = "Get Security"; } + }; + } + + + +RESOURCE MENU_PANE r_conntest_sub_menu_info + { + items= + { + MENU_ITEM + { + command = EConnTestCmdConnectionInfo; + txt = "Connection info"; + }, + MENU_ITEM + { + command = EConnTestCmdInterfaceInfo; + txt = "Interface info"; + } + }; + } + +RESOURCE MENU_PANE r_conntest_sub_menu_advanced + { + items= + { + MENU_ITEM + { + command=EConnTestCmdStartSnap; + txt = "Start Snap"; + }, + MENU_ITEM + { + command = EConnTestCmdStartInterfaceNoPrefs; + txt = "Start, no prefs"; + }, + MENU_ITEM + { + command = EConnTestCmdSetCustomPrefs; + txt = "Set custom prefs"; + }, + MENU_ITEM + { + command = EConnTestCmdStartInterfaceExtConnPrefs; + txt = "Start, custom prefs"; + }, + MENU_ITEM + { + command = EConnTestCmdStartForClose; + txt = "Start, test Close"; + }, + MENU_ITEM + { + command = EConnTestCmdCloseInterface; + txt = "RConnection::Close"; + }, + MENU_ITEM + { + command = EConnTestCmdConnectionPrefsIap; + txt = "ConnPrefs IapId"; + }, + MENU_ITEM + { + command = EConnTestCmdClearOutputWindow; + txt = "Timeouts"; + cascade=r_conntest_sub_menu_timeout; + flags = EEikMenuItemSeparatorAfter; + }, + MENU_ITEM + { + command = EConnTestCmdWLANQoSVoice; + txt = "WLAN QoS"; + cascade=r_conntest_sub_menu_wlanqos; + flags = EEikMenuItemSeparatorAfter; + }, + MENU_ITEM + { + command = EConnTestCmdParallelGet; + txt = "Parallel GET"; + } + }; + } + +RESOURCE MENU_PANE r_conntest_sub_menu_ipdump + { + items= + { + MENU_ITEM + { + command = EConnTestCmdStartIpLog; + txt = "Start logging"; + }, + MENU_ITEM + { + command = EConnTestCmdStopIpLog; + txt = "Stop logging"; + }, + MENU_ITEM + { + command = EConnTestCmdSendIpLog; + txt = "Send log"; + } + }; + } + + +RESOURCE MENU_PANE r_conntest_sub_menu_send + { + items= + { + MENU_ITEM + { + command = EConnTestCmdSendHttpGet; + txt = "HTTP GET"; + }, + MENU_ITEM + { + command = EConnTestCmdSendPerformanceHttpGet; + txt = "Performance GET"; + }, + MENU_ITEM + { + command = EConnTestCmdSendHttpPost; + txt = "Performance POST"; + }, + MENU_ITEM + { + command = EConnTestCmdSendRawData; + txt = "Raw data"; + } + }; + } + +RESOURCE MENU_PANE r_conntest_sub_menu_http_fw + { + items= + { + MENU_ITEM + { + command = EConnTestCmdHttpFrameworkGet; + txt = "HTTP Get"; + }, + //MENU_ITEM + // { + // command = EConnTestCmdHttpFrameworkPost; + // txt = "Post"; + // }, + MENU_ITEM + { + command = EConnTestCmdHttpFrameworkSecureGet; + txt = "HTTPS Get"; + }, + MENU_ITEM + { + command = EConnTestCmdHttpFrameworkPerformanceGet; + txt = "Performance GET"; + }, + MENU_ITEM + { + command = EConnTestCmdHttpFrameworkPerformancePost; + txt = "Performance POST"; + } + }; + } + +RESOURCE MENU_PANE r_conntest_sub_menu_timeout + { + items= + { + MENU_ITEM + { + command = EConnTestCmdTimeoutLastSocketActivity; + txt = "LastSocketActivity"; + }, + MENU_ITEM + { + command = EConnTestCmdTimeoutLastSocketClosed; + txt = "LastSocketclosed"; + }, + MENU_ITEM + { + command = EConnTestCmdTimeoutLastSessionClosed; + txt = "LastSessionClosed"; + } + }; + } + +RESOURCE MENU_PANE r_conntest_sub_menu_wlanqos + { + items= + { + MENU_ITEM + { + command = EConnTestCmdWLANQoSVoice; + txt = "Voice"; + }, + MENU_ITEM + { + command = EConnTestCmdWLANQoSVideo; + txt = "Video"; + }, + MENU_ITEM + { + command = EConnTestCmdWLANQoSBestEffort; + txt = "Best Effort"; + }, + MENU_ITEM + { + command = EConnTestCmdWLANQoSBackground; + txt = "Background"; + }, + MENU_ITEM + { + command = EConnTestCmdWLANQoSNone; + txt = "None"; + } + }; + } + + + +RESOURCE MENU_PANE r_conntest_sub_menu_qos + { + items= + { + MENU_ITEM + { + command = EConnTestCmdQoS1; + txt = "Join"; + } + }; + } + + +//---------------------------------------------------- +// +// r_conntest_app_menu +// ?description +// +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_conntest_app_menu + { + items= + { + //MENU_ITEM { command=EAknCmdExit; txt = qtn_appl_option_item; }, + MENU_ITEM { command=EAknCmdExit; txt="Exit"; } + }; + } + +RESOURCE STATUS_PANE_APP_MODEL r_conntest_status_pane + { + panes= + { + SPANE_PANE + { + id = EEikStatusPaneUidNavi; + type = EAknCtNaviPane; + resource = r_conntest_navi_decorator; + } + }; + } + +//---------------------------------------------------- +// +// r_conntest_navi_decorator +// ?description +// +//---------------------------------------------------- +// +RESOURCE NAVI_DECORATOR r_conntest_navi_decorator + { + type = ENaviDecoratorControlTabGroup; + control = TAB_GROUP + { + tab_width = EAknTabWidthWithFourTabs; // four tabs + active = 0; + tabs = { + TAB + { + id = EConnTestView1Tab; // from application hrh + txt = "1"; + }, + TAB + { + id = EConnTestView2Tab; // from application hrh + txt = "2"; + }, + TAB + { + id = EConnTestView3Tab; + txt = "3"; + }, + TAB + { + id = EConnTestView4Tab; + txt = "4"; + } + }; + }; + } + +//---------------------------------------------------- +// +// r_conntest_custom_prefs_list +// Custom Preferences list +// +//---------------------------------------------------- +// +RESOURCE AVKON_SETTING_ITEM_LIST r_conntest_custom_prefs_list + { + flags= EAknSettingItemNumberedStyle; + title = "custom_prefs"; + initial_number = 1; + items = + { + AVKON_SETTING_ITEM + { + identifier = EConnTestExtConnPrefsItemSnapPurpose; + setting_page_resource = r_conntest_enumtext_setting_page; + associated_resource = r_conntest_snap_purpose_list; + name = "SnapPurpose"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestExtConnPrefsItemSnapId; + setting_page_resource = r_conntest_integer_setting_page; + name = "SnapId"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestExtConnPrefsItemIapId; + setting_page_resource = r_conntest_integer_setting_page; + name = "IapId"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestExtConnPrefsItemBearerSet; + setting_page_resource = r_conntest_enumtext_setting_page; + associated_resource = r_conntest_bearer_set_list; + name = "BearerSet"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestExtConnPrefsItemNoteBehaviour; + setting_page_resource = r_conntest_enumtext_setting_page; + associated_resource = r_conntest_note_behaviour_list; + name = "NoteBehaviour"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestExtConnPrefsItemConnSelectionDialog; + setting_page_resource = r_conntest_binary_switch_setting_page; + associated_resource = r_conntest_conn_selection_dialog_list; + name = "SelectionDialog"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestExtConnPrefsItemDisconnectDialog; + setting_page_resource = r_conntest_binary_switch_setting_page; + associated_resource = r_conntest_disconnect_dialog_list; + name = "DisconnectDialog"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestExtConnPrefsItemForcedRoaming; + setting_page_resource = r_conntest_binary_switch_setting_page; + associated_resource = r_conntest_forced_roaming_list; + name = "ForcedRoaming"; + } + }; + } + +//---------------------------------------------------- +// +// r_conntest_setting_list +// Setting list +// +//---------------------------------------------------- +// +RESOURCE AVKON_SETTING_ITEM_LIST r_conntest_setting_list + { + flags= EAknSettingItemNumberedStyle; + title = "not_shown"; + initial_number = 1; + items = + { + AVKON_SETTING_ITEM + { + identifier = EConnTestRoaming; + setting_page_resource = r_conntest_enumtext_setting_page; + associated_resource = r_conntest_roaming_setting_list; + name = "Roaming"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestIpAddress; + setting_page_resource = r_conntest_text_setting_page; + name = "IP address"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestPort; + setting_page_resource = r_conntest_integer_setting_page; + name = "Port"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestHttpPage; + setting_page_resource = r_conntest_text_setting_page; + name = "HTTP page"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestProtocol; + setting_page_resource = r_conntest_enumtext_setting_page; + associated_resource = r_conntest_protocol_setting_list; + name = "Protocol"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestPacketSize; + setting_page_resource = r_conntest_integer_setting_page; + name = "Packet size (<16384)"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestPackets; + setting_page_resource = r_conntest_integer_setting_page; + name = "Number of packets"; + }, + AVKON_SETTING_ITEM + { + identifier = EConnTestDelay; + setting_page_resource = r_conntest_integer_setting_page; + name = "Delay (ms)"; + } + }; + } + +//---------------------------------------------------------------- + +RESOURCE AVKON_POPUP_SETTING_TEXTS r_conntest_snap_purpose_list + { + setting_texts_resource = r_conntest_snap_purpose_page_list; + popped_up_texts_resource = r_conntest_snap_purpose_list_item_array; + } + +RESOURCE ARRAY r_conntest_snap_purpose_page_list + { + items = + { + AVKON_ENUMERATED_TEXT + { + value = 0; + text = "Unknown"; + }, + AVKON_ENUMERATED_TEXT + { + value = 1; + text = "Internet"; + }, + AVKON_ENUMERATED_TEXT + { + value = 2; + text = "Operator"; + }, + AVKON_ENUMERATED_TEXT + { + value = 3; + text = "MMS"; + }, + AVKON_ENUMERATED_TEXT + { + value = 4; + text = "Intranet"; + } + }; + } + +RESOURCE ARRAY r_conntest_snap_purpose_list_item_array + { + items = + { + LBUF + { + txt = "Unknown"; + }, + LBUF + { + txt = "Internet"; + }, + LBUF + { + txt = "Operator"; + }, + LBUF + { + txt = "MMS"; + }, + LBUF + { + txt = "Intranet"; + } + }; + } + +//---------------------------------------------------------------- + +RESOURCE AVKON_POPUP_SETTING_TEXTS r_conntest_bearer_set_list + { + setting_texts_resource = r_conntest_bearer_set_page_list; + popped_up_texts_resource = r_conntest_bearer_set_list_item_array; + } + +RESOURCE ARRAY r_conntest_bearer_set_page_list + { + items = + { + AVKON_ENUMERATED_TEXT + { + value = 0; + text = "Unknown"; + }, + AVKON_ENUMERATED_TEXT + { + value = 1; + text = "Cellular"; + }, + AVKON_ENUMERATED_TEXT + { + value = 2; + text = "WLAN"; + } + }; + } + +RESOURCE ARRAY r_conntest_bearer_set_list_item_array + { + items = + { + LBUF + { + txt = "Unknown"; + }, + LBUF + { + txt = "Cellular"; + }, + LBUF + { + txt = "WLAN"; + } + }; + } + +//---------------------------------------------------------------- + +RESOURCE AVKON_POPUP_SETTING_TEXTS r_conntest_note_behaviour_list + { + setting_texts_resource = r_conntest_note_behaviour_page_list; + popped_up_texts_resource = r_conntest_note_behaviour_list_item_array; + } + +RESOURCE ARRAY r_conntest_note_behaviour_page_list + { + items = + { + AVKON_ENUMERATED_TEXT + { + value = 0; + text = "Default"; + }, + AVKON_ENUMERATED_TEXT + { + value = 1; + text = "Disable notes"; + }, + AVKON_ENUMERATED_TEXT + { + value = 2; + text = "Disable Queries"; + }, + AVKON_ENUMERATED_TEXT + { + value = 3; + text = "Silent"; + } + }; + } + +RESOURCE ARRAY r_conntest_note_behaviour_list_item_array + { + items = + { + LBUF + { + txt = "Default"; + }, + LBUF + { + txt = "Disable notes"; + }, + LBUF + { + txt = "Disable queries"; + }, + LBUF + { + txt = "Silent"; + } + }; + } + +//---------------------------------------------------------------- + +RESOURCE AVKON_POPUP_SETTING_TEXTS r_conntest_disconnect_dialog_list + { + setting_texts_resource = r_conntest_disconnect_dialog_page_list; + } + +RESOURCE ARRAY r_conntest_disconnect_dialog_page_list + { + items = + { + AVKON_ENUMERATED_TEXT + { + value = 0; + text = "Disabled"; + }, + AVKON_ENUMERATED_TEXT + { + value = 1; + text = "Enabled"; + } + }; + } + + +//---------------------------------------------------------------- + +RESOURCE AVKON_POPUP_SETTING_TEXTS r_conntest_conn_selection_dialog_list + { + setting_texts_resource = r_conntest_conn_selection_dialog_page_list; + } + +RESOURCE ARRAY r_conntest_conn_selection_dialog_page_list + { + items = + { + AVKON_ENUMERATED_TEXT + { + value = 0; + text = "Disabled"; + }, + AVKON_ENUMERATED_TEXT + { + value = 1; + text = "Enabled"; + } + }; + } + + +//---------------------------------------------------------------- + +RESOURCE AVKON_POPUP_SETTING_TEXTS r_conntest_forced_roaming_list + { + setting_texts_resource = r_conntest_forced_roaming_page_list; + } + +RESOURCE ARRAY r_conntest_forced_roaming_page_list + { + items = + { + AVKON_ENUMERATED_TEXT + { + value = 0; + text = "Disabled"; + }, + AVKON_ENUMERATED_TEXT + { + value = 1; + text = "Enabled"; + } + }; + } + +//---------------------------------------------------------------- + +RESOURCE AVKON_POPUP_SETTING_TEXTS r_conntest_roaming_setting_list + { + setting_texts_resource = r_conntest_roaming_page_list; + popped_up_texts_resource = r_conntest_roaming_list_item_array; + } + +RESOURCE ARRAY r_conntest_roaming_page_list + { + items = + { + AVKON_ENUMERATED_TEXT + { + value = 0; + text = "Off"; + }, + AVKON_ENUMERATED_TEXT + { + value = 1; + text = "Automatic"; + }, + AVKON_ENUMERATED_TEXT + { + value = 2; + text = "Manual"; + } + }; + } + +RESOURCE ARRAY r_conntest_roaming_list_item_array + { + items = + { + LBUF + { + txt = "Off"; + }, + LBUF + { + txt = "Automatic"; + }, + LBUF + { + txt = "Manual"; + } + }; + } + +//---------------------------------------------------------------------------- + +RESOURCE AVKON_POPUP_SETTING_TEXTS r_conntest_protocol_setting_list + { + setting_texts_resource = r_conntest_protocol_page_list; + popped_up_texts_resource = r_conntest_protocol_list_item_array; + } + +RESOURCE ARRAY r_conntest_protocol_page_list + { + items = + { + AVKON_ENUMERATED_TEXT + { + value = 0; + text = "TCP"; + }, + AVKON_ENUMERATED_TEXT + { + value = 1; + text = "UDP"; + } + }; + } + +RESOURCE ARRAY r_conntest_protocol_list_item_array + { + items = + { + LBUF + { + txt = "TCP/IP"; + }, + LBUF + { + txt = "UDP/IP"; + } + }; + } + + +//---------------------------------------------------------------------------- +// +// r_conntest_enumtext_setting_page +// Setting page for enumerations +// +//---------------------------------------------------------------------------- +// +RESOURCE AVKON_SETTING_PAGE r_conntest_enumtext_setting_page + { + number= 1; + label= qtn_conntest_enumtext_title; + type = EAknCtPopupSettingList; + editor_resource_id = r_conntest_popup_setting_list_new_entry; + } + +RESOURCE POPUP_SETTING_LIST r_conntest_popup_setting_list_new_entry + { + //flags = EAknPopupSettingListFlagAllowsUserDefinedEntry; + } + +//---------------------------------------------------------------------------- +// +// r_conntest_integer_setting_page +// Setting page for integers +// +//---------------------------------------------------------------------------- +// +RESOURCE AVKON_SETTING_PAGE r_conntest_integer_setting_page + { + number = 1; + //label = "Port"; + type = EAknCtIntegerEdwin; + editor_resource_id = r_conntest_integer; + } + +RESOURCE AVKON_INTEGER_EDWIN r_conntest_integer + { + min=0; + } + + +//---------------------------------------------------------------------------- +// +// r_conntest_binary_switch_setting_page +// Setting page for binary values +// +//---------------------------------------------------------------------------- +// +RESOURCE AVKON_SETTING_PAGE r_conntest_binary_switch_setting_page + { + number= 1; + label= "Binary switch"; + type = EAknCtPopupSettingList; + editor_resource_id = r_conntest_popup_setting_list_new_entry; + } + +//----------------------------------------------------------------------------- +// +// r_conntest_text_setting_page +// Setting page for text +// +//----------------------------------------------------------------------------- +// +RESOURCE AVKON_SETTING_PAGE r_conntest_text_setting_page + { + number = 1; + type = EEikCtEdwin; + editor_resource_id = r_conntest_edwin; + } + + +RESOURCE EDWIN r_conntest_edwin + { + width = TEXT_SETTING_PAGE_WIDTH ; + lines = TEXT_SETTING_PAGE_LINES; + maxlength = TEXT_SETTING_PAGE_MAXLENGTH; + } + +//----------------------------------------------------------------------------- +// +// r_aknatquery_number_layout +// Resource of Number Query. +// +//----------------------------------------------------------------------------- +// +RESOURCE DIALOG r_conntest_number_layout + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control= AVKON_DATA_QUERY + { + layout = ENumberLayout; + label = qtn_aknatquery_num_label_text; + control = AVKON_INTEGER_EDWIN + { + min = -1; + max = 1000000; + }; + }; + } + }; + } + +//----------------------------------------------------------------------------- +// +// r_aknatquery_number_layout +// Resource of Number Query. +// +//----------------------------------------------------------------------------- +// +RESOURCE DIALOG r_conntest_parallel_number_layout + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control= AVKON_DATA_QUERY + { + layout = ENumberLayout; + label = qtn_aknatquery_num_label_text; + control = AVKON_INTEGER_EDWIN + { + min = 0; + max = 4; // Max 4 parallel HTTP gets + }; + }; + } + }; + } + +// Add a new resource definition +RESOURCE LOCALISABLE_APP_INFO r_conntest_localisable_app_info + { + short_caption = "ConnTest"; + caption_and_icon = + CAPTION_AND_ICON_INFO + { + caption = "ConnTest"; + number_of_icons = 2; + icon_file = APP_BITMAP_DIR"\\ConnTest_aif.mbm"; + }; + } + + //icon_file = "Z:\\resource\\apps\\localisablefiles\\ConnTest_aif.mbm"; +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/data/ConnTest_caption.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/data/ConnTest_caption.rss Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The caption resource for Conntest +* +*/ + +#include "conntest.loc" +#include + +RESOURCE CAPTION_DATA +{ + caption=qtn_app_caption_string; + shortcaption=qtn_app_short_caption_string; +} diff -r 000000000000 -r 857a3e953887 nettools/conntest/data/ConnTest_reg.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/data/ConnTest_reg.rss Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The registration resource for ConnTest +* +*/ + +#include +#include + +UID2 KUidAppRegistrationResourceFile +UID3 0x101F6D2B // application UID + +RESOURCE APP_REGISTRATION_INFO + { + app_file="ConnTest"; // filename of application binary (minus extension) + localisable_resource_file = "\\resource\\apps\\ConnTest"; + localisable_resource_id = R_CONNTEST_LOCALISABLE_APP_INFO; + group_name = "RnD Tools"; + } + +// localisable_resource_file = "\\resource\\apps\\localisablefiles\\ConnTest"; diff -r 000000000000 -r 857a3e953887 nettools/conntest/group/ConnTest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/group/ConnTest.mmp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This is the project specification file for ConnTest. +* +*/ + +#include +#include + +TARGET ConnTest.exe +TARGETTYPE exe +EPOCSTACKSIZE 0x10000 +EPOCHEAPSIZE 0x2000 0x200000 + + +UID 0x100039CE 0x101F6D2B + +//TARGETPATH /system/apps/ConnTest + +VENDORID VID_DEFAULT +CAPABILITY LocalServices NetworkServices ReadUserData UserEnvironment WriteUserData PowerMgmt ProtServ ReadDeviceData TrustedUI WriteDeviceData NetworkControl CommDD AllFiles + +LANG SC + +SOURCEPATH ../src +SOURCE ConnTestApp.cpp +SOURCE ConnTestAppUi.cpp +SOURCE ConnTestDocument.cpp +SOURCE ConnTestContainer.cpp +SOURCE ConnTestView.cpp +SOURCE SettingItemList.cpp +SOURCE SettingData.cpp +SOURCE CustomPrefsItemList.cpp +SOURCE CustomPrefsData.cpp +SOURCE Utils.cpp + +SOURCEPATH ../Engine +SOURCE SocketsEngine.cpp +SOURCE SocketsWrite.cpp +SOURCE SocketsRead.cpp +SOURCE ProgressNotifier.cpp +SOURCE TimeOutTimer.cpp +SOURCE SendTimer.cpp +SOURCE HttpHandler.cpp +SOURCE ipdumpengine.cpp +SOURCE alractiveobject.cpp + +START RESOURCE ../data/ConnTest.rss +HEADER +TARGETPATH APP_RESOURCE_DIR +LANG SC +END + + +START RESOURCE ../data/ConnTest_reg.rss +DEPENDS conntest.rsg +// Do not change the UID below. +TARGETPATH /private/10003a3f/apps +END + +USERINCLUDE . ../inc + +APP_LAYER_SYSTEMINCLUDE + +LIBRARY apparc.lib +LIBRARY apgrfx.lib +LIBRARY avkon.lib +LIBRARY AknSkins.lib +LIBRARY aknnotify.lib +LIBRARY bafl.lib +LIBRARY commdb.lib +LIBRARY cone.lib +LIBRARY ecom.lib +LIBRARY efsrv.lib +LIBRARY eikcoctl.lib +LIBRARY eikcore.lib +LIBRARY eikctl.lib +LIBRARY egul.lib +LIBRARY estor.lib +LIBRARY etext.lib +LIBRARY euser.lib +LIBRARY gdi.lib +LIBRARY http.lib +LIBRARY inetprotutil.lib +LIBRARY insock.lib +LIBRARY esock.lib +LIBRARY ws32.lib +LIBRARY sendui.lib +LIBRARY cmmanager.lib +LIBRARY netmeta.lib +LIBRARY extendedconnpref.lib +LIBRARY esock_api_ext.lib + +// For performance marks +LIBRARY hal.lib + + +START WINS +// ?wins_specific_information +END + +START MARM +// ?marm_specific_information +END + +// Other possible keywords: +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCEPATH ?source_path +SOURCE ?color_depth ?source_bitmap_list +END +*/ +// DEFFILE ?filename + +//AIF ConnTest.aif ../aif ConnTestaif.rss c8 context_pane_icon.bmp context_pane_icon_mask.bmp list_icon.bmp list_icon_mask.bmp + diff -r 000000000000 -r 857a3e953887 nettools/conntest/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/group/bld.inf Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file for project ConnTest +* +*/ + +#include +#include "../probe/group/bld.inf" + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../rom/ConnTest.iby CORE_IBY_EXPORT_PATH(tools,ConnTest.iby) + +PRJ_MMPFILES +ConnTest.mmp + +PRJ_EXTENSIONS +START EXTENSION s60/mifconv +OPTION TARGETFILE conntest_aif.mif +OPTION SOURCEDIR ../aif +OPTION SOURCES -c8,1 list_icon -c8,1 context_pane_icon +END + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/group/ethernet.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/group/ethernet.ini Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,4 @@ +ETHER_NIF=\Device\NPF_{72E8E9AF-E5F0-4098-A5E0-42592B0EABF7} +ETHER_MAC=020d56797794 + +ETHER_SPEED=100Mbps diff -r 000000000000 -r 857a3e953887 nettools/conntest/group/icons_aif_bitmaps_dc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/group/icons_aif_bitmaps_dc.mk Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,67 @@ +# +# Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: This is part of ConnTest. +# + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z +else +ZDIR=\epoc32\data\z +endif + +# ---------------------------------------------------------------------------- +# Configuration +# ---------------------------------------------------------------------------- + +TARGETDIR=$(ZDIR)\RESOURCE\APPS +ICONTARGETFILENAME=$(TARGETDIR)\conntest_aif.mbm + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +# ---------------------------------------------------------------------------- +# +# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by +# MifConv if the mask detph is defined. +# +# NOTE 2: Usually, source paths should not be included in the bitmap +# definitions. MifConv searches for the icons in all icon directories in a +# predefined order, which is currently \s60\icons, \s60\bitmaps2. +# The directory \s60\icons is included in the search only if the feature flag +# __SCALABLE_ICONS is defined. +# ---------------------------------------------------------------------------- + +RESOURCE : + mifconv $(ICONTARGETFILENAME) \ + /c8,1 ..\aif\list_icon.bmp \ + /c8,1 ..\aif\context_pane_icon.bmp + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/ConnTest.pan --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/ConnTest.pan Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Defines the panics of the ConnTest +* +*/ + +#ifndef __CONNTEST_PAN__ +#define __CONNTEST_PAN__ + +#include + +_LIT(KPanicConnTest, "ConnTest"); +_LIT(KPanicSocketsEngine, "SocketsEngine"); +_LIT(KPanicSocketsWrite, "SocketsWrite"); + +/** ConnTest application panic codes */ +enum TConnTestPanics + { + EConnTestBasicUi = 1, + EConnTestBadStatus, + EConnTestAppView, + EConnTestContainer, + EConnTestBadRoamingStatus + // add further panics here + }; + +#endif // __CONNTEST_PAN__ diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/ConnTest.rh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/ConnTest.rh Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,20 @@ +/* +* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Resource header file +* +*/ + + + + diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/ConnTestApp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/ConnTestApp.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The application class for ConnTest +* +*/ + +#ifndef CONNTESTAPP_H +#define CONNTESTAPP_H + +// INCLUDES +#include + +// CONSTANTS +// UID of the application +const TUid KUidConnTest = { 0x101F6D2B }; + +// CLASS DECLARATION + +/** +* CConnTestApp application class. +* Provides factory to create concrete document object. +* +*/ +class CConnTestApp : public CAknApplication + { + + public: // Functions from base classes + private: + + /** + * From CApaApplication, creates CConnTestDocument document object. + * @return A pointer to the created document object. + */ + CApaDocument* CreateDocumentL(); + + /** + * From CApaApplication, returns application's UID (KUidConnTest). + * @return The value of KUidConnTest. + */ + TUid AppDllUid() const; + }; + +#endif + +// End of File + diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/ConnTestAppUi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/ConnTestAppUi.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,147 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The application UI class for ConnTest +* +*/ + +#ifndef CONNTESTAPPUI_H +#define CONNTESTAPPUI_H + +// INCLUDES +#include +#include +#include +#include +#include +#include +#include + +#include "conntest.hrh" + +// FORWARD DECLARATIONS +class CConnTestContainer; +class CConnTestView; +class CAknWarningNote; +class CIpdumpEngine; +class CSendUi; +class CSettingData; +class CCustomPrefsData; + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +/** +* Application UI class. +* Provides support for the following features: +* - EIKON control architecture +* - view architecture +* - status pane +* +*/ +class CConnTestAppUi : public CAknViewAppUi +{ +public: // // Constructors and destructor + + /** + * Symbian default constructor. + */ + void ConstructL(); + + /** + * Constructor. + */ + CConnTestAppUi( + TFixedArray& aSettings, + TFixedArray& aCustomPrefs); + + /** + * Destructor. + */ + ~CConnTestAppUi(); + +public: // New functions + + /** + * Is the IP logging on + * @return the logging state, ETrue = logging, EFalse = not logging + */ + TBool IsLogging(); + +public: // Functions from base classes + +protected: //From CAknViewAppUi + + /** + * Handles the status pane size changes + */ + void HandleStatusPaneSizeChange(); + +private: + // From MEikMenuObserver + void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane); + +private: + + /** + * From CEikAppUi, takes care of command handling. + * @param aCommand command to be handled + */ + void HandleCommandL(TInt aCommand); + + /** + * From CEikAppUi, handles key events. + * @param aKeyEvent Event to handled. + * @param aType Type of the key event. + * @return Response code (EKeyWasConsumed, EKeyWasNotConsumed). + */ + virtual TKeyResponse HandleKeyEventL( + const TKeyEvent& aKeyEvent,TEventCode aType); + +private: // new methods + /** + * ParallelGet initiates HTTP Get over socket for every view + * @param amount of gets if possible + */ + void ParallelGetL(TInt aCount); + + /** + * Launches a CSendUi for the log file + */ + void SendLogFileL(); + + /** + * Starts the ip packet logging + */ + void StartIpLoggingL(); + + /** + * Stops the ip packet logging + */ + void StopIpLoggingL(); + +private: //Data + RPointerArray iConnTestViews; // just for parallel get + CAknNavigationControlContainer* iNaviPane; + CAknTabGroup* iTabGroup; + CAknNavigationDecorator* iDecoratedTabGroup; + TFixedArray& iSettingDataArray; + TFixedArray& iCustomPrefsDataArray; + CAknWarningNote* iWarningDialog; // notice, currently used: ->ExecuteLD, so deleted automatically + CIpdumpEngine* iIpdumpEngine; // Only 1 dump engine/app, thus appui owns it + CSendUi* iSendUi; // For sending the log +}; + +#endif + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/ConnTestContainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/ConnTestContainer.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,159 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The container class for ConnTest +* Shows status line and notification text editor +* +*/ + +#ifndef CONNTESTCONTAINER_H +#define CONNTESTCONTAINER_H + +// INCLUDES +#include +#include "uinotify.h" + + +// FORWARD DECLARATIONS +class CRichText; +class CParaFormatLayer; +class CCharFormatLayer; +class CEikRichTextEditor; +class CEikLabel; + + +// CLASS DECLARATION + +/** +* CConnTestContainer container control class. +* +*/ +class CConnTestContainer : public CCoeControl, public MCoeControlObserver, public MUINotify +{ +public: // Constructors and destructor + + /** + * EPOC default constructor. + * @param aRect Frame rectangle for container. + */ + void ConstructL(const TRect& aRect); + + /** + * Destructor. + */ + ~CConnTestContainer(); + +public: // New functions + + /** + * Clear the output window. + */ + void ClearOutputWindow(); + +public: // Functions from base classes + + // From MUINotify + + /** + * Display text on output window + * @param aDes text to display + * @param aFontStyle style (italic/bold/etc) for this text + */ + void PrintNotify(const TDesC& aDes, TUint aFontStyle = 0); + void PrintNotify(const TDesC8& aDes, TUint aFontStyle = 0); + + /** + * Display integer as text on output window + * @param aInt integer to display + */ + void PrintNotify(TInt aInt); + + /** + * Notify user of an error + * @param aErrMessage message associated with error + * @param aErrCode error code + */ + void ErrorNotify(const TDesC& aErrMessage, TInt aErrCode); + + /** + * Notify user with a message + * @param aMessage message associated with error + */ + void CConnTestContainer::PopupNotify(const TDesC& aMessage); + + /** + * Change 'status' display. + * @param aStatus new status text to display + */ + void SetStatus(const TDesC& aStatus); + +private: // Functions from base classes + + /** + * From CoeControl. Calls SizeChangedL with TRAP. + */ + void SizeChanged(); + + /** + * From CoeControl. + */ + TInt CountComponentControls() const; + + /** + * From CCoeControl. + */ + CCoeControl* ComponentControl(TInt aIndex) const; + + /** + * Event handling section, e.g Listbox events. + */ + void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType); + + /** + * From CCoeControl,Draw. + */ + void Draw(const TRect& aRect) const; + + /** + * Key event handler. Handles up and down arrow keys, so that + * output window can be scrolled. + */ + TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); + + /** + * Change font style for subsequent text + * @param aFontStyle new font style + */ + void SetFontStyle(TUint aFontStyle); + + /** + * Set or clear an individual font attribute if necessary, + * so that it matches the required style + * @param aFontStyle required font style + * @param aAttribute the individual attribute to correct + */ + void UpdateFontAttribute(TUint aFontStyle, TInt aAttribute); + + +private: //data + CParaFormatLayer* iParaFormat; // Used by CEikRichTextEditor + CCharFormatLayer* iCharFormat; // Used by CEikRichTextEditor + CRichText* iRichText; // Used by CEikRichTextEditor + CEikRichTextEditor* iOutputWindow; // CRichText object for use as our output window + CEikLabel* iStatusWindow; // Single line of text to display connection status + TUint iFontStyle; // Current style in use by output window + }; + +#endif + + // End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/ConnTestDocument.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/ConnTestDocument.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The document class for ConnTest, stores the settings +* +*/ + +#ifndef CONNTESTDOCUMENT_H +#define CONNTESTDOCUMENT_H + +// INCLUDES +#include + +#include "conntest.hrh" + +// CONSTANTS + +// FORWARD DECLARATIONS +class CEikAppUi; +class CSettingData; +class CCustomPrefsData; + +// CLASS DECLARATION + +/** +* CConnTestDocument document class. +* Note! Base class is CEikDocument, because CAknDocument does +* not provide support for storing persistent data into file. +*/ +class CConnTestDocument : public CEikDocument +{ +public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CConnTestDocument* NewL(CEikApplication& aApp); + + /** + * Destructor. + */ + virtual ~CConnTestDocument(); + +protected: // Functions from base classes + + /** + * Store current connection settings to file. Uses default file name, + * which is \\private\\101F6D2B\\ConnTest. + */ + void StoreL(CStreamStore& aStore, CStreamDictionary& aStreamDic) const; + + /** + * Read previous connection settings from file. + */ + void RestoreL(const CStreamStore& aStore, const CStreamDictionary& aStreamDic); + +private: + + /** + * Symbian default constructor. + */ + CConnTestDocument(CEikApplication& aApp); + void ConstructL(); + +private: + + /** + * From CEikDocument, create CConnTestAppUi "App UI" object. + */ + CEikAppUi* CreateAppUiL(); + +private: // Data + TFixedArray iSettingDataArray; + TFixedArray iCustomPrefsDataArray; + +}; + +#endif + +// End of File + diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/ConnTestView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/ConnTestView.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,218 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The view class for ConnTest +* Implements command handling, menu initializing and view activation +* +*/ + +#ifndef CONNTESTVIEW_H +#define CONNTESTVIEW_H + +// INCLUDES +#include +#include "conntest.hrh" +#include + +// CONSTANTS + +// FORWARD DECLARATIONS +class CSocketsEngine; +class CConnTestContainer; +class CSettingItemList; +class CSettingData; +class CCustomPrefsItemList; +class CCustomPrefsData; +class CWlanScanInfo; +class CConnTestView; + +// CLASS DECLARATION + +enum TConnTestWaitType + { + EConnTestWaitTypeAvailableIaps, + EConnTestWaitTypeScan + }; + +class CWlanMgmtClient; + +class CConnTestViewWaiter : public CActive + { + public: + CConnTestViewWaiter( CWlanMgmtClient* aWlanMgmtClient, CConnTestView& aCallback, TConnTestWaitType aType ); + void ConstructL(); + virtual ~CConnTestViewWaiter(); + + void IssueRequest(); + void RunL(); + TInt RunError( TInt aError ); + void DoCancel(); + + private: + TConnTestWaitType iType; + CConnTestView& iCallback; + CWlanMgmtClient* iMgmtClient; + RArray iAvailableIaps; + CWlanScanInfo* iScanInfo; + }; + +/** +* CConnTestView view class. +* +*/ +class CConnTestView : public CAknView, public MWlanMgmtNotifications +{ +public: // Constructors and destructor + + /** + * Symbian default constructor. + */ + void ConstructL(); + + /** + * Constructor + * @aViewId Id for this view + */ + CConnTestView(const TUid aViewId); + + /** + * Constructor + * @aViewId Id for this view + * @aSettings Connection settings for the socket engine of this view + */ + CConnTestView(const TUid aViewId, CSettingData* aSettings, CCustomPrefsData* aCustomPrefs); + + /** + * Destructor. + */ + ~CConnTestView(); + +public: // New functions + + /** + * Returns if the iSocketsEngine has an open connection + * to be used in HTTP GET + */ + TBool IsReadyForHTTPGet(); + + /** + * Handles the view size changes + */ + void SizeChanged(); + + void RequestCompleted( TInt aStatus, RArray& aAvailableIaps ); + + void RequestCompleted( TInt aStatus, CWlanScanInfo& aScanInfo ); + +public: // Functions from base classes + + /** + * From CAknView + */ + TUid Id() const; + + /** + * From CAknView + */ + void HandleCommandL(TInt aCommand); + + /** + * From ?base_class ?member_description + */ + void HandleClientRectChange(); + +private: // new + + // + // WlanMgmtClient notifications + // + // + void ConnectionStateChanged( TWlanConnectionMode /* aNewState */ ); + void BssidChanged( TWlanBssid& /* aNewBSSID */ ); + void BssLost(); + void BssRegained(); + void NewNetworksDetected(); + void OldNetworksLost(); + void TransmitPowerChanged( TUint /* aPower */ ); + void RssChanged( + TWlanRssClass aRssClass, + TUint aRss ); + + /** + * Method for sending data over connected socket. + */ + void SendDataL(); + +private: + + /** + * From CAknView + */ + void DoActivateL(const TVwsViewId& aPrevViewId,TUid aCustomMessageId, + const TDesC8& aCustomMessage); + + /** + * From CAknView + */ + void DoDeactivate(); + + /** + * Adjusts the visible items in menu pane accordding to + * socket engine state. + * @aResourceId Resource ID identifying the menu pane to initialise + * @aMenuPane The in-memory representation of the menu pane + */ + void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane); + + /** + * Swaps container window between the main window and settings list. + * @param aActiveContainer Becomes container + */ + void SwapContainerL(TConnTestContainer aActiveContainer); + + /** + * Creates settings item list + * @param aResourceId for ListBox initialization + */ + void CreateSettingsListBoxL(TInt aResourceId); + + /** + * Creates Custom Preferences item list + * @param aResourceId for ListBox initialization + */ + void CreateCustomPrefsListBoxL(TInt aResourceId); + + /** + * Create the data packet that is sent over connected socket. + * Packet size can be set in settings page. + */ + void CreateDataPacket(); + +private: // Data + TUid iViewId; + CConnTestContainer* iContainer; + CSocketsEngine* iSocketsEngine; + CSettingItemList* iSettingsListBox; + CSettingData* iSettingData; + CCustomPrefsItemList* iCustomPrefsListBox; + CCustomPrefsData* iCustomPrefsData; + TConnTestContainer iActiveContainer; + HBufC8* iSendData; + TBool iSupportsWlan; + CConnTestViewWaiter* iWaiter; + CWlanMgmtClient* iWlanMgmtClient; +}; + +#endif + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/CustomPrefsData.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/CustomPrefsData.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: CSettingsData stores the settings for ConnTest + * + */ + +#ifndef CUSTOMPREFSDATA_H +#define CUSTOMPREFSDATA_H + +// INCLUDES + +// FORWARD DECLARATIONS + +// CLASS DECLARATION + +/** + * Class for encapsulating Custom Preferences data. + */ +class CCustomPrefsData : public CBase + { +public: + static CCustomPrefsData* NewL(); + ~CCustomPrefsData(); + +private: + CCustomPrefsData(); + void ConstructL(); + +public: + /** SNAP purpose. */ + // CMManager::TSnapPurpose iSnapPurpose; + TInt iSnapPurpose; + /** SNAP id. */ + TInt iSnapId; + /** IAP id. */ + TInt iIapId; + /** Bearer set. */ + TInt iBearerSet; + /** UI behaviour. */ + // TUint32 iUiBehaviour; + TInt iNoteBehaviour; + /** Indicates whether UI disconnect dialog is shown. */ + TBool iDisconnectDialog; + /** Indicates whether UI connection selection dialog is shown. */ + TBool iConnSelectionDialog; + /** Indicates whether forced roaming is enabled. */ + TBool iForcedRoaming; + }; + +#endif + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/CustomPrefsItemList.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/CustomPrefsItemList.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: CSettingItemList implemets the settings list for Conntest + * + */ + +#ifndef CUSTOMPREFSITEMLIST_H +#define CUSTOMPREFSITEMLIST_H + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class CCustomPrefsData; + +// CLASS DECLARATION + +/** + * Control for setting the (Extended) Custom Preferences. + */ +class CCustomPrefsItemList : public CAknSettingItemList + { +public: + CAknSettingItem* CreateSettingItemL( TInt identifier ); + void SetData( CCustomPrefsData* aData ); + + void EditItemL( TInt aIndex, TBool aCalledFromMenu ); + +private: + /** + * Size change handler + */ + void SizeChanged(); + + /** + * Selects a SNAP + */ + void SelectSnapL(); + + /** + * Selects a IAP + */ + void SelectIapL(); + +private: + CCustomPrefsData* iData; + + /** + * Control for selecting the Custom Preferences list's SNAP or IAP ID. + */ + class CCustomPrefsSelectedIntegerItem : public CAknIntegerSettingItem + { + public: + void EditSelectedIntegerItemL( TInt aId ); + }; + }; + +#endif + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/HttpHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/HttpHandler.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,168 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: HttpHandler is used for HTTP connection components testing +* +*/ + +#ifndef HTTPHANDLER_H +#define HTTPHANDLER_H + +// INCLUDES + +#include +#include +#include + +// CONSTANTS + +const TInt KMaxContentTypeSize = 64; + +// FORWARD DECLARATIONS +class MUINotify; +class CHttpEventHandler; +class CSettingData; + +// CLASS DECLARATION + + +/** +* CHttpClient +* +* Class for initiating HTTP transaction. +*/ +class CHttpClient : public CBase, public MHTTPDataSupplier, +public MHTTPAuthenticationCallback +{ +public: + virtual ~CHttpClient(); + static CHttpClient* NewLC(MUINotify& aConsole); + static CHttpClient* NewL(MUINotify& aConsole); + + + /** + * Start http request + */ + void InvokeHttpMethodL(const CSettingData* aData, TBool aHasBody, TBool aIsSecure); + + /** + * Set connection info for HTTP FW session + */ + void SetHttpConnectionInfoL( TBool aUseOwnConnection, + RConnection& aConnection, + RSocketServ& aSocketServ ); + + /** + * Set throughput calculation on or off. + */ + void SetPerformance(const TBool aValue); + + /** + * Methods inherited from MHTTPDataSupplier + */ + virtual TBool GetNextDataPart(TPtrC8& aDataPart); + virtual void ReleaseData(); + virtual TInt OverallDataSize(); + virtual TInt Reset(); + + /** + * Methods inherited from MHTTPAuthenticationCallback + */ + virtual TBool GetCredentialsL(const TUriC8& aURI, RString aRealm, + RStringF aAuthenticationType, + RString& aUsername, + RString& aPassword); + +protected: + CHttpClient(MUINotify& aConsole); + void ConstructL(); +private: + + enum TMenuItems + { + EGet, + EPost, + EHead, + ETrace, + EToggleVerbosity, + EQuit + }; + + /** + * Display performance information when sending POST. + */ + void DisplayTimeElapsed(); + + /** + * Set HTTP request header for http fw. + */ + void SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue); + +private: + RHTTPSession iHttpSession; + TTime iLastTimeStamp; + TInt iDataChunkCount; + RHTTPTransaction iTrans; + CHttpEventHandler* iTransObs; + HBufC8* iReqBodySubmitBuffer; + TPtr8 iReqBodySubmitBufferPtr; + TBool iNoMoreDate; + MUINotify& iConsole; + CSettingData* iSettingData; + TBool iDoPerformance; + TBuf iReqBodyContentType; // not used now +}; + + + + +/** +* CHttpEventHandler +* +* Handles all events for the active HTTP transaction. +*/ +class CHttpEventHandler : public CBase, public MHTTPTransactionCallback +{ +public: + virtual ~CHttpEventHandler(); + static CHttpEventHandler* NewLC(MUINotify& aConsole); + static CHttpEventHandler* NewL(MUINotify& aConsole); + + /** + * Turn performance measurement on/off + */ + void SetPerformance(const TBool aValue){iDoPerformance = aValue;}; + + /** + * Methods from MHTTPTransactionCallback + */ + virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent); + virtual TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& aEvent); + +protected: + CHttpEventHandler(MUINotify& aConsole); + void ConstructL(); +private: + void DumpRespHeadersL(RHTTPTransaction& aTrans); + void DumpRespBody(RHTTPTransaction& aTrans); + + MHTTPDataSupplier* iRespBody; + MUINotify& iConsole; // console for displaying text etc + TTime iStartTime; + TInt iBodySize; + TBool iDoPerformance; +}; + + +#endif // HTTPHANDLER_H + diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/ProgressNotifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/ProgressNotifier.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CProgressNotifier is used to notify about +* the current state of the request +* +*/ + +#ifndef __PROGRESSNOTIFIER_H__ +#define __PROGRESSNOTIFIER_H__ + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class MProgressNotifyHandler; + +/** +* Class for receiving notifications from interfaces. +* Notifications are handled by the class, that implements +* MProgressNotifyHandler interface. +*/ +class CProgressNotifier : public CActive +{ +public: // new methods + + /** + * Two-phased constructor. + */ + static CProgressNotifier* NewL(RConnection& aConnection, MProgressNotifyHandler& aHandler); + + /** + * Two-phased constructor. + */ + static CProgressNotifier* NewLC(RConnection& aConnection, MProgressNotifyHandler& aHandler); + + /** + * Destroy the object and release all memory objects + */ + ~CProgressNotifier(); + + /** + * Start waiting for the progress notifications. + */ + void StartNotify(); + + /** + * Reads the current stage of the interface when + * the progress notification is received, and issues + * a new progress notification request. + */ + void NotifyL(); + +protected: // from CActive + + /** + * Called when operation complete + */ + void RunL(); + + /** + * Cancel any outstanding operation + */ + void DoCancel(); + +private: // New methods + + /** + * Perform the first phase of two phase construction + */ + CProgressNotifier(RConnection& aConnection, MProgressNotifyHandler& aHandler); + + /** + * Perform the second phase construction of two phase construction + */ + void ConstructL(); + +private: + // Member variables + RConnection& iConnection; + MProgressNotifyHandler& iHandler; + TNifProgressBuf iProgressBuf; +}; + +#endif // __PROGRESSNOTIFIER_H__ + diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/ProgressNotifyHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/ProgressNotifyHandler.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface class for handling connection notifications. +* +*/ + +#ifndef __PROGRESSNOTIFYHANDLER_H__ +#define __PROGRESSNOTIFYHANDLER_H__ + + +/** +* Class that specifies the functions for handling progress +* notify messages of the active interface. +*/ +class MProgressNotifyHandler +{ +public: + + /** + * Actions when interface is up + */ + virtual void ProgressNotifyReceivedL(TInt aStage, TInt aError) = 0; + + /** + * Handle error + */ + virtual void ProgressNotifyError(TInt aStatus) = 0; +}; + +#endif \ No newline at end of file diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/QosObserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/QosObserver.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Receiver for QoS events. +* +*/ + +#ifndef __QOSOBSERVER_H__ +#define __QOSOBSERVER_H__ + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class MUINotify; + +/** +* Class that receives QoS events. +*/ +class CQosObserver : public CBase, public MQoSObserver +{ +public: // new methods + + /** + * Constructor + */ + CQosObserver(MUINotify& aConsole); + + /** + * Destructor + */ + ~CQosObserver(); + + /** + * This method is called when QoS event has been generated. + * Prints the event on the console. + */ + void Event(const CQoSEventBase& aQosEvent); + +private: + // Member variables + MUINotify& iConsole; +}; + +#endif // __QOSOBSERVER_H__ + diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/SendTimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/SendTimer.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSendTimer is used for sending data at specified intervals +* +*/ + +#ifndef __SENDTIMER_H__ +#define __SENDTIMER_H__ + +#include + +class CSocketsEngine; + +/** +* This class will send data over socket after given +* time has elapsed. +*/ +class CSendTimer : public CTimer +{ +public: + + /** + * Create a CSendTimer object + * @param aPriority priority to use for this timer + * @param aEngine object that knows how to send data + * @result a pointer to the created instance of CTimeOutTimer + */ + static CSendTimer* NewL(const TInt aPriority, CSocketsEngine* aEngine); + + /** + * Create a CSendTimer object + * @param aPriority priority to use for this timer + * @param aEngine object that knows how to send data + * @result a pointer to the created instance of CTimeOutTimer + */ + static CSendTimer* NewLC(const TInt aPriority, CSocketsEngine* aEngine); + + /** + * Destroy the object and release all memory objects + */ + ~CSendTimer(); + +protected: // From CTimer + + /** + * Invoked when a timer event occurs + */ + virtual void RunL(); + +private: + + /** + * Perform the first phase of two phase construction + * @param aPriority priority to use for this timer + * @param aEngine object that knows how to send data + */ + CSendTimer(const TInt aPriority, CSocketsEngine* aEngine); + + /** + * Perform the second phase construction of a CSendTimer + */ + void ConstructL(); + +private: + // Member variables + CSocketsEngine* iEngine; +}; + +#endif // __SENDTIMER_H__ + diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/SettingData.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/SettingData.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSettingsData stores the settings for ConnTest +* +*/ + +#ifndef SETTINGDATA_H +#define SETTINGDATA_H + +// INCLUDES +#include +#include "conntest.hrh" + +// FORWARD DECLARATIONS + + +// CLASS DECLARATION + +/** +* Class for encapsulating setting data. +*/ +class CSettingData : public CBase +{ +public: + static CSettingData* NewL(); + ~CSettingData(); + +private: + CSettingData(); + void ConstructL(); + +public: + TBuf iServerName; + TInt iPort; + TInt iProtocol; + TInt iPacketSize; + TInt iPackets; + TInt iDelay; + TInt iRoaming; + TBuf iHttpPage; +}; + + +#endif + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/SettingItemList.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/SettingItemList.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSettingItemList implemets the settings list for Conntest +* +*/ + +#ifndef SETTINGITEMLIST_H +#define SETTINGITEMLIST_H + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class CSettingData; + +// CLASS DECLARATION + +/** +* Control for settings. +*/ +class CSettingItemList : public CAknSettingItemList +{ +public: + CAknSettingItem* CreateSettingItemL( TInt identifier ); + void SetData(CSettingData* aData); + +private: + void SizeChanged(); + +private: + CSettingData* iData; +}; + + +#endif + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/SocketsEngine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/SocketsEngine.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,446 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSocketsEngine implements an engine for connection +* component checking: Interface opening/closing, connecting, +* sending/receiving data, etc. +* CSocketsEngine is an active object +* +*/ + + +#ifndef __SOCKETSENGINE_H__ +#define __SOCKETSENGINE_H__ + +// INCLUDES +#include +#include +#include +#include +#include +#include "TimeOutNotify.h" +#include "ProgressNotifyHandler.h" +#include "datasendnotifyhandler.h" +#include "conntest.hrh" +#include "alractiveobject.h" + +// CONSTANTS + +// FORWARD DECLARATIONS +class CSocketsRead; +class CSocketsWrite; +class CTimeOutTimer; +class MUINotify; +class CHttpClient; +class CProgressNotifier; +class CSettingData; +class CCustomPrefsData; +class CSendTimer; + +// CLASS DECLARATION + +/** +* CSocketsEngine +* +* This class is the main engine part of the sockets application. +* It establishes a TCP connection using its server name and port +* number (performing a DNS lookup operation first, if appropriate). +* It creates instances of separate active objects to perform reading +* from, and writing to, the socket. +*/ +class CSocketsEngine : public CActive, + public MTimeOutNotify, + public MProgressNotifyHandler, + public MDataSendNotifyHandler, + public MMobilityProtocolResp + +{ +public: + enum TRoamingSetting + { + ERoamingOff, + ERoamingAutomatic, + ERoamingManual + }; + + // Utilized when selecting UI menu items + enum TRoamingUIState + { + EIdle, + EPendingPreferredCarrier, + EPendingNewCarrierActive + }; + + enum TSocketsEngineState + { + EInterfaceDown, + EStartingInterface, + EInterfaceUp, + EConnecting, + EConnected, + EListening, + ETimedOut, + ELookingUp, + ELookUpFailed, + EConnectFailed, + EDisconnecting + }; + + enum TSocketsEngineStartType + { + EAskIap, + EExtPrefs, + EExtPrefsInternet, + ENoPrefs, + ENetworkId, + ESnap, + ETypeUnknown + }; + + + /** + * Two-phased constructor. + * @param aConsole console to use for ui output + * @return a pointer to the created instance of CSocketsEngine + */ + static CSocketsEngine* NewL(MUINotify& aConsole); + + /** + * Two-phased constructor. + * @param aConsole console to use for ui output + * @return a pointer to the created instance of CSocketsEngine + */ + static CSocketsEngine* NewLC(MUINotify& aConsole); + + /** + * Destructor. + */ + ~CSocketsEngine(); + + /** + * Calls From ConnTestView that are responds to roaming notifications + */ + void Migrate(); + void Ignore(); + void AcceptCarrier(); + void RejectCarrier(); + + /** + * Register to mobility API + */ + void RegisterToMobilityAPIL(); + + /** + * UnRegister from mobility API + */ + void UnRegisterFromMobilityAPI(); + + /** + * Start interface + * @param aStartType Define start type (with or without preferences, by nework id) + * @param aConnect If True, make connection after startup + */ + void StartInterfaceL(TSocketsEngineStartType aStartType, TBool aConnect = EFalse); + + /** + * Start interface and possible connection with snap + * @param aConnect If True, make connection after startup + */ + void StartConnWithSnapL(TBool aConnect = EFalse); + + /** + * Starting method for testing RConnection::Close + */ + void StartCloseInterfaceL(); + + /** + * Stop interface by calling RConnection::Stop + */ + void StopInterfaceL(); + + /** + * Stop interface by calling RConnection::Close + */ + void CloseInterface(); + + /** + * Make socket connection + */ + void ConnectL(); + + /** + * Disconnect socket + */ + void Disconnect(); + + /** + * Opens a Listening socket + */ + void ListenL(); + + /** + * Write data to socket + * @param aData data to be written + */ + void WriteL(const TDesC8& aData); + + /** + * Write data to socket (flood) + * @param aData data to be written + * @param aCount The data will be written aCount times + */ + void WriteFloodL(const TDesC8& aData, TInt aCount); + + /** + * Write HTTP request over socket + * @param aHasBody defines if request has body + */ + void SendHttpRequestOverSocketL(TBool aHasBody, TBool aDoPerformance); + + /** + * Initiate read of data from socket + */ + void Read(); + + /** + * Send HTTP request using http framework. + * @param aHasBody If true, send body data with POST + * @param aDoPerformance If true, calculate performance, no outputs + * @param aIsSecure If true, make HTTPS request + */ + void SendHttpFrameworkRequestL(TBool aHasBody, TBool aDoPerformance, TBool aIsSecure); + + /** + * Print information about active connections and their + * clients and sockets + */ + void ConnectionInfoL(); + + /** + * Print information about interfaces. + */ + void InterfaceInfoL(); + + /** + * Get socket engine state + * @return Socket engine state + */ + TSocketsEngineState GetSocketEngineState(); + + /** + * Gets Roaming state + * @return TRoamingState + */ + TRoamingUIState GetSocketEngineRoamingState(); + + /** + * Gets MobilityAPIImplementation + * @return CALRActiveObject + */ + CALRActiveObject* CSocketsEngine::GetMobilityAPI(); + + /** + * Get socket engine connection type + * @return socket engine connection type + */ + TSocketsEngineStartType GetSocketEngineConnType(); + + /** + * Set socket engine connection type + */ + void SetSocketEngineConnType(const CSocketsEngine::TSocketsEngineStartType aConnStartType); + + /** + * Set connection information + * @param aData + */ + void SetConnectionData(const CSettingData* aData); + + /** + * Set Custom preferences data + * @param aData + */ + void SetCustomPrefsData(const CCustomPrefsData* aData); + + /** + * QoS methods + */ + void SetWLANQoS(TInt aClass); + + void QoS1(); + void QoS2(); + + /** + * Start the sending of the data + * @param aData the data to send + */ + void SendDataL(const TBuf8 aData); + + /** + * Actual sending udp packets + * Must be public because of the timer calling it + */ + void DoSendDataL(); + +public: // MDataSendNotifyHandler + /** + * The function to be called when data has been sent + * @param aAmount the number of packets sent + */ + void NotifySend(TInt aAmount); + +public: // from MTimeOutNotify + + /** + * The function to be called when a timeout occurs + */ + void TimerExpired(); + +public: // from MProgressNotifyHandler + + /** + * Handle progress notification + */ + void ProgressNotifyReceivedL(TInt aStage, TInt aError); + + /** + * Handle progress notification error + */ + void ProgressNotifyError(TInt aStatus); + +public: // from MMobilityProtocolResp + /** + * This method is called by middleware to notify that there are no suitable connections available. + */ + virtual void Error( TInt aError ); + + /** + * This method is called by the middleware to notify a client about a new preferred connection. + */ + virtual void PreferredCarrierAvailable( + TAccessPointInfo aOldAP, + TAccessPointInfo aNewAP, + TBool aIsUpgrade, + TBool aIsSeamless ); + /** + * This method is called by the middleware to notify a client that a preferred connection has been activated. + */ + virtual void NewCarrierActive( TAccessPointInfo aNewAP, TBool aIsSeamless ); + +protected: // from CActive + + /** + * Called when operation completes + */ + void RunL(); + + /** + * Cancel any outstanding operation + */ + void DoCancel(); + +private: // New methods + + /** + * Perform the first phase of two phase construction + */ + CSocketsEngine(MUINotify& aConsole); + + /** + * Perform the second phase construction of a CSocketsEngine + * @param aConsole the console to use for ui output + */ + void ConstructL(); + + /** + * Initiate a connect operation on a socket + * @param aAddr the ip address to connect to + */ + void ConnectL(const TInetAddr& aAddr); + + /** + * Handle a change in this object's status + * @param aNewStatus new status + */ + void ChangeStatus(TSocketsEngineState aNewStatus); + + /** + * Display text on the console + * @param aDes text to display + */ + void PrintTextToConsole(const TDesC& aDes); + +public: // for performance testing + /** + * Marks starting time into memory + * + */ + + void UDPFlood(TInt aPackets, TInt aPacketSize, TDesC& aData); + /** + * Marks starting time into memory + */ + void inline StartTickCount(); + + /** + * Calculates time interval using tick count and prints it + */ + void StopTickCount(const TDesC& aComponentName); + +private: + // Member variables + TUint32 iStartTime; // for performance testing only + TTime iStartTTime; // for performance testing only + TTime iThroughputStartTime; // for performance testing only + TInt iTroughputDataSize; + TCommDbConnPref iPrefs; + TConnPrefList* iPrefsList; + TExtendedConnPref* iExtPrefs; + CCustomPrefsData* iCustomPrefsData; + RConnection iConnection; + RConnection* iCloseConnection; + CProgressNotifier* iProgressNotifier; + CProgressNotifier* iTempProgressNotifier; + CHttpClient* iHttpClient; + TRoamingUIState iRoamingState; + TRoamingSetting iRoaming; + TSocketsEngineState iEngineStatus; // this object's current status + MUINotify& iConsole; // console for displaying text etc + CSocketsRead* iSocketsRead; // socket reader active object + CSocketsWrite* iSocketsWrite; // socket writer active object + RSocket iSocket; // the actual socket + RSocket iListeningSocket; + RSocketServ iSocketServ; // the socket server + RHostResolver iResolver; // DNS name resolver + TNameEntry iNameEntry; + TNameRecord iNameRecord; + CTimeOutTimer* iTimer; // timer active object + TInetAddr iAddress; + TInt iPort; // port number to connect to + TBuf iServerName; // server name to connect to + TUint iProtocol; + TUint iSocketType; + TBool iConnectAfterStartup; + TBuf iHttpPage; + CSettingData* iSettingData; + CSendTimer* iSendTimer; // timer active object + HBufC8* iData; // The data to be sent + TInt iSendCount; + TBool iUseTTime; + TBool iIsRegisteredToMobAPI; //flag to mark state of registration to Mob API + CALRActiveObject* iMobility; //pointer to mob API instance + TSocketsEngineStartType iSockEngineStartType; //type of sock engine connection + }; + +#endif // __SOCKETSENGINE_H__ + diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/SocketsRead.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/SocketsRead.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,141 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSocketsRead is an active obejct that reads data from +* an already open socket and calculates some metrics from the data read +* +*/ + +#ifndef __SOCKETSREAD_H__ +#define __SOCKETSREAD_H__ + +#include +#include "conntest.hrh" + +// CONSTANTS + +const TInt KMaximumPacketCount = 4000; // Count to 4000. Fails if ploss is over 20% (1000pckts) + +// FORWARD DECLARATIONS +class MUINotify; +class CSocketsEngine; + +// CLASS DECLARATION + +/** +* This class handles reading data from the socket. +* In this implementation, any data read is simply +* displayed as text on the console. +*/ +class CSocketsRead : public CActive +{ +public: + + /** + * Create a CSocketsRead object + * @param aConsole console to use for ui output + * @param aSocket socket to read from + * @result a pointer to the created instance of CSocketsRead + */ + static CSocketsRead* NewL(MUINotify& aConsole, RSocket& aSocket, CSocketsEngine& aEngine); + + /** + * Create a CSocketsRead object + * @param aConsole console to use for ui output + * @param aSocket socket to read from + * @result a pointer to the created instance of CSocketsRead + */ + static CSocketsRead* NewLC(MUINotify& aConsole, RSocket& aSocket, CSocketsEngine& aEngine); + + /** + * Destroy the object and release all memory objects + */ + ~CSocketsRead(); + + /** + * Initiate the read process. + * @param aAddress Address where data is sent (needed by UDP) + * @param aProtocol Protocol to be used (TCP or UDP) + */ + void Start(TInetAddr* aAddress, TUint aProtocol); + + /** + * Set throughput calculation on or off. + * @param aValue If ETrue, measure throughput + */ + void SetPerformance(const TBool aValue); + + /** + * Start RAW read + */ + void StartRAWRead(TInetAddr* aAddress, TUint aProtocol); + +protected: // from CActive + + /** + * Cancel any outstanding operation + */ + void DoCancel(); + + /** + * Called when operation complete + */ + void RunL(); + +private: + + /** + * Perform the first phase of two phase construction + * @param aConsole console to use for ui output + * @param aSocket socket to read from + */ + CSocketsRead(MUINotify& aConsole, RSocket& aSocket, CSocketsEngine& aEngine); + + /** + * Perform the second phase construction of a CSocketsRead + */ + void ConstructL(); + + /** + * Read data from socket + */ + void IssueRead(); + + /** + * Calculate packet loss + * @return ploss percentage + */ + TInt32 CalculatePacketLoss(); + +private: // Member variables +// enum { KReadBufferSize = 4096 }; // 4K + //enum { KReadBufferSize = 10240 }; // 10K + // Member variables + CSocketsEngine& iEngine; // connection engine + RSocket& iSocket; // socket to read data from + MUINotify& iConsole; // console for displaying text etc + TBuf8 iBuffer; // buffer for receiving data + TSockXfrLength iDummyLength; // dummy - length of data read is written here + TInt iReceivedBytes; + TInt32 iUdpPacketCounter; + TBool iDoCount; + TBool iDoPerformance; + TInetAddr* iAddress; + TUint iProtocol; + TTime iStartTime; + TBuf8<2048> iHeaders; // buffer for HTTP headers + TInt iBodySize; +}; + +#endif // __SOCKETSREAD_H__ + diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/SocketsWrite.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/SocketsWrite.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,174 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSocketsWrite is an active object which implements data +* sending through an already open socket using UDP or TCP +* +*/ + +#ifndef __SOCKETSWRITE_H__ +#define __SOCKETSWRITE_H__ + +#include +#include "TimeOutNotify.h" +#include "conntest.hrh" + +// FORWARD DECLARATIONS +class CTimeOutTimer; +class MUINotify; +class MDataSendNotifyHandler; + +// CLASS DECLARATION + +/** +* This class handles writing data to the socket. +* Data to be written is accumulated in iTransferBuffer, +* and is then transferred to iWriteBuffer for the actual +* write to the socket. +*/ +class CSocketsWrite : public CActive, public MTimeOutNotify +{ +public: + + /** + * Create a CSocketsWrite object + * @param aConsole console to use for ui output + * @param aSocket socket to write to + * @param aSendHandler handler to notify UDP packet sends + * @result a pointer to the created instance of CSocketsWrite + */ + static CSocketsWrite* NewL( MUINotify& aConsole, + RSocket& aSocket, + MDataSendNotifyHandler& aSendHandler ); + + /** + * Create a CSocketsWrite object + * @param aConsole console to use for ui output + * @param aSocket socket to write to + * @param aSendHandler handler to notify UDP packet sends + * @result a pointer to the created instance of CSocketsWrite + */ + static CSocketsWrite* NewLC( MUINotify& aConsole, + RSocket& aSocket, + MDataSendNotifyHandler& aSendHandler ); + + /** + * Destroy the object and release all memory objects + */ + ~CSocketsWrite(); + + /** + * Write the data to the socket (buffered) + * @param aData the data to be written + * @param aAddress Address where data is sent (needed by UDP) + * @param aProtocol Protocol to be used (TCP or UDP) + */ + void IssueWriteL(const TDesC8& aData, TInetAddr* aAddress, TUint aProtocol); + + /** + * Write the data to the socket flooded + * @param aData the data to be written + * @param aAddress Address where data is sent (needed by UDP) + * @param aProtocol Protocol to be used (TCP or UDP) + * @param aCount The packet will be sent aCount times + */ + void IssueWriteL(const TDesC8& aData, TInetAddr* aAddress, TUint aProtocol, TInt aCount); + + /** + * Write the data to the socket (buffered) + * @param aData the data to be written + * @param aAddress Address where data is sent (needed by UDP) + * @param aProtocol Protocol to be used (TCP or UDP) + */ + void IssueWriteL( const TDesC8& aData, + TInetAddr* aAddress, + TUint aProtocol, + TInt aPacketSize, + TInt aPackets ); + +protected: // from CActive + + /** + * Cancel any outstanding operation + */ + void DoCancel(); + + /** + * Called when operation complete + */ + void RunL(); + + // From MTimeOutNotify + void TimerExpired(); + +private: + + /** + * Perform the first phase of two phase construction + * @param aConsole console to use for ui output + * @param aSocket socket to write to + * @param aSendHandler handler to notify UDP packet sends + */ + CSocketsWrite( MUINotify& aConsole, + RSocket& aSocket, + MDataSendNotifyHandler& aSendHandler ); + + /** + * Perform the second phase construction of a CSocketsWrite + */ + void ConstructL(); + + /** + * Handle a 'write buffer empty' situation. + */ + void SendNextPacket(); + + /** + * Calls the actual write when flooding + */ + void DoFloodWrite(); + + +private: // Member data + enum TWriteState + { + ESending, EWaiting ,ECommsFailed + }; + + + // Member variables + RSocket& iSocket; + MUINotify& iConsole; // console for displaying text etc + //TBuf8 iTransferBuffer; // Accumulate data to send in here + //TBuf8 iWriteBuffer; // Holds data currently being sent to socket + HBufC8* iTransferBuffer; + HBufC8* iWriteBuffer; + CTimeOutTimer* iTimer; + TInt iTimeOut; + TWriteState iWriteStatus; + TInetAddr* iAddress; + TUint iProtocol; + TInt iPackets; + TInt iPacketSize; + TInt iSentBytes; + TTime iStartTime; + TInt iDataChunkCount; + HBufC8* iReqBodySubmitBuffer; + TPtr8 iReqBodySubmitBufferPtr; + MDataSendNotifyHandler& iSendHandler; + TBool iFlood; // Flood mode sending + TInt iCount; // Times to flood the packet +}; + +#endif // __SOCKETSWRITE_H__ + diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/TimeOutNotify.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/TimeOutNotify.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MTimeOutNotify is an interface class used to +* notify about timeouts +* +*/ + +#ifndef _TIMEOUTNOTIFY_H_ +#define _TIMEOUTNOTIFY_H_ + +/** +* This class specifies the function to be called when a timeout occurs. +* Used in conjunction with CTimeOutTimer class +*/ +class MTimeOutNotify +{ +public: + + /** + * The function to be called when a timeout occurs + */ + virtual void TimerExpired() = 0; +}; + +#endif \ No newline at end of file diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/TimeOutTimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/TimeOutTimer.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CTimeOutTimer is used to generate time out events +* +*/ + +#ifndef __TIMEOUTTIMER_H__ +#define __TIMEOUTTIMER_H__ + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class MTimeOutNotify; + +/** +* This class will notify an object after a specified timeout. +*/ +class CTimeOutTimer : public CTimer +{ +public: + + /** + * Create a CTimeOutTimer object + * @param aPriority priority to use for this timer + * @param aTimeOutNotify object to notify of timeout event + * @result a pointer to the created instance of CTimeOutTimer + */ + static CTimeOutTimer* NewL(const TInt aPriority, MTimeOutNotify& aTimeOutNotify); + + /** + * Create a CTimeOutTimer object + * @param aPriority priority to use for this timer + * @param aTimeOutNotify object to notify of timeout event + * @result a pointer to the created instance of CTimeOutTimer + */ + static CTimeOutTimer* NewLC(const TInt aPriority, MTimeOutNotify& aTimeOutNotify); + + /** + * Destroy the object and release all memory objects + */ + ~CTimeOutTimer(); + +protected: // From CTimer + + /** + * Invoked when a timer event occurs + */ + virtual void RunL(); + +private: + + /** + * Perform the first phase of two phase construction + * @param aPriority priority to use for this timer + */ + CTimeOutTimer(const TInt aPriority, MTimeOutNotify& aTimeOutNotify); + + /** + * Perform the second phase construction of a CTimeOutTimer + */ + void ConstructL(); + +private: + // Member variables + MTimeOutNotify& iNotify; +}; + +#endif // __TIMEOUTTIMER_H__ + diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/Utils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/Utils.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Utils implements general tools for bandwidth and +* packet loss calculation and IAP selection etc +* +*/ + +#ifndef __UTILS_H__ +#define __UTILS_H__ + +#include + +#include "uinotify.h" + +class Utils +{ +public: + Utils(); + virtual ~Utils(); + + /** + * Adjust given Nifman's idle timeout for every bearer. + */ + static void SetTimeoutsL(const TInt aTimeout); + + /** + * Set Nifman's idle times for each record in given table. + */ + static void SetTableTimeoutL(const TInt aTimeout,const TDesC& aTableName); + + /** + * Calculate throughput + */ + static void CalculateThroughput(TDes8& aBuffer, TTime aStartTime, TInt aSize); + + /** + * Set IapId value into connection preferences table. + */ + static void SetConnectionPrefsIapL(); + + /** + * Create data chunk for POST performance tests. + */ + static void CreateDataChunk(TDes8& aBuffer, TInt aLength); + + /** + * Ask IAP id to be used from the user + * @param aId Selected IAP id + * @return Status of the selection (selection made or cancelled) + */ + static TInt AskIapIdL(TUint32& aId); + + /** + * Ask Network id from the user. + */ + static TInt AskNetworkIdL(TUint32& aId); + + /** + * Does the real work for selecting IAP or Network ide. + */ + static TInt SelectIdFromTableL(TUint32& aId, const TDesC& aTableName); + +}; + +#endif // __UTILS_H__ diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/alractiveobject.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/alractiveobject.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: conntest application +* +*/ + +#ifndef ALRACTIVEOBJECT_H +#define ALRACTIVEOBJECT_H + +#include +#include + +namespace ESock { class CPreferredCarrierAvailable; } +namespace ESock { class CNewCarrierActive; } + +class MUINotify; + +class CALRActiveObject : public CActive + { +public: // Constructors and destructor + /** + * NewL is first phase of two-phased constructor. + */ + static CALRActiveObject* NewL( + MUINotify& aConsole, + MMobilityProtocolResp* aApplication); + + /** + * Destructor. + */ + ~CALRActiveObject(); + + public: // from CActive + + void RunL(); + + void DoCancel(); + + TInt RunError( TInt aError ); + + public: // New functions + + void OpenL( RCommsSubSession& aExtensionProvider ); + void MigrateToPreferredCarrier(); + void IgnorePreferredCarrier(); + void NewCarrierAccepted(); + void NewCarrierRejected(); + + private: + + /** + * C++ default constructor. + */ + CALRActiveObject( MUINotify& aConsole, MMobilityProtocolResp* aApplication ); + + /** + * By default Symbian OS constructor is private. + */ + void ConstructL(MUINotify& aConsole); + + private: // Data + // MALRApplication& iApplication; // Backpointer + // CConsoleBase& iConsole; // Pointer to console + MUINotify& iConsole; + RCommsMobilityApiExt iExtApi; + RBuf8 iResponseBuf; + MMobilityProtocolResp* iApplication; + }; + +#endif // ALRACTIVEOBJECT_H + diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/conntest.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/conntest.hrh Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: ConnTest resource header + * + */ + +#ifndef CONNTEST_HRH +#define CONNTEST_HRH + +// Constants + +// KMaxSendBuffer must be atleast 1 byte larger than KSendDataSize +// since the socketswrite will add a null termination +#define KSendDataSize 16384 +#define KReadDataSize 16384 +#define KMaxSendBuffer 32772 +#define KConnTestViews 4 +#define KMaxServerNameLength 128 + +// Enumerations + +enum TConnTestContainer + { + ESettingsContainer, + EOutputContainer, + ECustomPrefsContainer + }; + +enum TConnTestCommandIds + { + EConnTestCmdSettings = 1, + EConnTestCmdStoreSettings, // not used at the moment + EConnTestCmdStartInterface, + EConnTestCmdStartSnap, + EConnTestCmdStartInterfaceNoPrefs, + EConnTestCmdSetCustomPrefs, + EConnTestCmdStartInterfaceExtConnPrefs, + EConnTestCmdStartByNetworkId, + EConnTestCmdStopInterface, + EConnTestCmdStartInternet, + EConnTestCmdStartForClose, // not used at the moment + EConnTestCmdCloseInterface, // not used at the moment + EConnTestCmdMigrate, + EConnTestCmdIgnore, + EConnTestCmdAccept, + EConnTestCmdReject, + EConnTestCmdConnect, + EConnTestCmdDisconnect, + EConnTestCmdListen, + EConnTestCmdSendHttpGet, + EConnTestCmdSendPerformanceHttpGet, + EConnTestCmdSendHttpPost, + EConnTestCmdSendRawData, + EConnTestCmdAdvanced, + EConnTestCmdConnectionInfo, + EConnTestCmdInterfaceInfo, + EConnTestCmdClearOutputWindow, + EConnTestCmdHttpFrameworkGet, + EConnTestCmdHttpFrameworkPost, + EConnTestCmdHttpFrameworkSecureGet, + EConnTestCmdHttpFrameworkPerformanceGet, + EConnTestCmdHttpFrameworkPerformancePost, + EConnTestCmdCancel, + EConnTestCmdTimeoutLastSocketActivity, + EConnTestCmdTimeoutLastSocketClosed, + EConnTestCmdTimeoutLastSessionClosed, + EConnTestCmdConnectionPrefsIap, + EConnTestCmdWLANQoSVoice, + EConnTestCmdWLANQoSVideo, + EConnTestCmdWLANQoSBestEffort, + EConnTestCmdWLANQoSBackground, + EConnTestCmdWLANQoSNone, + EConnTestCmdQoS1, + EConnTestCmdParallelGet, + EConnTestCmdIpLog, + EConnTestCmdStartIpLog, + EConnTestCmdStopIpLog, + EConnTestCmdSendIpLog, + EConnTestWlanAvailableIaps, + EConnTestWlanScan, + EConnTestWlanDir, + EConnTestWlanGetSsid, + EConnTestWlanGetBssid, + EConnTestWlanGetRssi, + EConnTestWlanGetConnMode, + EConnTestWlanGetSecurityMode + }; + +enum TConnTestTabViewId + { + EConnTestView1Tab = 1, + EConnTestView2Tab, + EConnTestView3Tab, + EConnTestView4Tab + }; + +enum TConnTestSettingItems + { + EConnTestIpAddress = 1, + EConnTestPort, + EConnTestProtocol, + EConnTestPacketSize, + EConnTestPackets, + EConnTestDelay, + EConnTestRoaming, + EConnTestHttpPage + }; + +// Must be in correct orded, these are checked against the menu index +enum TConnTestExtConnPrefsItems + { + EConnTestExtConnPrefsItemSnapPurpose = 0, + EConnTestExtConnPrefsItemSnapId, + EConnTestExtConnPrefsItemIapId, + EConnTestExtConnPrefsItemBearerSet, + EConnTestExtConnPrefsItemNoteBehaviour, + EConnTestExtConnPrefsItemDisconnectDialog, + EConnTestExtConnPrefsItemConnSelectionDialog, + EConnTestExtConnPrefsItemForcedRoaming + }; + +#endif // CONNTEST_HRH diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/conntest.loc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/conntest.loc Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This is a localisation file for ConnTest +* +*/ + +// LOCALISATION STRINGS + +//d:Command in options menu. +//d:Example application spesific command. +//l:list_single_popup_submenu_pane_1 +// +#define qtn_appl_option_item "" + +//d:Command in options menu. +//d:Example command for view 1. +//l:list_single_popup_submenu_pane_1 +// +#define qtn_view1_option_item "" + +//d:Command in options menu. +//d:Example command for view 2. +//l:list_single_popup_submenu_pane_1 +// +#define qtn_view2_option_item "" + +//d:Name of the view 1 tab. +//d: +//l: +// +#define qtn_view1_tab "View1" + +//d:Name of the view 2 tab. +//d: +//l: +// +#define qtn_view2_tab "View2" + +// example caption strings for app +#define qtn_app_caption_string "ConnTest" + +#define qtn_app_short_caption_string "ConnTest" + +//d:String shown when querying the number of parallel gets. +//d: +//l: +// +#define qtn_aknatquery_num_label_text "# of parallel GETs" + + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/datasendnotifyhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/datasendnotifyhandler.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MDataSendNotifyHandler is an interface to notify about +* the amount of data sent +* +*/ + +#ifndef __DATASENDNOTIFYHANDLER_H__ +#define __DATASENDNOTIFYHANDLER_H__ + + +/** +* Class that specifies the functions for handling data sending +* notify messages +*/ +class MDataSendNotifyHandler +{ +public: + /** + * Tells how many packets have been sent + */ + virtual void NotifySend(TInt aAmount) = 0; +}; + +#endif //__DATASENDNOTIFYHANDLER_H__ \ No newline at end of file diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/ipdumpengine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/ipdumpengine.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CIpdumpEngine is used to control the ip logging protocol +* +*/ + +#include + +class CIpdumpEngine : public CBase + { +public: + static CIpdumpEngine* NewL(); + virtual ~CIpdumpEngine(); + + void EnableLoggingL(); + void DisableLogging(); + + TBool LoggingEnabled() const; + const TDesC& LogFileName() const; + +private: + CIpdumpEngine(); + void ConstructL(); + + void CheckProtocolFilesL(); + TInt CreateLogDirectory(); + +private: + RSocketServ iSocketServ; + RSocket iSocket; + TBool iLoggingEnabled; + TName iLogFileName; + }; diff -r 000000000000 -r 857a3e953887 nettools/conntest/inc/uinotify.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/inc/uinotify.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface class for displaying notifications. +* +*/ + +#ifndef __UINOTIFY_H__ +#define __UINOTIFY_H__ + + +/** +* This class specifies the console output functions. It +* can be used in conjunction with any class that want to +* display notifications in output window of the container. +*/ +class MUINotify +{ +public: + + /** + * Displays the descriptor as text (with attributes) on the console + * @param the text to be displayed + * @param attributes e.g. CEikGlobalTextEditor::EItalic + */ + virtual void PrintNotify(const TDesC& aMessage, TUint aAttributes = 0) = 0; + + /** + * Displays the descriptor as text (with attributes) on the console + * @param the text to be displayed + * @param attributes e.g. CEikGlobalTextEditor::EItalic + */ + virtual void PrintNotify(const TDesC8& aMessage, TUint aAttributes = 0) = 0; + + /** + * Displays the integer as a decimal number on the console + * @param aNumber the number to be displayed + */ + virtual void PrintNotify(TInt aNumber) = 0; + + /** + * Displays an error message + * @param aErrMessage error message text + * @param aErrCode error code number + */ + virtual void ErrorNotify(const TDesC& aErrMessage, TInt aErrCode) = 0; + + /** + * Notify user with a message + * @param aMessage message associated + */ + virtual void PopupNotify(const TDesC& aMessage) = 0; + + /** + * Displays the text in the 'status' window + * @param aStatus new status description text + */ + virtual void SetStatus(const TDesC& aStatus) = 0; +}; + +#endif \ No newline at end of file diff -r 000000000000 -r 857a3e953887 nettools/conntest/install/ConnTest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/install/ConnTest.pkg Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,46 @@ +; +; Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: This is the package file for ConnTest SIS creation +; + +; +; Installation file for ConnTest application +; +;Languages +&EN +; +; UID is the app's UID +; +#{"ConnTest"},(0x101F6D2B),1,6,0,TYPE=SA +; +; Supports Series 60 v 3.0 +[0x101F7961], 0, 0, 0, {"Series60ProductID"} + +; Localised Vendor name +%{"Nokia Test EN"} + +; Unique Vendor name +:"Nokia" + +;Files to install +"\epoc32\data\Z\private\10003a3f\apps\ConnTest_reg.rsc"-"!:\private\10003a3f\import\apps\ConnTest_reg.rsc" +"\epoc32\release\armv5\urel\ConnTest.exe"-"!:\sys\bin\ConnTest.exe" +"\epoc32\data\Z\Resource\apps\ConnTest_AIF.mbm"-"!:\resource\apps\ConnTest_AIF.mbm" +"\epoc32\data\Z\Resource\apps\ConnTest_AIF.mif"-"!:\resource\apps\ConnTest_AIF.mif" +"\epoc32\data\Z\Resource\apps\ConnTest.rsc" -"!:\resource\apps\ConnTest.rsc" +"\epoc32\winscw\c\private\101f7989\Esock\ip.probe.esk" -"!:\private\101f7989\import\esock\ip.probe.esk" +"\epoc32\release\armv5\urel\probe.prt" -"!:\sys\bin\probe.prt" + +;@"..\probe\install\probe-x.sis",(0x101F6D2C) + diff -r 000000000000 -r 857a3e953887 nettools/conntest/probe/EABI/probeU.DEF --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/probe/EABI/probeU.DEF Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,9 @@ +EXPORTS + Install @ 1 NONAME + _ZTI14CProtocolProbe @ 2 NONAME ; ## + _ZTI14CProviderProbe @ 3 NONAME ; ## + _ZTI20CProtocolFamilyProbe @ 4 NONAME ; ## + _ZTV14CProtocolProbe @ 5 NONAME ; ## + _ZTV14CProviderProbe @ 6 NONAME ; ## + _ZTV20CProtocolFamilyProbe @ 7 NONAME ; ## + diff -r 000000000000 -r 857a3e953887 nettools/conntest/probe/bmarm/probeu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/probe/bmarm/probeu.def Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,3 @@ +EXPORTS + Install @ 1 NONAME R3UNUSED ; (null) + diff -r 000000000000 -r 857a3e953887 nettools/conntest/probe/bwins/probeu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/probe/bwins/probeu.def Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,3 @@ +EXPORTS + Install @ 1 NONAME + diff -r 000000000000 -r 857a3e953887 nettools/conntest/probe/data/probe.esk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/probe/data/probe.esk Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,8 @@ +[sockman] +protocols= probe + +[probe] +filename= probe.prt +bindto= ip6 +index= 1 + diff -r 000000000000 -r 857a3e953887 nettools/conntest/probe/group/ABLD.BAT --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/probe/group/ABLD.BAT Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,15 @@ +@ECHO OFF + +REM Bldmake-generated batch file - ABLD.BAT +REM ** DO NOT EDIT ** + +perl -S ABLD.PL "\ConnTest-vesjokin\ConnTest\probe\group\\" %1 %2 %3 %4 %5 %6 %7 %8 %9 +if errorlevel==1 goto CheckPerl +goto End + +:CheckPerl +perl -v >NUL +if errorlevel==1 echo Is Perl, version 5.003_07 or later, installed? +goto End + +:End diff -r 000000000000 -r 857a3e953887 nettools/conntest/probe/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/probe/group/bld.inf Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file for project probe +* +*/ + +#include + +PRJ_PLATFORMS + +PRJ_EXPORTS +//Export of these esk files is commented out, so that the plug-ins +//do not get activated accidentaly +//../data/probe.esk /epoc32/data/z/system/data/ip.probe.esk +//../data/probe.esk /epoc32/wins/c/system/data/probe.esk +../data/probe.esk /epoc32/winscw/c/private/101f7989/Esock/ip.probe.esk +../data/probe.esk /epoc32/data/c/private/101f7989/Esock/ip.probe.esk + +PRJ_MMPFILES +probe.mmp + +PRJ_TESTMMPFILES + diff -r 000000000000 -r 857a3e953887 nettools/conntest/probe/group/probe.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/probe/group/probe.mmp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The project specification file for probe +* +*/ + +#include +MACRO EPOC_SDK=0x07010000 + +TARGET probe.prt +TARGETTYPE dll + +UID 0x10003D38 0x101F6D2C + +VENDORID VID_DEFAULT +// CAPABILITY ALL -TCB +CAPABILITY CommDD PowerMgmt ReadDeviceData WriteDeviceData TrustedUI ProtServ NetworkControl NetworkServices LocalServices ReadUserData WriteUserData // as c32 process + +SOURCEPATH ../src + +SOURCE family.cpp prt.cpp sap.cpp + +USERINCLUDE ../inc +APP_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib esock.lib inhook6.lib nifman.lib +LIBRARY efsrv.lib esocksvr.lib mbufmgr.lib + diff -r 000000000000 -r 857a3e953887 nettools/conntest/probe/inc/family.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/probe/inc/family.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Packet probe hook +* +*/ + +#ifndef __PROBE_FAMILY_H +#define __PROBE_FAMILY_H + +const TUint16 KAfProbe = 0x08b6; //Dummy value + +enum TProbePanic +{ + EProbePanic_BadBind, + EProbePanic_NotSupported, + EProbePanic_NoData +}; + +void Panic(TProbePanic aPanic); + +#endif diff -r 000000000000 -r 857a3e953887 nettools/conntest/probe/inc/prt.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/probe/inc/prt.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Packet probe hook +* +*/ + +#ifndef __PROBE_PRT_H +#define __PROBE_PRT_H + +#include +#include +#include +#include +#include + +#include "family.h" + +class CProviderProbe; + +class CProtocolProbe : public CProtocolPosthook +{ + friend class CProviderProbe; + CProtocolProbe(TUint aId); + virtual ~CProtocolProbe(); +public: + virtual void InitL(TDesC& aTag); + virtual void StartL(); + virtual void Identify(TServerProtocolDesc *aDesc) const; + static void Identify(TServerProtocolDesc& aDesc, TUint aId); + static CProtocolProbe *NewL(TUint aId); + + virtual void NetworkAttachedL(); + virtual TInt Send(RMBufChain &aPacket, CProtocolBase* aSrc); + virtual void Process(RMBufChain &aPacket, CProtocolBase* aSrc); + + virtual CServProviderBase* NewSAPL(TUint aProtocol); + void CancelSAP(CServProviderBase *aSAP); +protected: + void Dump(RMBufChain &aPacket); + void LibcapDumpFileHeader(); + void LibcapDump(const TDesC8& aBuffer, TUint32 aTimeStampSecs, TUint32 aTimeStampMicros); + void Queue(RMBufChain &aPacket); + static TInt DumpCb(TAny* aThisPtr); + void DumpQueuedPackets(); + +protected: + TTime iTimeOrigin; + const TUint iId; + CProviderProbe *iList; + CAsyncCallBack iDumpCb; + RMBufPktQ iQueue; + RFs iFs; + RFile iFile; + RBuf8 iBuf; + TBool iFileServerOpen; + TBool iFileOpen; + TBool iBufCreated; +}; + +#endif diff -r 000000000000 -r 857a3e953887 nettools/conntest/probe/inc/sap.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/probe/inc/sap.h Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Packet probe hook +* +*/ + +#ifndef __PROBE_SAP_H +#define __PROBE_SAP_H + +#include "prt.h" +#include "family.h" + + +class CProviderProbe : public CServProviderBase +{ + friend class CProtocolProbe; +public: + CProviderProbe(CProtocolProbe* aProtocol); + virtual ~CProviderProbe(); + + //These might be useful + virtual void Start(); + virtual TInt GetOption(TUint level,TUint name,TDes8& anOption) const; + virtual TInt SetOption(TUint level,TUint name,const TDesC8 &anOption); + virtual void Ioctl(TUint level,TUint name,TDes8* anOption); + virtual void CancelIoctl(TUint aLevel,TUint aName); + + virtual TUint Write(const TDesC8& aDesc,TUint options, TSockAddr* aAddr=NULL); + virtual void GetData(TDes8& aDesc,TUint options,TSockAddr* anAddr=NULL); + + void Process(RMBufChain& aPacket, CProtocolBase *aSourceProtocol); + + //These do nothing + virtual void LocalName(TSockAddr& /*anAddr*/) const + { Panic(EProbePanic_NotSupported); } + inline virtual void RemName(TSockAddr& /*anAddr*/) const + { Panic(EProbePanic_NotSupported); } + inline virtual void ActiveOpen() + { Panic(EProbePanic_NotSupported); } + inline virtual void ActiveOpen(const TDesC8& /*aConnectionData*/) + { Panic(EProbePanic_NotSupported); } + virtual void Shutdown(TCloseType aOption); + virtual void Shutdown(TCloseType aOption, const TDesC8& aDisconnectionData); + virtual void AutoBind(); + virtual TInt SetLocalName(TSockAddr& /*anAddr*/); + + inline virtual TInt SetRemName(TSockAddr& /*anAddr*/) + { Panic(EProbePanic_NotSupported); return 0; } + inline virtual TInt PassiveOpen(TUint /*aQueSize*/) + { Panic(EProbePanic_NotSupported); return 0; } + inline virtual TInt PassiveOpen(TUint /*aQueSize*/,const TDesC8& /*aConnectionData*/) + { Panic(EProbePanic_NotSupported); return 0; } + + void Error(TInt aError, TUint aOperationMask); + inline TBool FatalState() { return (iErrorMask & (MSocketNotify::EErrorFatal|MSocketNotify::EErrorConnect)) != 0; } +protected: + CProtocolProbe *const iProtocol; + CProviderProbe *iNext; + // + // IsReceiving is intended for the protocol side. It is can be used by + // the protocol side "Deliver" method to ask if this SAP is willing to + // receive packets associated with the specified id. + virtual TBool IsReceiving(const RMBufPktInfo &info); + + RMBufPktQ iRecvQ; + // + // iQueueLimit is used to control how much buffered data is allowed + // to be in the iRecvQ, before "congestion" control hits. The value counts + // bytes in iRecvQ in following way + // - if iQueueLimit < 0, then incoming packet is dropped (= "congestion") + // - if iQueueLimit >= 0, then incoming packet is added into iRecvQ, and + // the length of the packet is subtracted from the iQueueLimit. When + // GetData removes the packet from the queue, the length is added back + // to iQueueLimit. + // Thus, if left as initial value (= 0), only one packet at time can be + // queued. If initialized to 8000, then at most 8000 bytes and 1 packet + // can be queued at any point. + TInt iQueueLimit; + TInt iPacketsDropped; // Count packets dropped due "congestion" + TBool iInputStopped:1; + TUint iErrorMask; + }; + +#endif diff -r 000000000000 -r 857a3e953887 nettools/conntest/probe/src/family.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/probe/src/family.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Packet probe hook +* +*/ + +#include +#include "family.h" +#include "prt.h" +// +// Nothing interesting here... +// +GLDEF_C TInt E32Dll() + { + return KErrNone; + } + +class CProtocolFamilyProbe : public CProtocolFamilyBase + { +public: + CProtocolFamilyProbe(); + ~CProtocolFamilyProbe(); + TInt Install(); + TInt Remove(); + TUint ProtocolList(TServerProtocolDesc *& aProtocolList); + CProtocolBase* NewProtocolL(TUint /*aSockType*/, TUint aProtocol); + }; + +extern "C" { IMPORT_C CProtocolFamilyBase* Install(); } +EXPORT_C CProtocolFamilyBase* Install() + { + // Due to naming convention this cannot leave + // However null return value handled correctly in the caller... + return new CProtocolFamilyProbe; + } + +//---------------------------------------------------------------------- +// Dummy protocol family declaration. Required for DLL's +// + +CProtocolFamilyProbe::CProtocolFamilyProbe() + { +// __DECLARE_NAME(_S("CProtocolFamilyProbe")); + } + +CProtocolFamilyProbe::~CProtocolFamilyProbe() + { + } + +TInt CProtocolFamilyProbe::Install() + { + return KErrNone; + } + +TInt CProtocolFamilyProbe::Remove() + { + return KErrNone; + } + +TUint CProtocolFamilyProbe::ProtocolList(TServerProtocolDesc *& aList) + { + aList = new TServerProtocolDesc[2]; + if (aList == NULL) + return 0; + + CProtocolProbe::Identify(aList[0], 1); + CProtocolProbe::Identify(aList[1], 2); + return 2; + } + + +CProtocolBase* CProtocolFamilyProbe::NewProtocolL(TUint /*aSockType*/, + TUint aProtocol) + { + return CProtocolProbe::NewL(aProtocol); + } + +void Panic(TProbePanic aPanic) + { + User::Panic(_L("PROBE"), aPanic); + } diff -r 000000000000 -r 857a3e953887 nettools/conntest/probe/src/prt.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/probe/src/prt.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,354 @@ +/* +* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Packet probe hook +* +*/ + +#include +#include +#include +#include +#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS +#include +#endif + + +#include "family.h" +#include "prt.h" +#include "sap.h" + +_LIT(KTcpDumpFolder, "tcpdump\\"); +_LIT(KProbeDumpFile, "probe.cap"); +_LIT(KLogFolder, "c:\\logs\\"); + + +CProtocolProbe::CProtocolProbe(TUint aId) : +iId(aId), +iDumpCb(CActive::EPriorityStandard), +iFileServerOpen(EFalse), +iFileOpen(EFalse), +iBufCreated(EFalse) + { + + iTimeOrigin.UniversalTime(); + + TCallBack cbFunc(DumpCb, this); + iDumpCb.Set(cbFunc); + } + +void CProtocolProbe::InitL(TDesC& aTag) + { + + CProtocolBase::InitL(aTag); + } + +void CProtocolProbe::StartL() + { + } + +CProtocolProbe::~CProtocolProbe() + { + if(iFileOpen) + { + iFile.Close(); + iFileOpen = EFalse; + } + if(iFileServerOpen) + { + iFs.Close(); + iFileServerOpen = EFalse; + } + if(iBufCreated) + { + iBuf.Close(); + iBufCreated = EFalse; + } + } + +CProtocolProbe *CProtocolProbe::NewL(TUint aId) + { + + return new (ELeave) CProtocolProbe(aId); + } + +void CProtocolProbe::Identify(TServerProtocolDesc& anEntry, TUint aId) + { + + anEntry.iName=_S("probe"); + if (aId > 1) + { + anEntry.iName.AppendNum(aId-1); + } + + anEntry.iAddrFamily = KAfProbe; + anEntry.iSockType = KSockDatagram; + anEntry.iProtocol = aId; + anEntry.iVersion = TVersion(1, 0, 0); + anEntry.iByteOrder = EBigEndian; + anEntry.iServiceInfo = KSIDatagram | KSIConnectionLess; + anEntry.iNamingServices = 0; + anEntry.iSecurity = KSocketNoSecurity; + anEntry.iMessageSize = 0xffff; + anEntry.iServiceTypeInfo = ESocketSupport; + anEntry.iNumSockets = KUnlimitedSockets; + } + +void CProtocolProbe::Identify(TServerProtocolDesc *aDesc) const + { + + Identify(*aDesc, iId); + } + +CServProviderBase* CProtocolProbe::NewSAPL(TUint aProtocol) + { + + if (aProtocol != KSockDatagram) + { + User::Leave(KErrNotSupported); + } + + CProviderProbe* sap = new (ELeave) CProviderProbe(this); + sap->iNext = iList; + iList = sap; + return sap; + } + +// +// CProtocolProbe::CancelSAP +// ************************* +// Disconnect SAP from the protocol +// +void CProtocolProbe::CancelSAP(CServProviderBase *aSAP) + { + + CProviderProbe **h, *sap; + for (h = &iList; (sap = *h) != NULL; h = &sap->iNext) + if (sap == aSAP) + { + *h = sap->iNext; + break; + } + } + +// CProtocolProbe::NetworkAttachedL +// ******************************** +// When network becomes available, do the hooking! +// +void CProtocolProbe::NetworkAttachedL() + { + + NetworkService()->BindL(this, MIp6Hook::BindPostHook()); + NetworkService()->BindL(this, MIp6Hook::BindPostHook()+1); + + // initialise dump file + if(iFileOpen) + { + iFile.Close(); + iFileOpen = EFalse; + } + if(iFileServerOpen) + { + iFs.Close(); + iFileServerOpen = EFalse; + } + + User::LeaveIfError(iFs.Connect()); + iFileServerOpen = ETrue; + TBuf<50> filename; + filename.Append(KLogFolder); + filename.Append(KTcpDumpFolder); + filename.Append(KProbeDumpFile); + User::LeaveIfError(iFile.Replace(iFs, filename, EFileWrite)); + iFileOpen = ETrue; + + // allocate buffer + if(!iBufCreated) + { + iBuf.CreateL(65535); + iBufCreated = ETrue; + } + + LibcapDumpFileHeader(); + } + +// +// CProtocolProbe::Dump +// *********************** +// Log the packet to file +// +void CProtocolProbe::Dump(RMBufChain &aPacket) + { + + RMBufPacket packet; + packet.Assign(aPacket); + RMBufPktInfo* info = packet.Unpack(); + + TUint32 secs = static_cast(info->iProtocol); + TUint32 micros = static_cast(info->iFlags); + + iBuf.SetMax(); + packet.CopyOut(iBuf, 0); + if(iBuf.Length() != info->iLength) + { + iBuf.SetLength(info->iLength); + } + LibcapDump(iBuf, secs, micros); + packet.Free(); + } + +TInt CProtocolProbe::Send(RMBufChain &aPacket, CProtocolBase* aSrc) + { + + Queue(aPacket); + return CProtocolPosthook::Send(aPacket, aSrc); + } + +void CProtocolProbe::Process(RMBufChain &aPacket, CProtocolBase* aSrc) + { + + Queue(aPacket); + CProtocolPosthook::Process(aPacket, aSrc); + } + +void CProtocolProbe::LibcapDumpFileHeader() +// +// Dump file header in a format compatible with Libcap +// +// Format is: +// +// struct FileHeader +// { +// TUint32 magic; +// TUint16 version_major; +// TUint16 version_minor; +// TUint32 thiszone; /* gmt to local correction */ +// TUint32 sigfigs; /* accuracy of timestamps */ +// TUint32 snaplen; /* max length saved portion of each pkt */ +// TUint32 linktype; /* data link type (LINKTYPE_*) */ +// }; +// +// Note LINKTYPE specified in libpcap/bpf/net/bpf.h (see www.tcpdump.org) +// + { + + TBuf8 fileHeader; + *((TUint32*) &(fileHeader.Ptr()[0])) = 0xa1b2c3d4; + *((TUint16*) &(fileHeader.Ptr()[4])) = 0x02; + *((TUint16*) &(fileHeader.Ptr()[6])) = 0x04; + *((TUint32*) &(fileHeader.Ptr()[8])) = 0x00; + *((TUint32*) &(fileHeader.Ptr()[12])) = 0x00; + *((TUint32*) &(fileHeader.Ptr()[16])) = 0xffff; + *((TUint32*) &(fileHeader.Ptr()[20])) = 12; // DLT_RAW 12 /* raw IP */ + fileHeader.SetLength(fileHeader.MaxLength()); + + iFile.Write(fileHeader); + } + +void CProtocolProbe::LibcapDump(const TDesC8& aBuffer, TUint32 aTimeStampSecs, TUint32 aTimeStampMicros) +// +// Dumps a packet in a format compatbible with Libcap +// +// For each record the format is: +// +// struct record +// { +// TUint32 sec; /* time stamp - secs*/ +// TUint32 usec; /* time stamp - microsecs*/ +// TUint32 captureLen; /* length packet captured */ +// TUint32 packetLen; /* total length of packet*/ +// }; +// +// Byte ordering of the header is little endian +// Byte ordering of the packet is network byte order (big endian) +// + { + + TBuf8 recordHeader; + recordHeader.FillZ(); + + *((TUint32*) &(recordHeader.Ptr()[0])) = aTimeStampSecs; + *((TUint32*) &(recordHeader.Ptr()[4])) = aTimeStampMicros; + *((TUint32*) &(recordHeader.Ptr()[8])) = aBuffer.Length(); + *((TUint32*) &(recordHeader.Ptr()[12])) = aBuffer.Length(); + recordHeader.SetLength(recordHeader.MaxLength()); + + iFile.Write(recordHeader); + iFile.Write(aBuffer); + } + +void CProtocolProbe::Queue(RMBufChain &aPacket) +// +// Takes a copy of aPacket, adds it to the queue and triggers the callback +// + { + + RMBufPacketBase copy; + TRAPD(err, copy.CopyPackedL(aPacket)); + if (err == KErrNone) + { + + // + // Calculate packet time-stamp + // + TTime newTime; + newTime.UniversalTime(); + TTimeIntervalMicroSeconds interval = newTime.MicroSecondsFrom(iTimeOrigin); + + const TInt KMicrosInASecond = 1000000; + + //TUint32 micros = interval.Int64().Low(); + TUint32 micros = I64LOW(interval.Int64());//.Low(); x.Low() -> I64LOW(x) + TUint32 secs = micros / KMicrosInASecond; + micros -= (secs * KMicrosInASecond); + + // + // Reuse the protocol and flags fields of + // RMBufPktInfo to store the time-stamp + // + RMBufPktInfo* info = RMBufPacket::PeekInfoInChain(copy); + info->iProtocol = static_cast(secs); + info->iFlags = static_cast(micros); + + iQueue.Append(copy); + iDumpCb.CallBack(); + } + else + { + copy.Free(); + } + } + +TInt CProtocolProbe::DumpCb(TAny* aThisPtr) +// +// Callback function - calls DumpQueuedPackets() +// + { + + CProtocolProbe* self = static_cast(aThisPtr); + self->DumpQueuedPackets(); + return KErrNone; + } + +void CProtocolProbe::DumpQueuedPackets() +// +// Dumps all packets on the queue to the log file +// + { + + RMBufPacketBase packet; + while(iQueue.Remove(packet)) + { + Dump(packet); + } + } diff -r 000000000000 -r 857a3e953887 nettools/conntest/probe/src/sap.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/probe/src/sap.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,188 @@ +/* +* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Packet probe hook +* +*/ + +#include "sap.h" + + +CProviderProbe::CProviderProbe(CProtocolProbe* aProtocol) : iProtocol(aProtocol) + { +// __DECLARE_NAME(_S("CProviderProbe")); + iQueueLimit = 8000; + } + +CProviderProbe::~CProviderProbe() + { + if (iProtocol) + iProtocol->CancelSAP(this); + } + +void CProviderProbe::Start() + { + } + +TInt CProviderProbe::GetOption(TUint /*aLevel*/, TUint /*aName*/, TDes8& /*aOption*/) const + { + return KErrNotSupported; + } + +TInt CProviderProbe::SetOption(TUint /*aLevel*/, TUint /*aName*/, const TDesC8& /*aOption*/) + { +// return KErrNotSupported; + return KErrNone; + } + +void CProviderProbe::Ioctl(TUint /*level*/,TUint /*name*/,TDes8* /*anOption*/) + { + Panic(EProbePanic_NotSupported); + } + +void CProviderProbe::CancelIoctl(TUint /*aLevel*/,TUint /*aName*/) + { + Panic(EProbePanic_NotSupported); + } + + +TUint CProviderProbe::Write(const TDesC8 &/*aDesc*/, TUint /*aOptions*/, TSockAddr* /*aAddr*/) + { + // For now, Write does nothing on probe socket + return 1; + } + +void CProviderProbe::Shutdown(TCloseType /*option*/,const TDesC8& /*aDisconnectionData*/) + { + Panic(EProbePanic_NotSupported); + } + +void CProviderProbe::Shutdown(TCloseType aOption) + { + switch(aOption) + { + case EStopInput: + iInputStopped = ETrue; + iRecvQ.Free(); + iSocket->Error(KErrNone,MSocketNotify::EErrorClose); // Complete KErrNone + break; + + case EStopOutput: + iSocket->Error(KErrNone,MSocketNotify::EErrorClose); // Complete KErrNone + break; + + default: + if (aOption != EImmediate) + iSocket->CanClose(); + } + } + +TInt CProviderProbe::SetLocalName(TSockAddr &/*aAddr*/) + { + return 0; // Ignore silently + } + +void CProviderProbe::AutoBind() + { + // Ignore silently + } + +// CProviderProbe::Error +// ********************* +// Soft errors are not immediately reported to the socket server. +// A soft error is indicated by a zero aOperationMask. +// +// The socket error can be cleared by calling this routing with +// aError == KErrNone. +// +void CProviderProbe::Error(TInt aError, TUint aOperationMask) + { + if (aError <= KErrNone && !FatalState()) + { + if (aError == KErrNone) + iErrorMask = aOperationMask; + else + iErrorMask |= aOperationMask; + if (iSocket && aOperationMask) + iSocket->Error(aError, aOperationMask); + } + } + +// +// CProviderProbe::Process() +// ************************* +// Process incoming data from the protocol object. +// +void CProviderProbe::Process(RMBufChain& aPacket, CProtocolBase * /*aSourceProtocol*/) + { + // iInputStopped is set at ShutDown() and no packets should be coming + // from the protocol after that. However, without knowing the exact + // details of the process model/threads, it could be possible that + // a Process() call has been initiated by the protocol and interrupted + // before the shutdown, thus there may be a need for this iInputStopped + // flag, although I would prefer to do without... NEED TO VERIFY IF + // iInputStopped is really needed!!! -- msa + // + if(!(iInputStopped || + (iErrorMask & (MSocketNotify::EErrorFatal|MSocketNotify::EErrorConnect|MSocketNotify::EErrorRecv)))) + { + iQueueLimit -= RMBufPacketBase::PeekInfoInChain(aPacket)->iLength; + iRecvQ.Append(aPacket); + iSocket->NewData(1); + } + else + aPacket.Free(); + } + +// CProviderProbe::IsReceiving +// *************************** +// +TBool CProviderProbe::IsReceiving(const RMBufPktInfo & /*aInfo*/) + { + if (iQueueLimit < 0) + { + // Receive Queue limit is full, cannot receive this packet + iPacketsDropped++; + return FALSE; + } + return TRUE; + } + + +// CProviderProbe::GetData +// *********************** +void CProviderProbe::GetData(TDes8 &aDesc, TUint aOptions, TSockAddr *anAddr) + { + RMBufPacketBase packet; + if (!iRecvQ.Remove(packet)) + Panic(EProbePanic_NoData); + + const RMBufPktInfo *const info = packet.Unpack(); + + packet.CopyOut(aDesc, 0); + + if (anAddr!=NULL) + *anAddr = info->iSrcAddr; + + if (aOptions & KSockReadPeek) + { + packet.Pack(); + iRecvQ.Prepend(packet); + iSocket->NewData(1); + } + else + { + iQueueLimit += info->iLength; // Allow more packets in.. + packet.Free(); + } + } diff -r 000000000000 -r 857a3e953887 nettools/conntest/rom/ConnTest.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/rom/ConnTest.iby Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ROM Image Component Include File for conntest. +* +*/ + +#ifndef __ConnTest_IBY__ +#define __ConnTest_IBY__ + + +file=ABI_DIR\BUILD_DIR\ConnTest.exe PROGRAMS_DIR\ConnTest.exe +AUTO-BITMAP=DATAZ_\APP_BITMAP_DIR\ConnTest_AIF.mbm APP_BITMAP_DIR\ConnTest_AIF.mbm +data=DATAZ_\APP_BITMAP_DIR\ConnTest_AIF.mif APP_BITMAP_DIR\ConnTest_AIF.mif + +data=ZSYSTEM\..\PRIVATE\10003A3F\APPS\ConnTEst_REG.RSC Private\10003a3f\apps\ConnTest_reg.rsc +//data=DATAZ_\PRIVATE\10003A3F\APPS\ConnTEst_REG.RSC Private\10003a3f\apps\ConnTest_reg.rsc + +data=DATAZ_\APP_RESOURCE_DIR\ConnTest.RSC APP_RESOURCE_DIR\ConnTest.rsc + +data=EPOCROOT##epoc32\data\c\private\101F7989\esock\ip.probe.esk private\101F7989\esock\ip.probe.esk +file=ABI_DIR\urel\probe.prt system\libs\probe.prt + +#endif \ No newline at end of file diff -r 000000000000 -r 857a3e953887 nettools/conntest/src/ConnTestApp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/src/ConnTestApp.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The application class for ConnTest +* +*/ + +// INCLUDE FILES +#include +#include "ConnTestApp.h" +#include "ConnTestDocument.h" + +// ================= OTHER EXPORTED FUNCTIONS ============== +// +// --------------------------------------------------------- +// NewApplication() +// Constructs CConnTestApp +// Returns: created application object +// --------------------------------------------------------- +// +LOCAL_C CApaApplication* NewApplication() + { + return new CConnTestApp; + } + +GLDEF_C TInt E32Main() + { + RDebug::Print(_L("ConnTest: E32Main()")); + return EikStart::RunApplication(NewApplication); + } + +// ================= MEMBER FUNCTIONS ======================= +// --------------------------------------------------------- +// CConnTestApp::AppDllUid() +// Returns application UID +// --------------------------------------------------------- +// +TUid CConnTestApp::AppDllUid() const + { + return KUidConnTest; + } + + +// --------------------------------------------------------- +// CConnTestApp::CreateDocumentL() +// Creates CConnTestDocument object +// --------------------------------------------------------- +// +CApaDocument* CConnTestApp::CreateDocumentL() + { + return CConnTestDocument::NewL( *this ); + } + +// --------------------------------------------------------- +// E32Dll(TDllReason) +// Entry point function for EPOC Apps +// Returns: KErrNone: No error +// --------------------------------------------------------- +// +/* +GLDEF_C TInt E32Dll( TDllReason ) +{ + return KErrNone; +} +*/ +// End of File + diff -r 000000000000 -r 857a3e953887 nettools/conntest/src/ConnTestAppUi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/src/ConnTestAppUi.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,368 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The application UI class for ConnTest +* +*/ + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include +#include + +#include "ConnTestAppUi.h" +#include "ConnTestView.h" +#include +#include "conntest.hrh" +#include "SettingData.h" +#include "ipdumpengine.h" + +// ================= MEMBER FUNCTIONS ======================= +// +// ---------------------------------------------------------- +// CConnTestAppUi::ConstructL() +// Default Symbian two phase constructor +// ---------------------------------------------------------- +// +void CConnTestAppUi::ConstructL() + { + RDebug::Print(_L("ConnTest: CConnTestAppUi::ConstructL()")); + BaseConstructL(); + + AknsUtils::SetAvkonSkinEnabledL( ETrue ); + + // Show tabs for main views from resources + CEikStatusPane* sp = StatusPane(); + + // Fetch pointer to the default navi pane control + iNaviPane = (CAknNavigationControlContainer*)sp->ControlL( + TUid::Uid(EEikStatusPaneUidNavi)); + + // Tabgroup has been read from resource and it were pushed to the navi pane. + // Get pointer to the navigation decorator with the ResourceDecorator() function. + // Application owns the decorator and it has responsibility to delete the object. + iDecoratedTabGroup = iNaviPane->ResourceDecorator(); + if (iDecoratedTabGroup) + { + iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl(); + } + + TUid uid; + CConnTestView* view1; + + // Create views; each view has same UI, but the data differs. + for(TInt i = 1; i <= KConnTestViews; i++) + { + RDebug::Print(_L("ConnTest: CConnTestAppUi::ConstructL() View=%d"), i); + uid.iUid = i; + view1 = new (ELeave) CConnTestView(uid, iSettingDataArray[i-1], iCustomPrefsDataArray[i-1]); + CleanupStack::PushL( view1 ); + view1->ConstructL(); + AddViewL( view1 ); // transfer ownership to CAknViewAppUi + CleanupStack::Pop(view1); // view1 + + iConnTestViews.Append(view1); + // First view must be set to default, otherwise views and their + // data are not in sync. + if(i == 1) + { + SetDefaultViewL(*view1); + } + } + } + + +// ---------------------------------------------------- +// CConnTestAppUi::CConnTestAppUi() +// Constructor +// ---------------------------------------------------- +// +CConnTestAppUi::CConnTestAppUi( + TFixedArray& aSettings, + TFixedArray& aCustomPrefs) + : iSettingDataArray(aSettings), iCustomPrefsDataArray(aCustomPrefs) + { + } + +// ---------------------------------------------------- +// CConnTestAppUi::~CConnTestAppUi() +// Destructor +// Frees reserved resources +// ---------------------------------------------------- +// +CConnTestAppUi::~CConnTestAppUi() + { + RDebug::Print(_L("ConnTest: CConnTestAppUi::~CConnTestAppUi")); + if(iIpdumpEngine) + { + delete iIpdumpEngine; + iIpdumpEngine = NULL; + } + delete iDecoratedTabGroup; + iConnTestViews.Reset(); + delete iSendUi; + // currently used with ->ExecuteLD, so deleted automatically elsewhere + // delete iWarningDialog; + } + +// ---------------------------------------------------- +// CConnTestAppUi::IsLogging() +// Is the ip packet logging on +// ---------------------------------------------------- +// +TBool CConnTestAppUi::IsLogging() + { + TBool res = EFalse; + if(iIpdumpEngine) + res = iIpdumpEngine->LoggingEnabled(); + return res; + } + +// ---------------------------------------------------- +// CConnTestAppUi::HandleStatusPaneSizeChange() +// This is called when ever the screen size has changed +// Takes care that the view components are resized +// ---------------------------------------------------- +// +void CConnTestAppUi::HandleStatusPaneSizeChange() + { + CAknViewAppUi::HandleStatusPaneSizeChange(); + for (TInt i = 0; i < KConnTestViews; i++) + { + iConnTestViews[i]->SizeChanged(); + } + } + +// ------------------------------------------------------------------------------ +// CConnTestAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) +// This function is called by the EIKON framework just before it displays +// a menu pane. Its default implementation is empty, and by overriding it, +// the application can set the state of menu items dynamically according +// to the state of application data. +// ------------------------------------------------------------------------------ +// +void CConnTestAppUi::DynInitMenuPaneL(TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/) + { + } + +// ---------------------------------------------------- +// CConnTestAppUi::HandleCommandL(TInt aCommand) +// Handles some of the users commands. +// ---------------------------------------------------- +// +void CConnTestAppUi::HandleCommandL(TInt aCommand) + { + switch ( aCommand ) + { + // Parallel GET + case EConnTestCmdParallelGet: + { + + TInt viewCount = 2; + CAknNumberQueryDialog* dlg = + CAknNumberQueryDialog::NewL(viewCount); + if( dlg->ExecuteLD(R_CONNTEST_PARALLEL_NUMBER_LAYOUT)) + { + // ask engine to handle combining. + if ((viewCount > 0) && (viewCount <= KConnTestViews)) + { + ParallelGetL(viewCount); + } + } + } + break; + // Start logging + case EConnTestCmdStartIpLog: + StartIpLoggingL(); + break; + // Stop logging + case EConnTestCmdStopIpLog: + StopIpLoggingL(); + break; + // Send log + case EConnTestCmdSendIpLog: + SendLogFileL(); + break; + + case EEikCmdExit: + SaveL(); + Exit(); + break; + + default: + break; + } + } + +// ---------------------------------------------------- +// CConnTestAppUi::HandleKeyEventL( +// const TKeyEvent& aKeyEvent,TEventCode /*aType*/) +// Handles UI key events. +// ---------------------------------------------------- +// +TKeyResponse CConnTestAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent, + TEventCode /*aType*/ ) + { + if (!iTabGroup) + { + return EKeyWasNotConsumed; + } + + TInt active = iTabGroup->ActiveTabIndex(); + TInt count = iTabGroup->TabCount(); + + switch ( aKeyEvent.iCode ) + { + case EKeyLeftArrow: + if ( active > 0 ) + { + active--; + RDebug::Print(_L("ConnTest: CConnTestAppUi::HandleKeyEventL Switching to view %d"), active); + iTabGroup->SetActiveTabByIndex( active ); + ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active))); + } + break; + case EKeyRightArrow: + if( (active + 1) < count ) + { + active++; + RDebug::Print(_L("ConnTest: CConnTestAppUi::HandleKeyEventL Switching to view %d"), active); + iTabGroup->SetActiveTabByIndex( active ); + ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active))); + } + break; + default: + return EKeyWasNotConsumed; + // break; get rid of cmpiler warning + } + + return EKeyWasConsumed; + } + +// ---------------------------------------------------------------------------- +// CConnTestView::ParallelGet +// Executes multiple HTTP gets over socket +// ---------------------------------------------------------------------------- +// +void CConnTestAppUi::ParallelGetL(TInt aCount) + { + for (TInt i = 0; i < aCount; i++) + { + if (!iConnTestViews[i]->IsReadyForHTTPGet()) + { + _LIT(KWarning, "Not enough open connections" ); + iWarningDialog = new (ELeave) CAknWarningNote(&iWarningDialog); + // notice, will be deleted automatically + iWarningDialog->ExecuteLD(KWarning); + return; + } + iConnTestViews[i]->HandleCommandL(EConnTestCmdSendPerformanceHttpGet); + } + } + +// ---------------------------------------------------- +// CConnTestAppUi::SendLogFileL() +// Launches the send ui for the ip log +// ---------------------------------------------------- +// +void CConnTestAppUi::SendLogFileL() + { + if(!iIpdumpEngine) + { + iIpdumpEngine = CIpdumpEngine::NewL(); + } + if(!iSendUi) + { + iSendUi = CSendUi::NewL(); + } + CMessageData* messageData = CMessageData::NewL(); + CleanupStack::PushL(messageData); + + // + // Since CSendUi doesn't support sending .log or .cap files, + // the file is renamed here. + // + _LIT(KNewName, "c:\\logs\\tcpdump\\probe.cap.txt"); + RFs fs; + if (fs.Connect() == KErrNone) + { + fs.Replace(iIpdumpEngine->LogFileName(), KNewName); + } + fs.Close(); + + messageData->AppendAttachmentL(KNewName); + + TSendingCapabilities cap(0, 1024, TSendingCapabilities::ESupportsAttachments); + iSendUi->ShowQueryAndSendL(messageData, cap); + CleanupStack::PopAndDestroy(messageData); // messageData + } + +// ---------------------------------------------------- +// CConnTestAppUi::StartIpLoggingL() +// Starts the logging of the ip traffic +// ---------------------------------------------------- +// +void CConnTestAppUi::StartIpLoggingL() +{ + _LIT(KLogEnabled, "IP logging enabled: " ); + _LIT(KLogError, "Error %d starting logging, Protocol not loaded. Try rebooting." ); + + if(!iIpdumpEngine) + { + iIpdumpEngine = CIpdumpEngine::NewL(); + } + if(!iIpdumpEngine->LoggingEnabled()) + { + + TRAPD(r, iIpdumpEngine->EnableLoggingL()); + if(r == KErrNone) + { + TBuf<256> tt; + tt.Format(KLogEnabled); + tt.Append(iIpdumpEngine->LogFileName()); + + CAknInformationNote* note = new (ELeave) CAknInformationNote(); + note->ExecuteLD(tt); + } + else + { + TBuf<64> tt; + tt.Format(KLogError, r); + iWarningDialog = new (ELeave) CAknWarningNote(&iWarningDialog); + // notice, will be deleted automatically + iWarningDialog->ExecuteLD(tt); + } + } +} + +// ---------------------------------------------------- +// CConnTestAppUi::StopIpLoggingL() +// Stops the logging of the ip traffic +// ---------------------------------------------------- +// +void CConnTestAppUi::StopIpLoggingL() +{ + _LIT(KLogDisabled, "IP logging disabled" ); + if(iIpdumpEngine && iIpdumpEngine->LoggingEnabled()) + { + iIpdumpEngine->DisableLogging(); + CAknInformationNote* note = new (ELeave) CAknInformationNote(); + note->ExecuteLD(KLogDisabled); + } +} + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/src/ConnTestContainer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/src/ConnTestContainer.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,455 @@ +/* + * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: The container class for ConnTest + * Shows status line and notification text editor + * + */ + +// INCLUDE FILES +#include +#include +#include +#include +#include "ConnTestContainer.h" +#include "ConnTest.pan" + + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CConnTestContainer::ConstructL(const TRect& aRect) +// EPOC two phased constructor +// --------------------------------------------------------- +// +void CConnTestContainer::ConstructL(const TRect& aRect) + { + CreateWindowL(); + Window().SetShadowDisabled(EFalse); + + SetBlank(); + + // Get an alternative font for output window. + // Note! Only NormalFont works in output window with current + // build version, alternative font doesn't. + _LIT(KMyFontName,"Arial"); + CFont* myFont; + TFontSpec myFontSpec(KMyFontName,1); // to get smallest Swiss font + CGraphicsDevice* screenDevice=iCoeEnv->ScreenDevice(); + screenDevice->GetNearestFontInTwips(myFont,myFontSpec); + //TFontSpec testFont = myFont->FontSpecInTwips(); + screenDevice->ReleaseFont(myFont); + + // construct main text display window + const CFont* font = CEikonEnv::Static()->NormalFont(); + + TFontSpec fontspec = font->FontSpecInTwips(); + + TCharFormat defaultCharFormat( fontspec.iTypeface.iName, fontspec.iHeight ); + // TCharFormat defaultCharFormat( testFont.iTypeface.iName, testFont.iHeight ); + TCharFormatMask defaultCharFormatMask; + + defaultCharFormatMask.SetAttrib(EAttFontTypeface); + defaultCharFormatMask.SetAttrib(EAttFontHeight); + + iParaFormat = CParaFormatLayer::NewL(); + iCharFormat = CCharFormatLayer::NewL(defaultCharFormat,defaultCharFormatMask); + + iRichText = CRichText::NewL(iParaFormat, iCharFormat); + + //Create bordered edit windows. + iOutputWindow = new (ELeave) CEikRichTextEditor(TGulBorder(TGulBorder::EShallowRaised)); + iOutputWindow->ConstructL(this,0,0,EEikEdwinOwnsWindow|EEikEdwinInclusiveSizeFixed| + EEikEdwinKeepDocument|EEikEdwinUserSuppliedText| + EEikEdwinLineCursor|EEikEdwinAlwaysShowSelection| + EEikEdwinReadOnly); + + iOutputWindow->SetContainerWindowL(*this); + + // Create the single line 'status' display + iStatusWindow = new (ELeave) CEikLabel; + iStatusWindow->SetContainerWindowL(*this); + iStatusWindow->SetNonFocusing(); + iStatusWindow->SetTextL(_L("Uninitialised")); + + TRect outputRect(Rect()); + TRect statusRect(Rect()); + + // Set status display to be a single line at bottom of screen + statusRect.iTl.iY = statusRect.iBr.iY - iStatusWindow->MinimumSize().iHeight; + + // Set main output window to occupy rest of screen + outputRect.iBr.iY = statusRect.iTl.iY - 1; + + // Create scrollbar show tabs + iOutputWindow->SetAknEditorFlags(EAknEditorFlagEnableScrollBars|EAknEditorFlagNoEditIndicators); + + iOutputWindow->CreateScrollBarFrameL(); + iOutputWindow->ScrollBarFrame()->SetScrollBarVisibilityL( + CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto); + + iOutputWindow->SetDocumentContentL(*iRichText,CEikEdwin::EUseText); + iOutputWindow->SetRect(outputRect); + iOutputWindow->ActivateL(); + iOutputWindow->SetFocus(ETrue); + iStatusWindow->SetRect(statusRect); + + SetRect(aRect); + ActivateL(); + iOutputWindow->UpdateScrollBarsL(); + iOutputWindow->DrawNow(); + SizeChanged(); + } + +// ---------------------------------------------------- +// CConnTestContainer::~CConnTestContainer() +// Destructor +// Frees reserved resources +// ---------------------------------------------------- +// +CConnTestContainer::~CConnTestContainer() + { + delete iParaFormat; + iParaFormat = NULL; + + delete iCharFormat; + iCharFormat = NULL; + + delete iOutputWindow; + iOutputWindow = NULL; + + delete iRichText; + iRichText = NULL; + + delete iStatusWindow; + iStatusWindow = NULL; + } + +// --------------------------------------------------------- +// CConnTestContainer::SizeChanged() +// Called by framework when the view size is changed +// --------------------------------------------------------- +// +void CConnTestContainer::SizeChanged() + { + TRect outputRect(Rect()); + TRect statusRect(Rect()); + + // Set status display to be a single line at bottom of screen + statusRect.iTl.iY = statusRect.iBr.iY - iStatusWindow->MinimumSize().iHeight; + + // Find the scrollbar rectangle. + TRect ScrollBarRect = iOutputWindow->ScrollBarFrame()->VerticalScrollBar()->Rect(); + + + // Set main output window to occupy rest of screen + outputRect.iBr.iY = statusRect.iTl.iY - 1; + outputRect.iBr.iX -= ScrollBarRect.Width(); + + iOutputWindow->SetRect(outputRect); + iOutputWindow->SetFocus(ETrue); + iStatusWindow->SetRect(statusRect); + } + +// --------------------------------------------------------- +// CConnTestContainer::CountComponentControls() const +// Note! Output window is ignored. +// --------------------------------------------------------- +// +TInt CConnTestContainer::CountComponentControls() const + { + // Return nbr of controls inside this container + // return 2; // Returning control for rich text editor makes it override navipanel. + return 2; + } + + +// --------------------------------------------------------- +// CConnTestContainer::ComponentControl(TInt aIndex) const +// Note! Output window is ignored. +// --------------------------------------------------------- +// +CCoeControl* CConnTestContainer::ComponentControl(TInt aIndex) const + { + switch ( aIndex ) + { + case 0: + return iStatusWindow; + case 1: + return iOutputWindow; + default: + return NULL; + } + } + +// --------------------------------------------------------- +// CConnTestContainer::Draw(const TRect& aRect) const +// --------------------------------------------------------- +// +void CConnTestContainer::Draw(const TRect& aRect) const + { + //CWindowGc& gc = SystemGc(); + //gc.Clear(Rect()); + CWindowGc& gc = SystemGc(); + gc.SetPenStyle(CGraphicsContext::ENullPen); + gc.SetBrushColor(KRgbWhite); + gc.SetBrushStyle(CGraphicsContext::ESolidBrush); + gc.DrawRect(aRect); + } + + +// --------------------------------------------------------- +// CConnTestContainer::HandleControlEventL( +// CCoeControl* aControl,TCoeEvent aEventType) +// --------------------------------------------------------- +// +void CConnTestContainer::HandleControlEventL( CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/ ) + { + // no implementation required. + } + + +// --------------------------------------------------------- +// CConnTestContainer::SetFontStyle(TUint aFontStyle) +// Set font style for output window. +// --------------------------------------------------------- +// +void CConnTestContainer::SetFontStyle(TUint aFontStyle) + { + // Set current main window style to match that requested + UpdateFontAttribute(aFontStyle, CEikGlobalTextEditor::EBold); + UpdateFontAttribute(aFontStyle, CEikGlobalTextEditor::EItalic); + UpdateFontAttribute(aFontStyle, CEikGlobalTextEditor::EUnderline); + } + + +// --------------------------------------------------------- +// CConnTestContainer::UpdateFontAttribute(TUint aFontStyle, +// TInt aAttribute) +// Do the real work of setting the font style. +// --------------------------------------------------------- +// +void CConnTestContainer::UpdateFontAttribute(TUint aFontStyle, + TInt aAttribute) + { + TInt error; + + // Ensure an individual attribute is on or off as requested + if ((aFontStyle & aAttribute) != (iFontStyle & aAttribute)) + { + TRAP(error, iOutputWindow->BoldItalicUnderlineEventL(aAttribute)); + if(error != KErrNone) + { + User::Panic (KPanicConnTest, EConnTestContainer); + } + iFontStyle ^= aAttribute; + } + } + + +// --------------------------------------------------------- +// CConnTestContainer::PrintNotify(const TDesC& aDes, TUint aFontStyle) +// Print text into output window. +// --------------------------------------------------------- +// +void CConnTestContainer::PrintNotify(const TDesC& aDes, TUint aFontStyle) + { + SetFontStyle(aFontStyle); + TChar ch; + TInt error; + + RDebug::Print(_L("ConnTest: %S"),&aDes); + + for (TInt i = 0; i < aDes.Length(); i++) + { + // Add linebreak if character is '\n', otherwise + // add character as it is. + ch = aDes[i] != 10 ? (TChar)aDes[i] : (TChar)CEditableText::ELineBreak; + TRAP(error, iRichText->InsertL(iOutputWindow->TextLength(), ch)); + if(error != KErrNone) + { + User::Panic (KPanicConnTest, EConnTestContainer); + } + } + + TRAP(error, iOutputWindow->NotifyNewDocumentL()); + if(error != KErrNone) + { + User::Panic (KPanicConnTest, EConnTestContainer); + } + + TRAP(error, iOutputWindow->SetCursorPosL(iOutputWindow->TextLength(), EFalse)); + if(error != KErrNone) + { + User::Panic (KPanicConnTest, EConnTestContainer); + } + } + + +// --------------------------------------------------------- +// CConnTestContainer::PrintNotify(const TDesC8& aDes, TUint aFontStyle) +// Print text into output window. +// --------------------------------------------------------- +// +void CConnTestContainer::PrintNotify(const TDesC8& aDes, TUint aFontStyle) + { + SetFontStyle(aFontStyle); + TChar ch; + TInt error; + + TBuf<128> des; + des.Copy( aDes ); + + RDebug::Print(_L("ConnTest: %S"),&des); + + TRAP(error, iRichText->InsertL(iOutputWindow->TextLength(), des)); + if(error != KErrNone) + { + User::Panic (KPanicConnTest, EConnTestContainer); + } + + TRAP(error, iOutputWindow->NotifyNewDocumentL()); + if(error != KErrNone) + { + User::Panic (KPanicConnTest, EConnTestContainer); + } + + TRAP(error, iOutputWindow->SetCursorPosL(iOutputWindow->TextLength(), EFalse)); + if(error != KErrNone) + { + User::Panic (KPanicConnTest, EConnTestContainer); + } + } + + +// --------------------------------------------------------- +// CConnTestContainer::PrintNotify(TInt aIn) +// Print integer into output window. +// --------------------------------------------------------- +// +void CConnTestContainer::PrintNotify(TInt aInt) + { + // Display number in ascii decimal + TBuf<50> buf; + buf.Num(aInt); + PrintNotify(buf); + } + + +// --------------------------------------------------------- +// CConnTestContainer::ErrorNotify(const TDesC& aErrMessage, TInt aErrCode) +// Display error message in an information window. +// --------------------------------------------------------- +// +void CConnTestContainer::ErrorNotify(const TDesC& aErrMessage, TInt aErrCode) + { + TInt error; + + // Error up call: inform user and quit + _LIT(KErrorTitle,"Error code "); + TBuf<25> errorTitleCode(KErrorTitle); + errorTitleCode.AppendNum(aErrCode); + RDebug::Print(_L("ConnTest: ErrorNotify: %S %d"), &aErrMessage, aErrCode); + TRAP(error, CEikonEnv::Static()->InfoWinL(errorTitleCode,aErrMessage)); + if(error != KErrNone) + { + User::Panic (KPanicConnTest, EConnTestContainer); + } + } + +// --------------------------------------------------------- +// CConnTestContainer::PopupNotify(const TDesC& msg) +// Display message in an information window. +// --------------------------------------------------------- +// +void CConnTestContainer::PopupNotify(const TDesC& aMessage) + { + // Error up call: inform user and quit + /* _LIT(KMsgTitle,"NOTE"); + TBuf<25> titleCode(KMsgTitle); + TRAPD(error, CEikonEnv::Static()->InfoWinL(titleCode,aMessage)); + if(error != KErrNone) + { + User::Panic (KPanicConnTest, EConnTestContainer); + } + */ + RDebug::Print(_L("ConnTest: PopupNotify: %S"), &aMessage); + CEikonEnv::Static()->InfoMsgWithDuration(aMessage, 1500000); + } + +// --------------------------------------------------------- +// CConnTestContainer::SetStatus(const TDesC& aStatus) +// Update the status line text. +// --------------------------------------------------------- +// +void CConnTestContainer::SetStatus(const TDesC& aStatus) + { + TInt error; + + // Update contents of status window + TRAP(error, iStatusWindow->SetTextL(aStatus)); + if(error != KErrNone) + { + User::Panic (KPanicConnTest, EConnTestContainer); + } + + iStatusWindow->DrawDeferred(); + } + + +// --------------------------------------------------------- +// CConnTestContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, +// TEventCode aType) +// Handle key event. Only up and down key arrow events are +// consumed in order to enable scrolling in output window. +// --------------------------------------------------------- +// +TKeyResponse CConnTestContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) + { + if(aType != EEventKey) + return EKeyWasNotConsumed; + + if(aKeyEvent.iCode == EKeyUpArrow) + { + iOutputWindow->MoveCursorL(TCursorPosition::EFLineUp,EFalse); + return EKeyWasConsumed; + } + + if(aKeyEvent.iCode == EKeyDownArrow) + { + iOutputWindow->MoveCursorL(TCursorPosition::EFLineDown,EFalse); + return EKeyWasConsumed; + } + + return EKeyWasNotConsumed; + } + +// --------------------------------------------------------- +// CConnTestContainer::ClearOutputWindow() +// Clear the output window. +// --------------------------------------------------------- +// +void CConnTestContainer::ClearOutputWindow() + { + TInt error; + + iRichText->Reset(); + TRAP(error, iOutputWindow->NotifyNewDocumentL()); + if(error != KErrNone) + { + User::Panic (KPanicConnTest, EConnTestContainer); + } + } + + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/src/ConnTestDocument.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/src/ConnTestDocument.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The document class for ConnTest, stores the settings +* +*/ + +// INCLUDE FILES +#include "ConnTestDocument.h" +#include "ConnTestAppUi.h" +#include "ConnTestApp.h" +#include "SettingData.h" +#include "CustomPrefsData.h" + +// ================= MEMBER FUNCTIONS ======================= + +// constructor +CConnTestDocument::CConnTestDocument(CEikApplication& aApp) + : CEikDocument(aApp) + { + } + +// destructor +CConnTestDocument::~CConnTestDocument() + { + RDebug::Print(_L("ConnTest: CConnTestDocument::~CConnTestDocument")); + for(TInt i = 0; i < KConnTestViews; i++) + { + delete iSettingDataArray[i]; + delete iCustomPrefsDataArray[i]; + } + } + +// Symbian default constructor can leave. +void CConnTestDocument::ConstructL() + { + RDebug::Print(_L("ConnTest: CConnTestDocument::ConstructL")); + for(TInt i = 0; i < KConnTestViews; i++) + { + iSettingDataArray[i] = CSettingData::NewL(); + iCustomPrefsDataArray[i] = CCustomPrefsData::NewL(); + } + } + +// Two-phased constructor. +CConnTestDocument* CConnTestDocument::NewL(CEikApplication& aApp) + { + CConnTestDocument* self = new (ELeave) CConnTestDocument( aApp ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// ---------------------------------------------------- +// CConnTestDocument::CreateAppUiL() +// constructs CConnTestAppUi +// ---------------------------------------------------- +// +CEikAppUi* CConnTestDocument::CreateAppUiL() + { + return new (ELeave) CConnTestAppUi(iSettingDataArray, iCustomPrefsDataArray); + } + + +// ---------------------------------------------------- +// CConnTestDocument::StoreL() +// Store current settings into file \\private\\101F6D2B\\ConnTest +// ---------------------------------------------------- +// +void CConnTestDocument::StoreL(CStreamStore& aStore, + CStreamDictionary& aStreamDic) const + { + RStoreWriteStream stream; + TStreamId id = stream.CreateLC(aStore); + for(TInt i = 0; i < KConnTestViews; i++) + { + stream << iSettingDataArray[i]->iServerName; + stream.WriteInt32L(iSettingDataArray[i]->iPort); + stream.WriteInt32L(iSettingDataArray[i]->iProtocol); + stream.WriteInt32L(iSettingDataArray[i]->iRoaming); + stream.WriteInt32L(iSettingDataArray[i]->iPacketSize); + stream.WriteInt32L(iSettingDataArray[i]->iPackets); + stream.WriteInt32L(iSettingDataArray[i]->iDelay); + stream << iSettingDataArray[i]->iHttpPage; + } + stream.CommitL(); + CleanupStack::PopAndDestroy(&stream); // stream + aStreamDic.AssignL(KUidConnTest, id); + } + + +// ---------------------------------------------------- +// CConnTestDocument::RestoreL() +// Read previous settings from file +// ---------------------------------------------------- +// +void CConnTestDocument::RestoreL(const CStreamStore& aStore, + const CStreamDictionary& aStreamDic) + { + TStreamId id = aStreamDic.At(KUidConnTest); + RStoreReadStream stream; + stream.OpenLC(aStore, id); + for(TInt i = 0; i < KConnTestViews; i++) + { + stream >> iSettingDataArray[i]->iServerName; + iSettingDataArray[i]->iPort = stream.ReadInt32L(); + iSettingDataArray[i]->iProtocol = stream.ReadInt32L(); + iSettingDataArray[i]->iRoaming = stream.ReadInt32L(); + iSettingDataArray[i]->iPacketSize = stream.ReadInt32L(); + iSettingDataArray[i]->iPackets = stream.ReadInt32L(); + iSettingDataArray[i]->iDelay = stream.ReadInt32L(); + stream >> iSettingDataArray[i]->iHttpPage; + } + CleanupStack::PopAndDestroy(&stream); // stream + } + + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/src/ConnTestView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/src/ConnTestView.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,1316 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The view class for ConnTest +* Implements command handling, menu initializing and view activation +* +*/ + +// INCLUDE FILES +#include +#include +#include +#include + +#include +#include "ConnTestView.h" +#include "ConnTestContainer.h" +#include "CustomPrefsItemList.h" +#include "CustomPrefsData.h" +#include "SettingItemList.h" +#include "SettingData.h" +#include "SocketsEngine.h" +#include "Utils.h" +#include +#include "ConnTestAppUi.h" + + +// CONSTANTS + + +// ================= MEMBER FUNCTIONS ======================= + + +// --------------------------------------------------------- +// CConnTestView::CConnTestView(const TUid aViewId) +// Constructor +// --------------------------------------------------------- +// +CConnTestView::CConnTestView(const TUid aViewId) + : iViewId(aViewId), iWaiter( NULL ) + { + RDebug::Print(_L("ConnTest: CConnTestView::CConnTestView( aViewId )")); + } + +// --------------------------------------------------------- +// CConnTestView::CConnTestView(const TUid aViewId, +// CSettingData* aSettings, +// CCustomPrefsData* aCustomPrefs) +// Constructor +// --------------------------------------------------------- +// +CConnTestView::CConnTestView(const TUid aViewId, CSettingData* aSettings, CCustomPrefsData* aCustomPrefs) + : iViewId(aViewId), iSettingData(aSettings), iCustomPrefsData(aCustomPrefs), iWaiter( NULL ) + { + RDebug::Print(_L("ConnTest: CConnTestView::CConnTestView( aViewId, aSettings, aCustomPrefs )")); + } + +// --------------------------------------------------------- +// CConnTestView::ConstructL() +// EPOC two-phased constructor +// --------------------------------------------------------- +// +void CConnTestView::ConstructL() + { + RDebug::Print(_L("ConnTest: CConnTestView::ConstructL")); + BaseConstructL( R_CONNTEST_VIEW1 ); + iSendData = HBufC8::NewL(KMaxSendBuffer); + RDebug::Print(_L("ConnTest: CConnTestView::ConstructL iWlanMgmtClient")); + TRAPD(err,iWlanMgmtClient = CWlanMgmtClient::NewL()); + if (err == KErrNone) + { + iSupportsWlan = ETrue; + } + else + { + iSupportsWlan = EFalse; + } + } + +// --------------------------------------------------------- +// CConnTestView::~CConnTestView() +// Destructor +// --------------------------------------------------------- +// +CConnTestView::~CConnTestView() + { + RDebug::Print(_L("ConnTest: CConnTestView::~CConnTestView")); + if ( iContainer ) + { + AppUi()->RemoveFromViewStack( *this, iContainer ); + } + + delete iSocketsEngine; + delete iContainer; + delete iSettingsListBox; + delete iCustomPrefsListBox; + // delete iSettingData; owned now by CConnTestDocument + if(iSendData) + { + delete iSendData; + iSendData = NULL; + + if ( iSupportsWlan && iWlanMgmtClient ) + { + iWlanMgmtClient->CancelNotifications(); + delete iWlanMgmtClient; + } + } + } + +// --------------------------------------------------------- +// TUid CConnTestView::Id() +// Return id of this view instance +// --------------------------------------------------------- +// +TUid CConnTestView::Id() const + { + //return KViewId; + return iViewId; + } + +// --------------------------------------------------------- +// CConnTestView::HandleCommandL(TInt aCommand) +// Command handler +// --------------------------------------------------------- +// +void CConnTestView::HandleCommandL(TInt aCommand) + { + switch ( aCommand ) + { + case EAknSoftkeyExit: + iSocketsEngine->Cancel(); + AppUi()->HandleCommandL(EEikCmdExit); + break; + + case EAknSoftkeyOk: + case EAknSoftkeyBack: + // Same actions for OK and Back keys. These are called + // from settings or Ext Connection Preferences view. + if (iActiveContainer == ESettingsContainer) + { + // Store settings and update the values + // in socket engine. + iSettingsListBox->StoreSettingsL(); + iSocketsEngine->SetConnectionData(iSettingData); + } + else // ECustomPrefsContainer + { + // Store the custom preferences and update the values + // in socket engine. + iCustomPrefsListBox->StoreSettingsL(); + iSocketsEngine->SetCustomPrefsData(iCustomPrefsData); + } + SwapContainerL(EOutputContainer); + break; + + case EConnTestCmdStartInterface: + // Start the interface + iSocketsEngine->StartInterfaceL(CSocketsEngine::EAskIap); + break; + + case EConnTestCmdStartSnap: + //start connection with snap + iSocketsEngine->StartConnWithSnapL(); + break; + + case EConnTestCmdStartInterfaceExtConnPrefs: + // Start the interface using Extended Connection Preferences + RDebug::Print(_L("ConnTest: Start ExtConnPrefs")); + iSocketsEngine->StartInterfaceL(CSocketsEngine::EExtPrefs); + break; + + case EConnTestCmdStartInternet: + // Start the interface using Extended Connection Preferences + RDebug::Print(_L("ConnTest: Start Internet")); + iSocketsEngine->StartInterfaceL(CSocketsEngine::EExtPrefsInternet); + break; + + case EConnTestCmdStartInterfaceNoPrefs: + // Start the interface + iSocketsEngine->StartInterfaceL(CSocketsEngine::ENoPrefs); + break; + + case EConnTestCmdStartByNetworkId: + // Start the interface with network id + iSocketsEngine->StartInterfaceL(CSocketsEngine::ENetworkId); + break; + + case EConnTestCmdStopInterface: + // Stop the interface with RConnection::Stop + iSocketsEngine->StopInterfaceL(); + break; + + case EConnTestCmdStartForClose: + // Stop the interface with RConnection::Close + iSocketsEngine->StartCloseInterfaceL(); + break; + + case EConnTestCmdCloseInterface: + // Stop the interface with RConnection::Close + iSocketsEngine->CloseInterface(); + break; + + case EConnTestCmdConnectionInfo: + // Print information about the active connections + iSocketsEngine->ConnectionInfoL(); + break; + + case EConnTestCmdInterfaceInfo: + // Print information about interfaces. Show wait note here, + // because this usually takes a while. + { + TInt permanentNoteId; + CAknGlobalNote* globalNote = CAknGlobalNote::NewL(); + CleanupStack::PushL(globalNote); + globalNote->SetSoftkeys(R_AVKON_SOFTKEYS_EMPTY); + permanentNoteId = globalNote->ShowNoteL( EAknGlobalWaitNote, _L("Fetching information...") ); + + iSocketsEngine->InterfaceInfoL(); + + globalNote->CancelNoteL(permanentNoteId); + CleanupStack::PopAndDestroy(globalNote); // globalNote + } + break; + + case EConnTestCmdClearOutputWindow: + // Clear the output window + iContainer->ClearOutputWindow(); + break; + + case EConnTestCmdSettings: + // Display settings list + SwapContainerL(ESettingsContainer); + break; + + case EConnTestCmdSetCustomPrefs: + // Display Custom Preferences list + SwapContainerL(ECustomPrefsContainer); + break; + + case EConnTestCmdMigrate: + iSocketsEngine->Migrate(); + break; + case EConnTestCmdIgnore: + iSocketsEngine->Ignore(); + break; + case EConnTestCmdAccept: + iSocketsEngine->AcceptCarrier(); + break; + case EConnTestCmdReject: + iSocketsEngine->RejectCarrier(); + break; + case EConnTestCmdConnect: + // Connect the socket + iSocketsEngine->ConnectL(); + break; + + case EConnTestCmdDisconnect: + // Disconnect the socket but do not stop the interface + iSocketsEngine->Disconnect(); + break; + + case EConnTestCmdListen: + // Create TCP socket that listens and receives raw TCP data + iSocketsEngine->ListenL(); + break; + + case EConnTestCmdSendHttpGet: + { + // Send HTTP Get + iSocketsEngine->SendHttpRequestOverSocketL(EFalse, EFalse); + } + break; + + case EConnTestCmdSendPerformanceHttpGet: + { + // Send HTTP Get + if (iSocketsEngine->GetSocketEngineState() == CSocketsEngine::EConnected) + { + iSocketsEngine->SendHttpRequestOverSocketL(EFalse, ETrue); + } + } + break; + + case EConnTestCmdSendHttpPost: + { + // Send HTTP Post + iSocketsEngine->SendHttpRequestOverSocketL(ETrue, ETrue); + } + break; + + case EConnTestCmdSendRawData: + // Send datagrams + CreateDataPacket(); + SendDataL(); + break; + + case EConnTestCmdHttpFrameworkGet: + // Send HTTP request (for testing the HTTP framework) + iSocketsEngine->SendHttpFrameworkRequestL(EFalse, EFalse, EFalse); + break; + + case EConnTestCmdHttpFrameworkPost: + // Send HTTP request (for testing the HTTP framework) + iSocketsEngine->SendHttpFrameworkRequestL(ETrue, EFalse, EFalse); + break; + + case EConnTestCmdHttpFrameworkSecureGet: + // Send HTTP request (for testing the HTTP framework) + iSocketsEngine->SendHttpFrameworkRequestL(EFalse, EFalse, ETrue); + break; + + case EConnTestCmdHttpFrameworkPerformanceGet: + // Send HTTP request (for testing the HTTP framework) + iSocketsEngine->SendHttpFrameworkRequestL(EFalse, ETrue, EFalse); + break; + + case EConnTestCmdHttpFrameworkPerformancePost: + // Send HTTP request (for testing the HTTP framework) + iSocketsEngine->SendHttpFrameworkRequestL(ETrue, ETrue, EFalse); + break; + + case EConnTestCmdCancel: + // Cancel ongoing operation + iSocketsEngine->Cancel(); + break; + + case EConnTestCmdConnectionPrefsIap: + // Write IapId value to ConnectionPreferences table + TRAPD(err, Utils::SetConnectionPrefsIapL()); + if(err) + { + if(err == KErrNotFound) + { + iContainer->ErrorNotify(_L("Non-existing id"), err); + } + else + { + iContainer->ErrorNotify(_L("Setting id failed"), err); + } + } + break; + + case EConnTestCmdTimeoutLastSocketActivity: + // Set LastSocketActivity + TRAPD(err2, Utils::SetTimeoutsL(EConnTestCmdTimeoutLastSocketActivity)); + if(err2) + { + iContainer->ErrorNotify(_L("Failed to set timer"), err2); + } + break; + + case EConnTestCmdTimeoutLastSocketClosed: + // Set LastSocketClosed + TRAPD(err3, Utils::SetTimeoutsL(EConnTestCmdTimeoutLastSocketClosed)); + if(err3) + { + iContainer->ErrorNotify(_L("Failed to set timer"), err3); + } + break; + + case EConnTestCmdTimeoutLastSessionClosed: + // Set LastSessionClosed + TRAP(err, Utils::SetTimeoutsL(EConnTestCmdTimeoutLastSessionClosed)); + if(err) + { + iContainer->ErrorNotify(_L("Failed to set timer"), err); + } + break; + + case EConnTestCmdWLANQoSVoice: + iSocketsEngine->SetWLANQoS(7); + break; + + case EConnTestCmdWLANQoSVideo: + iSocketsEngine->SetWLANQoS(5); + break; + + case EConnTestCmdWLANQoSBestEffort: + iSocketsEngine->SetWLANQoS(3); + break; + + case EConnTestCmdWLANQoSBackground: + iSocketsEngine->SetWLANQoS(1); + break; + + case EConnTestCmdWLANQoSNone: + iSocketsEngine->SetWLANQoS(0); + break; + + + // + // WLAN COMMANDS + // + case EConnTestWlanAvailableIaps: + { + if (!iSupportsWlan) { iContainer->PrintNotify(_L("WLAN not supported\n")); break; } + iWaiter = new (ELeave) CConnTestViewWaiter( iWlanMgmtClient, *this, EConnTestWaitTypeAvailableIaps ); + iWaiter->ConstructL(); + iWaiter->IssueRequest(); + } + break; + + case EConnTestWlanScan: + { + if (!iSupportsWlan) { iContainer->PrintNotify(_L("WLAN not supported\n")); break; } + iWaiter = new (ELeave) CConnTestViewWaiter( iWlanMgmtClient, *this, EConnTestWaitTypeScan ); + iWaiter->ConstructL(); + iWaiter->IssueRequest(); + } + break; + + case EConnTestWlanGetSsid: + { + if (!iSupportsWlan) { iContainer->PrintNotify(_L("WLAN not supported\n")); break; } + TWlanSsid ssid; + TInt ret = iWlanMgmtClient->GetConnectionSsid( ssid ); + if( ret ) + { + RDebug::Print( _L( "ConnTest: Error: %d" ), ret ); + break; + } + + RDebug::Print( _L( "ConnTest: SSID = %S" ), &ssid ); + + TBuf8<64> text; + text.Append(_L8("SSID: ")); + text.Append(ssid); + text.Append(_L8("\n")); + iContainer->PrintNotify(text); + } + break; + + case EConnTestWlanGetBssid: + { + if (!iSupportsWlan) { iContainer->PrintNotify(_L("WLAN not supported\n")); break; } + TWlanBssid bssid; + TInt ret = iWlanMgmtClient->GetConnectionBssid( bssid ); + if( ret ) + { + RDebug::Print( _L( "ConnTest: Error: %d" ), ret ); + break; + } + + RDebug::Print( _L( "ConnTest: BSSID = %S" ), &bssid ); + + TBuf8<64> text; + text.AppendFormat(_L8("BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n"), bssid[0], bssid[1], bssid[2], bssid[3],bssid[4], bssid[5] ); + iContainer->PrintNotify(text); + } + break; + + case EConnTestWlanGetRssi: + { + if (!iSupportsWlan) { iContainer->PrintNotify(_L("WLAN not supported\n")); break; } + TInt32 rssi32; + TInt ret = iWlanMgmtClient->GetConnectionSignalQuality( rssi32 ); + if( ret ) + { + RDebug::Print( _L( "ConnTest: Error: %d" ), ret ); + break; + } + + RDebug::Print( _L( "ConnTest: RSSI = %d" ), rssi32 ); + + TInt8 rssi8 = static_cast(rssi32); + TBuf8<64> text; + text.AppendFormat(_L8("RSSI: %d\n"), rssi8); + iContainer->PrintNotify(text); + } + break; + + case EConnTestWlanGetConnMode: + { + if (!iSupportsWlan) { iContainer->PrintNotify(_L("WLAN not supported\n")); break; } + TWlanConnectionMode connMode; + TInt ret = iWlanMgmtClient->GetConnectionMode( connMode ); + if( ret ) + { + RDebug::Print( _L( "ConnTest: Error: %d" ), ret ); + break; + } + + RDebug::Print( _L( "ConnTest: ConnectionMode = %d" ), connMode ); + + TBuf8<64> text; + text.Append(_L8("Mode: ")); + switch( connMode ) + { + case EWlanConnectionModeNotConnected: + text.Append(_L8("Not Connected")); + break; + case EWlanConnectionModeInfrastructure: + text.Append(_L8("Infrastructure")); + break; + case EWlanConnectionModeAdhoc: + text.Append(_L8("Ad hoc")); + break; + case EWlanConnectionModeSecureInfra: + text.Append(_L8("SecureInfra")); + break; + case EWlanConnectionModeSearching: + text.Append(_L8("Searching")); + break; + } + text.Append(_L8("\n")); + iContainer->PrintNotify(text); + } + break; + + case EConnTestWlanGetSecurityMode: + { + if (!iSupportsWlan) { iContainer->PrintNotify(_L("WLAN not supported\n")); break; } + TWlanConnectionSecurityMode securityMode; + TInt ret = iWlanMgmtClient->GetConnectionSecurityMode( securityMode ); + if( ret ) + { + RDebug::Print( _L( "ConnTest: Error: %d" ), ret ); + break; + } + + RDebug::Print( _L( "ConnTest: SecurityMode = %d" ), securityMode ); + + TBuf8<64> text; + text.Append(_L8("Mode: ")); + switch( securityMode ) + { + case EWlanConnectionSecurityOpen: + text.Append(_L8("Open")); + break; + case EWlanConnectionSecurityWep: + text.Append(_L8("WEP")); + break; + case EWlanConnectionSecurity802d1x: + text.Append(_L8("802.1X")); + break; + case EWlanConnectionSecurityWpa: + text.Append(_L8("WPA")); + break; + case EWlanConnectionSecurityWpaPsk: + text.Append(_L8("WPA-PSK")); + break; + } + text.Append(_L8("\n")); + iContainer->PrintNotify(text); + } + break; + + default: + { + AppUi()->HandleCommandL( aCommand ); + break; + } + } + } + +// --------------------------------------------------------- +// CConnTestView::HandleClientRectChange() +// --------------------------------------------------------- +// +void CConnTestView::SizeChanged() + { + if(iContainer) + { + iContainer->SetRect(ClientRect()); + } + if(iSettingsListBox) + { + iSettingsListBox->SetRect(ClientRect()); + } + } + +// --------------------------------------------------------- +// CConnTestView::DoActivateL(...) +// Activation of this view instance. +// --------------------------------------------------------- +// +void CConnTestView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/) + { + if(!iContainer) + { + RDebug::Print(_L("ConnTest: CConnTestView::DoActivateL iContainer")); + iContainer = new (ELeave) CConnTestContainer; + iContainer->SetMopParent(this); + iContainer->ConstructL( ClientRect() ); + //AppUi()->AddToStackL( *this, iContainer ); + } + AppUi()->AddToStackL( *this, iContainer ); + + // Connection data for this view + if(!iSettingData) + { + // Note! Document class owns now settings, so that they can + // be stored into file. + //iSettingData = CSettingData::NewL(); owned now by CConnTestDocument + } + + // Create socket engine with initial data + if(!iSocketsEngine) + { + RDebug::Print(_L("ConnTest: CConnTestView::DoActivateL iSocketsEngine")); + iSocketsEngine = CSocketsEngine::NewL(*iContainer); + iSocketsEngine->SetConnectionData(iSettingData); + } + + // Create settings list + if(!iSettingsListBox) + { + RDebug::Print(_L("ConnTest: CConnTestView::DoActivateL iSettingsListBox")); + CreateSettingsListBoxL(R_CONNTEST_SETTING_LIST); + } + + // Create Custom Preferences list + if(!iCustomPrefsListBox) + { + RDebug::Print(_L("ConnTest: CConnTestView::DoActivateL iCustomPrefsListBox")); + CreateCustomPrefsListBoxL(R_CONNTEST_CUSTOM_PREFS_LIST); + } + + iActiveContainer = EOutputContainer; + iContainer->MakeVisible(ETrue); + SizeChanged(); + + if ( iSupportsWlan ) + { + RDebug::Print(_L("ConnTest: CConnTestView::DoActivateL iWlanMgmtClient->ActivateNotificationsL")); + iWlanMgmtClient->ActivateNotificationsL( *this ); + } + } + +// --------------------------------------------------------- +// CConnTestView::DoDeactivate() +// Deactivation of this view instance. Controls are not +// deleted, so that old information in status and output +// windows stays visible. +// --------------------------------------------------------- +// +void CConnTestView::DoDeactivate() + { + if ( iSupportsWlan ) + { + iWlanMgmtClient->CancelNotifications(); + } + + if ( iContainer ) + { + AppUi()->RemoveFromStack( iContainer ); + } + iContainer->MakeVisible(EFalse); + + if (iSettingsListBox) + { + AppUi()->RemoveFromStack(iSettingsListBox); + } + } + + +// ---------------------------------------------------------------------------- +// CConnTestView::SwapContainerL +// Switch the display between main view and settings list. +// ---------------------------------------------------------------------------- +// +void CConnTestView::SwapContainerL(TConnTestContainer aActiveContainer) + { + CAknTitlePane* titlePane = STATIC_CAST( + CAknTitlePane*, + StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); + + if (iActiveContainer == aActiveContainer) + { + return; + } + + // Remove the old container... + switch (iActiveContainer) + { + case EOutputContainer: + { + iContainer->MakeVisible(EFalse); + AppUi()->RemoveFromStack( iContainer ); + break; + } + case ESettingsContainer: + { + AppUi()->RemoveFromStack(iSettingsListBox); + iSettingsListBox->MakeVisible(EFalse); + break; + } + default: // ECustomPrefsContainer: + { + AppUi()->RemoveFromStack(iCustomPrefsListBox); + iCustomPrefsListBox->MakeVisible(EFalse); + break; + } + } + + // And add the new container + switch (aActiveContainer) + { + case EOutputContainer: + { + Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_EXIT); + AppUi()->AddToStackL( *this, iContainer ); + iContainer->MakeVisible(ETrue); + titlePane->SetTextToDefaultL(); + + Cba()->DrawNow(); + break; + } + case ESettingsContainer: + { + Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_OK_BACK); + AppUi()->AddToStackL( *this, iSettingsListBox ); + iSettingsListBox->MakeVisible(ETrue); + titlePane->SetTextL( _L("Settings") ); + break; + } + default: // ECustomPrefsContainer: + { + Cba()->SetCommandSetL(R_AVKON_SOFTKEYS_OK_BACK); + AppUi()->AddToStackL( *this, iCustomPrefsListBox ); + iCustomPrefsListBox->MakeVisible(ETrue); + titlePane->SetTextL( _L("Custom Preferences") ); + break; + } + } + + iActiveContainer = aActiveContainer; + } + +// ---------------------------------------------------------------------------- +// CConnTestView::CreateSettingsListBoxL +// Create the setting item list, but don't show it. +// ---------------------------------------------------------------------------- +// +void CConnTestView::CreateSettingsListBoxL(TInt aResourceId) + { + iSettingsListBox = new (ELeave) CSettingItemList; + iSettingsListBox->SetData(iSettingData); + iSettingsListBox->SetMopParent(this); + iSettingsListBox->ConstructFromResourceL(aResourceId); + iSettingsListBox->MakeVisible(EFalse); + iSettingsListBox->SetRect(ClientRect()); + iSettingsListBox->ActivateL(); + } + +// ---------------------------------------------------------------------------- +// CConnTestView::CreateCustomPrefsListBoxL +// Create the Custom Prefs item list, but don't show it. +// ---------------------------------------------------------------------------- +// +void CConnTestView::CreateCustomPrefsListBoxL(TInt aResourceId) + { + iCustomPrefsListBox = new (ELeave) CCustomPrefsItemList; + iCustomPrefsListBox->SetData(iCustomPrefsData); + iCustomPrefsListBox->SetMopParent(this); + iCustomPrefsListBox->ConstructFromResourceL(aResourceId); + iCustomPrefsListBox->MakeVisible(EFalse); + iCustomPrefsListBox->SetRect(ClientRect()); + iCustomPrefsListBox->ActivateL(); + } + + +// ---------------------------------------------------------------------------- +// CConnTestView::CreateDataPacket +// Write data to internal buffer, which is sent to socket. Maximum +// size of the buffer is KSendDataSize bytes. +// ---------------------------------------------------------------------------- +// +void CConnTestView::CreateDataPacket() + { + RDebug::Print(_L("ConnTest: CConnTestView::CreateDataPacket: packet size = %d, SendDataSize = %d"),iSettingData->iPacketSize,KSendDataSize); + RDebug::Print(_L("ConnTest: CConnTestView::CreateDataPacket: buffer maxsize = %d"),iSendData->Des().MaxLength()); + + iSendData->Des().FillZ(); + iSendData->Des().Zero(); + TInt length = iSettingData->iPacketSize; + if(length > iSendData->Des().MaxLength()) + { + TBuf<128> tt; + tt.Format( + _L("There was not enough space in the buffer for the data, so truncating to %d"), + iSendData->Des().MaxLength() + ); + iContainer->PrintNotify(tt); + length = iSendData->Des().MaxLength(); + iSettingData->iPacketSize = length; + } + iSendData->Des().Fill('a', iSettingData->iPacketSize - 1); + iSendData->Des().Append(_L8("\n")); + RDebug::Print(_L("ConnTest: CConnTestView::CreateDataPacket: created size = %d"),iSendData->Length()); + } + + +// ---------------------------------------------------------------------------- +// CConnTestView::SendDataL +// The engine does the real work +// ---------------------------------------------------------------------------- +// +void CConnTestView::SendDataL() + { + iSocketsEngine->SendDataL(*iSendData); + } + +// ------------------------------------------------------------------------------ +// CConnTestView::IsReadyForHTTPGet() +// This function is used to check if a HTTP get can be performed +// on an already existing connection +// ------------------------------------------------------------------------------ +// +TBool CConnTestView::IsReadyForHTTPGet() + { + TBool res = EFalse; + if (iSocketsEngine && iSocketsEngine->GetSocketEngineState() == CSocketsEngine::EConnected ) + { + res = ETrue; + } + return res; + } + +// ------------------------------------------------------------------------------ +// CConnTestView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) +// This function is called by the EIKON framework just before it displays +// a menu pane. Menu is adjusted according to socket engine state. +// ------------------------------------------------------------------------------ +// +void CConnTestView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) + { + RDebug::Print(_L("ConnTest: DynInitMenuPaneL: resourceId=%x"), aResourceId); + + switch(aResourceId) + { + case R_CONNTEST_VIEW1_MENU: + { + CSocketsEngine::TSocketsEngineState state = iSocketsEngine->GetSocketEngineState(); + CSocketsEngine::TRoamingUIState roamingState = iSocketsEngine->GetSocketEngineRoamingState(); + + switch(state) + { + case CSocketsEngine::EInterfaceDown: + aMenuPane->SetItemDimmed(EConnTestCmdCancel, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStartInterface, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdStartInternet, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdStopInterface, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdConnect, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdDisconnect, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdListen, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdSendRawData, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdHttpFrameworkGet, EFalse); + break; + case CSocketsEngine::EStartingInterface: + aMenuPane->SetItemDimmed(EConnTestCmdCancel, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdStartInterface, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStartInternet, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStopInterface, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdConnect, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdDisconnect, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdListen, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdSendRawData, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdHttpFrameworkGet, ETrue); + break; + case CSocketsEngine::EInterfaceUp: + aMenuPane->SetItemDimmed(EConnTestCmdCancel, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStartInterface, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStartInternet, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStopInterface, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdConnect, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdDisconnect, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdListen, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdSendRawData, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdHttpFrameworkGet, EFalse); + break; + case CSocketsEngine::EConnected: + aMenuPane->SetItemDimmed(EConnTestCmdCancel, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStartInterface, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStartInternet, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStopInterface, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdConnect, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdDisconnect, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdListen, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdSendRawData, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdHttpFrameworkGet, EFalse); + break; + case CSocketsEngine::EConnecting: + aMenuPane->SetItemDimmed(EConnTestCmdCancel, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdStartInterface, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStartInternet, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStopInterface, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdConnect, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdDisconnect, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdListen, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdSendRawData, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdHttpFrameworkGet, ETrue); + break; + case CSocketsEngine::EListening: + aMenuPane->SetItemDimmed(EConnTestCmdCancel, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStartInterface, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStartInternet, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStopInterface, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdConnect, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdDisconnect, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdListen, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdSendRawData, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdHttpFrameworkGet, ETrue); + break; + case CSocketsEngine::EDisconnecting: + aMenuPane->SetItemDimmed(EConnTestCmdCancel, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdStartInterface, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStartInternet, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStopInterface, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdConnect, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdDisconnect, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdListen, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdSendRawData, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdHttpFrameworkGet, ETrue); + break; + case CSocketsEngine::ELookingUp: + aMenuPane->SetItemDimmed(EConnTestCmdCancel, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdStartInterface, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStartInternet, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdStopInterface, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdConnect, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdDisconnect, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdListen, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdSendRawData, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdHttpFrameworkGet, ETrue); + break; + default: + break; + } + switch (roamingState) + { + case CSocketsEngine::EPendingPreferredCarrier: + aMenuPane->SetItemDimmed(EConnTestCmdMigrate, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdIgnore, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdAccept, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdReject, ETrue); + break; + case CSocketsEngine::EPendingNewCarrierActive: + aMenuPane->SetItemDimmed(EConnTestCmdMigrate, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdIgnore, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdAccept, EFalse); + aMenuPane->SetItemDimmed(EConnTestCmdReject, EFalse); + break; + default: + aMenuPane->SetItemDimmed(EConnTestCmdMigrate, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdIgnore, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdAccept, ETrue); + aMenuPane->SetItemDimmed(EConnTestCmdReject, ETrue); + break; + } + } + break; + case R_CONNTEST_SUB_MENU_IPDUMP: + { + + // Additional menupane handling, which doesn't depend on the state of the socket engine + CConnTestAppUi* appui = (CConnTestAppUi *)AppUi(); + if(appui->IsLogging()) + { + aMenuPane->SetItemDimmed(EConnTestCmdStartIpLog, ETrue); + } + else + { + aMenuPane->SetItemDimmed(EConnTestCmdStopIpLog, ETrue); + } + } + break; + + //enable mobility API submenupoints when connection is started with a snap + case R_CONNTEST_SUB_MENU_ADVANCED: + { + + CSocketsEngine::TSocketsEngineStartType connType = iSocketsEngine->GetSocketEngineConnType(); + + + break; + + } + default: + break; + } + } + +// ------------------------------------------------------------------------------ +// CConnTestView::RequestCompleted() +// ------------------------------------------------------------------------------ +// +void CConnTestView::RequestCompleted( TInt aStatus, RArray& aAvailableIaps ) + { + RDebug::Print( _L( "ConnTest: CConnTestView::RequestCompleted(aAvailableIaps)" ) ); + + if ( aStatus != KErrNone ) + { + RDebug::Print( _L( "ConnTest: client->RequestCompleted failed with %d" ), aStatus ); + return; + } + + RDebug::Print( _L( "ConnTest: ivailableIaps.Count() = %u" ), aAvailableIaps.Count() ); + + TBuf<100> msg; + msg.AppendNum( aAvailableIaps.Count() ); + msg.Append( _L( " WLAN IAP(s) found\n\n" ) ); + for ( TUint idx( 0 ); idx < (TUint)aAvailableIaps.Count(); ++idx ) + { + msg.AppendFormat( _L("%02u "), aAvailableIaps[idx] ); + } + msg.Append( _L( "\n" ) ); + iContainer->ErrorNotify( msg, KErrNone ); + + delete iWaiter; + iWaiter = NULL; + } + +// ------------------------------------------------------------------------------ +// CConnTestView::RequestCompleted() +// ------------------------------------------------------------------------------ +// +void CConnTestView::RequestCompleted( TInt aStatus, CWlanScanInfo& aScanInfo ) + { + RDebug::Print( _L( "ConnTest: CConnTestView::RequestCompleted(aScanInfo)" ) ); + + if ( aStatus != KErrNone ) + { + RDebug::Print( _L( "ConnTest: client->RequestCompleted failed with %d" ), aStatus ); + return; + } + + TUint count( 0 ); + + aScanInfo.First(); + while (!aScanInfo.IsDone()) + { + ++count; + aScanInfo.Next(); + } + + TBuf<100> msg; + msg.AppendNum( count ); + msg.Append( _L( " WLAN AP(s) found\n\n" ) ); + iContainer->ErrorNotify( msg, KErrNone ); + + delete iWaiter; + iWaiter = NULL; + } + +// ------------------------------------------------------------------------------ +// CConnTestView::ConnectionStateChanged() +// ------------------------------------------------------------------------------ +// +void CConnTestView::ConnectionStateChanged( TWlanConnectionMode aNewState ) + { + RDebug::Print( _L( "ConnTest: CConnTestView::ConnectionStateChanged" ) ); + + TBuf8<64> text; + TTime currentTime(0); + currentTime.HomeTime(); + TDateTime time = currentTime.DateTime(); + text.AppendFormat(_L8("%02u:%02u:%02u "), + time.Hour(), time.Minute(), time.Second() ); + text.Append(_L8("Wlan State: ")); + switch( aNewState ) + { + case EWlanConnectionModeNotConnected: + text.Append(_L8("Not Connected")); + break; + case EWlanConnectionModeInfrastructure: + text.Append(_L8("Infrastructure")); + break; + case EWlanConnectionModeAdhoc: + text.Append(_L8("Ad hoc")); + break; + case EWlanConnectionModeSecureInfra: + text.Append(_L8("SecureInfra")); + break; + case EWlanConnectionModeSearching: + text.Append(_L8("Searching")); + break; + } + text.Append(_L8("\n")); + iContainer->PrintNotify(text); + } + +// ------------------------------------------------------------------------------ +// CConnTestView::BssidChanged() +// ------------------------------------------------------------------------------ +// +void CConnTestView::BssidChanged( TWlanBssid& aNewBSSID ) + { + RDebug::Print( _L( "ConnTest: CConnTestView::BssidChanged" ) ); + + TBuf8<64> text; + TTime currentTime(0); + currentTime.HomeTime(); + TDateTime time = currentTime.DateTime(); + text.AppendFormat(_L8("%02u:%02u:%02u "), + time.Hour(), time.Minute(), time.Second() ); + text.AppendFormat(_L8("Wlan BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n"), aNewBSSID[0], aNewBSSID[1], aNewBSSID[2], aNewBSSID[3], aNewBSSID[4], aNewBSSID[5] ); + iContainer->PrintNotify(text); + } + +// ------------------------------------------------------------------------------ +// CConnTestView::BssLost() +// ------------------------------------------------------------------------------ +// +void CConnTestView::BssLost() + { + RDebug::Print( _L( "ConnTest: CConnTestView::BssLost" ) ); + + TBuf8<64> text; + TTime currentTime(0); + currentTime.HomeTime(); + TDateTime time = currentTime.DateTime(); + text.AppendFormat(_L8("%02u:%02u:%02u "), + time.Hour(), time.Minute(), time.Second() ); + text.AppendFormat(_L8("Wlan: BssLost\n")); + iContainer->PrintNotify(text); + } + +// ------------------------------------------------------------------------------ +// CConnTestView::BssRegained() +// ------------------------------------------------------------------------------ +// +void CConnTestView::BssRegained() + { + RDebug::Print( _L( "ConnTest: CConnTestView::BssRegained" ) ); + + TBuf8<64> text; + TTime currentTime(0); + currentTime.HomeTime(); + TDateTime time = currentTime.DateTime(); + text.AppendFormat(_L8("%02u:%02u:%02u "), + time.Hour(), time.Minute(), time.Second() ); + text.AppendFormat(_L8("Wlan: BssRegained\n")); + iContainer->PrintNotify(text); + } + +// ------------------------------------------------------------------------------ +// CConnTestView::NewNetworksDetected() +// ------------------------------------------------------------------------------ +// +void CConnTestView::NewNetworksDetected() + { + RDebug::Print( _L( "ConnTest: CConnTestView::NewNetworksDetected" ) ); + + TBuf8<64> text; + TTime currentTime(0); + currentTime.HomeTime(); + TDateTime time = currentTime.DateTime(); + text.AppendFormat(_L8("%02u:%02u:%02u "), + time.Hour(), time.Minute(), time.Second() ); + text.AppendFormat(_L8("Wlan: NewNetworksDetected\n")); + iContainer->PrintNotify(text); + } + +// ------------------------------------------------------------------------------ +// CConnTestView::OldNetworksLost() +// ------------------------------------------------------------------------------ +// +void CConnTestView::OldNetworksLost() + { + RDebug::Print( _L( "ConnTest: CConnTestView::OldNetworksLost" ) ); + + TBuf8<64> text; + TTime currentTime(0); + currentTime.HomeTime(); + TDateTime time = currentTime.DateTime(); + text.AppendFormat(_L8("%02u:%02u:%02u "), + time.Hour(), time.Minute(), time.Second() ); + text.AppendFormat(_L8("Wlan: OldNetworksLost\n")); + iContainer->PrintNotify(text); + } + +// ------------------------------------------------------------------------------ +// CConnTestView::TransmitPowerChanged() +// ------------------------------------------------------------------------------ +// +void CConnTestView::TransmitPowerChanged( TUint aPower ) + { + RDebug::Print( _L( "ConnTest: CConnTestView::TransmitPowerChanged" ) ); + + TBuf8<64> text; + TTime currentTime(0); + currentTime.HomeTime(); + TDateTime time = currentTime.DateTime(); + text.AppendFormat(_L8("%02u:%02u:%02u "), + time.Hour(), time.Minute(), time.Second() ); + text.AppendFormat(_L8("Wlan: TxPower: %d\n"), aPower); + iContainer->PrintNotify(text); + } + +// ------------------------------------------------------------------------------ +// CConnTestView::RssChanged() +// ------------------------------------------------------------------------------ +// +void CConnTestView::RssChanged( TWlanRssClass aRssClass, + TUint aRss ) + { + RDebug::Print( _L( "ConnTest: CConnTestView::RssChanged" ) ); + + TBuf8<64> text; + TTime currentTime(0); + currentTime.HomeTime(); + TDateTime time = currentTime.DateTime(); + text.AppendFormat(_L8("%02u:%02u:%02u "), + time.Hour(), time.Minute(), time.Second() ); + text.AppendFormat(_L8("Wlan: RssChanged: %d, %d\n"), aRssClass, aRss); + iContainer->PrintNotify(text); + } + +// ------------------------------------------------------------------------------ +// CConnTestViewWaiter::CConnTestViewWaiter() +// ------------------------------------------------------------------------------ +// +CConnTestViewWaiter::CConnTestViewWaiter( CWlanMgmtClient* aWlanMgmtClient, + CConnTestView& aCallback, + TConnTestWaitType aType ) + : CActive( CActive::EPriorityStandard ), + iType( aType ), + iCallback( aCallback ), + iMgmtClient( aWlanMgmtClient ), + iScanInfo( NULL ) + { + RDebug::Print( _L( "ConnTest: CConnTestViewWaiter::CConnTestViewWaiter()" ) ); + CActiveScheduler::Add( this ); + } + +// ------------------------------------------------------------------------------ +// CConnTestViewWaiter::ConstructL() +// ------------------------------------------------------------------------------ +// +void CConnTestViewWaiter::ConstructL() + { + iScanInfo = CWlanScanInfo::NewL(); + } + +// ------------------------------------------------------------------------------ +// CConnTestViewWaiter::~CConnTestViewWaiter() +// ------------------------------------------------------------------------------ +// +CConnTestViewWaiter::~CConnTestViewWaiter() + { + RDebug::Print( _L( "ConnTest: CConnTestViewWaiter::~CConnTestViewWaiter()" ) ); + Cancel(); + iAvailableIaps.Close(); + delete iScanInfo; + } + +// ------------------------------------------------------------------------------ +// CConnTestViewWaiter::RunL() +// ------------------------------------------------------------------------------ +// +void CConnTestViewWaiter::RunL() + { + RDebug::Print( _L( "ConnTest: CConnTestViewWaiter::RunL()" ) ); + + if ( iType == EConnTestWaitTypeAvailableIaps ) + { + iCallback.RequestCompleted( iStatus.Int(), iAvailableIaps ); + } + else // EConnTestWaitTypeScan + { + iCallback.RequestCompleted( iStatus.Int(), *iScanInfo ); + } + } + +// ------------------------------------------------------------------------------ +// CConnTestViewWaiter::RunError() +// ------------------------------------------------------------------------------ +// +TInt CConnTestViewWaiter::RunError( TInt /* aError */ ) + { + RDebug::Print( _L( "ConnTest: CConnTestViewWaiter::RunError()" ) ); + return KErrNone; + } + +// ------------------------------------------------------------------------------ +// CConnTestViewWaiter::DoCancel() +// ------------------------------------------------------------------------------ +// +void CConnTestViewWaiter::DoCancel() + { + RDebug::Print( _L( "ConnTest: CConnTestViewWaiter::DoCancel()" ) ); + } + +// ------------------------------------------------------------------------------ +// CConnTestViewWaiter::IssueRequest() +// ------------------------------------------------------------------------------ +// +void CConnTestViewWaiter::IssueRequest() + { + RDebug::Print( _L( "ConnTest: CConnTestViewWaiter::IssueRequest()" ) ); + if ( iType == EConnTestWaitTypeAvailableIaps ) + { + iMgmtClient->GetAvailableIaps( iStatus, iAvailableIaps ); + } + else // EConnTestWaitTypeScan + { + iMgmtClient->GetScanResults( iStatus, *iScanInfo ); + } + SetActive(); + } + +// End of File + diff -r 000000000000 -r 857a3e953887 nettools/conntest/src/CustomPrefsData.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/src/CustomPrefsData.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CCustomPrefsData stores the Extended Connection Preferences +* +*/ + +// INCLUDE FILES +#include +#include "CustomPrefsData.h" +#include "extendedconnpref.h" + + +// ================= MEMBER FUNCTIONS ========================================= +// ---------------------------------------------------------------------------- +// CCustomPrefsData::NewL() +// Two-phase constructor +// ---------------------------------------------------------------------------- +// +CCustomPrefsData* CCustomPrefsData::NewL() + { + CCustomPrefsData* data = new(ELeave) CCustomPrefsData; + CleanupStack::PushL(data); + data->ConstructL(); + CleanupStack::Pop(data); // data + return data; + } + +// ---------------------------------------------------------------------------- +// CCustomPrefsData::~CCustomPrefsData() +// Destructor +// ---------------------------------------------------------------------------- +// +CCustomPrefsData::~CCustomPrefsData() + { + } + +// ---------------------------------------------------------------------------- +// CCustomPrefsData::CCustomPrefsData() +// Constructor +// ---------------------------------------------------------------------------- +// +CCustomPrefsData::CCustomPrefsData() : + iSnapPurpose( CMManager::ESnapPurposeUnknown ), + iSnapId( 0 ), + iIapId( 0 ), + iBearerSet( TExtendedConnPref::EExtendedConnBearerUnknown ), + iNoteBehaviour( TExtendedConnPref::ENoteBehaviourDefault ), + iDisconnectDialog( ETrue ), + iConnSelectionDialog( EFalse ), + iForcedRoaming( ETrue ) + { + } + +// ---------------------------------------------------------------------------- +// CCustomPrefsData::CCustomPrefsData() +// Symbian default constructor +// ---------------------------------------------------------------------------- +// +void CCustomPrefsData::ConstructL() + { + } + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/src/CustomPrefsItemList.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/src/CustomPrefsItemList.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: CCustomPrefsItemList implemets the Extended Connection Preferences setting + * list for Conntest. + * + */ + +// INCLUDE FILES +#include +#include + +#include "CustomPrefsItemList.h" +#include "CustomPrefsData.h" +#include "conntest.hrh" +#include "Utils.h" +#include "cmapplicationsettingsui.h" + +// ================= MEMBER FUNCTIONS ========================================= + +// ---------------------------------------------------------------------------- +// CCustomPrefsItemList::CreateSettingItemL +// Inherited from CAknSettingItem. Updates descriptor array for list box. +// ---------------------------------------------------------------------------- +// +CAknSettingItem* CCustomPrefsItemList::CreateSettingItemL( TInt aIdentifier ) + { + CAknSettingItem* customPrefsItem = NULL; + + switch (aIdentifier) + { + case EConnTestExtConnPrefsItemSnapPurpose: + customPrefsItem = new (ELeave) CAknEnumeratedTextPopupSettingItem( + aIdentifier, iData->iSnapPurpose ); + break; + case EConnTestExtConnPrefsItemSnapId: + customPrefsItem = new (ELeave) CAknIntegerEdwinSettingItem( + aIdentifier, iData->iSnapId ); + break; + case EConnTestExtConnPrefsItemIapId: + customPrefsItem = new (ELeave) CAknIntegerEdwinSettingItem( + aIdentifier, iData->iIapId ); + break; + case EConnTestExtConnPrefsItemBearerSet: + customPrefsItem = new (ELeave) CAknEnumeratedTextPopupSettingItem( + aIdentifier, iData->iBearerSet ); + break; + case EConnTestExtConnPrefsItemNoteBehaviour: + customPrefsItem = new (ELeave) CAknEnumeratedTextPopupSettingItem( + aIdentifier, iData->iNoteBehaviour ); + break; + case EConnTestExtConnPrefsItemDisconnectDialog: + customPrefsItem = new (ELeave) CAknBinaryPopupSettingItem( + aIdentifier, iData->iDisconnectDialog ); + break; + case EConnTestExtConnPrefsItemConnSelectionDialog: + customPrefsItem = new (ELeave) CAknBinaryPopupSettingItem( + aIdentifier, iData->iConnSelectionDialog ); + break; + case EConnTestExtConnPrefsItemForcedRoaming: + customPrefsItem = new (ELeave) CAknBinaryPopupSettingItem( + aIdentifier, iData->iForcedRoaming ); + break; + default: + break; + } + return customPrefsItem; + } + +// ---------------------------------------------------------------------------- +// CCustomPrefsItemList::SetData +// +// ---------------------------------------------------------------------------- +// +void CCustomPrefsItemList::SetData( CCustomPrefsData* aData ) + { + iData = aData; + } + +// ---------------------------------------------------------------------------- +// CCustomPrefsItemList::SizeChanged +// Size changed handler +// ---------------------------------------------------------------------------- +// +void CCustomPrefsItemList::SizeChanged() + { + if (ListBox()) + { + ListBox()->SetRect( Rect() ); + } + } + +// --------------------------------------------------------- +// CCustomPrefsItemList::SelectSnapL() +// Selects a SNAP +// --------------------------------------------------------- +// +void CCustomPrefsItemList::SelectSnapL() + { + // Start the SNAP selection dialog + CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL(); + CleanupStack::PushL( settings ); + TCmSettingSelection selection; + TUint listItems = CMManager::EShowDestinations; + TBearerFilterArray filterArray; + + settings->RunApplicationSettingsL( selection, listItems, filterArray ); + + CleanupStack::PopAndDestroy( settings ); + + switch (selection.iResult) + { + case CMManager::EDestination: + { + iData->iSnapId = selection.iId; + break; + } + default: + { + iData->iSnapId = 0; + RDebug::Print( _L("ConnTest: Invalid selection") ); + break; + } + } + } + +// --------------------------------------------------------- +// CCustomPrefsItemList::SelectIapL() +// Selects an IAP +// --------------------------------------------------------- +// +void CCustomPrefsItemList::SelectIapL() + { + // IAP selection menu + TUint32 iapId; + TInt popupOk = Utils::AskIapIdL( iapId ); + + if (popupOk) + { + RDebug::Print( _L("ConnTest: Selected IAP id=%d"), iapId ); + iData->iIapId = iapId; + } + else + { + RDebug::Print( _L("ConnTest: Invalid selection") ); + iData->iIapId = 0; + } + } + +// --------------------------------------------------------- +// CCustomPrefsItemList::EditItemL() +// Edits a menu item +// --------------------------------------------------------- +// +void CCustomPrefsItemList::EditItemL( TInt aIndex, TBool aCalledFromMenu ) + { + if (aIndex == EConnTestExtConnPrefsItemSnapId) + { + // SNAP selection menu + SelectSnapL(); + // Update the selected value into the CustomPrefsItemList + CCustomPrefsSelectedIntegerItem* snapItem = + (CCustomPrefsSelectedIntegerItem*)(*SettingItemArray())[aIndex]; + snapItem->EditSelectedIntegerItemL( iData->iSnapId ); + } + else if (aIndex == EConnTestExtConnPrefsItemIapId) + { + // IAP selection menu + SelectIapL(); + // Update the selected value into the CustomPrefsItemList + CCustomPrefsSelectedIntegerItem* iapItem = + (CCustomPrefsSelectedIntegerItem*)(*SettingItemArray())[aIndex]; + iapItem->EditSelectedIntegerItemL( iData->iIapId ); + } + else + { + // The rest are handled "traditionally", via the base class + CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu ); + } + } + +// --------------------------------------------------------- +// CCustomPrefsSelectedIntegerItem::EditSelectedIntegerItemL() +// Edits a SNAP or IAP item +// --------------------------------------------------------- +// +void CCustomPrefsItemList::CCustomPrefsSelectedIntegerItem::EditSelectedIntegerItemL( TInt aId ) + { + this->SetExternalValue( aId ); + this->LoadL(); + this->UpdateListBoxTextL(); + } + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/src/SettingData.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/src/SettingData.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSettingsData stores the settings for ConnTest +* +*/ + +// INCLUDE FILES +#include +#include "SettingData.h" + + +// ================= MEMBER FUNCTIONS ========================================= +// ---------------------------------------------------------------------------- +// CSettingData::NewL() +// Two-phase constructor +// ---------------------------------------------------------------------------- +// +CSettingData* CSettingData::NewL() + { + CSettingData* data = new(ELeave) CSettingData; + CleanupStack::PushL(data); + data->ConstructL(); + CleanupStack::Pop(data); // data + return data; + } + +// ---------------------------------------------------------------------------- +// CSettingData::~CSettingData() +// Destructor +// ---------------------------------------------------------------------------- +// +CSettingData::~CSettingData() + { + } + +// ---------------------------------------------------------------------------- +// CSettingData::CSettingData() +// Constructor +// ---------------------------------------------------------------------------- +// +CSettingData::CSettingData() + { + } + +// ---------------------------------------------------------------------------- +// CSettingData::CSettingData() +// Epoc default constructor +// ---------------------------------------------------------------------------- +// +void CSettingData::ConstructL() + { + //CEikonEnv* env = CEikonEnv::Static(); + + // Default data + iServerName.Copy(_L("www.google.com")); + iPort = 80; + iPacketSize = 5; + iPackets = 1; + iDelay = 500; + iProtocol = 0; + iRoaming = 1; + iHttpPage.Copy(_L("index.html")); + } + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/src/SettingItemList.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/src/SettingItemList.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,98 @@ +/* +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: CSettingItemList implemets the settings list for Conntest +* +*/ + +// INCLUDE FILES +#include "SettingItemList.h" +#include "SettingData.h" +#include "conntest.hrh" + + +// ================= MEMBER FUNCTIONS ========================================= + +// ---------------------------------------------------------------------------- +// CSettingItemList::CreateSettingItemL +// Updates descripter array for list box +// ---------------------------------------------------------------------------- +// +CAknSettingItem* CSettingItemList::CreateSettingItemL( TInt aIdentifier ) + { + CAknSettingItem* settingItem = NULL; + + switch (aIdentifier) + { + case EConnTestIpAddress: + settingItem = new (ELeave) + CAknTextSettingItem(aIdentifier, iData->iServerName ); + break; + case EConnTestPort: + settingItem = new (ELeave) + CAknIntegerEdwinSettingItem(aIdentifier, iData->iPort ); + break; + case EConnTestHttpPage: + settingItem = new (ELeave) + CAknTextSettingItem(aIdentifier, iData->iHttpPage); + break; + case EConnTestProtocol: + settingItem = new (ELeave) CAknEnumeratedTextPopupSettingItem( + aIdentifier, iData->iProtocol ); + break; + case EConnTestPacketSize: + settingItem = new (ELeave) + CAknIntegerEdwinSettingItem(aIdentifier, iData->iPacketSize ); + break; + case EConnTestPackets: + settingItem = new (ELeave) + CAknIntegerEdwinSettingItem(aIdentifier, iData->iPackets ); + break; + case EConnTestDelay: + settingItem = new (ELeave) + CAknIntegerEdwinSettingItem(aIdentifier, iData->iDelay ); + break; + case EConnTestRoaming: + settingItem = new (ELeave) CAknEnumeratedTextPopupSettingItem( + aIdentifier, iData->iRoaming ); + break; + default: + break; + } + return settingItem; + } + +// ---------------------------------------------------------------------------- +// CSettingItemList::SetData +// +// ---------------------------------------------------------------------------- +// +void CSettingItemList::SetData(CSettingData* aData) + { + iData = aData; + } + +// ---------------------------------------------------------------------------- +// CSettingItemList::SizeChanged +// Size changed handler +// ---------------------------------------------------------------------------- +// +void CSettingItemList::SizeChanged() + { + if (ListBox()) + { + ListBox()->SetRect(Rect()); + } + } + +// End of File diff -r 000000000000 -r 857a3e953887 nettools/conntest/src/Utils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/conntest/src/Utils.cpp Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,363 @@ +/* + * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Utils implements general tools for bandwidth and + * packet loss calculation and IAP selection etc + * + */ + +// INCLUDE FILES +#include +#include +#include + +#include +#include +#include +#include + +#include "Utils.h" +#include "conntest.hrh" + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +// ---------------------------------------------------------------------------- +// Utils::Utils() +// Constructor +// ---------------------------------------------------------------------------- +// +Utils::Utils() + { + } + +// ---------------------------------------------------------------------------- +// Utils::~Utils() +// Destructor +// ---------------------------------------------------------------------------- +// +Utils::~Utils() + { + } + +// ---------------------------------------------------------------------------- +// Utils::CalculateThroughput +// Calculate throughput +// ---------------------------------------------------------------------------- +// +void Utils::CalculateThroughput( TDes8& aBuffer, TTime aStartTime, TInt aSize ) + { + TTime now; + now.UniversalTime(); + TTimeIntervalMicroSeconds interval; + interval = now.MicroSecondsFrom( aStartTime ); + TInt num = I64INT(interval.Int64()); + + if (num != 0) + { + aBuffer.AppendFormat( _L8("Size: %d\n"), aSize ); + aBuffer.AppendFormat( _L8("Time: %4.1f s\n"), (TReal)num / 1000000 ); + aBuffer.AppendFormat( _L8(" - %4.1f kB/s\n"), (TReal)((TReal)aSize / (1024.0 + * (TReal)num)) * 1000000 ); + aBuffer.AppendFormat( _L8(" - %4.1f kbit/s\n"), (TReal)8 * ((TReal)aSize / (1024.0 + * (TReal)num)) * 1000000 ); + } + else + { + aBuffer.AppendFormat( _L8("Size: %d\n"), aSize ); + aBuffer.AppendFormat( _L8("Time zero\n") ); + } + + } + +// ---------------------------------------------------------------------------- +// Utils::SetTimeoutsL(const TInt aTimeout) +// Adjust given Nifman's idle timeout for every bearer. +// ---------------------------------------------------------------------------- +// +void Utils::SetTimeoutsL( const TInt aTimeout ) + { + // GPRS and CSD bearer + Utils::SetTableTimeoutL( aTimeout, TPtrC( MODEM_BEARER ) ); + + // LAN bearer + Utils::SetTableTimeoutL( aTimeout, TPtrC( LAN_BEARER ) ); + } + +// ---------------------------------------------------------------------------- +// Utils::SetTableTimeoutL() +// Set Nifman's idle times for each record in given table. +// ---------------------------------------------------------------------------- +// +void Utils::SetTableTimeoutL( const TInt aTimeout, const TDesC& aTableName ) + { + TInt result; + TUint32 value; + TBuf<64> title; + + CCommsDatabase* TheDb; + + TheDb = CCommsDatabase::NewL(); + CleanupStack::PushL( TheDb ); + + CCommsDbTableView* view2 = TheDb->OpenTableLC( aTableName ); + + result = view2->GotoFirstRecord(); + User::LeaveIfError( result ); + + while (result == KErrNone) + { + view2->ReadTextL( TPtrC( COMMDB_NAME ), title ); + + switch (aTimeout) + { + case EConnTestCmdTimeoutLastSocketActivity: + title.Append( _L("\nLastSocketActivity") ); + view2->ReadUintL( TPtrC( LAST_SOCKET_ACTIVITY_TIMEOUT ), value ); + break; + + case EConnTestCmdTimeoutLastSocketClosed: + title.Append( _L("\nLastSocketClosed") ); + view2->ReadUintL( TPtrC( LAST_SOCKET_CLOSED_TIMEOUT ), value ); + break; + + case EConnTestCmdTimeoutLastSessionClosed: + title.Append( _L("\nLastSessionClosed") ); + view2->ReadUintL( TPtrC( LAST_SESSION_CLOSED_TIMEOUT ), value ); + break; + + default: + value = 0; // To get rid of compiler warning + break; + } + + TInt val2( value ); + CAknNumberQueryDialog* dlg; + + dlg = CAknNumberQueryDialog::NewL( val2, CAknQueryDialog::ENoTone ); + CleanupStack::PushL( dlg ); + dlg->SetPromptL( title ); + TInt changed = dlg->ExecuteLD( R_CONNTEST_NUMBER_LAYOUT ); + CleanupStack::Pop( dlg ); + + if (changed) + { + result = view2->UpdateRecord(); + User::LeaveIfError( result ); + + if (val2 == -1) + { + val2 = KMaxTInt; + } + + switch (aTimeout) + { + case EConnTestCmdTimeoutLastSocketActivity: + view2->WriteUintL( TPtrC( LAST_SOCKET_ACTIVITY_TIMEOUT ), + val2 ); + break; + + case EConnTestCmdTimeoutLastSocketClosed: + view2->WriteUintL( TPtrC( LAST_SOCKET_CLOSED_TIMEOUT ), + val2 ); + break; + + case EConnTestCmdTimeoutLastSessionClosed: + view2->WriteUintL( TPtrC( LAST_SESSION_CLOSED_TIMEOUT ), + val2 ); + break; + + default: + break; + } + + result = view2->PutRecordChanges(); + User::LeaveIfError( result ); + } + result = view2->GotoNextRecord(); + } + + CleanupStack::PopAndDestroy( view2 ); // view2 + CleanupStack::PopAndDestroy( TheDb ); // TheDb + } + +// ---------------------------------------------------------------------------- +// Utils::SetConnectionPrefsIap() +// Set IapId value into connection preferences table +// ---------------------------------------------------------------------------- +// +void Utils::SetConnectionPrefsIapL() + { + + CCommsDatabase* TheDb; + + TheDb = CCommsDatabase::NewL(); + CleanupStack::PushL( TheDb ); + + CCommsDbConnectionPrefTableView* view = TheDb->OpenConnectionPrefTableLC(); + + TInt ret = view->GotoFirstRecord(); + + CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref tablePref; + + if (ret == KErrNone) + { + view->ReadConnectionPreferenceL( tablePref ); + } + + User::LeaveIfError( ret ); + + TInt value( tablePref.iBearer.iIapId ); + CAknNumberQueryDialog* dlg; + + dlg = CAknNumberQueryDialog::NewL( value, CAknQueryDialog::ENoTone ); + CleanupStack::PushL( dlg ); + dlg->SetPromptL( _L("Iap Id:") ); + TInt changed = dlg->ExecuteLD( R_CONNTEST_NUMBER_LAYOUT ); + CleanupStack::Pop( dlg ); + + if (changed) + { + tablePref.iBearer.iIapId = value; + view->UpdateBearerL( tablePref.iBearer ); + } + + CleanupStack::PopAndDestroy( view ); // view + CleanupStack::PopAndDestroy( TheDb ); // TheDb + } + +// ---------------------------------------------------------------------------- +// Utils::AskIapIdL(TUint32& aId) +// Ask IAP id from the user +// ---------------------------------------------------------------------------- +// +TInt Utils::AskIapIdL( TUint32& aId ) + { + return Utils::SelectIdFromTableL( aId, TPtrC( IAP ) ); + } + +// ---------------------------------------------------------------------------- +// Utils::AskNetworkIdL(TUint32& aId) +// Ask Network id from the user +// ---------------------------------------------------------------------------- +// +TInt Utils::AskNetworkIdL( TUint32& aId ) + { + return Utils::SelectIdFromTableL( aId, TPtrC( NETWORK ) ); + } + +// ---------------------------------------------------------------------------- +// Utils::SelectIdFromTableL() +// Does the real work for selecting IAP or Network id +// ---------------------------------------------------------------------------- +// +TInt Utils::SelectIdFromTableL( TUint32& aId, const TDesC& aTableName ) + { + CCommsDatabase* TheDb; + TInt res; + TBuf<40> name; + TBuf<20> title; + TUint32 id; + RArray idArray; + CDesCArrayFlat* items = new (ELeave) CDesCArrayFlat( 16 ); + + // Get IAP names and ids from the database + TheDb = CCommsDatabase::NewL( EDatabaseTypeIAP ); + CleanupStack::PushL( TheDb ); + + TheDb->ShowHiddenRecords(); + + CCommsDbTableView* view; + + view = TheDb->OpenTableLC( aTableName ); + title.Format( _L("Select %S:"), &aTableName ); + + res = view->GotoFirstRecord(); + + while (res == KErrNone) + { + view->ReadTextL( TPtrC( COMMDB_NAME ), name ); + view->ReadUintL( TPtrC( COMMDB_ID ), id ); + + idArray.Insert( id, 0 ); + items->InsertL( 0, name ); + + res = view->GotoNextRecord(); + RDebug::Print( _L("ConnTest: IAP name, id: %S, %d"), &name, id ); + } + + CleanupStack::PopAndDestroy( view ); // view + CleanupStack::PopAndDestroy( TheDb ); // TheDb + + // Create listbox and PUSH it. + CEikTextListBox* list = new (ELeave) CAknSinglePopupMenuStyleListBox; + CleanupStack::PushL( list ); + + // Create popup list and PUSH it. + CAknPopupList* popupList = CAknPopupList::NewL( list, + R_AVKON_SOFTKEYS_OK_CANCEL, AknPopupLayouts::EMenuWindow ); + CleanupStack::PushL( popupList ); + + // initialize listbox. + list->ConstructL( popupList, CEikListBox::ELeftDownInViewRect ); + list->CreateScrollBarFrameL( ETrue ); + list->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, + CEikScrollBarFrame::EAuto ); + + // Set listitems. + CTextListBoxModel* model = list->Model(); + model->SetItemTextArray( items ); + model->SetOwnershipType( ELbmOwnsItemArray ); + + // Set title + popupList->SetTitleL( title ); + + // Show popup list. + TInt popupOk = popupList->ExecuteLD(); + CleanupStack::Pop( popupList ); // popuplist + if (popupOk) + { + TInt index = list->CurrentItemIndex(); + aId = idArray[index]; + } + + CleanupStack::PopAndDestroy( list ); // list + + idArray.Close(); + // delete items; (list deletes) + items = NULL; + return popupOk; + } + +// ---------------------------------------------------------------------------- +// Utils::CreateDataChunk() +// Create data chunk for POST performance tests +// ---------------------------------------------------------------------------- +// +void Utils::CreateDataChunk( TDes8& aBuffer, TInt aLength ) + { + for (TInt i = 0; i < aLength && i < aBuffer.MaxLength(); i++) + { + if (i == 0) + { + aBuffer.Copy( _L8("a") ); + } + else + { + aBuffer.Append( _L8("a") ); + } + } + } + diff -r 000000000000 -r 857a3e953887 nettools/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nettools/group/bld.inf Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build information file for nettools. +* +*/ + + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS + +PRJ_MMPFILES +#include "../conntest/group/bld.inf" + + +PRJ_TESTMMPFILES + diff -r 000000000000 -r 857a3e953887 package_definition.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/package_definition.xml Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff -r 000000000000 -r 857a3e953887 sysdef_1_4_0.dtd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysdef_1_4_0.dtd Thu Dec 17 08:39:25 2009 +0200 @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +