/***************************************************************************

    supportware
    Copyright (C) 2001-2008 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/


#ifndef ddusersessionmanager_H
#define ddusersessionmanager_H

#include <ddstringrow.h>
#include <dduserid.h>
#include <ddthreadmutex.h>


using namespace std;



/// ddusersessionmanager: a map to store userid objects.

class ddusersessionmanager : public dduseridmap
{

friend class ddusermanager;

public:

	void 						cleanup_sessions();
	bool 						is_member_online( const ddstring& nickname ); 
	int		 					session_count(); 

	void						add_admin_access( dduserid* user, const ddstring& access );
		
	// neuer rott, crashed, aber wahrscheinlich schon in den blocks
	//void create_block_memberbox( ddstring& result );
	//void create_block_teambox( ddstring& result );
	
	// alter rott, läuft
	const ddstring& create_team_box();
	// alter rott, läuft nicht	
	const ddstring& create_member_box();

protected:
 
  dduserid*				get_user_id( const ddstring& key );
	void			 			add_user_id( const ddstring& key, dduserid* userid );
	void 						set_access_rights( dduserid* userid );
	
	void 						dump() const;

	dduseridmap			_membermap;
	//dduseridset		_memberset;
	dduseridset		 	_adminset;
	ddmapindex			_accessmap;
	
	ddthreadmutex	 	_listlock;
	
	// alter kram
	ddstring			 	_memberbox;
	ddstring			 	_teambox;
	
};














#endif


