diff options
author | George Hazan <george.hazan@gmail.com> | 2012-10-01 11:21:13 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-10-01 11:21:13 +0000 |
commit | 0f84c762b6cfcc5571d4c9b9c97726fc6cb4ad2c (patch) | |
tree | 0a775bae27d67e51402a7873a398484f263698d9 /protocols | |
parent | 47697127cec34eac8e141f62ccf1f6c173592bec (diff) |
SetStatus code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@1739 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rwxr-xr-x | protocols/IcqOscarJ/icq_proto.cpp | 184 | ||||
-rw-r--r-- | protocols/MRA/MraProto.cpp | 2 |
2 files changed, 93 insertions, 93 deletions
diff --git a/protocols/IcqOscarJ/icq_proto.cpp b/protocols/IcqOscarJ/icq_proto.cpp index 90a56838bb..d1490fac2e 100755 --- a/protocols/IcqOscarJ/icq_proto.cpp +++ b/protocols/IcqOscarJ/icq_proto.cpp @@ -1962,124 +1962,124 @@ int __cdecl CIcqProto::SetStatus(int iNewStatus) if (m_bTempVisListEnabled && icqOnline()) // remove temporary visible users
sendEntireListServ(ICQ_BOS_FAMILY, ICQ_CLI_REMOVETEMPVISIBLE, BUL_TEMPVISIBLE);
- if (nNewStatus != m_iStatus)
- {
- // clear custom status on status change
- if (getSettingByte(NULL, "XStatusReset", DEFAULT_XSTATUS_RESET))
- setXStatusEx(0, 0);
+ if (nNewStatus == m_iStatus)
+ return 0;
- // New status is OFFLINE
- if (nNewStatus == ID_STATUS_OFFLINE)
- { // for quick logoff
- if (icqOnline())
- { // set offline status note (otherwise the old will remain)
- char *szOfflineNote = PrepareStatusNote(nNewStatus);
+ // clear custom status on status change
+ if (getSettingByte(NULL, "XStatusReset", DEFAULT_XSTATUS_RESET))
+ setXStatusEx(0, 0);
- // Create unnamed event to wait until the status note change process is completed
- m_hNotifyNameInfoEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ // New status is OFFLINE
+ if (nNewStatus == ID_STATUS_OFFLINE)
+ { // for quick logoff
+ if (icqOnline())
+ { // set offline status note (otherwise the old will remain)
+ char *szOfflineNote = PrepareStatusNote(nNewStatus);
- int bNoteChanged = SetStatusNote(szOfflineNote, 0, FALSE);
+ // Create unnamed event to wait until the status note change process is completed
+ m_hNotifyNameInfoEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- SAFE_FREE(&szOfflineNote);
+ int bNoteChanged = SetStatusNote(szOfflineNote, 0, FALSE);
- // Note was changed, wait until the process is over
- if (bNoteChanged)
- ICQWaitForSingleObject(m_hNotifyNameInfoEvent, 4000, TRUE);
+ SAFE_FREE(&szOfflineNote);
- // Release the event
- CloseHandle(m_hNotifyNameInfoEvent);
- m_hNotifyNameInfoEvent = NULL;
- }
+ // Note was changed, wait until the process is over
+ if (bNoteChanged)
+ ICQWaitForSingleObject(m_hNotifyNameInfoEvent, 4000, TRUE);
- m_iDesiredStatus = nNewStatus;
+ // Release the event
+ CloseHandle(m_hNotifyNameInfoEvent);
+ m_hNotifyNameInfoEvent = NULL;
+ }
- if (hServerConn)
- { // Connected, Send disconnect packet
- icq_sendCloseConnection();
+ m_iDesiredStatus = nNewStatus;
- icq_serverDisconnect(FALSE);
+ if (hServerConn)
+ { // Connected, Send disconnect packet
+ icq_sendCloseConnection();
- SetCurrentStatus(ID_STATUS_OFFLINE);
+ icq_serverDisconnect(FALSE);
- NetLog_Server("Logged off.");
- }
- }
- else
- {
- switch (m_iStatus) {
+ SetCurrentStatus(ID_STATUS_OFFLINE);
- // We are offline and need to connect
- case ID_STATUS_OFFLINE:
- {
- // Update user connection settings
- UpdateGlobalSettings();
+ NetLog_Server("Logged off.");
+ }
+ }
+ else
+ {
+ switch (m_iStatus) {
- // Read UIN from database
- m_dwLocalUIN = getContactUin(NULL);
- if (m_dwLocalUIN == 0)
- {
- SetCurrentStatus(ID_STATUS_OFFLINE);
- BroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID);
- icq_LogMessage(LOG_FATAL, LPGEN("You have not entered a ICQ number.\nConfigure this in Options->Network->ICQ and try again."));
- return 0;
- }
+ // We are offline and need to connect
+ case ID_STATUS_OFFLINE:
+ {
+ // Update user connection settings
+ UpdateGlobalSettings();
- // Set status to 'Connecting'
- m_iDesiredStatus = nNewStatus;
- SetCurrentStatus(ID_STATUS_CONNECTING);
+ // Read UIN from database
+ m_dwLocalUIN = getContactUin(NULL);
+ if (m_dwLocalUIN == 0)
+ {
+ SetCurrentStatus(ID_STATUS_OFFLINE);
+ BroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID);
+ icq_LogMessage(LOG_FATAL, LPGEN("You have not entered a ICQ number.\nConfigure this in Options->Network->ICQ and try again."));
+ return 0;
+ }
- // Read password from database
- char *pszPwd = GetUserPassword(FALSE);
+ // Set status to 'Connecting'
+ m_iDesiredStatus = nNewStatus;
+ SetCurrentStatus(ID_STATUS_CONNECTING);
- if (pszPwd)
- icq_login(pszPwd);
- else
- RequestPassword();
+ // Read password from database
+ char *pszPwd = GetUserPassword(FALSE);
- break;
- }
+ if (pszPwd)
+ icq_login(pszPwd);
+ else
+ RequestPassword();
- // We are connecting... We only need to change the going online status
- case ID_STATUS_CONNECTING:
- m_iDesiredStatus = nNewStatus;
break;
+ }
- // We are already connected so we should just change status
- default:
- SetCurrentStatus(nNewStatus);
+ // We are connecting... We only need to change the going online status
+ case ID_STATUS_CONNECTING:
+ m_iDesiredStatus = nNewStatus;
+ break;
- char *szStatusNote = PrepareStatusNote(nNewStatus);
+ // We are already connected so we should just change status
+ default:
+ SetCurrentStatus(nNewStatus);
- //! This is a bit tricky, we do trigger status note change thread and then
- // change the status note right away (this spares one packet) - so SetStatusNote()
- // will only change User Details Directory
- SetStatusNote(szStatusNote, 6000, FALSE);
+ char *szStatusNote = PrepareStatusNote(nNewStatus);
- if (m_iStatus == ID_STATUS_INVISIBLE)
- {
- if (m_bSsiEnabled)
- updateServVisibilityCode(3);
- icq_setstatus(MirandaStatusToIcq(m_iStatus), szStatusNote);
- }
- else
- {
- icq_setstatus(MirandaStatusToIcq(m_iStatus), szStatusNote);
- if (m_bSsiEnabled)
- updateServVisibilityCode(4);
- }
- SAFE_FREE(&szStatusNote);
+ //! This is a bit tricky, we do trigger status note change thread and then
+ // change the status note right away (this spares one packet) - so SetStatusNote()
+ // will only change User Details Directory
+ SetStatusNote(szStatusNote, 6000, FALSE);
- if (m_bAimEnabled)
- {
- icq_lock l(m_modeMsgsMutex);
+ if (m_iStatus == ID_STATUS_INVISIBLE)
+ {
+ if (m_bSsiEnabled)
+ updateServVisibilityCode(3);
+ icq_setstatus(MirandaStatusToIcq(m_iStatus), szStatusNote);
+ }
+ else
+ {
+ icq_setstatus(MirandaStatusToIcq(m_iStatus), szStatusNote);
+ if (m_bSsiEnabled)
+ updateServVisibilityCode(4);
+ }
+ SAFE_FREE(&szStatusNote);
- char ** pszStatusNote = MirandaStatusToAwayMsg(m_iStatus);
+ if (m_bAimEnabled)
+ {
+ icq_lock l(m_modeMsgsMutex);
- if (pszStatusNote)
- icq_sendSetAimAwayMsgServ(*pszStatusNote);
- else // clear the away message
- icq_sendSetAimAwayMsgServ(NULL);
- }
+ char ** pszStatusNote = MirandaStatusToAwayMsg(m_iStatus);
+
+ if (pszStatusNote)
+ icq_sendSetAimAwayMsgServ(*pszStatusNote);
+ else // clear the away message
+ icq_sendSetAimAwayMsgServ(NULL);
}
}
}
diff --git a/protocols/MRA/MraProto.cpp b/protocols/MRA/MraProto.cpp index fc82af9785..3a83c98af5 100644 --- a/protocols/MRA/MraProto.cpp +++ b/protocols/MRA/MraProto.cpp @@ -615,7 +615,7 @@ int CMraProto::SetStatus(int iNewStatus) }
// nothing to change
- if (InterlockedExchangeAdd((volatile LONG*)&m_iStatus, 0) == iNewStatus && iNewStatus != m_iDesiredStatus)
+ if (m_iStatus == iNewStatus)
return 0;
DWORD dwOldStatusMode;
|