diff options
Diffstat (limited to 'plugins/MessageState')
-rw-r--r-- | plugins/MessageState/src/clist_extra.cpp | 14 | ||||
-rw-r--r-- | plugins/MessageState/src/main.cpp | 5 | ||||
-rw-r--r-- | plugins/MessageState/src/messagestate.cpp | 41 | ||||
-rw-r--r-- | plugins/MessageState/src/services.cpp | 7 | ||||
-rw-r--r-- | plugins/MessageState/src/stdafx.h | 2 | ||||
-rw-r--r-- | plugins/MessageState/src/utils.cpp | 3 |
6 files changed, 29 insertions, 43 deletions
diff --git a/plugins/MessageState/src/clist_extra.cpp b/plugins/MessageState/src/clist_extra.cpp index a4cf2e23f6..01a0f52739 100644 --- a/plugins/MessageState/src/clist_extra.cpp +++ b/plugins/MessageState/src/clist_extra.cpp @@ -4,12 +4,12 @@ HANDLE hExtraIcon = nullptr; int ExtraIconsApply(WPARAM hContact, LPARAM force)
{
- if (hContact == NULL) return 0;
-
- if (HasUnread(hContact) || force)
- ExtraIcon_SetIcon(hExtraIcon, hContact, Icons[ICON_EXTRA].hIcolib);
- else
- ExtraIcon_Clear(hExtraIcon, hContact);
+ if (hContact != NULL) {
+ if (HasUnread(hContact) || force)
+ ExtraIcon_SetIcon(hExtraIcon, hContact, Icons[ICON_EXTRA].hIcolib);
+ else
+ ExtraIcon_Clear(hExtraIcon, hContact);
+ }
return 0;
}
@@ -18,4 +18,4 @@ void InitClistExtraIcon() {
hExtraIcon = ExtraIcon_RegisterIcolib("messagestate_unread", LPGEN("MessageState unread extra icon"), "clist_unread_icon");
HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, ExtraIconsApply);
-}
\ No newline at end of file +}
diff --git a/plugins/MessageState/src/main.cpp b/plugins/MessageState/src/main.cpp index d799a1408e..d380c58a0a 100644 --- a/plugins/MessageState/src/main.cpp +++ b/plugins/MessageState/src/main.cpp @@ -4,7 +4,7 @@ CMPlugin g_plugin; /////////////////////////////////////////////////////////////////////////////////////////
-PLUGININFOEX pluginInfoEx =
+PLUGININFOEX pluginInfoEx =
{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -21,7 +21,8 @@ PLUGININFOEX pluginInfoEx = CMPlugin::CMPlugin() :
PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
-{}
+{
+}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/MessageState/src/messagestate.cpp b/plugins/MessageState/src/messagestate.cpp index 81bc96e438..a2dfc9c7f0 100644 --- a/plugins/MessageState/src/messagestate.cpp +++ b/plugins/MessageState/src/messagestate.cpp @@ -9,7 +9,7 @@ IconItem Icons[] = { LPGEN("Unread clist extra icon"), "clist_unread_icon", IDI_EXTRA },
};
-const wchar_t* Tooltips[] =
+const wchar_t* Tooltips[] =
{
LPGENW("Last message is not read"),
LPGENW("Last message read"),
@@ -26,31 +26,21 @@ void SetSRMMIcon(MCONTACT hContact, SRMM_ICON_TYPE type, time_t time) CMStringW tszTooltip;
- if (type != ICON_HIDDEN)
- {
+ if (type != ICON_HIDDEN) {
sid.hIcon = IcoLib_GetIconByHandle(Icons[type].hIcolib);
- if (type == ICON_READ)
- {
- if (g_plugin.getDword(hContact, DBKEY_MESSAGE_READ_TIME_TYPE, -1) == MRD_TYPE_READTIME)
- {
+ if (type == ICON_READ) {
+ if (g_plugin.getDword(hContact, DBKEY_MESSAGE_READ_TIME_TYPE, -1) == MRD_TYPE_READTIME) {
wcsftime(tszTooltip.GetBuffer(64), 64, TranslateT("Last message read at %X %x"), localtime(&time));
tszTooltip.ReleaseBuffer();
}
- else
- {
- tszTooltip = TranslateT("Last message read (unknown time)");
- }
+ else tszTooltip = TranslateT("Last message read (unknown time)");
}
- else
- tszTooltip = TranslateW(Tooltips[type]);
+ else tszTooltip = TranslateW(Tooltips[type]);
sid.tszTooltip = tszTooltip.GetBuffer();
}
- else
- {
- sid.flags |= MBF_HIDDEN;
- }
+ else sid.flags |= MBF_HIDDEN;
Srmm_ModifyIcon(hContact, &sid);
}
@@ -59,12 +49,10 @@ int IconsUpdate(MCONTACT hContact) {
time_t readtime = g_plugin.getDword(hContact, DBKEY_MESSAGE_READ_TIME, 0);
time_t lasttime = GetLastSentMessageTime(hContact);
- if (lasttime != -1 && readtime != 0)
- {
- SetSRMMIcon(hContact, HasUnread(hContact) ? ICON_UNREAD : ICON_READ , readtime);
+ if (lasttime != -1 && readtime != 0) {
+ SetSRMMIcon(hContact, HasUnread(hContact) ? ICON_UNREAD : ICON_READ, readtime);
}
- else
- {
+ else {
SetSRMMIcon(hContact, ICON_HIDDEN);
}
@@ -76,8 +64,7 @@ int IconsUpdate(MCONTACT hContact) int OnProtoAck(WPARAM, LPARAM lParam)
{
ACKDATA *pAck = (ACKDATA *)lParam;
- if (pAck && (pAck->type == ACKTYPE_MESSAGE || pAck->type == ACKTYPE_FILE) && CheckProtoSupport(pAck->szModule))
- {
+ if (pAck && (pAck->type == ACKTYPE_MESSAGE || pAck->type == ACKTYPE_FILE) && CheckProtoSupport(pAck->szModule)) {
if (pAck->result == ACKRESULT_SUCCESS) SetSRMMIcon(pAck->hContact, ICON_UNREAD);
else if (pAck->result == ACKRESULT_FAILED) SetSRMMIcon(pAck->hContact, ICON_FAILED);
@@ -86,7 +73,7 @@ int OnProtoAck(WPARAM, LPARAM lParam) return 0;
}
-int OnEventFilterAdd(WPARAM hContact, LPARAM lParam)
+int OnEventFilterAdd(WPARAM hContact, LPARAM lParam)
{
DBEVENTINFO *dbei = (DBEVENTINFO *)lParam;
if ((dbei->flags & DBEF_SENT) && CheckProtoSupport(dbei->szModule) && db_get_b(hContact, "Tab_SRMsg", "no_ack", 0))
@@ -98,7 +85,7 @@ int OnModulesLoaded(WPARAM, LPARAM) {
HookEvent(ME_PROTO_ACK, OnProtoAck);
HookEvent(ME_DB_EVENT_FILTER_ADD, OnEventFilterAdd);
-
+
g_plugin.registerIcon(MODULENAME, Icons);
StatusIconData sid = {};
@@ -108,7 +95,7 @@ int OnModulesLoaded(WPARAM, LPARAM) Srmm_AddIcon(&sid, &g_plugin);
InitClistExtraIcon();
-
+
for (auto &hContact : Contacts())
IconsUpdate(hContact);
diff --git a/plugins/MessageState/src/services.cpp b/plugins/MessageState/src/services.cpp index 3521ece9a9..4e2706d1e5 100644 --- a/plugins/MessageState/src/services.cpp +++ b/plugins/MessageState/src/services.cpp @@ -10,11 +10,10 @@ void InitServices() INT_PTR UpdateService(WPARAM hContact, LPARAM lParam)
{
MessageReadData *mrd = (MessageReadData*)lParam;
- if (mrd->dw_lastTime > g_plugin.getDword(hContact, DBKEY_MESSAGE_READ_TIME, 0))
- {
+ if (mrd->dw_lastTime > g_plugin.getDword(hContact, DBKEY_MESSAGE_READ_TIME, 0)) {
g_plugin.setDword(hContact, DBKEY_MESSAGE_READ_TIME, mrd->dw_lastTime);
g_plugin.setDword(hContact, DBKEY_MESSAGE_READ_TIME_TYPE, mrd->iTimeType);
IconsUpdate(hContact);
}
- return 0;
-}
\ No newline at end of file + return 0;
+}
diff --git a/plugins/MessageState/src/stdafx.h b/plugins/MessageState/src/stdafx.h index c5e033d418..ac6e58326e 100644 --- a/plugins/MessageState/src/stdafx.h +++ b/plugins/MessageState/src/stdafx.h @@ -27,4 +27,4 @@ struct CMPlugin : public PLUGIN<CMPlugin> int Load() override;
};
-extern IconItem Icons[];
\ No newline at end of file +extern IconItem Icons[];
diff --git a/plugins/MessageState/src/utils.cpp b/plugins/MessageState/src/utils.cpp index 7f8bf81487..ca4c028ef8 100644 --- a/plugins/MessageState/src/utils.cpp +++ b/plugins/MessageState/src/utils.cpp @@ -2,8 +2,7 @@ time_t GetLastSentMessageTime(MCONTACT hContact)
{
- for (MEVENT hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, hDbEvent))
- {
+ for (MEVENT hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, hDbEvent)) {
DBEVENTINFO dbei = {};
db_event_get(hDbEvent, &dbei);
if (dbei.flags & DBEF_SENT)
|