From 78be5bccf1435a0a6c4799c2cb5654a0d18c9f2b Mon Sep 17 00:00:00 2001 From: upstream svn Date: Sun, 22 Nov 2009 13:20:44 +0000 Subject: [PATCH] Upstream tarball 9882 --- .svn-revision | 2 +- MSVC Solution/aMuleGUI/aMuleGUI.vcproj | 8 ++++---- docs/Changelog | 1 + src/BaseClient.cpp | 2 +- src/Logger.h | 2 ++ src/Makefile.am | 2 +- src/Makefile.in | 2 +- src/OtherFunctions.cpp | 13 +++++-------- src/OtherFunctions.h | 2 +- src/Preferences.cpp | 4 ++++ src/StatTree.cpp | 25 ++++++++++--------------- src/StatTree.h | 34 +++++++++++++++++----------------- src/Statistics.cpp | 14 +++++++------- src/Statistics.h | 6 +++--- src/amule-remote-gui.cpp | 2 +- src/webserver/src/WebInterface.cpp | 2 +- 16 files changed, 60 insertions(+), 61 deletions(-) diff --git a/.svn-revision b/.svn-revision index b6754065..11c74982 100644 --- a/.svn-revision +++ b/.svn-revision @@ -1 +1 @@ -9881 +9882 diff --git a/MSVC Solution/aMuleGUI/aMuleGUI.vcproj b/MSVC Solution/aMuleGUI/aMuleGUI.vcproj index 66965557..9c95d4fe 100644 --- a/MSVC Solution/aMuleGUI/aMuleGUI.vcproj +++ b/MSVC Solution/aMuleGUI/aMuleGUI.vcproj @@ -43,7 +43,7 @@ AdditionalOptions="/MP" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)\..\..\wxWidgets\include";"$(SolutionDir)\..\..\wxWidgets\lib\vc_lib\mswud";"$(SolutionDir)\..\src\libs";"$(SolutionDir)\..\src";"$(SolutionDir)\..\src\include";"$(SolutionDir)\..\..\";"$(SolutionDir)\..\..\wxWidgets\src\zlib";"$(SolutionDir)\libs\libGeoIP"" - PreprocessorDefinitions="_DEBUG;__DEBUG__;USE_WX_EXTENSIONS;CONVAMULE_CPP;_CRT_SECURE_NO_WARNINGS;CLIENT_GUI;EC_REMOTE;ENABLE_NLS;ENABLE_IP2COUNTRY" + PreprocessorDefinitions="_DEBUG;__DEBUG__;USE_WX_EXTENSIONS;CONVAMULE_CPP;_CRT_SECURE_NO_WARNINGS;CLIENT_GUI;ENABLE_NLS;ENABLE_IP2COUNTRY" BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" @@ -121,7 +121,7 @@ AdditionalOptions="/MP" Optimization="3" AdditionalIncludeDirectories=""$(SolutionDir)\..\..\wxWidgets\include";"$(SolutionDir)\..\..\wxWidgets\lib\vc_lib\mswu";"$(SolutionDir)\..\src\libs";"$(SolutionDir)\..\src";"$(SolutionDir)\..\src\include";"$(SolutionDir)\..\..\";"$(SolutionDir)\..\..\wxWidgets\src\zlib";"$(SolutionDir)\libs\libGeoIP"" - PreprocessorDefinitions="USE_WX_EXTENSIONS;CONVAMULE_CPP;_CRT_SECURE_NO_WARNINGS;CLIENT_GUI;EC_REMOTE;ENABLE_NLS;ENABLE_IP2COUNTRY" + PreprocessorDefinitions="USE_WX_EXTENSIONS;CONVAMULE_CPP;_CRT_SECURE_NO_WARNINGS;CLIENT_GUI;ENABLE_NLS;ENABLE_IP2COUNTRY" RuntimeLibrary="0" UsePrecompiledHeader="0" WarningLevel="3" @@ -199,7 +199,7 @@ AdditionalOptions="/MP" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)\..\..\wxWidgets29\include";"$(SolutionDir)\..\..\wxWidgets29\lib\vc_lib\mswud";"$(SolutionDir)\..\src\libs";"$(SolutionDir)\..\src";"$(SolutionDir)\..\src\include";"$(SolutionDir)\..\..\";"$(SolutionDir)\..\..\wxWidgets29\src\zlib";"$(SolutionDir)\libs\libGeoIP"" - PreprocessorDefinitions="_DEBUG;__DEBUG__;USE_WX_EXTENSIONS;CONVAMULE_CPP;_CRT_SECURE_NO_WARNINGS;CLIENT_GUI;EC_REMOTE;ENABLE_NLS;ENABLE_IP2COUNTRY" + PreprocessorDefinitions="_DEBUG;__DEBUG__;USE_WX_EXTENSIONS;CONVAMULE_CPP;_CRT_SECURE_NO_WARNINGS;CLIENT_GUI;ENABLE_NLS;ENABLE_IP2COUNTRY" BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" @@ -277,7 +277,7 @@ AdditionalOptions="/MP" Optimization="3" AdditionalIncludeDirectories=""$(SolutionDir)\..\..\wxWidgets29\include";"$(SolutionDir)\..\..\wxWidgets29\lib\vc_lib\mswu";"$(SolutionDir)\..\src\libs";"$(SolutionDir)\..\src";"$(SolutionDir)\..\src\include";"$(SolutionDir)\..\..\";"$(SolutionDir)\..\..\wxWidgets29\src\zlib";"$(SolutionDir)\libs\libGeoIP"" - PreprocessorDefinitions="USE_WX_EXTENSIONS;CONVAMULE_CPP;_CRT_SECURE_NO_WARNINGS;CLIENT_GUI;EC_REMOTE;ENABLE_NLS;ENABLE_IP2COUNTRY" + PreprocessorDefinitions="USE_WX_EXTENSIONS;CONVAMULE_CPP;_CRT_SECURE_NO_WARNINGS;CLIENT_GUI;ENABLE_NLS;ENABLE_IP2COUNTRY" RuntimeLibrary="0" UsePrecompiledHeader="0" WarningLevel="3" diff --git a/docs/Changelog b/docs/Changelog index 148cd19a..1c5ad236 100644 --- a/docs/Changelog +++ b/docs/Changelog @@ -109,6 +109,7 @@ Version 2.3.0 - The river knows. * Allow passing of ED2K links by command line to amule and amuled, making ed2k program obsolete * Don't ignore current category in amulegui when pasting a link * Amulegui can now be controlled by ed2k + * EC tools (amulegui, amulecmd, amuleweb) can use a local config dir now Vollstrecker: * Unify copyright lines diff --git a/src/BaseClient.cpp b/src/BaseClient.cpp index 7d9ad15a..2ebe547b 100644 --- a/src/BaseClient.cpp +++ b/src/BaseClient.cpp @@ -1723,7 +1723,7 @@ int CUpDownClient::GetHashType() const void CUpDownClient::SetSocket(CClientTCPSocket* socket) { -#if defined(__DEBUG__) && !defined(EC_REMOTE) +#if defined(__DEBUG__) if (m_socket == NULL && socket != NULL) { theStats::SocketAssignedToClient(); } else if (m_socket != NULL && socket == NULL) { diff --git a/src/Logger.h b/src/Logger.h index 2f14609c..e6c4ba42 100644 --- a/src/Logger.h +++ b/src/Logger.h @@ -416,6 +416,8 @@ public: #define AddDebugLogLineC(...) do {} while (false) #define AddLogLineC(...) do {} while (false) #define AddLogLineCS(...) do {} while (false) +#elif defined(EC_REMOTE) // amuleweb, amulecmd + #define AddLogLineN(string) printf("%s\n", (const char *)unicode2char(wxString(string))) #else // Macros passing critical flag (legacy) #define AddDebugLogLineM(critical, type, string) theLogger.AddLogLine(__TFILE__, __LINE__, critical, type, string) diff --git a/src/Makefile.am b/src/Makefile.am index 25004fea..f604875c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -282,7 +282,7 @@ amule_CXXFLAGS = $(AM_CXXFLAGS) $(WX_CFLAGS_ONLY) $(WX_CPPFLAGS_ONLY) amule_LDADD = $(common_libs) $(core_libs) $(gui_libs) amulegui_DEPENDENCIES = $(common_deps) $(gui_deps) -amulegui_CPPFLAGS = $(AM_CPPFLAGS) $(gui_flags) $(common_flags) -DCLIENT_GUI -DEC_REMOTE +amulegui_CPPFLAGS = $(AM_CPPFLAGS) $(gui_flags) $(common_flags) -DCLIENT_GUI amulegui_CXXFLAGS = $(AM_CXXFLAGS) $(WX_CFLAGS_ONLY) $(WX_CXXFLAGS_ONLY) amulegui_LDADD = $(gui_libs) $(common_libs) $(WXBASE_LIBS) diff --git a/src/Makefile.in b/src/Makefile.in index 27237895..2fb57033 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -818,7 +818,7 @@ amule_CPPFLAGS = $(AM_CPPFLAGS) $(core_flags) $(gui_flags) $(common_flags) amule_CXXFLAGS = $(AM_CXXFLAGS) $(WX_CFLAGS_ONLY) $(WX_CPPFLAGS_ONLY) amule_LDADD = $(common_libs) $(core_libs) $(gui_libs) $(am__append_15) amulegui_DEPENDENCIES = $(common_deps) $(gui_deps) $(am__append_18) -amulegui_CPPFLAGS = $(AM_CPPFLAGS) $(gui_flags) $(common_flags) -DCLIENT_GUI -DEC_REMOTE +amulegui_CPPFLAGS = $(AM_CPPFLAGS) $(gui_flags) $(common_flags) -DCLIENT_GUI amulegui_CXXFLAGS = $(AM_CXXFLAGS) $(WX_CFLAGS_ONLY) $(WX_CXXFLAGS_ONLY) amulegui_LDADD = $(gui_libs) $(common_libs) $(WXBASE_LIBS) \ $(am__append_17) diff --git a/src/OtherFunctions.cpp b/src/OtherFunctions.cpp index 73eafc02..5a53c1d9 100644 --- a/src/OtherFunctions.cpp +++ b/src/OtherFunctions.cpp @@ -1087,28 +1087,25 @@ void DumpMem_DW(const uint32 *ptr, int count) } -wxString GetConfigDir() +wxString GetConfigDir(const wxString &configFileBase) { // Cache the path. static wxString configPath; if (configPath.IsEmpty()) { -#ifndef EC_REMOTE // "Portable aMule" - Use aMule from an external USB drive - // Check for ./config/amule.conf and use this configuration if found + // Check for ./config/amule.conf (or whatever gets passed as configFile) + // and use this configuration if found const wxString configDir = JoinPaths(wxFileName::GetCwd(), wxT("config")); - const wxString configFile = JoinPaths(configDir, wxT("amule.conf")); + const wxString configFile = JoinPaths(configDir, configFileBase); if (CPath::DirExists(configDir) && CPath::FileExists(configFile)) { - AddLogLineM(true, CFormat(wxT("Using configDir: %s")) % configDir); + AddLogLineN(CFormat(wxT("Using configDir: %s")) % configDir); configPath = configDir; } else { configPath = wxStandardPaths::Get().GetUserDataDir(); } -#else - configPath = wxStandardPaths::Get().GetUserDataDir(); -#endif configPath += wxFileName::GetPathSeparator(); } diff --git a/src/OtherFunctions.h b/src/OtherFunctions.h index 012eaa69..dd5e789b 100644 --- a/src/OtherFunctions.h +++ b/src/OtherFunctions.h @@ -355,7 +355,7 @@ inline long int make_full_ed2k_version(int a, int b, int c) { } -wxString GetConfigDir(); +wxString GetConfigDir(const wxString &configFile = wxT("amule.conf")); #if !wxCHECK_VERSION(2, 9, 0) enum { diff --git a/src/Preferences.cpp b/src/Preferences.cpp index c99ca151..bb1515d2 100644 --- a/src/Preferences.cpp +++ b/src/Preferences.cpp @@ -829,7 +829,11 @@ public: } else { folder = wxT("webserver"); } +#ifdef CLIENT_GUI + wxString dirName(JoinPaths(GetConfigDir(wxT("remote.conf")), folder)); +#else wxString dirName(JoinPaths(GetConfigDir(), folder)); +#endif wxString Filename; wxDir d; diff --git a/src/StatTree.cpp b/src/StatTree.cpp index 36a47783..24606c25 100644 --- a/src/StatTree.cpp +++ b/src/StatTree.cpp @@ -28,22 +28,21 @@ #include #include "OtherFunctions.h" -#ifndef EC_REMOTE +#ifndef CLIENT_GUI #include // Needed for CFormat #define a_brackets_b(a,b) (a + wxT(" (") + b + wxT(")")) -#endif /* !EC_REMOTE */ +#endif /* !CLIENT_GUI */ #include // Needed for CECTag -#ifdef EC_REMOTE +#ifdef CLIENT_GUI #include // Needed for CEC_StatTree_Node_Tag -#endif +#else -#ifndef EC_REMOTE uint32_t NewStatTreeItemId() { static uint32_t lastid = 0; @@ -54,7 +53,7 @@ uint32_t NewStatTreeItemId() /* CStatTreeItemBase */ -#ifdef EC_REMOTE +#ifdef CLIENT_GUI CStatTreeItemBase::CStatTreeItemBase(const CECTag *tag) : m_label(((CEC_StatTree_Node_Tag*)tag)->GetDisplayString()) , m_uniqueid(tag->GetTagByNameSafe(EC_TAG_STATTREE_NODEID)->GetInt()) @@ -68,14 +67,14 @@ CStatTreeItemBase::CStatTreeItemBase(const CECTag *tag) } } } -#endif /* EC_REMOTE */ +#endif /* CLIENT_GUI */ CStatTreeItemBase::~CStatTreeItemBase() { DeleteContents(m_children); } -#ifndef EC_REMOTE +#ifndef CLIENT_GUI CStatTreeItemBase* CStatTreeItemBase::AddChild( CStatTreeItemBase* child, uint32_t id, @@ -101,7 +100,7 @@ CStatTreeItemBase* CStatTreeItemBase::AddChild( } return child; } -#endif /* !EC_REMOTE */ +#endif /* !CLIENT_GUI */ bool CStatTreeItemBase::HasVisibleChildren() { @@ -116,7 +115,7 @@ bool CStatTreeItemBase::HasVisibleChildren() return false; } -#ifndef EC_REMOTE +#ifndef CLIENT_GUI bool CStatTreeItemBase::HasChildWithId(uint32_t id) { wxMutexLocker lock(m_lock); @@ -142,10 +141,8 @@ CStatTreeItemBase* CStatTreeItemBase::GetChildById(uint32_t id) } return NULL; } -#endif /* !EC_REMOTE */ // Note: these functions do not lock the list, because it is already locked at the time they're called -#ifndef EC_REMOTE StatTreeItemIterator CStatTreeItemBase::GetFirstVisibleChild(uint32_t max_children) { StatTreeItemIterator it = m_children.begin(); @@ -167,12 +164,10 @@ void CStatTreeItemBase::GetNextVisibleChild(StatTreeItemIterator& it) if (it != m_children.end()) ++it; while (it != m_children.end() && !(*it)->IsVisible()) ++it; } -#endif // // Anything below is only for core. // -#ifndef EC_REMOTE bool CStatTreeItemBase::ValueSort(const CStatTreeItemBase* a, const CStatTreeItemBase* b) { @@ -642,5 +637,5 @@ void CStatTreeItemTotalClients::AddECValues(CECTag *tag) const tag->AddTag(value2); } -#endif /* !EC_REMOTE */ +#endif /* !CLIENT_GUI */ // File_checked_for_headers diff --git a/src/StatTree.h b/src/StatTree.h index 5e78d09e..ae1b1e8c 100644 --- a/src/StatTree.h +++ b/src/StatTree.h @@ -36,7 +36,7 @@ */ -#ifndef EC_REMOTE // i.e. not CLIENT_GUI +#ifndef CLIENT_GUI # define VIRTUAL virtual #else # define VIRTUAL @@ -48,7 +48,7 @@ #include // Needed for wxMutex #include "Types.h" -#ifndef EC_REMOTE +#ifndef CLIENT_GUI #include // Needed for wxDateTime #include "GetTickCount.h" // Needed for GetTickCount64() @@ -98,7 +98,7 @@ enum EDisplayMode dmBytes ///< Treat integer value as bytes count. }; -#endif /* !EC_REMOTE */ +#endif /* !CLIENT_GUI */ class CStatTreeItemBase; @@ -117,7 +117,7 @@ class CStatTreeItemBase { public: -#ifndef EC_REMOTE +#ifndef CLIENT_GUI /** * Creates an item with a constant label. * @@ -151,7 +151,7 @@ public: */ VIRTUAL ~CStatTreeItemBase(); -#ifndef EC_REMOTE +#ifndef CLIENT_GUI /** * Adds a new child node. * @@ -181,7 +181,7 @@ public: */ bool HasVisibleChildren(); -#ifndef EC_REMOTE +#ifndef CLIENT_GUI /** * Check for a given child. @@ -211,7 +211,7 @@ public: */ void GetNextVisibleChild(StatTreeItemIterator& it); -#else /* EC_REMOTE */ +#else /* CLIENT_GUI */ /** * Get the first visible child. @@ -229,14 +229,14 @@ public: */ void GetNextVisibleChild(StatTreeItemIterator& it) { ++it; } -#endif /* !EC_REMOTE / EC_REMOTE */ +#endif /* !CLIENT_GUI / CLIENT_GUI */ /** * Check if we are past the end of child list. */ bool IsAtEndOfList(StatTreeItemIterator& it) { return it == m_children.end(); } -#ifndef EC_REMOTE +#ifndef CLIENT_GUI /** * Resorts children for the stSortByValue flag. */ @@ -244,7 +244,7 @@ public: #endif #ifndef AMULE_DAEMON -#ifndef EC_REMOTE +#ifndef CLIENT_GUI /** * Returns a string that will be displayed on the GUI tree. */ @@ -254,7 +254,7 @@ public: * Returns the associated text (GUI item label). */ const wxString& GetDisplayString() const { return m_label; } -#endif /* !EC_REMOTE / EC_REMOTE */ +#endif /* !CLIENT_GUI / CLIENT_GUI */ /** * Returns the mutex used to lock the child list of this node. @@ -275,7 +275,7 @@ public: */ VIRTUAL bool IsVisible() const { return true; } -#ifndef EC_REMOTE +#ifndef CLIENT_GUI /** * Create an EC tag from this node (and children). * @@ -288,7 +288,7 @@ public: protected: -#ifndef EC_REMOTE +#ifndef CLIENT_GUI /** * Add values to the EC tag being generated. * @@ -300,7 +300,7 @@ protected: //! Unformatted and untranslated label of the node. Note: On remote gui it is already formatted and translated. const wxString m_label; -#ifndef EC_REMOTE +#ifndef CLIENT_GUI //! Parent of this node. CStatTreeItemBase *m_parent; @@ -311,7 +311,7 @@ protected: private: -#ifndef EC_REMOTE +#ifndef CLIENT_GUI //! Function used when sorting children by value. static bool ValueSort(const CStatTreeItemBase* a, const CStatTreeItemBase* b); @@ -337,7 +337,7 @@ private: // // Anything below is only for core. // -#ifndef EC_REMOTE +#ifndef CLIENT_GUI /** * Simple tree item. @@ -1194,7 +1194,7 @@ protected: const CStatTreeItemCounter *m_unknown; }; -#endif /* !EC_REMOTE */ +#endif /* !CLIENT_GUI */ #endif /* STATTREE_H */ // File_checked_for_headers diff --git a/src/Statistics.cpp b/src/Statistics.cpp index 87ccae59..b823ecea 100644 --- a/src/Statistics.cpp +++ b/src/Statistics.cpp @@ -30,7 +30,7 @@ #include // Needed for CECTag -#ifndef EC_REMOTE +#ifndef CLIENT_GUI #ifndef AMULE_DAEMON #include // Needed for CFormat #endif @@ -56,7 +56,7 @@ #endif /* __BSD__ */ -#ifndef EC_REMOTE +#ifndef CLIENT_GUI /*----- CPreciseRateCounter -----*/ @@ -139,17 +139,17 @@ CPreciseRateCounter* CStatistics::s_downOverheadRate; CStatTreeItemRateCounter* CStatistics::s_uploadrate; CStatTreeItemRateCounter* CStatistics::s_downloadrate; -#else /* EC_REMOTE */ +#else /* CLIENT_GUI */ uint64 CStatistics::s_start_time; uint64 CStatistics::s_statData[sdTotalItems]; -#endif /* !EC_REMOTE / EC_REMOTE */ +#endif /* !CLIENT_GUI / CLIENT_GUI */ // Tree root CStatTreeItemBase* CStatistics::s_statTree; -#ifndef EC_REMOTE +#ifndef CLIENT_GUI // Uptime CStatTreeItemTimer* CStatistics::s_uptime; @@ -925,7 +925,7 @@ void CStatistics::RemoveKnownClient(uint32 clientSoft, uint32 clientVersion, con } } -#else /* EC_REMOTE (CLIENT_GUI) */ +#else /* CLIENT_GUI */ CStatistics::CStatistics(CRemoteConnect &conn) : @@ -997,6 +997,6 @@ void CStatistics::UpdateStatsTree() delete reply; } -#endif /* !EC_REMOTE */ +#endif /* !CLIENT_GUI */ // File_checked_for_headers diff --git a/src/Statistics.h b/src/Statistics.h index a4cc38a4..232ddf5f 100644 --- a/src/Statistics.h +++ b/src/Statistics.h @@ -62,7 +62,7 @@ typedef struct HistoryRecord { } HR; -#ifndef EC_REMOTE +#ifndef CLIENT_GUI /** * Counts precise rate/average on added bytes/values. @@ -470,7 +470,7 @@ class CStatistics { static uint16 s_kadNodesCur; }; -#else /* EC_REMOTE == CLIENT_GUI */ +#else /* CLIENT_GUI */ class CECPacket; class CRemoteConnect; @@ -553,7 +553,7 @@ private: static CStatTreeItemBase* GetTreeRoot() { return s_statTree; } }; -#endif /* !EC_REMOTE / EC_REMOTE */ +#endif /* !CLIENT_GUI / CLIENT_GUI */ /** diff --git a/src/amule-remote-gui.cpp b/src/amule-remote-gui.cpp index 73276ab6..01c1f792 100644 --- a/src/amule-remote-gui.cpp +++ b/src/amule-remote-gui.cpp @@ -283,7 +283,7 @@ bool CamuleRemoteGuiApp::OnInit() // Load Preferences // This creates the CFG file we shall use - ConfigDir = GetConfigDir(); + ConfigDir = GetConfigDir(wxT("remote.conf")); if (!wxDirExists(ConfigDir)) { wxMkdir(ConfigDir); } diff --git a/src/webserver/src/WebInterface.cpp b/src/webserver/src/WebInterface.cpp index 43e7e781..9bad77e1 100644 --- a/src/webserver/src/WebInterface.cpp +++ b/src/webserver/src/WebInterface.cpp @@ -480,7 +480,7 @@ bool CamulewebApp::GetTemplateDir(const wxString& templateName, wxString& templa } #endif - dir = GetConfigDir() + wxT("webserver"); + dir = GetConfigDir(wxT("remote.conf")) + wxT("webserver"); if (CheckDirForTemplate(dir, templateName)) { templateDir = dir; m_localTemplate = true; -- 2.11.4.GIT