From b81ce648978e75bc7db4cc3b8aa7d1b9fcb9239b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 21 Jun 2015 22:00:16 +0000 Subject: MS_UTILS_REPLACEVARS -> Utils_ReplaceVars git-svn-id: http://svn.miranda-ng.org/main/trunk@14316 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Exchange/src/emails.cpp | 3 +- plugins/PluginUpdater/src/Utils.cpp | 13 +++--- plugins/Quotes/src/SettingsDlg.cpp | 9 +--- plugins/Scriver/src/chat/options.cpp | 79 +++++++++++++++++----------------- plugins/TabSRMM/src/chat/options.cpp | 70 +++++++++++++++--------------- plugins/UserGuide/src/main.cpp | 8 +--- plugins/Utils.pas/mirutils.pas | 25 ++--------- plugins/Variables/src/parse_system.cpp | 8 +--- plugins/mRadio/rglobal.pas | 6 +-- 9 files changed, 90 insertions(+), 131 deletions(-) (limited to 'plugins') diff --git a/plugins/Exchange/src/emails.cpp b/plugins/Exchange/src/emails.cpp index c362ac3852..a2669f7abb 100644 --- a/plugins/Exchange/src/emails.cpp +++ b/plugins/Exchange/src/emails.cpp @@ -62,8 +62,7 @@ int CExchangeServer::Connect(int bForceConnect) TCHAR server[1024]; GetStringFromDatabase("Username", _T(""), user, _countof(user)); - if (ServiceExists(MS_UTILS_REPLACEVARS)) - _tcsncpy_s(user, VARST(user), _TRUNCATE); + _tcsncpy_s(user, VARST(user), _TRUNCATE); GetStringFromDatabase("Password", _T(""), password, _countof(password)); GetStringFromDatabase("Server", _T(""), server, _countof(server)); diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index 1ea04d468d..296fe7ffb6 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -113,18 +113,15 @@ int CompareHashes(const ServListEntry *p1, const ServListEntry *p2) bool ParseHashes(const TCHAR *ptszUrl, ptrT &baseUrl, SERVLIST &arHashes) { REPLACEVARSARRAY vars[2]; - vars[0].lptzKey = _T("platform"); + vars[0].key.t = _T("platform"); #ifdef _WIN64 - vars[0].lptzValue = _T("64"); + vars[0].value.t = _T("64"); #else - vars[0].lptzValue = _T("32"); + vars[0].value.t = _T("32"); #endif - vars[1].lptzKey = vars[1].lptzValue = 0; + vars[1].key.t = vars[1].value.t = 0; - REPLACEVARSDATA dat = { sizeof(REPLACEVARSDATA) }; - dat.dwFlags = RVF_TCHAR; - dat.variables = vars; - baseUrl = (TCHAR*)CallService(MS_UTILS_REPLACEVARS, (WPARAM)ptszUrl, (LPARAM)&dat); + baseUrl = Utils_ReplaceVarsT(ptszUrl, 0, vars); // Download version info FILEURL pFileUrl; diff --git a/plugins/Quotes/src/SettingsDlg.cpp b/plugins/Quotes/src/SettingsDlg.cpp index 268b9a1c1b..501b3b7aef 100644 --- a/plugins/Quotes/src/SettingsDlg.cpp +++ b/plugins/Quotes/src/SettingsDlg.cpp @@ -1070,14 +1070,9 @@ tstring GenerateLogFileName(const tstring& rsLogFilePattern, } } - if (nFlags&glfnResolveUserProfile) + if (nFlags & glfnResolveUserProfile) { - REPLACEVARSDATA dat = { 0 }; - dat.cbSize = sizeof(dat); - dat.dwFlags = RVF_TCHAR; - - TCHAR* ptszParsedName = reinterpret_cast(CallService(MS_UTILS_REPLACEVARS, - reinterpret_cast(sPath.c_str()), reinterpret_cast(&dat))); + TCHAR* ptszParsedName = Utils_ReplaceVarsT(sPath.c_str()); if (ptszParsedName) { sPath = ptszParsedName; diff --git a/plugins/Scriver/src/chat/options.cpp b/plugins/Scriver/src/chat/options.cpp index 3005ae0dd6..57dccf89b9 100644 --- a/plugins/Scriver/src/chat/options.cpp +++ b/plugins/Scriver/src/chat/options.cpp @@ -361,46 +361,45 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lPa PathToRelativeT(g_Settings.pszLogDir, tszTemp); SetDlgItemText(hwndDlg, IDC_CHAT_LOGDIRECTORY, tszTemp); } - if (ServiceExists(MS_UTILS_REPLACEVARS)) { - TCHAR tszTooltipText[2048]; - RECT rect; - - mir_sntprintf(tszTooltipText, _countof(tszTooltipText), - _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") - _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") - _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"), - // contact vars - _T("%nick%"), TranslateT("nick of current contact (if defined)"), - _T("%proto%"), TranslateT("protocol name of current contact (if defined). Account name is used when protocol supports multiple accounts"), - _T("%accountname%"), TranslateT("user-defined account name of current contact (if defined)."), - _T("%userid%"), TranslateT("user ID of current contact (if defined). It is like UIN for ICQ, JID for Jabber, etc."), - // global vars - _T("%miranda_path%"), TranslateT("path to Miranda root folder"), - _T("%miranda_profilesdir%"), TranslateT("path to folder containing Miranda profiles"), - _T("%miranda_profilename%"), TranslateT("name of current Miranda profile (filename, without extension)"), - _T("%miranda_userdata%"), TranslateT("will return parsed string %miranda_profilesdir%\\%miranda_profilename%"), - _T("%miranda_logpath%"), TranslateT("will return parsed string %miranda_userdata%\\Logs"), - _T("%appdata%"), TranslateT("same as environment variable %APPDATA% for currently logged-on Windows user"), - _T("%username%"), TranslateT("username for currently logged-on Windows user"), - _T("%mydocuments%"), TranslateT("\"My Documents\" folder for currently logged-on Windows user"), - _T("%desktop%"), TranslateT("\"Desktop\" folder for currently logged-on Windows user"), - _T("%xxxxxxx%"), TranslateT("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)"), - // date/time vars - _T("%d%"), TranslateT("day of month, 1-31"), - _T("%dd%"), TranslateT("day of month, 01-31"), - _T("%m%"), TranslateT("month number, 1-12"), - _T("%mm%"), TranslateT("month number, 01-12"), - _T("%mon%"), TranslateT("abbreviated month name"), - _T("%month%"), TranslateT("full month name"), - _T("%yy%"), TranslateT("year without century, 01-99"), - _T("%yyyy%"), TranslateT("year with century, 1901-9999"), - _T("%wday%"), TranslateT("abbreviated weekday name"), - _T("%weekday%"), TranslateT("full weekday name")); - GetClientRect (GetDlgItem(hwndDlg, IDC_CHAT_LOGDIRECTORY), &rect); - rect.left = -85; - hPathTip = CreateToolTip(GetDlgItem(hwndDlg, IDC_CHAT_LOGDIRECTORY), tszTooltipText, TranslateT("Variables"), &rect); - SetTimer(hwndDlg, 0, 3000, NULL); - } + + TCHAR tszTooltipText[2048]; + RECT rect; + + mir_sntprintf(tszTooltipText, _countof(tszTooltipText), + _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") + _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") + _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"), + // contact vars + _T("%nick%"), TranslateT("nick of current contact (if defined)"), + _T("%proto%"), TranslateT("protocol name of current contact (if defined). Account name is used when protocol supports multiple accounts"), + _T("%accountname%"), TranslateT("user-defined account name of current contact (if defined)."), + _T("%userid%"), TranslateT("user ID of current contact (if defined). It is like UIN for ICQ, JID for Jabber, etc."), + // global vars + _T("%miranda_path%"), TranslateT("path to Miranda root folder"), + _T("%miranda_profilesdir%"), TranslateT("path to folder containing Miranda profiles"), + _T("%miranda_profilename%"), TranslateT("name of current Miranda profile (filename, without extension)"), + _T("%miranda_userdata%"), TranslateT("will return parsed string %miranda_profilesdir%\\%miranda_profilename%"), + _T("%miranda_logpath%"), TranslateT("will return parsed string %miranda_userdata%\\Logs"), + _T("%appdata%"), TranslateT("same as environment variable %APPDATA% for currently logged-on Windows user"), + _T("%username%"), TranslateT("username for currently logged-on Windows user"), + _T("%mydocuments%"), TranslateT("\"My Documents\" folder for currently logged-on Windows user"), + _T("%desktop%"), TranslateT("\"Desktop\" folder for currently logged-on Windows user"), + _T("%xxxxxxx%"), TranslateT("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)"), + // date/time vars + _T("%d%"), TranslateT("day of month, 1-31"), + _T("%dd%"), TranslateT("day of month, 01-31"), + _T("%m%"), TranslateT("month number, 1-12"), + _T("%mm%"), TranslateT("month number, 01-12"), + _T("%mon%"), TranslateT("abbreviated month name"), + _T("%month%"), TranslateT("full month name"), + _T("%yy%"), TranslateT("year without century, 01-99"), + _T("%yyyy%"), TranslateT("year with century, 1901-9999"), + _T("%wday%"), TranslateT("abbreviated weekday name"), + _T("%weekday%"), TranslateT("full weekday name")); + GetClientRect(GetDlgItem(hwndDlg, IDC_CHAT_LOGDIRECTORY), &rect); + rect.left = -85; + hPathTip = CreateToolTip(GetDlgItem(hwndDlg, IDC_CHAT_LOGDIRECTORY), tszTooltipText, TranslateT("Variables"), &rect); + SetTimer(hwndDlg, 0, 3000, NULL); SetDlgItemText(hwndDlg, IDC_CHAT_HIGHLIGHTWORDS, g_Settings.pszHighlightWords); SetDlgItemText(hwndDlg, IDC_CHAT_LOGTIMESTAMP, g_Settings.pszTimeStampLog); diff --git a/plugins/TabSRMM/src/chat/options.cpp b/plugins/TabSRMM/src/chat/options.cpp index 791b695f5b..6aee911b79 100644 --- a/plugins/TabSRMM/src/chat/options.cpp +++ b/plugins/TabSRMM/src/chat/options.cpp @@ -689,42 +689,40 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM SendDlgItemMessage(hwndDlg, IDC_CHAT_SPIN4, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, CHAT_MODULE, "LoggingLimit", 100), 0)); Utils::enableDlgControl(hwndDlg, IDC_LIMIT, g_Settings.bLoggingEnabled); - if (ServiceExists(MS_UTILS_REPLACEVARS)) { - TCHAR tszTooltipText[2048]; - - mir_sntprintf(tszTooltipText, _countof(tszTooltipText), - _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") - _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") - _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"), - // contact vars - _T("%nick%"), TranslateT("nick of current contact (if defined)"), - _T("%proto%"), TranslateT("protocol name of current contact (if defined). Account name is used when protocol supports multiple accounts"), - _T("%accountname%"), TranslateT("user-defined account name of current contact (if defined)."), - _T("%userid%"), TranslateT("user ID of current contact (if defined). It is like UIN for ICQ, JID for Jabber, etc."), - // global vars - _T("%miranda_path%"), TranslateT("path to Miranda root folder"), - _T("%miranda_profilesdir%"), TranslateT("path to folder containing Miranda profiles"), - _T("%miranda_profilename%"), TranslateT("name of current Miranda profile (filename, without extension)"), - _T("%miranda_userdata%"), TranslateT("will return parsed string %miranda_profilesdir%\\%miranda_profilename%"), - _T("%miranda_logpath%"), TranslateT("will return parsed string %miranda_userdata%\\Logs"), - _T("%appdata%"), TranslateT("same as environment variable %APPDATA% for currently logged-on Windows user"), - _T("%username%"), TranslateT("username for currently logged-on Windows user"), - _T("%mydocuments%"), TranslateT("\"My Documents\" folder for currently logged-on Windows user"), - _T("%desktop%"), TranslateT("\"Desktop\" folder for currently logged-on Windows user"), - _T("%xxxxxxx%"), TranslateT("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)"), - // date/time vars - _T("%d%"), TranslateT("day of month, 1-31"), - _T("%dd%"), TranslateT("day of month, 01-31"), - _T("%m%"), TranslateT("month number, 1-12"), - _T("%mm%"), TranslateT("month number, 01-12"), - _T("%mon%"), TranslateT("abbreviated month name"), - _T("%month%"), TranslateT("full month name"), - _T("%yy%"), TranslateT("year without century, 01-99"), - _T("%yyyy%"), TranslateT("year with century, 1901-9999"), - _T("%wday%"), TranslateT("abbreviated weekday name"), - _T("%weekday%"), TranslateT("full weekday name")); - hPathTip = CreateToolTip(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), tszTooltipText, TranslateT("Variables")); - } + TCHAR tszTooltipText[2048]; + + mir_sntprintf(tszTooltipText, _countof(tszTooltipText), + _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") + _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n\n") + _T("%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s\n%s - %s"), + // contact vars + _T("%nick%"), TranslateT("nick of current contact (if defined)"), + _T("%proto%"), TranslateT("protocol name of current contact (if defined). Account name is used when protocol supports multiple accounts"), + _T("%accountname%"), TranslateT("user-defined account name of current contact (if defined)."), + _T("%userid%"), TranslateT("user ID of current contact (if defined). It is like UIN for ICQ, JID for Jabber, etc."), + // global vars + _T("%miranda_path%"), TranslateT("path to Miranda root folder"), + _T("%miranda_profilesdir%"), TranslateT("path to folder containing Miranda profiles"), + _T("%miranda_profilename%"), TranslateT("name of current Miranda profile (filename, without extension)"), + _T("%miranda_userdata%"), TranslateT("will return parsed string %miranda_profilesdir%\\%miranda_profilename%"), + _T("%miranda_logpath%"), TranslateT("will return parsed string %miranda_userdata%\\Logs"), + _T("%appdata%"), TranslateT("same as environment variable %APPDATA% for currently logged-on Windows user"), + _T("%username%"), TranslateT("username for currently logged-on Windows user"), + _T("%mydocuments%"), TranslateT("\"My Documents\" folder for currently logged-on Windows user"), + _T("%desktop%"), TranslateT("\"Desktop\" folder for currently logged-on Windows user"), + _T("%xxxxxxx%"), TranslateT("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)"), + // date/time vars + _T("%d%"), TranslateT("day of month, 1-31"), + _T("%dd%"), TranslateT("day of month, 01-31"), + _T("%m%"), TranslateT("month number, 1-12"), + _T("%mm%"), TranslateT("month number, 01-12"), + _T("%mon%"), TranslateT("abbreviated month name"), + _T("%month%"), TranslateT("full month name"), + _T("%yy%"), TranslateT("year without century, 01-99"), + _T("%yyyy%"), TranslateT("year with century, 1901-9999"), + _T("%wday%"), TranslateT("abbreviated weekday name"), + _T("%weekday%"), TranslateT("full weekday name")); + hPathTip = CreateToolTip(GetDlgItem(hwndDlg, IDC_LOGDIRECTORY), tszTooltipText, TranslateT("Variables")); } if (hPathTip) SetTimer(hwndDlg, 0, 3000, NULL); diff --git a/plugins/UserGuide/src/main.cpp b/plugins/UserGuide/src/main.cpp index d47ffad71d..4ca983f323 100644 --- a/plugins/UserGuide/src/main.cpp +++ b/plugins/UserGuide/src/main.cpp @@ -57,12 +57,8 @@ static INT_PTR ShowGuideFile(WPARAM, LPARAM) mir_free(ptszHelpFile); } LPTSTR pszDirNameEx; - if (ServiceExists(MS_UTILS_REPLACEVARS)) { - pszDirNameEx = Utils_ReplaceVarsT(pszDirName); - mir_free(pszDirName); - } - else - pszDirNameEx = pszDirName; + pszDirNameEx = Utils_ReplaceVarsT(pszDirName); + mir_free(pszDirName); ShellExecute(NULL, _T("open"), pszFileName, NULL, pszDirNameEx, SW_SHOW); mir_free(pszFileName); diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas index 16d92a3cec..0b5fe5be68 100644 --- a/plugins/Utils.pas/mirutils.pas +++ b/plugins/Utils.pas/mirutils.pas @@ -146,19 +146,11 @@ function ParseVarString(astr:PAnsiChar;aContact:TMCONTACT=0;extra:PAnsiChar=nil) var tfi:TFORMATINFO; tmp,pc:PAnsiChar; - dat:TREPLACEVARSDATA; begin if (astr=nil) or (astr^=#0) then exit; - if ServiceExists(MS_UTILS_REPLACEVARS)<>0 then - begin - FillChar(dat,SizeOf(TREPLACEVARSDATA),0); - dat.cbSize :=SizeOf(TREPLACEVARSDATA); - pc:=PAnsiChar(CallService(MS_UTILS_REPLACEVARS,wparam(astr),lparam(@dat))); - astr:=pc; - end - else - pc:=nil; + pc:=Utils_ReplaceVars(astr); + astr:=pc; if isVarsInstalled then begin @@ -185,20 +177,11 @@ function ParseVarString(astr:PWideChar;aContact:TMCONTACT=0;extra:PWideChar=nil) var tfi:TFORMATINFO; tmp,pc:PWideChar; - dat:TREPLACEVARSDATA; begin if (astr=nil) or (astr^=#0) then exit; - if ServiceExists(MS_UTILS_REPLACEVARS)<>0 then - begin - FillChar(dat,SizeOf(TREPLACEVARSDATA),0); - dat.cbSize :=SizeOf(TREPLACEVARSDATA); - dat.dwflags:=RVF_UNICODE; - pc:=PWideChar(CallService(MS_UTILS_REPLACEVARS,wparam(astr),lparam(@dat))); - astr:=pc; - end - else - pc:=nil; + pc:=Utils_ReplaceVarsW(astr); + astr:=pc; if isVarsInstalled then begin diff --git a/plugins/Variables/src/parse_system.cpp b/plugins/Variables/src/parse_system.cpp index 5b63678750..0f13c1f926 100644 --- a/plugins/Variables/src/parse_system.cpp +++ b/plugins/Variables/src/parse_system.cpp @@ -894,12 +894,8 @@ void registerSystemTokens() registerIntToken(TXTFILE, parseTextFile, TRF_FUNCTION, LPGEN("System Functions")"\t(x,y)\t"LPGEN("y > 0: line number y from file x, y = 0: the whole file, y < 0: line y counted from the end, y = r: random line")); registerIntToken(UPTIME, parseUpTime, TRF_FIELD, LPGEN("System Functions")"\t"LPGEN("uptime in seconds")); - if (!ServiceExists(MS_UTILS_REPLACEVARS)) - registerIntToken(ENVIRONMENTVARIABLE, parseEnvironmentVariable, TRF_FUNCTION, LPGEN("Miranda Core OS")"\t(%xxxxxxx%)\t"LPGEN("any environment variable defined in current Windows session (like %systemroot%, %allusersprofile%, etc.)")); - else { - registerIntToken(ENVIRONMENTVARIABLE, parseEnvironmentVariable, TRF_FUNCTION, LPGEN("System Functions")"\t(x)\t"LPGEN("expand environment variable x")); - registerIntToken(USERNAME, parseUserName, TRF_FIELD, LPGEN("System Functions")"\t"LPGEN("user name")); - } + registerIntToken(ENVIRONMENTVARIABLE, parseEnvironmentVariable, TRF_FUNCTION, LPGEN("System Functions")"\t(x)\t"LPGEN("expand environment variable x")); + registerIntToken(USERNAME, parseUserName, TRF_FIELD, LPGEN("System Functions")"\t"LPGEN("user name")); srand((unsigned int)GetTickCount()); diff --git a/plugins/mRadio/rglobal.pas b/plugins/mRadio/rglobal.pas index 07f3978dda..a6bccaa98f 100644 --- a/plugins/mRadio/rglobal.pas +++ b/plugins/mRadio/rglobal.pas @@ -226,15 +226,11 @@ end; function GetDefaultRecPath:pWideChar; var - dat:TREPLACEVARSDATA; mstr,szData:pWideChar; buf:array [0..MAX_PATH-1] of WideChar; begin - FillChar(dat,SizeOf(dat),0); - dat.cbSize :=SizeOf(TREPLACEVARSDATA); - dat.dwFlags:=RVF_UNICODE; szData:='%miranda_userdata%'+'\'+cPluginName; - mstr:=pWideChar(CallService(MS_UTILS_REPLACEVARS, WPARAM(szData), LPARAM(@dat))); + mstr:=Utils_ReplaceVarsW(szData); PathToRelativeW(mstr,buf); StrDupW(result,buf); mir_free(mstr); -- cgit v1.2.3