summaryrefslogtreecommitdiff
path: root/plugins/FTPFileYM/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/FTPFileYM/src')
-rw-r--r--plugins/FTPFileYM/src/dbentry.cpp20
-rw-r--r--plugins/FTPFileYM/src/dbentry.h2
-rw-r--r--plugins/FTPFileYM/src/deletetimer.cpp4
-rw-r--r--plugins/FTPFileYM/src/dialog.cpp34
-rw-r--r--plugins/FTPFileYM/src/dialog.h2
-rw-r--r--plugins/FTPFileYM/src/job_delete.cpp12
-rw-r--r--plugins/FTPFileYM/src/job_delete.h2
-rw-r--r--plugins/FTPFileYM/src/job_packer.cpp12
-rw-r--r--plugins/FTPFileYM/src/job_packer.h2
-rw-r--r--plugins/FTPFileYM/src/job_upload.cpp12
-rw-r--r--plugins/FTPFileYM/src/job_upload.h2
-rw-r--r--plugins/FTPFileYM/src/manager.cpp4
-rw-r--r--plugins/FTPFileYM/src/utils.h26
-rw-r--r--plugins/FTPFileYM/src/version.h14
14 files changed, 56 insertions, 92 deletions
diff --git a/plugins/FTPFileYM/src/dbentry.cpp b/plugins/FTPFileYM/src/dbentry.cpp
index b389c40430..82e21a2843 100644
--- a/plugins/FTPFileYM/src/dbentry.cpp
+++ b/plugins/FTPFileYM/src/dbentry.cpp
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "common.h"
int DBEntry::entryID;
-Mutex DBEntry::mutexDB;
+mir_cs DBEntry::mutexDB;
DBEntry::DBEntry()
{ }
@@ -113,20 +113,17 @@ void DBEntry::remove(int fileID)
bool DBEntry::entryExists(GenericJob *job)
{
- Lock *lock = new Lock(mutexDB);
+ mir_cslock lock(mutexDB);
DBEntry *entry = getFirts();
while (entry != NULL)
{
if (entry->iFtpNum == job->iFtpNum && !strcmp(entry->szFileName, job->szSafeFileName))
- {
- delete lock;
return true;
- }
+
entry = getNext(entry);
}
- delete lock;
return false;
}
@@ -135,7 +132,7 @@ void DBEntry::add(GenericJob *job)
if (entryExists(job))
return;
- Lock *lock = new Lock(mutexDB);
+ mir_cslock lock(mutexDB);
int id = db_get_dw(0, MODULE_FILES, "NextFileID", 0);
DB::setByteF(0, MODULE_FILES, "Ftp%d", id, job->iFtpNum);
DB::setAStringF(0, MODULE_FILES, "Filename%d", id, job->szSafeFileName);
@@ -149,8 +146,6 @@ void DBEntry::add(GenericJob *job)
db_set_dw(0, MODULE_FILES, "NextFileID", id + 1);
job->fileID = id;
-
- delete lock;
}
void DBEntry::setDeleteTS(GenericJob *job)
@@ -161,8 +156,5 @@ void DBEntry::setDeleteTS(GenericJob *job)
deleteTS += (job->tab->iOptAutoDelete * 60);
DB::setDwordF(0, MODULE_FILES, "DeleteTS%d", job->fileID, deleteTS);
}
- else
- {
- DB::deleteSettingF(0, MODULE_FILES, "DeleteTS%d", job->fileID);
- }
-} \ No newline at end of file
+ else DB::deleteSettingF(0, MODULE_FILES, "DeleteTS%d", job->fileID);
+}
diff --git a/plugins/FTPFileYM/src/dbentry.h b/plugins/FTPFileYM/src/dbentry.h
index 27ad865559..2588dc2de9 100644
--- a/plugins/FTPFileYM/src/dbentry.h
+++ b/plugins/FTPFileYM/src/dbentry.h
@@ -34,7 +34,7 @@ public:
char szFileName[256];
DWORD deleteTS;
- static Mutex mutexDB;
+ static mir_cs mutexDB;
DBEntry();
DBEntry(DBEntry *entry);
diff --git a/plugins/FTPFileYM/src/deletetimer.cpp b/plugins/FTPFileYM/src/deletetimer.cpp
index 2534069a0d..05aeaff64e 100644
--- a/plugins/FTPFileYM/src/deletetimer.cpp
+++ b/plugins/FTPFileYM/src/deletetimer.cpp
@@ -53,7 +53,7 @@ void DeleteTimer::stop()
void CALLBACK DeleteTimer::AutoDeleteTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
- Lock *lock = new Lock(DBEntry::mutexDB);
+ mir_cslock lock(DBEntry::mutexDB);
DBEntry *entry = DBEntry::getFirts();
while (entry != NULL)
@@ -66,6 +66,4 @@ void CALLBACK DeleteTimer::AutoDeleteTimerProc(HWND hwnd, UINT uMsg, UINT_PTR id
entry = DBEntry::getNext(entry);
}
-
- delete lock;
} \ No newline at end of file
diff --git a/plugins/FTPFileYM/src/dialog.cpp b/plugins/FTPFileYM/src/dialog.cpp
index d945d55f85..8044cfd3a7 100644
--- a/plugins/FTPFileYM/src/dialog.cpp
+++ b/plugins/FTPFileYM/src/dialog.cpp
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
UploadDialog *UploadDialog::instance = NULL;
UploadDialog *uDlg = NULL;
-Mutex UploadDialog::mutexTabs;
+mir_cs UploadDialog::mutexTabs;
extern Options &opt;
@@ -67,7 +67,11 @@ void UploadDialog::show()
}
UploadDialog::Tab::Tab(GenericJob *Job)
-:job(Job),bOptCloseDlg(opt.bCloseDlg),bOptCopyLink(opt.bCopyLink),bOptAutosend(opt.bAutosend),iOptAutoDelete(-1)
+ : job(Job),
+ bOptCloseDlg(opt.bCloseDlg),
+ bOptCopyLink(opt.bCopyLink),
+ bOptAutosend(opt.bAutosend),
+ iOptAutoDelete(-1)
{
if (opt.bAutoDelete)
this->iOptAutoDelete = Utils::getDeleteTimeMin();
@@ -81,20 +85,19 @@ UploadDialog::Tab::Tab(GenericJob *Job)
tab.mask = TCIF_TEXT;
tab.pszText = Utils::getTextFragment(job->stzFileName, 20, buff);
TabCtrl_InsertItem(uDlg->hwndTabs, uDlg->tabs.size(), &tab);
-
- Lock *lock = new Lock(mutexTabs);
- uDlg->tabs.push_back(this);
- delete lock;
-
+ {
+ mir_cslock lock(mutexTabs);
+ uDlg->tabs.push_back(this);
+ }
this->select();
}
UploadDialog::Tab::~Tab()
{
- Lock *lock = new Lock(mutexTabs);
- TabCtrl_DeleteItem(uDlg->hwndTabs, this->index());
- uDlg->tabs.erase(uDlg->tabs.begin() + this->index());
- delete lock;
+ { mir_cslock lock(mutexTabs);
+ TabCtrl_DeleteItem(uDlg->hwndTabs, this->index());
+ uDlg->tabs.erase(uDlg->tabs.begin() + this->index());
+ }
if (this->job->isCompleted())
delete this->job;
@@ -119,11 +122,10 @@ int UploadDialog::Tab::index()
void UploadDialog::Tab::select()
{
TabCtrl_SetCurSel(uDlg->hwndTabs, this->index());
-
- Lock *lock = new Lock(mutexTabs);
- uDlg->activeTab = this->index();
- delete lock;
-
+ {
+ mir_cslock lock(mutexTabs);
+ uDlg->activeTab = this->index();
+ }
this->job->refreshTab(true);
InvalidateRect(uDlg->hwnd, NULL, TRUE);
}
diff --git a/plugins/FTPFileYM/src/dialog.h b/plugins/FTPFileYM/src/dialog.h
index c7d3ceb81a..0b40c4ee2c 100644
--- a/plugins/FTPFileYM/src/dialog.h
+++ b/plugins/FTPFileYM/src/dialog.h
@@ -32,7 +32,7 @@ class UploadDialog
private:
static UploadDialog *instance;
- static Mutex mutexTabs;
+ static mir_cs mutexTabs;
TCHAR stzToolTipText[1024];
UploadDialog();
diff --git a/plugins/FTPFileYM/src/job_delete.cpp b/plugins/FTPFileYM/src/job_delete.cpp
index 63c50f8d88..0baa219117 100644
--- a/plugins/FTPFileYM/src/job_delete.cpp
+++ b/plugins/FTPFileYM/src/job_delete.cpp
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "job_delete.h"
Event DeleteJob::jobDone;
-Mutex DeleteJob::mutexJobCount;
+mir_cs DeleteJob::mutexJobCount;
int DeleteJob::iRunningJobCount = 0;
extern ServerList &ftpList;
@@ -41,23 +41,23 @@ void DeleteJob::waitingThread(void *arg)
while(!Miranda_Terminated())
{
- Lock *lock = new Lock(mutexJobCount);
+ mir_cslockfull lock(mutexJobCount);
if (iRunningJobCount < MAX_RUNNING_JOBS)
{
iRunningJobCount++;
- delete lock;
+ lock.unlock();
job->run();
delete job;
- Lock *lock = new Lock(mutexJobCount);
+ lock.lock();
iRunningJobCount--;
- delete lock;
+ lock.unlock();
jobDone.release();
return;
}
- delete lock;
+ lock.unlock();
jobDone.wait();
}
diff --git a/plugins/FTPFileYM/src/job_delete.h b/plugins/FTPFileYM/src/job_delete.h
index a2da7c5d24..79ef0f2794 100644
--- a/plugins/FTPFileYM/src/job_delete.h
+++ b/plugins/FTPFileYM/src/job_delete.h
@@ -31,7 +31,7 @@ private:
ServerList::FTP *ftp;
char buff[256];
- static Mutex mutexJobCount;
+ static mir_cs mutexJobCount;
static int iRunningJobCount;
char *getDelFileString();
diff --git a/plugins/FTPFileYM/src/job_packer.cpp b/plugins/FTPFileYM/src/job_packer.cpp
index 05898d3f41..ba68c58f7e 100644
--- a/plugins/FTPFileYM/src/job_packer.cpp
+++ b/plugins/FTPFileYM/src/job_packer.cpp
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "common.h"
Event PackerJob::jobDone;
-Mutex PackerJob::mutexJobCount;
+mir_cs PackerJob::mutexJobCount;
int PackerJob::iRunningJobCount = 0;
extern UploadDialog *uDlg;
@@ -79,23 +79,23 @@ void PackerJob::waitingThread(void *arg)
while(!Miranda_Terminated())
{
- Lock *lock = new Lock(mutexJobCount);
+ mir_cslockfull lock(mutexJobCount);
if (iRunningJobCount < MAX_RUNNING_JOBS)
{
iRunningJobCount++;
- delete lock;
+ lock.unlock();
job->pack();
delete job;
- Lock *lock = new Lock(mutexJobCount);
+ lock.lock();
iRunningJobCount--;
- delete lock;
+ lock.unlock();
jobDone.release();
return;
}
- delete lock;
+ lock.unlock();
jobDone.wait();
job->status = GenericJob::STATUS_WAITING;
}
diff --git a/plugins/FTPFileYM/src/job_packer.h b/plugins/FTPFileYM/src/job_packer.h
index 297f256076..bbdee99241 100644
--- a/plugins/FTPFileYM/src/job_packer.h
+++ b/plugins/FTPFileYM/src/job_packer.h
@@ -33,7 +33,7 @@ private:
time_t lastUpdateTick;
static Event jobDone;
- static Mutex mutexJobCount;
+ static mir_cs mutexJobCount;
static int iRunningJobCount;
static void waitingThread(void *arg);
diff --git a/plugins/FTPFileYM/src/job_upload.cpp b/plugins/FTPFileYM/src/job_upload.cpp
index ac490cf5a9..ace85a52a6 100644
--- a/plugins/FTPFileYM/src/job_upload.cpp
+++ b/plugins/FTPFileYM/src/job_upload.cpp
@@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "common.h"
Event UploadJob::jobDone;
-Mutex UploadJob::mutexJobCount;
+mir_cs UploadJob::mutexJobCount;
int UploadJob::iRunningJobCount = 0;
extern UploadDialog *uDlg;
@@ -149,24 +149,24 @@ void UploadJob::waitingThread(void *arg)
UploadJob *job = (UploadJob *)arg;
while (!Miranda_Terminated()) {
- Lock *lock = new Lock(mutexJobCount);
+ mir_cslockfull lock(mutexJobCount);
if (iRunningJobCount < MAX_RUNNING_JOBS) {
iRunningJobCount++;
- delete lock;
+ lock.unlock();
job->upload();
if (!job->isCompleted())
delete job;
- Lock *lock = new Lock(mutexJobCount);
+ lock.lock();
iRunningJobCount--;
- delete lock;
+ lock.unlock();
jobDone.release();
return;
}
- delete lock;
+ lock.unlock();
jobDone.wait();
job->status = GenericJob::STATUS_WAITING;
}
diff --git a/plugins/FTPFileYM/src/job_upload.h b/plugins/FTPFileYM/src/job_upload.h
index 3e4112befb..76432f3f92 100644
--- a/plugins/FTPFileYM/src/job_upload.h
+++ b/plugins/FTPFileYM/src/job_upload.h
@@ -41,7 +41,7 @@ private:
double lastSpeed[10];
double avgSpeed;
- static Mutex mutexJobCount;
+ static mir_cs mutexJobCount;
static int iRunningJobCount;
char *getChmodString();
diff --git a/plugins/FTPFileYM/src/manager.cpp b/plugins/FTPFileYM/src/manager.cpp
index 7e5fa09bae..cee488915b 100644
--- a/plugins/FTPFileYM/src/manager.cpp
+++ b/plugins/FTPFileYM/src/manager.cpp
@@ -120,7 +120,7 @@ void Manager::fillTree()
tvi.item.stateMask = TVIS_STATEIMAGEMASK;
tvi.item.state = TreeItem::_UNCHECKED();
- Lock *lock = new Lock(DBEntry::mutexDB);
+ mir_cslock lock(DBEntry::mutexDB);
DBEntry *entry = DBEntry::getFirts();
while (entry != NULL)
@@ -136,8 +136,6 @@ void Manager::fillTree()
entry = DBEntry::getNext(entry);
}
-
- delete lock;
}
int Manager::indexOf(HTREEITEM handle)
diff --git a/plugins/FTPFileYM/src/utils.h b/plugins/FTPFileYM/src/utils.h
index 3b22ccc7d6..ef3904e592 100644
--- a/plugins/FTPFileYM/src/utils.h
+++ b/plugins/FTPFileYM/src/utils.h
@@ -43,29 +43,3 @@ public:
static bool setFileNameDlg(TCHAR *nameBuff);
static bool setFileNameDlgA(char *nameBuff);
};
-
-class Mutex
-{
- friend class Lock;
-
-private:
- void Acquire() { EnterCriticalSection (&_critSection); }
- void Release() { LeaveCriticalSection (&_critSection); }
-
- CRITICAL_SECTION _critSection;
-
-public:
- Mutex() { InitializeCriticalSection (&_critSection); }
- ~Mutex() { DeleteCriticalSection (&_critSection); }
-};
-
-class Lock
-{
-private:
- Mutex &_mutex;
-
-public:
- Lock (Mutex &mutex): _mutex(mutex) { _mutex.Acquire(); }
- ~Lock () {_mutex.Release(); }
-};
-
diff --git a/plugins/FTPFileYM/src/version.h b/plugins/FTPFileYM/src/version.h
index fd7c8fdd2c..ad7c22b2e6 100644
--- a/plugins/FTPFileYM/src/version.h
+++ b/plugins/FTPFileYM/src/version.h
@@ -1,14 +1,14 @@
-#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 5
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 6
#define __RELEASE_NUM 0
-#define __BUILD_NUM 0
+#define __BUILD_NUM 0
#include <stdver.h>
#define __PLUGIN_NAME "FTP File YM"
#define __FILENAME "FTPFile.dll"
-#define __DESCRIPTION "FTP a file to a server and send the URL to your friend. Supported automatic zipping before upload and encryption via SFTP and FTPS."
-#define __AUTHOR "yaho"
+#define __DESCRIPTION "FTP a file to a server and send the URL to your friend. Supported automatic zipping before upload and encryption via SFTP and FTPS."
+#define __AUTHOR "yaho"
#define __AUTHOREMAIL "yaho@miranda-easy.net"
-#define __AUTHORWEB "http://miranda-ng.org/p/FTPFile/"
-#define __COPYRIGHT "© 2007-2010 Jan Holub"
+#define __AUTHORWEB "http://miranda-ng.org/p/FTPFile/"
+#define __COPYRIGHT "© 2007-2010 Jan Holub"