From 3576b67db9fa0a3d8d5c1747cc3560504d31d125 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 5 Mar 2014 12:52:30 +0000 Subject: - adaptation for standard Windows ways of handling Unicode; - obsoleted code removed; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@8407 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/HistoryStats/src/contact.cpp | 98 ++++++++++++++---------------------- 1 file changed, 37 insertions(+), 61 deletions(-) (limited to 'plugins/HistoryStats/src/contact.cpp') diff --git a/plugins/HistoryStats/src/contact.cpp b/plugins/HistoryStats/src/contact.cpp index 260ed68c1e..830c782f91 100644 --- a/plugins/HistoryStats/src/contact.cpp +++ b/plugins/HistoryStats/src/contact.cpp @@ -5,39 +5,37 @@ #include #include -Contact::Contact(Statistic* pStatistic, int nSlots, const ext::string& nick, const ext::string& protocol, const ext::string& group, int nContacts, int nSubcontacts) - : m_Nick(nick) - , m_Protocol(protocol) - , m_Group(group) - , m_Bytes(0, 0) - , m_Messages(0, 0) - , m_Chats(0, 0) - , m_bFirstLastTimeValid(false) - , m_FirstTime(0) - , m_LastTime(0) - , m_bChatDurValid(false) - , m_ChatDurMin(0xFFFFFFFF) - , m_ChatDurMax(0) - , m_ChatDurSum(0) - , m_Urls(0, 0) - , m_Files(0, 0) - , m_NumContacts(nContacts) - , m_NumSubcontacts(nSubcontacts) - , m_pStatistic(pStatistic) +Contact::Contact(Statistic* pStatistic, int nSlots, const ext::string& nick, const ext::string& protocol, const ext::string& group, int nContacts, int nSubcontacts) : + m_Nick(nick), + m_Protocol(protocol), + m_Group(group), + m_Bytes(0, 0), + m_Messages(0, 0), + m_Chats(0, 0), + m_bFirstLastTimeValid(false), + m_FirstTime(0), + m_LastTime(0), + m_bChatDurValid(false), + m_ChatDurMin(0xFFFFFFFF), + m_ChatDurMax(0), + m_ChatDurSum(0), + m_Urls(0, 0), + m_Files(0, 0), + m_NumContacts(nContacts), + m_NumSubcontacts(nSubcontacts), + m_pStatistic(pStatistic) { m_Slots.resize(nSlots, NULL); } void Contact::updateTime(DWORD msgTime) { - if (!m_bFirstLastTimeValid) - { + if (!m_bFirstLastTimeValid) { m_FirstTime = msgTime; m_LastTime = msgTime; m_bFirstLastTimeValid = true; } - else - { + else { m_FirstTime = min(m_FirstTime, msgTime); m_LastTime = max(m_LastTime, msgTime); } @@ -56,24 +54,19 @@ void Contact::updateChatDur(DWORD timeDelta) double Contact::getAvg(int nTotal) const { DWORD dwHistTime = m_pStatistic->getLastTime() - getFirstTime(); - if (dwHistTime < m_pStatistic->getAverageMinTime()) - { dwHistTime = m_pStatistic->getAverageMinTime(); - } return dwHistTime ? (0.0 + nTotal) / dwHistTime : 0.0; } void Contact::addMessage(Message& msg) { - if (msg.isOutgoing()) - { + if (msg.isOutgoing()) { m_Bytes.out += msg.getLength(); m_Messages.out++; } - else - { + else { m_Bytes.in += msg.getLength(); m_Messages.in++; } @@ -84,13 +77,9 @@ void Contact::addMessage(Message& msg) void Contact::addChat(bool bOutgoing, DWORD localTimestampStarted, DWORD duration) { if (bOutgoing) - { m_Chats.out++; - } else - { m_Chats.in++; - } updateChatDur(duration); } @@ -99,59 +88,46 @@ void Contact::addEvent(WORD eventType, bool bOutgoing) { InOut* pIO = NULL; - switch (eventType) - { - case EVENTTYPE_URL: - pIO = &m_Urls; - break; + switch (eventType) { + case EVENTTYPE_URL: + pIO = &m_Urls; + break; - case EVENTTYPE_FILE: - pIO = &m_Files; - break; + case EVENTTYPE_FILE: + pIO = &m_Files; + break; - default: - return; + default: + return; } if (bOutgoing) - { pIO->out++; - } else - { pIO->in++; - } } void Contact::merge(const Contact& other) { if (m_Nick != other.m_Nick) - { - m_Nick = i18n(muT("(multiple)")); - } + m_Nick = TranslateT("(multiple)"); if (m_Protocol != other.m_Protocol) - { - m_Protocol = i18n(muT("(multiple)")); - } + m_Protocol = TranslateT("(multiple)"); if (m_Group != other.m_Group) - { - m_Group = i18n(muT("(multiple)")); - } + m_Group = TranslateT("(multiple)"); m_Bytes += other.m_Bytes; m_Messages += other.m_Messages; m_Chats += other.m_Chats; - if (other.m_bFirstLastTimeValid) - { + if (other.m_bFirstLastTimeValid) { updateTime(other.m_FirstTime); updateTime(other.m_LastTime); } - if (other.m_bChatDurValid) - { + if (other.m_bChatDurValid) { m_ChatDurSum += other.m_ChatDurSum - other.m_ChatDurMin - other.m_ChatDurMax; updateChatDur(other.m_ChatDurMin); -- cgit v1.2.3