?? wikisecuresocketexappui.cpp
字號:
/*
============================================================================
Name : WikiSecureSocketExAppUi.cpp
based on : http://www.symbian.com/developer/techlib/v9.2docs/doc_source/examples/NetworkingEx/SSLExampleCode.guide.html#NetworkingEx%2eSSLExampleCode
Author : Konstantine; Company: Fishnest Ukraine Sebastopol
Support : bluspan@gmail.com
Description : CWikiSecureSocketExAppUi implementation
============================================================================
*/
// INCLUDE FILES
#include <avkon.hrh>
#include <aknmessagequerydialog.h>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <f32file.h>
#include <s32file.h>
#include <hlplch.h>
#include <WikiSecureSocketEx_0xE2404284.rsg>
#include "WikiSecureSocketEx_0xE2404284.hlp.hrh"
#include "WikiSecureSocketEx.hrh"
#include "WikiSecureSocketEx.pan"
#include "WikiSecureSocketExApplication.h"
#include "WikiSecureSocketExAppUi.h"
#include "WikiSecureSocketExAppView.h"
_LIT( KFileName, "C:\\private\\E2404284\\WikiSecureSocketEx.txt" );
_LIT( KText, "Secure Socket test");
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CWikiSecureSocketExAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CWikiSecureSocketExAppUi::ConstructL()
{
// Initialise app UI with standard value.
BaseConstructL(CAknAppUi::EAknEnableSkin);
// Create view object
iAppView = CWikiSecureSocketExAppView::NewL( ClientRect() );
// Create a file to write the text to
RFs fsSession;
User::LeaveIfError(fsSession.Connect());
CleanupClosePushL( fsSession );
TInt err = fsSession.MkDirAll(KFileName);
if ( (KErrNone != err) && (KErrAlreadyExists != err) )
{
CleanupStack::PopAndDestroy(1); // fsSession
return;
}
RFile file;
err = file.Replace(fsSession, KFileName, EFileWrite );
CleanupClosePushL( file );
if ( KErrNone != err )
{
CleanupStack::PopAndDestroy(2); // file, fsSession
return;
}
RFileWriteStream outputFileStream( file );
CleanupClosePushL( outputFileStream );
outputFileStream << KText;
CleanupStack::PopAndDestroy(3); // outputFileStream, file, fsSession
}
// -----------------------------------------------------------------------------
// CWikiSecureSocketExAppUi::CWikiSecureSocketExAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CWikiSecureSocketExAppUi::CWikiSecureSocketExAppUi()
{
// Initialize RBufConsole
TInt maxSizeOfMsgData = 150; // trims text to 150 characters
_LIT(KGenesis , "App starts\n");
msg.Create(KGenesis(), maxSizeOfMsgData);
iSecureSocketCore = CSecureSocketCore::NewL();
}
// -----------------------------------------------------------------------------
// CWikiSecureSocketExAppUi::~CWikiSecureSocketExAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CWikiSecureSocketExAppUi::~CWikiSecureSocketExAppUi()
{
// Clean RBuf console
msg.Close();
delete iSecureSocketCore;
//
if ( iAppView )
{
delete iAppView;
iAppView = NULL;
}
}
// -----------------------------------------------------------------------------
// CWikiSecureSocketExAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CWikiSecureSocketExAppUi::HandleCommandL( TInt aCommand )
{
switch( aCommand )
{
case EEikCmdExit:
case EAknSoftkeyExit:
Exit();
break;
case ECommand1:
{
iSecureSocketCore->SetRBufConsoleObserver(this);
iSecureSocketCore->ConnectL();
}
break;
case ECommand2:
{
}
//break;
case EHelp:
{
}
//break;
case EAbout:
{
CAknMessageQueryDialog* dlg = new (ELeave)CAknMessageQueryDialog();
dlg->PrepareLC(R_ABOUT_QUERY_DIALOG);
HBufC* title = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TITLE);
dlg->QueryHeading()->SetTextL(*title);
CleanupStack::PopAndDestroy(); //title
HBufC* msg = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TEXT);
dlg->SetMessageTextL(*msg);
CleanupStack::PopAndDestroy(); //msg
dlg->RunLD();
}
break;
default:
Panic( EWikiSecureSocketExUi );
break;
}
}
// -----------------------------------------------------------------------------
// Called by the framework when the application status pane
// size is changed. Passes the new client rectangle to the
// AppView
// -----------------------------------------------------------------------------
//
void CWikiSecureSocketExAppUi::HandleStatusPaneSizeChange()
{
iAppView->SetRect( ClientRect() );
}
CArrayFix<TCoeHelpContext>* CWikiSecureSocketExAppUi::HelpContextL() const
{
CArrayFixFlat<TCoeHelpContext>* array = new(ELeave)CArrayFixFlat<TCoeHelpContext>(1);
CleanupStack::PushL(array);
array->AppendL(TCoeHelpContext(KUidWikiSecureSocketExApp, KGeneral_Information));
CleanupStack::Pop(array);
return array;
}
//== Konstantine_entrance : mycode myfuncimplementation
void CWikiSecureSocketExAppUi::ShowTextOutPutDialog(RBuf &msg)
{
// Show OutPutedText
_LIT(KDialogHeader, "Output");
CAknMessageQueryDialog* dlg = new (ELeave)CAknMessageQueryDialog();
dlg->PrepareLC(R_TEXTOUTPUT_QUERY_DIALOG);
RBuf title;
title.Create(KDialogHeader());
dlg->QueryHeading()->SetTextL(title);
dlg->SetMessageTextL(msg);
dlg->RunLD();
title.Close();
return;
}
void CWikiSecureSocketExAppUi::AppendToOutPutString(RBuf &OutPut, TPtrC16 appendString)
{
const TInt newLength = OutPut.Length() + appendString.Length();
if (OutPut.Length() < newLength )
{
OutPut.ReAlloc(newLength);
}
OutPut.Append(appendString);
}
void CWikiSecureSocketExAppUi::AppendToConsole(TPtrC16 appendString)
{
AppendToOutPutString(msg, appendString);
}
void CWikiSecureSocketExAppUi::ShowConsole()
{
ShowTextOutPutDialog(msg);
}
// End of File
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -