void ReplaceVars(XSTATUSCHANGE *xsc , TCHAR *Template, TCHAR *delimiter, TCHAR *buff) { buff[0] = 0; TCHAR *pch = _tcschr(Template, _T('%')); while (pch != NULL) { size_t len = _tcslen(buff); _tcsncat(buff, Template, pch - Template); buff[len + pch - Template] = 0; if (pch[1] == _T('N') || pch[1] == _T('T') || pch[1] == _T('I') || pch[1] == _T('D') || pch[1] == _T('B')) { switch (pch[1]) { case _T('N'): { TCHAR stzType[32]; _tcscat(buff, GetStatusTypeAsString(xsc->type, stzType)); } break; case _T('T'): if (xsc->stzTitle) _tcscat(buff, xsc->stzTitle); break; case _T('I'): if (xsc->stzText) _tcscat(buff, xsc->stzText); break; case _T('D'): if (xsc->stzText) { if (_tcscmp(delimiter, _T("%B")) == 0) _tcscat(buff, _T("\r\n")); else _tcscat(buff, delimiter); } break; case _T('B'): _tcscat(buff, _T("\r\n")); break; } Template = pch + 2; } else { _tcscat(buff, _T("%")); Template = pch + 1; } pch = _tcschr(Template, _T('%')); } // append rest of the text if (Template != NULL) _tcscat(buff, Template); }
void LogChangeToFile(XSTATUSCHANGE *xsc) { TCHAR stzName[256], stzType[32]; TCHAR stzDate[32], stzTime[32]; TCHAR stzText[MAX_TEXT_LEN]; GetStatusTypeAsString(xsc->type, stzType); _tcscpy(stzName, (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)xsc->hContact, GCDNF_TCHAR)); GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL,_T("HH':'mm"), stzTime, SIZEOF(stzTime)); GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL,_T("dd/MM/yyyy"), stzDate, SIZEOF(stzDate)); if (xsc->action == NOTIFY_REMOVE) mir_sntprintf(stzText, SIZEOF(stzText), TranslateT("%s, %s. %s removed %s.\r\n"), stzDate, stzTime, stzName, stzType); else mir_sntprintf(stzText, SIZEOF(stzText), TranslateT("%s, %s. %s changed %s to: %s.\r\n"), stzDate, stzTime, stzName, stzType, xsc->stzTitle); LogToFile(stzText); }