summaryrefslogtreecommitdiff
path: root/chat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chat.cpp')
-rw-r--r--[-rwxr-xr-x]chat.cpp95
1 files changed, 50 insertions, 45 deletions
diff --git a/chat.cpp b/chat.cpp
index 2d6e681..301739e 100755..100644
--- a/chat.cpp
+++ b/chat.cpp
@@ -1,26 +1,27 @@
// class chat implementation.
-#ifndef s_chat_CXX
-#define s_chat_CXX
+#ifndef CHAT_CXX
+#define CHAT_CXX
#include "chat.h"
-#include "s_conf.h"
-#include "s_mutx.h"
-#include "s_tool.h"
+#include "CONF.h"
+#include "MUTX.h"
using namespace std;
chat::chat( )
{
- if ( s_conf::get().get_val( "HTML" ) == "OFF" )
- b_strip_html = true;
- else
- b_strip_html = false;
+#ifdef VERBOSE
+ cout << "chat::chat()" << endl;
+#endif
}
chat::~chat( )
{
+#ifdef VERBOSE
+ cout << "chat::~chat()" << endl;
+#endif
}
user*
@@ -33,6 +34,12 @@ chat::get_user( string &s_user )
user*
chat::get_user( string &s_user, bool &b_found )
{
+#ifdef VERBOSE_
+ pthread_mutex_lock ( &MUTX::get().mut_stdout );
+ cout << "chat::get_user( " << s_user << ", bool& )" << endl;
+ pthread_mutex_unlock( &MUTX::get().mut_stdout );
+#endif
+
container param;
param.elem[0] = (void*) &s_user ;
@@ -49,6 +56,11 @@ chat::get_user( string &s_user, bool &b_found )
void
chat::get_user_( name *name_obj, void *v_arg )
{
+#ifdef VERBOSE_
+ pthread_mutex_lock ( &MUTX::get().mut_stdout );
+ cout << "chat::get_user_( name *name_obj, void *v_arg )" << endl;
+ pthread_mutex_unlock( &MUTX::get().mut_stdout );
+#endif
container* param = (container*) v_arg;
room *room_obj = static_cast<room*>(name_obj);
param->elem[2] = (void*)room_obj->get_elem( *((string*)param->elem[0]), *((bool*)param->elem[1]) );
@@ -57,21 +69,19 @@ chat::get_user_( name *name_obj, void *v_arg )
void
chat::login( map_string &map_params )
{
+#ifdef VERBOSE_
+ pthread_mutex_lock ( &MUTX::get().mut_stdout );
+ cout << "chat::login( map_params )" << endl;
+ pthread_mutex_unlock( &MUTX::get().mut_stdout );
+#endif
+
string s_user = map_params["nick"];
- // prove if nick is empty:
+ // prove if nick is empty
if ( s_user.empty() )
{
map_params["INFO"] = E_NONICK;
- map_params["request"] = s_conf::get().get_val( "STARTMPL" ); // redirect to the startpage.
- return;
- }
-
- // prove if the nick ist alphanumeric:
- else if ( ! s_tool::is_alpha_numeric( s_user ) )
- {
- map_params["INFO"] = E_ALPNUM;
- map_params["request"] = s_conf::get().get_val( "STARTMPL" ); // redirect to the startpage.
+ map_params["request"] = CONF::get().get_val( "STARTMPL" ); // redirect to the startpage.
return;
}
@@ -82,7 +92,7 @@ chat::login( map_string &map_params )
if ( b_flag )
{
map_params["INFO"] = E_ONLINE;
- map_params["request"] = s_conf::get().get_val( "STARTMPL" );
+ map_params["request"] = CONF::get().get_val( "STARTMPL" );
return;
}
@@ -94,10 +104,10 @@ chat::login( map_string &map_params )
{
p_room = new room( s_room );
-#ifdef VERBOSE
- pthread_mutex_lock ( &s_mutx::get().mut_stdout );
+#ifdef _VERBOSE
+ pthread_mutex_lock ( &MUTX::get().mut_stdout );
cout << NEWROOM << s_room << endl;
- pthread_mutex_unlock( &s_mutx::get().mut_stdout );
+ pthread_mutex_unlock( &MUTX::get().mut_stdout );
#endif
add_elem( p_room );
@@ -111,36 +121,31 @@ chat::login( map_string &map_params )
// post "username enters the chat" into the room.
p_room->msg_post( new string( s_user.append( USERENTR ) ) );
-#ifdef VERBOSE
- pthread_mutex_lock ( &s_mutx::get().mut_stdout );
+#ifdef _VERBOSE
+ pthread_mutex_lock ( &MUTX::get().mut_stdout );
cout << LOGINPR << s_user << endl;
- pthread_mutex_unlock( &s_mutx::get().mut_stdout );
+ pthread_mutex_unlock( &MUTX::get().mut_stdout );
#endif
}
void
-chat::post( user* p_user, map_string &map_params )
+chat::post( user* u_user, map_string &map_params )
{
+#ifdef VERBOSE_
+ pthread_mutex_lock ( &MUTX::get().mut_stdout );
+ cout << "chat::post( user* u_user, map_string &map_params )" << endl;
+ pthread_mutex_unlock( &MUTX::get().mut_stdout );
+#endif
- string s_msg( map_params["message"] );
-
- auto unsigned i_pos = s_msg.find( "/" );
- if ( i_pos == 0 )
- return p_user->command( s_msg );
-
- if ( b_strip_html )
- s_tool::strip_html( &s_msg );
-
- string s_post( "<font color=\"" );
-
- s_post.append( p_user->get_col1() )
- .append( "\">" )
- .append( p_user->get_name() )
- .append( ": " )
- .append( s_msg )
- .append( "</font><br>\n" );
+ string s_msg( "<font color=\"" );
+ s_msg.append( u_user->get_col1() )
+ .append( "\">" )
+ .append( u_user->get_name() )
+ .append( ": " )
+ .append( map_params["message"] )
+ .append( "</font><br>\n" );
- p_user->get_p_room()->msg_post( &s_post );
+ u_user->get_p_room()->msg_post( &s_msg );
}
#endif