#ifndef __LOGINMANAGER_H__
#define __LOGINMANAGER_H__

// The purpose of this class is to manage some aspects of the login
// behaviour. These are:
// - Password dialog for servers with ASK or INTERACTIVE logontype
// - Storage of passwords for ASK servers for duration of current session

class CLoginManager
{
public:
	static CLoginManager& Get() { return m_theLoginManager; }

	bool GetPassword(CServer& server, bool silent, wxString const& name = wxString(), wxString const& challenge = wxString(), bool canRemember = true);

	void CachedPasswordFailed(const CServer& server, wxString const& challenge = wxString());

	void RememberPassword(CServer & server, wxString const& challenge = wxString());

protected:
	bool DisplayDialog(CServer& server, wxString const& name, wxString challenge, bool canRemember);

	static CLoginManager m_theLoginManager;

	// Session password cache for Ask-type servers
	struct t_passwordcache
	{
		wxString host;
		unsigned int port;
		wxString user;
		wxString password;
		wxString challenge;
	};
	
	std::list<t_passwordcache>::iterator FindItem(CServer const& server, wxString const& challenge);
	
	std::list<t_passwordcache> m_passwordCache;
};

#endif //__LOGINMANAGER_H__
