2008-09-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Removed CookieBox, CookieBoxFactory.
	* src/CookieBox.cc
	* src/CookieBox.h
	* src/CookieBoxFactory.cc
	* src/CookieBoxFactory.h
	* src/Makefile.am
This commit is contained in:
Tatsuhiro Tsujikawa 2008-09-01 13:57:44 +00:00
parent e7633f2939
commit 2152b20ba4
7 changed files with 32 additions and 333 deletions

View File

@ -1,3 +1,12 @@
2008-09-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed CookieBox, CookieBoxFactory.
* src/CookieBox.cc
* src/CookieBox.h
* src/CookieBoxFactory.cc
* src/CookieBoxFactory.h
* src/Makefile.am
2008-09-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use CookieStorage class instead of CookieBox class.

View File

@ -1,72 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "CookieBox.h"
#include "CookieParser.h"
namespace aria2 {
CookieBox::CookieBox() {}
CookieBox::~CookieBox() {}
void CookieBox::add(const Cookie& cookie) {
cookies.push_back(cookie);
}
void CookieBox::add(const std::string& cookieStr, const std::string& defaultDomain, const std::string& defaultPath)
{
Cookie c = CookieParser().parse(cookieStr, defaultDomain, defaultPath);
if(c.good()) {
cookies.push_back(c);
}
}
void CookieBox::add(const Cookies& cookies)
{
this->cookies.insert(this->cookies.end(), cookies.begin(), cookies.end());
}
Cookies CookieBox::criteriaFind(const std::string& host, const std::string& dir, time_t date, bool secure) const {
Cookies result;
for(Cookies::const_iterator itr = cookies.begin(); itr != cookies.end(); itr++) {
const Cookie& c = *itr;
if(c.match(host, dir, date, secure)) {
result.push_back(c);
}
}
return result;
}
} // namespace aria2

View File

@ -1,63 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_COOKIE_BOX_H_
#define _D_COOKIE_BOX_H_
#include "common.h"
#include "SharedHandle.h"
#include "Cookie.h"
#include "a2time.h"
namespace aria2 {
class CookieBox {
private:
Cookies cookies;
public:
CookieBox();
~CookieBox();
void clear();
void add(const Cookie& cookie);
void add(const std::string& cookieStr,
const std::string& defaultDomain, const std::string& defaultPath);
void add(const Cookies& cookies);
Cookies criteriaFind(const std::string& host, const std::string& dir, time_t date, bool secure) const;
};
typedef SharedHandle<CookieBox> CookieBoxHandle;
} // namespace aria2
#endif // _D_COOKIE_BOX_H_

View File

@ -1,91 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "CookieBoxFactory.h"
#include "CookieParser.h"
#include "CookieBox.h"
#include "Util.h"
#include "RecoverableException.h"
#include "LogFactory.h"
#include "Logger.h"
#include "NsCookieParser.h"
#ifdef HAVE_SQLITE3
# include "Sqlite3MozCookieParser.h"
#endif // HAVE_SQLITE3
#include <fstream>
#include <iomanip>
namespace aria2 {
CookieBoxFactory::CookieBoxFactory():_logger(LogFactory::getInstance()) {}
CookieBoxFactory::~CookieBoxFactory() {}
CookieBoxHandle CookieBoxFactory::createNewInstance()
{
CookieBoxHandle box(new CookieBox());
box->add(defaultCookies);
return box;
}
void CookieBoxFactory::loadDefaultCookie(const std::string& filename)
{
char header[16]; // "SQLite format 3" plus \0
{
std::ifstream s(filename.c_str());
s.get(header, sizeof(header));
if(s.bad()) {
_logger->error("Failed to read header of cookie file %s",
filename.c_str());
return;
}
}
try {
if(std::string(header) == "SQLite format 3") {
#ifdef HAVE_SQLITE3
defaultCookies = Sqlite3MozCookieParser().parse(filename);
#else // !HAVE_SQLITE3
_logger->notice("Cannot read SQLite3 database because SQLite3 support is"
" disabled by configuration.");
#endif // !HAVE_SQLITE3
} else {
defaultCookies = NsCookieParser().parse(filename);
}
} catch(RecoverableException& e) {
_logger->error("Failed to load cookies from %s, cause: %s",
filename.c_str(), e.what());
}
}
} // namespace aria2

View File

@ -1,75 +0,0 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2006 Tatsuhiro Tsujikawa
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#ifndef _D_COOKIE_BOX_FACTORY_H_
#define _D_COOKIE_BOX_FACTORY_H_
#include "common.h"
#include "SharedHandle.h"
#include "Cookie.h"
#include "SingletonHolder.h"
#include <string>
#include <iosfwd>
namespace aria2 {
class CookieBox;
class Logger;
class CookieBoxFactory {
private:
Cookies defaultCookies;
Logger* _logger;
public:
CookieBoxFactory();
~CookieBoxFactory();
SharedHandle<CookieBox> createNewInstance();
void loadDefaultCookie(const std::string& filename);
const Cookies& getDefaultCookies() const
{
return defaultCookies;
}
};
typedef SharedHandle<CookieBoxFactory> CookieBoxFactoryHandle;
typedef SingletonHolder<CookieBoxFactoryHandle> CookieBoxFactorySingletonHolder;
} // namespace aria2
#endif // _D_COOKIE_BOX_FACTORY_H_

View File

@ -49,7 +49,6 @@ SRCS = Socket.h\
File.cc File.h\
Option.cc Option.h\
Base64.cc Base64.h\
CookieBox.cc CookieBox.h\
LogFactory.cc LogFactory.h\
NullLogger.h\
TimeA2.cc TimeA2.h\
@ -100,7 +99,6 @@ SRCS = Socket.h\
RequestGroupEntry.cc RequestGroupEntry.h\
Cookie.cc Cookie.h\
CookieParser.cc CookieParser.h\
CookieBoxFactory.cc CookieBoxFactory.h\
HttpHeaderProcessor.cc HttpHeaderProcessor.h\
FileEntry.cc FileEntry.h\
Platform.cc Platform.h\

View File

@ -324,15 +324,14 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
AbstractDiskWriter.cc AbstractDiskWriter.h \
DefaultDiskWriter.cc DefaultDiskWriter.h \
DefaultDiskWriterFactory.cc DefaultDiskWriterFactory.h File.cc \
File.h Option.cc Option.h Base64.cc Base64.h CookieBox.cc \
CookieBox.h LogFactory.cc LogFactory.h NullLogger.h TimeA2.cc \
TimeA2.h SharedHandle.h HandleRegistry.h FeatureConfig.cc \
FeatureConfig.h DownloadEngineFactory.cc \
DownloadEngineFactory.h SpeedCalc.cc SpeedCalc.h PeerStat.h \
BitfieldMan.cc BitfieldMan.h BitfieldManFactory.cc \
BitfieldManFactory.h Randomizer.h SimpleRandomizer.cc \
SimpleRandomizer.h HttpResponse.cc HttpResponse.h \
HttpRequest.cc HttpRequest.h Range.h \
File.h Option.cc Option.h Base64.cc Base64.h LogFactory.cc \
LogFactory.h NullLogger.h TimeA2.cc TimeA2.h SharedHandle.h \
HandleRegistry.h FeatureConfig.cc FeatureConfig.h \
DownloadEngineFactory.cc DownloadEngineFactory.h SpeedCalc.cc \
SpeedCalc.h PeerStat.h BitfieldMan.cc BitfieldMan.h \
BitfieldManFactory.cc BitfieldManFactory.h Randomizer.h \
SimpleRandomizer.cc SimpleRandomizer.h HttpResponse.cc \
HttpResponse.h HttpRequest.cc HttpRequest.h Range.h \
AbstractProxyRequestCommand.cc AbstractProxyRequestCommand.h \
AbstractProxyResponseCommand.cc AbstractProxyResponseCommand.h \
Netrc.cc Netrc.h AuthConfig.cc AuthConfig.h AuthResolver.h \
@ -356,8 +355,7 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
DefaultSegmentManFactory.cc DefaultSegmentManFactory.h \
RealtimeCommand.cc RealtimeCommand.h ProgressAwareEntry.h \
RequestGroupEntry.cc RequestGroupEntry.h Cookie.cc Cookie.h \
CookieParser.cc CookieParser.h CookieBoxFactory.cc \
CookieBoxFactory.h HttpHeaderProcessor.cc \
CookieParser.cc CookieParser.h HttpHeaderProcessor.cc \
HttpHeaderProcessor.h FileEntry.cc FileEntry.h Platform.cc \
Platform.h PStringDatum.h PStringSegment.cc PStringSegment.h \
PStringNumLoop.h PStringSelect.h PStringVisitor.h \
@ -755,8 +753,8 @@ am__objects_18 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
Request.$(OBJEXT) Exception.$(OBJEXT) SimpleLogger.$(OBJEXT) \
AbstractDiskWriter.$(OBJEXT) DefaultDiskWriter.$(OBJEXT) \
DefaultDiskWriterFactory.$(OBJEXT) File.$(OBJEXT) \
Option.$(OBJEXT) Base64.$(OBJEXT) CookieBox.$(OBJEXT) \
LogFactory.$(OBJEXT) TimeA2.$(OBJEXT) FeatureConfig.$(OBJEXT) \
Option.$(OBJEXT) Base64.$(OBJEXT) LogFactory.$(OBJEXT) \
TimeA2.$(OBJEXT) FeatureConfig.$(OBJEXT) \
DownloadEngineFactory.$(OBJEXT) SpeedCalc.$(OBJEXT) \
BitfieldMan.$(OBJEXT) BitfieldManFactory.$(OBJEXT) \
SimpleRandomizer.$(OBJEXT) HttpResponse.$(OBJEXT) \
@ -776,10 +774,9 @@ am__objects_18 = SocketCore.$(OBJEXT) Command.$(OBJEXT) \
MultiUrlRequestInfo.$(OBJEXT) UriListParser.$(OBJEXT) \
DefaultSegmentManFactory.$(OBJEXT) RealtimeCommand.$(OBJEXT) \
RequestGroupEntry.$(OBJEXT) Cookie.$(OBJEXT) \
CookieParser.$(OBJEXT) CookieBoxFactory.$(OBJEXT) \
HttpHeaderProcessor.$(OBJEXT) FileEntry.$(OBJEXT) \
Platform.$(OBJEXT) PStringSegment.$(OBJEXT) \
PStringBuildVisitor.$(OBJEXT) \
CookieParser.$(OBJEXT) HttpHeaderProcessor.$(OBJEXT) \
FileEntry.$(OBJEXT) Platform.$(OBJEXT) \
PStringSegment.$(OBJEXT) PStringBuildVisitor.$(OBJEXT) \
ParameterizedStringParser.$(OBJEXT) TimeBasedCommand.$(OBJEXT) \
AutoSaveCommand.$(OBJEXT) DefaultPieceStorage.$(OBJEXT) \
UnknownLengthPieceStorage.$(OBJEXT) ConsoleStatCalc.$(OBJEXT) \
@ -1049,15 +1046,14 @@ SRCS = Socket.h SocketCore.cc SocketCore.h BinaryStream.h Command.cc \
AbstractDiskWriter.cc AbstractDiskWriter.h \
DefaultDiskWriter.cc DefaultDiskWriter.h \
DefaultDiskWriterFactory.cc DefaultDiskWriterFactory.h File.cc \
File.h Option.cc Option.h Base64.cc Base64.h CookieBox.cc \
CookieBox.h LogFactory.cc LogFactory.h NullLogger.h TimeA2.cc \
TimeA2.h SharedHandle.h HandleRegistry.h FeatureConfig.cc \
FeatureConfig.h DownloadEngineFactory.cc \
DownloadEngineFactory.h SpeedCalc.cc SpeedCalc.h PeerStat.h \
BitfieldMan.cc BitfieldMan.h BitfieldManFactory.cc \
BitfieldManFactory.h Randomizer.h SimpleRandomizer.cc \
SimpleRandomizer.h HttpResponse.cc HttpResponse.h \
HttpRequest.cc HttpRequest.h Range.h \
File.h Option.cc Option.h Base64.cc Base64.h LogFactory.cc \
LogFactory.h NullLogger.h TimeA2.cc TimeA2.h SharedHandle.h \
HandleRegistry.h FeatureConfig.cc FeatureConfig.h \
DownloadEngineFactory.cc DownloadEngineFactory.h SpeedCalc.cc \
SpeedCalc.h PeerStat.h BitfieldMan.cc BitfieldMan.h \
BitfieldManFactory.cc BitfieldManFactory.h Randomizer.h \
SimpleRandomizer.cc SimpleRandomizer.h HttpResponse.cc \
HttpResponse.h HttpRequest.cc HttpRequest.h Range.h \
AbstractProxyRequestCommand.cc AbstractProxyRequestCommand.h \
AbstractProxyResponseCommand.cc AbstractProxyResponseCommand.h \
Netrc.cc Netrc.h AuthConfig.cc AuthConfig.h AuthResolver.h \
@ -1081,8 +1077,7 @@ SRCS = Socket.h SocketCore.cc SocketCore.h BinaryStream.h Command.cc \
DefaultSegmentManFactory.cc DefaultSegmentManFactory.h \
RealtimeCommand.cc RealtimeCommand.h ProgressAwareEntry.h \
RequestGroupEntry.cc RequestGroupEntry.h Cookie.cc Cookie.h \
CookieParser.cc CookieParser.h CookieBoxFactory.cc \
CookieBoxFactory.h HttpHeaderProcessor.cc \
CookieParser.cc CookieParser.h HttpHeaderProcessor.cc \
HttpHeaderProcessor.h FileEntry.cc FileEntry.h Platform.cc \
Platform.h PStringDatum.h PStringSegment.cc PStringSegment.h \
PStringNumLoop.h PStringSelect.h PStringVisitor.h \
@ -1296,8 +1291,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConsoleStatCalc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ContentTypeRequestGroupCriteria.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cookie.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CookieBox.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CookieBoxFactory.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CookieParser.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CookieStorage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CopyDiskAdaptor.Po@am__quote@