// APGCLI.H
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//

#if !defined(__APGCLI_H__)
#define __APGCLI_H__

#if !defined(__E32BASE_H__)
#include <e32base.h>
#endif
#if !defined(__APMSTD_H__)
#include <apmstd.h>
#endif
#if !defined(__APMREC_H__)
#include <apmrec.h>
#endif

// classes referenced
class CApaCommandLine;
class TApaAppInfo;
class CApaMaskedBitmap;
//

////////////////////////////////////
// RApaLsSession
////////////////////////////////////

class RApaLsSession : public RSessionBase
	{
public:
	enum {
		ENoMoreAppsInList=1,
		EAppListInvalid
		};
	enum TLaunchType {
		ELaunchNewApp=1,
		ESwitchFiles
		};
public:
	IMPORT_C RApaLsSession();
	//
	IMPORT_C TInt Connect();
	IMPORT_C TVersion Version() const;
	//
	IMPORT_C TInt AppCount(TInt& aCount); // returns error
	IMPORT_C TInt EmbeddableAppCount(TInt& aCount); // returns error
	//
	IMPORT_C TInt GetAllApps(); // Call to initialize
	IMPORT_C TInt GetEmbeddableApps(); // Call to initialize
	IMPORT_C TInt GetNextApp(TApaAppInfo& aInfo); // call repeatedly, returns err (inc ENoMoreAppsInList,EAppListInvalid)
	//
	IMPORT_C TInt GetAppInfo(TApaAppInfo& aInfo,TUid aAppUid);
	IMPORT_C TInt GetAppCapability(TDes8& aCapabilityBuf,TUid aAppUid);
	IMPORT_C TInt StartApp(const CApaCommandLine& aCommandLine); // This is only recommended for non document based apps
	//
	// ER5 additions
	IMPORT_C TInt RecognizeData(const TDesC& aName, const TDesC8& aBuffer, TDataRecognitionResult& aDataType);
	IMPORT_C TInt RecognizeSpecificData(const TDesC& aName, const TDesC8& aBuffer, const TDataType& aDataType, TBool& aResult);
	//
	IMPORT_C TInt AppForDataType(const TDataType& aDataType, TUid& aAppUid);
	IMPORT_C TInt StartDocument(const TDesC& aFileName, TThreadId& aId, TLaunchType aLaunchType=ELaunchNewApp);
	IMPORT_C TInt StartDocument(const TDesC& aFileName, const TDataType& aDataType, TThreadId& aId, TLaunchType aLaunchType=ELaunchNewApp);
	IMPORT_C TInt StartDocument(const TDesC& aFileName, TUid aAppUid, TThreadId& aId, TLaunchType aLaunchType=ELaunchNewApp);
	IMPORT_C TInt CreateDocument(const TDesC& aFileName, TUid aAppUid, TThreadId& aId, TLaunchType aLaunchType=ELaunchNewApp);
	//
	IMPORT_C TInt GetAppIcon(TUid aAppUid, TInt aSize, CApaMaskedBitmap& aAppBitmap);
	//
	IMPORT_C TInt AppForDocument(const TDesC& aFileName, TUid& aUid, TDataType& aDataType);
	IMPORT_C TInt IsProgram(const TDesC& aFileName, TBool& aProgram);
	IMPORT_C TInt GetAcceptedConfidence(TInt& aConfidence);
	IMPORT_C TInt SetAcceptedConfidence(TInt aConfidence);
	IMPORT_C TInt GetMaxDataBufSize(TInt& aBufSize);
	IMPORT_C TInt SetMaxDataBufSize(TInt aBufSize);
	IMPORT_C TInt GetSupportedDataTypesL(CDataTypeArray& aDataTypes);
private:
	TInt DoAppCount(TInt& aCount,TInt aCommand);
	TInt DoGetApps(TInt aCommand);
	TInt StartAndCreate(TInt aRqst,const TDesC& aFileName, TUid aAppUid, TThreadId& aId, TLaunchType aLaunchType);
	TInt ReconnectToServer(TInt aErr,TBool& aTriedOnce);
	TInt SendReceiveWithReconnect(TInt aFunction, TAny* aPtr);
	};


#endif

