serviceview.cpp

来自「symbian下读取服务的程序」· C++ 代码 · 共 81 行

CPP
81
字号
// Copyright (c) 2006 Murray Read, All rights reserved

#include "ServiceView.h"
#include <SvexInfo.h>
#include <SvexService.h>
#include <SvexService.hrh>


CServiceView* CServiceView::NewLC(const CSvexInfo& aInfo)
	{
	CServiceView* self = new(ELeave) CServiceView(aInfo);
	CleanupStack::PushL(self);
	self->ConstructMainPaneL();
	return self;
	}

CServiceView::CServiceView(const CSvexInfo& aInfo)
: iInfo(aInfo)
	{
	}

CServiceView::~CServiceView()
	{
	// Delete the server app client if this app closes before
	// the server app. In S60, the usual behavior of the server
	// app is to close when all of its clients exit.
	delete iServerApp;
	delete iServicesInfo;
	}

CEikTextListBox* CServiceView::NewListBoxL() const
	{
	return new (ELeave) CAknDoubleStyleListBox();
	}

TInt CServiceView::Count() const
	{
	return iInfo.ServiceUids().Count();
	}

void CServiceView::GetText(TInt aIndex, TBuf<KMaxListText>& aText) const
	{
	TUid uid = iInfo.ServiceUids()[aIndex];
	_LIT(KFormat, "\t%S\t0x%08x\t");
	aText.Format(KFormat, &iServicesInfo->ServiceName(uid), uid.iUid);
	}

void CServiceView::ConstructMainPaneL()
	{
	CleanupStack::Pop(iServicesInfo = CSvexServiceServiceInfo::NewLC(iInfo.ServiceInfoServiceL()));
	CSvexListView::ConstructMainPaneL();
	}

void CServiceView::OpenL()
	{
	// A service has been selected. Find out which one and launch
	// a server app to get more information about it. First get
	// the service UID.
	TInt index = iListBox->CurrentItemIndex();
	TInt count = iInfo.ServiceUids().Count();
	if (index < 0 || count <= index)
		return;
	
	TUid uid = iInfo.ServiceUids()[index];

	// Then launch the server app. This class monitors the server app's
	// lifetime.
	delete iServerApp;
	iServerApp = 0;
	iServerApp = CSvexServiceInfoClient::NewAllL(iInfo.ServiceInfoServiceL(), this, uid);
	}

void CServiceView::HandleServerAppExit(TInt aReason)
	{
	// The server app has exited, clean up and base-call.
	delete iServerApp;
	iServerApp = 0;
	MAknServerAppExitObserver::HandleServerAppExit(aReason);
	}

⌨️ 快捷键说明

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