summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_presence_manager.h
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-09-06 12:19:24 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-09-06 12:19:24 +0000
commiteb61560d6fa9ab5e7bf895805dcedfd7870f482d (patch)
tree60fd612a969d560fe7e9613bd45f2b8ce56f02eb /protocols/JabberG/src/jabber_presence_manager.h
parente157bfe1e82eb3c6086fdd92d6c7604347d18d3f (diff)
Jabber: manual lists partially removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@10382 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_presence_manager.h')
-rw-r--r--protocols/JabberG/src/jabber_presence_manager.h93
1 files changed, 11 insertions, 82 deletions
diff --git a/protocols/JabberG/src/jabber_presence_manager.h b/protocols/JabberG/src/jabber_presence_manager.h
index ff753dfdf6..9b33288192 100644
--- a/protocols/JabberG/src/jabber_presence_manager.h
+++ b/protocols/JabberG/src/jabber_presence_manager.h
@@ -64,22 +64,24 @@ class CJabberPresencePermanentInfo
{
friend class CJabberPresenceManager;
- CJabberPresencePermanentInfo* m_pNext;
-
JABBER_PRESENCE_HANDLER m_pHandler;
void *m_pUserData;
PRESENCE_USER_DATA_FREE_FUNC m_pUserDataFree;
int m_iPriority;
+
public:
CJabberPresencePermanentInfo()
{
ZeroMemory(this, sizeof(CJabberPresencePermanentInfo));
}
+
~CJabberPresencePermanentInfo()
{
if (m_pUserDataFree)
m_pUserDataFree(m_pUserData);
}
+
+ __forceinline int getPriority() const { return m_iPriority; }
};
class CJabberPresenceManager
@@ -87,89 +89,16 @@ class CJabberPresenceManager
protected:
CJabberProto *ppro;
mir_cs m_cs;
- CJabberPresencePermanentInfo* m_pPermanentHandlers;
+ OBJLIST<CJabberPresencePermanentInfo> m_arHandlers;
public:
- CJabberPresenceManager(CJabberProto* proto)
- {
- m_pPermanentHandlers = NULL;
- ppro = proto;
- }
- ~CJabberPresenceManager()
- {
- CJabberPresencePermanentInfo *pInfo = m_pPermanentHandlers;
- while (pInfo) {
- CJabberPresencePermanentInfo *pTmp = pInfo->m_pNext;
- delete pInfo;
- pInfo = pTmp;
- }
- m_pPermanentHandlers = NULL;
- }
- BOOL Start()
- {
- return TRUE;
- }
- BOOL Shutdown()
- {
- return TRUE;
- }
- 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)
- return NULL;
-
- pInfo->m_pHandler = pHandler;
- pInfo->m_pUserData = pUserData;
- pInfo->m_pUserDataFree = pUserDataFree;
- pInfo->m_iPriority = iPriority;
-
- mir_cslock lck(m_cs);
- if (!m_pPermanentHandlers)
- m_pPermanentHandlers = pInfo;
- else {
- if (m_pPermanentHandlers->m_iPriority > pInfo->m_iPriority) {
- pInfo->m_pNext = m_pPermanentHandlers;
- m_pPermanentHandlers = pInfo;
- }
- else {
- CJabberPresencePermanentInfo* pTmp = m_pPermanentHandlers;
- while (pTmp->m_pNext && pTmp->m_pNext->m_iPriority <= pInfo->m_iPriority)
- pTmp = pTmp->m_pNext;
- pInfo->m_pNext = pTmp->m_pNext;
- pTmp->m_pNext = pInfo;
- }
- }
-
- return pInfo;
- }
- BOOL DeletePermanentHandler(CJabberPresencePermanentInfo *pInfo)
- { // returns TRUE when pInfo found, or FALSE otherwise
- mir_cslock lck(m_cs);
- if (!m_pPermanentHandlers)
- return FALSE;
-
- if (m_pPermanentHandlers == pInfo) { // check first item
- m_pPermanentHandlers = m_pPermanentHandlers->m_pNext;
- delete pInfo;
- return TRUE;
- }
-
- 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;
- }
-
- return FALSE;
- }
+ CJabberPresenceManager(CJabberProto*);
+ ~CJabberPresenceManager();
+
+ CJabberPresencePermanentInfo* AddPermanentHandler(JABBER_PRESENCE_HANDLER pHandler, void *pUserData = NULL, PRESENCE_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT);
+ bool DeletePermanentHandler(CJabberPresencePermanentInfo *pInfo);
- BOOL HandlePresencePermanent(HXML node, ThreadData *pThreadData);
- BOOL FillPermanentHandlers();
+ bool HandlePresencePermanent(HXML node, ThreadData *pThreadData);
};
#endif