diff options
Diffstat (limited to 'user.cpp')
| -rwxr-xr-x[-rw-r--r--] | user.cpp | 92 |
1 files changed, 23 insertions, 69 deletions
@@ -5,40 +5,29 @@ #include "user.h" #include "CONF.h" -#include "MUTX.h" #include "TOOL.h" using namespace std; user::user( string s_name ) : name( s_name ) { -#ifdef VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "user::user( string \"" << s_name << "\" )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - this -> b_online = true; this -> l_time = TOOL::unixtime(); this -> s_col1 = CONF::get().get_val( "USERCOL1" ); pthread_mutex_init( &mut_b_online, NULL); + pthread_mutex_init( &mut_i_sock , NULL); pthread_mutex_init( &mut_l_time , NULL); - pthread_mutex_init( &mut_p_room , NULL); - pthread_mutex_init( &mut_s_mess, NULL); + pthread_mutex_init( &mut_p_room , NULL); + pthread_mutex_init( &mut_s_mess , NULL); pthread_cond_init ( &cond_message, NULL); - pthread_mutex_init( &mut_message, NULL); + pthread_mutex_init( &mut_message , NULL); } user::~user() { -#ifdef VERBOSE - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "user::~user[ \"" << get_name() << "\" ]" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - pthread_mutex_destroy( &mut_b_online ); + pthread_mutex_destroy( &mut_i_sock ); pthread_mutex_destroy( &mut_l_time ); pthread_mutex_destroy( &mut_p_room ); pthread_mutex_destroy( &mut_s_mess ); @@ -49,12 +38,6 @@ user::~user() void user::get_data( map_string *p_map_data ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "user::get_data( map_string* )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - string s_req = (*p_map_data)["!get"]; // get the nick and the color of the user. @@ -65,12 +48,6 @@ user::get_data( map_string *p_map_data ) string user::get_mess( ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "user::get_mess( )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - string s_ret( "" ); pthread_mutex_lock ( &mut_s_mess ); s_ret.append( s_mess ); @@ -83,12 +60,6 @@ user::get_mess( ) bool user::get_online( ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "user::get_online( )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - bool b_ret; pthread_mutex_lock ( &mut_b_online ); b_ret = b_online; @@ -99,12 +70,6 @@ user::get_online( ) void user::set_online( bool b_online ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "user::set_online( bool )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - pthread_mutex_lock ( &mut_b_online ); this -> b_online = b_online; pthread_mutex_unlock( &mut_b_online ); @@ -113,12 +78,6 @@ user::set_online( bool b_online ) room* user::get_p_room( ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "user::get_p_room( )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - room* p_return; pthread_mutex_lock ( &mut_p_room ); p_return = p_room; @@ -129,25 +88,32 @@ user::get_p_room( ) void user::set_p_room( room* p_room ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "user::set_p_room( void* )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - pthread_mutex_lock ( &mut_p_room ); this -> p_room = p_room; pthread_mutex_unlock( &mut_p_room ); } +int +user::get_sock( ) +{ + int i_ret; + pthread_mutex_lock ( &mut_i_sock ); + i_ret = i_sock; + pthread_mutex_unlock( &mut_i_sock ); + return i_ret; +} + +void +user::set_sock( int i_sock ) +{ + pthread_mutex_lock ( &mut_i_sock ); + this -> i_sock = i_sock; + pthread_mutex_unlock( &mut_i_sock ); +} + void user::renew_stamp( ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "user::renew_stamp( )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif pthread_mutex_lock ( &mut_l_time ); l_time = TOOL::unixtime(); pthread_mutex_unlock( &mut_l_time ); @@ -156,12 +122,6 @@ user::renew_stamp( ) void user::msg_post( string *p_msg ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "user::msg_post_( string* )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - pthread_mutex_lock ( &mut_s_mess ); s_mess.append( *p_msg ); pthread_mutex_unlock( &mut_s_mess ); @@ -172,12 +132,6 @@ user::msg_post( string *p_msg ) void user::get_user_list( string &s_list, string &s_seperator ) { -#ifdef VERBOSE_ - pthread_mutex_lock ( &MUTX::get().mut_stdout ); - cout << "user::get_user_list( string &s_list, string &s_seperator )" << endl; - pthread_mutex_unlock( &MUTX::get().mut_stdout ); -#endif - s_list.append( "<font color=\"" ) .append( get_col1() ) .append( "\">" ) |
