diff options
| author | Paul Buetow <paul@buetow.org> | 2010-11-21 16:55:05 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2010-11-21 16:55:05 +0000 |
| commit | 5ca206ce46474fc47bfd966996df9fdbcb094a6c (patch) | |
| tree | 0da3a1d346d3a9f1aed8c3785699b138c0be1052 /src/chat | |
| parent | 7fa0ff180b35e7fef218f0b9113d7e0f3f9b54a8 (diff) | |
moving into ychat subdir
Diffstat (limited to 'src/chat')
| -rw-r--r-- | src/chat/base.h | 120 | ||||
| -rw-r--r-- | src/chat/base.tmpl | 89 | ||||
| -rw-r--r-- | src/chat/chat.cpp | 438 | ||||
| -rw-r--r-- | src/chat/chat.h | 94 | ||||
| -rw-r--r-- | src/chat/gcol.cpp | 146 | ||||
| -rw-r--r-- | src/chat/gcol.h | 62 | ||||
| -rw-r--r-- | src/chat/perm.cpp | 108 | ||||
| -rw-r--r-- | src/chat/perm.h | 67 | ||||
| -rw-r--r-- | src/chat/room.cpp | 133 | ||||
| -rw-r--r-- | src/chat/room.h | 116 | ||||
| -rw-r--r-- | src/chat/sess.cpp | 91 | ||||
| -rw-r--r-- | src/chat/sess.h | 56 | ||||
| -rw-r--r-- | src/chat/sman.cpp | 133 | ||||
| -rw-r--r-- | src/chat/sman.h | 60 | ||||
| -rw-r--r-- | src/chat/user.cpp | 650 | ||||
| -rw-r--r-- | src/chat/user.h | 166 |
16 files changed, 0 insertions, 2529 deletions
diff --git a/src/chat/base.h b/src/chat/base.h deleted file mode 100644 index bba37e0..0000000 --- a/src/chat/base.h +++ /dev/null @@ -1,120 +0,0 @@ -/*:* - *: File: ./src/chat/base.h - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ - -#include "../incl.h" - -#ifndef BASE_H -#define BASE_H - -#include <map> -#include "../maps/nhashmap.h" - -template<class type> -class base : public nhashmap<type*> -{ -protected: - void dumpit(); - -public: - base(); - ~base(); - - static string to_lower( string s ) - { - string s_tmp(""); - for (int i=0;i < s.size() ;i++) - s_tmp=s_tmp+(char)tolower(s.at(i)); - return s_tmp; - } - - virtual type* get_elem( string s_name, bool &b_found ); // get a element. - virtual type* get_elem( string s_name ); - virtual void add_elem( type* p_type ); // add a element. - - // chat::msg_post sends to all users of the system a message. - // room::msg_post sends to all users of the room a message. - // user::msg_post sends to the user a message. - virtual void msg_post( string *s_msg ) - { - nhashmap<type*>::run_func( &base<type>::msg_post_ , (void*)s_msg ); - } - - static void msg_post_( type* type_obj, void* v_arg ) - { - type_obj -> msg_post( (string*) v_arg ); - } - - virtual void check_timeout( int* i_timeout_settings ) - { - nhashmap<type*>::run_func( &base<type>::check_timeout_ , (void*)i_timeout_settings ); - } - - static void check_timeout_( type* type_obj, void* v_arg ) - { - type_obj -> check_timeout( (int*) v_arg ); - } - - virtual void reconf() - { - nhashmap<type*>::run_func( &base<type>::reconf_ ); - } - - static void reconf_ ( type* type_obj ) - { - type_obj -> reconf (); - } - - void get_data( map<string,string> *p_map_string ) - { - nhashmap<type*>::run_func( &base<type>::get_data_ , (void*)p_map_string ); - } - - static void get_data_( type* type_obj, void* v_arg ) - { - type_obj -> get_data ( (map<string,string>*) v_arg ); - } - - - // chat::get_user_list gets a list of all users of the system. - // room::get_user_list gets a list of all users of the room. - // user::get_user_list gets a "list" of a user <font color="usercolor">username</font>seperator - void get_user_list( string &s_list ) - { - container c; - c.elem[0] = (void*) &s_list; - - nhashmap<type*>::run_func( &base<type>::get_user_list_, (void*)&c ); - } - - static void get_user_list_( type* type_obj, void* v_arg ) - { - container *c = (container*) v_arg; - type_obj -> get_user_list( *((string*)c->elem[0]) ); - } -}; - -#include "base.tmpl" - -#endif diff --git a/src/chat/base.tmpl b/src/chat/base.tmpl deleted file mode 100644 index 9b1d682..0000000 --- a/src/chat/base.tmpl +++ /dev/null @@ -1,89 +0,0 @@ -/*:* - *: File: ./src/chat/base.tmpl - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ - -#ifndef BASE_CPP -#define BASE_CPP - -#include "base.h" - -template<class type> -base<type>::base() -{} - -template<class type> -base<type>::~base( ) -{} - -template<class type> -type* -base<type>::get_elem( string s_name, bool &b_found ) -{ - s_name = to_lower(s_name); - type* p_type = nhashmap<type*>::get_elem( s_name ); - b_found = p_type == NULL ? false : true; - return p_type; -} - -template<class type> -type* -base<type>::get_elem( string s_name) -{ - bool b; - return get_elem(s_name, b); -} - -template<class type> -void -base<type>::add_elem( type* p_type ) -{ - nhashmap<type*>::add_elem(p_type, p_type->get_lowercase_name()); -} - -template<class type> -void -base<type>::dumpit() -{ - dumpable::add - ("[base]"); - vector<string>* p_vec = nhashmap<type*>::get_key_vector(); - - vector<string>::iterator iter; - for (iter = p_vec->begin(); iter != p_vec->end(); ++iter) - { - dumpable::add - (*iter); - type* p_elem = get_elem(*iter); - if (p_elem) - { - dumpable::next_no_newline(); - dumpable::add - (p_elem->dump(dumpable::get_level())); - } - } - - delete p_vec; -} - -#endif diff --git a/src/chat/chat.cpp b/src/chat/chat.cpp deleted file mode 100644 index cea9ab6..0000000 --- a/src/chat/chat.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/*:* - *: File: ./src/chat/chat.cpp - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ - -// class chat implementation. - -#ifndef CHAT_CPP -#define CHAT_CPP - -#include "chat.h" -#include "../tool/tool.h" -#include "../maps/mtools.h" -#include <list> - -using namespace std; - -chat::chat( ) -{ - { - // Set up replace strings; - wrap::system_message(CHATREP); - vector<string>* p_vec_keys = wrap::CONF->get_key_vector(); - - for (vector<string>::iterator iter = p_vec_keys-> - begin(); - iter != p_vec_keys->end(); - iter++ ) - { - if ( iter->length() >= 24 && iter->compare( 0, 22, "chat.html.replace.from" ) == 0 ) - { - string s_from = wrap::CONF->get_elem(*iter); - map_replace_strings[s_from] = "chat.html.replace.into." + s_from; - vec_replace_keys.push_back(s_from); - } - } - - sort(vec_replace_keys.begin(), vec_replace_keys.end()); - delete p_vec_keys; - } -} - -chat::~chat( ) -{ - // Delete all room objects! - run_func( mtools<room*>::delete_obj ); -} - -user* -chat::get_user( string &s_user ) -{ - bool b_flag; - return get_user( s_user, b_flag ); -} - -user* -chat::get_user( string &s_user, bool &b_found ) -{ - container param; - - param.elem[0] = (void*) &s_user ; - param.elem[1] = (void*) &b_found; - - b_found = false; - - base<room>::run_func( get_user_, (void*)¶m ); - - if ( *( (bool*) param.elem[1] ) ) - return (user*) param.elem[2]; -} - -void -chat::get_user_( room *room_obj, void *v_arg ) -{ - container* param = (container*) v_arg; - - if ( *((bool*)param->elem[1]) ) - return; - - param->elem[2] = (void*)room_obj->get_elem( *((string*)param->elem[0]), *((bool*)param->elem[1]) ); -} - -void -chat::login( map<string,string> &map_params ) -{ - string s_user = map_params["nick"]; - - // prove if nick is empty: - if ( s_user.empty() ) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.nonick" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - wrap::system_message( LOGINE0 ); - return; - } - - // prove if the nick is alphanumeric: - else if ( ! tool::is_alpha_numeric( s_user ) ) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.alpnum" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - wrap::system_message( LOGINE1 + s_user ); - return; - } - - // prove if the nick is too long: - else if ( s_user.length() > tool::string2int( wrap::CONF->get_elem("chat.maxlength.username") ) ) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.nicklength" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - wrap::system_message( LOGINE2 + s_user ); - return; - } - - // prove if the room name is too long: - else if ( map_params["room"].length() > tool::string2int( wrap::CONF->get_elem("chat.maxlength.roomname") ) ) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.roomnamelength" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - wrap::system_message( LOGINE3 + s_user + " / " + map_params["room"] ); - return; - } - - // prove if the room name is valid - else if ( map_params["room"].length() < 1 ) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.noroom" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - wrap::system_message( LOGINE3 + s_user + " / " + map_params["room"] ); - return; - } - - // prove if nick is banned from chat - if (map_banned_nicks.exists(tool::to_lower(s_user))) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.banned" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); - return; - } - - bool b_flag; - - // prove if nick is already online / logged in. - get_user( s_user, b_flag ); - - if ( b_flag ) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.online" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); - return; - } - - // Prove if user is recycleable from the garbage collector: - user *p_user = wrap::GCOL->get_user_from_garbage( s_user ); - - if ( p_user != NULL ) - { - // 1. possibility to prove the password at login! (using recycled user) - if ( p_user->get_pass() != map_params["password"] ) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.wrongpassword" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - 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(); - p_sess->set_user(p_user); - map_params["tmpid"] = p_sess->get_tmpid(); - p_user->set_tmpid( map_params["tmpid"] ); - p_user->set_has_sess( true ); - } - } - else // if ( p_user == NULL ) // If not in garbage create a new user! - { - p_user = new user( s_user ); - - // prove if nick is registered, else create a guest chatter. -#ifdef DATABASE - - hashmap<string> map_results = wrap::DATA->select_user_data( tool::to_lower(s_user), "selectlogin"); - - if ( map_results["nick"] == tool::to_lower(s_user) ) - { - p_user->set_is_reg( true ); - // User exists in database, prove password: - // 2. possibility to prove the password at login! (using new created user from database) - if ( map_results["password"] != map_params["password"] ) - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.wrongpassword" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - wrap::system_message( LOGINER + s_user ); - return; - } - else - { - // If registered use saved options - map_params["registered"] = "yes"; - map_params["color1"] = map_results["color1"]; - map_params["color2"] = map_results["color2"]; - map_params["email"] = map_results["email"]; - map_params["status"] = map_results["status"]; - } - } - else -#endif - - { - // If not registered prove if guest chatting is enabled. - if (wrap::CONF->get_elem("chat.enableguest") != "true") - { - map_params["INFO"] = wrap::CONF->get_elem( "chat.msgs.err.noguest" ); - map_params["request"] = wrap::CONF->get_elem( "httpd.startsite" ); // redirect to the startpage. - wrap::system_message( LOGINE4 + s_user ); - return; - } - - // Guest chatter are enabled, use standard font colors - map_params["color1"] = wrap::CONF->get_elem( "chat.html.user.color1" ); - map_params["color2"] = wrap::CONF->get_elem( "chat.html.user.color2" ); - map_params["status"] = wrap::CONF->get_elem( "chat.defaultrang" ); - } - - sess* p_sess = wrap::SMAN->create_session(); - p_sess->set_user(p_user); - map_params["tmpid"] = p_sess->get_tmpid(); - p_user->set_tmpid( map_params["tmpid"] ); - p_user->set_col1( map_params["color1"] ); - p_user->set_col2( map_params["color2"] ); - p_user->set_status( tool::string2int(map_params["status"])); - } - - // Prove if user is the default operator. - if ( tool::to_lower(wrap::CONF->get_elem("chat.defaultop")) == tool::to_lower(s_user) ) - { - wrap::system_message(CHATDOP); - p_user->set_status(0); - } - - string s_room = map_params["room"]; - room* p_room = get_room( s_room , b_flag ); - - // if room does not exist add room to list! - if ( ! b_flag ) - { - p_room = wrap::GCOL->get_room_from_garbage(); - - if ( p_room ) - { - p_room->set_name( s_room ); - wrap::system_message( REUROOM + s_room ); - } - else - { - p_room = new room( s_room ); - wrap::system_message( NEWROOM + s_room ); - } - - add_elem( p_room ); - } - - // add user to the room. - p_room->add_user( p_user ); - - wrap::system_message( NEWUSER + s_user ); - - // post "username enters the chat" into the room. - string s_msg = wrap::TIMR->get_time() + " " + p_user->get_colored_bold_name() + wrap::CONF->get_elem( "chat.msgs.userenterschat" ) + "<br>\n"; - - // If created a new user from database while logging on (not a recycled user, they already have this set) - if ( map_params["registered"] == "yes" ) - { - p_user->set_email( map_params["email"] ); - p_user->set_pass( map_params["password"] ); - // Now we will store all wanted user data into MySQL after logging out! (recycled user already have this set) - p_user->set_changed_data_on(); - } - p_room->msg_post(&s_msg); -} - -void -chat::post( user* p_user, map<string,string> &map_params ) -{ - p_user->renew_timeout(); - - string s_msg( map_params["message"] ); - - if ( s_msg.empty() ) - return; - - int i_max_message_length = tool::string2int(wrap::CONF->get_elem( "chat.maxlength.message" )); - if ( s_msg.length() > i_max_message_length ) - { - s_msg = s_msg.substr( 0, i_max_message_length ); - string s_private = "<font color=\"" + wrap::CONF->get_elem( "chat.html.errorcolor" ) + "\">" - + wrap::CONF->get_elem( "chat.msgs.err.messagelength" ) + "</font><br>\n"; - p_user->msg_post( &s_private ); - } - - int i_max_word_length = tool::string2int(wrap::CONF->get_elem( "chat.maxlength.word" )); - - // Check max word length - list<string> list_msg = tool::split_string( s_msg, " "); - list<string>::iterator iter = list_msg.begin(); - - for ( s_msg = ""; iter != list_msg.end(); ++iter ) - { - if ( iter->length() > i_max_word_length ) - { - string s_tmp[] = { iter->substr(0, i_max_word_length ), iter->substr(i_max_word_length) }; - iter = list_msg.erase( iter ); - iter = list_msg.insert( iter, s_tmp[1] ); - iter = list_msg.insert( iter, s_tmp[0] ); - --iter; - } - else - { - s_msg.append(*iter + " "); - } - } - - if ( wrap::CONF->get_elem( "chat.html.tagsallow" ) != "true" ) - tool::strip_html( &s_msg ); - - unsigned i_pos = s_msg.find( "/" ); - if ( i_pos == 0 ) - return p_user->command( s_msg ); - - if (p_user->get_is_gag()) - { - p_user->msg_post(wrap::CONF->colored_error_msg("chat.msgs.err.gagged")); - return; - } - - - string_replacer(&s_msg); - string s_post; - - if ( wrap::CONF->get_elem( "chat.printalwaystime" ) == "true" ) - s_post.append( wrap::TIMR->get_time() + " " ); - - s_post.append( "<font color=\"#" ) - .append( p_user->get_col1() ) - .append( "\">" ) - .append( p_user->get_name() ) - .append( ":</font> <font color=\"#") - .append( p_user->get_col2() ) - .append( "\">" ) - .append( s_msg ) - .append( "</font><br>\n" ); - - p_user->get_room()->msg_post( &s_post ); -} - -void -chat::reconf() -{} - -void -chat::string_replacer(string *p_msg) -{ - if ( wrap::CONF->get_elem( "chat.html.replace.activate" ) == "true" ) - { - for (vector<string>::iterator iter = vec_replace_keys.end()-1; - iter != vec_replace_keys.begin(); - iter-- ) - *p_msg = tool::replace( *p_msg, *iter, wrap::CONF->get_elem(map_replace_strings[*iter]) ); - } -} - -void -chat::dumpit() -{ - dumpable::add - ("[chat]"); - base<room>::dumpit(); -} - -string -chat::ban_nick(string &s_nick, string s_reason) -{ - string s_lower_nick(tool::to_lower(s_nick)); - - if (map_banned_nicks.exists(s_lower_nick)) - return map_banned_nicks.get_elem(s_lower_nick); - - map_banned_nicks.add_elem(s_reason, s_lower_nick); - return ""; -} - -string -chat::unban_nick(string &s_nick) -{ - string s_lower_nick(tool::to_lower(s_nick)); - - if (!map_banned_nicks.exists(s_lower_nick)) - return ""; - - string s_ret(map_banned_nicks.get_elem(s_lower_nick)); - map_banned_nicks.del_elem(s_lower_nick); - - return s_ret; -} - -shashmap<string>* -chat::get_map_banned_nicks() -{ - return &map_banned_nicks; -} - -#endif diff --git a/src/chat/chat.h b/src/chat/chat.h deleted file mode 100644 index edc5270..0000000 --- a/src/chat/chat.h +++ /dev/null @@ -1,94 +0,0 @@ -/*:* - *: File: ./src/chat/chat.h - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ - -// class chat declaration. - -class chat; - -#ifndef CHAT_H -#define CHAT_H - -#include <vector> -#include "../incl.h" -#include "base.h" -#include "perm.h" -#include "room.h" -#include "user.h" -#include "sess.h" -#include "../tool/tool.h" -#include "../maps/shashmap.h" - -using namespace std; - -#undef chat -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: - virtual room* get_room( string s_name ) - { - bool b_bool; - return get_room( s_name, b_bool ); - } - - virtual room* get_room( string &s_name, bool &b_found ) - { - 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. - - // get the object of a specific user. - user* get_user( string &s_nick ); - user* get_user( string &s_nick, bool &b_found ); - static void get_user_( room* room_obj, void *v_arg ); - - // will be called every time a user tries to login. - void login( map<string,string> &map_params ); - - // will be called if a user posts a message. - void post ( user* u_user, map<string,string> &map_params ); - - 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 deleted file mode 100644 index dddb01d..0000000 --- a/src/chat/gcol.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/*:* - *: File: ./src/chat/gcol.cpp - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ - -#ifndef GCOL_CPP -#define GCOL_CPP - -#include "gcol.h" - -using namespace std; - -gcol::gcol() -{ - - p_map_users = new shashmap<user*>; - wrap::system_message( GARBAGE ); -} - -gcol::~gcol() -{ - remove_garbage(); - delete p_map_users; -} - -void -gcol::add_room_to_garbage( room* p_room ) -{ - vec_rooms.push_back( p_room ); - wrap::system_message( GARROOM + p_room->get_name() ); -} - -void -gcol::add_user_to_garbage( user* p_user ) -{ - p_user->destroy_session(); - p_map_users->add_elem(p_user, tool::to_lower(p_user->get_name())); - wrap::system_message(GARUSER + p_user->get_name()); -} - -bool -gcol::remove_garbage() -{ - bool b_empty; - - b_empty = ( vec_rooms.empty() && p_map_users->size() == 0); - - if ( b_empty ) - return false; - - wrap::system_message( GARBACT ); - - for ( vector<room*>::iterator iter = vec_rooms.begin(); - iter != vec_rooms.end(); iter++ ) - { - wrap::system_message( REMROOM + (*iter)->get_name() ); - delete *iter; - } - vec_rooms.clear(); - - - p_map_users->run_func( delete_users_ ); - p_map_users->clear(); - - return true; -} - -room* -gcol::get_room_from_garbage() -{ - - if ( vec_rooms.empty() ) - return NULL; - - room* p_room = vec_rooms.back(); - vec_rooms.pop_back(); - - return p_room; -} - -room* -gcol::get_room_from_garbage_or_new( string s_room ) -{ - room* p_room = get_room_from_garbage(); - if ( p_room == NULL ) - return new room( s_room ); - p_room->set_name( s_room ); - return p_room; -} - -user* -gcol::get_user_from_garbage( string s_user ) -{ - user* p_user = p_map_users->get_elem(tool::to_lower(s_user)); - - if ( p_user != NULL ) - { - p_map_users->del_elem(tool::to_lower(s_user)); - p_user->set_name(s_user); - p_user->set_online(true); - p_user->set_invisible(false); - p_user->set_sock(NULL); - p_user->renew_timeout(); - wrap::system_message(GARUSE2 + p_user->get_name()); - } - - return p_user; -} - -void -gcol::delete_users_( user *user_obj ) -{ - wrap::system_message( REMUSER + user_obj->get_name() ); - user_obj->clean(); - delete user_obj; -} - -void -gcol::lock_mutex() -{} - -void -gcol::unlock_mutex() -{} - -#endif diff --git a/src/chat/gcol.h b/src/chat/gcol.h deleted file mode 100644 index 710fc5f..0000000 --- a/src/chat/gcol.h +++ /dev/null @@ -1,62 +0,0 @@ -/*:* - *: File: ./src/chat/gcol.h - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ - -// garbage collector -#include "../incl.h" - -#ifndef GCOL_H -#define GCOL_H - -#include <vector> -#include "room.h" -#include "user.h" -#include "../maps/shashmap.h" - -using namespace std; - -class gcol -{ -private: - vector<room*> vec_rooms; - shashmap<user*>* p_map_users; - - - static void delete_users_( user* user_obj ); - -public: - gcol(); - ~gcol(); - - bool remove_garbage(); - void add_room_to_garbage( room* p_room ); - void add_user_to_garbage( user* p_user ); - virtual room* get_room_from_garbage(); - virtual room* get_room_from_garbage_or_new( string s_room ); - user* get_user_from_garbage( string s_user ); - virtual void lock_mutex(); - virtual void unlock_mutex(); -}; - -#endif diff --git a/src/chat/perm.cpp b/src/chat/perm.cpp deleted file mode 100644 index 8adb83f..0000000 --- a/src/chat/perm.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/*:* - *: File: ./src/chat/perm.cpp - *: - *: yChat; Homepage: ychat.buetow.org; Version 0.9.0-CURRENT - *: - *: Copyright (C) 2003 Paul C. Buetow, Volker Richter - *: Copyright (C) 2004 Paul C. Buetow - *: Copyright (C) 2005 EXA Digital Solutions GbR - *: Copyright (C) 2006, 2007 Paul C. Buetow - *: - *: This program is free software; you can redistribute it and/or - *: modify it under the terms of the GNU General Public License - *: as published by the Free Software Foundation; either version 2 - *: of the License, or (at your option) any later version. - *: - *: This program is distributed in the hope that it will be useful, - *: but WITHOUT ANY WARRANTY; without even the implied warranty of - *: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - *: GNU General Public License for more details. - *: - *: You should have received a copy of the GNU General Public License - *: along with this program; if not, write to the Free Software - *: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *:*/ - -#ifndef PERM_CPP -#define PERM_CPP - -#include "perm.h" -#include "../maps/mtools.h" - -using namespace std; - -perm::perm() -{ - p_command_status = new shashmap< valwrap<int>* >; - p_command_disabled = new shashmap< valwrap<bool>* >; - - set_standard_command_permissions(); |
