summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-07-14 15:16:35 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-07-14 15:16:35 +0000
commit1776597017e7a8c0565cc84ac30591159936902e (patch)
tree7c3d369c1dd245299c6075fa1846cc3f7ecf0c5e /src
parent26950a6982ca08e78c9e28dba8bbcc7d60768d65 (diff)
StdFile to get the incoming files folder's name via metacontact
git-svn-id: http://svn.miranda-ng.org/main/trunk@9796 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/core/stdfile/filerecvdlg.cpp54
1 files changed, 23 insertions, 31 deletions
diff --git a/src/core/stdfile/filerecvdlg.cpp b/src/core/stdfile/filerecvdlg.cpp
index e952632e8c..c8dba320ee 100644
--- a/src/core/stdfile/filerecvdlg.cpp
+++ b/src/core/stdfile/filerecvdlg.cpp
@@ -130,22 +130,18 @@ static void patchDir(TCHAR *str, size_t strSize)
void GetContactReceivedFilesDir(MCONTACT hContact, TCHAR *szDir, int cchDir, BOOL patchVars)
{
- DBVARIANT dbv;
- TCHAR szTemp[MAX_PATH];
- szTemp[0] = 0;
-
- if (!db_get_ts(NULL, "SRFile", "RecvFilesDirAdv", &dbv)) {
- if (lstrlen(dbv.ptszVal) > 0)
- lstrcpyn(szTemp, dbv.ptszVal, SIZEOF(szTemp));
- db_free(&dbv);
- }
-
- if (!szTemp[0])
-
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files"));
+ TCHAR tszTemp[MAX_PATH];
+ ptrT tszRecvPath(db_get_tsa(NULL, "SRFile", "RecvFilesDirAdv"));
+ if (tszRecvPath)
+ _tcsncpy_s(tszTemp, SIZEOF(tszTemp), tszRecvPath, _TRUNCATE);
+ else
+ mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files"));
if (hContact) {
+ if (db_mc_isSub(hContact))
+ hContact = db_mc_getMeta(hContact);
+
REPLACEVARSDATA dat = { 0 };
REPLACEVARSARRAY rvaVarsToReplace[4];
rvaVarsToReplace[0].lptzKey = _T("nick");
@@ -163,9 +159,9 @@ void GetContactReceivedFilesDir(MCONTACT hContact, TCHAR *szDir, int cchDir, BOO
dat.dwFlags = RVF_TCHAR;
dat.variables = rvaVarsToReplace;
dat.hContact = hContact;
- TCHAR *result = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)szTemp, (LPARAM)&dat);
+ TCHAR *result = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)tszTemp, (LPARAM)&dat);
if (result) {
- _tcsncpy(szTemp, result, SIZEOF(szTemp));
+ _tcsncpy(tszTemp, result, SIZEOF(tszTemp));
mir_free(result);
for (int i = 0; i < (SIZEOF(rvaVarsToReplace) - 1); i++)
mir_free(rvaVarsToReplace[i].lptzValue);
@@ -173,28 +169,24 @@ void GetContactReceivedFilesDir(MCONTACT hContact, TCHAR *szDir, int cchDir, BOO
}
if (patchVars)
- patchDir(szTemp, SIZEOF(szTemp));
- RemoveInvalidPathChars(szTemp);
- lstrcpyn(szDir, szTemp, cchDir);
+ patchDir(tszTemp, SIZEOF(tszTemp));
+ RemoveInvalidPathChars(tszTemp);
+ lstrcpyn(szDir, tszTemp, cchDir);
}
void GetReceivedFilesDir(TCHAR *szDir, int cchDir)
{
- TCHAR szTemp[MAX_PATH]; szTemp[0] = 0;
-
- DBVARIANT dbv;
- if (!db_get_ts(NULL, "SRFile", "RecvFilesDirAdv", &dbv)) {
- if (lstrlen(dbv.ptszVal) > 0)
- lstrcpyn(szTemp, dbv.ptszVal, SIZEOF(szTemp));
- db_free(&dbv);
- }
+ TCHAR tszTemp[MAX_PATH];
- if (!szTemp[0])
- mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%%mydocuments%%\\%s"), TranslateT("My received files"));
+ ptrT tszRecvPath(db_get_tsa(NULL, "SRFile", "RecvFilesDirAdv"));
+ if (tszRecvPath)
+ _tcsncpy_s(tszTemp, SIZEOF(tszTemp), tszRecvPath, _TRUNCATE);
+ else
+ mir_sntprintf(tszTemp, SIZEOF(tszTemp), _T("%%mydocuments%%\\%s\\%%userid%%"), TranslateT("My received files"));
- patchDir(szTemp, SIZEOF(szTemp));
- RemoveInvalidPathChars(szTemp);
- lstrcpyn(szDir, szTemp, cchDir);
+ patchDir(tszTemp, SIZEOF(tszTemp));
+ RemoveInvalidPathChars(tszTemp);
+ lstrcpyn(szDir, tszTemp, cchDir);
}
INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)