summaryrefslogtreecommitdiff
path: root/plugins/TipperYM
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-05-28 14:38:30 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-05-28 14:38:30 +0000
commit9728260c2851d1e45ca79237af6bda64db467045 (patch)
tree2d5f5c4719b8200c358d2883fa56e75c66a68871 /plugins/TipperYM
parentc69a4eeaf118719b3cc7d8e762696e131fe969f2 (diff)
- improved status messaging retrieving
- code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@211 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TipperYM')
-rw-r--r--plugins/TipperYM/subst.cpp27
-rw-r--r--plugins/TipperYM/translations.cpp134
2 files changed, 46 insertions, 115 deletions
diff --git a/plugins/TipperYM/subst.cpp b/plugins/TipperYM/subst.cpp
index 4fe91dff2f..bc99aee44b 100644
--- a/plugins/TipperYM/subst.cpp
+++ b/plugins/TipperYM/subst.cpp
@@ -834,9 +834,6 @@ void TruncateString(TCHAR *swzText)
TCHAR *GetProtoStatusMessage(char *szProto, WORD wStatus)
{
- TCHAR *swzText = NULL;
- char *tmpMsg = NULL;
-
if (!szProto || wStatus == ID_STATUS_OFFLINE)
return NULL;
@@ -845,20 +842,24 @@ TCHAR *GetProtoStatusMessage(char *szProto, WORD wStatus)
if (!(flags & Proto_Status2Flag(wStatus)))
return NULL;
- swzText = (TCHAR *)CallProtoService(szProto, PS_GETMYAWAYMSG, 0, SGMA_TCHAR);
- if ((INT_PTR)swzText != CALLSERVICE_NOTFOUND)
+ TCHAR *swzText = (TCHAR *)CallProtoService(szProto, PS_GETMYAWAYMSG, 0, SGMA_TCHAR);
+ if ((INT_PTR)swzText == CALLSERVICE_NOTFOUND)
{
- if (swzText == NULL)
- tmpMsg = ( char* )CallProtoService(szProto, PS_GETMYAWAYMSG, 0, 0);
+ swzText = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, wStatus, 0);
}
- else swzText = ( TCHAR* )CallService(MS_AWAYMSG_GETSTATUSMSGT, wStatus, 0);
-
- if (tmpMsg && (INT_PTR)tmpMsg != CALLSERVICE_NOTFOUND)
+#ifdef _UNICODE
+ else if (swzText == NULL)
{
- swzText = mir_a2t(tmpMsg);
- mir_free(tmpMsg);
+ // try to use service without SGMA_TCHAR
+ char *tmpMsg = (char *)CallProtoService(szProto, PS_GETMYAWAYMSG, 0, 0);
+ if (tmpMsg && (INT_PTR)tmpMsg != CALLSERVICE_NOTFOUND)
+ {
+ swzText = mir_a2t(tmpMsg);
+ mir_free(tmpMsg);
+ }
}
-
+#endif
+
if (swzText && !swzText[0])
{
mir_free(swzText);
diff --git a/plugins/TipperYM/translations.cpp b/plugins/TipperYM/translations.cpp
index 8b3eb3a3b5..57e55efee1 100644
--- a/plugins/TipperYM/translations.cpp
+++ b/plugins/TipperYM/translations.cpp
@@ -163,8 +163,8 @@ TCHAR *SecondsToTimeDifference(HANDLE hContact, const char *szModuleName, const
TCHAR *WordToStatusDesc(HANDLE hContact, const char *szModuleName, const char *szSettingName, TCHAR *buff, int bufflen)
{
WORD wStatus = DBGetContactSettingWord(hContact, szModuleName, szSettingName, ID_STATUS_OFFLINE);
- char *szStatus = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)wStatus, (LPARAM)0);
- a2t(szStatus, buff, bufflen);
+ TCHAR *szStatus = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)wStatus, GSMDF_TCHAR);
+ _tcsncpy(buff,szStatus, bufflen);
buff[bufflen - 1] = 0;
return buff;
}
@@ -425,7 +425,7 @@ TCHAR *HoursMinutesToTime(HANDLE hContact, const char *szModuleName, const char
return 0;
}
-TCHAR *DayMonthYearHoursMinutesSecondsToTimeDifference(HANDLE hContact, const char *szModuleName, const char *szPrefix, TCHAR *buff, int bufflen)
+TCHAR *DmyToTimeDifference(HANDLE hContact, const char *szModuleName, const char *szPrefix, TCHAR *buff, int bufflen)
{
DBVARIANT dbv;
char szSettingName[256];
@@ -700,108 +700,38 @@ INT_PTR ServiceAddTranslation(WPARAM wParam, LPARAM lParam)
return 0;
}
-#define INT_TRANS_COUNT 23
+static DBVTranslation internalTranslations[] =
+{
+ { NullTranslation, _T("[No translation]") },
+ { WordToStatusDesc, _T("WORD to status description") },
+ { TimestampToTime, _T("DWORD timestamp to time") },
+ { TimestampToTimeDifference, _T("DWORD timestamp to time difference") },
+ { ByteToYesNo, _T("BYTE to Yes/No") },
+ { ByteToGender, _T("BYTE to Male/Female (ICQ)") },
+ { WordToCountry, _T("WORD to country name") },
+ { DwordToIp, _T("DWORD to ip address") },
+ { DayMonthYearToDate, _T("<prefix>Day|Month|Year to date") },
+ { DayMonthYearToAge, _T("<prefix>Day|Month|Year to age") },
+ { HoursMinutesSecondsToTime, _T("<prefix>Hours|Minutes|Seconds to time") },
+ { DmyToTimeDifference, _T("<prefix>Day|Month|Year|Hours|Minutes|Seconds to time difference") },
+ { DayMonthToDaysToNextBirthday, _T("<prefix>Day|Month to days to next birthday") },
+ { TimestampToTimeNoSecs, _T("DWORD timestamp to time (no seconds)") },
+ { HoursMinutesToTime, _T("<prefix>Hours|Minutes to time") },
+ { TimestampToShortDate, _T("DWORD timestamp to date (short)") },
+ { TimestampToLongDate, _T("DWORD timestamp to date (long)") },
+ { EmptyXStatusToDefaultName, _T("xStatus: empty xStatus name to default name") },
+ { SecondsToTimeDifference, _T("DWORD seconds to time difference") },
+ { TimezoneToTime, _T("BYTE timezone to time") },
+ { ByteToDay, _T("WORD to name of a day (0..6, 0 is Sunday)") },
+ { ByteToMonth, _T("WORD to name of a month (1..12, 1 is January)") },
+ { ByteToLanguage, _T("BYTE to language (ICQ)") }
+};
+
void InitTranslations()
{
dwNextFuncId = DBGetContactSettingDword(0, MODULE_ITEMS, "NextFuncId", 1);
- DBVTranslation internalTranslations[INT_TRANS_COUNT] =
- {
- {
- (TranslateFunc *)NullTranslation,
- _T("[No translation]"),
- },
- {
- (TranslateFunc *)WordToStatusDesc,
- _T("WORD to status description")
- },
- {
- (TranslateFunc *)TimestampToTime,
- _T("DWORD timestamp to time")
- },
- {
- (TranslateFunc *)TimestampToTimeDifference,
- _T("DWORD timestamp to time difference")
- },
- {
- (TranslateFunc *)ByteToYesNo,
- _T("BYTE to Yes/No")
- },
- {
- (TranslateFunc *)ByteToGender,
- _T("BYTE to Male/Female (ICQ)")
- },
- {
- (TranslateFunc *)WordToCountry,
- _T("WORD to country name")
- },
- {
- (TranslateFunc *)DwordToIp,
- _T("DWORD to ip address")
- },
- {
- (TranslateFunc *)DayMonthYearToDate,
- _T("<prefix>Day|Month|Year to date")
- },
- {
- (TranslateFunc *)DayMonthYearToAge,
- _T("<prefix>Day|Month|Year to age")
- },
- {
- (TranslateFunc *)HoursMinutesSecondsToTime,
- _T("<prefix>Hours|Minutes|Seconds to time")
- },
- {
- (TranslateFunc *)DayMonthYearHoursMinutesSecondsToTimeDifference,
- _T("<prefix>Day|Month|Year|Hours|Minutes|Seconds to time difference")
- },
- {
- (TranslateFunc *)DayMonthToDaysToNextBirthday,
- _T("<prefix>Day|Month to days to next birthday")
- },
- {
- (TranslateFunc *)TimestampToTimeNoSecs,
- _T("DWORD timestamp to time (no seconds)")
- },
- {
- (TranslateFunc *)HoursMinutesToTime,
- _T("<prefix>Hours|Minutes to time")
- },
- {
- (TranslateFunc *)TimestampToShortDate,
- _T("DWORD timestamp to date (short)")
- },
- {
- (TranslateFunc *)TimestampToLongDate,
- _T("DWORD timestamp to date (long)")
- },
- {
- (TranslateFunc *)EmptyXStatusToDefaultName,
- _T("xStatus: empty xStatus name to default name")
- },
- {
- (TranslateFunc *)SecondsToTimeDifference,
- _T("DWORD seconds to time difference")
- },
- {
- (TranslateFunc *)TimezoneToTime,
- _T("BYTE timezone to time")
- },
- {
- (TranslateFunc *)ByteToDay,
- _T("WORD to name of a day (0..6, 0 is Sunday)")
- },
- {
- (TranslateFunc *)ByteToMonth,
- _T("WORD to name of a month (1..12, 1 is January)")
- },
- {
- (TranslateFunc *)ByteToLanguage,
- _T("BYTE to language (ICQ)")
- }
- };
-
- for (int i = 0; i < INT_TRANS_COUNT; i++)
- AddTranslation(&internalTranslations[i]);
+ for (int i = 0; i < SIZEOF(internalTranslations); i++)
+ AddTranslation( &internalTranslations[i] );
hServiceAdd = CreateServiceFunction(MS_TIPPER_ADDTRANSLATION, ServiceAddTranslation);
}