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

📄 appservicelist.cpp

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

#include "AppServiceList.h"
#include <SvexInfo.h>
#include "ServiceExplorerApp.hrh"
#include <SvexRegDialog.h>
#include <SvexService.hrh>
#include <SvexUtil.h>

const TInt KMaxTitleLen = 300;


CAppServiceListControl::CAppServiceListControl(const CSvexInfo& aInfo, TUid aAppUid)
: iInfo(aInfo), iAppUid(aAppUid), iAppInfo(aInfo.AppInfo(aAppUid))
	{
	}

CAppServiceListControl::~CAppServiceListControl()
	{
	// 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;
	}

void CAppServiceListControl::ConstructFromResourceL(TResourceReader&)
	{
	ConstructControlL();
	}

void CAppServiceListControl::ConstructControlL()
	{
	TBuf<KMaxTitleLen> b;
	_LIT(KFormat, "%S's services");
	b.Format(KFormat, &iAppInfo.AppCaption());
	SetTitlePaneL(b);
	CleanupStack::Pop(iServicesInfo = CSvexServiceServiceInfo::NewLC(iInfo.ServiceInfoServiceL()));
	CSvexListView::ConstructControlL();
	}

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

TInt CAppServiceListControl::Count() const
	{
	return iAppInfo.MsasiCount();
	}

void CAppServiceListControl::GetText(TInt aIndex, TBuf<KMaxListText>& aText) const
	{
	TSvexAppServiceInfo service = iAppInfo.MsasiAt(aIndex);
	TUid uid = service.iServiceUid;
	_LIT(KFormat, "\t%S\t0x%08x\t");
	aText.Format(KFormat, &iServicesInfo->ServiceName(uid), uid.iUid);
	}

void CAppServiceListControl::OpenL()
	{
	// An app's service has been selected, we need to open a server
	// app to show the details of the app's registration of
	// this service. First find out which service...
	TInt index = iListBox->CurrentItemIndex();
	if (0 <= index && index < Count())
		{
		delete iServerApp;
		iServerApp = 0;
		TSvexAppServiceInfo reg = iAppInfo.MsasiAt(index);
		// ... then launch the server app to show the detail,
		// with this class monitoring the server app's lifetime...
		iServerApp = CSvexServiceInfoClient::NewAppL(iInfo.ServiceInfoServiceL(), this, reg.iServiceUid, reg.iAppUid);
		// ... that's it!
		}
	}

TSize CAppServiceListControl::MinimumSize()
	{
	return iEikonEnv->EikAppUi()->ClientRect().Size();
	}

void CAppServiceListControl::HandleServerAppExit(TInt aReason)
	{
	// The server app has exited. Tidy up, then base call.
	delete iServerApp;
	iServerApp = 0;
	MAknServerAppExitObserver::HandleServerAppExit(aReason);
	}



CAppServiceListDialog::CAppServiceListDialog(const CSvexInfo& aInfo, TUid aAppUid)
: iInfo(aInfo), iAppUid(aAppUid)
	{
	}

SEikControlInfo CAppServiceListDialog::CreateCustomControlL(TInt aControlType)
	{
	// A custom control id is used to create the list
    SEikControlInfo control = {0, 0, 0};

    if (aControlType == EServiceExplorerControlId)
        control.iControl = new (ELeave) CAppServiceListControl(iInfo, iAppUid);
	else
		control = CAknDialog::CreateCustomControlL(aControlType);

    return control;
	}

void CAppServiceListDialog::ProcessCommandL(TInt aCommandId)
	{
	List()->HandleCommandL(aCommandId);
	CAknDialog::ProcessCommandL(aCommandId);
	}

TBool CAppServiceListDialog::OkToExitL(TInt aButtonId)
	{
	switch (aButtonId)
		{
		case EAknSoftkeyOk:
			List()->HandleCommandL(KSvexCmdIdOpen);
			break;
		case EAknSoftkeyBack:
			return ETrue;
		default:
			return CAknDialog::OkToExitL(aButtonId);
		}
    return EFalse;
	}

CAppServiceListControl* CAppServiceListDialog::List()
	{
	return ((CAppServiceListControl*)Control(EServiceExplorerLineId));
	}


⌨️ 快捷键说明

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