summaryrefslogtreecommitdiff
path: root/yapp
diff options
context:
space:
mode:
Diffstat (limited to 'yapp')
-rw-r--r--yapp/common.h2
-rw-r--r--yapp/options.cpp32
-rw-r--r--yapp/popup_history.cpp14
-rw-r--r--yapp/popup_history.h2
-rw-r--r--yapp/popups2.cpp155
-rw-r--r--yapp/popups2_8.vcproj12
-rw-r--r--yapp/popwin.cpp52
-rw-r--r--yapp/services.cpp13
-rw-r--r--yapp/str_utils.cpp229
-rw-r--r--yapp/str_utils.h53
-rw-r--r--yapp/version.h6
11 files changed, 460 insertions, 110 deletions
diff --git a/yapp/common.h b/yapp/common.h
index 967aef3..114aa47 100644
--- a/yapp/common.h
+++ b/yapp/common.h
@@ -46,7 +46,7 @@
#include <m_popup.h>
#include <m_updater.h>
-#include <m_fontservicew.h>
+#include <m_fontservice.h>
#include <m_avatars.h>
#include <m_notify.h>
diff --git a/yapp/options.cpp b/yapp/options.cpp
index 5f3e0d5..ed77921 100644
--- a/yapp/options.cpp
+++ b/yapp/options.cpp
@@ -3,6 +3,7 @@
#include "resource.h"
#include "popwin.h"
#include <commctrl.h>
+#include "str_utils.h"
Options options;
@@ -84,18 +85,18 @@ void SaveOptions() {
}
void ShowExamplePopups() {
- POPUPDATAW pd = {0};
+ POPUPDATAT pd = {0};
pd.lchIcon = hPopupIcon;
- wcscpy(pd.lpwzContactName, TranslateT("Example"));
- wcscpy(pd.lpwzText, TranslateT("The quick brown fox jumped over the lazy dog."));
- CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&pd, 0);
- wcscpy(pd.lpwzContactName, TranslateT("Example With a Long Title"));
- wcscpy(pd.lpwzText, TranslateT("The quick brown fox jumped over the lazy dog."));
- CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&pd, 0);
- wcscpy(pd.lpwzContactName, TranslateT("Example"));
- wcscpy(pd.lpwzText, TranslateT("Thequickbrownfoxjumpedoverthelazydog."));
- CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&pd, 0);
+ _tcscpy(pd.lptzContactName, TranslateT("Example"));
+ _tcscpy(pd.lptzText, TranslateT("The quick brown fox jumped over the lazy dog."));
+ CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, 0);
+ _tcscpy(pd.lptzContactName, TranslateT("Example With a Long Title"));
+ _tcscpy(pd.lptzText, TranslateT("The quick brown fox jumped over the lazy dog."));
+ CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, 0);
+ _tcscpy(pd.lptzContactName, TranslateT("Example"));
+ _tcscpy(pd.lptzText, TranslateT("Thequickbrownfoxjumpedoverthelazydog."));
+ CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, 0);
HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
while(hContact) {
@@ -103,8 +104,8 @@ void ShowExamplePopups() {
AVATARCACHEENTRY *ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)hContact, 0);
if(ace && ace->dwFlags & AVS_BITMAP_VALID) {
pd.lchContact = hContact;
- wcscpy(pd.lpwzText, TranslateT("An avatar."));
- CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&pd, 0);
+ _tcscpy(pd.lptzText, TranslateT("An avatar."));
+ CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, 0);
break;
}
}
@@ -180,14 +181,11 @@ static BOOL CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
lvI.mask = LVIF_TEXT;
char *strptr;
- wchar_t buff[256];
+ TCHAR buff[256];
int i = 0;
for(; i < 10; i++) {
strptr = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)(ID_STATUS_OFFLINE + i), (LPARAM)0);
- int cp = CP_ACP;
- if(ServiceExists(MS_LANGPACK_GETCODEPAGE))
- cp = (int)CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
- MultiByteToWideChar(cp, 0, strptr, -1, buff, 256);
+ a2t(strptr, buff, 256);
lvI.pszText = buff;
lvI.iItem = i;
ListView_InsertItem(hwndList, &lvI);
diff --git a/yapp/popup_history.cpp b/yapp/popup_history.cpp
index 6e9b59e..b10062f 100644
--- a/yapp/popup_history.cpp
+++ b/yapp/popup_history.cpp
@@ -154,17 +154,17 @@ void RefreshPopupHistory(HWND hWnd)
int i;
LVITEM item = {0};
item.mask = LVIF_TEXT;
- wchar_t buffer[1024];
+ TCHAR buffer[1024];
struct tm *myTime;
for (i = 0; i < lstPopupHistory.Count(); i++)
{
item.iItem = i;
PopupHistoryData *popupItem = lstPopupHistory.Get(i);
- item.pszText = popupItem->titleW;
+ item.pszText = popupItem->titleT;
ListView_InsertItem(hHistoryList, &item);
- ListView_SetItemText(hHistoryList, i, 1, popupItem->messageW);
+ ListView_SetItemText(hHistoryList, i, 1, popupItem->messageT);
myTime = localtime(&popupItem->timestamp);
- wcsftime(buffer, 1024, L"%c", myTime);
+ _tcsftime(buffer, 1024, _T("%c"), myTime);
ListView_SetItemText(hHistoryList, i, 2, buffer);
}
@@ -315,13 +315,13 @@ BOOL CALLBACK DlgProcHistLst(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
LVCOLUMN col;
col.mask = LVCF_TEXT | LVCF_WIDTH;
- col.pszText = L"Title";
+ col.pszText = _T("Title");
col.cx = 100;
ListView_InsertColumn(hHistoryList, 0, &col);
- col.pszText = L"Message";
+ col.pszText = _T("Message");
col.cx = 450;
ListView_InsertColumn(hHistoryList, 1, &col);
- col.pszText = L"Timestamp";
+ col.pszText = _T("Timestamp");
col.cx = 115;
ListView_InsertColumn(hHistoryList, 2, &col);
RefreshPopupHistory(hWnd);
diff --git a/yapp/popup_history.h b/yapp/popup_history.h
index 8bb6c7b..7bc49a0 100644
--- a/yapp/popup_history.h
+++ b/yapp/popup_history.h
@@ -10,10 +10,12 @@ struct PopupHistoryData{
union{
char *message;
wchar_t *messageW;
+ TCHAR *messageT;
};
union{
char *title;
wchar_t *titleW;
+ TCHAR *titleT;
};
time_t timestamp;
};
diff --git a/yapp/popups2.cpp b/yapp/popups2.cpp
index 3439832..1027289 100644
--- a/yapp/popups2.cpp
+++ b/yapp/popups2.cpp
@@ -8,30 +8,35 @@
#include "options.h"
#include "popwin.h"
#include "notify.h"
+#include "str_utils.h"
HMODULE hInst = 0;
HANDLE mainThread = 0;
MNOTIFYLINK *notifyLink = 0;
-int code_page = CP_ACP;
-
// used to work around a bug in neweventnotify and others with the address passed in the GetPluginData function
bool ignore_gpd_passed_addy = false;
-FontIDW font_id_firstline = {0}, font_id_secondline = {0}, font_id_time = {0};
-ColourIDW colour_id_bg = {0}, colour_id_border = {0}, colour_id_sidebar = {0};
+FontID font_id_firstline = {0}, font_id_secondline = {0}, font_id_time = {0};
+ColourID colour_id_bg = {0}, colour_id_border = {0}, colour_id_sidebar = {0};
+FontIDW font_id_firstlinew = {0}, font_id_secondlinew = {0}, font_id_timew = {0};
+ColourIDW colour_id_bgw = {0}, colour_id_borderw = {0}, colour_id_sidebarw = {0};
+
COLORREF colBg = GetSysColor(COLOR_3DSHADOW);
HFONT hFontFirstLine = 0, hFontSecondLine = 0, hFontTime = 0;
COLORREF colFirstLine = RGB(255, 0, 0), colSecondLine = 0, colTime = RGB(0, 0, 255), colBorder = RGB(0, 0, 0), colSidebar = RGB(128, 128, 128);
-
// hooked here so it's in the main thread
HANDLE hAvChangeEvent = 0;
PLUGININFO pluginInfo={
sizeof(PLUGININFO),
+#ifndef _UNICODE
+ __PLUGIN_NAME " (ANSI)",
+#else
__PLUGIN_NAME,
+#endif
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
__DESC,
__AUTHOR,
@@ -59,19 +64,35 @@ extern "C" POPUPS2_API PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion)
int ReloadFont(WPARAM wParam, LPARAM lParam) {
LOGFONT log_font;
- if(hFontFirstLine) DeleteObject(hFontFirstLine);
- colFirstLine = CallService(MS_FONT_GETW, (WPARAM)&font_id_firstline, (LPARAM)&log_font);
- hFontFirstLine = CreateFontIndirect(&log_font);
- if(hFontSecondLine) DeleteObject(hFontSecondLine);
- colSecondLine = CallService(MS_FONT_GETW, (WPARAM)&font_id_secondline, (LPARAM)&log_font);
- hFontSecondLine = CreateFontIndirect(&log_font);
- if(hFontTime) DeleteObject(hFontTime);
- colTime = CallService(MS_FONT_GETW, (WPARAM)&font_id_time, (LPARAM)&log_font);
- hFontTime = CreateFontIndirect(&log_font);
-
- colBg = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_bg, 0);
- colBorder = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_border, 0);
- colSidebar = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_sidebar, 0);
+ if(ServiceExists(MS_FONT_GETW)) {
+ if(hFontFirstLine) DeleteObject(hFontFirstLine);
+ colFirstLine = CallService(MS_FONT_GETW, (WPARAM)&font_id_firstlinew, (LPARAM)&log_font);
+ hFontFirstLine = CreateFontIndirect(&log_font);
+ if(hFontSecondLine) DeleteObject(hFontSecondLine);
+ colSecondLine = CallService(MS_FONT_GETW, (WPARAM)&font_id_secondlinew, (LPARAM)&log_font);
+ hFontSecondLine = CreateFontIndirect(&log_font);
+ if(hFontTime) DeleteObject(hFontTime);
+ colTime = CallService(MS_FONT_GETW, (WPARAM)&font_id_timew, (LPARAM)&log_font);
+ hFontTime = CreateFontIndirect(&log_font);
+
+ colBg = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_bgw, 0);
+ colBorder = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_borderw, 0);
+ colSidebar = CallService(MS_COLOUR_GETW, (WPARAM)&colour_id_sidebarw, 0);
+ } else {
+ if(hFontFirstLine) DeleteObject(hFontFirstLine);
+ colFirstLine = CallService(MS_FONT_GET, (WPARAM)&font_id_firstline, (LPARAM)&log_font);
+ hFontFirstLine = CreateFontIndirect(&log_font);
+ if(hFontSecondLine) DeleteObject(hFontSecondLine);
+ colSecondLine = CallService(MS_FONT_GET, (WPARAM)&font_id_secondline, (LPARAM)&log_font);
+ hFontSecondLine = CreateFontIndirect(&log_font);
+ if(hFontTime) DeleteObject(hFontTime);
+ colTime = CallService(MS_FONT_GET, (WPARAM)&font_id_time, (LPARAM)&log_font);
+ hFontTime = CreateFontIndirect(&log_font);
+
+ colBg = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_bg, 0);
+ colBorder = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_border, 0);
+ colSidebar = CallService(MS_COLOUR_GET, (WPARAM)&colour_id_sidebar, 0);
+ }
return 0;
}
@@ -108,61 +129,121 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) {
}
if(ServiceExists(MS_FONT_REGISTERW)) {
+ font_id_firstlinew.cbSize = sizeof(FontIDW);
+ font_id_firstlinew.flags = FIDF_ALLOWEFFECTS;
+ t2w(TranslateT("Popups"), font_id_firstlinew.group, 64);
+ t2w(TranslateT("First line"), font_id_firstlinew.name, 64);
+ strcpy(font_id_firstlinew.dbSettingsGroup, MODULE);
+ strcpy(font_id_firstlinew.prefix, "FontFirst");
+ font_id_firstlinew.order = 0;
+
+ font_id_secondlinew.cbSize = sizeof(FontIDW);
+ font_id_secondlinew.flags = FIDF_ALLOWEFFECTS;
+ t2w(TranslateT("Popups"), font_id_secondlinew.group, 64);
+ t2w(TranslateT("Second line"), font_id_secondlinew.name, 64);
+ strcpy(font_id_secondlinew.dbSettingsGroup, MODULE);
+ strcpy(font_id_secondlinew.prefix, "FontSecond");
+ font_id_secondlinew.order = 1;
+
+ font_id_timew.cbSize = sizeof(FontIDW);
+ font_id_timew.flags = FIDF_ALLOWEFFECTS;
+ t2w(TranslateT("Popups"), font_id_timew.group, 64);
+ t2w(TranslateT("Time"), font_id_timew.name, 64);
+ strcpy(font_id_timew.dbSettingsGroup, MODULE);
+ strcpy(font_id_timew.prefix, "FontTime");
+ font_id_timew.order = 2;
+
+ CallService(MS_FONT_REGISTERW, (WPARAM)&font_id_firstlinew, 0);
+ CallService(MS_FONT_REGISTERW, (WPARAM)&font_id_secondlinew, 0);
+ CallService(MS_FONT_REGISTERW, (WPARAM)&font_id_timew, 0);
+
+ colour_id_bgw.cbSize = sizeof(ColourIDW);
+ t2w(TranslateT("Popups"), colour_id_bgw.group, 64);
+ t2w(TranslateT("Background"), colour_id_bgw.name, 64);
+ strcpy(colour_id_bgw.dbSettingsGroup, MODULE);
+ strcpy(colour_id_bgw.setting, "ColourBg");
+ colour_id_bgw.defcolour = GetSysColor(COLOR_3DSHADOW);
+ colour_id_bgw.order = 0;
+
+ colour_id_borderw.cbSize = sizeof(ColourIDW);
+ t2w(TranslateT("Popups"), colour_id_borderw.group, 64);
+ t2w(TranslateT("Border"), colour_id_borderw.name, 64);
+ strcpy(colour_id_borderw.dbSettingsGroup, MODULE);
+ strcpy(colour_id_borderw.setting, "ColourBorder");
+ colour_id_borderw.defcolour = RGB(0, 0, 0);
+ colour_id_borderw.order = 1;
+
+ colour_id_sidebarw.cbSize = sizeof(ColourIDW);
+ t2w(TranslateT("Popups"), colour_id_sidebarw.group, 64);
+ t2w(TranslateT("Sidebar"), colour_id_sidebarw.name, 64);
+ strcpy(colour_id_sidebarw.dbSettingsGroup, MODULE);
+ strcpy(colour_id_sidebarw.setting, "ColourSidebar");
+ colour_id_sidebarw.defcolour = RGB(128, 128, 128);
+ colour_id_sidebarw.order = 2;
+
+ CallService(MS_COLOUR_REGISTERW, (WPARAM)&colour_id_bgw, 0);
+ CallService(MS_COLOUR_REGISTERW, (WPARAM)&colour_id_borderw, 0);
+ CallService(MS_COLOUR_REGISTERW, (WPARAM)&colour_id_sidebarw, 0);
+
+ ReloadFont(0, 0);
+
+ hEventReloadFont = HookEvent(ME_FONT_RELOAD, ReloadFont);
+ } else if(ServiceExists(MS_FONT_REGISTER)) {
font_id_firstline.cbSize = sizeof(FontIDW);
font_id_firstline.flags = FIDF_ALLOWEFFECTS;
- wcscpy(font_id_firstline.group, TranslateT("Popups"));
- wcscpy(font_id_firstline.name, TranslateT("First Line"));
+ t2a(TranslateT("Popups"), font_id_firstline.group, 64);
+ t2a(TranslateT("First line"), font_id_firstline.name, 64);
strcpy(font_id_firstline.dbSettingsGroup, MODULE);
strcpy(font_id_firstline.prefix, "FontFirst");
font_id_firstline.order = 0;
font_id_secondline.cbSize = sizeof(FontIDW);
font_id_secondline.flags = FIDF_ALLOWEFFECTS;
- wcscpy(font_id_secondline.group, TranslateT("Popups"));
- wcscpy(font_id_secondline.name, TranslateT("Second Line"));
+ t2a(TranslateT("Popups"), font_id_secondline.group, 64);
+ t2a(TranslateT("Second line"), font_id_secondline.name, 64);
strcpy(font_id_secondline.dbSettingsGroup, MODULE);
strcpy(font_id_secondline.prefix, "FontSecond");
font_id_secondline.order = 1;
font_id_time.cbSize = sizeof(FontIDW);
font_id_time.flags = FIDF_ALLOWEFFECTS;
- wcscpy(font_id_time.group, TranslateT("Popups"));
- wcscpy(font_id_time.name, TranslateT("Time"));
+ t2a(TranslateT("Popups"), font_id_time.group, 64);
+ t2a(TranslateT("Time"), font_id_time.name, 64);
strcpy(font_id_time.dbSettingsGroup, MODULE);
strcpy(font_id_time.prefix, "FontTime");
font_id_time.order = 2;
- CallService(MS_FONT_REGISTERW, (WPARAM)&font_id_firstline, 0);
- CallService(MS_FONT_REGISTERW, (WPARAM)&font_id_secondline, 0);
- CallService(MS_FONT_REGISTERW, (WPARAM)&font_id_time, 0);
+ CallService(MS_FONT_REGISTER, (WPARAM)&font_id_firstline, 0);
+ CallService(MS_FONT_REGISTER, (WPARAM)&font_id_secondline, 0);
+ CallService(MS_FONT_REGISTER, (WPARAM)&font_id_time, 0);
colour_id_bg.cbSize = sizeof(ColourIDW);
- wcscpy(colour_id_bg.group, TranslateT("Popups"));
- wcscpy(colour_id_bg.name, TranslateT("Background"));
+ t2a(TranslateT("Popups"), colour_id_bg.group, 64);
+ t2a(TranslateT("Background"), colour_id_bg.name, 64);
strcpy(colour_id_bg.dbSettingsGroup, MODULE);
strcpy(colour_id_bg.setting, "ColourBg");
colour_id_bg.defcolour = GetSysColor(COLOR_3DSHADOW);
colour_id_bg.order = 0;
colour_id_border.cbSize = sizeof(ColourIDW);
- wcscpy(colour_id_border.group, TranslateT("Popups"));
- wcscpy(colour_id_border.name, TranslateT("Border"));
+ t2a(TranslateT("Popups"), colour_id_border.group, 64);
+ t2a(TranslateT("Border"), colour_id_border.name, 64);
strcpy(colour_id_border.dbSettingsGroup, MODULE);
strcpy(colour_id_border.setting, "ColourBorder");
colour_id_border.defcolour = RGB(0, 0, 0);
colour_id_border.order = 1;
colour_id_sidebar.cbSize = sizeof(ColourIDW);
- wcscpy(colour_id_sidebar.group, TranslateT("Popups"));
- wcscpy(colour_id_sidebar.name, TranslateT("Sidebar"));
+ t2a(TranslateT("Popups"), colour_id_sidebar.group, 64);
+ t2a(TranslateT("Sidebar"), colour_id_sidebar.name, 64);
strcpy(colour_id_sidebar.dbSettingsGroup, MODULE);
strcpy(colour_id_sidebar.setting, "ColourSidebar");
colour_id_sidebar.defcolour = RGB(128, 128, 128);
colour_id_sidebar.order = 2;
- CallService(MS_COLOUR_REGISTERW, (WPARAM)&colour_id_bg, 0);
- CallService(MS_COLOUR_REGISTERW, (WPARAM)&colour_id_border, 0);
- CallService(MS_COLOUR_REGISTERW, (WPARAM)&colour_id_sidebar, 0);
+ CallService(MS_COLOUR_REGISTER, (WPARAM)&colour_id_bg, 0);
+ CallService(MS_COLOUR_REGISTER, (WPARAM)&colour_id_border, 0);
+ CallService(MS_COLOUR_REGISTER, (WPARAM)&colour_id_sidebar, 0);
ReloadFont(0, 0);
@@ -207,6 +288,8 @@ extern "C" int POPUPS2_API Load(PLUGINLINK *link) {
pluginLink = link;
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0);
+ set_codepage();
+
INITCOMMONCONTROLSEX icex;
// Ensure that the common control DLL is loaded (for listview)
diff --git a/yapp/popups2_8.vcproj b/yapp/popups2_8.vcproj
index 93dcc11..f4bdc33 100644
--- a/yapp/popups2_8.vcproj
+++ b/yapp/popups2_8.vcproj
@@ -21,7 +21,7 @@
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
- CharacterSet="1"
+ CharacterSet="2"
WholeProgramOptimization="0"
>
<Tool
@@ -43,7 +43,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../include"
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POPUPS2_EXPORTS;_UNICODE;UNICODE"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POPUPS2_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@@ -272,6 +272,10 @@
RelativePath=".\services.cpp"
>
</File>
+ <File
+ RelativePath=".\str_utils.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="Header Files"
@@ -315,6 +319,10 @@
>
</File>
<File
+ RelativePath=".\str_utils.h"
+ >
+ </File>
+ <File
RelativePath=".\version.h"
>
</File>
diff --git a/yapp/popwin.cpp b/yapp/popwin.cpp
index 9915961..3e327b3 100644
--- a/yapp/popwin.cpp
+++ b/yapp/popwin.cpp
@@ -2,6 +2,7 @@
#include "popwin.h"
#include "message_pump.h"
#include "options.h"
+#include "str_utils.h"
HMODULE hUserDll;
BOOL (WINAPI *MySetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD) = 0;
@@ -149,19 +150,6 @@ struct PopupWindowData {
HANDLE hNotify;
};
-void trim(TCHAR *str) {
- int len = _tcslen(str), pos;
- // trim whitespace (e.g. from OTR detection)
- for(pos = len - 1; pos >= 0; pos--) {
- if(str[pos] == _T(' ') || str[pos] == _T('\t') || str[pos] == _T('\r') || str[pos] == _T('\n')) str[pos] = 0;
- else break;
- }
-
- // remove tabs
- for(pos = len - 1; pos >= 0; pos--)
- if(str[pos] == _T('\t')) str[pos] = _T(' ');
-}
-
LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
PopupWindowData *pwd = (PopupWindowData *)GetWindowLong(hwnd, GWL_USERDATA);
POPUPDATAW *pd = 0;
@@ -176,8 +164,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
pwd->pd = pd;
pwd->hNotify = 0;
- trim(pwd->pd->lpwzContactName);
- trim(pwd->pd->lpwzText);
+ trimW(pwd->pd->lpwzContactName);
+ trimW(pwd->pd->lpwzText);
pwd->is_round = options.round;
pwd->av_is_round = options.av_round;
@@ -417,7 +405,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if(pwd->custom_col) SetTextColor(ps.hdc, pd->colorText);
else SetTextColor(ps.hdc, colTime);
if(hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime);
- DrawText(ps.hdc, pwd->tbuff, wcslen(pwd->tbuff), &avr, DT_VCENTER | DT_CENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
+ DrawText(ps.hdc, pwd->tbuff, _tcslen(pwd->tbuff), &avr, DT_VCENTER | DT_CENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
avr.top = avr.bottom + options.av_padding;
}
@@ -465,12 +453,12 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
case PT_LEFT:
ttr.left = textxmin; ttr.right = ttr.left + pwd->time_width;
textxmin += pwd->time_width + options.padding;
- DrawText(ps.hdc, pwd->tbuff, wcslen(pwd->tbuff), &ttr, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
+ DrawText(ps.hdc, pwd->tbuff, _tcslen(pwd->tbuff), &ttr, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
break;
case PT_RIGHT:
ttr.right = textxmax; ttr.left = ttr.right - pwd->time_width;
textxmax -= pwd->time_width + options.padding;
- DrawText(ps.hdc, pwd->tbuff, wcslen(pwd->tbuff), &ttr, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
+ DrawText(ps.hdc, pwd->tbuff, _tcslen(pwd->tbuff), &ttr, DT_VCENTER | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX);
break;
default:
break;
@@ -486,7 +474,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if(pwd->custom_col) SetTextColor(ps.hdc, pd->colorText);
else SetTextColor(ps.hdc, colFirstLine);
- DrawText(ps.hdc, pd->lpwzContactName, wcslen(pd->lpwzContactName), &tr, DT_VCENTER | DT_LEFT | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX);
+ DrawTextW(ps.hdc, pd->lptzContactName, wcslen(pd->lpwzContactName), &tr, DT_VCENTER | DT_LEFT | DT_END_ELLIPSIS | DT_SINGLELINE | DT_NOPREFIX);
// second line(s)
int len_second = wcslen(pd->lpwzText);
@@ -500,7 +488,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
GetClientRect(hwnd, &r);
tr.left = r.left + options.padding + options.text_indent; tr.right = r.right - options.padding; tr.top = tr.bottom + options.padding; tr.bottom = r.bottom - options.padding;
- DrawText(ps.hdc, pd->lpwzText, len_second, &tr, DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS);
+ DrawTextW(ps.hdc, pd->lpwzText, len_second, &tr, DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS);
}
EndPaint(hwnd, &ps);
@@ -586,14 +574,14 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if(options.time_layout != PT_NONE) {
SIZE size_t;
if(hFontTime) SelectObject(hdc, (HGDIOBJ)hFontTime);
- GetTextExtentPoint32(hdc, pwd->tbuff, wcslen(pwd->tbuff), &size_t);
+ GetTextExtentPoint32(hdc, pwd->tbuff, _tcslen(pwd->tbuff), &size_t);
pwd->time_height = size_t.cy;
pwd->time_width = size_t.cx;
}
// titlebar height
if(hFontFirstLine) SelectObject(hdc, (HGDIOBJ)hFontFirstLine);
- GetTextExtentPoint32(hdc, pd->lpwzContactName, wcslen(pd->lpwzContactName), &size);
+ GetTextExtentPoint32W(hdc, pd->lpwzContactName, wcslen(pd->lptzContactName), &size);
pwd->tb_height = size.cy;
if(options.time_layout == PT_LEFT || options.time_layout == PT_RIGHT) {
if(pwd->tb_height < pwd->time_height) pwd->tb_height = pwd->time_height;
@@ -617,7 +605,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
// text height
- int len_second = wcslen(pd->lpwzText);
+ int len_second = wcslen(pd->lptzText);
if(len_second) {
RECT r;
r.left = r.top = 0;
@@ -630,7 +618,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
r.right -= pwd->time_width + options.padding;
if(hFontSecondLine) SelectObject(hdc, (HGDIOBJ)hFontSecondLine);
- DrawText(hdc, pd->lpwzText, len_second, &r, DT_CALCRECT | DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS);
+ DrawTextW(hdc, pd->lpwzText, len_second, &r, DT_CALCRECT | DT_NOPREFIX | DT_WORDBREAK | DT_EXTERNALLEADING | DT_TOP | DT_LEFT | DT_WORD_ELLIPSIS);
pwd->text_height = r.bottom;
}
@@ -694,23 +682,11 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
pd->lchContact = (HANDLE)MNotifyGetDWord(pwd->hNotify, NFOPT_CONTACT, 0);
pd->lchIcon = (HICON)MNotifyGetDWord(pwd->hNotify, NFOPT_ICON, 0);
const wchar_t *swzName = MNotifyGetWString(pwd->hNotify, NFOPT_TITLEW, 0);
- if(swzName) {
- wcsncpy(pd->lpwzContactName, swzName, MAX_CONTACTNAME);
- } else {
- const char *szName = MNotifyGetString(pwd->hNotify, NFOPT_TITLE, 0);
- if(szName) MultiByteToWideChar(code_page, 0, szName, -1, pd->lpwzContactName, MAX_CONTACTNAME);
- else pd->lpwzContactName[0] = 0;
- }
+ wcsncpy(pd->lpwzContactName, swzName, MAX_CONTACTNAME);
pd->lpwzContactName[MAX_CONTACTNAME - 1] = 0;
const wchar_t *swzText = MNotifyGetWString(pwd->hNotify, NFOPT_TEXTW, 0);
- if(swzText) {
- wcsncpy(pd->lpwzText, swzText, MAX_SECONDLINE);
- } else {
- const char *szText = MNotifyGetString(pwd->hNotify, NFOPT_TEXT, 0);
- if(szText) MultiByteToWideChar(code_page, 0, szText, -1, pd->lpwzText, MAX_SECONDLINE);
- else pd->lpwzText[0] = 0;
- }
+ wcsncpy(pd->lpwzText, swzText, MAX_SECONDLINE);
pd->lpwzText[MAX_SECONDLINE - 1] = 0;
InvalidateRect(hwnd, 0, TRUE);
RepositionWindows();
diff --git a/yapp/services.cpp b/yapp/services.cpp
index e0b6bff..0b99f20 100644
--- a/yapp/services.cpp
+++ b/yapp/services.cpp
@@ -5,6 +5,7 @@
#include "resource.h"
#include "popup_history.h"
#include <time.h>
+#include "str_utils.h"
#define NUM_SERVICES 13
HANDLE hService[NUM_SERVICES];
@@ -285,14 +286,14 @@ int PopupChange(WPARAM wParam, LPARAM lParam) {
int ShowMessage(WPARAM wParam, LPARAM lParam) {
if(!DBGetContactSettingByte(0, MODULE, "Enabled", 1)) return 0;
- POPUPDATAW pd = {0};
- wcscpy(pd.lpwzContactName, lParam == SM_WARNING ? _T("Warning") : _T("Notification"));
+ POPUPDATAT pd = {0};
+ _tcscpy(pd.lptzContactName, lParam == SM_WARNING ? _T("Warning") : _T("Notification"));
pd.lchIcon = LoadIcon(0, lParam == SM_WARNING ? IDI_WARNING : IDI_INFORMATION);
- wchar_t buff[MAX_SECONDLINE];
- MultiByteToWideChar(code_page, 0, (char *)wParam, -1, buff, MAX_SECONDLINE);
- wcscpy(pd.lpwzText, buff);
+ TCHAR buff[MAX_SECONDLINE];
+ a2t((char *)wParam, buff, MAX_SECONDLINE);
+ _tcscpy(pd.lptzText, buff);
- CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&pd, 0);
+ CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, 0);
return 0;
}
diff --git a/yapp/str_utils.cpp b/yapp/str_utils.cpp
new file mode 100644
index 0000000..d9e3575
--- /dev/null
+++ b/yapp/str_utils.cpp
@@ -0,0 +1,229 @@
+#include "common.h"
+#include "str_utils.h"
+
+int code_page = CP_ACP;
+
+void set_codepage() {
+ if(ServiceExists(MS_LANGPACK_GETCODEPAGE))
+ code_page = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
+}
+
+bool a2w(const char *as, wchar_t *buff, int bufflen){
+ if(as) MultiByteToWideChar(code_page, 0, as, -1, buff, bufflen);
+ return true;
+}
+
+bool w2a(const wchar_t *ws, char *buff, int bufflen) {
+ if(ws) WideCharToMultiByte(code_page, 0, ws, -1, buff, bufflen, 0, 0);
+ return true;
+}
+
+bool u2w(const char *us, wchar_t *buff, int bufflen) {
+ if(us) MultiByteToWideChar(CP_UTF8, 0, us, -1, buff, bufflen);
+ return true;
+}
+
+bool w2u(const wchar_t *ws, char *buff, int bufflen) {
+ if(ws) WideCharToMultiByte(CP_UTF8, 0, ws, -1, buff, bufflen, 0, 0);
+ return true;
+}
+
+bool a2u(const char *as, char *buff, int bufflen) {
+ if(!as) return false;
+
+ wchar_t *ws = a2w(as);
+ if(ws) WideCharToMultiByte(CP_UTF8, 0, ws, -1, buff, bufflen, 0, 0);
+ free(ws);
+ return true;
+}
+
+bool u2a(const char *us, char *buff, int bufflen) {
+ if(!us) return false;
+
+ wchar_t *ws = u2w(us);
+ if(ws) WideCharToMultiByte(code_page, 0, ws, -1, buff, bufflen, 0, 0);
+ free(ws);
+ return true;
+}
+
+
+bool t2w(const TCHAR *ts, wchar_t *buff, int bufflen) {
+#ifdef _UNICODE
+ wcsncpy(buff, ts, bufflen);
+ return true;
+#else
+ return a2w(ts, buff, bufflen);
+#endif
+}
+
+bool w2t(const wchar_t *ws, TCHAR *buff, int bufflen) {
+#ifdef _UNICODE
+ wcsncpy(buff, ws, bufflen);
+ return true;
+#else
+ return w2a(ws, buff, bufflen);
+#endif
+}
+
+bool t2a(const TCHAR *ts, char *buff, int bufflen) {
+#ifdef _UNICODE
+ return w2a(ts, buff, bufflen);
+#else
+ strncpy(buff, ts, bufflen);
+ return true;
+#endif
+}
+
+bool a2t(const char *as, TCHAR *buff, int bufflen) {
+#ifdef _UNICODE
+ return a2w(as, buff, bufflen);
+#else
+ strncpy(buff, as, bufflen);
+ return true;
+#endif
+}
+
+bool t2u(const TCHAR *ts, char *buff, int bufflen) {
+#ifdef _UNICODE
+ return w2u(ts, buff, bufflen);
+#else
+ return a2u(ts, buff, bufflen);
+#endif
+}
+
+bool u2t(const char *us, TCHAR *buff, int bufflen) {
+#ifdef _UNICODE
+ return u2w(us, buff, bufflen);
+#else
+ return u2a(us, buff, bufflen);
+#endif
+}
+
+wchar_t *u2w(const char *us) {
+ if(us) {
+ int size = MultiByteToWideChar(CP_UTF8, 0, us, -1, 0, 0);
+ wchar_t *buff = (wchar_t *)malloc(size * sizeof(wchar_t));
+ MultiByteToWideChar(CP_UTF8, 0, us, -1, buff, size);
+ return buff;
+ } else
+ return 0;
+}
+
+char *w2u(const wchar_t *ws) {
+ if(ws) {
+ int size = WideCharToMultiByte(CP_UTF8, 0, ws, -1, 0, 0, 0, 0);
+ char *buff = (char *)malloc(size);
+ WideCharToMultiByte(CP_UTF8, 0, ws, -1, buff, size, 0, 0);
+ return buff;
+ } else
+ return 0;
+}
+
+wchar_t *a2w(const char *as) {
+ int size = MultiByteToWideChar(code_page, 0, as, -1, 0, 0);
+ wchar_t *buff = (wchar_t *)malloc(size * sizeof(wchar_t));
+ MultiByteToWideChar(code_page, 0, as, -1, buff, size);
+ return buff;
+}
+
+char *w2a(const wchar_t *ws) {
+ int size = WideCharToMultiByte(code_page, 0, ws, -1, 0, 0, 0, 0);
+ char *buff = (char *)malloc(size);
+ WideCharToMultiByte(code_page, 0, ws, -1, buff, size, 0, 0);
+ return buff;
+}
+
+char *u2a(const char *utfs) {
+ wchar_t *ws = u2w(utfs);
+ char *ret = w2a(ws);
+ free(ws);
+ return ret;
+}
+
+char *a2u(const char *as) {
+ wchar_t *ws = a2w(as);
+ char *ret = w2u(ws);
+ free(ws);
+ return ret;
+}
+
+TCHAR *w2t(const wchar_t *ws) {
+#ifdef _UNICODE
+ return wcsdup(ws);
+#else
+ return w2a(ws);
+#endif
+}
+
+wchar_t *t2w(const TCHAR *ts) {
+#ifdef _UNICODE
+ return _tcsdup(ts);
+#else
+ return a2w(ts);
+#endif
+}
+
+
+char *t2a(const TCHAR *ts) {
+#ifdef _UNICODE
+ return w2a(ts);
+#else
+ return _strdup(ts);
+#endif
+}
+
+TCHAR *a2t(const char *as) {
+#ifdef _UNICODE
+ return a2w(as);
+#else
+ return _strdup(as);
+#endif
+}
+
+TCHAR *u2t(const char *utfs) {
+#ifdef _UNICODE
+ return u2w(utfs);
+#else
+ wchar_t *ws = u2w(utfs);
+ char *ret = w2a(ws);
+ free(ws);
+ return ret;
+#endif
+}
+
+char *t2u(const TCHAR *ts) {
+#ifdef _UNICODE
+ return w2u(ts);
+#else
+ wchar_t *ws = a2w(ts);
+ char *ret = w2u(ws);
+ free(ws);
+ return ret;
+#endif
+}
+
+void trimW(wchar_t *str) {
+ int len = wcslen(str), pos;
+ // trim whitespace (e.g. from OTR detection)
+ for(pos = len - 1; pos >= 0; pos--) {
+ if(str[pos] == L' ' || str[pos] == L'\t' || str[pos] == L'\r' || str[pos] == L'\n') str[pos] = 0;
+ else break;
+ }
+
+ // remove tabs
+ for(pos = len - 1; pos >= 0; pos--)
+ if(str[pos] == L'\t') str[pos] = L' ';
+}
+
+void trimA(char *str) {
+ int len = strlen(str), pos;
+ // trim whitespace (e.g. from OTR detection)
+ for(pos = len - 1; pos >= 0; pos--) {
+ if(str[pos] == ' ' || str[pos] == '\t' || str[pos] == '\r' || str[pos] == '\n') str[pos] = 0;
+ else break;
+ }
+
+ // remove tabs
+ for(pos = len - 1; pos >= 0; pos--)
+ if(str[pos] == '\t') str[pos] = ' ';
+}
diff --git a/yapp/str_utils.h b/yapp/str_utils.h
new file mode 100644
index 0000000..d7db510
--- /dev/null
+++ b/yapp/str_utils.h
@@ -0,0 +1,53 @@
+#ifndef _STR_UTILS_INC
+#define _STR_UTILS_INC
+
+void set_codepage();
+
+bool a2w(const char *as, wchar_t *buff, int bufflen);
+bool w2a(const wchar_t *ws, char *buff, int bufflen);
+
+bool u2w(const char *us, wchar_t *buff, int bufflen);
+bool w2u(const wchar_t *ws, char *buff, int bufflen);
+
+bool a2u(const char *as, char *buff, int bufflen);
+bool u2a(const char *ws, char *buff, int bufflen);
+
+bool t2w(const TCHAR *ts, wchar_t *buff, int bufflen);
+bool w2t(const wchar_t *ws, TCHAR *buff, int bufflen);
+
+bool t2a(const TCHAR *ts, char *buff, int bufflen);
+bool a2t(const char *as, TCHAR *buff, int bufflen);
+
+bool t2u(const TCHAR *ts, char *buff, int bufflen);
+bool u2t(const char *us, TCHAR *buff, int bufflen);
+
+// remember to free return value
+wchar_t *a2w(const char *as);
+char *w2a(const wchar_t *ws);
+
+wchar_t *u2w(const char *us);
+char *w2u(const wchar_t *ws);
+
+char *u2a(const char *us);
+char *a2u(const char *as);
+
+wchar_t *t2w(const TCHAR *ts);
+TCHAR *w2t(const wchar_t *ws);
+
+TCHAR *u2t(const char *us);
+char *t2u(const TCHAR *ts);
+
+char *t2a(const TCHAR *ts);
+TCHAR *a2t(const char *as);
+
+void trimW(wchar_t *str);
+void trimA(char *str);
+
+#ifndef _UNICODE
+#define trim trimW
+#else
+#define trim trimA
+#endif
+
+#endif
+
diff --git a/yapp/version.h b/yapp/version.h
index fb22a17..80c5c9a 100644
--- a/yapp/version.h
+++ b/yapp/version.h
@@ -2,9 +2,9 @@
#define __VERSION_H_INCLUDED
#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 1
-#define __RELEASE_NUM 4
-#define __BUILD_NUM 6
+#define __MINOR_VERSION 2
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 0
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM