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

📄 svexinfo.h

📁 演示如何使用的symbian v9服务器应用框架
💻 H
字号:
// Copyright (c) 2006 Murray Read, All rights reserved

#ifndef SVEXINFO_H
#define SVEXINFO_H

#include <e32base.h>
#include <ApgCli.h>
#include <e32hashtab.h>


// The information for a single registration of a service by a
// server app.
class TSvexAppServiceInfo
	{
public:	// not exported
	TSvexAppServiceInfo(TUid aAppUid, TUid aServiceUid, const TApaAppServiceInfo& aInfo);

public:
	TUid iAppUid;
	TUid iServiceUid;
	const TApaAppServiceInfo& iInfo;
	};


// Interface class for collections of registrations
class MSvexAppServiceInfoArray
	{
public:
	virtual ~MSvexAppServiceInfoArray();
	virtual TInt MsasiCount() const = 0;
	virtual TSvexAppServiceInfo MsasiAt(TInt aIndex) const = 0;
	};


// A collection of services registered by a particular server app
class CSvexAppInfo : public CBase, public MSvexAppServiceInfoArray
	{
public:
	IMPORT_C ~CSvexAppInfo();

	IMPORT_C TUid AppUid() const;
	IMPORT_C const TApaAppCaption& AppCaption() const;

public: // from MSvexAppServiceInfoArray
	TInt MsasiCount() const;
	TSvexAppServiceInfo MsasiAt(TInt aIndex) const;

public: // not exported
	CSvexAppInfo(TUid aAppUid, const TApaAppCaption& aAppCaption, CApaAppServiceInfoArray* aServiceInfo);

private:
	TUid iUid;
	CApaAppServiceInfoArray* iInfo;		// owned
	TArray<TApaAppServiceInfo> iArray;
	TApaAppCaption iCaption;
	};


// A collection of server apps that implement a particular service.
// Note: real implementations are supplied as private derived classes
class CSvexServiceInfo : public CBase, public MSvexAppServiceInfoArray
	{
public:
	IMPORT_C TUid ServiceUid() const;

protected:	// not exported
	CSvexServiceInfo(TUid aServiceUid);

private:
	TUid iUid;	
	};


// All there is to know about the server apps and services that
// are discoverable through apparc.
// Part 1, the cheap version. This allows the client to get
// information directly from apparc. It assumes that the client
// already knows which server apps and services exists.
class CSvexInfoBase : public CBase
	{
public:
	IMPORT_C static CSvexInfoBase* NewL();
	IMPORT_C static CSvexInfoBase* NewLC();
	IMPORT_C ~CSvexInfoBase();

public: // APIs for exploring individual apps and services
	IMPORT_C CSvexServiceInfo* DirectServiceInfoLC(TUid aServiceUid) const;
	IMPORT_C CSvexAppInfo* DirectAppInfoLC(TUid aAppUid) const;

	IMPORT_C virtual TApaAppCaption AppCaption(TUid aAppUid) const;
	IMPORT_C virtual const CSvexServiceInfo& ServiceInfoServiceL() const;
	IMPORT_C RApaLsSession& LsSession() const;
	
protected:
	CSvexInfoBase();
	void ConstructL();

	CSvexAppInfo* DirectAppInfoLC(const TApaAppInfo& aAppInfo) const;

protected:
	mutable RApaLsSession iLs;
	
private:
	mutable CSvexServiceInfo* iServiceInfoService;
	};


// All there is to know about the server apps and services that
// are discoverable through apparc.
// Part 2, the expensive version.
// This class scans the entire apparc apps list looking for
// server apps and the services they implement.
// From this, it can build lists of all server apps and services.
// The apparc scan takes some time, but this class makes extensive
// use of RHashMap to reduce the computation time to cross reference
// the apps and services.
class CSvexInfo : public CSvexInfoBase
	{
public:
	IMPORT_C static CSvexInfo* NewL();
	IMPORT_C static CSvexInfo* NewLC();
	IMPORT_C ~CSvexInfo();
	
public: // APIs for exploring all apps and services
	// apps info
	IMPORT_C const RArray<TUid>& AppUids() const;
	IMPORT_C const CSvexAppInfo& AppInfo(TUid aAppUid) const;
	
	// services info
	IMPORT_C const RArray<TUid>& ServiceUids() const;
	IMPORT_C const CSvexServiceInfo& ServiceInfo(TUid aServiceUid) const;

public: // from CSvexInfoBase
	IMPORT_C TApaAppCaption AppCaption(TUid aAppUid) const;
	IMPORT_C const CSvexServiceInfo& ServiceInfoServiceL() const;

private:
	CSvexInfo();
	void ConstructL();

	void GetAllInfoL();	
	void CleanupInfo();
	static void CleanupInfoCallback(TAny* aThis);
	void AddAppL(const TApaAppInfo& aAppInfo);

private:
	typedef RHashMap<TInt, CSvexAppInfo*> RSvexAppInfoMap;
	RSvexAppInfoMap iAppMap;

	typedef RHashMap<TInt, CSvexServiceInfo*> RSvexServiceInfoMap;
	RSvexServiceInfoMap iServiceMap;
	
	RArray<TUid> iAppUids;
	RArray<TUid> iServiceUids;
	};


#endif

⌨️ 快捷键说明

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