diff options
Diffstat (limited to 'plugins/Scriver/src')
| -rw-r--r-- | plugins/Scriver/src/msgdialog.cpp | 42 | ||||
| -rw-r--r-- | plugins/Scriver/src/msglog.cpp | 6 | ||||
| -rw-r--r-- | plugins/Scriver/src/msgs.cpp | 20 | ||||
| -rw-r--r-- | plugins/Scriver/src/msgs.h | 8 | ||||
| -rw-r--r-- | plugins/Scriver/src/msgutils.cpp | 39 | 
5 files changed, 55 insertions, 60 deletions
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 8f7a405723..78ab1229ee 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -1165,48 +1165,6 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)  		InvalidateRect(m_pLog->GetHwnd(), nullptr, FALSE);
  		break;
 -	case HM_DBEVENTADDED:
 -		if (wParam == m_hContact && !isChat()) {
 -			MEVENT hDbEvent = lParam;
 -			DBEVENTINFO dbei = {};
 -			db_event_get(hDbEvent, &dbei);
 -			if (m_hDbEventFirst == 0)
 -				m_hDbEventFirst = hDbEvent;
 -			if (DbEventIsShown(dbei)) {
 -				bool bIsActive = IsActive();
 -				if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & (DBEF_SENT))) {
 -					/* store the event when the container is hidden so that clist notifications can be removed */
 -					if (!IsWindowVisible(m_hwndParent) && m_hDbUnreadEventFirst == 0)
 -						m_hDbUnreadEventFirst = hDbEvent;
 -					m_lastMessage = dbei.timestamp;
 -					UpdateStatusBar();
 -					if (bIsActive)
 -						Skin_PlaySound("RecvMsgActive");
 -					else
 -						Skin_PlaySound("RecvMsgInactive");
 -					if (g_dat.flags2.bSwitchToActive && (IsIconic(m_hwndParent) || GetActiveWindow() != m_hwndParent) && IsWindowVisible(m_hwndParent))
 -						m_pParent->ActivateChild(this);
 -					if (IsAutoPopup(m_hContact))
 -						PopupWindow(true);
 -				}
 -
 -				if (hDbEvent != m_hDbEventFirst && db_event_next(m_hContact, hDbEvent) == 0)
 -					m_pLog->LogEvents(hDbEvent, 1, 1);
 -				else
 -					SendMessage(m_hwnd, DM_REMAKELOG, 0, 0);
 -
 -				if (!(dbei.flags & DBEF_SENT) && !DbEventIsCustomForMsgWindow(&dbei)) {
 -					if (!bIsActive) {
 -						m_iShowUnread = 1;
 -						UpdateIcon();
 -						SetTimer(m_hwnd, TIMERID_UNREAD, TIMEOUT_UNREAD, nullptr);
 -					}
 -					StartFlashing();
 -				}
 -			}
 -		}
 -		break;
 -
  	case WM_TIMER:
  		if (wParam == TIMERID_MSGSEND)
  			ReportSendQueueTimeouts(this);
 diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index 95c7269cd7..139fd3eef0 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -50,18 +50,18 @@ struct LogStreamData  	EventData *events;
  };
 -int DbEventIsCustomForMsgWindow(DBEVENTINFO *dbei)
 +bool DbEventIsCustomForMsgWindow(const DBEVENTINFO *dbei)
  {
  	DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType);
  	return et && (et->flags & DETF_MSGWINDOW);
  }
 -int DbEventIsMessageOrCustom(DBEVENTINFO* dbei)
 +bool DbEventIsMessageOrCustom(const DBEVENTINFO* dbei)
  {
  	return dbei->eventType == EVENTTYPE_MESSAGE || DbEventIsCustomForMsgWindow(dbei);
  }
 -int DbEventIsShown(DBEVENTINFO &dbei)
 +bool DbEventIsShown(const DBEVENTINFO &dbei)
  {
  	switch (dbei.eventType) {
  	case EVENTTYPE_MESSAGE:
 diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 01ffec8586..e939a1c69e 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -79,19 +79,14 @@ static INT_PTR ReadMessageCommand(WPARAM, LPARAM lParam)  	return 0;
  }
 -static int MessageEventAdded(WPARAM hContact, LPARAM lParam)
 +static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent)
  {
 -	MCONTACT hContactWnd;
 -	MEVENT hDbEvent = (MEVENT)lParam;
 -
 -	HWND hwnd = Srmm_FindWindow(hContactWnd = hContact);
 -	if (hwnd == nullptr)
 -		hwnd = Srmm_FindWindow(hContactWnd = db_event_getContact(hDbEvent));
 -	if (hwnd)
 -		::PostMessage(hwnd, HM_DBEVENTADDED, hContactWnd, lParam);
 +	if (hContact == 0 || Contact::IsGroupChat(hContact))
 +		return 0;
  	DBEVENTINFO dbei = {};
 -	db_event_get(hDbEvent, &dbei);
 +	if (db_event_get(hDbEvent, &dbei))
 +		return 0;
  	if (dbei.eventType == EVENTTYPE_MESSAGE && (dbei.flags & DBEF_READ))
  		return 0;
 @@ -99,8 +94,11 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam)  	if (dbei.flags & DBEF_SENT || !DbEventIsMessageOrCustom(&dbei))
  		return 0;
 -	g_clistApi.pfnRemoveEvent(hContact, 1);
  	/* does a window for the contact exist? */
 +	HWND hwnd = Srmm_FindWindow(hContact);
 +	if (hwnd == nullptr)
 +		hwnd = Srmm_FindWindow(db_event_getContact(hDbEvent));
 +
  	if (hwnd == nullptr) {
  		/* new message */
  		Skin_PlaySound("AlertMsg");
 diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index 7b92e8ce24..30c228f101 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -172,6 +172,7 @@ public:  	void onType(CTimer *);
  	void CloseTab() override;
 +	void EventAdded(MEVENT, const DBEVENTINFO &dbei) override;
  	bool GetFirstEvent() override;
  	void LoadSettings() override;
  	void SetStatusText(const wchar_t *, HICON) override;
 @@ -217,7 +218,6 @@ public:  	void Reattach(HWND hwndContainer);
  };
 -#define HM_DBEVENTADDED        (WM_USER+10)
  #define HM_ACKEVENT            (WM_USER+11)
  #define DM_REMAKELOG           (WM_USER+12)
 @@ -235,9 +235,9 @@ public:  #define EVENTTYPE_JABBER_CHATSTATES	2000
  #define EVENTTYPE_JABBER_PRESENCE	2001
 -int DbEventIsShown(DBEVENTINFO &dbei);
 -int DbEventIsCustomForMsgWindow(DBEVENTINFO *dbei);
 -int DbEventIsMessageOrCustom(DBEVENTINFO *dbei);
 +bool DbEventIsShown(const DBEVENTINFO &dbei);
 +bool DbEventIsCustomForMsgWindow(const DBEVENTINFO *dbei);
 +bool DbEventIsMessageOrCustom(const DBEVENTINFO *dbei);
  void LoadMsgLogIcons(void);
  void FreeMsgLogIcons(void);
  int IsAutoPopup(MCONTACT hContact);
 diff --git a/plugins/Scriver/src/msgutils.cpp b/plugins/Scriver/src/msgutils.cpp index 01210cdcbd..4df469e568 100644 --- a/plugins/Scriver/src/msgutils.cpp +++ b/plugins/Scriver/src/msgutils.cpp @@ -36,6 +36,45 @@ void CMsgDialog::CloseTab()  	Close();  } +void CMsgDialog::EventAdded(MEVENT hDbEvent, const DBEVENTINFO &dbei) +{ +	if (m_hDbEventFirst == 0) +		m_hDbEventFirst = hDbEvent; + +	if (DbEventIsShown(dbei)) { +		bool bIsActive = IsActive(); +		if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & (DBEF_SENT))) { +			/* store the event when the container is hidden so that clist notifications can be removed */ +			if (!IsWindowVisible(m_hwndParent) && m_hDbUnreadEventFirst == 0) +				m_hDbUnreadEventFirst = hDbEvent; +			m_lastMessage = dbei.timestamp; +			UpdateStatusBar(); +			if (bIsActive) +				Skin_PlaySound("RecvMsgActive"); +			else +				Skin_PlaySound("RecvMsgInactive"); +			if (g_dat.flags2.bSwitchToActive && (IsIconic(m_hwndParent) || GetActiveWindow() != m_hwndParent) && IsWindowVisible(m_hwndParent)) +				m_pParent->ActivateChild(this); +			if (IsAutoPopup(m_hContact)) +				PopupWindow(true); +		} + +		if (hDbEvent != m_hDbEventFirst && db_event_next(m_hContact, hDbEvent) == 0) +			m_pLog->LogEvents(hDbEvent, 1, 1); +		else +			SendMessage(m_hwnd, DM_REMAKELOG, 0, 0); + +		if (!(dbei.flags & DBEF_SENT) && !DbEventIsCustomForMsgWindow(&dbei)) { +			if (!bIsActive) { +				m_iShowUnread = 1; +				UpdateIcon(); +				SetTimer(m_hwnd, TIMERID_UNREAD, TIMEOUT_UNREAD, nullptr); +			} +			StartFlashing(); +		} +	} +} +  bool CMsgDialog::GetFirstEvent()  {  	bool notifyUnread = false;  | 
