diff options
-rw-r--r-- | protocols/JabberG/src/jabber.h | 1 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_caps.cpp | 25 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_caps.h | 9 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_console.cpp | 21 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_disco.h | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iq.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iq.h | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_message_manager.cpp | 3 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_message_manager.h | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.cpp | 12 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.h | 10 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_send_manager.h | 4 |
12 files changed, 29 insertions, 64 deletions
diff --git a/protocols/JabberG/src/jabber.h b/protocols/JabberG/src/jabber.h index f633157494..5c376b7599 100644 --- a/protocols/JabberG/src/jabber.h +++ b/protocols/JabberG/src/jabber.h @@ -590,7 +590,6 @@ extern struct CountryListEntry* g_countries; extern FI_INTERFACE *FIP;
-extern CRITICAL_SECTION mutex;
extern HANDLE hExtListInit, hDiscoInfoResult;
extern int bSecureIM, bMirOTR, bNewGPG, bPlatform;
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index 4dde4c8864..ad8fad2425 100644 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -520,7 +520,6 @@ BOOL CJabberClientCaps::SetPartialCaps(int nIqId, JabberCapsBits jcbCaps) CJabberClientCapsManager::CJabberClientCapsManager(CJabberProto* proto)
{
ppro = proto;
- InitializeCriticalSection(&m_cs);
m_pClients = NULL;
}
@@ -528,7 +527,6 @@ CJabberClientCapsManager::~CJabberClientCapsManager() {
if (m_pClients)
delete m_pClients;
- DeleteCriticalSection(&m_cs);
}
CJabberClientCaps * CJabberClientCapsManager::FindClient(const TCHAR *szNode)
@@ -556,45 +554,43 @@ void CJabberClientCapsManager::AddDefaultCaps() JabberCapsBits CJabberClientCapsManager::GetClientCaps(TCHAR *szNode, TCHAR *szVer)
{
- Lock();
+ mir_cslockfull lck(m_cs);
CJabberClientCaps *pClient = FindClient(szNode);
if (!pClient) {
- Unlock();
+ lck.unlock();
ppro->debugLog(_T("CAPS: get no caps for: %s, %s"), szNode, szVer);
return JABBER_RESOURCE_CAPS_UNINIT;
}
JabberCapsBits jcbCaps = pClient->GetPartialCaps(szVer);
- Unlock();
+ lck.unlock();
ppro->debugLog(_T("CAPS: get caps %I64x for: %s, %s"), jcbCaps, szNode, szVer);
return jcbCaps;
}
BOOL CJabberClientCapsManager::SetClientCaps(const TCHAR *szNode, const TCHAR *szVer, JabberCapsBits jcbCaps, int nIqId /*= -1*/)
{
- Lock();
+ mir_cslockfull lck(m_cs);
CJabberClientCaps *pClient = FindClient(szNode);
if (!pClient) {
pClient = new CJabberClientCaps(szNode);
- if (!pClient) {
- Unlock();
+ if (!pClient)
return FALSE;
- }
+
pClient->SetNext(m_pClients);
m_pClients = pClient;
}
BOOL bOk = pClient->SetPartialCaps(szVer, jcbCaps, nIqId);
- Unlock();
+ lck.unlock();
ppro->debugLog(_T("CAPS: set caps %I64x for: %s, %s"), jcbCaps, szNode, szVer);
return bOk;
}
BOOL CJabberClientCapsManager::SetClientCaps(int nIqId, JabberCapsBits jcbCaps)
{
- Lock();
- if (!m_pClients) {
- Unlock();
+ mir_cslock lck(m_cs);
+ if (!m_pClients)
return FALSE;
- }
+
BOOL bOk = FALSE;
CJabberClientCaps *pClient = m_pClients;
while (pClient) {
@@ -605,7 +601,6 @@ BOOL CJabberClientCapsManager::SetClientCaps(int nIqId, JabberCapsBits jcbCaps) }
pClient = pClient->GetNext();
}
- Unlock();
return bOk;
}
diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h index 54417da858..e734b79bc3 100644 --- a/protocols/JabberG/src/jabber_caps.h +++ b/protocols/JabberG/src/jabber_caps.h @@ -268,7 +268,7 @@ class CJabberClientCapsManager {
protected:
- CRITICAL_SECTION m_cs;
+ mir_cs m_cs;
CJabberClientCaps *m_pClients;
CJabberProto *ppro;
@@ -279,13 +279,6 @@ public: CJabberClientCapsManager(CJabberProto* proto);
~CJabberClientCapsManager();
- __inline void Lock()
- { EnterCriticalSection(&m_cs);
- }
- __inline void Unlock()
- { LeaveCriticalSection(&m_cs);
- }
-
void AddDefaultCaps();
JabberCapsBits GetClientCaps(TCHAR *szNode, TCHAR *szVer);
diff --git a/protocols/JabberG/src/jabber_console.cpp b/protocols/JabberG/src/jabber_console.cpp index 10f6663c31..84be1ee556 100644 --- a/protocols/JabberG/src/jabber_console.cpp +++ b/protocols/JabberG/src/jabber_console.cpp @@ -125,32 +125,29 @@ bool CJabberProto::FilterXml(HXML node, DWORD flags) if (!m_filterInfo.iq && !lstrcmp(xmlGetName(node), _T("iq"))) return false;
if (m_filterInfo.type == TFilterInfo::T_OFF) return true;
- bool result = false;
- EnterCriticalSection(&m_filterInfo.csPatternLock);
+ mir_cslock lck(m_filterInfo.csPatternLock);
const TCHAR *attrValue;
switch (m_filterInfo.type) {
case TFilterInfo::T_JID:
attrValue = xmlGetAttrValue(node, (flags & JCPF_OUT) ? _T("to") : _T("from"));
if (attrValue)
- result = JabberStrIStr(attrValue, m_filterInfo.pattern) ? true : false;
+ return JabberStrIStr(attrValue, m_filterInfo.pattern) != NULL;
break;
case TFilterInfo::T_XMLNS:
if (xmlGetChildCount(node)) {
attrValue = xmlGetAttrValue(xmlGetChild(node, 0), _T("xmlns"));
if (attrValue)
- result = JabberStrIStr(attrValue, m_filterInfo.pattern) ? true : false;
+ return JabberStrIStr(attrValue, m_filterInfo.pattern) != NULL;
}
break;
case TFilterInfo::T_ANY:
- result = RecursiveCheckFilter(node, flags);
- break;
+ return RecursiveCheckFilter(node, flags);
}
- LeaveCriticalSection(&m_filterInfo.csPatternLock);
- return result;
+ return false;
}
static void sttAppendBufRaw(StringBuf *buf, const char *str)
@@ -557,7 +554,7 @@ INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) int idx = SendDlgItemMessage(m_hwnd, IDC_CB_FILTER, CB_GETCURSEL, 0, 0);
int len = SendDlgItemMessage(m_hwnd, IDC_CB_FILTER, CB_GETLBTEXTLEN, idx, 0) + 1;
- EnterCriticalSection(&m_proto->m_filterInfo.csPatternLock);
+ mir_cslock lck(m_proto->m_filterInfo.csPatternLock);
if (len > SIZEOF(m_proto->m_filterInfo.pattern)) {
TCHAR *buf = (TCHAR *)_alloca(len * sizeof(TCHAR));
@@ -565,13 +562,10 @@ INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) lstrcpyn(m_proto->m_filterInfo.pattern, buf, SIZEOF(m_proto->m_filterInfo.pattern));
}
else SendDlgItemMessage(m_hwnd, IDC_CB_FILTER, CB_GETLBTEXT, idx, (LPARAM)m_proto->m_filterInfo.pattern);
-
- LeaveCriticalSection(&m_proto->m_filterInfo.csPatternLock);
}
else if (HIWORD(wParam) == CBN_EDITCHANGE) {
- EnterCriticalSection(&m_proto->m_filterInfo.csPatternLock);
+ mir_cslock lck(m_proto->m_filterInfo.csPatternLock);
GetWindowText(GetDlgItem(m_hwnd, IDC_CB_FILTER), m_proto->m_filterInfo.pattern, SIZEOF(m_proto->m_filterInfo.pattern));
- LeaveCriticalSection(&m_proto->m_filterInfo.csPatternLock);
}
break;
@@ -626,7 +620,6 @@ void __cdecl CJabberProto::ConsoleThread(void*) void CJabberProto::ConsoleInit()
{
LoadLibraryA("riched20.dll");
- InitializeCriticalSection(&m_filterInfo.csPatternLock);
m_hThreadConsole = ForkThreadEx(&CJabberProto::ConsoleThread, 0, &m_dwConsoleThreadId);
}
diff --git a/protocols/JabberG/src/jabber_disco.h b/protocols/JabberG/src/jabber_disco.h index ad534d35fa..cb42d4d097 100644 --- a/protocols/JabberG/src/jabber_disco.h +++ b/protocols/JabberG/src/jabber_disco.h @@ -410,7 +410,7 @@ public: RemoveAll();
}
- CRITICAL_SECTION& cs() { return m_cs; }
+ mir_cs& cs() { return m_cs; }
void RemoveAll()
{
diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp index 7186ffe268..45e335e053 100644 --- a/protocols/JabberG/src/jabber_iq.cpp +++ b/protocols/JabberG/src/jabber_iq.cpp @@ -35,7 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. CJabberIqManager::CJabberIqManager(CJabberProto* proto)
{
- InitializeCriticalSection(&m_cs);
m_dwLastUsedHandle = 0;
m_pIqs = NULL;
m_hExpirerThread = NULL;
@@ -56,7 +55,6 @@ CJabberIqManager::~CJabberIqManager() }
m_pPermanentHandlers = NULL;
}
- DeleteCriticalSection(&m_cs);
}
BOOL CJabberIqManager::Start()
diff --git a/protocols/JabberG/src/jabber_iq.h b/protocols/JabberG/src/jabber_iq.h index cd229247ca..b1e0f786e8 100644 --- a/protocols/JabberG/src/jabber_iq.h +++ b/protocols/JabberG/src/jabber_iq.h @@ -169,7 +169,7 @@ class CJabberIqManager {
protected:
CJabberProto *ppro;
- CRITICAL_SECTION m_cs;
+ mir_cs m_cs;
DWORD m_dwLastUsedHandle;
CJabberIqInfo *m_pIqs; // list of iqs ordered by priority
HANDLE m_hExpirerThread;
diff --git a/protocols/JabberG/src/jabber_message_manager.cpp b/protocols/JabberG/src/jabber_message_manager.cpp index baaf3c4dc1..bea0d98def 100644 --- a/protocols/JabberG/src/jabber_message_manager.cpp +++ b/protocols/JabberG/src/jabber_message_manager.cpp @@ -29,7 +29,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. CJabberMessageManager::CJabberMessageManager(CJabberProto *proto)
{
- InitializeCriticalSection(&m_cs);
m_pPermanentHandlers = NULL;
ppro = proto;
}
@@ -42,8 +41,6 @@ CJabberMessageManager::~CJabberMessageManager() pInfo = pTmp;
}
m_pPermanentHandlers = NULL;
-
- DeleteCriticalSection(&m_cs);
}
void CJabberMessageManager::FillPermanentHandlers()
diff --git a/protocols/JabberG/src/jabber_message_manager.h b/protocols/JabberG/src/jabber_message_manager.h index ab12cf7ca7..41bd6cdc80 100644 --- a/protocols/JabberG/src/jabber_message_manager.h +++ b/protocols/JabberG/src/jabber_message_manager.h @@ -118,7 +118,7 @@ class CJabberMessageManager {
protected:
CJabberProto *ppro;
- CRITICAL_SECTION m_cs;
+ mir_cs m_cs;
CJabberMessagePermanentInfo* m_pPermanentHandlers;
public:
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index c14aeda740..5705dbef00 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -71,9 +71,6 @@ CJabberProto::CJabberProto(const char *aProtoName, const TCHAR *aUserName) : m_lstJabberFeatCapPairsDynamic(2),
m_uEnabledFeatCapsDynamic(0)
{
- InitializeCriticalSection(&m_csModeMsgMutex);
- InitializeCriticalSection(&m_csLists);
-
m_szXmlStreamToBeInitialized = NULL;
debugLogA("Setting protocol/module name to '%s'", m_szModuleName);
@@ -177,14 +174,10 @@ CJabberProto::~CJabberProto() DestroyHookableEvent(m_hEventXStatusChanged);
ListWipe();
- DeleteCriticalSection(&m_csLists);
mir_free(m_tszSelectedLang);
mir_free(m_AuthMechs.m_gssapiHostName);
- DeleteCriticalSection(&m_filterInfo.csPatternLock);
- DeleteCriticalSection(&m_csModeMsgMutex);
-
mir_free(m_modeMsgs.szOnline);
mir_free(m_modeMsgs.szAway);
mir_free(m_modeMsgs.szNa);
@@ -195,11 +188,10 @@ CJabberProto::~CJabberProto() mir_free(m_szStreamId);
- int i;
- for (i=0; i < m_lstTransports.getCount(); i++)
+ for (int i=0; i < m_lstTransports.getCount(); i++)
mir_free(m_lstTransports[i]);
- for (i=0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++) {
+ for (int i = 0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++) {
mir_free(m_lstJabberFeatCapPairsDynamic[i]->szExt);
mir_free(m_lstJabberFeatCapPairsDynamic[i]->szFeature);
mir_free(m_lstJabberFeatCapPairsDynamic[i]->szDescription);
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 2c384c2c9c..5ed75fb694 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -69,8 +69,8 @@ struct TFilterInfo volatile BOOL msg, presence, iq;
volatile Type type;
- CRITICAL_SECTION csPatternLock;
- TCHAR pattern[256];
+ mir_cs csPatternLock;
+ TCHAR pattern[256];
};
struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
@@ -168,7 +168,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface UINT m_nJabberCodePage;
TCHAR *m_tszSelectedLang;
- CRITICAL_SECTION m_csModeMsgMutex;
+ mir_cs m_csModeMsgMutex;
JABBER_MODEMSGS m_modeMsgs;
BOOL m_bModeMsgStatusChangePending;
@@ -222,8 +222,8 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface CJabberInfoFrame *m_pInfoFrame;
LIST<JABBER_LIST_ITEM> m_lstRoster;
- CRITICAL_SECTION m_csLists;
- BOOL m_bListInitialised;
+ mir_cs m_csLists;
+ BOOL m_bListInitialised;
LIST<JabberFeatCapPairDynamic> m_lstJabberFeatCapPairsDynamic; // list of features registered through IJabberNetInterface::RegisterFeature()
JabberCapsBits m_uEnabledFeatCapsDynamic;
diff --git a/protocols/JabberG/src/jabber_send_manager.h b/protocols/JabberG/src/jabber_send_manager.h index eee8647ca2..ac1ae878a5 100644 --- a/protocols/JabberG/src/jabber_send_manager.h +++ b/protocols/JabberG/src/jabber_send_manager.h @@ -86,13 +86,12 @@ class CJabberSendManager {
protected:
CJabberProto *ppro;
- CRITICAL_SECTION m_cs;
+ mir_cs m_cs;
CJabberSendPermanentInfo* m_pPermanentHandlers;
public:
CJabberSendManager(CJabberProto* proto)
{
- InitializeCriticalSection(&m_cs);
m_pPermanentHandlers = NULL;
ppro = proto;
}
@@ -105,7 +104,6 @@ public: pInfo = pTmp;
}
m_pPermanentHandlers = NULL;
- DeleteCriticalSection(&m_cs);
}
BOOL Start()
{
|