summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/FTPFileYM/src/dbentry.cpp94
-rw-r--r--plugins/FTPFileYM/src/dbentry.h10
-rw-r--r--plugins/FTPFileYM/src/deletetimer.cpp27
-rw-r--r--plugins/FTPFileYM/src/dialog.cpp471
-rw-r--r--plugins/FTPFileYM/src/dialog.h28
-rw-r--r--plugins/FTPFileYM/src/ftpfile.cpp35
-rw-r--r--plugins/FTPFileYM/src/job_delete.cpp66
-rw-r--r--plugins/FTPFileYM/src/job_delete.h8
-rw-r--r--plugins/FTPFileYM/src/job_generic.cpp178
-rw-r--r--plugins/FTPFileYM/src/job_generic.h28
-rw-r--r--plugins/FTPFileYM/src/job_packer.cpp212
-rw-r--r--plugins/FTPFileYM/src/job_packer.h14
-rw-r--r--plugins/FTPFileYM/src/job_upload.cpp425
-rw-r--r--plugins/FTPFileYM/src/job_upload.h26
-rw-r--r--plugins/FTPFileYM/src/manager.cpp498
-rw-r--r--plugins/FTPFileYM/src/manager.h22
-rw-r--r--plugins/FTPFileYM/src/mir_db.cpp6
-rw-r--r--plugins/FTPFileYM/src/options.cpp106
-rw-r--r--plugins/FTPFileYM/src/serverlist.cpp76
-rw-r--r--plugins/FTPFileYM/src/serverlist.h32
-rw-r--r--plugins/FTPFileYM/src/utils.cpp110
-rw-r--r--plugins/FTPFileYM/src/version.h2
22 files changed, 1156 insertions, 1318 deletions
diff --git a/plugins/FTPFileYM/src/dbentry.cpp b/plugins/FTPFileYM/src/dbentry.cpp
index de808096ac..625f0a023a 100644
--- a/plugins/FTPFileYM/src/dbentry.cpp
+++ b/plugins/FTPFileYM/src/dbentry.cpp
@@ -22,16 +22,17 @@ int DBEntry::entryID;
mir_cs DBEntry::mutexDB;
DBEntry::DBEntry()
-{ }
+{
+}
DBEntry::DBEntry(DBEntry *entry)
{
- this->fileID = entry->fileID;
- this->iFtpNum = entry->iFtpNum;
- mir_strcpy(this->szFileName, entry->szFileName);
+ m_fileID = entry->m_fileID;
+ m_iFtpNum = entry->m_iFtpNum;
+ mir_strcpy(m_szFileName, entry->m_szFileName);
}
-DBEntry *DBEntry::getFirts()
+DBEntry* DBEntry::getFirst()
{
entryID = 0;
DBEntry *entry = new DBEntry();
@@ -43,17 +44,14 @@ DBEntry *DBEntry::getNext(DBEntry *entry)
char szValue[256];
int count = db_get_dw(0, MODULE_FILES, "NextFileID", 0);
- for (; entryID < count; entryID++)
- {
+ for (; entryID < count; entryID++) {
int ftpNum = DB::getByteF(0, MODULE_FILES, "Ftp%d", entryID, -1);
- if (ftpNum != -1)
- {
- if (!DB::getAStringF(0, MODULE_FILES, "Filename%d", entryID, szValue))
- {
- entry->fileID = entryID;
- entry->iFtpNum = ftpNum;
- mir_strcpy(entry->szFileName, szValue);
- entry->deleteTS = DB::getDwordF(0, MODULE_FILES, "DeleteTS%d", entryID, 0);
+ if (ftpNum != -1) {
+ if (!DB::getAStringF(0, MODULE_FILES, "Filename%d", entryID, szValue)) {
+ entry->m_fileID = entryID;
+ entry->m_iFtpNum = ftpNum;
+ mir_strcpy(entry->m_szFileName, szValue);
+ entry->m_deleteTS = DB::getDwordF(0, MODULE_FILES, "DeleteTS%d", entryID, 0);
entryID++;
return entry;
}
@@ -67,36 +65,33 @@ DBEntry *DBEntry::getNext(DBEntry *entry)
void DBEntry::cleanupDB()
{
int count = 0;
-
- DBEntry *entry = getFirts();
- while (entry != NULL)
- {
- DB::setByteF(0, MODULE_FILES, "Ftp%d", count, entry->iFtpNum);
- DB::setAStringF(0, MODULE_FILES, "Filename%d", count, entry->szFileName);
- if (entry->deleteTS != 0)
- DB::setDwordF(0, MODULE_FILES, "DeleteTS%d", count, entry->deleteTS);
-
- count++;
+
+ DBEntry *entry = getFirst();
+ while (entry != NULL) {
+ DB::setByteF(0, MODULE_FILES, "Ftp%d", count, entry->m_iFtpNum);
+ DB::setAStringF(0, MODULE_FILES, "Filename%d", count, entry->m_szFileName);
+ if (entry->m_deleteTS != 0)
+ DB::setDwordF(0, MODULE_FILES, "DeleteTS%d", count, entry->m_deleteTS);
+
+ count++;
entry = getNext(entry);
}
db_set_dw(0, MODULE_FILES, "NextFileID", count);
}
-DBEntry *DBEntry::get(int fileID)
+DBEntry* DBEntry::get(int fileID)
{
char szValue[256];
DBEntry *entry = new DBEntry();
int ftpNum = DB::getByteF(0, MODULE_FILES, "Ftp%d", fileID, -1);
- if (ftpNum != -1)
- {
- if (!DB::getAStringF(0, MODULE_FILES, "Filename%d", fileID, szValue))
- {
- entry->fileID = fileID;
- entry->iFtpNum = ftpNum;
- mir_strcpy(entry->szFileName, szValue);
- entry->deleteTS = DB::getDwordF(0, MODULE_FILES, "DeleteTS%d", fileID, 0);
+ if (ftpNum != -1) {
+ if (!DB::getAStringF(0, MODULE_FILES, "Filename%d", fileID, szValue)) {
+ entry->m_fileID = fileID;
+ entry->m_iFtpNum = ftpNum;
+ mir_strcpy(entry->m_szFileName, szValue);
+ entry->m_deleteTS = DB::getDwordF(0, MODULE_FILES, "DeleteTS%d", fileID, 0);
return entry;
}
}
@@ -115,10 +110,9 @@ bool DBEntry::entryExists(GenericJob *job)
{
mir_cslock lock(mutexDB);
- DBEntry *entry = getFirts();
- while (entry != NULL)
- {
- if (entry->iFtpNum == job->iFtpNum && !strcmp(entry->szFileName, job->szSafeFileName))
+ DBEntry *entry = getFirst();
+ while (entry != NULL) {
+ if (entry->m_iFtpNum == job->m_iFtpNum && !strcmp(entry->m_szFileName, job->m_szSafeFileName))
return true;
entry = getNext(entry);
@@ -129,32 +123,30 @@ bool DBEntry::entryExists(GenericJob *job)
void DBEntry::add(GenericJob *job)
{
- if (entryExists(job))
+ if (entryExists(job))
return;
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);
+ DB::setByteF(0, MODULE_FILES, "Ftp%d", id, job->m_iFtpNum);
+ DB::setAStringF(0, MODULE_FILES, "Filename%d", id, job->m_szSafeFileName);
- if (job->tab->iOptAutoDelete != -1)
- {
+ if (job->m_tab->m_iOptAutoDelete != -1) {
time_t deleteTS = time(NULL);
- deleteTS += (job->tab->iOptAutoDelete * 60);
+ deleteTS += (job->m_tab->m_iOptAutoDelete * 60);
DB::setDwordF(0, MODULE_FILES, "DeleteTS%d", id, deleteTS);
}
-
+
db_set_dw(0, MODULE_FILES, "NextFileID", id + 1);
- job->fileID = id;
+ job->m_fileID = id;
}
void DBEntry::setDeleteTS(GenericJob *job)
{
- if (job->tab->iOptAutoDelete != -1)
- {
+ if (job->m_tab->m_iOptAutoDelete != -1) {
time_t deleteTS = time(NULL);
- deleteTS += (job->tab->iOptAutoDelete * 60);
- DB::setDwordF(0, MODULE_FILES, "DeleteTS%d", job->fileID, deleteTS);
+ deleteTS += (job->m_tab->m_iOptAutoDelete * 60);
+ DB::setDwordF(0, MODULE_FILES, "DeleteTS%d", job->m_fileID, deleteTS);
}
- else DB::deleteSettingF(0, MODULE_FILES, "DeleteTS%d", job->fileID);
+ else DB::deleteSettingF(0, MODULE_FILES, "DeleteTS%d", job->m_fileID);
}
diff --git a/plugins/FTPFileYM/src/dbentry.h b/plugins/FTPFileYM/src/dbentry.h
index 56ffa15c9b..8b0af27736 100644
--- a/plugins/FTPFileYM/src/dbentry.h
+++ b/plugins/FTPFileYM/src/dbentry.h
@@ -29,17 +29,17 @@ private:
static bool entryExists(GenericJob *job);
public:
- int fileID;
- int iFtpNum;
- char szFileName[256];
- DWORD deleteTS;
+ int m_fileID;
+ int m_iFtpNum;
+ char m_szFileName[256];
+ DWORD m_deleteTS;
static mir_cs mutexDB;
DBEntry();
DBEntry(DBEntry *entry);
- static DBEntry *getFirts();
+ static DBEntry *getFirst();
static DBEntry *getNext(DBEntry *entry);
static void cleanupDB();
diff --git a/plugins/FTPFileYM/src/deletetimer.cpp b/plugins/FTPFileYM/src/deletetimer.cpp
index f177ac081e..624d483553 100644
--- a/plugins/FTPFileYM/src/deletetimer.cpp
+++ b/plugins/FTPFileYM/src/deletetimer.cpp
@@ -24,15 +24,15 @@ DeleteTimer &deleteTimer = DeleteTimer::getInstance();
extern Options &opt;
void DeleteTimer::init()
-{
+{
timerId = 0;
- if (opt.bAutoDelete)
- this->start();
+ if (opt.bAutoDelete)
+ start();
}
void DeleteTimer::deinit()
-{
- this->stop();
+{
+ stop();
delete this;
}
@@ -44,26 +44,23 @@ void DeleteTimer::start()
void DeleteTimer::stop()
{
- if (timerId)
- {
+ if (timerId) {
KillTimer(NULL, timerId);
timerId = 0;
}
}
-void CALLBACK DeleteTimer::AutoDeleteTimerProc(HWND, UINT, UINT_PTR, DWORD)
+void CALLBACK DeleteTimer::AutoDeleteTimerProc(HWND, UINT, UINT_PTR, DWORD)
{
mir_cslock lock(DBEntry::mutexDB);
- DBEntry *entry = DBEntry::getFirts();
- while (entry != NULL)
- {
- if (entry->deleteTS > 0 && entry->deleteTS < time(NULL))
- {
+ DBEntry *entry = DBEntry::getFirst();
+ while (entry != NULL) {
+ if (entry->m_deleteTS > 0 && entry->m_deleteTS < time(NULL)) {
DeleteJob *job = new DeleteJob(new DBEntry(entry), NULL);
job->start();
- }
+ }
entry = DBEntry::getNext(entry);
}
-} \ No newline at end of file
+}
diff --git a/plugins/FTPFileYM/src/dialog.cpp b/plugins/FTPFileYM/src/dialog.cpp
index 61fec363ed..b6004ad18d 100644
--- a/plugins/FTPFileYM/src/dialog.cpp
+++ b/plugins/FTPFileYM/src/dialog.cpp
@@ -27,28 +27,27 @@ extern Options &opt;
UploadDialog::UploadDialog()
{
- this->hwnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DLG_UPLOAD), 0, UploadDlgProc);
- this->hwndTabs = GetDlgItem(this->hwnd, IDC_TAB);
- EnableThemeDialogTexture(this->hwnd, ETDT_ENABLETAB);
+ m_hwnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DLG_UPLOAD), 0, UploadDlgProc);
+ m_hwndTabs = GetDlgItem(m_hwnd, IDC_TAB);
+ EnableThemeDialogTexture(m_hwnd, ETDT_ENABLETAB);
- MONITORINFO mi = {0};
+ MONITORINFO mi = { 0 };
mi.cbSize = sizeof(mi);
- HMONITOR hMonitor = MonitorFromWindow(this->hwnd, MONITOR_DEFAULTTONEAREST);
+ HMONITOR hMonitor = MonitorFromWindow(m_hwnd, MONITOR_DEFAULTTONEAREST);
GetMonitorInfo(hMonitor, &mi);
RECT rc;
- GetWindowRect(this->hwnd, &rc);
- rc.left = mi.rcWork.left + ((mi.rcWork.right - mi.rcWork.left) - (rc.right-rc.left)) / 2;
- rc.top = mi.rcWork.top + ((mi.rcWork.bottom - mi.rcWork.top) - (rc.bottom-rc.top)) / 2;
- SetWindowPos(this->hwnd, 0, rc.left, rc.top, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
+ GetWindowRect(m_hwnd, &rc);
+ rc.left = mi.rcWork.left + ((mi.rcWork.right - mi.rcWork.left) - (rc.right - rc.left)) / 2;
+ rc.top = mi.rcWork.top + ((mi.rcWork.bottom - mi.rcWork.top) - (rc.bottom - rc.top)) / 2;
+ SetWindowPos(m_hwnd, 0, rc.left, rc.top, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
}
UploadDialog::~UploadDialog()
{
- if (this->hwnd)
- {
- ShowWindow(this->hwnd, SW_HIDE);
- SendMessage(this->hwnd, WMU_DESTROY, 0, 0);
+ if (m_hwnd) {
+ ShowWindow(m_hwnd, SW_HIDE);
+ SendMessage(m_hwnd, WMU_DESTROY, 0, 0);
}
instance = NULL;
@@ -57,91 +56,90 @@ UploadDialog::~UploadDialog()
void UploadDialog::selectTab(int index)
{
- if (tabs[index] != NULL)
- tabs[index]->select();
+ if (m_tabs[index] != NULL)
+ m_tabs[index]->select();
}
void UploadDialog::show()
{
- ShowWindow(this->hwnd, SW_SHOWNORMAL);
+ ShowWindow(m_hwnd, SW_SHOWNORMAL);
}
-UploadDialog::Tab::Tab(GenericJob *Job)
- : job(Job),
- bOptCloseDlg(opt.bCloseDlg),
- bOptCopyLink(opt.bCopyLink),
- bOptAutosend(opt.bAutosend),
- iOptAutoDelete(-1)
-{
+UploadDialog::Tab::Tab(GenericJob *Job) :
+ m_job(Job),
+ m_bOptCloseDlg(opt.bCloseDlg),
+ m_bOptCopyLink(opt.bCopyLink),
+ m_bOptAutosend(opt.bAutosend),
+ m_iOptAutoDelete(-1)
+{
if (opt.bAutoDelete)
- this->iOptAutoDelete = Utils::getDeleteTimeMin();
+ m_iOptAutoDelete = Utils::getDeleteTimeMin();
- this->stzSpeed[0] = 0;
- this->stzComplet[0] = 0;
- this->stzRemain[0] = 0;
+ m_stzSpeed[0] = 0;
+ m_stzComplet[0] = 0;
+ m_stzRemain[0] = 0;
TCHAR buff[256];
- TCITEM tab = {0};
+ TCITEM tab = { 0 };
tab.mask = TCIF_TEXT;
- tab.pszText = Utils::getTextFragment(job->stzFileName, 20, buff);
- TabCtrl_InsertItem(uDlg->hwndTabs, uDlg->tabs.size(), &tab);
+ tab.pszText = Utils::getTextFragment(m_job->m_tszFileName, 20, buff);
+ TabCtrl_InsertItem(uDlg->m_hwndTabs, uDlg->m_tabs.size(), &tab);
{
mir_cslock lock(mutexTabs);
- uDlg->tabs.push_back(this);
+ uDlg->m_tabs.push_back(this);
}
- this->select();
+ select();
}
UploadDialog::Tab::~Tab()
-{
- { mir_cslock lock(mutexTabs);
- TabCtrl_DeleteItem(uDlg->hwndTabs, this->index());
- uDlg->tabs.erase(uDlg->tabs.begin() + this->index());
+{
+ {
+ mir_cslock lock(mutexTabs);
+ TabCtrl_DeleteItem(uDlg->m_hwndTabs, index());
+ uDlg->m_tabs.erase(uDlg->m_tabs.begin() + index());
}
- if (this->job->isCompleted())
- delete this->job;
+ if (m_job->isCompleted())
+ delete m_job;
- if (uDlg->tabs.size() == 0)
+ if (uDlg->m_tabs.size() == 0)
delete uDlg;
- else
+ else
uDlg->selectTab(0);
}
int UploadDialog::Tab::index()
{
- for (UINT i = 0; i < uDlg->tabs.size(); i++)
- {
- if (uDlg->tabs[i] == this)
+ for (UINT i = 0; i < uDlg->m_tabs.size(); i++)
+ if (uDlg->m_tabs[i] == this)
return i;
- }
return -1;
}
void UploadDialog::Tab::select()
-{
- TabCtrl_SetCurSel(uDlg->hwndTabs, this->index());
+{
+ TabCtrl_SetCurSel(uDlg->m_hwndTabs, index());
{
mir_cslock lock(mutexTabs);
- uDlg->activeTab = this->index();
+ uDlg->m_activeTab = index();
}
- this->job->refreshTab(true);
- InvalidateRect(uDlg->hwnd, NULL, TRUE);
+ m_job->refreshTab(true);
+ InvalidateRect(uDlg->m_hwnd, NULL, TRUE);
}
void UploadDialog::Tab::labelCompleted()
-{
+{
TCHAR buff[64], buff2[256];
- mir_sntprintf(buff2, _countof(buff2), _T("* %s"), Utils::getTextFragment(this->job->stzFileName, 20, buff));
+ mir_sntprintf(buff2, _countof(buff2), _T("* %s"), Utils::getTextFragment(m_job->m_tszFileName, 20, buff));
- TCITEM tab = {0};
+ TCITEM tab = { 0 };
tab.mask = TCIF_TEXT;
tab.pszText = buff2;
- TabCtrl_SetItem(uDlg->hwndTabs, this->index(), &tab);
+ TabCtrl_SetItem(uDlg->m_hwndTabs, index(), &tab);
}
-LRESULT CALLBACK UploadDialog::TabControlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK UploadDialog::TabControlProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_LBUTTONDBLCLK:
@@ -149,15 +147,15 @@ LRESULT CALLBACK UploadDialog::TabControlProc(HWND hwnd, UINT msg, WPARAM wParam
{
POINT pt;
GetCursorPos(&pt);
- ScreenToClient(uDlg->hwndTabs, &pt);
+ ScreenToClient(uDlg->m_hwndTabs, &pt);
TCHITTESTINFO tch;
tch.pt = pt;
tch.flags = 0;
- int index = TabCtrl_HitTest(uDlg->hwndTabs, &tch);
+ int index = TabCtrl_HitTest(uDlg->m_hwndTabs, &tch);
if (index != -1)
- uDlg->tabs[index]->job->closeTab();
+ uDlg->m_tabs[index]->m_job->closeTab();
}
break;
}
@@ -165,18 +163,16 @@ LRESULT CALLBACK UploadDialog::TabControlProc(HWND hwnd, UINT msg, WPARAM wParam
return mir_callNextSubclass(hwnd, UploadDialog::TabControlProc, msg, wParam, lParam);
}
-INT_PTR CALLBACK UploadDialog::UploadDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK UploadDialog::UploadDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Utils::loadIconEx("main"));
-
- mir_subclassWindow(GetDlgItem(hwndDlg, IDC_TAB), TabControlProc);
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Utils::loadIconEx("main"));
- LOGFONT logFont = {0};
+ mir_subclassWindow(GetDlgItem(hwndDlg, IDC_TAB), TabControlProc);
+ {
+ LOGFONT logFont = { 0 };
HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_ST_FILE, WM_GETFONT, 0, 0);
GetObject(hFont, sizeof(logFont), &logFont);
logFont.lfWeight = FW_BOLD;
@@ -218,232 +214,205 @@ INT_PTR CALLBACK UploadDialog::UploadDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar
SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BUTTONSETASFLATBTN, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_DELETE));
SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Close"), BATF_TCHAR);
-
- break;
}
- case WM_MEASUREITEM:
- return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam);
+ break;
+
+ case WM_MEASUREITEM:
+ return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam);
- case WM_DRAWITEM:
- return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam);
+ case WM_DRAWITEM:
+ return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam);
- case WM_COMMAND:
+ case WM_COMMAND:
{
- MCONTACT hContact = uDlg->tabs[uDlg->activeTab]->job->hContact;
+ MCONTACT hContact = uDlg->m_tabs[uDlg->m_activeTab]->m_job->m_hContact;
if (hContact != NULL)
- {
- if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU), hContact))
+ if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), hContact))
break;
- }
- if (HIWORD(wParam) == BN_CLICKED)
- {
- switch (LOWORD(wParam))
- {
- case IDC_BTN_PROTO:
- {
- if (hContact != NULL)
- {
- RECT rc;
- GetWindowRect((HWND)lParam, &rc);
- HMENU hMenu = Menu_BuildContactMenu(hContact);
- TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
- DestroyMenu(hMenu);
- }
-
- break;
- }
- case IDC_BTN_PAUSE:
- {
- uDlg->tabs[uDlg->activeTab]->job->pauseHandler();
- return TRUE;
- }
- case IDC_BTN_CLIPBOARD:
- {
- UploadJob *job = (UploadJob *)uDlg->tabs[uDlg->activeTab]->job;
- Utils::copyToClipboard(job->szFileLink);
- return TRUE;
+ if (HIWORD(wParam) == BN_CLICKED) {
+ switch (LOWORD(wParam)) {
+ case IDC_BTN_PROTO:
+ if (hContact != NULL) {
+ RECT rc;
+ GetWindowRect((HWND)lParam, &rc);
+ HMENU hMenu = Menu_BuildContactMenu(hContact);
+ TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
+ DestroyMenu(hMenu);
}
- case IDC_BTN_DOWNLOAD:
+ break;
+
+ case IDC_BTN_PAUSE:
+ uDlg->m_tabs[uDlg->m_activeTab]->m_job->pauseHandler();
+ return TRUE;
+
+ case IDC_BTN_CLIPBOARD:
{
- UploadJob *job = (UploadJob *)uDlg->tabs[uDlg->activeTab]->job;
- ShellExecuteA(NULL, "open", job->szFileLink, NULL, NULL, SW_SHOWNORMAL);
- return TRUE;
+ UploadJob *job = (UploadJob *)uDlg->m_tabs[uDlg->m_activeTab]->m_job;
+ Utils::copyToClipboard(job->m_szFileLink);
}
- case IDC_BTN_FILEMANAGER:
+ return TRUE;
+
+ case IDC_BTN_DOWNLOAD:
{
- CallService(MS_FTPFILE_SHOWMANAGER, 0, 0);
- return TRUE;
+ UploadJob *job = (UploadJob *)uDlg->m_tabs[uDlg->m_activeTab]->m_job;
+ ShellExecuteA(NULL, "open", job->m_szFileLink, NULL, NULL, SW_SHOWNORMAL);
}
- case IDC_BTN_OPTIONS:
- {
- Tab *tab = uDlg->tabs[uDlg->activeTab];
-
- POINT pt;
- GetCursorPos(&pt);
- SetForegroundWindow(uDlg->hwndTabs);
-
- HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU_UPLOAD));
- if (hMenu)
- {
- HMENU hPopupMenu = GetSubMenu(hMenu, 0);
- TranslateMenu(hPopupMenu);
- CheckMenuItem(hPopupMenu, IDM_CLOSEDLG, MF_BYCOMMAND | tab->bOptCloseDlg ? MF_CHECKED : 0);
- CheckMenuItem(hPopupMenu, IDM_COPYLINK, MF_BYCOMMAND | tab->bOptCopyLink ? MF_CHECKED : 0);
- CheckMenuItem(hPopupMenu, IDM_AUTOSEND, MF_BYCOMMAND | tab->bOptAutosend ? MF_CHECKED : 0);
-
- HMENU hTimeMenu = GetSubMenu(hPopupMenu, 3);
- CheckMenuItem(hTimeMenu, IDM_DISABLED, MF_BYCOMMAND | (tab->iOptAutoDelete == -1) ? MF_CHECKED : MF_UNCHECKED);
-
- int times[10] = {5, 15, 30, 1 * 60, 2 * 60, 5 * 60, 10 * 60, 1 * 24 * 60, 2 * 24 * 60, 7 * 24 * 60};
- bool bChecked = (tab->iOptAutoDelete == -1) ? true : false;
- TCHAR buff[256];
-
- for (int i = 0; i < _countof(times); i++)
- {
- if (i == 3 || i == 7)
- AppendMenu(hTimeMenu, MF_SEPARATOR, 0, 0);
-
- if (i < 3)
- mir_sntprintf(buff, TranslateT("%d minutes"), times[i]);
- else if (i < 7)
- mir_sntprintf(buff, TranslateT("%d hours"), times[i] / 60);
- else
- mir_sntprintf(buff, TranslateT("%d days"), times[i] / 60 / 24);
-
- UINT check = MF_UNCHECKED;
- if (!bChecked && tab->iOptAutoDelete == times[i])
- {
- check = MF_CHECKED;
- bChecked = true;
- }
-
- AppendMenu(hTimeMenu, MF_STRING | check, times[i], buff);
- }
+ return TRUE;
+
+ case IDC_BTN_FILEMANAGER:
+ CallService(MS_FTPFILE_SHOWMANAGER, 0, 0);
+ return TRUE;
+
+ case IDC_BTN_CLOSE:
+ uDlg->m_tabs[uDlg->m_activeTab]->m_job->closeTab();
+ return TRUE;
+
+ case IDC_BTN_OPTIONS:
+ Tab *tab = uDlg->m_tabs[uDlg->m_activeTab];
+
+ POINT pt;
+ GetCursorPos(&pt);
+ SetForegroundWindow(uDlg->m_hwndTabs);
+
+ HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU_UPLOAD));
+ if (hMenu) {
+ HMENU hPopupMenu = GetSubMenu(hMenu, 0);
+ TranslateMenu(hPopupMenu);
+ CheckMenuItem(hPopupMenu, IDM_CLOSEDLG, MF_BYCOMMAND | tab->m_bOptCloseDlg ? MF_CHECKED : 0);
+ CheckMenuItem(hPopupMenu, IDM_COPYLINK, MF_BYCOMMAND | tab->m_bOptCopyLink ? MF_CHECKED : 0);
+ CheckMenuItem(hPopupMenu, IDM_AUTOSEND, MF_BYCOMMAND | tab->m_bOptAutosend ? MF_CHECKED : 0);
- if (opt.bAutoDelete)
- {
- switch (opt.timeRange)
- {
- case Options::TR_MINUTES: mir_sntprintf(buff, TranslateT("%d minutes"), opt.iDeleteTime); break;
- case Options::TR_HOURS: mir_sntprintf(buff, TranslateT("%d hours"), opt.iDeleteTime); break;
- case Options::TR_DAYS: mir_sntprintf(buff, TranslateT("%d days"), opt.iDeleteTime); break;
- }
+ HMENU hTimeMenu = GetSubMenu(hPopupMenu, 3);
+ CheckMenuItem(hTimeMenu, IDM_DISABLED, MF_BYCOMMAND | (tab->m_iOptAutoDelete == -1) ? MF_CHECKED : MF_UNCHECKED);
+ int times[10] = { 5, 15, 30, 1 * 60, 2 * 60, 5 * 60, 10 * 60, 1 * 24 * 60, 2 * 24 * 60, 7 * 24 * 60 };
+ bool bChecked = (tab->m_iOptAutoDelete == -1);
+ TCHAR buff[256];
+
+ for (int i = 0; i < _countof(times); i++) {
+ if (i == 3 || i == 7)
AppendMenu(hTimeMenu, MF_SEPARATOR, 0, 0);
- AppendMenu(hTimeMenu, MF_STRING | bChecked ? MF_UNCHECKED : MF_CHECKED, IDM_CUSTOM, buff);
+
+ if (i < 3)
+ mir_sntprintf(buff, TranslateT("%d minutes"), times[i]);
+ else if (i < 7)
+ mir_sntprintf(buff, TranslateT("%d hours"), times[i] / 60);
+ else
+ mir_sntprintf(buff, TranslateT("%d days"), times[i] / 60 / 24);
+
+ UINT check = MF_UNCHECKED;
+ if (!bChecked && tab->m_iOptAutoDelete == times[i]) {
+ check = MF_CHECKED;
+ bChecked = true;
}
- int command = TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, uDlg->hwndTabs, NULL);
- switch (command)
- {
- case IDM_CLOSEDLG:
- tab->bOptCloseDlg = !tab->bOptCloseDlg; break;
- case IDM_COPYLINK:
- tab->bOptCopyLink = !tab->bOptCopyLink; break;
- case IDM_AUTOSEND:
- tab->bOptAutosend = !tab->bOptAutosend; break;
- case IDM_DISABLED:
- tab->iOptAutoDelete = -1; break;
- case IDM_CUSTOM:
- switch (opt.timeRange)
- {
- case Options::TR_MINUTES: tab->iOptAutoDelete = opt.iDeleteTime; break;
- case Options::TR_HOURS: tab->iOptAutoDelete = opt.iDeleteTime * 60; break;
- case Options::TR_DAYS: tab->iOptAutoDelete = opt.iDeleteTime * 60 * 24; break;
- }
- break;
- default:
- tab->iOptAutoDelete = command;
- break;
+ AppendMenu(hTimeMenu, MF_STRING | check, times[i], buff);
+ }
+
+ if (opt.bAutoDelete) {
+ switch (opt.timeRange) {
+ case Options::TR_MINUTES: mir_sntprintf(buff, TranslateT("%d minutes"), opt.iDeleteTime); break;
+ case Options::TR_HOURS: mir_sntprintf(buff, TranslateT("%d hours"), opt.iDeleteTime); break;
+ case Options::TR_DAYS: mir_sntprintf(buff, TranslateT("%d days"), opt.iDeleteTime); break;
}
- if (command && ((UploadJob *)tab->job)->isCompleted())
- DBEntry::setDeleteTS(tab->job);
+ AppendMenu(hTimeMenu, MF_SEPARATOR, 0, 0);
+ AppendMenu(hTimeMenu, MF_STRING | bChecked ? MF_UNCHECKED : MF_CHECKED, IDM_CUSTOM, buff);
+ }
- DestroyMenu(hMenu);
+ int command = TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, uDlg->m_hwndTabs, NULL);
+ switch (command) {
+ case IDM_CLOSEDLG:
+ tab->m_bOptCloseDlg = !tab->m_bOptCloseDlg; break;
+ case IDM_COPYLINK:
+ tab->m_bOptCopyLink = !tab->m_bOptCopyLink; break;
+ case IDM_AUTOSEND:
+ tab->m_bOptAutosend = !tab->m_bOptAutosend; break;
+ case IDM_DISABLED:
+ tab->m_iOptAutoDelete = -1; break;
+ case IDM_CUSTOM:
+ switch (opt.timeRange) {
+ case Options::TR_MINUTES: tab->m_iOptAutoDelete = opt.iDeleteTime; break;
+ case Options::TR_HOURS: tab->m_iOptAutoDelete = opt.iDeleteTime * 60; break;
+ case Options::TR_DAYS: tab->m_iOptAutoDelete = opt.iDeleteTime * 60 * 24; break;
+ }
+ break;
+ default:
+ tab->m_iOptAutoDelete = command;
+ break;
}
- return TRUE;
- }
- case IDC_BTN_CLOSE:
- {
- uDlg->tabs[uDlg->activeTab]->job->closeTab();
- return TRUE;
+
+ if (command && ((UploadJob *)tab->m_job)->isCompleted())
+ DBEntry::setDeleteTS(tab->m_job);
+
+ DestroyMenu(hMenu);
}
+ return TRUE;
}
}
break;
}
- case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->code)
- {
- case TCN_SELCHANGE:
- {
- uDlg->selectTab(TabCtrl_GetCurSel(uDlg->hwndTabs));
- break;
- }
- case TTN_GETDISPINFO:
- {
- LPNMTTDISPINFO pInfo = (LPNMTTDISPINFO)lParam;
- POINT pt;
- GetCursorPos(&pt);
- ScreenToClient(hwndDlg, &pt);
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->code) {
+ case TCN_SELCHANGE:
+ uDlg->selectTab(TabCtrl_GetCurSel(uDlg->m_hwndTabs));
+ break;
- UINT i; RECT rc;
- for (i = 0; i < uDlg->tabs.size(); i++)
- {
- if (uDlg->tabs[i] != NULL)
- {
- TabCtrl_GetItemRect(uDlg->hwndTabs, i, &rc);
- if (PtInRect(&rc, pt)) break;
- }
- }
+ case TTN_GETDISPINFO:
+ LPNMTTDISPINFO pInfo = (LPNMTTDISPINFO)lParam;
- if (i < uDlg->tabs.size())
- {
- uDlg->tabs[i]->job->createToolTip();
- HWND hToolTip = TabCtrl_GetToolTips(uDlg->hwndTabs);
- SendMessage(hToolTip, TTM_SETMAXTIPWIDTH, 0, (LPARAM)500);
- pInfo->lpszText = uDlg->stzToolTipText;
- }
+ POINT pt;
+ GetCursorPos(&pt);
+ ScreenToClient(hwndDlg, &pt);
- break;
+ UINT i; RECT rc;
+ for (i = 0; i < uDlg->m_tabs.size(); i++) {
+ if (uDlg->m_tabs[i] != NULL) {
+ TabCtrl_GetItemRect(uDlg->m_hwndTabs, i, &rc);
+ if (PtInRect(&rc, pt))
+ break;
}
}
+
+ if (i < uDlg->m_tabs.size()) {
+ uDlg->m_tabs[i]->m_job->createToolTip();
+ HWND hToolTip = TabCtrl_GetToolTips(uDlg->m_hwndTabs);
+ SendMessage(hToolTip, TTM_SETMAXTIPWIDTH, 0, (LPARAM)500);
+ pInfo->lpszText = uDlg->m_tszToolTipText;
+ }
+
break;
}
- case WM_CLOSE:
+ break;
+
+ case WM_CLOSE:
{
- for (UINT i = 0; i < uDlg->tabs.size(); i++)
- uDlg->tabs[i]->job->pause();
+ for (UINT i = 0; i < uDlg->m_tabs.size(); i++)
+ uDlg->m_tabs[i]->m_job->pause();
- int result = IDYES;
+ int result = IDYES;
if (!Miranda_Terminated() && UploadJob::iRunningJobCount > 0)
result = Utils::msgBox(TranslateT("Do you really want to cancel all running jobs?"), MB_YESNO | MB_ICONQUESTION);
- if (result == IDYES)
- {
+ if (result == IDYES) {
SkinPlaySound(SOUND_CANCEL);
- size_t count = uDlg->tabs.size();
- for (UINT i = 0; i < count; i++)
- uDlg->tabs[0]->job->closeAllTabs();
+ size_t count = uDlg->m_tabs.size();
+ for (UINT i = 0; i < count; i++)
+ uDlg->m_tabs[0]->m_job->closeAllTabs();
+ }
+ else {
+ for (UINT i = 0; i < uDlg->m_tabs.size(); i++)
+ uDlg->m_tabs[i]->m_job->resume();
}
- else
- {
- for (UINT i = 0; i < uDlg->tabs.size(); i++)
- uDlg->tabs[i]->job->resume();
- }
-
- break;
- }
- case WMU_DESTROY:
- {
- DestroyWindow(hwndDlg);
- break;
}
+ break;
+
+ case WMU_DESTROY:
+ DestroyWindow(hwndDlg);
+ break;
}
return FALSE;
-} \ No newline at end of file
+}
diff --git a/plugins/FTPFileYM/src/dialog.h b/plugins/FTPFileYM/src/dialog.h
index 0f8db40f6f..9354d45e3c 100644
--- a/plugins/FTPFileYM/src/dialog.h
+++ b/plugins/FTPFileYM/src/dialog.h
@@ -33,7 +33,7 @@ class UploadDialog
private:
static UploadDialog *instance;
static mir_cs mutexTabs;
- TCHAR stzToolTipText[1024];
+ TCHAR m_tszToolTipText[1024];
UploadDialog();
@@ -41,16 +41,16 @@ public:
class Tab
{
public:
- GenericJob *job;
+ GenericJob *m_job;
- bool bOptCloseDlg;
- bool bOptCopyLink;
- bool bOptAutosend;
- int iOptAutoDelete;
+ bool m_bOptCloseDlg;
+ bool m_bOptCopyLink;
+ bool m_bOptAutosend;
+ int m_iOptAutoDelete;
- TCHAR stzSpeed[64];
- TCHAR stzComplet[64];
- TCHAR stzRemain[64];
+ TCHAR m_stzSpeed[64];
+ TCHAR m_stzComplet[64];
+ TCHAR m_stzRemain[64];
Tab(GenericJob *Job);
~Tab();
@@ -60,11 +60,11 @@ public:
void labelCompleted();
};
- HWND hwnd;
- HWND hwndTabs;
- int activeTab;
+ HWND m_hwnd;
+ HWND m_hwndTabs;
+ int m_activeTab;
- vector<Tab *> tabs;
+ vector<Tab *> m_tabs;
~UploadDialog();
@@ -80,4 +80,4 @@ public:
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);
-}; \ No newline at end of file
+};
diff --git a/plugins/FTPFileYM/src/ftpfile.cpp b/plugins/FTPFileYM/src/ftpfile.cpp
index 30ca9c91d7..8eba5013dd 100644
--- a/plugins/FTPFileYM/src/ftpfile.cpp
+++ b/plugins/FTPFileYM/src/ftpfile.cpp
@@ -35,7 +35,7 @@ extern Options &opt;
int PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
void PrebuildMainMenu();
int TabsrmmButtonPressed(WPARAM wParam, LPARAM lParam);
-int UploadFile(MCONTACT hContact, int iFtpNum, UploadJob::EMode mode);
+int UploadFile(MCONTACT hContact, int m_iFtpNum, UploadJob::EMode mode);
static PLUGININFOEX pluginInfoEx =
{
@@ -205,14 +205,14 @@ int PrebuildContactMenu(WPARAM wParam, LPARAM)
bool bHideRoot = opt.bHideInactive;
for (int i = 0; i < ServerList::FTP_COUNT; i++)
- if (ftpList[i]->bEnabled)
+ if (ftpList[i]->m_bEnabled)
bHideRoot = false;
if (opt.bUseSubmenu)
Menu_ShowItem(hMenu, bIsContact && !bHideRoot);
for (int i = 0; i < ServerList::FTP_COUNT; i++)
- Menu_ShowItem(hSubMenu[i], bIsContact && ftpList[i]->bEnabled);
+ Menu_ShowItem(hSubMenu[i], bIsContact && ftpList[i]->m_bEnabled);
return 0;
}
@@ -220,7 +220,7 @@ void PrebuildMainMenu()
{
for (int i = 0; i < ServerList::FTP_COUNT; i++)
if (ftpList[i])
- Menu_ShowItem(hMainSubMenu[i], ftpList[i]->bEnabled);
+ Menu_ShowItem(hMainSubMenu[i], ftpList[i]->m_bEnabled);
}
int TabsrmmButtonPressed(WPARAM hContact, LPARAM lParam)
@@ -233,12 +233,12 @@ int TabsrmmButtonPressed(WPARAM hContact, LPARAM lParam)
if (hPopupMenu) {
int iCount = 0;
for (UINT i = 0; i < ServerList::FTP_COUNT; i++) {
- if (ftpList[i]->bEnabled) {
+ if (ftpList[i]->m_bEnabled) {
HMENU hModeMenu = CreatePopupMenu();
AppendMenu(hModeMenu, MF_STRING, i + UploadJob::FTP_RAWFILE, TranslateT("Upload file"));
AppendMenu(hModeMenu, MF_STRING, i + UploadJob::FTP_ZIPFILE, TranslateT("Zip and upload file"));
AppendMenu(hModeMenu, MF_STRING, i + UploadJob::FTP_ZIPFOLDER, TranslateT("Zip and upload folder"));
- AppendMenu(hPopupMenu, MF_STRING | MF_POPUP, (UINT_PTR)hModeMenu, ftpList[i]->stzName);
+ AppendMenu(hPopupMenu, MF_STRING | MF_POPUP, (UINT_PTR)hModeMenu, ftpList[i]->m_stzName);
DestroyMenu(hModeMenu);
iCount++;
}
@@ -270,18 +270,18 @@ int TabsrmmButtonPressed(WPARAM hContact, LPARAM lParam)
return 0;
}
-int UploadFile(MCONTACT hContact, int iFtpNum, GenericJob::EMode mode, void **objects, int objCount, DWORD flags)
+int UploadFile(MCONTACT hContact, int m_iFtpNum, GenericJob::EMode mode, void **objects, int objCount, DWORD flags)
{
- if (!ftpList[iFtpNum]->isValid()) {
+ if (!ftpList[m_iFtpNum]->isValid()) {
Utils::msgBox(TranslateT("You have to fill FTP server setting before upload a file."), MB_OK | MB_ICONERROR);
return 1;
}
GenericJob *job;
if (mode == GenericJob::FTP_RAWFILE)
- job = new UploadJob(hContact, iFtpNum, mode);
+ job = new UploadJob(hContact, m_iFtpNum, mode);
else
- job = new PackerJob(hContact, iFtpNum, mode);
+ job = new PackerJob(hContact, m_iFtpNum, mode);
int result;
if (objects != NULL)
@@ -291,7 +291,7 @@ int UploadFile(MCONTACT hContact, int iFtpNum, GenericJob::EMode mode, void **ob
if (result != 0) {
uDlg = UploadDialog::getInstance();
- if (!uDlg->hwnd || !uDlg->hwndTabs) {
+ 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;
return 1;
@@ -308,16 +308,16 @@ int UploadFile(MCONTACT hContact, int iFtpNum, GenericJob::EMode mode, void **ob
return 0;
}
-int UploadFile(MCONTACT hContact, int iFtpNum, GenericJob::EMode mode)
+int UploadFile(MCONTACT hContact, int m_iFtpNum, GenericJob::EMode mode)
{
- return UploadFile(hContact, iFtpNum, mode, NULL, 0, 0);
+ return UploadFile(hContact, m_iFtpNum, mode, NULL, 0, 0);
}
//------------ MIRANDA SERVICES ------------//
INT_PTR UploadService(WPARAM, LPARAM lParam)
{
- FTPUPLOAD* ftpu = (FTPUPLOAD *)lParam;
+ FTPUPLOAD *ftpu = (FTPUPLOAD *)lParam;
if (ftpu == NULL || ftpu->cbSize != sizeof(FTPUPLOAD))
return 1;
@@ -369,7 +369,8 @@ int Shutdown(WPARAM, LPARAM)
deleteTimer.deinit();
delete manDlg;
- if (uDlg) SendMessage(uDlg->hwnd, WM_CLOSE, 0, 0);
+ if (uDlg)
+ SendMessage(uDlg->m_hwnd, WM_CLOSE, 0, 0);
UploadJob::jobDone.release();
DeleteJob::jobDone.release();
@@ -388,9 +389,9 @@ extern "C" int __declspec(dllexport) Load(void)
mir_getLP(&pluginInfoEx);
mir_getCLI();
- #ifdef _DEBUG
+#ifdef _DEBUG
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
- #endif
+#endif
CoInitialize(NULL);
diff --git a/plugins/FTPFileYM/src/job_delete.cpp b/plugins/FTPFileYM/src/job_delete.cpp
index 7ba1f76b30..19d6aff7ad 100644
--- a/plugins/FTPFileYM/src/job_delete.cpp
+++ b/plugins/FTPFileYM/src/job_delete.cpp
@@ -26,24 +26,25 @@ int DeleteJob::iRunningJobCount = 0;
extern ServerList &ftpList;
extern Manager *manDlg;
-DeleteJob::DeleteJob(DBEntry *_entry, Manager::TreeItem *_item)
-:entry(_entry),treeItem(_item),ftp(ftpList[entry->iFtpNum])
-{ }
+DeleteJob::DeleteJob(DBEntry *entry, Manager::TreeItem *item) :
+ m_entry(entry),
+ m_treeItem(item),
+ m_ftp(ftpList[m_entry->m_iFtpNum])
+{
+}
DeleteJob::~DeleteJob()
{
- delete this->entry;
+ delete m_entry;
}
-void DeleteJob::waitingThread(void *arg)
+void DeleteJob::waitingThread(void *arg)
{
DeleteJob *job = (DeleteJob *)arg;
- while(!Miranda_Terminated())
- {
+ while (!Miranda_Terminated()) {
mir_cslockfull lock(mutexJobCount);
- if (iRunningJobCount < MAX_RUNNING_JOBS)
- {
+ if (iRunningJobCount < MAX_RUNNING_JOBS) {
iRunningJobCount++;
lock.unlock();
job->run();
@@ -74,50 +75,47 @@ void DeleteJob::run()
char szError[1024];
CURL *hCurl = curl_easy_init();
- if (hCurl)
- {
+ if (hCurl) {
struct curl_slist *headerList = NULL;
headerList = curl_slist_append(headerList, getDelFileString());
- Utils::curlSetOpt(hCurl, this->ftp, getDelUrlString(), headerList, szError);
+ Utils::curlSetOpt(hCurl, m_ftp, getDelUrlString(), headerList, szError);
int result = curl_easy_perform(hCurl);
- if (result == CURLE_OK)
- {
- if (manDlg != NULL && this->treeItem)
- this->treeItem->remove();
+ if (result == CURLE_OK) {
+ if (manDlg != NULL && m_treeItem)
+ m_treeItem->remove();
else
- DBEntry::remove(entry->fileID);
+ DBEntry::remove(m_entry->m_fileID);
}
- else if (manDlg != NULL && this->treeItem)
- {
+ else if (manDlg != NULL && m_treeItem) {
TCHAR *error = mir_a2t(szError);
- mir_tstrcpy(this->treeItem->stzToolTip, error);
- this->treeItem->setState(Manager::TreeItem::_ERROR());
+ mir_tstrcpy(m_treeItem->m_tszToolTip, error);
+ m_treeItem->setState(Manager::TreeItem::_ERROR());
FREE(error);
- }
+ }
curl_slist_free_all(headerList);
curl_easy_cleanup(hCurl);
}
}
-char *DeleteJob::getDelFileString()
+char* DeleteJob::getDelFileString()
{
- if (ftp->ftpProto == ServerList::FTP::FT_SSH)
- mir_snprintf(buff, "rm \"%s/%s\"", ftp->szDir, entry->szFileName);
+ if (m_ftp->m_ftpProto == ServerList::FTP::FT_SSH)
+ mir_snprintf(m_buff, "rm \"%s/%s\"", m_ftp->m_szDir, m_entry->m_szFileName);
else
- mir_snprintf(buff, "DELE %s", entry->szFileName);
+ mir_snprintf(m_buff, "DELE %s", m_entry->m_szFileName);
- return buff;
+ return m_buff;
}
-char *DeleteJob::getDelUrlString()
-{
- if (ftp->szDir[0] && ftp->ftpProto != ServerList::FTP::FT_SSH)
- mir_snprintf(buff, "%s%s/%s/", ftp->getProtoString(), ftp->szServer, ftp->szDir);
+char* DeleteJob::getDelUrlString()
+{
+ if (m_ftp->m_szDir[0] && m_ftp->m_ftpProto != ServerList::FTP::FT_SSH)
+ mir_snprintf(m_buff, "%s%s/%s/", m_ftp->getProtoString(), m_ftp->m_szServer, m_ftp->m_szDir);
else
- mir_snprintf(buff, "%s%s/", ftp->getProtoString(), ftp->szServer);
+ mir_snprintf(m_buff, "%s%s/", m_ftp->getProtoString(), m_ftp->m_szServer);
- return buff;
-} \ No newline at end of file
+ return m_buff;
+}
diff --git a/plugins/FTPFileYM/src/job_delete.h b/plugins/FTPFileYM/src/job_delete.h
index 79ef0f2794..73e6b79822 100644
--- a/plugins/FTPFileYM/src/job_delete.h
+++ b/plugins/FTPFileYM/src/job_delete.h
@@ -26,10 +26,10 @@ class DeleteJob
private:
static const int MAX_RUNNING_JOBS = 2;
- DBEntry *entry;
- Manager::TreeItem *treeItem;
- ServerList::FTP *ftp;
- char buff[256];
+ DBEntry *m_entry;
+ Manager::TreeItem *m_treeItem;
+ ServerList::FTP *m_ftp;
+ char m_buff[256];
static mir_cs mutexJobCount;
static int iRunningJobCount;
diff --git a/plugins/FTPFileYM/src/job_generic.cpp b/plugins/FTPFileYM/src/job_generic.cpp
index e05561bfd8..0c99989da0 100644
--- a/plugins/FTPFileYM/src/job_generic.cpp
+++ b/plugins/FTPFileYM/src/job_generic.cpp
@@ -21,53 +21,61 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
extern UploadDialog *uDlg;
extern ServerList &ftpList;
-GenericJob::GenericJob(MCONTACT _hContact, int _iFtpNum, EMode _mode) :
- hContact(_hContact),iFtpNum(_iFtpNum),mode(_mode),status(STATUS_CREATED),ftp(ftpList[iFtpNum])
+GenericJob::GenericJob(MCONTACT hContact, int iFtpNum, EMode mode) :
+ m_hContact(hContact),
+ m_iFtpNum(iFtpNum),
+ m_mode(mode),
+ m_status(STATUS_CREATED),
+ m_ftp(ftpList[m_iFtpNum])
{
- this->stzFilePath[0] = 0;
- this->stzFileName[0] = 0;
- this->szSafeFileName[0] = 0;
+ m_tszFilePath[0] = 0;
+ m_tszFileName[0] = 0;
+ m_szSafeFileName[0] = 0;
}
-GenericJob::GenericJob(GenericJob *job)
-:hContact(job->hContact),iFtpNum(job->iFtpNum),mode(job->mode),status(job->status),ftp(job->ftp),tab(job->tab)
-{
- mir_tstrcpy(this->stzFilePath, job->stzFilePath);
- mir_tstrcpy(this->stzFileName, job->stzFileName);
- mir_strcpy(this->szSafeFileName, job->szSafeFileName);
+GenericJob::GenericJob(GenericJob *job) :
+ m_hContact(job->m_hContact),
+ m_iFtpNum(job->m_iFtpNum),
+ m_mode(job->m_mode),
+ m_status(job->m_status),
+ m_ftp(job->m_ftp),
+ m_tab(job->m_tab)
+{
+ mir_tstrcpy(m_tszFilePath, job->m_tszFilePath);
+ mir_tstrcpy(m_tszFileName, job->m_tszFileName);
+ mir_strcpy(m_szSafeFileName, job->m_szSafeFileName);
}
GenericJob::~GenericJob()
{
- for (UINT i = 0; i < this->files.size(); i++)
- mir_free(this->files[i]);
+ for (UINT i = 0; i < m_files.size(); i++)
+ mir_free(m_files[i]);
}
-int GenericJob::openFileDialog()
+int GenericJob::openFileDialog()
{
TCHAR temp[MAX_PATH] = _T("");
mir_sntprintf(temp, _T("%s\0*.*\0"), TranslateT("All Files (*.*)"));
- OPENFILENAME ofn = {0};
+ OPENFILENAME ofn = { 0 };
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = 0;
ofn.lpstrFilter = temp;
ofn.nFilterIndex = 1;
- ofn.lpstrFile = this->stzFilePath;
+ ofn.lpstrFile = m_tszFilePath;
ofn.lpstrTitle = TranslateT("FTP File - Select files");
- ofn.nMaxFile = _countof(this->stzFilePath);
+ ofn.nMaxFile = _countof(m_tszFilePath);
ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_NOCHANGEDIR;
return GetOpenFileName(&ofn);
}
int GenericJob::openFolderDialog()
{
- BROWSEINFO bi = {0};
+ BROWSEINFO bi = { 0 };
bi.lpszTitle = TranslateT("FTP File - Select a folder");
bi.ulFlags = BIF_NEWDIALOGSTYLE | BIF_NONEWFOLDERBUTTON | BIF_DONTGOBELOWDOMAIN;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
- if (pidl != 0)
- {
- SHGetPathFromIDList(pidl, this->stzFilePath);
+ if (pidl != 0) {
+ SHGetPathFromIDList(pidl, m_tszFilePath);
CoTaskMemFree(pidl);
return 1;
}
@@ -79,20 +87,18 @@ void GenericJob::getFilesFromOpenDialog()
{
TCHAR stzFile[MAX_PATH];
- size_t length = mir_tstrlen(this->stzFilePath);
- if (this->stzFilePath[0] && this->stzFilePath[length+1]) // multiple files
+ size_t length = mir_tstrlen(m_tszFilePath);
+ if (m_tszFilePath[0] && m_tszFilePath[length + 1]) // multiple files
{
- TCHAR *ptr = this->stzFilePath + length + 1;
- while (ptr[0])
- {
- mir_sntprintf(stzFile, _countof(stzFile), _T("%s\\%s"), this->stzFilePath, ptr);
- this->addFile(stzFile);
+ TCHAR *ptr = m_tszFilePath + length + 1;
+ while (ptr[0]) {
+ mir_sntprintf(stzFile, _countof(stzFile), _T("%s\\%s"), m_tszFilePath, ptr);
+ addFile(stzFile);
ptr += mir_tstrlen(ptr) + 1;
}
- }
- else
- {
- this->addFile(this->stzFilePath);
+ }
+ else {
+ addFile(m_tszFilePath);
}
}
@@ -101,20 +107,17 @@ int GenericJob::getFilesFromFolder(TCHAR *stzFolder)
TCHAR stzFile[MAX_PATH], stzDirSave[MAX_PATH];
GetCurrentDirectory(MAX_PATH, stzDirSave);
- if (!SetCurrentDirectory(stzFolder))
- {
+ if (!SetCurrentDirectory(stzFolder)) {
Utils::msgBox(TranslateT("Folder not found!"), MB_OK | MB_ICONERROR);
return 0;
}
WIN32_FIND_DATA ffd;
HANDLE hFind = FindFirstFile(_T("*.*"), &ffd);
- while (hFind != INVALID_HANDLE_VALUE)
- {
- if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
- {
+ while (hFind != INVALID_HANDLE_VALUE) {
+ if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
mir_sntprintf(stzFile, _countof(stzFile), _T("%s\\%s"), stzFolder, ffd.cFileName);
- this->addFile(stzFile);
+ addFile(stzFile);
}
if (!FindNextFile(hFind, &ffd))
@@ -124,8 +127,7 @@ int GenericJob::getFilesFromFolder(TCHAR *stzFolder)
FindClose(hFind);
SetCurrentDirectory(stzDirSave);
- if (this->files.size() == 0)
- {
+ if (m_files.size() == 0) {
Utils::msgBox(TranslateT("The selected folder does not contain any files.\nFTP File sends files only from the selected folder, not from subfolders."), MB_OK | MB_ICONERROR);
return 0;
}
@@ -135,13 +137,11 @@ int GenericJob::getFilesFromFolder(TCHAR *stzFolder)
int GenericJob::getFiles()
{
- if (this->mode == FTP_ZIPFOLDER)
- {
- if (!openFolderDialog()) return 0;
- return getFilesFromFolder(this->stzFilePath);
+ if (m_mode == FTP_ZIPFOLDER) {
+ if (!openFolderDialog()) return 0;
+ return getFilesFromFolder(m_tszFilePath);
}
- else
- {
+ else {
if (!openFileDialog()) return 0;
getFilesFromOpenDialog();
}
@@ -151,22 +151,19 @@ int GenericJob::getFiles()
int GenericJob::getFiles(void **objects, int objCount, DWORD flags)
{
- if (this->mode == FTP_ZIPFOLDER)
- {
+ if (m_mode == FTP_ZIPFOLDER) {
TCHAR *folder;
if (flags & FUPL_UNICODE)
folder = mir_u2t((wchar_t *)objects[0]);
else
folder = mir_a2t((char *)objects[0]);
- int result = getFilesFromFolder(folder);
+ int result = getFilesFromFolder(folder);
FREE(folder);
return result;
}
- else
- {
- for (int i = 0; i < objCount; i++)
- {
+ else {
+ for (int i = 0; i < objCount; i++) {
TCHAR *fileName;
if (flags & FUPL_UNICODE)
fileName = mir_u2t((wchar_t *)objects[i]);
@@ -177,79 +174,76 @@ int GenericJob::getFiles(void **objects, int objCount, DWORD flags)
FREE(fileName);
}
}
-
- return (this->files.size() == 0) ? 0 : 1;
+
+ return (m_files.size() == 0) ? 0 : 1;
}
-void GenericJob::addFile(TCHAR *fileName)
+void GenericJob::addFile(TCHAR *fileName)
{
TCHAR *buff = mir_tstrdup(fileName);
- this->files.push_back(buff);
+ m_files.push_back(buff);
}
-void GenericJob::setStatus(EStatus status)
+void GenericJob::setStatus(EStatus _status)
{
- this->status = status;
- this->refreshTab(true);
+ m_status = _status;
+ refreshTab(true);
}
bool GenericJob::isCompleted()
{
- return this->status == STATUS_COMPLETED;
+ return m_status == STATUS_COMPLETED;
}
bool GenericJob::isPaused()
{
- return this->status == STATUS_PAUSED;
+ return m_status == STATUS_PAUSED;
}
bool GenericJob::isWaitting()
{
- return this->status == STATUS_WAITING;
+ return m_status == STATUS_WAITING;
}
bool GenericJob::isCanceled()
{
- return this->status == STATUS_CANCELED;
+ return m_status == STATUS_CANCELED;
}
bool GenericJob::isConnecting()
{
- return (this->status == STATUS_CONNECTING || this->status == STATUS_CREATED);
+ return (m_status == STATUS_CONNECTING || m_status == STATUS_CREATED);
}
TCHAR *GenericJob::getStatusString()
{
- switch (this->status)
- {
- case STATUS_CANCELED: return TranslateT("CANCELED");
- case STATUS_COMPLETED: return TranslateT("COMPLETED");
- case STATUS_CONNECTING: return TranslateT("CONNECTING...");
- case STATUS_CREATED: return TranslateT("CREATED");
- case STATUS_PACKING: return TranslateT("PACKING...");
- case STATUS_PAUSED: return TranslateT("PAUSED");
- case STATUS_UPLOADING: return TranslateT("UPLOADING...");
- case STATUS_WAITING: return TranslateT("WAITING...");
- default: return TranslateT("UNKNOWN");
+ switch (m_status) {
+ case STATUS_CANCELED: return TranslateT("CANCELED");
+ case STATUS_COMPLETED: return TranslateT("COMPLETED");
+ case STATUS_CONNECTING: return TranslateT("CONNECTING...");
+ case STATUS_CREATED: return TranslateT("CREATED");
+ case STATUS_PACKING: return TranslateT("PACKING...");
+ case STATUS_PAUSED: return TranslateT("PAUSED");
+ case STATUS_UPLOADING: return TranslateT("UPLOADING...");
+ case STATUS_WAITING: return TranslateT("WAITING...");
+ default:
+ return TranslateT("UNKNOWN");
}
}
void GenericJob::refreshTab(bool bTabChanged)
-{
- if (bTabChanged)
- {
- if (this->hContact != NULL)
- {
- SendDlgItemMessage(uDlg->hwnd, IDC_BTN_PROTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadProtoIcon( GetContactProto(this->hContact), ID_STATUS_ONLINE));
- SetDlgItemText(uDlg->hwnd, IDC_UP_CONTACT, (TCHAR *)pcli->pfnGetContactDisplayName(this->hContact, 0));
+{
+ if (bTabChanged) {
+ if (m_hContact != NULL) {
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_BTN_PROTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadProtoIcon(GetContactProto(m_hContact), ID_STATUS_ONLINE));
+ SetDlgItemText(uDlg->m_hwnd, IDC_UP_CONTACT, pcli->pfnGetContactDisplayName(m_hContact, 0));
}
- else
- {
- SendDlgItemMessage(uDlg->hwnd, IDC_BTN_PROTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("main"));
- SetDlgItemTextA(uDlg->hwnd, IDC_UP_CONTACT, this->ftp->szServer);
+ else {
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_BTN_PROTO, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("main"));
+ SetDlgItemTextA(uDlg->m_hwnd, IDC_UP_CONTACT, m_ftp->m_szServer);
}
-
- SetDlgItemText(uDlg->hwnd, IDC_UP_FILE, this->stzFileName);
- SetDlgItemTextA(uDlg->hwnd, IDC_UP_SERVER, this->ftp->szServer);
+
+ SetDlgItemText(uDlg->m_hwnd, IDC_UP_FILE, m_tszFileName);
+ SetDlgItemTextA(uDlg->m_hwnd, IDC_UP_SERVER, m_ftp->m_szServer);
}
-} \ No newline at end of file
+}
diff --git a/plugins/FTPFileYM/src/job_generic.h b/plugins/FTPFileYM/src/job_generic.h
index 60487a1c48..beeb1b606f 100644
--- a/plugins/FTPFileYM/src/job_generic.h
+++ b/plugins/FTPFileYM/src/job_generic.h
@@ -66,20 +66,20 @@ public:
STATUS_COMPLETED
};
- MCONTACT hContact;
- int iFtpNum, fileID;
- ServerList::FTP *ftp;
- TCHAR stzFilePath[1024];
- TCHAR stzFileName[64];
- char szSafeFileName[64];
- EMode mode;
- EStatus status;
-
- UploadDialog::Tab *tab;
- vector<TCHAR *> files;
- TCHAR * operator[] (int i) const { return files[i];}
-
- GenericJob(MCONTACT hContact, int iFtpNum, EMode mode);
+ MCONTACT m_hContact;
+ int m_iFtpNum, m_fileID;
+ ServerList::FTP *m_ftp;
+ TCHAR m_tszFilePath[1024];
+ TCHAR m_tszFileName[64];
+ char m_szSafeFileName[64];
+ EMode m_mode;
+ EStatus m_status;
+
+ UploadDialog::Tab *m_tab;
+ vector<TCHAR *> m_files;
+ TCHAR* operator[] (int i) const { return m_files[i];}
+
+ GenericJob(MCONTACT hContact, int m_iFtpNum, EMode mode);
GenericJob(GenericJob *job);
virtual ~GenericJob();
diff --git a/plugins/FTPFileYM/src/job_packer.cpp b/plugins/FTPFileYM/src/job_packer.cpp
index 2d018f7639..f2a2942636 100644
--- a/plugins/FTPFileYM/src/job_packer.cpp
+++ b/plugins/FTPFileYM/src/job_packer.cpp
@@ -25,27 +25,28 @@ int PackerJob::iRunningJobCount = 0;
extern UploadDialog *uDlg;
extern Options &opt;
-PackerJob::PackerJob(MCONTACT _hContact, int _iFtpNum, EMode _mode) :
- GenericJob(_hContact, _iFtpNum, _mode),uiFileSize(0),uiReaded(0),lastUpdateTick(0)
-{ }
+PackerJob::PackerJob(MCONTACT hContact, int iFtpNum, EMode mode) :
+ GenericJob(hContact, iFtpNum, mode),
+ m_uiFileSize(0),
+ m_uiReaded(0),
+ m_lastUpdateTick(0)
+{
+}
void PackerJob::getZipFilePath()
{
- TCHAR buff[256], stzFileName[256] = {0};
+ TCHAR buff[256], stzFileName[256] = { 0 };
TCHAR *pch;
- if (this->files.size() == 1)
- {
- mir_tstrcpy(stzFileName, Utils::getFileNameFromPath(this->files[0]));
+ if (m_files.size() == 1) {
+ mir_tstrcpy(stzFileName, Utils::getFileNameFromPath(m_files[0]));
pch = _tcsrchr(stzFileName, '.');
if (pch) *pch = 0;
}
- else
- {
- mir_tstrcpy(buff, this->files[0]);
+ else {
+ mir_tstrcpy(buff, m_files[0]);
pch = _tcsrchr(buff, '\\');
- if (pch)
- {
+ if (pch) {
*pch = 0;
pch = _tcsrchr(buff, '\\');
if (pch) mir_tstrcpy(stzFileName, pch + 1);
@@ -57,31 +58,29 @@ void PackerJob::getZipFilePath()
GetTempPath(_countof(buff), buff);
- mir_sntprintf(this->stzFilePath, _countof(this->stzFilePath), _T("%s%s.zip"), buff, stzFileName);
- mir_tstrcpy(this->stzFileName, Utils::getFileNameFromPath(this->stzFilePath));
+ mir_sntprintf(m_tszFilePath, _countof(m_tszFilePath), _T("%s%s.zip"), buff, stzFileName);
+ mir_tstrcpy(m_tszFileName, Utils::getFileNameFromPath(m_tszFilePath));
if (opt.bSetZipName)
- Utils::setFileNameDlg(this->stzFileName);
+ Utils::setFileNameDlg(m_tszFileName);
}
void PackerJob::addToUploadDlg()
{
- this->getZipFilePath();
+ getZipFilePath();
UploadDialog::Tab *newTab = new UploadDialog::Tab(this);
- this->tab = newTab;
- this->start();
+ m_tab = newTab;
+ start();
}
-void PackerJob::waitingThread(void *arg)
+void PackerJob::waitingThread(void *arg)
{
PackerJob *job = (PackerJob *)arg;
- while(!Miranda_Terminated())
- {
+ while (!Miranda_Terminated()) {
mir_cslockfull lock(mutexJobCount);
- if (iRunningJobCount < MAX_RUNNING_JOBS)
- {
+ if (iRunningJobCount < MAX_RUNNING_JOBS) {
iRunningJobCount++;
lock.unlock();
job->pack();
@@ -97,7 +96,7 @@ void PackerJob::waitingThread(void *arg)
lock.unlock();
jobDone.wait();
- job->status = GenericJob::STATUS_WAITING;
+ job->m_status = GenericJob::STATUS_WAITING;
}
}
@@ -109,31 +108,27 @@ void PackerJob::start()
void PackerJob::pack()
{
struct _stat fileInfo;
- for (UINT i = 0; i < this->files.size(); i++)
- {
- if (_tstat(this->files[i], &fileInfo) == 0)
- this->uiFileSize += (UINT64)fileInfo.st_size;
+ for (UINT i = 0; i < m_files.size(); i++) {
+ if (_tstat(m_files[i], &fileInfo) == 0)
+ m_uiFileSize += (UINT64)fileInfo.st_size;
}
- this->setStatus(STATUS_PACKING);
- this->startTS = time(NULL);
+ setStatus(STATUS_PACKING);
+ m_startTS = time(NULL);
- int res = this->createZipFile();
- if (res == ZIP_OK)
- {
+ int res = createZipFile();
+ if (res == ZIP_OK) {
UploadJob *ujob = new UploadJob(this);
- ujob->tab->job = ujob;
- ujob->start();
+ ujob->m_tab->m_job = ujob;
+ ujob->start();
}
- else
- {
- if (res == ZIP_ERRNO)
- {
+ else {
+ if (res == ZIP_ERRNO) {
Utils::msgBox(TranslateT("Error occurred when zipping the file(s)."), MB_OK | MB_ICONERROR);
- delete this->tab;
+ delete m_tab;
}
- DeleteFile(this->stzFilePath);
+ DeleteFile(m_tszFilePath);
}
}
@@ -141,19 +136,17 @@ int PackerJob::createZipFile()
{
int result = ZIP_ERRNO;
- zipFile zf = zipOpen2_64(this->stzFilePath, 0, NULL, NULL);
+ zipFile zf = zipOpen2_64(m_tszFilePath, 0, NULL, NULL);
- if (zf != NULL)
- {
+ if (zf != NULL) {
result = ZIP_OK;
int size_buf = 65536;
void *buff = (void *)mir_alloc(size_buf);
- for (UINT i = 0; i < this->files.size(); i++)
- {
+ for (UINT i = 0; i < m_files.size(); i++) {
int size_read;
- zip_fileinfo zi;
+ zip_fileinfo zi;
zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = 0;
zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0;
@@ -161,21 +154,17 @@ int PackerJob::createZipFile()
zi.internal_fa = 0;
zi.external_fa = 0;
- getFileTime(this->files[i], &zi.tmz_date, &zi.dosDate);
+ getFileTime(m_files[i], &zi.tmz_date, &zi.dosDate);
- char *file = mir_t2a(Utils::getFileNameFromPath(this->files[i]));
+ char *file = mir_t2a(Utils::getFileNameFromPath(m_files[i]));
int err = zipOpenNewFileInZip(zf, file, &zi, NULL, 0, NULL, 0, NULL, Z_DEFLATED, opt.iCompressionLevel);
FREE(file);
- if (err == ZIP_OK)
- {
- FILE *fin = _tfopen(this->files[i], _T("rb"));
- if (fin)
- {
- do
- {
- if (this->isCanceled())
- {
+ if (err == ZIP_OK) {
+ FILE *fin = _tfopen(m_files[i], _T("rb"));
+ if (fin) {
+ do {
+ if (isCanceled()) {
fclose(fin);
result = STATUS_CANCELED;
goto Cleanup;
@@ -183,38 +172,30 @@ int PackerJob::createZipFile()
err = ZIP_OK;
size_read = (int)fread(buff, 1, size_buf, fin);
- if (size_read < size_buf && feof(fin) == 0)
- {
+ if (size_read < size_buf && feof(fin) == 0) {
fclose(fin);
result = ZIP_ERRNO;
goto Cleanup;
}
- if (size_read > 0)
- {
+ if (size_read > 0) {
err = zipWriteInFileInZip(zf, buff, size_read);
- this->uiReaded += size_read;
+ m_uiReaded += size_read;
}
- this->updateStats();
- }
- while ((err == ZIP_OK) && (size_read > 0));
+ updateStats();
+ } while ((err == ZIP_OK) && (size_read > 0));
fclose(fin);
- }
- else
- {
- err = ZIP_ERRNO;
}
+ else err = ZIP_ERRNO;
err = zipCloseFileInZip(zf);
- if (err < 0)
- {
+ if (err < 0) {
result = ZIP_ERRNO;
goto Cleanup;
}
}
- else
- {
+ else {
result = ZIP_ERRNO;
break;
}
@@ -224,7 +205,7 @@ Cleanup:
zipClose(zf, NULL);
FREE(buff);
}
-
+
return result;
}
@@ -235,10 +216,9 @@ uLong PackerJob::getFileTime(TCHAR *file, tm_zip*, uLong *dt)
WIN32_FIND_DATA ff32;
hFind = FindFirstFile(file, &ff32);
- if (hFind != INVALID_HANDLE_VALUE)
- {
- FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal);
- FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0);
+ if (hFind != INVALID_HANDLE_VALUE) {
+ FileTimeToLocalFileTime(&(ff32.ftLastWriteTime), &ftLocal);
+ FileTimeToDosDateTime(&ftLocal, ((LPWORD)dt) + 1, ((LPWORD)dt) + 0);
FindClose(hFind);
return 1;
}
@@ -249,55 +229,52 @@ uLong PackerJob::getFileTime(TCHAR *file, tm_zip*, uLong *dt)
void PackerJob::updateStats()
{
DWORD dwNewTick = GetTickCount();
- if (this->uiReaded && (time(NULL) > this->startTS) && (dwNewTick > this->lastUpdateTick + 100))
- {
- this->lastUpdateTick = dwNewTick;
+ if (m_uiReaded && (time(NULL) > m_startTS) && (dwNewTick > m_lastUpdateTick + 100)) {
+ m_lastUpdateTick = dwNewTick;
- double speed = ((double)this->uiReaded / 1024)/(time(NULL) - this->startTS);
- mir_sntprintf(this->tab->stzSpeed, _countof(this->tab->stzSpeed), TranslateT("%0.1f kB/s"), speed);
+ double speed = ((double)m_uiReaded / 1024) / (time(NULL) - m_startTS);
+ mir_sntprintf(m_tab->m_stzSpeed, TranslateT("%0.1f kB/s"), speed);
- double perc = this->uiFileSize ? ((double)this->uiReaded / this->uiFileSize) * 100 : 0;
- mir_sntprintf(this->tab->stzComplet, _countof(this->tab->stzComplet), TranslateT("%0.1f%% (%d kB/%d kB)"), perc, (int)this->uiReaded/1024, (int)this->uiFileSize/1024);
+ double perc = m_uiFileSize ? ((double)m_uiReaded / m_uiFileSize) * 100 : 0;
+ mir_sntprintf(m_tab->m_stzComplet, TranslateT("%0.1f%% (%d kB/%d kB)"), perc, (int)m_uiReaded / 1024, (int)m_uiFileSize / 1024);
TCHAR buff[256];
- long s = (this->uiFileSize - this->uiReaded) / (long)(speed * 1024);
+ long s = (m_uiFileSize - m_uiReaded) / (long)(speed * 1024);
int d = (s / 60 / 60 / 24);
int h = (s - d * 60 * 60 * 24) / 60 / 60;
- int m = (s - d * 60 * 60 * 24 - h * 60 * 60) / 60;
+ int m = (s - d * 60 * 60 * 24 - h * 60 * 60) / 60;
s = s - (d * 24 * 60 * 60) - (h * 60 * 60) - (m * 60);
if (d > 0) mir_sntprintf(buff, _T("%dd %02d:%02d:%02d"), d, h, m, s);
else mir_sntprintf(buff, _T("%02d:%02d:%02d"), h, m, s);
- mir_sntprintf(this->tab->stzRemain, _countof(this->tab->stzRemain), TranslateT("%s (%d kB/%d kB)"), buff, (this->uiFileSize - this->uiReaded)/1024, this->uiFileSize/1024);
+ mir_sntprintf(m_tab->m_stzRemain, TranslateT("%s (%d kB/%d kB)"), buff, (m_uiFileSize - m_uiReaded) / 1024, m_uiFileSize / 1024);
- this->refreshTab(false);
+ refreshTab(false);
}
}
void PackerJob::refreshTab(bool bTabChanged)
{
- if (uDlg->activeTab == this->tab->index())
- {
+ if (uDlg->m_activeTab == m_tab->index()) {
GenericJob::refreshTab(bTabChanged);
- SetDlgItemText(uDlg->hwnd, IDC_UP_SPEED, this->tab->stzSpeed);
- SetDlgItemText(uDlg->hwnd, IDC_UP_COMPLETED, this->tab->stzComplet);
- SetDlgItemText(uDlg->hwnd, IDC_UP_REMAIN, this->tab->stzRemain);
+ SetDlgItemText(uDlg->m_hwnd, IDC_UP_SPEED, m_tab->m_stzSpeed);
+ SetDlgItemText(uDlg->m_hwnd, IDC_UP_COMPLETED, m_tab->m_stzComplet);
+ SetDlgItemText(uDlg->m_hwnd, IDC_UP_REMAIN, m_tab->m_stzRemain);
- SendDlgItemMessage(uDlg->hwnd, IDC_PB_UPLOAD, PBM_SETRANGE32, 0, (LPARAM)this->uiFileSize);
- SendDlgItemMessage(uDlg->hwnd, IDC_PB_UPLOAD, PBM_SETPOS, (WPARAM)this->uiReaded, 0);
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_PB_UPLOAD, PBM_SETRANGE32, 0, (LPARAM)m_uiFileSize);
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_PB_UPLOAD, PBM_SETPOS, (WPARAM)m_uiReaded, 0);
- if (bTabChanged)
- {
- SetDlgItemText(uDlg->hwnd, IDC_STATUSBAR, TranslateT("PACKING..."));
- EnableWindow(GetDlgItem(uDlg->hwnd, IDC_BTN_PAUSE), FALSE);
- }
+ if (bTabChanged) {
+ SetDlgItemText(uDlg->m_hwnd, IDC_STATUSBAR, TranslateT("PACKING..."));
+ EnableWindow(GetDlgItem(uDlg->m_hwnd, IDC_BTN_PAUSE), FALSE);
+ }
}
}
bool PackerJob::isCanceled()
{
- return this->status == STATUS_CANCELED;
+ return m_status == STATUS_CANCELED;
}
void PackerJob::pauseHandler()
@@ -317,32 +294,25 @@ void PackerJob::resume()
void PackerJob::cancel()
{
- this->setStatus(STATUS_CANCELED);
+ setStatus(STATUS_CANCELED);
}
void PackerJob::closeTab()
{
- if (Utils::msgBox(TranslateT("Do you really want to cancel this upload?"), MB_YESNO | MB_ICONQUESTION) == IDYES)
- {
- this->cancel();
- delete this->tab;
- }
+ if (Utils::msgBox(TranslateT("Do you really want to cancel this upload?"), MB_YESNO | MB_ICONQUESTION) == IDYES) {
+ cancel();
+ delete m_tab;
+ }
}
void PackerJob::closeAllTabs()
-{
- this->cancel();
- delete this->tab;
+{
+ cancel();
+ delete m_tab;
}
void PackerJob::createToolTip()
{
- TCHAR *server = mir_a2t(this->ftp->szServer);
- mir_sntprintf(uDlg->stzToolTipText, _countof(uDlg->stzToolTipText),
- TranslateT("Status: %s\r\nFile: %s\r\nServer: %s"),
- this->getStatusString(),
- this->stzFileName,
- server);
-
- FREE(server);
-} \ No newline at end of file
+ mir_sntprintf(uDlg->m_tszToolTipText, TranslateT("Status: %s\r\nFile: %s\r\nServer: %S"),
+ getStatusString(), m_tszFileName, m_ftp->m_szServer);
+}
diff --git a/plugins/FTPFileYM/src/job_packer.h b/plugins/FTPFileYM/src/job_packer.h
index a632c9e37f..2b035ddda4 100644
--- a/plugins/FTPFileYM/src/job_packer.h
+++ b/plugins/FTPFileYM/src/job_packer.h
@@ -22,15 +22,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "job_generic.h"
#include "..\..\libs\zlib\src\zip.h"
-class PackerJob: public GenericJob
+class PackerJob : public GenericJob
{
private:
static const int MAX_RUNNING_JOBS = 1;
- UINT64 uiFileSize;
- UINT64 uiReaded;
- time_t startTS;
- time_t lastUpdateTick;
+ UINT64 m_uiFileSize;
+ UINT64 m_uiReaded;
+ time_t m_startTS;
+ time_t m_lastUpdateTick;
static Event jobDone;
static mir_cs mutexJobCount;
@@ -46,7 +46,7 @@ private:
bool isCanceled();
public:
- PackerJob(MCONTACT hContact, int iFtpNum, EMode mode);
+ PackerJob(MCONTACT hContact, int m_iFtpNum, EMode mode);
virtual ~PackerJob() {};
virtual void start();
@@ -60,4 +60,4 @@ public:
virtual void closeTab();
virtual void closeAllTabs();
virtual void createToolTip();
-}; \ No newline at end of file
+};
diff --git a/plugins/FTPFileYM/src/job_upload.cpp b/plugins/FTPFileYM/src/job_upload.cpp
index 40e35cdac0..1ec70984ec 100644
--- a/plugins/FTPFileYM/src/job_upload.cpp
+++ b/plugins/FTPFileYM/src/job_upload.cpp
@@ -26,48 +26,50 @@ extern UploadDialog *uDlg;
extern ServerList &ftpList;
UploadJob::UploadJob(MCONTACT _hContact, int _iFtpNum, EMode _mode) :
- GenericJob(_hContact, _iFtpNum, _mode),fp(NULL)
-{
- this->szFileLink[0] = 0;
+ GenericJob(_hContact, _iFtpNum, _mode),
+ m_fp(NULL)
+{
+ m_szFileLink[0] = 0;
}
UploadJob::UploadJob(UploadJob *job) :
- GenericJob(job),fp(NULL),uiSent(0),uiTotalSent(0),uiFileSize(0)
-{
- mir_strcpy(this->szFileLink, job->szFileLink);
- for (int i = 0; i < _countof(this->lastSpeed); i++)
- this->lastSpeed[i] = 0;
+ GenericJob(job),
+ m_fp(NULL), m_uiSent(0), m_uiTotalSent(0), m_uiFileSize(0)
+{
+ mir_strcpy(m_szFileLink, job->m_szFileLink);
+ for (int i = 0; i < _countof(m_lastSpeed); i++)
+ m_lastSpeed[i] = 0;
}
UploadJob::UploadJob(PackerJob *job) :
- GenericJob(job),fp(NULL),uiSent(0),uiTotalSent(0),uiFileSize(0)
-{
- for (int i = 0; i < _countof(this->lastSpeed); i++)
- this->lastSpeed[i] = 0;
+ GenericJob(job), m_fp(NULL), m_uiSent(0), m_uiTotalSent(0), m_uiFileSize(0)
+{
+ for (int i = 0; i < _countof(m_lastSpeed); i++)
+ m_lastSpeed[i] = 0;
- Utils::makeSafeString(job->stzFileName, this->szSafeFileName);
- this->status = STATUS_CREATED;
+ Utils::makeSafeString(job->m_tszFileName, m_szSafeFileName);
+ m_status = STATUS_CREATED;
}
UploadJob::~UploadJob()
{
- if (this->fp)
- fclose(this->fp);
+ if (m_fp)
+ fclose(m_fp);
- if (this->mode != FTP_RAWFILE)
- DeleteFile(this->stzFilePath);
+ if (m_mode != FTP_RAWFILE)
+ DeleteFile(m_tszFilePath);
}
void UploadJob::addToUploadDlg()
{
- for (UINT i = 0; i < this->files.size(); i++) {
+ for (UINT i = 0; i < m_files.size(); i++) {
UploadJob *jobCopy = new UploadJob(this);
- mir_tstrcpy(jobCopy->stzFilePath, this->files[i]);
- mir_tstrcpy(jobCopy->stzFileName, Utils::getFileNameFromPath(jobCopy->stzFilePath));
- Utils::makeSafeString(jobCopy->stzFileName, jobCopy->szSafeFileName);
+ mir_tstrcpy(jobCopy->m_tszFilePath, m_files[i]);
+ mir_tstrcpy(jobCopy->m_tszFileName, Utils::getFileNameFromPath(jobCopy->m_tszFilePath));
+ Utils::makeSafeString(jobCopy->m_tszFileName, jobCopy->m_szSafeFileName);
UploadDialog::Tab *newTab = new UploadDialog::Tab(jobCopy);
- jobCopy->tab = newTab;
+ jobCopy->m_tab = newTab;
jobCopy->start();
}
@@ -76,10 +78,10 @@ void UploadJob::addToUploadDlg()
void UploadJob::autoSend()
{
- if (this->hContact == NULL)
+ if (m_hContact == NULL)
return;
- char *szProto = GetContactProto(this->hContact);
+ char *szProto = GetContactProto(m_hContact);
if (szProto == NULL)
return;
@@ -88,63 +90,61 @@ void UploadJob::autoSend()
dbei.flags = DBEF_SENT;
dbei.szModule = szProto;
dbei.timestamp = (DWORD)time(NULL);
- dbei.cbBlob = (DWORD)mir_strlen(this->szFileLink) + 1;
- dbei.pBlob = (PBYTE)this->szFileLink;
- db_event_add(this->hContact, &dbei);
- CallContactService(this->hContact, PSS_MESSAGE, 0, (LPARAM)this->szFileLink);
- CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)this->hContact, 0);
+ dbei.cbBlob = (DWORD)mir_strlen(m_szFileLink) + 1;
+ dbei.pBlob = (PBYTE)m_szFileLink;
+ db_event_add(m_hContact, &dbei);
+ CallContactService(m_hContact, PSS_MESSAGE, 0, (LPARAM)m_szFileLink);
+ CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)m_hContact, 0);
}
void UploadJob::copyLinkToML()
{
- if (this->hContact != NULL) {
+ if (m_hContact != NULL) {
char buff[256];
- mir_snprintf(buff, "%s\r\n", this->szFileLink);
- CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)this->hContact, (LPARAM)buff);
+ mir_snprintf(buff, "%s\r\n", m_szFileLink);
+ CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)m_hContact, (LPARAM)buff);
}
}
void UploadJob::pause()
{
if (!isCompleted()) {
- curl_easy_pause(this->hCurl, CURLPAUSE_SEND);
- this->setStatus(STATUS_PAUSED);
+ curl_easy_pause(m_hCurl, CURLPAUSE_SEND);
+ setStatus(STATUS_PAUSED);
}
}
void UploadJob::pauseHandler()
{
- if (this->isPaused())
- {
- this->resume();
- SendDlgItemMessage(uDlg->hwnd, IDC_BTN_PAUSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("pause"));
- SendDlgItemMessage(uDlg->hwnd, IDC_BTN_PAUSE, BUTTONADDTOOLTIP, (WPARAM)Translate("Pause"), 0);
- }
- else
- {
- this->pause();
- SendDlgItemMessage(uDlg->hwnd, IDC_BTN_PAUSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("resume"));
- SendDlgItemMessage(uDlg->hwnd, IDC_BTN_PAUSE, BUTTONADDTOOLTIP, (WPARAM)Translate("Resume"), 0);
- }
+ if (isPaused()) {
+ resume();
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_BTN_PAUSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("pause"));
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_BTN_PAUSE, BUTTONADDTOOLTIP, (WPARAM)Translate("Pause"), 0);
+ }
+ else {
+ pause();
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_BTN_PAUSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("resume"));
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_BTN_PAUSE, BUTTONADDTOOLTIP, (WPARAM)Translate("Resume"), 0);
+ }
}
void UploadJob::resume()
{
- this->uiSent = 0;
- this->startTS = time(NULL);
+ m_uiSent = 0;
+ m_startTS = time(NULL);
if (!isCompleted()) {
- curl_easy_pause(this->hCurl, CURLPAUSE_CONT);
- this->setStatus(STATUS_UPLOADING);
+ curl_easy_pause(m_hCurl, CURLPAUSE_CONT);
+ setStatus(STATUS_UPLOADING);
}
}
void UploadJob::cancel()
{
- this->setStatus(STATUS_CANCELED);
- curl_easy_pause(this->hCurl, CURLPAUSE_CONT);
+ setStatus(STATUS_CANCELED);
+ curl_easy_pause(m_hCurl, CURLPAUSE_CONT);
}
-void UploadJob::waitingThread(void *arg)
+void UploadJob::waitingThread(void *arg)
{
UploadJob *job = (UploadJob *)arg;
@@ -168,7 +168,7 @@ void UploadJob::waitingThread(void *arg)
lock.unlock();
jobDone.wait();
- job->status = GenericJob::STATUS_WAITING;
+ job->m_status = GenericJob::STATUS_WAITING;
}
delete job;
@@ -181,66 +181,65 @@ void UploadJob::start()
char *UploadJob::getChmodString()
{
- if (ftp->ftpProto == ServerList::FTP::FT_SSH)
- mir_snprintf(buff, "%s \"%s/%s\"", ftp->szChmod, ftp->szDir, this->szSafeFileName);
- else
- mir_snprintf(buff, "%s %s", ftp->szChmod, this->szSafeFileName);
+ if (m_ftp->m_ftpProto == ServerList::FTP::FT_SSH)
+ mir_snprintf(m_buff, "%s \"%s/%s\"", m_ftp->m_szChmod, m_ftp->m_szDir, m_szSafeFileName);
+ else
+ mir_snprintf(m_buff, "%s %s", m_ftp->m_szChmod, m_szSafeFileName);
- return buff;
+ return m_buff;
}
char *UploadJob::getDelFileString()
{
- if (ftp->ftpProto == ServerList::FTP::FT_SSH)
- mir_snprintf(buff, "rm \"%s/%s\"", ftp->szDir, this->szSafeFileName);
+ if (m_ftp->m_ftpProto == ServerList::FTP::FT_SSH)
+ mir_snprintf(m_buff, "rm \"%s/%s\"", m_ftp->m_szDir, m_szSafeFileName);
else
- mir_snprintf(buff, "DELE %s", this->szSafeFileName);
+ mir_snprintf(m_buff, "DELE %s", m_szSafeFileName);
- return buff;
+ return m_buff;
}
char *UploadJob::getUrlString()
{
- if (ftp->szDir[0])
- mir_snprintf(buff, "%s%s/%s/%s", ftp->getProtoString(), ftp->szServer, ftp->szDir, this->szSafeFileName);
+ if (m_ftp->m_szDir[0])
+ mir_snprintf(m_buff, "%s%s/%s/%s", m_ftp->getProtoString(), m_ftp->m_szServer, m_ftp->m_szDir, m_szSafeFileName);
else
- mir_snprintf(buff, "%s%s/%s", ftp->getProtoString(), ftp->szServer, this->szSafeFileName);
+ mir_snprintf(m_buff, "%s%s/%s", m_ftp->getProtoString(), m_ftp->m_szServer, m_szSafeFileName);
- return buff;
+ return m_buff;
}
char *UploadJob::getDelUrlString()
{
- if (ftp->szDir[0] && ftp->ftpProto != ServerList::FTP::FT_SSH)
- mir_snprintf(buff, "%s%s/%s/", ftp->getProtoString(), ftp->szServer, ftp->szDir);
+ if (m_ftp->m_szDir[0] && m_ftp->m_ftpProto != ServerList::FTP::FT_SSH)
+ mir_snprintf(m_buff, "%s%s/%s/", m_ftp->getProtoString(), m_ftp->m_szServer, m_ftp->m_szDir);
else
- mir_snprintf(buff, "%s%s/", ftp->getProtoString(), ftp->szServer);
+ mir_snprintf(m_buff, "%s%s/", m_ftp->getProtoString(), m_ftp->m_szServer);
- return buff;
+ return m_buff;
}
CURL *UploadJob::curlInit(char *szUrl, struct curl_slist *headerList)
{
- this->hCurl = curl_easy_init();
- if (!hCurl) return NULL;
+ m_hCurl = curl_easy_init();
+ if (!m_hCurl)
+ return NULL;
- Utils::curlSetOpt(this->hCurl, this->ftp, szUrl, headerList, this->szError);
+ Utils::curlSetOpt(m_hCurl, m_ftp, szUrl, headerList, m_szError);
- curl_easy_setopt(this->hCurl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)this->uiFileSize);
- curl_easy_setopt(this->hCurl, CURLOPT_READDATA, this);
- curl_easy_setopt(this->hCurl, CURLOPT_READFUNCTION, &UploadJob::ReadCallback);
- //curl.easy_setopt(this->hCurl, CURLOPT_UPLOAD, 1L);
-
- return this->hCurl;
+ curl_easy_setopt(m_hCurl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)m_uiFileSize);
+ curl_easy_setopt(m_hCurl, CURLOPT_READDATA, this);
+ curl_easy_setopt(m_hCurl, CURLOPT_READFUNCTION, &UploadJob::ReadCallback);
+ return m_hCurl;
}
bool UploadJob::fileExistsOnServer()
{
- int result = curl_easy_perform(hCurl);
+ int result = curl_easy_perform(m_hCurl);
return result != CURLE_REMOTE_FILE_NOT_FOUND;
}
-INT_PTR CALLBACK UploadJob::DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK UploadJob::DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG:
@@ -255,7 +254,7 @@ INT_PTR CALLBACK UploadJob::DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wPa
return TRUE;
case WM_COMMAND:
- if (HIWORD(wParam) == BN_CLICKED)
+ if (HIWORD(wParam) == BN_CLICKED)
EndDialog(hwndDlg, LOWORD(wParam));
break;
}
@@ -263,25 +262,25 @@ INT_PTR CALLBACK UploadJob::DlgProcFileExists(HWND hwndDlg, UINT msg, WPARAM wPa
return FALSE;
}
-void UploadJob::upload()
+void UploadJob::upload()
{
- this->refreshTab(true);
+ refreshTab(true);
- this->fp = _tfopen(this->stzFilePath, _T("rb"));
- if (this->fp == NULL) {
+ m_fp = _tfopen(m_tszFilePath, _T("rb"));
+ if (m_fp == NULL) {
Utils::msgBox(TranslateT("Error occurred when opening local file.\nAborting file upload..."), MB_OK | MB_ICONERROR);
return;
}
- struct curl_slist *headerList = NULL;
- if (this->ftp->szChmod[0])
+ curl_slist *headerList = NULL;
+ if (m_ftp->m_szChmod[0])
headerList = curl_slist_append(headerList, getChmodString());
struct _stat fileInfo;
- _tstat(this->stzFilePath, &fileInfo);
- this->uiFileSize = (UINT64)fileInfo.st_size;
+ _tstat(m_tszFilePath, &fileInfo);
+ m_uiFileSize = (UINT64)fileInfo.st_size;
- CURL *hCurl = this->curlInit(getUrlString(), headerList);
+ CURL *hCurl = (getUrlString(), headerList);
if (!hCurl) {
Utils::msgBox(TranslateT("Error occurred when initializing libcurl.\nAborting file upload..."), MB_OK | MB_ICONERROR);
return;
@@ -289,54 +288,52 @@ void UploadJob::upload()
bool uploadFile = true;
if (fileExistsOnServer()) {
- int res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_FILEEXISTS), 0, DlgProcFileExists, (LPARAM)this->szSafeFileName);
+ int res = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_FILEEXISTS), 0, DlgProcFileExists, (LPARAM)m_szSafeFileName);
if (res == IDC_RENAME) {
- if (Utils::setFileNameDlgA(this->szSafeFileName) == true)
- curl_easy_setopt(hCurl, CURLOPT_URL, getUrlString());
+ if (Utils::setFileNameDlgA(m_szSafeFileName) == true)
+ curl_easy_setopt(hCurl, CURLOPT_URL, getUrlString());
}
else if (res == IDC_COPYURL) {
uploadFile = false;
}
else if (res == IDC_CANCEL) {
- this->setStatus(STATUS_CANCELED);
- delete this->tab;
+ setStatus(STATUS_CANCELED);
+ delete m_tab;
return;
}
}
- if (uploadFile)
- {
- curl_easy_setopt(this->hCurl, CURLOPT_UPLOAD, 1L);
- this->setStatus(STATUS_CONNECTING);
- this->startTS = time(NULL);
+ if (uploadFile) {
+ curl_easy_setopt(m_hCurl, CURLOPT_UPLOAD, 1L);
+ setStatus(STATUS_CONNECTING);
+ m_startTS = time(NULL);
int result = curl_easy_perform(hCurl);
curl_slist_free_all(headerList);
curl_easy_cleanup(hCurl);
-
+
if (result != CURLE_OK && result != CURLE_ABORTED_BY_CALLBACK) {
char buff[256];
- mir_snprintf(buff, Translate("FTP error occurred.\n%s"), this->szError);
+ mir_snprintf(buff, Translate("FTP error occurred.\n%s"), m_szError);
Utils::msgBoxA(buff, MB_OK | MB_ICONERROR);
}
-
+
if (result > CURLE_OPERATION_TIMEDOUT) {
- struct curl_slist *headerList = NULL;
- headerList = curl_slist_append(headerList, getDelFileString());
-
- CURL *hCurl = curl_easy_init();
- if (hCurl) {
- Utils::curlSetOpt(hCurl, this->ftp, getDelUrlString(), headerList, this->szError);
- curl_easy_perform(hCurl);
- curl_slist_free_all(headerList);
- curl_easy_cleanup(hCurl);
+ curl_slist *headers2 = curl_slist_append(headerList, getDelFileString());
+
+ CURL *hCurl2 = curl_easy_init();
+ if (hCurl2) {
+ Utils::curlSetOpt(hCurl2, m_ftp, getDelUrlString(), headers2, m_szError);
+ curl_easy_perform(hCurl2);
+ curl_slist_free_all(headers2);
+ curl_easy_cleanup(hCurl2);
}
- }
+ }
if (result != CURLE_OK && result != CURLE_QUOTE_ERROR) {
- if (!this->isCanceled()) {
- this->setStatus(STATUS_CANCELED);
- delete this->tab;
+ if (!isCanceled()) {
+ setStatus(STATUS_CANCELED);
+ delete m_tab;
}
return;
}
@@ -345,167 +342,161 @@ void UploadJob::upload()
SkinPlaySound(SOUND_UPCOMPLETE);
}
- this->setStatus(STATUS_COMPLETED);
+ setStatus(STATUS_COMPLETED);
- Utils::createFileDownloadLink(this->ftp->szUrl, this->szSafeFileName, this->szFileLink, sizeof(this->szFileLink));
- Utils::copyToClipboard(this->szFileLink);
+ Utils::createFileDownloadLink(m_ftp->m_szUrl, m_szSafeFileName, m_szFileLink, sizeof(m_szFileLink));
+ Utils::copyToClipboard(m_szFileLink);
- if (this->tab->bOptAutosend)
- this->autoSend();
- else if (this->tab->bOptCopyLink)
- this->copyLinkToML();
+ if (m_tab->m_bOptAutosend)
+ autoSend();
+ else if (m_tab->m_bOptCopyLink)
+ copyLinkToML();
- if (!this->tab->bOptCloseDlg) {
- this->tab->labelCompleted();
- this->tab->select();
+ if (!m_tab->m_bOptCloseDlg) {
+ m_tab->labelCompleted();
+ m_tab->select();
}
- else this->closeTab();
+ else closeTab();
}
size_t UploadJob::ReadCallback(void *ptr, size_t size, size_t nmemb, void *arg)
{
UploadJob *job = (UploadJob *)arg;
- if (job->uiTotalSent == 0)
- job->status = UploadJob::STATUS_UPLOADING;
+ if (job->m_uiTotalSent == 0)
+ job->m_status = UploadJob::STATUS_UPLOADING;
if (job->isCanceled())
return CURL_READFUNC_ABORT;
- size_t readed = fread(ptr, size, nmemb, job->fp);
- job->uiSent += readed;
- job->uiTotalSent += readed;
- job->updateStats();
+ size_t readed = fread(ptr, size, nmemb, job->m_fp);
+ job->m_uiSent += readed;
+ job->m_uiTotalSent += readed;
+ job->updateStats();
return readed;
}
void UploadJob::updateStats()
{
- if (this->uiSent && (time(NULL) > this->startTS)) {
- double speed = ((double)this->uiSent / 1024)/(time(NULL) - this->startTS);
- this->avgSpeed = speed;
- for (int i = 0; i < _countof(this->lastSpeed); i++) {
- this->avgSpeed += (this->lastSpeed[i] == 0 ? speed : this->lastSpeed[i]);
- if (i < _countof(this->lastSpeed) - 1)
- this->lastSpeed[i + 1] = this->lastSpeed[i];
+ if (m_uiSent && (time(NULL) > m_startTS)) {
+ double speed = ((double)m_uiSent / 1024) / (time(NULL) - m_startTS);
+ m_avgSpeed = speed;
+ for (int i = 0; i < _countof(m_lastSpeed); i++) {
+ m_avgSpeed += (m_lastSpeed[i] == 0 ? speed : m_lastSpeed[i]);
+ if (i < _countof(m_lastSpeed) - 1)
+ m_lastSpeed[i + 1] = m_lastSpeed[i];
}
- this->avgSpeed /= _countof(this->lastSpeed) + 1;
- this->lastSpeed[0] = speed;
-
- mir_sntprintf(this->tab->stzSpeed, _countof(this->tab->stzSpeed), _T("%0.1f kB/s"), this->avgSpeed);
-
- double perc = this->uiFileSize ? ((double)this->uiTotalSent / this->uiFileSize) * 100 : 0;
- mir_sntprintf(this->tab->stzComplet, _countof(this->tab->stzComplet), _T("%0.1f%% (%d kB/%d kB)"), perc, (int)this->uiTotalSent/1024, (int)this->uiFileSize/1024);
-
- long s = (this->uiFileSize - this->uiTotalSent) / (long)(this->avgSpeed * 1024);
+ m_avgSpeed /= _countof(m_lastSpeed) + 1;
+ m_lastSpeed[0] = speed;
+
+ mir_sntprintf(m_tab->m_stzSpeed, _T("%0.1f kB/s"), m_avgSpeed);
+
+ double perc = m_uiFileSize ? ((double)m_uiTotalSent / m_uiFileSize) * 100 : 0;
+ mir_sntprintf(m_tab->m_stzComplet, _T("%0.1f%% (%d kB/%d kB)"), perc, (int)m_uiTotalSent / 1024, (int)m_uiFileSize / 1024);
+
+ long s = (m_uiFileSize - m_uiTotalSent) / (long)(m_avgSpeed * 1024);
int d = (s / 60 / 60 / 24);
int h = (s - d * 60 * 60 * 24) / 60 / 60;
- int m = (s - d * 60 * 60 * 24 - h * 60 * 60) / 60;
+ int m = (s - d * 60 * 60 * 24 - h * 60 * 60) / 60;
s = s - (d * 24 * 60 * 60) - (h * 60 * 60) - (m * 60);
TCHAR buff[256];
if (d > 0) mir_sntprintf(buff, _T("%dd %02d:%02d:%02d"), d, h, m, s);
else mir_sntprintf(buff, _T("%02d:%02d:%02d"), h, m, s);
- mir_sntprintf(this->tab->stzRemain, _countof(this->tab->stzRemain), _T("%s (%d kB/%d kB)"), buff, (this->uiFileSize - this->uiTotalSent)/1024, this->uiFileSize/1024);
+ mir_sntprintf(m_tab->m_stzRemain, _T("%s (%d kB/%d kB)"), buff, (m_uiFileSize - m_uiTotalSent) / 1024, m_uiFileSize / 1024);
- this->refreshTab(false);
+ refreshTab(false);
}
}
void UploadJob::refreshTab(bool bTabChanged)
{
- if (uDlg->activeTab == this->tab->index()) {
+ if (uDlg->m_activeTab == m_tab->index()) {
GenericJob::refreshTab(bTabChanged);
- ShowWindow(GetDlgItem(uDlg->hwnd, IDC_BTN_CLIPBOARD), this->isCompleted() ? SW_SHOW : SW_HIDE);
- ShowWindow(GetDlgItem(uDlg->hwnd, IDC_BTN_DOWNLOAD), this->isCompleted() ? SW_SHOW : SW_HIDE);
- EnableWindow(GetDlgItem(uDlg->hwnd, IDC_BTN_PAUSE), !this->isCompleted() && !this->isConnecting());
-
- if (this->isCompleted())
- SetDlgItemText(uDlg->hwnd, IDC_STATUSBAR, TranslateT("COMPLETED"));
- else if (this->isConnecting())
- SetDlgItemText(uDlg->hwnd, IDC_STATUSBAR, TranslateT("CONNECTING..."));
- else if (this->isPaused())
- SetDlgItemText(uDlg->hwnd, IDC_STATUSBAR, TranslateT("PAUSED"));
- else if (this->isWaitting())
- SetDlgItemText(uDlg->hwnd, IDC_STATUSBAR, TranslateT("WAITING..."));
+ ShowWindow(GetDlgItem(uDlg->m_hwnd, IDC_BTN_CLIPBOARD), isCompleted() ? SW_SHOW : SW_HIDE);
+ ShowWindow(GetDlgItem(uDlg->m_hwnd, IDC_BTN_DOWNLOAD), isCompleted() ? SW_SHOW : SW_HIDE);
+ EnableWindow(GetDlgItem(uDlg->m_hwnd, IDC_BTN_PAUSE), !isCompleted() && !isConnecting());
+
+ if (isCompleted())
+ SetDlgItemText(uDlg->m_hwnd, IDC_STATUSBAR, TranslateT("COMPLETED"));
+ else if (isConnecting())
+ SetDlgItemText(uDlg->m_hwnd, IDC_STATUSBAR, TranslateT("CONNECTING..."));
+ else if (isPaused())
+ SetDlgItemText(uDlg->m_hwnd, IDC_STATUSBAR, TranslateT("PAUSED"));
+ else if (isWaitting())
+ SetDlgItemText(uDlg->m_hwnd, IDC_STATUSBAR, TranslateT("WAITING..."));
else
- SetDlgItemText(uDlg->hwnd, IDC_STATUSBAR, TranslateT("UPLOADING..."));
+ SetDlgItemText(uDlg->m_hwnd, IDC_STATUSBAR, TranslateT("UPLOADING..."));
if (bTabChanged) {
- if (this->isPaused()) {
- SendDlgItemMessage(uDlg->hwnd, IDC_BTN_PAUSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("resume"));
- SendDlgItemMessage(uDlg->hwnd, IDC_BTN_PAUSE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Resume"), BATF_TCHAR);
- }
+ if (isPaused()) {
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_BTN_PAUSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("resume"));
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_BTN_PAUSE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Resume"), BATF_TCHAR);
+ }
else {
- SendDlgItemMessage(uDlg->hwnd, IDC_BTN_PAUSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("pause"));
- SendDlgItemMessage(uDlg->hwnd, IDC_BTN_PAUSE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Pause"), BATF_TCHAR);
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_BTN_PAUSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("pause"));
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_BTN_PAUSE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Pause"), BATF_TCHAR);
}
- ShowWindow(GetDlgItem(uDlg->hwnd, IDC_ST_REMAIN), !this->isCompleted() ? SW_SHOW : SW_HIDE);
- ShowWindow(GetDlgItem(uDlg->hwnd, IDC_UP_COMPLETED), !this->isCompleted() ? SW_SHOW : SW_HIDE);
- ShowWindow(GetDlgItem(uDlg->hwnd, IDC_UP_REMAIN), !this->isCompleted() ? SW_SHOW : SW_HIDE);
- ShowWindow(GetDlgItem(uDlg->hwnd, IDC_ED_URL), this->isCompleted() ? SW_SHOW : SW_HIDE);
- SetDlgItemText(uDlg->hwnd, IDC_ST_COMPLETED, this->isCompleted() ? TranslateT("Download link:") : TranslateT("Completed:"));
+ ShowWindow(GetDlgItem(uDlg->m_hwnd, IDC_ST_REMAIN), !isCompleted() ? SW_SHOW : SW_HIDE);
+ ShowWindow(GetDlgItem(uDlg->m_hwnd, IDC_UP_COMPLETED), !isCompleted() ? SW_SHOW : SW_HIDE);
+ ShowWindow(GetDlgItem(uDlg->m_hwnd, IDC_UP_REMAIN), !isCompleted() ? SW_SHOW : SW_HIDE);
+ ShowWindow(GetDlgItem(uDlg->m_hwnd, IDC_ED_URL), isCompleted() ? SW_SHOW : SW_HIDE);
+ SetDlgItemText(uDlg->m_hwnd, IDC_ST_COMPLETED, isCompleted() ? TranslateT("Download link:") : TranslateT("Completed:"));
}
- if (this->isCompleted()) {
- SetDlgItemText(uDlg->hwnd, IDC_UP_SPEED, _T(""));
- SetDlgItemText(uDlg->hwnd, IDC_UP_COMPLETED, _T(""));
- SetDlgItemText(uDlg->hwnd, IDC_UP_REMAIN, _T(""));
+ if (isCompleted()) {
+ SetDlgItemText(uDlg->m_hwnd, IDC_UP_SPEED, _T(""));
+ SetDlgItemText(uDlg->m_hwnd, IDC_UP_COMPLETED, _T(""));
+ SetDlgItemText(uDlg->m_hwnd, IDC_UP_REMAIN, _T(""));
- SetDlgItemTextA(uDlg->hwnd, IDC_ED_URL, this->szFileLink);
- SendDlgItemMessage(uDlg->hwnd, IDC_PB_UPLOAD, PBM_SETRANGE32, 0, (LPARAM)100);
- SendDlgItemMessage(uDlg->hwnd, IDC_PB_UPLOAD, PBM_SETPOS, (WPARAM)100, 0);
+ SetDlgItemTextA(uDlg->m_hwnd, IDC_ED_URL, m_szFileLink);
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_PB_UPLOAD, PBM_SETRANGE32, 0, (LPARAM)100);
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_PB_UPLOAD, PBM_SETPOS, (WPARAM)100, 0);
}
- else
- {
- SetDlgItemText(uDlg->hwnd, IDC_UP_SPEED, this->tab->stzSpeed);
- SetDlgItemText(uDlg->hwnd, IDC_UP_COMPLETED, this->tab->stzComplet);
- SetDlgItemText(uDlg->hwnd, IDC_UP_REMAIN, this->tab->stzRemain);
+ else {
+ SetDlgItemText(uDlg->m_hwnd, IDC_UP_SPEED, m_tab->m_stzSpeed);
+ SetDlgItemText(uDlg->m_hwnd, IDC_UP_COMPLETED, m_tab->m_stzComplet);
+ SetDlgItemText(uDlg->m_hwnd, IDC_UP_REMAIN, m_tab->m_stzRemain);
- SendDlgItemMessage(uDlg->hwnd, IDC_PB_UPLOAD, PBM_SETRANGE32, 0, (LPARAM)this->uiFileSize);
- SendDlgItemMessage(uDlg->hwnd, IDC_PB_UPLOAD, PBM_SETPOS, (WPARAM)this->uiTotalSent, 0);
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_PB_UPLOAD, PBM_SETRANGE32, 0, (LPARAM)m_uiFileSize);
+ SendDlgItemMessage(uDlg->m_hwnd, IDC_PB_UPLOAD, PBM_SETPOS, (WPARAM)m_uiTotalSent, 0);
}
}
}
void UploadJob::closeTab()
-{
- if (!this->isCompleted()) {
- this->pause();
+{
+ if (!isCompleted()) {
+ pause();
if (Utils::msgBox(TranslateT("Do you really want to cancel running upload?"), MB_YESNO | MB_ICONQUESTION) == IDNO) {
- this->resume();
+ resume();
return;
}
- this->cancel();
+ cancel();
}
- delete this->tab;
+ delete m_tab;
}
void UploadJob::closeAllTabs()
-{
- if (!this->isCompleted())
- this->cancel();
+{
+ if (!isCompleted())
+ cancel();
- delete this->tab;
+ delete m_tab;
}
void UploadJob::createToolTip()
-{
- TCHAR *server = mir_a2t(this->ftp->szServer);
- mir_sntprintf(uDlg->stzToolTipText, _countof(uDlg->stzToolTipText),
- TranslateT("Status: %s\r\nFile: %s\r\nServer: %s"),
- this->getStatusString(), this->stzFileName, server);
-
- if (this->tab->stzSpeed[0] && this->tab->stzComplet[0] && this->tab->stzRemain[0])
- mir_sntprintf(uDlg->stzToolTipText, _countof(uDlg->stzToolTipText),
- TranslateT("%s\r\nSpeed: %s\r\nCompleted: %s\r\nRemaining: %s"),
- uDlg->stzToolTipText, this->tab->stzSpeed, this->tab->stzComplet, this->tab->stzRemain);
-
- FREE(server);
-} \ No newline at end of file
+{
+ mir_sntprintf(uDlg->m_tszToolTipText, TranslateT("Status: %s\r\nFile: %s\r\nServer: %S"),
+ getStatusString(), m_tszFileName, m_ftp->m_szServer);
+
+ if (m_tab->m_stzSpeed[0] && m_tab->m_stzComplet[0] && m_tab->m_stzRemain[0])
+ mir_sntprintf(uDlg->m_tszToolTipText, TranslateT("%s\r\nSpeed: %s\r\nCompleted: %s\r\nRemaining: %s"),
+ uDlg->m_tszToolTipText, m_tab->m_stzSpeed, m_tab->m_stzComplet, m_tab->m_stzRemain);
+}
diff --git a/plugins/FTPFileYM/src/job_upload.h b/plugins/FTPFileYM/src/job_upload.h
index f155453e7d..211eee3756 100644
--- a/plugins/FTPFileYM/src/job_upload.h
+++ b/plugins/FTPFileYM/src/job_upload.h
@@ -29,17 +29,17 @@ class UploadJob: public GenericJob
private:
static const int MAX_RUNNING_JOBS = 4;
- FILE *fp;
- CURL *hCurl;
- char szError[CURL_ERROR_SIZE];
- char buff[256];
-
- UINT64 uiFileSize;
- UINT64 uiTotalSent;
- UINT64 uiSent;
- time_t startTS;
- double lastSpeed[10];
- double avgSpeed;
+ FILE *m_fp;
+ CURL *m_hCurl;
+ char m_szError[CURL_ERROR_SIZE];
+ char m_buff[256];
+
+ UINT64 m_uiFileSize;
+ UINT64 m_uiTotalSent;
+ UINT64 m_uiSent;
+ time_t m_startTS;
+ double m_lastSpeed[10];
+ double m_avgSpeed;
static mir_cs mutexJobCount;
static int iRunningJobCount;
@@ -51,7 +51,7 @@ private:
void copyLinkToML();
void autoSend();
- CURL *curlInit(char *szUrl, struct curl_slist *headerList);
+ CURL* curlInit(char *szUrl, struct curl_slist *headerList);
static void waitingThread(void *arg);
static size_t ReadCallback(void *ptr, size_t size, size_t nmemb, void *arg);
@@ -62,7 +62,7 @@ private:
void updateStats();
public:
- char szFileLink[256];
+ char m_szFileLink[256];
static Event jobDone;
UploadJob(MCONTACT _hContact, int _iFtpNum, EMode _mode);
diff --git a/plugins/FTPFileYM/src/manager.cpp b/plugins/FTPFileYM/src/manager.cpp
index 5b5250169e..ebe4755682 100644
--- a/plugins/FTPFileYM/src/manager.cpp
+++ b/plugins/FTPFileYM/src/manager.cpp
@@ -30,17 +30,18 @@ extern Options &opt;
extern ServerList &ftpList;
Manager::Manager()
-{ }
+{
+}
Manager::~Manager()
{
- for (UINT i = 0; i < this->rootItems.size(); i++)
- delete this->rootItems[i];
+ for (UINT i = 0; i < m_rootItems.size(); i++)
+ delete m_rootItems[i];
- for (UINT i = 0; i < this->items.size(); i++)
- delete this->items[i];
+ for (UINT i = 0; i < m_items.size(); i++)
+ delete m_items[i];
- ImageList_Destroy(this->himlStates);
+ ImageList_Destroy(m_himlStates);
DBEntry::cleanupDB();
instance = NULL;
@@ -50,16 +51,14 @@ Manager::~Manager()
void Manager::init()
{
ServerList::FTP *ftp = ftpList.getSelected();
- if (ftp->bEnabled)
- {
- this->hwnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DLG_MANAGER), NULL, Manager::ManagerDlgProc);
- this->hwndFileTree = GetDlgItem(this->hwnd, IDC_FILELIST);
- this->initImageList();
- this->fillTree();
- this->show();
+ if (ftp->m_bEnabled) {
+ m_hwnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DLG_MANAGER), NULL, Manager::ManagerDlgProc);
+ m_hwndFileTree = GetDlgItem(m_hwnd, IDC_FILELIST);
+ initImageList();
+ fillTree();
+ show();
}
- else
- {
+ else {
Utils::msgBox(TranslateT("You have to fill and enable at least one FTP server in setting."), MB_OK);
delete this;
}
@@ -67,45 +66,42 @@ void Manager::init()
void Manager::show()
{
- ShowWindow(this->hwnd, SW_SHOWNORMAL);
- BringWindowToTop(this->hwnd);
+ ShowWindow(m_hwnd, SW_SHOWNORMAL);
+ BringWindowToTop(m_hwnd);
}
void Manager::initImageList()
{
char buff[256];
- this->himlStates = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, ServerList::FTP_COUNT + 4, 0);
- ImageList_AddIcon(himlStates, Skin_LoadIcon(SKINICON_OTHER_DELETE)); // image index 0 is useless for INDEXTOSTATEIMAGEMASK
- ImageList_AddIcon(himlStates, Skin_LoadIcon(SKINICON_OTHER_DELETE));
- ImageList_AddIcon(himlStates, Skin_LoadIcon(SKINICON_OTHER_NOTICK));
- ImageList_AddIcon(himlStates, Skin_LoadIcon(SKINICON_OTHER_TICK));
+ m_himlStates = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, ServerList::FTP_COUNT + 4, 0);
+ ImageList_AddIcon(m_himlStates, Skin_LoadIcon(SKINICON_OTHER_DELETE)); // image index 0 is useless for INDEXTOSTATEIMAGEMASK
+ ImageList_AddIcon(m_himlStates, Skin_LoadIcon(SKINICON_OTHER_DELETE));
+ ImageList_AddIcon(m_himlStates, Skin_LoadIcon(SKINICON_OTHER_NOTICK));
+ ImageList_AddIcon(m_himlStates, Skin_LoadIcon(SKINICON_OTHER_TICK));
- for (int i = 0; i < ServerList::FTP_COUNT; i++)
- {
+ for (int i = 0; i < ServerList::FTP_COUNT; i++) {
mir_snprintf(buff, "ftp%d", i);
- ImageList_AddIcon(himlStates, Utils::loadIconEx(buff));
+ ImageList_AddIcon(m_himlStates, Utils::loadIconEx(buff));
}
- TreeView_SetImageList(this->hwndFileTree, himlStates, TVSIL_STATE);
- TreeView_SetItemHeight(this->hwndFileTree, 18);
+ TreeView_SetImageList(m_hwndFileTree, m_himlStates, TVSIL_STATE);
+ TreeView_SetItemHeight(m_hwndFileTree, 18);
}
void Manager::initRootItems()
{
- TVINSERTSTRUCT tvi = {0};
+ TVINSERTSTRUCT tvi = { 0 };
tvi.hInsertAfter = TVI_LAST;
tvi.item.mask = TVIF_TEXT | TVIF_STATE;
tvi.item.stateMask = TVIS_STATEIMAGEMASK | TVIS_EXPANDED | TVIS_BOLD;
- for (UINT i = 0; i < ServerList::FTP_COUNT; i++)
- {
- if (ftpList[i]->bEnabled)
- {
- tvi.item.pszText = ftpList[i]->stzName;
+ for (UINT i = 0; i < ServerList::FTP_COUNT; i++) {
+ if (ftpList[i]->m_bEnabled) {
+ tvi.item.pszText = ftpList[i]->m_stzName;
tvi.item.state = INDEXTOSTATEIMAGEMASK(i + 4) | TVIS_EXPANDED | TVIS_BOLD;
- HTREEITEM hItem = TreeView_InsertItem(this->hwndFileTree, &tvi);
- this->AddRoot(hItem);
+ HTREEITEM hItem = TreeView_InsertItem(m_hwndFileTree, &tvi);
+ AddRoot(hItem);
}
}
}
@@ -114,7 +110,7 @@ void Manager::fillTree()
{
initRootItems();
- TVINSERTSTRUCT tvi = {0};
+ TVINSERTSTRUCT tvi = { 0 };
tvi.hInsertAfter = TVI_LAST;
tvi.item.mask = TVIF_TEXT | TVIF_STATE;
tvi.item.stateMask = TVIS_STATEIMAGEMASK;
@@ -122,15 +118,13 @@ void Manager::fillTree()
mir_cslock lock(DBEntry::mutexDB);
- DBEntry *entry = DBEntry::getFirts();
- while (entry != NULL)
- {
- if ((UINT)entry->iFtpNum < this->rootItems.size())
- {
- tvi.item.pszText = mir_a2t(entry->szFileName);
- tvi.hParent = this->rootItems[entry->iFtpNum]->handle;
- HTREEITEM hItem = TreeView_InsertItem(this->hwndFileTree, &tvi);
- this->AddLeaf(hItem, tvi.hParent, entry->fileID);
+ DBEntry *entry = DBEntry::getFirst();
+ while (entry != NULL) {
+ if ((UINT)entry->m_iFtpNum < m_rootItems.size()) {
+ tvi.item.pszText = mir_a2t(entry->m_szFileName);
+ tvi.hParent = m_rootItems[entry->m_iFtpNum]->m_handle;
+ HTREEITEM hItem = TreeView_InsertItem(m_hwndFileTree, &tvi);
+ AddLeaf(hItem, tvi.hParent, entry->m_fileID);
FREE(tvi.item.pszText);
}
@@ -140,9 +134,8 @@ void Manager::fillTree()
int Manager::indexOf(HTREEITEM handle)
{
- for (UINT i = 0; i < this->rootItems.size(); i++)
- {
- if (this->rootItems[i]->handle == handle)
+ for (UINT i = 0; i < m_rootItems.size(); i++) {
+ if (m_rootItems[i]->m_handle == handle)
return i;
}
@@ -151,59 +144,58 @@ int Manager::indexOf(HTREEITEM handle)
Manager::TreeItem *Manager::getItem(HTREEITEM handle)
{
- for (UINT i = 0; i < this->rootItems.size(); i++)
- {
- if (this->rootItems[i]->handle == handle)
- return this->rootItems[i];
+ for (UINT i = 0; i < m_rootItems.size(); i++) {
+ if (m_rootItems[i]->m_handle == handle)
+ return m_rootItems[i];
}
- for (UINT i = 0; i < this->items.size(); i++)
- {
- if (this->items[i]->handle == handle)
- return this->items[i];
+ for (UINT i = 0; i < m_items.size(); i++) {
+ if (m_items[i]->m_handle == handle)
+ return m_items[i];
}
return NULL;
}
-Manager::TreeItem::TreeItem(HTREEITEM _handle, HTREEITEM _parent, int _id)
-:handle(_handle),parent(_parent),fileID(_id)
-{
- stzToolTip[0] = 0;
+Manager::TreeItem::TreeItem(HTREEITEM _handle, HTREEITEM _parent, int _id) :
+ m_handle(_handle),
+ m_parent(_parent),
+ m_fileID(_id)
+{
+ m_tszToolTip[0] = 0;
}
void Manager::TreeItem::setState(UINT state)
{
- TVITEM item = {0};
+ TVITEM item = { 0 };
item.mask = TVIF_HANDLE | TVIF_STATE;
item.stateMask = TVIS_STATEIMAGEMASK;
- item.hItem = this->handle;
- TreeView_GetItem(manDlg->hwndFileTree, &item);
+ item.hItem = m_handle;
+ TreeView_GetItem(manDlg->m_hwndFileTree, &item);
- if (TreeItem::_GETSTATE(item.state) != 0)
- {
+ if (TreeItem::_GETSTATE(item.state) != 0) {
item.state = state;
- TreeView_SetItem(manDlg->hwndFileTree, &item);
+ TreeView_SetItem(manDlg->m_hwndFileTree, &item);
}
}
UINT Manager::TreeItem::getState()
{
- TVITEM item = {0};
+ TVITEM item = { 0 };
item.mask = TVIF_HANDLE | TVIF_STATE;
item.stateMask = TVIS_STATEIMAGEMASK;
- item.hItem = this->handle;
- TreeView_GetItem(manDlg->hwndFileTree, &item);
+ item.hItem = m_handle;
+ TreeView_GetItem(manDlg->m_hwndFileTree, &item);
return TreeItem::_GETSTATE(item.state);
}
void Manager::TreeItem::toggleState()
{
- TVITEM item = {0};
+ TVITEM item = { 0 };
item.mask = TVIF_HANDLE | TVIF_STATE;
item.stateMask = TVIS_STATEIMAGEMASK;
- item.hItem = this->handle;
- TreeView_GetItem(manDlg->hwndFileTree, &item);
+ item.hItem = m_handle;
+ TreeView_GetItem(manDlg->m_hwndFileTree, &item);
UINT state = TreeItem::_GETSTATE(item.state);
if (state == STATE_UNCHECKED)
@@ -211,238 +203,198 @@ void Manager::TreeItem::toggleState()
else if (state == STATE_CHECKED || state == STATE_ERROR)
item.state = TreeItem::_UNCHECKED();
- TreeView_SetItem(manDlg->hwndFileTree, &item);
+ TreeView_SetItem(manDlg->m_hwndFileTree, &item);
}
void Manager::TreeItem::remove()
{
- TreeView_DeleteItem(manDlg->hwndFileTree, this->handle);
- DBEntry::remove(this->fileID);
+ TreeView_DeleteItem(manDlg->m_hwndFileTree, m_handle);
+ DBEntry::remove(m_fileID);
}
bool Manager::TreeItem::isRoot()
{
- return (this->parent != NULL) ? false : true;
+ return (m_parent != NULL) ? false : true;
}
-INT_PTR CALLBACK Manager::ManagerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK Manager::ManagerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
-
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Utils::loadIconEx("main"));
- SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_TICK));
- SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Select All"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_NOTICK));
- SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Clear All"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("clear"));
- SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete from List"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("delete"));
- SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete from FTP"), BATF_TCHAR);
- SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BUTTONSETASFLATBTN, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_EXIT));
- SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Close"), BATF_TCHAR);
-
- return TRUE;
- }
- case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED)
- {
- switch (LOWORD(wParam))
- {
- case IDC_BTN_DELETE:
- {
- for (UINT i = 0; i < manDlg->items.size(); i++)
- {
- TreeItem *item = manDlg->items[i];
- if (item->getState() == STATE_CHECKED)
- {
- DeleteJob *job = new DeleteJob(DBEntry::get(item->fileID), item);
- job->start();
- }
- }
- break;
- }
- case IDC_BTN_DELETEFROMLIST:
- {
- for (UINT i = 0; i < manDlg->items.size(); i++)
- {
- TreeItem *item = manDlg->items[i];
- if (item->getState() == STATE_CHECKED)
- item->remove();
- }
- break;
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Utils::loadIconEx("main"));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_TICK));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_SELECTALL, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Select All"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_NOTICK));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DESELECTALL, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Clear All"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("clear"));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DELETEFROMLIST, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete from List"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Utils::loadIconEx("delete"));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_DELETE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Delete from FTP"), BATF_TCHAR);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_EXIT));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_CLOSE, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Close"), BATF_TCHAR);
+ return TRUE;
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) == BN_CLICKED) {
+ switch (LOWORD(wParam)) {
+ case IDC_BTN_DELETE:
+ for (UINT i = 0; i < manDlg->m_items.size(); i++) {
+ TreeItem *item = manDlg->m_items[i];
+ if (item->getState() == STATE_CHECKED) {
+ DeleteJob *job = new DeleteJob(DBEntry::get(item->m_fileID), item);
+ job->start();
}
- case IDC_BTN_SELECTALL:
- case IDC_BTN_DESELECTALL:
- {
- UINT newState = (LOWORD(wParam) == IDC_BTN_SELECTALL) ?
- TreeItem::_CHECKED() : TreeItem::_UNCHECKED();
+ }
+ break;
- for (UINT i = 0; i < manDlg->items.size(); i++)
- manDlg->items[i]->setState(newState);
+ case IDC_BTN_DELETEFROMLIST:
+ for (UINT i = 0; i < manDlg->m_items.size(); i++) {
+ TreeItem *item = manDlg->m_items[i];
+ if (item->getState() == STATE_CHECKED)
+ item->remove();
+ }
+ break;
+
+ case IDC_BTN_SELECTALL:
+ case IDC_BTN_DESELECTALL:
+ {
+ UINT newState = (LOWORD(wParam) == IDC_BTN_SELECTALL) ?
+ TreeItem::_CHECKED() : TreeItem::_UNCHECKED();
+
+ for (UINT i = 0; i < manDlg->m_items.size(); i++)
+ manDlg->m_items[i]->setState(newState);
- break;
- }
- case IDC_BTN_CLOSE:
- {
- DestroyWindow(hwndDlg);
- break;
- }
}
- }
+ break;
- break;
+ case IDC_BTN_CLOSE:
+ DestroyWindow(hwndDlg);
+ break;
+ }
}
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->idFrom == IDC_FILELIST)
- {
- switch(((LPNMHDR)lParam)->code)
+ break;
+
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->idFrom == IDC_FILELIST) {
+ switch (((LPNMHDR)lParam)->code) {
+ case TVN_KEYDOWN:
+ if (((LPNMTVKEYDOWN)lParam)->wVKey != VK_SPACE)
+ break;
+
+ case NM_CLICK:
{
- case TVN_KEYDOWN:
- if (((LPNMTVKEYDOWN)lParam)->wVKey != VK_SPACE)
- break;
- case NM_CLICK:
- {
- HTREEITEM hItem;
- TVHITTESTINFO hti = {0};
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
- if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti) || ((LPNMHDR)lParam)->code == TVN_KEYDOWN)
- {
- if (((LPNMHDR)lParam)->code == TVN_KEYDOWN)
- {
- hti.flags |= TVHT_ONITEMSTATEICON;
- hItem = TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom);
- }
- else
- {
- hItem = hti.hItem;
- }
-
- TreeItem *item = manDlg->getItem(hItem);
- if (item && (hti.flags & TVHT_ONITEMSTATEICON))
- {
- if (item->isRoot())
- {
- for (UINT i = 0; i < manDlg->items.size(); i++)
- {
- if (manDlg->items[i]->parent == item->handle)
- manDlg->items[i]->toggleState();
- }
- }
- else
- {
- item->toggleState();
+ HTREEITEM hItem;
+ TVHITTESTINFO hti = { 0 };
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
+ if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti) || ((LPNMHDR)lParam)->code == TVN_KEYDOWN) {
+ if (((LPNMHDR)lParam)->code == TVN_KEYDOWN) {
+ hti.flags |= TVHT_ONITEMSTATEICON;
+ hItem = TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom);
+ }
+ else {
+ hItem = hti.hItem;
+ }
+
+ TreeItem *item = manDlg->getItem(hItem);
+ if (item && (hti.flags & TVHT_ONITEMSTATEICON)) {
+ if (item->isRoot()) {
+ for (UINT i = 0; i < manDlg->m_items.size(); i++) {
+ if (manDlg->m_items[i]->m_parent == item->m_handle)
+ manDlg->m_items[i]->toggleState();
}
}
+ else {
+ item->toggleState();
+ }
}
- return TRUE;
- }
- case NM_RCLICK:
- {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(manDlg->hwndFileTree, &hti.pt);
- if (TreeView_HitTest(manDlg->hwndFileTree, &hti))
- {
- HTREEITEM hItem = hti.hItem;
- TreeItem *item = manDlg->getItem(hItem);
- if (item && !item->isRoot())
- {
- POINT pt;
- GetCursorPos(&pt);
- SetForegroundWindow(hwndDlg);
- HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU_MANAGER));
- if (hMenu)
- {
- HMENU hPopupMenu = GetSubMenu(hMenu, 0);
- TranslateMenu(hPopupMenu);
- int command = TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
- switch (command)
- {
-
- case IDM_DELETEFROMLIST:
- {
- item->remove();
- break;
- }
- case IDM_DELETEFROMFTP:
- {
- DeleteJob *job = new DeleteJob(DBEntry::get(item->fileID), item);
- job->start();
- break;
- }
- case IDM_COPYLINK:
- case IDM_DOWNLOAD:
- {
- int ftpNum = manDlg->indexOf(item->parent);
- if (ftpNum != -1)
- {
- char buff[256];
-
- DBEntry *entry = DBEntry::get(item->fileID);
- Utils::createFileDownloadLink(ftpList[ftpNum]->szUrl, entry->szFileName, buff, sizeof(buff));
- delete entry;
-
- if (command == IDM_COPYLINK)
- Utils::copyToClipboard(buff);
- else
- ShellExecuteA(NULL, "open", buff, NULL, NULL, SW_SHOWNORMAL);
- }
- break;
- }
+ }
+ }
+ return TRUE;
+
+ case NM_RCLICK:
+ {
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(manDlg->m_hwndFileTree, &hti.pt);
+ if (TreeView_HitTest(manDlg->m_hwndFileTree, &hti)) {
+ HTREEITEM hItem = hti.hItem;
+ TreeItem *item = manDlg->getItem(hItem);
+ if (item && !item->isRoot()) {
+ POINT pt;
+ GetCursorPos(&pt);
+ SetForegroundWindow(hwndDlg);
+ HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU_MANAGER));
+ if (hMenu) {
+ HMENU hPopupMenu = GetSubMenu(hMenu, 0);
+ TranslateMenu(hPopupMenu);
+ int command = TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
+ switch (command) {
+ case IDM_DELETEFROMLIST:
+ item->remove();
+ break;
+
+ case IDM_DELETEFROMFTP:
+ (new DeleteJob(DBEntry::get(item->m_fileID), item))->start();
+ break;
+
+ case IDM_COPYLINK:
+ case IDM_DOWNLOAD:
+ int ftpNum = manDlg->indexOf(item->m_parent);
+ if (ftpNum != -1) {
+ char buff[256];
+
+ DBEntry *entry = DBEntry::get(item->m_fileID);
+ Utils::createFileDownloadLink(ftpList[ftpNum]->m_szUrl, entry->m_szFileName, buff, sizeof(buff));
+ delete entry;
+
+ if (command == IDM_COPYLINK)
+ Utils::copyToClipboard(buff);
+ else
+ ShellExecuteA(NULL, "open", buff, NULL, NULL, SW_SHOWNORMAL);
}
- DestroyMenu(hMenu);
+ break;
}
+ DestroyMenu(hMenu);
}
}
- return TRUE;
}
- case TVN_GETINFOTIP:
- {
- NMTVGETINFOTIP *tvInfoTip = (NMTVGETINFOTIP *)lParam;
- TreeItem *item = manDlg->getItem(tvInfoTip->hItem);
-
- if (item)
- {
- if (item->stzToolTip[0])
- {
- _tcsncpy(tvInfoTip->pszText, item->stzToolTip, tvInfoTip->cchTextMax - 1);
- tvInfoTip->pszText[tvInfoTip->cchTextMax - 1] = 0;
- }
- }
-
- return TRUE;
+ return TRUE;
+ }
+ case TVN_GETINFOTIP:
+ NMTVGETINFOTIP *tvInfoTip = (NMTVGETINFOTIP *)lParam;
+ TreeItem *item = manDlg->getItem(tvInfoTip->hItem);
+
+ if (item) {
+ if (item->m_tszToolTip[0]) {
+ _tcsncpy(tvInfoTip->pszText, item->m_tszToolTip, tvInfoTip->cchTextMax - 1);
+ tvInfoTip->pszText[tvInfoTip->cchTextMax - 1] = 0;
}
}
- }
- break;
- }
- case WM_CLOSE:
- {
- DestroyWindow(hwndDlg);
- return TRUE;
- }
- case WM_DESTROY:
- {
- delete manDlg;
- return TRUE;
+ return TRUE;
+ }
}
+ break;
+
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ return TRUE;
+
+ case WM_DESTROY:
+ delete manDlg;
+ return TRUE;
}
return FALSE;
-} \ No newline at end of file
+}
diff --git a/plugins/FTPFileYM/src/manager.h b/plugins/FTPFileYM/src/manager.h
index 67ca00bd6a..088ddf0b03 100644
--- a/plugins/FTPFileYM/src/manager.h
+++ b/plugins/FTPFileYM/src/manager.h
@@ -32,9 +32,9 @@ private:
static Manager *instance;
- HWND hwnd;
- HWND hwndFileTree;
- HIMAGELIST himlStates;
+ HWND m_hwnd;
+ HWND m_hwndFileTree;
+ HIMAGELIST m_himlStates;
Manager();
@@ -47,10 +47,10 @@ public:
class TreeItem
{
public:
- HTREEITEM handle;
- HTREEITEM parent;
- TCHAR stzToolTip[256];
- int fileID;
+ HTREEITEM m_handle;
+ HTREEITEM m_parent;
+ TCHAR m_tszToolTip[256];
+ int m_fileID;
TreeItem(HTREEITEM _handle, HTREEITEM _parent, int _id);
void setState(UINT state);
@@ -65,13 +65,13 @@ public:
static UINT _CHECKED() { return INDEXTOSTATEIMAGEMASK(STATE_CHECKED); }
};
- vector<TreeItem *> rootItems;
- vector<TreeItem *> items;
+ vector<TreeItem*> m_rootItems;
+ vector<TreeItem*> m_items;
~Manager();
- void AddRoot(HTREEITEM h) { rootItems.push_back(new TreeItem(h,NULL,0)); }
- void AddLeaf(HTREEITEM h, HTREEITEM p, int id) { items.push_back(new TreeItem(h,p,id)); }
+ void AddRoot(HTREEITEM h) { m_rootItems.push_back(new TreeItem(h,NULL,0)); }
+ void AddLeaf(HTREEITEM h, HTREEITEM p, int id) { m_items.push_back(new TreeItem(h,p,id)); }
static Manager *getInstance()
{
diff --git a/plugins/FTPFileYM/src/mir_db.cpp b/plugins/FTPFileYM/src/mir_db.cpp
index 5f70e61d8e..c09b6dac51 100644
--- a/plugins/FTPFileYM/src/mir_db.cpp
+++ b/plugins/FTPFileYM/src/mir_db.cpp
@@ -77,8 +77,7 @@ int DB::getDwordF(MCONTACT hContact, char *szModule, char *szSetting, int id, in
int DB::getAString(MCONTACT hContact, char *szModule, char *szSetting, char *buff)
{
DBVARIANT dbv;
- if (!db_get_s(hContact, szModule, szSetting, &dbv))
- {
+ if (!db_get_s(hContact, szModule, szSetting, &dbv)) {
mir_strcpy(buff, dbv.pszVal);
db_free(&dbv);
return 0;
@@ -98,8 +97,7 @@ int DB::getAStringF(MCONTACT hContact, char *szModule, char *szSetting, int id,
int DB::getString(MCONTACT hContact, char *szModule, char *szSetting, TCHAR *buff)
{
DBVARIANT dbv;
- if (!db_get_ts(hContact, szModule, szSetting, &dbv))
- {
+ if (!db_get_ts(hContact, szModule, szSetting, &dbv)) {
mir_tstrcpy(buff, dbv.ptszVal);
db_free(&dbv);
return 0;
diff --git a/plugins/FTPFileYM/src/options.cpp b/plugins/FTPFileYM/src/options.cpp
index fa29f361ba..dc2942b077 100644
--- a/plugins/FTPFileYM/src/options.cpp
+++ b/plugins/FTPFileYM/src/options.cpp
@@ -27,7 +27,7 @@ extern ServerList &ftpList;
extern void PrebuildMainMenu();
void Options::deinit()
-{
+{
delete this;
}
@@ -50,7 +50,7 @@ void Options::loadOptions()
void Options::saveOptions() const
{
db_set_b(0, MODULE, "Autosend", bAutosend ? 1 : 0);
- db_set_b(0, MODULE, "CopyLink", bCopyLink ? 1 : 0);
+ db_set_b(0, MODULE, "CopyLink", bCopyLink ? 1 : 0);
db_set_b(0, MODULE, "UseSubmenu", bUseSubmenu ? 1 : 0);
db_set_b(0, MODULE, "HideInactive", bHideInactive ? 1 : 0);
db_set_b(0, MODULE, "CloseDlg", bCloseDlg ? 1 : 0);
@@ -64,7 +64,7 @@ void Options::saveOptions() const
void Options::enableItems(HWND hwndDlg, bool state)
{
EnableWindow(GetDlgItem(hwndDlg, IDC_DEFAULT), state);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PROTOLIST), state);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PROTOLIST), state);
EnableWindow(GetDlgItem(hwndDlg, IDC_SERVER), state);
EnableWindow(GetDlgItem(hwndDlg, IDC_USER), state);
EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), state);
@@ -72,38 +72,38 @@ void Options::enableItems(HWND hwndDlg, bool state)
EnableWindow(GetDlgItem(hwndDlg, IDC_URL), state);
EnableWindow(GetDlgItem(hwndDlg, IDC_PORT), state);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHMOD), state);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSIVE), state);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSIVE), state);
}
INT_PTR CALLBACK Options::DlgProcOptsAccounts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- {
- for (int i = 0; i < ServerList::FTP_COUNT; i++)
- ComboBox_AddString(GetDlgItem(hwndDlg, IDC_FTPLIST), ftpList[i]->stzName);
+ {
+ for (int i = 0; i < ServerList::FTP_COUNT; i++)
+ ComboBox_AddString(GetDlgItem(hwndDlg, IDC_FTPLIST), ftpList[i]->m_stzName);
ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_FTPLIST), opt.selected);
- CheckDlgButton(hwndDlg, IDC_DEFAULT, opt.selected == opt.defaultFTP ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_DEFAULT, opt.selected == opt.defaultFTP ? BST_CHECKED : BST_UNCHECKED);
ServerList::FTP *ftp = ftpList.getSelected();
ComboBox_AddString(GetDlgItem(hwndDlg, IDC_PROTOLIST), TranslateT("FTP (Standard)"));
ComboBox_AddString(GetDlgItem(hwndDlg, IDC_PROTOLIST), TranslateT("FTP+SSL (Explicit)"));
ComboBox_AddString(GetDlgItem(hwndDlg, IDC_PROTOLIST), TranslateT("FTP+SSL (Implicit)"));
ComboBox_AddString(GetDlgItem(hwndDlg, IDC_PROTOLIST), TranslateT("SFTP (Secure FTP over SSH)"));
- ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_PROTOLIST), ftp->ftpProto);
-
- SetDlgItemTextA(hwndDlg, IDC_SERVER, ftp->szServer);
- SetDlgItemTextA(hwndDlg, IDC_USER, ftp->szUser);
- SetDlgItemTextA(hwndDlg, IDC_PASSWORD, ftp->szPass);
- SetDlgItemTextA(hwndDlg, IDC_DIR, ftp->szDir);
- SetDlgItemTextA(hwndDlg, IDC_URL, ftp->szUrl);
- SetDlgItemTextA(hwndDlg, IDC_CHMOD, ftp->szChmod);
- SetDlgItemInt (hwndDlg, IDC_PORT, ftp->iPort, FALSE);
- CheckDlgButton(hwndDlg, IDC_PASSIVE, ftp->bPassive ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_ENABLED, ftp->bEnabled ? BST_CHECKED : BST_UNCHECKED);
- enableItems(hwndDlg, ftp->bEnabled);
+ ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_PROTOLIST), ftp->m_ftpProto);
+
+ SetDlgItemTextA(hwndDlg, IDC_SERVER, ftp->m_szServer);
+ SetDlgItemTextA(hwndDlg, IDC_USER, ftp->m_szUser);
+ SetDlgItemTextA(hwndDlg, IDC_PASSWORD, ftp->m_szPass);
+ SetDlgItemTextA(hwndDlg, IDC_DIR, ftp->m_szDir);
+ SetDlgItemTextA(hwndDlg, IDC_URL, ftp->m_szUrl);
+ SetDlgItemTextA(hwndDlg, IDC_CHMOD, ftp->m_szChmod);
+ SetDlgItemInt(hwndDlg, IDC_PORT, ftp->m_iPort, FALSE);
+ CheckDlgButton(hwndDlg, IDC_PASSIVE, ftp->m_bPassive ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_ENABLED, ftp->m_bEnabled ? BST_CHECKED : BST_UNCHECKED);
+ enableItems(hwndDlg, ftp->m_bEnabled);
}
return TRUE;
@@ -116,33 +116,33 @@ INT_PTR CALLBACK Options::DlgProcOptsAccounts(HWND hwndDlg, UINT msg, WPARAM wPa
else if (HIWORD(wParam) == CBN_SELCHANGE) {
if (LOWORD(wParam) == IDC_FTPLIST) {
opt.selected = (BYTE)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_FTPLIST));
- CheckDlgButton(hwndDlg, IDC_DEFAULT, opt.selected == opt.defaultFTP ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_DEFAULT, opt.selected == opt.defaultFTP ? BST_CHECKED : BST_UNCHECKED);
ServerList::FTP *ftp = ftpList.getSelected();
- SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_SETCURSEL, ftp->ftpProto, 0);
- SetDlgItemTextA(hwndDlg, IDC_SERVER, ftp->szServer);
- SetDlgItemTextA(hwndDlg, IDC_USER, ftp->szUser);
- SetDlgItemTextA(hwndDlg, IDC_PASSWORD, ftp->szPass);
- SetDlgItemTextA(hwndDlg, IDC_DIR, ftp->szDir);
- SetDlgItemTextA(hwndDlg, IDC_URL, ftp->szUrl);
- SetDlgItemTextA(hwndDlg, IDC_CHMOD, ftp->szChmod);
- SetDlgItemInt (hwndDlg, IDC_PORT, ftp->iPort, FALSE);
- CheckDlgButton(hwndDlg, IDC_PASSIVE, ftp->bPassive ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_ENABLED, ftp->bEnabled ? BST_CHECKED : BST_UNCHECKED);
- enableItems(hwndDlg, ftp->bEnabled);
+ SendDlgItemMessage(hwndDlg, IDC_PROTOLIST, CB_SETCURSEL, ftp->m_ftpProto, 0);
+ SetDlgItemTextA(hwndDlg, IDC_SERVER, ftp->m_szServer);
+ SetDlgItemTextA(hwndDlg, IDC_USER, ftp->m_szUser);
+ SetDlgItemTextA(hwndDlg, IDC_PASSWORD, ftp->m_szPass);
+ SetDlgItemTextA(hwndDlg, IDC_DIR, ftp->m_szDir);
+ SetDlgItemTextA(hwndDlg, IDC_URL, ftp->m_szUrl);
+ SetDlgItemTextA(hwndDlg, IDC_CHMOD, ftp->m_szChmod);
+ SetDlgItemInt(hwndDlg, IDC_PORT, ftp->m_iPort, FALSE);
+ CheckDlgButton(hwndDlg, IDC_PASSIVE, ftp->m_bPassive ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_ENABLED, ftp->m_bEnabled ? BST_CHECKED : BST_UNCHECKED);
+ enableItems(hwndDlg, ftp->m_bEnabled);
}
else if (LOWORD(wParam) == IDC_PROTOLIST) {
int sel = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PROTOLIST));
switch (sel) {
- case ServerList::FTP::FT_STANDARD:
- case ServerList::FTP::FT_SSL_EXPLICIT: SetDlgItemInt(hwndDlg, IDC_PORT, 21, FALSE); break;
- case ServerList::FTP::FT_SSL_IMPLICIT: SetDlgItemInt(hwndDlg, IDC_PORT, 990, FALSE); break;
- case ServerList::FTP::FT_SSH: SetDlgItemInt(hwndDlg, IDC_PORT, 22, FALSE); break;
+ case ServerList::FTP::FT_STANDARD:
+ case ServerList::FTP::FT_SSL_EXPLICIT: SetDlgItemInt(hwndDlg, IDC_PORT, 21, FALSE); break;
+ case ServerList::FTP::FT_SSL_IMPLICIT: SetDlgItemInt(hwndDlg, IDC_PORT, 990, FALSE); break;
+ case ServerList::FTP::FT_SSH: SetDlgItemInt(hwndDlg, IDC_PORT, 22, FALSE); break;
}
}
}
- if (HIWORD(wParam)==BN_CLICKED || HIWORD(wParam)==EN_CHANGE || HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)==CBN_EDITCHANGE)
+ if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE || HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
return TRUE;
@@ -153,21 +153,21 @@ INT_PTR CALLBACK Options::DlgProcOptsAccounts(HWND hwndDlg, UINT msg, WPARAM wPa
opt.defaultFTP = opt.selected;
ServerList::FTP *ftp = ftpList.getSelected();
- GetDlgItemText(hwndDlg, IDC_FTPLIST, ftp->stzName, _countof(ftp->stzName));
- GetDlgItemTextA(hwndDlg, IDC_SERVER, ftp->szServer, _countof(ftp->szServer));
- GetDlgItemTextA(hwndDlg, IDC_USER, ftp->szUser, _countof(ftp->szUser));
- GetDlgItemTextA(hwndDlg, IDC_PASSWORD, ftp->szPass, _countof(ftp->szPass));
- GetDlgItemTextA(hwndDlg, IDC_DIR, ftp->szDir, _countof(ftp->szDir));
- GetDlgItemTextA(hwndDlg, IDC_URL, ftp->szUrl, _countof(ftp->szUrl));
- GetDlgItemTextA(hwndDlg, IDC_CHMOD, ftp->szChmod, _countof(ftp->szChmod));
-
- ftp->ftpProto = (ServerList::FTP::EProtoType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PROTOLIST));
- ftp->iPort = GetDlgItemInt(hwndDlg, IDC_PORT, 0, 0);
- ftp->bPassive = IsDlgButtonChecked(hwndDlg, IDC_PASSIVE) ? true : false;
- ftp->bEnabled = IsDlgButtonChecked(hwndDlg, IDC_ENABLED) ? true : false;
+ GetDlgItemText(hwndDlg, IDC_FTPLIST, ftp->m_stzName, _countof(ftp->m_stzName));
+ GetDlgItemTextA(hwndDlg, IDC_SERVER, ftp->m_szServer, _countof(ftp->m_szServer));
+ GetDlgItemTextA(hwndDlg, IDC_USER, ftp->m_szUser, _countof(ftp->m_szUser));
+ GetDlgItemTextA(hwndDlg, IDC_PASSWORD, ftp->m_szPass, _countof(ftp->m_szPass));
+ GetDlgItemTextA(hwndDlg, IDC_DIR, ftp->m_szDir, _countof(ftp->m_szDir));
+ GetDlgItemTextA(hwndDlg, IDC_URL, ftp->m_szUrl, _countof(ftp->m_szUrl));
+ GetDlgItemTextA(hwndDlg, IDC_CHMOD, ftp->m_szChmod, _countof(ftp->m_szChmod));
+
+ ftp->m_ftpProto = (ServerList::FTP::EProtoType)ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_PROTOLIST));
+ ftp->m_iPort = GetDlgItemInt(hwndDlg, IDC_PORT, 0, 0);
+ ftp->m_bPassive = IsDlgButtonChecked(hwndDlg, IDC_PASSIVE) ? true : false;
+ ftp->m_bEnabled = IsDlgButtonChecked(hwndDlg, IDC_ENABLED) ? true : false;
ComboBox_DeleteString(GetDlgItem(hwndDlg, IDC_FTPLIST), opt.selected);
- ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_FTPLIST), opt.selected, ftp->stzName);
+ ComboBox_InsertString(GetDlgItem(hwndDlg, IDC_FTPLIST), opt.selected, ftp->m_stzName);
ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_FTPLIST), opt.selected);
ftpList.saveToDb();
@@ -181,7 +181,7 @@ INT_PTR CALLBACK Options::DlgProcOptsAccounts(HWND hwndDlg, UINT msg, WPARAM wPa
INT_PTR CALLBACK Options::DlgProcOptsAdvanced(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
@@ -220,7 +220,7 @@ INT_PTR CALLBACK Options::DlgProcOptsAdvanced(HWND hwndDlg, UINT msg, WPARAM wPa
return TRUE;
case WM_NOTIFY:
- if(((LPNMHDR)lParam)->code == PSN_APPLY) {
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
opt.bAutosend = IsDlgButtonChecked(hwndDlg, IDC_URL_AUTOSEND) ? true : false;
opt.bCopyLink = IsDlgButtonChecked(hwndDlg, IDC_URL_COPYTOML) ? true : false;
opt.bUseSubmenu = IsDlgButtonChecked(hwndDlg, IDC_USESUBMENU) ? true : false;
diff --git a/plugins/FTPFileYM/src/serverlist.cpp b/plugins/FTPFileYM/src/serverlist.cpp
index 512aafa0a0..50814f92cf 100644
--- a/plugins/FTPFileYM/src/serverlist.cpp
+++ b/plugins/FTPFileYM/src/serverlist.cpp
@@ -24,16 +24,15 @@ ServerList &ftpList = ServerList::getInstance();
extern Options &opt;
void ServerList::init()
-{
- for (int i = 0; i < FTP_COUNT; i++)
- {
+{
+ for (int i = 0; i < FTP_COUNT; i++) {
ServerList::FTP *ftp = new ServerList::FTP(i);
ftpList.add(ftp);
}
}
void ServerList::deinit()
-{
+{
for (UINT i = 0; i < ftpList.size(); i++)
delete ftpList[i];
@@ -46,37 +45,37 @@ void ServerList::saveToDb() const
char buff[256];
mir_snprintf(buff, "Password%d", opt.selected);
- DB::setAStringF(0, MODULE, buff, opt.selected, ftp->szPass);
-
- DB::setStringF(0, MODULE, "Name%d", opt.selected, ftp->stzName);
- DB::setAStringF(0, MODULE, "Server%d", opt.selected, ftp->szServer);
- DB::setAStringF(0, MODULE, "User%d", opt.selected, ftp->szUser);
- DB::setAStringF(0, MODULE, "Url%d", opt.selected, ftp->szUrl);
- DB::setAStringF(0, MODULE, "Dir%d", opt.selected, ftp->szDir);
- DB::setAStringF(0, MODULE, "Chmod%d", opt.selected, ftp->szChmod);
- DB::setWordF(0, MODULE, "FtpProto%d", opt.selected, ftp->ftpProto);
- DB::setWordF(0, MODULE, "Port%d", opt.selected, ftp->iPort);
- DB::setByteF(0, MODULE, "Passive%d", opt.selected, ftp->bPassive);
- DB::setByteF(0, MODULE, "Enabled%d", opt.selected, ftp->bEnabled);
+ DB::setAStringF(0, MODULE, buff, opt.selected, ftp->m_szPass);
+
+ DB::setStringF(0, MODULE, "Name%d", opt.selected, ftp->m_stzName);
+ DB::setAStringF(0, MODULE, "Server%d", opt.selected, ftp->m_szServer);
+ DB::setAStringF(0, MODULE, "User%d", opt.selected, ftp->m_szUser);
+ DB::setAStringF(0, MODULE, "Url%d", opt.selected, ftp->m_szUrl);
+ DB::setAStringF(0, MODULE, "Dir%d", opt.selected, ftp->m_szDir);
+ DB::setAStringF(0, MODULE, "Chmod%d", opt.selected, ftp->m_szChmod);
+ DB::setWordF(0, MODULE, "FtpProto%d", opt.selected, ftp->m_ftpProto);
+ DB::setWordF(0, MODULE, "Port%d", opt.selected, ftp->m_iPort);
+ DB::setByteF(0, MODULE, "Passive%d", opt.selected, ftp->m_bPassive);
+ DB::setByteF(0, MODULE, "Enabled%d", opt.selected, ftp->m_bEnabled);
db_set_b(0, MODULE, "Selected", opt.selected);
db_set_b(0, MODULE, "Default", opt.defaultFTP);
}
ServerList::FTP::FTP(int index)
{
- if (DB::getStringF(0, MODULE, "Name%d", index, this->stzName))
- mir_sntprintf(this->stzName, _countof(this->stzName), TranslateT("FTP Server %d"), index + 1);
-
- DB::getAStringF(0, MODULE, "Password%d", index, this->szPass);
- DB::getAStringF(0, MODULE, "Server%d", index, this->szServer);
- DB::getAStringF(0, MODULE, "User%d", index, this->szUser);
- DB::getAStringF(0, MODULE, "Url%d", index, this->szUrl);
- DB::getAStringF(0, MODULE, "Dir%d", index, this->szDir);
- DB::getAStringF(0, MODULE, "Chmod%d", index, this->szChmod);
- this->ftpProto = (FTP::EProtoType)DB::getWordF(0, MODULE, "FtpProto%d", index, FTP::FT_STANDARD);
- this->iPort = DB::getWordF(0, MODULE, "Port%d", index, 21);
- this->bPassive = DB::getByteF(0, MODULE, "Passive%d", index, 0) ? true : false;
- this->bEnabled = DB::getByteF(0, MODULE, "Enabled%d", index, 0) ? true : false;
+ if (DB::getStringF(0, MODULE, "Name%d", index, m_stzName))
+ mir_sntprintf(m_stzName, _countof(m_stzName), TranslateT("FTP Server %d"), index + 1);
+
+ DB::getAStringF(0, MODULE, "Password%d", index, m_szPass);
+ DB::getAStringF(0, MODULE, "Server%d", index, m_szServer);
+ DB::getAStringF(0, MODULE, "User%d", index, m_szUser);
+ DB::getAStringF(0, MODULE, "Url%d", index, m_szUrl);
+ DB::getAStringF(0, MODULE, "Dir%d", index, m_szDir);
+ DB::getAStringF(0, MODULE, "Chmod%d", index, m_szChmod);
+ m_ftpProto = (FTP::EProtoType)DB::getWordF(0, MODULE, "FtpProto%d", index, FTP::FT_STANDARD);
+ m_iPort = DB::getWordF(0, MODULE, "Port%d", index, 21);
+ m_bPassive = DB::getByteF(0, MODULE, "Passive%d", index, 0) ? true : false;
+ m_bEnabled = DB::getByteF(0, MODULE, "Enabled%d", index, 0) ? true : false;
}
ServerList::FTP *ServerList::getSelected() const
@@ -86,22 +85,17 @@ ServerList::FTP *ServerList::getSelected() const
bool ServerList::FTP::isValid() const
{
- return (this->bEnabled &&
- this->szServer[0] &&
- this->szUser[0] &&
- this->szPass[0] &&
- this->szUrl[0]) ? true : false;
+ return (m_bEnabled && m_szServer[0] && m_szUser[0] && m_szPass[0] && m_szUrl[0]) ? true : false;
}
char *ServerList::FTP::getProtoString() const
{
- switch (this->ftpProto)
- {
- case FT_STANDARD:
- case FT_SSL_EXPLICIT: return "ftp://";
- case FT_SSL_IMPLICIT: return "ftps://";
- case FT_SSH: return "sftp://";
+ switch (m_ftpProto) {
+ case FT_STANDARD:
+ case FT_SSL_EXPLICIT: return "ftp://";
+ case FT_SSL_IMPLICIT: return "ftps://";
+ case FT_SSH: return "sftp://";
}
return NULL;
-} \ No newline at end of file
+}
diff --git a/plugins/FTPFileYM/src/serverlist.h b/plugins/FTPFileYM/src/serverlist.h
index b701b77127..d542ea6c07 100644
--- a/plugins/FTPFileYM/src/serverlist.h
+++ b/plugins/FTPFileYM/src/serverlist.h
@@ -39,17 +39,17 @@ public:
FT_SSH
};
- bool bEnabled;
- TCHAR stzName[64];
- char szServer[256];
- char szUser[64];
- char szPass[64];
- char szDir[64];
- char szChmod[256];
- char szUrl[256];
- EProtoType ftpProto;
- int iPort;
- bool bPassive;
+ bool m_bEnabled;
+ TCHAR m_stzName[64];
+ char m_szServer[256];
+ char m_szUser[64];
+ char m_szPass[64];
+ char m_szDir[64];
+ char m_szChmod[256];
+ char m_szUrl[256];
+ EProtoType m_ftpProto;
+ int m_iPort;
+ bool m_bPassive;
FTP(int index);
@@ -59,11 +59,11 @@ public:
static const int FTP_COUNT = 5;
- vector<FTP *> items;
+ vector<FTP *> m_items;
- FTP *operator[] (int i) const { return items[i]; };
- void add(FTP *newItem) { items.push_back(newItem); }
- size_t size() { return items.size(); }
+ 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()
{
@@ -76,4 +76,4 @@ public:
void deinit();
void saveToDb() const;
FTP *getSelected() const;
-}; \ No newline at end of file
+};
diff --git a/plugins/FTPFileYM/src/utils.cpp b/plugins/FTPFileYM/src/utils.cpp
index 861f2238ea..ad47a3badf 100644
--- a/plugins/FTPFileYM/src/utils.cpp
+++ b/plugins/FTPFileYM/src/utils.cpp
@@ -23,11 +23,10 @@ extern UploadDialog *uDlg;
int Utils::getDeleteTimeMin()
{
- switch (opt.timeRange)
- {
- case (Options::TR_MINUTES): return (opt.iDeleteTime);
- case (Options::TR_HOURS): return (opt.iDeleteTime * 60);
- case (Options::TR_DAYS): return (opt.iDeleteTime * 60 * 24);
+ switch (opt.timeRange) {
+ case (Options::TR_MINUTES) : return (opt.iDeleteTime);
+ case (Options::TR_HOURS) : return (opt.iDeleteTime * 60);
+ case (Options::TR_DAYS) : return (opt.iDeleteTime * 60 * 24);
}
return -1;
@@ -35,13 +34,13 @@ int Utils::getDeleteTimeMin()
int Utils::msgBox(TCHAR *stzMsg, UINT uType)
{
- HWND hwnd = (uDlg != NULL) ? uDlg->hwnd : 0;
+ HWND hwnd = (uDlg != NULL) ? uDlg->m_hwnd : 0;
return MessageBox(hwnd, stzMsg, TranslateT("FTP File"), uType);
}
int Utils::msgBoxA(char *szMsg, UINT uType)
{
- HWND hwnd = (uDlg != NULL) ? uDlg->hwnd : 0;
+ HWND hwnd = (uDlg != NULL) ? uDlg->m_hwnd : 0;
return MessageBoxA(hwnd, szMsg, Translate("FTP File"), uType);
}
@@ -52,17 +51,16 @@ HICON Utils::loadIconEx(char *szName)
return IcoLib_GetIcon(buff);
}
-TCHAR *Utils::getFileNameFromPath(TCHAR *stzPath)
+TCHAR* Utils::getFileNameFromPath(TCHAR *stzPath)
{
TCHAR *pch = _tcsrchr(stzPath, '\\');
if (pch) return pch + 1;
else return _T("file.zip");
}
-TCHAR *Utils::getTextFragment(TCHAR *stzText, size_t length, TCHAR *buff)
+TCHAR* Utils::getTextFragment(TCHAR *stzText, size_t length, TCHAR *buff)
{
- if (mir_tstrlen(stzText) > length)
- {
+ if (mir_tstrlen(stzText) > length) {
mir_tstrcpy(buff, stzText);
buff[length - 1] = 0;
mir_tstrcat(buff, _T("..."));
@@ -74,10 +72,8 @@ TCHAR *Utils::getTextFragment(TCHAR *stzText, size_t length, TCHAR *buff)
void Utils::copyToClipboard(char *szText)
{
- if (szText)
- {
- if (OpenClipboard(NULL))
- {
+ if (szText) {
+ if (OpenClipboard(NULL)) {
EmptyClipboard();
HGLOBAL hClipboardData = GlobalAlloc(GMEM_DDESHARE, 1024);
char *pchData = (char *)GlobalLock(hClipboardData);
@@ -90,19 +86,16 @@ void Utils::copyToClipboard(char *szText)
}
const char from_chars[] = "àáâãäå¸æçèéêëìíîïðñòóôõö÷øùúûüýþÿÀÁÂÃÄŨÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß !@#$%^&=,{}[];'`";
-const char to_chars[] = "abvgdeezziiklmnoprstufhccwwqyqeuaABVGDEEZZIIKLMNOPRSTUFHCCWWQYQEUA_________________";
+const char to_chars[] = "abvgdeezziiklmnoprstufhccwwqyqeuaABVGDEEZZIIKLMNOPRSTUFHCCWWQYQEUA_________________";
char* Utils::makeSafeString(TCHAR *input, char *output)
{
char *buff = mir_t2a(input);
size_t length = mir_strlen(buff);
- for (UINT i = 0; i < length; i++)
- {
- for (int j = 0; from_chars[j] != 0; j++)
- {
- if (buff[i] == from_chars[j])
- {
+ for (UINT i = 0; i < length; i++) {
+ for (int j = 0; from_chars[j] != 0; j++) {
+ if (buff[i] == from_chars[j]) {
buff[i] = to_chars[j];
break;
}
@@ -125,32 +118,30 @@ void Utils::curlSetOpt(CURL *hCurl, ServerList::FTP *ftp, char *url, struct curl
curl_easy_setopt(hCurl, CURLOPT_NOPROGRESS, 1);
curl_easy_setopt(hCurl, CURLOPT_URL, url);
- curl_easy_setopt(hCurl, CURLOPT_PORT, ftp->iPort);
+ curl_easy_setopt(hCurl, CURLOPT_PORT, ftp->m_iPort);
curl_easy_setopt(hCurl, CURLOPT_CONNECTTIMEOUT, 30);
curl_easy_setopt(hCurl, CURLOPT_FTP_RESPONSE_TIMEOUT, 20);
curl_easy_setopt(hCurl, CURLOPT_FTP_USE_EPRT, 0);
curl_easy_setopt(hCurl, CURLOPT_FTP_USE_EPSV, 0);
- if (ftp->bPassive)
+ if (ftp->m_bPassive)
curl_easy_setopt(hCurl, CURLOPT_FTPPORT, 0);
else if (!DB::getAString(0, MODULE, "LocalIP", buff))
curl_easy_setopt(hCurl, CURLOPT_FTPPORT, buff);
else
curl_easy_setopt(hCurl, CURLOPT_FTPPORT, "-");
- mir_snprintf(buff, "%s:%s", ftp->szUser, ftp->szPass);
+ mir_snprintf(buff, "%s:%s", ftp->m_szUser, ftp->m_szPass);
curl_easy_setopt(hCurl, CURLOPT_USERPWD, buff);
- if (ftp->ftpProto == ServerList::FTP::FT_SSL_EXPLICIT || ftp->ftpProto == ServerList::FTP::FT_SSL_IMPLICIT)
- {
+ if (ftp->m_ftpProto == ServerList::FTP::FT_SSL_EXPLICIT || ftp->m_ftpProto == ServerList::FTP::FT_SSL_IMPLICIT) {
curl_easy_setopt(hCurl, CURLOPT_USE_SSL, CURLUSESSL_ALL);
curl_easy_setopt(hCurl, CURLOPT_FTPSSLAUTH, CURLFTPAUTH_DEFAULT);
curl_easy_setopt(hCurl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(hCurl, CURLOPT_SSL_VERIFYHOST, 2);
}
- else if (ftp->ftpProto == ServerList::FTP::FT_SSH)
- {
+ else if (ftp->m_ftpProto == ServerList::FTP::FT_SSH) {
curl_easy_setopt(hCurl, CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_PASSWORD);
}
}
@@ -159,41 +150,33 @@ INT_PTR CALLBACK Utils::DlgProcSetFileName(HWND hwndDlg, UINT msg, WPARAM wParam
{
TCHAR *fileName = (TCHAR *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- fileName = (TCHAR *)lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)fileName);
- SetDlgItemText(hwndDlg, IDC_NAME, fileName);
-
- if (GetDlgCtrlID((HWND)wParam) != IDC_NAME)
- {
- SetFocus(GetDlgItem(hwndDlg, IDC_NAME));
- SendDlgItemMessage(hwndDlg, IDC_NAME, EM_SETSEL, 0, mir_tstrlen(fileName) - 4);
- return FALSE;
- }
-
- return TRUE;
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ fileName = (TCHAR *)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)fileName);
+ SetDlgItemText(hwndDlg, IDC_NAME, fileName);
+
+ if (GetDlgCtrlID((HWND)wParam) != IDC_NAME) {
+ SetFocus(GetDlgItem(hwndDlg, IDC_NAME));
+ SendDlgItemMessage(hwndDlg, IDC_NAME, EM_SETSEL, 0, mir_tstrlen(fileName) - 4);
+ return FALSE;
}
- case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED)
- {
- if (LOWORD(wParam) == IDOK)
- {
- GetDlgItemText(hwndDlg, IDC_NAME, fileName, 64);
- EndDialog(hwndDlg, IDOK);
- }
- else if (LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hwndDlg, IDCANCEL);
- }
- }
- break;
+ return TRUE;
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) == BN_CLICKED) {
+ if (LOWORD(wParam) == IDOK) {
+ GetDlgItemText(hwndDlg, IDC_NAME, fileName, 64);
+ EndDialog(hwndDlg, IDOK);
+ }
+ else if (LOWORD(wParam) == IDCANCEL) {
+ EndDialog(hwndDlg, IDCANCEL);
+ }
}
+
+ break;
}
return FALSE;
@@ -215,8 +198,7 @@ bool Utils::setFileNameDlgA(char *nameBuff)
FREE(tmp);
bool res = setFileNameDlg(buff);
- if (res)
- {
+ if (res) {
char *p = mir_t2a(buff);
mir_strcpy(nameBuff, p);
FREE(p);
@@ -231,4 +213,4 @@ void Utils::createFileDownloadLink(char *szUrl, char *fileName, char *buff, int
mir_snprintf(buff, buffSize, "%s%s", szUrl, fileName);
else
mir_snprintf(buff, buffSize, "%s/%s", szUrl, fileName);
-} \ No newline at end of file
+}
diff --git a/plugins/FTPFileYM/src/version.h b/plugins/FTPFileYM/src/version.h
index 9175f8296e..ebfb4104cf 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 1
+#define __BUILD_NUM 2
#include <stdver.h>