summaryrefslogtreecommitdiff
path: root/plugins/Scriver/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Scriver/src')
-rw-r--r--plugins/Scriver/src/globals.cpp10
-rw-r--r--plugins/Scriver/src/msgdialog.cpp8
-rw-r--r--plugins/Scriver/src/msgs.h6
-rw-r--r--plugins/Scriver/src/msgtimedout.cpp12
-rw-r--r--plugins/Scriver/src/msgutils.cpp6
-rw-r--r--plugins/Scriver/src/sendqueue.cpp28
-rw-r--r--plugins/Scriver/src/sendqueue.h57
-rw-r--r--plugins/Scriver/src/tabs.cpp2
-rw-r--r--plugins/Scriver/src/tabs.h2
9 files changed, 68 insertions, 63 deletions
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp
index d3b03fb516..a9b36e00e5 100644
--- a/plugins/Scriver/src/globals.cpp
+++ b/plugins/Scriver/src/globals.cpp
@@ -102,23 +102,23 @@ static int ackevent(WPARAM, LPARAM lParam)
return 0;
MCONTACT hContact = pAck->hContact;
- MessageSendQueueItem *item = FindSendQueueItem(hContact, pAck->hProcess);
+ auto *item = SendQueue::FindItem(hContact, pAck->hProcess);
if (item == nullptr)
- item = FindSendQueueItem(hContact = db_mc_getMeta(pAck->hContact), pAck->hProcess);
+ item = SendQueue::FindItem(hContact = db_mc_getMeta(pAck->hContact), pAck->hProcess);
if (item == nullptr)
return 0;
auto *pSender = item->pDlg;
if (pAck->result == ACKRESULT_FAILED) {
if (item->hwndErrorDlg != nullptr)
- item = FindOldestPendingSendQueueItem(pSender, hContact);
+ item = SendQueue::FindOldestPendingItem(pSender, hContact);
if (item != nullptr && item->hwndErrorDlg == nullptr) {
if (pSender != nullptr) {
pSender->StopMessageSending();
pSender->ShowError((wchar_t *)pAck->lParam, item);
}
- else RemoveSendQueueItem(item);
+ else SendQueue::RemoveItem(item);
}
return 0;
}
@@ -143,7 +143,7 @@ static int ackevent(WPARAM, LPARAM lParam)
if (item->hwndErrorDlg != nullptr)
DestroyWindow(item->hwndErrorDlg);
- if (RemoveSendQueueItem(item) && g_plugin.bAutoClose) {
+ if (SendQueue::RemoveItem(item) && g_plugin.bAutoClose) {
if (pSender != nullptr)
pSender->Close();
}
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp
index 8821644dcd..5ef1d370be 100644
--- a/plugins/Scriver/src/msgdialog.cpp
+++ b/plugins/Scriver/src/msgdialog.cpp
@@ -218,7 +218,7 @@ bool CMsgDialog::OnInitDialog()
StartFlashing();
}
- m_iMessagesInProgress = ReattachSendQueueItems(this, m_hContact);
+ m_iMessagesInProgress = SendQueue::ReattachItems(this, m_hContact);
if (m_iMessagesInProgress > 0)
ShowMessageSending();
}
@@ -247,7 +247,7 @@ void CMsgDialog::OnDestroy()
m_hStatusIconOverlay = nullptr;
}
- ReleaseSendQueueItems(this);
+ SendQueue::ReleaseItems(this);
if (g_dat.flags.bSaveDrafts) {
ptrA szText(m_message.GetRichTextRtf(true));
if (szText)
@@ -296,7 +296,7 @@ void CMsgDialog::onClick_Ok(CCtrlButton *pButton)
pf2.dwMask = PFM_RTLPARA;
m_message.SendMsg(EM_GETPARAFORMAT, 0, (LPARAM)&pf2);
- MessageSendQueueItem msi = {};
+ SendQueue::Item msi = {};
if (pf2.wEffects & PFE_RTLPARA)
msi.flags |= PREF_RTL;
@@ -1001,7 +1001,7 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
case WM_TIMER:
if (wParam == TIMERID_MSGSEND)
- ReportSendQueueTimeouts(this);
+ SendQueue::ReportTimeouts(this);
else if (wParam == TIMERID_UNREAD) {
TabControlData tcd;
tcd.iFlags = TCDF_ICON;
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h
index 7c9fd6c3c5..78f75add4f 100644
--- a/plugins/Scriver/src/msgs.h
+++ b/plugins/Scriver/src/msgs.h
@@ -54,7 +54,7 @@ class CMsgDialog : public CSrmmBaseDialog
void Init(void);
int InputAreaShortcuts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void MessageDialogResize(int w, int h);
- void MessageSend(const MessageSendQueueItem &msg);
+ void MessageSend(const SendQueue::Item &msg);
void ShowAvatar(void);
void SetDialogToType(void);
void SetStatusIcon(void);
@@ -141,8 +141,8 @@ public:
void UpdateStatusBar() override;
void UpdateTitle() override;
- void HandleError(bool bRetry, MessageSendQueueItem *pItem);
- void ShowError(const wchar_t *pwszMsg, MessageSendQueueItem *pItem);
+ void HandleError(bool bRetry, SendQueue::Item *pItem);
+ void ShowError(const wchar_t *pwszMsg, SendQueue::Item *pItem);
void FixTabIcons();
void GetAvatar();
diff --git a/plugins/Scriver/src/msgtimedout.cpp b/plugins/Scriver/src/msgtimedout.cpp
index 2ea8412755..f65e9a2c29 100644
--- a/plugins/Scriver/src/msgtimedout.cpp
+++ b/plugins/Scriver/src/msgtimedout.cpp
@@ -28,12 +28,12 @@ class CErrorDlg : public CDlgBase
ptrW m_wszText;
CMStringW m_wszName, m_wszDescr;
CMsgDialog *m_pOwner;
- MessageSendQueueItem *m_queueItem;
+ SendQueue::Item *m_queueItem;
CCtrlBase m_errorText, m_msgText;
public:
- CErrorDlg(CMsgDialog *pOwner, const wchar_t *pwszDescr, MessageSendQueueItem *pItem) :
+ CErrorDlg(CMsgDialog *pOwner, const wchar_t *pwszDescr, SendQueue::Item *pItem) :
CDlgBase(g_plugin, IDD_MSGSENDERROR),
m_pOwner(pOwner),
m_wszText(mir_utf8decodeW(pItem->sendBuffer)),
@@ -75,21 +75,21 @@ public:
}
};
-void CMsgDialog::ShowError(const wchar_t *pwszMsg, MessageSendQueueItem *pItem)
+void CMsgDialog::ShowError(const wchar_t *pwszMsg, SendQueue::Item *pItem)
{
auto *pDlg = new CErrorDlg(this, pwszMsg, pItem);
pDlg->SetParent(m_hwnd);
pDlg->Show();
}
-void CMsgDialog::HandleError(bool bRetry, MessageSendQueueItem *pItem)
+void CMsgDialog::HandleError(bool bRetry, SendQueue::Item *pItem)
{
if (bRetry) {
StartMessageSending();
- SendSendQueueItem(pItem);
+ SendQueue::SendItem(pItem);
}
else {
- RemoveSendQueueItem(pItem);
+ SendQueue::RemoveItem(pItem);
SetFocus(m_message.GetHwnd());
}
}
diff --git a/plugins/Scriver/src/msgutils.cpp b/plugins/Scriver/src/msgutils.cpp
index fdbeb7a117..62429f8c9c 100644
--- a/plugins/Scriver/src/msgutils.cpp
+++ b/plugins/Scriver/src/msgutils.cpp
@@ -259,17 +259,17 @@ void CMsgDialog::LoadSettings()
LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, nullptr, &m_clrInputFG);
}
-void CMsgDialog::MessageSend(const MessageSendQueueItem &msi)
+void CMsgDialog::MessageSend(const SendQueue::Item &msi)
{
StartMessageSending();
- MessageSendQueueItem *item = CreateSendQueueItem(this);
+ SendQueue::Item *item = SendQueue::CreateItem(this);
item->hContact = m_hContact;
item->proto = mir_strdup(m_szProto);
item->flags = msi.flags;
item->sendBufferSize = msi.sendBufferSize;
item->sendBuffer = mir_strndup(msi.sendBuffer, msi.sendBufferSize);
- SendSendQueueItem(item);
+ SendQueue::SendItem(item);
}
// Don't send to protocols who don't support typing
diff --git a/plugins/Scriver/src/sendqueue.cpp b/plugins/Scriver/src/sendqueue.cpp
index 2447759f57..a450e2f280 100644
--- a/plugins/Scriver/src/sendqueue.cpp
+++ b/plugins/Scriver/src/sendqueue.cpp
@@ -23,12 +23,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
-static OBJLIST<MessageSendQueueItem> arQueue(1, PtrKeySortT);
+using namespace SendQueue;
+
+static OBJLIST<Item> arQueue(1, PtrKeySortT);
static mir_cs queueMutex;
-MessageSendQueueItem* CreateSendQueueItem(CMsgDialog *pDlg)
+Item* SendQueue::CreateItem(CMsgDialog *pDlg)
{
- MessageSendQueueItem *item = new MessageSendQueueItem();
+ Item *item = new Item();
item->pDlg = pDlg;
mir_cslock lck(queueMutex);
@@ -36,7 +38,7 @@ MessageSendQueueItem* CreateSendQueueItem(CMsgDialog *pDlg)
return item;
}
-MessageSendQueueItem* FindOldestPendingSendQueueItem(CMsgDialog *pDlg, MCONTACT hContact)
+Item* SendQueue::FindOldestPendingItem(CMsgDialog *pDlg, MCONTACT hContact)
{
mir_cslock lck(queueMutex);
for (auto &it : arQueue)
@@ -46,7 +48,7 @@ MessageSendQueueItem* FindOldestPendingSendQueueItem(CMsgDialog *pDlg, MCONTACT
return nullptr;
}
-MessageSendQueueItem* FindSendQueueItem(MCONTACT hContact, HANDLE hSendId)
+Item* SendQueue::FindItem(MCONTACT hContact, HANDLE hSendId)
{
mir_cslock lock(queueMutex);
for (auto &it : arQueue)
@@ -56,7 +58,7 @@ MessageSendQueueItem* FindSendQueueItem(MCONTACT hContact, HANDLE hSendId)
return nullptr;
}
-bool RemoveSendQueueItem(MessageSendQueueItem *item)
+bool SendQueue::RemoveItem(Item *item)
{
auto *pDlg = item->pDlg;
{
@@ -71,7 +73,7 @@ bool RemoveSendQueueItem(MessageSendQueueItem *item)
return true;
}
-void ReportSendQueueTimeouts(CMsgDialog *pDlg)
+void SendQueue::ReportTimeouts(CMsgDialog *pDlg)
{
int timeout = g_plugin.iMsgTimeout * 1000;
@@ -80,7 +82,7 @@ void ReportSendQueueTimeouts(CMsgDialog *pDlg)
for (auto &it : arQueue.rev_iter()) {
if (it->timeout >= timeout)
continue;
-
+
it->timeout += 1000;
if (it->timeout < timeout || it->pDlg != pDlg || it->hwndErrorDlg != nullptr)
continue;
@@ -93,7 +95,7 @@ void ReportSendQueueTimeouts(CMsgDialog *pDlg)
}
}
-void ReleaseSendQueueItems(CMsgDialog *pDlg)
+void SendQueue::ReleaseItems(CMsgDialog *pDlg)
{
mir_cslock lock(queueMutex);
@@ -109,7 +111,7 @@ void ReleaseSendQueueItems(CMsgDialog *pDlg)
}
}
-int ReattachSendQueueItems(CMsgDialog *pDlg, MCONTACT hContact)
+int SendQueue::ReattachItems(CMsgDialog *pDlg, MCONTACT hContact)
{
int count = 0;
@@ -125,14 +127,14 @@ int ReattachSendQueueItems(CMsgDialog *pDlg, MCONTACT hContact)
return count;
}
-void RemoveAllSendQueueItems()
+void SendQueue::RemoveAllItems()
{
mir_cslock lock(queueMutex);
arQueue.destroy();
}
-void SendSendQueueItem(MessageSendQueueItem* item)
+void SendQueue::SendItem(Item *item)
{
item->timeout = 0;
- item->hSendId = ProtoChainSend(item->hContact, PSS_MESSAGE, item->flags, (LPARAM)item->sendBuffer);
+ item->hSendId = ProtoChainSend(item->hContact, PSS_MESSAGE, item->pDlg->m_hQuoteEvent, (LPARAM)item->sendBuffer);
}
diff --git a/plugins/Scriver/src/sendqueue.h b/plugins/Scriver/src/sendqueue.h
index ea4e7599a4..0fc3658678 100644
--- a/plugins/Scriver/src/sendqueue.h
+++ b/plugins/Scriver/src/sendqueue.h
@@ -24,35 +24,38 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SRMM_SENDQUEUE_H
#define SRMM_SENDQUEUE_H
-struct MessageSendQueueItem : public MZeroedObject
+namespace SendQueue
{
- ~MessageSendQueueItem()
+ struct Item : public MZeroedObject
{
- mir_free(proto);
- mir_free(sendBuffer);
- }
-
- CMsgDialog *pDlg;
- MCONTACT hContact;
- char *proto;
- int hSendId;
- int timeout;
- char *sendBuffer;
- int sendBufferSize;
- int codepage;
- int flags;
- HWND hwndErrorDlg;
+ ~Item()
+ {
+ mir_free(proto);
+ mir_free(sendBuffer);
+ }
+
+ CMsgDialog *pDlg;
+ MCONTACT hContact;
+ char *proto;
+ int hSendId;
+ int timeout;
+ char *sendBuffer;
+ int sendBufferSize;
+ int codepage;
+ int flags;
+ HWND hwndErrorDlg;
+ };
+
+ Item* CreateItem(CMsgDialog *pDlg);
+ Item* FindItem(MCONTACT hContact, HANDLE hSendId);
+ Item* FindOldestPendingItem(CMsgDialog *pDlg, MCONTACT hContact);
+
+ bool RemoveItem(Item *item);
+ void ReportTimeouts(CMsgDialog *pDlg);
+ void ReleaseItems(CMsgDialog *pDlg);
+ int ReattachItems(CMsgDialog *pDlg, MCONTACT hContact);
+ void RemoveAllItems();
+ void SendItem(Item *item);
};
-MessageSendQueueItem* CreateSendQueueItem(CMsgDialog *pDlg);
-MessageSendQueueItem* FindOldestPendingSendQueueItem(CMsgDialog *pDlg, MCONTACT hContact);
-MessageSendQueueItem* FindSendQueueItem(MCONTACT hContact, HANDLE hSendId);
-
-bool RemoveSendQueueItem(MessageSendQueueItem* item);
-void ReportSendQueueTimeouts(CMsgDialog *pDlg);
-void ReleaseSendQueueItems(CMsgDialog *pDlg);
-int ReattachSendQueueItems(CMsgDialog *pDlg, MCONTACT hContact);
-void RemoveAllSendQueueItems();
-void SendSendQueueItem(MessageSendQueueItem* item);
-
#endif
diff --git a/plugins/Scriver/src/tabs.cpp b/plugins/Scriver/src/tabs.cpp
index 8af0659443..ae5955063c 100644
--- a/plugins/Scriver/src/tabs.cpp
+++ b/plugins/Scriver/src/tabs.cpp
@@ -267,7 +267,7 @@ void ParentWindowData::CloseOtherChilden(CMsgDialog *pChildDlg)
ActivateChild(pChildDlg);
}
-void ParentWindowData::MessageSend(const MessageSendQueueItem &msg)
+void ParentWindowData::MessageSend(const SendQueue::Item &msg)
{
for (int i = 0; i < m_iChildrenCount; i++) {
CMsgDialog *pDlg = GetChildFromTab(m_hwndTabs, i);
diff --git a/plugins/Scriver/src/tabs.h b/plugins/Scriver/src/tabs.h
index 41a0de8cb1..9f9d714a29 100644
--- a/plugins/Scriver/src/tabs.h
+++ b/plugins/Scriver/src/tabs.h
@@ -108,7 +108,7 @@ struct ParentWindowData
CMsgDialog *GetChildFromHWND(HWND hwnd);
void PopupWindow(CMsgDialog *pDlg, bool bIncoming);
void RemoveChild(HWND child);
- void MessageSend(const MessageSendQueueItem &msg);
+ void MessageSend(const SendQueue::Item &msg);
void SetContainerWindowStyle();
void StartFlashing();
void ToggleInfoBar();