📄 sysinfo60container.cpp
字号:
/*
* ============================================================================
* Name : CSYSINFO60Container from SYSINFO60Container.h
* Part of : SYSINFO60
* Created : 10.05.2003 by Petri-Veikko Alaj鋜vi OH1GIU
* Implementation notes:
* Initial content was generated by Series 60 AppWizard.
* Version :
* Copyright: (c) 2003, Petri-Veikko Alaj鋜vi OH1GIU
* ============================================================================
*/
// INCLUDE FILES
#include "SYSINFO60Container.h"
#include <apaid.h>
#include <barsread.h>
#include <gdi.h>
#include <eikgted.h>
#include <eikenv.h>
#include <aknutils.h>
#include <w32std.h>
#include <t32alm.h>
#include <t32wld.h>
#include <f32file.h>
#include <etel.h>
#include <nifman.h>
#include <fbs.h>
#include <btsdp.h>
#include <d32dbms.h>
#include <wapcli.h>
#include <apgcli.h>
#include <sysutil.h>
#include <aknselectionlist.h>
#include "GenFuncs.h"
using namespace NGenFuncs;
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CSYSINFO60Container::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CSYSINFO60Container::ConstructL(const TRect& aRect)
{
CreateWindowL();
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC(reader, R_SYS_EDWIN);
iSysText = new (ELeave) CEikGlobalTextEditor;
iSysText->SetContainerWindowL(*this);
iSysText->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy();
iSysText->SetBackgroundColorL(KRgbDitheredLightGray);
SetFontL(R_EDITOR_FONT);
iSysText->SetWordWrapL(ETrue);
TBuf<1> clrTxt(_L(""));
iSysText->SetTextL(&clrTxt);
iSysText->SetFocus(EFalse);
iBitmapIndex = 0;
iBitmaps = new (ELeave) CArrayPtrFlat<CFbsBitmap>(KNumOfBitmaps);
LoadImageL(KPic_path);
SetImageDefs(iBitmapIndex);
SetRect(aRect);
ActivateL();
}
// Destructor
CSYSINFO60Container::~CSYSINFO60Container()
{
if (iBitmaps)
iBitmaps->ResetAndDestroy();
delete iBitmaps;
iBitmaps = NULL;
delete iSysText;
}
// ---------------------------------------------------------
// CSYSINFO60Container::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CSYSINFO60Container::SizeChanged()
{
iSysText->SetExtent(TPoint(0, 0), iSysText->MinimumSize());
}
// ---------------------------------------------------------
// CSYSINFO60Container::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CSYSINFO60Container::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CSYSINFO60Container::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CSYSINFO60Container::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iSysText;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CSYSINFO60Container::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CSYSINFO60Container::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbGray);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
TSize imageSize(iRfu60imgSize.iWidth, iRfu60imgSize.iHeight);
//TRect clientRect = Rect();
TPoint topLeft(KImageTop, KImageLeft);
TRect rect(topLeft, imageSize);
//gc.SetDrawMode(CGraphicsContext::TDrawMode::EDrawModeXOR);
gc.DrawBitmap(rect, iBitmaps->At(iBitmapIndex));
}
// ---------------------------------------------------------
// CSYSINFO60Container::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CSYSINFO60Container::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
// TODO: Add your control event handler code here
}
void CSYSINFO60Container::SetFontL(const TInt aResourceId)
{
TFontSpec* fontSpec = CreateFontSpecFromResourceL(aResourceId);
CleanupStack::PushL(fontSpec);
TCharFormat charFormat;
TCharFormatMask charFormatMask;
CFont* editorFont = iCoeEnv->CreateScreenFontL(*fontSpec);
CleanupStack::PushL(editorFont);
charFormat.iFontSpec = editorFont->FontSpecInTwips();
charFormatMask.SetAll();
iSysText->ApplyCharFormatL(charFormat, charFormatMask);
iCoeEnv->ReleaseScreenFont(editorFont); // release editorFont
CleanupStack::Pop(); // editorFont
CleanupStack::Pop(); // fontSpec
delete fontSpec; // delete Font
}
TFontSpec* CSYSINFO60Container::CreateFontSpecFromResourceL(const TInt aResourceId)
{
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC(reader, aResourceId);
HBufC* fontName;
TInt fontSize;
fontName = reader.ReadHBufCL();
fontSize = reader.ReadInt16();
CleanupStack::PopAndDestroy(); // for reader
CleanupStack::PushL(fontName);
TFontSpec* fontSpec = new TFontSpec(*fontName, fontSize);
CleanupStack::PopAndDestroy(); // for fontName
return fontSpec;
}
void CSYSINFO60Container::FmtVerString(const TVersion aVersion, TDes& aVersionTxt)
{
aVersionTxt.AppendNum(aVersion.iMajor);
aVersionTxt.Append(_L("."));
aVersionTxt.AppendNum(aVersion.iMinor);
aVersionTxt.Append(_L(" build "));
aVersionTxt.AppendNum(aVersion.iBuild);
}
void CSYSINFO60Container::GetGenVer(void)
{
ClrScreen();
iGText.Copy(_L("SERIES60 "));
FmtVerString(User::Version(), iGText);
iGText.Append(_L("\fUIKON "));
FmtVerString(iEikonEnv->Version(), iGText);
iGText.Append(_L("\fWIN SERVER "));
RWsSession rws = RWsSession();
FmtVerString(rws.Version(), iGText);
iGText.Append(_L("\fALARM SERVER "));
RAlarmServer ras;
FmtVerString(ras.Version(), iGText);
iGText.Append(_L("\fWORLD SERVER "));
RWorldServer rwsrv;
FmtVerString(rwsrv.Version(), iGText);
iGText.Append(_L("\fBITMAP SERVER "));
RFbsSession rfbs;
FmtVerString(rfbs.Version(), iGText);
iGText.Append(_L("\fDBMS SERVER "));
RDbs rdbs;
FmtVerString(rdbs.Version(), iGText);
iSysText->SetTextL(&iGText);
SizeChanged();
}
void CSYSINFO60Container::GetCFVer(void)
{
ClrScreen();
iGText.Copy(_L("FILE SERVER "));
FmtVerString(iRfs.Version(), iGText);
iGText.Append(_L("\fCOMMS SERVER "));
RCommServ rcs;
FmtVerString(rcs.Version(), iGText);
iGText.Append(_L("\fTEL SERVER "));
RTelServer ts;
FmtVerString(ts.Version(), iGText);
iGText.Append(_L("\fSOCKET SERVER "));
RSocketServ ss;
FmtVerString(ss.Version(), iGText);
iGText.Append(_L("\fWAP SERVER "));
RWAPServ ws;
FmtVerString(ws.Version(), iGText);
iGText.Append(_L("\fNIFMAN SERVER "));
RNif nif;
FmtVerString(nif.Version(), iGText);
iGText.Append(_L("\fSERV DISCOVERY "));
RSdp sdp;
FmtVerString(sdp.Version(), iGText);
iSysText->SetTextL(&iGText);
SizeChanged();
}
void CSYSINFO60Container::GetDrivesL(void)
{
ClrScreen();
User::LeaveIfError(iRfs.Connect());
TChar driveLetter;
TDriveInfo driveInfo;
TInt driveNumber = EDriveA;
iError = KErrNone;
TVolumeInfo volumeInfo;
TBuf<40> fileSys;
fileSys.Zero();
for (; driveNumber <= EDriveZ; driveNumber++)
{
iRfs.Drive(driveInfo, driveNumber);
if (iError != KErrNone)
{
iRfs.Close();
User::Leave(iError);
}
if (driveInfo.iDriveAtt != static_cast<TUint> (KDriveAbsent))
{
iError = iRfs.DriveToChar(driveNumber, driveLetter);
if (iError != KErrNone)
{
iRfs.Close();
User::Leave(iError);
}
iGText.Append(driveLetter);
iGText.Append(_L(" "));
switch (driveInfo.iType)
{
case EMediaRam:
iGText.Append(_L("RAM"));
break;
case EMediaRom:
iGText.Append(_L("ROM"));
break;
case EMediaFlash:
iGText.Append(_L("FLASH"));
break;
case EMediaRemote:
iGText.Append(_L("RMT"));
break;
case EMediaHardDisk:
iGText.Append(_L("HDD"));
break;
case EMediaFloppy:
iGText.Append(_L("FDD"));
break;
case EMediaCdRom:
iGText.Append(_L("CD"));
break;
default:
iGText.Append(_L("?"));
break;
}
if (iRfs.Volume(volumeInfo, driveNumber) == KErrNone)
{
iGText.Append(_L(" "));
iGText.AppendNum(volumeInfo.iSize / 1024);
iGText.Append(_L("K/"));
iGText.AppendNum(volumeInfo.iFree / 1024);
iGText.Append(_L("K"));
}
if (iRfs.FileSystemName(fileSys, driveNumber) == KErrNone)
{
iGText+=(_L(" "));
iGText+=(fileSys.Left(7));
}
iGText+=(_L("\f"));
}
}
iRfs.Close();
iSysText->SetTextL(&iGText);
SizeChanged();
}
void CSYSINFO60Container::ShowAppListLC(const TInt aMode)
{
User::LeaveIfError(iRfs.Connect());
RApaLsSession apa;
iError = apa.Connect();
if (iError)
{
iRfs.Close();
User::Leave(iError);
}
TInt appCount = 0;
iError = apa.AppCount(appCount);
if (iError != KErrNone)
{
iRfs.Close();
apa.Close();
User::Leave(iError);
}
if (aMode == KApps)
{
TInt empAppCount = 0;
iError = apa.EmbeddableAppCount(empAppCount);
if (iError != KErrNone)
{
iRfs.Close();
apa.Close();
User::Leave(iError);
}
ClrScreen();
iGText.Format(_L("Applications %d"), appCount);
//iGText.AppendNum(appCount);
iGText.Append(_L("\fEmbeddable applications "));
iGText.AppendNum(empAppCount);
iGText.Append(_L("\fApp architecture server\f"));
FmtVerString(apa.Version(), iGText);
apa.Close();
RWsSession rws = RWsSession();
if (rws.Connect() == KErrNone)
{
empAppCount = rws.NumWindowGroups();
rws.Close();
iGText.Append(_L("\fWindow groups "));
iGText.AppendNum(empAppCount);
}
iSysText->SetTextL(&iGText);
SizeChanged();
return;
}
iError = apa.GetAllApps();
if (iError != KErrNone)
{
iRfs.Close();
apa.Close();
User::Leave(iError);
}
CDesCArrayFlat* items = new(ELeave) CDesCArrayFlat(appCount);
CleanupStack::PushL(items);
CArrayFixFlat<TUid>* appUids = new (ELeave) CArrayFixFlat<TUid>(appCount);
CleanupStack::PushL(appUids);
TApaAppInfo appInfo;
TInt i = 0;
for (; i < appCount; i++)
{
if (apa.GetNextApp(appInfo) != KErrNone) break;
iKdata.Copy(_L(""));
iKdata.AppendNum(i + 1);
iKdata.Append(_L("\t"));
TBuf<64> appname(appInfo.iCaption);
appname.Trim();
if (appname.Length() != 0)
{
iKdata.Append(appInfo.iCaption);
}
else
{
/*
TChar searchStr('\\');
TInt strLen = -1;
TInt chPos = appInfo.iFullName.LocateReverse(searchStr);
if (chPos != KErrNotFound)
{
strLen = appInfo.iFullName.Length() - ++chPos;
}
if (strLen > 0)
kdata.Append(appInfo.iFullName.Right(strLen));
else
kdata.Append(appInfo.iFullName.Right(18));
*/
TParse p;
p.Set(appInfo.iFullName, NULL, NULL);
iKdata.Append(p.Name());
}
iItemData.Copy(iKdata);
items->AppendL(iItemData);
appUids->AppendL(appInfo.iUid);
}
if (i > 0)
{
TInt selectedItem(0);
CAknSelectionListDialog* apaList = CAknSelectionListDialog::NewL(selectedItem, items, R_MENUBAR);
if (apaList->ExecuteLD(R_APA_LIST))
{
iError = apa.GetAppInfo(appInfo, appUids->At(selectedItem));
if (!iError)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -