summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp7
-rw-r--r--src/core/stdmsg/src/msgs.cpp26
-rw-r--r--src/core/stdmsg/src/msgs.h10
-rw-r--r--src/core/stdmsg/src/msgtimedout.cpp2
4 files changed, 21 insertions, 24 deletions
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index b152f7b86e..4059a6ba1e 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -99,20 +99,17 @@ static void SetEditorText(HWND hwnd, const wchar_t* txt)
/////////////////////////////////////////////////////////////////////////////////////////
-CSrmmWindow::CSrmmWindow(MCONTACT hContact, bool noActivate, const char *szInitialText, bool bIsUnicode) :
+CSrmmWindow::CSrmmWindow(MCONTACT hContact) :
CSrmmBaseDialog(g_hInst, IDD_MSG),
m_splitter(this, IDC_SPLITTERY),
m_btnOk(this, IDOK),
m_cmdList(20),
- m_bNoActivate(noActivate)
+ m_bNoActivate(g_dat.bDoNotStealFocus)
{
m_hContact = hContact;
m_autoClose = CLOSE_ON_CANCEL;
m_btnOk.OnClick = Callback(this, &CSrmmWindow::onClick_Ok);
-
- m_wszInitialText = (bIsUnicode) ? mir_wstrdup((wchar_t*)szInitialText) : mir_a2u(szInitialText);
-
m_splitter.OnChange = Callback(this, &CSrmmWindow::OnSplitterMoved);
}
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp
index f7f59929e8..1af01ed518 100644
--- a/src/core/stdmsg/src/msgs.cpp
+++ b/src/core/stdmsg/src/msgs.cpp
@@ -82,7 +82,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam)
char *szProto = GetContactProto(hContact);
if (szProto && (g_dat.openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0)))) {
- CSrmmWindow *pDlg = new CSrmmWindow(hContact, g_dat.bDoNotStealFocus);
+ CSrmmWindow *pDlg = new CSrmmWindow(hContact);
pDlg->Show();
return 0;
}
@@ -101,7 +101,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam)
return 0;
}
-INT_PTR SendMessageCmd(MCONTACT hContact, char *msg, int isWchar)
+INT_PTR SendMessageCmd(MCONTACT hContact, wchar_t *pwszInitialText)
{
/* does the MCONTACT's protocol support IM messages? */
char *szProto = GetContactProto(hContact);
@@ -112,19 +112,19 @@ INT_PTR SendMessageCmd(MCONTACT hContact, char *msg, int isWchar)
HWND hwnd = WindowList_Find(pci->hWindowList, hContact);
if (hwnd) {
- if (msg) {
+ if (pwszInitialText) {
SendDlgItemMessage(hwnd, IDC_SRMM_MESSAGE, EM_SETSEL, -1, SendDlgItemMessage(hwnd, IDC_SRMM_MESSAGE, WM_GETTEXTLENGTH, 0, 0));
- if (isWchar)
- SendDlgItemMessageW(hwnd, IDC_SRMM_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)msg);
- else
- SendDlgItemMessageA(hwnd, IDC_SRMM_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)msg);
+ SendDlgItemMessageW(hwnd, IDC_SRMM_MESSAGE, EM_REPLACESEL, FALSE, (LPARAM)pwszInitialText);
+ mir_free(pwszInitialText);
}
ShowWindow(hwnd, SW_RESTORE);
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
SetForegroundWindow(hwnd);
}
else {
- CSrmmWindow *pDlg = new CSrmmWindow(hContact, false, msg, isWchar != 0);
+ CSrmmWindow *pDlg = new CSrmmWindow(hContact);
+ pDlg->m_wszInitialText = pwszInitialText;
+ pDlg->m_bNoActivate = false;
pDlg->Show();
}
return 0;
@@ -132,19 +132,19 @@ INT_PTR SendMessageCmd(MCONTACT hContact, char *msg, int isWchar)
static INT_PTR SendMessageCommand_W(WPARAM wParam, LPARAM lParam)
{
- return SendMessageCmd(wParam, (char*)lParam, TRUE);
+ return SendMessageCmd(wParam, mir_wstrdup((wchar_t*)lParam));
}
static INT_PTR SendMessageCommand(WPARAM wParam, LPARAM lParam)
{
- return SendMessageCmd(wParam, (char*)lParam, FALSE);
+ return SendMessageCmd(wParam, mir_a2u((char*)lParam));
}
static INT_PTR ReadMessageCommand(WPARAM, LPARAM lParam)
{
- CLISTEVENT *cle = (CLISTEVENT *)lParam;
+ CLISTEVENT *cle = (CLISTEVENT*)lParam;
if (cle)
- SendMessageCmd(cle->hContact, nullptr, 0);
+ SendMessageCmd(cle->hContact, nullptr);
return 0;
}
@@ -249,7 +249,7 @@ static void RestoreUnreadMessageAlerts(void)
autoPopup = true;
if (autoPopup && !windowAlreadyExists) {
- CSrmmWindow *pDlg = new CSrmmWindow(hContact, g_dat.bDoNotStealFocus);
+ CSrmmWindow *pDlg = new CSrmmWindow(hContact);
pDlg->Show();
}
else arEvents.insert(new MSavedEvent(hContact, hDbEvent));
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h
index 67f1dbd6ae..7976d3eca9 100644
--- a/src/core/stdmsg/src/msgs.h
+++ b/src/core/stdmsg/src/msgs.h
@@ -82,12 +82,11 @@ class CSrmmWindow : public CSrmmBaseDialog
HANDLE m_hTimeZone;
WORD m_wStatus, m_wOldStatus;
WORD m_wMinute;
- wchar_t *m_wszInitialText;
- bool m_bIsMeta, m_bShowTyping, m_bNoActivate;
+ bool m_bIsMeta, m_bShowTyping;
public:
+ bool m_bIsAutoRTL, m_bNoActivate;
MEVENT m_hDbEventFirst, m_hDbEventLast;
- bool m_bIsAutoRTL;
int m_avatarWidth, m_avatarHeight;
int m_splitterPos, m_originalSplitterPos;
@@ -97,9 +96,10 @@ public:
LIST<wchar_t> m_cmdList;
HBITMAP m_avatarPic;
+ wchar_t *m_wszInitialText;
public:
- CSrmmWindow(MCONTACT hContact, bool bNoActivate, const char *szInitialText = nullptr, bool bIsUnicode = false);
+ CSrmmWindow(MCONTACT hContact);
virtual void OnInitDialog() override;
virtual void OnDestroy() override;
@@ -128,7 +128,7 @@ INT_PTR CALLBACK ErrorDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
int DbEventIsForMsgWindow(DBEVENTINFO *dbei);
int DbEventIsShown(DBEVENTINFO *dbei);
int SendMessageDirect(const wchar_t *szMsg, MCONTACT hContact);
-INT_PTR SendMessageCmd(MCONTACT hContact, char *msg, int isWchar);
+INT_PTR SendMessageCmd(MCONTACT hContact, wchar_t *msg);
void LoadMsgLogIcons(void);
void FreeMsgLogIcons(void);
diff --git a/src/core/stdmsg/src/msgtimedout.cpp b/src/core/stdmsg/src/msgtimedout.cpp
index 044dd74b5e..d7bfb30d1b 100644
--- a/src/core/stdmsg/src/msgtimedout.cpp
+++ b/src/core/stdmsg/src/msgtimedout.cpp
@@ -88,7 +88,7 @@ void MessageFailureProcess(TMsgQueue *item, const char* err)
HWND hwnd = WindowList_Find(pci->hWindowList, hContact);
if (hwnd == nullptr) {
// If message window doesn't already exist, open a new one
- SendMessageCmd(item->hContact, nullptr, 0);
+ SendMessageCmd(item->hContact, nullptr);
hwnd = WindowList_Find(pci->hWindowList, hContact);
}
else SendMessage(hwnd, DM_REMAKELOG, 0, 0);