You can subscribe to this list here.
2003 |
Jan
(136) |
Feb
(56) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Stephane T. <mb...@us...> - 2003-02-08 00:06:11
|
Update of /cvsroot/craw/Craw/Sources/Core In directory sc8-pr-cvs1:/tmp/cvs-serv10541 Added Files: CrawIRCBotEvents.cpp CrawIRCBotEvents.h Log Message: These files handle core bots events. --- NEW FILE: CrawIRCBotEvents.cpp --- /* CrawIRCBotEvents.cpp * * Copyright (C) 2003 Stephane Thiell <mb...@bu...> * This file is part of Craw. * * Craw 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. * * Craw 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. * * $Id: CrawIRCBotEvents.cpp,v 1.1 2003/02/08 00:06:08 mbuna Exp $ */ #include "CrawIRCBotEvents.h" #include "CrawCoreService.h" CrawIRCBotEvents::CrawIRCBotEvents( CrawCoreService *inCoreService, CrawCoreBot* inCoreBot) : mCoreService( inCoreService ), mCoreBot( inCoreBot ) { } CrawIRCBotEvents::~CrawIRCBotEvents() { } void CrawIRCBotEvents::SendEventConnected(CFStringRef inHostName, CFNumberRef inPortNum) { CFDictionaryRef dict; CFTypeRef keys[] = { CFSTR(kCCHostNameKey), CFSTR(kCCPortKey) }; CFTypeRef values[] = { inHostName, inPortNum }; dict = CFDictionaryCreate(NULL, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); assert (dict != NULL); mCoreService->EventGenerate(mCoreBot, kCCEventBotConnected, CFTypeRef(dict)); CFRelease(dict); } void CrawIRCBotEvents::SendEventNotice( CFStringRef inSource, CFStringRef inMessage) { CFDictionaryRef dict; CFTypeRef keys[] = { CFSTR(kCCSourceKey), CFSTR(kCCMessageKey) }; CFTypeRef values[] = { inSource, inMessage }; dict = CFDictionaryCreate(NULL, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); mCoreService->EventGenerate(mCoreBot, kCCEventBotNotice, CFTypeRef(dict)); CFRelease(dict); } void CrawIRCBotEvents::SendEventPrivmsg( CFStringRef inSource, CFStringRef inMessage) { CFDictionaryRef dict; CFTypeRef keys[] = { CFSTR(kCCSourceKey), CFSTR(kCCMessageKey) }; CFTypeRef values[] = { inSource, inMessage }; dict = CFDictionaryCreate(NULL, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); mCoreService->EventGenerate(mCoreBot, kCCEventBotPrivmsg, CFTypeRef(dict)); CFRelease(dict); } void CrawIRCBotEvents::SendEventCTCP( CFStringRef inSource, CFStringRef inMessage) { CFDictionaryRef dict; CFTypeRef keys[] = { CFSTR(kCCSourceKey), CFSTR(kCCMessageKey) }; CFTypeRef values[] = { inSource, inMessage }; dict = CFDictionaryCreate(NULL, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); mCoreService->EventGenerate(mCoreBot, kCCEventBotCTCP, CFTypeRef(dict)); CFRelease(dict); } --- NEW FILE: CrawIRCBotEvents.h --- /* CrawIRCBotEvents.h * * Copyright (C) 2003 Stephane Thiell <mb...@bu...> * This file is part of Craw. * * Craw 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. * * Craw 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. * * $Id: CrawIRCBotEvents.h,v 1.1 2003/02/08 00:06:08 mbuna Exp $ */ #pragma once #include <CoreFoundation/CoreFoundation.h> class CrawCoreService; class CrawCoreBot; // CrawIRCBotEvents - implementation of IRC bot events methods class CrawIRCBotEvents { public: CrawIRCBotEvents(CrawCoreService* inCoreService, CrawCoreBot* inCoreBot); virtual ~CrawIRCBotEvents(); // Core Service Events virtual void SendEventConnected(CFStringRef inHostName, CFNumberRef inPortNum); virtual void SendEventNotice(CFStringRef inSource, CFStringRef inMessage); virtual void SendEventPrivmsg(CFStringRef inSource, CFStringRef inMessage); virtual void SendEventCTCP(CFStringRef inSource, CFStringRef inMessage); CrawCoreService* mCoreService; CrawCoreBot* mCoreBot; }; |
Update of /cvsroot/craw/Craw/Sources/Core In directory sc8-pr-cvs1:/tmp/cvs-serv8831/Sources/Core Modified Files: CCBot.cpp CCChannel.cpp CCModule.cpp CrawCore.cpp CrawCore.h CrawCoreBot.cpp CrawCoreBot.h CrawCoreChannel.cpp CrawCoreChannel.h CrawCoreConfig.cpp CrawCoreConfig.h CrawCoreService.cpp CrawCoreService.h CrawIRCBot.cpp CrawIRCBot.h CrawIRCChannel.cpp CrawIRCChannel.h CrawIRCRunLoop.cpp CrawModule.cpp CrawModule.h CrawSendMsg.cpp Makefile Added Files: CrawCoreNetwork.cpp CrawCoreNetwork.h Log Message: C'est la fete. --- NEW FILE: CrawCoreNetwork.cpp --- /* CrawCoreNetwork.cpp * * Copyright (C) 2003 Stephane Thiell <mb...@bu...> * This file is part of Craw. * * Craw 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. * * Craw 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. * * $Id: CrawCoreNetwork.cpp,v 1.1 2003/02/08 00:01:56 mbuna Exp $ */ #include "CrawCoreNetwork.h" #include "CrawCoreConfig.h" CrawCoreNetwork::CrawCoreNetwork(CrawNetworkConfig* inNetConfig) : mNetConfig( inNetConfig ), mRetCount(1) { // Cache name for performance purpose mName = CFStringRef(CFRetain(mNetConfig->GetName())); } CrawCoreNetwork::~CrawCoreNetwork() { CFRelease(mName); } --- NEW FILE: CrawCoreNetwork.h --- /* CrawCoreNetwork.h * * Copyright (C) 2003 Stephane Thiell <mb...@bu...> * This file is part of Craw. * * Craw 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. * * Craw 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. * * $Id: CrawCoreNetwork.h,v 1.1 2003/02/08 00:01:56 mbuna Exp $ */ #pragma once #include <CoreFoundation/CoreFoundation.h> class CrawNetworkConfig; class CrawCoreNetwork { public: CrawCoreNetwork(CrawNetworkConfig* inNetConfig); virtual ~CrawCoreNetwork(); CFStringRef GetName() const { return mName; } void Release() { mRetCount--; } void Retain() { mRetCount++; } protected: CFStringRef mName; CrawNetworkConfig* mNetConfig; CFIndex mRetCount; }; Index: CCBot.cpp =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CCBot.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CCBot.cpp 30 Jan 2003 22:24:22 -0000 1.2 --- CCBot.cpp 8 Feb 2003 00:01:55 -0000 1.3 *************** *** 19,26 **** #define OpaqueCCBot CrawCoreBot #include "CrawCoreInterface.h" #include "CrawCore.h" ! #include "CrawCoreAbstraction.h" //#include "CrawCoreService.h" #include "CrawCoreConfig.h" --- 19,28 ---- #define OpaqueCCBot CrawCoreBot + #define OpaqueCCChannel CrawCoreChannel + #define OpaqueCCNetwork CrawCoreNetwork #include "CrawCoreInterface.h" #include "CrawCore.h" ! #include "CrawCoreBot.h" //#include "CrawCoreService.h" #include "CrawCoreConfig.h" *************** *** 31,34 **** --- 33,39 ---- CCBotGetBirthName(CCBotRef inBot) { + return inBot->GetBirthName(); + + #if 0 CrawCore *core = CrawCore::sCurrentCore; assert (core != NULL); *************** *** 36,39 **** --- 41,45 ---- // if (core->GetCoreAbstract()->IRCBotExists(int(inBot))) return inBot->GetMyConfig()->GetBirthName(); + #endif } *************** *** 41,45 **** CCBotGetUserName(CCBotRef inBot) { ! return NULL; // Not implemented } --- 47,51 ---- CCBotGetUserName(CCBotRef inBot) { ! return inBot->GetUserName(); } *************** *** 47,89 **** CCBotGetRealName(CCBotRef inBot) { ! return NULL; // Not implemented } ! void CCBotSend(CCBotRef inBot, CFStringRef inTarget, CFStringRef inMessage, bool isNotice, CCSendPriority inPriority) { ! CrawCore *core = CrawCore::sCurrentCore; ! assert (core != NULL); ! if (core->GetCoreAbstract()->IRCBotExists(int(inBot))) ! { ! ! } } ! void CCBotSendMessage(CCBotRef inBot, CFStringRef inTarget, CFStringRef inMessage) { ! CrawCore *core = CrawCore::sCurrentCore; ! assert (core != NULL); ! ! if (core->GetCoreAbstract()->IRCBotExists(int(inBot))) ! { ! ((CrawIRCBot *)inBot)->SendToTargetString(inTarget, inMessage, false, kSendMsgPrioStdMessage); ! } } ! void CCBotSendNotice(CCBotRef inBot, CFStringRef inTarget, CFStringRef inNotice) { ! CrawCore *core = CrawCore::sCurrentCore; ! assert (core != NULL); ! if (core->GetCoreAbstract()->IRCBotExists(int(inBot))) ! { ! ((CrawIRCBot *)inBot)->SendToTargetString(inTarget, inNotice, true, kSendMsgPrioStdMessage); ! } } --- 53,124 ---- CCBotGetRealName(CCBotRef inBot) { ! return inBot->GetRealName(); } ! CCNetworkRef ! CCBotGetNetwork(CCBotRef inBot) ! { ! return inBot->GetNetwork(); ! } ! ! bool CCBotSend(CCBotRef inBot, CFStringRef inTarget, CFStringRef inMessage, bool isNotice, CCSendPriority inPriority) { ! if (inPriority > kSendMsgPrioModuleMax || inPriority < kSendMsgPrioModuleMin) ! return false; ! return inBot->SendToTargetString(inTarget, inMessage, isNotice, inPriority); } ! bool CCBotSendMessage(CCBotRef inBot, CFStringRef inTarget, CFStringRef inMessage) { ! return inBot->SendToTargetString(inTarget, inMessage, false, kSendMsgPrioStdMessage); } ! bool CCBotSendNotice(CCBotRef inBot, CFStringRef inTarget, CFStringRef inNotice) { ! return inBot->SendToTargetString(inTarget, inNotice, true, kSendMsgPrioStdMessage); ! } ! ! bool ! CCBotSendRaw(CCBotRef inBot, CFStringRef inRawMsg, CCSendPriority inPriority) ! { ! if (inPriority > kSendMsgPrioModuleMax || inPriority < kSendMsgPrioModuleMin) ! return false; ! return inBot->SendRaw(inPriority, inRawMsg); ! } ! ! bool ! CCBotCreate(CFStringRef inBirthName, CFStringRef inUserName, CFStringRef inRealName, CCNetworkRef inNet, CCBotRef *newBot) ! { ! return CrawCore::sCurrentCore->BotCreate(inBirthName, inUserName, inRealName, inNet, newBot); ! } ! ! bool ! CCBotDestroy(CCBotRef inBot) ! { ! return CrawCore::sCurrentCore->BotDestroy(inBot); } + void + CCBotSetEnabled(CCBotRef inBot, bool isEnabled) + { + return inBot->SetEnabled(isEnabled); + } + + CFIndex + CCBotGetChannelsCount(CCBotRef inBot) + { + return inBot->GetChannelsCount(); + } + + CFIndex + CCBotRetrieveChannels(CCBotRef inBot, CFIndex inLength, CCChannelRef *oChannels) + { + return inBot->RetrieveChannels(inLength, oChannels); + } Index: CCChannel.cpp =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CCChannel.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CCChannel.cpp 30 Jan 2003 21:56:41 -0000 1.1 --- CCChannel.cpp 8 Feb 2003 00:01:55 -0000 1.2 *************** *** 18,34 **** */ #define OpaqueCCChannel CrawCoreChannel #include "CrawCoreInterface.h" #include "CrawCore.h" ! #include "CrawCoreAbstraction.h" ! //#include "CrawCoreService.h" ! //#include "CrawCoreConfig.h" #include "CrawSendMsg.h" - #include "CrawIRCBot.h" - #include "CrawIRCChannel.h" - // Not thread safe! CFStringRef CCChannelGetName(CCChannelRef inChannel) --- 18,31 ---- */ + #define OpaqueCCBot CrawCoreBot #define OpaqueCCChannel CrawCoreChannel #include "CrawCoreInterface.h" #include "CrawCore.h" ! #include "CrawCoreBot.h" ! #include "CrawCoreChannel.h" #include "CrawSendMsg.h" CFStringRef CCChannelGetName(CCChannelRef inChannel) *************** *** 37,63 **** } CCChannelRef CCChannelGetFromName(CCBotRef inBot, CFStringRef inName) { ! CrawCore *core = CrawCore::sCurrentCore; ! assert (core != NULL); ! ! if (core->GetCoreAbstract()->IRCBotExists(int(inBot))) ! { ! printf("it exists!\n"); ! return ((CrawIRCBot*)inBot)->GetChannelFromName(inName); ! } ! return NULL; } ! void CCChannelSendMessage(CCChannelRef inChannel, CFStringRef inMessage) { ! ((CrawIRCChannel *)inChannel)->SendTo(inMessage, false, kSendMsgPrioStdMessage); } ! void CCChannelSendNotice(CCChannelRef inChannel, CFStringRef inNotice) { ! ((CrawIRCChannel *)inChannel)->SendTo(inNotice, true, kSendMsgPrioStdMessage); } --- 34,76 ---- } + CFStringRef + CCChannelGetKey(CCChannelRef inChannel) + { + return inChannel->GetKey(); + } + CCChannelRef CCChannelGetFromName(CCBotRef inBot, CFStringRef inName) { ! return inBot->GetChannelFromName(inName); } ! bool CCChannelSendMessage(CCChannelRef inChannel, CFStringRef inMessage) { ! return inChannel->SendTo(inMessage, false, kSendMsgPrioStdMessage); } ! bool CCChannelSendNotice(CCChannelRef inChannel, CFStringRef inNotice) { ! return inChannel->SendTo(inNotice, true, kSendMsgPrioStdMessage); ! } ! ! void ! CCChannelSetEnabled(CCChannelRef inChannel, bool isEnabled) ! { ! inChannel->SetEnabled(isEnabled); ! } ! ! bool ! CCChannelAdd(CCBotRef inBot, CFStringRef inName, CFStringRef inKey, CFStringRef inCmdChar, CCChannelRef *newChannel) ! { ! return inBot->AddCoreChannel(inName, inKey, inCmdChar, newChannel); ! } ! ! void ! CCChannelDelete(CCChannelRef inChannel) ! { ! return inChannel->DeleteSelf(); } Index: CCModule.cpp =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CCModule.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CCModule.cpp 30 Jan 2003 21:56:41 -0000 1.1 --- CCModule.cpp 8 Feb 2003 00:01:55 -0000 1.2 *************** *** 72,75 **** --- 72,76 ---- CCModuleLookupSymbolAddress(CCModuleRef inModule, const char *inSymbolName) { + if (!inModule) return NULL; return inModule->LookupAndGetAddressOfSymbol(inSymbolName); } Index: CrawCore.cpp =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CrawCore.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CrawCore.cpp 31 Jan 2003 17:39:29 -0000 1.9 --- CrawCore.cpp 8 Feb 2003 00:01:55 -0000 1.10 *************** *** 25,30 **** #include "CrawCore.h" #include "CrawCoreConfig.h" ! #include "CrawCoreAbstraction.h" ! #include "CrawIRCBot.h" #include "CrawCoreService.h" #include "CrawLoggingFacility.h" --- 25,32 ---- #include "CrawCore.h" #include "CrawCoreConfig.h" ! #include "CrawCoreBot.h" ! #include "CrawCoreNetwork.h" ! //#include "CrawCoreAbstraction.h" ! //#include "CrawIRCBot.h" #include "CrawCoreService.h" #include "CrawLoggingFacility.h" *************** *** 51,55 **** assert (mPulse != NULL); ! mIRCBotsSync = false; mQuitting = false; mService = NULL; --- 53,57 ---- assert (mPulse != NULL); ! mSyncBots = true; mQuitting = false; mService = NULL; *************** *** 145,152 **** } ! mAbstract = new CrawCoreAbstraction(); mService = new CrawCoreService(); mService->Start(); } --- 147,156 ---- } ! // mAbstract = new CrawCoreAbstraction(); mService = new CrawCoreService(); mService->Start(); + + this->Sync(); } *************** *** 159,162 **** --- 163,285 ---- void + CrawCore::Sync() + { + if (mQuitting) + return; + + // Core networks first + for (list<CrawNetworkConfig*>::const_iterator cf = gCoreConfig->mNetworks.begin(); + cf != gCoreConfig->mNetworks.end(); cf++) + { + ccNetMapType::const_iterator found = mNetworks.find((*cf)->GetName()); + if (found == mNetworks.end()) + { + CrawCoreNetwork *ccnet = new CrawCoreNetwork(*cf); + mNetworks.insert(ccNetPairType(ccnet->GetName(), ccnet)); + } + } + + // Then core bots. + for (list<CrawBotConfig*>::const_iterator cf = gCoreConfig->mBots.begin(); + cf != gCoreConfig->mBots.end(); cf++) + { + ccBotMapType::const_iterator found = mBots.find((*cf)->GetBirthName()); + if (found == mBots.end()) + { + CrawCoreBot *ccbot = new CrawCoreBot(this, mService, *cf); + mBots.insert(ccBotPairType(ccbot->GetBirthName(), ccbot)); + } + } + } + + bool + CrawCore::BotCreate( + CFStringRef inBirthName, + CFStringRef inUserName, + CFStringRef inRealName, + CrawCoreNetwork *inNet, + CrawCoreBot **newBot) + { + // If the bot already exists, the creation fails. + ccBotMapType::const_iterator found = mBots.find(inBirthName); + if (found != mBots.end()) + { + *newBot = NULL; + return false; + } + + try + { + CrawBotConfig *cfp; + + // first, we try to add the new bot to the config stuffs + cfp = gCoreConfig->BotCreate(inBirthName, inUserName, inRealName, inNet->GetName()); + + // then, if we're still there, we really create the CCBot + CrawCoreBot *ccbot = new CrawCoreBot(this, mService, cfp); + mBots.insert(ccBotPairType(ccbot->GetBirthName(), ccbot)); + *newBot = ccbot; + } + catch (...) + { + return false; + } + return true; + } + + bool + CrawCore::BotDestroy(CrawCoreBot *inBot) + { + if (inBot == NULL) + return false; // wtf + + ccBotMapType::const_iterator found = mBots.find(inBot->GetBirthName()); + if (found == mBots.end()) + return false; + + + } + + CrawCoreNetwork* + CrawCore::GetNetworkFromName(CFStringRef inNetName) + { + ccNetMapType::const_iterator found = mNetworks.find(inNetName); + if (found == mNetworks.end()) + return NULL; + return found->second; + } + + void + CrawCore::SyncBots() + { + mSyncBots = false; + + for (ccBotMapType::iterator b = mBots.begin(); b != mBots.end(); b++) + b->second->Sync(); + } + + void + CrawCore::DeSync() + { + if (mQuitting) + { + bool running = false; + for (ccBotMapType::iterator b = mBots.begin(); b != mBots.end(); b++) + if (b->second->IsConnected()) + { + running = true; + break; + } + if (!running) + CFRunLoopStop(CFRunLoopGetCurrent()); + } + else + { + mSyncBots = true; + } + } + + /* + void CrawCore::IRCSync() { *************** *** 166,169 **** --- 289,296 ---- return; + #if 1 + + + #else for (list<CrawBotConfig*>::const_iterator cf = gCoreConfig->GetBotsBegin(); cf != gCoreConfig->GetBotsEnd(); cf++) *************** *** 181,186 **** --- 308,315 ---- nextCf:; } + #endif } + void CrawCore::IRCDesync(CrawIRCBot *inDeadBot) *************** *** 199,202 **** --- 328,332 ---- } } + */ void *************** *** 213,216 **** --- 343,357 ---- mDeadLock = lock; + if (mQuitting) + CFRunLoopStop(CFRunLoopGetCurrent()); + + #if 1 + for (ccBotMapType::iterator botp = mBots.begin(); botp != mBots.end(); botp++) + { + mQuitting = true; + botp->second->Terminate(inMessage); + } + + #else for (list<CrawIRCBot*>::iterator botp = mIRCBots.begin(); botp != mIRCBots.end(); botp++) { *************** *** 218,221 **** --- 359,363 ---- (*botp)->Terminate(inMessage); } + #endif if (!mQuitting) *************** *** 241,250 **** CrawCore::PulseTimerCallBack( CFRunLoopTimerRef timer, ! CrawCore * info) { ! if (!info->mIRCBotsSync) ! info->IRCSync(); ! ! info->HandleSignals(); } --- 383,392 ---- CrawCore::PulseTimerCallBack( CFRunLoopTimerRef timer, ! CrawCore * core) { ! if (core->mSyncBots) ! core->SyncBots(); ! ! core->HandleSignals(); } Index: CrawCore.h =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CrawCore.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CrawCore.h 31 Jan 2003 17:39:30 -0000 1.6 --- CrawCore.h 8 Feb 2003 00:01:56 -0000 1.7 *************** *** 19,35 **** #include <CoreFoundation/CoreFoundation.h> - #include <list> #include <mach-o/dyld.h> #include "CrawSignals.h" ! using std::list; - class CrawCoreAbstraction; class CrawCoreService; ! class CrawIRCBot; class CrawCore : public CrawSignals { public: CrawCore(int argc, char **argv); --- 19,42 ---- #include <CoreFoundation/CoreFoundation.h> #include <mach-o/dyld.h> + #include <map> + + #include "CrawCoreComparators.h" #include "CrawSignals.h" ! using std::map; class CrawCoreService; ! class CrawCoreBot; ! class CrawCoreNetwork; class CrawCore : public CrawSignals { + typedef map<CFStringRef const, CrawCoreBot*, CFStringNoCaseComparator> ccBotMapType; + typedef ccBotMapType::value_type ccBotPairType; + typedef map<CFStringRef const, CrawCoreNetwork*, CFStringNoCaseComparator> ccNetMapType; + typedef ccNetMapType::value_type ccNetPairType; + public: CrawCore(int argc, char **argv); *************** *** 39,47 **** void StartEpoch(); void IRCSync(); ! void IRCDesync(CrawIRCBot *inDeadBot); void DynamicReload(); void Exit(CFStringRef inMessage, int lock); ! CrawCoreAbstraction* GetCoreAbstract() { return mAbstract; } CrawCoreService* GetCoreService() { return mService; } --- 46,67 ---- void StartEpoch(); void IRCSync(); ! ! bool BotCreate(CFStringRef inBirthName, ! CFStringRef inUserName, ! CFStringRef inRealName, ! CrawCoreNetwork *inNet, ! CrawCoreBot **newBot); ! ! bool BotDestroy(CrawCoreBot *inBot); ! ! void DeSync(); ! ! CrawCoreNetwork* GetNetworkFromName(CFStringRef inNetName); ! ! // void IRCDesync(CrawIRCBot *inDeadBot); void DynamicReload(); void Exit(CFStringRef inMessage, int lock); ! // CrawCoreAbstraction* GetCoreAbstract() { return mAbstract; } CrawCoreService* GetCoreService() { return mService; } *************** *** 52,68 **** void PrintVersion() const; void PrintUsage() const; ! void HandleSignals(); static void PulseTimerCallBack(CFRunLoopTimerRef timer, ! CrawCore * info); CFRunLoopTimerRef mPulse; ! list<CrawIRCBot*> mIRCBots; ! bool mIRCBotsSync; bool mQuitting; int mDeadLock; ! CrawCoreAbstraction* mAbstract; CrawCoreService* mService; }; --- 72,91 ---- void PrintVersion() const; void PrintUsage() const; ! ! void Sync(); ! void SyncBots(); void HandleSignals(); static void PulseTimerCallBack(CFRunLoopTimerRef timer, ! CrawCore * core); CFRunLoopTimerRef mPulse; ! ccBotMapType mBots; ! ccNetMapType mNetworks; ! bool mSyncBots; bool mQuitting; int mDeadLock; ! // CrawCoreAbstraction* mAbstract; CrawCoreService* mService; }; Index: CrawCoreBot.cpp =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CrawCoreBot.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CrawCoreBot.cpp 31 Jan 2003 13:08:03 -0000 1.1 --- CrawCoreBot.cpp 8 Feb 2003 00:01:56 -0000 1.2 *************** *** 19,32 **** #include "CrawCoreBot.h" ! CrawCoreBot::CrawCoreBot(CrawBotConfig *inBotConfig) ! : mBotConfig( inBotConfig ) { } CrawCoreBot::~CrawCoreBot() { } --- 19,223 ---- #include "CrawCoreBot.h" + #include "CrawCoreChannel.h" + #include "CrawCoreNetwork.h" + #include "CrawCoreConfig.h" + #include "CrawCore.h" + #include "CrawIRCBot.h" + #include "CrawLoggingFacility.h" ! CrawCoreBot::CrawCoreBot( ! CrawCore* inCore, ! CrawCoreService* inCoreService, ! CrawBotConfig* inBotConfig) ! : mCore( inCore ), ! mCoreService( inCoreService ), ! mBotConfig( inBotConfig ), ! mIRCBot( NULL ) { + mName = CFStringRef(CFRetain(mBotConfig->GetBirthName())); // cache + mNetwork = mCore->GetNetworkFromName(mBotConfig->GetNetwork()); + mNetwork->Retain(); + for (chancfMapType::const_iterator cf = mBotConfig->ChanMapBegin(); + cf != mBotConfig->ChanMapEnd(); cf++) + { + CrawCoreChannel *ccch( new CrawCoreChannel(this, cf->second) ); + mChanMap.insert(ccchPairType(ccch->GetName(), ccch)); + } + + if (mBotConfig->IsEnabled()) + mIRCBot = new CrawIRCBot(inCore, inCoreService, this, inBotConfig); } CrawCoreBot::~CrawCoreBot() { + for (ccchMapType::iterator chp = mChanMap.begin(); chp != mChanMap.end(); chp++) + delete chp->second; + mChanMap.clear(); + // delete mIRCBot; + mNetwork->Release(); + CFRelease(mName); + } + + CFStringRef + CrawCoreBot::GetUserName() const + { + return mBotConfig->GetUserName(); + } + + + CFStringRef + CrawCoreBot::GetRealName() const + { + return mBotConfig->GetRealName(); + } + + void + CrawCoreBot::SetEnabled(bool isEnabled) + { + mBotConfig->SetEnabled(isEnabled); + mCore->DeSync(); + } + CFIndex + CrawCoreBot::RetrieveChannels(CFIndex inLength, CrawCoreChannel **oChannels) + { + CFIndex count = 0; + + if (inLength <= 0) + return count; + + for (ccchMapType::iterator i = mChanMap.begin(); i != mChanMap.end() && count < inLength; i++, count++) + oChannels[count] = i->second; + + return count; } + bool + CrawCoreBot::AddCoreChannel( + CFStringRef inName, + CFStringRef inKey, // can be NULL + CFStringRef inCmdChar, + CrawCoreChannel **newChannel) + { + ccchMapType::iterator found = mChanMap.find(inName); + if (found == mChanMap.end()) + { + try + { + CrawChannelConfig *cfp = mBotConfig->AddChannel(inName, inKey, inCmdChar); + + CrawCoreChannel *ccch( new CrawCoreChannel(this, cfp) ); + mChanMap.insert(ccchPairType(ccch->GetName(), ccch)); + *newChannel = ccch; + return true; + } + catch (...) + { + CCLog(CFSTR("Exception raised in CrawCoreBot::CreateCoreChannel %@"), inName); + // Fall through + } + } + *newChannel = NULL; + return false; + } + + void + CrawCoreBot::DeleteCoreChannel(CrawCoreChannel *inChannel) + { + ccchMapType::iterator found = mChanMap.find(inChannel->GetName()); + assert (found != mChanMap.end()); + + + } + + #pragma mark - + + + bool + CrawCoreBot::SendRaw( + CFIndex inPriority, + CFStringRef inRawMsg) + { + if (!mIRCBot) + return false; + + mIRCBot->SendRaw(inPriority, inRawMsg); + return true; + } + + #if 0 + bool + CrawCoreBot::SendToChannel( + CrawCoreChannel* inChannel, + CFStringRef inMessage, + bool isNotice, + CFIndex inPriority) + { + if (!mIRCBot) + return false; + // mIRCBot->SendToChannel(inChannel, inMessage, isNotice, inPriority); + return true; + } + #endif + + bool + CrawCoreBot::SendToTargetString( + CFStringRef inTarget, + CFStringRef inMessage, + bool isNotice, + CFIndex inPriority) + { + if (!mIRCBot) + return false; + mIRCBot->SendToTargetString(inTarget, inMessage, isNotice, inPriority); + return true; + } + + void + CrawCoreBot::Sync() + { + if ((mIRCBot != NULL) ^ mBotConfig->IsEnabled()) + { + if (mIRCBot) + mIRCBot->Terminate(NULL); + else + mIRCBot = new CrawIRCBot(mCore, mCoreService, this, mBotConfig); + } + } + + void + CrawCoreBot::IRCBotDied() + { + mIRCBot = NULL; + mCore->DeSync(); + } + + CrawIRCChannel* + CrawCoreBot::CreateIRCChannel(CFStringRef inChannel) + { + ccchMapType::iterator found = mChanMap.find(inChannel); + if (found == mChanMap.end()) + { + CCLog(CFSTR("CrawCoreBot::CreateIRCChannel: Well, we didn't ask to join this channel (%@), eh?"), inChannel); + return NULL; + } + return found->second->CreateIRCChannel(mIRCBot); + } + + CrawCoreChannel* + CrawCoreBot::GetChannelFromName(CFStringRef inChanName) + { + ccchMapType::iterator found = mChanMap.find(inChanName); + if (found == mChanMap.end()) + return NULL; + return found->second; + } + + + void + CrawCoreBot::Terminate(CFStringRef inMessage) + { + if (mIRCBot) + mIRCBot->Terminate(inMessage); + } Index: CrawCoreBot.h =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CrawCoreBot.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CrawCoreBot.h 31 Jan 2003 13:08:03 -0000 1.1 --- CrawCoreBot.h 8 Feb 2003 00:01:56 -0000 1.2 *************** *** 17,34 **** */ #pragma once class CrawCore; class CrawCoreService; class CrawBotConfig; class CrawCoreBot { public: ! CrawCoreBot(CrawBotConfig* inBotConfig); virtual ~CrawCoreBot(); ! CrawBotConfig* GetMyConfig() const { return mBotConfig; } protected: ! CrawBotConfig * mBotConfig; }; --- 17,101 ---- */ #pragma once + #include <CoreFoundation/CoreFoundation.h> + #include <map> + + #include "CrawCoreComparators.h" + + using std::map; class CrawCore; class CrawCoreService; + class CrawCoreChannel; + class CrawCoreNetwork; class CrawBotConfig; + class CrawIRCBot; + class CrawIRCChannel; + + typedef map<CFStringRef, CrawCoreChannel*, CFStringNoCaseComparator> ccchMapType; + typedef ccchMapType::value_type ccchPairType; class CrawCoreBot { + friend class CrawCoreChannel; + friend class CrawIRCBot; + public: ! CrawCoreBot(CrawCore* inCore, ! CrawCoreService* inCoreService, ! CrawBotConfig* inBotConfig); virtual ~CrawCoreBot(); ! ! bool IsConnected() const { return mIRCBot != NULL; } ! CrawBotConfig* GetMyConfig() const { return mBotConfig; } + CFStringRef GetBirthName() const { return mName; } + CFStringRef GetUserName() const; + CFStringRef GetRealName() const; + + void SetEnabled(bool isEnabled); + + CFIndex GetChannelsCount() const { return mChanMap.size(); } + CFIndex RetrieveChannels(CFIndex inLength, CrawCoreChannel **oChannels); + + bool AddCoreChannel(CFStringRef inName, + CFStringRef inKey, // can be NULL + CFStringRef inCmdChar, + CrawCoreChannel **newChannel); + void DeleteCoreChannel(CrawCoreChannel *inChannel); + + virtual void Terminate(CFStringRef inMessage); + + virtual bool SendRaw(CFIndex inPriority, + CFStringRef inRawMsg); + + #if 0 + virtual bool SendToChannel(CrawCoreChannel* inChannel, + CFStringRef inMessage, + bool isNotice, + CFIndex inPriority); + #endif + + virtual bool SendToTargetString(CFStringRef inTarget, + CFStringRef inMessage, + bool isNotice, + CFIndex inPriority); + + virtual void Sync(); + virtual void IRCBotDied(); + + CrawIRCChannel* CreateIRCChannel(CFStringRef inChannel); + + CrawCoreChannel* GetChannelFromName(CFStringRef inChanName); + + CrawCoreNetwork* GetNetwork() { return mNetwork; } protected: ! CrawCore *mCore; ! CrawCoreService *mCoreService; ! CrawBotConfig *mBotConfig; ! CrawIRCBot *mIRCBot; ! ! CFStringRef mName; ! ccchMapType mChanMap; ! CrawCoreNetwork *mNetwork; }; Index: CrawCoreChannel.cpp =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CrawCoreChannel.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CrawCoreChannel.cpp 31 Jan 2003 13:10:38 -0000 1.1 --- CrawCoreChannel.cpp 8 Feb 2003 00:01:56 -0000 1.2 *************** *** 19,39 **** #include "CrawCoreChannel.h" #include "CrawCoreConfig.h" ! CrawCoreChannel::CrawCoreChannel(CrawChannelConfig *inChannelConfig) ! : mChannelConfig( inChannelConfig ) { ! } CrawCoreChannel::~CrawCoreChannel() { } CFStringRef ! CrawCoreChannel::GetName() const { ! return mChannelConfig->GetName(); } --- 19,102 ---- #include "CrawCoreChannel.h" + #include "CrawCoreBot.h" #include "CrawCoreConfig.h" + #include "CrawLoggingFacility.h" + #include "CrawIRCBot.h" + #include "CrawIRCChannel.h" ! CrawCoreChannel::CrawCoreChannel( ! CrawCoreBot *inCoreBot, ! CrawChannelConfig *inChannelConfig) ! : mCoreBot( inCoreBot ), ! mChannelConfig( inChannelConfig ), ! mIRCChannel( NULL ) { ! mName = CFStringRef(CFRetain(inChannelConfig->GetName())); // for cached accessor ! mEncoding = mChannelConfig->GetEncoding(); ! mEnabled = inChannelConfig->IsEnabled(); // for cached accessor } CrawCoreChannel::~CrawCoreChannel() { + delete mIRCChannel; + CFRelease(mName); + } + void + CrawCoreChannel::DeleteSelf() + { + mCoreBot->DeleteCoreChannel(this); } CFStringRef ! CrawCoreChannel::GetCmdChar() const { ! return mChannelConfig->GetCmdChar(); ! } ! ! CFStringRef ! CrawCoreChannel::GetKey() const ! { ! return mChannelConfig->GetKey(); ! } ! ! void ! CrawCoreChannel::SetEnabled(bool isEnabled) ! { ! mChannelConfig->SetEnabled(isEnabled); ! mEnabled = mChannelConfig->IsEnabled(); ! } ! ! CrawIRCChannel* ! CrawCoreChannel::CreateIRCChannel(CrawIRCBot *inIRCBot) ! { ! if (mIRCChannel != NULL) ! { ! CCLog(CFSTR("CrawCoreChannel::CreateIRCChannel: Already exists (%@), eh?"), mName); ! return NULL; ! } ! return (mIRCChannel = new CrawIRCChannel(mName, inIRCBot, this, mCoreBot->mCoreService)); ! } ! ! void ! CrawCoreChannel::DestroyIRCChannel() ! { ! assert (mIRCChannel != NULL); ! mIRCChannel = NULL; ! } ! ! #pragma mark - ! ! bool ! CrawCoreChannel::SendTo( ! CFStringRef inMessage, ! bool isNotice, ! CFIndex inPriority) ! { ! if (mIRCChannel == NULL) ! return false; ! ! mIRCChannel->SendTo(inMessage, isNotice, inPriority); ! return true; } Index: CrawCoreChannel.h =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CrawCoreChannel.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CrawCoreChannel.h 31 Jan 2003 13:10:38 -0000 1.1 --- CrawCoreChannel.h 8 Feb 2003 00:01:56 -0000 1.2 *************** *** 20,38 **** #include <CoreFoundation/CoreFoundation.h> class CrawChannelConfig; class CrawCoreChannel { public: ! CrawCoreChannel(CrawChannelConfig* inChannelConfig); virtual ~CrawCoreChannel(); ! CFStringRef GetName() const; ! CFStringEncoding GetEncoding() const { return 0; } CrawChannelConfig* GetMyConfig() const { return mChannelConfig; } protected: ! CrawChannelConfig * mChannelConfig; CFStringEncoding mEncoding; }; --- 20,64 ---- #include <CoreFoundation/CoreFoundation.h> + class CrawCoreBot; class CrawChannelConfig; + class CrawIRCBot; + class CrawIRCChannel; class CrawCoreChannel { + friend class CrawIRCChannel; + public: ! CrawCoreChannel(CrawCoreBot *inCoreBot, CrawChannelConfig* inChannelConfig); virtual ~CrawCoreChannel(); ! void DeleteSelf(); ! ! CFStringRef GetName() const { return mName; }; ! ! CFStringEncoding GetEncoding() const { return mEncoding; } ! CFStringRef GetCmdChar() const; ! CFStringRef GetKey() const; CrawChannelConfig* GetMyConfig() const { return mChannelConfig; } + bool IsEnabled() const { return mEnabled; } + void SetEnabled(bool isEnabled); + + CrawIRCChannel* CreateIRCChannel(CrawIRCBot *inIRCBot); + void DestroyIRCChannel(); + + bool SendTo(CFStringRef inMessage, + bool isNotice, + CFIndex inPriority); + protected: ! CrawCoreBot *mCoreBot; ! CrawChannelConfig *mChannelConfig; ! ! CrawIRCChannel *mIRCChannel; ! CFStringEncoding mEncoding; + CFStringRef mName; + bool mEnabled; }; Index: CrawCoreConfig.cpp =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CrawCoreConfig.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CrawCoreConfig.cpp 1 Feb 2003 13:52:41 -0000 1.6 --- CrawCoreConfig.cpp 8 Feb 2003 00:01:56 -0000 1.7 *************** *** 115,118 **** --- 115,123 ---- } + void + CrawBotConfig::SetEnabled(bool isEnabled) + { + mEnabled = isEnabled; + } CrawChannelConfig* *************** *** 123,126 **** --- 128,145 ---- } + CrawChannelConfig* + CrawBotConfig::AddChannel(CFStringRef inName, CFStringRef inKey, CFStringRef inCmdChar) + { + chancfMapType::const_iterator chk = mChannels.find(inName); + if (chk != mChannels.end()) + { + CCLog(CFSTR("CrawBotConfig::AddChannel %@ failed: it already exists!"), inName); + CrawCoreConfigException::Throw(CFSTR("CrawBotConfig::AddChannel")); + } + CrawChannelConfig *chanp = new CrawChannelConfig(inName, inKey, NULL, inCmdChar, kCFBooleanFalse); + mChannels.insert(chancfPairType(chanp->GetName(), chanp)); + return chanp; + } + #pragma mark - *************** *** 174,178 **** CFStringRef inKey, CFNumberRef inEncoding, ! CFStringRef inCmdChar) // for network-specific channels, not supported yet : mName( inName ), mKey( inKey ), --- 193,198 ---- CFStringRef inKey, CFNumberRef inEncoding, ! CFStringRef inCmdChar, ! CFBooleanRef isEnabled) : mName( inName ), mKey( inKey ), *************** *** 180,191 **** { // Channel encoding ! CFNumberGetValue(inEncoding, kCFNumberSInt32Type, &mEncoding); if (!CFStringIsEncodingAvailable(mEncoding)) CrawCoreConfigException::Throw(CFSTR("Bad configuration file: unsupported channel::encoding value")); ! CFShow(mName); CFRetain(mName); CFRetain(mKey); CFRetain(mCmdChar); --- 200,218 ---- { // Channel encoding ! if (inEncoding) ! CFNumberGetValue(inEncoding, kCFNumberSInt32Type, &mEncoding); ! else ! mEncoding = kCFStringEncodingUTF8; if (!CFStringIsEncodingAvailable(mEncoding)) CrawCoreConfigException::Throw(CFSTR("Bad configuration file: unsupported channel::encoding value")); ! if (isEnabled) ! mEnabled = CFBooleanGetValue(isEnabled); ! else ! mEnabled = true; CFRetain(mName); + if (!mKey) mKey = CFSTR(""); CFRetain(mKey); CFRetain(mCmdChar); *************** *** 199,203 **** } ! #pragma mark - --- 226,234 ---- } ! void ! CrawChannelConfig::SetEnabled(bool isEnabled) ! { ! mEnabled = isEnabled; ! } #pragma mark - *************** *** 347,350 **** --- 378,382 ---- CFStringRef chanName, chanKey, chanCmdChar; CFNumberRef chanEncoding; + CFBooleanRef chanEnabled; chanDict = CFDictionaryRef(CFArrayGetValueAtIndex(chanArray, i)); *************** *** 354,364 **** CFVERIFY(chanName, CFString, "Bad configuration file: illegal/missing channels::channel::name"); chanKey = CFStringRef(CFDictionaryGetValue(chanDict, CFSTR("key"))); ! CFVERIFY(chanKey, CFString, "Bad configuration file: illegal/missing channels::channel::key"); chanEncoding = CFNumberRef(CFDictionaryGetValue(chanDict, CFSTR("encoding"))); ! CFVERIFY(chanEncoding, CFNumber, "Bad configuration file: illegal/missing channels::channel::encoding"); chanCmdChar = CFStringRef(CFDictionaryGetValue(chanDict, CFSTR("cmdchar"))); CFVERIFY(chanCmdChar, CFString, "Bad configuration file: illegal/missing channels::channel::cmdchar"); ! ! chanList.push_back(new CrawChannelConfig(chanName, chanKey, chanEncoding, chanCmdChar)); } } --- 386,401 ---- CFVERIFY(chanName, CFString, "Bad configuration file: illegal/missing channels::channel::name"); chanKey = CFStringRef(CFDictionaryGetValue(chanDict, CFSTR("key"))); ! if (chanKey) ! CFVERIFY(chanKey, CFString, "Bad configuration file: illegal channels::channel::key"); chanEncoding = CFNumberRef(CFDictionaryGetValue(chanDict, CFSTR("encoding"))); ! if (chanEncoding) ! CFVERIFY(chanEncoding, CFNumber, "Bad configuration file: illegal/missing channels::channel::encoding"); chanCmdChar = CFStringRef(CFDictionaryGetValue(chanDict, CFSTR("cmdchar"))); CFVERIFY(chanCmdChar, CFString, "Bad configuration file: illegal/missing channels::channel::cmdchar"); ! chanEnabled = CFBooleanRef(CFDictionaryGetValue(chanDict, CFSTR("enabled"))); ! if (chanEnabled) ! CFVERIFY(chanEnabled, CFBoolean, "Bad configuration file, illegal channels::channel::enabled"); ! ! chanList.push_back(new CrawChannelConfig(chanName, chanKey, chanEncoding, chanCmdChar, chanEnabled)); } } *************** *** 443,446 **** --- 480,485 ---- { // TODO :P + + } *************** *** 483,486 **** --- 522,563 ---- } return NULL; + } + + CrawBotConfig* + CrawCoreConfig::BotCreate( + CFStringRef inBirthName, + CFStringRef inUserName, + CFStringRef inRealName, + CFStringRef inNetwork) + { + #if 1 + for (list<CrawBotConfig*>::const_iterator b = mBots.begin(); b != mBots.end(); b++) + { + if (CFStringCompare((*b)->GetBirthName(), inBirthName, kCFCompareCaseInsensitive) == kCFCompareEqualTo) + { + CCLog(CFSTR("CrawCoreConfig::BotCreate %@ failed: bot already exists!"), inBirthName); + CrawCoreConfigException::Throw(CFSTR("CrawCoreConfig::BotCreate")); + /*UNREACHED*/ + } + } + #endif + list<CrawChannelConfig*> noChan; + mBots.push_back(new CrawBotConfig(inBirthName, inUserName, inRealName, inNetwork, noChan, kCFBooleanFalse)); + return mBots.back(); + } + + void + CrawCoreConfig::BotDestroy(CFStringRef inBirthName) + { + for (list<CrawBotConfig*>::iterator b = mBots.begin(); b != mBots.end(); b++) + { + if (CFStringCompare((*b)->GetBirthName(), inBirthName, kCFCompareCaseInsensitive) == kCFCompareEqualTo) + { + delete *b; + mBots.erase(b); + return; + } + } + CrawCoreConfigException::Throw(CFSTR("CrawCoreConfig::BotDestroy (not found)")); } Index: CrawCoreConfig.h =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CrawCoreConfig.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CrawCoreConfig.h 1 Feb 2003 13:52:41 -0000 1.5 --- CrawCoreConfig.h 8 Feb 2003 00:01:56 -0000 1.6 *************** *** 74,78 **** CFStringRef inKey, CFNumberRef inEncoding, ! CFStringRef inCmdChar); ~CrawChannelConfig(); --- 74,79 ---- CFStringRef inKey, CFNumberRef inEncoding, ! CFStringRef inCmdChar, ! CFBooleanRef isEnabled); ~CrawChannelConfig(); *************** *** 81,85 **** --- 82,88 ---- CFStringEncoding GetEncoding() const { return mEncoding; } CFStringRef GetCmdChar() const { return mCmdChar; } + bool IsEnabled() const { return mEnabled; } + void SetEnabled(bool isEnabled); /* void SetName(CFStringRef inName); *************** *** 94,97 **** --- 97,101 ---- CFStringEncoding mEncoding; CFStringRef mCmdChar; + bool mEnabled; }; *************** *** 111,116 **** CFStringRef GetBirthName() const { return mBirthName; } ! CFStringRef GetUsername() const { return mUserName; } ! CFStringRef GetRealname() const { return mRealName; } bool IsEnabled() const { return mEnabled; } CFStringRef GetNetwork() const { return mNetwork; } --- 115,120 ---- CFStringRef GetBirthName() const { return mBirthName; } ! CFStringRef GetUserName() const { return mUserName; } ! CFStringRef GetRealName() const { return mRealName; } bool IsEnabled() const { return mEnabled; } CFStringRef GetNetwork() const { return mNetwork; } *************** *** 119,132 **** CrawChannelConfig* GetChannel(CFStringRef inName); ! // CFArrayRef GetChannels() const { return mChannels; } ! ! /* ! void SetUsername(CFStringRef inUsername); ! void SetRealname(CFStringRef inRealname); ! void SetNetwork(CFStringRef inNetwork); ! void AddChannel(CFStringRef inChannel); ! void SetEnabled(bool isEnabled) { mEnabled = isEnabled; } ! void Close(); ! */ CFIndex IncConnectionCount() { return mConnectionCount++; } --- 123,131 ---- CrawChannelConfig* GetChannel(CFStringRef inName); ! void SetEnabled(bool isEnabled); ! ! CrawChannelConfig* AddChannel(CFStringRef inName, ! CFStringRef inKey, // can be NULL ! CFStringRef inCmdChar); CFIndex IncConnectionCount() { return mConnectionCount++; } *************** *** 191,194 **** --- 190,195 ---- class CrawCoreConfig { + friend class CrawCore; + public: CrawCoreConfig(const char *inFilePath); *************** *** 197,211 **** CFStringRef GetCoreModulePrefsDirectory() const { return CFSTR("modules/prefs"); } // void SetCoreModulePrefsDirectory(const char *text); ! // CrawChannelConfig* FindChannel(CFStringRef inChannel); ! CrawServerConfig* GetServerForNetwork(CFStringRef inNetwork, CFIndex inConnectionCount) const; ! void DisplaySummary() const; ! list<CrawBotConfig*>::const_iterator GetBotsBegin() const { return mBots.begin(); } ! list<CrawBotConfig*>::const_iterator GetBotsEnd() const { return mBots.end(); } const list<CrawCoreModuleConfig*>& GetModules() const { return mModules; } --- 198,215 ---- CFStringRef GetCoreModulePrefsDirectory() const { return CFSTR("modules/prefs"); } // void SetCoreModulePrefsDirectory(const char *text); ! // CrawChannelConfig* FindChannel(CFStringRef inChannel); ! CrawServerConfig* GetServerForNetwork(CFStringRef inNetwork, CFIndex inConnectionCount) const; + CrawBotConfig* BotCreate(CFStringRef inBirthName, + CFStringRef inUserName, + CFStringRef inRealName, + CFStringRef inNetwork); ! void BotDestroy(CFStringRef inBirthName); ! void DisplaySummary() const; const list<CrawCoreModuleConfig*>& GetModules() const { return mModules; } Index: CrawCoreService.cpp =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CrawCoreService.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CrawCoreService.cpp 30 Jan 2003 21:49:09 -0000 1.6 --- CrawCoreService.cpp 8 Feb 2003 00:01:56 -0000 1.7 *************** *** 186,190 **** bool CrawCoreService::EventGenerate( ! CrawIRCBot* inIRCBot, CCEventID inCoreEventID, CFTypeRef inData) --- 186,190 ---- bool CrawCoreService::EventGenerate( ! CrawCoreBot* inBot, CCEventID inCoreEventID, CFTypeRef inData) *************** *** 203,207 **** for (list<CrawModule*>::iterator i = e->second->begin(); i != e->second->end(); i++) { ! if ((*i)->HandleEvent(inIRCBot, inCoreEventID, inData)) --- 203,207 ---- for (list<CrawModule*>::iterator i = e->second->begin(); i != e->second->end(); i++) { ! if ((*i)->HandleEvent(inBot, inCoreEventID, inData)) *************** *** 214,218 **** void CrawCoreService::HandleChannelCommand( ! CrawIRCBot* inIRCBot, CFStringRef inChannel, CFStringRef inSource, --- 214,218 ---- void CrawCoreService::HandleChannelCommand( ! CrawCoreBot* inBot, CFStringRef inChannel, CFStringRef inSource, *************** *** 241,245 **** &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); ! p->second->mModule->HandleEvent(inIRCBot, p->second->mCommandID, CFTypeRef(dict)); --- 241,245 ---- &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); ! p->second->mModule->HandleEvent(inBot, p->second->mCommandID, CFTypeRef(dict)); *************** *** 250,254 **** void CrawCoreService::HandleChannelMessage( ! CrawIRCBot* inIRCBot, CFStringRef inChannel, CFStringRef inSource, --- 250,254 ---- void CrawCoreService::HandleChannelMessage( ! CrawCoreBot* inBot, CFStringRef inChannel, CFStringRef inSource, *************** *** 266,270 **** &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); ! this->EventGenerate(inIRCBot, kCCEventChannelMessage, CFTypeRef(dict)); CFRelease(dict); --- 266,270 ---- &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); ! this->EventGenerate(inBot, kCCEventChannelMessage, CFTypeRef(dict)); CFRelease(dict); Index: CrawCoreService.h =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CrawCoreService.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CrawCoreService.h 30 Jan 2003 21:49:10 -0000 1.4 --- CrawCoreService.h 8 Feb 2003 00:01:56 -0000 1.5 *************** *** 58,62 **** }; ! class CrawIRCBot; class CrawIRCChannel; --- 58,62 ---- }; ! class CrawCoreBot; class CrawIRCChannel; *************** *** 78,82 **** CCEventID inEventID); void EventUnregister(CrawModule * inModule, ! CCEventID inEventID); void UnregisterAllCoreEvents(); --- 78,82 ---- CCEventID inEventID); void EventUnregister(CrawModule * inModule, ! CCEventID inEventID); void UnregisterAllCoreEvents(); *************** *** 90,94 **** void UnregisterAllCommands(); ! void HandleChannelCommand(CrawIRCBot* inIRCBot, CFStringRef inChannel, CFStringRef inSource, --- 90,94 ---- void UnregisterAllCommands(); ! void HandleChannelCommand(CrawCoreBot* inBot, CFStringRef inChannel, CFStringRef inSource, *************** *** 98,102 **** // Privmsg or Notice in channel ! void HandleChannelMessage(CrawIRCBot* inIRCBot, CFStringRef inChannel, CFStringRef inSource, --- 98,102 ---- // Privmsg or Notice in channel ! void HandleChannelMessage(CrawCoreBot* inBot, CFStringRef inChannel, CFStringRef inSource, *************** *** 106,110 **** void Reload(); ! bool EventGenerate(CrawIRCBot* inIRCBot, CCEventID inCoreEventID, CFTypeRef inData); --- 106,110 ---- void Reload(); ! bool EventGenerate(CrawCoreBot* inBot, CCEventID inCoreEventID, CFTypeRef inData); Index: CrawIRCBot.cpp =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CrawIRCBot.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** CrawIRCBot.cpp 1 Feb 2003 13:52:41 -0000 1.14 --- CrawIRCBot.cpp 8 Feb 2003 00:01:56 -0000 1.15 *************** *** 27,31 **** #include "CrawCoreConfig.h" #include "CrawCore.h" ! #include "CrawCoreAbstraction.h" #include "CrawLoggingFacility.h" --- 27,31 ---- #include "CrawCoreConfig.h" #include "CrawCore.h" ! #include "CrawCoreBot.h" #include "CrawLoggingFacility.h" *************** *** 45,55 **** CrawCore* inCore, CrawCoreService* inCoreService, CrawBotConfig* inBotConfig) ! : CrawCoreBot(inBotConfig), ! mCore( inCore ), ! mCoreService( inCoreService ) { ! mServerConfig = gCoreConfig->GetServerForNetwork(mBotConfig->GetNetwork(), ! mBotConfig->IncConnectionCount()); assert (mServerConfig != NULL); --- 45,55 ---- CrawCore* inCore, CrawCoreService* inCoreService, + CrawCoreBot* inCoreBot, CrawBotConfig* inBotConfig) ! : CrawIRCBotEvents( inCoreService, inCoreBot ), ! mCore( inCore ) { ! mServerConfig = gCoreConfig->GetServerForNetwork(inBotConfig->GetNetwork(), ! inBotConfig->IncConnectionCount()); assert (mServerConfig != NULL); *************** *** 68,71 **** --- 68,72 ---- MKPARSEMAP('NICK', CrawIRCBot::ParseNICK); MKPARSEMAP('NOTI', CrawIRCBot::ParseNOTICE); + MKPARSEMAP('PART', CrawIRCBot::ParsePART); MKPARSEMAP('PRIV', CrawIRCBot::ParsePRIVMSG); MKPARSEMAP('RPON', CrawIRCBot::ParseRPONG); *************** *** 80,86 **** { printf("~CrawIRCBot\n"); // TODO: free channels ! mCore->IRCDesync(this); } --- 81,88 ---- { printf("~CrawIRCBot\n"); + mCoreBot->IRCBotDied(); // TODO: free channels ! // mCore->IRCDesync(this); } *************** *** 90,99 **** { // First, generate an pre-authentication event ! this->SendEventConnected(); CFStringRef msg = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s %@ 0 0 :%@\n%s %@\n"), ! kIRCUser, mBotConfig->GetUsername(), mBotConfig->GetRealname(), ! kIRCNick, mBotConfig->GetBirthName()); // TODO: need to know the default encoding - hardcoding UTF-8 here --- 92,111 ---- { // First, generate an pre-authentication event ! CFStringRef hostName = CFStringRef(CFReadStreamCopyProperty(mReadStream, ! kCFStreamPropertySocketRemoteHostName)); ! CFNumberRef portNum = CFNumberRef(CFReadStreamCopyProperty(mReadStream, ! kCFStreamPropertySocketRemotePortNumber)); ! assert (hostName != NULL); ! assert (portNum != NULL); ! ! this->SendEventConnected(hostName, portNum); CFStringRef msg = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s %@ 0 0 :%@\n%s %@\n"), ! kIRCUser, ! mCoreBot->GetMyConfig()->GetUserName(), ! mCoreBot->GetMyConfig()->GetRealName(), ! kIRCNick, ! mCoreBot->GetMyConfig()->GetBirthName()); // TODO: need to know the default encoding - hardcoding UTF-8 here *************** *** 101,104 **** --- 113,118 ---- CFRelease(msg); + CFRelease(portNum); + CFRelease(hostName); } *************** *** 140,143 **** --- 154,166 ---- } + void + CrawIRCBot::SendRaw( + CFIndex inPriority, + CFStringRef inRawMsg) + { + CFStringRef output = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@\n"), inRawMsg); + this->SendQPush(output, kCFStringEncodingUTF8, inPriority); + CFRelease(output); + } void *************** *** 152,163 **** inChannel->GetEncoding(), CFSTR("%@ :%@"), inChannel->GetName(), inMessage); - /* - CFStringRef output = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s %@ :%@\n"), - isNotice ? kIRCNotice : kIRCPrivmsg, - inChannel->GetName(), inMessage); - - this->SendQPush(output, inChannel->GetEncoding(), inPriority); - CFRelease(output); - */ } --- 175,178 ---- *************** *** 359,375 **** CrawIRCBot::SyncChannels() { ! for (chancfMapType::const_iterator cm = mBotConfig->ChanMapBegin(); cm != mBotConfig->ChanMapEnd(); cm++) { chanMapType::iterator p = mChannelMap.find(cm->first); if (p == mChannelMap.end()) { ! CrawChannelConfig *chancf = cm->second; CCLog(CFSTR("SyncChannels> Channel %@ not found!"), cm->first); CFStringRef msg; ! if (chancf->GetKey()) { msg = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s %@ %@\n"), ! kIRCJoin, chancf->GetName(), chancf->GetKey()); } else --- 374,393 ---- CrawIRCBot::SyncChannels() { ! for (ccchMapType::iterator cm = mCoreBot->mChanMap.begin(); cm != mCoreBot->mChanMap.end(); cm++) { + CrawCoreChannel *cch = cm->second; + chanMapType::iterator p = mChannelMap.find(cm->first); if (p == mChannelMap.end()) { ! if (!cch->IsEnabled()) ! continue; CCLog(CFSTR("SyncChannels> Channel %@ not found!"), cm->first); CFStringRef msg; ! if (cch->GetKey()) { msg = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s %@ %@\n"), ! kIRCJoin, cch->GetName(), cch->GetKey()); } else *************** *** 377,387 **** msg = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s %@\n"), ! kIRCJoin, chancf->GetName()); } ! this->SendQPush(msg, chancf->GetEncoding(), kSendMsgPrioStdProtocol); CFRelease(msg); } } ! #if 0 CFArrayRef channels = mBotConfig->GetChannels(); --- 395,416 ---- msg = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s %@\n"), ! kIRCJoin, cch->GetName()); } ! this->SendQPush(msg, cch->GetEncoding(), kSendMsgPrioStdProtocol); CFRelease(msg); } + else + { + if (!cch->IsEnabled()) + { + CFStringRef msg = CFStringCreateWithFormat(NULL, NULL, + CFSTR("%s %@\n"), + kIRCPart, cch->GetName()); + this->SendQPush(msg, cch->GetEncoding(), kSendMsgPrioStdProtocol); + CFRelease(msg); + } + } } ! #if 0 CFArrayRef channels = mBotConfig->GetChannels(); *************** *** 443,456 **** - CrawIRCChannel* - CrawIRCBot::GetChannelFromName(CFStringRef inChanName) - { - chanMapType::iterator p = mChannelMap.find(inChanName); - if (p == mChannelMap.end()) - return NULL; - return p->second; - } - - void CrawIRCBot::ParseINVITE(int argc, char *argv[]) --- 472,475 ---- *************** *** 480,502 **** if (p == mChannelMap.end()) { ! // CrawChannelConfig *chancf = gCoreConfig->FindChannel(channel); ! CrawChannelConfig *chancf = mBotConfig->GetChannel(channel); ! ! CrawIRCChannel *newChannel = new CrawIRCChannel(channel, chancf, this, mCoreService); ! if (chancf) { ! // Set text encoding according to the configuration file, if found. ! // Some networks auto-joins clients, that sucks. In this case, the ! // channel will usually not be found in Craw.conf. Default encoding ! // is then UTF-8. ! // newChannel->SetEncoding(chancf->GetEncoding()); ! // Custom command char? ! // newChannel->SetCmdChar(chancf->GetCmdChar()); } - mChannelMap.insert(chanPairType(channel, newChannel)); - mCore->GetCoreAbstract()->IRCChannelCreated(newChannel); - - // Try to sync on this channel - newChannel->TrySync(); } else --- 499,517 ---- if (p == mChannelMap.end()) { ! CrawIRCChannel *ircChan = mCoreBot->CreateIRCChannel(channel); ! if (ircChan) { ! mChannelMap.insert(chanPairType(ircChan->GetName(), ircChan)); ! ircChan->TrySync(); ! } ! else ! { ! // TODO: send part msg ! CFStringRef msg = CFStringCreateWithFormat(NULL, NULL, ! CFSTR("%s %@\n"), ! kIRCPart, channel); ! this->SendQPush(msg, INTERNAL_CHANNEL_ENCODING, kSendMsgPrioStdProtocol); ! CFRelease(msg); } } else *************** *** 548,552 **** CrawIRCChannel *chan = p->second; mChannelMap.erase(p); ! mCore->GetCoreAbstract()->IRCChannelDestroyed(chan); delete chan; } --- 563,567 ---- CrawIRCChannel *chan = p->second; mChannelMap.erase(p); ! // mCore->GetCoreAbstract()->IRCChannelDestroyed(chan); delete chan; } *************** *** 654,657 **** --- 669,728 ---- void + CrawIRCBot::ParsePART(int argc, char *argv[]) + { + CFStringRef fullsource, channel, message = NULL; + CFArrayRef source; + + // :Craw!~da...@ca... PART :#craw + if (argc < 3) + return; + + fullsource = CFStringCreateWithCString(NULL, (char *)argv[0], kCFStringEncodingASCII); + source = CFStringCreateArrayBySeparatingStrings(NULL, fullsource, CFSTR("!")); + + char *cp = (char *)argv[2]; + if (*cp == ':') ++cp; + + channel = CFStringCreateWithCStringNoCopy(NULL, cp, INTERNAL_CHANNEL_ENCODING, kCFAllocatorNull); + assert (channel != NULL); + + chanMapType::iterator p = mChannelMap.find(channel); + + if (!CFStringCompare(CFStringRef(CFArrayGetValueAtIndex(source, 0)), mMyNick, 0)) + { + if (p != mChannelMap.end()) + { + CrawIRCChannel *chan = p->second; + mChannelMap.erase(p); + delete chan; + } + } + else + { + if (p == mChannelMap.end()) + { + // desynch - panic (TODO) + assert (false); + } + else + { + CFStringRef message = NULL; + + // message is optional + if (argc > 3) + message = CFStringCreateWithCString(NULL, (char *)argv[3], p->second->GetEncoding()); + + p->second->HandlePart(fullsource, message); + + if (message) CFRelease(message); + } + } + + CFRelease(channel); + CFRelease(source); + CFRelease(fullsource); + } + + void CrawIRCBot::ParsePRIVMSG(int argc, char *argv[]) { *************** *** 777,859 **** if (mMySVersion) CFRelease(mMySVersion); mMySVersion = inVersionString; // no retain - } - - #pragma mark - - - void - CrawIRCBot::SendEventConnected() - { - CFDictionaryRef dict; - - CFStringRef hostName = CFStringRef(CFReadStreamCopyProperty(mReadStream, - kCFStreamPropertySocketRemoteHostName)); - CFNumberRef portNum = CFNumberRef(CFReadStreamCopyProperty(mReadStream, - kCFStreamPropertySocketRemotePortNumber)); - assert (hostName != NULL); - assert (portNum != NULL); - CFTypeRef keys[] = { CFSTR(kCCHostNameKey), CFSTR(kCCPortKey) }; - CFTypeRef values[] = { hostName, portNum }; - dict = CFDictionaryCreate(NULL, keys, values, 2, - &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - assert (dict != NULL); - - mCoreService->EventGenerate(this, kCCEventBotConnected, CFTypeRef(dict)); - - CFRelease(dict); - CFRelease(portNum); - CFRelease(hostName); - } - - void - CrawIRCBot::SendEventNotice( - CFStringRef inSource, - CFStringRef inMessage) - { - CFDictionaryRef dict; - - CFTypeRef keys[] = { CFSTR(kCCSourceKey), CFSTR(kCCMessageKey) }; - CFTypeRef values[] = { inSource, inMessage }; - - dict = CFDictionaryCreate(NULL, keys, values, 2, - &k... [truncated message content] |
From: Stephane T. <mb...@us...> - 2003-02-08 00:02:28
|
Update of /cvsroot/craw/Craw/Sources In directory sc8-pr-cvs1:/tmp/cvs-serv8831/Sources Modified Files: Makefile Log Message: C'est la fete. Index: Makefile =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Makefile,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Makefile 1 Feb 2003 15:05:47 -0000 1.6 --- Makefile 8 Feb 2003 00:01:54 -0000 1.7 *************** *** 32,35 **** --- 32,43 ---- fi; + modclean: + @if [ -n "$$name" ]; then \ + cd Modules; $(MAKE) modclean name="${name}"; \ + else \ + echo "The module target requires a name parameter,"; \ + echo "e.g.: \"make module name=somemodulename\""; \ + fi; + clean: @rm -f *.o *~ *.core |
From: Stephane T. <mb...@us...> - 2003-02-08 00:02:28
|
Update of /cvsroot/craw/Craw In directory sc8-pr-cvs1:/tmp/cvs-serv8831 Modified Files: Makefile Removed Files: Craw.mcp Log Message: C'est la fete. Index: Makefile =================================================================== RCS file: /cvsroot/craw/Craw/Makefile,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Makefile 1 Feb 2003 15:05:46 -0000 1.9 --- Makefile 8 Feb 2003 00:01:54 -0000 1.10 *************** *** 34,37 **** --- 34,45 ---- fi; + modclean: + @if [ -n "$$name" ]; then \ + cd Sources; ${MAKE} modclean name="${name}"; \ + else \ + echo "The module target requires a name parameter,"; \ + echo "e.g.: \"make module name=somemodulename\""; \ + fi; + update: clean @echo "Updating local source, please wait..."; --- Craw.mcp DELETED --- |
From: Stephane T. <mb...@us...> - 2003-02-08 00:02:02
|
Update of /cvsroot/craw/Craw/Sources/Modules/cmd_test In directory sc8-pr-cvs1:/tmp/cvs-serv8831/Sources/Modules/cmd_test Modified Files: main.m Log Message: C'est la fete. Index: main.m =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/cmd_test/main.m,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** main.m 31 Jan 2003 17:39:31 -0000 1.14 --- main.m 8 Feb 2003 00:01:58 -0000 1.15 *************** *** 23,26 **** --- 23,29 ---- { kCCCommandTest = 'Test', // warning: all lowercase eventIDs are reserved by the Core !! + kCCCommandTest2 = 'Tes2', + kCCCommandRaw = 'Raw ', + kCCCommandJoin = 'TJoi', kCCCommandUname = 'Unam' }; *************** *** 35,38 **** --- 38,44 ---- // We want to create 2 commands CCEventRegisterCommand(module, CFSTR("test"), TRUE, kCCCommandTest); + CCEventRegisterCommand(module, CFSTR("test2"), TRUE, kCCCommandTest2); + CCEventRegisterCommand(module, CFSTR("raw"), TRUE, kCCCommandRaw); + CCEventRegisterCommand(module, CFSTR("join"), TRUE, kCCCommandJoin); CCEventRegisterCommand(module, CFSTR("uname"), TRUE, kCCCommandUname); *************** *** 150,153 **** --- 156,189 ---- case kCCCommandTest: { + NSDictionary *dict = (NSDictionary *)inData; + CCChannelRef theTarget = CCChannelGetFromName(inBot, [dict objectForKey:@"channel"]); + NSString *args = [dict objectForKey:@"args"]; + NSArray *sepa = [args componentsSeparatedByString:@" "]; + NSString *bot = [sepa objectAtIndex:0]; + NSString *username = [sepa objectAtIndex:1]; + NSString *realname = [sepa objectAtIndex:2]; + NSString *cmdchar = [sepa objectAtIndex:3]; + + CCChannelSendMessage(theTarget, [NSString stringWithFormat:@"bot=%@ username=%@ realname=%@", + bot, username, realname]); + + CCBotRef newBot; + if (CCBotCreate(bot, username, realname, CCBotGetNetwork(inBot), &newBot)) + { + CCChannelSendMessage(theTarget, CFSTR("1- CCBotCreate OK")); + CCChannelSendMessage(theTarget, [NSString stringWithFormat:@"Bot: %@", CCBotGetBirthName(newBot)]); + CCBotSetEnabled(newBot, true); + CCChannelSendMessage(theTarget, CFSTR("2- Enabled OK")); + + CCChannelRef newChannel; + if (CCChannelAdd(newBot, CCChannelGetName(theTarget), CCChannelGetKey(theTarget), cmdchar, &newChannel)) + { + CCChannelSendMessage(theTarget, CFSTR("3- CCBotAddChannel OK")); + CCChannelSetEnabled(newChannel, true); + CCChannelSendMessage(theTarget, CFSTR("4- CCChannelSetEnabled OK...")); + } + + } + /* int i, p; *************** *** 168,171 **** --- 204,256 ---- break; } + case kCCCommandTest2: + { + NSDictionary *dict = (NSDictionary *)inData; + CCChannelRef theTarget = CCChannelGetFromName(inBot, [dict objectForKey:@"channel"]); + int i, count = CCBotGetChannelsCount(inBot); + if (count == 0) + { + CCChannelSendMessage(theTarget, CFSTR("No channel found!")); + break; + } + CCChannelSendMessage(theTarget, [NSString stringWithFormat:@"%d channels found (max 10 display)", count]); + + CCChannelRef ccChannels[10]; + + count = CCBotRetrieveChannels(inBot, 10, ccChannels); + + for (i = 0; i < count; i++) + { + CCChannelSendMessage(theTarget, [NSString stringWithFormat:@"#%d Channel: %@", i, CCChannelGetName(ccChannels[i])]); + } + break; + } + + case kCCCommandRaw: + { + NSDictionary *dict = (NSDictionary *)inData; + CCBotSendRaw(inBot, [dict objectForKey:@"args"], kCCSendPrioStd); + break; + } + case kCCCommandJoin: + { + NSDictionary *dict = (NSDictionary *)inData; + CCChannelRef theTarget = CCChannelGetFromName(inBot, [dict objectForKey:@"channel"]); + NSString *args = [dict objectForKey:@"args"]; + NSArray *sepa = [args componentsSeparatedByString:@" "]; + NSString *chanName = [sepa objectAtIndex:0]; + CCChannelRef newChannel; + + if (CCBotAddChannel(inBot, chanName, nil, CFSTR("."), &newChannel)) + { + CCChannelSendMessage(theTarget, CFSTR("Channel created!")); + CCChannelSetEnabled(newChannel, true); + } + else + { + CCChannelSendMessage(theTarget, CFSTR("Channel creation failed! (already exists?)")); + } + break; + } case kCCCommandUname: { |
From: Stephane T. <mb...@us...> - 2003-02-08 00:02:02
|
Update of /cvsroot/craw/Craw/build In directory sc8-pr-cvs1:/tmp/cvs-serv8831/build Modified Files: Makefile crawconf-example.plist Log Message: C'est la fete. Index: Makefile =================================================================== RCS file: /cvsroot/craw/Craw/build/Makefile,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile 1 Feb 2003 14:30:47 -0000 1.4 --- Makefile 8 Feb 2003 00:01:59 -0000 1.5 *************** *** 24,27 **** --- 24,35 ---- fi; + modclean: + @if [ -n "$$name" ]; then \ + cd ..; ${MAKE} modclean name="${name}"; \ + else \ + echo "The module target requires a name parameter,"; \ + echo "e.g.: \"make module name=somemodulename\""; \ + fi; + update: cd ..; ${MAKE} update; Index: crawconf-example.plist =================================================================== RCS file: /cvsroot/craw/Craw/build/crawconf-example.plist,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** crawconf-example.plist 1 Feb 2003 13:52:41 -0000 1.4 --- crawconf-example.plist 8 Feb 2003 00:01:59 -0000 1.5 *************** *** 38,43 **** <array> <dict> - <key>description</key> - <string>CTCP module</string> <key>enabled</key> <true/> --- 38,41 ---- *************** *** 46,51 **** </dict> <dict> - <key>description</key> - <string>Test command</string> <key>enabled</key> <true/> --- 44,47 ---- *************** *** 54,59 **** </dict> <dict> - <key>description</key> - <string>Memo commands module</string> <key>enabled</key> <true/> --- 50,53 ---- *************** *** 62,67 **** </dict> <dict> - <key>description</key> - <string>Web commands</string> <key>enabled</key> <true/> --- 56,59 ---- *************** *** 70,75 **** </dict> <dict> - <key>description</key> - <string>AppleScript command module</string> <key>enabled</key> <true/> --- 62,65 ---- |
From: Stephane T. <mb...@us...> - 2003-02-08 00:02:02
|
Update of /cvsroot/craw/Craw/Sources/Modules/mod_auth In directory sc8-pr-cvs1:/tmp/cvs-serv8831/Sources/Modules/mod_auth Modified Files: MAInterface.h MAInterface.m Log Message: C'est la fete. Index: MAInterface.h =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/mod_auth/MAInterface.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MAInterface.h 2 Feb 2003 18:49:11 -0000 1.1 --- MAInterface.h 8 Feb 2003 00:01:59 -0000 1.2 *************** *** 16,22 **** * $Id$ */ ! #include "CrawCoreInterface.h" /*! @function MAUserIsOwner --- 16,26 ---- * $Id$ */ ! #pragma once #include "CrawCoreInterface.h" + #if defined(__cplusplus) + extern "C" { + #endif + /*! @function MAUserIsOwner *************** *** 33,36 **** --- 37,53 ---- /*! + @function MAUserCopyCorrectName + @discussion Usernames are not case sensitive. This convenience function allows modules to correct the case of a specified user. + @param inBot The concerned bot. Can be NULL if the user is the owner. + @param inUser The username of the user to check/correct. + @result A copy of the case-corrected (if needed) username of the user. You need to release it when you're done with it. If the user is not found, returns NULL. + */ + extern CFStringRef + MAUserCopyCorrectName(CCBotRef inBot, CFStringRef inUser); + + typedef CFStringRef (*MAUserCopyCorrectNameProc)(CCBotRef inBot, CFStringRef inUser); + + + /*! @function MAUserGetGlobalLevel @discussion Get access level for a login and password, on the specified bot. Because it's possible, this function give some useful additional information (eg. the possibility to know if the user is a channel "local" user). *************** *** 41,45 **** */ extern int ! MAUserGetGlobalLevel(CCBotRef inBot, CFStringRef inLogin, CFStringRef inPassword); typedef int (*MAUserGetGlobalLevelProc)(CCBotRef inBot, CFStringRef inLogin, CFStringRef inPassword); --- 58,62 ---- */ extern int ! MAUserGlobalGetLevel(CCBotRef inBot, CFStringRef inLogin, CFStringRef inPassword); typedef int (*MAUserGetGlobalLevelProc)(CCBotRef inBot, CFStringRef inLogin, CFStringRef inPassword); *************** *** 55,59 **** */ extern int ! MAUserGetChannelLevel(CCChannelRef inChannel, CFStringRef inLogin, CFStringRef inPassword); typedef int (*MAUserGetChannelLevelProc)(CCChannelRef inChannel, CFStringRef inLogin, CFStringRef inPassword); --- 72,91 ---- */ extern int ! MAUserChannelGetLevel(CCChannelRef inChannel, CFStringRef inLogin, CFStringRef inPassword); typedef int (*MAUserGetChannelLevelProc)(CCChannelRef inChannel, CFStringRef inLogin, CFStringRef inPassword); + + + /*! + @function MAUserCopyInfoDict + @discussion Copy the info dictionary for an user (local or global) on a specified bot. Work for the owner too, as it's username is reserved on all bots. + @param inBot The concerned bot + @param inUser Login name of the user. + @result The information dictionary of the user, or NULL if the user is invalid. + */ + extern CFDictionaryRef + MAUserCopyInfoDict(CCBotRef inBot, CFStringRef inUser); + + #if defined(__cplusplus) + } + #endif Index: MAInterface.m =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/mod_auth/MAInterface.m,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MAInterface.m 2 Feb 2003 18:49:11 -0000 1.1 --- MAInterface.m 8 Feb 2003 00:01:59 -0000 1.2 *************** *** 28,32 **** int ! MAUserGetGlobalLevel(CCBotRef inBot, CFStringRef inLogin, CFStringRef inPassword) { return 1001; --- 28,32 ---- int ! MAUserGlobalGetLevel(CCBotRef inBot, CFStringRef inLogin, CFStringRef inPassword) { return 1001; *************** *** 34,42 **** - int ! MAUserGetChannelLevel(CCChannelRef inChannel, CFStringRef inLogin, CFStringRef inPassword) { return 1001; } --- 34,57 ---- int ! MAUserChannelGetLevel(CCChannelRef inChannel, CFStringRef inLogin, CFStringRef inPassword) { return 1001; } + + + CFDictionaryRef + MAUserCopyInfoDict(CCBotRef inBot, CFStringRef inUser) + { + return NULL; + } + + + CFStringRef + MAUserCopyCorrectName(CCBotRef inBot, CFStringRef inUser) + { + return CFRetain(inUser); + } + + |
From: Stephane T. <mb...@us...> - 2003-02-08 00:02:01
|
Update of /cvsroot/craw/Craw/Sources/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv8831/Sources/Modules Modified Files: Makefile Log Message: C'est la fete. Index: Makefile =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/Makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile 1 Feb 2003 14:30:46 -0000 1.5 --- Makefile 8 Feb 2003 00:01:58 -0000 1.6 *************** *** 29,32 **** --- 29,43 ---- fi; + modclean: + @if [ -n "$$name" ]; then \ + if [ -d "${name}" ]; then \ + cd "${name}"; $(MAKE) clean; \ + else \ + echo "Sorry, no module found with this name!"; \ + fi; \ + else \ + echo "The module target requires a name parameter,"; \ + echo "e.g.: \"make module name=somemodulename\""; \ + fi; clean: |
From: Stephane T. <mb...@us...> - 2003-02-08 00:02:01
|
Update of /cvsroot/craw/Craw/Sources/Core/export In directory sc8-pr-cvs1:/tmp/cvs-serv8831/Sources/Core/export Modified Files: CCBot.h CCChannel.h CCModule.h Log Message: C'est la fete. Index: CCBot.h =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/export/CCBot.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CCBot.h 30 Jan 2003 21:57:57 -0000 1.1 --- CCBot.h 8 Feb 2003 00:01:57 -0000 1.2 *************** *** 20,23 **** --- 20,24 ---- #include <CoreFoundation/CoreFoundation.h> + #include "CCTypes.h" #if defined(__cplusplus) *************** *** 58,61 **** --- 59,65 ---- CCBotGetRealName(CCBotRef inBot); + extern CCNetworkRef + CCBotGetNetwork(CCBotRef inBot); + /*! *************** *** 66,73 **** @param inMessage The message to send. @param isNotice A boolean to specify if the message should be sent as a NOTICE or a PRIVMSG. ! @param inPriority Craw's core priority-queues messages. Use a priority between 20 (low) and -20 (high!). 0 is the standard priority. */ ! extern ! void CCBotSend(CCBotRef inBot, CFStringRef inTarget, CFStringRef inMessage, bool isNotice, CCSendPriority inPriority); /*! --- 70,78 ---- @param inMessage The message to send. @param isNotice A boolean to specify if the message should be sent as a NOTICE or a PRIVMSG. ! @param inPriority Craw's core priority-queues messages. Use a priority (integer) between 20 (low) and -20 (high!). 0 is the standard priority. ! @result TRUE if succesfull. FALSE for illegal priority number (not between -20..20), or if the bot is not connected to a server at the moment. */ ! extern bool ! CCBotSend(CCBotRef inBot, CFStringRef inTarget, CFStringRef inMessage, bool isNotice, CCSendPriority inPriority); /*! *************** *** 77,83 **** @param inTarget The target (usually a nickname), as string. @param inMessage The message to send. */ ! extern ! void CCBotSendMessage(CCBotRef inBot, CFStringRef inTarget, CFStringRef inMessage); /*! --- 82,89 ---- @param inTarget The target (usually a nickname), as string. @param inMessage The message to send. + @result TRUE if succesfull. FALSE if the bot is not connected to a server at the moment. */ ! extern bool ! CCBotSendMessage(CCBotRef inBot, CFStringRef inTarget, CFStringRef inMessage); /*! *************** *** 87,94 **** @param inTarget The target (usually a nickname), as string. @param inMessage The message to send. */ ! extern ! void CCBotSendNotice(CCBotRef inBot, CFStringRef inTarget, CFStringRef inNotice); --- 93,135 ---- @param inTarget The target (usually a nickname), as string. @param inMessage The message to send. + @result TRUE if succesfull. FALSE if the bot is not connected to a server at the moment. */ ! extern bool ! CCBotSendNotice(CCBotRef inBot, CFStringRef inTarget, CFStringRef inNotice); + + /*! + @function CCBotSendRaw + @discussion To use when you want to send a "raw" IRC command, with priority parameter. This method uses the default bot text encoding. + @param inBot The core bot instance. + @param inRawMsg The raw command/message to send to the server. + @param inPriority Craw's core priority-queues messages. Use a priority (integer) between 20 (low) and -20 (high!). 0 is the standard priority. + @result TRUE if succesfull. FALSE for illegal priority number (not between -20..20), or if the bot is not connected to a server at the moment. + */ + extern bool + CCBotSendRaw(CCBotRef inBot, CFStringRef inRawMsg, CCSendPriority inPriority); + + + /* Bots management */ + + /* ok */ + extern bool + CCBotCreate(CFStringRef inBirthName, CFStringRef inUserName, CFStringRef inRealName, CCNetworkRef inNet, CCBotRef *newBot); + + /* not tested */ + extern bool + CCBotDestroy(CCBotRef inBot); + + /* ok */ + extern void + CCBotSetEnabled(CCBotRef inBot, bool isEnabled); + + /* ok */ + extern CFIndex + CCBotGetChannelsCount(CCBotRef inBot); + + /* ok */ + extern CFIndex + CCBotRetrieveChannels(CCBotRef inBot, CFIndex inLength, CCChannelRef *oChannels); Index: CCChannel.h =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/export/CCChannel.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CCChannel.h 31 Jan 2003 15:01:33 -0000 1.2 --- CCChannel.h 8 Feb 2003 00:01:57 -0000 1.3 *************** *** 33,37 **** @function CCChannelGetName @discussion Get the name of a channel core reference. ! @param inChannel The channel name (not case sensitive). @result The full name of the channel, as string. */ --- 33,37 ---- @function CCChannelGetName @discussion Get the name of a channel core reference. ! @param inChannel The core channel reference. @result The full name of the channel, as string. */ *************** *** 40,43 **** --- 40,52 ---- /*! + @function CCChannelGetKey + @discussion Get the key of a channel core reference. + @param inChannel The core channel reference. + @result The key of the channel, empty if not set, as string. + */ + extern CFStringRef + CCChannelGetKey(CCChannelRef inChannel); + + /*! @function CCChannelGetFromName @discussion Use this method to get a channel core reference from its name. *************** *** 58,62 **** @param inPriority Craw's core priority-queues messages. Use a priority between 20 (low) and -20 (high!). 0 is the standard priority. */ ! extern void CCChannelSend(CCChannelRef inChannel, CFStringRef inMessage, bool isNotice, CCSendPriority inPriority); --- 67,71 ---- @param inPriority Craw's core priority-queues messages. Use a priority between 20 (low) and -20 (high!). 0 is the standard priority. */ ! extern bool CCChannelSend(CCChannelRef inChannel, CFStringRef inMessage, bool isNotice, CCSendPriority inPriority); *************** *** 68,72 **** @param inMessage The message to send. */ ! extern void CCChannelSendMessage(CCChannelRef inChannel, CFStringRef inMessage); --- 77,81 ---- @param inMessage The message to send. */ ! extern bool CCChannelSendMessage(CCChannelRef inChannel, CFStringRef inMessage); *************** *** 78,84 **** @param inNotice The notice message to send. */ ! extern void CCChannelSendNotice(CCChannelRef inChannel, CFStringRef inNotice); #if defined(__cplusplus) --- 87,104 ---- @param inNotice The notice message to send. */ ! extern bool CCChannelSendNotice(CCChannelRef inChannel, CFStringRef inNotice); + + extern void + CCChannelSetEnabled(CCChannelRef inChannel, bool isEnabled); + + + extern bool + CCChannelAdd(CCBotRef inBot, CFStringRef inName, CFStringRef inKey, CFStringRef inCmdChar, CCChannelRef *newChannel); + + /* Not implemented yet */ + extern void + CCChannelDelete(CCChannelRef inChannel); #if defined(__cplusplus) Index: CCModule.h =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/export/CCModule.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CCModule.h 30 Jan 2003 21:57:57 -0000 1.1 --- CCModule.h 8 Feb 2003 00:01:57 -0000 1.2 *************** *** 41,45 **** /*! ! @function CCModuleRetrieveAll @discussion Fills the buffer with module references. @param inLength Number of pointers in the oModules buffer. --- 41,45 ---- /*! ! @function CCModuleRetrieve @discussion Fills the buffer with module references. @param inLength Number of pointers in the oModules buffer. *************** *** 94,98 **** @function CCModuleLookupSymbol @discussion For inter-module communication. Retrieves the address of the specified symbol (eg. function) in the module. ! @param inModule The module reference. @param inSymbolName The name of the symbol (eg. "_" + name of the function). @result The symbol's address. --- 94,98 ---- @function CCModuleLookupSymbol @discussion For inter-module communication. Retrieves the address of the specified symbol (eg. function) in the module. ! @param inModule The module reference. For convenience, this parameter might be NULL (and CCModuleLookupSymbol will return NULL). @param inSymbolName The name of the symbol (eg. "_" + name of the function). @result The symbol's address. |
From: Kevin R. <fl...@us...> - 2003-02-07 14:21:50
|
Update of /cvsroot/craw/Craw/Sources/Modules/mod_talk In directory sc8-pr-cvs1:/tmp/cvs-serv6211/mod_talk Modified Files: TalkCenter.h TalkCenter.m talk.m Log Message: Added !del, !rep, !add, !search, !dsearch to Talk module Index: TalkCenter.h =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/mod_talk/TalkCenter.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TalkCenter.h 7 Feb 2003 00:41:19 -0000 1.3 --- TalkCenter.h 7 Feb 2003 14:21:46 -0000 1.4 *************** *** 27,31 **** --- 27,35 ---- + (void)checkTalkMessage:(NSMutableDictionary *)dict; + (void)addEntry:(NSMutableDictionary *)dict; + + (void)deleteEntry:(NSMutableDictionary *)dict; + + (void)replaceEntry:(NSMutableDictionary *)dict; + (void)displayRaw:(NSMutableDictionary *)dict; + + (void)searchEntry:(NSMutableDictionary *)dict; + + (void)dsearchEntry:(NSMutableDictionary *)dict; @end Index: TalkCenter.m =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/mod_talk/TalkCenter.m,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TalkCenter.m 7 Feb 2003 00:41:19 -0000 1.3 --- TalkCenter.m 7 Feb 2003 14:21:46 -0000 1.4 *************** *** 135,141 **** { NSLog(@"addEntry: %@", [dict objectForKey:@"args"]); ! //NSFileHandle *theFileHandle = [NSFileHandle fileHandleForWritingAtPath:[thePrefPath stringByAppendingPathComponent:@"talk_database.db"]]; ! ! // [theFileHandle writeData:[output dataUsingEncoding:NSISOLatin1StringEncoding]]; } --- 135,220 ---- { NSLog(@"addEntry: %@", [dict objectForKey:@"args"]); ! NSAutoreleasePool *addPool = [[NSAutoreleasePool alloc] init]; ! NSString *theArg = [[NSString alloc] initWithString:[dict objectForKey:@"args"]]; ! NSString *theEntry = [[NSString alloc] initWithString:[[theArg componentsSeparatedByString:@" "] objectAtIndex:0]]; ! NSFileHandle *theFileHandle = [NSFileHandle fileHandleForWritingAtPath:[thePrefPath stringByAppendingPathComponent:@"talk_database.db"]]; ! ! NSLog(@"theEntry: %@", theEntry); ! ! if ([talkDatabase indexOfObject:theEntry] == NSNotFound) ! { ! ! if ([[theArg componentsSeparatedByString:@" "] count] >= 2) ! { ! [theFileHandle seekToEndOfFile]; ! [theFileHandle writeData:[[theArg stringByAppendingString:@"\n"] dataUsingEncoding:NSMacOSRomanStringEncoding]]; ! ! NSLog(@"count: %d", [talkDatabase count]); ! [talkDatabase release]; ! talkDatabase = [[NSArray alloc] initWithArray:[self parsedDatabase]]; ! NSLog(@"count: %d", [talkDatabase count]); ! CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"%@, the entry '%@' has ben added.", [[[dict objectForKey:@"source"] componentsSeparatedByString:@"!"] objectAtIndex:0], theEntry]); ! } else { ! CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"%@, don't you have anything to say about %@ ?", [[[dict objectForKey:@"source"] componentsSeparatedByString:@"!"] objectAtIndex:0], theEntry]); ! } ! ! } else { ! CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"I'm sorry %@, the entry '%@' already exists.", [[[dict objectForKey:@"source"] componentsSeparatedByString:@"!"] objectAtIndex:0], theEntry]); ! } ! ! [addPool release]; ! } ! ! + (void)deleteEntry:(NSMutableDictionary *)dict ! { ! NSAutoreleasePool *delPool = [[NSAutoreleasePool alloc] init]; ! NSString *theArg = [[NSString alloc] initWithString:[dict objectForKey:@"args"]]; ! NSMutableArray *dbArray = [[NSMutableArray alloc] init]; ! ! if ([talkDatabase indexOfObject:theArg] != NSNotFound) ! { ! dbArray = [[NSString stringWithContentsOfFile:[thePrefPath stringByAppendingPathComponent:@"talk_database.db"]] componentsSeparatedByString:@"\n"]; ! NSLog(@"count: %d", [talkDatabase count]); ! NSLog(@"removing entry #%d", [talkDatabase indexOfObject:theArg]); ! [dbArray removeObjectAtIndex:[talkDatabase indexOfObject:theArg]]; ! [[dbArray componentsJoinedByString:@"\n"] writeToFile:[thePrefPath stringByAppendingPathComponent:@"talk_database.db"] atomically:YES]; ! [talkDatabase release]; ! talkDatabase = [[NSArray alloc] initWithArray:[self parsedDatabase]]; ! NSLog(@"count: %d", [talkDatabase count]); ! CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"%@, the entry '%@' has been removed.", [[[dict objectForKey:@"source"] componentsSeparatedByString:@"!"] objectAtIndex:0], theArg]); ! } else { ! CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"I'm sorry %@, the entry '%@' does not exist.", [[[dict objectForKey:@"source"] componentsSeparatedByString:@"!"] objectAtIndex:0], theArg]); ! } ! [delPool release]; ! } ! ! + (void)replaceEntry:(NSMutableDictionary *)dict ! { ! NSAutoreleasePool *replacePool = [[NSAutoreleasePool alloc] init]; ! NSString *theArg = [[NSString alloc] initWithString:[dict objectForKey:@"args"]]; ! NSMutableArray *dbArray = [[NSMutableArray alloc] init]; ! NSString *theEntry = [[NSString alloc] initWithString:[[theArg componentsSeparatedByString:@" "] objectAtIndex:0]]; ! ! if ([talkDatabase indexOfObject:theEntry] != NSNotFound) ! { ! if ([[theArg componentsSeparatedByString:@" "] count] >= 2) ! { ! dbArray = [[NSString stringWithContentsOfFile:[thePrefPath stringByAppendingPathComponent:@"talk_database.db"]] componentsSeparatedByString:@"\n"]; ! NSLog(@"count: %d", [talkDatabase count]); ! NSLog(@"replacing entry #%d", [talkDatabase indexOfObject:theEntry]); ! [dbArray removeObjectAtIndex:[talkDatabase indexOfObject:theEntry]]; ! [dbArray insertObject:theArg atIndex:[talkDatabase count] - 2]; ! [[dbArray componentsJoinedByString:@"\n"] writeToFile:[thePrefPath stringByAppendingPathComponent:@"talk_database.db"] atomically:YES]; ! [talkDatabase release]; ! talkDatabase = [[NSArray alloc] initWithArray:[self parsedDatabase]]; ! NSLog(@"count: %d", [talkDatabase count]); ! CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"%@, the entry '%@' has been replaced.", [[[dict objectForKey:@"source"] componentsSeparatedByString:@"!"] objectAtIndex:0], theEntry]); ! } else { ! CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"%@, don't you have anything to say about %@ ?", [[[dict objectForKey:@"source"] componentsSeparatedByString:@"!"] objectAtIndex:0], theEntry]); ! } ! } else { ! CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"I'm sorry %@, the entry '%@' does not exist.", [[[dict objectForKey:@"source"] componentsSeparatedByString:@"!"] objectAtIndex:0], theEntry]); ! } ! [replacePool release]; } *************** *** 182,185 **** --- 261,352 ---- CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"RAW: could not find '%@'", theArg]); } + } + + + (void)searchEntry:(NSMutableDictionary *)dict + { + NSAutoreleasePool *searchPool = [[NSAutoreleasePool alloc] init]; + NSMutableArray *searchRes = [[NSMutableArray alloc] init]; + NSString *theArg = [[NSString alloc] initWithString:[dict objectForKey:@"args"]]; + int y, u, p; + u = 0; + p = 0; + for (y=0;y<[talkDatabase count];y++) + { + if ([[[talkDatabase objectAtIndex:y] componentsSeparatedByString:theArg] count] > 1) + { + if ([[[searchRes componentsJoinedByString:@", "] stringByAppendingString:[talkDatabase objectAtIndex:y]] length] < 350) + { + [searchRes addObject:[talkDatabase objectAtIndex:y]]; + p = [searchRes count]; + } + u++; + } + } + NSLog(@"u: %d - p: %d", u, p); + + if (p >= 1) + { + + if (u > p) + CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"%d results found, here are the first %d: %@", u, p, [searchRes componentsJoinedByString:@", "]]); + else + CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"%d results found: %@", p, [searchRes componentsJoinedByString:@", "]]); + + } else { + + CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"Could not find any entry matching '%@'", theArg]); + + } + + [searchPool release]; + } + + + (void)dsearchEntry:(NSMutableDictionary *)dict + { + NSString *theArg = [[NSString alloc] initWithString:[dict objectForKey:@"args"]]; + NSString *data = [[NSString alloc] initWithContentsOfFile:[thePrefPath + stringByAppendingPathComponent:@"talk_database.db"]]; + NSArray *lines = [[NSArray alloc] initWithArray:[data + componentsSeparatedByString:@"\n"]]; + NSMutableArray *searchRes = [[NSMutableArray alloc] init]; + int j, u, p, k=[lines count]; + u = 0; + p = 0; + NSAutoreleasePool *findPool = [[NSAutoreleasePool alloc] init]; + + for (j=0; j<k; j++) + { + NSString *str=[lines objectAtIndex:j]; + if ([[str componentsSeparatedByString:theArg] count] > 1) + { + if ([[[searchRes componentsJoinedByString:@", "] stringByAppendingString:str] length] < 350) + { + [searchRes addObject:[talkDatabase objectAtIndex:j]]; + p = [searchRes count]; + } + u++; + } + } + + [findPool release]; + + NSLog(@"u: %d - p: %d", u, p); + + if (p >= 1) + { + + if (u > p) + CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"%d results found, here are the first %d: %@", u, p, [searchRes componentsJoinedByString:@", "]]); + else + CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"%d results found: %@", p, [searchRes componentsJoinedByString:@", "]]); + + } else { + + CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"Could not find any entry text matching '%@'", theArg]); + + } + + [data release]; + [lines release]; } Index: talk.m =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/mod_talk/talk.m,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** talk.m 7 Feb 2003 00:07:05 -0000 1.2 --- talk.m 7 Feb 2003 14:21:46 -0000 1.3 *************** *** 27,31 **** kCCCommandRep = 'RepE', // the terms in '' are the internal referrers, always use 4 chars kCCCommandDel = 'DelE', // and -please- incluse at least one capital ! kCCCommandRaw = 'RawE' }; --- 27,33 ---- kCCCommandRep = 'RepE', // the terms in '' are the internal referrers, always use 4 chars kCCCommandDel = 'DelE', // and -please- incluse at least one capital ! kCCCommandRaw = 'RawE', ! kCCCommandSearch = 'EnSc', ! kCCCommandDSearch = 'DSch' }; *************** *** 34,38 **** void _CrawModuleInit(CCModuleRef module) { ! NSLog(@"_CrawModuleInit admin"); talkPool = [[NSAutoreleasePool alloc] init]; --- 36,40 ---- void _CrawModuleInit(CCModuleRef module) { ! NSLog(@"_CrawModuleInit talk"); talkPool = [[NSAutoreleasePool alloc] init]; *************** *** 41,45 **** CCEventRegisterCommand(module, CFSTR("del"), TRUE, kCCCommandDel); CCEventRegisterCommand(module, CFSTR("raw"), TRUE, kCCCommandRaw); ! CCEventRegister(module, kCCEventChannelMessage); --- 43,48 ---- CCEventRegisterCommand(module, CFSTR("del"), TRUE, kCCCommandDel); CCEventRegisterCommand(module, CFSTR("raw"), TRUE, kCCCommandRaw); ! CCEventRegisterCommand(module, CFSTR("search"), TRUE, kCCCommandSearch); ! CCEventRegisterCommand(module, CFSTR("dsearch"), TRUE, kCCCommandDSearch); CCEventRegister(module, kCCEventChannelMessage); *************** *** 108,121 **** case kCCCommandRep: { NSDictionary *dict = (NSDictionary *)inData; ! break; } case kCCCommandDel: { NSDictionary *dict = (NSDictionary *)inData; ! break; } case kCCCommandRaw: { --- 111,164 ---- case kCCCommandRep: { + NSAutoreleasePool *addPool = [[NSAutoreleasePool alloc] init]; NSDictionary *dict = (NSDictionary *)inData; ! CCChannelRef theTarget = CCChannelGetFromName(inBot, [dict objectForKey:@"channel"]); ! NSMutableDictionary *fullDict = [[[NSMutableDictionary alloc] init] retain]; ! [fullDict setObject:[NSValue valueWithPointer:inBot] forKey:@"TheBot"]; ! [fullDict setObject:[NSValue valueWithPointer:theTarget] forKey:@"TheTarget"]; ! [fullDict addEntriesFromDictionary:dict]; ! [[TalkCenter class] performSelectorOnMainThread:@selector(replaceEntry:) withObject:fullDict waitUntilDone:TRUE]; ! [addPool release]; break; } case kCCCommandDel: { + NSAutoreleasePool *repPool = [[NSAutoreleasePool alloc] init]; NSDictionary *dict = (NSDictionary *)inData; ! CCChannelRef theTarget = CCChannelGetFromName(inBot, [dict objectForKey:@"channel"]); ! NSMutableDictionary *fullDict = [[[NSMutableDictionary alloc] init] retain]; ! [fullDict setObject:[NSValue valueWithPointer:inBot] forKey:@"TheBot"]; ! [fullDict setObject:[NSValue valueWithPointer:theTarget] forKey:@"TheTarget"]; ! [fullDict addEntriesFromDictionary:dict]; ! [[TalkCenter class] performSelectorOnMainThread:@selector(deleteEntry:) withObject:fullDict waitUntilDone:TRUE]; ! [repPool release]; break; } + case kCCCommandSearch: + { + NSAutoreleasePool *repPool = [[NSAutoreleasePool alloc] init]; + NSDictionary *dict = (NSDictionary *)inData; + CCChannelRef theTarget = CCChannelGetFromName(inBot, [dict objectForKey:@"channel"]); + NSMutableDictionary *fullDict = [[[NSMutableDictionary alloc] init] retain]; + [fullDict setObject:[NSValue valueWithPointer:inBot] forKey:@"TheBot"]; + [fullDict setObject:[NSValue valueWithPointer:theTarget] forKey:@"TheTarget"]; + [fullDict addEntriesFromDictionary:dict]; + [[TalkCenter class] performSelectorOnMainThread:@selector(searchEntry:) withObject:fullDict waitUntilDone:TRUE]; + [repPool release]; + break; + } + case kCCCommandDSearch: + { + NSAutoreleasePool *repPool = [[NSAutoreleasePool alloc] init]; + NSDictionary *dict = (NSDictionary *)inData; + CCChannelRef theTarget = CCChannelGetFromName(inBot, [dict objectForKey:@"channel"]); + NSMutableDictionary *fullDict = [[[NSMutableDictionary alloc] init] retain]; + [fullDict setObject:[NSValue valueWithPointer:inBot] forKey:@"TheBot"]; + [fullDict setObject:[NSValue valueWithPointer:theTarget] forKey:@"TheTarget"]; + [fullDict addEntriesFromDictionary:dict]; + [[TalkCenter class] performSelectorOnMainThread:@selector(dsearchEntry:) withObject:fullDict waitUntilDone:TRUE]; + [repPool release]; + break; + } case kCCCommandRaw: { *************** *** 129,133 **** [[TalkCenter class] performSelectorOnMainThread:@selector(displayRaw:) withObject:fullDict waitUntilDone:TRUE]; [rawPool release]; - } } --- 172,175 ---- |
From: Kevin R. <fl...@us...> - 2003-02-07 14:21:49
|
Update of /cvsroot/craw/Craw/Sources/Modules/cmd_applescript In directory sc8-pr-cvs1:/tmp/cvs-serv6211/cmd_applescript Modified Files: AS.m Log Message: Added !del, !rep, !add, !search, !dsearch to Talk module Index: AS.m =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/cmd_applescript/AS.m,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AS.m 31 Jan 2003 16:01:32 -0000 1.7 --- AS.m 7 Feb 2003 14:21:46 -0000 1.8 *************** *** 72,77 **** [fullDict addEntriesFromDictionary:dict]; [[ASCenter class] performSelectorOnMainThread:@selector(execAppleScript:) withObject:fullDict waitUntilDone:TRUE]; - [dict release]; - [fullDict release]; [execPool release]; break; --- 72,75 ---- |
From: Kevin R. <fl...@us...> - 2003-02-07 00:41:22
|
Update of /cvsroot/craw/Craw/Sources/Modules/mod_talk In directory sc8-pr-cvs1:/tmp/cvs-serv15192 Modified Files: TalkCenter.h TalkCenter.m Log Message: !raw command addedy Index: TalkCenter.h =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/mod_talk/TalkCenter.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TalkCenter.h 7 Feb 2003 00:07:05 -0000 1.2 --- TalkCenter.h 7 Feb 2003 00:41:19 -0000 1.3 *************** *** 27,31 **** + (void)checkTalkMessage:(NSMutableDictionary *)dict; + (void)addEntry:(NSMutableDictionary *)dict; ! + (void)displayRaw:(NSMutableDictionary *)dict @end --- 27,31 ---- + (void)checkTalkMessage:(NSMutableDictionary *)dict; + (void)addEntry:(NSMutableDictionary *)dict; ! + (void)displayRaw:(NSMutableDictionary *)dict; @end Index: TalkCenter.m =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/mod_talk/TalkCenter.m,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TalkCenter.m 7 Feb 2003 00:07:05 -0000 1.2 --- TalkCenter.m 7 Feb 2003 00:41:19 -0000 1.3 *************** *** 134,138 **** + (void)addEntry:(NSMutableDictionary *)dict { ! NSLog(@"addEntry: %@", [dict objectForKey:@"args"]); } --- 134,185 ---- + (void)addEntry:(NSMutableDictionary *)dict { ! NSLog(@"addEntry: %@", [dict objectForKey:@"args"]); ! //NSFileHandle *theFileHandle = [NSFileHandle fileHandleForWritingAtPath:[thePrefPath stringByAppendingPathComponent:@"talk_database.db"]]; ! ! // [theFileHandle writeData:[output dataUsingEncoding:NSISOLatin1StringEncoding]]; ! } ! ! + (void)displayRaw:(NSMutableDictionary *)dict ! { ! NSString *theArg = [[NSString alloc] initWithString:[dict objectForKey:@"args"]]; ! NSString *talkResult = [[NSString alloc] init]; ! int c, z; ! char buffer[1024]; ! ! if ([talkDatabase indexOfObject:theArg] != NSNotFound) ! { ! NSLog(@"mod_talk: FOUND match at %d !", [talkDatabase indexOfObject:theArg]); ! ! z = [talkDatabase indexOfObject:theArg]; ! ! FILE *fp = fopen([[thePrefPath stringByAppendingPathComponent:@"talk_database.db"] cString], "r"); ! ! if (fp == NULL) ! { ! NSLog(@"mod_talk: fopen error, file is missing"); ! exit(1); ! } ! ! for (c = 0; c < z; c++) ! fgets(buffer, sizeof(buffer), fp); // many thanks to mbuna ! ! if (fgets(buffer, sizeof(buffer), fp) != NULL) ! { ! printf("buffer=%s", buffer); ! } ! else ! { ! printf("not found\n"); ! } ! ! fclose(fp); ! ! talkResult = [NSString stringWithFormat:@"RAW: %@", [NSString stringWithCString:buffer]]; ! ! CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], talkResult); ! ! } else { ! CCChannelSendMessage([[dict objectForKey:@"TheTarget"] pointerValue], [NSString stringWithFormat:@"RAW: could not find '%@'", theArg]); ! } } |
From: Kevin R. <fl...@us...> - 2003-02-07 00:07:08
|
Update of /cvsroot/craw/Craw/Sources/Modules/mod_talk In directory sc8-pr-cvs1:/tmp/cvs-serv28205 Modified Files: TalkCenter.h TalkCenter.m talk.m Added Files: Makefile Log Message: hurm :) --- NEW FILE: Makefile --- # Craw IRC Bot - Makefile # $Revision: 1.1 $ # $Date: 2003/02/07 00:07:04 $ # # Makefile configuration LIBS = -framework Foundation CC = gcc CXX = g++ CPPFLAGS=-I. -I../../Core/export -pipe CFLAGS = -Wall -g -O2 DEFS = MAKE = make # Undefined symbols: warning or suppress UNDEFSYM = suppress BUNDLE = mod_talk.so MODNAME = mod_talk MODDESC = Talk Commands # Module objects OBJS = talk.o TalkCenter.o match.o SRC = ${OBJS:%.o=%.m} ## End of Makefile configuration all: mod .c.o: ${CXX} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ mod: ${OBJS} @echo "Bundling module: ${MODDESC}..."; ${CXX} -bundle -flat_namespace -undefined ${UNDEFSYM} -o ${BUNDLE} ${OBJS} ${LIBS}; mv ${BUNDLE} ../../../build/modules/ clean: @echo "Cleaning objects in ${MODNAME}."; @rm -f *.o *~ *.core re: clean all Index: TalkCenter.h =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/mod_talk/TalkCenter.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TalkCenter.h 6 Feb 2003 23:55:01 -0000 1.1 --- TalkCenter.h 7 Feb 2003 00:07:05 -0000 1.2 *************** *** 24,30 **** + (void)importPrefPath:(NSString *)thePath; + (void)checkTalkMessage:(NSMutableDictionary *)dict; + (void)addEntry:(NSMutableDictionary *)dict; ! + (NSArray *)parsedDatabase; @end --- 24,31 ---- + (void)importPrefPath:(NSString *)thePath; + + (NSArray *)parsedDatabase; + (void)checkTalkMessage:(NSMutableDictionary *)dict; + (void)addEntry:(NSMutableDictionary *)dict; ! + (void)displayRaw:(NSMutableDictionary *)dict @end Index: TalkCenter.m =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/mod_talk/TalkCenter.m,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TalkCenter.m 6 Feb 2003 23:55:01 -0000 1.1 --- TalkCenter.m 7 Feb 2003 00:07:05 -0000 1.2 *************** *** 63,67 **** NSMutableArray *parsed = [[NSMutableArray alloc] init]; int j, k=[lines count]; ! NSAutoreleasePool *maPool = [[NSAutoreleasePool alloc] init]; for (j=0; j<k; j++) // special Thanks to nl and Thomas, wonderful routine.. :) { --- 63,67 ---- NSMutableArray *parsed = [[NSMutableArray alloc] init]; int j, k=[lines count]; ! NSAutoreleasePool *parsePool = [[NSAutoreleasePool alloc] init]; for (j=0; j<k; j++) // special Thanks to nl and Thomas, wonderful routine.. :) { *************** *** 73,77 **** [scanner release]; } ! [maPool release]; [data release]; [lines release]; --- 73,77 ---- [scanner release]; } ! [parsePool release]; [data release]; [lines release]; Index: talk.m =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/mod_talk/talk.m,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** talk.m 6 Feb 2003 23:55:01 -0000 1.1 --- talk.m 7 Feb 2003 00:07:05 -0000 1.2 *************** *** 120,124 **** --- 120,132 ---- case kCCCommandRaw: { + NSAutoreleasePool *rawPool = [[NSAutoreleasePool alloc] init]; NSDictionary *dict = (NSDictionary *)inData; + CCChannelRef theTarget = CCChannelGetFromName(inBot, [dict objectForKey:@"channel"]); + NSMutableDictionary *fullDict = [[[NSMutableDictionary alloc] init] retain]; + [fullDict setObject:[NSValue valueWithPointer:inBot] forKey:@"TheBot"]; + [fullDict setObject:[NSValue valueWithPointer:theTarget] forKey:@"TheTarget"]; + [fullDict addEntriesFromDictionary:dict]; + [[TalkCenter class] performSelectorOnMainThread:@selector(displayRaw:) withObject:fullDict waitUntilDone:TRUE]; + [rawPool release]; } |
From: Kevin R. <fl...@us...> - 2003-02-06 23:55:04
|
Update of /cvsroot/craw/Craw/Sources/Modules/mod_talk In directory sc8-pr-cvs1:/tmp/cvs-serv22143 Added Files: TalkCenter.h TalkCenter.m match.c match.h talk.m Log Message: Talk module! Can talk now from loaded darkbot database --- NEW FILE: TalkCenter.h --- /* TalkCenter.h - mod_auth module * * Copyright (C) 2003 Kevin Roettger <fl...@lo...> * This file is part of Craw. * * Craw 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. * * Craw 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. * * $Id: TalkCenter.h,v 1.1 2003/02/06 23:55:01 flymac Exp $ */ #import <Cocoa/Cocoa.h> @interface TalkCenter : NSObject { } + (void)importPrefPath:(NSString *)thePath; + (void)checkTalkMessage:(NSMutableDictionary *)dict; + (void)addEntry:(NSMutableDictionary *)dict; + (NSArray *)parsedDatabase; @end --- NEW FILE: TalkCenter.m --- (This appears to be a binary file; contents omitted.) --- NEW FILE: match.c --- /* * From IRC - Internet Relay Chat, common/match.c * * 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: match.c,v 1.1 2003/02/06 23:55:01 flymac Exp $ */ #include "match.h" #include <ctype.h> /* * Compare if a given string (name) matches the given * mask (which can contain wild cards: '*' - match any * number of chars, '?' - match any single character. * * return 0, if match * 1, if no match */ /* * match * * Rewritten by Andrea Cocito (Nemesi), November 1998. * */ /****************** Nemesi's match() ***************/ #define ToLower tolower int match(const char *mask, const char *string) { const char *m = mask, *s = string; char ch; const char *bm, *bs; /* Will be reg anyway on a decent CPU/compiler */ /* Process the "head" of the mask, if any */ while ((ch = *m++) && (ch != '*')) switch (ch) { case '\\': if (*m == '?' || *m == '*') ch = *m++; default: if (ToLower(*s) != ToLower(ch)) return 1; case '?': if (!*s++) return 1; }; if (!ch) return *s; /* We got a star: quickly find if/where we match the next char */ got_star: bm = m; /* Next try rollback here */ while ((ch = *m++)) switch (ch) { case '?': if (!*s++) return 1; case '*': bm = m; continue; /* while */ case '\\': if (*m == '?' || *m == '*') ch = *m++; default: goto break_while; /* C is structured ? */ }; break_while: if (!ch) return 0; /* mask ends with '*', we got it */ ch = ToLower(ch); while (ToLower(*s++) != ch) if (!*s) return 1; bs = s; /* Next try start from here */ /* Check the rest of the "chunk" */ while ((ch = *m++)) { switch (ch) { case '*': goto got_star; case '\\': if (*m == '?' || *m == '*') ch = *m++; default: if (ToLower(*s) != ToLower(ch)) { m = bm; s = bs; goto got_star; }; case '?': if (!*s++) return 1; }; }; if (*s) { m = bm; s = bs; goto got_star; }; return 0; } --- NEW FILE: match.h --- /* match.h * * This file is part of Craw. * * Craw 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. * * Craw 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. * * $Id: match.h,v 1.1 2003/02/06 23:55:01 flymac Exp $ */ #pragma once #if defined(__cplusplus) extern "C" { #endif extern int match(const char *mask, const char *string); #if defined(__cplusplus) } #endif --- NEW FILE: talk.m --- /* talk.m - mod_talk module * * Copyright (C) 2003 Kevin Roettger <fl...@lo...> * This file is part of Craw. * * Craw 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. * * Craw 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. * * $Id: talk.m,v 1.1 2003/02/06 23:55:01 flymac Exp $ */ #import <Cocoa/Cocoa.h> #import <Foundation/Foundation.h> #import "CrawCoreInterface.h" #import "TalkCenter.h" enum { kCCCommandAdd = 'AddE', // here we register our 4 commands kCCCommandRep = 'RepE', // the terms in '' are the internal referrers, always use 4 chars kCCCommandDel = 'DelE', // and -please- incluse at least one capital kCCCommandRaw = 'RawE' }; static NSAutoreleasePool *talkPool; void _CrawModuleInit(CCModuleRef module) { NSLog(@"_CrawModuleInit admin"); talkPool = [[NSAutoreleasePool alloc] init]; CCEventRegisterCommand(module, CFSTR("add"), TRUE, kCCCommandAdd); CCEventRegisterCommand(module, CFSTR("rep"), TRUE, kCCCommandRep); CCEventRegisterCommand(module, CFSTR("del"), TRUE, kCCCommandDel); CCEventRegisterCommand(module, CFSTR("raw"), TRUE, kCCCommandRaw); CCEventRegister(module, kCCEventChannelMessage); NSString *prefsPath = (NSString *) CCModuleGetBasePrefsDirectoryPath(); NSLog(prefsPath); [TalkCenter importPrefPath:prefsPath]; } void _CrawModuleDestroy() // called when a module gets unloaded { NSLog (@"_CrawModuleDestroy cmd_admin"); [talkPool release]; } bool _CrawModuleHandleEvent( CCBotRef inBot, CCEventID inEventID, CFTypeRef inData) { NSLog (@"_CrawModuleHandleEvent (cmd_talk)"); switch (inEventID) { case kCCEventChannelMessage: { /* kCCEventChannelMessage * An user's just msg'd or notice'd the channel. * * Data: CFDictionary * --> kkCCChannelKey : channel (CFString) * --> kCCSourceKey : source (nick!user@host) (CFString) * --> kCCMessageKey : the notice message (CFStringRef) * --> kCCNoticedKey : true if it's a /notice, false if it's a /msg * H ben si. */ NSAutoreleasePool *msgPool2 = [[NSAutoreleasePool alloc] init]; NSDictionary *dict = (NSDictionary *)inData; NSMutableDictionary *fullDict = [[[NSMutableDictionary alloc] init] retain]; CCChannelRef theTarget = CCChannelGetFromName(inBot, [dict objectForKey:@"channel"]); [fullDict setObject:[NSValue valueWithPointer:theTarget] forKey:@"TheTarget"]; [fullDict addEntriesFromDictionary:dict]; [[TalkCenter class] performSelectorOnMainThread:@selector(checkTalkMessage:) withObject:fullDict waitUntilDone:TRUE]; [msgPool2 release]; break; } case kCCCommandAdd: { NSAutoreleasePool *addPool = [[NSAutoreleasePool alloc] init]; NSDictionary *dict = (NSDictionary *)inData; CCChannelRef theTarget = CCChannelGetFromName(inBot, [dict objectForKey:@"channel"]); NSMutableDictionary *fullDict = [[[NSMutableDictionary alloc] init] retain]; [fullDict setObject:[NSValue valueWithPointer:inBot] forKey:@"TheBot"]; [fullDict setObject:[NSValue valueWithPointer:theTarget] forKey:@"TheTarget"]; [fullDict addEntriesFromDictionary:dict]; [[TalkCenter class] performSelectorOnMainThread:@selector(addEntry:) withObject:fullDict waitUntilDone:TRUE]; [addPool release]; break; } case kCCCommandRep: { NSDictionary *dict = (NSDictionary *)inData; break; } case kCCCommandDel: { NSDictionary *dict = (NSDictionary *)inData; break; } case kCCCommandRaw: { NSDictionary *dict = (NSDictionary *)inData; } } return FALSE; } |
From: Kevin R. <fl...@us...> - 2003-02-06 23:53:20
|
Update of /cvsroot/craw/Craw/Sources/Modules/mod_talk In directory sc8-pr-cvs1:/tmp/cvs-serv21478/mod_talk Log Message: Directory /cvsroot/craw/Craw/Sources/Modules/mod_talk added to the repository |
From: Stephane T. <mb...@us...> - 2003-02-06 23:04:28
|
Update of /cvsroot/craw/Craw/Sources/Core In directory sc8-pr-cvs1:/tmp/cvs-serv25140 Modified Files: CrawSendMsg.cpp Log Message: Removing annoying debugs Index: CrawSendMsg.cpp =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Core/CrawSendMsg.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CrawSendMsg.cpp 1 Feb 2003 13:52:41 -0000 1.4 --- CrawSendMsg.cpp 6 Feb 2003 23:04:24 -0000 1.5 *************** *** 19,22 **** --- 19,23 ---- #include "CrawSendMsg.h" + #include "CrawLoggingFacility.h" #define COMPAREPRIO(p1, p2) ((p1) > (p2)) *************** *** 56,60 **** CFIndex usedBufLen; ! printf("FillBuffer: length=%d\n", length); CFStringGetBytes(mMessage, --- 57,61 ---- CFIndex usedBufLen; ! CCLog(CFSTR("FillBuffer: length=%d"), length); CFStringGetBytes(mMessage, *************** *** 67,71 **** &usedBufLen); ! printf("usedBufLen=%d\n", usedBufLen); return usedBufLen; --- 68,72 ---- &usedBufLen); ! CCLog(CFSTR("usedBufLen=%d"), usedBufLen); return usedBufLen; |
From: Kevin R. <fl...@us...> - 2003-02-02 23:22:51
|
Update of /cvsroot/craw/Craw/CrawConfig/English.lproj/MainMenu.nib In directory sc8-pr-cvs1:/tmp/cvs-serv11440/English.lproj/MainMenu.nib Modified Files: classes.nib info.nib objects.nib Log Message: on est pas rendus *g* Index: classes.nib =================================================================== RCS file: /cvsroot/craw/Craw/CrawConfig/English.lproj/MainMenu.nib/classes.nib,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** classes.nib 2 Feb 2003 00:31:30 -0000 1.1 --- classes.nib 2 Feb 2003 23:22:48 -0000 1.2 *************** *** 5,9 **** --- 5,11 ---- activeModulesClick = id; botCombo = id; + channelsCombo = id; disabledModulesClick = id; + enableBot = id; makeModuleActive = id; makeModuleInactive = id; *************** *** 20,23 **** --- 22,26 ---- channelsComboBox = id; crawconfWindow = id; + enableBotBox = id; encodingPopup = id; networkComboBox = id; Index: info.nib =================================================================== RCS file: /cvsroot/craw/Craw/CrawConfig/English.lproj/MainMenu.nib/info.nib,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** info.nib 2 Feb 2003 14:44:25 -0000 1.2 --- info.nib 2 Feb 2003 23:22:48 -0000 1.3 *************** *** 4,8 **** <dict> <key>IBDocumentLocation</key> ! <string>502 64 356 240 0 0 1152 746 </string> <key>IBEditorPositions</key> <dict> --- 4,8 ---- <dict> <key>IBDocumentLocation</key> ! <string>416 49 356 240 0 0 1152 746 </string> <key>IBEditorPositions</key> <dict> Index: objects.nib =================================================================== RCS file: /cvsroot/craw/Craw/CrawConfig/English.lproj/MainMenu.nib/objects.nib,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsiJhBwU and /tmp/cvsYXjdJE differ |
From: Kevin R. <fl...@us...> - 2003-02-02 23:22:51
|
Update of /cvsroot/craw/Craw/CrawConfig In directory sc8-pr-cvs1:/tmp/cvs-serv11440 Modified Files: CConfigController.h CConfigController.m Log Message: on est pas rendus *g* Index: CConfigController.h =================================================================== RCS file: /cvsroot/craw/Craw/CrawConfig/CConfigController.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CConfigController.h 2 Feb 2003 14:44:25 -0000 1.2 --- CConfigController.h 2 Feb 2003 23:22:48 -0000 1.3 *************** *** 19,22 **** --- 19,24 ---- IBOutlet id startButton; IBOutlet id usernameField; + IBOutlet id enableBotBox; + NSMutableDictionary *ccConfigDict; // main big brozah dictionary (/root) *************** *** 33,40 **** } - - (int)numberOfRowsInTableView:(NSTableView *)aTableView; - - (id)tableView:(NSTableView *)aTableView - objectValueForTableColumn:(NSTableColumn *)aTableColumn - row:(int)rowIndex; - (IBAction)makeModuleActive:(id)sender; - (IBAction)makeModuleInactive:(id)sender; --- 35,38 ---- *************** *** 47,50 **** --- 45,50 ---- - (IBAction)disabledModulesClick:(id)sender; - (IBAction)activeModulesClick:(id)sender; + - (IBAction)enableBot:(id)sender; + - (IBAction)channelsCombo:(id)sender; @end Index: CConfigController.m =================================================================== RCS file: /cvsroot/craw/Craw/CrawConfig/CConfigController.m,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CConfigController.m 2 Feb 2003 14:44:25 -0000 1.2 --- CConfigController.m 2 Feb 2003 23:22:48 -0000 1.3 *************** *** 30,49 **** [[[ccBndl bundlePath] substringWithRange: NSMakeRange(0, [[ccBndl bundlePath] length]-31)] stringByAppendingString:@"build/crawconf.plist"]]; - - //NSLog(@"ccConfigDict description: %@", [ccConfigDict description]); ccBotsArray = [ccConfigDict objectForKey:@"bots"]; - //NSLog(@"ccBotsArray description: %@", [ccBotsArray description]); - ccCoreDict = [ccConfigDict objectForKey:@"core"]; - //NSLog(@"ccCoreDict description: %@", [ccCoreDict description]); - ccNetworksArray = [ccConfigDict objectForKey:@"networks"]; - //NSLog(@"ccNetworksArray description: %@", [ccNetworksArray description]); - ccModules = [ccCoreDict objectForKey:@"modules"]; ! ! NSLog(@"-> %@", [[ccModules objectAtIndex:2] objectForKey:@"path"]); ! for(i=0;i<[ccModules count];i++) { --- 30,39 ---- [[[ccBndl bundlePath] substringWithRange: NSMakeRange(0, [[ccBndl bundlePath] length]-31)] stringByAppendingString:@"build/crawconf.plist"]]; ccBotsArray = [ccConfigDict objectForKey:@"bots"]; ccCoreDict = [ccConfigDict objectForKey:@"core"]; ccNetworksArray = [ccConfigDict objectForKey:@"networks"]; ccModules = [ccCoreDict objectForKey:@"modules"]; ! for(i=0;i<[ccModules count];i++) { *************** *** 83,90 **** NSLog(@"awakeFromNib"); - //[botComboBox setUsesDataSource:YES]; - //[botComboBox setDataSource:self]; - //[botComboBox reloadData]; - [crawconfWindow makeKeyAndOrderFront:self]; --- 73,76 ---- *************** *** 94,97 **** --- 80,86 ---- [networkPopup removeAllItems]; [networkPopup addItemsWithTitles:networksArray]; + [networkPopup selectItemWithTitle:[[ccBotsArray objectAtIndex:0] objectForKey:@"network"]]; + + // channelsComboBox } *************** *** 99,103 **** - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index { ! return [botNicks objectAtIndex:index]; } --- 88,99 ---- - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index { ! NSString *zeItem = [[NSString alloc] init]; ! ! if ([aComboBox tag] == 0) ! zeItem = [botNicks objectAtIndex:index]; ! else if ([aComboBox tag] == 1) ! zeItem = [botNicks objectAtIndex:index]; ! ! return zeItem; } *************** *** 129,132 **** --- 125,129 ---- else if ([aTableView tag] == 1) n = enabledMod; + return n; } *************** *** 145,151 **** { NSLog(@"reloadButton:"); - /* [botComboBox setUsesDataSource:TRUE]; - [botComboBox setDataSource:self]; - [botComboBox reloadData]; */ } --- 142,145 ---- *************** *** 184,186 **** --- 178,191 ---- NSLog(@"activeModulesClick:"); } + + - (IBAction)enableBot:(id)sender + { + NSLog(@"enableBot:"); + } + + - (IBAction)channelsCombo:(id)sender + { + NSLog(@"channelsCombo:"); + } + @end |
From: Stephane T. <mb...@us...> - 2003-02-02 18:49:15
|
Update of /cvsroot/craw/Craw/Sources/Modules/cmd_memo In directory sc8-pr-cvs1:/tmp/cvs-serv25933/cmd_memo Modified Files: Makefile Log Message: Users authentication module. Index: Makefile =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/cmd_memo/Makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile 1 Feb 2003 14:30:47 -0000 1.5 --- Makefile 2 Feb 2003 18:49:11 -0000 1.6 *************** *** 4,7 **** --- 4,8 ---- # # Makefile configuration + MACOSX_DEPLOYMENT_TARGET = 10.2 LIBS = -framework Foundation CC = gcc |
From: Stephane T. <mb...@us...> - 2003-02-02 18:49:14
|
Update of /cvsroot/craw/Craw/Sources/Modules/mod_auth In directory sc8-pr-cvs1:/tmp/cvs-serv25933/mod_auth Added Files: MAInterface.h MAInterface.m Makefile auth.m Log Message: Users authentication module. --- NEW FILE: MAInterface.h --- /* MAInterface.h - mod_auth module * * Copyright (C) 2003 Stephane Thiell <mb...@bu...> * This file is part of Craw. * * Craw 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. * * Craw 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. * * $Id: MAInterface.h,v 1.1 2003/02/02 18:49:11 mbuna Exp $ */ #include "CrawCoreInterface.h" /*! @function MAUserIsOwner @discussion Verify the login and password and returns TRUE if it matchs the owner. @param inLogin Login name of the user. @param inPassword Pass phrase (as entered by the user). @result TRUE if this is the login/password of the owner. */ extern bool MAUserIsOwner(CFStringRef inLogin, CFStringRef inPassword); typedef bool (*MAUserIsOwnerProc)(CFStringRef inLogin, CFStringRef inPassword); /*! @function MAUserGetGlobalLevel @discussion Get access level for a login and password, on the specified bot. Because it's possible, this function give some useful additional information (eg. the possibility to know if the user is a channel "local" user). @param inBot The concerned bot. @param inLogin Login name of the user. @param inPassword Pass phrase (as entered by the user). @result The global access level: 1001 if the user is the owner, in the range 501-1000 if the global user is found, 1 if the user if found as a local user (you could then use MAUserGetChannelLevel) and 0 if the login/password is not found at all. */ extern int MAUserGetGlobalLevel(CCBotRef inBot, CFStringRef inLogin, CFStringRef inPassword); typedef int (*MAUserGetGlobalLevelProc)(CCBotRef inBot, CFStringRef inLogin, CFStringRef inPassword); /*! @function MAUserGetChannelLevel @discussion Get the access level for a login and password, on the specified channel (bot implicitly specified). Because it's possible, this function give some useful additional information (eg. the possibility to check by the way global users too). @param inChannel Core channel instance to check. @param inLogin Login name of the user. @param inPassword Pass phrase (as entered by the user). @result The channel access level: 1001 if the user is the owner, in the range 501-1000 if a global user is found on this bot, in the range 1-500 if the user is known to have access on this channel and 0 if the login/password is not found at all. */ extern int MAUserGetChannelLevel(CCChannelRef inChannel, CFStringRef inLogin, CFStringRef inPassword); typedef int (*MAUserGetChannelLevelProc)(CCChannelRef inChannel, CFStringRef inLogin, CFStringRef inPassword); --- NEW FILE: MAInterface.m --- /* MAInterface.m - mod_auth module * * Copyright (C) 2003 Stephane Thiell <mb...@bu...> * This file is part of Craw. * * Craw 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. * * Craw 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. * * $Id: MAInterface.m,v 1.1 2003/02/02 18:49:11 mbuna Exp $ */ #include "MAInterface.h" bool MAUserIsOwner(CFStringRef inLogin, CFStringRef inPassword) { printf("MAUserIsOwner test\n"); return true; } int MAUserGetGlobalLevel(CCBotRef inBot, CFStringRef inLogin, CFStringRef inPassword) { return 1001; } int MAUserGetChannelLevel(CCChannelRef inChannel, CFStringRef inLogin, CFStringRef inPassword) { return 1001; } --- NEW FILE: Makefile --- # Craw IRC Bot - Makefile # $Revision: 1.1 $ # $Date: 2003/02/02 18:49:11 $ # # Makefile configuration LIBS = -framework Foundation CC = gcc CXX = g++ CPPFLAGS=-I. -I../../Core/export -pipe CFLAGS = -Wall -g -O2 DEFS = MAKE = make # Undefined symbols: warning or suppress UNDEFSYM = suppress BUNDLE = mod_auth.so MODNAME = mod_auth MODDESC = Users authentication # Module objects OBJS = auth.o MAInterface.o SRC = ${OBJS:%.o=%.m} ## End of Makefile configuration all: mod .c.o: ${CXX} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ mod: ${OBJS} @echo "Bundling module: ${MODDESC}..."; ${CXX} -bundle -flat_namespace -undefined ${UNDEFSYM} -o ${BUNDLE} ${OBJS} ${LIBS}; mv ${BUNDLE} ../../../build/modules/ clean: @echo "Cleaning objects in ${MODNAME}."; @rm -f *.o *~ *.core re: clean all --- NEW FILE: auth.m --- /* auth.m - mod_auth module * * Copyright (C) 2003 Stephane Thiell <mb...@bu...> * This file is part of Craw. * * Craw 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. * * Craw 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. * * $Id: auth.m,v 1.1 2003/02/02 18:49:11 mbuna Exp $ */ #include "CrawCoreInterface.h" enum { kCCCommandLogin = 'LogI', // warning: all lowercase eventIDs are reserved by the Core kCCCommandLogout = 'LogO' }; void _CrawModuleInit(CCModuleRef module) { // Commands handled by this module: CCEventRegisterCommand(module, CFSTR("login"), TRUE, kCCCommandLogin); CCEventRegisterCommand(module, CFSTR("logout"), TRUE, kCCCommandLogout); } void _CrawModuleDestroy() { } bool _CrawModuleHandleEvent( CCBotRef inBot, CCEventID inEventID, CFTypeRef inData) { switch (inEventID) { case kCCCommandLogin: // Uh oh. break; } return false; } |
From: Stephane T. <mb...@us...> - 2003-02-02 18:49:14
|
Update of /cvsroot/craw/Craw/Sources/Modules/mod_ctcp In directory sc8-pr-cvs1:/tmp/cvs-serv25933/mod_ctcp Modified Files: Makefile Log Message: Users authentication module. Index: Makefile =================================================================== RCS file: /cvsroot/craw/Craw/Sources/Modules/mod_ctcp/Makefile,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile 1 Feb 2003 16:05:10 -0000 1.5 --- Makefile 2 Feb 2003 18:49:11 -0000 1.6 *************** *** 19,23 **** # Module objects OBJS = mod.o ctcp.o ! SRC = ${OBJS:%.o=%.m} ## End of Makefile configuration --- 19,23 ---- # Module objects OBJS = mod.o ctcp.o ! SRC = ${OBJS:%.o=%.c} ## End of Makefile configuration |
From: Stephane T. <mb...@us...> - 2003-02-02 18:46:27
|
Update of /cvsroot/craw/Craw/Sources/Modules/mod_auth In directory sc8-pr-cvs1:/tmp/cvs-serv24842/mod_auth Log Message: Directory /cvsroot/craw/Craw/Sources/Modules/mod_auth added to the repository |
From: Kevin R. <fl...@us...> - 2003-02-02 14:44:28
|
Update of /cvsroot/craw/Craw/CrawConfig In directory sc8-pr-cvs1:/tmp/cvs-serv2557 Modified Files: CConfigController.h CConfigController.m Log Message: updating a bit Index: CConfigController.h =================================================================== RCS file: /cvsroot/craw/Craw/CrawConfig/CConfigController.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CConfigController.h 2 Feb 2003 00:28:52 -0000 1.1 --- CConfigController.h 2 Feb 2003 14:44:25 -0000 1.2 *************** *** 19,23 **** --- 19,40 ---- IBOutlet id startButton; IBOutlet id usernameField; + + NSMutableDictionary *ccConfigDict; // main big brozah dictionary (/root) + + NSMutableArray *ccBotsArray; // /root/bots Array + NSMutableDictionary *ccCoreDict; // /root/core Dictionary + NSMutableArray *ccNetworksArray; // /root/networks Array + NSMutableArray *ccModules; // /root/core/modules Array + NSMutableArray *activeMod; + NSMutableArray *inactivedMod; + NSMutableArray *botNicks; + NSMutableArray *networksArray; + } + + - (int)numberOfRowsInTableView:(NSTableView *)aTableView; + - (id)tableView:(NSTableView *)aTableView + objectValueForTableColumn:(NSTableColumn *)aTableColumn + row:(int)rowIndex; - (IBAction)makeModuleActive:(id)sender; - (IBAction)makeModuleInactive:(id)sender; *************** *** 30,32 **** --- 47,50 ---- - (IBAction)disabledModulesClick:(id)sender; - (IBAction)activeModulesClick:(id)sender; + @end Index: CConfigController.m =================================================================== RCS file: /cvsroot/craw/Craw/CrawConfig/CConfigController.m,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CConfigController.m 2 Feb 2003 00:28:52 -0000 1.1 --- CConfigController.m 2 Feb 2003 14:44:25 -0000 1.2 *************** *** 3,15 **** @implementation CConfigController ! NSMutableDictionary *ccConfigDict; // main big brozah dictionary (/root) ! ! NSMutableArray *ccBotsArray; // /root/bots Array ! NSMutableDictionary *ccCoreDict; // /root/core Dictionary ! NSMutableArray *ccNetworksArray; // /root/networks Array ! - (void)awakeFromNib { - NSLog(@"awakeFromNib"); NSBundle *ccBndl = [NSBundle mainBundle]; ccConfigDict = [[NSMutableDictionary alloc] init]; --- 3,10 ---- @implementation CConfigController ! int enabledMod, disabledMod, botNum; ! - (id)init { NSBundle *ccBndl = [NSBundle mainBundle]; ccConfigDict = [[NSMutableDictionary alloc] init]; *************** *** 17,20 **** --- 12,26 ---- ccCoreDict = [[NSMutableDictionary alloc] init]; ccNetworksArray = [[NSMutableArray alloc] init]; + ccModules = [[NSMutableArray alloc] init]; + activeMod = [[NSMutableArray alloc] init]; + inactivedMod = [[NSMutableArray alloc] init]; + botNicks = [[NSMutableArray alloc] init]; + networksArray = [[NSMutableArray alloc] init]; + + int i; + + enabledMod = 0; + disabledMod = 0; + NSLog(@"self path: %@", [[[ccBndl bundlePath] substringWithRange: *************** *** 28,50 **** ccBotsArray = [ccConfigDict objectForKey:@"bots"]; ! NSLog(@"ccBotsArray description: %@", [ccBotsArray description]); ccCoreDict = [ccConfigDict objectForKey:@"core"]; ! NSLog(@"ccCoreDict description: %@", [ccCoreDict description]); ccNetworksArray = [ccConfigDict objectForKey:@"networks"]; ! NSLog(@"ccNetworksArray description: %@", [ccNetworksArray description]); } - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { ! return @"blah blah"; } - (int)numberOfRowsInTableView:(NSTableView *)aTableView { ! return 5; } --- 34,133 ---- ccBotsArray = [ccConfigDict objectForKey:@"bots"]; ! //NSLog(@"ccBotsArray description: %@", [ccBotsArray description]); ccCoreDict = [ccConfigDict objectForKey:@"core"]; ! //NSLog(@"ccCoreDict description: %@", [ccCoreDict description]); ccNetworksArray = [ccConfigDict objectForKey:@"networks"]; ! //NSLog(@"ccNetworksArray description: %@", [ccNetworksArray description]); ! ! ccModules = [ccCoreDict objectForKey:@"modules"]; ! ! NSLog(@"-> %@", [[ccModules objectAtIndex:2] objectForKey:@"path"]); ! ! for(i=0;i<[ccModules count];i++) ! { ! if ([[[ccModules objectAtIndex:i] objectForKey:@"enabled"] boolValue] == FALSE) ! { ! disabledMod++; ! [inactivedMod addObject:[[ccModules objectAtIndex:i] objectForKey:@"path"]]; ! } ! } ! ! for(i=0;i<[ccModules count];i++) ! { ! if ([[[ccModules objectAtIndex:i] objectForKey:@"enabled"] boolValue] == TRUE) ! { ! enabledMod++; ! [activeMod addObject:[[ccModules objectAtIndex:i] objectForKey:@"path"]]; ! } ! } ! ! botNum = [ccBotsArray count]; ! ! for(i=0;i<[ccBotsArray count];i++) ! { ! [botNicks addObject:[[ccBotsArray objectAtIndex:i] objectForKey:@"birthname"]]; ! } ! ! for(i=0;i<[ccNetworksArray count];i++) ! { ! [networksArray addObject:[[ccNetworksArray objectAtIndex:i] objectForKey:@"name"]]; ! } ! ! return self; ! } ! ! - (void)awakeFromNib ! { ! NSLog(@"awakeFromNib"); ! ! //[botComboBox setUsesDataSource:YES]; ! //[botComboBox setDataSource:self]; ! //[botComboBox reloadData]; ! ! [crawconfWindow makeKeyAndOrderFront:self]; ! ! [botComboBox setNumberOfVisibleItems:[ccBotsArray count]]; ! [botComboBox selectItemAtIndex:0]; ! ! [networkPopup removeAllItems]; ! [networkPopup addItemsWithTitles:networksArray]; ! } + - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)index + { + return [botNicks objectAtIndex:index]; + } + + - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox + { + return botNum; + } + - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { ! NSString *zeModule = [[NSString alloc] init]; ! ! if ([aTableView tag] == 0) ! zeModule = [inactivedMod objectAtIndex:rowIndex]; ! else if ([aTableView tag] == 1) ! zeModule = [activeMod objectAtIndex:rowIndex]; ! ! return zeModule; } - (int)numberOfRowsInTableView:(NSTableView *)aTableView { ! int n; ! ! if ([aTableView tag] == 0) ! n = disabledMod; ! else if ([aTableView tag] == 1) ! n = enabledMod; ! return n; } *************** *** 62,65 **** --- 145,151 ---- { NSLog(@"reloadButton:"); + /* [botComboBox setUsesDataSource:TRUE]; + [botComboBox setDataSource:self]; + [botComboBox reloadData]; */ } |
From: Kevin R. <fl...@us...> - 2003-02-02 14:44:28
|
Update of /cvsroot/craw/Craw/CrawConfig/English.lproj/MainMenu.nib In directory sc8-pr-cvs1:/tmp/cvs-serv2557/English.lproj/MainMenu.nib Modified Files: info.nib objects.nib Log Message: updating a bit Index: info.nib =================================================================== RCS file: /cvsroot/craw/Craw/CrawConfig/English.lproj/MainMenu.nib/info.nib,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** info.nib 2 Feb 2003 00:31:30 -0000 1.1 --- info.nib 2 Feb 2003 14:44:25 -0000 1.2 *************** *** 4,8 **** <dict> <key>IBDocumentLocation</key> ! <string>419 64 356 240 0 0 1152 746 </string> <key>IBEditorPositions</key> <dict> --- 4,8 ---- <dict> <key>IBDocumentLocation</key> ! <string>502 64 356 240 0 0 1152 746 </string> <key>IBEditorPositions</key> <dict> *************** *** 14,19 **** <key>IBOpenObjects</key> <array> - <integer>29</integer> <integer>21</integer> </array> <key>IBSystem Version</key> --- 14,19 ---- <key>IBOpenObjects</key> <array> <integer>21</integer> + <integer>29</integer> </array> <key>IBSystem Version</key> Index: objects.nib =================================================================== RCS file: /cvsroot/craw/Craw/CrawConfig/English.lproj/MainMenu.nib/objects.nib,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsvTYfS4 and /tmp/cvsAg83rZ differ |
From: Kevin R. <fl...@us...> - 2003-02-02 00:31:34
|
Update of /cvsroot/craw/Craw/CrawConfig/English.lproj/MainMenu.nib In directory sc8-pr-cvs1:/tmp/cvs-serv19704 Added Files: classes.nib info.nib objects.nib Log Message: MainMenu.nib contents --- NEW FILE: classes.nib --- { IBClasses = ( { ACTIONS = { activeModulesClick = id; botCombo = id; disabledModulesClick = id; makeModuleActive = id; makeModuleInactive = id; networkCombo = id; reloadButton = id; restartButton = id; serverCombo = id; startCrawButton = id; }; CLASS = CConfigController; LANGUAGE = ObjC; OUTLETS = { botComboBox = id; channelsComboBox = id; crawconfWindow = id; encodingPopup = id; networkComboBox = id; networkPopup = id; passwordField = id; portField = id; realnameField = id; reloadButton = id; restartButton = id; serversComboBox = id; startButton = id; usernameField = id; }; SUPERCLASS = NSObject; }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; } ); IBVersion = 1; } --- NEW FILE: info.nib --- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>IBDocumentLocation</key> <string>419 64 356 240 0 0 1152 746 </string> <key>IBEditorPositions</key> <dict> <key>29</key> <string>-1 30 318 44 0 0 1152 746 </string> </dict> <key>IBFramework Version</key> <string>291.0</string> <key>IBOpenObjects</key> <array> <integer>29</integer> <integer>21</integer> </array> <key>IBSystem Version</key> <string>6G30</string> <key>IBUserGuides</key> <dict> <key>21</key> <dict> <key>guideLocations</key> <array> <string>Horizontal:188.000000</string> <string>Vertical:259.000000</string> <string>Horizontal:188.000000</string> <string>Vertical:259.000000</string> </array> <key>guidesLocked</key> <false/> </dict> </dict> </dict> </plist> --- NEW FILE: objects.nib --- (This appears to be a binary file; contents omitted.) |