diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-11 15:07:50 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-11 15:07:50 +0000 |
commit | 764b106951b4c47cef929d17ca99e8f4a8165483 (patch) | |
tree | d1606321274760672db3e47d084586a55ce6b983 /protocols/JabberG | |
parent | fabb5ec61205a9a3dca6f82645f257d00a534572 (diff) |
Jabber not to eat the trailing symbol in chat's topic
git-svn-id: http://svn.miranda-ng.org/main/trunk@7592 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG')
-rw-r--r-- | protocols/JabberG/src/jabber_disco.cpp | 6 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_form.cpp | 3 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_ft.cpp | 3 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_ibb.cpp | 8 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iqid_muc.cpp | 16 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_message_handlers.cpp | 11 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_misc.cpp | 3 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_notes.cpp | 204 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_opt.cpp | 20 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_opttree.cpp | 154 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_secur.cpp | 56 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_thread.cpp | 3 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_treelist.cpp | 37 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_util.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_xml.cpp | 103 |
15 files changed, 257 insertions, 372 deletions
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp index 37dbbdb54a..9b0ad50aad 100644 --- a/protocols/JabberG/src/jabber_disco.cpp +++ b/protocols/JabberG/src/jabber_disco.cpp @@ -498,7 +498,8 @@ void CJabberProto::ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode) iOverlay = SD_OVERLAY_REGISTERED;
else
iOverlay = SD_OVERLAY_NONE;
- } else if (pNode->GetInfoRequestId() == JABBER_DISCO_RESULT_OK) {
+ }
+ else if (pNode->GetInfoRequestId() == JABBER_DISCO_RESULT_OK) {
if (IsNodeRegistered(pNode))
iOverlay = SD_OVERLAY_REGISTERED;
else if (pNode->GetInfoRequestId() == JABBER_DISCO_RESULT_ERROR)
@@ -640,7 +641,8 @@ void CJabberDlgDiscovery::OnInitDialog() SetDlgItemText(m_hwnd, IDC_COMBO_JID, m_jid);
SetDlgItemText(m_hwnd, IDC_COMBO_NODE, _T(""));
m_focusEditAfterBrowse = false;
- } else {
+ }
+ else {
SetDlgItemTextA(m_hwnd, IDC_COMBO_JID, m_proto->m_ThreadInfo->server);
SetDlgItemText(m_hwnd, IDC_COMBO_NODE, _T(""));
m_focusEditAfterBrowse = true;
diff --git a/protocols/JabberG/src/jabber_form.cpp b/protocols/JabberG/src/jabber_form.cpp index 90d06a099a..d3d5d58d4e 100644 --- a/protocols/JabberG/src/jabber_form.cpp +++ b/protocols/JabberG/src/jabber_form.cpp @@ -157,7 +157,8 @@ void JabberFormSetInstruction(HWND hwndForm, const TCHAR *text) HWND hwndEdit = GetDlgItem(hwndForm, IDC_INSTRUCTION);
SetWindowLongPtr(hwndEdit, GWL_STYLE, WS_VSCROLL | GetWindowLongPtr(hwndEdit, GWL_STYLE));
rcText.bottom = rcText.top + (rcWindow.bottom-rcWindow.top)/5;
- } else {
+ }
+ else {
HWND hwndEdit = GetDlgItem(hwndForm, IDC_INSTRUCTION);
SetWindowLongPtr(hwndEdit, GWL_STYLE, ~WS_VSCROLL & GetWindowLongPtr(hwndEdit, GWL_STYLE));
}
diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index 4fe4904462..2d34b62a5b 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -153,7 +153,8 @@ void CJabberProto::OnFtSiResult(HXML iqNode, CJabberIqInfo *pInfo) ft->type = FT_BYTESTREAM;
ft->jbt = jbt;
ForkThread((MyThreadFunc)&CJabberProto::ByteSendThread, jbt);
- } else if (!_tcscmp(xmlGetText(valueNode), JABBER_FEAT_IBB)) {
+ }
+ else if (!_tcscmp(xmlGetText(valueNode), JABBER_FEAT_IBB)) {
JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *) mir_alloc(sizeof (JABBER_IBB_TRANSFER));
ZeroMemory(jibb, sizeof(JABBER_IBB_TRANSFER));
jibb->srcJID = mir_tstrdup(pInfo->m_szTo);
diff --git a/protocols/JabberG/src/jabber_ibb.cpp b/protocols/JabberG/src/jabber_ibb.cpp index 54f936aab2..c4d4f4e752 100644 --- a/protocols/JabberG/src/jabber_ibb.cpp +++ b/protocols/JabberG/src/jabber_ibb.cpp @@ -105,13 +105,11 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb) jibb->hEvent = NULL;
if (jibb->bStreamInitialized) {
-
jibb->wPacketId = 0;
BOOL bSent = (this->*jibb->pfnSend)(JABBER_IBB_BLOCK_SIZE, jibb->ft);
- if (!jibb->bStreamClosed)
- {
+ if (!jibb->bStreamClosed) {
jibb->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
m_ThreadInfo->send(
@@ -124,10 +122,8 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb) if (jibb->bStreamClosed && bSent)
jibb->state = JIBB_DONE;
-
- } else {
- jibb->state = JIBB_ERROR;
}
+ else jibb->state = JIBB_ERROR;
}
(this->*jibb->pfnFinal)((jibb->state==JIBB_DONE)?TRUE:FALSE, jibb->ft);
diff --git a/protocols/JabberG/src/jabber_iqid_muc.cpp b/protocols/JabberG/src/jabber_iqid_muc.cpp index 30c0fadc52..42d460c578 100644 --- a/protocols/JabberG/src/jabber_iqid_muc.cpp +++ b/protocols/JabberG/src/jabber_iqid_muc.cpp @@ -365,24 +365,16 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc(HWND hwndDlg, UINT msg, WPARAM w {
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_FILTER), GWLP_USERDATA, 1);
sttFillJidList(hwndDlg);
- } else
- if ((LOWORD(wParam) == IDC_BTN_FILTERRESET) ||
+ }
+ else if ((LOWORD(wParam) == IDC_BTN_FILTERRESET) ||
((LOWORD(wParam) == IDCANCEL) && (GetFocus() == GetDlgItem(hwndDlg, IDC_FILTER))))
{
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_FILTER), GWLP_USERDATA, 0);
sttFillJidList(hwndDlg);
}
break;
-/* case WM_SETCURSOR:
- if (LOWORD(LPARAM)!= HTCLIENT) break;
- if (GetForegroundWindow() == GetParent(hwndDlg)) {
- POINT pt;
- GetCursorPos(&pt);
- ScreenToClient(hwndDlg,&pt);
- SetFocus(ChildWindowFromPoint(hwndDlg,pt)); //ugly hack because listviews ignore their first click
- }
- break;
-*/ case WM_CLOSE:
+
+ case WM_CLOSE:
{
HWND hwndList;
int count, i;
diff --git a/protocols/JabberG/src/jabber_message_handlers.cpp b/protocols/JabberG/src/jabber_message_handlers.cpp index 84ae11f28b..cda431a346 100644 --- a/protocols/JabberG/src/jabber_message_handlers.cpp +++ b/protocols/JabberG/src/jabber_message_handlers.cpp @@ -40,7 +40,8 @@ BOOL CJabberProto::OnMessageError(HXML node, ThreadData *pThreadData, CJabberMes char *errText = mir_t2a(szErrText);
ProtoBroadcastAck(pInfo->GetHContact(), ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)id, (LPARAM)errText);
mir_free(errText);
- } else {
+ }
+ else {
TCHAR buf[512];
HXML bodyNode = xmlGetChild(node, "body");
if (bodyNode)
@@ -75,11 +76,11 @@ BOOL CJabberProto::OnMessagePubsubEvent(HXML node, ThreadData *pThreadData, CJab BOOL CJabberProto::OnMessageGroupchat(HXML node, ThreadData *pThreadData, CJabberMessageInfo* pInfo)
{
JABBER_LIST_ITEM *chatItem = ListGetItemPtr(LIST_CHATROOM, pInfo->GetFrom());
- if (chatItem)
- { // process GC message
+ if (chatItem) // process GC message
GroupchatProcessMessage(node);
- } else
- { // got message from unknown conference... let's leave it :)
+
+ // got message from unknown conference... let's leave it :)
+ else {
// TCHAR *conference = NEWTSTR_ALLOCA(from);
// if (TCHAR *s = _tcschr(conference, _T('/'))) *s = 0;
// XmlNode p("presence"); xmlAddAttr(p, "to", conference); xmlAddAttr(p, "type", "unavailable");
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index ab035c8e3e..e649aad0bb 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -517,7 +517,8 @@ void CJabberProto::MsgPopup(HANDLE hContact, const TCHAR *szMsg, const TCHAR *sz mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Error");
CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&ppd);
- } else {
+ }
+ else {
DWORD mtype = MB_OK | MB_SETFOREGROUND | MB_ICONSTOP;
MessageBox(NULL, szMsg, szTitle, mtype);
}
diff --git a/protocols/JabberG/src/jabber_notes.cpp b/protocols/JabberG/src/jabber_notes.cpp index b6274917f3..33a183be41 100644 --- a/protocols/JabberG/src/jabber_notes.cpp +++ b/protocols/JabberG/src/jabber_notes.cpp @@ -38,8 +38,7 @@ static TCHAR *StrTrimCopy(TCHAR *str) if (!*str) return mir_tstrdup(str);
TCHAR *res = mir_tstrdup(str);
- for (TCHAR *p = res + lstrlen(res) - 1; p >= res; --p)
- {
+ for (TCHAR *p = res + lstrlen(res) - 1; p >= res; --p) {
if (_istspace(*p))
*p = 0;
else
@@ -51,21 +50,12 @@ static TCHAR *StrTrimCopy(TCHAR *str) CNoteItem::CNoteItem()
{
- m_szTitle =
- m_szFrom =
- m_szText =
- m_szTags =
- m_szTagsStr = NULL;
+ m_szTitle = m_szFrom = m_szText = m_szTags = m_szTagsStr = NULL;
}
CNoteItem::CNoteItem(HXML hXml, TCHAR *szFrom)
{
- m_szTitle =
- m_szFrom =
- m_szText =
- m_szTags =
- m_szTagsStr = NULL;
-
+ m_szTitle = m_szFrom = m_szText = m_szTags = m_szTagsStr = NULL;
SetData(
XPathT(hXml, "title"),
szFrom ? szFrom : XPathT(hXml, "@from"),
@@ -97,13 +87,11 @@ void CNoteItem::SetData(TCHAR *title, TCHAR *from, TCHAR *text, TCHAR *tags) const TCHAR *szTags = tags;
TCHAR *p = m_szTags = (TCHAR *)mir_alloc((lstrlen(szTags) + 2 /*for double zero*/) * sizeof(TCHAR));
TCHAR *q = m_szTagsStr = (TCHAR *)mir_alloc((lstrlen(szTags) + 1) * sizeof(TCHAR));
- for (; szTags && *szTags; ++szTags)
- {
+ for (; szTags && *szTags; ++szTags) {
if (_istspace(*szTags))
continue;
- if (*szTags == _T(','))
- {
+ if (*szTags == _T(',')) {
*q++ = _T(',');
*p++ = 0;
continue;
@@ -252,13 +240,12 @@ void CJabberDlgNoteItem::OnInitDialog() CSuper::OnInitDialog();
WindowSetIcon(m_hwnd, m_proto, "notes");
- if (m_fnProcess)
- {
- TCHAR buf[256];
+ if (m_fnProcess) {
+ CMString buf;
if (m_fnProcess == &CJabberProto::ProcessIncomingNote)
- mir_sntprintf(buf, SIZEOF(buf), TranslateT("Incoming note from %s"), m_pNote->GetFrom());
+ buf.Format(TranslateT("Incoming note from %s"), m_pNote->GetFrom());
else
- mir_sntprintf(buf, SIZEOF(buf), TranslateT("Send note to %s"), m_pNote->GetFrom());
+ buf.Format(TranslateT("Send note to %s"), m_pNote->GetFrom());
SetWindowText(m_hwnd, buf);
}
@@ -270,19 +257,18 @@ void CJabberDlgNoteItem::OnInitDialog() int CJabberDlgNoteItem::Resizer(UTILRESIZECONTROL *urc)
{
- switch (urc->wId)
- {
+ switch (urc->wId) {
case IDC_TXT_TITLE:
- return RD_ANCHORX_WIDTH|RD_ANCHORY_TOP;
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
case IDC_TXT_TEXT:
- return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT;
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
case IDC_ST_TAGS:
case IDC_TXT_TAGS:
- return RD_ANCHORX_WIDTH|RD_ANCHORY_BOTTOM;
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_BOTTOM;
case IDOK:
case IDCANCEL:
- return RD_ANCHORX_RIGHT|RD_ANCHORY_BOTTOM;
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
}
return CSuper::Resizer(urc);
@@ -302,18 +288,18 @@ public: void SetFonts(HFONT hfntNormal, HFONT hfntSmall, HFONT hfntBold)
{
m_hfntNormal = hfntNormal;
- m_hfntSmall = hfntSmall;
+ m_hfntSmall = hfntSmall;
m_hfntBold = hfntBold;
}
- int AddString(TCHAR *text, LPARAM data=0)
+ int AddString(TCHAR *text, LPARAM data = 0)
{
m_adding = true;
int idx = CCtrlListBox::AddString(text, data);
m_adding = false;
if (idx == LB_ERR) return idx;
- MEASUREITEMSTRUCT mis = {0};
+ MEASUREITEMSTRUCT mis = { 0 };
mis.CtlType = ODT_LISTBOX;
mis.CtlID = m_idCtrl;
mis.itemID = idx;
@@ -331,13 +317,11 @@ public: LRESULT CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
- if (msg == WM_SIZE)
- {
+ if (msg == WM_SIZE) {
SendMessage(m_hwnd, WM_SETREDRAW, FALSE, 0);
int cnt = GetCount();
- for (int idx = 0; idx < cnt; ++idx)
- {
- MEASUREITEMSTRUCT mis = {0};
+ for (int idx = 0; idx < cnt; ++idx) {
+ MEASUREITEMSTRUCT mis = { 0 };
mis.CtlType = ODT_LISTBOX;
mis.CtlID = m_idCtrl;
mis.itemID = idx;
@@ -362,19 +346,17 @@ public: CNoteItem *pNote = (CNoteItem *)lps->itemData;
SetBkMode(hdc, TRANSPARENT);
- if (lps->itemState & ODS_SELECTED)
- {
+ if (lps->itemState & ODS_SELECTED) {
FillRect(hdc, &lps->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT));
SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
- } else
- {
+ }
+ else {
FillRect(hdc, &lps->rcItem, GetSysColorBrush(COLOR_WINDOW));
SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
}
- if (lps->itemID)
- {
- RECT rcTmp = lps->rcItem; rcTmp.bottom = rcTmp.top+1;
+ if (lps->itemID) {
+ RECT rcTmp = lps->rcItem; rcTmp.bottom = rcTmp.top + 1;
FillRect(hdc, &rcTmp, GetSysColorBrush(COLOR_BTNSHADOW));
}
@@ -384,17 +366,16 @@ public: rc.top += 2;
SelectObject(hdc, m_hfntBold);
- rc.top += DrawText(hdc, pNote->GetTitle(), -1, &rc, DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS);
+ rc.top += DrawText(hdc, pNote->GetTitle(), -1, &rc, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
SelectObject(hdc, m_hfntNormal);
- if (pNote->GetFrom())
- {
+ if (pNote->GetFrom()) {
TCHAR buf[256];
mir_sntprintf(buf, SIZEOF(buf), TranslateT("From: %s"), pNote->GetFrom());
- rc.top += DrawText(hdc, buf, -1, &rc, DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS);
+ rc.top += DrawText(hdc, buf, -1, &rc, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
}
- rc.top += DrawText(hdc, pNote->GetText(), -1, &rc, DT_NOPREFIX|DT_WORDBREAK|DT_EXPANDTABS|DT_END_ELLIPSIS);
+ rc.top += DrawText(hdc, pNote->GetText(), -1, &rc, DT_NOPREFIX | DT_WORDBREAK | DT_EXPANDTABS | DT_END_ELLIPSIS);
SelectObject(hdc, m_hfntSmall);
- rc.top += DrawText(hdc, pNote->GetTagsStr(), -1, &rc, DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS);
+ rc.top += DrawText(hdc, pNote->GetTagsStr(), -1, &rc, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS);
rc.top += 5;
int h = min(255, max(0, rc.bottom - rc.top));
@@ -420,23 +401,22 @@ public: SelectObject(hdc, m_hfntBold);
rcTmp = rc;
- DrawText(hdc, pNote->GetTitle(), -1, &rcTmp, DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS|DT_CALCRECT);
+ DrawText(hdc, pNote->GetTitle(), -1, &rcTmp, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS | DT_CALCRECT);
lps->itemHeight += rcTmp.bottom;
SelectObject(hdc, m_hfntNormal);
- if (pNote->GetFrom())
- {
+ if (pNote->GetFrom()) {
TCHAR buf[256];
mir_sntprintf(buf, SIZEOF(buf), TranslateT("From: %s"), pNote->GetFrom());
rcTmp = rc;
- DrawText(hdc, buf, -1, &rcTmp, DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS|DT_CALCRECT);
+ DrawText(hdc, buf, -1, &rcTmp, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS | DT_CALCRECT);
lps->itemHeight += rcTmp.bottom;
}
rcTmp = rc;
- DrawText(hdc, pNote->GetText(), -1, &rcTmp, DT_NOPREFIX|DT_WORDBREAK|DT_EXPANDTABS|DT_END_ELLIPSIS|DT_CALCRECT);
+ DrawText(hdc, pNote->GetText(), -1, &rcTmp, DT_NOPREFIX | DT_WORDBREAK | DT_EXPANDTABS | DT_END_ELLIPSIS | DT_CALCRECT);
lps->itemHeight += rcTmp.bottom;
SelectObject(hdc, m_hfntSmall);
rcTmp = rc;
- DrawText(hdc, pNote->GetTagsStr(), -1, &rcTmp, DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS|DT_CALCRECT);
+ DrawText(hdc, pNote->GetTagsStr(), -1, &rcTmp, DT_NOPREFIX | DT_SINGLELINE | DT_END_ELLIPSIS | DT_CALCRECT);
lps->itemHeight += rcTmp.bottom;
lps->itemHeight += 5;
@@ -484,10 +464,10 @@ private: void InsertTag(HTREEITEM htiRoot, const TCHAR *tag, bool bSelect)
{
- TVINSERTSTRUCT tvi = {0};
+ TVINSERTSTRUCT tvi = { 0 };
tvi.hParent = htiRoot;
tvi.hInsertAfter = TVI_LAST;
- tvi.itemex.mask = TVIF_TEXT|TVIF_PARAM;
+ tvi.itemex.mask = TVIF_TEXT | TVIF_PARAM;
tvi.itemex.pszText = (TCHAR *)tag;
tvi.itemex.lParam = (LPARAM)mir_tstrdup(tag);
HTREEITEM hti = m_tvFilter.InsertItem(&tvi);
@@ -497,17 +477,15 @@ private: void PopulateTags(HTREEITEM htiRoot, TCHAR *szActiveTag)
{
LIST<TCHAR> tagSet(5, _tcscmp);
- for (int i=0; i < m_proto->m_notes.getCount(); i++)
- {
+ for (int i = 0; i < m_proto->m_notes.getCount(); i++) {
TCHAR *tags = m_proto->m_notes[i].GetTags();
for (TCHAR *tag = tags; tag && *tag; tag = tag + lstrlen(tag) + 1)
- if (!tagSet.find(tag))
- tagSet.insert(tag);
+ if (!tagSet.find(tag))
+ tagSet.insert(tag);
}
bool selected = false;
- for (int j = 0; j < tagSet.getCount(); ++j)
- {
+ for (int j = 0; j < tagSet.getCount(); ++j) {
bool select = !lstrcmp(szActiveTag, tagSet[j]);
selected |= select;
InsertTag(htiRoot, tagSet[j], select);
@@ -519,23 +497,19 @@ private: void RebuildTree()
{
- TVITEMEX tvi = {0};
- tvi.mask = TVIF_HANDLE|TVIF_PARAM;
+ TVITEMEX tvi = { 0 };
+ tvi.mask = TVIF_HANDLE | TVIF_PARAM;
tvi.hItem = m_tvFilter.GetSelection();
m_tvFilter.GetItem(&tvi);
TCHAR *szActiveTag = mir_tstrdup((TCHAR *)tvi.lParam);
m_tvFilter.DeleteAllItems();
- TVINSERTSTRUCT tvis = {0};
- tvis.hParent = NULL;
+ TVINSERTSTRUCT tvis = { 0 };
tvis.hInsertAfter = TVI_LAST;
- tvis.itemex.mask = TVIF_TEXT|TVIF_PARAM|TVIF_STATE;
- tvis.itemex.stateMask =
- tvis.itemex.state = TVIS_BOLD|TVIS_EXPANDED;
+ tvis.itemex.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE;
+ tvis.itemex.stateMask = tvis.itemex.state = TVIS_BOLD | TVIS_EXPANDED;
tvis.itemex.pszText = TranslateT("All tags");
- tvis.itemex.lParam = NULL;
-
PopulateTags(m_tvFilter.InsertItem(&tvis), szActiveTag);
mir_free(szActiveTag);
@@ -562,13 +536,12 @@ private: CJabberDlgNoteItem dlg(this, pNote);
dlg.DoModal();
- if (pNote->IsNotEmpty())
- {
+ if (pNote->IsNotEmpty()) {
m_proto->m_notes.insert(pNote);
m_proto->m_notes.Modify();
UpdateData();
- } else
- {
+ }
+ else {
delete pNote;
return;
}
@@ -578,13 +551,10 @@ private: void btnEdit_OnClick(CCtrlFilterListView *)
{
int idx = m_lstNotes.GetCurSel();
- if (idx != LB_ERR)
- {
- if (CNoteItem *pItem = (CNoteItem *)m_lstNotes.GetItemData(idx))
- {
+ if (idx != LB_ERR) {
+ if (CNoteItem *pItem = (CNoteItem *)m_lstNotes.GetItemData(idx)) {
CJabberDlgNoteItem dlg(this, pItem);
- if (dlg.DoModal())
- {
+ if (dlg.DoModal()) {
m_proto->m_notes.Modify();
RebuildTree();
}
@@ -596,10 +566,8 @@ private: void btnRemove_OnClick(CCtrlFilterListView *)
{
int idx = m_lstNotes.GetCurSel();
- if (idx != LB_ERR)
- {
- if (CNoteItem *pItem = (CNoteItem *)m_lstNotes.GetItemData(idx))
- {
+ if (idx != LB_ERR) {
+ if (CNoteItem *pItem = (CNoteItem *)m_lstNotes.GetItemData(idx)) {
m_lstNotes.DeleteString(idx);
m_proto->m_notes.remove(pItem);
}
@@ -640,12 +608,12 @@ private: CJabberDlgNotes::CJabberDlgNotes(CJabberProto *proto) :
CSuper(proto, IDD_NOTEBOOK, NULL),
- m_btnAdd(this, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add")),
- m_btnEdit(this, IDC_EDIT, SKINICON_OTHER_RENAME, LPGEN("Edit")),
- m_btnRemove(this, IDC_REMOVE, SKINICON_OTHER_DELETE, LPGEN("Remove")),
- m_lstNotes(this, IDC_LST_NOTES),
- m_tvFilter(this, IDC_TV_FILTER),
- m_btnSave(this, IDC_APPLY)
+ m_btnAdd(this, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add")),
+ m_btnEdit(this, IDC_EDIT, SKINICON_OTHER_RENAME, LPGEN("Edit")),
+ m_btnRemove(this, IDC_REMOVE, SKINICON_OTHER_DELETE, LPGEN("Remove")),
+ m_lstNotes(this, IDC_LST_NOTES),
+ m_tvFilter(this, IDC_TV_FILTER),
+ m_btnSave(this, IDC_APPLY)
{
m_btnAdd.OnClick = Callback(this, &CJabberDlgNotes::btnAdd_OnClick);
m_btnEdit.OnClick = Callback(this, &CJabberDlgNotes::btnEdit_OnClick);
@@ -684,10 +652,8 @@ void CJabberDlgNotes::OnInitDialog() void CJabberDlgNotes::OnClose()
{
- if (m_proto->m_notes.IsModified())
- {
- if (IDYES != MessageBox(m_hwnd, TranslateT("Notes are not saved, close this window without uploading data to server?"), TranslateT("Are you sure?"), MB_ICONWARNING|MB_YESNO|MB_DEFBUTTON2))
- {
+ if (m_proto->m_notes.IsModified()) {
+ if (IDYES != MessageBox(m_hwnd, TranslateT("Notes are not saved, close this window without uploading data to server?"), TranslateT("Are you sure?"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2)) {
m_lresult = TRUE;
return;
}
@@ -718,17 +684,17 @@ void CJabberDlgNotes::OnProtoRefresh(WPARAM, LPARAM) int CJabberDlgNotes::Resizer(UTILRESIZECONTROL *urc)
{
switch (urc->wId) {
- case IDC_TV_FILTER:
- return RD_ANCHORX_LEFT|RD_ANCHORY_HEIGHT;
- case IDC_LST_NOTES:
- return RD_ANCHORX_WIDTH|RD_ANCHORY_HEIGHT;
- case IDC_APPLY:
- case IDCANCEL:
- return RD_ANCHORX_RIGHT|RD_ANCHORY_BOTTOM;
- case IDC_ADD:
- case IDC_EDIT:
- case IDC_REMOVE:
- return RD_ANCHORX_LEFT|RD_ANCHORY_BOTTOM;
+ case IDC_TV_FILTER:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_HEIGHT;
+ case IDC_LST_NOTES:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+ case IDC_APPLY:
+ case IDCANCEL:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+ case IDC_ADD:
+ case IDC_EDIT:
+ case IDC_REMOVE:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
}
return CSuper::Resizer(urc);
}
@@ -738,8 +704,7 @@ int CJabberDlgNotes::Resizer(UTILRESIZECONTROL *urc) void CJabberProto::ProcessIncomingNote(CNoteItem *pNote, bool ok)
{
- if (ok && pNote->IsNotEmpty())
- {
+ if (ok && pNote->IsNotEmpty()) {
m_notes.insert(pNote);
XmlNodeIq iq(_T("set"));
@@ -747,16 +712,13 @@ void CJabberProto::ProcessIncomingNote(CNoteItem *pNote, bool ok) HXML storage = query << XCHILDNS(_T("storage"), JABBER_FEAT_MIRANDA_NOTES);
m_notes.SaveXml(storage);
m_ThreadInfo->send(iq);
- } else
- {
- delete pNote;
}
+ else delete pNote;
}
void CJabberProto::ProcessOutgoingNote(CNoteItem *pNote, bool ok)
{
- if (!ok || !pNote->IsNotEmpty())
- {
+ if (!ok || !pNote->IsNotEmpty()) {
delete pNote;
return;
}
@@ -801,24 +763,22 @@ bool CJabberProto::OnIncomingNote(const TCHAR *szFrom, HXML hXml) if (!szFrom || !hXml) return true;
CNoteItem *pItem = new CNoteItem(hXml, (TCHAR *)szFrom);
- if (!pItem->IsNotEmpty())
- {
+ if (!pItem->IsNotEmpty()) {
delete pItem;
return true;
}
- if (m_options.AutosaveNotes && HContactFromJID(szFrom))
- {
+ if (m_options.AutosaveNotes && HContactFromJID(szFrom)) {
ProcessIncomingNote(pItem, true);
return false;
}
- CLISTEVENT cle = {0};
+ CLISTEVENT cle = { 0 };
char szService[256];
- mir_snprintf(szService, sizeof(szService),"%s%s", m_szModuleName, JS_INCOMING_NOTE_EVENT);
+ mir_snprintf(szService, sizeof(szService), "%s%s", m_szModuleName, JS_INCOMING_NOTE_EVENT);
cle.cbSize = sizeof(CLISTEVENT);
cle.hIcon = (HICON)LoadIconEx("notes");
- cle.flags = CLEF_PROTOCOLGLOBAL|CLEF_TCHAR;
+ cle.flags = CLEF_PROTOCOLGLOBAL | CLEF_TCHAR;
cle.hDbEvent = (HANDLE)("test");
cle.lParam = (LPARAM)pItem;
cle.pszService = szService;
@@ -853,7 +813,7 @@ INT_PTR __cdecl CJabberProto::OnMenuHandleNotes(WPARAM, LPARAM) INT_PTR __cdecl CJabberProto::OnMenuSendNote(WPARAM wParam, LPARAM)
{
if (wParam) {
- CNoteItem *pItem = new CNoteItem(NULL, ptrT( getTStringA((HANDLE)wParam, "jid")));
+ CNoteItem *pItem = new CNoteItem(NULL, ptrT(getTStringA((HANDLE)wParam, "jid")));
CJabberDlgBase *pDlg = new CJabberDlgNoteItem(this, pItem, &CJabberProto::ProcessOutgoingNote);
pDlg->Show();
}
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index c0e3276b53..14f3ca7cba 100644 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -1870,19 +1870,12 @@ private: m_cbServer.GetTextA(regInfo.server, SIZEOF(regInfo.server));
regInfo.port = (WORD)m_txtPort.GetInt();
if (m_chkManualHost.GetState() == BST_CHECKED)
- {
m_txtManualHost.GetTextA(regInfo.manualHost, SIZEOF(regInfo.manualHost));
- } else
- {
+ else
regInfo.manualHost[0] = '\0';
- }
- if (regInfo.username[0] && regInfo.password[0] && regInfo.server[0] && regInfo.port>0 && ((m_chkManualHost.GetState() != BST_CHECKED) || regInfo.manualHost[0]))
- {
- CJabberDlgRegister dlg(m_proto, m_hwnd, ®Info);
- dlg.DoModal();
-// DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_OPT_REGISTER), m_hwnd, JabberRegisterDlgProc, (LPARAM)®Info);
- }
+ if (regInfo.username[0] && regInfo.password[0] && regInfo.server[0] && regInfo.port > 0 && ((m_chkManualHost.GetState() != BST_CHECKED) || regInfo.manualHost[0]))
+ CJabberDlgRegister(m_proto, m_hwnd, ®Info).DoModal();
}
void cbServer_OnDropdown(CCtrlCombo*)
@@ -1917,8 +1910,7 @@ private: {
CCtrlCheck *chk = (CCtrlCheck *)sender;
- if (chk->GetState() == BST_CHECKED)
- {
+ if (chk->GetState() == BST_CHECKED) {
char buf[256];
m_cbServer.GetTextA(buf, SIZEOF(buf));
m_txtManualHost.SetTextA(buf);
@@ -1926,8 +1918,8 @@ private: m_txtManualHost.Enable();
m_txtPort.Enable();
- } else
- {
+ }
+ else {
m_txtManualHost.Disable();
m_txtPort.Disable();
}
diff --git a/protocols/JabberG/src/jabber_opttree.cpp b/protocols/JabberG/src/jabber_opttree.cpp index ae063fcbbf..e177b0897b 100644 --- a/protocols/JabberG/src/jabber_opttree.cpp +++ b/protocols/JabberG/src/jabber_opttree.cpp @@ -48,52 +48,49 @@ void CCtrlTreeOpts::AddOption(TCHAR *szOption, CMOption<BYTE> &option) BOOL CCtrlTreeOpts::OnNotify(int idCtrl, NMHDR *pnmh)
{
- switch (pnmh->code)
- {
- case TVN_KEYDOWN:
+ switch (pnmh->code) {
+ case TVN_KEYDOWN:
{
LPNMTVKEYDOWN lpnmtvkd = (LPNMTVKEYDOWN)pnmh;
HTREEITEM hti;
if ((lpnmtvkd->wVKey == VK_SPACE) && (hti = GetSelection()))
ProcessItemClick(hti);
- break;
}
+ break;
- case NM_CLICK:
+ case NM_CLICK:
{
TVHITTESTINFO hti;
- hti.pt.x=(short)LOWORD(GetMessagePos());
- hti.pt.y=(short)HIWORD(GetMessagePos());
- ScreenToClient(pnmh->hwndFrom,&hti.pt);
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(pnmh->hwndFrom, &hti.pt);
if (HitTest(&hti))
- if (hti.flags&TVHT_ONITEMICON)
- ProcessItemClick(hti.hItem);
- break;
+ if (hti.flags&TVHT_ONITEMICON)
+ ProcessItemClick(hti.hItem);
}
+ break;
- case TVN_ITEMEXPANDEDW:
+ case TVN_ITEMEXPANDEDW:
{
LPNMTREEVIEWW lpnmtv = (LPNMTREEVIEWW)pnmh;
TVITEM tvi;
- tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvi.hItem = lpnmtv->itemNew.hItem;
tvi.iImage = tvi.iSelectedImage =
(lpnmtv->itemNew.state & TVIS_EXPANDED) ? IMG_GRPOPEN : IMG_GRPCLOSED;
SendMessageW(pnmh->hwndFrom, TVM_SETITEMW, 0, (LPARAM)&tvi);
- break;
- }
-
- case TVN_ITEMEXPANDEDA:
- {
- LPNMTREEVIEWA lpnmtv = (LPNMTREEVIEWA)pnmh;
- TVITEM tvi;
- tvi.mask=TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
- tvi.hItem = lpnmtv->itemNew.hItem;
- tvi.iImage = tvi.iSelectedImage =
- (lpnmtv->itemNew.state & TVIS_EXPANDED) ? IMG_GRPOPEN : IMG_GRPCLOSED;
- SendMessageA(pnmh->hwndFrom, TVM_SETITEMA, 0, (LPARAM)&tvi);
- break;
}
+ break;
+
+ case TVN_ITEMEXPANDEDA:
+ LPNMTREEVIEWA lpnmtv = (LPNMTREEVIEWA)pnmh;
+ TVITEM tvi;
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+ tvi.hItem = lpnmtv->itemNew.hItem;
+ tvi.iImage = tvi.iSelectedImage =
+ (lpnmtv->itemNew.state & TVIS_EXPANDED) ? IMG_GRPOPEN : IMG_GRPCLOSED;
+ SendMessageA(pnmh->hwndFrom, TVM_SETITEMA, 0, (LPARAM)&tvi);
+ break;
}
return CCtrlTreeView::OnNotify(idCtrl, pnmh);
@@ -109,7 +106,7 @@ void CCtrlTreeOpts::OnInit() SelectItem(NULL);
DeleteAllItems();
- hImgLst = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR|ILC_COLOR32|ILC_MASK, 5, 1);
+ hImgLst = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR | ILC_COLOR32 | ILC_MASK, 5, 1);
ImageList_AddIcon_Icolib(hImgLst, LoadSkinnedIcon(SKINICON_OTHER_MIRANDA));
ImageList_AddIcon_Icolib(hImgLst, LoadSkinnedIcon(SKINICON_OTHER_TICK)); // check on
ImageList_AddIcon_Icolib(hImgLst, LoadSkinnedIcon(SKINICON_OTHER_NOTICK)); // check off
@@ -120,8 +117,7 @@ void CCtrlTreeOpts::OnInit() SetImageList(hImgLst, TVSIL_NORMAL);
/* build options tree. based on code from IcoLib */
- for (int i=0; i < m_options.getCount(); i++)
- {
+ for (int i = 0; i < m_options.getCount(); i++) {
TCHAR *sectionName;
int sectionLevel = 0;
@@ -129,50 +125,41 @@ void CCtrlTreeOpts::OnInit() lstrcpy(itemName, m_options[i]->m_szOptionName);
sectionName = itemName;
- while (sectionName)
- {
+ while (sectionName) {
// allow multi-level tree
TCHAR *pItemName = sectionName;
HTREEITEM hItem;
- if (sectionName = _tcschr(sectionName, '/'))
- {
+ if (sectionName = _tcschr(sectionName, '/')) {
// one level deeper
*sectionName = 0;
sectionName++;
}
hItem = FindNamedItem(hSection, pItemName);
- if (!sectionName || !hItem)
- {
- if (!hItem)
- {
- TVINSERTSTRUCT tvis = {0};
-
+ if (!sectionName || !hItem) {
+ if (!hItem) {
+ TVINSERTSTRUCT tvis = { 0 };
tvis.hParent = hSection;
tvis.hInsertAfter = TVI_LAST;//TVI_SORT;
- tvis.item.mask = TVIF_TEXT|TVIF_PARAM|TVIF_STATE|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
+ tvis.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvis.item.pszText = pItemName;
tvis.item.state = tvis.item.stateMask = TVIS_EXPANDED;
- if (sectionName)
- {
+ if (sectionName) {
tvis.item.lParam = -1;
tvis.item.state |= TVIS_BOLD;
tvis.item.stateMask |= TVIS_BOLD;
tvis.item.iImage = tvis.item.iSelectedImage = IMG_GRPOPEN;
- } else
- {
+ }
+ else {
tvis.item.lParam = i;
BYTE val = *m_options[i]->m_option;
if (m_options[i]->m_groupId == OPTTREE_CHECK)
- {
tvis.item.iImage = tvis.item.iSelectedImage = val ? IMG_CHECK : IMG_NOCHECK;
- } else
- {
+ else
tvis.item.iImage = tvis.item.iSelectedImage = val ? IMG_RCHECK : IMG_NORCHECK;
- }
}
hItem = InsertItem(&tvis);
if (!sectionName)
@@ -198,8 +185,7 @@ void CCtrlTreeOpts::OnApply() {
CCtrlTreeView::OnApply();
- for (int i=0; i < m_options.getCount(); i++)
- {
+ for (int i = 0; i < m_options.getCount(); i++) {
TVITEMEX tvi;
GetItem(m_options[i]->m_hItem, &tvi);
*m_options[i]->m_option = ((tvi.iImage == IMG_CHECK) || (tvi.iImage == IMG_RCHECK)) ? 1 : 0;
@@ -210,50 +196,44 @@ void CCtrlTreeOpts::ProcessItemClick(HTREEITEM hti) {
TVITEMEX tvi;
GetItem(hti, &tvi);
- switch (tvi.iImage)
- {
- case IMG_GRPOPEN:
- tvi.iImage = tvi.iSelectedImage = IMG_GRPCLOSED;
- Expand(tvi.hItem, TVE_COLLAPSE);
- break;
- case IMG_GRPCLOSED:
- tvi.iImage = tvi.iSelectedImage = IMG_GRPOPEN;
- Expand(tvi.hItem, TVE_EXPAND);
- break;
-
- case IMG_CHECK:
- tvi.iImage = tvi.iSelectedImage = IMG_NOCHECK;
- SendMessage(::GetParent(::GetParent(m_hwnd)), PSM_CHANGED, 0, 0);
- break;
- case IMG_NOCHECK:
- tvi.iImage = tvi.iSelectedImage = IMG_CHECK;
- SendMessage(::GetParent(::GetParent(m_hwnd)), PSM_CHANGED, 0, 0);
- break;
- case IMG_NORCHECK:
- {
- int i;
- for (i=0; i < m_options.getCount(); i++)
- {
- if (m_options[i]->m_groupId == m_options[tvi.lParam]->m_groupId)
- {
- TVITEMEX tvi_tmp;
- tvi_tmp.mask = TVIF_HANDLE|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
- tvi_tmp.hItem = m_options[i]->m_hItem;
- tvi_tmp.iImage = tvi_tmp.iSelectedImage = IMG_NORCHECK;
- SetItem(&tvi_tmp);
- }
+ switch (tvi.iImage) {
+ case IMG_GRPOPEN:
+ tvi.iImage = tvi.iSelectedImage = IMG_GRPCLOSED;
+ Expand(tvi.hItem, TVE_COLLAPSE);
+ break;
+ case IMG_GRPCLOSED:
+ tvi.iImage = tvi.iSelectedImage = IMG_GRPOPEN;
+ Expand(tvi.hItem, TVE_EXPAND);
+ break;
+
+ case IMG_CHECK:
+ tvi.iImage = tvi.iSelectedImage = IMG_NOCHECK;
+ SendMessage(::GetParent(::GetParent(m_hwnd)), PSM_CHANGED, 0, 0);
+ break;
+ case IMG_NOCHECK:
+ tvi.iImage = tvi.iSelectedImage = IMG_CHECK;
+ SendMessage(::GetParent(::GetParent(m_hwnd)), PSM_CHANGED, 0, 0);
+ break;
+ case IMG_NORCHECK:
+ for (int i = 0; i < m_options.getCount(); i++) {
+ if (m_options[i]->m_groupId == m_options[tvi.lParam]->m_groupId) {
+ TVITEMEX tvi_tmp;
+ tvi_tmp.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+ tvi_tmp.hItem = m_options[i]->m_hItem;
+ tvi_tmp.iImage = tvi_tmp.iSelectedImage = IMG_NORCHECK;
+ SetItem(&tvi_tmp);
}
- tvi.iImage = tvi.iSelectedImage = IMG_RCHECK;
- SendMessage(::GetParent(::GetParent(m_hwnd)), PSM_CHANGED, 0, 0);
- break;
}
+ tvi.iImage = tvi.iSelectedImage = IMG_RCHECK;
+ SendMessage(::GetParent(::GetParent(m_hwnd)), PSM_CHANGED, 0, 0);
+ break;
}
SetItem(&tvi);
}
-CCtrlTreeOpts::COptionsItem::COptionsItem(TCHAR *szOption, CMOption<BYTE> &option):
- m_option(&option), m_groupId(OPTTREE_CHECK), m_hItem(NULL)
+CCtrlTreeOpts::COptionsItem::COptionsItem(TCHAR *szOption, CMOption<BYTE> &option) :
+m_option(&option), m_groupId(OPTTREE_CHECK), m_hItem(NULL)
{
m_szOptionName = mir_tstrdup(szOption);
}
diff --git a/protocols/JabberG/src/jabber_secur.cpp b/protocols/JabberG/src/jabber_secur.cpp index 7abcd96ef7..df736ea7d9 100644 --- a/protocols/JabberG/src/jabber_secur.cpp +++ b/protocols/JabberG/src/jabber_secur.cpp @@ -46,12 +46,13 @@ TNtlmAuth::TNtlmAuth(ThreadData* info, const char* mechanism, const TCHAR *hostn return;
}
- TCHAR szSpn[ 1024 ] = _T("");
+ TCHAR szSpn[1024] = _T("");
if (strcmp(mechanism, "NTLM")) {
if (!getSpn(szSpn, SIZEOF(szSpn)) && !strcmp(mechanism, "GSSAPI")) {
bIsValid = false;
return;
- } }
+ }
+ }
if ((hProvider = Netlib_InitSecurityProvider2(szProvider, szSpn)) == NULL)
bIsValid = false;
@@ -65,11 +66,10 @@ TNtlmAuth::~TNtlmAuth() bool TNtlmAuth::getSpn(TCHAR* szSpn, size_t dwSpnLen)
{
-
TCHAR szFullUserName[128] = _T("");
ULONG szFullUserNameLen = SIZEOF(szFullUserName);
if (!GetUserNameEx(NameDnsDomain, szFullUserName, &szFullUserNameLen)) {
- szFullUserName[ 0 ] = 0;
+ szFullUserName[0] = 0;
szFullUserNameLen = SIZEOF(szFullUserName);
GetUserNameEx(NameSamCompatible, szFullUserName, &szFullUserNameLen);
}
@@ -82,12 +82,11 @@ bool TNtlmAuth::getSpn(TCHAR* szSpn, size_t dwSpnLen) TCHAR *szFullUserNameU = _tcsupr(mir_tstrdup(szFullUserName));
mir_sntprintf(szSpn, dwSpnLen, _T("xmpp/%s/%s@%s"), szHostName, szFullUserName, szFullUserNameU);
mir_free(szFullUserNameU);
- } else {
+ }
+ else {
const char* connectHost = info->manualHost[0] ? info->manualHost : info->server;
- unsigned long ip = inet_addr(connectHost);
- // Convert host name to FQDN
-// PHOSTENT host = (ip == INADDR_NONE) ? gethostbyname(szHost) : gethostbyaddr((char*)&ip, 4, AF_INET);
+ unsigned long ip = inet_addr(connectHost);
PHOSTENT host = (ip == INADDR_NONE) ? NULL : gethostbyaddr((char*)&ip, 4, AF_INET);
if (host && host->h_name)
connectHost = host->h_name;
@@ -98,8 +97,6 @@ bool TNtlmAuth::getSpn(TCHAR* szSpn, size_t dwSpnLen) }
Netlib_Logf(NULL, "SPN: %S", szSpn);
-
-
return true;
}
@@ -176,13 +173,13 @@ char* TMD5Auth::getChallenge(const TCHAR *challenge) mir_md5_append(&ctx, (BYTE*)":", 1);
mir_md5_append(&ctx, (BYTE*)realm, (int)strlen(realm));
mir_md5_append(&ctx, (BYTE*)":", 1);
- mir_md5_append(&ctx, (BYTE*)(char*)passw, (int)strlen(passw));
+ mir_md5_append(&ctx, (BYTE*)(char*)passw, (int)strlen(passw));
mir_md5_finish(&ctx, (BYTE*)hash1);
mir_md5_init(&ctx);
mir_md5_append(&ctx, (BYTE*)hash1, 16);
mir_md5_append(&ctx, (BYTE*)":", 1);
- mir_md5_append(&ctx, (BYTE*)nonce, (int)strlen(nonce));
+ mir_md5_append(&ctx, (BYTE*)nonce, (int)strlen(nonce));
mir_md5_append(&ctx, (BYTE*)":", 1);
mir_md5_append(&ctx, (BYTE*)cnonce, (int)strlen(cnonce));
mir_md5_finish(&ctx, (BYTE*)hash1);
@@ -195,8 +192,8 @@ char* TMD5Auth::getChallenge(const TCHAR *challenge) mir_md5_init(&ctx);
mir_snprintf(tmpBuf, SIZEOF(tmpBuf), "%08x%08x%08x%08x", htonl(hash1[0]), htonl(hash1[1]), htonl(hash1[2]), htonl(hash1[3]));
mir_md5_append(&ctx, (BYTE*)tmpBuf, (int)strlen(tmpBuf));
- mir_md5_append(&ctx, (BYTE*)":", 1);
- mir_md5_append(&ctx, (BYTE*)nonce, (int)strlen(nonce));
+ mir_md5_append(&ctx, (BYTE*)":", 1);
+ mir_md5_append(&ctx, (BYTE*)nonce, (int)strlen(nonce));
mir_snprintf(tmpBuf, SIZEOF(tmpBuf), ":%08d:", iCallCount);
mir_md5_append(&ctx, (BYTE*)tmpBuf, (int)strlen(tmpBuf));
mir_md5_append(&ctx, (BYTE*)cnonce, (int)strlen(cnonce));
@@ -212,7 +209,7 @@ char* TMD5Auth::getChallenge(const TCHAR *challenge) uname, realm, nonce, cnonce, iCallCount, serv,
htonl(digest[0]), htonl(digest[1]), htonl(digest[2]), htonl(digest[3]));
- return mir_base64_encode((PBYTE)buf, cbLen);
+ return mir_base64_encode((PBYTE)buf, cbLen);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -232,14 +229,13 @@ TScramAuth::~TScramAuth() mir_free(serverSignature);
}
-void TScramAuth::Hi(BYTE* res , char* passw, size_t passwLen, char* salt, size_t saltLen, int ind)
+void TScramAuth::Hi(BYTE* res, char* passw, size_t passwLen, char* salt, size_t saltLen, int ind)
{
- BYTE u[ MIR_SHA1_HASH_SIZE ];
- memcpy(u, salt, saltLen); *(unsigned*)(u + saltLen) = htonl(1); saltLen += 4;
+ BYTE u[MIR_SHA1_HASH_SIZE];
+ memcpy(u, salt, saltLen); *(unsigned*)(u + saltLen) = htonl(1); saltLen += 4;
memset(res, 0, MIR_SHA1_HASH_SIZE);
- for (int i=0; i < ind; i++)
- {
+ for (int i = 0; i < ind; i++) {
mir_hmac_sha1(u, (BYTE*)passw, passwLen, u, saltLen);
saltLen = sizeof(u);
@@ -251,14 +247,14 @@ void TScramAuth::Hi(BYTE* res , char* passw, size_t passwLen, char* salt, size_t char* TScramAuth::getChallenge(const TCHAR *challenge)
{
unsigned chlLen;
- ptrA chl((char*)mir_base64_decode( _T2A(challenge), &chlLen));
+ ptrA chl((char*)mir_base64_decode(_T2A(challenge), &chlLen));
char *r = strstr(chl, "r=");
if (!r)
return NULL;
char *e = strchr(r, ','); if (e) *e = 0;
- ptrA snonce( mir_strdup(r + 2));
+ ptrA snonce(mir_strdup(r + 2));
if (e) *e = ',';
size_t cnlen = strlen(cnonce);
@@ -304,30 +300,30 @@ char* TScramAuth::getChallenge(const TCHAR *challenge) char authmsg[4096];
int authmsgLen = mir_snprintf(authmsg, sizeof(authmsg), "%s,%s,c=biws,r=%s", msg1, chl, snonce);
- BYTE clientSig[ MIR_SHA1_HASH_SIZE ];
+ BYTE clientSig[MIR_SHA1_HASH_SIZE];
mir_hmac_sha1(clientSig, storedKey, sizeof(storedKey), (BYTE*)authmsg, authmsgLen);
- BYTE clientProof[ MIR_SHA1_HASH_SIZE ];
+ BYTE clientProof[MIR_SHA1_HASH_SIZE];
for (unsigned j = 0; j < sizeof(clientKey); j++)
clientProof[j] = clientKey[j] ^ clientSig[j];
/* Calculate the server signature */
- BYTE serverKey[ MIR_SHA1_HASH_SIZE ];
+ BYTE serverKey[MIR_SHA1_HASH_SIZE];
mir_hmac_sha1(serverKey, saltedPassw, sizeof(saltedPassw), (BYTE*)"Server Key", 10);
- BYTE srvSig[ MIR_SHA1_HASH_SIZE ];
+ BYTE srvSig[MIR_SHA1_HASH_SIZE];
mir_hmac_sha1(srvSig, serverKey, sizeof(serverKey), (BYTE*)authmsg, authmsgLen);
serverSignature = mir_base64_encode((PBYTE)srvSig, sizeof(srvSig));
char buf[4096];
- ptrA encproof( mir_base64_encode((PBYTE)clientProof, sizeof(clientProof)));
+ ptrA encproof(mir_base64_encode((PBYTE)clientProof, sizeof(clientProof)));
int cbLen = mir_snprintf(buf, sizeof(buf), "c=biws,r=%s,p=%s", snonce, encproof);
return mir_base64_encode((PBYTE)buf, cbLen);
}
char* TScramAuth::getInitialRequest()
{
- ptrA uname( mir_utf8encodeT(info->username));
+ ptrA uname(mir_utf8encodeT(info->username));
unsigned char nonce[24];
CallService(MS_UTILS_GETRANDOM, sizeof(nonce), (LPARAM)nonce);
@@ -342,7 +338,7 @@ char* TScramAuth::getInitialRequest() bool TScramAuth::validateLogin(const TCHAR *challenge)
{
unsigned chlLen;
- ptrA chl((char*)mir_base64_decode( _T2A(challenge), &chlLen));
+ ptrA chl((char*)mir_base64_decode(_T2A(challenge), &chlLen));
return chl && strncmp((char*)chl + 2, serverSignature, chlLen - 2) == 0;
}
@@ -362,7 +358,7 @@ TPlainAuth::~TPlainAuth() char* TPlainAuth::getInitialRequest()
{
- ptrA uname( mir_utf8encodeT(info->username)), passw( mir_utf8encodeT(info->password));
+ ptrA uname(mir_utf8encodeT(info->username)), passw(mir_utf8encodeT(info->password));
size_t size = 2 * strlen(uname) + strlen(passw) + strlen(info->server) + 4;
char *toEncode = (char*)alloca(size);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index e39a37ebdd..2d5240d8b1 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -670,7 +670,8 @@ void CJabberProto::PerformAuthentication(ThreadData* info) if (!auth->isValid()) {
delete auth;
auth = NULL;
- } else {
+ }
+ else {
request = auth->getInitialRequest();
if (!request) {
delete auth;
diff --git a/protocols/JabberG/src/jabber_treelist.cpp b/protocols/JabberG/src/jabber_treelist.cpp index 3f864deb60..d006c4a306 100644 --- a/protocols/JabberG/src/jabber_treelist.cpp +++ b/protocols/JabberG/src/jabber_treelist.cpp @@ -208,12 +208,11 @@ HTREELISTITEM TreeList_AddItem(HWND hwnd, HTREELISTITEM hParent, TCHAR *text, LP item->parent = hParent;
item->text.insert(mir_tstrdup(text));
item->flags |= TLIF_MODIFIED;
- if (hParent->flags & TLIF_ROOT)
- {
+ if (hParent->flags & TLIF_ROOT) {
item->flags |= TLIF_EXPANDED;
data->hItemSelected = item;
}
- item->indent = hParent->indent+1;
+ item->indent = hParent->indent + 1;
hParent->subItems.insert(item);
return item;
}
@@ -263,10 +262,11 @@ void TreeList_SetIcon(HTREELISTITEM hItem, int iIcon, int iOverlay) void TreeList_RecursiveApply(HTREELISTITEM hItem, void (*func)(HTREELISTITEM, LPARAM), LPARAM data)
{
- for (int i=0; i < hItem->subItems.getCount(); i++) {
+ for (int i = 0; i < hItem->subItems.getCount(); i++) {
func(hItem->subItems[i], data);
TreeList_RecursiveApply(hItem->subItems[i], func, data);
-} }
+ }
+}
void TreeList_Update(HWND hwnd)
{
@@ -298,19 +298,17 @@ void TreeList_Update(HWND hwnd) lvi.stateMask = LVIS_OVERLAYMASK|LVIS_STATEIMAGEMASK;
lvi.iImage = ptli->iIcon;
if (data->mode == TLM_TREE)
- {
lvi.state =
INDEXTOSTATEIMAGEMASK(
- ((ptli->subItems.getCount() == 0) && !(ptli->flags & TLIF_FAKEPARENT)) ? 0 :
- (ptli->flags & TLIF_EXPANDED) ? 1 : 2) |
+ ((ptli->subItems.getCount() == 0) && !(ptli->flags & TLIF_FAKEPARENT)) ? 0 :
+ (ptli->flags & TLIF_EXPANDED) ? 1 : 2) |
INDEXTOOVERLAYMASK(ptli->iOverlay);
- } else
- {
+ else
lvi.state =
INDEXTOSTATEIMAGEMASK(
- ((ptli->subItems.getCount() == 0) && !(ptli->flags & TLIF_FAKEPARENT)) ? 0 : 3) |
+ ((ptli->subItems.getCount() == 0) && !(ptli->flags & TLIF_FAKEPARENT)) ? 0 : 3) |
INDEXTOOVERLAYMASK(ptli->iOverlay);
- }
+
ListView_SetItem(hwnd, &lvi);
for (int j = 1; j < ptli->text.getCount(); ++j)
ListView_SetItemText(hwnd, i, j, ptli->text[j]);
@@ -320,11 +318,10 @@ void TreeList_Update(HWND hwnd) }
if (data->mode == TLM_TREE)
TreeList_RecursiveApply(hItem, sttTreeList_CreateItems, (LPARAM)hwnd);
- else
- {
+ else {
for (int i = data->hItemSelected->subItems.getCount(); i--;)
sttTreeList_CreateItems_List(data->hItemSelected->subItems[i], (LPARAM)hwnd);
- for (HTREELISTITEM hItem = data->hItemSelected; !(hItem->flags & TLIF_ROOT); hItem = hItem->parent)
+ for (HTREELISTITEM hItem = data->hItemSelected; !(hItem->flags & TLIF_ROOT); hItem = hItem->parent)
sttTreeList_CreateItems_List(hItem, (LPARAM)hwnd);
}
ListView_SortItems(hwnd, sttTreeList_SortFunc, 0);
@@ -514,17 +511,13 @@ static void sttTreeList_FilterItems(HTREELISTITEM hItem, LPARAM data) if (JabberStrIStr(hItem->text[i], (TCHAR *)data))
break;
- if (i < hItem->text.getCount())
- {
- while (!(hItem->flags & TLIF_ROOT))
- {
+ if (i < hItem->text.getCount()) {
+ while (!(hItem->flags & TLIF_ROOT)) {
hItem->flags |= TLIF_FILTERED;
hItem = hItem->parent;
}
- } else
- {
- hItem->flags &= ~TLIF_FILTERED;
}
+ else hItem->flags &= ~TLIF_FILTERED;
}
static void sttTreeList_CreateItems(HTREELISTITEM hItem, LPARAM data)
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 07814849e3..f15be70a32 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -1196,7 +1196,7 @@ static INT_PTR CALLBACK sttEnterStringDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa HWND hWnd = GetDlgItem(hwndDlg, params->idcControl);
int len = GetWindowTextLength(hWnd);
params->result.Truncate(len);
- GetWindowText(hWnd, params->result.GetBuffer(), len);
+ GetWindowText(hWnd, params->result.GetBuffer(), len+1);
if ((params->type == JES_COMBO) && params->windowName && params->recentCount)
params->ppro->ComboAddRecentString(hwndDlg, IDC_TXT_COMBO, params->windowName, params->result, params->recentCount);
diff --git a/protocols/JabberG/src/jabber_xml.cpp b/protocols/JabberG/src/jabber_xml.cpp index 7d4208a2cc..8596609b47 100644 --- a/protocols/JabberG/src/jabber_xml.cpp +++ b/protocols/JabberG/src/jabber_xml.cpp @@ -283,24 +283,20 @@ void XPath::ProcessPath(LookupInfo &info, bool bCreate) TCHAR *nodeName = (TCHAR *)alloca(sizeof(TCHAR) * (info.nodeName.length+1));
lstrcpyn(nodeName, info.nodeName.p, info.nodeName.length+1);
- if (info.attrName && info.attrValue)
- {
- TCHAR *attrName = (TCHAR *)alloca(sizeof(TCHAR) * (info.attrName.length+1));
- lstrcpyn(attrName, info.attrName.p, info.attrName.length+1);
- TCHAR *attrValue = (TCHAR *)alloca(sizeof(TCHAR) * (info.attrValue.length+1));
- lstrcpyn(attrValue, info.attrValue.p, info.attrValue.length+1);
+ if (info.attrName && info.attrValue) {
+ TCHAR *attrName = (TCHAR *)alloca(sizeof(TCHAR)* (info.attrName.length + 1));
+ lstrcpyn(attrName, info.attrName.p, info.attrName.length + 1);
+ TCHAR *attrValue = (TCHAR *)alloca(sizeof(TCHAR)* (info.attrValue.length + 1));
+ lstrcpyn(attrValue, info.attrValue.p, info.attrValue.length + 1);
HXML hXml = xmlGetChildByTag(m_hXml, nodeName, attrName, attrValue);
m_hXml = (hXml || !bCreate) ? hXml : (m_hXml << XCHILD(nodeName) << XATTR(attrName, attrValue));
- } else
- if (info.nodeIndex)
- {
+ }
+ else if (info.nodeIndex) {
int idx = _ttoi(info.nodeIndex.p);
- m_hXml = lstrcmp(nodeName, _T("*")) ? xmlGetNthChild(m_hXml, nodeName, idx) : xmlGetChild(m_hXml, idx-1);
-
- // no support for such creation mode
- } else
- {
+ m_hXml = lstrcmp(nodeName, _T("*")) ? xmlGetNthChild(m_hXml, nodeName, idx) : xmlGetChild(m_hXml, idx - 1);
+ }
+ else {
HXML hXml = xmlGetChild(m_hXml, nodeName);
m_hXml = (hXml || !bCreate) ? hXml : (m_hXml << XCHILD(nodeName));
}
@@ -313,26 +309,21 @@ XPath::PathType XPath::LookupImpl(bool bCreate) LookupState state = S_START;
LookupInfo info = {0};
- for (LPCTSTR p = m_szPath; state < S_FINAL; ++p)
- {
- switch (state)
- {
+ for (LPCTSTR p = m_szPath; state < S_FINAL; ++p) {
+ switch (state) {
case S_START:
- {
ProcessPath(info, bCreate);
- if (!m_hXml)
- {
+ if (!m_hXml) {
state = S_FINAL_ERROR;
break;
}
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
case _T('@'):
- info.attrName.Begin(p+1);
+ info.attrName.Begin(p + 1);
state = S_ATTR_STEP;
break;
case _T('/'):
@@ -343,11 +334,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_ATTR_STEP:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
info.attrName.End(p);
state = S_FINAL_ATTR;
@@ -356,11 +345,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_NAME:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
info.nodeName.End(p);
state = S_FINAL_NODESET;
@@ -377,16 +364,14 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_OPENBRACKET:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
case _T('@'):
- info.attrName.Begin(p+1);
+ info.attrName.Begin(p + 1);
state = S_NODE_ATTRNAME;
break;
case _T('0'): case _T('1'): case _T('2'): case _T('3'): case _T('4'):
@@ -399,11 +384,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_INDEX:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
@@ -419,11 +402,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_ATTRNAME:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
@@ -435,16 +416,14 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_ATTREQUALS:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
case _T('\''):
- info.attrValue.Begin(p+1);
+ info.attrValue.Begin(p + 1);
state = S_NODE_ATTRVALUE;
break;
default:
@@ -452,11 +431,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_ATTRVALUE:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
@@ -468,11 +445,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_ATTRCLOSEVALUE:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_ERROR;
break;
@@ -484,11 +459,9 @@ XPath::PathType XPath::LookupImpl(bool bCreate) break;
};
break;
- }
+
case S_NODE_CLOSEBRACKET:
- {
- switch (*p)
- {
+ switch (*p) {
case 0:
state = S_FINAL_NODE;
break;
@@ -501,16 +474,12 @@ XPath::PathType XPath::LookupImpl(bool bCreate) };
break;
}
- }
if (!*p && (state < S_FINAL))
- {
state = S_FINAL_ERROR;
- }
}
- switch (state)
- {
+ switch (state) {
case S_FINAL_ATTR:
m_szParam = info.attrName.p;
return T_ATTRIBUTE;
|