summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-12-17 19:25:36 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-12-17 19:25:36 +0300
commit45e8cd4d903d4ea823f0ab4ca2e7afe27ddc514b (patch)
tree1b2e1c275f87170c029c6f0181a54984c435cc4a /plugins
parent47eae603adab188624f17dab14318c1b1995f0ab (diff)
FtpFile:
- fixes #1662 (FTPFile: Default account's names looks weird) - code cleaning - version bump
Diffstat (limited to 'plugins')
-rw-r--r--plugins/FTPFileYM/src/deletetimer.cpp6
-rw-r--r--plugins/FTPFileYM/src/deletetimer.h17
-rw-r--r--plugins/FTPFileYM/src/dialog.cpp4
-rw-r--r--plugins/FTPFileYM/src/dialog.h14
-rw-r--r--plugins/FTPFileYM/src/ftpfile.cpp18
-rw-r--r--plugins/FTPFileYM/src/job_delete.cpp3
-rw-r--r--plugins/FTPFileYM/src/job_generic.cpp3
-rw-r--r--plugins/FTPFileYM/src/job_packer.cpp3
-rw-r--r--plugins/FTPFileYM/src/job_upload.cpp3
-rw-r--r--plugins/FTPFileYM/src/job_upload.h2
-rw-r--r--plugins/FTPFileYM/src/manager.cpp9
-rw-r--r--plugins/FTPFileYM/src/manager.h11
-rw-r--r--plugins/FTPFileYM/src/options.cpp11
-rw-r--r--plugins/FTPFileYM/src/options.h21
-rw-r--r--plugins/FTPFileYM/src/serverlist.cpp9
-rw-r--r--plugins/FTPFileYM/src/serverlist.h20
-rw-r--r--plugins/FTPFileYM/src/stdafx.h9
-rw-r--r--plugins/FTPFileYM/src/utils.cpp7
-rw-r--r--plugins/FTPFileYM/src/version.h2
19 files changed, 27 insertions, 145 deletions
diff --git a/plugins/FTPFileYM/src/deletetimer.cpp b/plugins/FTPFileYM/src/deletetimer.cpp
index cb7b0063d7..fe263d96c0 100644
--- a/plugins/FTPFileYM/src/deletetimer.cpp
+++ b/plugins/FTPFileYM/src/deletetimer.cpp
@@ -18,10 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-DeleteTimer *DeleteTimer::instance = nullptr;
-DeleteTimer &deleteTimer = DeleteTimer::getInstance();
-
-extern Options &opt;
+DeleteTimer deleteTimer;
void DeleteTimer::init()
{
@@ -33,7 +30,6 @@ void DeleteTimer::init()
void DeleteTimer::deinit()
{
stop();
- delete this;
}
void DeleteTimer::start()
diff --git a/plugins/FTPFileYM/src/deletetimer.h b/plugins/FTPFileYM/src/deletetimer.h
index 1daec28b3b..6909cd981e 100644
--- a/plugins/FTPFileYM/src/deletetimer.h
+++ b/plugins/FTPFileYM/src/deletetimer.h
@@ -24,24 +24,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class DeleteTimer
{
private:
- static DeleteTimer *instance;
- UINT timerId;
-
- DeleteTimer() { };
- ~DeleteTimer() { instance = nullptr; };
+ UINT timerId = 0;
static void CALLBACK AutoDeleteTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
public:
- static DeleteTimer &getInstance()
- {
- if (!instance)
- instance = new DeleteTimer();
- return *instance;
- };
-
void init();
void deinit();
void start();
void stop();
-}; \ No newline at end of file
+};
+
+extern DeleteTimer deleteTimer;
diff --git a/plugins/FTPFileYM/src/dialog.cpp b/plugins/FTPFileYM/src/dialog.cpp
index 2783a1fa17..1eb2d1ed78 100644
--- a/plugins/FTPFileYM/src/dialog.cpp
+++ b/plugins/FTPFileYM/src/dialog.cpp
@@ -18,13 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-UploadDialog *UploadDialog::instance = nullptr;
UploadDialog *uDlg = nullptr;
mir_cs UploadDialog::mutexTabs;
-extern Options &opt;
-
UploadDialog::UploadDialog()
{
m_hwnd = CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DLG_UPLOAD), nullptr, UploadDlgProc);
@@ -50,7 +47,6 @@ UploadDialog::~UploadDialog()
SendMessage(m_hwnd, WMU_DESTROY, 0, 0);
}
- instance = nullptr;
uDlg = nullptr;
}
diff --git a/plugins/FTPFileYM/src/dialog.h b/plugins/FTPFileYM/src/dialog.h
index 66244b7168..449bebacca 100644
--- a/plugins/FTPFileYM/src/dialog.h
+++ b/plugins/FTPFileYM/src/dialog.h
@@ -30,13 +30,9 @@ class UploadDialog
friend class UploadJob;
friend class PackerJob;
-private:
- static UploadDialog *instance;
static mir_cs mutexTabs;
wchar_t m_tszToolTipText[1024];
- UploadDialog();
-
public:
class Tab
{
@@ -66,18 +62,14 @@ public:
vector<Tab *> m_tabs;
+ UploadDialog();
~UploadDialog();
- static UploadDialog *getInstance()
- {
- if (!instance)
- instance = new UploadDialog();
- return instance;
- };
-
void selectTab(int index);
void show();
static LRESULT CALLBACK TabControlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK UploadDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
};
+
+extern UploadDialog *uDlg;
diff --git a/plugins/FTPFileYM/src/ftpfile.cpp b/plugins/FTPFileYM/src/ftpfile.cpp
index 18230a7b24..eabee7f882 100644
--- a/plugins/FTPFileYM/src/ftpfile.cpp
+++ b/plugins/FTPFileYM/src/ftpfile.cpp
@@ -22,13 +22,6 @@ CMPlugin g_plugin;
HGENMENU hMenu, hMainMenu, hSubMenu[ServerList::FTP_COUNT], hMainSubMenu[ServerList::FTP_COUNT];
-extern UploadDialog *uDlg;
-extern Manager *manDlg;
-
-extern DeleteTimer &deleteTimer;
-extern ServerList &ftpList;
-extern Options &opt;
-
int PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
void PrebuildMainMenu();
int TabsrmmButtonPressed(WPARAM wParam, LPARAM lParam);
@@ -278,7 +271,8 @@ int UploadFile(MCONTACT hContact, int m_iFtpNum, GenericJob::EMode mode, void **
result = job->getFiles();
if (result != 0) {
- uDlg = UploadDialog::getInstance();
+ if (uDlg == nullptr)
+ uDlg = new UploadDialog();
if (!uDlg->m_hwnd || !uDlg->m_hwndTabs) {
Utils::msgBox(TranslateT("Error has occurred while trying to create a dialog!"), MB_OK | MB_ICONERROR);
delete uDlg;
@@ -318,7 +312,7 @@ INT_PTR UploadService(WPARAM, LPARAM lParam)
INT_PTR ShowManagerService(WPARAM, LPARAM)
{
- manDlg = Manager::getInstance();
+ manDlg = new Manager();
manDlg->init();
return 0;
}
@@ -367,17 +361,11 @@ static int Shutdown(WPARAM, LPARAM)
curl_global_cleanup();
ftpList.deinit();
- opt.deinit();
-
return 0;
}
int CMPlugin::Load()
{
-#ifdef _DEBUG
- _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
-#endif
-
CoInitialize(nullptr);
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
diff --git a/plugins/FTPFileYM/src/job_delete.cpp b/plugins/FTPFileYM/src/job_delete.cpp
index d9efb9ae97..0e529c3f17 100644
--- a/plugins/FTPFileYM/src/job_delete.cpp
+++ b/plugins/FTPFileYM/src/job_delete.cpp
@@ -23,9 +23,6 @@ Event DeleteJob::jobDone;
mir_cs DeleteJob::mutexJobCount;
int DeleteJob::iRunningJobCount = 0;
-extern ServerList &ftpList;
-extern Manager *manDlg;
-
DeleteJob::DeleteJob(DBEntry *entry, Manager::TreeItem *item) :
m_entry(entry),
m_treeItem(item),
diff --git a/plugins/FTPFileYM/src/job_generic.cpp b/plugins/FTPFileYM/src/job_generic.cpp
index a1f8efc728..5596a1998b 100644
--- a/plugins/FTPFileYM/src/job_generic.cpp
+++ b/plugins/FTPFileYM/src/job_generic.cpp
@@ -18,9 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-extern UploadDialog *uDlg;
-extern ServerList &ftpList;
-
GenericJob::GenericJob(MCONTACT hContact, int iFtpNum, EMode mode) :
m_hContact(hContact),
m_iFtpNum(iFtpNum),
diff --git a/plugins/FTPFileYM/src/job_packer.cpp b/plugins/FTPFileYM/src/job_packer.cpp
index e85e28910b..c0e8ca7115 100644
--- a/plugins/FTPFileYM/src/job_packer.cpp
+++ b/plugins/FTPFileYM/src/job_packer.cpp
@@ -22,9 +22,6 @@ Event PackerJob::jobDone;
mir_cs PackerJob::mutexJobCount;
int PackerJob::iRunningJobCount = 0;
-extern UploadDialog *uDlg;
-extern Options &opt;
-
PackerJob::PackerJob(MCONTACT hContact, int iFtpNum, EMode mode) :
GenericJob(hContact, iFtpNum, mode),
m_uiFileSize(0),
diff --git a/plugins/FTPFileYM/src/job_upload.cpp b/plugins/FTPFileYM/src/job_upload.cpp
index a89bbe32dc..29a51fc1fb 100644
--- a/plugins/FTPFileYM/src/job_upload.cpp
+++ b/plugins/FTPFileYM/src/job_upload.cpp
@@ -22,9 +22,6 @@ Event UploadJob::jobDone;
mir_cs UploadJob::mutexJobCount;
int UploadJob::iRunningJobCount = 0;
-extern UploadDialog *uDlg;
-extern ServerList &ftpList;
-
UploadJob::UploadJob(MCONTACT _hContact, int _iFtpNum, EMode _mode) :
GenericJob(_hContact, _iFtpNum, _mode),
m_fp(nullptr)
diff --git a/plugins/FTPFileYM/src/job_upload.h b/plugins/FTPFileYM/src/job_upload.h
index cf46c48a06..dfa34e638a 100644
--- a/plugins/FTPFileYM/src/job_upload.h
+++ b/plugins/FTPFileYM/src/job_upload.h
@@ -81,4 +81,4 @@ public:
virtual void closeTab();
virtual void closeAllTabs();
virtual void createToolTip();
-}; \ No newline at end of file
+};
diff --git a/plugins/FTPFileYM/src/manager.cpp b/plugins/FTPFileYM/src/manager.cpp
index b3e2a3c1c5..c4ea35a8f3 100644
--- a/plugins/FTPFileYM/src/manager.cpp
+++ b/plugins/FTPFileYM/src/manager.cpp
@@ -24,14 +24,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "utils.h"
Manager *manDlg = nullptr;
-Manager *Manager::instance = nullptr;
-
-extern Options &opt;
-extern ServerList &ftpList;
-
-Manager::Manager()
-{
-}
Manager::~Manager()
{
@@ -44,7 +36,6 @@ Manager::~Manager()
ImageList_Destroy(m_himlStates);
DBEntry::cleanupDB();
- instance = nullptr;
manDlg = nullptr;
}
diff --git a/plugins/FTPFileYM/src/manager.h b/plugins/FTPFileYM/src/manager.h
index 6eb3a541a9..0b4c606784 100644
--- a/plugins/FTPFileYM/src/manager.h
+++ b/plugins/FTPFileYM/src/manager.h
@@ -30,14 +30,10 @@ private:
STATE_CHECKED
};
- static Manager *instance;
-
HWND m_hwnd;
HWND m_hwndFileTree;
HIMAGELIST m_himlStates;
- Manager();
-
void show();
void initRootItems();
void initImageList();
@@ -73,13 +69,6 @@ public:
void AddRoot(HTREEITEM h) { m_rootItems.push_back(new TreeItem(h, nullptr, 0)); }
void AddLeaf(HTREEITEM h, HTREEITEM p, int id) { m_items.push_back(new TreeItem(h,p,id)); }
- static Manager *getInstance()
- {
- if (!instance)
- instance = new Manager();
- return instance;
- };
-
void init();
int indexOf(HTREEITEM handle);
TreeItem *getItem(HTREEITEM handle);
diff --git a/plugins/FTPFileYM/src/options.cpp b/plugins/FTPFileYM/src/options.cpp
index b71aaaa0a1..f07e1d8168 100644
--- a/plugins/FTPFileYM/src/options.cpp
+++ b/plugins/FTPFileYM/src/options.cpp
@@ -18,19 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-Options *Options::instance = nullptr;
-Options &opt = Options::getInstance();
-
-extern DeleteTimer &deleteTimer;
-extern ServerList &ftpList;
+Options opt;
extern void PrebuildMainMenu();
-void Options::deinit()
-{
- delete this;
-}
-
void Options::loadOptions()
{
selected = g_plugin.getByte("Selected", 0);
diff --git a/plugins/FTPFileYM/src/options.h b/plugins/FTPFileYM/src/options.h
index e4bd98fbc8..0c4051cf21 100644
--- a/plugins/FTPFileYM/src/options.h
+++ b/plugins/FTPFileYM/src/options.h
@@ -21,15 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
#include "serverlist.h"
-class Options
+struct Options
{
-private:
- static Options *instance;
-
- Options() { };
- ~Options() { instance = nullptr; };
-
-public:
enum ETimeRange
{
TR_MINUTES= 0,
@@ -50,19 +43,13 @@ public:
int iDeleteTime;
ETimeRange timeRange;
- static Options &getInstance()
- {
- if (!instance)
- instance = new Options();
- return *instance;
- };
-
static void enableItems(HWND hwndDlg, bool state);
static int InitOptions(WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK DlgProcOptsAccounts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK DlgProcOptsAdvanced(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
- void deinit();
void loadOptions();
void saveOptions() const;
-}; \ No newline at end of file
+};
+
+extern Options opt;
diff --git a/plugins/FTPFileYM/src/serverlist.cpp b/plugins/FTPFileYM/src/serverlist.cpp
index 33cce223ec..eb1ad9c2cc 100644
--- a/plugins/FTPFileYM/src/serverlist.cpp
+++ b/plugins/FTPFileYM/src/serverlist.cpp
@@ -18,15 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-ServerList *ServerList::instance = nullptr;
-ServerList &ftpList = ServerList::getInstance();
-
-extern Options &opt;
+ServerList ftpList;
void ServerList::init()
{
for (int i = 0; i < FTP_COUNT; i++) {
- ServerList::FTP *ftp = new ServerList::FTP(i);
+ FTP *ftp = new FTP(i);
ftpList.add(ftp);
}
}
@@ -35,8 +32,6 @@ void ServerList::deinit()
{
for (UINT i = 0; i < ftpList.size(); i++)
delete ftpList[i];
-
- delete this;
}
void ServerList::saveToDb() const
diff --git a/plugins/FTPFileYM/src/serverlist.h b/plugins/FTPFileYM/src/serverlist.h
index 0b41d0b4e7..d2b89608f9 100644
--- a/plugins/FTPFileYM/src/serverlist.h
+++ b/plugins/FTPFileYM/src/serverlist.h
@@ -20,17 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-class ServerList
+struct ServerList
{
-private:
- static ServerList *instance;
- ServerList() { };
- ~ServerList() { instance = nullptr; };
-
-public:
- class FTP
+ struct FTP : public MZeroedObject
{
- public:
enum EProtoType
{
FT_STANDARD = 0,
@@ -61,17 +54,10 @@ public:
vector<FTP *> m_items;
- FTP *operator[] (int i) const { return m_items[i]; };
+ FTP* operator[] (int i) const { return m_items[i]; };
void add(FTP *newItem) { m_items.push_back(newItem); }
size_t size() { return m_items.size(); }
- static ServerList &getInstance()
- {
- if (!instance)
- instance = new ServerList();
- return *instance;
- };
-
void init();
void deinit();
void saveToDb() const;
diff --git a/plugins/FTPFileYM/src/stdafx.h b/plugins/FTPFileYM/src/stdafx.h
index 9f1a9c41a7..0752376744 100644
--- a/plugins/FTPFileYM/src/stdafx.h
+++ b/plugins/FTPFileYM/src/stdafx.h
@@ -64,13 +64,8 @@ using namespace std;
#define FREE(X) if (X) { mir_free(X); X = NULL; }
#endif
-#ifdef _DEBUG
-#define _CRTDBG_MAP_ALLOC
-#define new DEBUG_CLIENTBLOCK
-#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
-#else
-#define DEBUG_CLIENTBLOCK
-#endif
+extern Manager *manDlg;
+extern ServerList ftpList;
#define MS_FTPFILE_CONTACTMENU "FTPFile/ContactMenu"
#define MS_FTPFILE_MAINMENU "FTPFile/MainMenu"
diff --git a/plugins/FTPFileYM/src/utils.cpp b/plugins/FTPFileYM/src/utils.cpp
index 6b17c59f52..4cf391444b 100644
--- a/plugins/FTPFileYM/src/utils.cpp
+++ b/plugins/FTPFileYM/src/utils.cpp
@@ -18,9 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-extern Options &opt;
-extern UploadDialog *uDlg;
-
int Utils::getDeleteTimeMin()
{
switch (opt.timeRange) {
@@ -85,8 +82,8 @@ const char to_chars[] = "abvgdeezziiklmnoprstufhccwwqyqeuaABVGDEEZZIIKLMNOPRSTUF
CMStringA Utils::makeSafeString(CMStringA &input)
{
- int len = mir_strlen(from_chars);
- for (int i = 0; i < len; i++)
+ size_t len = mir_strlen(from_chars);
+ for (size_t i = 0; i < len; i++)
input.Replace(from_chars[i], to_chars[i]);
return input;
}
diff --git a/plugins/FTPFileYM/src/version.h b/plugins/FTPFileYM/src/version.h
index c551742f77..422594ceac 100644
--- a/plugins/FTPFileYM/src/version.h
+++ b/plugins/FTPFileYM/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 6
#define __RELEASE_NUM 0
-#define __BUILD_NUM 2
+#define __BUILD_NUM 3
#include <stdver.h>