diff options
author | George Hazan <george.hazan@gmail.com> | 2015-08-26 17:25:14 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-08-26 17:25:14 +0000 |
commit | 6a1a045e620dba38a7a64070af59d1a91b104921 (patch) | |
tree | a883339faf5d30db219509d86acb090eae77e2b6 /plugins/FTPFileYM/src/utils.cpp | |
parent | 1c023b4c677e8dcf0a776b07d8679a6464d2ee61 (diff) |
massive code cleaning due to numerous name conflicts
git-svn-id: http://svn.miranda-ng.org/main/trunk@15036 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/FTPFileYM/src/utils.cpp')
-rw-r--r-- | plugins/FTPFileYM/src/utils.cpp | 110 |
1 files changed, 46 insertions, 64 deletions
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 +}
|