From 1776597017e7a8c0565cc84ac30591159936902e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 14 Jul 2014 15:16:35 +0000 Subject: 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 --- src/core/stdfile/filerecvdlg.cpp | 54 +++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 31 deletions(-) (limited to 'src') 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) -- cgit v1.2.3