summaryrefslogtreecommitdiff
path: root/src/chat
diff options
context:
space:
mode:
Diffstat (limited to 'src/chat')
-rw-r--r--src/chat/base.tmpl4
-rw-r--r--src/chat/chat.cpp4
-rw-r--r--src/chat/chat.h18
-rw-r--r--src/chat/gcol.cpp9
-rw-r--r--src/chat/gcol.h5
-rw-r--r--src/chat/room.h4
-rw-r--r--src/chat/sess.cpp14
-rw-r--r--src/chat/sess.h2
-rw-r--r--src/chat/sman.cpp25
-rw-r--r--src/chat/sman.h6
-rw-r--r--src/chat/user.cpp24
-rw-r--r--src/chat/user.h15
12 files changed, 68 insertions, 62 deletions
diff --git a/src/chat/base.tmpl b/src/chat/base.tmpl
index a8db1a0..87c3a0b 100644
--- a/src/chat/base.tmpl
+++ b/src/chat/base.tmpl
@@ -50,7 +50,7 @@ type*
base<type>::get_elem( string s_name)
{
bool b;
- return get_elem(s_name, b);
+ return get_elem(s_name, b);
}
template<class type>
@@ -80,7 +80,7 @@ base<type>::dumpit()
dumpable::add
(p_elem->dump(dumpable::get_level()));
}
- }
+ }
delete p_vec;
}
diff --git a/src/chat/chat.cpp b/src/chat/chat.cpp
index 066bfbc..a56c74d 100644
--- a/src/chat/chat.cpp
+++ b/src/chat/chat.cpp
@@ -171,6 +171,7 @@ chat::login( map<string,string> &map_params )
{
map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.online" );
map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" );
+
return;
}
@@ -187,12 +188,10 @@ chat::login( map<string,string> &map_params )
wrap::system_message( LOGINER + s_user );
return;
}
-
if ( p_user->get_has_sess() )
{
map_params["tmpid"] = p_user->get_tmpid();
}
-
else
{
sess* p_sess = wrap::SMAN->create_session();
@@ -257,6 +256,7 @@ chat::login( map<string,string> &map_params )
p_user->set_col1( map_params["color1"] );
p_user->set_col2( map_params["color2"] );
p_user->set_status( tool::string2int(map_params["status"]));
+ // p_user->set_sess( p_sess );
}
// Prove if user is the default operator.
diff --git a/src/chat/chat.h b/src/chat/chat.h
index 9da40e7..1758790 100644
--- a/src/chat/chat.h
+++ b/src/chat/chat.h
@@ -37,7 +37,7 @@ class chat;
#include "user.h"
#include "sess.h"
#include "../tool/tool.h"
-#include "../maps/shashmap.h"
+#include "../maps/hashmap.h"
using namespace std;
@@ -47,9 +47,6 @@ class chat : public base<room>, public perm
private:
map<string,string> map_replace_strings;
vector<string> vec_replace_keys;
- shashmap<string> map_banned_nicks;
- shashmap<string, unsigned, self_hash<unsigned>, equals_allocator<unsigned> > map_banned_ips;
-
void dumpit();
public:
@@ -64,11 +61,6 @@ public:
return static_cast<room*>( get_elem( s_name, b_found ) );
}
- void del_elem( string s_name )
- {
- base<room>::del_elem( s_name );
- }
-
// public methods:
explicit chat(); // a standard constructor.
~chat(); // destructor.
@@ -84,10 +76,12 @@ public:
// will be called if a user posts a message.
void post ( user* u_user, map<string,string> &map_params );
+ void del_elem( string s_name )
+ {
+ base<room>::del_elem( s_name );
+ }
+
void reconf();
void string_replacer(string *p_msg);
- string ban_nick(string &s_nick, string s_reason);
- string unban_nick(string &s_nick);
- shashmap<string>* get_map_banned_nicks();
};
#endif
diff --git a/src/chat/gcol.cpp b/src/chat/gcol.cpp
index ffdb8e5..b7f1288 100644
--- a/src/chat/gcol.cpp
+++ b/src/chat/gcol.cpp
@@ -52,6 +52,10 @@ gcol::add_room_to_garbage( room* p_room )
vec_rooms.push_back( p_room );
pthread_mutex_unlock( &mut_vec_rooms );
wrap::system_message( GARROOM + p_room->get_name() );
+#ifdef NCURSES
+
+ print_garbage();
+#endif
}
void
@@ -92,6 +96,11 @@ gcol::remove_garbage()
p_map_users->run_func( delete_users_ );
p_map_users->clear();
+#ifdef NCURSES
+
+ print_garbage();
+#endif
+
return true;
}
diff --git a/src/chat/gcol.h b/src/chat/gcol.h
index bce0db0..a564d22 100644
--- a/src/chat/gcol.h
+++ b/src/chat/gcol.h
@@ -45,6 +45,11 @@ private:
static void delete_users_( user* user_obj );
+#ifdef NCURSES
+
+ void print_garbage( );
+#endif
+
public:
gcol();
~gcol();
diff --git a/src/chat/room.h b/src/chat/room.h
index 0988fd4..6de217a 100644
--- a/src/chat/room.h
+++ b/src/chat/room.h
@@ -47,7 +47,7 @@ private:
logd* p_logd;
#endif
-
+
void dumpit();
public:
@@ -95,7 +95,7 @@ public:
void javascript_post( string s_msg )
{
- string s_js = "<script language=\"JavaScript\">"+s_msg+"</script>\n";
+ string s_js = "<script language=\"JavaScript\">"+s_msg+"</script>\n";
base<user>::msg_post( &s_js );
}
diff --git a/src/chat/sess.cpp b/src/chat/sess.cpp
index 846876d..2007cb1 100644
--- a/src/chat/sess.cpp
+++ b/src/chat/sess.cpp
@@ -42,12 +42,6 @@ sess::get_tmpid()
return s_tmpid;
}
-void
-sess::set_tmpid(string s_tmpid)
-{
- this->s_tmpid = s_tmpid;
-}
-
string
sess::get_name()
{
@@ -74,17 +68,13 @@ void
sess::set_user(user* p_user)
{
this->p_user = p_user;
- //p_user->set_sess(this);
}
-/*
+
void
sess::invalidate()
{
- set_user(NULL);
- set_tmpid("!invalidated");
- wrap::system_message(SESSIOI);
+ this->s_tmpid = "0";
}
-*/
#endif
diff --git a/src/chat/sess.h b/src/chat/sess.h
index db4ad11..e6d9b8c 100644
--- a/src/chat/sess.h
+++ b/src/chat/sess.h
@@ -45,7 +45,7 @@ public:
~sess();
string get_tmpid();
- void set_tmpid(string s_tmpid);
+
void set_user(user* p_user);
user* get_user();
void set_name(string s_name);
diff --git a/src/chat/sman.cpp b/src/chat/sman.cpp
index 187531d..53a15f7 100644
--- a/src/chat/sman.cpp
+++ b/src/chat/sman.cpp
@@ -68,7 +68,7 @@ string sman::generate_id( int i_len )
// Prove, if the TempID already exists
sess* p_sess = get_elem(s_ret);
- if (p_sess)
+ if (p_sess)
{
wrap::system_message(SESSEXI);
return generate_id(i_len);
@@ -109,6 +109,7 @@ sman::destroy_session( string s_id )
pthread_mutex_lock( &mut_i_session_count );
i_session_count--;
+#ifdef NCURSES
wrap::system_message(string(SESSIOD) + "(" +
tool::int2string(i_continous_session_count) + "," +
@@ -116,10 +117,30 @@ sman::destroy_session( string s_id )
pthread_mutex_unlock( &mut_i_session_count );
- del_elem(s_id);
+ sess* p_sess = get_elem( s_id );
+ del_elem( s_id );
delete p_sess;
}
+#ifdef NCURSES
+void sman::print_sessions()
+{
+ if ( wrap::NCUR->is_ready() )
+ {
+ mvprintw( NCUR_SESSION_X,NCUR_SESSION_Y, "Sessions: %d ", i_session_count);
+ refresh();
+ }
+}
+
+#ifdef NCURSES
+void sman::print_init_ncurses()
+{
+ pthread_mutex_lock( &mut_i_session_count );
+ print_sessions();
+ pthread_mutex_unlock( &mut_i_session_count );
+}
+#endif
+
int
sman::get_session_count()
{
diff --git a/src/chat/sman.h b/src/chat/sman.h
index 4526ade..d97a12d 100644
--- a/src/chat/sman.h
+++ b/src/chat/sman.h
@@ -40,7 +40,6 @@ class sman : public shashmap<sess*>
private:
string generate_id( int i_len );
int i_session_count;
- int i_continous_session_count;
pthread_mutex_t mut_i_session_count;
@@ -51,8 +50,11 @@ public:
int get_session_count( );
sess *create_session( );
void destroy_session( string s_tmpid );
+#ifdef NCURSES
+
+ void print_init_ncurses();
+#endif
- //virtual void dump();
};
diff --git a/src/chat/user.cpp b/src/chat/user.cpp
index 93dd672..b7816ab 100644
--- a/src/chat/user.cpp
+++ b/src/chat/user.cpp
@@ -73,7 +73,6 @@ user::initialize()
this -> p_room = NULL;
this -> b_is_reg = false;
- this -> b_is_gag = false;
this -> b_set_changed_data = false;
this -> b_away = false;
this -> b_fake = false;
@@ -127,7 +126,6 @@ user::destroy_session()
set_has_sess(false);
wrap::SMAN->destroy_session(get_tmpid());
- //wrap::system_message(tool::int2string(reinterpret_cast<int>(*p_sess)));
set_tmpid("");
}
@@ -314,14 +312,6 @@ user::set_p_room( room* p_room )
pthread_mutex_unlock( &mut_p_room );
}
-/*
-void
-user::set_sess( sess** p_sess )
-{
- this -> p_sess = p_sess;
-}
-*/
-
string
user::get_pass()
{
@@ -535,7 +525,7 @@ user::s_mess_delete( )
void
-user::msg_post( string *p_msg )
+user::s_mess_delete( )
{
pthread_mutex_lock ( &mut_s_mess );
s_mess.append( *p_msg );
@@ -550,6 +540,7 @@ user::post_action_msg(string s_msgkey)
get_room()->msg_post(wrap::TIMR->get_time()+" "+get_colored_bold_name()+wrap::CONF->get_elem(s_msgkey)+"<br>\n");
}
+
void
user::renew_timeout()
{
@@ -587,10 +578,11 @@ user::renew_timeout()
void
user::check_timeout( int* i_idle_timeout )
{
- double d_user_timeout = get_last_activity();
- if ( get_away() ? i_idle_timeout[1] <= d_user_timeout : i_idle_timeout[0] <= d_user_timeout )
+ int i_user_timeout = (int) get_last_activity();
+
+ if ( get_away() ? i_idle_timeout[1] <= i_user_timeout : i_idle_timeout[0] <= i_user_timeout )
{
- wrap::system_message( string(TIMERTO) + "(" + get_name() + "," + tool::int2string((int)d_user_timeout) + ")");
+ wrap::system_message( string(TIMERTO) + "(" + get_name() + "," + tool::int2string(i_user_timeout) + ")");
string s_quit = "<script language=JavaScript>top.location.href='/"
+ wrap::CONF->get_elem("httpd.startsite")
+ "';</script>";
@@ -599,9 +591,9 @@ user::check_timeout( int* i_idle_timeout )
pthread_cond_signal( &cond_message );
}
- else if ( ! get_away() && i_idle_timeout[2] <= d_user_timeout )
+ else if ( ! get_away() && i_idle_timeout[2] <= i_user_timeout )
{
- wrap::system_message( string(TIMERAT) + "(" + get_name() + "," + tool::int2string((int)d_user_timeout) + ")");
+ wrap::system_message( string(TIMERAT) + "(" + get_name() + "," + tool::int2string(i_user_timeout) + ")");
string s_msg = wrap::CONF->get_elem("chat.msgs.userautoawaytimeout");
set_away( true, s_msg );
string s_msg2 = wrap::TIMR->get_time() + " <b>" + get_colored_name()+ "</b>" + s_msg + "<br>\n";
diff --git a/src/chat/user.h b/src/chat/user.h
index cde0729..b88a820 100644
--- a/src/chat/user.h
+++ b/src/chat/user.h
@@ -29,19 +29,13 @@
#include "../name.h"
#include "../time/timo.h"
-#include "../memb/memb.h"
#include "../monitor/dump.h"
-using namespace std;
-
class room;
-//class sess;
-class user :
- public name,
- public timo,
- public dumpable,
- public memb_base
+using namespace std;
+
+class user : public name, public timo, public dumpable
{
private:
@@ -68,6 +62,7 @@ private:
string s_col1; // user's nick color.
string s_col2; // user's text color.
string s_email; // user's email addres
+ string s_mess; // message string which has to be sent to the user.
string s_pass; // password
room* p_room; // pointer to the user's room.
// sess** p_sess; // pointer to the pointer to the session object
@@ -174,8 +169,6 @@ public:
void get_user_list( string &s_list );
void check_restore_away();
void reconf();
- bool same_rooms(user *p_user);
- string make_colors(string s_msg);
};
#endif