[SithNet-Patches] [CVS] Module gnuworld-sithnet: Change committed
Brought to you by:
darthsidious_
From: Tim I. <dar...@us...> - 2003-10-25 07:32:33
|
Committer : Tim Ireland <dar...@us...> CVSROOT : /cvsroot/sithnet-dev Module : gnuworld-sithnet Commit time: 2003-10-24 17:31:56 UTC Modified files: mod.cservice/cservice.h mod.cservice/levels.h mod.cservice/cservice.cc mod.cservice/sqlChannel.cc mod.cservice/sqlChannel.h Log message: Started work on a 'STRICTVOICE' option. this is incomplete and not tested. also made several misc updates ---------------------- diff included ---------------------- Index: gnuworld-sithnet/mod.cservice/cservice.cc diff -u gnuworld-sithnet/mod.cservice/cservice.cc:1.1.1.1 gnuworld-sithnet/mod.cservice/cservice.cc:1.2 --- gnuworld-sithnet/mod.cservice/cservice.cc:1.1.1.1 Sun Oct 19 10:45:53 2003 +++ gnuworld-sithnet/mod.cservice/cservice.cc Fri Oct 24 10:31:45 2003 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: cservice.cc,v 1.1.1.1 2003/10/19 17:45:53 darthsidious_ Exp $ + * $Id: cservice.cc,v 1.2 2003/10/24 17:31:45 darthsidious_ Exp $ */ #include <new> @@ -2427,6 +2427,27 @@ deopList.push_back(tmpUser->getClient()); sourceHasBeenBad = true; } + // If the channel is STRICTVOICE, devoice everyone who isn't + // authenticated or and doesn't have access on the + // channel. + + if (reggedChan->getFlag(sqlChannel::F_STRICTVOICE)) + { + if (!authUser) + { + // Not authed, devoice. + if ( !tmpUser->getClient()->getMode(iClient::MODE_SERVICES) ) + devoiceList.push_back(tmpUser->getClient()); + sourceHasBeenBad = true; + // Authed but doesn't have access... devoice. + } + else if (!getEffectiveAccessLevel(authUser,reggedChan, false) >= level::voice)) + { + if ( !tmpUser->getClient()->getMode(iClient::MODE_SERVICES) ) + devoiceList.puch_back(tmpUser->getClient()); + sourceHasBeenBad = true; + } + } // If the channel is STRICTOP, deop everyone who isn't // authenticated or and doesn't have access on the @@ -2498,7 +2519,7 @@ } // for() /* - * Send notices and perform the deop's. (But don't deop anything thats +k). + * Send notices and perform the deop's(/devoices). (But don't deop anything thats +k). */ if (theChanUser && sourceHasBeenBad && !theChanUser->getClient()->getMode(iClient::MODE_SERVICES)) @@ -2522,7 +2543,13 @@ DeOp(theChan, deopList); } - +if( !devoiceList.empty() ) + { + if ((theChanUser) && (reggedChan->getFlag(sqlChannel::F_STRICTVOICE)) ) + { + Notice( theChanUser->getClient(), + "The STRICTVOICE flag is set on %s", + reggedChan->getName().c_str()); /* * Have more than 'maxdeoppro' been deopped? * If so, suspend and kick 'em. (Unless they're +k of course ;) @@ -2777,6 +2804,147 @@ if( !deopList.empty() ) { DeOp(theChan, deopList); + } + +} +/** + * Support function to devoice all voiced users on a channel. + */ +void cservice::devoiceAllOnChan(Channel* theChan) +{ +if( !theChan ) + { + /* Don't try this on a null channel. */ + return; + } + +sqlChannel* reggedChan = getChannelRecord(theChan->getName()); + +if (!reggedChan) + { + return; + } + +if (!reggedChan->getInChan()) + { + return; + } + +/* Check we're actually opped first.. */ + +ChannelUser* tmpBotUser = theChan->findUser(getInstance()); +if( !tmpBotUser || !tmpBotUser->getMode(ChannelUser::MODE_V) ) + { + return; + } + +vector< iClient* > deopList; + +for( Channel::const_userIterator ptr = theChan->userList_begin(); + ptr != theChan->userList_end() ; ++ptr ) + { + if( ptr->second->getMode(ChannelUser::MODE_V)) + { + + /* Don't devoice +k things */ + if ( !ptr->second->getClient()->getMode(iClient::MODE_SERVICES) ) + deopList.push_back( ptr->second->getClient() ); + + } // If opped. + } + +if( !devoiceList.empty() ) + { + DeVoice(theChan, devoiceList); + } + +} + +size_t cservice::countChanVoices(const Channel* theChan) +{ +if( !theChan ) + { + /* Don't try this on a null channel. */ + return 0; + } + +size_t chanVoices = 0; + +for( Channel::const_userIterator ptr = theChan->userList_begin(); + ptr != theChan->userList_end() ; ++ptr ) + { + if( ptr->second->getMode(ChannelUser::MODE_V)) + { + chanVoices++; + } // If voiced. + } + +return chanVoices; +} + +/** + * Support function to devoice all non authed opped users on a channel. + */ +void cservice::devoiceAllUnAuthedOnChan(Channel* theChan) +{ +// TODO: assert( theChan != 0 ) ; + +if( !theChan ) + { + /* Don't try this on a null channel. */ + return; + } + +sqlChannel* reggedChan = getChannelRecord(theChan->getName()); + +if( !reggedChan || !reggedChan->getInChan() ) + { + return; + } + +/* Check we're actually opped first.. */ + +ChannelUser* tmpBotUser = theChan->findUser(getInstance()); +if(! tmpBotUser || !tmpBotUser->getMode(ChannelUser::MODE_V)) + { + return; + } + +vector< iClient* > devoiceList; + +for( Channel::const_userIterator ptr = theChan->userList_begin(); + ptr != theChan->userList_end() ; ++ptr ) + { + if( ptr->second->getMode(ChannelUser::MODE_V)) + { + /* Are they authed? */ + sqlUser* authUser = isAuthed(ptr->second->getClient(), false); + + if (!authUser) + { + /* Not authed, deop this guy + Don't deop +k things */ + if ( !ptr->second->getClient()->getMode(iClient::MODE_SERVICES) ) + { + deopList.push_back( ptr->second->getClient() ); + } + + /* Authed but no access? Tough. :) */ + } + else if ((reggedChan) && !(getEffectiveAccessLevel(authUser, reggedChan, false) >= level::voice)) + { + /* Don't deop +k things */ + if ( !ptr->second->getClient()->getMode(iClient::MODE_SERVICES) ) + { + devoiceList.push_back( ptr->second->getClient() ); + } + } + + } // if voiced. + } // forall users in channel. + +if( !devoiceList.empty() ) + { + DeVoice(theChan, devoiceList); } } Index: gnuworld-sithnet/mod.cservice/cservice.h diff -u gnuworld-sithnet/mod.cservice/cservice.h:1.1.1.1 gnuworld-sithnet/mod.cservice/cservice.h:1.2 --- gnuworld-sithnet/mod.cservice/cservice.h:1.1.1.1 Sun Oct 19 10:45:53 2003 +++ gnuworld-sithnet/mod.cservice/cservice.h Fri Oct 24 10:31:45 2003 @@ -17,11 +17,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: cservice.h,v 1.1.1.1 2003/10/19 17:45:53 darthsidious_ Exp $ + * $Id: cservice.h,v 1.2 2003/10/24 17:31:45 darthsidious_ Exp $ */ #ifndef __CSERVICE_H -#define __CSERVICE_H "$Id: cservice.h,v 1.1.1.1 2003/10/19 17:45:53 darthsidious_ Exp $" +#define __CSERVICE_H "$Id: cservice.h,v 1.2 2003/10/24 17:31:45 darthsidious_ Exp $" #include <string> #include <vector> @@ -357,6 +357,10 @@ // Deop everyone on this channel. void deopAllOnChan(Channel*); void deopAllUnAuthedOnChan(Channel*); + + // Devoice everyone on this channel + void devoiceAllOnChan(Channel*); + void devoiceAllUnAuthedOnChan(Channel*); /* Sets a description (url) topic combo. */ void doAutoTopic(sqlChannel*); Index: gnuworld-sithnet/mod.cservice/levels.h diff -u gnuworld-sithnet/mod.cservice/levels.h:1.1.1.1 gnuworld-sithnet/mod.cservice/levels.h:1.2 --- gnuworld-sithnet/mod.cservice/levels.h:1.1.1.1 Sun Oct 19 10:45:55 2003 +++ gnuworld-sithnet/mod.cservice/levels.h Fri Oct 24 10:31:45 2003 @@ -21,11 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: levels.h,v 1.1.1.1 2003/10/19 17:45:55 darthsidious_ Exp $ + * $Id: levels.h,v 1.2 2003/10/24 17:31:45 darthsidious_ Exp $ */ #ifndef __LEVELS_H -#define __LEVELS_H "$Id: levels.h,v 1.1.1.1 2003/10/19 17:45:55 darthsidious_ Exp $" +#define __LEVELS_H "$Id: levels.h,v 1.2 2003/10/24 17:31:45 darthsidious_ Exp $" namespace gnuworld { @@ -98,17 +98,18 @@ const int userflag = 450; const int autotopic = 450; const int url = 450; - const int massdeoppro = 500; + const int massdeoppro = 499; const int keywords = 450; const int floatlim = 450; const int desc = 450; const int mode = 450; - const int noop = 500; + const int noop = 499; const int oponly = 500; - const int strictop = 500; + const int strictop = 475; + const int strictvoice = 475; const int lang = 500; - const int floodpro = 500; + const int floodpro = 499; const int autojoin = 500; const int nopurge = 501; Index: gnuworld-sithnet/mod.cservice/sqlChannel.cc diff -u gnuworld-sithnet/mod.cservice/sqlChannel.cc:1.1.1.1 gnuworld-sithnet/mod.cservice/sqlChannel.cc:1.2 --- gnuworld-sithnet/mod.cservice/sqlChannel.cc:1.1.1.1 Sun Oct 19 10:46:11 2003 +++ gnuworld-sithnet/mod.cservice/sqlChannel.cc Fri Oct 24 10:31:46 2003 @@ -24,7 +24,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: sqlChannel.cc,v 1.1.1.1 2003/10/19 17:46:11 darthsidious_ Exp $ + * $Id: sqlChannel.cc,v 1.2 2003/10/24 17:31:46 darthsidious_ Exp $ */ #include <sstream> @@ -41,7 +41,7 @@ #include "cservice_config.h" const char sqlChannel_h_rcsId[] = __SQLCHANNEL_H ; -const char sqlChannel_cc_rcsId[] = "$Id: sqlChannel.cc,v 1.1.1.1 2003/10/19 17:46:11 darthsidious_ Exp $" ; +const char sqlChannel_cc_rcsId[] = "$Id: sqlChannel.cc,v 1.2 2003/10/24 17:31:46 darthsidious_ Exp $" ; namespace gnuworld { @@ -69,6 +69,7 @@ const sqlChannel::flagType sqlChannel::F_OPONLY = 0x00100000 ; // Deprecated const sqlChannel::flagType sqlChannel::F_AUTOJOIN = 0x00200000 ; const sqlChannel::flagType sqlChannel::F_NOFORCE = 0x00400000 ; // Reserved for use by Planetarion. +const sqlChannel::flagType sqlChannel::F_STRICTVOICE = 0x00800000; // Reserved for use by SithNet const int sqlChannel::EV_MISC = 1 ; const int sqlChannel::EV_JOIN = 2 ; Index: gnuworld-sithnet/mod.cservice/sqlChannel.h diff -u gnuworld-sithnet/mod.cservice/sqlChannel.h:1.1.1.1 gnuworld-sithnet/mod.cservice/sqlChannel.h:1.2 --- gnuworld-sithnet/mod.cservice/sqlChannel.h:1.1.1.1 Sun Oct 19 10:46:12 2003 +++ gnuworld-sithnet/mod.cservice/sqlChannel.h Fri Oct 24 10:31:46 2003 @@ -17,11 +17,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. * - * $Id: sqlChannel.h,v 1.1.1.1 2003/10/19 17:46:12 darthsidious_ Exp $ + * $Id: sqlChannel.h,v 1.2 2003/10/24 17:31:46 darthsidious_ Exp $ */ #ifndef __SQLCHANNEL_H -#define __SQLCHANNEL_H "$Id: sqlChannel.h,v 1.1.1.1 2003/10/19 17:46:12 darthsidious_ Exp $" +#define __SQLCHANNEL_H "$Id: sqlChannel.h,v 1.2 2003/10/24 17:31:46 darthsidious_ Exp $" #include <string> #include <map> @@ -61,6 +61,7 @@ static const flagType F_ALWAYSOP; static const flagType F_STRICTOP; + static const flagType F_STRICTVOICE; static const flagType F_NOOP; static const flagType F_AUTOTOPIC; static const flagType F_OPONLY; // Deprecated. ----------------------- End of diff ----------------------- |