diff options
author | George Hazan <george.hazan@gmail.com> | 2013-10-02 16:46:22 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-10-02 16:46:22 +0000 |
commit | 0e130d1a06db358ed90d0ad30d633c4fad839d6e (patch) | |
tree | 0b7052aafb152385823b5ec7d876e58e6e1f2708 /protocols/JabberG/src/jabber_message_manager.h | |
parent | 6069deebf16c166dec9432853ce32dfaa6cc4f98 (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@6309 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_message_manager.h')
-rw-r--r-- | protocols/JabberG/src/jabber_message_manager.h | 171 |
1 files changed, 27 insertions, 144 deletions
diff --git a/protocols/JabberG/src/jabber_message_manager.h b/protocols/JabberG/src/jabber_message_manager.h index 3af7fe9af3..ac655b547c 100644 --- a/protocols/JabberG/src/jabber_message_manager.h +++ b/protocols/JabberG/src/jabber_message_manager.h @@ -41,7 +41,7 @@ typedef BOOL (CJabberProto::*JABBER_PERMANENT_MESSAGE_HANDLER)(HXML messageNode, #define JABBER_MESSAGE_PARSE_TO (1<<5)
#define JABBER_MESSAGE_PARSE_ID_STR (1<<6)
-class CJabberMessageInfo
+class CJabberMessageInfo : public MZeroedObject
{
protected:
friend class CJabberMessageManager;
@@ -61,48 +61,33 @@ public: LPCTSTR m_szId;
public:
- CJabberMessageInfo()
- {
- ZeroMemory(this, sizeof(*this));
- }
- ~CJabberMessageInfo()
- {
- }
- int GetMessageType()
- {
- return m_nMessageType;
+ __forceinline int GetMessageType()
+ { return m_nMessageType;
}
- void* GetUserData()
- {
- return m_pUserData;
+ __forceinline void* GetUserData()
+ { return m_pUserData;
}
- LPCTSTR GetFrom()
- {
- return m_szFrom;
+ __forceinline LPCTSTR GetFrom()
+ { return m_szFrom;
}
- LPCTSTR GetTo()
- {
- return m_szTo;
+ __forceinline LPCTSTR GetTo()
+ { return m_szTo;
}
- LPCTSTR GetIdStr()
- {
- return m_szId;
+ __forceinline LPCTSTR GetIdStr()
+ { return m_szId;
}
- HANDLE GetHContact()
- {
- return m_hContact;
+ __forceinline HANDLE GetHContact()
+ { return m_hContact;
}
- HXML GetChildNode()
- {
- return m_hChildNode;
+ __forceinline HXML GetChildNode()
+ { return m_hChildNode;
}
- LPCTSTR GetChildNodeName()
- {
- return m_szChildTagName;
+ __forceinline LPCTSTR GetChildNodeName()
+ { return m_szChildTagName;
}
};
-class CJabberMessagePermanentInfo
+class CJabberMessagePermanentInfo : public MZeroedObject
{
friend class CJabberMessageManager;
@@ -117,11 +102,8 @@ class CJabberMessagePermanentInfo void *m_pUserData;
MESSAGE_USER_DATA_FREE_FUNC m_pUserDataFree;
int m_iPriority;
+
public:
- CJabberMessagePermanentInfo()
- {
- ZeroMemory(this, sizeof(CJabberMessagePermanentInfo));
- }
~CJabberMessagePermanentInfo()
{
if (m_pUserDataFree)
@@ -139,113 +121,14 @@ protected: CJabberMessagePermanentInfo* m_pPermanentHandlers;
public:
- CJabberMessageManager(CJabberProto* proto)
- {
- InitializeCriticalSection(&m_cs);
- m_pPermanentHandlers = NULL;
- ppro = proto;
- }
- ~CJabberMessageManager()
- {
- Lock();
- CJabberMessagePermanentInfo *pInfo = m_pPermanentHandlers;
- while (pInfo)
- {
- CJabberMessagePermanentInfo *pTmp = pInfo->m_pNext;
- delete pInfo;
- pInfo = pTmp;
- }
- m_pPermanentHandlers = NULL;
- Unlock();
- DeleteCriticalSection(&m_cs);
- }
- BOOL Start()
- {
- return TRUE;
- }
- BOOL Shutdown()
- {
- return TRUE;
- }
- void Lock()
- {
- EnterCriticalSection(&m_cs);
- }
- void Unlock()
- {
- LeaveCriticalSection(&m_cs);
- }
- CJabberMessagePermanentInfo* AddPermanentHandler(JABBER_PERMANENT_MESSAGE_HANDLER pHandler, int nMessageTypes, DWORD dwParamsToParse, const TCHAR *szXmlns, BOOL bAllowPartialNs, const TCHAR *szTag, void *pUserData = NULL, MESSAGE_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT)
- {
- CJabberMessagePermanentInfo* pInfo = new CJabberMessagePermanentInfo();
- if ( !pInfo)
- return NULL;
-
- pInfo->m_pHandler = pHandler;
- pInfo->m_nMessageTypes = nMessageTypes ? nMessageTypes : JABBER_MESSAGE_TYPE_ANY;
- replaceStrT(pInfo->m_szXmlns, szXmlns);
- pInfo->m_bAllowPartialNs = bAllowPartialNs;
- replaceStrT(pInfo->m_szTag, szTag);
- pInfo->m_dwParamsToParse = dwParamsToParse;
- pInfo->m_pUserData = pUserData;
- pInfo->m_pUserDataFree = pUserDataFree;
- pInfo->m_iPriority = iPriority;
-
- Lock();
- if ( !m_pPermanentHandlers)
- m_pPermanentHandlers = pInfo;
- else
- {
- if (m_pPermanentHandlers->m_iPriority > pInfo->m_iPriority) {
- pInfo->m_pNext = m_pPermanentHandlers;
- m_pPermanentHandlers = pInfo;
- } else
- {
- CJabberMessagePermanentInfo* 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;
- }
- }
- Unlock();
-
- return pInfo;
- }
- BOOL DeletePermanentHandler(CJabberMessagePermanentInfo *pInfo)
- { // returns TRUE when pInfo found, or FALSE otherwise
- Lock();
- if ( !m_pPermanentHandlers)
- {
- Unlock();
- return FALSE;
- }
- if (m_pPermanentHandlers == pInfo) // check first item
- {
- m_pPermanentHandlers = m_pPermanentHandlers->m_pNext;
- delete pInfo;
- Unlock();
- return TRUE;
- } else
- {
- CJabberMessagePermanentInfo* 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;
- }
- }
- Unlock();
- return FALSE;
- }
- BOOL HandleMessagePermanent(HXML node, ThreadData *pThreadData);
- BOOL FillPermanentHandlers();
+ CJabberMessageManager(CJabberProto* proto);
+ ~CJabberMessageManager();
+
+ CJabberMessagePermanentInfo* AddPermanentHandler(JABBER_PERMANENT_MESSAGE_HANDLER pHandler, int nMessageTypes, DWORD dwParamsToParse, const TCHAR *szXmlns, BOOL bAllowPartialNs, const TCHAR *szTag, void *pUserData = NULL, MESSAGE_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT);
+ bool DeletePermanentHandler(CJabberMessagePermanentInfo *pInfo);
+
+ bool HandleMessagePermanent(HXML node, ThreadData *pThreadData);
+ void FillPermanentHandlers();
};
#endif
|