diff options
author | George Hazan <george.hazan@gmail.com> | 2014-09-06 12:19:24 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-09-06 12:19:24 +0000 |
commit | eb61560d6fa9ab5e7bf895805dcedfd7870f482d (patch) | |
tree | 60fd612a969d560fe7e9613bd45f2b8ce56f02eb /protocols/JabberG/src/jabber_presence_manager.cpp | |
parent | e157bfe1e82eb3c6086fdd92d6c7604347d18d3f (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.cpp')
-rw-r--r-- | protocols/JabberG/src/jabber_presence_manager.cpp | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/protocols/JabberG/src/jabber_presence_manager.cpp b/protocols/JabberG/src/jabber_presence_manager.cpp index 680f852532..31cd8d5e26 100644 --- a/protocols/JabberG/src/jabber_presence_manager.cpp +++ b/protocols/JabberG/src/jabber_presence_manager.cpp @@ -25,20 +25,53 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "jabber.h"
-#include "jabber_presence_manager.h"
-BOOL CJabberPresenceManager::FillPermanentHandlers()
+static int CompareItems(const CJabberPresencePermanentInfo *p1, const CJabberPresencePermanentInfo *p2)
{
- return TRUE;
+ return p1->getPriority() - p2->getPriority();
}
-BOOL CJabberPresenceManager::HandlePresencePermanent(HXML node, ThreadData *pThreadData)
+CJabberPresenceManager::CJabberPresenceManager(CJabberProto *proto) :
+ m_arHandlers(1, &CompareItems)
{
+ ppro = proto;
+}
+
+CJabberPresenceManager::~CJabberPresenceManager()
+{
+}
+
+CJabberPresencePermanentInfo* CJabberPresenceManager::AddPermanentHandler(
+ JABBER_PRESENCE_HANDLER pHandler,
+ void *pUserData,
+ PRESENCE_USER_DATA_FREE_FUNC pUserDataFree,
+ int iPriority)
+{
+ CJabberPresencePermanentInfo* pInfo = new CJabberPresencePermanentInfo();
+ pInfo->m_pHandler = pHandler;
+ pInfo->m_pUserData = pUserData;
+ pInfo->m_pUserDataFree = pUserDataFree;
+ pInfo->m_iPriority = iPriority;
+
mir_cslock lck(m_cs);
- for (CJabberPresencePermanentInfo *pInfo = m_pPermanentHandlers; pInfo; pInfo = pInfo->m_pNext) {
+ m_arHandlers.insert(pInfo);
+ return pInfo;
+}
+
+bool CJabberPresenceManager::DeletePermanentHandler(CJabberPresencePermanentInfo *pInfo)
+{
+ mir_cslock lck(m_cs);
+ return m_arHandlers.remove(pInfo) == 1;
+}
+
+bool CJabberPresenceManager::HandlePresencePermanent(HXML node, ThreadData *pThreadData)
+{
+ for (int i = 0; i < m_arHandlers.getCount(); i++) {
+ CJabberPresencePermanentInfo &pInfo = m_arHandlers[i];
+
CJabberPresenceInfo presenceInfo;
- presenceInfo.m_pUserData = pInfo->m_pUserData;
- if ((ppro->*(pInfo->m_pHandler))(node, pThreadData, &presenceInfo))
+ presenceInfo.m_pUserData = pInfo.m_pUserData;
+ if ((ppro->*(pInfo.m_pHandler))(node, pThreadData, &presenceInfo))
return true;
}
|