diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_secure_sockets_8cpp-source.html --- a/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_secure_sockets_8cpp-source.html Tue Mar 30 11:56:28 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,249 +0,0 @@ - -
-00001 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). -00002 // All rights reserved. -00003 // This component and the accompanying materials are made available -00004 // under the terms of "Eclipse Public License v1.0" -00005 // which accompanies this distribution, and is available -00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". -00007 // -00008 // Initial Contributors: -00009 // Nokia Corporation - initial contribution. -00010 // -00011 // Contributors: -00012 // -00013 // Description: -00014 // Definitions of CConsoleControl, CSecAppUi, -00015 // CSecDocument, CSecApplication -00016 // -00017 -00018 -00019 #include <eikmenup.h> -00020 #include <eikmfne.h> -00021 #include <eikconso.h> -00022 -00023 #include "SecureSockets.h" -00024 #include "SecureSockets.hrh" -00025 -00026 #include <eikstart.h> -00027 -00028 -00029 -00030 -00031 CConsoleControl* CConsoleControl::NewL(const TRect& aClientRect) -00032 { -00033 CConsoleControl* self=new (ELeave) CConsoleControl(); -00034 CleanupStack::PushL(self); -00035 self->ConstructL(aClientRect); -00036 CleanupStack::Pop(); -00037 return self; -00038 } -00039 -00040 void CConsoleControl::ConstructL(const TRect& aClientRect) -00041 { -00042 iConsole=new(ELeave) CEikConsoleScreen; -00043 _LIT(KEikSec,"EikSec"); -00044 iConsole->ConstructL(KEikSec,aClientRect.iTl, aClientRect.Size(),0,EEikConsWinInPixels); -00045 } -00046 -00047 -00048 CConsoleControl::~CConsoleControl() -00049 { -00050 delete iConsole; -00051 } -00052 -00053 CConsoleBase& CConsoleControl::Console() -00054 { -00055 return *iConsole; -00056 } -00057 -00058 void CConsoleControl::ActivateL() -00059 // Mark control ready to draw -00060 { -00061 CCoeControl::ActivateL(); -00062 iConsole->SetKeepCursorInSight(EFalse); -00063 iConsole->DrawCursor(); -00064 iConsole->ConsoleControl()->SetFocus(ETrue, EDrawNow); -00065 } -00066 -00067 // CSettingsDialog: settings dialog -00068 TBool CSettingsDialog::RunDlgLD(TConnectSettings& aConnectSettings) -00069 { -00070 CEikDialog* dialog=new(ELeave) CSettingsDialog(aConnectSettings); -00071 return (dialog->ExecuteLD(R_SECS_SETTINGS)); -00072 } -00073 -00074 CSettingsDialog::CSettingsDialog(TConnectSettings& aConnectSettings) -00075 : iConnectSettings(aConnectSettings) -00076 { -00077 } -00078 -00079 void CSettingsDialog::PreLayoutDynInitL() -00080 { -00081 // Populate dialog with initial settings -00082 CEikEdwin* name=(CEikEdwin*)Control(EServerName); -00083 name->SetTextL(&iConnectSettings.iAddress); -00084 CEikEdwin* page=(CEikEdwin*)Control(EPage); -00085 TBuf<KSettingFieldWidth> temp; -00086 temp.Copy(iConnectSettings.iPage); -00087 page->SetTextL(&temp); -00088 CEikNumberEditor* port = (CEikNumberEditor*)Control(EPort); -00089 port->SetNumber(iConnectSettings.iPortNum); -00090 } -00091 -00092 TBool CSettingsDialog::OkToExitL(TInt /*aButtonId*/) -00093 { -00094 // Store dialog input -00095 CEikEdwin* name=(CEikEdwin*)Control(EServerName); -00096 name->GetText(iConnectSettings.iAddress); -00097 CEikEdwin* page=(CEikEdwin*)Control(EPage); -00098 TBuf<KSettingFieldWidth> temp; -00099 page->GetText(temp); -00100 iConnectSettings.iPage.Copy(temp); -00101 CEikNumberEditor* port = (CEikNumberEditor*)Control(EPort); -00102 iConnectSettings.iPortNum = port->Number(); -00103 -00104 return ETrue; -00105 } -00106 -00107 // -00108 // CSecAppUi: user interface command handling -00109 // -00110 -00111 // Construction functions -00112 CSecAppUi::CSecAppUi(CSecEngine* aSecEngine) -00113 : iSecEngine(aSecEngine) -00114 { -00115 _LIT(KFile,"\\secsocout.txt"); -00116 iOutputFileName = KFile; -00117 iConnectSettings.iPortNum = 443; -00118 } -00119 -00120 void CSecAppUi::ConstructL() -00121 // Set up control and engine -00122 { -00123 BaseConstructL(); -00124 -00125 iConsoleControl=CConsoleControl::NewL(ClientRect()); -00126 AddToStackL(iConsoleControl); -00127 iConsoleControl->ActivateL(); -00128 -00129 iSecEngine -> SetConsole( iConsoleControl->Console() ); -00130 _LIT(KStart,"\nChoose Connect from the menu to get a secure web page\n"); -00131 iConsoleControl->Console().Printf(KStart); -00132 } -00133 -00134 -00135 CSecAppUi::~CSecAppUi() -00136 { -00137 RemoveFromStack(iConsoleControl); -00138 delete iConsoleControl; -00139 } -00140 -00141 void CSecAppUi::HandleCommandL(TInt aCommand) -00142 // Command handling -00143 { -00144 switch (aCommand) -00145 { -00146 // Start -00147 case ECmdStart: -00148 if (CSettingsDialog::RunDlgLD(iConnectSettings)) -00149 { -00150 User::LeaveIfError(iOutputFile.Replace(iEikonEnv->FsSession(), -00151 iOutputFileName, -00152 EFileWrite)); -00153 iSecEngine -> SetOutputFile(iOutputFile); -00154 iSecEngine -> ConnectL(iConnectSettings); -00155 } -00156 // This may be helpful for testing - www.fortify.net SSL test -00157 else -00158 { -00159 -00160 iConnectSettings.iAddress=_L(" 203.124.140.161"); -00161 iConnectSettings.iPage=_L8("https://www.mail.mphasis.com"); -00162 //cgi-bin/ssl_2 -00163 User::LeaveIfError(iOutputFile.Replace(iEikonEnv->FsSession(), -00164 iOutputFileName, -00165 EFileWrite)); -00166 iSecEngine -> SetOutputFile(iOutputFile); -00167 iSecEngine -> ConnectL(iConnectSettings); -00168 } -00169 break; -00170 // Cancel -00171 case ECmdCancel: -00172 iSecEngine -> Cancel(); -00173 break; -00174 // When Exit chosen, stop engine and quit -00175 case EEikCmdExit: -00176 iSecEngine -> Cancel(); -00177 Exit(); -00178 default:; -00179 } -00180 } -00181 -00182 void CSecAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) -00183 { -00184 if (aResourceId == R_CONS_FILE_MENU) -00185 { -00186 // Dim items appropriately according to whether in engine started or not -00187 aMenuPane->SetItemDimmed(ECmdStart,iSecEngine->InUse()); -00188 aMenuPane->SetItemDimmed(ECmdCancel,!(iSecEngine->InUse())); -00189 } -00190 } -00191 -00192 CSecDocument::CSecDocument(CEikApplication& aApp) -00193 : CEikDocument(aApp) { } -00194 -00195 CSecDocument* CSecDocument::NewL(CEikApplication& aApp) -00196 { -00197 CSecDocument* self=new (ELeave) CSecDocument(aApp); -00198 CleanupStack::PushL(self); -00199 self->ConstructL(); -00200 CleanupStack::Pop(); -00201 return self; -00202 } -00203 -00204 void CSecDocument::ConstructL() -00205 { -00206 iSecEngine = CSecEngine::NewL(); -00207 } -00208 CSecDocument::~CSecDocument() -00209 { -00210 delete iSecEngine; -00211 } -00212 -00213 CEikAppUi* CSecDocument::CreateAppUiL() -00214 { -00215 return(new(ELeave) CSecAppUi(iSecEngine)); -00216 } -00217 -00218 TUid CSecApplication::AppDllUid() const -00219 { -00220 return(KUidSecApp); -00221 } -00222 -00223 CApaDocument* CSecApplication::CreateDocumentL() -00224 { -00225 return CSecDocument::NewL(*this); -00226 } -00227 -00228 EXPORT_C CApaApplication* NewApplication() -00229 { -00230 return(new CSecApplication); -00231 } -00232 -00233 GLDEF_C TInt E32Main() -00234 { -00235 return EikStart::RunApplication(NewApplication); -00236 } -00237 -