]> jfr.im git - irc/UndernetIRC/gnuworld.git/commitdiff
Condensed DB handle usage to one global handle. This means that chanfix should work...
authorCompy <redacted>
Wed, 16 Jan 2008 02:03:37 +0000 (02:03 +0000)
committerCompy <redacted>
Wed, 16 Jan 2008 02:03:37 +0000 (02:03 +0000)
33 files changed:
mod.openchanfix/ADDFLAGCommand.cc
mod.openchanfix/ADDHOSTCommand.cc
mod.openchanfix/ADDNOTECommand.cc
mod.openchanfix/ADDUSERCommand.cc
mod.openchanfix/ALERTCommand.cc
mod.openchanfix/BLOCKCommand.cc
mod.openchanfix/CHANFIXCommand.cc
mod.openchanfix/DELFLAGCommand.cc
mod.openchanfix/DELHOSTCommand.cc
mod.openchanfix/DELNOTECommand.cc
mod.openchanfix/DELUSERCommand.cc
mod.openchanfix/HISTORYCommand.cc
mod.openchanfix/INFOCommand.cc
mod.openchanfix/LASTCOMCommand.cc
mod.openchanfix/LISTBLOCKEDCommand.cc
mod.openchanfix/Makefile.in
mod.openchanfix/OPLISTCommand.cc
mod.openchanfix/REQUESTOPCommand.cc
mod.openchanfix/SCORECommand.cc
mod.openchanfix/SETGROUPCommand.cc
mod.openchanfix/SIMULATECommand.cc
mod.openchanfix/SUSPENDCommand.cc
mod.openchanfix/UNALERTCommand.cc
mod.openchanfix/UNBLOCKCommand.cc
mod.openchanfix/UNSUSPENDCommand.cc
mod.openchanfix/USETCommand.cc
mod.openchanfix/WHOGROUPCommand.cc
mod.openchanfix/chanfix.cc
mod.openchanfix/chanfix.h
mod.openchanfix/sqlChannel.cc
mod.openchanfix/sqlChannel.h
mod.openchanfix/sqlcfUser.cc
mod.openchanfix/sqlcfUser.h

index dcea035daa20d9682e97b8c7e63ece7b8e3bbeb0..1f0bfed211abd9f9b51b0e9fac9f0c3abde16b89 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: ADDFLAGCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: ADDFLAGCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -32,7 +32,7 @@
 #include "StringTokenizer.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: ADDFLAGCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: ADDFLAGCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -128,7 +128,7 @@ targetUser->setLastUpdatedBy( std::string( "("
        + theUser->getUserName()
        + ") "
        + theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
 bot->SendTo(theClient,
            bot->getResponse(theUser,
                             language::added_flag_to_user,
index 41085a78e681538af6f05b79584b3b0cedfa855c..29627de58f775d70be1a346c1d9ec69091a2bd91 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: ADDHOSTCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: ADDHOSTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -31,7 +31,7 @@
 #include "StringTokenizer.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: ADDHOSTCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: ADDHOSTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -82,7 +82,7 @@ if (theUser->getFlag(sqlcfUser::F_SERVERADMIN) &&
   
 if (targetUser->matchHost(st[2].c_str())) {
   if ((st[2] != "*!*@*") && targetUser->hasHost("*!*@*")) {
-    targetUser->delHost("*!*@*");
+    targetUser->delHost(bot->getLocalDBHandle(),"*!*@*");
     bot->SendTo(theClient,
                bot->getResponse(theUser,
                        language::removed_default_hostmask,
@@ -99,7 +99,7 @@ if (targetUser->matchHost(st[2].c_str())) {
   }
 }
 
-if (!targetUser->addHost(st[2].c_str())) {
+if (!targetUser->addHost(bot->getLocalDBHandle(),st[2].c_str())) {
   bot->SendTo(theClient,
              bot->getResponse(theUser,
                        language::failed_adding_hostmask,
@@ -113,7 +113,7 @@ targetUser->setLastUpdatedBy( std::string( "("
        + theUser->getUserName()
        + ") "
        + theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
 
 bot->SendTo(theClient,
             bot->getResponse(theUser,
index 9cb68e3b8f30f5d399ff4b4b3c0ec8bd093fa0a0..89be43a0527486a66234901b1d31d74bacee0c83 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: ADDNOTECommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: ADDNOTECommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -32,7 +32,7 @@
 #include "sqlChannel.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: ADDNOTECommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: ADDNOTECommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -55,9 +55,9 @@ sqlChannel* theChan = bot->getChannelRecord(st[1]);
 if (!theChan) theChan = bot->newChannelRecord(st[1]);
 
 if (!theChan->useSQL())
-  theChan->Insert();
+  theChan->Insert(bot->getLocalDBHandle());
 
-theChan->addNote(sqlChannel::EV_NOTE, theClient, st.assemble(2));
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_NOTE, theClient, st.assemble(2));
 
 bot->SendTo(theClient,
             bot->getResponse(theUser,
index 350540dc002927209cbfd757d7d5ed1026eb4d10..a9379380415b75554349a5181d89159f80660784 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: ADDUSERCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: ADDUSERCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -32,7 +32,7 @@
 #include "StringTokenizer.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: ADDUSERCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: ADDUSERCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -70,7 +70,7 @@ if (theUser->getFlag(sqlcfUser::F_SERVERADMIN) &&
 else
   newUser->setGroup("undernet.org");
 
-if (!newUser->Insert()) {
+if (!newUser->Insert(bot->getLocalDBHandle())) {
   bot->SendTo(theClient,
              bot->getResponse(theUser,
                        language::error_creating_user,
@@ -82,7 +82,7 @@ if (!newUser->Insert()) {
 bot->usersMap[newUser->getUserName()] = newUser;
 
 if (st.size() > 2) {
-  if (newUser->addHost(st[2].c_str())) {
+  if (newUser->addHost(bot->getLocalDBHandle(),st[2].c_str())) {
     bot->SendTo(theClient,
                bot->getResponse(theUser,
                                 language::created_user_w_host,
index 93912ad031e83fa4e7881b6a118c9305c193db1f..dddeb5a3a4511603f291db6ece13d1995f1a07c2 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: ALERTCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: ALERTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -32,7 +32,7 @@
 #include "sqlChannel.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: ALERTCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: ALERTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -67,12 +67,12 @@ if (theChan->getFlag(sqlChannel::F_ALERT)) {
 theChan->setFlag(sqlChannel::F_ALERT);
 
 if (!theChan->useSQL())
-  theChan->Insert();
+  theChan->Insert(bot->getLocalDBHandle());
 else
-  theChan->commit();
+  theChan->commit(bot->getLocalDBHandle());
 
 /* Add note to the channel about this command */
-theChan->addNote(sqlChannel::EV_ALERT, theClient, (st.size() > 2) ? st.assemble(2) : "");
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_ALERT, theClient, (st.size() > 2) ? st.assemble(2) : "");
 
 bot->SendTo(theClient,
             bot->getResponse(theUser,
index 36f16a7047b2cc9a5e9fc198cbc4e1e2ce4e9e54..7dc4771c124d0bb1181b072f949a51a59927bd98 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: BLOCKCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: BLOCKCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -33,7 +33,7 @@
 #include "sqlChannel.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: BLOCKCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: BLOCKCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -77,12 +77,12 @@ if (theChan->getFlag(sqlChannel::F_BLOCKED)) {
 theChan->setFlag(sqlChannel::F_BLOCKED);
 
 if (!theChan->useSQL())
-  theChan->Insert();
+  theChan->Insert(bot->getLocalDBHandle());
 else
-  theChan->commit();
+  theChan->commit(bot->getLocalDBHandle());
 
 /* Add note to the channel about this command */
-theChan->addNote(sqlChannel::EV_BLOCK, theClient, st.assemble(2));
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_BLOCK, theClient, st.assemble(2));
 
 bot->SendTo(theClient,
             bot->getResponse(theUser,
index 1c8299fefe244c5725a1b2ee1f49f61adede3bba..1f31c70bf187e1aa57d2942632af6566dc4e6ca4 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: CHANFIXCommand.cc,v 1.5 2007/03/11 14:52:28 buzlip01 Exp $
+ * $Id: CHANFIXCommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -31,7 +31,7 @@
 #include "responses.h"
 #include "StringTokenizer.h"
 
-RCSTAG("$Id: CHANFIXCommand.cc,v 1.5 2007/03/11 14:52:28 buzlip01 Exp $");
+RCSTAG("$Id: CHANFIXCommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -193,7 +193,7 @@ if (theChan->getFlag(sqlChannel::F_ALERT) && !override) {
 
 /* Add the channel to the SQL database if it hasn't already been added */
 if (!theChan->useSQL())
-  theChan->Insert();
+  theChan->Insert(bot->getLocalDBHandle());
 
 /* Alert top ops out of the channel if wanted */
 if (alert)
@@ -203,7 +203,7 @@ if (alert)
 bot->manualFix(netChan);
 
 /* Add note to the channel about this manual fix */
-theChan->addNote(sqlChannel::EV_CHANFIX, theClient, (override) ? "[override]" : "");
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_CHANFIX, theClient, (override) ? "[override]" : "");
 
 /* Log the chanfix */
 bot->SendTo(theClient,
index b945a129fd24dcb68dec3ac6d7ff2693bd43569b..1dd3664854fe953e3725ce11b898d465cc117620 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: DELFLAGCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: DELFLAGCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -31,7 +31,7 @@
 #include "StringTokenizer.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: DELFLAGCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: DELFLAGCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -128,7 +128,7 @@ targetUser->setLastUpdatedBy( std::string( "("
        + theUser->getUserName()
        + ") "
        + theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
 bot->SendTo(theClient,
             bot->getResponse(theUser,
                             language::deleted_flag,
index ccd5d74a200470e98f818790cc827569d931770b..0cdcaa63b69d0402f64cca2d08a21c422758963f 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: DELHOSTCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: DELHOSTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -31,7 +31,7 @@
 #include "StringTokenizer.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: DELHOSTCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: DELHOSTCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -90,7 +90,7 @@ if (!targetUser->hasHost(st[2].c_str())) {
   return;
 }
 
-if (!targetUser->delHost(st[2].c_str())) {
+if (!targetUser->delHost(bot->getLocalDBHandle(),st[2].c_str())) {
   bot->SendTo(theClient,
              bot->getResponse(theUser,
                        language::failed_deleting_host,
@@ -104,7 +104,7 @@ targetUser->setLastUpdatedBy( std::string( "("
        + theUser->getUserName()
        + ") "
        + theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
 
 bot->SendTo(theClient,
             bot->getResponse(theUser,
index 15438c303efb37c6e96c7cd0dafc769945d199b9..d060c5433aa3c48ef2a72369d4922ab8854f40e1 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: DELNOTECommand.cc,v 1.5 2007/08/28 16:10:20 dan_karrels Exp $
+ * $Id: DELNOTECommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -32,7 +32,7 @@
 #include "sqlChannel.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: DELNOTECommand.cc,v 1.5 2007/08/28 16:10:20 dan_karrels Exp $");
+RCSTAG("$Id: DELNOTECommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -53,7 +53,7 @@ if (!theChan) {
   return;
 }
 
-if (!theChan->useSQL() || (theChan->countNotes(0) <= 0)) {
+if (!theChan->useSQL() || (theChan->countNotes(bot->getLocalDBHandle(),0) <= 0)) {
   bot->SendTo(theClient,
               bot->getResponse(theUser,
                               language::chan_has_no_notes,
@@ -65,7 +65,7 @@ if (!theChan->useSQL() || (theChan->countNotes(0) <= 0)) {
 unsigned int messageId = atoi(st[2].c_str());
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = bot->theManager->getConnection();
+dbHandle* cacheCon = bot->getLocalDBHandle();
 
 /* Retrieve the note */
 std::stringstream noteCheckQuery;
@@ -75,7 +75,7 @@ noteCheckQuery        << "SELECT channelID, user_name, event "
                << messageId
                ;
 
-if (!cacheCon->Exec(noteCheckQuery,true)) {
+if (!cacheCon->Exec(noteCheckQuery.str(),true)) {
   elog << "DELNOTECommand> SQL Error: "
        << cacheCon->ErrorMessage()
        << std::endl ;
@@ -86,7 +86,7 @@ if (!cacheCon->Exec(noteCheckQuery,true)) {
                                std::string("An unknown error occured while checking the note id.")).c_str());
 
   /* Dispose of our connection instance */
-  bot->theManager->removeConnection(cacheCon);
+  //bot->theManager->removeConnection(cacheCon);
 
   return;
 }
@@ -104,7 +104,7 @@ std::string user_name = cacheCon->GetValue(0,1);
 unsigned short eventType = atoi(cacheCon->GetValue(0,2));
 
 /* Dispose of our connection instance */
-bot->theManager->removeConnection(cacheCon);
+//bot->theManager->removeConnection(cacheCon);
 
 if (channelID != theChan->getID()) {
   bot->SendTo(theClient,
@@ -133,7 +133,7 @@ if (eventType != sqlChannel::EV_NOTE && !theUser->getFlag(sqlcfUser::F_OWNER)) {
   return;
 }
 
-theChan->deleteNote(messageId);
+theChan->deleteNote(bot->getLocalDBHandle(),messageId);
 
 bot->SendTo(theClient,
             bot->getResponse(theUser,
index 7d9d483bc47ba77e09df2b9157cdbfa0fc5fd406..68358151befe577b037f469f9195d890f4789bd4 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: DELUSERCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $
+ * $Id: DELUSERCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -31,7 +31,7 @@
 #include "StringTokenizer.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: DELUSERCommand.cc,v 1.4 2006/12/09 00:29:18 buzlip01 Exp $");
+RCSTAG("$Id: DELUSERCommand.cc,v 1.5 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -81,7 +81,7 @@ if (theUser->getFlag(sqlcfUser::F_SERVERADMIN) &&
   }
 }
 
-if (targetUser->Delete()) {
+if (targetUser->Delete(bot->getLocalDBHandle())) {
   bot->usersMap.erase(bot->usersMap.find(targetUser->getUserName()));
   bot->SendTo(theClient,
              bot->getResponse(theUser,
index e2ed17a21f65d95ff6c7b75e3fa9298f5dde2e07..9ee03dbf80140404e0dadb624a5ded4c15a2a8b3 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: HISTORYCommand.cc,v 1.5 2007/08/28 16:10:21 dan_karrels Exp $
+ * $Id: HISTORYCommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -32,7 +32,7 @@
 #include "sqlChannel.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: HISTORYCommand.cc,v 1.5 2007/08/28 16:10:21 dan_karrels Exp $");
+RCSTAG("$Id: HISTORYCommand.cc,v 1.6 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -54,7 +54,7 @@ if (!theChan || !theChan->useSQL()) {
 }
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = bot->theManager->getConnection();
+dbHandle* cacheCon = bot->getLocalDBHandle();
 
 /*
  * Perform a query to list the dates/times this channel was last chanfixed.
@@ -71,7 +71,7 @@ chanfixQuery  << "SELECT ts "
                << ") ORDER BY ts DESC"
                ;
 
-if (!cacheCon->Exec(chanfixQuery,true)) {
+if (!cacheCon->Exec(chanfixQuery.str(),true)) {
        elog    << "HISTORYCommand> SQL Error: "
                << cacheCon->ErrorMessage()
                << std::endl;
@@ -93,7 +93,7 @@ if (noteCount <= 0) {
                                           theChan->getChannel().c_str());
 
   /* Dispose of our connection instance */
-  bot->theManager->removeConnection(cacheCon);
+  //bot->theManager->removeConnection(cacheCon);
 
   return;
 }
@@ -113,7 +113,7 @@ bot->SendTo(theClient,
                             std::string("End of list.")).c_str());
 
 /* Dispose of our connection instance */
-bot->theManager->removeConnection(cacheCon);
+//bot->theManager->removeConnection(cacheCon);
 
 bot->logAdminMessage("%s (%s) HISTORY %s",
                     theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
index 3c195d020faaeb26ba2c60dca455b965dbfca257..3fe018582abcacbe0f9b8ca53f82edeff959eca3 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: INFOCommand.cc,v 1.6 2007/08/28 16:10:21 dan_karrels Exp $
+ * $Id: INFOCommand.cc,v 1.7 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -33,7 +33,7 @@
 #include "sqlChannel.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: INFOCommand.cc,v 1.6 2007/08/28 16:10:21 dan_karrels Exp $");
+RCSTAG("$Id: INFOCommand.cc,v 1.7 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -133,7 +133,7 @@ if (!theChan->useSQL()) {
 }
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = bot->theManager->getConnection();
+dbHandle* cacheCon = bot->getLocalDBHandle();
 
 /*
  * Perform a query to list all notes belonging to this channel.
@@ -146,7 +146,7 @@ allNotesQuery       << "SELECT notes.id, notes.ts, notes.user_name, notes.event, notes
                << " ORDER BY notes.ts DESC"
                ;
 
-if (!cacheCon->Exec(allNotesQuery,true)) {
+if (!cacheCon->Exec(allNotesQuery.str(),true)) {
   elog << "INFOCommand> SQL Error: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -157,7 +157,7 @@ if (!cacheCon->Exec(allNotesQuery,true)) {
                                std::string("An unknown error occurred while reading this channel's notes.")).c_str());
 
   /* Dispose of our connection instance */
-  bot->theManager->removeConnection(cacheCon);
+  //bot->theManager->removeConnection(cacheCon);
 
   return ;
 }
@@ -194,7 +194,7 @@ bot->SendTo(theClient,
                             std::string("End of information.")).c_str());
 
 /* Dispose of our connection instance */
-bot->theManager->removeConnection(cacheCon);
+//bot->theManager->removeConnection(cacheCon);
 
 bot->logAdminMessage("%s (%s) INFO %s",
                     theUser ? theUser->getUserName().c_str() : "!NOT-LOGGED-IN!",
index 825e6e79ec759ff4bff990fffb5b79aebbd7076c..a577f3aa60e1706e8b49768f01f4bc402d6d4e94 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: LASTCOMCommand.cc,v 1.3 2007/08/28 16:10:21 dan_karrels Exp $
+ * $Id: LASTCOMCommand.cc,v 1.4 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include       <sstream>
@@ -45,7 +45,7 @@
 #include       "ELog.h"
 #include       "gnuworld_config.h"
 
-RCSTAG( "$Id: LASTCOMCommand.cc,v 1.3 2007/08/28 16:10:21 dan_karrels Exp $" ) ;
+RCSTAG( "$Id: LASTCOMCommand.cc,v 1.4 2008/01/16 02:03:37 buzlip01 Exp $" ) ;
 
 namespace gnuworld
 {
@@ -60,7 +60,7 @@ unsigned int NumOfCom;
 unsigned int Days = 0;
 std::stringstream theQuery;
 
-dbHandle* cacheCon = bot->theManager->getConnection();
+dbHandle* cacheCon = bot->getLocalDBHandle();
 
 if (st.size() == 1 ) {
   NumOfCom = 20;
@@ -99,7 +99,7 @@ elog  << "chanfix::LASTCOM> "
        << theQuery.str().c_str() 
        << std::endl;
        
-if (!cacheCon->Exec(theQuery,true)) {
+if (!cacheCon->Exec(theQuery.str(),true)) {
   elog << "chanfix::LASTCOM> SQL Error: "
        << cacheCon->ErrorMessage()
        << std::endl ;
@@ -127,7 +127,7 @@ bot->SendTo(theClient,
                              std::string("End of LASTCOM report.")).c_str());
 
 /* Dispose of our connection instance */
-bot->theManager->removeConnection(cacheCon);
+//bot->theManager->removeConnection(cacheCon);
 
 bot->logLastComMessage(theClient, Message);
 
index 333382f5643e2e16923862905d8fe842e3a13027..40315c3408244c6ca04f2cf0826892f8eea73708 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: LISTBLOCKEDCommand.cc,v 1.3 2007/08/28 16:10:21 dan_karrels Exp $
+ * $Id: LISTBLOCKEDCommand.cc,v 1.4 2008/01/16 02:03:37 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -33,7 +33,7 @@
 #include "sqlChannel.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: LISTBLOCKEDCommand.cc,v 1.3 2007/08/28 16:10:21 dan_karrels Exp $");
+RCSTAG("$Id: LISTBLOCKEDCommand.cc,v 1.4 2008/01/16 02:03:37 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -52,7 +52,7 @@ if (!bot->doChanBlocking()) {
 }
 
 /* List blocks */
-dbHandle* cacheCon = bot->theManager->getConnection();
+dbHandle* cacheCon = bot->getLocalDBHandle();
 
 std::stringstream theQuery;
 theQuery << "SELECT channel FROM channels WHERE (flags & "
@@ -61,7 +61,7 @@ theQuery << "SELECT channel FROM channels WHERE (flags & "
         << sqlChannel::F_BLOCKED
         << " ORDER BY channel ASC";
 
-if (!cacheCon->Exec(theQuery,true)) {
+if (!cacheCon->Exec(theQuery.str(),true)) {
   elog << "chanfix::LISTBLOCKEDCommand> SQL Error: "
                << cacheCon->ErrorMessage()
                << std::endl;
@@ -87,7 +87,7 @@ for (unsigned int i = 0 ; i < cacheCon->Tuples(); i++) {
 }
 
 /* Dispose of our connection instance */
-bot->theManager->removeConnection(cacheCon);
+//bot->theManager->removeConnection(cacheCon);
 
 if (strBlocks.size())
   bot->SendTo(theClient, strBlocks.c_str());
index 2c9b8696ac7c7f6e813a084789f8173815ec6c5a..6bbf00ddd6a97d06b897a4b11958454d480ae129 100644 (file)
@@ -14,7 +14,7 @@
 
 @SET_MAKE@
 
-# "$Id: Makefile.in,v 1.14 2007/10/31 14:56:44 kewlio Exp $"
+# "$Id: Makefile.in,v 1.15 2008/01/16 02:03:38 buzlip01 Exp $"
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
index 97e10042f398829cddd0c56798ae2760d87820b6..002f7b90ece50e2992bf340ce163d6bce247dcc0 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: OPLISTCommand.cc,v 1.6 2007/02/01 14:11:17 buzlip01 Exp $
+ * $Id: OPLISTCommand.cc,v 1.7 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -33,7 +33,7 @@
 #include "sqlChannel.h"
 #include "sqlChanOp.h"
 
-RCSTAG("$Id: OPLISTCommand.cc,v 1.6 2007/02/01 14:11:17 buzlip01 Exp $");
+RCSTAG("$Id: OPLISTCommand.cc,v 1.7 2008/01/16 02:03:39 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -74,7 +74,7 @@ if (myOps.empty()) {
        
        sqlChannel* theChan = bot->getChannelRecord(st[1]);
        if (theChan) {
-         bot->SendTo(theClient, "Notes: %d", theChan->countNotes(0));
+         bot->SendTo(theClient, "Notes: %d", theChan->countNotes(bot->getLocalDBHandle(),0));
 
          if (bot->isTempBlocked(theChan->getChannel()))
            bot->SendTo(theClient,
@@ -113,7 +113,7 @@ if (oCnt == 0) {
        
        sqlChannel* theChan = bot->getChannelRecord(st[1]);
        if (theChan) {
-         bot->SendTo(theClient, "Notes: %d", theChan->countNotes(0));
+         bot->SendTo(theClient, "Notes: %d", theChan->countNotes(bot->getLocalDBHandle(),0));
 
          if (bot->isTempBlocked(theChan->getChannel()))
            bot->SendTo(theClient,
@@ -219,7 +219,7 @@ for (chanfix::chanOpsType::iterator opPtr = myOps.begin();
 
 sqlChannel* theChan = bot->getChannelRecord(st[1]);
 if (theChan) {
-  bot->SendTo(theClient, "Notes: %d", theChan->countNotes(0));
+  bot->SendTo(theClient, "Notes: %d", theChan->countNotes(bot->getLocalDBHandle(), 0));
 
   if (bot->isTempBlocked(theChan->getChannel()))
     bot->SendTo(theClient,
index 6cbe8aa58865c542a413f8d1b86f3bdb60521c28..cf28ccf66d862b1743b306995453a542d50dd813 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: REQUESTOPCommand.cc,v 1.1 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: REQUESTOPCommand.cc,v 1.2 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -31,7 +31,7 @@
 #include "responses.h"
 #include "StringTokenizer.h"
 
-RCSTAG("$Id: REQUESTOPCommand.cc,v 1.1 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: REQUESTOPCommand.cc,v 1.2 2008/01/16 02:03:39 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -230,7 +230,7 @@ if ((bot->isTempBlocked(theChan->getChannel())) || (theChan->getFlag(sqlChannel:
 
 /* Add the channel to the SQL database if it hasn't already been added */
 if (!theChan->useSQL())
-  theChan->Insert();
+  theChan->Insert(bot->getLocalDBHandle());
 
 /* Alert top ops out of the channel if wanted */
 if (alert)
@@ -240,7 +240,7 @@ if (alert)
 bot->manualFix(netChan);
 
 /* Add note to the channel about this manual fix */
-theChan->addNote(sqlChannel::EV_REQUESTOP, theClient, "");
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_REQUESTOP, theClient, "");
 
 /* Log the chanfix */
 bot->SendTo(theClient,
index bab477c1b5cf39fa297a6a96f7d7f203ff2e9477..6ca2958496df6a8c47c121d2a3ccbcf599d84190 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: SCORECommand.cc,v 1.5 2007/02/01 14:11:16 buzlip01 Exp $
+ * $Id: SCORECommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #include <sstream>
@@ -37,7 +37,7 @@
 #include "sqlChanOp.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: SCORECommand.cc,v 1.5 2007/02/01 14:11:16 buzlip01 Exp $");
+RCSTAG("$Id: SCORECommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -333,7 +333,7 @@ if (compact) {
 
 sqlChannel* theChan = bot->getChannelRecord(st[1]);
 if (theChan) {
-  bot->SendTo(theClient, "Notes: %d", theChan->countNotes(0));
+  bot->SendTo(theClient, "Notes: %d", theChan->countNotes(bot->getLocalDBHandle(), 0));
        
   if (theChan->getFlag(sqlChannel::F_BLOCKED))
     bot->SendTo(theClient,
index 5974cd41674429b2ce0477e635be8f041aecf542..48ec5e700a8b799c674686e9961076c324d551bf 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: SETGROUPCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: SETGROUPCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -31,7 +31,7 @@
 #include "StringTokenizer.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: SETGROUPCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: SETGROUPCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -68,7 +68,7 @@ targetUser->setLastUpdatedBy( std::string( "("
        + theUser->getUserName()
        + ") "
        + theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
 
 bot->SendTo(theClient,
             bot->getResponse(theUser,
index 553d1d3d7d59137e7deae0334efaacfd6901cd4b..97dd1f8648295f76fc0088e54a98469b6a20504f 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: SIMULATECommand.cc,v 1.1 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: SIMULATECommand.cc,v 1.2 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -33,7 +33,7 @@
 #include "sqlChannel.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: SIMULATECommand.cc,v 1.1 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: SIMULATECommand.cc,v 1.2 2008/01/16 02:03:39 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -144,7 +144,7 @@ if (bot->isTempBlocked(theChan->getChannel())) {
 }
 
 if (!theChan->useSQL())
-  theChan->Insert();
+  theChan->Insert(bot->getLocalDBHandle());
 
 bot->SendTo(theClient,
             bot->getResponse(theUser,
@@ -161,7 +161,7 @@ bot->SendTo(theClient,
 sqlChannel* sqlChan = bot->getChannelRecord(st[1]);
 bot->simulateFix(sqlChan, autof, theClient, theUser);
 
-theChan->addNote(sqlChannel::EV_SIMULATE, theClient, (autof) ? "[auto]" : "[manual]");
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_SIMULATE, theClient, (autof) ? "[auto]" : "[manual]");
 
 bot->SendTo(theClient,
             bot->getResponse(theUser,
index ccb1de010b19db071d82473bbbbb3a50aeff742b..222f2a066c1d1710a12a41e38ec582b61852dfb7 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: SUSPENDCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: SUSPENDCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -31,7 +31,7 @@
 #include "StringTokenizer.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: SUSPENDCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: SUSPENDCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -105,7 +105,7 @@ targetUser->setLastUpdatedBy( std::string( "("
        + theUser->getUserName()
        + ") "
        + theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
 
 bot->SendTo(theClient,
             bot->getResponse(theUser,
index 87158fc262bce5c64428b376afcdacaa08cbc72f..18e91d183126b11d4583b554a343c22321ee3d17 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: UNALERTCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: UNALERTCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -32,7 +32,7 @@
 #include "sqlChannel.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: UNALERTCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: UNALERTCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -65,12 +65,12 @@ if (!theChan->getFlag(sqlChannel::F_ALERT)) {
 theChan->removeFlag(sqlChannel::F_ALERT);
 
 if (!theChan->useSQL())
-  theChan->Insert();
+  theChan->Insert(bot->getLocalDBHandle());
 else
-  theChan->commit();
+  theChan->commit(bot->getLocalDBHandle());
 
 /* Add note to the channel about this command */
-theChan->addNote(sqlChannel::EV_UNALERT, theClient, "");
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_UNALERT, theClient, "");
 
 bot->SendTo(theClient,
             bot->getResponse(theUser,
index 9870b9dcb54e9049db4317d4b190c1167d7f6281..92472ae9c0af3e3e1002ad2f6e13098e9ea33ed6 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: UNBLOCKCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: UNBLOCKCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -32,7 +32,7 @@
 #include "sqlChannel.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: UNBLOCKCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: UNBLOCKCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -74,12 +74,12 @@ if (!theChan->getFlag(sqlChannel::F_BLOCKED)) {
 theChan->removeFlag(sqlChannel::F_BLOCKED);
 
 if (!theChan->useSQL())
-  theChan->Insert();
+  theChan->Insert(bot->getLocalDBHandle());
 else
-  theChan->commit();
+  theChan->commit(bot->getLocalDBHandle());
 
 /* Add note to the channel about this command */
-theChan->addNote(sqlChannel::EV_UNBLOCK, theClient, "");
+theChan->addNote(bot->getLocalDBHandle(), sqlChannel::EV_UNBLOCK, theClient, "");
 
 bot->SendTo(theClient,
             bot->getResponse(theUser,
index cf759caf36c02b4e51e719af47ff5e4a08ca4361..ed1ffc2b6b3afec9b63c6da1a8109c58a07cbfeb 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: UNSUSPENDCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: UNSUSPENDCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -31,7 +31,7 @@
 #include "StringTokenizer.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: UNSUSPENDCommand.cc,v 1.4 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: UNSUSPENDCommand.cc,v 1.5 2008/01/16 02:03:39 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -96,7 +96,7 @@ targetUser->setLastUpdatedBy( std::string( "("
        + theUser->getUserName()
        + ") "
        + theClient->getRealNickUserHost() ) );
-targetUser->commit();
+targetUser->commit(bot->getLocalDBHandle());
 
 bot->SendTo(theClient,
            bot->getResponse(theUser,
index 26d0521db308deffe0c306a8fb5cd7ac0ab5680b..8379cdc73089e75e6a97f0e4e677ba85991f0c4d 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  * USA.
  *
- * $Id: USETCommand.cc,v 1.5 2006/12/09 00:29:19 buzlip01 Exp $
+ * $Id: USETCommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #include       <string>
@@ -33,7 +33,7 @@
 #include       "responses.h"
 #include       "sqlcfUser.h"
 
-RCSTAG("$Id: USETCommand.cc,v 1.5 2006/12/09 00:29:19 buzlip01 Exp $");
+RCSTAG("$Id: USETCommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -67,13 +67,13 @@ if (st.size() == 4) {
       targetUser->setNeedOper(true);
       bot->SendTo(theClient, "%s is now required to be an IRC Operator", 
                  targetUser->getUserName().c_str());
-      targetUser->commit();
+      targetUser->commit(bot->getLocalDBHandle());
       return;
     } else if (value == "OFF" || value == "NO" || value == "0") {
       targetUser->setNeedOper(false);
       bot->SendTo(theClient, "%s is now not required to be an IRC Operator", 
                  targetUser->getUserName().c_str());
-      targetUser->commit();
+      targetUser->commit(bot->getLocalDBHandle());
       return;
     } else {
       bot->SendTo(theClient, "Please use USET <username> NEEDOPER <on/off>.");
@@ -97,7 +97,7 @@ if (option == "NOTICE") {
                 bot->getResponse(theUser,
                                 language::send_notices,
                                 std::string("I will now send you notices.")).c_str());
-    theUser->commit();
+    theUser->commit(bot->getLocalDBHandle());
     return;
   } else if (value == "OFF" || value == "NO" || value == "0") {
     theUser->setNotice(false);
@@ -105,7 +105,7 @@ if (option == "NOTICE") {
                 bot->getResponse(theUser,
                                 language::send_privmsgs,
                                 std::string("I will now send you privmsgs.")).c_str());
-    theUser->commit();
+    theUser->commit(bot->getLocalDBHandle());
     return;
   } else {
     bot->SendTo(theClient,
@@ -122,7 +122,7 @@ if (option == "LANG")
   if (ptr != bot->languageTable.end()) {
     std::string lang = ptr->second.second;
     theUser->setLanguageId(ptr->second.first);
-    theUser->commit();
+    theUser->commit(bot->getLocalDBHandle());
     bot->SendTo(theClient,
                bot->getResponse(theUser,
                        language::lang_set_to,
index fe24846e47956f3eb86fdb886b217e66bb769320..a4ae7589a1531485b48791a6db2adc5a785ba75e 100644 (file)
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: WHOGROUPCommand.cc,v 1.5 2007/08/28 16:10:22 dan_karrels Exp $
+ * $Id: WHOGROUPCommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #include "gnuworld_config.h"
@@ -31,7 +31,7 @@
 #include "StringTokenizer.h"
 #include "sqlcfUser.h"
 
-RCSTAG("$Id: WHOGROUPCommand.cc,v 1.5 2007/08/28 16:10:22 dan_karrels Exp $");
+RCSTAG("$Id: WHOGROUPCommand.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -49,12 +49,12 @@ bot->logAdminMessage("%s (%s) WHOGROUP %s",
 
 if (st.size() == 1) {
   /* No parameter supplied, so list all groups */
-  dbHandle* cacheCon = bot->theManager->getConnection();
+  dbHandle* cacheCon = bot->getLocalDBHandle();
 
   std::stringstream theQuery;
   theQuery << "SELECT DISTINCT faction FROM users ORDER BY faction ASC";
 
-  if (!cacheCon->Exec(theQuery,true)) {
+  if (!cacheCon->Exec(theQuery.str(),true)) {
     elog       << "chanfix::WHOGROUPCommand> SQL Error: "
                << cacheCon->ErrorMessage()
                << std::endl;
@@ -74,7 +74,7 @@ if (st.size() == 1) {
   }
 
   /* Dispose of our connection instance */
-  bot->theManager->removeConnection(cacheCon);
+  //bot->theManager->removeConnection(cacheCon);
 
   bot->SendTo(theClient,
              bot->getResponse(theUser,
index 83e310b1dae1dbd71b3b092849c8db9239bee1ea..05c51d60b64f64602e01af9709520dd2ddae1901 100644 (file)
@@ -23,7 +23,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: chanfix.cc,v 1.13 2007/08/28 16:10:22 dan_karrels Exp $
+ * $Id: chanfix.cc,v 1.14 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #include       <csignal>
@@ -62,7 +62,7 @@
 #include       <boost/thread/thread.hpp>
 #endif /* CHANFIX_HAVE_BOOST_THREAD */
 
-RCSTAG("$Id: chanfix.cc,v 1.13 2007/08/28 16:10:22 dan_karrels Exp $");
+RCSTAG("$Id: chanfix.cc,v 1.14 2008/01/16 02:03:39 buzlip01 Exp $");
 
 namespace gnuworld
 {
@@ -342,6 +342,9 @@ RegisterCommand(new WHOISCommand(this, "WHOIS",
        sqlcfUser::F_LOGGEDIN
        ));
 
+/* Our global DB handler */
+localDBHandle = theManager->getConnection(); 
+
 /* Set our current day. */
 setCurrentDay();
 
@@ -731,7 +734,7 @@ if (requiredFlags) {
 
 if (theUser) {
   theUser->setLastSeen(currentTime());
-  theUser->commit();
+  theUser->commit(localDBHandle);
 }
 
 commHandler->second->Exec(theClient, theUser ? theUser : NULL, Message);
@@ -890,7 +893,7 @@ bool chanfix::logLastComMessage(iClient* theClient, const std::string& Message)
   const std::string Command = string_upper(st[0]);
 
   std::string log;
-  dbHandle* cacheCon = theManager->getConnection();
+  dbHandle* cacheCon = getLocalDBHandle();
 
   static const char *Main = "INSERT into comlog (ts,user_name,command) VALUES (now()::abstime::int4,'";
 
@@ -911,13 +914,13 @@ bool chanfix::logLastComMessage(iClient* theClient, const std::string& Message)
   insertString << "')"
                << std::ends;
 
-  if (!cacheCon->Exec(insertString)) {
+  if (!cacheCon->Exec(insertString.str())) {
     elog << "sqlChannel::Insert> Something went wrong: "
         << cacheCon->ErrorMessage()
         << std::endl;
   }
 
-  theManager->removeConnection(cacheCon);
+  //theManager->removeConnection(cacheCon);
 
   return true;
 }
@@ -1259,19 +1262,19 @@ void chanfix::precacheChanOps()
 elog << "*** [chanfix::precacheChanOps] Precaching chanops." << std::endl;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = theManager->getConnection();
+//dbHandle* cacheCon = theManager->getConnection();
 
 /* Check for the backup table. If it exists, something went wrong. */
 /* SELECT count(*) FROM pg_tables WHERE tablename = 'chanOpsBackup' */
 /* SELECT chanOpsBackup FROM information_schema.tables */
-if (!cacheCon->Exec("SELECT count(*) FROM pg_tables WHERE tablename = 'chanOpsBackup'",true)) {
+if (!localDBHandle->Exec("SELECT count(*) FROM pg_tables WHERE tablename = 'chanOpsBackup'",true)) {
   elog << "*** [chanfix::precacheChanOps]: Error checking for backup table presence: " 
-               << cacheCon->ErrorMessage()
+               << localDBHandle->ErrorMessage()
                << std::endl;
   return;
 }
 
-if (cacheCon->Tuples() && atoi(cacheCon->GetValue(0, 0))) {
+if (localDBHandle->Tuples() && atoi(localDBHandle->GetValue(0, 0))) {
   elog << "*** [chanfix::precacheChanOps]: Backup table still exists! "
        << "Something must have gone wrong on the last update. Exiting..."
        << std::endl;
@@ -1286,12 +1289,12 @@ theQuery        << "SELECT channel,account,last_seen_as,ts_firstopped,ts_lastopped,day0
 elog           << "*** [chanfix::precacheChanOps]: Loading chanOps and their points ..." 
                << std::endl;
 
-if (cacheCon->Exec(theQuery,true)) {
-  for (unsigned int i = 0 ; i < cacheCon->Tuples(); i++) {
+if (localDBHandle->Exec(theQuery.str(),true)) {
+  for (unsigned int i = 0 ; i < localDBHandle->Tuples(); i++) {
      sqlChanOp* newOp = new (std::nothrow) sqlChanOp(theManager);
      assert( newOp != 0 ) ;
 
-     newOp->setAllMembers(cacheCon, i);
+     newOp->setAllMembers(localDBHandle, i);
      sqlChanOpsType::iterator ptr = sqlChanOps.find(newOp->getChannel());
      if (ptr != sqlChanOps.end()) {
        ptr->second.insert(sqlChanOpsType::mapped_type::value_type(newOp->getAccount(),newOp));
@@ -1303,7 +1306,7 @@ if (cacheCon->Exec(theQuery,true)) {
   }
 } else {
   elog << "*** [chanfix::precacheChanOps] Error executing query: "
-       << cacheCon->ErrorMessage()
+       << localDBHandle->ErrorMessage()
        << std::endl;
   ::exit(0);
 }
@@ -1315,7 +1318,7 @@ elog      << "*** [chanfix::precacheChanOps]: Done. Loaded "
        << std::endl;
 
 /* Dispose of our connection instance */
-theManager->removeConnection(cacheCon);
+//theManager->removeConnection(cacheCon);
 
 return;
 }
@@ -1325,7 +1328,7 @@ void chanfix::precacheChannels()
 elog << "*** [chanfix::precacheChannels] Precaching channels." << std::endl;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = theManager->getConnection();
+dbHandle* cacheCon = localDBHandle;
 
 /* Retrieve the list of channels */
 std::stringstream theQuery;
@@ -1335,7 +1338,7 @@ theQuery  << "SELECT id, channel, flags FROM channels"
 elog           << "*** [chanfix::precacheChannels]: Loading channels ..."
                << std::endl;
 
-if (cacheCon->Exec(theQuery,true)) {
+if (cacheCon->Exec(theQuery.str(),true)) {
   for (unsigned int i = 0; i < cacheCon->Tuples(); i++) {
      sqlChannel* newChan = new (std::nothrow) sqlChannel(theManager);
      assert( newChan != 0 ) ;
@@ -1356,7 +1359,7 @@ elog      << "*** [chanfix::precacheChannels]: Done. Loaded "
        << std::endl;
 
 /* Dispose of our connection instance */
-theManager->removeConnection(cacheCon);
+//theManager->removeConnection(cacheCon);
 
 return;
 }
@@ -1366,15 +1369,23 @@ void chanfix::precacheUsers()
 elog << "*** [chanfix::precacheUsers] Precaching users." << std::endl;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = theManager->getConnection();
+dbHandle* cacheCon = localDBHandle;
+
+if (!cacheCon)
+         elog  << "*** [chanfix::precacheUsers]: Error getting a new SQL connection through the manager."
+                << std::endl;
 
 /* Retrieve the list of chanops */
-std::stringstream theQuery;
-theQuery       << "SELECT id, user_name, created, last_seen, last_updated, last_updated_by, language_id, faction, flags, issuspended, usenotice, needoper "
+std::stringstream myQuery;
+
+
+myQuery        << "SELECT id, user_name, created, last_seen, last_updated, last_updated_by, language_id, faction, flags, issuspended, usenotice, needoper "
                << "FROM users"
                ;
 
-if (cacheCon->Exec(theQuery,true)) {
+
+if (cacheCon->Exec(myQuery.str(),true)) {
+
   /* First we need to clear the current cache. */
   for (usersMapType::iterator itr = usersMap.begin();
        itr != usersMap.end(); ++itr) {
@@ -1389,6 +1400,8 @@ if (cacheCon->Exec(theQuery,true)) {
     newUser->setAllMembers(cacheCon, i);
     usersMap.insert(usersMapType::value_type(newUser->getUserName(), newUser));
   }
+
+
 } else {
   elog << "*** [chanfix::precacheUsers] Error executing query: "
     << cacheCon->ErrorMessage()
@@ -1399,7 +1412,8 @@ if (cacheCon->Exec(theQuery,true)) {
 /* Load up the host cache */
 for (usersMapType::iterator itr = usersMap.begin();
      itr != usersMap.end(); ++itr) {
-  itr->second->loadHostList();
+  itr->second->loadHostList(cacheCon);
+
 }
        
 elog   << "chanfix::precacheUsers> Loaded "
@@ -1408,7 +1422,7 @@ elog      << "chanfix::precacheUsers> Loaded "
        << std::endl;
 
 /* Dispose of our connection instance */
-theManager->removeConnection(cacheCon);
+//theManager->removeConnection(cacheCon);
 
 return;
 }
@@ -1576,7 +1590,7 @@ return countMyOps(theChan->getName());
 const std::string chanfix::getHostList( sqlcfUser* User)
 {
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = theManager->getConnection();
+dbHandle* cacheCon = localDBHandle;
 
 /* Grab the user's host list */
 static const char* queryHeader
@@ -1587,7 +1601,7 @@ theQuery  << queryHeader
                << User->getID()
                ;
 
-if (!cacheCon->Exec(theQuery,true)) {
+if (!cacheCon->Exec(theQuery.str(),true)) {
   elog << "chanfix::getHostList> SQL Error: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -1606,7 +1620,7 @@ for (unsigned int i = 0 ; i < cacheCon->Tuples(); i++)
 if (hostlist.str() == "") hostlist << "None.";
 
 /* Dispose of our connection instance */
-theManager->removeConnection(cacheCon);
+//theManager->removeConnection(cacheCon);
 
 return hostlist.str();
 }
@@ -1785,7 +1799,7 @@ return;
 const int chanfix::getLastFix(sqlChannel* theChan)
 {
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = theManager->getConnection();
+dbHandle* cacheCon = localDBHandle;
 
 /* Grab the user's host list */
 static const char* queryHeader
@@ -1796,7 +1810,7 @@ theQuery  << queryHeader
                << theChan->getID()
                ;
 
-if (!cacheCon->Exec(theQuery,true)) {
+if (!cacheCon->Exec(theQuery.str(),true)) {
   elog << "chanfix::getHostList> SQL Error: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -1821,7 +1835,7 @@ for (unsigned int i = 0 ; i < cacheCon->Tuples(); i++)
 }
 
 /* Dispose of our connection instance */
-theManager->removeConnection(cacheCon);
+//theManager->removeConnection(cacheCon);
 
 return max_ts;
 }
@@ -2560,7 +2574,7 @@ return newChannelRecord(theChan->getName());
 
 bool chanfix::deleteChannelRecord(sqlChannel* sqlChan)
 {
-if (sqlChan->useSQL() && sqlChan->Delete())
+if (sqlChan->useSQL() && sqlChan->Delete(localDBHandle))
   return false;
 sqlChanCache.erase(sqlChan->getChannel());
 delete sqlChan; sqlChan = 0;
@@ -2928,7 +2942,7 @@ void chanfix::updateDB()
   updateDBTimer.Start();
 
   /* Get a connection instance to our backend */
-  dbHandle* cacheCon = theManager->getConnection();
+  dbHandle* cacheCon = localDBHandle;
 
   /* Check for the backup table. If it exists, something went wrong. */
   /* SELECT count(*) FROM pg_tables WHERE tablename = 'chanOpsBackup' */
@@ -2967,9 +2981,10 @@ void chanfix::updateDB()
   }
 
   /* Copy the current chanOps to SQL. */
-  if( !cacheCon->StartCopyIn("COPY chanOps FROM stdin") )
+  if( !cacheCon->Exec("COPY chanOps FROM stdin") )
    { 
     elog       << "*** [chanfix::updateDB]: Error starting copy of chanOps table."
+               << cacheCon->ErrorMessage()
                << std::endl;
     return;
   }
@@ -3051,7 +3066,7 @@ void chanfix::updateDB()
   }
 
   /* Dispose of our connection instance */
-  theManager->removeConnection(cacheCon);
+  //theManager->removeConnection(cacheCon);
 
   /* Clean-up after ourselves and allow new updates to be started */
   snapShot.clear();
@@ -3328,19 +3343,18 @@ return std::string("");
 void chanfix::loadHelpTable()
 {
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = theManager->getConnection();
+//dbHandle* cacheCon = theManager->getConnection();
 
 /* Grab the help table */
 std::stringstream theQuery;
 theQuery       << "SELECT language_id,topic,contents FROM help"
                ;
-
-if (cacheCon->Exec(theQuery,true))
-  for (unsigned int i = 0; i < cacheCon->Tuples(); i++)
+if (localDBHandle->Exec("SELECT language_id,topic,contents FROM help",true))
+  for (unsigned int i = 0; i < localDBHandle->Tuples(); i++)
     helpTable.insert(helpTableType::value_type(
-                    std::make_pair(atoi(cacheCon->GetValue(i, 0)),
-                                   cacheCon->GetValue(i, 1)),
-                    cacheCon->GetValue(i, 2)));
+                    std::make_pair(atoi(localDBHandle->GetValue(i, 0)),
+                                   localDBHandle->GetValue(i, 1)),
+                    localDBHandle->GetValue(i, 2)));
 
 elog   << "*** [chanfix::loadHelpTable]: Loaded "
        << helpTable.size()
@@ -3348,7 +3362,7 @@ elog      << "*** [chanfix::loadHelpTable]: Loaded "
        << std::endl;
 
 /* Dispose of our connection instance */
-theManager->removeConnection(cacheCon);
+//theManager->removeConnection(cacheCon);
 
 return;
 }
@@ -3402,7 +3416,7 @@ std::stringstream langQuery;
 langQuery      << "SELECT id,code,name FROM languages"
                ;
 
-if (cacheCon->Exec(langQuery,true))
+if (cacheCon->Exec(langQuery.str(),true))
   for (unsigned int i = 0; i < cacheCon->Tuples(); i++)
     languageTable.insert(languageTableType::value_type(cacheCon->GetValue(i, 1),
                         std::make_pair(atoi(cacheCon->GetValue(i, 0)),
@@ -3418,7 +3432,7 @@ std::stringstream transQuery;
 transQuery     << "SELECT language_id,response_id,text FROM translations"
                ;
 
-if (cacheCon->Exec(transQuery,true)) {
+if (cacheCon->Exec(transQuery.str(),true)) {
   for (unsigned int i = 0 ; i < cacheCon->Tuples(); i++) {
     /*
      *  Add to our translations table.
index feb7ffea9a57611697272ea012d8c560247a6b66..fdabd88f4b9a85ebd5bac86509d9d89592a3993c 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
  * USA.
  *
- * $Id: chanfix.h,v 1.8 2007/08/28 16:10:22 dan_karrels Exp $
+ * $Id: chanfix.h,v 1.9 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #ifndef __CHANFIX_H
-#define __CHANFIX_H "$Id: chanfix.h,v 1.8 2007/08/28 16:10:22 dan_karrels Exp $"
+#define __CHANFIX_H "$Id: chanfix.h,v 1.9 2008/01/16 02:03:39 buzlip01 Exp $"
 
 #include       <string>
 #include       <vector>
 #include       <map>
 #include       <list>
+#include       <sstream>
 
 #include       "client.h"
 #include       "EConfig.h"
@@ -197,6 +198,8 @@ public:
        sqlChanOp* findChanOp(const std::string&, const std::string&);
        sqlChanOp* findChanOp(Channel*, iClient*);
 
+       dbHandle* getLocalDBHandle() { return localDBHandle; }
+
        size_t countMyOps(const std::string&);
        size_t countMyOps(Channel*);
 
@@ -513,6 +516,12 @@ protected:
        std::ofstream   adminLog;
        std::ofstream   debugLog;
 
+       /**
+        * DB Handle
+        */
+       dbHandle*       localDBHandle;
+
+
 public:
 
        /*
index 13e0249ee2b4000423d451afcab8ca2fc65d2b25..406ffbd5e9b1fe3fa1df42f98ec14f0f388b84f7 100644 (file)
@@ -18,7 +18,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  * USA.
  *
- * $Id: sqlChannel.cc,v 1.5 2007/08/28 16:10:25 dan_karrels Exp $
+ * $Id: sqlChannel.cc,v 1.6 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #include       <sstream>
@@ -82,10 +82,10 @@ void sqlChannel::setAllMembers(dbHandle* theDB, int row)
 /**
  * This function inserts a brand new channel into the DB.
  */
-bool sqlChannel::Insert()
+bool sqlChannel::Insert(dbHandle* cacheCon)
 {
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Grab the next available user id */
 id = ++maxUserId;
@@ -102,7 +102,7 @@ insertString    << "INSERT INTO channels "
                << ")"
                ;
 
-if (!cacheCon->Exec(insertString)) {
+if (!cacheCon->Exec(insertString.str())) {
   elog << "sqlChannel::Insert> Something went wrong: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -113,17 +113,17 @@ if (!cacheCon->Exec(insertString)) {
 }
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 return inSQL;
 } // sqlChannel::Insert()
 
-bool sqlChannel::Delete()
+bool sqlChannel::Delete(dbHandle* cacheCon)
 {
 bool retval = false;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Create the DELETE statement */
 std::stringstream deleteString;
@@ -131,7 +131,7 @@ deleteString    << "DELETE FROM channels "
                << "WHERE id = '" << id << "'"
                ;
 
-if (!cacheCon->Exec(deleteString)) {
+if (!cacheCon->Exec(deleteString.str())) {
   elog << "sqlChannel::Delete> Something went wrong: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -140,17 +140,17 @@ if (!cacheCon->Exec(deleteString)) {
   retval = true;
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 return retval;
 }
 
-bool sqlChannel::commit()
+bool sqlChannel::commit(dbHandle* cacheCon)
 {
 bool retval = false;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Create the UPDATE statement */
 std::stringstream chanCommit;
@@ -160,7 +160,7 @@ chanCommit  << "UPDATE channels SET "
                << "id = " << id
                ;
 
-if (!cacheCon->Exec(chanCommit)) {
+if (!cacheCon->Exec(chanCommit.str())) {
   elog << "sqlChannel::commit> Something went wrong: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -169,7 +169,7 @@ if (!cacheCon->Exec(chanCommit)) {
   retval = true;
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 return retval;
 }
@@ -179,18 +179,18 @@ return retval;
  * occured in this channel.
  */
 
-void sqlChannel::addNote(unsigned short eventType, iClient* theUser,
+void sqlChannel::addNote(dbHandle* cacheCon, unsigned short eventType, iClient* theUser,
        const std::string& theMessage)
 {
-unsigned int num_notes = countNotes(0);
+unsigned int num_notes = countNotes(cacheCon, 0);
 while (num_notes >= MAXNOTECOUNT) {
-  if (!deleteOldestNote())
+  if (!deleteOldestNote(cacheCon))
     return;
   num_notes--;
 }
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Create the INSERT statement */
 std::stringstream theLog;
@@ -209,24 +209,24 @@ theLog    << "INSERT INTO notes (ts, channelID, user_name, event, message) "
        << "')"
        ;
 
-if (!cacheCon->Exec(theLog)) {
+if (!cacheCon->Exec(theLog.str())) {
   elog << "sqlChannel::addNote> Something went wrong: "
        << cacheCon->ErrorMessage()
        << std::endl;
 }
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 return;
 }
 
-const std::string sqlChannel::getLastNote(unsigned short eventType, time_t& eventTime)
+const std::string sqlChannel::getLastNote(dbHandle* cacheCon, unsigned short eventType, time_t& eventTime)
 {
 std::string retval;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Retrieve the last note */
 std::stringstream queryString;
@@ -238,7 +238,7 @@ queryString << "SELECT message,ts"
                << " ORDER BY ts DESC LIMIT 1"
                ;
 
-if (cacheCon->Exec(queryString,true)) {
+if (cacheCon->Exec(queryString.str(),true)) {
   if (cacheCon->Tuples() > 0) {
     std::string note = cacheCon->GetValue(0, 0);
     eventTime = atoi(cacheCon->GetValue(0, 1));
@@ -247,17 +247,17 @@ if (cacheCon->Exec(queryString,true)) {
 }
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 return retval;
 }
 
-bool sqlChannel::deleteNote(unsigned int messageId)
+bool sqlChannel::deleteNote(dbHandle* cacheCon, unsigned int messageId)
 {
 bool retval = false;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Create the DELETE statement */
 std::stringstream deleteString;
@@ -267,7 +267,7 @@ deleteString        << "DELETE FROM notes WHERE channelID = "
                << messageId
                ;
 
-if (!cacheCon->Exec(deleteString)) {
+if (!cacheCon->Exec(deleteString.str())) {
   elog << "sqlChannel::deleteNote> Something went wrong: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -276,17 +276,17 @@ if (!cacheCon->Exec(deleteString)) {
   retval = true;
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 return retval;
 }
 
-bool sqlChannel::deleteOldestNote()
+bool sqlChannel::deleteOldestNote(dbHandle* cacheCon)
 {
 bool retval = false;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Retrieve the id of the oldest note */
 std::stringstream selectString;
@@ -295,7 +295,7 @@ selectString        << "SELECT id FROM notes WHERE channelID = "
                << " ORDER BY ts ASC LIMIT 1"
                ;
 
-if (cacheCon->Exec(selectString,true)) {
+if (cacheCon->Exec(selectString.str(),true)) {
   if (cacheCon->Tuples() > 0) {
     unsigned int note_id = atoi(cacheCon->GetValue(0, 0));
 
@@ -304,23 +304,23 @@ if (cacheCon->Exec(selectString,true)) {
                        << note_id
                        ;
 
-    if (cacheCon->Exec(deleteString,true))
+    if (cacheCon->Exec(deleteString.str(),true))
       retval = true;
   }
 }
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 return retval;
 }
 
-bool sqlChannel::deleteAllNotes()
+bool sqlChannel::deleteAllNotes(dbHandle* cacheCon)
 {
 bool retval = false;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Create the DELETE statement */
 std::stringstream deleteString;
@@ -328,7 +328,7 @@ deleteString        << "DELETE FROM notes WHERE channelID = "
                << id
                ;
 
-if (!cacheCon->Exec(deleteString)) {
+if (!cacheCon->Exec(deleteString.str())) {
   elog << "sqlChannel::deleteAllNotes> Something went wrong: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -337,15 +337,15 @@ if (!cacheCon->Exec(deleteString)) {
   retval = true;
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 return retval;
 }
 
-size_t sqlChannel::countNotes(unsigned short eventType)
+size_t sqlChannel::countNotes(dbHandle* cacheCon, unsigned short eventType)
 {
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Count the notes */
 std::stringstream queryString;
@@ -360,11 +360,11 @@ queryString       << " AND event = "
 
 size_t num_notes = 0;
 
-if (cacheCon->Exec(queryString,true))
+if (cacheCon->Exec(queryString.str(),true))
   num_notes = atoi(cacheCon->GetValue(0, 0));
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 return num_notes;
 }
index 0090c2d81807ecb50e0fb9228562fe1e7648cec4..5b9a75148e96667d640f1a1c9d51ebc33ee171b5 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  * USA.
  *
- * $Id: sqlChannel.h,v 1.6 2007/08/28 16:10:25 dan_karrels Exp $
+ * $Id: sqlChannel.h,v 1.7 2008/01/16 02:03:39 buzlip01 Exp $
  */
 
 #ifndef __SQLCHANNEL_H
-#define __SQLCHANNEL_H "$Id: sqlChannel.h,v 1.6 2007/08/28 16:10:25 dan_karrels Exp $"
+#define __SQLCHANNEL_H "$Id: sqlChannel.h,v 1.7 2008/01/16 02:03:39 buzlip01 Exp $"
 
 #include       <string>
 #include       <ctime>
@@ -163,20 +163,20 @@ public:
        inline void     setUseSQL(bool _inSQL)
                { inSQL = _inSQL; }
 
-       bool Insert();
-       bool Delete();
-       bool commit();
+       bool Insert(dbHandle*);
+       bool Delete(dbHandle*);
+       bool commit(dbHandle*);
        void setAllMembers(dbHandle*, int);
 
        /** Static member for keeping track of max user id */
        static unsigned long int maxUserId;
 
-       void addNote(unsigned short, iClient*, const std::string&);
-       bool deleteNote(unsigned int);
-       bool deleteOldestNote();
-       bool deleteAllNotes();
-       size_t countNotes(unsigned short);
-       const std::string getLastNote(unsigned short, time_t&);
+       void addNote(dbHandle*, unsigned short, iClient*, const std::string&);
+       bool deleteNote(dbHandle*, unsigned int);
+       bool deleteOldestNote(dbHandle*);
+       bool deleteAllNotes(dbHandle*);
+       size_t countNotes(dbHandle*, unsigned short);
+       const std::string getLastNote(dbHandle*, unsigned short, time_t&);
 
 protected:
 
index 7f792b7bc8dc6e2478856f9a8a0c21a978031471..9437c34f91c46e9f7daf02c7ecf32aba7f928428 100644 (file)
@@ -16,7 +16,7 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  * USA.
  *
- * $Id: sqlcfUser.cc,v 1.3 2007/08/28 16:10:25 dan_karrels Exp $
+ * $Id: sqlcfUser.cc,v 1.4 2008/01/16 02:03:40 buzlip01 Exp $
  */
 
 #include       <sstream>
 #include       "chanfix.h"
 #include       "sqlcfUser.h"
 
+using namespace std;
+
 namespace gnuworld
 {
 
+using std::stringstream;
+using std::string;
+
 namespace cf
 {
 
@@ -82,12 +87,12 @@ void sqlcfUser::setAllMembers(dbHandle* theDB, int row)
   if (id > maxUserId) maxUserId = id;
 }
 
-bool sqlcfUser::commit()
+bool sqlcfUser::commit(dbHandle* cacheCon)
 {
 bool retval = false;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Create the UPDATE statement */
 std::stringstream userCommit;
@@ -105,7 +110,7 @@ userCommit  << "UPDATE users SET "
                << "id = " << id
                ;
 
-if (!cacheCon->Exec(userCommit)) {
+if (!cacheCon->Exec(userCommit.str())) {
   elog << "sqlcfUser::commit> Something went wrong: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -114,7 +119,7 @@ if (!cacheCon->Exec(userCommit)) {
   retval = true;
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 return retval;
 }
@@ -126,12 +131,12 @@ return retval;
  * so that any new fields added will automatically be dealt with in commit()
  * instead of in 50 different functions.
  */
-bool sqlcfUser::Insert()
+bool sqlcfUser::Insert(dbHandle* cacheCon)
 {
 bool retval = false;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Grab the next available user id */
 id = ++maxUserId;
@@ -147,7 +152,7 @@ insertString        << "INSERT INTO users "
                << ")"
                ;
 
-if (!cacheCon->Exec(insertString)) {
+if (!cacheCon->Exec(insertString.str())) {
   elog << "sqlcfUser::Insert> Something went wrong: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -157,20 +162,20 @@ if (!cacheCon->Exec(insertString)) {
   retval = true;
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 if (retval)
-  commit();
+  commit(cacheCon);
 
 return retval;
 } // sqlcfUser::Insert()
 
-bool sqlcfUser::Delete()
+bool sqlcfUser::Delete(dbHandle* cacheCon)
 {
 bool retval = false;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Create the DELETE statement */
 std::stringstream hostString;
@@ -178,7 +183,7 @@ hostString  << "DELETE FROM hosts "
                << "WHERE user_id = " << id
                ;
 
-if (!cacheCon->Exec(hostString)) {
+if (!cacheCon->Exec(hostString.str())) {
   elog << "sqlcfUser::Delete> Something went wrong: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -192,7 +197,7 @@ deleteString        << "DELETE FROM users "
                << "WHERE id = '" << id << "'"
                ;
 
-if (!cacheCon->Exec(deleteString)) {
+if (!cacheCon->Exec(deleteString.str())) {
   elog << "sqlcfUser::Delete> Something went wrong: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -201,23 +206,29 @@ if (!cacheCon->Exec(deleteString)) {
   retval = true;
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 return retval;
 }
 
-void sqlcfUser::loadHostList()
+void sqlcfUser::loadHostList(dbHandle* cacheCon)
 {
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+
+// dbHandle* cacheCon = myManager->getConnection();
+// if (!cacheCon)
+//     elog << "[sqlcfUser::loadHostList() Could not get a connection to the database from the manager." << std::endl;
+
 
 /* Retrieve the hosts */
 std::stringstream theQuery;
+
 theQuery       << "SELECT host FROM hosts WHERE user_id = "
                << id
-               ;
+               << ends ;
 
-if (cacheCon->Exec(theQuery,true)) {
+
+if (cacheCon->Exec(theQuery.str(),true)) {
   // SQL Query succeeded
   for (unsigned int i = 0 ; i < cacheCon->Tuples(); i++) {
     hostList.push_back(cacheCon->GetValue(i, 0));
@@ -225,17 +236,16 @@ if (cacheCon->Exec(theQuery,true)) {
 }
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
-
+// myManager->removeConnection(cacheCon);
 return; 
 }
 
-bool sqlcfUser::addHost(const std::string& _theHost)
+bool sqlcfUser::addHost(dbHandle* cacheCon, const std::string& _theHost)
 {
 bool retval = false;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Create the INSERT statement */
 std::stringstream insertString;
@@ -248,7 +258,7 @@ insertString    << "INSERT INTO hosts "
                 << "')"
                 ;
 
-if (!cacheCon->Exec(insertString)) {
+if (!cacheCon->Exec(insertString.str())) {
   elog << "sqlcfUser::addHost> Something went wrong: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -257,19 +267,19 @@ if (!cacheCon->Exec(insertString)) {
   retval = true;
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 hostList.push_back(_theHost);
 
 return retval;
 }
 
-bool sqlcfUser::delHost(const std::string& _theHost)
+bool sqlcfUser::delHost(dbHandle* cacheCon, const std::string& _theHost)
 {
 bool retval = false;
 
 /* Get a connection instance to our backend */
-dbHandle* cacheCon = myManager->getConnection();
+//dbHandle* cacheCon = myManager->getConnection();
 
 /* Create the DELETE statement */
 std::stringstream deleteString;
@@ -281,7 +291,7 @@ deleteString        << "DELETE FROM hosts "
                << "'"
                ;
 
-if (!cacheCon->Exec(deleteString)) {
+if (!cacheCon->Exec(deleteString.str())) {
   elog << "sqlcfUser::delHost> Something went wrong: "
        << cacheCon->ErrorMessage()
        << std::endl;
@@ -290,7 +300,7 @@ if (!cacheCon->Exec(deleteString)) {
   retval = true;
 
 /* Dispose of our connection instance */
-myManager->removeConnection(cacheCon);
+//myManager->removeConnection(cacheCon);
 
 if (hostList.size() < 1) return false;
 hostListType::iterator ptr = find( hostList.begin(), hostList.end(), string_lower(_theHost) );
index ad5cbd4504734d189934fe43ee3de634929f21de..25f720f8996f42f33d7df2f042e22d2d8f8d73c7 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  * USA.
  *
- * $Id: sqlcfUser.h,v 1.3 2007/08/28 16:10:25 dan_karrels Exp $
+ * $Id: sqlcfUser.h,v 1.4 2008/01/16 02:03:40 buzlip01 Exp $
  */
 
 #ifndef __sqlcfUser_H
-#define __sqlcfUser_H "$Id: sqlcfUser.h,v 1.3 2007/08/28 16:10:25 dan_karrels Exp $"
+#define __sqlcfUser_H "$Id: sqlcfUser.h,v 1.4 2008/01/16 02:03:40 buzlip01 Exp $"
 
 #include       <string>
 #include       <vector>
 #include       <ctime>
+#include       <sstream>
 #include       "dbHandle.h"
 
+using namespace std;
+
 namespace gnuworld
 {
 
@@ -141,16 +144,16 @@ public:
 
        /* Methods to alter our SQL status */
        void setAllMembers(dbHandle*, int);
-       bool commit();
-       bool Insert();
-       bool Delete();
+       bool commit(dbHandle*);
+       bool Insert(dbHandle*);
+       bool Delete(dbHandle*);
 
        /** Static member for keeping track of max user id */
        static unsigned long int maxUserId;
 
-       void loadHostList();
-       bool addHost(const std::string&);               
-       bool delHost(const std::string&);               
+       void loadHostList(dbHandle*);
+       bool addHost(dbHandle*, const std::string&);            
+       bool delHost(dbHandle*, const std::string&);            
        bool matchHost(const std::string&);
        bool hasHost(const std::string&);