summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/TabSRMM/src/contactcache.cpp3
-rw-r--r--plugins/TabSRMM/src/container.cpp2
-rw-r--r--plugins/TabSRMM/src/generic_msghandlers.cpp39
-rw-r--r--plugins/TabSRMM/src/infopanel.cpp5
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp196
-rw-r--r--plugins/TabSRMM/src/msgdlgother.cpp74
-rw-r--r--plugins/TabSRMM/src/msglog.cpp3
-rw-r--r--plugins/TabSRMM/src/msgs.cpp7
-rw-r--r--plugins/TabSRMM/src/sendqueue.cpp3
-rw-r--r--plugins/TabSRMM/src/templates.cpp25
10 files changed, 163 insertions, 194 deletions
diff --git a/plugins/TabSRMM/src/contactcache.cpp b/plugins/TabSRMM/src/contactcache.cpp
index f218ffdd80..e597abe53c 100644
--- a/plugins/TabSRMM/src/contactcache.cpp
+++ b/plugins/TabSRMM/src/contactcache.cpp
@@ -36,10 +36,9 @@ static OBJLIST<CContactCache> arContacts(50, NumericKeySortT);
static DBCachedContact ccInvalid;
CContactCache::CContactCache(MCONTACT hContact) :
+ m_hContact(hContact),
m_history(10)
{
- m_hContact = hContact;
-
if (hContact) {
if ((cc = db_get_contact(hContact)) != nullptr) {
initPhaseTwo();
diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp
index d83419ae9f..eed9366ed2 100644
--- a/plugins/TabSRMM/src/container.cpp
+++ b/plugins/TabSRMM/src/container.cpp
@@ -1394,7 +1394,7 @@ panel_found:
db_unset(dat->m_hContact, SRMSGMOD_T, "tabindex");
break;
case ID_TABMENU_LEAVECHATROOM:
- if (dat && dat->isChat() && dat->m_hContact) {
+ if (dat && dat->isChat()) {
char *szProto = Proto_GetBaseAccountName(dat->m_hContact);
if (szProto)
CallProtoService(szProto, PS_LEAVECHAT, dat->m_hContact, 0);
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp
index fa85f21edf..794f214921 100644
--- a/plugins/TabSRMM/src/generic_msghandlers.cpp
+++ b/plugins/TabSRMM/src/generic_msghandlers.cpp
@@ -249,8 +249,8 @@ LRESULT CMsgDialog::DM_MsgWindowCmdHandler(UINT cmd, WPARAM wParam, LPARAM lPara
return MsgWindowMenuHandler(iSelection, MENU_LOGMENU);
case IDC_PROTOMENU:
- if (m_hContact) {
- submenu = GetSubMenu(PluginConfig.g_hMenuContext, 4);
+ submenu = GetSubMenu(PluginConfig.g_hMenuContext, 4);
+ {
int iOldGlobalSendFormat = PluginConfig.m_SendFormat;
int iLocalFormat = M.GetDword(m_hContact, "sendformat", 0);
int iNewLocalFormat = iLocalFormat;
@@ -278,7 +278,7 @@ LRESULT CMsgDialog::DM_MsgWindowCmdHandler(UINT cmd, WPARAM wParam, LPARAM lPara
DM_RecalcPictureSize();
Resize();
break;
-
+
case ID_MODE_PRIVATE:
m_bSplitterOverride = true;
db_set_b(m_hContact, SRMSGMOD_T, "splitoverride", 1);
@@ -287,28 +287,28 @@ LRESULT CMsgDialog::DM_MsgWindowCmdHandler(UINT cmd, WPARAM wParam, LPARAM lPara
DM_RecalcPictureSize();
Resize();
break;
-
+
case ID_GLOBAL_BBCODE:
PluginConfig.m_SendFormat = SENDFORMAT_BBCODE;
break;
-
+
case ID_GLOBAL_OFF:
PluginConfig.m_SendFormat = SENDFORMAT_NONE;
break;
-
+
case ID_THISCONTACT_GLOBALSETTING:
iNewLocalFormat = 0;
break;
-
+
case ID_THISCONTACT_BBCODE:
iNewLocalFormat = SENDFORMAT_BBCODE;
break;
-
+
case ID_THISCONTACT_OFF:
iNewLocalFormat = -1;
break;
}
-
+
if (iNewLocalFormat == 0)
db_unset(m_hContact, SRMSGMOD_T, "sendformat");
else if (iNewLocalFormat != iLocalFormat)
@@ -476,15 +476,12 @@ LRESULT CMsgDialog::DM_MsgWindowCmdHandler(UINT cmd, WPARAM wParam, LPARAM lPara
case IDC_SELFTYPING:
if (m_si == nullptr || m_si->iType == GCW_PRIVMESS) {
- if (m_hContact) {
- int iCurrentTypingMode = g_plugin.getByte(m_hContact, SRMSGSET_TYPING, g_plugin.getByte(SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW));
-
- if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON && iCurrentTypingMode) {
- DM_NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
- m_nTypeMode = PROTOTYPE_SELFTYPING_OFF;
- }
- g_plugin.setByte(m_hContact, SRMSGSET_TYPING, (BYTE)!iCurrentTypingMode);
+ int iCurrentTypingMode = g_plugin.getByte(m_hContact, SRMSGSET_TYPING, g_plugin.getByte(SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW));
+ if (m_nTypeMode == PROTOTYPE_SELFTYPING_ON && iCurrentTypingMode) {
+ DM_NotifyTyping(PROTOTYPE_SELFTYPING_OFF);
+ m_nTypeMode = PROTOTYPE_SELFTYPING_OFF;
}
+ g_plugin.setByte(m_hContact, SRMSGSET_TYPING, (BYTE)!iCurrentTypingMode);
}
break;
@@ -604,11 +601,6 @@ void CMsgDialog::DM_SetDBButtonStates()
char *szModule = buttonItem->szModule;
char *szSetting = buttonItem->szSetting;
if (buttonItem->dwFlags & BUTTON_DBACTIONONCONTACT || buttonItem->dwFlags & BUTTON_ISCONTACTDBACTION) {
- if (m_hContact == 0) {
- SendMessage(hWnd, BM_SETCHECK, BST_UNCHECKED, 0);
- buttonItem = buttonItem->nextItem;
- continue;
- }
if (buttonItem->dwFlags & BUTTON_ISCONTACTDBACTION)
szModule = Proto_GetBaseAccountName(m_hContact);
hFinalContact = m_hContact;
@@ -813,9 +805,6 @@ void CMsgDialog::DM_ThemeChanged()
void CMsgDialog::DM_NotifyTyping(int mode)
{
- if (!m_hContact)
- return;
-
DeletePopupsForContact(m_hContact, PU_REMOVE_ON_TYPE);
const char *szProto = m_cache->getActiveProto();
diff --git a/plugins/TabSRMM/src/infopanel.cpp b/plugins/TabSRMM/src/infopanel.cpp
index 18d6fdb55d..dfa76b980d 100644
--- a/plugins/TabSRMM/src/infopanel.cpp
+++ b/plugins/TabSRMM/src/infopanel.cpp
@@ -218,11 +218,6 @@ void CInfoPanel::showHide() const
bool CInfoPanel::getVisibility()
{
- if (m_dat->m_hContact == 0) {
- setActive(false); // no info panel, if no hcontact
- return false;
- }
-
BYTE bDefault = (m_dat->m_pContainer->m_flags.m_bInfoPanel) ? 1 : 0;
BYTE bContact = M.GetByte(m_dat->m_hContact, "infopanel", 0);
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index 5e02fcba75..dd7f2743f2 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -28,8 +28,6 @@
#include "stdafx.h"
-#define MS_HTTPSERVER_ADDFILENAME "HTTPServer/AddFileName"
-
bool IsStringValidLink(wchar_t *pszText);
LIST<void> g_arUnreadWindows(1, PtrKeySortT);
@@ -45,7 +43,7 @@ static const UINT errorControls[] = { IDC_STATICERRORICON, IDC_STATICTEXT, IDC_R
struct
{
int id;
- const wchar_t* text;
+ const wchar_t *text;
}
static tooltips[] =
{
@@ -126,18 +124,16 @@ static void ShowMultipleControls(HWND hwndDlg, const UINT *controls, int cContro
void CMsgDialog::SetDialogToType()
{
- if (m_hContact) {
- if (!Contact_OnList(m_hContact)) {
- m_bNotOnList = true;
- ShowMultipleControls(m_hwnd, addControls, _countof(addControls), SW_SHOW);
- Utils::showDlgControl(m_hwnd, IDC_LOGFROZENTEXT, SW_SHOW);
- SetDlgItemText(m_hwnd, IDC_LOGFROZENTEXT, TranslateT("Contact not on list. You may add it..."));
- }
- else {
- ShowMultipleControls(m_hwnd, addControls, _countof(addControls), SW_HIDE);
- m_bNotOnList = false;
- Utils::showDlgControl(m_hwnd, IDC_LOGFROZENTEXT, SW_HIDE);
- }
+ if (!Contact_OnList(m_hContact)) {
+ m_bNotOnList = true;
+ ShowMultipleControls(m_hwnd, addControls, _countof(addControls), SW_SHOW);
+ Utils::showDlgControl(m_hwnd, IDC_LOGFROZENTEXT, SW_SHOW);
+ SetDlgItemText(m_hwnd, IDC_LOGFROZENTEXT, TranslateT("Contact not on list. You may add it..."));
+ }
+ else {
+ ShowMultipleControls(m_hwnd, addControls, _countof(addControls), SW_HIDE);
+ m_bNotOnList = false;
+ Utils::showDlgControl(m_hwnd, IDC_LOGFROZENTEXT, SW_HIDE);
}
Utils::enableDlgControl(m_hwnd, IDC_TIME, true);
@@ -351,6 +347,8 @@ CMsgDialog::CMsgDialog(SESSION_INFO *si) :
m_btnQuote(this, IDC_QUOTE),
m_btnCancelAdd(this, IDC_CANCELADD)
{
+ m_hContact = si->hContact;
+
m_btnQuote.OnClick = Callback(this, &CMsgDialog::onClick_Quote);
m_btnFilter.OnClick = Callback(this, &CMsgDialog::onClick_Filter);
m_btnNickList.OnClick = Callback(this, &CMsgDialog::onClick_ShowNickList);
@@ -428,11 +426,11 @@ bool CMsgDialog::OnInitDialog()
m_pPanel.Configure();
for (auto &it : btnControls)
- ShowWindow(GetDlgItem(m_hwnd,it), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, it), SW_HIDE);
}
else {
ShowWindow(GetDlgItem(m_hwnd, IDC_SPLITTERX), SW_HIDE);
- m_nickList.Hide();
+ m_nickList.Hide();
for (auto &it : btnControls)
CustomizeButton(GetDlgItem(m_hwnd, it));
@@ -447,9 +445,9 @@ bool CMsgDialog::OnInitDialog()
}
m_hDbEventFirst = 0;
- if (m_hContact && m_szProto != nullptr) {
+ if (m_szProto != nullptr) {
m_wStatus = db_get_w(m_hContact, m_szProto, "Status", ID_STATUS_OFFLINE);
- wcsncpy_s(m_wszStatus, Clist_GetStatusModeDescription(m_szProto == nullptr ? ID_STATUS_OFFLINE : m_wStatus, 0), _TRUNCATE);
+ wcsncpy_s(m_wszStatus, Clist_GetStatusModeDescription(m_wStatus, 0), _TRUNCATE);
}
else m_wStatus = ID_STATUS_OFFLINE;
@@ -468,8 +466,8 @@ bool CMsgDialog::OnInitDialog()
mir_subclassWindow(m_hwndPanelPicParent, CInfoPanel::avatarParentSubclass);
m_bShowUIElements = (m_pContainer->m_flags.m_bHideToolbar) == 0;
- m_sendMode |= m_hContact == 0 ? SMODE_MULTIPLE : 0;
- m_sendMode |= M.GetByte(m_hContact, "no_ack", 0) ? SMODE_NOACK : 0;
+ if (M.GetByte(m_hContact, "no_ack", 0))
+ m_sendMode |= SMODE_NOACK;
m_hQueuedEvents = (MEVENT*)mir_calloc(sizeof(MEVENT)* EVENT_QUEUE_SIZE);
m_iEventQueueSize = EVENT_QUEUE_SIZE;
@@ -500,7 +498,7 @@ bool CMsgDialog::OnInitDialog()
m_dwFlags = m_pContainer->m_theme.dwFlags;
// consider per-contact message setting overrides
- if (m_hContact && M.GetDword(m_hContact, "mwmask", 0))
+ if (M.GetDword(m_hContact, "mwmask", 0))
LoadLocalFlags();
DM_InitTip();
@@ -508,8 +506,7 @@ bool CMsgDialog::OnInitDialog()
m_bSplitterOverride = M.GetByte(m_hContact, "splitoverride", 0) != 0;
m_pPanel.getVisibility();
- if (m_hContact)
- m_pPanel.loadHeight();
+ m_pPanel.loadHeight();
m_bShowAvatar = GetAvatarVisibility();
@@ -517,7 +514,7 @@ bool CMsgDialog::OnInitDialog()
RECT rc;
GetWindowRect(GetDlgItem(m_hwnd, IDC_SPLITTERY), &rc);
-
+
POINT pt;
pt.y = (rc.top + rc.bottom) / 2;
pt.x = 0;
@@ -594,22 +591,20 @@ bool CMsgDialog::OnInitDialog()
UpdateNickList();
}
else {
- if (m_hContact)
- FindFirstEvent();
+ FindFirstEvent();
DM_OptionsApplied();
// restore saved msg if any...
- if (m_hContact) {
- ptrW tszSavedMsg(g_plugin.getWStringA(m_hContact, "SavedMsg"));
- if (tszSavedMsg != 0) {
- SETTEXTEX stx = { ST_DEFAULT, 1200 };
- m_message.SendMsg(EM_SETTEXTEX, (WPARAM)& stx, tszSavedMsg);
- UpdateSaveAndSendButton();
- if (m_pContainer->m_hwndActive == m_hwnd)
- UpdateReadChars();
- }
+ ptrW wszSavedMsg(g_plugin.getWStringA(m_hContact, "SavedMsg"));
+ if (wszSavedMsg != 0) {
+ SETTEXTEX stx = { ST_DEFAULT, 1200 };
+ m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&stx, wszSavedMsg);
+ UpdateSaveAndSendButton();
+ if (m_pContainer->m_hwndActive == m_hwnd)
+ UpdateReadChars();
}
+
if (wszInitialText) {
m_message.SetText(wszInitialText);
int len = GetWindowTextLength(m_message.GetHwnd());
@@ -698,7 +693,7 @@ void CMsgDialog::OnDestroy()
if (m_pContainer->m_flags.m_bSideBar)
m_pContainer->m_pSideBar->removeSession(this);
- if (m_hContact && M.GetByte("deletetemp", 0))
+ if (M.GetByte("deletetemp", 0))
if (!Contact_OnList(m_hContact))
db_delete_contact(m_hContact);
@@ -720,17 +715,15 @@ void CMsgDialog::OnDestroy()
}
if (m_cache->isValid()) { // not valid means the contact was deleted
- if (m_hContact) {
- if (!m_bEditNotesActive) {
- char *msg = m_message.GetRichTextRtf(true);
- if (msg) {
- db_set_utf(m_hContact, SRMSGMOD, "SavedMsg", msg);
- mir_free(msg);
- }
- else g_plugin.delSetting(m_hContact, "SavedMsg");
+ if (!m_bEditNotesActive) {
+ char *msg = m_message.GetRichTextRtf(true);
+ if (msg) {
+ db_set_utf(m_hContact, SRMSGMOD, "SavedMsg", msg);
+ mir_free(msg);
}
- else SendMessage(m_hwnd, WM_COMMAND, IDC_PIC, 0);
+ else g_plugin.delSetting(m_hContact, "SavedMsg");
}
+ else SendMessage(m_hwnd, WM_COMMAND, IDC_PIC, 0);
}
if (m_si == nullptr || m_si->iType == GCW_PRIVMESS)
@@ -746,7 +739,7 @@ void CMsgDialog::OnDestroy()
for (int i = 0; i < SendQueue::NR_SENDJOBS; i++) {
if (jobs[i].hContact == m_hContact) {
- if (jobs[i].iStatus >(unsigned)SendQueue::SQ_INPROGRESS)
+ if (jobs[i].iStatus > (unsigned)SendQueue::SQ_INPROGRESS)
sendQueue->clearJob(i);
// unfinished jobs which did not yet return anything are kept in the queue.
@@ -863,7 +856,7 @@ void CMsgDialog::onClick_Ok(CCtrlButton *)
pf2.cbSize = sizeof(pf2);
pf2.dwMask = PFM_RTLPARA;
SendMessage(hwndEdit, EM_SETSEL, 0, -1);
- SendMessage(hwndEdit, EM_GETPARAFORMAT, 0, (LPARAM)& pf2);
+ SendMessage(hwndEdit, EM_GETPARAFORMAT, 0, (LPARAM)&pf2);
int flags = 0;
if (pf2.wEffects & PFE_RTLPARA)
@@ -896,7 +889,7 @@ void CMsgDialog::onClick_Ok(CCtrlButton *)
if (contacthwnd != m_hwnd) {
SETTEXTEX stx = { ST_DEFAULT, CP_UTF8 };
// send the buffer to the contacts msg typing area
- SendDlgItemMessage(contacthwnd, IDC_SRMM_MESSAGE, EM_SETTEXTEX, (WPARAM)& stx, (LPARAM)szFromStream);
+ SendDlgItemMessage(contacthwnd, IDC_SRMM_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)szFromStream);
SendMessage(contacthwnd, WM_COMMAND, IDOK, 0);
}
}
@@ -977,7 +970,7 @@ void CMsgDialog::onClick_Quote(CCtrlButton*)
MultiByteToWideChar(CP_ACP, 0, (char*)dbei.pBlob, -1, szConverted, iSize);
}
}
-
+
if (dbei.eventType == EVENTTYPE_FILE) {
size_t iDescr = mir_strlen((char *)(szText + sizeof(DWORD)));
memmove(szText, szText + sizeof(DWORD), iDescr);
@@ -988,7 +981,7 @@ void CMsgDialog::onClick_Quote(CCtrlButton*)
MultiByteToWideChar(CP_ACP, 0, (char *)szText, -1, szConverted, 1 + (int)mir_strlen((char *)szText));
bNeedsFree = true;
}
-
+
if (szConverted != nullptr)
m_message.SendMsg(EM_SETTEXTEX, (WPARAM)&stx, ptrW(QuoteText(szConverted)));
@@ -1926,7 +1919,7 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam)
case WM_MOUSEWHEEL:
if (DM_MouseWheelHandler(wParam, lParam) == 0)
return 0;
-
+
m_iLastEnterTime = 0;
break;
@@ -2129,7 +2122,7 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam)
TranslateMenu(hSubMenu);
CHARRANGE sel, all = { 0, -1 };
- m_message.SendMsg(EM_EXGETSEL, 0, (LPARAM)& sel);
+ m_message.SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel);
if (sel.cpMin == sel.cpMax) {
EnableMenuItem(hSubMenu, IDM_COPY, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(hSubMenu, IDM_CUT, MF_BYCOMMAND | MF_GRAYED);
@@ -2142,13 +2135,13 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam)
mwpd.hwnd = m_message.GetHwnd();
mwpd.hMenu = hSubMenu;
mwpd.pt = pt;
- NotifyEventHooks(g_chatApi.hevWinPopup, 0, (LPARAM)& mwpd);
+ NotifyEventHooks(g_chatApi.hevWinPopup, 0, (LPARAM)&mwpd);
int iSelection = TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_hwnd, nullptr);
mwpd.selection = iSelection;
mwpd.uType = MSG_WINDOWPOPUP_SELECTED;
- NotifyEventHooks(g_chatApi.hevWinPopup, 0, (LPARAM)& mwpd);
+ NotifyEventHooks(g_chatApi.hevWinPopup, 0, (LPARAM)&mwpd);
switch (iSelection) {
case IDM_COPY:
@@ -2162,12 +2155,12 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam)
m_message.SendMsg(EM_PASTESPECIAL, (iSelection == IDM_PASTE) ? CF_UNICODETEXT : 0, 0);
break;
case IDM_COPYALL:
- m_message.SendMsg(EM_EXSETSEL, 0, (LPARAM)& all);
+ m_message.SendMsg(EM_EXSETSEL, 0, (LPARAM)&all);
m_message.SendMsg(WM_COPY, 0, 0);
- m_message.SendMsg(EM_EXSETSEL, 0, (LPARAM)& sel);
+ m_message.SendMsg(EM_EXSETSEL, 0, (LPARAM)&sel);
break;
case IDM_SELECTALL:
- m_message.SendMsg(EM_EXSETSEL, 0, (LPARAM)& all);
+ m_message.SendMsg(EM_EXSETSEL, 0, (LPARAM)&all);
break;
}
DestroyMenu(hMenu);
@@ -2175,8 +2168,8 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam)
else {
if (lParam == 0xFFFFFFFF) {
CHARRANGE sel;
- m_message.SendMsg(EM_EXGETSEL, 0, (LPARAM)& sel);
- m_message.SendMsg(EM_POSFROMCHAR, (WPARAM)& pt, (LPARAM)sel.cpMax);
+ m_message.SendMsg(EM_EXGETSEL, 0, (LPARAM)&sel);
+ m_message.SendMsg(EM_POSFROMCHAR, (WPARAM)&pt, (LPARAM)sel.cpMax);
ClientToScreen(m_message.GetHwnd(), &pt);
}
else {
@@ -2554,7 +2547,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
CHARRANGE sel;
- SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM)& sel);
+ SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM)&sel);
if (sel.cpMin == sel.cpMax) {
UINT msg = ((ENLINK *)lParam)->msg;
m_pContainer->m_pMenuBar->Cancel();
@@ -2563,7 +2556,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
tr.lpstrText = nullptr;
tr.chrg = ((ENLINK *)lParam)->chrg;
tr.lpstrText = (wchar_t *)mir_alloc(sizeof(wchar_t) * (tr.chrg.cpMax - tr.chrg.cpMin + 2));
- SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)& tr);
+ SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
BOOL isLink = IsStringValidLink(tr.lpstrText);
if (isLink) // handled by core
@@ -2587,7 +2580,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (msg == WM_LBUTTONUP) {
CHARRANGE chr;
- m_message.SendMsg(EM_EXGETSEL, 0, (LPARAM)& chr);
+ m_message.SendMsg(EM_EXGETSEL, 0, (LPARAM)&chr);
wchar_t tszAplTmpl[] = L"%s:";
size_t bufSize = mir_wstrlen(tr.lpstrText) + mir_wstrlen(tszAplTmpl) + 3;
@@ -2599,7 +2592,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
// prepend nick with space if needed
tr2.chrg.cpMin = chr.cpMin - 1;
tr2.chrg.cpMax = chr.cpMin;
- m_message.SendMsg(EM_GETTEXTRANGE, 0, (LPARAM)& tr2);
+ m_message.SendMsg(EM_GETTEXTRANGE, 0, (LPARAM)&tr2);
if (!iswspace(*tr2.lpstrText))
*tszTmp++ = ' ';
mir_wstrcpy(tszTmp, tr.lpstrText);
@@ -2613,7 +2606,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
tr2.chrg.cpMax = chr.cpMax + 1;
// if there is no space after selection,
// or there is nothing after selection at all...
- if (!m_message.SendMsg(EM_GETTEXTRANGE, 0, (LPARAM)& tr2) || !iswspace(*tr2.lpstrText)) {
+ if (!m_message.SendMsg(EM_GETTEXTRANGE, 0, (LPARAM)&tr2) || !iswspace(*tr2.lpstrText)) {
tszAppeal[st++] = ' ';
tszAppeal[st++] = '\0';
}
@@ -2745,7 +2738,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
case HM_DBEVENTADDED:
// this is called whenever a new event has been added to the database.
// this CAN be posted (some sanity checks required).
- if (this && m_hContact)
+ if (this)
DM_EventAdded(m_hContact, lParam);
return 0;
@@ -2873,7 +2866,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
HMENU submenu = GetSubMenu(PluginConfig.g_hMenuContext, 1);
GetCursorPos(&pt);
MsgWindowUpdateMenu(submenu, menuID);
-
+
int iSelection = TrackPopupMenu(submenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_hwnd, nullptr);
MsgWindowMenuHandler(iSelection, menuID);
break;
@@ -3121,52 +3114,35 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_DROPFILES:
{
- BOOL not_sending = GetKeyState(VK_CONTROL) & 0x8000;
- if (!not_sending) {
- const char *szProto = m_cache->getActiveProto();
- if (szProto == nullptr)
- break;
+ const char *szProto = m_cache->getActiveProto();
+ if (szProto == nullptr)
+ break;
- int pcaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
- if (!(pcaps & PF1_FILESEND))
+ int pcaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
+ if (!(pcaps & PF1_FILESEND))
+ break;
+ if (m_wStatus == ID_STATUS_OFFLINE) {
+ pcaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0);
+ if (!(pcaps & PF4_OFFLINEFILES)) {
+ ActivateTooltip(IDC_SRMM_MESSAGE, TranslateT("Contact is offline and this protocol does not support sending files to offline users."));
break;
- if (m_wStatus == ID_STATUS_OFFLINE) {
- pcaps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0);
- if (!(pcaps & PF4_OFFLINEFILES)) {
- ActivateTooltip(IDC_SRMM_MESSAGE, TranslateT("Contact is offline and this protocol does not support sending files to offline users."));
- break;
- }
}
}
- if (m_hContact != 0) {
- wchar_t szFilename[MAX_PATH];
- HDROP hDrop = (HDROP)wParam;
- int fileCount = DragQueryFile(hDrop, -1, nullptr, 0), totalCount = 0, i;
- wchar_t** ppFiles = nullptr;
- for (i = 0; i < fileCount; i++) {
- DragQueryFile(hDrop, i, szFilename, _countof(szFilename));
- Utils::AddToFileList(&ppFiles, &totalCount, szFilename);
- }
-
- if (!not_sending)
- CallService(MS_FILE_SENDSPECIFICFILEST, m_hContact, (LPARAM)ppFiles);
- else {
- if (ServiceExists(MS_HTTPSERVER_ADDFILENAME)) {
- for (i = 0; i < totalCount; i++) {
- char* szFileName = mir_u2a(ppFiles[i]);
- CallService(MS_HTTPSERVER_ADDFILENAME, (WPARAM)szFileName, 0);
- mir_free(szFileName);
- }
- char *szHTTPText = "DEBUG";
- SendDlgItemMessageA(m_hwnd, IDC_SRMM_MESSAGE, EM_REPLACESEL, TRUE, (LPARAM)szHTTPText);
- SetFocus(m_message.GetHwnd());
- }
- }
- for (i = 0; ppFiles[i]; i++)
- mir_free(ppFiles[i]);
- mir_free(ppFiles);
+ wchar_t szFilename[MAX_PATH];
+ HDROP hDrop = (HDROP)wParam;
+ int fileCount = DragQueryFile(hDrop, -1, nullptr, 0), totalCount = 0, i;
+ wchar_t **ppFiles = nullptr;
+ for (i = 0; i < fileCount; i++) {
+ DragQueryFile(hDrop, i, szFilename, _countof(szFilename));
+ Utils::AddToFileList(&ppFiles, &totalCount, szFilename);
}
+
+ CallService(MS_FILE_SENDSPECIFICFILEST, m_hContact, (LPARAM)ppFiles);
+
+ for (i = 0; ppFiles[i]; i++)
+ mir_free(ppFiles[i]);
+ mir_free(ppFiles);
}
return 0;
@@ -3186,7 +3162,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
DM_ErrorDetected(MSGERROR_CANCEL, 0);
return TRUE;
}
-
+
switch (PluginConfig.m_EscapeCloses) {
case 1: // minimize container
SendMessage(m_pContainer->m_hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
@@ -3236,7 +3212,7 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
case DM_CHECKINFOTIP:
m_pPanel.hideTip(reinterpret_cast<HWND>(lParam));
return 0;
-
+
case DM_SETINFOPANEL: // broadcasted when global info panel setting changes
if (wParam == 0 && lParam == 0) {
m_pPanel.getVisibility();
@@ -3342,6 +3318,6 @@ INT_PTR CMsgDialog::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
DM_SplitterGlobalEvent(wParam, lParam);
return 0;
}
-
+
return CSuper::DlgProc(uMsg, wParam, lParam);
}
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp
index d438a8a221..6396916029 100644
--- a/plugins/TabSRMM/src/msgdlgother.cpp
+++ b/plugins/TabSRMM/src/msgdlgother.cpp
@@ -1092,7 +1092,7 @@ int CMsgDialog::MsgWindowMenuHandler(int selection, int menuId)
db_unset(m_hContact, SRMSGMOD_T, "tabindex");
break;
case ID_TABMENU_LEAVECHATROOM:
- if (isChat() && m_hContact != 0) {
+ if (isChat()) {
char *szProto = Proto_GetBaseAccountName(m_hContact);
if (szProto)
CallProtoService(szProto, PS_LEAVECHAT, m_hContact, 0);
@@ -2073,52 +2073,50 @@ void CMsgDialog::UpdateTitle()
bool bChanged = false;
wchar_t newtitle[128];
- if (m_hContact) {
- if (m_szProto) {
- szActProto = m_cache->getProto();
+ if (m_szProto) {
+ szActProto = m_cache->getProto();
- bool bHasName = (m_cache->getUIN()[0] != 0);
- m_idle = m_cache->getIdleTS();
- m_bIsIdle = m_idle != 0;
+ bool bHasName = (m_cache->getUIN()[0] != 0);
+ m_idle = m_cache->getIdleTS();
+ m_bIsIdle = m_idle != 0;
- m_wStatus = m_cache->getStatus();
- wcsncpy_s(m_wszStatus, Clist_GetStatusModeDescription(m_szProto == nullptr ? ID_STATUS_OFFLINE : m_wStatus, 0), _TRUNCATE);
+ m_wStatus = m_cache->getStatus();
+ wcsncpy_s(m_wszStatus, Clist_GetStatusModeDescription(m_szProto == nullptr ? ID_STATUS_OFFLINE : m_wStatus, 0), _TRUNCATE);
- wchar_t newcontactname[128]; newcontactname[0] = 0;
- if (PluginConfig.m_bCutContactNameOnTabs)
- CutContactName(m_cache->getNick(), newcontactname, _countof(newcontactname));
- else
- wcsncpy_s(newcontactname, m_cache->getNick(), _TRUNCATE);
+ wchar_t newcontactname[128]; newcontactname[0] = 0;
+ if (PluginConfig.m_bCutContactNameOnTabs)
+ CutContactName(m_cache->getNick(), newcontactname, _countof(newcontactname));
+ else
+ wcsncpy_s(newcontactname, m_cache->getNick(), _TRUNCATE);
- Utils::DoubleAmpersands(newcontactname, _countof(newcontactname));
+ Utils::DoubleAmpersands(newcontactname, _countof(newcontactname));
- if (newcontactname[0] != 0) {
- if (PluginConfig.m_bStatusOnTabs)
- mir_snwprintf(newtitle, L"%s (%s)", newcontactname, m_wszStatus);
- else
- wcsncpy_s(newtitle, newcontactname, _TRUNCATE);
- }
- else wcsncpy_s(newtitle, L"Forward", _TRUNCATE);
+ if (newcontactname[0] != 0) {
+ if (PluginConfig.m_bStatusOnTabs)
+ mir_snwprintf(newtitle, L"%s (%s)", newcontactname, m_wszStatus);
+ else
+ wcsncpy_s(newtitle, newcontactname, _TRUNCATE);
+ }
+ else wcsncpy_s(newtitle, L"Forward", _TRUNCATE);
- if (mir_wstrcmp(newtitle, m_wszTitle))
- bChanged = true;
- else if (m_wStatus != m_wOldStatus)
- bChanged = true;
+ if (mir_wstrcmp(newtitle, m_wszTitle))
+ bChanged = true;
+ else if (m_wStatus != m_wOldStatus)
+ bChanged = true;
- UpdateWindowIcon();
+ UpdateWindowIcon();
- wchar_t fulluin[256];
- if (m_bIsMeta)
- mir_snwprintf(fulluin,
- TranslateT("UID: %s (Shift+click -> copy to clipboard)\nClick for user's details\nRight click for metacontact control\nClick dropdown to add or remove user from your favorites."),
- bHasName ? m_cache->getUIN() : TranslateT("No UID"));
- else
- mir_snwprintf(fulluin,
- TranslateT("UID: %s (Shift+click -> copy to clipboard)\nClick for user's details\nClick dropdown to change this contact's favorite status."),
- bHasName ? m_cache->getUIN() : TranslateT("No UID"));
+ wchar_t fulluin[256];
+ if (m_bIsMeta)
+ mir_snwprintf(fulluin,
+ TranslateT("UID: %s (Shift+click -> copy to clipboard)\nClick for user's details\nRight click for metacontact control\nClick dropdown to add or remove user from your favorites."),
+ bHasName ? m_cache->getUIN() : TranslateT("No UID"));
+ else
+ mir_snwprintf(fulluin,
+ TranslateT("UID: %s (Shift+click -> copy to clipboard)\nClick for user's details\nClick dropdown to change this contact's favorite status."),
+ bHasName ? m_cache->getUIN() : TranslateT("No UID"));
- SendDlgItemMessage(m_hwnd, IDC_NAME, BUTTONADDTOOLTIP, (WPARAM)fulluin, BATF_UNICODE);
- }
+ SendDlgItemMessage(m_hwnd, IDC_NAME, BUTTONADDTOOLTIP, (WPARAM)fulluin, BATF_UNICODE);
}
else wcsncpy_s(newtitle, L"Message Session", _TRUNCATE);
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp
index 1d03aa7a1c..cd057cae83 100644
--- a/plugins/TabSRMM/src/msglog.cpp
+++ b/plugins/TabSRMM/src/msglog.cpp
@@ -468,7 +468,8 @@ static char* Template_CreateRTFFromDbEvent(CMsgDialog *dat, MCONTACT hContact, M
CMStringA str;
- if (dat->m_isAutoRTL & 2) { // means: last \\par was deleted to avoid new line at end of log
+ // means: last \\par was deleted to avoid new line at end of log
+ if (dat->m_isAutoRTL & 2) {
str.Append("\\par");
dat->m_isAutoRTL &= ~2;
}
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp
index 56b552fc78..d245b7e032 100644
--- a/plugins/TabSRMM/src/msgs.cpp
+++ b/plugins/TabSRMM/src/msgs.cpp
@@ -254,13 +254,18 @@ int MyAvatarChanged(WPARAM wParam, LPARAM lParam)
void TSAPI CreateNewTabForContact(TContainerData *pContainer, MCONTACT hContact, bool bActivateTab, bool bPopupContainer, bool bWantPopup, MEVENT hdbEvent, bool bIsUnicode, const char *pszInitialText)
{
+ if (hContact == 0) {
+ _DebugPopup(hContact, L"Warning: trying to create a window for empty contact");
+ return;
+ }
+
if (Srmm_FindWindow(hContact) != nullptr) {
_DebugPopup(hContact, L"Warning: trying to create duplicate window");
return ;
}
// if we have a max # of tabs/container set and want to open something in the default container...
- if (hContact != 0 && M.GetByte("limittabs", 0) && !wcsncmp(pContainer->m_wszName, L"default", 6))
+ if (M.GetByte("limittabs", 0) && !wcsncmp(pContainer->m_wszName, L"default", 6))
if ((pContainer = FindMatchingContainer(L"default")) == nullptr)
if ((pContainer = CreateContainer(L"default", CNT_CREATEFLAG_CLONED, hContact)) == nullptr)
return;
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp
index c15d03e5f1..8f33be1bea 100644
--- a/plugins/TabSRMM/src/sendqueue.cpp
+++ b/plugins/TabSRMM/src/sendqueue.cpp
@@ -235,9 +235,6 @@ int SendQueue::sendQueued(CMsgDialog *dat, const int iEntry)
return 0;
}
- if (dat->m_hContact == 0)
- return 0; //never happens
-
size_t iMaxSize = dat->m_cache->getMaxMessageLength();
if (M.GetByte("autosplit", 0) && !(dat->m_sendMode & SMODE_SENDLATER)) {
diff --git a/plugins/TabSRMM/src/templates.cpp b/plugins/TabSRMM/src/templates.cpp
index 8ce727e011..7829258d75 100644
--- a/plugins/TabSRMM/src/templates.cpp
+++ b/plugins/TabSRMM/src/templates.cpp
@@ -125,6 +125,23 @@ CTemplateEditDlg::CTemplateEditDlg(BOOL _rtl, HWND hwndParent) :
{
SetParent(hwndParent);
+ // set hContact to the first found contact so that we can use the Preview window properly
+ // also, set other parameters needed by the streaming function to display events
+ for (auto &cc : Contacts()) {
+ if (m_szProto = Proto_GetBaseAccountName(m_hContact)) {
+ m_hContact = cc;
+ break;
+ }
+ }
+
+ // empty contact list? create a temportary one, that will be automatically removed
+ if (m_hContact == 0) {
+ m_hContact = db_add_contact();
+ Proto_AddToContact(m_hContact, m_szProto = META_PROTO);
+ Contact_Hide(m_hContact);
+ Contact_RemoveFromList(m_hContact);
+ }
+
m_pContainer = new TContainerData();
m_pContainer->LoadOverrideTheme();
tSet = rtl ? m_pContainer->m_rtl_templates : m_pContainer->m_ltr_templates;
@@ -145,14 +162,6 @@ bool CTemplateEditDlg::OnInitDialog()
{
m_pLog = new CLogWindow(*this);
- // set hContact to the first found contact so that we can use the Preview window properly
- // also, set other parameters needed by the streaming function to display events
- m_hContact = db_find_first();
- m_szProto = Proto_GetBaseAccountName(m_hContact);
- while (m_szProto == nullptr && m_hContact != 0) {
- m_hContact = db_find_next(m_hContact);
- m_szProto = Proto_GetBaseAccountName(m_hContact);
- }
m_dwFlags = m_pContainer->m_theme.dwFlags;
m_cache = CContactCache::getContactCache(m_hContact);