diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-06-16 17:42:08 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2012-06-16 17:42:08 +0000 |
commit | 5975b2d0903bd5df128d55e20cd27d7c13b4e46c (patch) | |
tree | 6696492511c591fa8bf3b65a64864245caa3e7c2 /plugins/SimpleStatusMsg | |
parent | 8617d7e00546f892c9084f7c382648b23d8bbb63 (diff) |
another portion of "#ifdef Unicode" removal
git-svn-id: http://svn.miranda-ng.org/main/trunk@448 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SimpleStatusMsg')
-rw-r--r-- | plugins/SimpleStatusMsg/awaymsg.cpp | 32 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/main.cpp | 97 | ||||
-rw-r--r-- | plugins/SimpleStatusMsg/msgbox.cpp | 28 |
3 files changed, 58 insertions, 99 deletions
diff --git a/plugins/SimpleStatusMsg/awaymsg.cpp b/plugins/SimpleStatusMsg/awaymsg.cpp index 4932f475a1..5aebe1edb1 100644 --- a/plugins/SimpleStatusMsg/awaymsg.cpp +++ b/plugins/SimpleStatusMsg/awaymsg.cpp @@ -54,7 +54,7 @@ static char *StrNormNewlineA(char *szStr) return szNewStr;
}
-#ifdef _UNICODE
+
static TCHAR *StrNormNewline(TCHAR *tszStr)
{
if (tszStr == NULL) return NULL;
@@ -76,7 +76,7 @@ static TCHAR *StrNormNewline(TCHAR *tszStr) return tszNewStr;
}
-#endif
+
struct AwayMsgDlgData
{
@@ -137,7 +137,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP if (ack->result != ACKRESULT_SUCCESS) break;
if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; }
-#ifdef _UNICODE
+
DBVARIANT dbv;
bool unicode = !DBGetContactSetting(dat->hContact, "CList", "StatusMsg", &dbv) &&
(dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR);
@@ -151,7 +151,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP DBFreeVariant(&dbv);
}
else
-#endif
+
{
char *szMsg = StrNormNewlineA((char *)ack->lParam);
SetDlgItemTextA(hwndDlg, IDC_MSG, szMsg);
@@ -192,11 +192,9 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP memcpy(lptstrCopy, msg, len * sizeof(TCHAR));
lptstrCopy[len] = (TCHAR)0;
GlobalUnlock(hglbCopy);
-#ifdef _UNICODE
+
SetClipboardData(CF_UNICODETEXT, hglbCopy);
-#else
- SetClipboardData(CF_TEXT, hglbCopy);
-#endif
+
}
}
CloseClipboard();
@@ -270,7 +268,7 @@ static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP {
TCHAR msg[1024];
int len;
-#ifdef _UNICODE
+
DBVARIANT dbv;
bool unicode = !DBGetContactSetting(dat->hContact, "CList", "StatusMsg", &dbv) &&
(dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR);
@@ -284,7 +282,7 @@ static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP DBFreeVariant(&dbv);
}
else
-#endif
+
{
char *szMsg = StrNormNewlineA((char *)ack->lParam);
mir_sntprintf(msg, SIZEOF(msg), _T("%hs"), szMsg);
@@ -306,11 +304,9 @@ static INT_PTR CALLBACK CopyAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP memcpy(lptstrCopy, msg, len * sizeof(TCHAR));
lptstrCopy[len] = (TCHAR)0;
GlobalUnlock(hglbCopy);
-#ifdef _UNICODE
+
SetClipboardData(CF_UNICODETEXT, hglbCopy);
-#else
- SetClipboardData(CF_TEXT, hglbCopy);
-#endif
+
}
}
CloseClipboard();
@@ -375,7 +371,7 @@ static INT_PTR GoToURLMsgCommand(WPARAM wParam, LPARAM lParam) DBVARIANT dbv;
char *szMsg;
-#ifdef _UNICODE
+
int unicode = !DBGetContactSetting((HANDLE)wParam, "CList", "StatusMsg", &dbv) && (dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR);
DBFreeVariant(&dbv);
if (unicode)
@@ -384,7 +380,7 @@ static INT_PTR GoToURLMsgCommand(WPARAM wParam, LPARAM lParam) szMsg = mir_u2a(dbv.pwszVal);
}
else
-#endif
+
{
DBGetContactSettingString((HANDLE)wParam, "CList", "StatusMsg", &dbv);
szMsg = mir_strdup(dbv.pszVal);
@@ -446,7 +442,7 @@ static int AwayMsgPreBuildMenu(WPARAM wParam, LPARAM lParam) if (!iHidden)
{
DBVARIANT dbv;
-#ifdef _UNICODE
+
int unicode = !DBGetContactSetting((HANDLE)wParam, "CList", "StatusMsg", &dbv) && (dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR);
DBFreeVariant(&dbv);
if (unicode)
@@ -455,7 +451,7 @@ static int AwayMsgPreBuildMenu(WPARAM wParam, LPARAM lParam) szMsg = mir_u2a(dbv.pwszVal);
}
else
-#endif
+
{
DBGetContactSettingString((HANDLE)wParam, "CList", "StatusMsg", &dbv);
szMsg = mir_strdup(dbv.pszVal);
diff --git a/plugins/SimpleStatusMsg/main.cpp b/plugins/SimpleStatusMsg/main.cpp index 4cdaee3023..59f27d9920 100644 --- a/plugins/SimpleStatusMsg/main.cpp +++ b/plugins/SimpleStatusMsg/main.cpp @@ -212,19 +212,16 @@ TCHAR *InsertBuiltinVarsIntoMsg(TCHAR *in, const char *szProto, int status) else if (!_tcsnicmp(msg+i, _T("%fortunemsg%"), 12))
{
TCHAR *FortuneMsg;
-#ifdef _UNICODE
+
char *FortuneMsgA;
-#endif
+
if (!ServiceExists(MS_FORTUNEMSG_GETMESSAGE))
continue;
-#ifdef _UNICODE
+
FortuneMsgA = (char*)CallService(MS_FORTUNEMSG_GETMESSAGE, 0, 0);
FortuneMsg = mir_a2u(FortuneMsgA);
-#else
- FortuneMsg = (char*)CallService(MS_FORTUNEMSG_GETMESSAGE, 0, 0);
-#endif
if (lstrlen(FortuneMsg) > 12)
msg = (TCHAR *)mir_realloc(msg, (lstrlen(msg) + 1 + lstrlen(FortuneMsg) - 12) * sizeof(TCHAR));
@@ -232,29 +229,25 @@ TCHAR *InsertBuiltinVarsIntoMsg(TCHAR *in, const char *szProto, int status) MoveMemory(msg + i + lstrlen(FortuneMsg), msg + i + 12, (lstrlen(msg) - i - 11) * sizeof(TCHAR));
CopyMemory(msg + i, FortuneMsg, lstrlen(FortuneMsg) * sizeof(TCHAR));
-#ifdef _UNICODE
+
mir_free(FortuneMsg);
CallService(MS_FORTUNEMSG_FREEMEMORY, 0, (LPARAM)FortuneMsgA);
-#else
- CallService(MS_FORTUNEMSG_FREEMEMORY, 0, (LPARAM)FortuneMsg);
-#endif
+
}
else if (!_tcsnicmp(msg+i, _T("%protofortunemsg%"), 17))
{
TCHAR *FortuneMsg;
-#ifdef _UNICODE
+
char *FortuneMsgA;
-#endif
+
if (!ServiceExists(MS_FORTUNEMSG_GETPROTOMSG))
continue;
-#ifdef _UNICODE
+
FortuneMsgA = (char*)CallService(MS_FORTUNEMSG_GETPROTOMSG, (WPARAM)szProto, 0);
FortuneMsg = mir_a2u(FortuneMsgA);
-#else
- FortuneMsg = (char*)CallService(MS_FORTUNEMSG_GETPROTOMSG, (WPARAM)szProto, 0);
-#endif
+
if (lstrlen(FortuneMsg) > 17)
msg = (TCHAR *)mir_realloc(msg, (lstrlen(msg) + 1 + lstrlen(FortuneMsg) - 17) * sizeof(TCHAR));
@@ -262,29 +255,25 @@ TCHAR *InsertBuiltinVarsIntoMsg(TCHAR *in, const char *szProto, int status) MoveMemory(msg + i + lstrlen(FortuneMsg), msg + i + 17, (lstrlen(msg) - i - 16) * sizeof(TCHAR));
CopyMemory(msg + i, FortuneMsg, lstrlen(FortuneMsg) * sizeof(TCHAR));
-#ifdef _UNICODE
+
mir_free(FortuneMsg);
CallService(MS_FORTUNEMSG_FREEMEMORY, 0, (LPARAM)FortuneMsgA);
-#else
- CallService(MS_FORTUNEMSG_FREEMEMORY, 0, (LPARAM)FortuneMsg);
-#endif
+
}
else if (!_tcsnicmp(msg+i, _T("%statusfortunemsg%"), 18))
{
TCHAR *FortuneMsg;
-#ifdef _UNICODE
+
char *FortuneMsgA;
-#endif
+
if (!ServiceExists(MS_FORTUNEMSG_GETSTATUSMSG))
continue;
-#ifdef _UNICODE
+
FortuneMsgA = (char*)CallService(MS_FORTUNEMSG_GETSTATUSMSG, (WPARAM)status, 0);
FortuneMsg = mir_a2u(FortuneMsgA);
-#else
- FortuneMsg = (char*)CallService(MS_FORTUNEMSG_GETSTATUSMSG, (WPARAM)status, 0);
-#endif
+
if (lstrlen(FortuneMsg) > 18)
msg = (TCHAR *)mir_realloc(msg, (lstrlen(msg) + 1 + lstrlen(FortuneMsg) - 18) * sizeof(TCHAR));
@@ -292,12 +281,10 @@ TCHAR *InsertBuiltinVarsIntoMsg(TCHAR *in, const char *szProto, int status) MoveMemory(msg + i + lstrlen(FortuneMsg), msg + i + 18, (lstrlen(msg) - i - 17) * sizeof(TCHAR));
CopyMemory(msg + i, FortuneMsg, lstrlen(FortuneMsg) * sizeof(TCHAR));
-#ifdef _UNICODE
+
mir_free(FortuneMsg);
CallService(MS_FORTUNEMSG_FREEMEMORY, 0, (LPARAM)FortuneMsgA);
-#else
- CallService(MS_FORTUNEMSG_FREEMEMORY, 0, (LPARAM)FortuneMsg);
-#endif
+
}
else if (!_tcsnicmp(msg + i, _T("%time%"), 6))
{
@@ -727,16 +714,14 @@ static void Proto_SetAwayMsgT(const char *szProto, int iStatus, TCHAR *tszMsg) {
if (!(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_INDIVMODEMSG))
{
-#ifdef _UNICODE
+
if (CallProtoService(szProto, PS_SETAWAYMSGW, (WPARAM)iStatus, (LPARAM)tszMsg) == CALLSERVICE_NOTFOUND)
{
char *szMsg = mir_u2a(tszMsg);
CallProtoService(szProto, PS_SETAWAYMSG, (WPARAM)iStatus, (LPARAM)szMsg);
mir_free(szMsg);
}
-#else
- CallProtoService(szProto, PS_SETAWAYMSG, (WPARAM)iStatus, (LPARAM)tszMsg);
-#endif
+
}
}
@@ -748,16 +733,14 @@ static void Proto_SetStatus(const char *szProto, int iInitialStatus, int iStatus if (!(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_INDIVMODEMSG))
{
int iMsgStatus = CheckProtoSettings(szProto, iInitialStatus);
-#ifdef _UNICODE
+
if (CallProtoService(szProto, PS_SETAWAYMSGW, (WPARAM)iMsgStatus, (LPARAM)tszMsg) == CALLSERVICE_NOTFOUND)
{
char *szMsg = mir_u2a(tszMsg);
CallProtoService(szProto, PS_SETAWAYMSG, (WPARAM)iMsgStatus, (LPARAM)szMsg);
mir_free(szMsg);
}
-#else
- CallProtoService(szProto, PS_SETAWAYMSG, (WPARAM)iMsgStatus, (LPARAM)tszMsg);
-#endif
+
CallProtoService(szProto, PS_SETSTATUS, (WPARAM)iMsgStatus, 0);
}
if (ServiceExists(MS_KS_ANNOUNCESTATUSCHANGE))
@@ -1376,15 +1359,13 @@ static int ProcessProtoAck(WPARAM wParam,LPARAM lParam) if (ack->type == ACKTYPE_AWAYMSG && ack->result == ACKRESULT_SENTREQUEST && !ack->lParam)
{
TCHAR *tszMsg = GetAwayMessage(CallProtoService((char *)ack->szModule, PS_GETSTATUS, 0, 0), (char *)ack->szModule, TRUE, NULL);
-#ifdef _UNICODE
+
{
char *szMsg = mir_u2a(tszMsg);
CallContactService(ack->hContact, PSS_AWAYMSG, (WPARAM)(HANDLE)ack->hProcess, (LPARAM)szMsg);
if (szMsg) mir_free(szMsg);
}
-#else
- CallContactService(ack->hContact, PSS_AWAYMSG, (WPARAM)(HANDLE)ack->hProcess, (LPARAM)tszMsg);
-#endif
+
#ifdef _DEBUG
log2file("ProcessProtoAck(): Send away message \"" TCHAR_STR_PARAM "\" reply.", tszMsg);
#endif
@@ -1843,9 +1824,9 @@ static int CSStatusChange(WPARAM wParam, LPARAM lParam) DBVARIANT dbv;
char buff[80];
BOOL found = FALSE;
-#ifdef _UNICODE
+
wchar_t *szMsgW = mir_a2u(ps[i]->szMsg);
-#endif
+
#ifdef _DEBUG
log2file("CSStatusChange(): Set \"%s\" status message for %s.", ps[i]->szMsg, ps[i]->szName);
@@ -1856,11 +1837,9 @@ static int CSStatusChange(WPARAM wParam, LPARAM lParam) mir_snprintf(buff, SIZEOF(buff), "SMsg%d", j);
if (!DBGetContactSettingTString(NULL, "SimpleStatusMsg", buff, &dbv))
{
-#ifdef _UNICODE
+
if (!lstrcmp(dbv.ptszVal, szMsgW))
-#else
- if (!lstrcmp(dbv.ptszVal, ps[i]->szMsg))
-#endif
+
{
found = TRUE;
mir_snprintf(szSetting, SIZEOF(szSetting), "Last%sMsg", ps[i]->szName);
@@ -1879,16 +1858,12 @@ static int CSStatusChange(WPARAM wParam, LPARAM lParam) }
mir_snprintf(szSetting, SIZEOF(szSetting), "%sMsg", ps[i]->szName);
-#ifdef _UNICODE
+
DBWriteContactSettingWString(NULL, "SRAway", StatusModeToDbSetting(status_mode, szSetting), szMsgW);
msg = InsertVarsIntoMsg(szMsgW, ps[i]->szName, status_mode, NULL);
SaveMessageToDB(ps[i]->szName, szMsgW, TRUE);
mir_free(szMsgW);
-#else
- DBWriteContactSettingString(NULL, "SRAway", StatusModeToDbSetting(status_mode, szSetting), ps[i]->szMsg);
- msg = InsertVarsIntoMsg(ps[i]->szMsg, ps[i]->szName, status_mode, NULL);
- SaveMessageToDB(ps[i]->szName, ps[i]->szMsg, TRUE);
-#endif
+
SaveMessageToDB(ps[i]->szName, msg, FALSE);
mir_free(msg);
}
@@ -2031,10 +2006,8 @@ static int OnModulesLoaded(WPARAM wParam, LPARAM lParam) if (ServiceExists(MS_UPDATE_REGISTERFL))
#if defined(_WIN64)
CallService(MS_UPDATE_REGISTERFL, 4322, (LPARAM)&pluginInfo);
-#elif defined(_UNICODE)
- CallService(MS_UPDATE_REGISTERFL, 4321, (LPARAM)&pluginInfo);
#else
- CallService(MS_UPDATE_REGISTERFL, 4320, (LPARAM)&pluginInfo);
+ CallService(MS_UPDATE_REGISTERFL, 4321, (LPARAM)&pluginInfo);
#endif
IconsInit();
@@ -2179,7 +2152,7 @@ static INT_PTR sttGetAwayMessageT(WPARAM wParam, LPARAM lParam) return (INT_PTR)GetAwayMessage((int)wParam, (char*)lParam, TRUE, NULL);
}
-#ifdef UNICODE
+
static INT_PTR sttGetAwayMessage(WPARAM wParam, LPARAM lParam)
{
TCHAR* msg = GetAwayMessage((int)wParam, (char*)lParam, TRUE, NULL);
@@ -2187,7 +2160,7 @@ static INT_PTR sttGetAwayMessage(WPARAM wParam, LPARAM lParam) mir_free(msg);
return (INT_PTR)res;
}
-#endif
+
extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
{
@@ -2202,12 +2175,10 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) HookEventEx(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
HookEventEx(ME_PROTO_ACCLISTCHANGED, OnAccListChanged);
-#ifdef UNICODE
+
CreateServiceFunctionEx(MS_AWAYMSG_GETSTATUSMSG, sttGetAwayMessage);
CreateServiceFunctionEx(MS_AWAYMSG_GETSTATUSMSGW, sttGetAwayMessageT);
-#else
- CreateServiceFunctionEx(MS_AWAYMSG_GETSTATUSMSG, sttGetAwayMessageT);
-#endif
+
CreateServiceFunctionEx(MS_SIMPLESTATUSMSG_SETSTATUS, SetStatusModeFromExtern);
CreateServiceFunctionEx(MS_SIMPLESTATUSMSG_SHOWDIALOG, ShowStatusMessageDialog);
CreateServiceFunctionEx(MS_SIMPLESTATUSMSG_CHANGESTATUSMSG, ChangeStatusMsg);
diff --git a/plugins/SimpleStatusMsg/msgbox.cpp b/plugins/SimpleStatusMsg/msgbox.cpp index b984c03338..c6cec33b6b 100644 --- a/plugins/SimpleStatusMsg/msgbox.cpp +++ b/plugins/SimpleStatusMsg/msgbox.cpp @@ -184,11 +184,9 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) for (int i = 0; i < profileCount; ++i)
{
CallService(MS_SS_GETPROFILENAME, (WPARAM)i, (LPARAM)buff1);
-#ifdef _UNICODE
+
status_desc = mir_a2u(buff1);
-#else
- status_desc = (char*)buff1;
-#endif
+
cbei.iItem = j;
cbei.pszText = (LPTSTR)status_desc;
cbei.cchTextMax = sizeof(status_desc);
@@ -200,9 +198,9 @@ HWND WINAPI CreateStatusComboBoxEx(HWND hwndDlg, struct MsgBoxData *data) cbei.iSelectedImage = statusicon_nr[k];
}
cbei.lParam = (LPARAM)40083+i;
-#ifdef _UNICODE
+
mir_free(status_desc);
-#endif
+
if (SendMessage(handle, CBEM_INSERTITEM, 0, (LPARAM)&cbei) == -1)
break;
j++;
@@ -498,11 +496,9 @@ VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, HWND edit_control) break;
case ID__VARIABLES:
-#ifdef _UNICODE
+
CallService(MS_UTILS_OPENURL,1,(LPARAM)"http://addons.miranda-im.org/details.php?action=viewfile&id=3815");
-#else
- CallService(MS_UTILS_OPENURL,1,(LPARAM)"http://addons.miranda-im.org/details.php?action=viewfile&id=3814");
-#endif
+
break;
case ID__VARIABLES_MOREVARIABLES:
@@ -539,11 +535,9 @@ VOID APIENTRY HandlePopupMenu(HWND hwnd, POINT pt, HWND edit_control) memcpy(lptstrCopy, item_string, len * sizeof(TCHAR));
lptstrCopy[len] = (TCHAR)0;
GlobalUnlock(hglbCopy);
-#ifdef _UNICODE
+
SetClipboardData(CF_UNICODETEXT, hglbCopy);
-#else
- SetClipboardData(CF_TEXT, hglbCopy);
-#endif
+
}
}
CloseClipboard();
@@ -878,13 +872,11 @@ void ChangeDlgStatus(HWND hwndDlg, struct MsgBoxData *msgbox_data, int iStatus) else if (iStatus > ID_STATUS_CURRENT)
{
TCHAR buff[128];
-#ifdef _UNICODE
+
char buff1[128];
CallService(MS_SS_GETPROFILENAME, iStatus - 40083, (LPARAM)buff1);
MultiByteToWideChar(CallService(MS_LANGPACK_GETCODEPAGE, 0, 0), 0, buff1, -1, buff, 128);
-#else
- CallService(MS_SS_GETPROFILENAME, iStatus - 40083, (LPARAM)buff);
-#endif
+
mir_sntprintf(szTitle, SIZEOF(szTitle), TranslateT("%s Message (%s)"), (TCHAR*)buff, szProtoName);
}
else
|