diff options
Diffstat (limited to 'plugins/TipperYM/src/subst.cpp')
-rw-r--r-- | plugins/TipperYM/src/subst.cpp | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp index 071e73c212..bbcce4b4e7 100644 --- a/plugins/TipperYM/src/subst.cpp +++ b/plugins/TipperYM/src/subst.cpp @@ -85,7 +85,7 @@ void StripBBCodesInPlace(wchar_t *ptszText) return; size_t iRead = 0, iWrite = 0; - size_t iLen = mir_tstrlen(ptszText); + size_t iLen = mir_wstrlen(ptszText); while(iRead <= iLen) { // copy terminating null too while (iRead <= iLen && ptszText[iRead] != '[') { @@ -174,7 +174,7 @@ wchar_t* GetLastMessageText(MCONTACT hContact, bool received) return 0; wchar_t *buff = DbGetEventTextT( &dbei, CP_ACP ); - wchar_t *swzMsg = mir_tstrdup(buff); + wchar_t *swzMsg = mir_wstrdup(buff); mir_free(buff); StripBBCodesInPlace(swzMsg); @@ -221,8 +221,8 @@ wchar_t* GetStatusMessageText(MCONTACT hContact) return NULL; if (!db_get_ts(hContact, MODULE, "TempStatusMsg", &dbv)) { - if (mir_tstrlen(dbv.ptszVal) != 0) - swzMsg = mir_tstrdup(dbv.ptszVal); + if (mir_wstrlen(dbv.ptszVal) != 0) + swzMsg = mir_wstrdup(dbv.ptszVal); db_free(&dbv); } } @@ -233,8 +233,8 @@ wchar_t* GetStatusMessageText(MCONTACT hContact) return NULL; if (!db_get_ts(hContact, "CList", "StatusMsg", &dbv)) { - if (mir_tstrlen(dbv.ptszVal) != 0) - swzMsg = mir_tstrdup(dbv.ptszVal); + if (mir_wstrlen(dbv.ptszVal) != 0) + swzMsg = mir_wstrdup(dbv.ptszVal); db_free(&dbv); } } @@ -250,17 +250,17 @@ bool GetSysSubstText(MCONTACT hContact, wchar_t *swzRawSpec, wchar_t *buff, int { bool recv = false; - if (!mir_tstrcmp(swzRawSpec, L"uid")) + if (!mir_wstrcmp(swzRawSpec, L"uid")) return Uid(hContact, 0, buff, bufflen); - if (!mir_tstrcmp(swzRawSpec, L"proto")) { + if (!mir_wstrcmp(swzRawSpec, L"proto")) { char *szProto = GetContactProto(hContact); if (szProto) { a2t(szProto, buff, bufflen); return true; } } - else if (!mir_tstrcmp(swzRawSpec, L"account")) { + else if (!mir_wstrcmp(swzRawSpec, L"account")) { char *szProto = Proto_GetBaseAccountName(hContact); if ((INT_PTR)szProto == CALLSERVICE_NOTFOUND) { return GetSysSubstText(hContact, L"proto", buff, bufflen); @@ -275,15 +275,15 @@ bool GetSysSubstText(MCONTACT hContact, wchar_t *swzRawSpec, wchar_t *buff, int return GetSysSubstText(hContact, L"proto", buff, bufflen); } } - else if (!mir_tstrcmp(swzRawSpec, L"time")) { + else if (!mir_wstrcmp(swzRawSpec, L"time")) { if (!printDateTimeByContact(hContact, L"t", buff, bufflen, TZF_KNOWNONLY)) return true; } - else if (!mir_tstrcmp(swzRawSpec, L"uidname")) { + else if (!mir_wstrcmp(swzRawSpec, L"uidname")) { char *szProto = GetContactProto(hContact); return UidName(szProto, buff, bufflen); } - else if (!mir_tstrcmp(swzRawSpec, L"status_msg")) { + else if (!mir_wstrcmp(swzRawSpec, L"status_msg")) { wchar_t *swzMsg = GetStatusMessageText(hContact); if (swzMsg) { wcsncpy(buff, swzMsg, bufflen); @@ -291,7 +291,7 @@ bool GetSysSubstText(MCONTACT hContact, wchar_t *swzRawSpec, wchar_t *buff, int return true; } } - else if ((recv = !mir_tstrcmp(swzRawSpec, L"last_msg")) || !mir_tstrcmp(swzRawSpec, L"last_msg_out")) { + else if ((recv = !mir_wstrcmp(swzRawSpec, L"last_msg")) || !mir_wstrcmp(swzRawSpec, L"last_msg_out")) { wchar_t *swzMsg = GetLastMessageText(hContact, recv); if (swzMsg) { wcsncpy(buff, swzMsg, bufflen); @@ -299,7 +299,7 @@ bool GetSysSubstText(MCONTACT hContact, wchar_t *swzRawSpec, wchar_t *buff, int return true; } } - else if (!mir_tstrcmp(swzRawSpec, L"meta_subname")) { + else if (!mir_wstrcmp(swzRawSpec, L"meta_subname")) { // get contact list name of active subcontact MCONTACT hSubContact = db_mc_getMostOnline(hContact); if (!hSubContact) @@ -310,32 +310,32 @@ bool GetSysSubstText(MCONTACT hContact, wchar_t *swzRawSpec, wchar_t *buff, int wcsncpy(buff, swzNick, bufflen); return true; } - else if (!mir_tstrcmp(swzRawSpec, L"meta_subuid")) { + else if (!mir_wstrcmp(swzRawSpec, L"meta_subuid")) { MCONTACT hSubContact = db_mc_getMostOnline(hContact); if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND) return false; return Uid(hSubContact, 0, buff, bufflen); } - else if (!mir_tstrcmp(swzRawSpec, L"meta_subproto")) { + else if (!mir_wstrcmp(swzRawSpec, L"meta_subproto")) { // get protocol of active subcontact MCONTACT hSubContact = db_mc_getMostOnline(hContact); if (!hSubContact || (INT_PTR)hSubContact == CALLSERVICE_NOTFOUND) return false; return GetSysSubstText(hSubContact, L"account", buff, bufflen); } - else if ((recv = !mir_tstrcmp(swzRawSpec, L"last_msg_time")) || !mir_tstrcmp(swzRawSpec, L"last_msg_out_time")) { + else if ((recv = !mir_wstrcmp(swzRawSpec, L"last_msg_time")) || !mir_wstrcmp(swzRawSpec, L"last_msg_out_time")) { DWORD ts = LastMessageTimestamp(hContact, recv); if (ts == 0) return false; FormatTimestamp(ts, "t", buff, bufflen); return true; } - else if ((recv = !mir_tstrcmp(swzRawSpec, L"last_msg_date")) || !mir_tstrcmp(swzRawSpec, L"last_msg_out_date")) { + else if ((recv = !mir_wstrcmp(swzRawSpec, L"last_msg_date")) || !mir_wstrcmp(swzRawSpec, L"last_msg_out_date")) { DWORD ts = LastMessageTimestamp(hContact, recv); if (ts == 0) return false; FormatTimestamp(ts, "d", buff, bufflen); return true; } - else if ((recv = !mir_tstrcmp(swzRawSpec, L"last_msg_reltime")) || !mir_tstrcmp(swzRawSpec, L"last_msg_out_reltime")) { + else if ((recv = !mir_wstrcmp(swzRawSpec, L"last_msg_reltime")) || !mir_wstrcmp(swzRawSpec, L"last_msg_out_reltime")) { DWORD ts = LastMessageTimestamp(hContact, recv); if (ts == 0) return false; DWORD t = (DWORD)time(0); @@ -343,12 +343,12 @@ bool GetSysSubstText(MCONTACT hContact, wchar_t *swzRawSpec, wchar_t *buff, int int d = (diff / 60 / 60 / 24); int h = (diff - d * 60 * 60 * 24) / 60 / 60; int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60; - if (d > 0) mir_sntprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m); - else if (h > 0) mir_sntprintf(buff, bufflen, TranslateT("%dh %dm"), h, m); - else mir_sntprintf(buff, bufflen, TranslateT("%dm"), m); + if (d > 0) mir_snwprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m); + else if (h > 0) mir_snwprintf(buff, bufflen, TranslateT("%dh %dm"), h, m); + else mir_snwprintf(buff, bufflen, TranslateT("%dm"), m); return true; } - else if (!mir_tstrcmp(swzRawSpec, L"msg_count_all") || !mir_tstrcmp(swzRawSpec, L"msg_count_out") || !mir_tstrcmp(swzRawSpec, L"msg_count_in")) { + else if (!mir_wstrcmp(swzRawSpec, L"msg_count_all") || !mir_wstrcmp(swzRawSpec, L"msg_count_out") || !mir_wstrcmp(swzRawSpec, L"msg_count_in")) { DWORD dwCountOut, dwCountIn; DWORD dwMetaCountOut = 0, dwMetaCountIn = 0; DWORD dwLastTs, dwNewTs, dwRecountTs; @@ -406,12 +406,12 @@ bool GetSysSubstText(MCONTACT hContact, wchar_t *swzRawSpec, wchar_t *buff, int dwMetaCountIn += dwCountIn; } - if (!mir_tstrcmp(swzRawSpec, L"msg_count_out")) - mir_sntprintf(buff, bufflen, L"%d", dwMetaCountOut); - else if (!mir_tstrcmp(swzRawSpec, L"msg_count_in")) - mir_sntprintf(buff, bufflen, L"%d", dwMetaCountIn); + if (!mir_wstrcmp(swzRawSpec, L"msg_count_out")) + mir_snwprintf(buff, bufflen, L"%d", dwMetaCountOut); + else if (!mir_wstrcmp(swzRawSpec, L"msg_count_in")) + mir_snwprintf(buff, bufflen, L"%d", dwMetaCountIn); else - mir_sntprintf(buff, bufflen, L"%d", dwMetaCountOut + dwMetaCountIn); + mir_snwprintf(buff, bufflen, L"%d", dwMetaCountOut + dwMetaCountIn); return true; } @@ -475,9 +475,9 @@ bool ApplySubst(MCONTACT hContact, const wchar_t *swzSource, bool parseTipperVar } // pass to variables plugin if available - wchar_t *swzVarSrc = (parseTipperVarsFirst ? mir_tstrdup(swzSource) : variables_parsedup((wchar_t *)swzSource, 0, hContact)); + wchar_t *swzVarSrc = (parseTipperVarsFirst ? mir_wstrdup(swzSource) : variables_parsedup((wchar_t *)swzSource, 0, hContact)); - size_t iSourceLen = mir_tstrlen(swzVarSrc); + size_t iSourceLen = mir_wstrlen(swzVarSrc); size_t si = 0, di = 0, v = 0; wchar_t swzVName[LABEL_LEN], swzRep[VALUE_LEN], swzAlt[VALUE_LEN]; @@ -555,13 +555,13 @@ bool ApplySubst(MCONTACT hContact, const wchar_t *swzSource, bool parseTipperVar if (p) { *p = 0; // clip swzAlt from swzVName p++; - if (mir_tstrlen(p) > 4 && wcsncmp(p, L"raw:", 4) == 0) { // raw db substitution + if (mir_wstrlen(p) > 4 && wcsncmp(p, L"raw:", 4) == 0) { // raw db substitution char raw_spec[LABEL_LEN]; p += 4; t2a(p, raw_spec, LABEL_LEN); GetRawSubstText(hContact, raw_spec, swzAlt, VALUE_LEN); } - else if (mir_tstrlen(p) > 4 && wcsncmp(p, L"sys:", 4) == 0) { // 'system' substitution + else if (mir_wstrlen(p) > 4 && wcsncmp(p, L"sys:", 4) == 0) { // 'system' substitution p += 4; GetSysSubstText(hContact, p, swzAlt, VALUE_LEN); } @@ -569,7 +569,7 @@ bool ApplySubst(MCONTACT hContact, const wchar_t *swzSource, bool parseTipperVar // see if we can find the bSubst DSListNode *ds_node = opt.dsList; while (ds_node) { - if (mir_tstrcmp(ds_node->ds.swzName, p) == 0) + if (mir_wstrcmp(ds_node->ds.swzName, p) == 0) break; ds_node = ds_node->next; @@ -583,7 +583,7 @@ bool ApplySubst(MCONTACT hContact, const wchar_t *swzSource, bool parseTipperVar } } swzAlt[VALUE_LEN - 1] = 0; - if (mir_tstrlen(swzAlt) != 0) + if (mir_wstrlen(swzAlt) != 0) bAltSubst = true; } @@ -602,7 +602,7 @@ bool ApplySubst(MCONTACT hContact, const wchar_t *swzSource, bool parseTipperVar // see if we can find the bSubst DSListNode *ds_node = opt.dsList; while (ds_node) { - if (mir_tstrcmp(ds_node->ds.swzName, swzVName) == 0) + if (mir_wstrcmp(ds_node->ds.swzName, swzVName) == 0) break; ds_node = ds_node->next; @@ -615,12 +615,12 @@ bool ApplySubst(MCONTACT hContact, const wchar_t *swzSource, bool parseTipperVar } if (bSubst) { - size_t rep_len = mir_tstrlen(swzRep); + size_t rep_len = mir_wstrlen(swzRep); wcsncpy(&swzDest[di], swzRep, min(rep_len, iDestLen - di)); di += rep_len - 1; // -1 because we inc at bottom of loop } else if (bAltSubst) { - size_t alt_len = mir_tstrlen(swzAlt); + size_t alt_len = mir_wstrlen(swzAlt); wcsncpy(&swzDest[di], swzAlt, min(alt_len, iDestLen - di)); di += alt_len - 1; // -1 because we inc at bottom of loop } @@ -677,9 +677,9 @@ bool GetValueText(MCONTACT hContact, const DISPLAYITEM &di, wchar_t *buff, size_ void TruncateString(wchar_t *ptszText) { if (ptszText && opt.iLimitCharCount > 3) { - if ((int)mir_tstrlen(ptszText) > opt.iLimitCharCount) { + if ((int)mir_wstrlen(ptszText) > opt.iLimitCharCount) { ptszText[opt.iLimitCharCount - 3] = 0; - mir_tstrcat(ptszText, L"..."); + mir_wstrcat(ptszText, L"..."); } } } @@ -702,7 +702,7 @@ wchar_t* GetProtoStatusMessage(char *szProto, WORD wStatus) // try to use service without SGMA_TCHAR char *tmpMsg = (char *)CallProtoService(szProto, PS_GETMYAWAYMSG, 0, 0); if (tmpMsg && (INT_PTR)tmpMsg != CALLSERVICE_NOTFOUND) { - ptszText = mir_a2t(tmpMsg); + ptszText = mir_a2u(tmpMsg); mir_free(tmpMsg); } } @@ -728,7 +728,7 @@ wchar_t* GetProtoExtraStatusTitle(char *szProto) if (!ptszText) { wchar_t buff[256]; if (EmptyXStatusToDefaultName(0, szProto, 0, buff, 256)) - ptszText = mir_tstrdup(buff); + ptszText = mir_wstrdup(buff); } if (opt.bLimitMsg) |