This repository has been archived by the owner on Nov 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#351: refactor: moved changeable state into new Unit "WorkState.cpp"
from Unit “Options.cpp”. The latter now contains only program options (which cannot be changed without reload).
- Loading branch information
Showing
26 changed files
with
235 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 1,7 @@ | ||
# | ||
# This file is part of nzbget. See <http://nzbget.net>. | ||
# | ||
# Copyright (C) 2008-2016 Andrey Prygunkov <[email protected]> | ||
# Copyright (C) 2008-2019 Andrey Prygunkov <[email protected]> | ||
# | ||
# 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 | ||
|
@@ -68,6 68,8 @@ nzbget_SOURCES = \ | |
daemon/main/nzbget.h \ | ||
daemon/main/Options.cpp \ | ||
daemon/main/Options.h \ | ||
daemon/main/WorkState.cpp \ | ||
daemon/main/WorkState.h \ | ||
daemon/main/Scheduler.cpp \ | ||
daemon/main/Scheduler.h \ | ||
daemon/main/StackTrace.cpp \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 17,7 @@ | |
# | ||
# This file is part of nzbget. See <http://nzbget.net>. | ||
# | ||
# Copyright (C) 2008-2016 Andrey Prygunkov <[email protected]> | ||
# Copyright (C) 2008-2019 Andrey Prygunkov <[email protected]> | ||
# | ||
# 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 | ||
|
@@ -232,7 232,8 @@ am__nzbget_SOURCES_DIST = daemon/connect/Connection.cpp \ | |
daemon/main/DiskService.h daemon/main/Maintenance.cpp \ | ||
daemon/main/Maintenance.h daemon/main/nzbget.cpp \ | ||
daemon/main/nzbget.h daemon/main/Options.cpp \ | ||
daemon/main/Options.h daemon/main/Scheduler.cpp \ | ||
daemon/main/Options.h daemon/main/WorkState.cpp \ | ||
daemon/main/WorkState.h daemon/main/Scheduler.cpp \ | ||
daemon/main/Scheduler.h daemon/main/StackTrace.cpp \ | ||
daemon/main/StackTrace.h daemon/nntp/ArticleDownloader.cpp \ | ||
daemon/nntp/ArticleDownloader.h daemon/nntp/ArticleWriter.cpp \ | ||
|
@@ -387,7 388,8 @@ am_nzbget_OBJECTS = daemon/connect/Connection.$(OBJEXT) \ | |
daemon/main/CommandLineParser.$(OBJEXT) \ | ||
daemon/main/DiskService.$(OBJEXT) \ | ||
daemon/main/Maintenance.$(OBJEXT) daemon/main/nzbget.$(OBJEXT) \ | ||
daemon/main/Options.$(OBJEXT) daemon/main/Scheduler.$(OBJEXT) \ | ||
daemon/main/Options.$(OBJEXT) daemon/main/WorkState.$(OBJEXT) \ | ||
daemon/main/Scheduler.$(OBJEXT) \ | ||
daemon/main/StackTrace.$(OBJEXT) \ | ||
daemon/nntp/ArticleDownloader.$(OBJEXT) \ | ||
daemon/nntp/ArticleWriter.$(OBJEXT) \ | ||
|
@@ -720,7 722,8 @@ nzbget_SOURCES = daemon/connect/Connection.cpp \ | |
daemon/main/DiskService.h daemon/main/Maintenance.cpp \ | ||
daemon/main/Maintenance.h daemon/main/nzbget.cpp \ | ||
daemon/main/nzbget.h daemon/main/Options.cpp \ | ||
daemon/main/Options.h daemon/main/Scheduler.cpp \ | ||
daemon/main/Options.h daemon/main/WorkState.cpp \ | ||
daemon/main/WorkState.h daemon/main/Scheduler.cpp \ | ||
daemon/main/Scheduler.h daemon/main/StackTrace.cpp \ | ||
daemon/main/StackTrace.h daemon/nntp/ArticleDownloader.cpp \ | ||
daemon/nntp/ArticleDownloader.h daemon/nntp/ArticleWriter.cpp \ | ||
|
@@ -1158,6 1161,8 @@ daemon/main/nzbget.$(OBJEXT): daemon/main/$(am__dirstamp) \ | |
daemon/main/$(DEPDIR)/$(am__dirstamp) | ||
daemon/main/Options.$(OBJEXT): daemon/main/$(am__dirstamp) \ | ||
daemon/main/$(DEPDIR)/$(am__dirstamp) | ||
daemon/main/WorkState.$(OBJEXT): daemon/main/$(am__dirstamp) \ | ||
daemon/main/$(DEPDIR)/$(am__dirstamp) | ||
daemon/main/Scheduler.$(OBJEXT): daemon/main/$(am__dirstamp) \ | ||
daemon/main/$(DEPDIR)/$(am__dirstamp) | ||
daemon/main/StackTrace.$(OBJEXT): daemon/main/$(am__dirstamp) \ | ||
|
@@ -1553,6 1558,7 @@ distclean-compile: | |
@AMDEP_TRUE@@am__include@ @am__quote@daemon/main/$(DEPDIR)/Options.Po@am__quote@ | ||
@AMDEP_TRUE@@am__include@ @am__quote@daemon/main/$(DEPDIR)/Scheduler.Po@am__quote@ | ||
@AMDEP_TRUE@@am__include@ @am__quote@daemon/main/$(DEPDIR)/StackTrace.Po@am__quote@ | ||
@AMDEP_TRUE@@am__include@ @am__quote@daemon/main/$(DEPDIR)/WorkState.Po@am__quote@ | ||
@AMDEP_TRUE@@am__include@ @am__quote@daemon/main/$(DEPDIR)/nzbget.Po@am__quote@ | ||
@AMDEP_TRUE@@am__include@ @am__quote@daemon/nntp/$(DEPDIR)/ArticleDownloader.Po@am__quote@ | ||
@AMDEP_TRUE@@am__include@ @am__quote@daemon/nntp/$(DEPDIR)/ArticleWriter.Po@am__quote@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 1,7 @@ | ||
/* | ||
* This file is part of nzbget. See <http://nzbget.net>. | ||
* | ||
* Copyright (C) 2012-2016 Andrey Prygunkov <[email protected]> | ||
* Copyright (C) 2012-2019 Andrey Prygunkov <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -22,6 22,7 @@ | |
#include "WebDownloader.h" | ||
#include "Log.h" | ||
#include "Options.h" | ||
#include "WorkState.h" | ||
#include "Util.h" | ||
#include "FileSystem.h" | ||
|
||
|
@@ -72,19 73,19 @@ void WebDownloader::Run() | |
|
||
if ((((Status == adFailed) && (remainedDownloadRetries > 1)) || | ||
((Status == adConnectError) && (remainedConnectRetries > 1))) | ||
&& !IsStopped() && !(!m_force && g_Options->GetPauseDownload())) | ||
&& !IsStopped() && !(!m_force && g_WorkState->GetPauseDownload())) | ||
{ | ||
detail("Waiting %i sec to retry", g_Options->GetUrlInterval()); | ||
int msec = 0; | ||
while (!IsStopped() && (msec < g_Options->GetUrlInterval() * 1000) && | ||
!(!m_force && g_Options->GetPauseDownload())) | ||
!(!m_force && g_WorkState->GetPauseDownload())) | ||
{ | ||
usleep(100 * 1000); | ||
msec = 100; | ||
} | ||
} | ||
|
||
if (IsStopped() || (!m_force && g_Options->GetPauseDownload())) | ||
if (IsStopped() || (!m_force && g_WorkState->GetPauseDownload())) | ||
{ | ||
Status = adRetry; | ||
break; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 1,7 @@ | ||
/* | ||
* This file is part of nzbget. See <http://nzbget.net>. | ||
* | ||
* Copyright (C) 2007-2016 Andrey Prygunkov <[email protected]> | ||
* Copyright (C) 2007-2019 Andrey Prygunkov <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -23,6 23,7 @@ | |
#include "Log.h" | ||
#include "Util.h" | ||
#include "Options.h" | ||
#include "WorkState.h" | ||
|
||
static const int POSTPROCESS_PARCHECK = 92; | ||
static const int POSTPROCESS_SUCCESS = 93; | ||
|
@@ -272,14 273,14 @@ void PostScriptController::AddMessage(Message::EKind kind, const char* text) | |
m_postInfo->SetProgressLabel(text); | ||
} | ||
|
||
if (g_Options->GetPausePostProcess() && !m_postInfo->GetNzbInfo()->GetForcePriority()) | ||
if (g_WorkState->GetPausePostProcess() && !m_postInfo->GetNzbInfo()->GetForcePriority()) | ||
{ | ||
time_t stageTime = m_postInfo->GetStageTime(); | ||
time_t startTime = m_postInfo->GetStartTime(); | ||
time_t waitTime = Util::CurrentTime(); | ||
|
||
// wait until Post-processor is unpaused | ||
while (g_Options->GetPausePostProcess() && !m_postInfo->GetNzbInfo()->GetForcePriority() && !IsStopped()) | ||
while (g_WorkState->GetPausePostProcess() && !m_postInfo->GetNzbInfo()->GetForcePriority() && !IsStopped()) | ||
{ | ||
usleep(100 * 1000); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 2,7 @@ | |
* This file is part of nzbget. See <http://nzbget.net>. | ||
* | ||
* Copyright (C) 2004 Sven Henkel <[email protected]> | ||
* Copyright (C) 2007-2016 Andrey Prygunkov <[email protected]> | ||
* Copyright (C) 2007-2019 Andrey Prygunkov <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -21,6 21,7 @@ | |
|
||
#include "nzbget.h" | ||
#include "Options.h" | ||
#include "WorkState.h" | ||
#include "Frontend.h" | ||
#include "Log.h" | ||
#include "Connection.h" | ||
|
@@ -57,8 58,8 @@ bool Frontend::PrepareData() | |
if (m_summary) | ||
{ | ||
m_currentDownloadSpeed = g_StatMeter->CalcCurrentDownloadSpeed(); | ||
m_pauseDownload = g_Options->GetPauseDownload(); | ||
m_downloadLimit = g_Options->GetDownloadRate(); | ||
m_pauseDownload = g_WorkState->GetPauseDownload(); | ||
m_downloadLimit = g_WorkState->GetSpeedLimit(); | ||
m_threadCount = Thread::GetThreadCount(); | ||
g_StatMeter->CalcTotalStat(&m_upTimeSec, &m_dnTimeSec, &m_allBytes, &m_standBy); | ||
|
||
|
@@ -108,8 109,8 @@ void Frontend::ServerPauseUnpause(bool pause) | |
} | ||
else | ||
{ | ||
g_Options->SetResumeTime(0); | ||
g_Options->SetPauseDownload(pause); | ||
g_WorkState->SetResumeTime(0); | ||
g_WorkState->SetPauseDownload(pause); | ||
} | ||
} | ||
|
||
|
@@ -121,7 122,7 @@ void Frontend::ServerSetDownloadRate(int rate) | |
} | ||
else | ||
{ | ||
g_Options->SetDownloadRate(rate); | ||
g_WorkState->SetSpeedLimit(rate); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 2,7 @@ | |
* This file is part of nzbget. See <http://nzbget.net>. | ||
* | ||
* Copyright (C) 2004 Sven Henkel <[email protected]> | ||
* Copyright (C) 2007-2016 Andrey Prygunkov <[email protected]> | ||
* Copyright (C) 2007-2019 Andrey Prygunkov <[email protected]> | ||
* | ||
* 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 1,7 @@ | ||
/* | ||
* This file is part of nzbget. See <http://nzbget.net>. | ||
* | ||
* Copyright (C) 2007-2016 Andrey Prygunkov <[email protected]> | ||
* Copyright (C) 2007-2019 Andrey Prygunkov <[email protected]> | ||
* | ||
* 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 2,7 @@ | |
* This file is part of nzbget. See <http://nzbget.net>. | ||
* | ||
* Copyright (C) 2004 Sven Henkel <[email protected]> | ||
* Copyright (C) 2007-2016 Andrey Prygunkov <[email protected]> | ||
* Copyright (C) 2007-2019 Andrey Prygunkov <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -300,6 300,7 @@ class Options | |
bool GetDirectRename() { return m_directRename; } | ||
bool GetReorderFiles() { return m_reorderFiles; } | ||
EFileNaming GetFileNaming() { return m_fileNaming; } | ||
int GetDownloadRate() const { return m_downloadRate; } | ||
|
||
Categories* GetCategories() { return &m_categories; } | ||
Category* FindCategory(const char* name, bool searchAliases) { return m_categories.FindCategory(name, searchAliases); } | ||
|
@@ -311,24 312,6 @@ class Options | |
bool GetDaemonMode() { return m_daemonMode; } | ||
void SetRemoteClientMode(bool remoteClientMode) { m_remoteClientMode = remoteClientMode; } | ||
bool GetRemoteClientMode() { return m_remoteClientMode; } | ||
void SetPauseDownload(bool pauseDownload) { m_pauseDownload = pauseDownload; } | ||
bool GetPauseDownload() const { return m_pauseDownload; } | ||
void SetPausePostProcess(bool pausePostProcess) { m_pausePostProcess = pausePostProcess; } | ||
bool GetPausePostProcess() const { return m_pausePostProcess; } | ||
void SetPauseScan(bool pauseScan) { m_pauseScan = pauseScan; } | ||
bool GetPauseScan() const { return m_pauseScan; } | ||
void SetTempPauseDownload(bool tempPauseDownload) { m_tempPauseDownload = tempPauseDownload; } | ||
bool GetTempPauseDownload() const { return m_tempPauseDownload; } | ||
bool GetTempPausePostprocess() const { return m_tempPausePostprocess; } | ||
void SetTempPausePostprocess(bool tempPausePostprocess) { m_tempPausePostprocess = tempPausePostprocess; } | ||
void SetDownloadRate(int rate) { m_downloadRate = rate; } | ||
int GetDownloadRate() const { return m_downloadRate; } | ||
void SetResumeTime(time_t resumeTime) { m_resumeTime = resumeTime; } | ||
time_t GetResumeTime() const { return m_resumeTime; } | ||
void SetLocalTimeOffset(int localTimeOffset) { m_localTimeOffset = localTimeOffset; } | ||
int GetLocalTimeOffset() { return m_localTimeOffset; } | ||
void SetQuotaReached(bool quotaReached) { m_quotaReached = quotaReached; } | ||
bool GetQuotaReached() { return m_quotaReached; } | ||
|
||
private: | ||
OptEntries m_optEntries; | ||
|
@@ -450,20 433,12 @@ class Options | |
int m_dailyQuota = 0; | ||
bool m_reorderFiles = false; | ||
EFileNaming m_fileNaming = nfArticle; | ||
int m_downloadRate = 0; | ||
|
||
// Current state | ||
// Application mode | ||
bool m_serverMode = false; | ||
bool m_daemonMode = false; | ||
bool m_remoteClientMode = false; | ||
bool m_pauseDownload = false; | ||
bool m_pausePostProcess = false; | ||
bool m_pauseScan = false; | ||
bool m_tempPauseDownload = true; | ||
bool m_tempPausePostprocess = true; | ||
int m_downloadRate = 0; | ||
time_t m_resumeTime = 0; | ||
int m_localTimeOffset = 0; | ||
bool m_quotaReached = false; | ||
|
||
void Init(const char* exeName, const char* configFilename, bool noConfig, | ||
CmdOptList* commandLineOptions, bool noDiskAccess, Extender* extender); | ||
|
Oops, something went wrong.