summaryrefslogtreecommitdiff
path: root/plugins/TipperYM/src/translations.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/TipperYM/src/translations.cpp')
-rw-r--r--plugins/TipperYM/src/translations.cpp339
1 files changed, 143 insertions, 196 deletions
diff --git a/plugins/TipperYM/src/translations.cpp b/plugins/TipperYM/src/translations.cpp
index c8f8d58e18..086309c988 100644
--- a/plugins/TipperYM/src/translations.cpp
+++ b/plugins/TipperYM/src/translations.cpp
@@ -15,7 +15,7 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this file; see the file license.txt. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
+Boston, MA 02111-1307, USA.
*/
#include "stdafx.h"
@@ -26,33 +26,29 @@ DBVTranslation *translations = nullptr;
DWORD dwNextFuncId;
HANDLE hServiceAdd;
-void AddTranslation(DBVTranslation *newTrans)
+void AddTranslation(DBVTranslation *newTrans)
{
- DBVTranslation *ptranslations = (DBVTranslation *)mir_realloc(translations, sizeof(DBVTranslation) * (iTransFuncsCount+1));
+ DBVTranslation *ptranslations = (DBVTranslation *)mir_realloc(translations, sizeof(DBVTranslation) * (iTransFuncsCount + 1));
if (ptranslations == nullptr)
return;
translations = ptranslations;
iTransFuncsCount++;
translations[iTransFuncsCount - 1] = *newTrans;
-
+
char *szName = mir_u2a(newTrans->swzName);
char szSetting[256];
- mir_snprintf(szSetting, sizeof(szSetting),"Trans_%s",szName);
+ mir_snprintf(szSetting, sizeof(szSetting), "Trans_%s", szName);
- if (mir_wstrcmp(newTrans->swzName, L"[No translation]") == 0)
- {
+ if (mir_wstrcmp(newTrans->swzName, L"[No translation]") == 0) {
translations[iTransFuncsCount - 1].id = 0;
- }
- else
- {
+ }
+ else {
DWORD id = db_get_dw(0, MODULE_ITEMS, szSetting, 0);
- if (id != 0)
- {
+ if (id != 0) {
translations[iTransFuncsCount - 1].id = id;
if (dwNextFuncId <= id) dwNextFuncId = id + 1;
- }
- else
- {
+ }
+ else {
translations[iTransFuncsCount - 1].id = dwNextFuncId++;
db_set_dw(0, MODULE_ITEMS, szSetting, translations[iTransFuncsCount - 1].id);
}
@@ -63,59 +59,59 @@ void AddTranslation(DBVTranslation *newTrans)
mir_free(szName);
}
-wchar_t *NullTranslation(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *NullTranslation(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
if (DBGetContactSettingAsString(hContact, szModuleName, szSettingName, buff, bufflen))
return buff;
return nullptr;
}
-wchar_t* TimestampToShortDate(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t* TimestampToShortDate(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD ts = db_get_dw(hContact, szModuleName, szSettingName, 0);
if (ts == 0)
return nullptr;
-
+
return TimeZone_ToStringT(ts, L"d", buff, bufflen);
}
-wchar_t* TimestampToLongDate(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t* TimestampToLongDate(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD ts = db_get_dw(hContact, szModuleName, szSettingName, 0);
if (ts == 0)
return nullptr;
-
+
return TimeZone_ToStringT(ts, L"D", buff, bufflen);
}
-wchar_t* TimestampToTime(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t* TimestampToTime(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD ts = db_get_dw(hContact, szModuleName, szSettingName, 0);
if (ts == 0)
return nullptr;
-
+
return TimeZone_ToStringT(ts, L"s", buff, bufflen);
}
-wchar_t* TimestampToTimeNoSecs(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t* TimestampToTimeNoSecs(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD ts = db_get_dw(hContact, szModuleName, szSettingName, 0);
if (ts == 0)
return nullptr;
-
+
return TimeZone_ToStringT(ts, L"t", buff, bufflen);
}
-wchar_t* TimestampToTimeDifference(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t* TimestampToTimeDifference(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD ts = db_get_dw(hContact, szModuleName, szSettingName, 0);
DWORD t = (DWORD)time(nullptr);
if (ts == 0) return nullptr;
-
+
DWORD diff = (ts > t) ? 0 : (t - ts);
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;
+ int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60;
if (d > 0)
mir_snwprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m);
else if (h > 0)
@@ -126,12 +122,12 @@ wchar_t* TimestampToTimeDifference(MCONTACT hContact, const char *szModuleName,
return buff;
}
-wchar_t *SecondsToTimeDifference(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *SecondsToTimeDifference(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD diff = db_get_dw(hContact, szModuleName, szSettingName, 0);
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;
+ int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60;
if (d > 0)
mir_snwprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m);
else if (h > 0)
@@ -142,7 +138,7 @@ wchar_t *SecondsToTimeDifference(MCONTACT hContact, const char *szModuleName, co
return buff;
}
-wchar_t *WordToStatusDesc(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *WordToStatusDesc(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
WORD wStatus = db_get_w(hContact, szModuleName, szSettingName, ID_STATUS_OFFLINE);
wchar_t *szStatus = pcli->pfnGetStatusModeDescription(wStatus, 0);
@@ -150,13 +146,11 @@ wchar_t *WordToStatusDesc(MCONTACT hContact, const char *szModuleName, const cha
return buff;
}
-wchar_t *ByteToYesNo(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *ByteToYesNo(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (dbv.type == DBVT_BYTE)
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (dbv.type == DBVT_BYTE) {
if (dbv.bVal != 0)
wcsncpy(buff, L"Yes", bufflen);
else
@@ -170,7 +164,7 @@ wchar_t *ByteToYesNo(MCONTACT hContact, const char *szModuleName, const char *sz
return nullptr;
}
-wchar_t *ByteToGender(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *ByteToGender(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
BYTE val = (BYTE)db_get_b(hContact, szModuleName, szSettingName, 0);
if (val == 'F')
@@ -184,12 +178,11 @@ wchar_t *ByteToGender(MCONTACT hContact, const char *szModuleName, const char *s
return buff;
}
-wchar_t *WordToCountry(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *WordToCountry(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
char *szCountryName = nullptr;
WORD cid = (WORD)db_get_w(hContact, szModuleName, szSettingName, (WORD)-1);
- if (cid != (WORD)-1 && ServiceExists(MS_UTILS_GETCOUNTRYBYNUMBER) && (szCountryName = (char *)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, cid, 0)) != nullptr)
- {
+ if (cid != (WORD)-1 && ServiceExists(MS_UTILS_GETCOUNTRYBYNUMBER) && (szCountryName = (char *)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, cid, 0)) != nullptr) {
if (mir_strcmp(szCountryName, "Unknown") == 0)
return nullptr;
a2t(szCountryName, buff, bufflen);
@@ -199,7 +192,7 @@ wchar_t *WordToCountry(MCONTACT hContact, const char *szModuleName, const char *
return nullptr;
}
-wchar_t *DwordToIp(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *DwordToIp(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD ip = db_get_dw(hContact, szModuleName, szSettingName, 0);
if (ip) {
@@ -210,42 +203,37 @@ wchar_t *DwordToIp(MCONTACT hContact, const char *szModuleName, const char *szSe
return nullptr;
}
-bool GetInt(const DBVARIANT &dbv, int *iVal)
+bool GetInt(const DBVARIANT &dbv, int *iVal)
{
if (!iVal) return false;
- switch(dbv.type)
- {
- case DBVT_BYTE:
- if (iVal) *iVal = (int)dbv.bVal;
- return true;
- case DBVT_WORD:
- if (iVal) *iVal = (int)dbv.wVal;
- return true;
- case DBVT_DWORD:
- if (iVal) *iVal = (int)dbv.dVal;
- return true;
+ switch (dbv.type) {
+ case DBVT_BYTE:
+ if (iVal) *iVal = (int)dbv.bVal;
+ return true;
+ case DBVT_WORD:
+ if (iVal) *iVal = (int)dbv.wVal;
+ return true;
+ case DBVT_DWORD:
+ if (iVal) *iVal = (int)dbv.dVal;
+ return true;
}
return false;
}
-wchar_t *DayMonthYearToDate(MCONTACT hContact, const char *szModuleName, const char *prefix, wchar_t *buff, int bufflen)
+wchar_t *DayMonthYearToDate(MCONTACT hContact, const char *szModuleName, const char *prefix, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
char szSettingName[256];
mir_snprintf(szSettingName, "%sDay", prefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int day = 0;
- if (GetInt(dbv, &day))
- {
+ if (GetInt(dbv, &day)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMonth", prefix);
int month = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &month))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &month)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sYear", prefix);
int year = 0;
@@ -262,42 +250,36 @@ wchar_t *DayMonthYearToDate(MCONTACT hContact, const char *szModuleName, const c
wcsftime(buff, bufflen, L"%x", &time);
return buff;
-
- }
- else
+
+ }
+ else
db_free(&dbv);
}
- }
- else
+ }
+ else
db_free(&dbv);
}
return nullptr;
}
-wchar_t *DayMonthYearToAge(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
+wchar_t *DayMonthYearToAge(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
char szSettingName[256];
mir_snprintf(szSettingName, "%sDay", szPrefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int day = 0;
- if (GetInt(dbv, &day))
- {
+ if (GetInt(dbv, &day)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMonth", szPrefix);
int month = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &month))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &month)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sYear", szPrefix);
int year = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &year) && year != 0)
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &year) && year != 0) {
db_free(&dbv);
SYSTEMTIME now;
@@ -308,149 +290,129 @@ wchar_t *DayMonthYearToAge(MCONTACT hContact, const char *szModuleName, const ch
age--;
mir_snwprintf(buff, bufflen, L"%d", age);
return buff;
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
return nullptr;
}
-wchar_t *HoursMinutesSecondsToTime(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
+wchar_t *HoursMinutesSecondsToTime(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
char szSettingName[256];
mir_snprintf(szSettingName, "%sHours", szPrefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int hours = 0;
- if (GetInt(dbv, &hours))
- {
+ if (GetInt(dbv, &hours)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMinutes", szPrefix);
int minutes = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &minutes))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &minutes)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sSeconds", szPrefix);
int seconds = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
GetInt(dbv, &seconds);
db_free(&dbv);
}
- SYSTEMTIME st = {0};
+ SYSTEMTIME st = { 0 };
st.wHour = hours;
st.wMinute = minutes;
st.wSecond = seconds;
- GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, nullptr, buff, bufflen);
+ GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, nullptr, buff, bufflen);
return buff;
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
return nullptr;
}
-wchar_t *HoursMinutesToTime(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
+wchar_t *HoursMinutesToTime(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
char szSettingName[256];
mir_snprintf(szSettingName, "%sHours", szPrefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int hours = 0;
- if (GetInt(dbv, &hours))
- {
+ if (GetInt(dbv, &hours)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMinutes", szPrefix);
int minutes = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &minutes))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &minutes)) {
db_free(&dbv);
- SYSTEMTIME st = {0};
+ SYSTEMTIME st = { 0 };
st.wHour = hours;
st.wMinute = minutes;
- GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, nullptr, buff, bufflen);
+ GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, nullptr, buff, bufflen);
return buff;
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
return nullptr;
}
-wchar_t *DmyToTimeDifference(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
+wchar_t *DmyToTimeDifference(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
char szSettingName[256];
mir_snprintf(szSettingName, "%sDay", szPrefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int day = 0;
- if (GetInt(dbv, &day))
- {
+ if (GetInt(dbv, &day)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMonth", szPrefix);
int month = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &month))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &month)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sYear", szPrefix);
int year = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &year))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &year)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sHours", szPrefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int hours = 0;
- if (GetInt(dbv, &hours))
- {
+ if (GetInt(dbv, &hours)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMinutes", szPrefix);
int minutes = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &minutes))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &minutes)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sSeconds", szPrefix);
int seconds = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
GetInt(dbv, &seconds);
db_free(&dbv);
}
- SYSTEMTIME st = {0}, st_now;
+ SYSTEMTIME st = { 0 }, st_now;
st.wDay = day;
st.wMonth = month;
st.wYear = year;
@@ -462,7 +424,7 @@ wchar_t *DmyToTimeDifference(MCONTACT hContact, const char *szModuleName, const
FILETIME ft, ft_now;
SystemTimeToFileTime(&st, &ft);
SystemTimeToFileTime(&st_now, &ft_now);
-
+
LARGE_INTEGER li, li_now;
li.HighPart = ft.dwHighDateTime; li.LowPart = ft.dwLowDateTime;
li_now.HighPart = ft_now.dwHighDateTime; li_now.LowPart = ft_now.dwLowDateTime;
@@ -471,7 +433,7 @@ wchar_t *DmyToTimeDifference(MCONTACT hContact, const char *szModuleName, const
int y = diff / 60 / 60 / 24 / 365;
int d = (diff - y * 60 * 60 * 24 * 365) / 60 / 60 / 24;
int h = (diff - y * 60 * 60 * 24 * 365 - d * 60 * 60 * 24) / 60 / 60;
- int m = (diff - y * 60 * 60 * 24 * 365 - d * 60 * 60 * 24 - h * 60 * 60) / 60;
+ int m = (diff - y * 60 * 60 * 24 * 365 - d * 60 * 60 * 24 - h * 60 * 60) / 60;
if (y != 0)
mir_snwprintf(buff, bufflen, TranslateT("%dy %dd %dh %dm"), y, d, h, m);
else if (d != 0)
@@ -482,46 +444,42 @@ wchar_t *DmyToTimeDifference(MCONTACT hContact, const char *szModuleName, const
mir_snwprintf(buff, bufflen, TranslateT("%dm"), m);
return buff;
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
return nullptr;
}
-wchar_t *DayMonthToDaysToNextBirthday(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
+wchar_t *DayMonthToDaysToNextBirthday(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
char szSettingName[256];
mir_snprintf(szSettingName, "%sDay", szPrefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int day = 0;
- if (GetInt(dbv, &day))
- {
+ if (GetInt(dbv, &day)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMonth", szPrefix);
int month = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &month))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &month)) {
db_free(&dbv);
time_t now = time(nullptr);
struct tm *ti = localtime(&now);
@@ -532,25 +490,22 @@ wchar_t *DayMonthToDaysToNextBirthday(MCONTACT hContact, const char *szModuleNam
mktime(ti);
int yday_birth = ti->tm_yday;
- if (yday_birth < yday_now)
- {
+ if (yday_birth < yday_now) {
yday_now -= 365;
- yday_now -= (ti->tm_year % 4) ? 0 : 1;
+ yday_now -= (ti->tm_year % 4) ? 0 : 1;
}
int diff = yday_birth - yday_now;
mir_snwprintf(buff, bufflen, TranslateT("%dd"), diff);
-
+
return buff;
}
- else
- {
+ else {
db_free(&dbv);
}
}
- }
- else
- {
+ }
+ else {
db_free(&dbv);
}
}
@@ -558,17 +513,16 @@ wchar_t *DayMonthToDaysToNextBirthday(MCONTACT hContact, const char *szModuleNam
}
-wchar_t *EmptyXStatusToDefaultName(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *EmptyXStatusToDefaultName(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
wchar_t szDefaultName[1024];
- CUSTOM_STATUS xstatus = {0};
+ CUSTOM_STATUS xstatus = { 0 };
DBVARIANT dbv;
// translate jabber mood
if (ProtoServiceExists(szModuleName, "/SendXML")) // jabber protocol?
- {
- if (!db_get_ws(hContact, szModuleName, szSettingName, &dbv))
- {
+ {
+ if (!db_get_ws(hContact, szModuleName, szSettingName, &dbv)) {
wcsncpy(buff, TranslateW(dbv.ptszVal), bufflen);
buff[bufflen - 1] = 0;
return buff;
@@ -576,32 +530,31 @@ wchar_t *EmptyXStatusToDefaultName(MCONTACT hContact, const char *szModuleName,
}
if (NullTranslation(hContact, szModuleName, szSettingName, buff, bufflen))
- return buff;
-
+ return buff;
+
int status = db_get_b(hContact, szModuleName, "XStatusId", 0);
if (!status) return nullptr;
-
- if (ProtoServiceExists(szModuleName, PS_GETCUSTOMSTATUSEX))
- {
+
+ if (ProtoServiceExists(szModuleName, PS_GETCUSTOMSTATUSEX)) {
xstatus.cbSize = sizeof(CUSTOM_STATUS);
xstatus.flags = CSSF_MASK_NAME | CSSF_DEFAULT_NAME | CSSF_UNICODE;
xstatus.ptszName = szDefaultName;
xstatus.wParam = (WPARAM *)&status;
if (CallProtoService(szModuleName, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&xstatus))
- return nullptr;
-
+ return nullptr;
+
wcsncpy(buff, TranslateW(szDefaultName), bufflen);
buff[bufflen - 1] = 0;
return buff;
- }
+ }
return nullptr;
}
-wchar_t *TimezoneToTime(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *TimezoneToTime(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
- int timezone = db_get_b(hContact,szModuleName,szSettingName,256);
- if (timezone==256 || (char)timezone==-100)
+ int timezone = db_get_b(hContact, szModuleName, szSettingName, 256);
+ if (timezone == 256 || (char)timezone == -100)
return nullptr;
TIME_ZONE_INFORMATION tzi;
@@ -609,7 +562,7 @@ wchar_t *TimezoneToTime(MCONTACT hContact, const char *szModuleName, const char
LARGE_INTEGER lift;
SYSTEMTIME st;
- timezone=(char)timezone;
+ timezone = (char)timezone;
GetSystemTimeAsFileTime(&ft);
if (GetTimeZoneInformation(&tzi) == TIME_ZONE_ID_DAYLIGHT)
timezone += tzi.DaylightBias / 30;
@@ -623,11 +576,10 @@ wchar_t *TimezoneToTime(MCONTACT hContact, const char *szModuleName, const char
return buff;
}
-wchar_t *ByteToDay(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *ByteToDay(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
int iDay = db_get_w(hContact, szModuleName, szSettingName, -1);
- if (iDay > -1 && iDay < 7)
- {
+ if (iDay > -1 && iDay < 7) {
a2t(Translate(days[iDay]), buff, bufflen);
buff[bufflen - 1] = 0;
return buff;
@@ -636,11 +588,10 @@ wchar_t *ByteToDay(MCONTACT hContact, const char *szModuleName, const char *szSe
return nullptr;
}
-wchar_t *ByteToMonth(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *ByteToMonth(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
int iMonth = db_get_w(hContact, szModuleName, szSettingName, 0);
- if (iMonth > 0 && iMonth < 13)
- {
+ if (iMonth > 0 && iMonth < 13) {
a2t(Translate(months[iMonth - 1]), buff, bufflen);
buff[bufflen - 1] = 0;
return buff;
@@ -649,16 +600,13 @@ wchar_t *ByteToMonth(MCONTACT hContact, const char *szModuleName, const char *sz
return nullptr;
}
-wchar_t *ByteToLanguage(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *ByteToLanguage(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
int iLang = db_get_b(hContact, szModuleName, szSettingName, 0);
- if (iLang)
- {
- for (int i = 0; i < _countof(languages); i++)
- {
- if (iLang == languages[i].id)
- {
- a2t(Translate(languages[i].szValue), buff, bufflen);
+ if (iLang) {
+ for (auto &it : languages) {
+ if (iLang == it.id) {
+ a2t(Translate(it.szValue), buff, bufflen);
buff[bufflen - 1] = 0;
return buff;
}
@@ -668,7 +616,7 @@ wchar_t *ByteToLanguage(MCONTACT hContact, const char *szModuleName, const char
return nullptr;
}
-INT_PTR ServiceAddTranslation(WPARAM, LPARAM lParam)
+INT_PTR ServiceAddTranslation(WPARAM, LPARAM lParam)
{
if (!lParam) return 1;
@@ -678,7 +626,7 @@ INT_PTR ServiceAddTranslation(WPARAM, LPARAM lParam)
return 0;
}
-static DBVTranslation internalTranslations[] =
+static DBVTranslation internalTranslations[] =
{
{ NullTranslation, LPGENW("[No translation]") },
{ WordToStatusDesc, LPGENW("WORD to status description") },
@@ -705,11 +653,11 @@ static DBVTranslation internalTranslations[] =
{ ByteToLanguage, LPGENW("BYTE to language (ICQ)") },
};
-void InitTranslations()
+void InitTranslations()
{
dwNextFuncId = db_get_dw(0, MODULE_ITEMS, "NextFuncId", 1);
- for (int i = 0; i < _countof(internalTranslations); i++)
- AddTranslation(&internalTranslations[i]);
+ for (auto &it : internalTranslations)
+ AddTranslation(&it);
hServiceAdd = CreateServiceFunction(MS_TIPPER_ADDTRANSLATION, ServiceAddTranslation);
}
@@ -719,4 +667,3 @@ void DeinitTranslations()
DestroyServiceFunction(hServiceAdd);
mir_free(translations);
}
-