Skip to content

Commit 39cda2f

Browse files
committed
- avoid usage of additional _DebugMode in FTPSettings by making FTPSettings::m_debugMode and corresponding setter/getter static
- make further methods const
1 parent 60f1173 commit 39cda2f

File tree

6 files changed

+66
-68
lines changed

6 files changed

+66
-68
lines changed

src/FTPSettings.cpp

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/*
2-
NppFTP: FTP/SFTP functionality for Notepad++
3-
Copyright (C) 2010 Harry (harrybharry@users.sourceforge.net)
2+
NppFTP: FTP/SFTP functionality for Notepad++
3+
Copyright (C) 2010 Harry (harrybharry@users.sourceforge.net)
44
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
99
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU General Public License for more details.
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
1414
15-
You should have received a copy of the GNU General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

1919
#include "StdInc.h"
@@ -22,7 +22,7 @@
2222
#include "Encryption.h"
2323
#include "InputDialog.h"
2424

25-
bool _DebugMode = false;
25+
bool FTPSettings::m_debugMode = false;
2626

2727
FTPSettings::FTPSettings() :
2828
m_clearCache(false),
@@ -32,7 +32,7 @@ FTPSettings::FTPSettings() :
3232
{
3333
m_globalCachePath = SU::DupString(TEXT("%CONFIGDIR%\\Cache\\%USERNAME%@%HOSTNAME%"));
3434

35-
PathMap globalPathmap;
35+
PathMap globalPathmap{};
3636
globalPathmap.localpath = SU::DupString(m_globalCachePath);
3737
globalPathmap.externalpath = SU::strdup("/");
3838
m_globalCache.Clear();
@@ -53,7 +53,7 @@ int FTPSettings::SetGlobalCachePath(const TCHAR * path) {
5353
path = TEXT("%CONFIGDIR%\\Cache\\%USERNAME%@%HOSTNAME%\\%PORT%");
5454
}
5555

56-
PathMap globalPathmap;
56+
PathMap globalPathmap{};
5757
globalPathmap.localpath = SU::DupString(path);
5858
globalPathmap.externalpath = SU::strdup("/");
5959
m_globalCache.Clear();
@@ -78,13 +78,12 @@ int FTPSettings::SetEncryptionKey(const char * key) {
7878
return 0;
7979
}
8080

81-
bool FTPSettings::GetDebugMode() const {
81+
bool FTPSettings::GetDebugMode() {
8282
return m_debugMode;
8383
}
8484

8585
int FTPSettings::SetDebugMode(bool debugMode) {
8686
m_debugMode = debugMode;
87-
_DebugMode = m_debugMode;
8887
return 0;
8988
}
9089

@@ -187,14 +186,13 @@ int FTPSettings::LoadSettings(const TiXmlElement * settingsElem) {
187186
clearState = 0;
188187
}
189188
m_clearCache = (clearState != 0);
190-
189+
191190
int debugModeState = 0;
192191
const char * debugModeStr = settingsElem->Attribute("debugMode", &debugModeState);
193192
if (!debugModeStr) {
194193
debugModeState = 0;
195194
}
196195
m_debugMode = (debugModeState != 0);
197-
_DebugMode = m_debugMode;
198196

199197

200198
clearState = 0;
@@ -207,7 +205,7 @@ int FTPSettings::LoadSettings(const TiXmlElement * settingsElem) {
207205
return 0;
208206
}
209207

210-
int FTPSettings::SaveSettings(TiXmlElement * settingsElem) {
208+
int FTPSettings::SaveSettings(TiXmlElement * settingsElem) const {
211209
char * defaultCacheutf8 = SU::TCharToUtf8(m_globalCachePath);
212210
settingsElem->SetAttribute("defaultCache", defaultCacheutf8);
213211
SU::FreeChar(defaultCacheutf8);

src/FTPSettings.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/*
2-
NppFTP: FTP/SFTP functionality for Notepad++
3-
Copyright (C) 2010 Harry (harrybharry@users.sourceforge.net)
2+
NppFTP: FTP/SFTP functionality for Notepad++
3+
Copyright (C) 2010 Harry (harrybharry@users.sourceforge.net)
44
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
99
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU General Public License for more details.
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
1414
15-
You should have received a copy of the GNU General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

1919
#ifndef FTPSETTINGS_H
@@ -36,8 +36,8 @@ class FTPSettings {
3636
const char* GetEncryptionKey() const; //array of size 8
3737
int SetEncryptionKey(const char * key); //key must array of size 8
3838

39-
bool GetDebugMode() const;
40-
int SetDebugMode(bool debugMode);
39+
static bool GetDebugMode();
40+
static int SetDebugMode(bool debugMode);
4141

4242
bool GetClearCache() const;
4343
int SetClearCache(bool clearCache);
@@ -52,15 +52,15 @@ class FTPSettings {
5252
int SetSplitRatio(double splitRatio);
5353

5454
int LoadSettings(const TiXmlElement * settingsElem);
55-
int SaveSettings(TiXmlElement * settingsElem);
55+
int SaveSettings(TiXmlElement * settingsElem) const;
5656
private:
5757
TCHAR* m_globalCachePath;
5858
FTPCache m_globalCache;
5959
bool m_clearCache;
6060
bool m_clearCachePermanent;
6161
bool m_showOutput;
6262
double m_splitRatio;
63-
bool m_debugMode;
63+
static bool m_debugMode;
6464
};
6565

6666
#endif //FTPSETTINGS_H

src/Output.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
/*
2-
NppFTP: FTP/SFTP functionality for Notepad++
3-
Copyright (C) 2010 Harry (harrybharry@users.sourceforge.net)
2+
NppFTP: FTP/SFTP functionality for Notepad++
3+
Copyright (C) 2010 Harry (harrybharry@users.sourceforge.net)
44
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
99
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU General Public License for more details.
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
1414
15-
You should have received a copy of the GNU General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

1919
#include "StdInc.h"
2020
//#include "Output.h"
21+
#include "FTPSettings.h"
2122

2223

2324
int OutputDebug(const TCHAR * msg, ...) {
2425

25-
if (!_DebugMode) {
26+
if (!FTPSettings::GetDebugMode()) {
2627
return 0;
2728
}
28-
29+
2930
va_list vaList;
3031
va_start(vaList, msg);
3132
int ret = -1;
@@ -50,7 +51,7 @@ int OutputMsg(const TCHAR * msg, ...) {
5051

5152
int OutputClnt(const TCHAR * msg, ...) {
5253

53-
if (!_DebugMode) {
54+
if (!FTPSettings::GetDebugMode()) {
5455
return 0;
5556
}
5657

src/Output.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/*
2-
NppFTP: FTP/SFTP functionality for Notepad++
3-
Copyright (C) 2010 Harry (harrybharry@users.sourceforge.net)
2+
NppFTP: FTP/SFTP functionality for Notepad++
3+
Copyright (C) 2010 Harry (harrybharry@users.sourceforge.net)
44
5-
This program is free software: you can redistribute it and/or modify
6-
it under the terms of the GNU General Public License as published by
7-
the Free Software Foundation, either version 3 of the License, or
8-
(at your option) any later version.
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
99
10-
This program is distributed in the hope that it will be useful,
11-
but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
GNU General Public License for more details.
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
1414
15-
You should have received a copy of the GNU General Public License
16-
along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

1919
#ifndef OUTPUT_H
@@ -31,7 +31,6 @@ class Output {
3131

3232
extern Output* _MainOutput;
3333
extern HWND _MainOutputWindow;
34-
extern bool _DebugMode;
3534

3635
int OutputDebug(const TCHAR * msg, ...);
3736
int OutputMsg(const TCHAR * msg, ...);

src/QueueOperation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ const char* QueueCopyFile::GetExternalPath() {
377377
return m_externalFile;
378378
}
379379

380-
const char* QueueCopyFile::GetExternalOriginParent() {
380+
const char* QueueCopyFile::GetExternalOriginParent() const {
381381
char* basepath = SU::strdup(m_externalFile);
382382
char * lastSlash=strrchr(basepath, '/');
383383
lastSlash[0] = '\0';
@@ -387,7 +387,7 @@ const char* QueueCopyFile::GetExternalOriginParent() {
387387
return basepath;
388388
}
389389

390-
const char* QueueCopyFile::GetExternalNewParent() {
390+
const char* QueueCopyFile::GetExternalNewParent() const {
391391
char* basepath = SU::strdup(m_target);
392392
char* lastSlash = strrchr(basepath, '/');
393393
lastSlash[0] = '\0';

src/QueueOperation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ class QueueCopyFile : public QueueOperation {
177177
virtual bool Equals(const QueueOperation& other);
178178

179179
virtual const char* GetExternalPath();
180-
const char* GetExternalOriginParent();
181-
const char* GetExternalNewParent();
180+
const char* GetExternalOriginParent() const;
181+
const char* GetExternalNewParent() const;
182182
protected:
183183
char* m_externalFile;
184184
char* m_target;

0 commit comments

Comments
 (0)