⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svexregdialog.cpp

📁 symbian下读取服务的程序
💻 CPP
字号:
// Copyright (c) 2006 Murray Read, All rights reserved

#include "SvexRegDialog.h"
#include "SvexService.h"
#include <EikEnv.h>
#include <ServiceExplorerLib.rsg>
#include <AknMessageQueryDialog.h>
#include <bautils.h>

const TInt KInitBufLen = 64;
const TInt KMaxTextLen = 64;


EXPORT_C CAppServiceInfoDialog* CAppServiceInfoDialog::NewL(const TSvexAppServiceInfo& aReg, const CSvexInfoBase& aInfo)
	{
	CAppServiceInfoDialog* self = new(ELeave) CAppServiceInfoDialog(aReg, aInfo);
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop(self);
	return self;
	}

EXPORT_C CAppServiceInfoDialog::~CAppServiceInfoDialog()
	{
	delete iDialog;
	delete iBuf;
	// unload the resource file if it was added by this class
	if (iResourceOffset)
		iEikonEnv->RemoveLibrary(iResourceOffset);
	delete iServicesInfo;
	}

EXPORT_C void CAppServiceInfoDialog::ExecuteLD()
	{
	if (iDialog)
	    iDialog->ExecuteLD(R_SERVICEEXPLORERLIB_REG_DLG);
    iDialog = 0;
    delete this;
	}

EXPORT_C CAppServiceInfoDialog::CAppServiceInfoDialog(const TSvexAppServiceInfo& aReg, const CSvexInfoBase& aInfo)
: iReg(aReg), iInfo(aInfo), iCoeEnv(CCoeEnv::Static())
	{
	}

EXPORT_C void CAppServiceInfoDialog::ConstructL()
	{
	CleanupStack::Pop(iServicesInfo = CSvexServiceServiceInfo::NewLC(iInfo.ServiceInfoServiceL()));
	LoadResourcesL();
	MakeBufL();
    iDialog = new (ELeave) CAknMessageQueryDialog;
    iDialog->SetMessageTextL(*iBuf);
	}

void CAppServiceInfoDialog::MakeBufL()
	{
	iBuf = HBufC::NewL(KInitBufLen);
	DialogTextL();
	}

EXPORT_C void CAppServiceInfoDialog::DialogTextL()
	{
	// Use AppendTextL() to add all known generic info about a
	// service registration
	TBuf<KMaxTextLen> b;
	
	_LIT(KServiceName, "Service name:\n");
	AppendTextL(KServiceName);
	AppendTextL(iServicesInfo->ServiceName(iReg.iServiceUid));
	_LIT(KCrlf, "\n");
	AppendTextL(KCrlf);
	_LIT(KServiceUid ,"Service UID:\n");
	AppendTextL(KServiceUid);
	_LIT(KHexFormat, "0x%08x\n\n");
	b.Format(KHexFormat, iReg.iServiceUid);
	AppendTextL(b);
	
	_LIT(KAppName, "App name:\n");
	AppendTextL(KAppName);
	AppendTextL(iInfo.AppCaption(iReg.iAppUid));
	AppendTextL(KCrlf);
	_LIT(KAppUid, "App UID:\n");
	AppendTextL(KAppUid);
	b.Format(KHexFormat, iReg.iAppUid);
	AppendTextL(b);

	_LIT(KMimeTypes, "Mime types:\n");
	AppendTextL(KMimeTypes);
	const CArrayFixFlat<TDataTypeWithPriority>& dataTypes = iReg.iInfo.DataTypes();
	TInt count = dataTypes.Count();
	for (TInt ii=0; ii<count; ii++)
		{
		const TDataTypeWithPriority& dataType = dataTypes[ii];
		_LIT(KInt, "%d ");
		b.Format(KInt, dataType.iPriority);
		AppendTextL(b);
		AppendTextL(dataType.iDataType.Des());
		AppendTextL(KCrlf);
		}
	
	_LIT(KOpaqueData, "\nopaque data:\n");
	AppendTextL(KOpaqueData);
	const TDesC8& opaque = iReg.iInfo.OpaqueData();
	count = opaque.Length();
	for (TInt ii=0; ii<count; ii++)
		{
		TText8 ch = opaque[ii];
		_LIT(K2HexFormat, "%02x ");
		b.Format(K2HexFormat, ch);
		AppendTextL(b);
		}
	AppendTextL(KCrlf);
	for (TInt ii=0; ii<count; ii++)
		{
		TText8 ch = opaque[ii];
		_LIT(KCharFormat, "%c");
		b.Format(KCharFormat, ch);
		AppendTextL(b);
		}
	}

void CAppServiceInfoDialog::LoadResourcesL()
	{
	if (iEikonEnv->IsResourceAvailableL(R_SERVICEEXPLORERLIB_REG_DLG))
		return;
	
	// find and load the resource file that the dialog needs.
    TFileName fileName;
    Dll::FileName(fileName);
    fileName.SetLength(2);
	_LIT(KResFile,"\\resource\\ServiceExplorerLib.rsc");
    fileName.Append(KResFile);

    BaflUtils::NearestLanguageFile(iEikonEnv->FsSession(), fileName);
	iResourceOffset = iEikonEnv->AddLibraryL(&fileName);
	}

EXPORT_C void CAppServiceInfoDialog::AppendTextL(const TDesC& aText)
	{
	// AppendTextL uses exponential growth of the HBufC to
	// reduce runtime to O(n log n) from O(n^2)
	while (aText.Length() + iBuf->Length() > iBuf->Des().MaxLength())
		iBuf = iBuf->ReAllocL(iBuf->Des().MaxLength()*2);
	iBuf->Des().Append(aText);
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -