diff options
author | George Hazan <george.hazan@gmail.com> | 2013-10-03 17:27:06 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-10-03 17:27:06 +0000 |
commit | a9fac2d04887b80526ab90c4c8ce45cd482e80b2 (patch) | |
tree | 0bc62363778c6110d16016816650278a147049f7 /protocols/JabberG/src/jabber_privacy.cpp | |
parent | 9257dc8641a40437ceda38b65f4be7390e57954b (diff) |
- filetransfer::iqid converted from string to int;
- further code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@6319 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_privacy.cpp')
-rw-r--r-- | protocols/JabberG/src/jabber_privacy.cpp | 999 |
1 files changed, 463 insertions, 536 deletions
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp index 9fcb7046c9..748a0d8df5 100644 --- a/protocols/JabberG/src/jabber_privacy.cpp +++ b/protocols/JabberG/src/jabber_privacy.cpp @@ -32,22 +32,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. BOOL CJabberProto::OnIqRequestPrivacyLists(HXML, CJabberIqInfo *pInfo)
{
if (pInfo->GetIqType() == JABBER_IQ_TYPE_SET) {
- if ( !m_pDlgPrivacyLists)
- {
+ if ( !m_pDlgPrivacyLists) {
m_privacyListManager.RemoveAllLists();
QueryPrivacyLists();
}
else m_pDlgPrivacyLists->SetStatusText(TranslateT("Warning: privacy lists were changed on server."));
- XmlNodeIq iq(_T("result"), pInfo);
- m_ThreadInfo->send(iq);
+ m_ThreadInfo->send( XmlNodeIq(_T("result"), pInfo));
}
return TRUE;
}
void CJabberProto::OnIqResultPrivacyListModify(HXML, CJabberIqInfo *pInfo)
{
- if ( !pInfo->m_pUserData)
+ if (!pInfo->m_pUserData)
return;
CPrivacyListModifyUserParam *pParam = (CPrivacyListModifyUserParam *)pInfo->m_pUserData;
@@ -71,77 +69,78 @@ void CJabberProto::OnIqResultPrivacyListModify(HXML, CJabberIqInfo *pInfo) void CJabberProto::OnIqResultPrivacyList(HXML iqNode, CJabberIqInfo*)
{
- if ( !iqNode)
+ if (iqNode == NULL)
return;
const TCHAR *type = xmlGetAttrValue(iqNode, _T("type"));
- if ( !type)
+ if (type == NULL)
return;
- if ( !_tcscmp(type, _T("result"))) {
- HXML query = xmlGetChild(iqNode , "query");
- if ( !query)
- return;
- HXML list = xmlGetChild(query , "list");
- if ( !list)
- return;
- TCHAR *szListName = (TCHAR*)xmlGetAttrValue(list, _T("name"));
- if ( !szListName)
+ if ( _tcscmp(type, _T("result")))
+ return;
+
+ HXML query = xmlGetChild(iqNode , "query");
+ if (query == NULL)
+ return;
+ HXML list = xmlGetChild(query, "list");
+ if (list == NULL)
+ return;
+ TCHAR *szListName = (TCHAR*)xmlGetAttrValue(list, _T("name"));
+ if ( !szListName)
+ return;
+
+ mir_cslockfull lck(m_privacyListManager.m_cs);
+ CPrivacyList *pList = m_privacyListManager.FindList(szListName);
+ if (pList == NULL) {
+ m_privacyListManager.AddList(szListName);
+ pList = m_privacyListManager.FindList(szListName);
+ if (pList == NULL)
return;
- m_privacyListManager.Lock();
- CPrivacyList* pList = m_privacyListManager.FindList(szListName);
- if ( !pList) {
- m_privacyListManager.AddList(szListName);
- pList = m_privacyListManager.FindList(szListName);
- if ( !pList) {
- m_privacyListManager.Unlock();
- return;
- } }
-
- HXML item;
- for (int i = 1; (item = xmlGetNthChild(list, _T("item"), i)) != NULL; i++) {
- const TCHAR *itemType = xmlGetAttrValue(item, _T("type"));
- PrivacyListRuleType nItemType = Else;
- if (itemType) {
- if ( !_tcsicmp(itemType, _T("jid")))
- nItemType = Jid;
- else if ( !_tcsicmp(itemType, _T("group")))
- nItemType = Group;
- else if ( !_tcsicmp(itemType, _T("subscription")))
- nItemType = Subscription;
- }
+ }
- const TCHAR *itemValue = xmlGetAttrValue(item, _T("value"));
-
- const TCHAR *itemAction = xmlGetAttrValue(item, _T("action"));
- BOOL bAllow = TRUE;
- if (itemAction && !_tcsicmp(itemAction, _T("deny")))
- bAllow = FALSE;
-
- const TCHAR *itemOrder = xmlGetAttrValue(item, _T("order"));
- DWORD dwOrder = 0;
- if (itemOrder)
- dwOrder = _ttoi(itemOrder);
-
- DWORD dwPackets = 0;
- if (xmlGetChild(item , "message"))
- dwPackets |= JABBER_PL_RULE_TYPE_MESSAGE;
- if (xmlGetChild(item , "presence-in"))
- dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
- if (xmlGetChild(item , "presence-out"))
- dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
- if (xmlGetChild(item , "iq"))
- dwPackets |= JABBER_PL_RULE_TYPE_IQ;
-
- pList->AddRule(nItemType, itemValue, bAllow, dwOrder, dwPackets);
+ HXML item;
+ for (int i = 1; (item = xmlGetNthChild(list, _T("item"), i)) != NULL; i++) {
+ const TCHAR *itemType = xmlGetAttrValue(item, _T("type"));
+ PrivacyListRuleType nItemType = Else;
+ if (itemType) {
+ if ( !_tcsicmp(itemType, _T("jid")))
+ nItemType = Jid;
+ else if ( !_tcsicmp(itemType, _T("group")))
+ nItemType = Group;
+ else if ( !_tcsicmp(itemType, _T("subscription")))
+ nItemType = Subscription;
}
- pList->Reorder();
- pList->SetLoaded();
- pList->SetModified(FALSE);
- m_privacyListManager.Unlock();
- UI_SAFE_NOTIFY(m_pDlgPrivacyLists, WM_JABBER_REFRESH);
-} }
+ const TCHAR *itemValue = xmlGetAttrValue(item, _T("value"));
+
+ const TCHAR *itemAction = xmlGetAttrValue(item, _T("action"));
+ BOOL bAllow = TRUE;
+ if (itemAction && !_tcsicmp(itemAction, _T("deny")))
+ bAllow = FALSE;
+
+ const TCHAR *itemOrder = xmlGetAttrValue(item, _T("order"));
+ DWORD dwOrder = 0;
+ if (itemOrder)
+ dwOrder = _ttoi(itemOrder);
+
+ DWORD dwPackets = 0;
+ if (xmlGetChild(item , "message"))
+ dwPackets |= JABBER_PL_RULE_TYPE_MESSAGE;
+ if (xmlGetChild(item , "presence-in"))
+ dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_IN;
+ if (xmlGetChild(item , "presence-out"))
+ dwPackets |= JABBER_PL_RULE_TYPE_PRESENCE_OUT;
+ if (xmlGetChild(item , "iq"))
+ dwPackets |= JABBER_PL_RULE_TYPE_IQ;
+ pList->AddRule(nItemType, itemValue, bAllow, dwOrder, dwPackets);
+ }
+ pList->Reorder();
+ pList->SetLoaded();
+ pList->SetModified(FALSE);
+
+ lck.unlock();
+ UI_SAFE_NOTIFY(m_pDlgPrivacyLists, WM_JABBER_REFRESH);
+}
CPrivacyList* GetSelectedList(HWND hDlg)
{
@@ -176,32 +175,29 @@ void CJabberProto::OnIqResultPrivacyListActive(HXML iqNode, CJabberIqInfo *pInfo if (m_pDlgPrivacyLists)
EnableWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_ACTIVATE), TRUE);
- if ( !iqNode)
+ if (iqNode == NULL)
return;
const TCHAR *type = xmlGetAttrValue(iqNode, _T("type"));
- if ( !type)
+ if (type == NULL)
return;
- TCHAR szText[ 512 ];
- szText[0] = _T('\0');
- m_privacyListManager.Lock();
+ CMString szText;
+
if ( !_tcscmp(type, _T("result"))) {
+ mir_cslock lck(m_privacyListManager.m_cs);
if (pList) {
m_privacyListManager.SetActiveListName(pList->GetListName());
- mir_sntprintf(szText, SIZEOF(szText), TranslateT("Privacy list %s set as active"), pList->GetListName());
+ szText.Format( TranslateT("Privacy list %s set as active"), pList->GetListName());
}
else {
m_privacyListManager.SetActiveListName(NULL);
- mir_sntprintf(szText, SIZEOF(szText), TranslateT("Active privacy list successfully declined"));
+ szText.Format( TranslateT("Active privacy list successfully declined"));
}
}
- else mir_sntprintf(szText, SIZEOF(szText), TranslateT("Error occurred while setting active list"));
+ else szText = TranslateT("Error occurred while setting active list");
- m_privacyListManager.Unlock();
-
- if (m_pDlgPrivacyLists)
- {
+ if (m_pDlgPrivacyLists) {
m_pDlgPrivacyLists->SetStatusText(szText);
RedrawWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_LB_LISTS), NULL, NULL, RDW_INVALIDATE);
}
@@ -211,38 +207,35 @@ void CJabberProto::OnIqResultPrivacyListActive(HXML iqNode, CJabberIqInfo *pInfo void CJabberProto::OnIqResultPrivacyListDefault(HXML iqNode, CJabberIqInfo *pInfo)
{
- CPrivacyList *pList = (CPrivacyList *)pInfo->GetUserData();
-
if (m_pDlgPrivacyLists)
EnableWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_SET_DEFAULT), TRUE);
- if ( !iqNode)
+ if (iqNode == NULL)
return;
const TCHAR *type = xmlGetAttrValue(iqNode, _T("type"));
- if ( !type)
+ if (type == NULL)
return;
TCHAR szText[ 512 ];
szText[0] = _T('\0');
- m_privacyListManager.Lock();
- if ( !_tcscmp(type, _T("result"))) {
- if (pList) {
- m_privacyListManager.SetDefaultListName(pList->GetListName());
- mir_sntprintf(szText, SIZEOF(szText), TranslateT("Privacy list %s set as default"), pList->GetListName());
- }
- else {
- m_privacyListManager.SetDefaultListName(NULL);
- mir_sntprintf(szText, SIZEOF(szText), TranslateT("Default privacy list successfully declined"));
+ {
+ mir_cslock lck(m_privacyListManager.m_cs);
+ if ( !_tcscmp(type, _T("result"))) {
+ CPrivacyList *pList = (CPrivacyList *)pInfo->GetUserData();
+ if (pList) {
+ m_privacyListManager.SetDefaultListName(pList->GetListName());
+ mir_sntprintf(szText, SIZEOF(szText), TranslateT("Privacy list %s set as default"), pList->GetListName());
+ }
+ else {
+ m_privacyListManager.SetDefaultListName(NULL);
+ mir_sntprintf(szText, SIZEOF(szText), TranslateT("Default privacy list successfully declined"));
+ }
}
+ else mir_sntprintf(szText, SIZEOF(szText), TranslateT("Error occurred while setting default list"));
}
- else {
- mir_sntprintf(szText, SIZEOF(szText), TranslateT("Error occurred while setting default list"));
- }
- m_privacyListManager.Unlock();
- if (m_pDlgPrivacyLists)
- {
+ if (m_pDlgPrivacyLists) {
m_pDlgPrivacyLists->SetStatusText(szText);
RedrawWindow(GetDlgItem(m_pDlgPrivacyLists->GetHwnd(), IDC_LB_LISTS), NULL, NULL, RDW_INVALIDATE);
}
@@ -254,45 +247,44 @@ void CJabberProto::OnIqResultPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo) return;
HXML query = xmlGetChild(iqNode, "query");
- if ( !query)
+ if (query == NULL)
return;
if (m_ThreadInfo)
m_ThreadInfo->jabberServerCaps |= JABBER_CAPS_PRIVACY_LISTS;
+ {
+ mir_cslock lck(m_privacyListManager.m_cs);
+ m_privacyListManager.RemoveAllLists();
- m_privacyListManager.Lock();
- m_privacyListManager.RemoveAllLists();
-
- for (int i = 1; ; i++) {
- HXML list = xmlGetNthChild(query, _T("list"), i);
- if ( !list)
- break;
-
- const TCHAR *listName = xmlGetAttrValue(list, _T("name"));
- if (listName) {
- m_privacyListManager.AddList((TCHAR*)listName);
-
- // Query contents only if list editior is visible!
- if (m_pDlgPrivacyLists)
- m_ThreadInfo->send(
- XmlNodeIq( AddIQ(&CJabberProto::OnIqResultPrivacyList, JABBER_IQ_TYPE_GET))
- << XQUERY(JABBER_FEAT_PRIVACY_LISTS) << XCHILD(_T("list")) << XATTR(_T("name"), listName));
- } }
-
- const TCHAR *szName = NULL;
- HXML node = xmlGetChild(query , "active");
- if (node)
- szName = xmlGetAttrValue(node, _T("name"));
- m_privacyListManager.SetActiveListName(szName);
+ for (int i = 1; ; i++) {
+ HXML list = xmlGetNthChild(query, _T("list"), i);
+ if (list == NULL)
+ break;
- szName = NULL;
- node = xmlGetChild(query , "default");
- if (node)
- szName = xmlGetAttrValue(node, _T("name"));
- m_privacyListManager.SetDefaultListName(szName);
+ const TCHAR *listName = xmlGetAttrValue(list, _T("name"));
+ if (listName) {
+ m_privacyListManager.AddList((TCHAR*)listName);
- m_privacyListManager.Unlock();
+ // Query contents only if list editior is visible!
+ if (m_pDlgPrivacyLists)
+ m_ThreadInfo->send(
+ XmlNodeIq( AddIQ(&CJabberProto::OnIqResultPrivacyList, JABBER_IQ_TYPE_GET))
+ << XQUERY(JABBER_FEAT_PRIVACY_LISTS) << XCHILD(_T("list")) << XATTR(_T("name"), listName));
+ }
+ }
+ const TCHAR *szName = NULL;
+ HXML node = xmlGetChild(query , "active");
+ if (node)
+ szName = xmlGetAttrValue(node, _T("name"));
+ m_privacyListManager.SetActiveListName(szName);
+
+ szName = NULL;
+ node = xmlGetChild(query , "default");
+ if (node)
+ szName = xmlGetAttrValue(node, _T("name"));
+ m_privacyListManager.SetDefaultListName(szName);
+ }
UI_SAFE_NOTIFY(m_pDlgPrivacyLists, WM_JABBER_REFRESH);
BuildPrivacyListsMenu(true);
@@ -372,8 +364,7 @@ public: TCHAR *szTypes[] = { _T("JID"), _T("Group"), _T("Subscription"), _T("Any") };
int i, nTypes[] = { Jid, Group, Subscription, Else };
- for (i=0; i < SIZEOF(szTypes); i++)
- {
+ for (i=0; i < SIZEOF(szTypes); i++) {
LRESULT nItem = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateTS(szTypes[i]));
SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_SETITEMDATA, nItem, nTypes[i]);
if (m_pRule->GetType() == nTypes[i])
@@ -382,8 +373,7 @@ public: SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_RESETCONTENT, 0, 0);
TCHAR *szSubscriptions[] = { _T("none"), _T("from"), _T("to"), _T("both") };
- for (i=0; i < SIZEOF(szSubscriptions); i++)
- {
+ for (i=0; i < SIZEOF(szSubscriptions); i++) {
LRESULT nItem = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_ADDSTRING, 0, (LPARAM)TranslateTS(szSubscriptions[i]));
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SETITEMDATA, nItem, (LPARAM)szSubscriptions[i]);
}
@@ -421,13 +411,12 @@ public: LRESULT nItemData = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_GETITEMDATA, nCurSel, 0);
switch (nItemData) {
- case Jid:
- {
- ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_SHOW);
- ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUE), SW_HIDE);
-
- SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0);
+ case Jid:
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUE), SW_HIDE);
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0);
+ {
for (HANDLE hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName)) {
DBVARIANT dbv;
if ( !m_proto->getTString(hContact, "jid", &dbv)) {
@@ -443,64 +432,54 @@ public: if (item = m_proto->ListGetItemPtrFromIndex(i))
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)item->jid);
}
-
- // FIXME: ugly code :)
- if (m_pRule->GetValue())
- {
- SetDlgItemText(m_hwnd, IDC_COMBO_VALUES, m_pRule->GetValue());
- LRESULT nSelPos = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_FINDSTRINGEXACT , -1, (LPARAM)m_pRule->GetValue());
- if (nSelPos != CB_ERR)
- SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_SETCURSEL, nSelPos, 0);
- }
- break;
}
- case Group:
- {
- ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_SHOW);
- ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUE), SW_HIDE);
+ // FIXME: ugly code :)
+ if (m_pRule->GetValue()) {
+ SetDlgItemText(m_hwnd, IDC_COMBO_VALUES, m_pRule->GetValue());
+ LRESULT nSelPos = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_FINDSTRINGEXACT , -1, (LPARAM)m_pRule->GetValue());
+ if (nSelPos != CB_ERR)
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_SETCURSEL, nSelPos, 0);
+ }
+ break;
- SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0);
+ case Group:
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_SHOW);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUE), SW_HIDE);
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0);
+ {
TCHAR *grpName;
for (int i=1; (grpName = pcli->pfnGetGroupName(i, NULL)) != NULL; i++)
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)grpName);
+ }
- // FIXME: ugly code :)
- if (m_pRule->GetValue())
- {
- SetDlgItemText(m_hwnd, IDC_COMBO_VALUES, m_pRule->GetValue());
- LRESULT nSelPos = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_FINDSTRINGEXACT , -1, (LPARAM)m_pRule->GetValue());
- if (nSelPos != CB_ERR)
- SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_SETCURSEL, nSelPos, 0);
- }
- break;
+ // FIXME: ugly code :)
+ if (m_pRule->GetValue()) {
+ SetDlgItemText(m_hwnd, IDC_COMBO_VALUES, m_pRule->GetValue());
+ LRESULT nSelPos = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_FINDSTRINGEXACT , -1, (LPARAM)m_pRule->GetValue());
+ if (nSelPos != CB_ERR)
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_SETCURSEL, nSelPos, 0);
}
+ break;
- case Subscription:
- {
- ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_HIDE);
- ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUE), SW_SHOW);
+ case Subscription:
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUE), SW_SHOW);
- if (m_pRule->GetValue())
- {
- LRESULT nSelected = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SELECTSTRING, -1, (LPARAM)TranslateTS(m_pRule->GetValue()));
- if (nSelected == CB_ERR)
- SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SETCURSEL, 0, 0);
- }
- else SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SETCURSEL, 0, 0);
- break;
+ if (m_pRule->GetValue()) {
+ LRESULT nSelected = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SELECTSTRING, -1, (LPARAM)TranslateTS(m_pRule->GetValue()));
+ if (nSelected == CB_ERR)
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SETCURSEL, 0, 0);
}
+ else SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SETCURSEL, 0, 0);
+ break;
- case Else:
- {
- ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_HIDE);
- ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUE), SW_HIDE);
- break;
- }
+ case Else:
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_HIDE);
+ ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUE), SW_HIDE);
+ break;
}
-
- return;
}
void btnOk_OnClick(CCtrlButton *)
@@ -510,29 +489,27 @@ public: if (nCurSel != CB_ERR)
nItemData = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_GETITEMDATA, nCurSel, 0);
- switch (nItemData)
- {
- case Jid:
- case Group:
+ switch (nItemData) {
+ case Jid:
+ case Group:
{
TCHAR szText[ 512 ];
GetDlgItemText(m_hwnd, IDC_COMBO_VALUES, szText, SIZEOF(szText));
m_pRule->SetValue(szText);
- break;
- }
- case Subscription:
- {
- nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_GETCURSEL, 0, 0);
- if (nCurSel != CB_ERR)
- m_pRule->SetValue((TCHAR*)SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_GETITEMDATA, nCurSel, 0));
- else
- m_pRule->SetValue(_T("none"));
- break;
}
+ break;
- default:
- m_pRule->SetValue(NULL);
- break;
+ case Subscription:
+ nCurSel = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_GETCURSEL, 0, 0);
+ if (nCurSel != CB_ERR)
+ m_pRule->SetValue((TCHAR*)SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_GETITEMDATA, nCurSel, 0));
+ else
+ m_pRule->SetValue(_T("none"));
+ break;
+
+ default:
+ m_pRule->SetValue(NULL);
+ break;
}
m_pRule->SetType((PrivacyListRuleType)nItemData);
@@ -671,8 +648,7 @@ protected: TCLCInfo(): newJids(1, TJidData::cmp), bChanged(false), pList(0) {}
~TCLCInfo()
{
- for (int i=0; i < newJids.getCount(); i++)
- {
+ for (int i=0; i < newJids.getCount(); i++) {
mir_free(newJids[i]->jid);
mir_free(newJids[i]);
}
@@ -899,23 +875,23 @@ void CJabberDlgPrivacyLists::OnProtoRefresh(WPARAM, LPARAM) LRESULT nItemId = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)TranslateT("<none>"));
SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nItemId, 0);
+ {
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- m_proto->m_privacyListManager.Lock();
- CPrivacyList* pList = m_proto->m_privacyListManager.GetFirstList();
- while (pList) {
- if ( !pList->IsDeleted()) {
- nItemId = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)pList->GetListName());
- SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nItemId, (LPARAM)pList);
+ CPrivacyList *pList = m_proto->m_privacyListManager.GetFirstList();
+ while (pList) {
+ if ( !pList->IsDeleted()) {
+ nItemId = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_ADDSTRING, 0, (LPARAM)pList->GetListName());
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nItemId, (LPARAM)pList);
+ }
+ pList = pList->GetNext();
}
- pList = pList->GetNext();
- }
-
- if ( !szCurrentSelectedList || (SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SELECTSTRING, -1, (LPARAM)szCurrentSelectedList) == LB_ERR))
- SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, 0, 0);
- if (szCurrentSelectedList)
- mir_free(szCurrentSelectedList);
- m_proto->m_privacyListManager.Unlock();
+ if ( !szCurrentSelectedList || (SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SELECTSTRING, -1, (LPARAM)szCurrentSelectedList) == LB_ERR))
+ SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, 0, 0);
+ if (szCurrentSelectedList)
+ mir_free(szCurrentSelectedList);
+ }
PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_LB_LISTS, LBN_SELCHANGE), 0);
EnableEditorControls();
@@ -942,6 +918,22 @@ BOOL CJabberDlgPrivacyLists::OnWmMeasureItem(UINT, WPARAM, LPARAM lParam) return TRUE;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct
+{
+ TCHAR *textEng;
+ char *icon;
+ TCHAR *text;
+}
+static drawItems[] =
+{
+ { _T("Message"), "pl_msg_allow" },
+ { _T("Presence (in)"), "pl_prin_allow" },
+ { _T("Presence (out)"), "pl_prout_allow" },
+ { _T("Query"), "pl_iq_allow" }
+};
+
BOOL CJabberDlgPrivacyLists::OnWmDrawItem(UINT, WPARAM, LPARAM lParam)
{
LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
@@ -950,27 +942,12 @@ BOOL CJabberDlgPrivacyLists::OnWmDrawItem(UINT, WPARAM, LPARAM lParam) DrawRulesList(lpdis);
else if (lpdis->CtlID == IDC_LB_LISTS)
DrawLists(lpdis);
- else if (lpdis->CtlID == IDC_CANVAS)
- {
- static struct
- {
- TCHAR *textEng;
- char *icon;
- TCHAR *text;
- } items[] =
- {
- { _T("Message"), "pl_msg_allow" },
- { _T("Presence (in)"), "pl_prin_allow" },
- { _T("Presence (out)"), "pl_prout_allow" },
- { _T("Query"), "pl_iq_allow" },
- };
-
+ else if (lpdis->CtlID == IDC_CANVAS) {
int i, totalWidth = -5; // spacing for last item
- for (i=0; i < SIZEOF(items); i++)
- {
+ for (i=0; i < SIZEOF(drawItems); i++) {
SIZE sz = {0};
- items[i].text = TranslateTS(items[i].textEng);
- GetTextExtentPoint32(lpdis->hDC, items[i].text, lstrlen(items[i].text), &sz);
+ drawItems[i].text = TranslateTS(drawItems[i].textEng);
+ GetTextExtentPoint32(lpdis->hDC, drawItems[i].text, lstrlen(drawItems[i].text), &sz);
totalWidth += sz.cx + 18 + 5; // 18 pixels for icon, 5 pixel spacing
}
@@ -978,12 +955,11 @@ BOOL CJabberDlgPrivacyLists::OnWmDrawItem(UINT, WPARAM, LPARAM lParam) RECT rc = lpdis->rcItem;
rc.left = (rc.left + rc.right - totalWidth)/2;
- for (i=0; i < SIZEOF(items); i++)
- {
- DrawIconEx(lpdis->hDC, rc.left, (rc.top+rc.bottom-16)/2, m_proto->LoadIconEx(items[i].icon),
+ for (i=0; i < SIZEOF(drawItems); i++) {
+ DrawIconEx(lpdis->hDC, rc.left, (rc.top+rc.bottom-16)/2, m_proto->LoadIconEx(drawItems[i].icon),
16, 16, 0, NULL, DI_NORMAL);
rc.left += 18;
- DrawNextRulePart(lpdis->hDC, clText, items[i].text, &rc);
+ DrawNextRulePart(lpdis->hDC, clText, drawItems[i].text, &rc);
rc.left += 5;
}
}
@@ -1008,7 +984,6 @@ void CJabberDlgPrivacyLists::ShowAdvancedList(CPrivacyList *pList) BOOL bListEmpty = TRUE;
CPrivacyListRule* pRule = pList->GetFirstRule();
-
while (pRule) {
bListEmpty = FALSE;
TCHAR szTypeValue[ 512 ];
@@ -1052,7 +1027,8 @@ void CJabberDlgPrivacyLists::ShowAdvancedList(CPrivacyList *pList) if (_tcslen(szPackets))
_tcscat(szPackets, _T(", "));
_tcscat(szPackets, _T("queries"));
- } }
+ }
+ }
TCHAR szListItem[ 512 ];
mir_sntprintf(szListItem, SIZEOF(szListItem), _T("%s %s %s"), szTypeValue, pRule->GetAction() ? _T("allow") : _T("deny"), szPackets);
@@ -1086,10 +1062,8 @@ void CJabberDlgPrivacyLists::DrawRuleAction(HDC hdc, COLORREF clLine1, COLORREF, {
DrawNextRulePart(hdc, clLine1, pRule->GetAction() ? TranslateT("allow ") : TranslateT("deny "), rc);
if ( !pRule->GetPackets() || (pRule->GetPackets() == JABBER_PL_RULE_TYPE_ALL))
- {
DrawNextRulePart(hdc, clLine1, TranslateT("all."), rc);
- } else
- {
+ else {
bool needComma = false;
int itemCount =
((pRule->GetPackets() & JABBER_PL_RULE_TYPE_MESSAGE) ? 1 : 0) +
@@ -1097,30 +1071,26 @@ void CJabberDlgPrivacyLists::DrawRuleAction(HDC hdc, COLORREF clLine1, COLORREF, ((pRule->GetPackets() & JABBER_PL_RULE_TYPE_PRESENCE_OUT) ? 1 : 0) +
((pRule->GetPackets() & JABBER_PL_RULE_TYPE_IQ) ? 1 : 0);
- if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_MESSAGE)
- {
+ if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_MESSAGE) {
--itemCount;
needComma = true;
DrawNextRulePart(hdc, clLine1, TranslateT("messages"), rc);
}
- if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_PRESENCE_IN)
- {
+ if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_PRESENCE_IN) {
--itemCount;
if (needComma)
DrawNextRulePart(hdc, clLine1, itemCount ? _T(", ") : TranslateT(" and "), rc);
needComma = true;
DrawNextRulePart(hdc, clLine1, TranslateT("incoming presences"), rc);
}
- if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_PRESENCE_OUT)
- {
+ if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_PRESENCE_OUT) {
--itemCount;
if (needComma)
DrawNextRulePart(hdc, clLine1, itemCount ? _T(", ") : TranslateT(" and "), rc);
needComma = true;
DrawNextRulePart(hdc, clLine1, TranslateT("outgoing presences"), rc);
}
- if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_IQ)
- {
+ if (pRule->GetPackets() & JABBER_PL_RULE_TYPE_IQ) {
--itemCount;
if (needComma)
DrawNextRulePart(hdc, clLine1, itemCount ? _T(", ") : TranslateT(" and "), rc);
@@ -1139,13 +1109,12 @@ void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis) CPrivacyListRule *pRule = (CPrivacyListRule *)lpdis->itemData;
COLORREF clLine1, clLine2, clBack;
- if (lpdis->itemState & ODS_SELECTED)
- {
+ if (lpdis->itemState & ODS_SELECTED) {
FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
clBack = GetSysColor(COLOR_HIGHLIGHT);
clLine1 = GetSysColor(COLOR_HIGHLIGHTTEXT);
- } else
- {
+ }
+ else {
FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW));
clBack = GetSysColor(COLOR_WINDOW);
clLine1 = GetSysColor(COLOR_WINDOWTEXT);
@@ -1153,13 +1122,11 @@ void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis) clLine2 = RGB(
GetRValue(clLine1) * 0.66 + GetRValue(clBack) * 0.34,
GetGValue(clLine1) * 0.66 + GetGValue(clBack) * 0.34,
- GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34
- );
+ GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34);
SetBkMode(lpdis->hDC, TRANSPARENT);
RECT rc;
-
if ( !pRule) {
rc = lpdis->rcItem;
rc.left += 25;
@@ -1181,9 +1148,8 @@ void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis) rc.bottom -= (rc.bottom - rc.top) / 2;
rc.left += 25;
- switch (pRule->GetType())
- {
- case Jid:
+ switch (pRule->GetType()) {
+ case Jid:
{
DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If jabber id is '"), &rc);
DrawNextRulePart(lpdis->hDC, clLine1, pRule->GetValue(), &rc);
@@ -1199,16 +1165,17 @@ void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis) break;
}
- case Group:
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If group is '"), &rc);
- DrawNextRulePart(lpdis->hDC, clLine1, pRule->GetValue(), &rc);
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("'"), &rc);
- break;
- case Subscription:
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If subscription is '"), &rc);
- DrawNextRulePart(lpdis->hDC, clLine1, pRule->GetValue(), &rc);
- DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("'"), &rc);
- break;
+ case Group:
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If group is '"), &rc);
+ DrawNextRulePart(lpdis->hDC, clLine1, pRule->GetValue(), &rc);
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("'"), &rc);
+ break;
+
+ case Subscription:
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("If subscription is '"), &rc);
+ DrawNextRulePart(lpdis->hDC, clLine1, pRule->GetValue(), &rc);
+ DrawNextRulePart(lpdis->hDC, clLine2, TranslateT("'"), &rc);
+ break;
}
rc = lpdis->rcItem;
@@ -1222,15 +1189,12 @@ void CJabberDlgPrivacyLists::DrawRulesList(LPDRAWITEMSTRUCT lpdis) DrawIconEx(lpdis->hDC, lpdis->rcItem.left+4, (lpdis->rcItem.top+lpdis->rcItem.bottom-16)/2,
m_proto->LoadIconEx("main"), 16, 16, 0, NULL, DI_NORMAL);
- if (pRule)
- {
+ if (pRule)
DrawIconEx(lpdis->hDC, lpdis->rcItem.left+4, (lpdis->rcItem.top+lpdis->rcItem.bottom-16)/2,
m_proto->LoadIconEx(pRule->GetAction() ? "disco_ok" : "disco_fail"),
16, 16, 0, NULL, DI_NORMAL);
- }
- if (lpdis->itemState & ODS_FOCUS)
- {
+ if (lpdis->itemState & ODS_FOCUS) {
LRESULT sel = SendDlgItemMessage(m_hwnd, lpdis->CtlID, LB_GETCURSEL, 0, 0);
if ((sel == LB_ERR) || (sel == (LRESULT)lpdis->itemID))
DrawFocusRect(lpdis->hDC, &lpdis->rcItem);
@@ -1245,13 +1209,12 @@ void CJabberDlgPrivacyLists::DrawLists(LPDRAWITEMSTRUCT lpdis) CPrivacyList *pList = (CPrivacyList *)lpdis->itemData;
COLORREF clLine1, clLine2, clBack;
- if (lpdis->itemState & ODS_SELECTED)
- {
+ if (lpdis->itemState & ODS_SELECTED) {
FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
clBack = GetSysColor(COLOR_HIGHLIGHT);
clLine1 = GetSysColor(COLOR_HIGHLIGHTTEXT);
- } else
- {
+ }
+ else {
FillRect(lpdis->hDC, &lpdis->rcItem, GetSysColorBrush(COLOR_WINDOW));
clBack = GetSysColor(COLOR_WINDOW);
clLine1 = GetSysColor(COLOR_WINDOWTEXT);
@@ -1259,17 +1222,17 @@ void CJabberDlgPrivacyLists::DrawLists(LPDRAWITEMSTRUCT lpdis) clLine2 = RGB(
GetRValue(clLine1) * 0.66 + GetRValue(clBack) * 0.34,
GetGValue(clLine1) * 0.66 + GetGValue(clBack) * 0.34,
- GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34
- );
+ GetBValue(clLine1) * 0.66 + GetBValue(clBack) * 0.34);
SetBkMode(lpdis->hDC, TRANSPARENT);
- RECT rc;
- m_proto->m_privacyListManager.Lock();
- TCHAR *szDefault = NEWTSTR_ALLOCA(m_proto->m_privacyListManager.GetDefaultListName());
- TCHAR *szActive = NEWTSTR_ALLOCA(m_proto->m_privacyListManager.GetActiveListName());
- m_proto->m_privacyListManager.Unlock();
+ TCHAR *szDefault, *szActive;
+ { mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+ szDefault = NEWTSTR_ALLOCA(m_proto->m_privacyListManager.GetDefaultListName());
+ szActive = NEWTSTR_ALLOCA(m_proto->m_privacyListManager.GetActiveListName());
+ }
+ RECT rc;
rc = lpdis->rcItem;
rc.left +=3;
@@ -1277,21 +1240,19 @@ void CJabberDlgPrivacyLists::DrawLists(LPDRAWITEMSTRUCT lpdis) bool bDefault = false;
TCHAR *szName;
- if ( !pList)
- {
+ if ( !pList) {
if ( !szActive) bActive = true;
if ( !szDefault) bDefault = true;
szName = TranslateT("<none>");
- } else
- {
+ }
+ else {
if ( !lstrcmp(pList->GetListName(), szActive)) bActive = true;
if ( !lstrcmp(pList->GetListName(), szDefault)) bDefault = true;
szName = pList->GetListName();
}
HFONT hfnt = NULL;
- if (bActive)
- {
+ if (bActive) {
LOGFONT lf;
GetObject(GetCurrentObject(lpdis->hDC, OBJ_FONT), sizeof(lf), &lf);
lf.lfWeight = FW_BOLD;
@@ -1319,8 +1280,7 @@ void CJabberDlgPrivacyLists::DrawLists(LPDRAWITEMSTRUCT lpdis) if (hfnt)
DeleteObject(SelectObject(lpdis->hDC, hfnt));
- if (lpdis->itemState & ODS_FOCUS)
- {
+ if (lpdis->itemState & ODS_FOCUS) {
int sel = SendDlgItemMessage(m_hwnd, lpdis->CtlID, LB_GETCURSEL, 0, 0);
if ((sel == LB_ERR) || (sel == (int)lpdis->itemID))
DrawFocusRect(lpdis->hDC, &lpdis->rcItem);
@@ -1364,25 +1324,19 @@ void CJabberDlgPrivacyLists::CListSetupIcons(HWND, HANDLE hItem, int iSlot, DWOR HANDLE CJabberDlgPrivacyLists::CListAddContact(HWND hwndList, TCHAR *jid)
{
- HANDLE hItem = 0;
-
HANDLE hContact = m_proto->HContactFromJID(jid);
- if ( !hContact) {
- hItem = clc_info.findJid(jid);
- if ( !hItem)
- {
- CLCINFOITEM cii = {0};
- cii.cbSize = sizeof(cii);
- cii.pszText = jid;
- hItem = m_clcClist.AddInfoItem(&cii);
- CListResetIcons(hwndList, hItem);
- clc_info.addJid(hItem, jid);
- }
- } else
- {
- hItem = m_clcClist.FindContact(hContact);
+ if (hContact)
+ return m_clcClist.FindContact(hContact);
+
+ HANDLE hItem = clc_info.findJid(jid);
+ if ( !hItem) {
+ CLCINFOITEM cii = {0};
+ cii.cbSize = sizeof(cii);
+ cii.pszText = jid;
+ hItem = m_clcClist.AddInfoItem(&cii);
+ CListResetIcons(hwndList, hItem);
+ clc_info.addJid(hItem, jid);
}
-
return hItem;
}
@@ -1417,39 +1371,31 @@ void CJabberDlgPrivacyLists::CListApplyList(HWND hwndList, CPrivacyList *pList) if ( !pList)
goto lbl_return;
- CPrivacyListRule *pRule;
- for (pRule = pList->GetFirstRule(); pRule; pRule = pRule->GetNext())
- {
+ for (CPrivacyListRule *pRule = pList->GetFirstRule(); pRule; pRule = pRule->GetNext()) {
HANDLE hItem = 0;
- switch (pRule->GetType())
- {
- case Jid:
- {
- hItem = CListAddContact(hwndList, pRule->GetValue());
- break;
- }
- case Group:
- {
- HANDLE hGroup = Clist_GroupExists(pRule->GetValue());
- hItem = m_clcClist.FindGroup(hGroup);
- break;
- }
- case Subscription:
- {
- if ( !lstrcmp(pRule->GetValue(), _T("none"))) hItem = clc_info.hItemSubNone;
- else if ( !lstrcmp(pRule->GetValue(), _T("from"))) hItem = clc_info.hItemSubFrom;
- else if ( !lstrcmp(pRule->GetValue(), _T("to"))) hItem = clc_info.hItemSubTo;
- else if ( !lstrcmp(pRule->GetValue(), _T("both"))) hItem = clc_info.hItemSubBoth;
- break;
- }
- case Else:
- {
- hItem = clc_info.hItemDefault;
- break;
- }
+ switch (pRule->GetType()) {
+ case Jid:
+ hItem = CListAddContact(hwndList, pRule->GetValue());
+ break;
+
+ case Group:
+ hItem = m_clcClist.FindGroup( Clist_GroupExists(pRule->GetValue()));
+ break;
+
+ case Subscription:
+ if ( !lstrcmp(pRule->GetValue(), _T("none"))) hItem = clc_info.hItemSubNone;
+ else if ( !lstrcmp(pRule->GetValue(), _T("from"))) hItem = clc_info.hItemSubFrom;
+ else if ( !lstrcmp(pRule->GetValue(), _T("to"))) hItem = clc_info.hItemSubTo;
+ else if ( !lstrcmp(pRule->GetValue(), _T("both"))) hItem = clc_info.hItemSubBoth;
+ break;
+
+ case Else:
+ hItem = clc_info.hItemDefault;
+ break;
}
- if ( !hItem) continue;
+ if (!hItem)
+ continue;
DWORD dwPackets = pRule->GetPackets();
if ( !dwPackets) dwPackets = JABBER_PL_RULE_TYPE_ALL;
@@ -1467,9 +1413,7 @@ DWORD CJabberDlgPrivacyLists::CListGetPackets(HWND, HANDLE hItem, bool bAction) {
DWORD result = 0;
- int iIcon = 0;
-
- iIcon = m_clcClist.GetExtraImage(hItem, 0);
+ int iIcon = m_clcClist.GetExtraImage(hItem, 0);
if (bAction && (iIcon == 1)) result |= JABBER_PL_RULE_TYPE_MESSAGE;
else if ( !bAction && (iIcon == 2)) result |= JABBER_PL_RULE_TYPE_MESSAGE;
@@ -1490,9 +1434,8 @@ DWORD CJabberDlgPrivacyLists::CListGetPackets(HWND, HANDLE hItem, bool bAction) void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList)
{
- if ( !pList) return;
-
- if ( !clc_info.bChanged) return;
+ if (!pList || !clc_info.bChanged)
+ return;
clc_info.bChanged = false;
@@ -1583,10 +1526,11 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList) void CJabberDlgPrivacyLists::EnableEditorControls()
{
- m_proto->m_privacyListManager.Lock();
- BOOL bListsLoaded = m_proto->m_privacyListManager.IsAllListsLoaded();
- BOOL bListsModified = m_proto->m_privacyListManager.IsModified() || clc_info.bChanged;
- m_proto->m_privacyListManager.Unlock();
+ BOOL bListsLoaded, bListsModified;
+ { mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+ bListsLoaded = m_proto->m_privacyListManager.IsAllListsLoaded();
+ bListsModified = m_proto->m_privacyListManager.IsModified() || clc_info.bChanged;
+ }
int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
int nItemCount = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0);
@@ -1654,9 +1598,10 @@ LRESULT CALLBACK CJabberDlgPrivacyLists::LstRulesSubclassProc(HWND hwnd, UINT ms BOOL CJabberDlgPrivacyLists::CanExit()
{
- m_proto->m_privacyListManager.Lock();
- BOOL bModified = m_proto->m_privacyListManager.IsModified();
- m_proto->m_privacyListManager.Unlock();
+ BOOL bModified;
+ { mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+ bModified = m_proto->m_privacyListManager.IsModified();
+ }
if (clc_info.bChanged)
bModified = TRUE;
@@ -1700,55 +1645,55 @@ void CJabberDlgPrivacyLists::btnAddJid_OnClick(CCtrlButton *) void CJabberDlgPrivacyLists::btnActivate_OnClick(CCtrlButton *)
{
- if (m_proto->m_bJabberOnline)
- {
- m_proto->m_privacyListManager.Lock();
- CPrivacyList* pList = GetSelectedList(m_hwnd);
- if (pList && pList->IsModified()) {
- m_proto->m_privacyListManager.Unlock();
- MessageBox(m_hwnd, TranslateT("Please save list before activating"), TranslateT("First, save the list"), MB_OK | MB_ICONSTOP);
- return;
- }
- EnableWindow(GetDlgItem(m_hwnd, IDC_ACTIVATE), FALSE);
- SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ACTIVATE), GWLP_USERDATA, (LONG_PTR)pList);
- XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList));
- HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
- HXML active = query << XCHILD(_T("active"));
- if (pList)
- active << XATTR(_T("name"), pList->GetListName());
- m_proto->m_privacyListManager.Unlock();
-
- SetStatusText(TranslateT(JABBER_PL_BUSY_MSG));
+ if (!m_proto->m_bJabberOnline)
+ return;
- m_proto->m_ThreadInfo->send(iq);
+ mir_cslockfull lck(m_proto->m_privacyListManager.m_cs);
+
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ if (pList && pList->IsModified()) {
+ lck.unlock();
+ MessageBox(m_hwnd, TranslateT("Please save list before activating"), TranslateT("First, save the list"), MB_OK | MB_ICONSTOP);
+ return;
}
+ EnableWindow(GetDlgItem(m_hwnd, IDC_ACTIVATE), FALSE);
+ SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_ACTIVATE), GWLP_USERDATA, (LONG_PTR)pList);
+ XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListActive, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList));
+ HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
+ HXML active = query << XCHILD(_T("active"));
+ if (pList)
+ active << XATTR(_T("name"), pList->GetListName());
+
+ lck.unlock();
+ SetStatusText(TranslateT(JABBER_PL_BUSY_MSG));
+ m_proto->m_ThreadInfo->send(iq);
}
void CJabberDlgPrivacyLists::btnSetDefault_OnClick(CCtrlButton *)
{
- if (m_proto->m_bJabberOnline)
- {
- m_proto->m_privacyListManager.Lock();
- CPrivacyList* pList = GetSelectedList(m_hwnd);
- if (pList && pList->IsModified()) {
- m_proto->m_privacyListManager.Unlock();
- MessageBox(m_hwnd, TranslateT("Please save list before you make it the default list"), TranslateT("First, save the list"), MB_OK | MB_ICONSTOP);
- return;
- }
- EnableWindow(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), FALSE);
- SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), GWLP_USERDATA, (LONG_PTR)pList);
-
- XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListDefault, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList));
- HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
- HXML defaultTag = query << XCHILD(_T("default"));
- if (pList)
- xmlAddAttr(defaultTag, _T("name"), pList->GetListName());
- m_proto->m_privacyListManager.Unlock();
+ if (!m_proto->m_bJabberOnline)
+ return;
- SetStatusText(TranslateT(JABBER_PL_BUSY_MSG));
+ mir_cslockfull lck(m_proto->m_privacyListManager.m_cs);
- m_proto->m_ThreadInfo->send(iq);
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ if (pList && pList->IsModified()) {
+ lck.unlock();
+ MessageBox(m_hwnd, TranslateT("Please save list before you make it the default list"), TranslateT("First, save the list"), MB_OK | MB_ICONSTOP);
+ return;
}
+ EnableWindow(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), FALSE);
+ SetWindowLongPtr(GetDlgItem(m_hwnd, IDC_SET_DEFAULT), GWLP_USERDATA, (LONG_PTR)pList);
+
+ XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultPrivacyListDefault, JABBER_IQ_TYPE_SET, NULL, 0, -1, pList));
+ HXML query = iq << XQUERY(JABBER_FEAT_PRIVACY_LISTS);
+ HXML defaultTag = query << XCHILD(_T("default"));
+ if (pList)
+ xmlAddAttr(defaultTag, _T("name"), pList->GetListName());
+
+ lck.unlock();
+ SetStatusText(TranslateT(JABBER_PL_BUSY_MSG));
+ m_proto->m_ThreadInfo->send(iq);
}
void CJabberDlgPrivacyLists::lbLists_OnSelChange(CCtrlListBox *)
@@ -1760,14 +1705,12 @@ void CJabberDlgPrivacyLists::lbLists_OnSelChange(CCtrlListBox *) LRESULT nErr = SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_GETITEMDATA, nCurSel, 0);
if (nErr == LB_ERR)
return;
- if (nErr == 0)
- {
- if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CLIST)))
- {
+ if (nErr == 0) {
+ if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CLIST))) {
CListBuildList(GetDlgItem(m_hwnd, IDC_CLIST), clc_info.pList);
CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST), NULL);
- } else
- {
+ }
+ else {
EnableWindow(GetDlgItem(m_hwnd, IDC_PL_RULES_LIST), FALSE);
SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_RESETCONTENT, 0, 0);
SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_ADDSTRING, 0, (LPARAM)TranslateTS(_T("No list selected")));
@@ -1775,141 +1718,132 @@ void CJabberDlgPrivacyLists::lbLists_OnSelChange(CCtrlListBox *) EnableEditorControls();
return;
}
-
- m_proto->m_privacyListManager.Lock();
- if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CLIST)))
{
- CListBuildList(GetDlgItem(m_hwnd, IDC_CLIST), clc_info.pList);
- CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST), (CPrivacyList*)nErr);
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+ if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CLIST))) {
+ CListBuildList(GetDlgItem(m_hwnd, IDC_CLIST), clc_info.pList);
+ CListApplyList(GetDlgItem(m_hwnd, IDC_CLIST), (CPrivacyList*)nErr);
+ }
+ else ShowAdvancedList((CPrivacyList*)nErr);
}
- else ShowAdvancedList((CPrivacyList*)nErr);
-
- m_proto->m_privacyListManager.Unlock();
-
EnableEditorControls();
}
-void CJabberDlgPrivacyLists::lbLists_OnDblClick(CCtrlListBox *)
+void CJabberDlgPrivacyLists::lbLists_OnDblClick(CCtrlListBox*)
{
PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_ACTIVATE, 0), 0);
}
-void CJabberDlgPrivacyLists::lbRules_OnSelChange(CCtrlListBox *)
+void CJabberDlgPrivacyLists::lbRules_OnSelChange(CCtrlListBox*)
{
EnableEditorControls();
}
-void CJabberDlgPrivacyLists::lbRules_OnDblClick(CCtrlListBox *)
+void CJabberDlgPrivacyLists::lbRules_OnDblClick(CCtrlListBox*)
{
PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_EDIT_RULE, 0), 0);
}
-void CJabberDlgPrivacyLists::btnEditRule_OnClick(CCtrlButton *)
+void CJabberDlgPrivacyLists::btnEditRule_OnClick(CCtrlButton*)
{
// FIXME: potential deadlock due to PLM lock while editing rule
- m_proto->m_privacyListManager.Lock();
- {
- CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
- CPrivacyList* pList = GetSelectedList(m_hwnd);
- if (pList && pRule) {
- CJabberDlgPrivacyRule dlgPrivacyRule(m_proto, m_hwnd, pRule);
- int nResult = dlgPrivacyRule.DoModal();
- if (nResult) {
- pList->SetModified();
- PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
- } } }
- m_proto->m_privacyListManager.Unlock();
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+
+ CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ if (pList && pRule) {
+ CJabberDlgPrivacyRule dlgPrivacyRule(m_proto, m_hwnd, pRule);
+ int nResult = dlgPrivacyRule.DoModal();
+ if (nResult) {
+ pList->SetModified();
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
+ }
+ }
}
-void CJabberDlgPrivacyLists::btnAddRule_OnClick(CCtrlButton *)
+void CJabberDlgPrivacyLists::btnAddRule_OnClick(CCtrlButton*)
{
// FIXME: potential deadlock due to PLM lock while editing rule
- m_proto->m_privacyListManager.Lock();
- {
- CPrivacyList* pList = GetSelectedList(m_hwnd);
- if (pList) {
- CPrivacyListRule* pRule = new CPrivacyListRule(m_proto, Jid, _T(""), FALSE);
- CJabberDlgPrivacyRule dlgPrivacyRule(m_proto, m_hwnd, pRule);
- int nResult = dlgPrivacyRule.DoModal();
- if (nResult) {
- pList->AddRule(pRule);
- pList->Reorder();
- pList->SetModified();
- PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
- }
- else delete pRule;
- } }
- m_proto->m_privacyListManager.Unlock();
-}
-
-void CJabberDlgPrivacyLists::btnRemoveRule_OnClick(CCtrlButton *)
-{
- m_proto->m_privacyListManager.Lock();
- {
- CPrivacyList* pList = GetSelectedList(m_hwnd);
- CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
-
- if (pList && pRule) {
- pList->RemoveRule(pRule);
- int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
- int nItemCount = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0);
- SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel != nItemCount - 1 ? nCurSel : nCurSel - 1, 0);
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ if (pList) {
+ CPrivacyListRule* pRule = new CPrivacyListRule(m_proto, Jid, _T(""), FALSE);
+ CJabberDlgPrivacyRule dlgPrivacyRule(m_proto, m_hwnd, pRule);
+ int nResult = dlgPrivacyRule.DoModal();
+ if (nResult) {
+ pList->AddRule(pRule);
pList->Reorder();
pList->SetModified();
PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
- } }
-
- m_proto->m_privacyListManager.Unlock();
+ }
+ else delete pRule;
+ }
}
-void CJabberDlgPrivacyLists::btnUpRule_OnClick(CCtrlButton *)
+void CJabberDlgPrivacyLists::btnRemoveRule_OnClick(CCtrlButton*)
{
- m_proto->m_privacyListManager.Lock();
- {
- CPrivacyList* pList = GetSelectedList(m_hwnd);
- CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
+
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
+
+ if (pList && pRule) {
+ pList->RemoveRule(pRule);
int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
+ int nItemCount = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel != nItemCount - 1 ? nCurSel : nCurSel - 1, 0);
+ pList->Reorder();
+ pList->SetModified();
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
+ }
+}
- if (pList && pRule && nCurSel) {
- pRule->SetOrder(pRule->GetOrder() - 11);
- SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel - 1, 0);
- pList->Reorder();
- pList->SetModified();
- PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
- } }
+void CJabberDlgPrivacyLists::btnUpRule_OnClick(CCtrlButton*)
+{
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- m_proto->m_privacyListManager.Unlock();
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
+ int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
+
+ if (pList && pRule && nCurSel) {
+ pRule->SetOrder(pRule->GetOrder() - 11);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel - 1, 0);
+ pList->Reorder();
+ pList->SetModified();
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
+ }
}
-void CJabberDlgPrivacyLists::btnDownRule_OnClick(CCtrlButton *)
+void CJabberDlgPrivacyLists::btnDownRule_OnClick(CCtrlButton*)
{
- m_proto->m_privacyListManager.Lock();
- {
- CPrivacyList* pList = GetSelectedList(m_hwnd);
- CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
- int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
- int nItemCount = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0);
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
- if (pList && pRule && (nCurSel != (nItemCount - 1))) {
- pRule->SetOrder(pRule->GetOrder() + 11);
- SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel + 1, 0);
- pList->Reorder();
- pList->SetModified();
- PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
- } }
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ CPrivacyListRule* pRule = GetSelectedRule(m_hwnd);
+ int nCurSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0);
+ int nItemCount = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCOUNT, 0, 0);
- m_proto->m_privacyListManager.Unlock();
+ if (pList && pRule && (nCurSel != (nItemCount - 1))) {
+ pRule->SetOrder(pRule->GetOrder() + 11);
+ SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_SETCURSEL, nCurSel + 1, 0);
+ pList->Reorder();
+ pList->SetModified();
+ PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
+ }
}
-void CJabberDlgPrivacyLists::btnAddList_OnClick(CCtrlButton *)
+void CJabberDlgPrivacyLists::btnAddList_OnClick(CCtrlButton*)
{
// FIXME: line length is hard coded in dialog procedure
CJabberDlgPrivacyAddList dlgPrivacyAddList(m_proto, m_hwnd);
int nRetVal = dlgPrivacyAddList.DoModal();
if (nRetVal && _tcslen(dlgPrivacyAddList.szLine)) {
- m_proto->m_privacyListManager.Lock();
- CPrivacyList* pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine);
- if ( !pList) {
+ mir_cslockfull lck(m_proto->m_privacyListManager.m_cs);
+
+ CPrivacyList *pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine);
+ if (pList == NULL) {
m_proto->m_privacyListManager.AddList(dlgPrivacyAddList.szLine);
pList = m_proto->m_privacyListManager.FindList(dlgPrivacyAddList.szLine);
if (pList) {
@@ -1925,29 +1859,31 @@ void CJabberDlgPrivacyLists::btnAddList_OnClick(CCtrlButton *) SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETITEMDATA, nSelected, (LPARAM)pList);
SendDlgItemMessage(m_hwnd, IDC_LB_LISTS, LB_SETCURSEL, nSelected, 0);
}
- m_proto->m_privacyListManager.Unlock();
+
+ lck.unlock();
PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
}
}
void CJabberDlgPrivacyLists::btnRemoveList_OnClick(CCtrlButton *)
{
- m_proto->m_privacyListManager.Lock();
- {
- CPrivacyList* pList = GetSelectedList(m_hwnd);
- if (pList) {
- TCHAR *szListName = pList->GetListName();
- if ((m_proto->m_privacyListManager.GetActiveListName() && !_tcscmp(szListName, m_proto->m_privacyListManager.GetActiveListName()))
- || (m_proto->m_privacyListManager.GetDefaultListName() && !_tcscmp(szListName, m_proto->m_privacyListManager.GetDefaultListName()))) {
- m_proto->m_privacyListManager.Unlock();
- MessageBox(m_hwnd, TranslateTS(_T("Can't remove active or default list")), TranslateTS(_T("Sorry")), MB_OK | MB_ICONSTOP);
- return;
- }
- pList->SetDeleted();
- pList->SetModified();
- } }
+ mir_cslockfull lck(m_proto->m_privacyListManager.m_cs);
+
+ CPrivacyList *pList = GetSelectedList(m_hwnd);
+ if (pList) {
+ TCHAR *szListName = pList->GetListName();
+ if ((m_proto->m_privacyListManager.GetActiveListName() && !_tcscmp(szListName, m_proto->m_privacyListManager.GetActiveListName())) ||
+ (m_proto->m_privacyListManager.GetDefaultListName() && !_tcscmp(szListName, m_proto->m_privacyListManager.GetDefaultListName())))
+ {
+ lck.unlock();
+ MessageBox(m_hwnd, TranslateTS(_T("Can't remove active or default list")), TranslateTS(_T("Sorry")), MB_OK | MB_ICONSTOP);
+ return;
+ }
+ pList->SetDeleted();
+ pList->SetModified();
+ }
- m_proto->m_privacyListManager.Unlock();
+ lck.unlock();
PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
}
@@ -1958,13 +1894,13 @@ void CJabberDlgPrivacyLists::btnApply_OnClick(CCtrlButton *) return;
}
- m_proto->m_privacyListManager.Lock();
{
+ mir_cslock lck(m_proto->m_privacyListManager.m_cs);
if (IsWindowVisible(GetDlgItem(m_hwnd, IDC_CLIST)))
CListBuildList(GetDlgItem(m_hwnd, IDC_CLIST), clc_info.pList);
CPrivacyListModifyUserParam *pUserData = NULL;
- CPrivacyList* pList = m_proto->m_privacyListManager.GetFirstList();
+ CPrivacyList *pList = m_proto->m_privacyListManager.GetFirstList();
while (pList) {
if (pList->IsModified()) {
CPrivacyListRule* pRule = pList->GetFirstRule();
@@ -2023,8 +1959,8 @@ void CJabberDlgPrivacyLists::btnApply_OnClick(CCtrlButton *) }
pList = pList->GetNext();
} }
- m_proto->m_privacyListManager.Unlock();
- SetStatusText(TranslateT(JABBER_PL_BUSY_MSG));
+
+ SetStatusText( TranslateT(JABBER_PL_BUSY_MSG));
PostMessage(m_hwnd, WM_JABBER_REFRESH, 0, 0);
}
@@ -2051,16 +1987,15 @@ void CJabberDlgPrivacyLists::clcClist_OnOptionsChanged(CCtrlClc::TEventInfo*) void CJabberDlgPrivacyLists::clcClist_OnClick(CCtrlClc::TEventInfo *evt)
{
- HANDLE hItem;
- DWORD hitFlags;
- int iImage;
+ if (evt->info->iColumn == -1)
+ return;
- if (evt->info->iColumn==-1) return;
- hItem = m_clcClist.HitTest(evt->info->pt.x, evt->info->pt.y, &hitFlags);
- if (hItem == NULL) return;
- if ( !(hitFlags&CLCHT_ONITEMEXTRA)) return;
+ DWORD hitFlags;
+ HANDLE hItem = m_clcClist.HitTest(evt->info->pt.x, evt->info->pt.y, &hitFlags);
+ if (hItem == NULL || !(hitFlags & CLCHT_ONITEMEXTRA))
+ return;
- iImage = m_clcClist.GetExtraImage(hItem, evt->info->iColumn);
+ int iImage = m_clcClist.GetExtraImage(hItem, evt->info->iColumn);
if (iImage != EMPTY_EXTRA_ICON) {
if (iImage == 0)
iImage = evt->info->iColumn * 2 + 2;
@@ -2133,11 +2068,9 @@ void CJabberProto::QueryPrivacyLists(ThreadData *pThreadInfo) INT_PTR __cdecl CJabberProto::menuSetPrivacyList(WPARAM, LPARAM, LPARAM iList)
{
- m_privacyListManager.Lock();
+ mir_cslockfull lck(m_privacyListManager.m_cs);
CPrivacyList *pList = NULL;
-
- if (iList)
- {
+ if (iList) {
pList = m_privacyListManager.GetFirstList();
for (int i = 1; pList && (i < iList); i++)
pList = pList->GetNext();
@@ -2148,7 +2081,7 @@ INT_PTR __cdecl CJabberProto::menuSetPrivacyList(WPARAM, LPARAM, LPARAM iList) HXML active = query << XCHILD(_T("active"));
if (pList)
active << XATTR(_T("name"), pList->GetListName());
- m_privacyListManager.Unlock();
+ lck.unlock();
m_ThreadInfo->send(iq);
return 0;
@@ -2182,15 +2115,13 @@ void CJabberProto::BuildPrivacyMenu() void CJabberProto::BuildPrivacyListsMenu(bool bDeleteOld)
{
- int i;
if (bDeleteOld)
- for (i=0; i < m_hPrivacyMenuItems.getCount(); i++)
+ for (int i=0; i < m_hPrivacyMenuItems.getCount(); i++)
CallService(MO_REMOVEMENUITEM, (WPARAM)m_hPrivacyMenuItems[i], 0);
m_hPrivacyMenuItems.destroy();
- m_privacyListManager.Lock();
+ mir_cslock lck(m_privacyListManager.m_cs);
- i = 0;
char srvFce[MAX_PATH + 64], *svcName = srvFce+strlen(m_szModuleName);
CLISTMENUITEM mi = { sizeof(mi) };
@@ -2199,16 +2130,14 @@ void CJabberProto::BuildPrivacyListsMenu(bool bDeleteOld) mi.hParentMenu = m_hPrivacyMenuRoot;
mi.pszService = srvFce;
+ int i=0;
mir_snprintf(srvFce, SIZEOF(srvFce), "%s/menuPrivacy%d", m_szModuleName, i);
if (i > m_privacyMenuServiceAllocated) {
CreateProtoServiceParam(svcName, &CJabberProto::menuSetPrivacyList, i);
m_privacyMenuServiceAllocated = i;
}
mi.position++;
- mi.icolibItem = LoadSkinnedIconHandle(
- m_privacyListManager.GetActiveListName() ?
- SKINICON_OTHER_SMALLDOT :
- SKINICON_OTHER_EMPTYBLOB);
+ mi.icolibItem = LoadSkinnedIconHandle(m_privacyListManager.GetActiveListName() ? SKINICON_OTHER_SMALLDOT : SKINICON_OTHER_EMPTYBLOB);
mi.ptszName = LPGENT("<none>");
m_hPrivacyMenuItems.insert(Menu_AddProtoMenuItem(&mi));
@@ -2229,6 +2158,4 @@ void CJabberProto::BuildPrivacyListsMenu(bool bDeleteOld) mi.ptszName = pList->GetListName();
m_hPrivacyMenuItems.insert(Menu_AddProtoMenuItem(&mi));
}
-
- m_privacyListManager.Unlock();
}
|