#ifndef __FPM_PROFILE_MANAGER_H__
#define __FPM_PROFILE_MANAGER_H__

#include "FirefoxPasswordManager.h"
#include "Common.h"
#include "SignonManager.h"


class ProfileManager
{
	SignonManager signonManager;
	
	char *profilePath;
	char *libraryPath;
	char *masterPassword;

	HMODULE libnss;
	HMODULE libplc;

	// NSS Library function pointers
	NSS_Init                NSSInit;
	NSS_Shutdown            NSSShutdown;
	//PK11_SetPasswordFunc    PK11SetPasswordFunc;
	PK11_GetInternalKeySlot PK11GetInternalKeySlot;
	PK11_FreeSlot           PK11FreeSlot;
	PK11_Authenticate       PK11Authenticate;
    PK11_CheckUserPassword  PK11CheckUserPassword;
	PK11SDR_Decrypt         PK11SDRDecrypt;
	PK11SDR_Encrypt         PK11SDREncrypt;

	PL_Base64Encode         PLBase64Encode;
	PL_Base64Decode         PLBase64Decode;

public : 

	char *profileName;
	int isInitialized;

private :

	char *GetFirefoxProfilePath(char *profileName);
	char *GetFirefoxLibPath();
	HMODULE PMLoadLibrary(char *firefoxDir, char *libName);
	int RefreshSignonData();
	


public:

	ProfileManager();

	int IsStoreAvailable();
	int ProfileInit(char *profileName);
	void ProfileExit();

	int IsMasterPasswordSet();
	int CheckMasterPassword(char *masterPassword, int doSave);

	int GetSignonData( struct Host **host, int doRefresh);
	int WriteSignonData();

	int AddHost(struct Host *host, int doUpdate);
	int ModifyHost(struct Host *host, int doUpdat);
	int RemoveHost(char *hostname, int doUpdate);

};


#endif