You can subscribe to this list here.
2006 |
Jan
|
Feb
(24) |
Mar
(9) |
Apr
(4) |
May
(7) |
Jun
(13) |
Jul
(19) |
Aug
(1) |
Sep
(12) |
Oct
(20) |
Nov
(1) |
Dec
(15) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
(6) |
Mar
(24) |
Apr
(1) |
May
(10) |
Jun
(30) |
Jul
(46) |
Aug
(20) |
Sep
(12) |
Oct
(27) |
Nov
(51) |
Dec
(58) |
2008 |
Jan
(40) |
Feb
(40) |
Mar
(78) |
Apr
(138) |
May
(4) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(5) |
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
(2) |
Jul
(10) |
Aug
(1) |
Sep
(11) |
Oct
(31) |
Nov
(7) |
Dec
(1) |
2011 |
Jan
(1) |
Feb
|
Mar
(3) |
Apr
|
May
(1) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
(2) |
Dec
(2) |
2013 |
Jan
(3) |
Feb
(5) |
Mar
(1) |
Apr
|
May
|
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(4) |
2014 |
Jan
(2) |
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2025 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <arn...@us...> - 2007-12-03 22:25:42
|
Revision: 926 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=926&view=rev Author: arnetheduck Date: 2007-12-03 14:25:40 -0800 (Mon, 03 Dec 2007) Log Message: ----------- patches, begin upgrade to adc 1.0 (protocol string, features, error handling etc) Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/dcpp/AdcCommand.h dcplusplus/trunk/dcpp/AdcHub.cpp dcplusplus/trunk/dcpp/AdcHub.h dcplusplus/trunk/dcpp/BufferedSocket.cpp dcplusplus/trunk/dcpp/ClientManager.cpp dcplusplus/trunk/dcpp/FavoriteManager.cpp dcplusplus/trunk/dcpp/FavoriteManager.h dcplusplus/trunk/dcpp/SearchManager.cpp dcplusplus/trunk/dcpp/User.h dcplusplus/trunk/dcpp/UserCommand.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetToolbar.h dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp dcplusplus/trunk/smartwin/source/widgets/WidgetToolbar.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/changelog.txt 2007-12-03 22:25:40 UTC (rev 926) @@ -7,7 +7,7 @@ * Fixed version info (poy) * Keep selection visible on move up/down in some list views (poy) * Fixed clicking in the header of the favorite hubs list view (poy) -* Update to ADC 0.14 +* Update to ADC 1.0 * Fixed pressing enter in the notepad (poy) * Fixed user commands params (poy) * Readded list view double buffering (thanks poy) @@ -19,6 +19,10 @@ * Fixed user list filter (poy) * Readded chat message box auto-scroll (poy) * Fixed tab order in public hubs (poy) +* Tooltips for toolbars (thanks poy) +* Close tab with middle mouse button (thanks poy) +* Fixed socket ip bind (thanks garg's quasi-friend) +* Finished UCMD extension draft implementation -- 0.703 2007-11-08 -- * Fixed invalid strings (thanks james ross) Modified: dcplusplus/trunk/dcpp/AdcCommand.h =================================================================== --- dcplusplus/trunk/dcpp/AdcCommand.h 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/dcpp/AdcCommand.h 2007-12-03 22:25:40 UTC (rev 926) @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#if !defined(ADC_COMMAND_H) -#define ADC_COMMAND_H +#ifndef DCPLUSPLUS_DCPP_ADC_COMMAND_H +#define DCPLUSPLUS_DCPP_ADC_COMMAND_H #include "SettingsManager.h" #include "Exception.h" @@ -58,10 +58,12 @@ ERROR_BAD_STATE = 44, ERROR_FEATURE_MISSING = 45, ERROR_BAD_IP = 46, + ERROR_NO_HUB_HASH = 47, ERROR_TRANSFER_GENERIC = 50, ERROR_FILE_NOT_AVAILABLE = 51, ERROR_FILE_PART_NOT_AVAILABLE = 52, - ERROR_SLOTS_FULL = 53 + ERROR_SLOTS_FULL = 53, + ERROR_NO_CLIENT_HASH = 54 }; enum Severity { Modified: dcplusplus/trunk/dcpp/AdcHub.cpp =================================================================== --- dcplusplus/trunk/dcpp/AdcHub.cpp 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/dcpp/AdcHub.cpp 2007-12-03 22:25:40 UTC (rev 926) @@ -28,21 +28,22 @@ #include "version.h" #include "Util.h" #include "UserCommand.h" -#include "FavoriteManager.h" #include "CryptoManager.h" #include "ResourceManager.h" #include "LogManager.h" namespace dcpp { -const string AdcHub::CLIENT_PROTOCOL("ADC/0.10"); -const string AdcHub::SECURE_CLIENT_PROTOCOL("ADCS/0.10"); +const string AdcHub::CLIENT_PROTOCOL("ADC/1.0"); +const string AdcHub::CLIENT_PROTOCOL_TEST("ADC/0.10"); +const string AdcHub::SECURE_CLIENT_PROTOCOL_TEST("ADCS/0.10"); const string AdcHub::ADCS_FEATURE("ADC0"); const string AdcHub::TCP4_FEATURE("TCP4"); const string AdcHub::UDP4_FEATURE("UDP4"); const string AdcHub::BASE_SUPPORT("ADBASE"); const string AdcHub::BAS0_SUPPORT("ADBAS0"); const string AdcHub::TIGR_SUPPORT("ADTIGR"); +const string AdcHub::UCM0_SUPPORT("ADUCM0"); AdcHub::AdcHub(const string& aHubURL, bool secure) : Client(aHubURL, '\n', secure), sid(0) { TimerManager::getInstance()->addListener(this); @@ -288,10 +289,10 @@ token = c.getParam(2); } - bool secure; - if(protocol == CLIENT_PROTOCOL) { - secure = false; - } else if(protocol == SECURE_CLIENT_PROTOCOL && CryptoManager::getInstance()->TLSOk()) { + bool secure = false; + if(protocol == CLIENT_PROTOCOL || protocol == CLIENT_PROTOCOL_TEST) { + // Nothing special + } else if(protocol == SECURE_CLIENT_PROTOCOL_TEST && CryptoManager::getInstance()->TLSOk()) { secure = true; } else { AdcCommand cmd(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_UNSUPPORTED, "Protocol unknown"); @@ -328,9 +329,9 @@ bool hasToken = c.getParam("TO", 1, token); bool secure; - if(protocol == CLIENT_PROTOCOL) { + if(protocol == CLIENT_PROTOCOL || protocol == CLIENT_PROTOCOL_TEST) { secure = false; - } else if(protocol == SECURE_CLIENT_PROTOCOL && CryptoManager::getInstance()->TLSOk()) { + } else if(protocol == SECURE_CLIENT_PROTOCOL_TEST && CryptoManager::getInstance()->TLSOk()) { secure = true; } else { AdcCommand cmd(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_UNSUPPORTED, "Protocol unknown"); @@ -352,9 +353,8 @@ const string& name = c.getParam(0); bool rem = c.hasFlag("RM", 1); if(rem) { - int cmd = FavoriteManager::getInstance()->findUserCommand(name); - if(cmd != -1) - FavoriteManager::getInstance()->removeUserCommand(cmd); + fire(ClientListener::HubUserCommand(), this, (int)UserCommand::TYPE_REMOVE, 0, name, Util::emptyString); + return; } bool sep = c.hasFlag("SP", 1); string sctx; @@ -364,14 +364,14 @@ if(ctx <= 0) return; if(sep) { - FavoriteManager::getInstance()->addUserCommand(UserCommand::TYPE_SEPARATOR, ctx, UserCommand::FLAG_NOSAVE, name, "", getHubUrl()); + fire(ClientListener::HubUserCommand(), this, (int)UserCommand::TYPE_SEPARATOR, ctx, name, Util::emptyString); return; } bool once = c.hasFlag("CO", 1); string txt; if(!c.getParam("TT", 1, txt)) return; - FavoriteManager::getInstance()->addUserCommand(once ? UserCommand::TYPE_RAW_ONCE : UserCommand::TYPE_RAW, ctx, UserCommand::FLAG_NOSAVE, name, txt, getHubUrl()); + fire(ClientListener::HubUserCommand(), this, (int)(once ? UserCommand::TYPE_RAW_ONCE : UserCommand::TYPE_RAW), ctx, name, txt); } void AdcHub::sendUDP(const AdcCommand& cmd) throw() { @@ -417,8 +417,19 @@ if(code == AdcCommand::ERROR_BAD_PASSWORD) { setPassword(Util::emptyString); + } else if(code == AdcCommand::ERROR_PROTOCOL_UNSUPPORTED) { + string tmp; + if(c.getParam("PR", 1, tmp)) { + if(tmp == CLIENT_PROTOCOL) { + u->getUser()->setFlag(User::NO_ADC_1_0_PROTOCOL); + } else if(tmp == CLIENT_PROTOCOL_TEST) { + u->getUser()->setFlag(User::NO_ADC_0_10_PROTOCOL); + } else if(tmp == SECURE_CLIENT_PROTOCOL_TEST) { + u->getUser()->setFlag(User::NO_ADCS_0_10_PROTOCOL); + u->getUser()->unsetFlag(User::TLS); + } + } } - // @todo Check for invalid protocol and unset TLS if necessary fire(ClientListener::Message(), this, *u, c.getParam(1)); } @@ -448,8 +459,26 @@ void AdcHub::connect(const OnlineUser& user, string const& token, bool secure) { if(state != STATE_NORMAL) return; + + const string* proto = 0; + if(secure) { + if(user.getUser()->isSet(User::NO_ADCS_0_10_PROTOCOL)) { + /// @todo log + return; + } + proto = &SECURE_CLIENT_PROTOCOL_TEST; + } else { + if(user.getUser()->isSet(User::NO_ADC_1_0_PROTOCOL)) { + if(user.getUser()->isSet(User::NO_ADC_0_10_PROTOCOL)) { + /// @todo log + return; + } + proto = &CLIENT_PROTOCOL_TEST; + } else { + proto = &CLIENT_PROTOCOL; + } + } - const string& proto = secure ? SECURE_CLIENT_PROTOCOL : CLIENT_PROTOCOL; if(ClientManager::getInstance()->isActive()) { uint16_t port = secure ? ConnectionManager::getInstance()->getSecurePort() : ConnectionManager::getInstance()->getPort(); if(port == 0) { @@ -457,9 +486,9 @@ LogManager::getInstance()->message(STRING(NOT_LISTENING)); return; } - send(AdcCommand(AdcCommand::CMD_CTM, user.getIdentity().getSID(), AdcCommand::TYPE_DIRECT).addParam(proto).addParam(Util::toString(port)).addParam(token)); + send(AdcCommand(AdcCommand::CMD_CTM, user.getIdentity().getSID(), AdcCommand::TYPE_DIRECT).addParam(*proto).addParam(Util::toString(port)).addParam(token)); } else { - send(AdcCommand(AdcCommand::CMD_RCM, user.getIdentity().getSID(), AdcCommand::TYPE_DIRECT).addParam(proto).addParam(token)); + send(AdcCommand(AdcCommand::CMD_RCM, user.getIdentity().getSID(), AdcCommand::TYPE_DIRECT).addParam(*proto).addParam(token)); } } @@ -576,7 +605,6 @@ addParam(lastInfoMap, c, "DS", Util::emptyString); } - string su; if(CryptoManager::getInstance()->TLSOk()) { su += ADCS_FEATURE + ","; @@ -637,7 +665,13 @@ lastInfoMap.clear(); sid = 0; - send(AdcCommand(AdcCommand::CMD_SUP, AdcCommand::TYPE_HUB).addParam(BAS0_SUPPORT).addParam(TIGR_SUPPORT)); + AdcCommand cmd(AdcCommand::CMD_SUP, AdcCommand::TYPE_HUB); + cmd.addParam(BAS0_SUPPORT).addParam(TIGR_SUPPORT); + + if(BOOLSETTING(HUB_USER_COMMANDS)) { + cmd.addParam(UCM0_SUPPORT); + } + send(cmd); } void AdcHub::on(Line, const string& aLine) throw() { Modified: dcplusplus/trunk/dcpp/AdcHub.h =================================================================== --- dcplusplus/trunk/dcpp/AdcHub.h 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/dcpp/AdcHub.h 2007-12-03 22:25:40 UTC (rev 926) @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#if !defined(ADC_HUB_H) -#define ADC_HUB_H +#ifndef DCPLUSPLUS_DCPP_ADC_HUB_H +#define DCPLUSPLUS_DCPP_ADC_HUB_H #include "Client.h" #include "AdcCommand.h" @@ -73,13 +73,15 @@ uint32_t sid; static const string CLIENT_PROTOCOL; - static const string SECURE_CLIENT_PROTOCOL; + static const string CLIENT_PROTOCOL_TEST; + static const string SECURE_CLIENT_PROTOCOL_TEST; static const string ADCS_FEATURE; static const string TCP4_FEATURE; static const string UDP4_FEATURE; static const string BASE_SUPPORT; static const string BAS0_SUPPORT; static const string TIGR_SUPPORT; + static const string UCM0_SUPPORT; virtual string checkNick(const string& nick); Modified: dcplusplus/trunk/dcpp/BufferedSocket.cpp =================================================================== --- dcplusplus/trunk/dcpp/BufferedSocket.cpp 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/dcpp/BufferedSocket.cpp 2007-12-03 22:25:40 UTC (rev 926) @@ -112,6 +112,7 @@ sock = secure ? CryptoManager::getInstance()->getClientSocket(allowUntrusted) : new Socket; sock->create(); + sock->bind(0, SETTING(BIND_ADDRESS)); if(SETTING(SOCKET_IN_BUFFER) >= 1024) sock->setSocketOpt(SO_RCVBUF, SETTING(SOCKET_IN_BUFFER)); if(SETTING(SOCKET_OUT_BUFFER) >= 1024) Modified: dcplusplus/trunk/dcpp/ClientManager.cpp =================================================================== --- dcplusplus/trunk/dcpp/ClientManager.cpp 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/dcpp/ClientManager.cpp 2007-12-03 22:25:40 UTC (rev 926) @@ -481,7 +481,11 @@ void ClientManager::on(HubUserCommand, Client* client, int aType, int ctx, const string& name, const string& command) throw() { if(BOOLSETTING(HUB_USER_COMMANDS)) { - if(aType == UserCommand::TYPE_CLEAR) { + if(aType == UserCommand::TYPE_REMOVE) { + int cmd = FavoriteManager::getInstance()->findUserCommand(name, client->getHubUrl()); + if(cmd != -1) + FavoriteManager::getInstance()->removeUserCommand(cmd); + } else if(aType == UserCommand::TYPE_CLEAR) { FavoriteManager::getInstance()->removeHubUserCommands(ctx, client->getHubUrl()); } else { FavoriteManager::getInstance()->addUserCommand(aType, ctx, UserCommand::FLAG_NOSAVE, name, command, client->getHubUrl()); Modified: dcplusplus/trunk/dcpp/FavoriteManager.cpp =================================================================== --- dcplusplus/trunk/dcpp/FavoriteManager.cpp 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/dcpp/FavoriteManager.cpp 2007-12-03 22:25:40 UTC (rev 926) @@ -98,10 +98,10 @@ save(); } -int FavoriteManager::findUserCommand(const string& aName) { +int FavoriteManager::findUserCommand(const string& aName, const string& aUrl) { Lock l(cs); for(UserCommand::List::iterator i = userCommands.begin(); i != userCommands.end(); ++i) { - if(i->getName() == aName) { + if(i->getName() == aName && i->getHub() == aUrl) { return i->getId(); } } Modified: dcplusplus/trunk/dcpp/FavoriteManager.h =================================================================== --- dcplusplus/trunk/dcpp/FavoriteManager.h 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/dcpp/FavoriteManager.h 2007-12-03 22:25:40 UTC (rev 926) @@ -90,7 +90,7 @@ // User Commands UserCommand addUserCommand(int type, int ctx, int flags, const string& name, const string& command, const string& hub); bool getUserCommand(int cid, UserCommand& uc); - int findUserCommand(const string& aName); + int findUserCommand(const string& aName, const string& aUrl); bool moveUserCommand(int cid, int pos); void updateUserCommand(const UserCommand& uc); void removeUserCommand(int cid); Modified: dcplusplus/trunk/dcpp/SearchManager.cpp =================================================================== --- dcplusplus/trunk/dcpp/SearchManager.cpp 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/dcpp/SearchManager.cpp 2007-12-03 22:25:40 UTC (rev 926) @@ -126,7 +126,7 @@ socket = new Socket(); socket->create(Socket::TYPE_UDP); - port = socket->bind(static_cast<uint16_t>(SETTING(UDP_PORT))); + port = socket->bind(static_cast<uint16_t>(SETTING(UDP_PORT)), SETTING(BIND_ADDRESS)); start(); } @@ -166,7 +166,7 @@ try { socket->disconnect(); socket->create(Socket::TYPE_UDP); - socket->bind(port); + socket->bind(port, SETTING(BIND_ADDRESS)); } catch(const SocketException& e) { // Oops, fatal this time... dcdebug("SearchManager::run Stopped listening: %s\n", e.getError().c_str()); Modified: dcplusplus/trunk/dcpp/User.h =================================================================== --- dcplusplus/trunk/dcpp/User.h 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/dcpp/User.h 2007-12-03 22:25:40 UTC (rev 926) @@ -40,7 +40,10 @@ NMDC_BIT, BOT_BIT, TLS_BIT, - OLD_CLIENT_BIT + OLD_CLIENT_BIT, + NO_ADC_1_0_PROTOCOL_BIT, + NO_ADC_0_10_PROTOCOL_BIT, + NO_ADCS_0_10_PROTOCOL_BIT }; /** Each flag is set if it's true in at least one hub */ @@ -51,7 +54,10 @@ NMDC = 1<<NMDC_BIT, BOT = 1<<BOT_BIT, TLS = 1<<TLS_BIT, //< Client supports TLS - OLD_CLIENT = 1<<OLD_CLIENT_BIT //< Can't download - old client + OLD_CLIENT = 1<<OLD_CLIENT_BIT, //< Can't download - old client + NO_ADC_1_0_PROTOCOL = 1<<NO_ADC_1_0_PROTOCOL_BIT, //< Doesn't support "ADC/1.0" (dc++ <=0.703) + NO_ADC_0_10_PROTOCOL = 1<<NO_ADC_0_10_PROTOCOL_BIT, //< Doesn't support "ADC/0.10" + NO_ADCS_0_10_PROTOCOL = 1<< NO_ADCS_0_10_PROTOCOL_BIT //< Doesn't support "ADCS/0.10" }; struct Hash { @@ -90,8 +96,9 @@ CT_BOT = 1, CT_REGGED = 2, CT_OP = 4, - CT_OWNER = 8, - CT_HUB = 16 + CT_SU = 8, + CT_OWNER = 16, + CT_HUB = 32 }; Identity() : sid(0) { } @@ -117,7 +124,7 @@ string getTag() const; bool supports(const string& name) const; bool isHub() const { return isClientType(CT_HUB) || !get("HU").empty(); } - bool isOp() const { return isClientType(CT_OP) || !get("OP").empty(); } + bool isOp() const { return isClientType(CT_OP) || isClientType(CT_SU) || isClientType(CT_OWNER) || !get("OP").empty(); } bool isRegistered() const { return isClientType(CT_REGGED) || !get("RG").empty(); } bool isHidden() const { return !get("HI").empty(); } bool isBot() const { return isClientType(CT_BOT) || !get("BO").empty(); } Modified: dcplusplus/trunk/dcpp/UserCommand.h =================================================================== --- dcplusplus/trunk/dcpp/UserCommand.h 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/dcpp/UserCommand.h 2007-12-03 22:25:40 UTC (rev 926) @@ -32,7 +32,8 @@ TYPE_SEPARATOR, TYPE_RAW, TYPE_RAW_ONCE, - TYPE_CLEAR = 255 + TYPE_REMOVE, + TYPE_CLEAR = 255 // In a momentary lapse of reason, 255 was chosen in the nmdc version of usercommand for clearing them all }; enum { Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2007-12-03 22:25:40 UTC (rev 926) @@ -101,6 +101,7 @@ bool handleSized(const WidgetSizedEventResult&); void handleTabSelected(); bool handleContextMenu(SmartWin::ScreenCoordinate pt); + void handleMiddleMouseDown(const MouseEventResult& mouseEventResult); SmartUtil::tstring cutTitle(const SmartUtil::tstring& title); void layout(); Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetToolbar.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetToolbar.h 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetToolbar.h 2007-12-03 22:25:40 UTC (rev 926) @@ -171,8 +171,6 @@ virtual bool tryFire( const MSG & msg, LRESULT & retVal ); private: - std::map< unsigned int, SmartUtil::tstring > itsToolTips; - // Keep references ImageListPtr itsNormalImageList; ImageListPtr itsHotImageList; Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2007-12-03 22:25:40 UTC (rev 926) @@ -31,6 +31,7 @@ onSized(std::tr1::bind(&WidgetTabView::handleSized, this, _1)); tab->onContextMenu(std::tr1::bind(&WidgetTabView::handleContextMenu, this, _1)); + tab->onMiddleMouseDown(std::tr1::bind(&WidgetTabView::handleMiddleMouseDown, this, _1)); } void WidgetTabView::add(WidgetChildWindow* w, const IconPtr& icon) { @@ -268,7 +269,7 @@ return image; } -bool WidgetTabView::handleContextMenu(SmartWin::ScreenCoordinate pt) { +bool WidgetTabView::handleContextMenu(ScreenCoordinate pt) { TabInfo* ti = 0; if(pt.x() == -1 && pt.y() == -1) { int i = tab->getSelectedIndex(); @@ -294,6 +295,12 @@ return false; } +void WidgetTabView::handleMiddleMouseDown(const MouseEventResult& mouseEventResult) { + TabInfo* ti = getTabInfo(tab->hitTest(mouseEventResult.pos)); + if(ti) + ti->w->close(); +} + bool WidgetTabView::filter(const MSG& msg) { if(msg.message == WM_KEYUP && msg.wParam == VK_CONTROL) { inTab = false; Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetToolbar.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetToolbar.cpp 2007-12-01 23:34:02 UTC (rev 925) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetToolbar.cpp 2007-12-03 22:25:40 UTC (rev 926) @@ -3,7 +3,7 @@ namespace SmartWin { WidgetToolbar::Seed::Seed() : - Widget::Seed(TOOLBARCLASSNAME, WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS) + Widget::Seed(TOOLBARCLASSNAME, WS_CHILD | WS_VISIBLE | TBSTYLE_LIST | TBSTYLE_TOOLTIPS) { } @@ -11,6 +11,8 @@ { ControlType::create(cs); + this->sendMessage(TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_MIXEDBUTTONS); + //// Telling the toolbar what the size of TBBUTTON struct is this->sendMessage(TB_BUTTONSTRUCTSIZE, ( WPARAM ) sizeof( TBBUTTON )); } @@ -30,46 +32,25 @@ void WidgetToolbar::appendItem( unsigned int id, int image, const SmartUtil::tstring& toolTip, const Dispatcher::F& f) { - // Checking if tooltip id exists from before - if ( itsToolTips.find( id ) != itsToolTips.end() ) - { - xCeption x( _T( "Tried to add a button with an ID that already exists..." ) ); - throw x; - } - // Adding button TBBUTTON tb = { 0 }; tb.iBitmap = image; tb.idCommand = id; tb.fsState = TBSTATE_ENABLED; tb.fsStyle = BTNS_AUTOSIZE; + tb.iString = reinterpret_cast<INT_PTR>(toolTip.c_str()); if ( this->sendMessage(TB_ADDBUTTONS, 1, reinterpret_cast< LPARAM >( &tb ) ) == FALSE ) { xCeption x( _T( "Error while trying to add a button to toolbar..." ) ); throw x; } - - if(!toolTip.empty()) { - itsToolTips[id] = toolTip; - } - + if(f) setCallback(Message(WM_COMMAND, id), Dispatcher(f)); } bool WidgetToolbar::tryFire( const MSG & msg, LRESULT & retVal ) { - if(msg.message == WM_NOTIFY) { - LPNMHDR hdr = reinterpret_cast< LPNMHDR >( msg.lParam ); - if(hdr->code == TTN_GETDISPINFO) { - LPTOOLTIPTEXT lpttt = reinterpret_cast< LPTOOLTIPTEXT >( msg.lParam ); - if(itsToolTips.find(lpttt->hdr.idFrom) != itsToolTips.end()) { - lpttt->lpszText = const_cast < TCHAR * >( itsToolTips[lpttt->hdr.idFrom].c_str() ); - return true; - } - } - } - bool handled = PolicyType::tryFire(msg, retVal); if(!handled && msg.message == WM_COMMAND) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-02 22:02:05
|
Revision: 97 http://adchpp.svn.sourceforge.net/adchpp/?rev=97&view=rev Author: arnetheduck Date: 2007-12-02 14:01:57 -0800 (Sun, 02 Dec 2007) Log Message: ----------- Some adc 1.0 issues fixed, bring back lua on track, lua 5.1.2 Modified Paths: -------------- adchpp/trunk/adchpp/AdcCommand.h adchpp/trunk/adchpp/Client.h adchpp/trunk/adchpp/SettingsManager.cpp adchpp/trunk/adchpp/SettingsManager.h adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/etc/adchpp.xml adchpp/trunk/lua/Makefile adchpp/trunk/lua/lbaselib.c adchpp/trunk/lua/lcode.c adchpp/trunk/lua/ldebug.c adchpp/trunk/lua/lfunc.c adchpp/trunk/lua/loadlib.c adchpp/trunk/lua/loslib.c adchpp/trunk/lua/lparser.c adchpp/trunk/lua/lstrlib.c adchpp/trunk/lua/lua.h adchpp/trunk/lua/luaconf.h adchpp/trunk/lua/lvm.c adchpp/trunk/lua/print.c adchpp/trunk/plugins/Script/examples/access.lua adchpp/trunk/readme.txt adchpp/trunk/swig/SConscript adchpp/trunk/swig/adchpp.i adchpp/trunk/swig/lua.i Removed Paths: ------------- adchpp/trunk/etc/Example.adchpp.xml Modified: adchpp/trunk/adchpp/AdcCommand.h =================================================================== --- adchpp/trunk/adchpp/AdcCommand.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/AdcCommand.h 2007-12-02 22:01:57 UTC (rev 97) @@ -57,10 +57,12 @@ ERROR_BAD_STATE = 44, ERROR_FEATURE_MISSING = 45, ERROR_BAD_IP = 46, + ERROR_NO_HUB_HASH = 47, ERROR_TRANSFER_GENERIC = 50, ERROR_FILE_NOT_AVAILABLE = 51, ERROR_FILE_PART_NOT_AVAILABLE = 52, - ERROR_SLOTS_FULL = 53 + ERROR_SLOTS_FULL = 53, + ERROR_NO_CLIENT_HASH = 54 }; enum Severity { @@ -100,7 +102,7 @@ C(CMD, 'C','M','D'); #undef C - enum { HUB_SID = 0x41414141 }; + enum { HUB_SID = 0xffffffff }; uint32_t toCMD(uint8_t a, uint8_t b, uint8_t c) { return (((uint32_t)a) | (((uint32_t)b)<<8) | (((uint32_t)c)<<16)); } Modified: adchpp/trunk/adchpp/Client.h =================================================================== --- adchpp/trunk/adchpp/Client.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/Client.h 2007-12-02 22:01:57 UTC (rev 97) @@ -50,9 +50,10 @@ FLAG_BOT = 0x01, FLAG_REGISTERED = 0x02, FLAG_OP = 0x04, - FLAG_OWNER = 0x08, - FLAG_HUB = 0x10, - MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_OWNER | FLAG_HUB, + FLAG_SU = 0x08, + FLAG_OWNER = 0x10, + FLAG_HUB = 0x20, + MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_SU | FLAG_OWNER | FLAG_HUB, FLAG_PASSWORD = 0x100, FLAG_HIDDEN = 0x101, /** Extended away, no need to send msg */ Modified: adchpp/trunk/adchpp/SettingsManager.cpp =================================================================== --- adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/SettingsManager.cpp 2007-12-02 22:01:57 UTC (rev 97) @@ -47,7 +47,6 @@ SettingsManager::SettingsManager() throw() { memset(intSettings, 0, sizeof(intSettings)); - memset(int64Settings, 0, sizeof(int64Settings)); set(HUB_NAME, appName); // set(SERVER_IP, ""); Modified: adchpp/trunk/adchpp/SettingsManager.h =================================================================== --- adchpp/trunk/adchpp/SettingsManager.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/SettingsManager.h 2007-12-02 22:01:57 UTC (rev 97) @@ -109,7 +109,6 @@ std::string strSettings[STR_LAST - STR_FIRST]; int intSettings[INT_LAST - INT_FIRST]; - int64_t int64Settings[/*INT64_LAST - INT64_FIRST*/1]; SignalLoad::Signal signalLoad_; }; Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/adchpp/SocketManager.cpp 2007-12-02 22:01:57 UTC (rev 97) @@ -581,12 +581,18 @@ bool get(vector<epoll_event>& events) { events.resize(1024); - int n = epoll_wait(poll_fd, &events[0], events.size(), WRITE_TIMEOUT); - if(n == -1) { - return false; + while(true) { + int n = epoll_wait(poll_fd, &events[0], events.size(), WRITE_TIMEOUT); + if(n == -1) { + if(errno != EINTR) { + return false; + } + // Keep looping + } else { + events.resize(n); + return true; + } } - events.resize(n); - return true; } void remove(const ManagedSocketPtr& ms) { Deleted: adchpp/trunk/etc/Example.adchpp.xml =================================================================== --- adchpp/trunk/etc/Example.adchpp.xml 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/etc/Example.adchpp.xml 2007-12-02 22:01:57 UTC (rev 97) @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<Language Name="Example Language" Author="arnetheduck" Version=2.0 Revision="1"> - <Strings> - <String Name="B">B</String> - <String Name="CidTaken">CID taken</String> - <String Name="DiskFull">Disk full?</String> - <String Name="Gb">GiB</String> - <String Name="HubFull">Hub is currently full</String> - <String Name="Kb">KiB</String> - <String Name="Mb">MiB</String> - <String Name="NickInvalid">Your nick contains invalid characters. Adios.</String> - <String Name="NickTaken">Your nick is already taken, please select another one</String> - <String Name="Tb">TiB</String> - </Strings> -</Language> Modified: adchpp/trunk/etc/adchpp.xml =================================================================== --- adchpp/trunk/etc/adchpp.xml 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/etc/adchpp.xml 2007-12-02 22:01:57 UTC (rev 97) @@ -1,9 +1,6 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <ADCHubPlusPlus> <Settings> -<!-- Language file --> - <!-- The strings in the language file is used when messages are sent out to the user by the hub --> - <LanguageFile type="string">Example.adchpp.xml</LanguageFile> <!-- Hub name and message of the day --> <!-- This is the name of the hub as it should be reported to the clients during @@ -27,17 +24,6 @@ on the same port, which facilates hub blocking. --> <ServerPort type="int">2780</ServerPort> -<!-- Maximum users --> - <!-- The maximum number of users that should be allowed into the hub at any time, - 0 = disable --> - <MaxUsers type="int">0</MaxUsers> - -<!-- Redirection settings --> - <!-- The server to redirect to (if enabled) when full --> - <RedirectServer>adc://wza.digitalbrains.com:1416</RedirectServer> - <!-- Enable/disable redirect when full --> - <RedirectFull>0</RedirectFull> - <!-- Flood protection --> <FloodAdd>1</FloodAdd> <FloodThreshold>25</FloodThreshold> Modified: adchpp/trunk/lua/Makefile =================================================================== --- adchpp/trunk/lua/Makefile 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/Makefile 2007-12-02 22:01:57 UTC (rev 97) @@ -20,7 +20,7 @@ # == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE ========= -PLATS= aix ansi bsd generic linux macosx mingw posix solaris +PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris LUA_A= liblua.a CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \ @@ -77,7 +77,8 @@ # convenience targets for popular platforms none: - @echo "Please choose a platform: $(PLATS)" + @echo "Please choose a platform:" + @echo " $(PLATS)" aix: $(MAKE) all CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-ldl" MYLDFLAGS="-brtl -bexpall" @@ -88,6 +89,9 @@ bsd: $(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E" +freebsd: + $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" + generic: $(MAKE) all MYCFLAGS= @@ -103,6 +107,7 @@ $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \ "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe + $(MAKE) "LUAC_T=luac.exe" luac.exe posix: $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX Modified: adchpp/trunk/lua/lbaselib.c =================================================================== --- adchpp/trunk/lua/lbaselib.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lbaselib.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.191 2006/06/02 15:34:00 roberto Exp $ +** $Id: lbaselib.c,v 1.191a 2006/06/02 15:34:00 roberto Exp $ ** Basic library ** See Copyright Notice in lua.h */ @@ -114,11 +114,11 @@ } -static void getfunc (lua_State *L) { +static void getfunc (lua_State *L, int opt) { if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); else { lua_Debug ar; - int level = luaL_optint(L, 1, 1); + int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1); luaL_argcheck(L, level >= 0, 1, "level must be non-negative"); if (lua_getstack(L, level, &ar) == 0) luaL_argerror(L, 1, "invalid level"); @@ -131,7 +131,7 @@ static int luaB_getfenv (lua_State *L) { - getfunc(L); + getfunc(L, 1); if (lua_iscfunction(L, -1)) /* is a C function? */ lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ else @@ -142,7 +142,7 @@ static int luaB_setfenv (lua_State *L) { luaL_checktype(L, 2, LUA_TTABLE); - getfunc(L); + getfunc(L, 0); lua_pushvalue(L, 2); if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) { /* change environment of current thread */ Modified: adchpp/trunk/lua/lcode.c =================================================================== --- adchpp/trunk/lua/lcode.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lcode.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.25 2006/03/21 19:28:49 roberto Exp $ +** $Id: lcode.c,v 2.25a 2006/03/21 19:28:49 roberto Exp $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -35,15 +35,20 @@ void luaK_nil (FuncState *fs, int from, int n) { Instruction *previous; if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ - if (fs->pc == 0) /* function start? */ - return; /* positions are already clean */ - if (GET_OPCODE(*(previous = &fs->f->code[fs->pc-1])) == OP_LOADNIL) { - int pfrom = GETARG_A(*previous); - int pto = GETARG_B(*previous); - if (pfrom <= from && from <= pto+1) { /* can connect both? */ - if (from+n-1 > pto) - SETARG_B(*previous, from+n-1); - return; + if (fs->pc == 0) { /* function start? */ + if (from >= fs->nactvar) + return; /* positions are already clean */ + } + else { + previous = &fs->f->code[fs->pc-1]; + if (GET_OPCODE(*previous) == OP_LOADNIL) { + int pfrom = GETARG_A(*previous); + int pto = GETARG_B(*previous); + if (pfrom <= from && from <= pto+1) { /* can connect both? */ + if (from+n-1 > pto) + SETARG_B(*previous, from+n-1); + return; + } } } } @@ -657,10 +662,16 @@ if (constfolding(op, e1, e2)) return; else { + int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; int o1 = luaK_exp2RK(fs, e1); - int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0; - freeexp(fs, e2); - freeexp(fs, e1); + if (o1 > o2) { + freeexp(fs, e1); + freeexp(fs, e2); + } + else { + freeexp(fs, e2); + freeexp(fs, e1); + } e1->u.s.info = luaK_codeABC(fs, op, 0, o1, o2); e1->k = VRELOCABLE; } @@ -718,10 +729,15 @@ luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */ break; } - default: { + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { if (!isnumeral(v)) luaK_exp2RK(fs, v); break; } + default: { + luaK_exp2RK(fs, v); + break; + } } } Modified: adchpp/trunk/lua/ldebug.c =================================================================== --- adchpp/trunk/lua/ldebug.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/ldebug.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.29 2005/12/22 16:19:56 roberto Exp $ +** $Id: ldebug.c,v 2.29a 2005/12/22 16:19:56 roberto Exp $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -432,14 +432,16 @@ break; } case OP_CLOSURE: { - int nup; + int nup, j; check(b < pt->sizep); nup = pt->p[b]->nups; check(pc + nup < pt->sizecode); - for (; nup>0; nup--) { - OpCode op1 = GET_OPCODE(pt->code[pc+nup]); + for (j = 1; j <= nup; j++) { + OpCode op1 = GET_OPCODE(pt->code[pc + j]); check(op1 == OP_GETUPVAL || op1 == OP_MOVE); } + if (reg != NO_REG) /* tracing? */ + pc += nup; /* do not 'execute' these pseudo-instructions */ break; } case OP_VARARG: { Modified: adchpp/trunk/lua/lfunc.c =================================================================== --- adchpp/trunk/lua/lfunc.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lfunc.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lfunc.c,v 2.12 2005/12/22 16:19:56 roberto Exp $ +** $Id: lfunc.c,v 2.12a 2005/12/22 16:19:56 roberto Exp $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ @@ -55,7 +55,7 @@ GCObject **pp = &L->openupval; UpVal *p; UpVal *uv; - while ((p = ngcotouv(*pp)) != NULL && p->v >= level) { + while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) { lua_assert(p->v != &p->u.value); if (p->v == level) { /* found a corresponding upvalue? */ if (isdead(g, obj2gco(p))) /* is it dead? */ @@ -96,7 +96,7 @@ void luaF_close (lua_State *L, StkId level) { UpVal *uv; global_State *g = G(L); - while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) { + while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { GCObject *o = obj2gco(uv); lua_assert(!isblack(o) && uv->v != &uv->u.value); L->openupval = uv->next; /* remove from `open' list */ Modified: adchpp/trunk/lua/loadlib.c =================================================================== --- adchpp/trunk/lua/loadlib.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/loadlib.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.52 2006/04/10 18:27:23 roberto Exp $ +** $Id: loadlib.c,v 1.54a 2006/07/03 20:16:49 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -16,9 +16,9 @@ #define loadlib_c #define LUA_LIB +#include "lua.h" + #include "lauxlib.h" -#include "lobject.h" -#include "lua.h" #include "lualib.h" @@ -98,7 +98,7 @@ char buff[MAX_PATH + 1]; char *lb; DWORD nsize = sizeof(buff)/sizeof(char); - DWORD n = GetModuleFileName(NULL, buff, nsize); + DWORD n = GetModuleFileNameA(NULL, buff, nsize); if (n == 0 || n == nsize || (lb = strrchr(buff, '\\')) == NULL) luaL_error(L, "unable to get ModuleFileName"); else { @@ -112,7 +112,7 @@ static void pusherror (lua_State *L) { int error = GetLastError(); char buffer[128]; - if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, + if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, buffer, sizeof(buffer), NULL)) lua_pushstring(L, buffer); else @@ -125,7 +125,7 @@ static void *ll_load (lua_State *L, const char *path) { - HINSTANCE lib = LoadLibrary(path); + HINSTANCE lib = LoadLibraryA(path); if (lib == NULL) pusherror(L); return lib; } @@ -356,15 +356,16 @@ path = lua_tostring(L, -1); if (path == NULL) luaL_error(L, LUA_QL("package.%s") " must be a string", pname); - lua_pushstring(L, ""); /* error accumulator */ + lua_pushliteral(L, ""); /* error accumulator */ while ((path = pushnexttemplate(L, path)) != NULL) { const char *filename; filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ - lua_pop(L, 2); /* remove path template and file name */ - luaO_pushfstring(L, "\n\tno file " LUA_QS, filename); - lua_concat(L, 2); + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + lua_concat(L, 2); /* add entry to possible error message */ } return NULL; /* not found */ } @@ -423,8 +424,8 @@ funcname = mkfuncname(L, name); if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { if (stat != ERRFUNC) loaderror(L, filename); /* real error */ - luaO_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, - name, filename); + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); return 1; /* function not found */ } return 1; @@ -438,7 +439,7 @@ luaL_error(L, LUA_QL("package.preload") " must be a table"); lua_getfield(L, -1, name); if (lua_isnil(L, -1)) /* not found? */ - luaO_pushfstring(L, "\n\tno field package.preload['%s']", name); + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); return 1; } @@ -462,7 +463,7 @@ lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); if (!lua_istable(L, -1)) luaL_error(L, LUA_QL("package.loaders") " must be a table"); - lua_pushstring(L, ""); /* error message accumulator */ + lua_pushliteral(L, ""); /* error message accumulator */ for (i=1; ; i++) { lua_rawgeti(L, -2, i); /* get a loader */ if (lua_isnil(L, -1)) @@ -646,8 +647,8 @@ setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ /* store config information */ - lua_pushstring(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" - LUA_EXECDIR "\n" LUA_IGMARK); + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" + LUA_EXECDIR "\n" LUA_IGMARK); lua_setfield(L, -2, "config"); /* set field `loaded' */ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); Modified: adchpp/trunk/lua/loslib.c =================================================================== --- adchpp/trunk/lua/loslib.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/loslib.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.19 2006/04/26 18:19:49 roberto Exp $ +** $Id: loslib.c,v 1.20 2006/09/19 13:57:08 roberto Exp $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -146,11 +146,22 @@ setboolfield(L, "isdst", stm->tm_isdst); } else { - char b[256]; - if (strftime(b, sizeof(b), s, stm)) - lua_pushstring(L, b); - else - return luaL_error(L, LUA_QL("date") " format too long"); + char cc[3]; + luaL_Buffer b; + cc[0] = '%'; cc[2] = '\0'; + luaL_buffinit(L, &b); + for (; *s; s++) { + if (*s != '%' || *(s + 1) == '\0') /* no conversion specifier? */ + luaL_addchar(&b, *s); + else { + size_t reslen; + char buff[200]; /* should be big enough for any conversion result */ + cc[1] = *(++s); + reslen = strftime(buff, sizeof(buff), cc, stm); + luaL_addlstring(&b, buff, reslen); + } + } + luaL_pushresult(&b); } return 1; } Modified: adchpp/trunk/lua/lparser.c =================================================================== --- adchpp/trunk/lua/lparser.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lparser.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.42 2006/06/05 15:57:59 roberto Exp $ +** $Id: lparser.c,v 2.42a 2006/06/05 15:57:59 roberto Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -489,7 +489,7 @@ static void listfield (LexState *ls, struct ConsControl *cc) { expr(ls, &cc->v); - luaY_checklimit(ls->fs, cc->na, MAXARG_Bx, "items in a constructor"); + luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor"); cc->na++; cc->tostore++; } Modified: adchpp/trunk/lua/lstrlib.c =================================================================== --- adchpp/trunk/lua/lstrlib.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lstrlib.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.132 2006/04/26 20:41:19 roberto Exp $ +** $Id: lstrlib.c,v 1.132a 2006/04/26 20:41:19 roberto Exp $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -723,7 +723,7 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { const char *p = strfrmt; - while (strchr(FLAGS, *p)) p++; /* skip flags */ + while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) luaL_error(L, "invalid format (repeated flags)"); if (isdigit(uchar(*p))) p++; /* skip width */ Modified: adchpp/trunk/lua/lua.h =================================================================== --- adchpp/trunk/lua/lua.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lua.h 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.218 2006/06/02 15:34:00 roberto Exp $ +** $Id: lua.h,v 1.218a 2006/06/02 15:34:00 roberto Exp $ ** Lua - An Extensible Extension Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file @@ -17,9 +17,9 @@ #define LUA_VERSION "Lua 5.1" -#define LUA_RELEASE "Lua 5.1.1" +#define LUA_RELEASE "Lua 5.1.2" #define LUA_VERSION_NUM 501 -#define LUA_COPYRIGHT "Copyright (C) 1994-2006 Lua.org, PUC-Rio" +#define LUA_COPYRIGHT "Copyright (C) 1994-2007 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" @@ -359,7 +359,7 @@ /****************************************************************************** -* Copyright (C) 1994-2006 Lua.org, PUC-Rio. All rights reserved. +* Copyright (C) 1994-2007 Lua.org, PUC-Rio. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the Modified: adchpp/trunk/lua/luaconf.h =================================================================== --- adchpp/trunk/lua/luaconf.h 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/luaconf.h 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.82 2006/04/10 18:27:23 roberto Exp $ +** $Id: luaconf.h,v 1.82a 2006/04/10 18:27:23 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -216,7 +216,7 @@ ** =================================================================== */ -#if defined(lua_c) +#if defined(lua_c) || defined(luaall_c) /* @@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that @@ -360,7 +360,7 @@ /* @@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' @* behavior. -** CHANGE it to undefined as soon as you replace to 'luaL_registry' +** CHANGE it to undefined as soon as you replace to 'luaL_register' ** your uses of 'luaL_openlib' */ #define LUA_COMPAT_OPENLIB Modified: adchpp/trunk/lua/lvm.c =================================================================== --- adchpp/trunk/lua/lvm.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/lvm.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.63 2006/06/05 15:58:59 roberto Exp $ +** $Id: lvm.c,v 2.63a 2006/06/05 15:58:59 roberto Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -165,7 +165,7 @@ const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ if (ttisnil(tm)) tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ - if (!ttisfunction(tm)) return 0; + if (ttisnil(tm)) return 0; callTMres(L, res, tm, p1, p2); return 1; } @@ -281,10 +281,12 @@ do { StkId top = L->base + last + 1; int n = 2; /* number of elements handled in this pass (at least 2) */ - if (!tostring(L, top-2) || !tostring(L, top-1)) { + if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) { if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) luaG_concaterror(L, top-2, top-1); - } else if (tsvalue(top-1)->len > 0) { /* if len=0, do nothing */ + } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ + (void)tostring(L, top - 2); /* result is first op (as string) */ + else { /* at least two string values; get as many as possible */ size_t tl = tsvalue(top-1)->len; char *buffer; Modified: adchpp/trunk/lua/print.c =================================================================== --- adchpp/trunk/lua/print.c 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/lua/print.c 2007-12-02 22:01:57 UTC (rev 97) @@ -1,5 +1,5 @@ /* -** $Id: print.c,v 1.55 2006/05/31 13:30:05 lhf Exp $ +** $Id: print.c,v 1.55a 2006/05/31 13:30:05 lhf Exp $ ** print bytecodes ** See Copyright Notice in lua.h */ @@ -23,8 +23,7 @@ static void PrintString(const TString* ts) { const char* s=getstr(ts); - int n=ts->tsv.len; - int i; + size_t i,n=ts->tsv.len; putchar('"'); for (i=0; i<n; i++) { @@ -32,6 +31,7 @@ switch (c) { case '"': printf("\\\""); break; + case '\\': printf("\\\\"); break; case '\a': printf("\\a"); break; case '\b': printf("\\b"); break; case '\f': printf("\\f"); break; Modified: adchpp/trunk/plugins/Script/examples/access.lua =================================================================== --- adchpp/trunk/plugins/Script/examples/access.lua 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/plugins/Script/examples/access.lua 2007-12-02 22:01:57 UTC (rev 97) @@ -5,14 +5,6 @@ adchpp = luadchpp --- Temporary fixes for SWIG 1.3.29 -adchpp.TYPE_BROADCAST = string.char(adchpp.TYPE_BROADCAST) -adchpp.TYPE_DIRECT = string.char(adchpp.TYPE_DIRECT) -adchpp.TYPE_ECHO = string.char(adchpp.TYPE_ECHO) -adchpp.TYPE_FEATURE = string.char(adchpp.TYPE_FEATURE) -adchpp.TYPE_INFO = string.char(adchpp.TYPE_INFO) -adchpp.TYPE_HUB = string.char(adchpp.TYPE_HUB) - -- Configuration local users_file = adchpp.Util_getCfgPath() .. "users.txt" @@ -59,21 +51,21 @@ local context_send = "[BFD]" local command_contexts = { - [adchpp.CMD_STA] = context_hub, - [adchpp.CMD_SUP] = context_hub, - [adchpp.CMD_SID] = context_hub, - [adchpp.CMD_INF] = context_bcast, - [adchpp.CMD_MSG] = context_send, - [adchpp.CMD_SCH] = context_send, - [adchpp.CMD_RES] = context_direct, - [adchpp.CMD_CTM] = context_direct, - [adchpp.CMD_RCM] = context_direct, - [adchpp.CMD_GPA] = context_hub, - [adchpp.CMD_PAS] = context_hub, - [adchpp.CMD_QUI] = context_hub, - [adchpp.CMD_GET] = context_hub, - [adchpp.CMD_GFI] = context_hub, - [adchpp.CMD_SND] = context_hub, + [adchpp.AdcCommand_CMD_STA] = context_hub, + [adchpp.AdcCommand_CMD_SUP] = context_hub, + [adchpp.AdcCommand_CMD_SID] = context_hub, + [adchpp.AdcCommand_CMD_INF] = context_bcast, + [adchpp.AdcCommand_CMD_MSG] = context_send, + [adchpp.AdcCommand_CMD_SCH] = context_send, + [adchpp.AdcCommand_CMD_RES] = context_direct, + [adchpp.AdcCommand_CMD_CTM] = context_direct, + [adchpp.AdcCommand_CMD_RCM] = context_direct, + [adchpp.AdcCommand_CMD_GPA] = context_hub, + [adchpp.AdcCommand_CMD_PAS] = context_hub, + [adchpp.AdcCommand_CMD_QUI] = context_hub, + [adchpp.AdcCommand_CMD_GET] = context_hub, + [adchpp.AdcCommand_CMD_GFI] = context_hub, + [adchpp.AdcCommand_CMD_SND] = context_hub, } local user_commands = { @@ -242,7 +234,7 @@ save_users() end -local command_processed = adchpp.DONT_DISPATCH + adchpp.DONT_SEND +local command_processed = adchpp.ClientManager_DONT_DISPATCH + adchpp.ClientManager_DONT_SEND local function onINF(c, cmd) Modified: adchpp/trunk/readme.txt =================================================================== --- adchpp/trunk/readme.txt 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/readme.txt 2007-12-02 22:01:57 UTC (rev 97) @@ -18,7 +18,7 @@ gcc 4.2+ (linux or mingw) boost (http://www.boost.org) scons (http://www.scons.org) -swig 1.3.31+ +swig 1.3.31 ** Important!! The hub will _NOT_ run on Win9x/ME. ** Modified: adchpp/trunk/swig/SConscript =================================================================== --- adchpp/trunk/swig/SConscript 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/swig/SConscript 2007-12-02 22:01:57 UTC (rev 97) @@ -104,7 +104,7 @@ # We assume the lua from the script plugin will be used... env.Append(CPPPATH=['#', '#/lua/']) - + if env['PLATFORM'] == 'win32': env.Append(CPPDEFINES=['LUA_BUILD_AS_DLL=1']) else: Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/swig/adchpp.i 2007-12-02 22:01:57 UTC (rev 97) @@ -278,21 +278,15 @@ SEV_FATAL = 2 }; -#ifdef SWIGLUA - static const short TYPE_BROADCAST = 'B'; - static const short TYPE_DIRECT = 'D'; - static const short TYPE_ECHO = 'E'; - static const short TYPE_FEATURE = 'F'; - static const short TYPE_INFO = 'I'; - static const short TYPE_HUB = 'H'; -#else static const char TYPE_BROADCAST = 'B'; + static const char TYPE_CLIENT = 'C'; static const char TYPE_DIRECT = 'D'; static const char TYPE_ECHO = 'E'; static const char TYPE_FEATURE = 'F'; static const char TYPE_INFO = 'I'; static const char TYPE_HUB = 'H'; -#endif + static const char TYPE_UDP = 'U'; + // Known commands... #define C(n, a, b, c) static const unsigned int CMD_##n = (((uint32_t)a) | (((uint32_t)b)<<8) | (((uint32_t)c)<<16)); // Base commands @@ -315,7 +309,7 @@ C(CMD, 'C','M','D'); #undef C - enum { HUB_SID = 0x41414141 }; + enum { HUB_SID = 0xffffffff }; AdcCommand(); explicit AdcCommand(Severity sev, Error err, const std::string& desc, char aType); @@ -389,9 +383,10 @@ FLAG_BOT = 0x01, FLAG_REGISTERED = 0x02, FLAG_OP = 0x04, - FLAG_OWNER = 0x08, - FLAG_HUB = 0x10, - MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_OWNER | FLAG_HUB, + FLAG_SU = 0x08, + FLAG_OWNER = 0x10, + FLAG_HUB = 0x20, + MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_SU | FLAG_OWNER | FLAG_HUB, FLAG_PASSWORD = 0x100, FLAG_HIDDEN = 0x101, /** Extended away, no need to send msg */ @@ -460,6 +455,62 @@ void logDateTime(const std::string& area, const std::string& msg) throw(); }; +%template(SignalC) Signal<void (Client&)>; +%template(SignalTraitsC) SignalTraits<void (Client&)>; +%template(SignalCA) Signal<void (Client&, AdcCommand&)>; +%template(SignalTraitsCA) SignalTraits<void (Client&, AdcCommand&)>; +%template(SignalCAI) Signal<void (Client&, AdcCommand&, int&)>; +%template(SignalTraitsCAI) SignalTraits<void (Client&, AdcCommand&, int&)>; +%template(SignalCI) Signal<void (Client&, int)>; +%template(SignalTraitsCI) SignalTraits<void (Client&, int)>; +%template(SignalCS) Signal<void (Client&, const std::string&)>; +%template(SignalTraitsCS) SignalTraits<void (Client&, const std::string&)>; +%template(SignalS) Signal<void (const SimpleXML&)>; +%template(SignalTraitsS) SignalTraits<void (const SimpleXML&)>; + +%template(ManagedC) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&)> > >; +%template(ManagedCA) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&)> > >; +%template(ManagedCAI) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&, int&)> > >; +%template(ManagedCI) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, int)> > >; +%template(ManagedCS) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, const std::string&)> > >; +%template(ManagedS) boost::intrusive_ptr<ManagedConnection<Signal<const SimpleXML&> > >; + +%extend Signal<void (Client&)> { + SignalTraits<void (Client&)>::ManagedConnection connect(std::tr1::function<void (Client&)> f) { + return manage(self, f); + } +} + +%extend Signal<void (Client&, AdcCommand&)> { + SignalTraits<void (Client&, AdcCommand&)>::ManagedConnection connect(std::tr1::function<void (Client&, AdcCommand&)> f) { + return manage(self, f); + } +} + +%extend Signal<void (Client&, AdcCommand&, int&)> { + SignalTraits<void (Client&, AdcCommand&, int&)>::ManagedConnection connect(std::tr1::function<void (Client&, AdcCommand&, int&)> f) { + return manage(self, f); + } +} + +%extend Signal<void (Client&, int)> { + SignalTraits<void (Client&, int)>::ManagedConnection connect(std::tr1::function<void (Client&, int)> f) { + return manage(self, f); + } +} + +%extend Signal<void (Client&, const std::string&)> { + SignalTraits<void (Client&, const std::string&)>::ManagedConnection connect(std::tr1::function<void (Client&, const std::string&)> f) { + return manage(self, f); + } +} + +%extend Signal<void (const SimpleXML&)> { + SignalTraits<void (const SimpleXML&)>::ManagedConnection connect(std::tr1::function<void (const SimpleXML&)> f) { + return manage(self, f); + } +} + class SocketManager { public: %extend { @@ -541,7 +592,7 @@ void enterIdentify(Client& c, bool sendData) throw(); - vector<uint8_t> enterVerify(Client& c, bool sendData) throw(); + ByteVector enterVerify(Client& c, bool sendData) throw(); bool enterNormal(Client& c, bool sendData, bool sendOwnInf) throw(); bool verifySUP(Client& c, AdcCommand& cmd) throw(); @@ -659,40 +710,6 @@ SignalLoad::Signal& signalLoad(); }; -%template(SignalC) Signal<void (Client&)>; -%template(SignalCA) Signal<void (Client&, AdcCommand&)>; -%template(SignalCAI) Signal<void (Client&, AdcCommand&, int&)>; -%template(SignalS) Signal<void (const SimpleXML&)>; - -%template(ManagedC) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&)> > >; -%template(ManagedCAI) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&, int&)> > >; -%template(ManagedCS) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, const std::string&)> > >; -%template(ManagedCI) boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, int)> > >; - -%extend Signal<void (Client&)> { - boost::intrusive_ptr<ManagedConnection<Signal<void (Client&)> > > connect(std::tr1::function<void (Client&)> f) { - return manage(self, f); - } -} - -%extend Signal<void (Client&, AdcCommand&)> { - boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&)> > > connect(std::tr1::function<void (Client&, AdcCommand&)> f) { - return manage(self, f); - } -} - -%extend Signal<void (Client&, AdcCommand&, int&)> { - boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, AdcCommand&, int&)> > > connect(std::tr1::function<void (Client&, AdcCommand&, int&)> f) { - return manage(self, f); - } -} - -%extend Signal<void (Client&, std::string&)> { - boost::intrusive_ptr<ManagedConnection<Signal<void (Client&, std::string&)> > > connect(std::tr1::function<void (Client&, std::string&)> f) { - return manage(self, f)); - } -} - class TigerHash { public: /** Hash size in bytes */ Modified: adchpp/trunk/swig/lua.i =================================================================== --- adchpp/trunk/swig/lua.i 2007-11-25 21:44:36 UTC (rev 96) +++ adchpp/trunk/swig/lua.i 2007-12-02 22:01:57 UTC (rev 97) @@ -5,23 +5,23 @@ %wrapper %{ static int traceback (lua_State *L) { - lua_getfield(L, LUA_GLOBALSINDEX, "debug"); - if (!lua_istable(L, -1)) { - printf("No debug table\n"); - lua_pop(L, 1); - return 1; - } - lua_getfield(L, -1, "traceback"); - if (!lua_isfunction(L, -1)) { - printf("No traceback in debug\n"); - lua_pop(L, 2); - return 1; - } + lua_getfield(L, LUA_GLOBALSINDEX, "debug"); + if (!lua_istable(L, -1)) { + printf("No debug table\n"); + lua_pop(L, 1); + return 1; + } + lua_getfield(L, -1, "traceback"); + if (!lua_isfunction(L, -1)) { + printf("No traceback in debug\n"); + lua_pop(L, 2); + return 1; + } - lua_pushvalue(L, 1); /* pass error message */ - lua_pushinteger(L, 2); /* skip this function and traceback */ - lua_call(L, 2, 1); /* call debug.traceback */ - return 1; + lua_pushvalue(L, 1); /* pass error message */ + lua_pushinteger(L, 2); /* skip this function and traceback */ + lua_call(L, 2, 1); /* call debug.traceback */ + return 1; } class RegistryItem : private boost::noncopyable { @@ -92,6 +92,14 @@ lua_pop(L, 1); } + void operator()(const adchpp::SimpleXML& s) { + pushFunction(); + + SWIG_NewPointerObj(L, &s, SWIGTYPE_p_adchpp__SimpleXML, 0); + docall(1, 0); + } + + private: void pushFunction() { registryItem->push(); } @@ -147,6 +155,18 @@ $1 = LuaFunction(L); } +%typemap(in) std::tr1::function<void (adchpp::Client &, int) > { + $1 = LuaFunction(L); +} + +%typemap(in) std::tr1::function<void (adchpp::Client &, const std::string&) > { + $1 = LuaFunction(L); +} + +%typemap(in) std::tr1::function<void (const SimpleXML&) > { + $1 = LuaFunction(L); +} + %include "adchpp.i" %extend adchpp::AdcCommand { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zou...@us...> - 2007-12-01 23:34:05
|
Revision: 925 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=925&view=rev Author: zouzou123gen Date: 2007-12-01 15:34:02 -0800 (Sat, 01 Dec 2007) Log Message: ----------- tab order & missing addWidget in PublicHubsFrame Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/win32/PublicHubsFrame.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2007-12-01 23:05:03 UTC (rev 924) +++ dcplusplus/trunk/changelog.txt 2007-12-01 23:34:02 UTC (rev 925) @@ -18,6 +18,7 @@ * Fixed missing title changes on tab change (thanks poy) * Fixed user list filter (poy) * Readded chat message box auto-scroll (poy) +* Fixed tab order in public hubs (poy) -- 0.703 2007-11-08 -- * Fixed invalid strings (thanks james ross) Modified: dcplusplus/trunk/win32/PublicHubsFrame.cpp =================================================================== --- dcplusplus/trunk/win32/PublicHubsFrame.cpp 2007-12-01 23:05:03 UTC (rev 924) +++ dcplusplus/trunk/win32/PublicHubsFrame.cpp 2007-12-01 23:34:02 UTC (rev 925) @@ -120,8 +120,33 @@ hubs->onKeyDown(std::tr1::bind(&PublicHubsFrame::handleKeyDown, this, _1)); hubs->onContextMenu(std::tr1::bind(&PublicHubsFrame::handleContextMenu, this, _1)); } - + { + WidgetTextBox::Seed cs = WinUtil::Seeds::textBox; + cs.style = WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL; + filter = createTextBox(cs); + addWidget(filter); + filter->onKeyDown(std::tr1::bind(&PublicHubsFrame::handleFilterKeyDown, this, _1)); + } + + { + filterSel = createComboBox(WinUtil::Seeds::comboBoxStatic); + addWidget(filterSel); + + //populate the filter list with the column names + for(int j=0; j<COLUMN_LAST; j++) { + filterSel->addValue(TSTRING_I(columnNames[j])); + } + filterSel->addValue(TSTRING(ANY)); + filterSel->setSelectedIndex(COLUMN_LAST); + filterSel->onSelectionChanged(std::tr1::bind(&PublicHubsFrame::updateList, this)); + + pubLists = createComboBox(WinUtil::Seeds::comboBoxStatic); + addWidget(pubLists); + pubLists->onSelectionChanged(std::tr1::bind(&PublicHubsFrame::handleListSelChanged, this)); + } + + { WidgetButton::Seed cs = WinUtil::Seeds::button; cs.caption = TSTRING(CONFIGURE); @@ -145,32 +170,8 @@ cs.caption = TSTRING(FILTER); filterDesc = createButton(cs); filterDesc->setFont(WinUtil::font); - } - { - pubLists = createComboBox(WinUtil::Seeds::comboBoxStatic); - pubLists->onSelectionChanged(std::tr1::bind(&PublicHubsFrame::handleListSelChanged, this)); - - filterSel = createComboBox(WinUtil::Seeds::comboBoxStatic); - addWidget(filterSel); - - //populate the filter list with the column names - for(int j=0; j<COLUMN_LAST; j++) { - filterSel->addValue(TSTRING_I(columnNames[j])); - } - filterSel->addValue(TSTRING(ANY)); - filterSel->setSelectedIndex(COLUMN_LAST); - filterSel->onSelectionChanged(std::tr1::bind(&PublicHubsFrame::updateList, this)); - } - { - WidgetTextBox::Seed cs = WinUtil::Seeds::textBox; - cs.style = WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL; - filter = createTextBox(cs); - addWidget(filter); - filter->onKeyDown(std::tr1::bind(&PublicHubsFrame::handleFilterKeyDown, this, _1)); - } - initStatus(); FavoriteManager::getInstance()->addListener(this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zou...@us...> - 2007-12-01 23:05:17
|
Revision: 924 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=924&view=rev Author: zouzou123gen Date: 2007-12-01 15:05:03 -0800 (Sat, 01 Dec 2007) Log Message: ----------- tab handling in HubFrame Modified Paths: -------------- dcplusplus/trunk/win32/HubFrame.cpp dcplusplus/trunk/win32/HubFrame.h Modified: dcplusplus/trunk/win32/HubFrame.cpp =================================================================== --- dcplusplus/trunk/win32/HubFrame.cpp 2007-12-01 21:15:53 UTC (rev 923) +++ dcplusplus/trunk/win32/HubFrame.cpp 2007-12-01 23:05:03 UTC (rev 924) @@ -86,16 +86,17 @@ { WidgetTextBox::Seed cs = WinUtil::Seeds::textBox; - cs.style = WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE; + cs.style = WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE; message = createTextBox(cs); addWidget(message, true); + message->onRaw(std::tr1::bind(&HubFrame::handleMessageGetDlgCode, this), SmartWin::Message(WM_GETDLGCODE)); message->onKeyDown(std::tr1::bind(&HubFrame::handleMessageKeyDown, this, _1)); message->onChar(std::tr1::bind(&HubFrame::handleMessageChar, this, _1)); } { WidgetTextBox::Seed cs = WinUtil::Seeds::textBox; - cs.style = WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_NOHIDESEL | ES_READONLY; + cs.style = WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | ES_MULTILINE | ES_NOHIDESEL | ES_READONLY; chat = createTextBox(cs); chat->setTextLimit(0); addWidget(chat); @@ -105,7 +106,7 @@ { WidgetTextBox::Seed cs = WinUtil::Seeds::textBox; - cs.style = WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL; + cs.style = WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL; filter = createTextBox(cs); addWidget(filter); filter->onKeyUp(std::tr1::bind(&HubFrame::handleFilterKey, this, _1)); @@ -671,6 +672,11 @@ return false; } +LRESULT HubFrame::handleMessageGetDlgCode() { + // override the MDIChildFrame behavior, which tells the Dialog Manager to process Tab presses by itself + return DLGC_WANTMESSAGE; +} + bool HubFrame::handleMessageChar(int c) { switch(c) { case VK_TAB: Modified: dcplusplus/trunk/win32/HubFrame.h =================================================================== --- dcplusplus/trunk/win32/HubFrame.h 2007-12-01 21:15:53 UTC (rev 923) +++ dcplusplus/trunk/win32/HubFrame.h 2007-12-01 23:05:03 UTC (rev 924) @@ -229,6 +229,7 @@ void runUserCommand(const UserCommand& uc); + LRESULT handleMessageGetDlgCode(); bool handleMessageChar(int c); bool handleMessageKeyDown(int c); bool handleUsersKeyDown(int c); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-01 21:15:57
|
Revision: 923 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=923&view=rev Author: arnetheduck Date: 2007-12-01 13:15:53 -0800 (Sat, 01 Dec 2007) Log Message: ----------- ADC 1.0 Modified Paths: -------------- dcplusplus/trunk/ADC.txt Modified: dcplusplus/trunk/ADC.txt =================================================================== --- dcplusplus/trunk/ADC.txt 2007-12-01 14:43:52 UTC (rev 922) +++ dcplusplus/trunk/ADC.txt 2007-12-01 21:15:53 UTC (rev 923) @@ -1,4 +1,4 @@ -= ADC Protocol Draft += ADC Protocol Jacek Sieka <arn...@gm...> 1.0, December 2007 @@ -19,18 +19,23 @@ Ullner, Fredrik Stenberg and others. Jon Hess contributed the original Direct Connect idea through the Neo-Modus Direct Connect client / hub. -The latest draft version of this document can be downloaded from +== Version history +The latest draft of the next version of this document as well as intermediate +and older versions can be downloaded from $URL$. This version correspods to $Revision$. +=== Version 1.0, 2007-12-01 +* Initial release + == Line protocol === General * All messages begin with a four-letter word. The first letter designates how the message should be sent and the other three specify what to do. * Parameters are separated by space and a newline (codepoint 0x0a) ends each message. The string "\s" escapes space, "\n" newline and "\\" backslash. - This version of the protocol reserves all other escapes for future use; - any message containing unknown escapes must be discarded. + This version of the protocol reserves all other escapes for future use; any + message containing unknown escapes must be discarded. * All text must be sent as UTF-8 encoded Unicode in normalization form C. * Clients must ignore unknown/badly formatted messages. Hubs must ignore invalid messages and should dispatch unknown messages according to their @@ -39,10 +44,10 @@ IPv4 and RFC 1884 form for IPv6. Hub addresses must be specified in URL form, with "adc" as protocol specifier ("adc://server:port/"). * Numbers are sent as strings in standard floating point notation, using '.' - as the decimal separator and without a thousands separator. Integers are numbers - with neither a decimal portion nor an exponent. Applications should be - prepared to handle at least 64-bit signed integers and 64-bit floating point - numbers. A '-' prefix negates. + as the decimal separator and without a thousands separator. Integers are + numbers with neither a decimal portion nor an exponent. Applications should + be prepared to handle at least 64-bit signed integers and 64-bit floating + point numbers. A '-' prefix negates. * SIDs, PIDs, CIDs, and short binary data are sent as base32-encoded strings. Long binary data transfers should use the file transfer mechanism with named roots. @@ -50,10 +55,10 @@ only include viewable characters that can be encoded by one byte in the UTF-8 encoding (Unicode codepoints 33-127). ADC is case-sensitive, requiring upper case for command names. -* Some commands and functionality require the use of a hash function. - The hash function is negotiated during session setup and stays the same for - the duration of the session. - +* Some commands and functionality require the use of a hash function. The + hash function is negotiated during session setup and stays the same for the + duration of the session. + === Message syntax .................. message ::= message_body? eol @@ -486,7 +491,7 @@ CT | integer | Client (user) type, 1=bot, 2=registered user, 4=operator, 8=super user, 16=hub owner, 32=hub (used when the hub sends an INF about itself). Multiple types are specified by adding the numbers together. AW | integer | 1=Away, 2=Extended away, not interested in hub chat (hubs may skip sending broadcast type MSG commands to clients with this flag) SU | string | Comma-separated list of feature FOURCC's. This notifies other clients of extended capabilities of the connecting client. -RF | string | URL of referxrer (hub in case of redirect, web page) +RF | string | URL of referer (hub in case of redirect, web page) ___ NOTE: Normally one would only accept an IP (I4 or I6) that is the same as the @@ -499,8 +504,8 @@ PD and ID fields, and proceed to the VERIFY state by sending a PAS request or NORMAL state by sending its own INF (unless it already did so previously), then the INF of all connected clients in NORMAL state, and last the INF of the -connecting client. When the hub that sends an INF about itself, the NI becomes -hub name, the VE the hub version, and DE the hub description. +connecting client. When the hub sends an INF about itself, the NI becomes hub +name, the VE the hub version, and DE the hub description. When the server receives this during client-client communication in IDENTIFY state, it should verify the ID and TO fields, send an INF about itself and This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-01 14:43:57
|
Revision: 922 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=922&view=rev Author: arnetheduck Date: 2007-12-01 06:43:52 -0800 (Sat, 01 Dec 2007) Log Message: ----------- Add super user Modified Paths: -------------- dcplusplus/trunk/ADC.txt Modified: dcplusplus/trunk/ADC.txt =================================================================== --- dcplusplus/trunk/ADC.txt 2007-12-01 14:16:02 UTC (rev 921) +++ dcplusplus/trunk/ADC.txt 2007-12-01 14:43:52 UTC (rev 922) @@ -483,13 +483,13 @@ HR | integer | Hubs where user is registered (had to supply password) and in NORMAL state HO | integer | Hubs where user is op and in NORMAL state TO | string | Token, as received in RCM/CTM, when establishing a C-C connection. -CT | integer | Client (user) type, 1=bot, 2=registered user, 4=operator, 8=hub owner, 16=hub (used when the hub sends an INF about itself). Multiple types are specified by adding the numbers together. +CT | integer | Client (user) type, 1=bot, 2=registered user, 4=operator, 8=super user, 16=hub owner, 32=hub (used when the hub sends an INF about itself). Multiple types are specified by adding the numbers together. AW | integer | 1=Away, 2=Extended away, not interested in hub chat (hubs may skip sending broadcast type MSG commands to clients with this flag) SU | string | Comma-separated list of feature FOURCC's. This notifies other clients of extended capabilities of the connecting client. RF | string | URL of referxrer (hub in case of redirect, web page) ___ -NOTE: normally one would only accept an IP (I4 or I6) that is the same as the +NOTE: Normally one would only accept an IP (I4 or I6) that is the same as the source IP of the connecting peer. Use caution when accepting unknown IPs. Only for trusted users one may allow a different IP or an IP from a different domain (IPv4 or IPv6) to be specified. If you fail to do this, your hub can be This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-01 14:16:05
|
Revision: 921 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=921&view=rev Author: arnetheduck Date: 2007-12-01 06:16:02 -0800 (Sat, 01 Dec 2007) Log Message: ----------- More minor adjustments Modified Paths: -------------- dcplusplus/trunk/ADC.txt Modified: dcplusplus/trunk/ADC.txt =================================================================== --- dcplusplus/trunk/ADC.txt 2007-12-01 12:26:20 UTC (rev 920) +++ dcplusplus/trunk/ADC.txt 2007-12-01 14:16:02 UTC (rev 921) @@ -486,12 +486,10 @@ CT | integer | Client (user) type, 1=bot, 2=registered user, 4=operator, 8=hub owner, 16=hub (used when the hub sends an INF about itself). Multiple types are specified by adding the numbers together. AW | integer | 1=Away, 2=Extended away, not interested in hub chat (hubs may skip sending broadcast type MSG commands to clients with this flag) SU | string | Comma-separated list of feature FOURCC's. This notifies other clients of extended capabilities of the connecting client. +RF | string | URL of referxrer (hub in case of redirect, web page) ___ -Hubs may mandate or discard any set of fields, but obviously the more the -merrier (and clients could be disconnected for not sending some of them). - -Note; normally one would only accept an IP (I4 or I6) that is the same as the +NOTE: normally one would only accept an IP (I4 or I6) that is the same as the source IP of the connecting peer. Use caution when accepting unknown IPs. Only for trusted users one may allow a different IP or an IP from a different domain (IPv4 or IPv6) to be specified. If you fail to do this, your hub can be This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-01 12:26:22
|
Revision: 920 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=920&view=rev Author: arnetheduck Date: 2007-12-01 04:26:20 -0800 (Sat, 01 Dec 2007) Log Message: ----------- typo Modified Paths: -------------- dcplusplus/trunk/ADC.txt Modified: dcplusplus/trunk/ADC.txt =================================================================== --- dcplusplus/trunk/ADC.txt 2007-12-01 12:14:25 UTC (rev 919) +++ dcplusplus/trunk/ADC.txt 2007-12-01 12:26:20 UTC (rev 920) @@ -415,7 +415,7 @@ meaning add and 'RM' meaning remove. When the hub receives this message in PROTOCOL state, it should reply in kind, -assign and SID to the client, optionally send an INF about itself, and move to +assign a SID to the client, optionally send an INF about itself, and move to the IDENTIFY state. When the server receives this message in a client-client connection in the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-12-01 12:14:32
|
Revision: 919 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=919&view=rev Author: arnetheduck Date: 2007-12-01 04:14:25 -0800 (Sat, 01 Dec 2007) Log Message: ----------- ADC 1.0 preparation Modified Paths: -------------- dcplusplus/trunk/ADC-EXT.txt dcplusplus/trunk/ADC.txt Modified: dcplusplus/trunk/ADC-EXT.txt =================================================================== --- dcplusplus/trunk/ADC-EXT.txt 2007-11-30 20:08:08 UTC (rev 918) +++ dcplusplus/trunk/ADC-EXT.txt 2007-12-01 12:14:25 UTC (rev 919) @@ -29,4 +29,75 @@ field. Clients supporting encrypted connections must indicate this in the INF SU field with "ADCS" +=== UCMD - User commands +User commands are used to send hub-specific commands to the client which +provide useful shortcuts for the user. These commands contain strings which +must be sent back to the hub and parameter substitutions in the strings. Each +user command has a display name, a string to be sent to the hub, and one or +more categories where it may appear. The strings passed to the hub must first +be passed through a dictionary replacement that replaces all keywords in the +string and then through the equivalent of the C standard function "strftime", +with the current time. + +==== CMD + CMD name + +Context: F + +Name uniquely (per hub) identifies a particular user command. The name may +contain "/" to indicate a logical structure on the viewing client, where each +"/" introduces a new submenu level. Other than name, the command also has a +number of flags that further detail what to do with it. + +[separator="|"] +``_ +RM | 1 = Remove command +CT | Context, the following flags summed: + | 1 = Hub command, client parameters only + | 2 = User list command, client and user parameters + | 4 = Search result command, client, user and file parameters + | 8 = File list command, client, user and file parameters +TT | The full text to be sent to hub, including FOURCC and any parameters +CO | 1 = Constrained, when sending this command on multiple users (for example in search results), constrain it to once per CID only +SP | 1 = Insert separator instead of command name (name must still be present to uniquely identify the command) +___ + +Keywords are specified using "%[keyword]". Unknown keywords must be replaced +by the empty string. Additionally, all %-substitutions of the C function +"strftime" must be supported. + +The following tables specify the parameters that must be available. + +Client parameters + +[separator="|"] +``_ +myCID | Client CID +mySID | Client SID +myXX | One for each flag on that particular hub; for example, myI4 and myNI +___ + +User parameters + +[separator="|"] +``_ +userCID | User CID +userSID | SID of the user +userXX | One for each flag the user sent; for example, userI4 and userNI +___ + +File parameters + +[separator="|"] +``_ +fileXX | One for each flag contained within a search result or file list entry (see RES) +___ + +Hub parameters + +[separator="|"] +``_ +hubXX | One for each flag of the hub +___ + // vim: set syntax=asciidoc: Modified: dcplusplus/trunk/ADC.txt =================================================================== --- dcplusplus/trunk/ADC.txt 2007-11-30 20:08:08 UTC (rev 918) +++ dcplusplus/trunk/ADC.txt 2007-12-01 12:14:25 UTC (rev 919) @@ -1,12 +1,12 @@ = ADC Protocol Draft Jacek Sieka <arn...@gm...> -0.14, November 2007 +1.0, December 2007 == Abstract ADC is a text protocol for a client-server network similar to Neo-Modus' Direct Connect (NMDC). The goal is to create a simple protocol that doesn't require much effort neither in hub nor client, and is yet extensible. It -addresses some of the issues in the NMDC protocol, but definitely not all. +addresses some of the issues in the NMDC protocol, but not all. The same protocol structure is used both for client-hub and client-client communication. This document is split into two parts; the first shows the @@ -14,7 +14,7 @@ this structure. ADC stands for anything you would like it to stand for; Advanced Direct Connect is the first neutral thing that springs to mind =). -Many ideas for the protocol come from Jan Vidar Krey's DCTNG draft. Other +Many ideas for the protocol come from Jan Vidar Krey's DCTNG draft. Major contributors include Dustin Brody, Walter Doekes, Timmo Stange, Fredrik Ullner, Fredrik Stenberg and others. Jon Hess contributed the original Direct Connect idea through the Neo-Modus Direct Connect client / hub. @@ -414,10 +414,14 @@ This command can also be used to dynamically add / remove features, 'AD' meaning add and 'RM' meaning remove. -When the server receives this message the first time, it should reply in kind, -assign an SID to the client, send an INF about itself, and move to the -IDENTIFY state. +When the hub receives this message in PROTOCOL state, it should reply in kind, +assign and SID to the client, optionally send an INF about itself, and move to +the IDENTIFY state. +When the server receives this message in a client-client connection in the +PROTOCOL state, it should reply in kind, send an INF about itself, and move to +the IDENTIFY state. + ==== SID SID sid @@ -493,11 +497,12 @@ domain (IPv4 or IPv6) to be specified. If you fail to do this, your hub can be used as a medium for DDoS attacks. -When a hub receives this message in the IDENTIFY state, it should proceed to -the VERIFY state by sending a PAS request or NORMAL state by starting sending -the INF of all clients, where the INF of the connecting client must come last. -When the hub that sends an INF about itself, the NI becomes hub name, the VE -the hub version, and DE the hub description. +When a hub receives this message in the IDENTIFY state, it should verify the +PD and ID fields, and proceed to the VERIFY state by sending a PAS request or +NORMAL state by sending its own INF (unless it already did so previously), +then the INF of all connected clients in NORMAL state, and last the INF of the +connecting client. When the hub that sends an INF about itself, the NI becomes +hub name, the VE the hub version, and DE the hub description. When the server receives this during client-client communication in IDENTIFY state, it should verify the ID and TO fields, send an INF about itself and @@ -797,75 +802,4 @@ parameter of the GET and SND commands is to be interpreted as the number of uncompressed bytes to be transferred. -=== UCMD - User commands -User commands are used to send hub-specific commands to the client which -provide useful shortcuts for the user. These commands contain strings which -must be sent back to the hub and parameter substitutions in the strings. Each -user command has a display name, a string to be sent to the hub, and one or -more categories where it may appear. The strings passed to the hub must first -be passed through a dictionary replacement that replaces all keywords in the -string and then through the equivalent of the C standard function "strftime", -with the current time. - -==== CMD - CMD name - -Context: F - -Name uniquely (per hub) identifies a particular user command. The name may -contain "/" to indicate a logical structure on the viewing client, where each -"/" introduces a new submenu level. Other than name, the command also has a -number of flags that further detail what to do with it. - -[separator="|"] -``_ -RM | 1 = Remove command -CT | Context, the following flags summed: - | 1 = Hub command, client parameters only - | 2 = User list command, client and user parameters - | 4 = Search result command, client, user and file parameters - | 8 = File list command, client, user and file parameters -TT | The full text to be sent to hub, including FOURCC and any parameters -CO | 1 = Constrained, when sending this command on multiple users (for example in search results), constrain it to once per CID only -SP | 1 = Insert separator instead of command name (name must still be present to uniquely identify the command) -___ - -Keywords are specified using "%[keyword]". Unknown keywords must be replaced -by the empty string. Additionally, all %-substitutions of the C function -"strftime" must be supported. - -The following tables specify the parameters that must be available. - -Client parameters - -[separator="|"] -``_ -myCID | Client CID -mySID | Client SID -myXX | One for each flag on that particular hub; for example, myI4 and myNI -___ - -User parameters - -[separator="|"] -``_ -userCID | User CID -userSID | SID of the user -userXX | One for each flag the user sent; for example, userI4 and userNI -___ - -File parameters - -[separator="|"] -``_ -fileXX | One for each flag contained within a search result or file list entry (see RES) -___ - -Hub parameters - -[separator="|"] -``_ -hubXX | One for each flag of the hub -___ - // vim: set syntax=asciidoc: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zou...@us...> - 2007-11-30 20:08:13
|
Revision: 918 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=918&view=rev Author: zouzou123gen Date: 2007-11-30 12:08:08 -0800 (Fri, 30 Nov 2007) Log Message: ----------- chat message box auto-scroll Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/win32/HubFrame.cpp dcplusplus/trunk/win32/PrivateFrame.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2007-11-30 18:57:40 UTC (rev 917) +++ dcplusplus/trunk/changelog.txt 2007-11-30 20:08:08 UTC (rev 918) @@ -17,6 +17,7 @@ * Fixed filter in public hubs (thanks poy) * Fixed missing title changes on tab change (thanks poy) * Fixed user list filter (poy) +* Readded chat message box auto-scroll (poy) -- 0.703 2007-11-08 -- * Fixed invalid strings (thanks james ross) Modified: dcplusplus/trunk/win32/HubFrame.cpp =================================================================== --- dcplusplus/trunk/win32/HubFrame.cpp 2007-11-30 18:57:40 UTC (rev 917) +++ dcplusplus/trunk/win32/HubFrame.cpp 2007-11-30 20:08:08 UTC (rev 918) @@ -86,7 +86,7 @@ { WidgetTextBox::Seed cs = WinUtil::Seeds::textBox; - cs.style = WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_AUTOVSCROLL | ES_MULTILINE; + cs.style = WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE; message = createTextBox(cs); addWidget(message, true); message->onKeyDown(std::tr1::bind(&HubFrame::handleMessageKeyDown, this, _1)); Modified: dcplusplus/trunk/win32/PrivateFrame.cpp =================================================================== --- dcplusplus/trunk/win32/PrivateFrame.cpp 2007-11-30 18:57:40 UTC (rev 917) +++ dcplusplus/trunk/win32/PrivateFrame.cpp 2007-11-30 20:08:08 UTC (rev 918) @@ -100,7 +100,7 @@ { { WidgetTextBox::Seed cs = WinUtil::Seeds::textBox; - cs.style = WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | ES_AUTOVSCROLL | ES_MULTILINE; + cs.style = WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE; message = createTextBox(cs); addWidget(message, true); message->onKeyDown(std::tr1::bind(&PrivateFrame::handleKeyDown, this, _1)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zou...@us...> - 2007-11-30 18:57:51
|
Revision: 917 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=917&view=rev Author: zouzou123gen Date: 2007-11-30 10:57:40 -0800 (Fri, 30 Nov 2007) Log Message: ----------- user list filter: no multiline & combobox items visible Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/win32/HubFrame.cpp dcplusplus/trunk/win32/PublicHubsFrame.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2007-11-30 18:30:26 UTC (rev 916) +++ dcplusplus/trunk/changelog.txt 2007-11-30 18:57:40 UTC (rev 917) @@ -16,6 +16,7 @@ * Message always focused first in chats (poy) * Fixed filter in public hubs (thanks poy) * Fixed missing title changes on tab change (thanks poy) +* Fixed user list filter (poy) -- 0.703 2007-11-08 -- * Fixed invalid strings (thanks james ross) Modified: dcplusplus/trunk/win32/HubFrame.cpp =================================================================== --- dcplusplus/trunk/win32/HubFrame.cpp 2007-11-30 18:30:26 UTC (rev 916) +++ dcplusplus/trunk/win32/HubFrame.cpp 2007-11-30 18:57:40 UTC (rev 917) @@ -105,7 +105,7 @@ { WidgetTextBox::Seed cs = WinUtil::Seeds::textBox; - cs.style = WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE; + cs.style = WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL; filter = createTextBox(cs); addWidget(filter); filter->onKeyUp(std::tr1::bind(&HubFrame::handleFilterKey, this, _1)); @@ -118,7 +118,7 @@ for(int j=0; j<COLUMN_LAST; j++) { filterType->addValue(TSTRING_I(columnNames[j])); } - filterType->addValue(CTSTRING(ANY)); + filterType->addValue(TSTRING(ANY)); filterType->setSelectedIndex(COLUMN_LAST); filterType->onSelectionChanged(std::tr1::bind(&HubFrame::updateUserList, this, (UserInfo*)0)); } @@ -206,6 +206,8 @@ int xfilter = showUsers->getChecked() ? std::min(r.size.x / 4, 200l) : 0; SmartWin::Rectangle rm(0, r.size.y - ymessage, r.size.x - xfilter, ymessage); message->setBounds(rm); + + r.size.y -= rm.size.y + border; rm.pos.x += rm.size.x + border; rm.size.x = showUsers->getChecked() ? xfilter * 2 / 3 - border : 0; @@ -213,9 +215,8 @@ rm.pos.x += rm.size.x + border; rm.size.x = showUsers->getChecked() ? xfilter / 3 - border : 0; + rm.size.y += 140; filterType->setBounds(rm); - - r.size.y -= rm.size.y + border; bool checked = showUsers->getChecked(); if(checked && !paned->getSecond()) { Modified: dcplusplus/trunk/win32/PublicHubsFrame.cpp =================================================================== --- dcplusplus/trunk/win32/PublicHubsFrame.cpp 2007-11-30 18:30:26 UTC (rev 916) +++ dcplusplus/trunk/win32/PublicHubsFrame.cpp 2007-11-30 18:57:40 UTC (rev 917) @@ -157,9 +157,9 @@ //populate the filter list with the column names for(int j=0; j<COLUMN_LAST; j++) { - filterSel->addValue(CTSTRING_I(columnNames[j])); + filterSel->addValue(TSTRING_I(columnNames[j])); } - filterSel->addValue(CTSTRING(ANY)); + filterSel->addValue(TSTRING(ANY)); filterSel->setSelectedIndex(COLUMN_LAST); filterSel->onSelectionChanged(std::tr1::bind(&PublicHubsFrame::updateList, this)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zou...@us...> - 2007-11-30 18:30:30
|
Revision: 916 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=916&view=rev Author: zouzou123gen Date: 2007-11-30 10:30:26 -0800 (Fri, 30 Nov 2007) Log Message: ----------- WidgetTabView fixes (add & addWidget merged; active window check in WM_SETTEXT) Modified Paths: -------------- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2007-11-29 23:07:27 UTC (rev 915) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2007-11-30 18:30:26 UTC (rev 916) @@ -32,10 +32,7 @@ Seed(); }; - void add(WidgetChildWindow* w, const IconPtr& icon) { - addWidget(w, icon, w->getText(), w->getVisible()); - w->onTextChanging(std::tr1::bind(&WidgetTabView::handleTextChanging, this, w, _1)); - } + void add(WidgetChildWindow* w, const IconPtr& icon); void mark(WidgetChildWindow* w); @@ -109,7 +106,6 @@ void layout(); int addIcon(const IconPtr& icon); - void addWidget(WidgetChildWindow* w, const IconPtr& icon, const SmartUtil::tstring& title, bool visible); void swapWidgets(WidgetChildWindow* oldW, WidgetChildWindow* newW); }; Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2007-11-29 23:07:27 UTC (rev 915) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2007-11-30 18:30:26 UTC (rev 916) @@ -33,15 +33,15 @@ tab->onContextMenu(std::tr1::bind(&WidgetTabView::handleContextMenu, this, _1)); } -void WidgetTabView::addWidget(WidgetChildWindow* w, const IconPtr& icon, const SmartUtil::tstring& title, bool visible) { +void WidgetTabView::add(WidgetChildWindow* w, const IconPtr& icon) { int image = addIcon(icon); size_t tabs = tab->size(); TabInfo* ti = new TabInfo(w); - tab->addPage(cutTitle(title), tabs, reinterpret_cast<LPARAM>(ti), image); + tab->addPage(cutTitle(w->getText()), tabs, reinterpret_cast<LPARAM>(ti), image); viewOrder.push_front(w); - if(viewOrder.size() == 1 || visible) { + if(viewOrder.size() == 1 || w->getVisible()) { if(viewOrder.size() > 1) { swapWidgets(viewOrder.back(), w); } else { @@ -51,6 +51,8 @@ } layout(); + + w->onTextChanging(std::tr1::bind(&WidgetTabView::handleTextChanging, this, w, _1)); } WidgetChildWindow* WidgetTabView::getActive() { @@ -165,7 +167,7 @@ tab->setHeader(i, cutTitle(newText)); layout(); - if(titleChangedFunction) + if((i == active) && titleChangedFunction) titleChangedFunction(newText); } return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-29 23:07:29
|
Revision: 915 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=915&view=rev Author: arnetheduck Date: 2007-11-29 15:07:27 -0800 (Thu, 29 Nov 2007) Log Message: ----------- Split out some extensions, cologic's editing Modified Paths: -------------- dcplusplus/trunk/ADC.txt Added Paths: ----------- dcplusplus/trunk/ADC-EXT.txt Added: dcplusplus/trunk/ADC-EXT.txt =================================================================== --- dcplusplus/trunk/ADC-EXT.txt (rev 0) +++ dcplusplus/trunk/ADC-EXT.txt 2007-11-29 23:07:27 UTC (rev 915) @@ -0,0 +1,32 @@ += Proposed ADC extensions + +These are extensions which have been proposed but lack implementation, detail +or testing before they can be added to the real ADC spec. + +=== REGX - Regular expressions in searches +This extension adds to the SCH command an additional operator RE that takes a +Perl regular expression (http://perldoc.perl.org/perlre.html) with full +Unicode support. Clients that support this must send "REGX" in their support +string in the INF SU field. + +=== ADCS - Secure ADC <work-in-progress> +==== Introduction +Secure ADC connections can be established using a TLS tunnel, both for hub and +for client connections. Certificates can be used to authenticate both hub and +user, for example by making the hub the root CA, and only allow clients signed +by the hub to connect. Ephemeral keys should be use to ensure forward secrecy +when possible. + +==== Client-Hub encryption +TLS client-hub connections can be initiated either by negotiating the feature +"ADCS" on connection or by using the protocol adcs:// when initiating the +connection. Hubs can choose to request a certificate for the user on login, +and use this certificate to replace password-based login. + +==== Client-Client encryption +TLS client-client connections can be established either by negotiating the +feature "ADCS" on connection or by specifying "ADCS/1.0" in the CTM protocol +field. Clients supporting encrypted connections must indicate this in the INF +SU field with "ADCS" + +// vim: set syntax=asciidoc: Modified: dcplusplus/trunk/ADC.txt =================================================================== --- dcplusplus/trunk/ADC.txt 2007-11-29 23:02:47 UTC (rev 914) +++ dcplusplus/trunk/ADC.txt 2007-11-29 23:07:27 UTC (rev 915) @@ -15,9 +15,9 @@ Advanced Direct Connect is the first neutral thing that springs to mind =). Many ideas for the protocol come from Jan Vidar Krey's DCTNG draft. Other -contributors include Dustin Brody, Walter Doekes, Timmo Stange, Fredrik Ullner -and others. Jon Hess contributed the original Direct Connect idea through the -Neo-Modus Direct Connect client / hub. +contributors include Dustin Brody, Walter Doekes, Timmo Stange, Fredrik +Ullner, Fredrik Stenberg and others. Jon Hess contributed the original Direct +Connect idea through the Neo-Modus Direct Connect client / hub. The latest draft version of this document can be downloaded from $URL$. @@ -27,9 +27,9 @@ === General * All messages begin with a four-letter word. The first letter designates how the message should be sent and the other three specify what to do. -* Parameters are separated by space, and a newline (codepoint 0x0a) ends each +* Parameters are separated by space and a newline (codepoint 0x0a) ends each message. The string "\s" escapes space, "\n" newline and "\\" backslash. - This version of the protocol reserves all other escapes for future use; and + This version of the protocol reserves all other escapes for future use; any message containing unknown escapes must be discarded. * All text must be sent as UTF-8 encoded Unicode in normalization form C. * Clients must ignore unknown/badly formatted messages. Hubs must ignore @@ -39,18 +39,18 @@ IPv4 and RFC 1884 form for IPv6. Hub addresses must be specified in URL form, with "adc" as protocol specifier ("adc://server:port/"). * Numbers are sent as strings in standard floating point notation, using '.' - as the decimal separator and no thousands separator. Integers are numbers + as the decimal separator and without a thousands separator. Integers are numbers with neither a decimal portion nor an exponent. Applications should be prepared to handle at least 64-bit signed integers and 64-bit floating point numbers. A '-' prefix negates. -* SIDs, PIDs, CIDs and short binary data are sent as base32-encoded strings. +* SIDs, PIDs, CIDs, and short binary data are sent as base32-encoded strings. Long binary data transfers should use the file transfer mechanism with named roots. -* Extension names, protocol names and other text not entered by the user may +* Extension names, protocol names, and other text not entered by the user may only include viewable characters that can be encoded by one byte in the UTF-8 encoding (Unicode codepoints 33-127). ADC is case-sensitive, requiring upper case for command names. -* Some of the commands and functionality require the use of a hash function. +* Some commands and functionality require the use of a hash function. The hash function is negotiated during session setup and stays the same for the duration of the session. @@ -85,11 +85,11 @@ .................. === Message types -Message type specifies how messages should be routed, and thus which -additional fields can be found in the message header. Clients should use the -most limiting type, in terms of recipients, that makes sense for a particular -message when sending it to the hub for distribution. Clients should disregard -the message type when interpreting the message (after having parsed it). The +Message type specifies how messages should be routed and thus which additional +fields can be found in the message header. Clients should use the most +limiting type, in terms of recipients, that makes sense for a particular +message when sending it to the hub for distribution. Clients should use the +message type only to aid in parsing the message and otherwise ignore it. The following message types are defined: [separator="|"] @@ -106,9 +106,9 @@ === Session hash Certain commands require the use of a hash function. The hash function used is -negotiated each time a new connection is established using the SUP mechanism. +negotiated using the SUP mechanism each time a new connection is established. When a client first connects, it offers a set of hash functions as SUP -features. The server picks one of the offered functions and communicates the +features. The server picks one of the offered functions and communicates its choice to the client by placing it before any other hash features present in the first SUP from the server. Clients and hubs are required to support at least one hash function, used both for protocol purposes and file @@ -116,7 +116,7 @@ === Client identification Each client is identified by three different IDs, Session ID (SID), Private ID -(PID) and Client ID (CID). +(PID), and Client ID (CID). ==== Session ID Session IDs appear in all communication that interacts with the hub. They @@ -126,7 +126,7 @@ ==== Private ID Private IDs globally identify a unique client. They function during initial -protocol negotiation to generate the CID, and are invisible to other clients. +protocol negotiation to generate the CID and are invisible to other clients. PIDs should be generated in a way to avoid collisions, for example using the hash of the current time and primary network card MAC address if sufficient randomness cannot be generated. Hubs and clients may not disclose PIDs to @@ -144,18 +144,18 @@ == Files === File names and structure Filenames are relative to a fictive root in the user's share. "/" separates -directories, and each file or directory name must be unique in a -case-insensitive context. All printable characters, including whitespace, are -valid names for files, the "/" and "\" being escaped by "\". Clients must then -properly filter the filename for the target file system, as well as request -filenames from other clients according to these rules. The special names "." -and ".." may not occur as a directory or filename; any file list received -containing those must be ignored. All directory names must end with a "/". +directories; each file or directory name must be unique in a case-insensitive +context. All printable characters, including whitespace, are valid names for +files, the "/" and "\" being escaped by "\". Clients must then properly filter +the filename for the target file system, as well as request filenames from +other clients according to these rules. The special names "." and ".." may not +occur as a directory or filename; any file list received containing those must +be ignored. All directory names must end with a "/". Shared files are identified relative to the unnamed root "/" ("/dir/subdir/filename.ext"), while extensions can add named roots to this namespace. For example, "TTH/..." from the TIGR extension uses the named root -"TTH" to identify files by their tiger tree hash. It is invalid for names +"TTH" to identify files by their Tiger tree hash. It is invalid for names from the unnamed root to appear in the share without also being identified by at least one hash value. @@ -322,7 +322,7 @@ During login, the client goes through a number of stages. An action is valid only in the NORMAL stage unless otherwise noted. The stages, in login order, are PROTOCOL (feature support discovery), IDENTIFY (user identification, -static checks), VERIFY (password check), NORMAL (normal operation) and DATA +static checks), VERIFY (password check), NORMAL (normal operation), and DATA (for binary transfers). === Client – Client communication @@ -340,7 +340,7 @@ States: All -Status code in the form "xyy" where x specifies severity, and yy the specific +Status code in the form "xyy" where x specifies severity and yy the specific error code. The severity and error code are treated separately, the same error could occur at different severity levels. @@ -348,7 +348,7 @@ [separator="|"] ``_ -0 | Success (used for confirming commands), error code must be "00" and an additional flag "FC" contains the FOURCC of the command being confirmed if applicable. +0 | Success (used for confirming commands), error code must be "00", and an additional flag "FC" contains the FOURCC of the command being confirmed if applicable. 1 | Recoverable (error but no disconnect) 2 | Fatal (disconnect) ___ @@ -380,10 +380,12 @@ 44 | Invalid state, flag "FC" the FOURCC of the offending command. 45 | Required feature missing, flag "FC" specifies the FOURCC of the missing feature. 46 | Invalid IP supplied in INF, flag "I4" or "I6" specifies the correct IP. +47 | No hash support overlap in SUP between client and hub. 50 | Client-client / file transfer error 51 | File not available 52 | File part not available 53 | Slots full +54 | No hash support overlap in SUP between clients. ___ Description: @@ -410,11 +412,11 @@ indicates support for regardless of its own SUP, and vice versa. This command can also be used to dynamically add / remove features, 'AD' -meaning add and 'RM' remove. +meaning add and 'RM' meaning remove. When the server receives this message the first time, it should reply in kind, -assign an SID to the client, send an INF about itself and move to the IDENTIFY -state. +assign an SID to the client, send an INF about itself, and move to the +IDENTIFY state. ==== SID SID sid @@ -437,7 +439,7 @@ This command updates the information about a client. Each time this is received, it means that the fields specified have been added or updated. Each field is identified by two characters, directly followed by the data -associated with that field. A field (and the effects of its presence) can be +associated with that field. A field, and the effects of its presence, can be canceled by sending the field name without data. Clients must ignore fields they don't recognize. Most of these fields are only interesting in the client-hub communication; during client-client this command is mainly used for @@ -458,7 +460,7 @@ ___ ID | base32 | The CID of the client. Mandatory for C-C connections. PD | base32 | The PID of the client. Hubs must check that the hash(PID) == CID and then discard the field before broadcasting it to other clients. Must not be sent in C-C connections. -I4 | IPv4 | IPv4 address without port. A zero address (0.0.0.0) means that the server should replace it with the real IP of the client. Hubs must check that a specified address corresponds to what the client is connecting from to avoid DoS attacks, and only allow trusted clients to specify a different address. Clients should use the zero address when connecting, but may opt not to do so at the user's discretion. Any client that supports incoming TCPv4 connections must also add the feature TCP4 to their SU field. +I4 | IPv4 | IPv4 address without port. A zero address (0.0.0.0) means that the server should replace it with the real IP of the client. Hubs must check that a specified address corresponds to what the client is connecting from to avoid DoS attacks and only allow trusted clients to specify a different address. Clients should use the zero address when connecting, but may opt not to do so at the user's discretion. Any client that supports incoming TCPv4 connections must also add the feature TCP4 to their SU field. I6 | IPv6 | IPv6 address without port. A zero address (::) means that the server should replace it with the IP of the client. Any client that supports incoming TCPv6 connections must also add the feature TCP6 to their SU field. U4 | integer | Client UDP port. Any client that supports incoming UDPv4 packets must also add the feature UDP4 to their SU field. U6 | integer | Same as U4, but for IPv6. Any client that supports incoming UDPv6 packets must also add the feature UDP6 to their SU field. @@ -486,17 +488,16 @@ merrier (and clients could be disconnected for not sending some of them). Note; normally one would only accept an IP (I4 or I6) that is the same as the -source IP of the connecting peer, allowing otherwise for trusted users only -because your could channel DDoS attacks. Use caution when accepting unknown -IPs. Only for trusted users one may allow a different IP or an IP from a -different domain (Ipv4 or Ipv6) to be specified. If you fail to do this, your -hub can be used as a medium for DDoS attacks. +source IP of the connecting peer. Use caution when accepting unknown IPs. Only +for trusted users one may allow a different IP or an IP from a different +domain (IPv4 or IPv6) to be specified. If you fail to do this, your hub can be +used as a medium for DDoS attacks. When a hub receives this message in the IDENTIFY state, it should proceed to the VERIFY state by sending a PAS request or NORMAL state by starting sending the INF of all clients, where the INF of the connecting client must come last. -When the hub that sends an INF about itself, the NI becomes hub name, VE -version etc. +When the hub that sends an INF about itself, the NI becomes hub name, the VE +the hub version, and DE the hub description. When the server receives this during client-client communication in IDENTIFY state, it should verify the ID and TO fields, send an INF about itself and @@ -539,8 +540,8 @@ TY | File type, to be chosen from the following (none specified = any type): 1 = File, 2 = Directory ___ -Searching by UDP is subject to IP spoofing, and can thus be used to initiate a -DoS attack. Clients should only accept incoming UDP searches in a trusted +Searching by UDP is subject to IP spoofing; can thus be used to initiate a DoS +attack. Clients should only accept incoming UDP searches in a trusted environment. ==== RES @@ -568,11 +569,11 @@ Connect to me. Used by active clients that want to connect to someone, or in response to RCM. Only TCP active clients may send this. <token> is a string -that identifies the incoming connection triggered by this command, and must be +that identifies the incoming connection triggered by this command and must be present in the INF command of the connecting client. Clients should not accept incoming connections with a token they did not send earlier. <protocol> is an arbitrary string specifying the protocol to connect with; in the case of an -ADC compliant connection attempt, this should be the string "ADC/1.0". If +ADC 1.0 compliant connection attempt, this should be the string "ADC/1.0". If <protocol> is supported, a response to RCM must copy the <token> and <protocol> fields directly. If a protocol is not supported, a DSTA must be sent indicating this. @@ -674,9 +675,9 @@ Contexts: C Transitions to DATA state. The sender will transmit until <bytes> bytes of -binary data have been sent, and then will transition back to NORMAL state. The -parameters essentially correspond to the GET parameters, but if <bytes> equals --1 it must be replaced by the number of bytes needed to complete the file +binary data have been sent and then will transition back to NORMAL state. The +parameters correspond to the GET parameters except that if <bytes> equals -1 +it must be replaced by the number of bytes needed to complete the file starting at <start_pos>. == Examples @@ -715,19 +716,23 @@ == Standard Extensions +Apart from supporting BASE, clients may opt to implement one or more of the +following standard extensions. To be considered for addition, an extension must +be well documented and must be implemented and tested in the real world. + === TIGR - Tiger tree hash support ==== General -This extension adds tiger tree hash support to the base protocol. It is -intended to be used both for identifying files and for protocol purposes such -as CID generation and password negotiation +This extension adds Tiger tree hash support to the base protocol. It is +intended to be used both for identifying files and for purposes such as CID +generation and password negotiation ==== TIGR for shared files All files shared by TIGR supporting clients must have been hashed using Merkle Hash trees, as defined by http://www.open-content.net/specs/draft-jchapweske-thex-02.html. The Tiger -algorithm, as specified by http://www.cs.technion.ac.il/~biham/Reports/Tiger/ +algorithm, as specified by http://www.cs.technion.ac.il/~biham/Reports/Tiger/, functions as the hash algorithm. A base segment size of 1024 bytes must be used when generating the tree, but clients may then discard parts of the tree as long as at least 7 levels are kept or a block granularity of 64 KiB is @@ -735,23 +740,23 @@ Generally, the root of the tree (TTH) serves to identify a file uniquely. Searches use it and it must be present in the file list. Further, the root of -the file list must also be available, and discoverable via GFI. A client may +the file list must also be available and discoverable via GFI. A client may also request the rest of the tree using the normal client-client transfer procedure. The root must be encoded using base32 encoding when converted to text. In the file list, each File element carries an additional attribute "TTH" -containing the base32-encoded value of the tiger tree root. +containing the base32-encoded value of the Tiger tree root. In the GET/GFI type, the full tree may be accessed using the "tthl" type. "tthl" transfers send the largest set of leaves available) as a binary stream of leaf data, right-to-left, with no spacing in between them. <start_pos> must be set to 0 and <bytes> to -1 when requesting the data. <bytes> must -contain the total binary size of the leaf stream in SND, and by dividing this +contain the total binary size of the leaf stream in SND; by dividing this length by the individual hash length, the number of leaves, and thus the leaf -level can be deducted. The received leaves can then be used to reconstruct the -entire tree, and the resulting root must match the root of the file (this +level, can be deducted. The received leaves can then be used to reconstruct +the entire tree, and the resulting root must match the root of the file (this verifies the integrity of the tree itself). Identifier must be a TTH root value from the "TTH/" root. @@ -762,7 +767,7 @@ [separator="|"] ``_ -TR | Tiger tree hash root, encoded with base32. +TR | Tiger tree Hash root, encoded with base32. TD | Tree depth, index of the highest level of tree data available, root-only = 0, first level (2 leaves) = 1, second level = 2, etc... ___ @@ -770,12 +775,6 @@ This extension adds a special file "files.xml.bz2" in the unnamed root of the share which contains "files.xml" compressed with bzip2 1.0.3+ (www.bzip.org). -=== REGX - Regular expressions in searches -This extension adds to the SCH command an additional operator RE that takes a -Perl regular expression (http://perldoc.perl.org/perlre.html) with full -Unicode support. Clients that support this must send "REGX" in their support -string in the INF SU field. - === ZLIB - Compressed communication There are two variants of zlib support, FULL and GET, and only one should be used on a each communications channel set up. @@ -801,11 +800,11 @@ === UCMD - User commands User commands are used to send hub-specific commands to the client which provide useful shortcuts for the user. These commands contain strings which -must be sent back to the hub, and parameter substitutions in the strings. Each +must be sent back to the hub and parameter substitutions in the strings. Each user command has a display name, a string to be sent to the hub, and one or more categories where it may appear. The strings passed to the hub must first be passed through a dictionary replacement that replaces all keywords in the -string, and then through the equivalent of the C standard function "strftime", +string and then through the equivalent of the C standard function "strftime", with the current time. ==== CMD @@ -826,7 +825,7 @@ | 2 = User list command, client and user parameters | 4 = Search result command, client, user and file parameters | 8 = File list command, client, user and file parameters -TT | The full text to be sent to hub, including fourcc and any parameters +TT | The full text to be sent to hub, including FOURCC and any parameters CO | 1 = Constrained, when sending this command on multiple users (for example in search results), constrain it to once per CID only SP | 1 = Insert separator instead of command name (name must still be present to uniquely identify the command) ___ @@ -843,7 +842,7 @@ ``_ myCID | Client CID mySID | Client SID -myXX | One for each flag on that particular hub, for example myI4, myNI, etc. +myXX | One for each flag on that particular hub; for example, myI4 and myNI ___ User parameters @@ -852,7 +851,7 @@ ``_ userCID | User CID userSID | SID of the user -userXX | One for each flag the user sent, for example userI4, userNI, etc. +userXX | One for each flag the user sent; for example, userI4 and userNI ___ File parameters @@ -869,24 +868,4 @@ hubXX | One for each flag of the hub ___ -=== ADCS - Secure ADC <work-in-progress> -==== Introduction -Secure ADC connections can be established using a TLS tunnel, both for hub and -for client connections. Certificates can be used to authenticate both hub and -user, for example by making the hub the root CA, and only allow clients signed -by the hub to connect. Ephemeral keys should be use to ensure forward secrecy -when possible. - -==== Client-Hub encryption -TLS client-hub connections can be initiated either by negotiating the feature -"ADCS" on connection or by using the protocol adcs:// when initiating the -connection. Hubs can choose to request a certificate for the user on login, -and use this certificate to replace password-based login. - -==== Client-Client encryption -TLS client-client connections can be established either by negotiating the -feature "ADCS" on connection or by specifying "ADCS/1.0" in the CTM protocol -field. Clients supporting encrypted connections must indicate this in the INF -SU field with "ADCS" - // vim: set syntax=asciidoc: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-29 23:02:49
|
Revision: 914 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=914&view=rev Author: arnetheduck Date: 2007-11-29 15:02:47 -0800 (Thu, 29 Nov 2007) Log Message: ----------- patches Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp dcplusplus/trunk/win32/MDIChildFrame.h dcplusplus/trunk/win32/MainWindow.cpp dcplusplus/trunk/win32/MainWindow.h dcplusplus/trunk/win32/PublicHubsFrame.cpp dcplusplus/trunk/win32/PublicHubsFrame.h dcplusplus/trunk/win32/SearchFrame.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/changelog.txt 2007-11-29 23:02:47 UTC (rev 914) @@ -14,6 +14,8 @@ * Fixed some msvc compile issues (thanks james ross) * Fixed key handling in file listings (poy) * Message always focused first in chats (poy) +* Fixed filter in public hubs (thanks poy) +* Fixed missing title changes on tab change (thanks poy) -- 0.703 2007-11-08 -- * Fixed invalid strings (thanks james ross) Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTabView.h 2007-11-29 23:02:47 UTC (rev 914) @@ -2,6 +2,7 @@ #define WIDGETTABVIEW_H_ #include "WidgetTabSheet.h" +#include "WidgetWindow.h" #include "../WindowClass.h" #include <list> #include <vector> @@ -30,24 +31,27 @@ /// Fills with default parameters Seed(); }; - - template<typename T> - void add(T* w, const IconPtr& icon) { + + void add(WidgetChildWindow* w, const IconPtr& icon) { addWidget(w, icon, w->getText(), w->getVisible()); w->onTextChanging(std::tr1::bind(&WidgetTabView::handleTextChanging, this, w, _1)); } - void mark(Widget* w); + void mark(WidgetChildWindow* w); - void remove(Widget* w); + void remove(WidgetChildWindow* w); void next(bool reverse = false); - Widget* getActive(); - void setActive(Widget* w) { setActive(findTab(w)); } - - void onTabContextMenu(Widget* w, const std::tr1::function<bool (const ScreenCoordinate& pt)>& f); + WidgetChildWindow* getActive(); + void setActive(WidgetChildWindow* w) { setActive(findTab(w)); } + void onTitleChanged(const std::tr1::function<void (const SmartUtil::tstring&)>& f) { + titleChangedFunction = f; + } + + void onTabContextMenu(WidgetChildWindow* w, const std::tr1::function<bool (const ScreenCoordinate& pt)>& f); + bool filter(const MSG& msg); WidgetTabSheet::ObjectType getTab(); @@ -68,8 +72,8 @@ private: enum { MAX_TITLE_LENGTH = 20 }; struct TabInfo { - TabInfo(Widget* w_) : w(w_) { } - Widget* w; + TabInfo(WidgetChildWindow* w_) : w(w_) { } + WidgetChildWindow* w; std::tr1::function<bool (const ScreenCoordinate& pt)> handleContextMenu; }; @@ -77,24 +81,26 @@ WidgetTabSheet::ObjectType tab; + std::tr1::function<void (const SmartUtil::tstring&)> titleChangedFunction; + bool inTab; - typedef std::list<Widget*> WindowList; + typedef std::list<WidgetChildWindow*> WindowList; typedef WindowList::iterator WindowIter; WindowList viewOrder; Rectangle clientSize; std::vector<IconPtr> icons; int active; - int findTab(Widget* w); + int findTab(WidgetChildWindow* w); void setActive(int i); - TabInfo* getTabInfo(Widget* w); + TabInfo* getTabInfo(WidgetChildWindow* w); TabInfo* getTabInfo(int i); - void setTop(Widget* w); + void setTop(WidgetChildWindow* w); - bool handleTextChanging(Widget* w, const SmartUtil::tstring& newText); + bool handleTextChanging(WidgetChildWindow* w, const SmartUtil::tstring& newText); bool handleSized(const WidgetSizedEventResult&); void handleTabSelected(); bool handleContextMenu(SmartWin::ScreenCoordinate pt); @@ -103,8 +109,8 @@ void layout(); int addIcon(const IconPtr& icon); - void addWidget(Widget* w, const IconPtr& icon, const SmartUtil::tstring& title, bool visible); - void swapWidgets(Widget* oldW, Widget* newW); + void addWidget(WidgetChildWindow* w, const IconPtr& icon, const SmartUtil::tstring& title, bool visible); + void swapWidgets(WidgetChildWindow* oldW, WidgetChildWindow* newW); }; inline WidgetTabSheet::ObjectType WidgetTabView::getTab() Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetTabView.cpp 2007-11-29 23:02:47 UTC (rev 914) @@ -33,7 +33,7 @@ tab->onContextMenu(std::tr1::bind(&WidgetTabView::handleContextMenu, this, _1)); } -void WidgetTabView::addWidget(Widget* w, const IconPtr& icon, const SmartUtil::tstring& title, bool visible) { +void WidgetTabView::addWidget(WidgetChildWindow* w, const IconPtr& icon, const SmartUtil::tstring& title, bool visible) { int image = addIcon(icon); size_t tabs = tab->size(); TabInfo* ti = new TabInfo(w); @@ -53,17 +53,17 @@ layout(); } -Widget* WidgetTabView::getActive() { +WidgetChildWindow* WidgetTabView::getActive() { TabInfo* ti = getTabInfo(tab->getSelectedIndex()); return ti ? ti->w : 0; } -void WidgetTabView::remove(Widget* w) { +void WidgetTabView::remove(WidgetChildWindow* w) { if(viewOrder.size() > 1 && viewOrder.back() == w) { setActive(*(--(--viewOrder.end()))); } - Widget* cur = getTabInfo(tab->getSelectedIndex())->w; + WidgetChildWindow* cur = getTabInfo(tab->getSelectedIndex())->w; viewOrder.remove(w); @@ -74,9 +74,13 @@ layout(); } active = findTab(cur); + + // when no tab is opened + if(titleChangedFunction && (active == -1)) + titleChangedFunction(SmartUtil::tstring()); } -void WidgetTabView::onTabContextMenu(Widget* w, const std::tr1::function<bool (const ScreenCoordinate& pt)>& f) { +void WidgetTabView::onTabContextMenu(WidgetChildWindow* w, const std::tr1::function<bool (const ScreenCoordinate& pt)>& f) { TabInfo* ti = getTabInfo(w); if(ti) { ti->handleContextMenu = f; @@ -91,7 +95,7 @@ handleTabSelected(); } -void WidgetTabView::swapWidgets(Widget* oldW, Widget* newW) { +void WidgetTabView::swapWidgets(WidgetChildWindow* oldW, WidgetChildWindow* newW) { sendMessage(WM_SETREDRAW, FALSE); if(oldW) { @@ -126,16 +130,19 @@ setTop(ti->w); active = i; tab->setHighlight(i, false); + + if(titleChangedFunction) + titleChangedFunction(ti->w->getText()); } -void WidgetTabView::mark(Widget* w) { +void WidgetTabView::mark(WidgetChildWindow* w) { int i = findTab(w); if(i != -1 && i != tab->getSelectedIndex()) { tab->setHighlight(i, true); } } -int WidgetTabView::findTab(Widget* w) { +int WidgetTabView::findTab(WidgetChildWindow* w) { for(size_t i = 0; i < tab->size(); ++i) { if(getTabInfo(i)->w == w) { return static_cast<int>(i); @@ -144,7 +151,7 @@ return -1; } -WidgetTabView::TabInfo* WidgetTabView::getTabInfo(Widget* w) { +WidgetTabView::TabInfo* WidgetTabView::getTabInfo(WidgetChildWindow* w) { return getTabInfo(findTab(w)); } @@ -152,11 +159,14 @@ return i == -1 ? 0 : reinterpret_cast<TabInfo*>(tab->getData(i)); } -bool WidgetTabView::handleTextChanging(Widget* w, const SmartUtil::tstring& newText) { +bool WidgetTabView::handleTextChanging(WidgetChildWindow* w, const SmartUtil::tstring& newText) { int i = findTab(w); if(i != -1) { tab->setHeader(i, cutTitle(newText)); layout(); + + if(titleChangedFunction) + titleChangedFunction(newText); } return true; } @@ -195,7 +205,7 @@ if(viewOrder.size() < 2) { return; } - Widget* wnd = getActive(); + WidgetChildWindow* wnd = getActive(); if(!wnd) { return; } @@ -230,7 +240,7 @@ return; } -void WidgetTabView::setTop(Widget* wnd) { +void WidgetTabView::setTop(WidgetChildWindow* wnd) { WindowIter i = std::find(viewOrder.begin(), viewOrder.end(), wnd); if(i != viewOrder.end() && i != --viewOrder.end()) { viewOrder.erase(i); Modified: dcplusplus/trunk/win32/MDIChildFrame.h =================================================================== --- dcplusplus/trunk/win32/MDIChildFrame.h 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/win32/MDIChildFrame.h 2007-11-29 23:02:47 UTC (rev 914) @@ -66,6 +66,7 @@ onSized(std::tr1::bind(&ThisType::handleSized, this, _1)); onActivate(std::tr1::bind(&ThisType::handleActivate, this, _1)); onCommand(std::tr1::bind(&ThisType::close, this, true), IDC_CLOSE_WINDOW); + addDlgCodeMessage(this); } virtual ~MDIChildFrame() { @@ -90,7 +91,10 @@ template<typename W> void addWidget(W* widget, bool alwaysFocus = false) { + addDlgCodeMessage(widget); + addColor(widget); + if(alwaysFocus || (lastFocus == NULL)) { lastFocus = widget->handle(); ::SetFocus(lastFocus); @@ -122,7 +126,19 @@ bool alwaysSameFocus; // always focus the same widget bool reallyClose; - + + void addDlgCodeMessage(SmartWin::WidgetComboBox* widget) { + widget->onRaw(std::tr1::bind(&ThisType::handleGetDlgCode, this, _1), SmartWin::Message(WM_GETDLGCODE)); + SmartWin::WidgetTextBox* text = widget->getTextBox(); + if(text) + text->onRaw(std::tr1::bind(&ThisType::handleGetDlgCode, this, _1), SmartWin::Message(WM_GETDLGCODE)); + } + + template<typename W> + void addDlgCodeMessage(W* widget) { + widget->onRaw(std::tr1::bind(&ThisType::handleGetDlgCode, this, _1), SmartWin::Message(WM_GETDLGCODE)); + } + void addColor(SmartWin::WidgetComboBox* widget) { widget->onBackgroundColor(std::tr1::bind(&ThisType::handleBackgroundColor, this, _1)); SmartWin::WidgetTextBox* text = widget->getTextBox(); @@ -156,7 +172,13 @@ lastFocus = focus; } } - + + LRESULT handleGetDlgCode(WPARAM wParam) { + if(wParam != VK_TAB) + return DLGC_WANTMESSAGE; + return 0; + } + SmartWin::BrushPtr handleBackgroundColor(SmartWin::Canvas& canvas) { canvas.setBkColor(WinUtil::bgColor); canvas.setTextColor(WinUtil::textColor); Modified: dcplusplus/trunk/win32/MainWindow.cpp =================================================================== --- dcplusplus/trunk/win32/MainWindow.cpp 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/win32/MainWindow.cpp 2007-11-29 23:02:47 UTC (rev 914) @@ -309,6 +309,7 @@ WidgetTabView::Seed cs; cs.style = WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE; tabs = createTabView(cs); + tabs->onTitleChanged(std::tr1::bind(&MainWindow::handleTabsTitleChanged, this, _1)); paned->setFirst(tabs); } @@ -327,7 +328,7 @@ return true; } - SmartWin::Widget* active = getMDIParent()->getActive(); + SmartWin::WidgetChildWindow* active = getMDIParent()->getActive(); if(active) { if(::IsDialogMessage( active->handle(), & msg )) { return true; @@ -337,6 +338,10 @@ return false; } +void MainWindow::handleTabsTitleChanged(const SmartUtil::tstring& title) { + setText(title.empty() ? _T(APPNAME) _T(" ") _T(VERSIONSTRING) : _T(APPNAME) _T(" ") _T(VERSIONSTRING) _T(" - [") + title + _T("]")); +} + void MainWindow::handleExit() { close(true); } @@ -788,7 +793,7 @@ void MainWindow::handleActivate(bool active) { // Forward to active tab window - Widget* w = tabs->getActive(); + WidgetChildWindow* w = tabs->getActive(); if(w) { w->sendMessage(WM_ACTIVATE, active ? WA_ACTIVE : WA_INACTIVE); } Modified: dcplusplus/trunk/win32/MainWindow.h =================================================================== --- dcplusplus/trunk/win32/MainWindow.h 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/win32/MainWindow.h 2007-11-29 23:02:47 UTC (rev 914) @@ -169,6 +169,8 @@ LRESULT trayMessage(WPARAM wParam, LPARAM lParam); LRESULT handleCopyData(WPARAM wParam, LPARAM lParam); LRESULT handleWhereAreYou(WPARAM wParam, LPARAM lParam); + + void handleTabsTitleChanged(const SmartUtil::tstring& title); void layout(); bool eachSecond(); Modified: dcplusplus/trunk/win32/PublicHubsFrame.cpp =================================================================== --- dcplusplus/trunk/win32/PublicHubsFrame.cpp 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/win32/PublicHubsFrame.cpp 2007-11-29 23:02:47 UTC (rev 914) @@ -153,6 +153,7 @@ pubLists->onSelectionChanged(std::tr1::bind(&PublicHubsFrame::handleListSelChanged, this)); filterSel = createComboBox(WinUtil::Seeds::comboBoxStatic); + addWidget(filterSel); //populate the filter list with the column names for(int j=0; j<COLUMN_LAST; j++) { @@ -160,12 +161,14 @@ } filterSel->addValue(CTSTRING(ANY)); filterSel->setSelectedIndex(COLUMN_LAST); + filterSel->onSelectionChanged(std::tr1::bind(&PublicHubsFrame::updateList, this)); } { WidgetTextBox::Seed cs = WinUtil::Seeds::textBox; cs.style = WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL; filter = createTextBox(cs); - filter->onChar(std::tr1::bind(&PublicHubsFrame::handleFilterChar, this, _1)); + addWidget(filter); + filter->onKeyDown(std::tr1::bind(&PublicHubsFrame::handleFilterKeyDown, this, _1)); } initStatus(); @@ -306,7 +309,7 @@ updateStatus(); } -HRESULT PublicHubsFrame::handleSpeaker(WPARAM wParam, LPARAM lParam) { +LRESULT PublicHubsFrame::handleSpeaker(WPARAM wParam, LPARAM lParam) { if((wParam == FINISHED) || (wParam == LOADED_FROM_CACHE)) { std::auto_ptr<tstring> x(reinterpret_cast<tstring*>(lParam)); entries = FavoriteManager::getInstance()->getPublicHubs(); @@ -516,13 +519,12 @@ } void PublicHubsFrame::handleListSelChanged() { - printf("x\n"); FavoriteManager::getInstance()->setHubList(pubLists->getSelectedIndex()); entries = FavoriteManager::getInstance()->getPublicHubs(); updateList(); } -bool PublicHubsFrame::handleFilterChar(int c) { +bool PublicHubsFrame::handleFilterKeyDown(int c) { if(c == VK_RETURN) { filterString = Text::fromT(filter->getText()); updateList(); Modified: dcplusplus/trunk/win32/PublicHubsFrame.h =================================================================== --- dcplusplus/trunk/win32/PublicHubsFrame.h 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/win32/PublicHubsFrame.h 2007-11-29 23:02:47 UTC (rev 914) @@ -121,7 +121,7 @@ void layout(); bool preClosing(); void postClosing(); - HRESULT handleSpeaker(WPARAM wParam, LPARAM lParam); + LRESULT handleSpeaker(WPARAM wParam, LPARAM lParam); void handleConfigure(); void handleRefresh(); void handleConnect(); @@ -130,7 +130,7 @@ bool handleContextMenu(SmartWin::ScreenCoordinate pt); bool handleKeyDown(int c); void handleListSelChanged(); - bool handleFilterChar(int c); + bool handleFilterKeyDown(int c); bool checkNick(); void updateStatus(); Modified: dcplusplus/trunk/win32/SearchFrame.cpp =================================================================== --- dcplusplus/trunk/win32/SearchFrame.cpp 2007-11-26 22:24:35 UTC (rev 913) +++ dcplusplus/trunk/win32/SearchFrame.cpp 2007-11-29 23:02:47 UTC (rev 914) @@ -71,12 +71,6 @@ (*i)->close(true); } -static HRESULT allKeys(WPARAM wParam, LPARAM) { - if(wParam != VK_TAB) - return DLGC_WANTMESSAGE; - return 0; -} - SearchFrame::SearchFrame(SmartWin::WidgetTabView* mdiParent, const tstring& initialString_, LONGLONG initialSize_, SearchManager::SizeModes initialMode_, SearchManager::TypeModes initialType_) : BaseType(mdiParent, TSTRING(SEARCH), SmartWin::IconPtr(new SmartWin::Icon(IDR_SEARCH))), searchLabel(0), @@ -132,7 +126,6 @@ for(TStringIter i = lastSearches.begin(); i != lastSearches.end(); ++i) { searchBox->insertValue(0, *i); } - searchBox->getTextBox()->onRaw(std::tr1::bind(&allKeys, _1, _2), SmartWin::Message(WM_GETDLGCODE)); searchBox->getTextBox()->onKeyDown(std::tr1::bind(&SearchFrame::handleSearchKeyDown, this, _1)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-26 22:24:37
|
Revision: 913 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=913&view=rev Author: arnetheduck Date: 2007-11-26 14:24:35 -0800 (Mon, 26 Nov 2007) Log Message: ----------- patch Modified Paths: -------------- dcplusplus/trunk/ADC.txt dcplusplus/trunk/changelog.txt dcplusplus/trunk/win32/HubFrame.cpp dcplusplus/trunk/win32/MDIChildFrame.h dcplusplus/trunk/win32/PrivateFrame.cpp Modified: dcplusplus/trunk/ADC.txt =================================================================== --- dcplusplus/trunk/ADC.txt 2007-11-25 18:44:05 UTC (rev 912) +++ dcplusplus/trunk/ADC.txt 2007-11-26 22:24:35 UTC (rev 913) @@ -479,7 +479,7 @@ TO | string | Token, as received in RCM/CTM, when establishing a C-C connection. CT | integer | Client (user) type, 1=bot, 2=registered user, 4=operator, 8=hub owner, 16=hub (used when the hub sends an INF about itself). Multiple types are specified by adding the numbers together. AW | integer | 1=Away, 2=Extended away, not interested in hub chat (hubs may skip sending broadcast type MSG commands to clients with this flag) -SU | string | Comma-separated list of feature FOURCC's. This notifies other clients of extended capabilities of the connecting client. Use with discretion. +SU | string | Comma-separated list of feature FOURCC's. This notifies other clients of extended capabilities of the connecting client. ___ Hubs may mandate or discard any set of fields, but obviously the more the @@ -686,8 +686,8 @@ ``_ Client | Hub ___ -HSUP ADBASE <other-features> | - | ISUP ADBASE <other-features> +HSUP ADBASE ADTIGR ... | + | ISUP ADBASE ADTIGR ... | ISID <client-sid> | IINF HU1 HI1 ... BINF <my-sid> ID... PD... | @@ -704,8 +704,8 @@ ``_ Client | Server ___ -CSUP ADBASE <other-features> | - | CSUP ADBASE <other-features> +CSUP ADBASE ADTIGR ... | + | CSUP ADBASE ADTIGR ... | CINF IDxxx CINF IDxxx TO<token> | | CGET ... Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2007-11-25 18:44:05 UTC (rev 912) +++ dcplusplus/trunk/changelog.txt 2007-11-26 22:24:35 UTC (rev 913) @@ -13,6 +13,7 @@ * Readded list view double buffering (thanks poy) * Fixed some msvc compile issues (thanks james ross) * Fixed key handling in file listings (poy) +* Message always focused first in chats (poy) -- 0.703 2007-11-08 -- * Fixed invalid strings (thanks james ross) Modified: dcplusplus/trunk/win32/HubFrame.cpp =================================================================== --- dcplusplus/trunk/win32/HubFrame.cpp 2007-11-25 18:44:05 UTC (rev 912) +++ dcplusplus/trunk/win32/HubFrame.cpp 2007-11-26 22:24:35 UTC (rev 913) @@ -88,7 +88,7 @@ WidgetTextBox::Seed cs = WinUtil::Seeds::textBox; cs.style = WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_AUTOVSCROLL | ES_MULTILINE; message = createTextBox(cs); - addWidget(message); + addWidget(message, true); message->onKeyDown(std::tr1::bind(&HubFrame::handleMessageKeyDown, this, _1)); message->onChar(std::tr1::bind(&HubFrame::handleMessageChar, this, _1)); } Modified: dcplusplus/trunk/win32/MDIChildFrame.h =================================================================== --- dcplusplus/trunk/win32/MDIChildFrame.h 2007-11-25 18:44:05 UTC (rev 912) +++ dcplusplus/trunk/win32/MDIChildFrame.h 2007-11-26 22:24:35 UTC (rev 913) @@ -39,10 +39,11 @@ typedef WidgetFactory< SmartWin::WidgetChildWindow > BaseType; protected: - MDIChildFrame(SmartWin::WidgetTabView* tabView, const tstring& title, SmartWin::IconPtr icon = SmartWin::IconPtr(), bool activate = true) : - BaseType(tabView->getTab()), - lastFocus(NULL), - reallyClose(false) + MDIChildFrame(SmartWin::WidgetTabView* tabView, const tstring& title, SmartWin::IconPtr icon = SmartWin::IconPtr(), bool activate = true) : + BaseType(tabView->getTab()), + lastFocus(NULL), + alwaysSameFocus(false), + reallyClose(false) { typename ThisType::Seed cs; cs.style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS; @@ -88,12 +89,14 @@ void postClosing() { } template<typename W> - void addWidget(W* widget) { + void addWidget(W* widget, bool alwaysFocus = false) { addColor(widget); - if(lastFocus == NULL) { + if(alwaysFocus || (lastFocus == NULL)) { lastFocus = widget->handle(); ::SetFocus(lastFocus); } + if(alwaysFocus) + alwaysSameFocus = true; } void setDirty(SettingsManager::IntSetting setting) { @@ -115,7 +118,9 @@ } private: - HWND lastFocus; + HWND lastFocus; // last focused widget + bool alwaysSameFocus; // always focus the same widget + bool reallyClose; void addColor(SmartWin::WidgetComboBox* widget) { @@ -145,7 +150,7 @@ if(lastFocus) { ::SetFocus(lastFocus); } - } else { + } else if(!alwaysSameFocus) { HWND focus = ::GetFocus(); if(focus != NULL && ::IsChild(static_cast<T*>(this)->handle(), focus)) lastFocus = focus; Modified: dcplusplus/trunk/win32/PrivateFrame.cpp =================================================================== --- dcplusplus/trunk/win32/PrivateFrame.cpp 2007-11-25 18:44:05 UTC (rev 912) +++ dcplusplus/trunk/win32/PrivateFrame.cpp 2007-11-26 22:24:35 UTC (rev 913) @@ -102,7 +102,7 @@ WidgetTextBox::Seed cs = WinUtil::Seeds::textBox; cs.style = WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_VSCROLL | ES_AUTOVSCROLL | ES_MULTILINE; message = createTextBox(cs); - addWidget(message); + addWidget(message, true); message->onKeyDown(std::tr1::bind(&PrivateFrame::handleKeyDown, this, _1)); message->onChar(std::tr1::bind(&PrivateFrame::handleChar, this, _1)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-25 21:44:38
|
Revision: 96 http://adchpp.svn.sourceforge.net/adchpp/?rev=96&view=rev Author: arnetheduck Date: 2007-11-25 13:44:36 -0800 (Sun, 25 Nov 2007) Log Message: ----------- Add simple gettext support, fix settings Modified Paths: -------------- adchpp/trunk/SConstruct adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/ClientManager.h adchpp/trunk/adchpp/Exception.h adchpp/trunk/adchpp/ManagedSocket.h adchpp/trunk/adchpp/SConscript adchpp/trunk/adchpp/SettingsManager.cpp adchpp/trunk/adchpp/SettingsManager.h adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/adchpp/SocketManager.h adchpp/trunk/adchpp/adchpp.h adchpp/trunk/build_util.py adchpp/trunk/unix/SConscript adchpp/trunk/unix/main.cpp Added Paths: ----------- adchpp/trunk/adchpp/forward.h adchpp/trunk/intl/ adchpp/trunk/intl/COPYING.LIB-2.0 adchpp/trunk/intl/COPYING.LIB-2.1 adchpp/trunk/intl/SConscript adchpp/trunk/intl/bindtextdom.c adchpp/trunk/intl/config.h adchpp/trunk/intl/dcgettext.c adchpp/trunk/intl/dcigettext.c adchpp/trunk/intl/dcngettext.c adchpp/trunk/intl/dgettext.c adchpp/trunk/intl/dngettext.c adchpp/trunk/intl/eval-plural.h adchpp/trunk/intl/explodename.c adchpp/trunk/intl/finddomain.c adchpp/trunk/intl/gettext.c adchpp/trunk/intl/gettextP.h adchpp/trunk/intl/gmo.h adchpp/trunk/intl/hash-string.c adchpp/trunk/intl/hash-string.h adchpp/trunk/intl/intl-compat.c adchpp/trunk/intl/l10nflist.c adchpp/trunk/intl/langprefs.c adchpp/trunk/intl/libgnuintl.h adchpp/trunk/intl/libgnuintl.h.in adchpp/trunk/intl/libintl.h adchpp/trunk/intl/loadinfo.h adchpp/trunk/intl/loadmsgcat.c adchpp/trunk/intl/localcharset.c adchpp/trunk/intl/localcharset.h adchpp/trunk/intl/locale.alias adchpp/trunk/intl/localealias.c adchpp/trunk/intl/localename.c adchpp/trunk/intl/lock.c adchpp/trunk/intl/lock.h adchpp/trunk/intl/log.c adchpp/trunk/intl/ngettext.c adchpp/trunk/intl/plural-exp.c adchpp/trunk/intl/plural-exp.h adchpp/trunk/intl/plural.c adchpp/trunk/intl/plural.y adchpp/trunk/intl/printf-args.c adchpp/trunk/intl/printf-args.h adchpp/trunk/intl/printf-parse.c adchpp/trunk/intl/printf-parse.h adchpp/trunk/intl/printf.c adchpp/trunk/intl/relocatable.c adchpp/trunk/intl/relocatable.h adchpp/trunk/intl/textdomain.c adchpp/trunk/intl/vasnprintf.c adchpp/trunk/intl/vasnprintf.h adchpp/trunk/intl/vasnwprintf.h adchpp/trunk/intl/version.c adchpp/trunk/intl/wprintf-parse.h adchpp/trunk/intl/xsize.h adchpp/trunk/unix/po/ adchpp/trunk/unix/po/adchppd.pot Modified: adchpp/trunk/SConstruct =================================================================== --- adchpp/trunk/SConstruct 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/SConstruct 2007-11-25 21:44:36 UTC (rev 96) @@ -72,6 +72,7 @@ BoolOption('nativestl', 'Use native STL instead of STLPort', 'yes'), BoolOption('verbose', 'Show verbose command lines', 'no'), BoolOption('savetemps', 'Save intermediate compilation files (assembly output)', 'no'), + BoolOption('nls', 'Build with internationalization support', 'yes'), ('prefix', 'Prefix to use when cross compiling', 'i386-mingw32-') ) @@ -153,6 +154,63 @@ ) env.Append(SCANNERS=[SWIGScanner]) +# +# internationalization (taken from the ardour build files (ardour.org) +# + +# po_builder: builder function to copy po files to the parent directory while updating them +# +# first source: .po file +# second source: .pot file +# + +def po_builder(target,source,env): + args = [ 'msgmerge', + '--update', + str(target[0]), + str(source[0]) + ] + print 'Updating ' + str(target[0]) + return os.spawnvp (os.P_WAIT, 'msgmerge', args) + +po_bld = Builder (action = po_builder) +env.Append(BUILDERS = {'PoBuild' : po_bld}) + +# mo_builder: builder function for (binary) message catalogs (.mo) +# +# first source: .po file +# +def mo_builder(target,source,env): + args = [ 'msgfmt', + '-c', + '-o', + target[0].get_path(), + source[0].get_path() + ] + return os.spawnvp (os.P_WAIT, 'msgfmt', args) + +mo_bld = Builder (action = mo_builder) +env.Append(BUILDERS = {'MoBuild' : mo_bld}) + +# pot_builder: builder function for message templates (.pot) +# +# source: list of C/C++ etc. files to extract messages from +# +def pot_builder(target,source,env): + args = [ 'xgettext', + '--keyword=_', + '--keyword=N_', + '--from-code=UTF-8', + '-o', target[0].get_path(), + '--foreign-user', + '--package-name="adchpp"' + '--copyright-holder="Jacek Sieka"' ] + args += [ src.get_path() for src in source ] + return os.spawnvp (os.P_WAIT, 'xgettext', args) + +pot_bld = Builder (action = pot_builder) +env.Append(BUILDERS = {'PotBuild' : pot_bld}) + conf = Configure(env) if conf.CheckCHeader('sys/epoll.h'): @@ -164,6 +222,8 @@ env = conf.Finish() +dev.intl = dev.build('intl/') + dev.adchpp = dev.build('adchpp/') if dev.is_win32(): Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-11-25 21:44:36 UTC (rev 96) @@ -40,50 +40,50 @@ ClientManager::ClientManager() throw() { supports.push_back("BASE"); supports.push_back("TIGR"); + + SocketManager::getInstance()->setIncomingHandler(&Client::create); } ClientManager::~ClientManager() throw() { - + } void ClientManager::send(const AdcCommand& cmd, bool lowPrio /* = false */) throw() { const string& txt = cmd.toString(); - switch(cmd.getType()) { - case AdcCommand::TYPE_FEATURE: - case AdcCommand::TYPE_BROADCAST: - { - bool all = (cmd.getType() == AdcCommand::TYPE_BROADCAST); - FastMutex::Lock l(ManagedSocket::getWriteMutex()); - for(ClientIter i = clients.begin(); i != clients.end(); ++i) { - if(all || !i->second->isFiltered(cmd.getFeatures())) - i->second->fastSend(txt, lowPrio); - } + switch (cmd.getType()) { + case AdcCommand::TYPE_FEATURE: + case AdcCommand::TYPE_BROADCAST: { + bool all = (cmd.getType() == AdcCommand::TYPE_BROADCAST); + FastMutex::Lock l(ManagedSocket::getWriteMutex()); + for (ClientIter i = clients.begin(); i != clients.end(); ++i) { + if (all || !i->second->isFiltered(cmd.getFeatures())) + i->second->fastSend(txt, lowPrio); } + } SocketManager::getInstance()->addAllWriters(); break; - case AdcCommand::TYPE_DIRECT: // Fallthrough - case AdcCommand::TYPE_ECHO: - { - ClientIter i = clients.find(cmd.getTo()); - if(i != clients.end()) { + case AdcCommand::TYPE_DIRECT: // Fallthrough + case AdcCommand::TYPE_ECHO: { + ClientIter i = clients.find(cmd.getTo()); + if (i != clients.end()) { + i->second->send(txt); + if (COMPATIBILITY || cmd.getType() == AdcCommand::TYPE_ECHO) { + i = clients.find(cmd.getFrom()); + if (i != clients.end()) { i->second->send(txt); - if(COMPATIBILITY || cmd.getType() == AdcCommand::TYPE_ECHO) { - i = clients.find(cmd.getFrom()); - if(i != clients.end()) { - i->second->send(txt); - } - } } } - break; + } } + break; + } } void ClientManager::sendToAll(const string& cmd) throw() { { FastMutex::Lock l(ManagedSocket::getWriteMutex()); - for(ClientIter i = clients.begin(); i != clients.end(); ++i) { + for (ClientIter i = clients.begin(); i != clients.end(); ++i) { i->second->fastSend(cmd); } } @@ -92,9 +92,9 @@ size_t ClientManager::getQueuedBytes() throw() { size_t total = 0; - + FastMutex::Lock l(ManagedSocket::getWriteMutex()); - for(ClientIter i = clients.begin(); i != clients.end(); ++i) { + for (ClientIter i = clients.begin(); i != clients.end(); ++i) { total += i->second->getQueuedBytes(); } return total; @@ -102,7 +102,7 @@ void ClientManager::sendTo(const AdcCommand& cmd, const uint32_t& to) throw() { ClientIter i = clients.find(to); - if(i != clients.end()) { + if (i != clients.end()) { i->second->send(cmd.toString()); } } @@ -110,36 +110,33 @@ void ClientManager::updateCache() throw() { // Update static strings... AdcCommand s(AdcCommand::CMD_SUP); - for(StringIter i = supports.begin(); i != supports.end(); ++i) + for (StringIter i = supports.begin(); i != supports.end(); ++i) s.addParam("AD" + *i); strings.sup = s.toString(); strings.inf = AdcCommand(AdcCommand::CMD_INF) - .addParam("NI", SETTING(HUB_NAME)) - .addParam("HI1") - .addParam("DE", SETTING(DESCRIPTION)) - .addParam("VE", versionString) - .addParam("CT5") - .addParam("HU1") // ADC <=0.13 - .toString(); + .addParam("NI", SETTING(HUB_NAME)) + .addParam("HI1") + .addParam("DE", SETTING(DESCRIPTION)) + .addParam("VE", versionString) + .addParam("CT5") + .addParam("HU1") // ADC <=0.13 + .toString(); } bool ClientManager::checkFlooding(Client& c, const AdcCommand& cmd) throw() { - time_t add = ((cmd.getType() == AdcCommand::TYPE_BROADCAST || cmd.getType() == AdcCommand::TYPE_FEATURE) ? 1 : 0) * SETTING(FLOOD_ADD); - if(c.isFlooding(add)) { + time_t add = ((cmd.getType() == AdcCommand::TYPE_BROADCAST || cmd.getType() == AdcCommand::TYPE_FEATURE) ? 1 : 0) + * SETTING(FLOOD_ADD); + if (c.isFlooding(add)) { c.disconnect(Util::REASON_FLOODING); return true; } - + return false; } -void ClientManager::incomingConnection(const ManagedSocketPtr& ms) throw() { - Client::create(ms); -} - uint32_t ClientManager::makeSID() { - while(true) { + while (true) { union { uint32_t sid; char chars[4]; @@ -148,7 +145,7 @@ sid.chars[1] = Encoder::base32Alphabet[Util::rand(sizeof(Encoder::base32Alphabet))]; sid.chars[2] = Encoder::base32Alphabet[Util::rand(sizeof(Encoder::base32Alphabet))]; sid.chars[3] = Encoder::base32Alphabet[Util::rand(sizeof(Encoder::base32Alphabet))]; - if(sids.find(sid.sid) == sids.end()) { + if (sids.find(sid.sid) == sids.end()) { sids.insert(sid.sid); return sid.sid; } @@ -157,8 +154,8 @@ void ClientManager::onConnected(Client& c) throw() { // First let's check if any clients have passed the login timeout... - time_t timeout = GET_TIME() - SETTING(LOGIN_TIMEOUT); - while(!logins.empty() && (timeout > logins.front().second) ) { + time_t timeout= GET_TIME() - SETTING(LOGIN_TIMEOUT); + while (!logins.empty() && (timeout > logins.front().second)) { Client* cc = logins.front().first; dcdebug("ClientManager: Login timeout in state %d\n", cc->getState()); @@ -173,31 +170,26 @@ void ClientManager::onReceive(Client& c, AdcCommand& cmd) throw() { int override = 0; - if(!( - cmd.getType() == AdcCommand::TYPE_BROADCAST || - cmd.getType() == AdcCommand::TYPE_DIRECT || - cmd.getType() == AdcCommand::TYPE_ECHO || - cmd.getType() == AdcCommand::TYPE_FEATURE || - cmd.getType() == AdcCommand::TYPE_HUB)) - { + if (!(cmd.getType() == AdcCommand::TYPE_BROADCAST || cmd.getType() == AdcCommand::TYPE_DIRECT || cmd.getType() + == AdcCommand::TYPE_ECHO || cmd.getType() == AdcCommand::TYPE_FEATURE || cmd.getType() == AdcCommand::TYPE_HUB)) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "Invalid command type")); c.disconnect(Util::REASON_INVALID_COMMAND_TYPE); return; } - if(checkFlooding(c, cmd)) { + if (checkFlooding(c, cmd)) { return; } - + signalReceive_(c, cmd, override); - if(!(override & DONT_DISPATCH)) { - if(!dispatch(c, cmd)) { + if (!(override & DONT_DISPATCH)) { + if (!dispatch(c, cmd)) { return; } } - - if(!(override & DONT_SEND)) { + + if (!(override & DONT_SEND)) { send(cmd); } } @@ -209,24 +201,24 @@ void ClientManager::badState(Client& c, const AdcCommand& cmd) throw() { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_BAD_STATE, "Invalid state for command").addParam("FC", cmd.toString().substr(0, 4))); c.disconnect(Util::REASON_BAD_STATE); -} +} bool ClientManager::handleDefault(Client& c, AdcCommand& cmd) throw() { - if(c.getState() != Client::STATE_NORMAL) { + if (c.getState() != Client::STATE_NORMAL) { badState(c, cmd); return false; - } - return true; + } + return true; } bool ClientManager::handle(AdcCommand::SUP, Client& c, AdcCommand& cmd) throw() { - if(!verifySUP(c, cmd)) { + if (!verifySUP(c, cmd)) { return false; } - if(c.getState() == Client::STATE_PROTOCOL) { + if (c.getState() == Client::STATE_PROTOCOL) { enterIdentify(c, true); - } else if(c.getState() != Client::STATE_NORMAL) { + } else if (c.getState() != Client::STATE_NORMAL) { badState(c, cmd); return false; } @@ -235,97 +227,100 @@ bool ClientManager::verifySUP(Client& c, AdcCommand& cmd) throw() { c.updateSupports(cmd); - if(!c.supports("BASE")) { - if(COMPATIBILITY && c.supports("BAS0")) { + if (!c.supports("BASE")) { + if (COMPATIBILITY && c.supports("BAS0")) { c.send(AdcCommand(AdcCommand::CMD_MSG).addParam("Your client only supports an experimental version of ADC, please upgrade as soon as possible as you will not be able to connect in the future")); } else { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "This hub requires BASE support")); + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, + "This hub requires BASE support")); c.disconnect(Util::REASON_NO_BASE_SUPPORT); } } - - if(c.supports("BASE") && !c.supports("TIGR")) { - if(COMPATIBILITY) { + + if (c.supports("BASE") && !c.supports("TIGR")) { + if (COMPATIBILITY) { // ADC <= 0.13 c.send(AdcCommand(AdcCommand::CMD_MSG).addParam("Your client claims to support BASE but not TIGR, please upgrade as soon as possible")); } else { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "This hub requires TIGR support")); + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, + "This hub requires TIGR support")); c.disconnect(Util::REASON_NO_TIGR_SUPPORT); } } - + return true; } bool ClientManager::verifyINF(Client& c, AdcCommand& cmd) throw() { - if(!verifyIp(c, cmd)) + if (!verifyIp(c, cmd)) return false; - if(!verifyCID(c, cmd)) + if (!verifyCID(c, cmd)) return false; - if(!verifyNick(c, cmd)) + if (!verifyNick(c, cmd)) return false; c.updateFields(cmd); return true; } -bool ClientManager::verifyPassword(Client& c, const string& password, const vector<uint8_t>& salt, const string& suppliedHash) { +bool ClientManager::verifyPassword(Client& c, const string& password, const vector<uint8_t>& salt, + const string& suppliedHash) { TigerHash tiger; tiger.update(&password[0], password.size()); tiger.update(&salt[0], salt.size()); uint8_t tmp[TigerHash::HASH_SIZE]; Encoder::fromBase32(suppliedHash.c_str(), tmp, TigerHash::HASH_SIZE); - if(memcmp(tiger.finalize(), tmp, TigerHash::HASH_SIZE) == 0) + if (memcmp(tiger.finalize(), tmp, TigerHash::HASH_SIZE) == 0) return true; - - if(!COMPATIBILITY) + + if (!COMPATIBILITY) return false; - + TigerHash tiger2; // Support dc++ 0.69 for a while string cid = c.getCID().toBase32(); tiger2.update(c.getCID().data(), CID::SIZE); tiger2.update(&password[0], password.size()); tiger2.update(&salt[0], salt.size()); - if(memcmp(tiger2.finalize(), tmp, TigerHash::HASH_SIZE) == 0) { + if (memcmp(tiger2.finalize(), tmp, TigerHash::HASH_SIZE) == 0) { c.send(AdcCommand(AdcCommand::CMD_MSG).addParam("Your client uses an old PAS encoding, please upgrade")); return true; } - return false; + return false; } bool ClientManager::handle(AdcCommand::INF, Client& c, AdcCommand& cmd) throw() { - if(c.getState() != Client::STATE_IDENTIFY && c.getState() != Client::STATE_NORMAL) { + if (c.getState() != Client::STATE_IDENTIFY && c.getState() != Client::STATE_NORMAL) { badState(c, cmd); return false; } - - if(!verifyINF(c, cmd)) + + if (!verifyINF(c, cmd)) return false; - if(c.getState() == Client::STATE_IDENTIFY) { + if (c.getState() == Client::STATE_IDENTIFY) { enterNormal(c, true, false); } - + return true; } bool ClientManager::verifyIp(Client& c, AdcCommand& cmd) throw() { - if(c.isSet(Client::FLAG_OK_IP)) + if (c.isSet(Client::FLAG_OK_IP)) return true; - - for(StringIter j = cmd.getParameters().begin(); j != cmd.getParameters().end(); ++j) { - if(j->compare(0, 2, "I4") == 0) { + + for (StringIter j = cmd.getParameters().begin(); j != cmd.getParameters().end(); ++j) { + if (j->compare(0, 2, "I4") == 0) { dcdebug("%s verifying ip\n", AdcCommand::fromSID(c.getSID()).c_str()); - if(j->size() == 2) { + if (j->size() == 2) { // Clearing is ok - } else if(j->compare(2, j->size()-2, "0.0.0.0") == 0) { + } else if (j->compare(2, j->size()-2, "0.0.0.0") == 0) { c.setField("I4", c.getIp()); *j = "I4" + c.getIp(); cmd.resetString(); - } else if(j->size()-2 != c.getIp().size() || j->compare(2, j->size()-2, c.getIp()) != 0) { + } else if (j->size()-2 != c.getIp().size() || j->compare(2, j->size()-2, c.getIp()) != 0) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_BAD_IP, "Your ip is " + c.getIp()).addParam("IP", c.getIp())); c.disconnect(Util::REASON_INVALID_IP); return false; @@ -336,41 +331,41 @@ } bool ClientManager::verifyCID(Client& c, AdcCommand& cmd) throw() { - if(cmd.getParam("ID", 0, strtmp)) { + if (cmd.getParam("ID", 0, strtmp)) { dcdebug("%s verifying CID\n", AdcCommand::fromSID(c.getSID()).c_str()); - if(c.getState() != Client::STATE_IDENTIFY) { + if (c.getState() != Client::STATE_IDENTIFY) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "CID changes not allowed")); c.disconnect(Util::REASON_CID_CHANGE); - return false; + return false; } - + string spid; - if(!cmd.getParam("PD", 0, spid)) { + if (!cmd.getParam("PD", 0, spid)) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_INF_MISSING, "PID missing").addParam("FLPD")); c.disconnect(Util::REASON_PID_MISSING); return false; } - - if(strtmp.size() != CID::BASE32_SIZE || spid.size() != CID::BASE32_SIZE) { + + if (strtmp.size() != CID::BASE32_SIZE || spid.size() != CID::BASE32_SIZE) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "Invalid CID/PID length")); c.disconnect(Util::REASON_PID_CID_LENGTH); return false; - } - + } + CID cid(strtmp); CID pid(spid); TigerHash th; th.update(pid.data(), CID::SIZE); - if(!(CID(th.finalize()) == cid)) { + if (!(CID(th.finalize()) == cid)) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_INVALID_PID, "PID does not correspond to CID")); c.disconnect(Util::REASON_PID_CID_MISMATCH); return false; } CIDMap::iterator i = cids.find(cid); - if(i != cids.end()) { + if (i != cids.end()) { ClientIter j = clients.find(i->second); - if(j != clients.end()) { + if (j != clients.end()) { j->second->send("\n"); } c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_CID_TAKEN, "CID taken, please try again later")); @@ -382,8 +377,8 @@ cids.insert(make_pair(c.getCID(), c.getSID())); cmd.delParam("PD", 0); } - - if(cmd.getParam("PD", 0, strtmp)) { + + if (cmd.getParam("PD", 0, strtmp)) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "CID required when sending PID")); c.disconnect(Util::REASON_PID_WITHOUT_CID); return false; @@ -392,21 +387,22 @@ } bool ClientManager::verifyNick(Client& c, const AdcCommand& cmd) throw() { - if(cmd.getParam("NI", 0, strtmp)) { + if (cmd.getParam("NI", 0, strtmp)) { dcdebug("%s verifying nick\n", AdcCommand::fromSID(c.getSID()).c_str()); - for(string::size_type i = 0; i < strtmp.length(); ++i) { - if((uint8_t)strtmp[i] < 33) { + for (string::size_type i = 0; i < strtmp.length(); ++i) { + if ((uint8_t)strtmp[i] < 33) { c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_INVALID, "Invalid character in nick")); c.disconnect(Util::REASON_NICK_INVALID); return false; } } const string& oldNick = c.getField("NI"); - if(!oldNick.empty()) + if (!oldNick.empty()) nicks.erase(oldNick); - - if(nicks.find(strtmp) != nicks.end()) { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_TAKEN, "Nick taken, please pick another one")); + + if (nicks.find(strtmp) != nicks.end()) { + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_TAKEN, + "Nick taken, please pick another one")); c.disconnect(Util::REASON_NICK_TAKEN); return false; } @@ -426,7 +422,7 @@ void ClientManager::enterIdentify(Client& c, bool sendData) throw() { dcassert(c.getState() == Client::STATE_PROTOCOL); dcdebug("%s entering IDENTIFY\n", AdcCommand::fromSID(c.getSID()).c_str()); - if(sendData) { + if (sendData) { c.send(strings.sup); c.send(AdcCommand(AdcCommand::CMD_SID).addParam(AdcCommand::fromSID(c.getSID()))); c.send(strings.inf); @@ -438,8 +434,8 @@ dcassert(c.getState() == Client::STATE_IDENTIFY); dcdebug("%s entering VERIFY\n", AdcCommand::fromSID(c.getSID()).c_str()); vector<uint8_t> challenge; - if(sendData) { - for(int i = 0; i < 32/4; ++i) { + if (sendData) { + for (int i = 0; i < 32/4; ++i) { uint32_t r = Util::rand(); challenge.insert(challenge.end(), (uint8_t*)&r, 4 + (uint8_t*)&r); } @@ -453,13 +449,13 @@ dcassert(c.getState() == Client::STATE_IDENTIFY || c.getState() == Client::STATE_VERIFY); dcdebug("%s entering NORMAL\n", AdcCommand::fromSID(c.getSID()).c_str()); - if(sendData) { + if (sendData) { string str; - for(ClientIter i = clients.begin(); i != clients.end(); ++i) { + for (ClientIter i = clients.begin(); i != clients.end(); ++i) { str += i->second->getINF(); } c.send(str); - if(sendOwnInf) { + if (sendOwnInf) { sendToAll(c.getINF()); c.send(c.getINF()); } @@ -474,8 +470,9 @@ } void ClientManager::removeLogins(Client& c) throw() { - deque<pair<Client*, time_t> >::iterator i = find_if(logins.begin(), logins.end(), CompareFirst<Client*, time_t>(&c)); - if(i != logins.end()) { + deque<pair<Client*, time_t> >::iterator i = + find_if(logins.begin(), logins.end(), CompareFirst<Client*, time_t>(&c)); + if (i != logins.end()) { logins.erase(i); } } @@ -483,7 +480,7 @@ void ClientManager::removeClient(Client& c) throw() { signalDisconnected_(c); dcdebug("Removing %s\n", AdcCommand::fromSID(c.getSID()).c_str()); - if(c.getState() == Client::STATE_NORMAL) { + if (c.getState() == Client::STATE_NORMAL) { clients.erase(c.getSID()); sendToAll(AdcCommand(AdcCommand::CMD_QUI).addParam(AdcCommand::fromSID(c.getSID()))); } else { @@ -495,9 +492,9 @@ } void ClientManager::addSupports(const string& str) throw() { - if(find(supports.begin(), supports.end(), str) != supports.end()) + if (find(supports.begin(), supports.end(), str) != supports.end()) return; - + supports.push_back(str); updateCache(); sendToAll(AdcCommand(AdcCommand::CMD_SUP).addParam("AD" + str)); @@ -505,7 +502,7 @@ void ClientManager::removeSupports(const string& str) throw() { StringIter i = find(supports.begin(), supports.end(), str); - if(i != supports.end()) { + if (i != supports.end()) { supports.erase(i); updateCache(); sendToAll(AdcCommand(AdcCommand::CMD_SUP).addParam("RM" + str)); @@ -519,11 +516,11 @@ uint32_t ClientManager::getSID(const CID& cid) const throw() { CIDMap::const_iterator i = cids.find(cid); - return (i == cids.end()) ? 0 : i->second; + return (i == cids.end()) ? 0 : i->second; } void ClientManager::shutdown() { - + } void ClientManager::onFailed(Client& c) throw() { Modified: adchpp/trunk/adchpp/ClientManager.h =================================================================== --- adchpp/trunk/adchpp/ClientManager.h 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/ClientManager.h 2007-11-25 21:44:36 UTC (rev 96) @@ -146,12 +146,6 @@ ADCHPP_DLL size_t getQueuedBytes() throw(); - /** - * The SocketManager calls this when a new connection has been accepted. - * Don't touch. - */ - void incomingConnection(const ManagedSocketPtr& ms) throw(); - void startup() throw() { updateCache(); } void shutdown(); Modified: adchpp/trunk/adchpp/Exception.h =================================================================== --- adchpp/trunk/adchpp/Exception.h 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/Exception.h 2007-11-25 21:44:36 UTC (rev 96) @@ -50,7 +50,7 @@ #define STANDARD_EXCEPTION(name) class ADCHPP_VISIBLE name : public Exception { \ public:\ name() throw() : Exception() { } \ - name(const string& aError) throw() : Exception(aError) { } \ + name(const std::string& aError) throw() : Exception(aError) { } \ virtual ~name() throw() { } \ } #endif Modified: adchpp/trunk/adchpp/ManagedSocket.h =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.h 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/ManagedSocket.h 2007-11-25 21:44:36 UTC (rev 96) @@ -20,6 +20,8 @@ #define ADCHPP_MANAGEDSOCKET_H #include "common.h" + +#include "forward.h" #include "Socket.h" #include "Mutex.h" #include "Signal.h" @@ -27,9 +29,6 @@ namespace adchpp { -class SocketManager; -class Writer; - /** * An asynchronous socket managed by SocketManager. */ @@ -113,8 +112,6 @@ ADCHPP_DLL static FastMutex writeMutex; }; -typedef boost::intrusive_ptr<ManagedSocket> ManagedSocketPtr; - } #endif // MANAGEDSOCKET_H Modified: adchpp/trunk/adchpp/SConscript =================================================================== --- adchpp/trunk/adchpp/SConscript 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/SConscript 2007-11-25 21:44:36 UTC (rev 96) @@ -53,5 +53,5 @@ if env['PLATFORM'] != 'win32': dev.env.Append(RPATH = env.Literal('\\$$ORIGIN')) - + Return('ret') Modified: adchpp/trunk/adchpp/SettingsManager.cpp =================================================================== --- adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-25 21:44:36 UTC (rev 96) @@ -42,9 +42,6 @@ "MaxSendSize", "MaxBufferSize", "BufferSize", "MaxCommandSize", "OverflowTimeout", "DisconnectTimeout", "FloodAdd", "FloodThreshold", "LoginTimeout", - "SENTRY", - // Int64 - "SENTRY" }; Modified: adchpp/trunk/adchpp/SettingsManager.h =================================================================== --- adchpp/trunk/adchpp/SettingsManager.h 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/SettingsManager.h 2007-11-25 21:44:36 UTC (rev 96) @@ -38,7 +38,6 @@ enum StrSetting { STR_FIRST, HUB_NAME = STR_FIRST, SERVER_IP, LOG_FILE, DESCRIPTION, - LANGUAGE_FILE, STR_LAST }; enum IntSetting { INT_FIRST = STR_LAST + 1, Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/SocketManager.cpp 2007-11-25 21:44:36 UTC (rev 96) @@ -22,7 +22,6 @@ #include "LogManager.h" #include "TimerManager.h" -#include "ClientManager.h" #include "SettingsManager.h" #include "Semaphores.h" #include "ManagedSocket.h" @@ -338,8 +337,7 @@ active.insert(ms); accepting.erase(ms); - ClientManager::getInstance()->incomingConnection(ms); - + SocketManager::getInstance()->incomingHandler(ms); ms->completeAccept(); prepareRead(ms); @@ -801,7 +799,7 @@ active.insert(ms); - ClientManager::getInstance()->incomingConnection(ms); + SocketManager::getInstance()->incomingHandler(ms); ms->completeAccept(); @@ -1045,5 +1043,4 @@ writer->getErrors(acceptErrors_, readErrors_, writeErrors_); } - } Modified: adchpp/trunk/adchpp/SocketManager.h =================================================================== --- adchpp/trunk/adchpp/SocketManager.h 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/SocketManager.h 2007-11-25 21:44:36 UTC (rev 96) @@ -19,6 +19,9 @@ #ifndef ADCHPP_SOCKETMANAGER_H #define ADCHPP_SOCKETMANAGER_H +#include "common.h" + +#include "forward.h" #include "Thread.h" #include "Semaphores.h" #include "Mutex.h" @@ -26,9 +29,6 @@ namespace adchpp { -class ManagedSocket; -class Writer; - class SocketManager : public Singleton<SocketManager>, public Thread { public: typedef std::tr1::function<void()> Callback; @@ -41,6 +41,9 @@ void addDisconnect(const boost::intrusive_ptr<ManagedSocket>& ms) throw(); void addAllWriters() throw(); + typedef std::tr1::function<void (const ManagedSocketPtr&)> IncomingHandler; + void setIncomingHandler(const IncomingHandler& handler) { incomingHandler = handler; } + typedef std::tr1::unordered_map<int, size_t> ErrorMap; ADCHPP_DLL void getErrors(ErrorMap& acceptErrors_, ErrorMap& readErrors_, ErrorMap& writeErrors_); private: @@ -59,6 +62,7 @@ Semaphore processSem; std::auto_ptr<Writer> writer; + IncomingHandler incomingHandler; static const std::string className; Modified: adchpp/trunk/adchpp/adchpp.h =================================================================== --- adchpp/trunk/adchpp/adchpp.h 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/adchpp/adchpp.h 2007-11-25 21:44:36 UTC (rev 96) @@ -151,4 +151,10 @@ # endif #endif +// TODO Maybe do this in the implementations? +#ifndef _ +#define _(String) String +#define bindtextdomain(Package, Directory) +#endif + #endif // STDINC_H Added: adchpp/trunk/adchpp/forward.h =================================================================== --- adchpp/trunk/adchpp/forward.h (rev 0) +++ adchpp/trunk/adchpp/forward.h 2007-11-25 21:44:36 UTC (rev 96) @@ -0,0 +1,13 @@ +#ifndef FORWARD_H_ +#define FORWARD_H_ + +namespace adchpp { +class ManagedSocket; +typedef boost::intrusive_ptr<ManagedSocket> ManagedSocketPtr; + +class SocketManager; +class Writer; + +} + +#endif /*FORWARD_H_*/ Modified: adchpp/trunk/build_util.py =================================================================== --- adchpp/trunk/build_util.py 2007-11-19 14:20:21 UTC (rev 95) +++ adchpp/trunk/build_util.py 2007-11-25 21:44:36 UTC (rev 96) @@ -1,5 +1,6 @@ import glob import sys +import os class Dev: def __init__(self, mode, tools, env): @@ -40,6 +41,7 @@ self.env['PROGSUFFIX'] = '.exe' self.env['LIBPREFIX'] = 'lib' self.env['LIBSUFFIX'] = '.a' + self.env['SHLIBSUFFIX'] = '.dll' def is_win32(self): return sys.platform == 'win32' or 'mingw' in self.env['TOOLS'] @@ -72,6 +74,24 @@ full_path = local_env.Dir('.').path + '/' + source_path return local_env.SConscript(source_path + 'SConscript', exports={'dev' : self, 'source_path' : full_path }) + def i18n (self, source_path, buildenv, sources, name): + p_oze = glob.glob('po/*.po') + languages = [ os.path.basename(po).replace ('.po', '') for po in p_oze ] + potfile = 'po/' + name + '.pot' + + ret = buildenv.PotBuild(potfile, sources) + + for po_file in p_oze: + buildenv.Precious(buildenv.PoBuild(po_file, [potfile])) +# mo_file = po_file.replace (".po", ".mo") +# installenv.Alias ('install', buildenv.MoBuild (mo_file, po_file)) + +# for lang in languages: +# modir = (os.path.join (install_prefix, 'share/locale/' + lang + '/LC_MESSAGES/')) +# moname = domain + '.mo' +# installenv.Alias('install', installenv.InstallAs (os.path.join (modir, moname), lang + '.mo')) + return ret + def CheckPKGConfig(context, version): context.Message( 'Checking for pkg-config... ' ) ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0] Added: adchpp/trunk/intl/COPYING.LIB-2.0 =================================================================== --- adchpp/trunk/intl/COPYING.LIB-2.0 (rev 0) +++ adchpp/trunk/intl/COPYING.LIB-2.0 2007-11-25 21:44:36 UTC (rev 96) @@ -0,0 +1,482 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! Added: adchpp/trunk/intl/COPYING.LIB-2.1 =================================================================== --- adchpp/trunk/intl/COPYING.LIB-2.1 (rev 0) +++ adchpp/trunk/intl/COPYING.LIB-2.1 2007-11-25 21:44:36 UTC (rev 96) @@ -0,0 +1,516 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations +below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library a... [truncated message content] |
From: <zou...@us...> - 2007-11-25 18:44:08
|
Revision: 912 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=912&view=rev Author: zouzou123gen Date: 2007-11-25 10:44:05 -0800 (Sun, 25 Nov 2007) Log Message: ----------- key handling in file listings Modified Paths: -------------- dcplusplus/trunk/changelog.txt dcplusplus/trunk/win32/DirectoryListingFrame.cpp Modified: dcplusplus/trunk/changelog.txt =================================================================== --- dcplusplus/trunk/changelog.txt 2007-11-16 23:11:07 UTC (rev 911) +++ dcplusplus/trunk/changelog.txt 2007-11-25 18:44:05 UTC (rev 912) @@ -12,6 +12,7 @@ * Fixed user commands params (poy) * Readded list view double buffering (thanks poy) * Fixed some msvc compile issues (thanks james ross) +* Fixed key handling in file listings (poy) -- 0.703 2007-11-08 -- * Fixed invalid strings (thanks james ross) Modified: dcplusplus/trunk/win32/DirectoryListingFrame.cpp =================================================================== --- dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2007-11-16 23:11:07 UTC (rev 911) +++ dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2007-11-25 18:44:05 UTC (rev 912) @@ -963,11 +963,17 @@ bool DirectoryListingFrame::handleKeyDownFiles(int c) { if(c == VK_BACK) { up(); - } else if(c == VK_LEFT && WinUtil::isAlt()) { + return true; + } + if(c == VK_LEFT && WinUtil::isAlt()) { back(); - } else if(c == VK_RIGHT && WinUtil::isAlt()) { + return true; + } + if(c == VK_RIGHT && WinUtil::isAlt()) { forward(); - } else if(c == VK_RETURN) { + return true; + } + if(c == VK_RETURN) { if(files->getSelectedCount() == 1) { ItemInfo* ii = files->getSelectedData(); if(ii->type == ItemInfo::DIRECTORY) { @@ -985,6 +991,7 @@ } else { downloadFiles(SETTING(DOWNLOAD_DIRECTORY)); } + return true; } - return true; + return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-19 14:20:25
|
Revision: 95 http://adchpp.svn.sourceforge.net/adchpp/?rev=95&view=rev Author: arnetheduck Date: 2007-11-19 06:20:21 -0800 (Mon, 19 Nov 2007) Log Message: ----------- win32 fixes Modified Paths: -------------- adchpp/trunk/SConstruct adchpp/trunk/adchpp/File.h adchpp/trunk/adchpp/SConscript adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/adchpp/adchpp.h adchpp/trunk/build_util.py adchpp/trunk/lua/SConscript adchpp/trunk/swig/SConscript adchpp/trunk/windows/adchppdw.cpp Modified: adchpp/trunk/SConstruct =================================================================== --- adchpp/trunk/SConstruct 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/SConstruct 2007-11-19 14:20:21 UTC (rev 95) @@ -60,8 +60,13 @@ opts = Options('custom.py', ARGUMENTS) +if sys.platform == 'win32': + tooldef = 'mingw' +else: + tooldef = 'default' + opts.AddOptions( - EnumOption('tools', 'Toolset to compile with, default = platform default (msvc under windows)', 'mingw', ['mingw', 'default']), + EnumOption('tools', 'Toolset to compile with, default = platform default (msvc under windows)', tooldef, ['mingw', 'default']), EnumOption('mode', 'Compile mode', 'debug', ['debug', 'release']), ListOption('plugins', 'The plugins to compile', 'all', plugins), BoolOption('nativestl', 'Use native STL instead of STLPort', 'yes'), @@ -71,11 +76,6 @@ ) -if sys.platform == 'win32': - tooldef = 'mingw' -else: - tooldef = 'default' - tools = ARGUMENTS.get('tools', tooldef) toolset = [tools, 'swig'] @@ -98,7 +98,7 @@ env.Append(CPPPATH = ["#/boost/boost/tr1/tr1/", "#/boost/"]) -if env['PLATFORM'] != 'win32': +if not dev.is_win32(): env.Append(CPPDEFINES = ['_XOPEN_SOURCE=500'] ) env.Append(CCFLAGS=['-fvisibility=hidden']) @@ -166,7 +166,7 @@ dev.adchpp = dev.build('adchpp/') -if env['PLATFORM'] == 'win32' or env['PLATFORM'] == 'cygwin': +if dev.is_win32(): dev.build('windows/') else: dev.build('unix/') Modified: adchpp/trunk/adchpp/File.h =================================================================== --- adchpp/trunk/adchpp/File.h 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/adchpp/File.h 2007-11-19 14:20:21 UTC (rev 95) @@ -107,7 +107,7 @@ throw FileException(Util::translateError(GetLastError())); } if(x < len) { - throw FileException(STRING(DISK_FULL)); + throw FileException("Unable to write, disk full?"); } } @@ -118,8 +118,8 @@ } } - static void deleteFile(const string& aFileName) { ::DeleteFile(aFileName.c_str()); }; - static void renameFile(const string& source, const string& target) { ::MoveFile(source.c_str(), target.c_str()); }; + static void deleteFile(const std::string& aFileName) { ::DeleteFile(aFileName.c_str()); }; + static void renameFile(const std::string& source, const std::string& target) { ::MoveFile(source.c_str(), target.c_str()); }; #else // WIN32 Modified: adchpp/trunk/adchpp/SConscript =================================================================== --- adchpp/trunk/adchpp/SConscript 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/adchpp/SConscript 2007-11-19 14:20:21 UTC (rev 95) @@ -35,8 +35,8 @@ if 'HAVE_PTHREAD' in env['CPPDEFINES']: env.Append(LIBS = ['pthread']) -if env['PLATFORM'] == 'win32': - env.Append(LIBS = ['ws2_32', 'mswsock']) +if dev.is_win32(): + env.Append(LIBS = ['ws2_32', 'mswsock']) if 'gcc' in env['TOOLS']: env['GchSh'] = env.GchSh('adchpp.h')[0] @@ -54,5 +54,4 @@ if env['PLATFORM'] != 'win32': dev.env.Append(RPATH = env.Literal('\\$$ORIGIN')) - Return('ret') Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/adchpp/SocketManager.cpp 2007-11-19 14:20:21 UTC (rev 95) @@ -29,7 +29,7 @@ #include "Thread.h" #ifdef _WIN32 -#include <MSWSock.h> +#include <mswsock.h> #endif #ifdef HAVE_SYS_EPOLL_H @@ -39,6 +39,7 @@ namespace adchpp { using namespace std; +using namespace std::tr1; static uint32_t WRITE_TIMEOUT = 100; @@ -537,7 +538,7 @@ Pool<MSOverlapped, ClearOverlapped> pool; - typedef HASH_SET<ManagedSocketPtr, PointerHash<ManagedSocket> > SocketSet; + typedef unordered_set<ManagedSocketPtr, PointerHash<ManagedSocket> > SocketSet; /** Sockets that have a pending read */ SocketSet active; /** Sockets that have a pending accept */ Modified: adchpp/trunk/adchpp/adchpp.h =================================================================== --- adchpp/trunk/adchpp/adchpp.h 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/adchpp/adchpp.h 2007-11-19 14:20:21 UTC (rev 95) @@ -99,7 +99,7 @@ # define ADCHPP_DLL __declspec(dllimport) # endif // DLLEXPORT -#include <Winsock2.h> +#include <winsock2.h> #include <windows.h> #include <tchar.h> Modified: adchpp/trunk/build_util.py =================================================================== --- adchpp/trunk/build_util.py 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/build_util.py 2007-11-19 14:20:21 UTC (rev 95) @@ -40,6 +40,9 @@ self.env['PROGSUFFIX'] = '.exe' self.env['LIBPREFIX'] = 'lib' self.env['LIBSUFFIX'] = '.a' + + def is_win32(self): + return sys.platform == 'win32' or 'mingw' in self.env['TOOLS'] def get_build_root(self): return '#/build/' + self.mode + '-' + self.tools + '/' Modified: adchpp/trunk/lua/SConscript =================================================================== --- adchpp/trunk/lua/SConscript 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/lua/SConscript 2007-11-19 14:20:21 UTC (rev 95) @@ -2,7 +2,7 @@ env, target, sources = dev.prepare_build(source_path, 'alua', 'all.c') -if env['PLATFORM'] == 'win32': +if dev.is_win32(): env.Append(CPPDEFINES=['LUA_BUILD_AS_DLL=1']) else: env.Append(CPPDEFINES=['LUA_USE_LINUX=1']) Modified: adchpp/trunk/swig/SConscript =================================================================== --- adchpp/trunk/swig/SConscript 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/swig/SConscript 2007-11-19 14:20:21 UTC (rev 95) @@ -59,6 +59,11 @@ targets.append(rb) def buildPyModule(): + import sys + if dev.is_win32() and sys.platform != 'win32': + print "Cross-compiling python module not supported" + return + env, target, sources = dev.prepare_build(source_path, '_pyadchpp', 'python.i') env.Append(SWIGFLAGS=['-c++','-threads','-Wall','-python', '-O', '-classic']) Modified: adchpp/trunk/windows/adchppdw.cpp =================================================================== --- adchpp/trunk/windows/adchppdw.cpp 2007-11-18 20:58:59 UTC (rev 94) +++ adchpp/trunk/windows/adchppdw.cpp 2007-11-19 14:20:21 UTC (rev 95) @@ -23,8 +23,8 @@ #include <adchpp/File.h> #include <adchpp/version.h> - using namespace adchpp; +using namespace std; static const string modName = "adchpp"; @@ -169,7 +169,7 @@ SetUnhandledExceptionFilter(&DCUnhandledExceptionFilter); #endif - initConfig(configPath); + initialize(configPath); if(asService) LOGDT(modName, versionString + " started as a service"); @@ -189,6 +189,7 @@ EXTENDEDTRACEUNINITIALIZE(); #endif printf(".\n"); + cleanup(); } Semaphore exitSem; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-18 20:59:02
|
Revision: 94 http://adchpp.svn.sourceforge.net/adchpp/?rev=94&view=rev Author: arnetheduck Date: 2007-11-18 12:58:59 -0800 (Sun, 18 Nov 2007) Log Message: ----------- Remove StringDefs etc in preparation for gettext Modified Paths: -------------- adchpp/trunk/SConstruct adchpp/trunk/adchpp/CID.h adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/ClientManager.h adchpp/trunk/adchpp/File.h adchpp/trunk/adchpp/SettingsManager.cpp adchpp/trunk/adchpp/SettingsManager.h adchpp/trunk/adchpp/Util.cpp adchpp/trunk/adchpp/Util.h adchpp/trunk/adchpp/adchpp.cpp adchpp/trunk/swig/adchpp.i adchpp/trunk/swig/lua.i Removed Paths: ------------- adchpp/trunk/adchpp/ResourceManager.cpp adchpp/trunk/adchpp/ResourceManager.h adchpp/trunk/adchpp/StringDefs.cpp adchpp/trunk/adchpp/StringDefs.h adchpp/trunk/makedefs.py Property Changed: ---------------- adchpp/trunk/ adchpp/trunk/plugins/Bloom/src/ adchpp/trunk/plugins/Script/src/ Property changes on: adchpp/trunk ___________________________________________________________________ Name: svn:ignore - build STLport .* + build STLport .* custom.py Modified: adchpp/trunk/SConstruct =================================================================== --- adchpp/trunk/SConstruct 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/SConstruct 2007-11-18 20:58:59 UTC (rev 94) @@ -2,17 +2,6 @@ from build_util import Dev -opts = Options('custom.py', ARGUMENTS) - -opts.AddOptions( - EnumOption('tools', 'Toolset to compile with, default = platform default (msvc under windows)', 'mingw', ['mingw', 'default']), - EnumOption('mode', 'Compile mode', 'debug', ['debug', 'release']), - BoolOption('nativestl', 'Use native STL instead of STLPort', 'yes'), - BoolOption('verbose', 'Show verbose command lines', 'no'), - BoolOption('savetemps', 'Save intermediate compilation files (assembly output)', 'no'), - ('prefix', 'Prefix to use when cross compiling', 'i386-mingw32-') -) - gcc_flags = { 'common': ['-ggdb', '-Wall', '-Wextra', '-pipe', '-Wno-unused-parameter', '-Wno-missing-field-initializers', '-fexceptions'], 'debug': [], @@ -67,6 +56,21 @@ import os,sys +plugins = filter(lambda x: os.path.isfile(os.path.join('plugins', x, 'SConscript')), os.listdir('plugins')) + +opts = Options('custom.py', ARGUMENTS) + +opts.AddOptions( + EnumOption('tools', 'Toolset to compile with, default = platform default (msvc under windows)', 'mingw', ['mingw', 'default']), + EnumOption('mode', 'Compile mode', 'debug', ['debug', 'release']), + ListOption('plugins', 'The plugins to compile', 'all', plugins), + BoolOption('nativestl', 'Use native STL instead of STLPort', 'yes'), + BoolOption('verbose', 'Show verbose command lines', 'no'), + BoolOption('savetemps', 'Save intermediate compilation files (assembly output)', 'no'), + ('prefix', 'Prefix to use when cross compiling', 'i386-mingw32-') +) + + if sys.platform == 'win32': tooldef = 'mingw' else: @@ -174,6 +178,6 @@ dev.build('swig/') # Plugins -dev.build('plugins/Script/') -dev.build('plugins/Bloom/') +for plugin in env['plugins']: + dev.build('plugins/' + plugin + '/') Modified: adchpp/trunk/adchpp/CID.h =================================================================== --- adchpp/trunk/adchpp/CID.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/CID.h 2007-11-18 20:58:59 UTC (rev 94) @@ -19,6 +19,7 @@ #ifndef ADCHPP_CID_H #define ADCHPP_CID_H +#include "Util.h" #include "Encoder.h" namespace adchpp { @@ -29,10 +30,6 @@ enum { BASE32_SIZE = 39 }; struct Hash { -#if _MSC_VER >= 1300 - static const size_t bucket_size = 4; - static const size_t min_buckets = 8; -#endif size_t operator()(const CID& c) const { return c.toHash(); } bool operator()(const CID& a, const CID& b) const { return a < b; } }; Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-11-18 20:58:59 UTC (rev 94) @@ -373,7 +373,7 @@ if(j != clients.end()) { j->second->send("\n"); } - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_CID_TAKEN, STRING(CID_TAKEN))); + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_CID_TAKEN, "CID taken, please try again later")); c.disconnect(Util::REASON_CID_TAKEN); return false; } @@ -396,7 +396,7 @@ dcdebug("%s verifying nick\n", AdcCommand::fromSID(c.getSID()).c_str()); for(string::size_type i = 0; i < strtmp.length(); ++i) { if((uint8_t)strtmp[i] < 33) { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_INVALID, STRING(NICK_INVALID))); + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_INVALID, "Invalid character in nick")); c.disconnect(Util::REASON_NICK_INVALID); return false; } @@ -406,7 +406,7 @@ nicks.erase(oldNick); if(nicks.find(strtmp) != nicks.end()) { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_TAKEN, STRING(NICK_TAKEN))); + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_NICK_TAKEN, "Nick taken, please pick another one")); c.disconnect(Util::REASON_NICK_TAKEN); return false; } Modified: adchpp/trunk/adchpp/ClientManager.h =================================================================== --- adchpp/trunk/adchpp/ClientManager.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/ClientManager.h 2007-11-18 20:58:59 UTC (rev 94) @@ -19,11 +19,11 @@ #ifndef ADCHPP_CLIENTMANAGER_H #define ADCHPP_CLIENTMANAGER_H -#include "Util.h" #include "CID.h" #include "AdcCommand.h" #include "Signal.h" #include "Client.h" +#include "Singleton.h" namespace adchpp { Modified: adchpp/trunk/adchpp/File.h =================================================================== --- adchpp/trunk/adchpp/File.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/File.h 2007-11-18 20:58:59 UTC (rev 94) @@ -21,7 +21,6 @@ #include "Exception.h" #include "Util.h" -#include "ResourceManager.h" #ifndef _WIN32 #include <sys/stat.h> @@ -150,7 +149,7 @@ if(x == -1) throw FileException(Util::translateError(errno)); if(x < (ssize_t)len) - throw FileException(STRING(DISK_FULL)); + throw FileException("Unable to write, disk full?"); } /** Deleted: adchpp/trunk/adchpp/ResourceManager.cpp =================================================================== --- adchpp/trunk/adchpp/ResourceManager.cpp 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/ResourceManager.cpp 2007-11-18 20:58:59 UTC (rev 94) @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2006-2007 Jacek Sieka, arnetheduck on gmail point com - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "adchpp.h" - -#include "ResourceManager.h" - -#include "SimpleXML.h" -#include "File.h" -#include "LogManager.h" - -namespace adchpp { - -using namespace std; -using namespace std::tr1; - -ResourceManager* ResourceManager::instance = 0; -const string ResourceManager::className = "ResourceManager"; - -void ResourceManager::loadLanguage(const string& aFile) { - try { - File f(aFile, File::READ, File::OPEN); - SimpleXML xml; - xml.fromXML(f.read()); - - unordered_map<string, int> h; - - for(int i = 0; i < LAST; ++i) { - h[names[i]] = i; - } - - if(xml.findChild("Language")) { - xml.stepIn(); - if(xml.findChild("Strings")) { - xml.stepIn(); - - while(xml.findChild("String")) { - unordered_map<string, int>::iterator j = h.find(xml.getChildAttrib("Name")); - - if(j != h.end()) { - strings[j->second] = xml.getChildData(); - } - } - } - } - } catch(const Exception& e) { - LOGDT(className, "Failed to load language file: " + e.getError()); - } -} - -} Deleted: adchpp/trunk/adchpp/ResourceManager.h =================================================================== --- adchpp/trunk/adchpp/ResourceManager.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/ResourceManager.h 2007-11-18 20:58:59 UTC (rev 94) @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2006-2007 Jacek Sieka, arnetheduck on gmail point com - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef ADCHPP_RESOURCEMANAGER_H -#define ADCHPP_RESOURCEMANAGER_H - -#include "Singleton.h" - -namespace adchpp { - -/** - * This class takes care of internationalization, providing the correct strings. - */ -class ResourceManager : public Singleton<ResourceManager> { -public: - -#include "StringDefs.h" - - void loadLanguage(const std::string& aFile); - const std::string& getString(Strings x) const { return strings[x]; } - -private: - - friend class Singleton<ResourceManager>; - - ADCHPP_DLL static ResourceManager* instance; - - ResourceManager() throw() { } - virtual ~ResourceManager() throw() { } - - ADCHPP_DLL static std::string strings[LAST]; - static std::string names[LAST]; - - static const std::string className; -}; - -#define STRING(x) ResourceManager::getInstance()->getString(ResourceManager::x) -#define CSTRING(x) ResourceManager::getInstance()->getString(ResourceManager::x).c_str() - -} - -#endif // RESOURCEMANAGER_H Modified: adchpp/trunk/adchpp/SettingsManager.cpp =================================================================== --- adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-18 20:58:59 UTC (rev 94) @@ -36,7 +36,6 @@ { // Strings "HubName", "ServerIp", "LogFile", "Description", - "LanguageFile", "SENTRY", // Ints "ServerPort", "Log", "KeepSlowUsers", @@ -57,7 +56,6 @@ // set(SERVER_IP, ""); set(LOG_FILE, "logs/adchpp%Y%m.log"); set(DESCRIPTION, versionString); - // set(LANGUAGE_FILE, "Example.adchpp.xml"); set(SERVER_PORT, 2780); set(LOG, 1); set(KEEP_SLOW_USERS, 0); @@ -73,7 +71,7 @@ } bool SettingsManager::getType(const char* name, int& n, int& type) { - for(n = 0; n < INT64_LAST; n++) { + for(n = 0; n < SETTINGS_LAST; n++) { if(strcmp(settingTags[n].c_str(), name) == 0) { if(n < STR_LAST) { type = TYPE_STRING; @@ -81,9 +79,6 @@ } else if(n < INT_LAST) { type = TYPE_INT; return true; - } else { - type = TYPE_INT64; - return true; } } } @@ -127,16 +122,6 @@ LOGDT(className, attr + " missing from settings, using default"); xml.resetCurrentChild(); } - for(i=INT64_FIRST; i<INT64_LAST; i++) { - attr = settingTags[i]; - dcassert(attr.find("SENTRY") == string::npos); - - if(xml.findChild(attr)) - set(Int64Setting(i), Util::toInt64(xml.getChildData())); - else - LOGDT(className, attr + " missing from settings, using default"); - xml.resetCurrentChild(); - } xml.stepOut(); Modified: adchpp/trunk/adchpp/SettingsManager.h =================================================================== --- adchpp/trunk/adchpp/SettingsManager.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/SettingsManager.h 2007-11-18 20:58:59 UTC (rev 94) @@ -21,6 +21,7 @@ #include "Util.h" #include "Signal.h" +#include "Singleton.h" namespace adchpp { @@ -45,11 +46,8 @@ MAX_SEND_SIZE, MAX_BUFFER_SIZE, BUFFER_SIZE, MAX_COMMAND_SIZE, OVERFLOW_TIMEOUT, DISCONNECT_TIMEOUT, FLOOD_ADD, FLOOD_THRESHOLD, LOGIN_TIMEOUT, - INT_LAST }; + INT_LAST, SETTINGS_LAST = INT_LAST }; - enum Int64Setting { INT64_FIRST = INT_LAST + 1, - INT64_LAST = INT64_FIRST, SETTINGS_LAST = INT64_LAST }; - /** * Get the type of setting based on its name. By using the type info you can * convert the n to the proper enum type and get the setting. @@ -72,9 +70,6 @@ int get(IntSetting key) const { return intSettings[key - INT_FIRST]; } - int64_t get(Int64Setting key) const { - return int64Settings[key - INT64_FIRST]; - } bool getBool(IntSetting key) const { return (get(key) > 0); @@ -92,17 +87,6 @@ intSettings[key - INT_FIRST] = Util::toInt(value); } - void set(Int64Setting key, int64_t value) { - int64Settings[key - INT64_FIRST] = value; - } - void set(Int64Setting key, int value) { - int64Settings[key - INT64_FIRST] = value; - } - - template<typename T> void set(Int64Setting key, const T& value) { - int64Settings[key - INT64_FIRST] = Util::toInt64(value); - } - void set(IntSetting key, bool value) { set(key, (int)value); } void load() { Deleted: adchpp/trunk/adchpp/StringDefs.cpp =================================================================== --- adchpp/trunk/adchpp/StringDefs.cpp 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/StringDefs.cpp 2007-11-18 20:58:59 UTC (rev 94) @@ -1,29 +0,0 @@ -#include "adchpp.h" -#include "ResourceManager.h" -namespace adchpp { -using namespace std; -string ResourceManager::strings[] = { -"B", -"CID taken", -"Disk full?", -"GiB", -"Hub is currently full", -"KiB", -"MiB", -"Your nick contains invalid characters. Adios.", -"Your nick is already taken, please select another one", -"TiB", -}; -string ResourceManager::names[] = { -"B", -"CidTaken", -"DiskFull", -"Gb", -"HubFull", -"Kb", -"Mb", -"NickInvalid", -"NickTaken", -"Tb", -}; -} Deleted: adchpp/trunk/adchpp/StringDefs.h =================================================================== --- adchpp/trunk/adchpp/StringDefs.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/StringDefs.h 2007-11-18 20:58:59 UTC (rev 94) @@ -1,23 +0,0 @@ -// @Prolog: #include "adchpp.h" -// @Prolog: #include "ResourceManager.h" -// @Prolog: namespace adchpp { -// @Prolog: using namespace std; - -// @Strings: string ResourceManager::strings[] -// @Names: string ResourceManager::names[] - -enum Strings { // @DontAdd - B, // "B" - CID_TAKEN, // "CID taken" - DISK_FULL, // "Disk full?" - GB, // "GiB" - HUB_FULL, // "Hub is currently full" - KB, // "KiB" - MB, // "MiB" - NICK_INVALID, // "Your nick contains invalid characters. Adios." - NICK_TAKEN, // "Your nick is already taken, please select another one" - TB, // "TiB" - LAST // @DontAdd -}; - -// @Epilog: } Modified: adchpp/trunk/adchpp/Util.cpp =================================================================== --- adchpp/trunk/adchpp/Util.cpp 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/Util.cpp 2007-11-18 20:58:59 UTC (rev 94) @@ -232,15 +232,15 @@ string Util::formatBytes(int64_t aBytes) { char buf[64]; if(aBytes < 1024) { - sprintf(buf, "%d %s", (int)(aBytes&0xffffffff), CSTRING(B)); + sprintf(buf, "%d B", (int)(aBytes&0xffffffff)); } else if(aBytes < 1024*1024) { - sprintf(buf, "%.02f %s", (double)aBytes/(1024.0), CSTRING(KB)); + sprintf(buf, "%.02f KiB", (double)aBytes/(1024.0)); } else if(aBytes < 1024*1024*1024) { - sprintf(buf, "%.02f %s", (double)aBytes/(1024.0*1024.0), CSTRING(MB)); + sprintf(buf, "%.02f MiB", (double)aBytes/(1024.0*1024.0)); } else if(aBytes < (int64_t)1024*1024*1024*1024) { - sprintf(buf, "%.02f %s", (double)aBytes/(1024.0*1024.0*1024.0), CSTRING(GB)); + sprintf(buf, "%.02f GiB", (double)aBytes/(1024.0*1024.0*1024.0)); } else { - sprintf(buf, "%.02f %s", (double)aBytes/(1024.0*1024.0*1024.0*1024.0), CSTRING(TB)); + sprintf(buf, "%.02f TiB", (double)aBytes/(1024.0*1024.0*1024.0*1024.0)); } return buf; Modified: adchpp/trunk/adchpp/Util.h =================================================================== --- adchpp/trunk/adchpp/Util.h 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/Util.h 2007-11-18 20:58:59 UTC (rev 94) @@ -19,7 +19,6 @@ #ifndef ADCHPP_UTIL_H #define ADCHPP_UTIL_H -#include "ResourceManager.h" #include "Pool.h" #include "Mutex.h" Modified: adchpp/trunk/adchpp/adchpp.cpp =================================================================== --- adchpp/trunk/adchpp/adchpp.cpp 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/adchpp/adchpp.cpp 2007-11-18 20:58:59 UTC (rev 94) @@ -47,7 +47,6 @@ Util::initialize(configPath); - ResourceManager::newInstance(); SettingsManager::newInstance(); LogManager::newInstance(); TimerManager::newInstance(); @@ -63,14 +62,6 @@ if(!initialized) { throw Exception("adchpp not initialized"); } -/* if(!SETTING(LANGUAGE_FILE).empty()) { - if(File::isAbsolutePath(SETTING(LANGUAGE_FILE))) { - ResourceManager::getInstance()->loadLanguage(SETTING(LANGUAGE_FILE)); - } else { - ResourceManager::getInstance()->loadLanguage(Util::getCfgPath() + SETTING(LANGUAGE_FILE)); - } - } -*/ Stats::startTime = GET_TIME(); if(f) f(); @@ -114,7 +105,6 @@ LogManager::deleteInstance(); SettingsManager::deleteInstance(); TimerManager::deleteInstance(); - ResourceManager::deleteInstance(); #ifdef _WIN32 WSACleanup(); Deleted: adchpp/trunk/makedefs.py =================================================================== --- adchpp/trunk/makedefs.py 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/makedefs.py 2007-11-18 20:58:59 UTC (rev 94) @@ -1,64 +0,0 @@ -import re -import codecs -import xml.sax.saxutils - -def makename(oldname): - name = ""; - nextBig = True; - for x in oldname: - if x == '_': - nextBig = True; - else: - if nextBig: - name += x.upper(); - nextBig = False; - else: - name += x.lower(); - - return name; - - -version = re.search("VERSIONFLOAT (\S+)", file("adchpp/version.cpp").read()).group(1) - -varstr = ""; -strings = ""; -varname = ""; -names = ""; - -prolog = ""; -epilog = ""; - -example = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n'; -example += '<Language Name="Example Language" Author="arnetheduck" Version=' + version + ' Revision="1">\n' -example += '\t<Strings>\n'; - -lre = re.compile('\s*(\w+),\s*//\s*\"(.+)\"\s*') - -decoder = codecs.getdecoder('cp1252') -encoder = codecs.getencoder('utf8') -recodeattr = lambda s: encoder(decoder(xml.sax.saxutils.quoteattr(s))[0])[0] -recodeval = lambda s: encoder(decoder(xml.sax.saxutils.escape(s, {"\\t" : "\t"}))[0])[0] - -for x in file("adchpp/StringDefs.h", "r"): - if x.startswith("// @Strings: "): - varstr = x[13:].strip(); - elif x.startswith("// @Names: "): - varname = x[11:].strip(); - elif x.startswith("// @Prolog: "): - prolog += x[12:]; - elif x.startswith("// @Epilog: "): - epilog += x[12:]; - elif len(x) >= 5: - match = lre.match(x); - if match is not None: - name , value = match.groups(); - strings += '"' + value + '", \n' - newname = makename(name) - names += '"' + newname + '", \n' - example += '\t\t<String Name=%s>%s</String>\n' % (recodeattr(newname), recodeval(value)) - -example += '\t</Strings>\n'; -example += '</Language>\n'; - -file('adchpp/StringDefs.cpp', 'w').write(prolog + varstr + " = {\n" + strings + "};\n" + varname + " = {\n" + names + "};\n" + epilog); -file('etc/Example.adchpp.xml', 'w').write(example); Property changes on: adchpp/trunk/plugins/Bloom/src ___________________________________________________________________ Name: svn:ignore + stdinc.h.gch Property changes on: adchpp/trunk/plugins/Script/src ___________________________________________________________________ Name: svn:ignore - .sconsign + .sconsign stdinc.h.gch Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/swig/adchpp.i 2007-11-18 20:58:59 UTC (rev 94) @@ -624,7 +624,6 @@ enum StrSetting { STR_FIRST, HUB_NAME = STR_FIRST, SERVER_IP, LOG_FILE, DESCRIPTION, - LANGUAGE_FILE, STR_LAST }; enum IntSetting { INT_FIRST = STR_LAST + 1, @@ -634,9 +633,6 @@ LOGIN_TIMEOUT, INT_LAST }; - enum Int64Setting { INT64_FIRST = INT_LAST + 1, - INT64_LAST = INT64_FIRST, SETTINGS_LAST = INT64_LAST }; - //bool getType(const char* name, int& n, int& type); const std::string& getName(int n) { dcassert(n < SETTINGS_LAST); return settingTags[n]; } @@ -647,19 +643,12 @@ int getInt(IntSetting key) { return self->get(key); } - int64_t getInt64(Int64Setting key) { - return self->get(key); - } - void setString(StrSetting key, std::string const& value) { self->set(key, value); } void setInt(IntSetting key, int value) { self->set(key, value); } - void setInt64(Int64Setting key, int64_t value) { - self->set(key, value); - } void setBool(IntSetting key, bool value) { self->set(key, value); } Modified: adchpp/trunk/swig/lua.i =================================================================== --- adchpp/trunk/swig/lua.i 2007-11-18 19:04:42 UTC (rev 93) +++ adchpp/trunk/swig/lua.i 2007-11-18 20:58:59 UTC (rev 94) @@ -158,3 +158,4 @@ return std::string(); } } + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-18 19:04:50
|
Revision: 93 http://adchpp.svn.sourceforge.net/adchpp/?rev=93&view=rev Author: arnetheduck Date: 2007-11-18 11:04:42 -0800 (Sun, 18 Nov 2007) Log Message: ----------- Experimental Bloom filter plugin Added Paths: ----------- adchpp/trunk/plugins/Bloom/ adchpp/trunk/plugins/Bloom/SConscript adchpp/trunk/plugins/Bloom/src/ adchpp/trunk/plugins/Bloom/src/BloomManager.cpp adchpp/trunk/plugins/Bloom/src/BloomManager.h adchpp/trunk/plugins/Bloom/src/BloomPlugin.cpp adchpp/trunk/plugins/Bloom/src/HashBloom.h adchpp/trunk/plugins/Bloom/src/HashValue.h adchpp/trunk/plugins/Bloom/src/SConscript adchpp/trunk/plugins/Bloom/src/stdinc.cpp adchpp/trunk/plugins/Bloom/src/stdinc.h Added: adchpp/trunk/plugins/Bloom/SConscript =================================================================== --- adchpp/trunk/plugins/Bloom/SConscript (rev 0) +++ adchpp/trunk/plugins/Bloom/SConscript 2007-11-18 19:04:42 UTC (rev 93) @@ -0,0 +1,5 @@ +Import('dev source_path') + +ret = dev.build('src/') + +Return('ret') Added: adchpp/trunk/plugins/Bloom/src/BloomManager.cpp =================================================================== --- adchpp/trunk/plugins/Bloom/src/BloomManager.cpp (rev 0) +++ adchpp/trunk/plugins/Bloom/src/BloomManager.cpp 2007-11-18 19:04:42 UTC (rev 93) @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2006-2007 Jacek Sieka, arnetheduck on gmail point com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "stdinc.h" +#include "BloomManager.h" + +#include <adchpp/LogManager.h> + +using namespace std; +using namespace std::tr1::placeholders; + +BloomManager* BloomManager::instance = 0; +const string BloomManager::className = "BloomManager"; + +BloomManager::BloomManager() { + LOGDT(className, "Starting"); + ClientManager* cm = ClientManager::getInstance(); + receiveConn = manage(&cm->signalReceive(), std::tr1::bind(&BloomManager::onReceive, this, _1, _2, _3)); + disconnectConn = manage(&cm->signalDisconnected(), std::tr1::bind(&BloomManager::onDisconnected, this, _1)); +} + +BloomManager::~BloomManager() { + LOGDT(className, "Shutting down"); +} + +static const std::string FEATURE = "BLOM"; + +void BloomManager::onReceive(Client& c, AdcCommand& cmd, int& override) { + std::string tth; + + if(cmd.getCommand() == AdcCommand::CMD_INF && c.supports(FEATURE)) { + AdcCommand get(AdcCommand::CMD_GET); + get.addParam("blom"); + get.addParam("/"); + get.addParam("0"); + get.addParam("-1"); + c.send(get); + } else if(cmd.getCommand() == AdcCommand::CMD_SND) { + if(cmd.getParameters().size() < 4) { + return; + } + if(cmd.getParam(0) != "blom") { + return; + } + + int64_t bytes = Util::toInt(cmd.getParam(4)); + + c.setDataMode(std::tr1::bind(&BloomManager::onData, this, _1, _2, _3), bytes); + } else if(cmd.getCommand() == AdcCommand::CMD_SCH && cmd.getParam("TH", 0, tth)) { + + BloomMap::const_iterator i = blooms.find(c.getCID()); + if(i != blooms.end() && i->second.match(TTHValue(tth))) { + // Stop it + override |= ClientManager::DONT_DISPATCH | ClientManager::DONT_SEND; + } + } +} + +void BloomManager::onData(Client& c, const uint8_t* data, size_t len) { + HashBloom& bloom = blooms[c.getCID()]; + for(size_t i = 0; i < len; ++i) { + for(size_t j = 0; j < 8; ++j) { + bloom.push_back(data[i] & 1 << j); + } + } +} + +void BloomManager::onDisconnected(Client& c) { + blooms.erase(c.getCID()); +} + Added: adchpp/trunk/plugins/Bloom/src/BloomManager.h =================================================================== --- adchpp/trunk/plugins/Bloom/src/BloomManager.h (rev 0) +++ adchpp/trunk/plugins/Bloom/src/BloomManager.h 2007-11-18 19:04:42 UTC (rev 93) @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2006-2007 Jacek Sieka, arnetheduck on gmail point com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef BLOOM_MANAGER_H +#define BLOOM_MANAGER_H + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include <adchpp/Exception.h> +#include <adchpp/Singleton.h> +#include <adchpp/ClientManager.h> + +#include "HashBloom.h" + +#ifdef _WIN32 +# ifdef BLOOM_EXPORT +# define BLOOM_DLL __declspec(dllexport) +# else +# define BLOOM_DLL __declspec(dllimport) +# endif +#else +# define BLOOM_DLL +#endif + +STANDARD_EXCEPTION(BloomException); +class Engine; + +namespace adchpp { +class SimpleXML; +class Client; +class AdcCommand; +} + +class BloomManager : public Singleton<BloomManager> { +public: + BloomManager(); + virtual ~BloomManager(); + + virtual int getVersion() { return 0; } + + void onReceive(Client& c, AdcCommand& cmd, int&); + void onData(Client& c, const uint8_t* data, size_t len); + void onDisconnected(Client& c); + + static const std::string className; +private: + friend class Singleton<BloomManager>; + static BloomManager* instance; + + typedef std::tr1::unordered_map<CID, HashBloom, CID::Hash> BloomMap; + BloomMap blooms; + + ClientManager::SignalReceive::ManagedConnection receiveConn; + ClientManager::SignalDisconnected::ManagedConnection disconnectConn; + +}; + +#endif //ACCESSMANAGER_H Added: adchpp/trunk/plugins/Bloom/src/BloomPlugin.cpp =================================================================== --- adchpp/trunk/plugins/Bloom/src/BloomPlugin.cpp (rev 0) +++ adchpp/trunk/plugins/Bloom/src/BloomPlugin.cpp 2007-11-18 19:04:42 UTC (rev 93) @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2006-2007 Jacek Sieka, arnetheduck on gmail point com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "stdinc.h" +#include "BloomManager.h" + +#include <adchpp/PluginManager.h> + +#ifdef _WIN32 + +BOOL APIENTRY DllMain(HANDLE /*hModule */, DWORD /* reason*/, LPVOID /*lpReserved*/) { + return TRUE; +} + +#endif + +extern "C" { +int PLUGIN_API pluginGetVersion() { return PLUGINVERSION; } + +int PLUGIN_API pluginLoad() { + BloomManager::newInstance(); + return 0; +} + +void PLUGIN_API pluginUnload() { + BloomManager::deleteInstance(); +} +} + Added: adchpp/trunk/plugins/Bloom/src/HashBloom.h =================================================================== --- adchpp/trunk/plugins/Bloom/src/HashBloom.h (rev 0) +++ adchpp/trunk/plugins/Bloom/src/HashBloom.h 2007-11-18 19:04:42 UTC (rev 93) @@ -0,0 +1,21 @@ +#ifndef HASHBLOOM_H_ +#define HASHBLOOM_H_ + +#include "HashValue.h" + +class HashBloom { +public: + void add(const TTHValue& tth) { bloom[pos(tth)] = true; } + bool match(const TTHValue& tth) const { return bloom[pos(tth)]; } + void resize(size_t hashes) { bloom.resize(hashes); std::fill(bloom.begin(), bloom.end(), false); } + void push_back(bool v) { bloom.push_back(v); } +private: + + size_t pos(const TTHValue& tth) const { + return (*(size_t*)tth.data) % bloom.size(); + } + + std::vector<bool> bloom; +}; + +#endif /*HASHBLOOM_H_*/ Added: adchpp/trunk/plugins/Bloom/src/HashValue.h =================================================================== --- adchpp/trunk/plugins/Bloom/src/HashValue.h (rev 0) +++ adchpp/trunk/plugins/Bloom/src/HashValue.h 2007-11-18 19:04:42 UTC (rev 93) @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2001-2006 Jacek Sieka, arnetheduck on gmail point com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#if !defined(HASH_VALUE_H) +#define HASH_VALUE_H + +#include <adchpp/TigerHash.h> + +template<class Hasher> +struct HashValue { + static const size_t SIZE = Hasher::HASH_SIZE; + + struct Hash { +#ifdef _MSC_VER + static const size_t bucket_size = 4; + static const size_t min_buckets = 8; +#endif + size_t operator()(const HashValue& rhs) const { return *(size_t*)&rhs; } + bool operator()(const HashValue& a, const HashValue& b) const { return a < b; } + }; + + HashValue() { } + explicit HashValue(uint8_t* aData) { memcpy(data, aData, SIZE); } + explicit HashValue(const std::string& base32) { Encoder::fromBase32(base32.c_str(), data, SIZE); } + HashValue(const HashValue& rhs) { memcpy(data, rhs.data, SIZE); } + HashValue& operator=(const HashValue& rhs) { memcpy(data, rhs.data, SIZE); return *this; } + bool operator!=(const HashValue& rhs) const { return !(*this == rhs); } + bool operator==(const HashValue& rhs) const { return memcmp(data, rhs.data, SIZE) == 0; } + bool operator<(const HashValue& rhs) const { return memcmp(data, rhs.data, SIZE) < 0; } + + std::string toBase32() const { return Encoder::toBase32(data, SIZE); } + std::string& toBase32(std::string& tmp) const { return Encoder::toBase32(data, SIZE, tmp); } + + uint8_t data[SIZE]; +}; + +typedef HashValue<TigerHash> TTHValue; + +#endif // !defined(HASH_VALUE_H) Added: adchpp/trunk/plugins/Bloom/src/SConscript =================================================================== --- adchpp/trunk/plugins/Bloom/src/SConscript (rev 0) +++ adchpp/trunk/plugins/Bloom/src/SConscript 2007-11-18 19:04:42 UTC (rev 93) @@ -0,0 +1,14 @@ +Import('dev source_path') + +env, target, sources = dev.prepare_build(source_path, 'Bloom') +env['SHLIBPREFIX'] = '' + +if 'gcc' in env['TOOLS']: + env['GchSh'] = env.GchSh('stdinc.h')[0] + +env.Append(CPPPATH = ['#']) +env.Append(LIBS = ['adchpp']) + +ret = env.SharedLibrary(target, sources) + +Return('ret') Added: adchpp/trunk/plugins/Bloom/src/stdinc.cpp =================================================================== --- adchpp/trunk/plugins/Bloom/src/stdinc.cpp (rev 0) +++ adchpp/trunk/plugins/Bloom/src/stdinc.cpp 2007-11-18 19:04:42 UTC (rev 93) @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2006-2007 Jacek Sieka, arnetheduck on gmail point com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "stdinc.h" Added: adchpp/trunk/plugins/Bloom/src/stdinc.h =================================================================== --- adchpp/trunk/plugins/Bloom/src/stdinc.h (rev 0) +++ adchpp/trunk/plugins/Bloom/src/stdinc.h 2007-11-18 19:04:42 UTC (rev 93) @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2006-2007 Jacek Sieka, arnetheduck on gmail point com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef SCRIPT_STDINC_H +#define SCRIPT_STDINC_H + +#include <adchpp/adchpp.h> +#include <adchpp/common.h> + +using namespace adchpp; + +#endif //ACCESS_STDINC_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-18 19:03:41
|
Revision: 92 http://adchpp.svn.sourceforge.net/adchpp/?rev=92&view=rev Author: arnetheduck Date: 2007-11-18 11:03:32 -0800 (Sun, 18 Nov 2007) Log Message: ----------- Don't import std Modified Paths: -------------- adchpp/trunk/SConstruct adchpp/trunk/adchpp/AdcCommand.cpp adchpp/trunk/adchpp/AdcCommand.h adchpp/trunk/adchpp/CID.h adchpp/trunk/adchpp/Client.cpp adchpp/trunk/adchpp/Client.h adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/ClientManager.h adchpp/trunk/adchpp/Encoder.cpp adchpp/trunk/adchpp/Encoder.h adchpp/trunk/adchpp/Exception.h adchpp/trunk/adchpp/File.cpp adchpp/trunk/adchpp/File.h adchpp/trunk/adchpp/LogManager.cpp adchpp/trunk/adchpp/LogManager.h adchpp/trunk/adchpp/ManagedSocket.cpp adchpp/trunk/adchpp/ManagedSocket.h adchpp/trunk/adchpp/PluginManager.cpp adchpp/trunk/adchpp/PluginManager.h adchpp/trunk/adchpp/Pool.h adchpp/trunk/adchpp/ResourceManager.cpp adchpp/trunk/adchpp/ResourceManager.h adchpp/trunk/adchpp/SettingsManager.cpp adchpp/trunk/adchpp/SettingsManager.h adchpp/trunk/adchpp/Signal.h adchpp/trunk/adchpp/SimpleXML.cpp adchpp/trunk/adchpp/SimpleXML.h adchpp/trunk/adchpp/Socket.cpp adchpp/trunk/adchpp/Socket.h adchpp/trunk/adchpp/SocketManager.cpp adchpp/trunk/adchpp/SocketManager.h adchpp/trunk/adchpp/StringDefs.cpp adchpp/trunk/adchpp/StringDefs.h adchpp/trunk/adchpp/TigerHash.cpp adchpp/trunk/adchpp/Util.cpp adchpp/trunk/adchpp/Util.h adchpp/trunk/adchpp/adchpp.cpp adchpp/trunk/adchpp/adchpp.h adchpp/trunk/adchpp/common.h adchpp/trunk/adchpp/version.cpp adchpp/trunk/adchpp/version.h adchpp/trunk/plugins/Script/src/Engine.h adchpp/trunk/plugins/Script/src/LuaEngine.cpp adchpp/trunk/plugins/Script/src/LuaEngine.h adchpp/trunk/plugins/Script/src/LuaScript.cpp adchpp/trunk/plugins/Script/src/LuaScript.h adchpp/trunk/plugins/Script/src/ScriptManager.cpp adchpp/trunk/plugins/Script/src/ScriptManager.h adchpp/trunk/swig/adchpp.i Modified: adchpp/trunk/SConstruct =================================================================== --- adchpp/trunk/SConstruct 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/SConstruct 2007-11-18 19:03:32 UTC (rev 92) @@ -152,13 +152,11 @@ conf = Configure(env) if conf.CheckCHeader('sys/epoll.h'): - conf.env.Append(CPPDEFINES='HAVE_SYS_EPOLL_H') -if conf.CheckCHeader('sys/poll.h'): - conf.env.Append(CPPDEFINES='HAVE_SYS_POLL_H') + conf.env.Append(CPPDEFINES=['HAVE_SYS_EPOLL_H']) if conf.CheckLib('dl', 'dlopen'): - conf.env.Append(CPPDEFINES='HAVE_DL') + conf.env.Append(CPPDEFINES=['HAVE_DL']) if conf.CheckLib('pthread', 'pthread_create'): - conf.env.Append(CPPDEFINES='HAVE_PTHREAD') + conf.env.Append(CPPDEFINES=['HAVE_PTHREAD']) env = conf.Finish() Modified: adchpp/trunk/adchpp/AdcCommand.cpp =================================================================== --- adchpp/trunk/adchpp/AdcCommand.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/AdcCommand.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -21,7 +21,9 @@ #include "AdcCommand.h" namespace adchpp { - + +using namespace std; + AdcCommand::AdcCommand() : cmdInt(0), str(0), from(0), type(0) { } AdcCommand::AdcCommand(Severity sev, Error err, const string& desc, char aType /* = TYPE_INFO */) : cmdInt(CMD_STA), str(&tmp), from(HUB_SID), type(aType) { Modified: adchpp/trunk/adchpp/AdcCommand.h =================================================================== --- adchpp/trunk/adchpp/AdcCommand.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/AdcCommand.h 2007-11-18 19:03:32 UTC (rev 92) @@ -105,38 +105,38 @@ uint32_t toCMD(uint8_t a, uint8_t b, uint8_t c) { return (((uint32_t)a) | (((uint32_t)b)<<8) | (((uint32_t)c)<<16)); } ADCHPP_DLL AdcCommand(); - ADCHPP_DLL explicit AdcCommand(Severity sev, Error err, const string& desc, char aType = TYPE_INFO); + ADCHPP_DLL explicit AdcCommand(Severity sev, Error err, const std::string& desc, char aType = TYPE_INFO); explicit AdcCommand(uint32_t cmd, char aType = TYPE_INFO, uint32_t aFrom = HUB_SID) : cmdInt(cmd), str(&tmp), from(aFrom), type(aType) { } - explicit AdcCommand(const string& aLine) throw(ParseException) : cmdInt(0), str(&aLine), type(0) { parse(aLine); } + explicit AdcCommand(const std::string& aLine) throw(ParseException) : cmdInt(0), str(&aLine), type(0) { parse(aLine); } AdcCommand(const AdcCommand& rhs) : parameters(rhs.parameters), cmdInt(rhs.cmdInt), str(&tmp), from(rhs.from), to(rhs.to), type(rhs.type) { } - ADCHPP_DLL void parse(const string& aLine) throw(ParseException); + ADCHPP_DLL void parse(const std::string& aLine) throw(ParseException); uint32_t getCommand() const { return cmdInt; } char getType() const { return type; } StringList& getParameters() { return parameters; } const StringList& getParameters() const { return parameters; } - ADCHPP_DLL const string& toString() const; + ADCHPP_DLL const std::string& toString() const; void resetString() { tmp.clear(); str = &tmp; } - AdcCommand& addParam(const string& name, const string& value) { + AdcCommand& addParam(const std::string& name, const std::string& value) { parameters.push_back(name); parameters.back() += value; return *this; } - AdcCommand& addParam(const string& param) { + AdcCommand& addParam(const std::string& param) { parameters.push_back(param); return *this; } - const string& getParam(size_t n) const { + const std::string& getParam(size_t n) const { return getParameters().size() > n ? getParameters()[n] : Util::emptyString; } - const string& getFeatures() const { return features; } + const std::string& getFeatures() const { return features; } /** Return a named parameter where the name is a two-letter code */ - ADCHPP_DLL bool getParam(const char* name, size_t start, string& ret) const; + ADCHPP_DLL bool getParam(const char* name, size_t start, std::string& ret) const; ADCHPP_DLL bool delParam(const char* name, size_t start); ADCHPP_DLL bool hasFlag(const char* name, size_t start) const; @@ -144,28 +144,28 @@ bool operator==(uint32_t aCmd) const { return cmdInt == aCmd; } - ADCHPP_DLL static void escape(const string& s, string& out); + ADCHPP_DLL static void escape(const std::string& s, std::string& out); uint32_t getTo() const { return to; } void setTo(uint32_t aTo) { to = aTo; } uint32_t getFrom() const { return from; } void setFrom(uint32_t aFrom) { from = aFrom; } - static uint32_t toSID(const string& aSID) { return *reinterpret_cast<const uint32_t*>(aSID.data()); } - static string fromSID(const uint32_t aSID) { return string(reinterpret_cast<const char*>(&aSID), sizeof(aSID)); } - static void appendSID(string& str, uint32_t aSID) { str.append(reinterpret_cast<const char*>(&aSID), sizeof(aSID)); } + static uint32_t toSID(const std::string& aSID) { return *reinterpret_cast<const uint32_t*>(aSID.data()); } + static std::string fromSID(const uint32_t aSID) { return std::string(reinterpret_cast<const char*>(&aSID), sizeof(aSID)); } + static void appendSID(std::string& str, uint32_t aSID) { str.append(reinterpret_cast<const char*>(&aSID), sizeof(aSID)); } private: AdcCommand& operator=(const AdcCommand&); StringList parameters; - string features; + std::string features; union { char cmdChar[4]; uint8_t cmd[4]; uint32_t cmdInt; }; - const string* str; - mutable string tmp; + const std::string* str; + mutable std::string tmp; uint32_t from; uint32_t to; Modified: adchpp/trunk/adchpp/CID.h =================================================================== --- adchpp/trunk/adchpp/CID.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/CID.h 2007-11-18 19:03:32 UTC (rev 92) @@ -38,18 +38,18 @@ }; CID() { memset(cid, 0, sizeof(cid)); } explicit CID(const uint8_t* data) { memcpy(cid, data, sizeof(cid)); } - explicit CID(const string& base32) { Encoder::fromBase32(base32.c_str(), cid, sizeof(cid)); } + explicit CID(const std::string& base32) { Encoder::fromBase32(base32.c_str(), cid, sizeof(cid)); } bool operator==(const CID& rhs) const { return memcmp(cid, rhs.cid, sizeof(cid)) == 0; } bool operator<(const CID& rhs) const { return memcmp(cid, rhs.cid, sizeof(cid)) < 0; } - string toBase32() const { return Encoder::toBase32(cid, sizeof(cid)); } - string& toBase32(string& tmp) const { return Encoder::toBase32(cid, sizeof(cid), tmp); } + std::string toBase32() const { return Encoder::toBase32(cid, sizeof(cid)); } + std::string& toBase32(std::string& tmp) const { return Encoder::toBase32(cid, sizeof(cid), tmp); } size_t toHash() const { return *reinterpret_cast<const size_t*>(cid); } const uint8_t* data() const { return cid; } - bool isZero() const { return find_if(cid, cid+SIZE, bind2nd(not_equal_to<uint8_t>(), 0)) == (cid+SIZE); } + bool isZero() const { return std::find_if(cid, cid+SIZE, std::bind2nd(std::not_equal_to<uint8_t>(), 0)) == (cid+SIZE); } static CID generate() { uint8_t data[CID::SIZE]; Modified: adchpp/trunk/adchpp/Client.cpp =================================================================== --- adchpp/trunk/adchpp/Client.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Client.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -26,6 +26,7 @@ namespace adchpp { +using namespace std; using namespace std::tr1::placeholders; Client* Client::create(const ManagedSocketPtr& ms) throw() { Modified: adchpp/trunk/adchpp/Client.h =================================================================== --- adchpp/trunk/adchpp/Client.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Client.h 2007-11-18 19:03:32 UTC (rev 92) @@ -65,17 +65,17 @@ static Client* create(const ManagedSocketPtr& ms_) throw(); const StringList& getSupportList() const throw() { return supportList; } - bool supports(const string& feat) const throw() { return find(supportList.begin(), supportList.end(), feat) != supportList.end(); } + bool supports(const std::string& feat) const throw() { return find(supportList.begin(), supportList.end(), feat) != supportList.end(); } void send(const char* command, size_t len) throw() { dcassert(socket != NULL); socket->write(command, len); } void send(const AdcCommand& cmd) throw() { send(cmd.toString()); } - void send(const string& command) throw() { send(command.c_str(), command.length()); } + void send(const std::string& command) throw() { send(command.c_str(), command.length()); } void send(const char* command) throw() { socket->write(command, strlen(command)); } - void fastSend(const string& command, bool lowPrio = false) throw() { + void fastSend(const std::string& command, bool lowPrio = false) throw() { socket->fastWrite(command.c_str(), command.length(), lowPrio); } size_t getQueuedBytes() throw() { return socket->getQueuedBytes(); } @@ -84,7 +84,7 @@ ADCHPP_DLL void disconnect(Util::Reason reason) throw(); const ManagedSocketPtr& getSocket() throw() { return socket; } const ManagedSocketPtr& getSocket() const throw() { return socket; } - const string& getIp() const throw() { dcassert(socket != NULL); return getSocket()->getIp(); } + const std::string& getIp() const throw() { dcassert(socket != NULL); return getSocket()->getIp(); } /** * Set data mode for aBytes bytes. @@ -96,12 +96,12 @@ /** Add any flags that have been updated to the AdcCommand (type etc is not set) */ ADCHPP_DLL bool getChangedFields(AdcCommand& cmd) const throw(); ADCHPP_DLL bool getAllFields(AdcCommand& cmd) const throw(); - ADCHPP_DLL const string& getINF() const throw(); + ADCHPP_DLL const std::string& getINF() const throw(); void resetChanged() { changed.clear(); } - const string& getField(const char* name) const throw() { InfMap::const_iterator i = info.find(AdcCommand::toCode(name)); return i == info.end() ? Util::emptyString : i->second; } - ADCHPP_DLL void setField(const char* name, const string& value) throw(); + const std::string& getField(const char* name) const throw() { InfMap::const_iterator i = info.find(AdcCommand::toCode(name)); return i == info.end() ? Util::emptyString : i->second; } + ADCHPP_DLL void setField(const char* name, const std::string& value) throw(); ADCHPP_DLL void updateFields(const AdcCommand& cmd) throw(); ADCHPP_DLL void updateSupports(const AdcCommand& cmd) throw(); @@ -150,11 +150,11 @@ StringList filters; /** H-C SUP */ StringList supportList; - typedef pair<int, void*> PSDPair; - typedef vector<PSDPair> PSDList; + typedef std::pair<int, void*> PSDPair; + typedef std::vector<PSDPair> PSDList; typedef PSDList::iterator PSDIter; - typedef std::tr1::unordered_map<uint16_t, string> InfMap; + typedef std::tr1::unordered_map<uint16_t, std::string> InfMap; typedef InfMap::iterator InfIter; InfMap info; @@ -168,14 +168,14 @@ bool disconnecting; PSDList psd; - string line; + std::string line; ManagedSocketPtr socket; int64_t dataBytes; time_t floodTimer; /** Latest INF cached */ - mutable string INF; + mutable std::string INF; DataFunction dataHandler; void setSocket(const ManagedSocketPtr& aSocket) throw(); Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -31,7 +31,9 @@ #include "SettingsManager.h" namespace adchpp { - + +using namespace std; + ClientManager* ClientManager::instance = 0; const string ClientManager::className = "ClientManager"; Modified: adchpp/trunk/adchpp/ClientManager.h =================================================================== --- adchpp/trunk/adchpp/ClientManager.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/ClientManager.h 2007-11-18 19:03:32 UTC (rev 92) @@ -45,14 +45,14 @@ typedef ClientMap::iterator ClientIter; /** Adds a string to SUP, propagating the change to all connected clients */ - ADCHPP_DLL void addSupports(const string& str) throw(); + ADCHPP_DLL void addSupports(const std::string& str) throw(); /** Removes a string from SUP, propagating the change to all connected clients */ - ADCHPP_DLL void removeSupports(const string& str) throw(); + ADCHPP_DLL void removeSupports(const std::string& str) throw(); ADCHPP_DLL void updateCache() throw(); /** @return SID of client or 0 if not found */ - ADCHPP_DLL uint32_t getSID(const string& nick) const throw(); + ADCHPP_DLL uint32_t getSID(const std::string& nick) const throw(); /** @return SID of client or 0 if not found */ ADCHPP_DLL uint32_t getSID(const CID& cid) const throw(); @@ -71,7 +71,7 @@ ADCHPP_DLL void send(const AdcCommand& cmd, bool lowPrio = false) throw(); /** Send command to all regardless of type */ void sendToAll(const AdcCommand& cmd) throw() { sendToAll(cmd.toString()); } - ADCHPP_DLL void sendToAll(const string& cmd) throw(); + ADCHPP_DLL void sendToAll(const std::string& cmd) throw(); /** Send command to a single client regardless of type */ ADCHPP_DLL void sendTo(const AdcCommand& cmd, const uint32_t& to) throw(); @@ -97,7 +97,7 @@ * @param sendData Send GPA. * @return The random data that was sent to the client (if sendData was true, undefined otherwise). */ - ADCHPP_DLL vector<uint8_t> enterVerify(Client& c, bool sendData) throw(); + ADCHPP_DLL ByteVector enterVerify(Client& c, bool sendData) throw(); /** * Enter NORMAL state. Call this if you stop an INF of a password-less @@ -129,7 +129,7 @@ /** * Verify password */ - ADCHPP_DLL bool verifyPassword(Client& c, const string& password, const vector<uint8_t>& salt, const string& suppliedHash); + ADCHPP_DLL bool verifyPassword(Client& c, const std::string& password, const ByteVector& salt, const std::string& suppliedHash); /** * Verify that IP is correct and replace any zero addresses. @@ -157,7 +157,7 @@ typedef SignalTraits<void (Client&)> SignalConnected; typedef SignalTraits<void (Client&, AdcCommand&, int&)> SignalReceive; - typedef SignalTraits<void (Client&, const string&)> SignalBadLine; + typedef SignalTraits<void (Client&, const std::string&)> SignalBadLine; typedef SignalTraits<void (Client&, AdcCommand&, int&)> SignalSend; typedef SignalTraits<void (Client&, int)> SignalState; typedef SignalTraits<void (Client&)> SignalDisconnected; @@ -177,10 +177,10 @@ */ StringList supports; - deque<pair<Client*, time_t> > logins; + std::deque<std::pair<Client*, time_t> > logins; ClientMap clients; - typedef std::tr1::unordered_map<string, uint32_t> NickMap; + typedef std::tr1::unordered_map<std::string, uint32_t> NickMap; NickMap nicks; typedef std::tr1::unordered_map<CID, uint32_t, CID::Hash> CIDMap; CIDMap cids; @@ -188,14 +188,14 @@ SIDSet sids; // Temporary string to use whenever a temporary string is needed (to avoid (de)allocating memory all the time...) - string strtmp; + std::string strtmp; - static const string className; + static const std::string className; // Strings used in various places along the pipeline...rebuilt in updateCache()... struct Strings { - string sup; - string inf; + std::string sup; + std::string inf; } strings; friend class Singleton<ClientManager>; @@ -216,7 +216,7 @@ void onConnected(Client&) throw(); void onReceive(Client&, AdcCommand&) throw(); - void onBadLine(Client&, const string&) throw(); + void onBadLine(Client&, const std::string&) throw(); void onFailed(Client&) throw(); void badState(Client& c, const AdcCommand& cmd) throw(); Modified: adchpp/trunk/adchpp/Encoder.cpp =================================================================== --- adchpp/trunk/adchpp/Encoder.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Encoder.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -22,7 +22,9 @@ #include "common.h" namespace adchpp { - + +using namespace std; + const int8_t Encoder::base32Table[256] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, Modified: adchpp/trunk/adchpp/Encoder.h =================================================================== --- adchpp/trunk/adchpp/Encoder.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Encoder.h 2007-11-18 19:03:32 UTC (rev 92) @@ -24,9 +24,9 @@ class Encoder { public: - ADCHPP_DLL static string& toBase32(const uint8_t* src, size_t len, string& tgt); - static string toBase32(const uint8_t* src, size_t len) { - string tmp; + ADCHPP_DLL static std::string& toBase32(const uint8_t* src, size_t len, std::string& tgt); + static std::string toBase32(const uint8_t* src, size_t len) { + std::string tmp; return toBase32(src, len, tmp); } ADCHPP_DLL static void fromBase32(const char* src, uint8_t* dst, size_t len); Modified: adchpp/trunk/adchpp/Exception.h =================================================================== --- adchpp/trunk/adchpp/Exception.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Exception.h 2007-11-18 19:03:32 UTC (rev 92) @@ -23,17 +23,17 @@ namespace adchpp { -class ADCHPP_VISIBLE Exception : public exception +class ADCHPP_VISIBLE Exception : public std::exception { public: Exception() { } - Exception(const string& aError) throw() : error(aError) { dcdebug("Thrown: %s\n", error.c_str()); } + Exception(const std::string& aError) throw() : error(aError) { dcdebug("Thrown: %s\n", error.c_str()); } virtual ~Exception() throw() { } - const string& getError() const throw() { return error; } + const std::string& getError() const throw() { return error; } virtual const char* what() { return error.c_str(); } protected: - string error; + std::string error; }; #ifndef NDEBUG @@ -41,7 +41,7 @@ #define STANDARD_EXCEPTION(name) class ADCHPP_VISIBLE name : public Exception { \ public:\ name() throw() : Exception(#name) { } \ - name(const string& aError) throw() : Exception(#name ": " + aError) { } \ + name(const std::string& aError) throw() : Exception(#name ": " + aError) { } \ virtual ~name() throw() { } \ } Modified: adchpp/trunk/adchpp/File.cpp =================================================================== --- adchpp/trunk/adchpp/File.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/File.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -21,7 +21,9 @@ #include "File.h" namespace adchpp { - + +using namespace std; + string File::read(uint32_t len) throw(FileException) { string tmp; tmp.resize(len); Modified: adchpp/trunk/adchpp/File.h =================================================================== --- adchpp/trunk/adchpp/File.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/File.h 2007-11-18 19:03:32 UTC (rev 92) @@ -46,24 +46,24 @@ TRUNCATE = 0x04 }; - ADCHPP_DLL File(const string& aFileName, int access, int mode = OPEN) throw(FileException); + ADCHPP_DLL File(const std::string& aFileName, int access, int mode = OPEN) throw(FileException); ADCHPP_DLL int64_t getSize(); - ADCHPP_DLL static int64_t getSize(const string& aFileName); + ADCHPP_DLL static int64_t getSize(const std::string& aFileName); - ADCHPP_DLL string read(uint32_t len) throw(FileException); + ADCHPP_DLL std::string read(uint32_t len) throw(FileException); /** Returns the directory part of the full path */ - ADCHPP_DLL static string getFilePath(const string& name) throw(); + ADCHPP_DLL static std::string getFilePath(const std::string& name) throw(); /** Returns the filename part of the full path */ - ADCHPP_DLL static string getFileName(const string& name) throw(); - ADCHPP_DLL static bool isAbsolutePath(const string& name) throw(); + ADCHPP_DLL static std::string getFileName(const std::string& name) throw(); + ADCHPP_DLL static bool isAbsolutePath(const std::string& name) throw(); - static string makeAbsolutePath(string const& path, string const& filename) { + static std::string makeAbsolutePath(const std::string& path, const std::string& filename) { return isAbsolutePath(filename) ? filename : path + filename; } - ADCHPP_DLL static void ensureDirectory(const string& aFile) throw(); + ADCHPP_DLL static void ensureDirectory(const std::string& aFile) throw(); #ifdef _WIN32 void close() { @@ -159,8 +159,8 @@ void setEOF() throw(FileException) { } - static void deleteFile(const string& aFileName) { ::unlink(aFileName.c_str()); }; - static void renameFile(const string& source, const string& target) { ::rename(source.c_str(), target.c_str()); }; + static void deleteFile(const std::string& aFileName) { ::unlink(aFileName.c_str()); }; + static void renameFile(const std::string& source, const std::string& target) { ::rename(source.c_str(), target.c_str()); }; #endif // WIN32 @@ -168,12 +168,12 @@ close(); } - string read() throw(FileException) { + std::string read() throw(FileException) { setPos(0); return read((uint32_t)getSize()); } - void write(const string& aString) throw(FileException) { + void write(const std::string& aString) throw(FileException) { write((void*)aString.data(), aString.size()); } Modified: adchpp/trunk/adchpp/LogManager.cpp =================================================================== --- adchpp/trunk/adchpp/LogManager.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/LogManager.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -25,6 +25,8 @@ namespace adchpp { +using namespace std; + LogManager* LogManager::instance = 0; void LogManager::logDateTime(const string& area, const string& msg) throw() Modified: adchpp/trunk/adchpp/LogManager.h =================================================================== --- adchpp/trunk/adchpp/LogManager.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/LogManager.h 2007-11-18 19:03:32 UTC (rev 92) @@ -35,8 +35,8 @@ * @param area Name of the module that generated the error. * @param msg Message to log. */ - void log(const string& area, const string& msg) throw() { - string tmp(area); + void log(const std::string& area, const std::string& msg) throw() { + std::string tmp(area); tmp += ": "; tmp += msg; dolog(tmp); @@ -46,7 +46,7 @@ * Same as log, but prepends the current date and time. * @see log */ - ADCHPP_DLL void logDateTime(const string& area, const string& msg) throw(); + ADCHPP_DLL void logDateTime(const std::string& area, const std::string& msg) throw(); private: friend class Singleton<LogManager>; ADCHPP_DLL static LogManager* instance; @@ -55,7 +55,7 @@ LogManager() throw() { } virtual ~LogManager() throw() { } - ADCHPP_DLL void dolog(const string& msg) throw(); + ADCHPP_DLL void dolog(const std::string& msg) throw(); }; #define LOG(area, msg) LogManager::getInstance()->log(area, msg) Modified: adchpp/trunk/adchpp/ManagedSocket.cpp =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/ManagedSocket.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -27,6 +27,8 @@ namespace adchpp { +using namespace std; + FastMutex ManagedSocket::writeMutex; ManagedSocket::ManagedSocket() throw() : outBuf(0), overFlow(0), disc(0) Modified: adchpp/trunk/adchpp/ManagedSocket.h =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/ManagedSocket.h 2007-11-18 19:03:32 UTC (rev 92) @@ -52,8 +52,8 @@ /** Asynchronous disconnect. Pending data will be written, but no more data will be read. */ ADCHPP_DLL void disconnect(Util::Reason reason) throw(); - const string& getIp() const { return ip; } - void setIp(const string& ip_) { ip = ip_; } + const std::string& getIp() const { return ip; } + void setIp(const std::string& ip_) { ip = ip_; } typedef std::tr1::function<void()> ConnectedHandler; void setConnectedHandler(const ConnectedHandler& handler) { connectedHandler = handler; } @@ -98,7 +98,7 @@ /** Disconnection scheduled for this socket */ uint32_t disc; - string ip; + std::string ip; #ifdef _WIN32 /** Data currently being sent by WSASend, 0 if not sending */ ByteVector* writeBuf; Modified: adchpp/trunk/adchpp/PluginManager.cpp =================================================================== --- adchpp/trunk/adchpp/PluginManager.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/PluginManager.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -27,8 +27,6 @@ #include "version.h" #include "File.h" -using namespace std::tr1::placeholders; - #ifdef _WIN32 #define PLUGIN_EXT _T(".dll") @@ -53,6 +51,9 @@ namespace adchpp { +using namespace std; +using namespace std::tr1::placeholders; + PluginManager* PluginManager::instance = 0; const string PluginManager::className = "PluginManager"; Modified: adchpp/trunk/adchpp/PluginManager.h =================================================================== --- adchpp/trunk/adchpp/PluginManager.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/PluginManager.h 2007-11-18 19:03:32 UTC (rev 92) @@ -143,7 +143,7 @@ class PluginManager : public Singleton<PluginManager> { public: - typedef std::tr1::unordered_map<string, Plugin*> Registry; + typedef std::tr1::unordered_map<std::string, Plugin*> Registry; typedef Registry::iterator RegistryIter; /** @@ -156,7 +156,7 @@ /** * Get the plugin path as set in adchpp.xml */ - const string& getPluginPath() const { + const std::string& getPluginPath() const { return pluginPath; } @@ -173,19 +173,19 @@ * Register a plugin interface under a name. * @return false if name was already registered and call fails */ - bool registerPlugin(const string& name, Plugin* ptr) { - return registry.insert(make_pair(name, ptr)).second; + bool registerPlugin(const std::string& name, Plugin* ptr) { + return registry.insert(std::make_pair(name, ptr)).second; } /** @return True if the plugin existed and was thus unregistered */ - bool unregisterPlugin(const string& name) { + bool unregisterPlugin(const std::string& name) { return registry.erase(name) > 0; } /** * @return Plugin interface, or NULL if not found */ - Plugin* getPlugin(const string& name) { + Plugin* getPlugin(const std::string& name) { RegistryIter i = registry.find(name); return i == registry.end() ? NULL : i->second; } @@ -224,22 +224,22 @@ friend class Singleton<PluginManager>; ADCHPP_DLL static PluginManager* instance; - typedef vector<PluginInfo> PluginList; + typedef std::vector<PluginInfo> PluginList; typedef PluginList::iterator PluginIter; PluginList active; Registry registry; StringList plugins; - string pluginPath; + std::string pluginPath; int pluginIds; - static const string className; + static const std::string className; PluginManager() throw(); - bool loadPlugin(const string& file); + bool loadPlugin(const std::string& file); void onLoad(const SimpleXML& xml) throw(); }; Modified: adchpp/trunk/adchpp/Pool.h =================================================================== --- adchpp/trunk/adchpp/Pool.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Pool.h 2007-11-18 19:03:32 UTC (rev 92) @@ -64,7 +64,7 @@ private: size_t busy; - vector<T*> free; + std::vector<T*> free; }; Modified: adchpp/trunk/adchpp/ResourceManager.cpp =================================================================== --- adchpp/trunk/adchpp/ResourceManager.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/ResourceManager.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -26,6 +26,9 @@ namespace adchpp { +using namespace std; +using namespace std::tr1; + ResourceManager* ResourceManager::instance = 0; const string ResourceManager::className = "ResourceManager"; @@ -35,7 +38,7 @@ SimpleXML xml; xml.fromXML(f.read()); - std::tr1::unordered_map<string, int> h; + unordered_map<string, int> h; for(int i = 0; i < LAST; ++i) { h[names[i]] = i; @@ -47,7 +50,7 @@ xml.stepIn(); while(xml.findChild("String")) { - std::tr1::unordered_map<string, int>::iterator j = h.find(xml.getChildAttrib("Name")); + unordered_map<string, int>::iterator j = h.find(xml.getChildAttrib("Name")); if(j != h.end()) { strings[j->second] = xml.getChildData(); Modified: adchpp/trunk/adchpp/ResourceManager.h =================================================================== --- adchpp/trunk/adchpp/ResourceManager.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/ResourceManager.h 2007-11-18 19:03:32 UTC (rev 92) @@ -31,8 +31,8 @@ #include "StringDefs.h" - void loadLanguage(const string& aFile); - const string& getString(Strings x) const { return strings[x]; } + void loadLanguage(const std::string& aFile); + const std::string& getString(Strings x) const { return strings[x]; } private: @@ -43,10 +43,10 @@ ResourceManager() throw() { } virtual ~ResourceManager() throw() { } - ADCHPP_DLL static string strings[LAST]; - static string names[LAST]; + ADCHPP_DLL static std::string strings[LAST]; + static std::string names[LAST]; - static const string className; + static const std::string className; }; #define STRING(x) ResourceManager::getInstance()->getString(ResourceManager::x) Modified: adchpp/trunk/adchpp/SettingsManager.cpp =================================================================== --- adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -27,6 +27,8 @@ namespace adchpp { +using namespace std; + SettingsManager* SettingsManager::instance = 0; const string SettingsManager::className = "SettingsManager"; Modified: adchpp/trunk/adchpp/SettingsManager.h =================================================================== --- adchpp/trunk/adchpp/SettingsManager.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/SettingsManager.h 2007-11-18 19:03:32 UTC (rev 92) @@ -63,9 +63,9 @@ * Get the XML name of a setting * @param n Setting identifier */ - const string& getName(int n) { dcassert(n < SETTINGS_LAST); return settingTags[n]; } + const std::string& getName(int n) { dcassert(n < SETTINGS_LAST); return settingTags[n]; } - const string& get(StrSetting key) const { + const std::string& get(StrSetting key) const { return strSettings[key - STR_FIRST]; } @@ -80,7 +80,7 @@ return (get(key) > 0); } - void set(StrSetting key, string const& value) { + void set(StrSetting key, const std::string& value) { strSettings[key - STR_FIRST] = value; } @@ -109,7 +109,7 @@ load(Util::getCfgPath() + _T("adchpp.xml")); } - void load(const string& aFileName); + void load(const std::string& aFileName); typedef SignalTraits<void (const SimpleXML&)> SignalLoad; SignalLoad::Signal& signalLoad() { return signalLoad_; } @@ -120,12 +120,12 @@ SettingsManager() throw(); virtual ~SettingsManager() throw() { } - ADCHPP_DLL static const string settingTags[SETTINGS_LAST+1]; + ADCHPP_DLL static const std::string settingTags[SETTINGS_LAST+1]; - static const string className; + static const std::string className; - string strSettings[STR_LAST - STR_FIRST]; - int intSettings[INT_LAST - INT_FIRST]; + std::string strSettings[STR_LAST - STR_FIRST]; + int intSettings[INT_LAST - INT_FIRST]; int64_t int64Settings[/*INT64_LAST - INT64_FIRST*/1]; SignalLoad::Signal signalLoad_; Modified: adchpp/trunk/adchpp/Signal.h =================================================================== --- adchpp/trunk/adchpp/Signal.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Signal.h 2007-11-18 19:03:32 UTC (rev 92) @@ -26,7 +26,7 @@ template<typename F> struct Signal { typedef std::tr1::function<F> Slot; - typedef list<Slot> SlotList; + typedef std::list<Slot> SlotList; typedef typename SlotList::iterator Connection; typedef F FunctionType; Modified: adchpp/trunk/adchpp/SimpleXML.cpp =================================================================== --- adchpp/trunk/adchpp/SimpleXML.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/SimpleXML.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -22,6 +22,8 @@ namespace adchpp { +using namespace std; + SimpleXML::SimpleXML(int numAttribs) : attribs(numAttribs), found(false) { root = current = new Tag("BOGUSROOT", Util::emptyString, NULL); } Modified: adchpp/trunk/adchpp/SimpleXML.h =================================================================== --- adchpp/trunk/adchpp/SimpleXML.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/SimpleXML.h 2007-11-18 19:03:32 UTC (rev 92) @@ -36,34 +36,28 @@ ADCHPP_DLL SimpleXML(int numAttribs = 0); ADCHPP_DLL ~SimpleXML(); - ADCHPP_DLL void addTag(const string& aName, const string& aData = Util::emptyString) throw(SimpleXMLException); - void addTag(const string& aName, int aData) throw(SimpleXMLException) { + ADCHPP_DLL void addTag(const std::string& aName, const std::string& aData = Util::emptyString) throw(SimpleXMLException); + void addTag(const std::string& aName, int aData) throw(SimpleXMLException) { addTag(aName, Util::toString(aData)); } - void addTag(const string& aName, int64_t aData) throw(SimpleXMLException) { + void addTag(const std::string& aName, int64_t aData) throw(SimpleXMLException) { addTag(aName, Util::toString(aData)); } template<typename T> - void addAttrib(const string& aName, const T& aData) throw(SimpleXMLException) { + void addAttrib(const std::string& aName, const T& aData) throw(SimpleXMLException) { addAttrib(aName, Util::toString(aData)); } - ADCHPP_DLL void addAttrib(const string& aName, const string& aData) throw(SimpleXMLException); - void addAttrib(const string& aName, bool aData) throw(SimpleXMLException) { - addAttrib(aName, string(aData ? "1" : "0")); - } + ADCHPP_DLL void addAttrib(const std::string& aName, const std::string& aData) throw(SimpleXMLException); template <typename T> - void addChildAttrib(const string& aName, const T& aData) throw(SimpleXMLException) { + void addChildAttrib(const std::string& aName, const T& aData) throw(SimpleXMLException) { addChildAttrib(aName, Util::toString(aData)); } - ADCHPP_DLL void addChildAttrib(const string& aName, const string& aData) throw(SimpleXMLException); - void addChildAttrib(const string& aName, bool aData) throw(SimpleXMLException) { - addChildAttrib(aName, string(aData ? "1" : "0")); - } + ADCHPP_DLL void addChildAttrib(const std::string& aName, const std::string& aData) throw(SimpleXMLException); - const string& getData() const { + const std::string& getData() const { dcassert(current != NULL); return current->data; } @@ -77,53 +71,53 @@ currentChild = current->children.begin(); } - ADCHPP_DLL bool findChild(const string& aName) const throw(); + ADCHPP_DLL bool findChild(const std::string& aName) const throw(); - const string& getChildData() const throw(SimpleXMLException) { + const std::string& getChildData() const throw(SimpleXMLException) { checkChildSelected(); return (*currentChild)->data; } - const string& getChildAttrib(const string& aName, const string& aDefault = Util::emptyString) const throw(SimpleXMLException) { + const std::string& getChildAttrib(const std::string& aName, const std::string& aDefault = Util::emptyString) const throw(SimpleXMLException) { checkChildSelected(); return (*currentChild)->getAttrib(aName, aDefault); } - int getIntChildAttrib(const string& aName) throw(SimpleXMLException) { + int getIntChildAttrib(const std::string& aName) throw(SimpleXMLException) { checkChildSelected(); return Util::toInt(getChildAttrib(aName)); } - int64_t getLongLongChildAttrib(const string& aName) throw(SimpleXMLException) { + int64_t getLongLongChildAttrib(const std::string& aName) throw(SimpleXMLException) { checkChildSelected(); return Util::toInt64(getChildAttrib(aName)); } - bool getBoolChildAttrib(const string& aName) throw(SimpleXMLException) { + bool getBoolChildAttrib(const std::string& aName) throw(SimpleXMLException) { checkChildSelected(); - const string& tmp = getChildAttrib(aName); + const std::string& tmp = getChildAttrib(aName); return (tmp.size() > 0) && tmp[0] == '1'; } - ADCHPP_DLL void fromXML(const string& aXML) throw(SimpleXMLException); - string toXML() { return (!root->children.empty()) ? root->children[0]->toXML(0) : Util::emptyString; } + ADCHPP_DLL void fromXML(const std::string& aXML) throw(SimpleXMLException); + std::string toXML() { return (!root->children.empty()) ? root->children[0]->toXML(0) : Util::emptyString; } - ADCHPP_DLL static void escape(string& aString, bool aAttrib, bool aLoading = false); + ADCHPP_DLL static void escape(std::string& aString, bool aAttrib, bool aLoading = false); /** * This is a heurestic for whether escape needs to be called or not. The results are * only guaranteed for false, i e sometimes true might be returned even though escape * was not needed... */ - static bool needsEscape(const string& aString, bool aAttrib, bool aLoading = false) { - return ((aLoading) ? aString.find('&') : aString.find_first_of(aAttrib ? "<&>'\"" : "<&>")) != string::npos; + static bool needsEscape(const std::string& aString, bool aAttrib, bool aLoading = false) { + return ((aLoading) ? aString.find('&') : aString.find_first_of(aAttrib ? "<&>'\"" : "<&>")) != std::string::npos; } private: class Tag { public: typedef Tag* Ptr; - typedef vector<Ptr> List; + typedef std::vector<Ptr> List; typedef List::iterator Iter; - typedef pair<string,string> StringPair; - typedef vector<StringPair> AttribMap; + typedef std::pair<std::string, std::string> StringPair; + typedef std::vector<StringPair> AttribMap; typedef AttribMap::iterator AttribIter; /** @@ -139,29 +133,29 @@ AttribMap attribs; /** Tag name */ - string name; + std::string name; /** Tag data, may be empty. */ - string data; + std::string data; /** Parent tag, for easy traversal */ Ptr parent; - Tag(const string& aName, const string& aData, Ptr aParent, int numAttribs = 0) : name(aName), data(aData), parent(aParent) { + Tag(const std::string& aName, const std::string& aData, Ptr aParent, int numAttribs = 0) : name(aName), data(aData), parent(aParent) { if(numAttribs > 0) attribs.reserve(numAttribs); } - const string& getAttrib(const string& aName, const string& aDefault = Util::emptyString) { - AttribIter i = find_if(attribs.begin(), attribs.end(), CompareFirst<string,string>(aName)); + const std::string& getAttrib(const std::string& aName, const std::string& aDefault = Util::emptyString) { + AttribIter i = find_if(attribs.begin(), attribs.end(), CompareFirst<std::string, std::string>(aName)); return (i == attribs.end()) ? aDefault : i->second; } - ADCHPP_DLL string toXML(int indent); + ADCHPP_DLL std::string toXML(int indent); - string::size_type fromXML(const string& tmp, string::size_type start, int aa, bool isRoot = false) throw(SimpleXMLException); - string::size_type loadAttribs(const string& tmp, string::size_type start) throw(SimpleXMLException); + std::string::size_type fromXML(const std::string& tmp, std::string::size_type start, int aa, bool isRoot = false) throw(SimpleXMLException); + std::string::size_type loadAttribs(const std::string& tmp, std::string::size_type start) throw(SimpleXMLException); - void appendAttribString(string& tmp); + void appendAttribString(std::string& tmp); /** Delete all children! */ ~Tag() { for(Iter i = children.begin(); i != children.end(); ++i) { Modified: adchpp/trunk/adchpp/Socket.cpp =================================================================== --- adchpp/trunk/adchpp/Socket.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Socket.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -21,7 +21,9 @@ #include "Socket.h" namespace adchpp { - + +using namespace std; + string SocketException::errorToString(int aError) throw() { return Util::translateError(aError); } Modified: adchpp/trunk/adchpp/Socket.h =================================================================== --- adchpp/trunk/adchpp/Socket.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Socket.h 2007-11-18 19:03:32 UTC (rev 92) @@ -80,7 +80,7 @@ virtual ~SocketException() throw() { } private: int err; - static string errorToString(int aError) throw(); + static std::string errorToString(int aError) throw(); }; class Socket @@ -99,21 +99,21 @@ }; Socket() throw(SocketException) : sock(INVALID_SOCKET) { } - Socket(const string& aIp, const string& aPort) throw(SocketException) : sock(INVALID_SOCKET) { connect(aIp, aPort); } - Socket(const string& aIp, short aPort) throw(SocketException) : sock(INVALID_SOCKET) { connect(aIp, aPort); } + Socket(const std::string& aIp, const std::string& aPort) throw(SocketException) : sock(INVALID_SOCKET) { connect(aIp, aPort); } + Socket(const std::string& aIp, short aPort) throw(SocketException) : sock(INVALID_SOCKET) { connect(aIp, aPort); } virtual ~Socket() throw() { disconnect(); } virtual void create(int aType = TYPE_TCP) throw(SocketException); virtual void bind(short aPort) throw(SocketException); - virtual void connect(const string& aIp, short aPort) throw(SocketException); - void connect(const string& aIp, const string& aPort) throw(SocketException) { connect(aIp, (short)Util::toInt(aPort)); } - virtual string accept(const Socket& aSocket) throw(SocketException); + virtual void connect(const std::string& aIp, short aPort) throw(SocketException); + void connect(const std::string& aIp, const std::string& aPort) throw(SocketException) { connect(aIp, (short)Util::toInt(aPort)); } + virtual std::string accept(const Socket& aSocket) throw(SocketException); virtual void write(const char* aBuffer, size_t aLen) throw(SocketException); - void write(const string& aData) throw(SocketException) { write(aData.data(), aData.length()); } + void write(const std::string& aData) throw(SocketException) { write(aData.data(), aData.length()); } virtual int writeNB(const char* aBuffer, size_t aLen) throw(SocketException); - int writeNB(const string& aData) throw(SocketException) { return writeNB(aData.data(), aData.length()); } - virtual void writeTo(const string& aIp, short aPort, const char* aBuffer, size_t aLen) throw(SocketException); - void writeTo(const string& aIp, short aPort, const string& aData) throw(SocketException) { writeTo(aIp, aPort, aData.data(), aData.length()); } + int writeNB(const std::string& aData) throw(SocketException) { return writeNB(aData.data(), aData.length()); } + virtual void writeTo(const std::string& aIp, short aPort, const char* aBuffer, size_t aLen) throw(SocketException); + void writeTo(const std::string& aIp, short aPort, const std::string& aData) throw(SocketException) { writeTo(aIp, aPort, aData.data(), aData.length()); } virtual void disconnect() throw(); void listen(short aPort) throw(SocketException); @@ -123,7 +123,7 @@ int read(void* aBuffer, size_t aBufLen) throw(SocketException); int wait(uint32_t millis, int waitFor) throw(SocketException); - static string resolve(const string& aDns); + static std::string resolve(const std::string& aDns); int getAvailable() { u_long i = 0; @@ -143,7 +143,7 @@ } #endif - string getLocalIp() throw(); + std::string getLocalIp() throw(); int getLocalPort() throw(); socket_t getSocket() { return sock; } Modified: adchpp/trunk/adchpp/SocketManager.cpp =================================================================== --- adchpp/trunk/adchpp/SocketManager.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/SocketManager.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -37,6 +37,9 @@ #endif namespace adchpp { + +using namespace std; + static uint32_t WRITE_TIMEOUT = 100; #ifdef _WIN32 Modified: adchpp/trunk/adchpp/SocketManager.h =================================================================== --- adchpp/trunk/adchpp/SocketManager.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/SocketManager.h 2007-11-18 19:03:32 UTC (rev 92) @@ -49,7 +49,7 @@ virtual int run(); - typedef vector<Callback> ProcessQueue; + typedef std::vector<Callback> ProcessQueue; FastMutex processCS; @@ -58,9 +58,9 @@ Semaphore processSem; - auto_ptr<Writer> writer; + std::auto_ptr<Writer> writer; - static const string className; + static const std::string className; friend class Singleton<SocketManager>; ADCHPP_DLL static SocketManager* instance; Modified: adchpp/trunk/adchpp/StringDefs.cpp =================================================================== --- adchpp/trunk/adchpp/StringDefs.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/StringDefs.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -1,6 +1,7 @@ #include "adchpp.h" #include "ResourceManager.h" namespace adchpp { +using namespace std; string ResourceManager::strings[] = { "B", "CID taken", Modified: adchpp/trunk/adchpp/StringDefs.h =================================================================== --- adchpp/trunk/adchpp/StringDefs.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/StringDefs.h 2007-11-18 19:03:32 UTC (rev 92) @@ -1,6 +1,7 @@ // @Prolog: #include "adchpp.h" // @Prolog: #include "ResourceManager.h" // @Prolog: namespace adchpp { +// @Prolog: using namespace std; // @Strings: string ResourceManager::strings[] // @Names: string ResourceManager::names[] Modified: adchpp/trunk/adchpp/TigerHash.cpp =================================================================== --- adchpp/trunk/adchpp/TigerHash.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/TigerHash.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -23,6 +23,7 @@ namespace adchpp { +using namespace std; #define PASSES 3 Modified: adchpp/trunk/adchpp/Util.cpp =================================================================== --- adchpp/trunk/adchpp/Util.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Util.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -35,6 +35,8 @@ namespace adchpp { +using namespace std; + intrusive_ptr_base::~intrusive_ptr_base() { } Modified: adchpp/trunk/adchpp/Util.h =================================================================== --- adchpp/trunk/adchpp/Util.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/Util.h 2007-11-18 19:03:32 UTC (rev 92) @@ -56,22 +56,22 @@ } /** Evaluates op(pair<T1, T2>.first, compareTo) */ -template<class T1, class T2, class op = equal_to<T1> > +template<class T1, class T2, class op = std::equal_to<T1> > class CompareFirst { public: CompareFirst(const T1& compareTo) : a(compareTo) { } - bool operator()(const pair<T1, T2>& p) { return op()(p.first, a); } + bool operator()(const std::pair<T1, T2>& p) { return op()(p.first, a); } private: CompareFirst& operator=(const CompareFirst&); const T1& a; }; /** Evaluates op(pair<T1, T2>.second, compareTo) */ -template<class T1, class T2, class op = equal_to<T2> > +template<class T1, class T2, class op = std::equal_to<T2> > class CompareSecond { public: CompareSecond(const T2& compareTo) : a(compareTo) { } - bool operator()(const pair<T1, T2>& p) { return op()(p.second, a); } + bool operator()(const std::pair<T1, T2>& p) { return op()(p.second, a); } private: CompareSecond& operator=(const CompareSecond&); const T2& a; @@ -179,56 +179,56 @@ ADCHPP_DLL static size_t reasons[REASON_LAST]; - ADCHPP_DLL static string emptyString; + ADCHPP_DLL static std::string emptyString; - ADCHPP_DLL static void initialize(const string& configPath); - ADCHPP_DLL static string getOsVersion(); - ADCHPP_DLL static void decodeUrl(const string& aUrl, string& aServer, short& aPort, string& aFile); - ADCHPP_DLL static string formatTime(const string& msg, time_t t = time(NULL)); + ADCHPP_DLL static void initialize(const std::string& configPath); + ADCHPP_DLL static std::string getOsVersion(); + ADCHPP_DLL static void decodeUrl(const std::string& aUrl, std::string& aServer, short& aPort, std::string& aFile); + ADCHPP_DLL static std::string formatTime(const std::string& msg, time_t t = time(NULL)); - static const string& getCfgPath() { return cfgPath; } - static void setCfgPath(const string& path) { cfgPath = path; } + static const std::string& getCfgPath() { return cfgPath; } + static void setCfgPath(const std::string& path) { cfgPath = path; } - ADCHPP_DLL static string getAppPath(); - ADCHPP_DLL static string getAppName(); + ADCHPP_DLL static std::string getAppPath(); + ADCHPP_DLL static std::string getAppName(); #ifndef _WIN32 - ADCHPP_DLL static void setApp(const string& app); - static string appPath; - static string appName; + ADCHPP_DLL static void setApp(const std::string& app); + static std::string appPath; + static std::string appName; #endif - ADCHPP_DLL static string translateError(int aError); + ADCHPP_DLL static std::string translateError(int aError); - ADCHPP_DLL static string toAcp(const wstring& wString); - static const string& toAcp(const string& wString) { return wString; } - static string& toAcp(string& wString) { return wString; } + ADCHPP_DLL static std::string toAcp(const std::wstring& wString); + static const std::string& toAcp(const std::string& wString) { return wString; } + static std::string& toAcp(std::string& wString) { return wString; } - ADCHPP_DLL static wstring toUnicode(const string& aString); - static const wstring& toUnicode(const wstring& aString) { return aString; } - static wstring& toUnicode(wstring& aString) { return aString; } + ADCHPP_DLL static std::wstring toUnicode(const std::string& aString); + static const std::wstring& toUnicode(const std::wstring& aString) { return aString; } + static std::wstring& toUnicode(std::wstring& aString) { return aString; } - static string formatBytes(const string& aString) { return formatBytes(toInt64(aString)); } + static std::string formatBytes(const std::string& aString) { return formatBytes(toInt64(aString)); } - ADCHPP_DLL static string getShortTimeString(); - ADCHPP_DLL static string getTimeString(); + ADCHPP_DLL static std::string getShortTimeString(); + ADCHPP_DLL static std::string getTimeString(); - ADCHPP_DLL static string formatBytes(int64_t aBytes); + ADCHPP_DLL static std::string formatBytes(int64_t aBytes); - ADCHPP_DLL static void tokenize(StringList& lst, const string& str, char sep, string::size_type j = 0); + ADCHPP_DLL static void tokenize(StringList& lst, const std::string& str, char sep, std::string::size_type j = 0); - static string formatSeconds(int64_t aSec) { + static std::string formatSeconds(int64_t aSec) { char buf[64]; sprintf(buf, "%01d:%02d:%02d:%02d", (int)(aSec / (24*60*60)), (int)((aSec / (60*60)) % 24), (int)((aSec / 60) % 60), (int)(aSec % 60)); return buf; } - static bool toBool(const string& aString) { return toBool(aString.c_str()); } - static int toInt(const string& aString) { return toInt(aString.c_str()); } - static double toDouble(const string& aString) { return toDouble(aString.c_str()); } - static float toFloat(const string& aString) { return toFloat(aString.c_str()); } - static int64_t toInt64(const string& aString) { return toInt64(aString.c_str()); } + static bool toBool(const std::string& aString) { return toBool(aString.c_str()); } + static int toInt(const std::string& aString) { return toInt(aString.c_str()); } + static double toDouble(const std::string& aString) { return toDouble(aString.c_str()); } + static float toFloat(const std::string& aString) { return toFloat(aString.c_str()); } + static int64_t toInt64(const std::string& aString) { return toInt64(aString.c_str()); } static bool toBool(const char* aString) { return toInt(aString) > 0; } static int toInt(const char* aString) { return ::atoi(aString); } @@ -242,37 +242,41 @@ #endif } - static string toString(short val) { + static std::string toString(bool val) { + return val ? "1" : "0"; + } + + static std::string toString(short val) { char buf[8]; sprintf(buf, "%d", (int)val); return buf; } - static string toString(unsigned short val) { + static std::string toString(unsigned short val) { char buf[8]; sprintf(buf, "%u", (unsigned int)val); return buf; } - static string toString(int val) { + static std::string toString(int val) { char buf[16]; sprintf(buf, "%d", val); return buf; } - static string toString(unsigned int val) { + static std::string toString(unsigned int val) { char buf[16]; sprintf(buf, "%u", val); return buf; } - static string toString(long val) { + static std::string toString(long val) { char buf[32]; sprintf(buf, "%ld", val); return buf; } - static string toString(unsigned long val) { + static std::string toString(unsigned long val) { char buf[32]; sprintf(buf, "%lu", val); return buf; } - static string toString(long long val) { + static std::string toString(long long val) { char buf[32]; #ifdef _MSC_VER sprintf(buf, "%I64d", val); @@ -281,7 +285,7 @@ #endif return buf; } - static string toString(unsigned long long val) { + static std::string toString(unsigned long long val) { char buf[32]; #ifdef _MSC_VER sprintf(buf, "%I64u", val); @@ -291,18 +295,18 @@ return buf; } - static string toString(double val, int maxDec = 2) { + static std::string toString(double val, int maxDec = 2) { char buf[32]; sprintf(buf, "%.*f", maxDec, val); return buf; } - static const string& toString(const string& aString) { + static const std::string& toString(const std::string& aString) { return aString; } /** Avoid this! Use the one of a connected socket instead... */ - ADCHPP_DLL static string getLocalIp(); + ADCHPP_DLL static std::string getLocalIp(); struct Clear { void operator()(ByteVector& x); @@ -316,7 +320,7 @@ static double randd() { return ((double)rand()) / ((double)0xffffffff); } private: - ADCHPP_DLL static string cfgPath; + ADCHPP_DLL static std::string cfgPath; }; } Modified: adchpp/trunk/adchpp/adchpp.cpp =================================================================== --- adchpp/trunk/adchpp/adchpp.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/adchpp.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -27,7 +27,9 @@ #include "SettingsManager.h" namespace adchpp { - + +using namespace std; + const char compileTime[] = __DATE__ " " __TIME__; static bool initialized = false; Modified: adchpp/trunk/adchpp/adchpp.h =================================================================== --- adchpp/trunk/adchpp/adchpp.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/adchpp.h 2007-11-18 19:03:32 UTC (rev 92) @@ -111,8 +111,9 @@ #endif -#include <cerrno> -#include <cstdarg> +#include <errno.h> +#include <stdarg.h> +#include <stddef.h> #include <string> #include <vector> @@ -140,12 +141,6 @@ #include <boost/intrusive_ptr.hpp> #include <boost/noncopyable.hpp> -namespace adchpp { - -using namespace std; - -} - #ifdef _UNICODE # ifndef _T # define _T(s) L##s Modified: adchpp/trunk/adchpp/common.h =================================================================== --- adchpp/trunk/adchpp/common.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/common.h 2007-11-18 19:03:32 UTC (rev 92) @@ -102,7 +102,7 @@ /** * Initialize configuration. */ -ADCHPP_DLL void initialize(const string& path); +ADCHPP_DLL void initialize(const std::string& path); /** * Load plugins and start listening for incoming connections Modified: adchpp/trunk/adchpp/version.cpp =================================================================== --- adchpp/trunk/adchpp/version.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/version.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -21,9 +21,11 @@ #define FULLVERSIONSTRING APPNAME " v" VERSIONSTRING "-" BUILDSTRING namespace adchpp { + +using namespace std; + +string appName = APPNAME; +string versionString = FULLVERSIONSTRING; +float versionFloat = VERSIONFLOAT; - string appName = APPNAME; - string versionString = FULLVERSIONSTRING; - float versionFloat = VERSIONFLOAT; - } Modified: adchpp/trunk/adchpp/version.h =================================================================== --- adchpp/trunk/adchpp/version.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/adchpp/version.h 2007-11-18 19:03:32 UTC (rev 92) @@ -20,8 +20,8 @@ #define ADCHPP_VERSION_H namespace adchpp { - ADCHPP_DLL extern string appName; - ADCHPP_DLL extern string versionString; + ADCHPP_DLL extern std::string appName; + ADCHPP_DLL extern std::string versionString; ADCHPP_DLL extern float versionFloat; } Modified: adchpp/trunk/plugins/Script/src/Engine.h =================================================================== --- adchpp/trunk/plugins/Script/src/Engine.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/plugins/Script/src/Engine.h 2007-11-18 19:03:32 UTC (rev 92) @@ -27,10 +27,10 @@ public: virtual ~Engine() { } - virtual Script* loadScript(const string& path, const string& filename, const ParameterMap& parameters) = 0; + virtual Script* loadScript(const std::string& path, const std::string& filename, const ParameterMap& parameters) = 0; virtual void unloadScript(Script* script) = 0; - virtual void getStats(string& str) const = 0; + virtual void getStats(std::string& str) const = 0; private: }; Modified: adchpp/trunk/plugins/Script/src/LuaEngine.cpp =================================================================== --- adchpp/trunk/plugins/Script/src/LuaEngine.cpp 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/plugins/Script/src/LuaEngine.cpp 2007-11-18 19:03:32 UTC (rev 92) @@ -22,8 +22,13 @@ #include "LuaScript.h" #include <adchpp/Util.h> + +extern "C" { #include <lua.h> +} +using namespace std; + LuaEngine::LuaEngine() { } Modified: adchpp/trunk/plugins/Script/src/LuaEngine.h =================================================================== --- adchpp/trunk/plugins/Script/src/LuaEngine.h 2007-11-18 17:13:18 UTC (rev 91) +++ adchpp/trunk/plugins/Script/src/LuaEngine.h 2007-11-18 19:03:32 UTC (rev 92) @@ -28,11 +28,11 @@ LuaEngine(); virtual ~LuaEngine(); - virtual Script* loadScript(const string& path, const string& filename, const ParameterMap& parameters); + virtual Script* loadScript(const std::string& path, const std::string& filename, const ParameterMap& parameters); virtual void unloadScri... [truncated message content] |
From: <arn...@us...> - 2007-11-18 17:13:23
|
Revision: 91 http://adchpp.svn.sourceforge.net/adchpp/?rev=91&view=rev Author: arnetheduck Date: 2007-11-18 09:13:18 -0800 (Sun, 18 Nov 2007) Log Message: ----------- init cleanup, clienttype field Modified Paths: -------------- adchpp/trunk/adchpp/Client.cpp adchpp/trunk/adchpp/Client.h adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/ClientManager.h adchpp/trunk/adchpp/SettingsManager.cpp adchpp/trunk/adchpp/SettingsManager.h adchpp/trunk/adchpp/Util.h adchpp/trunk/adchpp/adchpp.cpp adchpp/trunk/adchpp/common.h adchpp/trunk/swig/SConscript adchpp/trunk/swig/adchpp.i adchpp/trunk/unix/main.cpp Modified: adchpp/trunk/adchpp/Client.cpp =================================================================== --- adchpp/trunk/adchpp/Client.cpp 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/Client.cpp 2007-11-18 17:13:18 UTC (rev 91) @@ -89,7 +89,7 @@ return (i != psd.end()) ? i->second : 0; } -void Client::onData(const vector<uint8_t>& data) throw() { +void Client::onData(const ByteVector& data) throw() { dcdebug("In (%d): %.*s\n", data.size(), data.size(), &data[0]); size_t done = 0; @@ -164,6 +164,7 @@ cmd.addParam(string((char*)&i->first, 2)); return !changed.empty(); } + bool Client::getAllFields(AdcCommand& cmd) const throw() { for(InfMap::const_iterator i = info.begin(); i != info.end(); ++i) cmd.addParam(string((char*)&i->first, 2), i->second); @@ -184,7 +185,7 @@ for(StringIterC j = cmd.getParameters().begin(); j != cmd.getParameters().end(); ++j) { if(j->size() < 2) continue; - setField(j->substr(0, 2).c_str(), j->substr(2)); + setField(j->c_str(), j->substr(2)); } } @@ -251,4 +252,18 @@ delete this; } +void Client::setFlag(size_t flag) { + flags.setFlag(flag); + if(flag & MASK_CLIENT_TYPE) { + setField("CT", Util::toString(flags.getFlags() & MASK_CLIENT_TYPE)); + } } + +void Client::unsetFlag(size_t flag) { + flags.setFlag(flag); + if(flag & MASK_CLIENT_TYPE) { + setField("CT", Util::toString(flags.getFlags() & MASK_CLIENT_TYPE)); + } +} + +} Modified: adchpp/trunk/adchpp/Client.h =================================================================== --- adchpp/trunk/adchpp/Client.h 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/Client.h 2007-11-18 17:13:18 UTC (rev 91) @@ -31,7 +31,7 @@ /** * The client represents one connection to a user. */ -class Client : public Flags, public FastAlloc<Client>, public boost::noncopyable { +class Client : public FastAlloc<Client>, public boost::noncopyable { public: enum State { /** Initial protocol negotiation (wait for SUP) */ @@ -48,17 +48,18 @@ enum { FLAG_BOT = 0x01, - FLAG_OP = 0x02, - FLAG_PASSWORD = 0x04, - FLAG_HIDDEN = 0x08, + FLAG_REGISTERED = 0x02, + FLAG_OP = 0x04, + FLAG_OWNER = 0x08, FLAG_HUB = 0x10, + MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_OWNER | FLAG_HUB, + FLAG_PASSWORD = 0x100, + FLAG_HIDDEN = 0x101, /** Extended away, no need to send msg */ - FLAG_EXT_AWAY = 0x20, + FLAG_EXT_AWAY = 0x102, /** Plugins can use these flags to disable various checks */ - /** Bypass max users count */ - FLAG_OK_COUNT = 0x80, /** Bypass ip check */ - FLAG_OK_IP = 0x100 + FLAG_OK_IP = 0x104 }; static Client* create(const ManagedSocketPtr& ms_) throw(); @@ -112,6 +113,11 @@ ADCHPP_DLL bool isFlooding(time_t addSeconds); + bool isSet(size_t aFlag) const { return flags.isSet(aFlag); } + bool isAnySet(size_t aFlag) const { return flags.isAnySet(aFlag); } + void setFlag(size_t aFlag); + void unsetFlag(size_t aFlag); + /** * Set PSD (plugin specific data). This allows a plugin to store arbitrary * per-client data, and retrieve it later on. Each plugin is only allowed @@ -153,6 +159,8 @@ InfMap info; InfMap changed; + + Flags flags; CID cid; uint32_t sid; Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-11-18 17:13:18 UTC (rev 91) @@ -118,6 +118,7 @@ .addParam("DE", SETTING(DESCRIPTION)) .addParam("VE", versionString) .addParam("CT5") + .addParam("HU1") // ADC <=0.13 .toString(); } @@ -203,14 +204,14 @@ signalBadLine_(c, aLine); } -void ClientManager::badState(Client& c) throw() { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_BAD_STATE, "Invalid state for command")); +void ClientManager::badState(Client& c, const AdcCommand& cmd) throw() { + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_BAD_STATE, "Invalid state for command").addParam("FC", cmd.toString().substr(0, 4))); c.disconnect(Util::REASON_BAD_STATE); } -bool ClientManager::handleDefault(Client& c, AdcCommand&) throw() { +bool ClientManager::handleDefault(Client& c, AdcCommand& cmd) throw() { if(c.getState() != Client::STATE_NORMAL) { - badState(c); + badState(c, cmd); return false; } return true; @@ -224,7 +225,7 @@ if(c.getState() == Client::STATE_PROTOCOL) { enterIdentify(c, true); } else if(c.getState() != Client::STATE_NORMAL) { - badState(c); + badState(c, cmd); return false; } return true; @@ -232,10 +233,25 @@ bool ClientManager::verifySUP(Client& c, AdcCommand& cmd) throw() { c.updateSupports(cmd); - if(!c.supports("BASE") && !c.supports("BAS0")) { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "This hub requires BASE support")); - c.disconnect(Util::REASON_NO_BASE_SUPPORT); + if(!c.supports("BASE")) { + if(COMPATIBILITY && c.supports("BAS0")) { + c.send(AdcCommand(AdcCommand::CMD_MSG).addParam("Your client only supports an experimental version of ADC, please upgrade as soon as possible as you will not be able to connect in the future")); + } else { + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "This hub requires BASE support")); + c.disconnect(Util::REASON_NO_BASE_SUPPORT); + } } + + if(c.supports("BASE") && !c.supports("TIGR")) { + if(COMPATIBILITY) { + // ADC <= 0.13 + c.send(AdcCommand(AdcCommand::CMD_MSG).addParam("Your client claims to support BASE but not TIGR, please upgrade as soon as possible")); + } else { + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "This hub requires TIGR support")); + c.disconnect(Util::REASON_NO_TIGR_SUPPORT); + } + } + return true; } @@ -249,9 +265,6 @@ if(!verifyNick(c, cmd)) return false; - if(!verifyUsers(c)) - return false; - c.updateFields(cmd); return true; } @@ -265,6 +278,9 @@ if(memcmp(tiger.finalize(), tmp, TigerHash::HASH_SIZE) == 0) return true; + if(!COMPATIBILITY) + return false; + TigerHash tiger2; // Support dc++ 0.69 for a while string cid = c.getCID().toBase32(); @@ -280,7 +296,7 @@ bool ClientManager::handle(AdcCommand::INF, Client& c, AdcCommand& cmd) throw() { if(c.getState() != Client::STATE_IDENTIFY && c.getState() != Client::STATE_NORMAL) { - badState(c); + badState(c, cmd); return false; } @@ -366,7 +382,7 @@ } if(cmd.getParam("PD", 0, strtmp)) { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "PD but no ID")); + c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "CID required when sending PID")); c.disconnect(Util::REASON_PID_WITHOUT_CID); return false; } @@ -374,7 +390,6 @@ } bool ClientManager::verifyNick(Client& c, const AdcCommand& cmd) throw() { - if(cmd.getParam("NI", 0, strtmp)) { dcdebug("%s verifying nick\n", AdcCommand::fromSID(c.getSID()).c_str()); for(string::size_type i = 0; i < strtmp.length(); ++i) { @@ -406,24 +421,6 @@ signalState_(c, oldState); } -bool ClientManager::verifyUsers(Client& c) throw() { - if(c.isSet(Client::FLAG_OK_COUNT)) - return true; - dcdebug("%s verifying user count\n", AdcCommand::fromSID(c.getSID()).c_str()); - - if(SETTING(MAX_USERS) > 0 && clients.size() >= (size_t)SETTING(MAX_USERS)) { - if(BOOLSETTING(REDIRECT_FULL)) { - c.send(AdcCommand(AdcCommand::CMD_QUI).addParam("RD", SETTING(REDIRECT_SERVER)).addParam("MS", STRING(HUB_FULL))); - } else { - c.send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_HUB_FULL, STRING(HUB_FULL))); - } - c.disconnect(Util::REASON_HUB_FULL); - return false; - } - c.setFlag(Client::FLAG_OK_COUNT); - return true; -} - void ClientManager::enterIdentify(Client& c, bool sendData) throw() { dcassert(c.getState() == Client::STATE_PROTOCOL); dcdebug("%s entering IDENTIFY\n", AdcCommand::fromSID(c.getSID()).c_str()); Modified: adchpp/trunk/adchpp/ClientManager.h =================================================================== --- adchpp/trunk/adchpp/ClientManager.h 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/ClientManager.h 2007-11-18 17:13:18 UTC (rev 91) @@ -136,11 +136,11 @@ */ ADCHPP_DLL bool verifyIp(Client& c, AdcCommand& cmd) throw(); + /** + * Verify that CID is correct and corresponds to PID + */ ADCHPP_DLL bool verifyCID(Client& c, AdcCommand& cmd) throw(); - /** Verify the number of connected clients */ - ADCHPP_DLL bool verifyUsers(Client& c) throw(); - /** Update the state of c (this fires signalState as well) */ ADCHPP_DLL void setState(Client& c, Client::State newState) throw(); @@ -219,7 +219,7 @@ void onBadLine(Client&, const string&) throw(); void onFailed(Client&) throw(); - void badState(Client& c) throw(); + void badState(Client& c, const AdcCommand& cmd) throw(); SignalConnected::Signal signalConnected_; SignalReceive::Signal signalReceive_; Modified: adchpp/trunk/adchpp/SettingsManager.cpp =================================================================== --- adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/SettingsManager.cpp 2007-11-18 17:13:18 UTC (rev 91) @@ -34,11 +34,11 @@ { // Strings "HubName", "ServerIp", "LogFile", "Description", - "LanguageFile", "RedirectServer", + "LanguageFile", "SENTRY", // Ints - "ServerPort", "Log", "MaxUsers", "KeepSlowUsers", - "MaxSendSize", "MaxBufferSize", "BufferSize", "MaxCommandSize", "RedirectFull", + "ServerPort", "Log", "KeepSlowUsers", + "MaxSendSize", "MaxBufferSize", "BufferSize", "MaxCommandSize", "OverflowTimeout", "DisconnectTimeout", "FloodAdd", "FloodThreshold", "LoginTimeout", "SENTRY", @@ -56,16 +56,13 @@ set(LOG_FILE, "logs/adchpp%Y%m.log"); set(DESCRIPTION, versionString); // set(LANGUAGE_FILE, "Example.adchpp.xml"); - // set(REDIRECT_SERVER, ""); set(SERVER_PORT, 2780); set(LOG, 1); - set(MAX_USERS, 0); set(KEEP_SLOW_USERS, 0); set(MAX_SEND_SIZE, 1400); set(MAX_BUFFER_SIZE, 16384); set(BUFFER_SIZE, 256); set(MAX_COMMAND_SIZE, 16384); - set(REDIRECT_FULL, 0); set(OVERFLOW_TIMEOUT, 60*1000); set(DISCONNECT_TIMEOUT, 5*1000); set(FLOOD_ADD, 1); Modified: adchpp/trunk/adchpp/SettingsManager.h =================================================================== --- adchpp/trunk/adchpp/SettingsManager.h 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/SettingsManager.h 2007-11-18 17:13:18 UTC (rev 91) @@ -37,12 +37,12 @@ enum StrSetting { STR_FIRST, HUB_NAME = STR_FIRST, SERVER_IP, LOG_FILE, DESCRIPTION, - LANGUAGE_FILE, REDIRECT_SERVER, + LANGUAGE_FILE, STR_LAST }; enum IntSetting { INT_FIRST = STR_LAST + 1, - SERVER_PORT = INT_FIRST, LOG, MAX_USERS, KEEP_SLOW_USERS, - MAX_SEND_SIZE, MAX_BUFFER_SIZE, BUFFER_SIZE, MAX_COMMAND_SIZE, REDIRECT_FULL, + SERVER_PORT = INT_FIRST, LOG, KEEP_SLOW_USERS, + MAX_SEND_SIZE, MAX_BUFFER_SIZE, BUFFER_SIZE, MAX_COMMAND_SIZE, OVERFLOW_TIMEOUT, DISCONNECT_TIMEOUT, FLOOD_ADD, FLOOD_THRESHOLD, LOGIN_TIMEOUT, INT_LAST }; Modified: adchpp/trunk/adchpp/Util.h =================================================================== --- adchpp/trunk/adchpp/Util.h 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/Util.h 2007-11-18 17:13:18 UTC (rev 91) @@ -109,11 +109,12 @@ class Flags { public: - typedef int MaskType; + typedef size_t MaskType; Flags() : flags(0) { } Flags(const Flags& rhs) : flags(rhs.flags) { } Flags(MaskType f) : flags(f) { } + MaskType getFlags() const { return flags; } bool isSet(MaskType aFlag) const { return (flags & aFlag) == aFlag; } bool isAnySet(MaskType aFlag) const { return (flags & aFlag) != 0; } void setFlag(MaskType aFlag) { flags |= aFlag; } @@ -166,6 +167,7 @@ REASON_NICK_INVALID, REASON_NICK_TAKEN, REASON_NO_BASE_SUPPORT, + REASON_NO_TIGR_SUPPORT, REASON_PID_MISSING, REASON_PID_CID_LENGTH, REASON_PID_CID_MISMATCH, Modified: adchpp/trunk/adchpp/adchpp.cpp =================================================================== --- adchpp/trunk/adchpp/adchpp.cpp 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/adchpp.cpp 2007-11-18 17:13:18 UTC (rev 91) @@ -30,7 +30,14 @@ const char compileTime[] = __DATE__ " " __TIME__; -void initConfig(const string& configPath) { +static bool initialized = false; +static bool running = false; + +void initialize(const string& configPath) { + if(initialized) { + throw Exception("Already initialized"); + } + #ifdef _WIN32 WSADATA wsaData; WSAStartup(MAKEWORD(2, 2), &wsaData); @@ -47,9 +54,13 @@ PluginManager::newInstance(); SettingsManager::getInstance()->load(); + initialized = true; } void startup(void (*f)()) { + if(!initialized) { + throw Exception("adchpp not initialized"); + } /* if(!SETTING(LANGUAGE_FILE).empty()) { if(File::isAbsolutePath(SETTING(LANGUAGE_FILE))) { ResourceManager::getInstance()->loadLanguage(SETTING(LANGUAGE_FILE)); @@ -62,12 +73,21 @@ if(f) f(); ClientManager::getInstance()->startup(); + if(f) f(); SocketManager::getInstance()->startup(); if(f) f(); PluginManager::getInstance()->load(); + if(f) f(); + + running = true; } void shutdown(void (*f)()) { + if(!running) { + return; + } + + if(f) f(); PluginManager::getInstance()->shutdown(); if(f) f(); ClientManager::getInstance()->shutdown(); @@ -75,6 +95,17 @@ SocketManager::getInstance()->shutdown(); if(f) f(); + running = false; +} + +void cleanup() { + if(!initialized) { + return; + } + if(running) { + shutdown(0); + } + PluginManager::deleteInstance(); ClientManager::deleteInstance(); SocketManager::deleteInstance(); @@ -86,6 +117,8 @@ #ifdef _WIN32 WSACleanup(); #endif + + initialized = false; } //#ifdef _DEBUG Modified: adchpp/trunk/adchpp/common.h =================================================================== --- adchpp/trunk/adchpp/common.h 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/adchpp/common.h 2007-11-18 17:13:18 UTC (rev 91) @@ -100,20 +100,25 @@ typedef ByteVector::iterator ByteIter; /** - * Initialize configuration, must be called before startup + * Initialize configuration. */ -ADCHPP_DLL void initConfig(const string& path); +ADCHPP_DLL void initialize(const string& path); /** - * Second startup phase, this can take quite some time as plugins and - * dynamic data are loaded. - * @param f Unless NULL, this function is called after each step in the initialization + * Load plugins and start listening for incoming connections */ ADCHPP_DLL void startup(void (*f)()); -/** Shuts down the adchpp hub library (doh!). */ +/** + * Stop listening for incoming connections + */ ADCHPP_DLL void shutdown(void (*f)()); +/** + * Release any resources held by adchpp. Before using any library routines again, you must call initalialize. + */ +ADCHPP_DLL void cleanup(); + } #endif // COMMON_H Modified: adchpp/trunk/swig/SConscript =================================================================== --- adchpp/trunk/swig/SConscript 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/swig/SConscript 2007-11-18 17:13:18 UTC (rev 91) @@ -59,17 +59,9 @@ targets.append(rb) def buildPyModule(): - env = dev.env.Copy() - + env, target, sources = dev.prepare_build(source_path, '_pyadchpp', 'python.i') env.Append(SWIGFLAGS=['-c++','-threads','-Wall','-python', '-O', '-classic']) - cxxfile = build_path + 'python_wrap.cxx' - f = env.CXXFile(target=cxxfile, source='python.i') - pyfile = build_path + 'pyadchpp.py' - env.SideEffect(pyfile, f[0]) - targetfile = dev.get_target(source_path, 'pyadchpp.py') - env.Command(targetfile, pyfile, Copy('$TARGET', '$SOURCE')) - env.Depends(targetfile, pyfile) - + import distutils.sysconfig env.Append(CPPPATH=['#', distutils.sysconfig.get_python_inc()]) @@ -85,17 +77,23 @@ env.Append(LIBS=["python"+"".join(sys.version[0:3].split(".")), 'adchpp']) else: env.Append(LIBS=['python2.4', 'adchpp']) - - pyd = env.SharedLibrary(dev.get_target(source_path, '_pyadchpp'), [cxxfile], - SHLIBPREFIX='') + + wrapper = build_path + 'python_wrap.cc' + pyfile = build_path + 'pyadchpp.py' + pytarget = dev.get_target(source_path, 'pyadchpp.py') + env.SideEffect(pyfile, wrapper) + env.Command(pytarget, pyfile, Copy('$TARGET', '$SOURCE')) + env.Depends(pytarget, pyfile) + + pyd = env.SharedLibrary(target, sources, SHLIBPREFIX='') + env.Depends(pyd, pytarget) + targets.append(pyd) def buildLuaModule(): - env = dev.env.Copy() + env, target, sources = dev.prepare_build(source_path, 'luadchpp', 'lua.i') env.Append(SWIGFLAGS=['-c++','-Wall','-lua']) - cxxfile = build_path + 'lua_wrap.cxx' - f = env.CXXFile(build_path + 'lua_wrap.cxx', source='lua.i') env.Append(LIBS=['adchpp', 'alua']) # We assume the lua from the script plugin will be used... @@ -107,8 +105,7 @@ else: env.Append(CPPDEFINES=['LUA_USE_LINUX=1']) - luadchpp = env.SharedLibrary(dev.get_target(source_path, 'luadchpp'), [cxxfile], - SHLIBPREFIX='') + luadchpp = env.SharedLibrary(target, sources, SHLIBPREFIX='') targets.append(luadchpp) # buildRbModule() - needs threading sorted out Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/swig/adchpp.i 2007-11-18 17:13:18 UTC (rev 91) @@ -81,7 +81,8 @@ namespace adchpp { -void initConfig(const std::string& configPath); +void initialize(const std::string& configPath); +void cleanup(); template<typename F> struct Signal { @@ -138,6 +139,7 @@ REASON_NICK_INVALID, REASON_NICK_TAKEN, REASON_NO_BASE_SUPPORT, + REASON_NO_TIGR_SUPPORT, REASON_PID_MISSING, REASON_PID_CID_LENGTH, REASON_PID_CID_MISMATCH, @@ -373,16 +375,21 @@ STATE_NORMAL, STATE_DATA }; - + enum { FLAG_BOT = 0x01, - FLAG_OP = 0x02, - FLAG_PASSWORD = 0x04, - FLAG_HIDDEN = 0x08, + FLAG_REGISTERED = 0x02, + FLAG_OP = 0x04, + FLAG_OWNER = 0x08, FLAG_HUB = 0x10, - FLAG_EXT_AWAY = 0x20, - FLAG_OK_COUNT = 0x80, - FLAG_OK_IP = 0x100 + MASK_CLIENT_TYPE = FLAG_BOT | FLAG_REGISTERED | FLAG_OP | FLAG_OWNER | FLAG_HUB, + FLAG_PASSWORD = 0x100, + FLAG_HIDDEN = 0x101, + /** Extended away, no need to send msg */ + FLAG_EXT_AWAY = 0x102, + /** Plugins can use these flags to disable various checks */ + /** Bypass ip check */ + FLAG_OK_IP = 0x104 }; //static Client* create(uint32_t sid) throw(); @@ -534,7 +541,6 @@ bool verifyPassword(Client& c, const string& password, const vector<uint8_t>& salt, const string& suppliedHash); bool verifyIp(Client& c, AdcCommand& cmd) throw(); bool verifyCID(Client& c, AdcCommand& cmd) throw(); - bool verifyUsers(Client& c) throw(); void setState(Client& c, Client::State newState) throw(); @@ -609,12 +615,12 @@ enum StrSetting { STR_FIRST, HUB_NAME = STR_FIRST, SERVER_IP, LOG_FILE, DESCRIPTION, - LANGUAGE_FILE, REDIRECT_SERVER, + LANGUAGE_FILE, STR_LAST }; enum IntSetting { INT_FIRST = STR_LAST + 1, - SERVER_PORT = INT_FIRST, LOG, MAX_USERS, KEEP_SLOW_USERS, - MAX_SEND_SIZE, MAX_BUFFER_SIZE, BUFFER_SIZE, MAX_COMMAND_SIZE, REDIRECT_FULL, + SERVER_PORT = INT_FIRST, LOG, KEEP_SLOW_USERS, + MAX_SEND_SIZE, MAX_BUFFER_SIZE, BUFFER_SIZE, MAX_COMMAND_SIZE, OVERFLOW_TIMEOUT, DISCONNECT_TIMEOUT, FLOOD_ADD, FLOOD_THRESHOLD, LOGIN_TIMEOUT, INT_LAST }; Modified: adchpp/trunk/unix/main.cpp =================================================================== --- adchpp/trunk/unix/main.cpp 2007-11-17 15:16:11 UTC (rev 90) +++ adchpp/trunk/unix/main.cpp 2007-11-18 17:13:18 UTC (rev 91) @@ -26,6 +26,7 @@ #include <signal.h> +using namespace std; using namespace adchpp; static const string modName = "adchpp"; @@ -69,6 +70,7 @@ if(!asdaemon) printf("Shutting down."); shutdown(&f2); + cleanup(); if(!asdaemon) printf(".\n"); @@ -113,13 +115,13 @@ #include <sys/wait.h> static void runDaemon(const string& configPath) { - initConfig(configPath); + initialize(configPath); daemonize(); init(); try { - startup(&f2); - } catch(const Exception& e) { - LOGDT(modName, "Failed to load in stage 2"); + adchpp::startup(&f2); + } catch(const adchpp::Exception& e) { + LOGDT(modName, "Failed to start: " + e.getError()); uninit(); return; } @@ -138,7 +140,7 @@ static void runConsole(const string& configPath) { printf("Starting"); init(); - initConfig(configPath); + initialize(configPath); LOGDT(modName, versionString + " starting from console"); printf("."); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-17 15:16:16
|
Revision: 90 http://adchpp.svn.sourceforge.net/adchpp/?rev=90&view=rev Author: arnetheduck Date: 2007-11-17 07:16:11 -0800 (Sat, 17 Nov 2007) Log Message: ----------- update feature variable Modified Paths: -------------- adchpp/trunk/adchpp/Client.cpp Modified: adchpp/trunk/adchpp/Client.cpp =================================================================== --- adchpp/trunk/adchpp/Client.cpp 2007-11-17 14:47:54 UTC (rev 89) +++ adchpp/trunk/adchpp/Client.cpp 2007-11-17 15:16:11 UTC (rev 90) @@ -27,229 +27,228 @@ namespace adchpp { using namespace std::tr1::placeholders; - + Client* Client::create(const ManagedSocketPtr& ms) throw() { Client* c = new Client(); c->setSocket(ms); return c; } -Client::Client() throw() : - sid(0), state(STATE_PROTOCOL), disconnecting(false), socket(0), dataBytes(0), floodTimer(0) { +Client::Client() throw() : sid(0), state(STATE_PROTOCOL), disconnecting(false), socket(0), dataBytes(0), floodTimer(0) { } namespace { -// Lightweight call forwarders, instead of tr1::bind -struct Handler { - Handler(void (Client::*f)(), Client* c_) : - c(c_), f0(f) { - } - Handler(void (Client::*f)(const ByteVector&), Client* c_) : - c(c_), f1(f) { - } - - void operator()() throw() { - (c->*f0)(); - } - void operator()(const ByteVector& bv) throw() { - (c->*f1)(bv); - } - - Client* c; - union { - void (Client::*f0)(); - void (Client::*f1)(const ByteVector&); + // Lightweight call forwarders, instead of tr1::bind + struct Handler { + Handler(void (Client::*f)(), Client* c_) : c(c_), f0(f) { } + Handler(void (Client::*f)(const ByteVector&), Client* c_) : c(c_), f1(f) { } + + void operator()() throw() { + (c->*f0)(); + } + void operator()(const ByteVector& bv) throw() { + (c->*f1)(bv); + } + + Client* c; + union { + void (Client::*f0)(); + void (Client::*f1)(const ByteVector&); + }; }; -}; } void Client::setSocket(const ManagedSocketPtr& aSocket) throw() { -dcassert(!socket); -socket = aSocket; -socket->setConnectedHandler(Handler(&Client::onConnected, this)); -socket->setDataHandler(Handler(&Client::onData, this)); -socket->setFailedHandler(Handler(&Client::onFailed, this)); + dcassert(!socket); + socket = aSocket; + socket->setConnectedHandler(Handler(&Client::onConnected, this)); + socket->setDataHandler(Handler(&Client::onData, this)); + socket->setFailedHandler(Handler(&Client::onFailed, this)); } void Client::onConnected() throw() { -dcdebug("Client::onConnected\n"); -ClientManager::getInstance()->onConnected(*this); + dcdebug("Client::onConnected\n"); + ClientManager::getInstance()->onConnected(*this); } void* Client::setPSD(int id, void* data) throw() { -PSDIter i = find_if(psd.begin(), psd.end(), CompareFirst<int, void*>(id)); -if(i != psd.end()) { - void* old = i->second; - i->second = data; - return old; -} else { - psd.push_back(make_pair(id, data)); - return 0; + PSDIter i = find_if(psd.begin(), psd.end(), CompareFirst<int, void*>(id)); + if(i != psd.end()) { + void* old = i->second; + i->second = data; + return old; + } else { + psd.push_back(make_pair(id, data)); + return 0; + } } -} void* Client::getPSD(int id) throw() { -PSDIter i = find_if(psd.begin(), psd.end(), CompareFirst<int, void*>(id)); -if(i != psd.end()) -return i->second; -else -return 0; + PSDIter i = find_if(psd.begin(), psd.end(), CompareFirst<int, void*>(id)); + return (i != psd.end()) ? i->second : 0; } void Client::onData(const vector<uint8_t>& data) throw() { -dcdebug("In (%d): %.*s\n", data.size(), data.size(), &data[0]); + dcdebug("In (%d): %.*s\n", data.size(), data.size(), &data[0]); -size_t done = 0; -size_t len = data.size(); -while(!disconnecting && done < len) { - if(dataBytes > 0) { - size_t n = (size_t)min(dataBytes, (int64_t)(len - done)); - dataHandler(*this, &data[done], n); - dataBytes -= n; - done += n; - } else { - size_t j = done; - while(j < len && data[j] != '\n') - ++j; + size_t done = 0; + size_t len = data.size(); + while(!disconnecting && done < len) { + if(dataBytes > 0) { + size_t n = (size_t)min(dataBytes, (int64_t)(len - done)); + dataHandler(*this, &data[done], n); + dataBytes -= n; + done += n; + } else { + size_t j = done; + while(j < len && data[j] != '\n') + ++j; + + if(j == len) { + line.append((char*)&data[done], j - done); + return; + } + line.append((char*)&data[done], j - done + 1); // include LF + + done = j + 1; - if(j == len) { - line.append((char*)&data[done], j - done); - return; + if(SETTING(MAX_COMMAND_SIZE) > 0 && line.size() > (size_t)SETTING(MAX_COMMAND_SIZE)) { + send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "Command too long")); + disconnect(Util::REASON_MAX_COMMAND_SIZE); + return; + } + + if(line.size() == 1) { + line.clear(); + continue; + } + + try { + AdcCommand cmd(line); + + if(cmd.getType() == 'H') { + cmd.setFrom(getSID()); + } else if(cmd.getFrom() != getSID()) { + disconnect(Util::REASON_INVALID_SID); + return; + } + ClientManager::getInstance()->onReceive(*this, cmd); + } catch(const ParseException&) { + ClientManager::getInstance()->onBadLine(*this, line); + } + line.clear(); } - line.append((char*)&data[done], j - done + 1); // include LF + } +} - done = j + 1; - - if(SETTING(MAX_COMMAND_SIZE) > 0 && line.size() > (size_t)SETTING(MAX_COMMAND_SIZE)) { - send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "Command too long")); - disconnect(Util::REASON_MAX_COMMAND_SIZE); - return; - } - - if(line.size() == 1) { - line.clear(); - continue; - } - - try { - AdcCommand cmd(line); - - if(cmd.getType() == 'H') { - cmd.setFrom(getSID()); - } else if(cmd.getFrom() != getSID()) { - disconnect(Util::REASON_INVALID_SID); - return; - } - ClientManager::getInstance()->onReceive(*this, cmd); - } catch(const ParseException&) { - ClientManager::getInstance()->onBadLine(*this, line); - } - line.clear(); - } - } -} - void Client::setField(const char* name, const string& value) throw() { + uint16_t code = AdcCommand::toCode(name); + + if(code == AdcCommand::toCode("SU")) { + filters.clear(); + Util::tokenize(filters, value, ','); + } + if(value.empty()) { - info.erase(AdcCommand::toCode(name)); + info.erase(code); } else { - info[AdcCommand::toCode(name)] = value; + info[code] = value; } - changed[AdcCommand::toCode(name)] = value; + changed[code] = value; INF.clear(); } bool Client::getChangedFields(AdcCommand& cmd) const throw() { - for(InfMap::const_iterator i = changed.begin(); i != changed.end(); ++i) - cmd.addParam(string((char*)&i->first, 2)); - return !changed.empty(); + for(InfMap::const_iterator i = changed.begin(); i != changed.end(); ++i) + cmd.addParam(string((char*)&i->first, 2)); + return !changed.empty(); } bool Client::getAllFields(AdcCommand& cmd) const throw() { - for(InfMap::const_iterator i = info.begin(); i != info.end(); ++i) - cmd.addParam(string((char*)&i->first, 2), i->second); - return !info.empty(); + for(InfMap::const_iterator i = info.begin(); i != info.end(); ++i) + cmd.addParam(string((char*)&i->first, 2), i->second); + return !info.empty(); } const string& Client::getINF() const throw() { - if(INF.empty()) { - AdcCommand cmd(AdcCommand::CMD_INF, AdcCommand::TYPE_BROADCAST, getSID()); - getAllFields(cmd); - INF = cmd.toString(); - } - return INF; + if(INF.empty()) { + AdcCommand cmd(AdcCommand::CMD_INF, AdcCommand::TYPE_BROADCAST, getSID()); + getAllFields(cmd); + INF = cmd.toString(); + } + return INF; } void Client::updateFields(const AdcCommand& cmd) throw() { - dcassert(cmd.getCommand() == AdcCommand::CMD_INF); - for(StringIterC j = cmd.getParameters().begin(); j != cmd.getParameters().end(); ++j) { - if(j->size() < 2) - continue; - setField(j->substr(0, 2).c_str(), j->substr(2)); - } + dcassert(cmd.getCommand() == AdcCommand::CMD_INF); + for(StringIterC j = cmd.getParameters().begin(); j != cmd.getParameters().end(); ++j) { + if(j->size() < 2) + continue; + setField(j->substr(0, 2).c_str(), j->substr(2)); + } } bool Client::isFiltered(const string& features) const { - if(filters.empty()) { - return true; - } - - for(size_t i = 0; i < features.size(); i += 5) { - if(features[i] == '-') { - if(std::find(filters.begin(), filters.end(), features.substr(i+1, 4)) != filters.end()) { - return true; - } - } else if(features[i] == '+') { - if(std::find(filters.begin(), filters.end(), features.substr(i+1, 4)) == filters.end()) { - return true; - } - } - } - return false; + if(filters.empty()) { + return true; + } + + for(size_t i = 0; i < features.size(); i += 5) { + if(features[i] == '-') { + if(std::find(filters.begin(), filters.end(), features.substr(i+1, 4)) != filters.end()) { + return true; + } + } else if(features[i] == '+') { + if(std::find(filters.begin(), filters.end(), features.substr(i+1, 4)) == filters.end()) { + return true; + } + } + } + return false; } void Client::updateSupports(const AdcCommand& cmd) throw() { - for(StringIterC i = cmd.getParameters().begin(); i != cmd.getParameters().end(); ++i) { - const string& str = *i; - if(str.size() != 6) { - continue; - } - if(str.compare(0, 2, "AD") == 0) { - supportList.push_back(str.substr(2)); - } else if(str.compare(0, 2, "RM") == 0) { - supportList.erase(std::remove(supportList.begin(), supportList.end(), str.substr(2)), supportList.end()); - } else { - continue; - } - } + for(StringIterC i = cmd.getParameters().begin(); i != cmd.getParameters().end(); ++i) { + const string& str = *i; + if(str.size() != 6) { + continue; + } + if(str.compare(0, 2, "AD") == 0) { + supportList.push_back(str.substr(2)); + } else if(str.compare(0, 2, "RM") == 0) { + supportList.erase(std::remove(supportList.begin(), supportList.end(), str.substr(2)), supportList.end()); + } else { + continue; + } + } } bool Client::isFlooding(time_t addSeconds) { - time_t now = GET_TIME(); - if(floodTimer < now) { - floodTimer = now; - } - - floodTimer += addSeconds; - - if(floodTimer > now + SETTING(FLOOD_THRESHOLD)) { - return true; - } - - return false; + time_t now = GET_TIME(); + if(floodTimer < now) { + floodTimer = now; + } + + floodTimer += addSeconds; + + if(floodTimer > now + SETTING(FLOOD_THRESHOLD)) { + return true; + } + + return false; } void Client::disconnect(Util::Reason reason) throw() { - if(socket && !disconnecting) { - disconnecting = true; - line.clear(); - socket->disconnect(reason); - } + if(socket && !disconnecting) { + disconnecting = true; + line.clear(); + socket->disconnect(reason); + } } void Client::onFailed() throw() { - ClientManager::getInstance()->onFailed(*this); - delete this; + ClientManager::getInstance()->onFailed(*this); + delete this; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-17 14:47:58
|
Revision: 89 http://adchpp.svn.sourceforge.net/adchpp/?rev=89&view=rev Author: arnetheduck Date: 2007-11-17 06:47:54 -0800 (Sat, 17 Nov 2007) Log Message: ----------- Implement type F Modified Paths: -------------- adchpp/trunk/adchpp/AdcCommand.h adchpp/trunk/adchpp/Client.cpp adchpp/trunk/adchpp/Client.h adchpp/trunk/adchpp/ClientManager.cpp adchpp/trunk/adchpp/ManagedSocket.cpp adchpp/trunk/adchpp/ManagedSocket.h adchpp/trunk/swig/adchpp.i Modified: adchpp/trunk/adchpp/AdcCommand.h =================================================================== --- adchpp/trunk/adchpp/AdcCommand.h 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/adchpp/AdcCommand.h 2007-11-17 14:47:54 UTC (rev 89) @@ -132,6 +132,8 @@ const string& getParam(size_t n) const { return getParameters().size() > n ? getParameters()[n] : Util::emptyString; } + + const string& getFeatures() const { return features; } /** Return a named parameter where the name is a two-letter code */ ADCHPP_DLL bool getParam(const char* name, size_t start, string& ret) const; Modified: adchpp/trunk/adchpp/Client.cpp =================================================================== --- adchpp/trunk/adchpp/Client.cpp 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/adchpp/Client.cpp 2007-11-17 14:47:54 UTC (rev 89) @@ -27,184 +27,229 @@ namespace adchpp { using namespace std::tr1::placeholders; - + Client* Client::create(const ManagedSocketPtr& ms) throw() { Client* c = new Client(); c->setSocket(ms); return c; } -Client::Client() throw() : sid(0), state(STATE_PROTOCOL), disconnecting(false), socket(0), dataBytes(0), floodTimer(0) { +Client::Client() throw() : + sid(0), state(STATE_PROTOCOL), disconnecting(false), socket(0), dataBytes(0), floodTimer(0) { } +namespace { +// Lightweight call forwarders, instead of tr1::bind +struct Handler { + Handler(void (Client::*f)(), Client* c_) : + c(c_), f0(f) { + } + Handler(void (Client::*f)(const ByteVector&), Client* c_) : + c(c_), f1(f) { + } + + void operator()() throw() { + (c->*f0)(); + } + void operator()(const ByteVector& bv) throw() { + (c->*f1)(bv); + } + + Client* c; + union { + void (Client::*f0)(); + void (Client::*f1)(const ByteVector&); + }; +}; +} + void Client::setSocket(const ManagedSocketPtr& aSocket) throw() { - dcassert(!socket); - socket = aSocket; - socket->setConnectedHandler(std::tr1::bind(&Client::onConnected, this)); - socket->setDataHandler(std::tr1::bind(&Client::onData, this, _1)); - socket->setFailedHandler(std::tr1::bind(&Client::onFailed, this)); +dcassert(!socket); +socket = aSocket; +socket->setConnectedHandler(Handler(&Client::onConnected, this)); +socket->setDataHandler(Handler(&Client::onData, this)); +socket->setFailedHandler(Handler(&Client::onFailed, this)); } void Client::onConnected() throw() { - dcdebug("Client::onConnected\n"); - ClientManager::getInstance()->onConnected(*this); +dcdebug("Client::onConnected\n"); +ClientManager::getInstance()->onConnected(*this); } void* Client::setPSD(int id, void* data) throw() { - PSDIter i = find_if(psd.begin(), psd.end(), CompareFirst<int, void*>(id)); - if(i != psd.end()) { - void* old = i->second; - i->second = data; - return old; - } else { - psd.push_back(make_pair(id, data)); - return 0; - } +PSDIter i = find_if(psd.begin(), psd.end(), CompareFirst<int, void*>(id)); +if(i != psd.end()) { + void* old = i->second; + i->second = data; + return old; +} else { + psd.push_back(make_pair(id, data)); + return 0; } +} void* Client::getPSD(int id) throw() { - PSDIter i = find_if(psd.begin(), psd.end(), CompareFirst<int, void*>(id)); - if(i != psd.end()) - return i->second; - else - return 0; +PSDIter i = find_if(psd.begin(), psd.end(), CompareFirst<int, void*>(id)); +if(i != psd.end()) +return i->second; +else +return 0; } void Client::onData(const vector<uint8_t>& data) throw() { - dcdebug("In (%d): %.*s\n", data.size(), data.size(), &data[0]); +dcdebug("In (%d): %.*s\n", data.size(), data.size(), &data[0]); - size_t done = 0; - size_t len = data.size(); - while(!disconnecting && done < len) { - if(dataBytes > 0) { - size_t n = (size_t)min(dataBytes, (int64_t)(len - done)); - dataHandler(*this, &data[done], n); - dataBytes -= n; - done += n; - } else { - size_t j = done; - while(j < len && data[j] != '\n') - ++j; - - if(j == len) { - line.append((char*)&data[done], j - done); - return; - } - line.append((char*)&data[done], j - done + 1); // include LF - - done = j + 1; +size_t done = 0; +size_t len = data.size(); +while(!disconnecting && done < len) { + if(dataBytes > 0) { + size_t n = (size_t)min(dataBytes, (int64_t)(len - done)); + dataHandler(*this, &data[done], n); + dataBytes -= n; + done += n; + } else { + size_t j = done; + while(j < len && data[j] != '\n') + ++j; - if(SETTING(MAX_COMMAND_SIZE) > 0 && line.size() > (size_t)SETTING(MAX_COMMAND_SIZE)) { - send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "Command too long")); - disconnect(Util::REASON_MAX_COMMAND_SIZE); - return; - } - - if(line.size() == 1) { - line.clear(); - continue; - } - - try { - AdcCommand cmd(line); - - if(cmd.getType() == 'H') { - cmd.setFrom(getSID()); - } else if(cmd.getFrom() != getSID()) { - disconnect(Util::REASON_INVALID_SID); - return; - } - ClientManager::getInstance()->onReceive(*this, cmd); - } catch(const ParseException&) { - ClientManager::getInstance()->onBadLine(*this, line); - } - line.clear(); + if(j == len) { + line.append((char*)&data[done], j - done); + return; } - } -} + line.append((char*)&data[done], j - done + 1); // include LF -void Client::setField(const char* name, const string& value) throw() { - if(value.empty()) { - info.erase(*(uint16_t*)name); - } else { - info[*(uint16_t*)name] = value; - } - changed[*(uint16_t*)name] = value; - INF.clear(); + done = j + 1; + + if(SETTING(MAX_COMMAND_SIZE) > 0 && line.size() > (size_t)SETTING(MAX_COMMAND_SIZE)) { + send(AdcCommand(AdcCommand::SEV_FATAL, AdcCommand::ERROR_PROTOCOL_GENERIC, "Command too long")); + disconnect(Util::REASON_MAX_COMMAND_SIZE); + return; + } + + if(line.size() == 1) { + line.clear(); + continue; + } + + try { + AdcCommand cmd(line); + + if(cmd.getType() == 'H') { + cmd.setFrom(getSID()); + } else if(cmd.getFrom() != getSID()) { + disconnect(Util::REASON_INVALID_SID); + return; + } + ClientManager::getInstance()->onReceive(*this, cmd); + } catch(const ParseException&) { + ClientManager::getInstance()->onBadLine(*this, line); + } + line.clear(); + } + } } +void Client::setField(const char* name, const string& value) throw() { + if(value.empty()) { + info.erase(AdcCommand::toCode(name)); + } else { + info[AdcCommand::toCode(name)] = value; + } + changed[AdcCommand::toCode(name)] = value; + INF.clear(); +} + bool Client::getChangedFields(AdcCommand& cmd) const throw() { - for(InfMap::const_iterator i = changed.begin(); i != changed.end(); ++i) - cmd.addParam(string((char*)&i->first, 2)); - return !changed.empty(); + for(InfMap::const_iterator i = changed.begin(); i != changed.end(); ++i) + cmd.addParam(string((char*)&i->first, 2)); + return !changed.empty(); } bool Client::getAllFields(AdcCommand& cmd) const throw() { - for(InfMap::const_iterator i = info.begin(); i != info.end(); ++i) - cmd.addParam(string((char*)&i->first, 2), i->second); - return !info.empty(); + for(InfMap::const_iterator i = info.begin(); i != info.end(); ++i) + cmd.addParam(string((char*)&i->first, 2), i->second); + return !info.empty(); } const string& Client::getINF() const throw() { - if(INF.empty()) { - AdcCommand cmd(AdcCommand::CMD_INF, AdcCommand::TYPE_BROADCAST, getSID()); - getAllFields(cmd); - INF = cmd.toString(); - } - return INF; + if(INF.empty()) { + AdcCommand cmd(AdcCommand::CMD_INF, AdcCommand::TYPE_BROADCAST, getSID()); + getAllFields(cmd); + INF = cmd.toString(); + } + return INF; } void Client::updateFields(const AdcCommand& cmd) throw() { - dcassert(cmd.getCommand() == AdcCommand::CMD_INF); - for(StringIterC j = cmd.getParameters().begin(); j != cmd.getParameters().end(); ++j) { - if(j->size() < 2) - continue; - setField(j->substr(0, 2).c_str(), j->substr(2)); - } + dcassert(cmd.getCommand() == AdcCommand::CMD_INF); + for(StringIterC j = cmd.getParameters().begin(); j != cmd.getParameters().end(); ++j) { + if(j->size() < 2) + continue; + setField(j->substr(0, 2).c_str(), j->substr(2)); + } } +bool Client::isFiltered(const string& features) const { + if(filters.empty()) { + return true; + } + + for(size_t i = 0; i < features.size(); i += 5) { + if(features[i] == '-') { + if(std::find(filters.begin(), filters.end(), features.substr(i+1, 4)) != filters.end()) { + return true; + } + } else if(features[i] == '+') { + if(std::find(filters.begin(), filters.end(), features.substr(i+1, 4)) == filters.end()) { + return true; + } + } + } + return false; +} + void Client::updateSupports(const AdcCommand& cmd) throw() { - for(StringIterC i = cmd.getParameters().begin(); i != cmd.getParameters().end(); ++i) { - const string& str = *i; - if(str.size() != 6) { - continue; - } - if(str.compare(0, 2, "AD") == 0) { - supportList.push_back(str.substr(2)); - } else if(str.compare(0, 2, "RM") == 0) { - supportList.erase(std::remove(supportList.begin(), supportList.end(), str.substr(2)), supportList.end()); - } else { - continue; - } - } + for(StringIterC i = cmd.getParameters().begin(); i != cmd.getParameters().end(); ++i) { + const string& str = *i; + if(str.size() != 6) { + continue; + } + if(str.compare(0, 2, "AD") == 0) { + supportList.push_back(str.substr(2)); + } else if(str.compare(0, 2, "RM") == 0) { + supportList.erase(std::remove(supportList.begin(), supportList.end(), str.substr(2)), supportList.end()); + } else { + continue; + } + } } bool Client::isFlooding(time_t addSeconds) { - time_t now = GET_TIME(); - if(floodTimer < now) { - floodTimer = now; - } - - floodTimer += addSeconds; - - if(floodTimer > now + SETTING(FLOOD_THRESHOLD)) { - return true; - } - - return false; + time_t now = GET_TIME(); + if(floodTimer < now) { + floodTimer = now; + } + + floodTimer += addSeconds; + + if(floodTimer > now + SETTING(FLOOD_THRESHOLD)) { + return true; + } + + return false; } void Client::disconnect(Util::Reason reason) throw() { - if(socket && !disconnecting) { - disconnecting = true; - line.clear(); - socket->disconnect(reason); - } + if(socket && !disconnecting) { + disconnecting = true; + line.clear(); + socket->disconnect(reason); + } } void Client::onFailed() throw() { - ClientManager::getInstance()->onFailed(*this); - delete this; + ClientManager::getInstance()->onFailed(*this); + delete this; } } Modified: adchpp/trunk/adchpp/Client.h =================================================================== --- adchpp/trunk/adchpp/Client.h 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/adchpp/Client.h 2007-11-17 14:47:54 UTC (rev 89) @@ -99,14 +99,16 @@ void resetChanged() { changed.clear(); } - const string& getField(const char* name) const throw() { InfMap::const_iterator i = info.find(*(uint16_t*)name); return i == info.end() ? Util::emptyString : i->second; } + const string& getField(const char* name) const throw() { InfMap::const_iterator i = info.find(AdcCommand::toCode(name)); return i == info.end() ? Util::emptyString : i->second; } ADCHPP_DLL void setField(const char* name, const string& value) throw(); ADCHPP_DLL void updateFields(const AdcCommand& cmd) throw(); ADCHPP_DLL void updateSupports(const AdcCommand& cmd) throw(); - bool isUdpActive() const { return info.find(*(uint16_t*)"U4") != info.end(); } - bool isTcpActive() const { return info.find(*(uint16_t*)"I4") != info.end(); } + bool isUdpActive() const { return info.find(AdcCommand::toCode("U4")) != info.end(); } + bool isTcpActive() const { return info.find(AdcCommand::toCode("I4")) != info.end(); } + + ADCHPP_DLL bool isFiltered(const std::string& features) const; ADCHPP_DLL bool isFlooding(time_t addSeconds); @@ -138,6 +140,9 @@ Client() throw(); virtual ~Client() throw() { } + /** H-C INF SU */ + StringList filters; + /** H-C SUP */ StringList supportList; typedef pair<int, void*> PSDPair; typedef vector<PSDPair> PSDList; Modified: adchpp/trunk/adchpp/ClientManager.cpp =================================================================== --- adchpp/trunk/adchpp/ClientManager.cpp 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/adchpp/ClientManager.cpp 2007-11-17 14:47:54 UTC (rev 89) @@ -51,9 +51,11 @@ case AdcCommand::TYPE_FEATURE: case AdcCommand::TYPE_BROADCAST: { - FastMutex::Lock l(ManagedSocket::getWriteLock()); + bool all = (cmd.getType() == AdcCommand::TYPE_BROADCAST); + FastMutex::Lock l(ManagedSocket::getWriteMutex()); for(ClientIter i = clients.begin(); i != clients.end(); ++i) { - i->second->fastSend(txt, lowPrio); + if(all || !i->second->isFiltered(cmd.getFeatures())) + i->second->fastSend(txt, lowPrio); } } SocketManager::getInstance()->addAllWriters(); @@ -78,7 +80,7 @@ void ClientManager::sendToAll(const string& cmd) throw() { { - FastMutex::Lock l(ManagedSocket::getWriteLock()); + FastMutex::Lock l(ManagedSocket::getWriteMutex()); for(ClientIter i = clients.begin(); i != clients.end(); ++i) { i->second->fastSend(cmd); } @@ -89,7 +91,7 @@ size_t ClientManager::getQueuedBytes() throw() { size_t total = 0; - FastMutex::Lock l(ManagedSocket::getWriteLock()); + FastMutex::Lock l(ManagedSocket::getWriteMutex()); for(ClientIter i = clients.begin(); i != clients.end(); ++i) { total += i->second->getQueuedBytes(); } Modified: adchpp/trunk/adchpp/ManagedSocket.cpp =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.cpp 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/adchpp/ManagedSocket.cpp 2007-11-17 14:47:54 UTC (rev 89) @@ -27,7 +27,7 @@ namespace adchpp { -FastMutex ManagedSocket::outbufCS; +FastMutex ManagedSocket::writeMutex; ManagedSocket::ManagedSocket() throw() : outBuf(0), overFlow(0), disc(0) #ifdef _WIN32 @@ -54,7 +54,7 @@ void ManagedSocket::write(const char* buf, size_t len) throw() { bool add = false; { - FastMutex::Lock l(outbufCS); + FastMutex::Lock l(writeMutex); add = fastWrite(buf, len); } if(add) { @@ -93,7 +93,7 @@ ByteVector* buffer = 0; { - FastMutex::Lock l(outbufCS); + FastMutex::Lock l(writeMutex); if(outBuf == 0) { return 0; @@ -119,7 +119,7 @@ bool moreData; { - FastMutex::Lock l(outbufCS); + FastMutex::Lock l(writeMutex); if(written != buf->size()) { if(outBuf == 0) { Modified: adchpp/trunk/adchpp/ManagedSocket.h =================================================================== --- adchpp/trunk/adchpp/ManagedSocket.h 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/adchpp/ManagedSocket.h 2007-11-17 14:47:54 UTC (rev 89) @@ -44,7 +44,7 @@ ADCHPP_DLL bool fastWrite(const char* buf, size_t len, bool lowPrio = false) throw(); /** Returns the lock used for the write buffers */ - static FastMutex& getWriteLock() { return outbufCS; } + static FastMutex& getWriteMutex() { return writeMutex; } /** Returns the number of bytes in the output buffer; buffers must be locked */ size_t getQueuedBytes() { return outBuf ? outBuf->size() : 0; } @@ -110,7 +110,7 @@ DataHandler dataHandler; FailedHandler failedHandler; - ADCHPP_DLL static FastMutex outbufCS; + ADCHPP_DLL static FastMutex writeMutex; }; typedef boost::intrusive_ptr<ManagedSocket> ManagedSocketPtr; Modified: adchpp/trunk/swig/adchpp.i =================================================================== --- adchpp/trunk/swig/adchpp.i 2007-11-17 13:53:54 UTC (rev 88) +++ adchpp/trunk/swig/adchpp.i 2007-11-17 14:47:54 UTC (rev 89) @@ -85,15 +85,10 @@ template<typename F> struct Signal { - - ~Signal() { } }; template<typename Sig> struct ManagedConnection { - ManagedConnection(Sig* signal_, const typename Sig::SlotList::iterator& iter_); - ~ManagedConnection(); - void disconnect(); void release(); }; @@ -330,6 +325,8 @@ AdcCommand& addParam(const string& name, const string& value); AdcCommand& addParam(const string& str); const string& getParam(size_t n) const; + + const string& getFeatures() const; #ifndef SWIGLUA bool getParam(const char* name, size_t start, string& OUTPUT) const; @@ -423,6 +420,8 @@ bool isUdpActive(); bool isTcpActive(); + bool isFiltered(const std::string& features) const; + bool isFlooding(time_t addSeconds); //void* setPSD(int id, void* data) throw(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <arn...@us...> - 2007-11-16 23:11:12
|
Revision: 911 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=911&view=rev Author: arnetheduck Date: 2007-11-16 15:11:07 -0800 (Fri, 16 Nov 2007) Log Message: ----------- More 0.14 support Modified Paths: -------------- dcplusplus/trunk/dcpp/AdcHub.cpp dcplusplus/trunk/dcpp/ConnectionManager.cpp dcplusplus/trunk/dcpp/User.cpp dcplusplus/trunk/dcpp/User.h Modified: dcplusplus/trunk/dcpp/AdcHub.cpp =================================================================== --- dcplusplus/trunk/dcpp/AdcHub.cpp 2007-11-16 17:34:06 UTC (rev 910) +++ dcplusplus/trunk/dcpp/AdcHub.cpp 2007-11-16 23:11:07 UTC (rev 911) @@ -527,6 +527,24 @@ } } +static void addParam(StringMap& lastInfoMap, AdcCommand& c, const string& var, const string& value) { + StringMapIter i = lastInfoMap.find(var); + + if(i != lastInfoMap.end()) { + if(i->second != value) { + if(value.empty()) { + lastInfoMap.erase(i); + } else { + i->second = value; + } + c.addParam(var, value); + } + } else if(!value.empty()) { + lastInfoMap.insert(make_pair(var, value)); + c.addParam(var, value); + } +} + void AdcHub::info(bool /*alwaysSend*/) { if(state != STATE_IDENTIFY && state != STATE_NORMAL) return; @@ -534,51 +552,30 @@ reloadSettings(false); AdcCommand c(AdcCommand::CMD_INF, AdcCommand::TYPE_BROADCAST); - string tmp; - StringMapIter i; -#define ADDPARAM(var, content) \ - tmp = content; \ - if((i = lastInfoMap.find(var)) != lastInfoMap.end()) { \ - if(i->second != tmp) { \ - if(tmp.empty()) \ - lastInfoMap.erase(i); \ - else \ - i->second = tmp; \ - c.addParam(var, tmp); \ - } \ - } else if(!tmp.empty()) { \ - c.addParam(var, tmp); \ - lastInfoMap[var] = tmp; \ - } + updateCounts(false); - updateCounts(false); \ + addParam(lastInfoMap, c, "ID", ClientManager::getInstance()->getMyCID().toBase32()); + addParam(lastInfoMap, c, "PD", ClientManager::getInstance()->getMyPID().toBase32()); + addParam(lastInfoMap, c, "NI", getCurrentNick()); + addParam(lastInfoMap, c, "DE", getCurrentDescription()); + addParam(lastInfoMap, c, "SL", Util::toString(SETTING(SLOTS))); + addParam(lastInfoMap, c, "SS", ShareManager::getInstance()->getShareSizeString()); + addParam(lastInfoMap, c, "SF", Util::toString(ShareManager::getInstance()->getSharedFiles())); + addParam(lastInfoMap, c, "EM", SETTING(EMAIL)); + addParam(lastInfoMap, c, "HN", Util::toString(counts.normal)); + addParam(lastInfoMap, c, "HR", Util::toString(counts.registered)); + addParam(lastInfoMap, c, "HO", Util::toString(counts.op)); + addParam(lastInfoMap, c, "VE", "++ " VERSIONSTRING); + addParam(lastInfoMap, c, "US", Util::toString((long)(Util::toDouble(SETTING(UPLOAD_SPEED))*1024*1024))); + addParam(lastInfoMap, c, "AW", Util::getAway() ? "1" : Util::emptyString); - ADDPARAM("ID", ClientManager::getInstance()->getMyCID().toBase32()); - ADDPARAM("PD", ClientManager::getInstance()->getMyPID().toBase32()); - ADDPARAM("NI", getCurrentNick()); - ADDPARAM("DE", getCurrentDescription()); - ADDPARAM("SL", Util::toString(SETTING(SLOTS))); - ADDPARAM("SS", ShareManager::getInstance()->getShareSizeString()); - ADDPARAM("SF", Util::toString(ShareManager::getInstance()->getSharedFiles())); - ADDPARAM("EM", SETTING(EMAIL)); - ADDPARAM("HN", Util::toString(counts.normal)); - ADDPARAM("HR", Util::toString(counts.registered)); - ADDPARAM("HO", Util::toString(counts.op)); - ADDPARAM("VE", "++ " VERSIONSTRING); - ADDPARAM("US", Util::toString((long)(Util::toDouble(SETTING(UPLOAD_SPEED))*1024*1024))); - if(SETTING(MAX_DOWNLOAD_SPEED) > 0) { - ADDPARAM("DS", Util::toString((SETTING(MAX_DOWNLOAD_SPEED)*1024*8))); + addParam(lastInfoMap, c, "DS", Util::toString((SETTING(MAX_DOWNLOAD_SPEED)*1024*8))); } else { - ADDPARAM("DS", Util::emptyString); + addParam(lastInfoMap, c, "DS", Util::emptyString); } - if(Util::getAway()){ - ADDPARAM("AW", '1'); - } else { - ADDPARAM("AW", Util::emptyString); - } string su; if(CryptoManager::getInstance()->TLSOk()) { @@ -587,25 +584,23 @@ if(ClientManager::getInstance()->isActive()) { if(BOOLSETTING(NO_IP_OVERRIDE) && !SETTING(EXTERNAL_IP).empty()) { - ADDPARAM("I4", Socket::resolve(SETTING(EXTERNAL_IP))); + addParam(lastInfoMap, c, "I4", Socket::resolve(SETTING(EXTERNAL_IP))); } else { - ADDPARAM("I4", "0.0.0.0"); + addParam(lastInfoMap, c, "I4", "0.0.0.0"); } - ADDPARAM("U4", Util::toString(SearchManager::getInstance()->getPort())); + addParam(lastInfoMap, c, "U4", Util::toString(SearchManager::getInstance()->getPort())); su += TCP4_FEATURE + ","; su += UDP4_FEATURE + ","; } else { - ADDPARAM("I4", ""); - ADDPARAM("U4", ""); + addParam(lastInfoMap, c, "I4", ""); + addParam(lastInfoMap, c, "U4", ""); } if(!su.empty()) { su.erase(su.size() - 1); } - ADDPARAM("SU", su); + addParam(lastInfoMap, c, "SU", su); -#undef ADDPARAM - if(c.getParameters().size() > 0) { send(c); } Modified: dcplusplus/trunk/dcpp/ConnectionManager.cpp =================================================================== --- dcplusplus/trunk/dcpp/ConnectionManager.cpp 2007-11-16 17:34:06 UTC (rev 910) +++ dcplusplus/trunk/dcpp/ConnectionManager.cpp 2007-11-16 23:11:07 UTC (rev 911) @@ -736,8 +736,6 @@ conn->setFlag(UserConnection::FLAG_SUPPORTS_TTHL); } else if(*i == UserConnection::FEATURE_TTHF) { conn->setFlag(UserConnection::FLAG_SUPPORTS_TTHF); - if(conn->getUser()) - conn->getUser()->setFlag(User::TTH_GET); } } } Modified: dcplusplus/trunk/dcpp/User.cpp =================================================================== --- dcplusplus/trunk/dcpp/User.cpp 2007-11-16 17:34:06 UTC (rev 910) +++ dcplusplus/trunk/dcpp/User.cpp 2007-11-16 23:11:07 UTC (rev 911) @@ -61,6 +61,11 @@ } } +bool Identity::isClientType(ClientType ct) const { + int type = Util::toInt(get("CT")); + return (type & ct) == ct; +} + string Identity::getTag() const { if(!get("TA").empty()) return get("TA"); @@ -69,6 +74,7 @@ return "<" + get("VE") + ",M:" + string(isTcpActive() ? "A" : "P") + ",H:" + get("HN") + "/" + get("HR") + "/" + get("HO") + ",S:" + get("SL") + ">"; } + string Identity::get(const char* name) const { Lock l(cs); InfMap::const_iterator i = info.find(*(short*)name); Modified: dcplusplus/trunk/dcpp/User.h =================================================================== --- dcplusplus/trunk/dcpp/User.h 2007-11-16 17:34:06 UTC (rev 910) +++ dcplusplus/trunk/dcpp/User.h 2007-11-16 23:11:07 UTC (rev 911) @@ -39,7 +39,6 @@ PASSIVE_BIT, NMDC_BIT, BOT_BIT, - TTH_GET_BIT, TLS_BIT, OLD_CLIENT_BIT }; @@ -51,7 +50,6 @@ PASSIVE = 1<<PASSIVE_BIT, NMDC = 1<<NMDC_BIT, BOT = 1<<BOT_BIT, - TTH_GET = 1<<TTH_GET_BIT, //< User supports getting files by tth -> don't have path in queue... TLS = 1<<TLS_BIT, //< Client supports TLS OLD_CLIENT = 1<<OLD_CLIENT_BIT //< Can't download - old client }; @@ -80,7 +78,7 @@ /** One of possibly many identities of a user, mainly for UI purposes */ class Identity : public Flags { public: - enum { + enum IdentityFlagBits { GOT_INF_BIT, NMDC_PASSIVE_BIT }; @@ -88,7 +86,14 @@ GOT_INF = 1 << GOT_INF_BIT, NMDC_PASSIVE = 1 << NMDC_PASSIVE_BIT }; - + enum ClientType { + CT_BOT = 1, + CT_REGGED = 2, + CT_OP = 4, + CT_OWNER = 8, + CT_HUB = 16 + }; + Identity() : sid(0) { } Identity(const UserPtr& ptr, uint32_t aSID) : user(ptr), sid(aSID) { } Identity(const Identity& rhs) : Flags(rhs), user(rhs.user), sid(rhs.sid), info(rhs.info) { } @@ -111,24 +116,26 @@ void setHidden(bool hidden) { set("HI", hidden ? "1" : Util::emptyString); } string getTag() const; bool supports(const string& name) const; - bool isHub() const { return !get("HU").empty(); } - bool isOp() const { return !get("OP").empty(); } - bool isRegistered() const { return !get("RG").empty(); } + bool isHub() const { return isClientType(CT_HUB) || !get("HU").empty(); } + bool isOp() const { return isClientType(CT_OP) || !get("OP").empty(); } + bool isRegistered() const { return isClientType(CT_REGGED) || !get("RG").empty(); } bool isHidden() const { return !get("HI").empty(); } - bool isBot() const { return !get("BO").empty(); } + bool isBot() const { return isClientType(CT_BOT) || !get("BO").empty(); } bool isAway() const { return !get("AW").empty(); } bool isTcpActive() const { return !getIp().empty() || (user->isSet(User::NMDC) && !user->isSet(User::PASSIVE)); } bool isUdpActive() const { return !getIp().empty() && !getUdpPort().empty(); } string get(const char* name) const; void set(const char* name, const string& val); string getSIDString() const { return string((const char*)&sid, 4); } + + bool isClientType(ClientType ct) const; void getParams(StringMap& map, const string& prefix, bool compatibility) const; UserPtr& getUser() { return user; } GETSET(UserPtr, user, User); GETSET(uint32_t, sid, SID); private: - typedef map<short, string> InfMap; + typedef std::tr1::unordered_map<short, string> InfMap; typedef InfMap::iterator InfIter; InfMap info; /** @todo there are probably more threading issues here ...*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |