summaryrefslogtreecommitdiff
path: root/plugins/MirandaG15/src/CChatScreen.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-03-12 13:43:31 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-03-12 13:43:31 +0300
commit8dd4143614ffa1a309f07f0b1a19921955f9c3f5 (patch)
treec99f5116020adb618d020fe4df7283fb5268d9ab /plugins/MirandaG15/src/CChatScreen.cpp
parent6312425c1ad093cad87a688497728fdb12e24385 (diff)
MirandaG15: warning fixes + massive code cleaning
Diffstat (limited to 'plugins/MirandaG15/src/CChatScreen.cpp')
-rw-r--r--plugins/MirandaG15/src/CChatScreen.cpp391
1 files changed, 179 insertions, 212 deletions
diff --git a/plugins/MirandaG15/src/CChatScreen.cpp b/plugins/MirandaG15/src/CChatScreen.cpp
index 8fb8c7af79..580d5aa024 100644
--- a/plugins/MirandaG15/src/CChatScreen.cpp
+++ b/plugins/MirandaG15/src/CChatScreen.cpp
@@ -6,11 +6,7 @@
//************************************************************************
// Constructor
//************************************************************************
-CChatScreen::CChatScreen() : m_bTyping(false), m_bHideTitle(false), m_bContactTyping(false),
- m_bHideLabels(false), m_bMaximizedTimer(false), m_bCloseTimer(false),
- m_bIRCProtocol(false), m_dwCloseTimer(0), m_dwMaximizedTimer(0),
- m_dwMaximizedDuration(0), m_eReplyState(REPLY_STATE_NONE), m_iStatus(ID_STATUS_OFFLINE),
- m_hContact(NULL), m_hMessage(0)
+CChatScreen::CChatScreen()
{
}
@@ -26,7 +22,7 @@ CChatScreen::~CChatScreen()
//************************************************************************
bool CChatScreen::Initialize()
{
- if(!CScreen::Initialize())
+ if (!CScreen::Initialize())
return false;
m_InfoText.Initialize();
@@ -36,7 +32,7 @@ bool CChatScreen::Initialize()
m_Input.Initialize();
m_TextLog.Initialize();
m_Scrollbar.Initialize();
-
+
UpdateObjects();
// other attributes
m_InfoText.SetAlignment(DT_CENTER);
@@ -52,16 +48,16 @@ bool CChatScreen::Initialize()
m_UserStatus.SetAlignment(DT_LEFT);
m_UserStatus.SetWordWrap(TRUE);
m_UserStatus.SetText(L"Status");
-
-
+
+
m_UserProto.SetAlignment(DT_RIGHT);
m_UserProto.SetWordWrap(TRUE);
m_UserProto.SetText(L"User");
m_Input.Show(0);
-
+
m_TextLog.Show(1);
-
+
m_TextLog.SetScrollbar(&m_Scrollbar);
AddObject(&m_Scrollbar);
@@ -73,10 +69,10 @@ bool CChatScreen::Initialize()
AddObject(&m_UserProto);
- SetButtonBitmap(0,IDB_UP);
- SetButtonBitmap(1,IDB_DOWN);
- SetButtonBitmap(2,IDB_HISTORY);
- SetButtonBitmap(3,IDB_REPLY);
+ SetButtonBitmap(0, IDB_UP);
+ SetButtonBitmap(1, IDB_DOWN);
+ SetButtonBitmap(2, IDB_HISTORY);
+ SetButtonBitmap(3, IDB_REPLY);
return true;
}
@@ -86,7 +82,7 @@ bool CChatScreen::Initialize()
//************************************************************************
bool CChatScreen::Shutdown()
{
- if(!CScreen::Shutdown())
+ if (!CScreen::Shutdown())
return false;
return true;
@@ -99,13 +95,12 @@ void CChatScreen::UpdateObjects()
{
m_bHideTitle = false;
m_bHideLabels = !CConfig::GetBoolSetting(SHOW_LABELS);
-
- if(IsMaximized())
- {
- if(!m_bHideTitle && !CConfig::GetBoolSetting(MAXIMIZED_TITLE))
+
+ if (IsMaximized()) {
+ if (!m_bHideTitle && !CConfig::GetBoolSetting(MAXIMIZED_TITLE))
m_bHideTitle = true;
- if(!m_bHideLabels && !CConfig::GetBoolSetting(MAXIMIZED_LABELS))
+ if (!m_bHideLabels && !CConfig::GetBoolSetting(MAXIMIZED_LABELS))
m_bHideLabels = true;
}
@@ -117,45 +112,45 @@ void CChatScreen::UpdateObjects()
m_UserName.SetFont(CConfig::GetFont(FONT_TITLE));
m_UserStatus.SetFont(CConfig::GetFont(FONT_TITLE));
m_UserProto.SetFont(CConfig::GetFont(FONT_TITLE));
-
+
int w = GetWidth() - 8;
// Sizes
m_UserName.SetSize(w*0.4, CConfig::GetFontHeight(FONT_TITLE));
m_UserStatus.SetSize(w*0.25, CConfig::GetFontHeight(FONT_TITLE));
m_UserProto.SetSize(w*0.3, CConfig::GetFontHeight(FONT_TITLE));
-
- int iHeight =GetHeight();
- iHeight -= m_bHideTitle?0:CConfig::GetFontHeight(FONT_TITLE)+2;
- iHeight -= m_bHideLabels?0:5;
-
- m_Input.SetSize(GetWidth()-5, iHeight);
- m_TextLog.SetSize(GetWidth()-5, iHeight);
-
+
+ int iHeight = GetHeight();
+ iHeight -= m_bHideTitle ? 0 : CConfig::GetFontHeight(FONT_TITLE) + 2;
+ iHeight -= m_bHideLabels ? 0 : 5;
+
+ m_Input.SetSize(GetWidth() - 5, iHeight);
+ m_TextLog.SetSize(GetWidth() - 5, iHeight);
+
m_InfoText.SetSize(160, 28);
- m_InfoText.SetOrigin(0,(iHeight-CConfig::GetFontHeight(FONT_SESSION))/2);
+ m_InfoText.SetOrigin(0, (iHeight - CConfig::GetFontHeight(FONT_SESSION)) / 2);
// Origins
-
- m_UserName.SetOrigin(8+w*0.25, 0);
+
+ m_UserName.SetOrigin(8 + w * 0.25, 0);
m_UserStatus.SetOrigin(8, 0);
- m_UserProto.SetOrigin(GetWidth()-w*0.3, 0);
-
- m_TextLog.SetOrigin(0, m_bHideTitle?0:CConfig::GetFontHeight(FONT_TITLE)+2);
- m_Input.SetOrigin(0,m_bHideTitle?0:CConfig::GetFontHeight(FONT_TITLE)+2);
-
+ m_UserProto.SetOrigin(GetWidth() - w * 0.3, 0);
+
+ m_TextLog.SetOrigin(0, m_bHideTitle ? 0 : CConfig::GetFontHeight(FONT_TITLE) + 2);
+ m_Input.SetOrigin(0, m_bHideTitle ? 0 : CConfig::GetFontHeight(FONT_TITLE) + 2);
+
m_InfoText.SetOrigin(0, 10);
-
+
m_UserName.Show(!m_bHideTitle);
m_UserStatus.Show(!m_bHideTitle);
m_UserProto.Show(!m_bHideTitle);
- m_Scrollbar.SetOrigin(GetWidth()-4,(m_bHideTitle?0:CConfig::GetFontHeight(FONT_TITLE)+2));
- m_Scrollbar.SetSize(4,iHeight);
+ m_Scrollbar.SetOrigin(GetWidth() - 4, (m_bHideTitle ? 0 : CConfig::GetFontHeight(FONT_TITLE) + 2));
+ m_Scrollbar.SetSize(4, iHeight);
// other options
m_TextLog.SetLogSize(CConfig::GetIntSetting(SESSION_LOGSIZE));
-
- m_Input.SetBreakKeys(CConfig::GetBoolSetting(SESSION_SENDRETURN)?KEYS_RETURN:KEYS_CTRL_RETURN);
+
+ m_Input.SetBreakKeys(CConfig::GetBoolSetting(SESSION_SENDRETURN) ? KEYS_RETURN : KEYS_CTRL_RETURN);
m_Input.ShowSymbols(CConfig::GetBoolSetting(SESSION_SYMBOLS));
ShowButtons(!m_bHideLabels);
@@ -172,20 +167,19 @@ void CChatScreen::UpdateLabels()
tstring strProto = L"";
tstring strStatus = L"";
- if(szProto != nullptr)
- {
+ if (szProto != nullptr) {
strProto = L"(" + toTstring(szProto) + L")";
- m_iStatus = db_get_w(m_hContact,szProto,"Status",ID_STATUS_OFFLINE);
+ m_iStatus = db_get_w(m_hContact, szProto, "Status", ID_STATUS_OFFLINE);
}
-
+
wchar_t *szStatus = Clist_GetStatusModeDescription(m_iStatus, 0);
- if(szStatus != nullptr)
+ if (szStatus != nullptr)
strStatus = toTstring(szStatus);
m_UserName.SetText(strNickname.c_str());
m_UserStatus.SetText(strStatus.c_str());
- if(m_bContactTyping && CConfig::GetBoolSetting(SESSION_SHOWTYPING))
+ if (m_bContactTyping && CConfig::GetBoolSetting(SESSION_SHOWTYPING))
m_UserProto.SetText(CAppletManager::TranslateString(L"typing.."));
else
m_UserProto.SetText(strProto.c_str());
@@ -194,7 +188,7 @@ void CChatScreen::UpdateLabels()
// returns wether the input mode is active
bool CChatScreen::IsInputActive()
{
- if(m_eReplyState != REPLY_STATE_NONE)
+ if (m_eReplyState != REPLY_STATE_NONE)
return true;
else
return false;
@@ -213,29 +207,28 @@ MCONTACT CChatScreen::GetContact()
//************************************************************************
bool CChatScreen::SetContact(MCONTACT hContact)
{
- if(hContact == NULL)
- {
+ if (hContact == NULL) {
m_hContact = NULL;
return true;
}
-
+
// Check if the contact is valid
char *szProto = GetContactProto(hContact);
m_strProto = toTstring(szProto);
CIRCConnection *pIRCCon = CAppletManager::GetInstance()->GetIRCConnection(m_strProto);
- if(pIRCCon)
+ if (pIRCCon)
m_bIRCProtocol = true;
else
m_bIRCProtocol = false;
-
-
- if(!szProto)
+
+
+ if (!szProto)
return false;
- if(m_eReplyState != REPLY_STATE_NONE)
+ if (m_eReplyState != REPLY_STATE_NONE)
DeactivateMessageMode();
- else if(IsMaximized())
+ else if (IsMaximized())
Minimize();
m_bContactTyping = false;
@@ -253,83 +246,70 @@ bool CChatScreen::SetContact(MCONTACT hContact)
//************************************************************************
void CChatScreen::LoadHistory()
{
- if(!m_hContact)
+ if (!m_hContact)
return;
char *szProto = GetContactProto(m_hContact);
-
- if(m_bIRCProtocol && db_get_b(m_hContact, szProto, "ChatRoom", 0) != 0)
- {
- if(!CAppletManager::GetInstance()->IsIRCHookEnabled())
- {
+
+ if (m_bIRCProtocol && db_get_b(m_hContact, szProto, "ChatRoom", 0) != 0) {
+ if (!CAppletManager::GetInstance()->IsIRCHookEnabled()) {
time_t now;
tm tm_now;
time(&now);
- localtime_s(&tm_now,&now);
+ localtime_s(&tm_now, &now);
- AddIncomingMessage(CAppletManager::TranslateString(L"IRC-Chatroom support is disabled!\nYou need to install the patched IRC.dll (see the readme) to use IRC-Chatrooms on the LCD"),&tm_now,true);
+ AddIncomingMessage(CAppletManager::TranslateString(L"IRC-Chatroom support is disabled!\nYou need to install the patched IRC.dll (see the readme) to use IRC-Chatrooms on the LCD"), &tm_now, true);
}
- else
- {
+ else {
CIRCHistory *pHistory = CAppletManager::GetInstance()->GetIRCHistory(m_hContact);
- if(pHistory)
- {
+ if (pHistory) {
list<SIRCMessage>::iterator iter = pHistory->LMessages.begin();
- while(iter != pHistory->LMessages.end())
- {
- if((*iter).bIsMe)
- AddOutgoingMessage((*iter).strMessage,&((*iter).Time),true);
+ while (iter != pHistory->LMessages.end()) {
+ if ((*iter).bIsMe)
+ AddOutgoingMessage((*iter).strMessage, &((*iter).Time), true);
else
- AddIncomingMessage((*iter).strMessage,&((*iter).Time),true);
+ AddIncomingMessage((*iter).strMessage, &((*iter).Time), true);
iter++;
}
}
}
}
- else
- {
+ else {
// Get last events from database
CEvent Event;
list<MEVENT> LHandles;
MEVENT hEvent = db_event_last(m_hContact);
MEVENT hUnread = db_event_firstUnread(m_hContact);
-
- if(CConfig::GetBoolSetting(SESSION_LOADDB))
- {
- while(hEvent != NULL && hUnread != NULL)
- {
+
+ if (CConfig::GetBoolSetting(SESSION_LOADDB)) {
+ while (hEvent != NULL && hUnread != NULL) {
LHandles.push_front(hEvent);
- if(CConfig::GetBoolSetting(SESSION_LOADDB) && *(LHandles.begin()) == hUnread)
+ if (CConfig::GetBoolSetting(SESSION_LOADDB) && *(LHandles.begin()) == hUnread)
break;
hEvent = db_event_prev(m_hContact, hEvent);
}
}
- else
- {
- for (int i = CConfig::GetIntSetting(SESSION_LOGSIZE); i > 0 && hEvent!=NULL; i--)
- {
+ else {
+ for (int i = CConfig::GetIntSetting(SESSION_LOGSIZE); i > 0 && hEvent != NULL; i--) {
LHandles.push_front(hEvent);
hEvent = db_event_prev(m_hContact, hEvent);
}
}
bool bRead = true;
- while(!(LHandles.empty()))
- {
- if(CAppletManager::TranslateDBEvent(&Event,(LPARAM)m_hContact,(WPARAM)*(LHandles.begin())))
- {
- if(Event.hValue == hUnread)
+ while (!(LHandles.empty())) {
+ if (CAppletManager::TranslateDBEvent(&Event, (LPARAM)m_hContact, (WPARAM)*(LHandles.begin()))) {
+ if (Event.hValue == hUnread)
bRead = false;
- if(Event.eType == EVENT_MSG_RECEIVED)
- {
- AddIncomingMessage(Event.strValue,&Event.Time);
- if(!bRead && CConfig::GetBoolSetting(SESSION_MARKREAD) && !CAppletManager::IsMessageWindowOpen(m_hContact))
- CAppletManager::MarkMessageAsRead(m_hContact,Event.hValue);
+ if (Event.eType == EVENT_MSG_RECEIVED) {
+ AddIncomingMessage(Event.strValue, &Event.Time);
+ if (!bRead && CConfig::GetBoolSetting(SESSION_MARKREAD) && !CAppletManager::IsMessageWindowOpen(m_hContact))
+ CAppletManager::MarkMessageAsRead(m_hContact, Event.hValue);
}
else
- AddOutgoingMessage(Event.strValue,&Event.Time);
+ AddOutgoingMessage(Event.strValue, &Event.Time);
- }
+ }
LHandles.pop_front();
}
}
@@ -340,16 +320,16 @@ void CChatScreen::LoadHistory()
//************************************************************************
bool CChatScreen::Update()
{
- if(!CScreen::Update())
+ if (!CScreen::Update())
return false;
-
- if(CConfig::GetBoolSetting(SESSION_CLOSE)) {
- if(!CAppletManager::GetInstance()->GetLCDConnection()->IsForeground()) {
- if(!m_bCloseTimer && CConfig::GetIntSetting(SESSION_CLOSETIMER) != 0) {
+
+ if (CConfig::GetBoolSetting(SESSION_CLOSE)) {
+ if (!CAppletManager::GetInstance()->GetLCDConnection()->IsForeground()) {
+ if (!m_bCloseTimer && CConfig::GetIntSetting(SESSION_CLOSETIMER) != 0) {
m_bCloseTimer = true;
m_dwCloseTimer = GetTickCount();
}
- else if(CConfig::GetIntSetting(SESSION_CLOSETIMER) == 0 || GetTickCount() - m_dwCloseTimer >= CConfig::GetIntSetting(SESSION_CLOSETIMER)) {
+ else if (CConfig::GetIntSetting(SESSION_CLOSETIMER) == 0 || GetTickCount() - m_dwCloseTimer >= CConfig::GetIntSetting(SESSION_CLOSETIMER)) {
m_bCloseTimer = false;
CAppletManager::GetInstance()->ActivateEventScreen();
return true;
@@ -357,36 +337,30 @@ bool CChatScreen::Update()
}
}
- if(m_bMaximizedTimer && m_dwMaximizedDuration != INFINITE)
- {
- if(m_dwMaximizedTimer + m_dwMaximizedDuration <= GetTickCount())
+ if (m_bMaximizedTimer && m_dwMaximizedDuration != INFINITE) {
+ if (m_dwMaximizedTimer + m_dwMaximizedDuration <= GetTickCount())
Minimize();
}
- if(m_eReplyState == REPLY_STATE_INPUT && !m_Input.IsInputActive())
+ if (m_eReplyState == REPLY_STATE_INPUT && !m_Input.IsInputActive())
SendCurrentMessage();
-
+
// Handle Typing notifications
- if(IsInputActive())
- {
- if(m_Input.GetLastInputTime() + 10000 <= GetTickCount())
- {
- if(m_bTyping)
- {
+ if (IsInputActive()) {
+ if (m_Input.GetLastInputTime() + 10000 <= GetTickCount()) {
+ if (m_bTyping) {
m_bTyping = false;
- CAppletManager::GetInstance()->SendTypingNotification(m_hContact,0);
+ CAppletManager::GetInstance()->SendTypingNotification(m_hContact, 0);
}
}
- else if(CConfig::GetBoolSetting(SESSION_SENDTYPING) && !m_bTyping)
- {
+ else if (CConfig::GetBoolSetting(SESSION_SENDTYPING) && !m_bTyping) {
m_bTyping = true;
- CAppletManager::GetInstance()->SendTypingNotification(m_hContact,1);
+ CAppletManager::GetInstance()->SendTypingNotification(m_hContact, 1);
}
}
- else if(m_bTyping)
- {
+ else if (m_bTyping) {
m_bTyping = false;
- CAppletManager::GetInstance()->SendTypingNotification(m_hContact,0);
+ CAppletManager::GetInstance()->SendTypingNotification(m_hContact, 0);
}
return true;
@@ -397,15 +371,14 @@ bool CChatScreen::Update()
//************************************************************************
bool CChatScreen::Draw(CLCDGfx *pGfx)
{
- if(!CScreen::Draw(pGfx))
+ if (!CScreen::Draw(pGfx))
return false;
- if(!m_bHideTitle)
- {
- int iTitleHeight = CConfig::GetFontHeight(FONT_TITLE)+1;
- pGfx->DrawLine(0,iTitleHeight<6?6:iTitleHeight,GetWidth(),iTitleHeight<6?6:iTitleHeight);
- int iOffset = (iTitleHeight-5)/2;
- pGfx->DrawBitmap(1,iOffset,5,5,CAppletManager::GetInstance()->GetStatusBitmap(m_iStatus));
+ if (!m_bHideTitle) {
+ int iTitleHeight = CConfig::GetFontHeight(FONT_TITLE) + 1;
+ pGfx->DrawLine(0, iTitleHeight < 6 ? 6 : iTitleHeight, GetWidth(), iTitleHeight < 6 ? 6 : iTitleHeight);
+ int iOffset = (iTitleHeight - 5) / 2;
+ pGfx->DrawBitmap(1, iOffset, 5, 5, CAppletManager::GetInstance()->GetStatusBitmap(m_iStatus));
}
return true;
@@ -414,34 +387,33 @@ bool CChatScreen::Draw(CLCDGfx *pGfx)
//************************************************************************
// Adds an outgoing message to the log
//************************************************************************
-void CChatScreen::AddOutgoingMessage(tstring strMessage,tm *time,bool bIRC)
+void CChatScreen::AddOutgoingMessage(tstring strMessage, tm *time, bool bIRC)
{
- tstring strPrefix = bIRC?L"":L">> ";
- if(CConfig::GetBoolSetting(SESSION_TIMESTAMPS))
+ tstring strPrefix = bIRC ? L"" : L">> ";
+ if (CConfig::GetBoolSetting(SESSION_TIMESTAMPS))
strPrefix += CAppletManager::GetFormattedTimestamp(time) + L" ";
// adjust the scroll mode
m_TextLog.SetAutoscrollMode(SCROLL_LINE);
// add the message
- m_TextLog.AddText(strPrefix + strMessage,true);
+ m_TextLog.AddText(strPrefix + strMessage, true);
}
//************************************************************************
// Adds an incoming message to the log
//************************************************************************
-void CChatScreen::AddIncomingMessage(tstring strMessage,tm *time,bool bIRC)
+void CChatScreen::AddIncomingMessage(tstring strMessage, tm *time, bool bIRC)
{
- tstring strPrefix = bIRC?L"":L"<< ";
- if(CConfig::GetBoolSetting(SESSION_TIMESTAMPS))
+ tstring strPrefix = bIRC ? L"" : L"<< ";
+ if (CConfig::GetBoolSetting(SESSION_TIMESTAMPS))
strPrefix += CAppletManager::GetFormattedTimestamp(time) + L" ";
-
+
// adjust the scroll mode
EScrollMode eMode;
- switch(CConfig::GetIntSetting(SESSION_AUTOSCROLL))
- {
+ switch (CConfig::GetIntSetting(SESSION_AUTOSCROLL)) {
case SESSION_AUTOSCROLL_FIRST: eMode = SCROLL_MESSAGE; break;
case SESSION_AUTOSCROLL_LAST: eMode = SCROLL_LINE; break;
default: eMode = SCROLL_NONE;
@@ -462,7 +434,7 @@ void CChatScreen::ActivateMessageMode()
m_TextLog.SetScrollbar(nullptr);
m_Input.SetScrollbar(&m_Scrollbar);
- if(m_eReplyState != REPLY_STATE_FAILED)
+ if (m_eReplyState != REPLY_STATE_FAILED)
m_Input.Reset();
m_Input.Show(1);
@@ -470,10 +442,10 @@ void CChatScreen::ActivateMessageMode()
m_eReplyState = REPLY_STATE_INPUT;
- SetButtonBitmap(2,IDB_BACK);
- SetButtonBitmap(3,IDB_SEND);
+ SetButtonBitmap(2, IDB_BACK);
+ SetButtonBitmap(3, IDB_SEND);
- if(CConfig::GetBoolSetting(SESSION_REPLY_MAXIMIZED))
+ if (CConfig::GetBoolSetting(SESSION_REPLY_MAXIMIZED))
Maximize();
else
Minimize();
@@ -484,8 +456,7 @@ void CChatScreen::ActivateMessageMode()
//************************************************************************
void CChatScreen::SendCurrentMessage()
{
- if(m_Input.GetText().empty())
- {
+ if (m_Input.GetText().empty()) {
DeactivateMessageMode();
return;
}
@@ -498,15 +469,14 @@ void CChatScreen::SendCurrentMessage()
m_InfoText.SetText(CAppletManager::TranslateString(L"Sending message..."));
m_InfoText.Show(1);
m_Input.Show(0);
-
- m_hMessage = CAppletManager::SendMessageToContact(m_hContact,m_Input.GetText());
- if(m_hMessage == NULL)
- {
+
+ m_hMessage = CAppletManager::SendMessageToContact(m_hContact, m_Input.GetText());
+ if (m_hMessage == NULL) {
DeactivateMessageMode();
return;
}
- SetButtonBitmap(2,NULL);
- SetButtonBitmap(3,NULL);
+ SetButtonBitmap(2, NULL);
+ SetButtonBitmap(3, NULL);
}
//************************************************************************
@@ -518,10 +488,10 @@ void CChatScreen::InvalidateMessageMode(tstring strError)
m_InfoText.SetText(strError);
- SetButtonBitmap(2,IDB_BACK);
- SetButtonBitmap(3,IDB_SEND);
+ SetButtonBitmap(2, IDB_BACK);
+ SetButtonBitmap(3, IDB_SEND);
- if(IsMaximized())
+ if (IsMaximized())
Minimize();
}
@@ -538,15 +508,15 @@ void CChatScreen::DeactivateMessageMode()
m_TextLog.Show(1);
m_InfoText.Show(0);
m_Input.Show(0);
-
+
m_Input.DeactivateInput();
m_eReplyState = REPLY_STATE_NONE;
-
- SetButtonBitmap(2,IDB_HISTORY);
- SetButtonBitmap(3,IDB_REPLY);
- if(IsMaximized())
+ SetButtonBitmap(2, IDB_HISTORY);
+ SetButtonBitmap(3, IDB_REPLY);
+
+ if (IsMaximized())
Minimize();
}
@@ -607,47 +577,45 @@ void CChatScreen::OnConfigChanged()
void CChatScreen::OnEventReceived(CEvent *pEvent)
{
// only let events for this contact pass
- if(pEvent->hContact != m_hContact &&
+ if (pEvent->hContact != m_hContact &&
// expect for IRC events without a contact -> global notifications
!((pEvent->eType == EVENT_IRC_SENT || pEvent->eType == EVENT_IRC_RECEIVED) && pEvent->hContact == NULL))
return;
-
- switch(pEvent->eType)
- {
+
+ switch (pEvent->eType) {
case EVENT_MESSAGE_ACK:
- if(pEvent->hValue != m_hMessage)
+ if (pEvent->hValue != m_hMessage)
return;
- if(pEvent->iValue == ACKRESULT_SUCCESS)
+ if (pEvent->iValue == ACKRESULT_SUCCESS)
DeactivateMessageMode();
else
- InvalidateMessageMode(pEvent->strValue.empty()?CAppletManager::TranslateString(L"Could not send the message!"):pEvent->strValue);
+ InvalidateMessageMode(pEvent->strValue.empty() ? CAppletManager::TranslateString(L"Could not send the message!") : pEvent->strValue);
break;
case EVENT_IRC_SENT:
// Add the message to the log
- AddOutgoingMessage(pEvent->strValue,&pEvent->Time,true);
+ AddOutgoingMessage(pEvent->strValue, &pEvent->Time, true);
break;
case EVENT_IRC_RECEIVED:
// Add the message to the log
- AddIncomingMessage(pEvent->strValue,&pEvent->Time,true);
+ AddIncomingMessage(pEvent->strValue, &pEvent->Time, true);
break;
case EVENT_MSG_RECEIVED:
// mark it as read if required
- if(CConfig::GetBoolSetting(SESSION_MARKREAD) && !CAppletManager::IsMessageWindowOpen(m_hContact))
- CAppletManager::MarkMessageAsRead(m_hContact,pEvent->hValue);
+ if (CConfig::GetBoolSetting(SESSION_MARKREAD) && !CAppletManager::IsMessageWindowOpen(m_hContact))
+ CAppletManager::MarkMessageAsRead(m_hContact, pEvent->hValue);
// Add the message to the log
- AddIncomingMessage(pEvent->strValue,&pEvent->Time);
+ AddIncomingMessage(pEvent->strValue, &pEvent->Time);
break;
case EVENT_MSG_SENT:
// Add the message to the log
- AddOutgoingMessage(pEvent->strValue,&pEvent->Time);
+ AddOutgoingMessage(pEvent->strValue, &pEvent->Time);
break;
case EVENT_CONTACT_HIDDEN:
// contact is set to hidden
- if(pEvent->iValue == 1)
- {
+ if (pEvent->iValue == 1) {
// Close the chat screen if the contact is an irc chatroom
- if(!(m_bIRCProtocol && db_get_b(pEvent->hContact, toNarrowString(m_strProto).c_str(), "ChatRoom", 0) != 0))
+ if (!(m_bIRCProtocol && db_get_b(pEvent->hContact, toNarrowString(m_strProto).c_str(), "ChatRoom", 0) != 0))
break;
}
else
@@ -673,59 +641,60 @@ void CChatScreen::OnEventReceived(CEvent *pEvent)
//************************************************************************
void CChatScreen::OnLCDButtonDown(int iButton)
{
- switch(m_eReplyState)
- {
+ switch (m_eReplyState) {
case REPLY_STATE_NONE:
- if(iButton == LGLCDBUTTON_CANCEL) {
+ if (iButton == LGLCDBUTTON_CANCEL) {
CAppletManager::GetInstance()->ActivatePreviousScreen();
- } else if(iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_MENU)
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_MENU)
CAppletManager::GetInstance()->ActivateEventScreen();
// enter reply mode
- else if(iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK)
+ else if (iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK)
ActivateMessageMode();
else {
bool bRes = false;
- if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
+ if (iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
bRes = m_TextLog.ScrollUp();
- } else if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
bRes = m_TextLog.ScrollDown();
}
- if(bRes && CConfig::GetBoolSetting(SESSION_SCROLL_MAXIMIZED)) {
+ if (bRes && CConfig::GetBoolSetting(SESSION_SCROLL_MAXIMIZED)) {
Maximize(5000);
}
}
break;
+
case REPLY_STATE_FAILED:
- if(iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_CANCEL) {
+ if (iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_CANCEL) {
DeactivateMessageMode();
- } else if(iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
- ActivateMessageMode();
}
-/*
- // Dead code
- else if(iButton == LGLCDBUTTON_CANCEL) {
- DeactivateMessageMode();
- CAppletManager::GetInstance()->ActivatePreviousScreen();
+ else if (iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
+ ActivateMessageMode();
}
-*/
- else if(iButton == LGLCDBUTTON_MENU) {
+ else if (iButton == LGLCDBUTTON_MENU) {
DeactivateMessageMode();
CAppletManager::GetInstance()->ActivateEventScreen();
}
break;
+
case REPLY_STATE_SENDING:
break;
+
case REPLY_STATE_INPUT:
- if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
+ if (iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
m_Input.ScrollLine(0);
- } else if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
m_Input.ScrollLine(1);
- // send the message
- } else if(iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
+ // send the message
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON3 || iButton == LGLCDBUTTON_OK) {
SendCurrentMessage();
- // cancel message mode
- } else if(iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_CANCEL) {
+ // cancel message mode
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON2 || iButton == LGLCDBUTTON_CANCEL) {
DeactivateMessageMode();
}
break;
@@ -737,24 +706,23 @@ void CChatScreen::OnLCDButtonDown(int iButton)
//************************************************************************
void CChatScreen::OnLCDButtonRepeated(int iButton)
{
- switch(m_eReplyState)
- {
+ switch (m_eReplyState) {
case REPLY_STATE_NONE:
- if(iButton < 2)
- {
+ if (iButton < 2) {
bool bRes = false;
- if(iButton == LGLCDBUTTON_BUTTON0) {
+ if (iButton == LGLCDBUTTON_BUTTON0) {
bRes = m_TextLog.ScrollUp();
}
- if(bRes && CConfig::GetBoolSetting(SESSION_SCROLL_MAXIMIZED))
+ if (bRes && CConfig::GetBoolSetting(SESSION_SCROLL_MAXIMIZED))
Maximize(5000);
}
break;
case REPLY_STATE_INPUT:
- if(iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
+ if (iButton == LGLCDBUTTON_BUTTON0 || iButton == LGLCDBUTTON_UP) {
m_Input.ScrollLine(0);
- } else if(iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
+ }
+ else if (iButton == LGLCDBUTTON_BUTTON1 || iButton == LGLCDBUTTON_DOWN) {
m_Input.ScrollLine(1);
}
}
@@ -765,7 +733,6 @@ void CChatScreen::OnLCDButtonRepeated(int iButton)
//************************************************************************
void CChatScreen::OnLCDButtonUp(int)
{
-
}
//************************************************************************
@@ -781,11 +748,11 @@ void CChatScreen::OnActivation()
//************************************************************************
void CChatScreen::OnDeactivation()
{
-}
+}
//************************************************************************
// Called when the screen has expired
//************************************************************************
void CChatScreen::OnExpiration()
{
-} \ No newline at end of file
+}