diff options
Diffstat (limited to 'protocols/JabberG/src/jabber_presence_manager.h')
-rw-r--r-- | protocols/JabberG/src/jabber_presence_manager.h | 64 |
1 files changed, 22 insertions, 42 deletions
diff --git a/protocols/JabberG/src/jabber_presence_manager.h b/protocols/JabberG/src/jabber_presence_manager.h index 81ab98b7ab..97e9077c8a 100644 --- a/protocols/JabberG/src/jabber_presence_manager.h +++ b/protocols/JabberG/src/jabber_presence_manager.h @@ -98,16 +98,13 @@ public: }
~CJabberPresenceManager()
{
- Lock();
CJabberPresencePermanentInfo *pInfo = m_pPermanentHandlers;
- while (pInfo)
- {
+ while (pInfo) {
CJabberPresencePermanentInfo *pTmp = pInfo->m_pNext;
delete pInfo;
pInfo = pTmp;
}
m_pPermanentHandlers = NULL;
- Unlock();
DeleteCriticalSection(&m_cs);
}
BOOL Start()
@@ -118,18 +115,10 @@ public: {
return TRUE;
}
- void Lock()
- {
- EnterCriticalSection(&m_cs);
- }
- void Unlock()
- {
- LeaveCriticalSection(&m_cs);
- }
CJabberPresencePermanentInfo* AddPermanentHandler(JABBER_PRESENCE_HANDLER pHandler, void *pUserData = NULL, PRESENCE_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT)
{
CJabberPresencePermanentInfo* pInfo = new CJabberPresencePermanentInfo();
- if ( !pInfo)
+ if (!pInfo)
return NULL;
pInfo->m_pHandler = pHandler;
@@ -137,16 +126,15 @@ public: pInfo->m_pUserDataFree = pUserDataFree;
pInfo->m_iPriority = iPriority;
- Lock();
- if ( !m_pPermanentHandlers)
+ mir_cslock lck(m_cs);
+ if (!m_pPermanentHandlers)
m_pPermanentHandlers = pInfo;
- else
- {
+ else {
if (m_pPermanentHandlers->m_iPriority > pInfo->m_iPriority) {
pInfo->m_pNext = m_pPermanentHandlers;
m_pPermanentHandlers = pInfo;
- } else
- {
+ }
+ else {
CJabberPresencePermanentInfo* pTmp = m_pPermanentHandlers;
while (pTmp->m_pNext && pTmp->m_pNext->m_iPriority <= pInfo->m_iPriority)
pTmp = pTmp->m_pNext;
@@ -154,42 +142,34 @@ public: pTmp->m_pNext = pInfo;
}
}
- Unlock();
return pInfo;
}
BOOL DeletePermanentHandler(CJabberPresencePermanentInfo *pInfo)
{ // returns TRUE when pInfo found, or FALSE otherwise
- Lock();
- if ( !m_pPermanentHandlers)
- {
- Unlock();
+ mir_cslock lck(m_cs);
+ if (!m_pPermanentHandlers)
return FALSE;
- }
- if (m_pPermanentHandlers == pInfo) // check first item
- {
+
+ if (m_pPermanentHandlers == pInfo) { // check first item
m_pPermanentHandlers = m_pPermanentHandlers->m_pNext;
delete pInfo;
- Unlock();
return TRUE;
- } else
- {
- CJabberPresencePermanentInfo* pTmp = m_pPermanentHandlers;
- while (pTmp->m_pNext)
- {
- if (pTmp->m_pNext == pInfo)
- {
- pTmp->m_pNext = pTmp->m_pNext->m_pNext;
- delete pInfo;
- Unlock();
- return TRUE;
- }
- pTmp = pTmp->m_pNext;
+ }
+
+ CJabberPresencePermanentInfo *pTmp = m_pPermanentHandlers;
+ while (pTmp->m_pNext) {
+ if (pTmp->m_pNext == pInfo) {
+ pTmp->m_pNext = pTmp->m_pNext->m_pNext;
+ delete pInfo;
+ return TRUE;
}
+ pTmp = pTmp->m_pNext;
}
- Unlock();
+
return FALSE;
}
+
BOOL HandlePresencePermanent(HXML node, ThreadData *pThreadData);
BOOL FillPermanentHandlers();
};
|