diff options
| author | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:41 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2013-04-06 13:14:41 +0200 |
| commit | 520f54d6219b7c625b4e07463ac393e6982ddab6 (patch) | |
| tree | 74b4483786b3842b1a0384fd33deb7483276bea1 /src/time | |
| parent | ae4e87df37ed8904de92c7cf2f3a11128cda2a21 (diff) | |
tagging ychat-0.7.1ychat-0.7.1
Diffstat (limited to 'src/time')
| -rwxr-xr-x | src/time/timo.cpp | 4 | ||||
| -rwxr-xr-x | src/time/timr.cpp | 31 | ||||
| -rwxr-xr-x | src/time/timr.h | 8 |
3 files changed, 17 insertions, 26 deletions
diff --git a/src/time/timo.cpp b/src/time/timo.cpp index d00bafe..c44ebae 100755 --- a/src/time/timo.cpp +++ b/src/time/timo.cpp @@ -9,7 +9,6 @@ timo::timo() { pthread_mutex_init( &mut_t_time, NULL ); } - timo::~timo() { pthread_mutex_destroy( &mut_t_time ); @@ -19,11 +18,9 @@ double timo::get_last_activity( ) { double d_ret; - pthread_mutex_lock ( &mut_t_time ); d_ret = wrap::TIMR->get_time_diff( t_time ); pthread_mutex_unlock( &mut_t_time ); - return d_ret; } @@ -35,4 +32,5 @@ timo::renew_timeout( ) pthread_mutex_unlock( &mut_t_time ); } + #endif diff --git a/src/time/timr.cpp b/src/time/timr.cpp index 40240c3..fa308d3 100755 --- a/src/time/timr.cpp +++ b/src/time/timr.cpp @@ -10,14 +10,11 @@ timr::timr() { wrap::system_message( TIMERIN ); b_timer_active = true; - pthread_mutex_init( &mut_s_time, NULL); pthread_mutex_init( &mut_s_uptime, NULL); pthread_mutex_init( &mut_i_offset, NULL); - i_time_offset = tool::string2int( wrap::CONF->get_elem("chat.timeoffset") ); wrap::system_message( TIMEROF + tool::int2string( i_time_offset ) ); - s_time = "00:00:00"; s_uptime = "00:00:00"; } @@ -45,8 +42,10 @@ timr::get_offset() } void -timr::start( void *v_ptr ) +timr::start( void *v_pointer ) { +// timr* p_timer = this; //static_cast<timr*>(this); + wrap::system_message( TIMERTH ); #ifdef NCURSES @@ -59,7 +58,6 @@ timr::start( void *v_ptr ) time( &clock_start ); tm time_start = *localtime( &clock_start ); tm time_now; - while ( get_timer_active() ) { // sleep a second! @@ -73,12 +71,10 @@ timr::start( void *v_ptr ) // set the current time && the current ychat uptime! set_time( difftime( clock_now, clock_start ), time_now.tm_sec, time_now.tm_min, time_now.tm_hour ); - #ifdef NCURSES if (wrap::NCUR->is_ready()) print_time( ); #endif - // run every minute: if ( time_now.tm_sec == 0 ) { @@ -86,12 +82,12 @@ timr::start( void *v_ptr ) cout << TIMERUP << get_uptime() << endl; #endif //<<* - int* p_timeout_settings = new int[3]; - p_timeout_settings[0] = tool::string2int(wrap::CONF->get_elem("chat.idle.timeout")); - p_timeout_settings[1] = tool::string2int(wrap::CONF->get_elem("chat.idle.awaytimeout")); - p_timeout_settings[2] = tool::string2int(wrap::CONF->get_elem("chat.idle.autoawaytimeout")); - wrap::CHAT->check_timeout( p_timeout_settings ); - delete p_timeout_settings; + int* i_timeout_settings = new int[3]; + i_timeout_settings[0] = tool::string2int(wrap::CONF->get_elem("chat.idle.timeout")); + i_timeout_settings[1] = tool::string2int(wrap::CONF->get_elem("chat.idle.awaytimeout")); + i_timeout_settings[2] = tool::string2int(wrap::CONF->get_elem("chat.idle.autoawaytimeout")); + wrap::CHAT->check_timeout( i_timeout_settings ); + delete i_timeout_settings; string s_ping = "<!-- PING! //-->\n"; wrap::CHAT->msg_post( &s_ping ); @@ -139,7 +135,6 @@ timr::set_time( double d_uptime, int i_cur_seconds, int i_cur_minutes, int i_cur int i_hours = (int) d_uptime / 3600; int i_minutes = (int) d_uptime / 60; - while ( i_minutes >= 60 ) i_minutes -= 60; @@ -148,8 +143,7 @@ timr::set_time( double d_uptime, int i_cur_seconds, int i_cur_minutes, int i_cur // Calculate offset time i_cur_hours += get_offset(); - - for ( int i = 24-i_cur_hours; i < 0; i = 24-i_cur_hours ) + for (int i = 24 - i_cur_hours; i < 0; i = 24 - i_cur_hours) i_cur_hours =- i; if (i_cur_hours == 24) @@ -181,11 +175,10 @@ timr::add_zero_to_front( string s_time ) } double -timr::get_time_diff( time_t &clock_diff ) +timr::get_time_diff( time_t& clock_diff ) { time_t clock_now; time( &clock_now ); - - return difftime(clock_now, clock_diff); + return difftime( clock_now, clock_diff ); } #endif diff --git a/src/time/timr.h b/src/time/timr.h index 46234b3..a327d5b 100755 --- a/src/time/timr.h +++ b/src/time/timr.h @@ -26,10 +26,10 @@ public: ~timr(); bool get_timer_active() const; - void start( void *v_ptr ); + void start( void *v_pointer ); #ifdef NCURSES - void print_time(); + void print_time( ); #endif void set_time( double d_uptime, int i_cur_seconds, int i_cur_minutes, int i_cur_hours ); @@ -56,8 +56,8 @@ public: return s_ret; } - int get_offset(); - double get_time_diff( time_t &clock_diff ); + virtual int get_offset(); + virtual double get_time_diff( time_t& clock_diff ); }; #endif |
