diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:45 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:45 +0200 |
| commit | 23c5e7d57e1e9216f4da3446656df2dc7202975d (patch) | |
| tree | b387afc4ad6acad4681252df8ce8def5dc8aa54d /user.cpp | |
| parent | 9dcec1feba68dc5ba38cdc634f5bf113c0f77348 (diff) | |
tagging ychat-0.1ychat-0.1
Diffstat (limited to 'user.cpp')
| -rw-r--r--[-rwxr-xr-x] | user.cpp | 108 |
1 files changed, 74 insertions, 34 deletions
@@ -4,30 +4,41 @@ #define USER_CXX #include "user.h" -#include "s_conf.h" -#include "s_tool.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 = s_tool::unixtime(); - this -> s_col1 = s_conf::get().get_val( "USERCOL1" ); + 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 ); @@ -38,6 +49,12 @@ 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. @@ -48,6 +65,12 @@ 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 ); @@ -60,6 +83,12 @@ 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; @@ -70,6 +99,12 @@ 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 ); @@ -78,6 +113,12 @@ 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; @@ -88,46 +129,39 @@ 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::command( string &s_command ) -{ - msg_post( new string( ERRORCMD ) ); -} - 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 = s_tool::unixtime(); + l_time = TOOL::unixtime(); pthread_mutex_unlock( &mut_l_time ); } 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 ); @@ -138,6 +172,12 @@ 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( "\">" ) |
