From 73769ed8b0004dd35a33fdf75d3186f557cb60f3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 17 Feb 2020 18:00:46 +0300 Subject: code cleaning --- protocols/JabberG/src/jabber_adhoc.cpp | 41 +- protocols/JabberG/src/jabber_api.cpp | 8 +- protocols/JabberG/src/jabber_archive.cpp | 22 +- protocols/JabberG/src/jabber_byte.cpp | 26 +- protocols/JabberG/src/jabber_byte.h | 7 +- protocols/JabberG/src/jabber_chat.cpp | 14 +- protocols/JabberG/src/jabber_console.cpp | 2 +- protocols/JabberG/src/jabber_disco.cpp | 45 +- protocols/JabberG/src/jabber_disco.h | 77 +- protocols/JabberG/src/jabber_ft.cpp | 80 ++- protocols/JabberG/src/jabber_groupchat.cpp | 12 +- protocols/JabberG/src/jabber_ibb.cpp | 31 +- protocols/JabberG/src/jabber_ibb.h | 8 +- protocols/JabberG/src/jabber_icolib.cpp | 10 +- protocols/JabberG/src/jabber_iq.cpp | 2 +- protocols/JabberG/src/jabber_iq.h | 2 +- protocols/JabberG/src/jabber_iq_handlers.cpp | 82 +-- protocols/JabberG/src/jabber_menu.cpp | 2 +- protocols/JabberG/src/jabber_message_handlers.cpp | 18 +- protocols/JabberG/src/jabber_message_manager.h | 2 +- protocols/JabberG/src/jabber_misc.cpp | 11 +- protocols/JabberG/src/jabber_omemo.cpp | 4 +- protocols/JabberG/src/jabber_opt.cpp | 36 +- protocols/JabberG/src/jabber_presence_manager.h | 2 +- protocols/JabberG/src/jabber_privacy.cpp | 27 +- protocols/JabberG/src/jabber_privacy.h | 152 ++-- protocols/JabberG/src/jabber_proto.cpp | 2 +- protocols/JabberG/src/jabber_proto.h | 838 +++++++++++----------- protocols/JabberG/src/jabber_rc.cpp | 97 ++- protocols/JabberG/src/jabber_rc.h | 105 +-- protocols/JabberG/src/jabber_roster.cpp | 25 +- protocols/JabberG/src/jabber_search.cpp | 9 +- protocols/JabberG/src/jabber_search.h | 4 +- protocols/JabberG/src/jabber_send_manager.h | 2 +- protocols/JabberG/src/jabber_strm_mgmt.cpp | 2 +- protocols/JabberG/src/jabber_svc.cpp | 13 +- protocols/JabberG/src/jabber_thread.cpp | 32 +- protocols/JabberG/src/jabber_vcard.cpp | 10 +- protocols/JabberG/src/jabber_ws.cpp | 2 +- protocols/JabberG/src/jabber_xstatus.cpp | 7 +- protocols/JabberG/src/jabber_zstream.cpp | 8 +- protocols/JabberG/src/stdafx.h | 2 +- 42 files changed, 963 insertions(+), 918 deletions(-) diff --git a/protocols/JabberG/src/jabber_adhoc.cpp b/protocols/JabberG/src/jabber_adhoc.cpp index ffbfb4f1b5..7148fdc748 100644 --- a/protocols/JabberG/src/jabber_adhoc.cpp +++ b/protocols/JabberG/src/jabber_adhoc.cpp @@ -107,7 +107,7 @@ void CJabberProto::AdHoc_RequestListOfCommands(char *szResponder, HWND hwndDlg) << XQUERY(JABBER_FEAT_DISCO_ITEMS) << XATTR("node", JABBER_FEAT_COMMANDS)); } -int CJabberProto::AdHoc_ExecuteCommand(HWND hwndDlg, char*, JabberAdHocData *dat) +void CJabberProto::AdHoc_ExecuteCommand(HWND hwndDlg, char*, JabberAdHocData *dat) { int i = 1; for (auto *itemNode : TiXmlFilter(dat->CommandsNode, "item")) { @@ -125,12 +125,10 @@ int CJabberProto::AdHoc_ExecuteCommand(HWND hwndDlg, char*, JabberAdHocData *dat SetDlgItemText(hwndDlg, IDC_SUBMIT, TranslateT("OK")); } } - - return TRUE; } // Messages handlers -int CJabberProto::AdHoc_OnJAHMCommandListResult(HWND hwndDlg, TiXmlElement *iqNode, JabberAdHocData *dat) +void CJabberProto::AdHoc_OnJAHMCommandListResult(HWND hwndDlg, TiXmlElement *iqNode, JabberAdHocData *dat) { const char *type = XmlGetAttr(iqNode, "type"); if (!type || !mir_strcmp(type, "error")) { @@ -182,10 +180,9 @@ int CJabberProto::AdHoc_OnJAHMCommandListResult(HWND hwndDlg, TiXmlElement *iqNo } JabberAdHoc_RefreshFrameScroll(hwndDlg, dat); - return (TRUE); } -int CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, TiXmlElement *workNode, JabberAdHocData *dat) +void CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, TiXmlElement *workNode, JabberAdHocData *dat) { EnumChildWindows(GetDlgItem(hwndDlg, IDC_FRAME), sttDeleteChildWindowsProc, 0); dat->CurrentHeight = 0; @@ -193,17 +190,19 @@ int CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, TiXmlElement *workNode SetScrollPos(GetDlgItem(hwndDlg, IDC_VSCROLL), SB_CTL, 0, FALSE); if (workNode == nullptr) - return TRUE; + return; dat->AdHocNode = workNode->DeepClone(&dat->doc)->ToElement(); const char *type; - if ((type = XmlGetAttr(workNode, "type")) == nullptr) return TRUE; + if ((type = XmlGetAttr(workNode, "type")) == nullptr) + return; + if (!mir_strcmp(type, "result")) { // wParam = node from responder as a result of command execution const TiXmlElement *commandNode, *xNode; if ((commandNode = XmlFirstChild(dat->AdHocNode, "command")) == nullptr) - return TRUE; + return; const char *status = XmlGetAttr(commandNode, "status"); if (!status) @@ -270,10 +269,9 @@ int CJabberProto::AdHoc_OnJAHMProcessResult(HWND hwndDlg, TiXmlElement *workNode JabberFormSetInstruction(hwndDlg, CMStringA(FORMAT, TranslateU("Error %s %s"), code, description)); } JabberAdHoc_RefreshFrameScroll(hwndDlg, dat); - return TRUE; } -int CJabberProto::AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData *dat, char* action) +void CJabberProto::AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData *dat, char* action) { auto *commandNode = XmlFirstChild(dat->AdHocNode, "command"); auto *xNode = XmlFirstChild(commandNode, "x"); @@ -300,7 +298,6 @@ int CJabberProto::AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData *dat, ch static const int toDisable[] = { IDC_SUBMIT, IDC_PREV, IDC_NEXT, IDC_COMPLETE, 0 }; sttEnableControls(hwndDlg, FALSE, toDisable); - return TRUE; } int CJabberProto::AdHoc_AddCommandRadio(HWND hFrame, const char *labelStr, int id, int ypos, int value) @@ -396,16 +393,20 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_PREV: - return dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, "prev"); + dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, "prev"); + return TRUE; case IDC_NEXT: - return dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, "next"); + dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, "next"); + return TRUE; case IDC_COMPLETE: - return dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, "complete"); + dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, "complete"); + return TRUE; case IDC_SUBMIT: if (!dat->AdHocNode && dat->CommandsNode && LOWORD(wParam) == IDC_SUBMIT) - return dat->proto->AdHoc_ExecuteCommand(hwndDlg, dat->ResponderJID, dat); + dat->proto->AdHoc_ExecuteCommand(hwndDlg, dat->ResponderJID, dat); else - return dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, nullptr); + dat->proto->AdHoc_SubmitCommandForm(hwndDlg, dat, nullptr); + return TRUE; case IDCLOSE: case IDCANCEL: DestroyWindow(hwndDlg); @@ -414,10 +415,12 @@ static INT_PTR CALLBACK JabberAdHoc_CommandDlgProc(HWND hwndDlg, UINT msg, WPARA break; case JAHM_COMMANDLISTRESULT: - return dat->proto->AdHoc_OnJAHMCommandListResult(hwndDlg, (TiXmlElement*)lParam, dat); + dat->proto->AdHoc_OnJAHMCommandListResult(hwndDlg, (TiXmlElement*)lParam, dat); + return TRUE; case JAHM_PROCESSRESULT: - return dat->proto->AdHoc_OnJAHMProcessResult(hwndDlg, (TiXmlElement*)lParam, dat); + dat->proto->AdHoc_OnJAHMProcessResult(hwndDlg, (TiXmlElement*)lParam, dat); + return TRUE; case WM_MOUSEWHEEL: { diff --git a/protocols/JabberG/src/jabber_api.cpp b/protocols/JabberG/src/jabber_api.cpp index f97ad68b1c..f238fa7d15 100644 --- a/protocols/JabberG/src/jabber_api.cpp +++ b/protocols/JabberG/src/jabber_api.cpp @@ -115,25 +115,25 @@ void CJabberProto::ExternalTempIqHandler(const TiXmlElement *node, CJabberIqInfo free(d); // free IqHandlerData allocated in CJabberProto::AddIqHandler below } -BOOL CJabberProto::ExternalIqHandler(const TiXmlElement *node, CJabberIqInfo *pInfo) +bool CJabberProto::ExternalIqHandler(const TiXmlElement *node, CJabberIqInfo *pInfo) { sHandlerData *d = (sHandlerData*)pInfo->GetUserData(); return d->Func(this, node, d->pUserData); } -BOOL CJabberProto::ExternalMessageHandler(const TiXmlElement *node, ThreadData*, CJabberMessageInfo* pInfo) +bool CJabberProto::ExternalMessageHandler(const TiXmlElement *node, ThreadData*, CJabberMessageInfo* pInfo) { sHandlerData *d = (sHandlerData*)pInfo->GetUserData(); return d->Func(this, node, d->pUserData); } -BOOL CJabberProto::ExternalPresenceHandler(const TiXmlElement *node, ThreadData*, CJabberPresenceInfo* pInfo) +bool CJabberProto::ExternalPresenceHandler(const TiXmlElement *node, ThreadData*, CJabberPresenceInfo* pInfo) { sHandlerData *d = (sHandlerData*)pInfo->GetUserData(); return d->Func(this, node, d->pUserData); } -BOOL CJabberProto::ExternalSendHandler(const TiXmlElement *node, ThreadData*, CJabberSendInfo* pInfo) +bool CJabberProto::ExternalSendHandler(const TiXmlElement *node, ThreadData*, CJabberSendInfo* pInfo) { sHandlerData *d = (sHandlerData*)pInfo->GetUserData(); return d->Func(this, node, d->pUserData); diff --git a/protocols/JabberG/src/jabber_archive.cpp b/protocols/JabberG/src/jabber_archive.cpp index adc1811f2d..2c478b2b61 100644 --- a/protocols/JabberG/src/jabber_archive.cpp +++ b/protocols/JabberG/src/jabber_archive.cpp @@ -83,12 +83,12 @@ static MCONTACT hPreviousContact = INVALID_CONTACT_ID; static MEVENT hPreviousDbEvent = 0; // Returns TRUE if the event already exist in the database -BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) +bool IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) { // get last event MEVENT hExistingDbEvent = db_event_last(hContact); if (!hExistingDbEvent) - return FALSE; + return false; DBEVENTINFO dbeiExisting = {}; db_event_get(hExistingDbEvent, &dbeiExisting); @@ -99,7 +99,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) // remember event hPreviousDbEvent = hExistingDbEvent; dwPreviousTimeStamp = dwEventTimeStamp; - return FALSE; + return false; } if (hContact != hPreviousContact) { @@ -110,7 +110,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) // get first event if (!(hExistingDbEvent = db_event_first(hContact))) - return FALSE; + return false; memset(&dbeiExisting, 0, sizeof(dbeiExisting)); db_event_get(hExistingDbEvent, &dbeiExisting); @@ -123,7 +123,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) hPreviousDbEvent = hExistingDbEvent; if (dbei.timestamp != dwEventTimeStamp) - return FALSE; + return false; } } @@ -133,7 +133,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) db_event_get(hPreviousDbEvent, &dbeiExisting); if (dbei == dbeiExisting) - return TRUE; + return true; // find event with another timestamp hExistingDbEvent = db_event_next(hContact, hPreviousDbEvent); @@ -165,7 +165,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) // remember event hPreviousDbEvent = hExistingDbEvent; dwPreviousTimeStamp = dbeiExisting.timestamp; - return FALSE; + return false; } // Compare event with import candidate @@ -173,7 +173,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) // remember event hPreviousDbEvent = hExistingDbEvent; dwPreviousTimeStamp = dbeiExisting.timestamp; - return TRUE; + return true; } // Get previous event in chain @@ -190,7 +190,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) // remember event hPreviousDbEvent = hExistingDbEvent; dwPreviousTimeStamp = dbeiExisting.timestamp; - return FALSE; + return false; } // Compare event with import candidate @@ -198,7 +198,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) // remember event hPreviousDbEvent = hExistingDbEvent; dwPreviousTimeStamp = dbeiExisting.timestamp; - return TRUE; + return true; } // Get next event in chain @@ -207,7 +207,7 @@ BOOL IsDuplicateEvent(MCONTACT hContact, DBEVENTINFO& dbei) } // reset last event hPreviousContact = INVALID_CONTACT_ID; - return FALSE; + return false; } void CJabberProto::OnIqResultGetCollection(const TiXmlElement *iqNode, CJabberIqInfo*) diff --git a/protocols/JabberG/src/jabber_byte.cpp b/protocols/JabberG/src/jabber_byte.cpp index ac3b06e3c9..0a1f24e297 100644 --- a/protocols/JabberG/src/jabber_byte.cpp +++ b/protocols/JabberG/src/jabber_byte.cpp @@ -155,7 +155,7 @@ void CJabberProto::ByteSendThread(JABBER_BYTE_TRANSFER *jbt) if (m_bBsProxyManual) { ptrA proxyJid(getUStringA("BsProxyServer")); if (proxyJid) { - jbt->bProxyDiscovered = FALSE; + jbt->bProxyDiscovered = false; jbt->szProxyHost = nullptr; jbt->szProxyPort = nullptr; jbt->szProxyJid = nullptr; @@ -414,7 +414,7 @@ void CJabberProto::IqResultStreamActivate(const TiXmlElement *iqNode, CJabberIqI return; if (!mir_strcmp(XmlGetAttr(iqNode, "type"), "result")) - item->jbt->bStreamActivated = TRUE; + item->jbt->bStreamActivated = true; if (item->jbt->hProxyEvent) SetEvent(item->jbt->hProxyEvent); @@ -434,7 +434,7 @@ void CJabberProto::ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt) } jbt->state = JBT_INIT; - BOOL validStreamhost = FALSE; + bool validStreamhost = false; char *szPort = jbt->szProxyPort; char *szHost = jbt->szProxyHost; @@ -466,7 +466,8 @@ void CJabberProto::ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt) if (bytesParsed < datalen) memmove(buffer, buffer + bytesParsed, datalen - bytesParsed); datalen -= bytesParsed; - if (jbt->state == JBT_DONE) validStreamhost = TRUE; + if (jbt->state == JBT_DONE) + validStreamhost = true; } Netlib_CloseHandle(hConn); } @@ -536,7 +537,7 @@ int CJabberProto::ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jb jbt->state = JBT_SENDING; jbt->hProxyEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); - jbt->bStreamActivated = FALSE; + jbt->bStreamActivated = false; auto *pIq = AddIQ(&CJabberProto::IqResultStreamActivate, JABBER_IQ_TYPE_SET, jbt->streamhostJID); @@ -568,15 +569,17 @@ int CJabberProto::ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jb void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt) { + Thread_SetName("Jabber: ByteReceiveThread"); + + if (jbt == nullptr) + return; + const TiXmlElement *iqNode, *queryNode = nullptr; WORD port; char data[3]; char* buffer; int datalen, bytesParsed, recvResult; - BOOL validStreamhost = FALSE; - - if (jbt == nullptr) return; - Thread_SetName("Jabber: ByteReceiveThread"); + bool validStreamhost = false; jbt->state = JBT_INIT; @@ -636,12 +639,13 @@ void __cdecl CJabberProto::ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt) if (bytesParsed < datalen) memmove(buffer, buffer + bytesParsed, datalen - bytesParsed); datalen -= bytesParsed; - if (jbt->state == JBT_RECVING) validStreamhost = TRUE; + if (jbt->state == JBT_RECVING) + validStreamhost = true; } Netlib_CloseHandle(hConn); debugLogA("bytestream_recv_connection closing connection"); } - if (jbt->state == JBT_ERROR || validStreamhost == TRUE) + if (jbt->state == JBT_ERROR || validStreamhost) break; debugLogA("bytestream_recv_connection stream cannot be established, try next streamhost"); } diff --git a/protocols/JabberG/src/jabber_byte.h b/protocols/JabberG/src/jabber_byte.h index 434e3b27f0..d2308214ef 100644 --- a/protocols/JabberG/src/jabber_byte.h +++ b/protocols/JabberG/src/jabber_byte.h @@ -45,19 +45,18 @@ struct JABBER_BYTE_TRANSFER : public MZeroedObject HANDLE hEvent; TiXmlDocument doc; TiXmlElement *iqNode; - BOOL (CJabberProto::*pfnSend)(HNETLIBCONN hConn, filetransfer *ft); - int (CJabberProto::*pfnRecv)(HNETLIBCONN hConn, filetransfer *ft, char* buffer, int datalen); + bool (CJabberProto::*pfnSend)(HNETLIBCONN hConn, filetransfer *ft); + int (CJabberProto::*pfnRecv)(HNETLIBCONN hConn, filetransfer *ft, char* buffer, int datalen); void (CJabberProto::*pfnFinal)(BOOL success, filetransfer *ft); filetransfer *ft; // XEP-0065 proxy support - BOOL bProxyDiscovered; + bool bProxyDiscovered, bStreamActivated; HANDLE hProxyEvent; char *szProxyHost; char *szProxyPort; char *szProxyJid; char *szStreamhostUsed; - BOOL bStreamActivated; HANDLE hSendEvent; }; diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 3df9b3df91..e3512d3321 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -63,14 +63,14 @@ struct TRoleOrAffiliationInfo wchar_t *title; - BOOL check(JABBER_RESOURCE_STATUS *me, JABBER_RESOURCE_STATUS *him) + bool check(JABBER_RESOURCE_STATUS *me, JABBER_RESOURCE_STATUS *him) { - if (me->m_affiliation == AFFILIATION_OWNER) return TRUE; - if (me == him) return FALSE; - if (me->m_affiliation <= him->m_affiliation) return FALSE; - if (me->m_role < min_role) return FALSE; - if (me->m_affiliation < min_affiliation) return FALSE; - return TRUE; + if (me->m_affiliation == AFFILIATION_OWNER) return true; + if (me == him) return false; + if (me->m_affiliation <= him->m_affiliation) return false; + if (me->m_role < min_role) return false; + if (me->m_affiliation < min_affiliation) return false; + return true; } void translate() diff --git a/protocols/JabberG/src/jabber_console.cpp b/protocols/JabberG/src/jabber_console.cpp index 0a612dfacb..e11f7dcadf 100644 --- a/protocols/JabberG/src/jabber_console.cpp +++ b/protocols/JabberG/src/jabber_console.cpp @@ -603,7 +603,7 @@ void CJabberProto::ConsoleUninit() m_hThreadConsole = nullptr; } - m_filterInfo.iq = m_filterInfo.msg = m_filterInfo.presence = FALSE; + m_filterInfo.iq = m_filterInfo.msg = m_filterInfo.presence = false; m_filterInfo.type = TFilterInfo::T_OFF; } diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp index 647309492a..c909bb5b5c 100644 --- a/protocols/JabberG/src/jabber_disco.cpp +++ b/protocols/JabberG/src/jabber_disco.cpp @@ -217,10 +217,10 @@ void CJabberProto::OnIqResultServiceDiscoveryRootItems(const TiXmlElement *iqNod m_ThreadInfo->send(packet.RootElement()); } -BOOL CJabberProto::SendInfoRequest(CJabberSDNode *pNode, TiXmlNode *parent) +bool CJabberProto::SendInfoRequest(CJabberSDNode *pNode, TiXmlNode *parent) { if (!pNode || !m_bJabberOnline) - return FALSE; + return false; // disco#info if (!pNode->GetInfoRequestId()) { @@ -244,13 +244,13 @@ BOOL CJabberProto::SendInfoRequest(CJabberSDNode *pNode, TiXmlNode *parent) PostMessage(m_pDlgServiceDiscovery->GetHwnd(), WM_JABBER_REFRESH, 0, 0); } - return TRUE; + return true; } -BOOL CJabberProto::SendBothRequests(CJabberSDNode *pNode, TiXmlNode *parent) +bool CJabberProto::SendBothRequests(CJabberSDNode *pNode, TiXmlNode *parent) { if (!pNode || !m_bJabberOnline) - return FALSE; + return false; // disco#info if (!pNode->GetInfoRequestId()) { @@ -291,7 +291,7 @@ BOOL CJabberProto::SendBothRequests(CJabberSDNode *pNode, TiXmlNode *parent) PostMessage(m_pDlgServiceDiscovery->GetHwnd(), WM_JABBER_REFRESH, 0, 0); } - return TRUE; + return true; } void CJabberProto::PerformBrowse(HWND hwndDlg) @@ -373,19 +373,19 @@ void CJabberProto::PerformBrowse(HWND hwndDlg) PostMessage(hwndDlg, WM_JABBER_REFRESH, 0, 0); } -BOOL CJabberProto::IsNodeRegistered(CJabberSDNode *pNode) +bool CJabberProto::IsNodeRegistered(CJabberSDNode *pNode) { if (pNode->GetNode()) - return FALSE; + return false; JABBER_LIST_ITEM *item; if (item = ListGetItemPtr(LIST_ROSTER, pNode->GetJid())) - return (item->subscription != SUB_NONE) ? TRUE : FALSE; + return item->subscription != SUB_NONE; if (item = ListGetItemPtr(LIST_BOOKMARK, pNode->GetJid())) - return TRUE; + return true; - return FALSE; + return false; } void CJabberProto::ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode) @@ -444,9 +444,10 @@ void CJabberProto::ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode) TreeList_SetIcon(pNode->GetTreeItemHandle(), iIcon, iOverlay); } -BOOL CJabberProto::SyncTree(HTREELISTITEM hIndex, CJabberSDNode *pNode) +bool CJabberProto::SyncTree(HTREELISTITEM hIndex, CJabberSDNode *pNode) { - if (!m_pDlgServiceDiscovery) return FALSE; + if (!m_pDlgServiceDiscovery) + return false; CJabberSDNode* pTmp = pNode; while (pTmp) { @@ -471,7 +472,7 @@ BOOL CJabberProto::SyncTree(HTREELISTITEM hIndex, CJabberSDNode *pNode) pTmp = pTmp->GetNext(); } - return TRUE; + return true; } /////////////////////////////////////////////////////////////////////////////// @@ -865,7 +866,8 @@ public: m_proto->m_dwSDLastRefresh = GetTickCount(); return TRUE; } - else if (wParam == AUTODISCO_TIMER) { + + if (wParam == AUTODISCO_TIMER) { HWND hwndList = GetDlgItem(m_hwnd, IDC_TREE_DISCO); RECT rcCtl; GetClientRect(hwndList, &rcCtl); RECT rcHdr; GetClientRect(ListView_GetHeader(hwndList), &rcHdr); @@ -915,7 +917,8 @@ public: if ((pt.x == -1) && (pt.y == -1)) { LVITEM lvi = { 0 }; lvi.iItem = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED); - if (lvi.iItem < 0) return FALSE; + if (lvi.iItem < 0) + return FALSE; RECT rc; ListView_GetItemRect(hwndList, lvi.iItem, &rc, LVIR_LABEL); @@ -1079,7 +1082,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM }; HMENU hMenu = CreatePopupMenu(); - BOOL lastSeparator = TRUE; + bool lastSeparator = true; bool bFilterItems = !GetAsyncKeyState(VK_CONTROL); for (auto &it : items) { JABBER_LIST_ITEM *rosterItem = nullptr; @@ -1112,11 +1115,11 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hContactMenu, TranslateW(it.title)); } else AppendMenu(hMenu, MF_STRING, it.action, TranslateW(it.title)); - lastSeparator = FALSE; + lastSeparator = false; } else if (!lastSeparator) { AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr); - lastSeparator = TRUE; + lastSeparator = true; } continue; } @@ -1146,11 +1149,11 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM } AppendMenu(hMenu, dwFlags, it.action, TranslateW(it.title)); - lastSeparator = FALSE; + lastSeparator = false; } else if (!lastSeparator) { AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr); - lastSeparator = TRUE; + lastSeparator = true; } } } diff --git a/protocols/JabberG/src/jabber_disco.h b/protocols/JabberG/src/jabber_disco.h index fa0fd62844..5954b29f03 100644 --- a/protocols/JabberG/src/jabber_disco.h +++ b/protocols/JabberG/src/jabber_disco.h @@ -155,7 +155,8 @@ public: { RemoveAll(); } - BOOL RemoveAll() + + void RemoveAll() { replaceStr(m_szJid, nullptr); replaceStr(m_szNode, nullptr); @@ -179,9 +180,9 @@ public: m_dwInfoRequestTime = 0; m_dwItemsRequestTime = 0; m_hTreeItem = nullptr; - return TRUE; } - BOOL ResetInfo() + + void ResetInfo() { replaceStrW(m_szInfoError, nullptr); replaceStrW(m_szItemsError, nullptr); @@ -198,81 +199,92 @@ public: m_nItemsRequestId = JABBER_DISCO_RESULT_NOT_REQUESTED; m_dwInfoRequestTime = 0; m_dwItemsRequestTime = 0; - return TRUE; } - BOOL SetTreeItemHandle(HTREELISTITEM hItem) + + void SetTreeItemHandle(HTREELISTITEM hItem) { m_hTreeItem = hItem; - return TRUE; } + HTREELISTITEM GetTreeItemHandle() { return m_hTreeItem; } - BOOL SetInfoRequestId(int nId) + + void SetInfoRequestId(int nId) { m_nInfoRequestId = nId; m_dwInfoRequestTime = GetTickCount(); - return TRUE; } + int GetInfoRequestId() { return m_nInfoRequestId; } - BOOL SetItemsRequestId(int nId) + + void SetItemsRequestId(int nId) { m_nItemsRequestId = nId; m_dwItemsRequestTime = GetTickCount(); - return TRUE; } + int GetItemsRequestId() { return m_nItemsRequestId; } - BOOL SetJid(char *szJid) + + void SetJid(char *szJid) { replaceStr(m_szJid, szJid); - return TRUE; } + char* GetJid() { return m_szJid; } - BOOL SetNode(char *szNode) + + void SetNode(char *szNode) { replaceStr(m_szNode, szNode); - return TRUE; } + char* GetNode() { return m_szNode; } - char *GetName() + + char* GetName() { return m_szName; } + CJabberSDIdentity* GetFirstIdentity() { return m_pIdentities; } + CJabberSDFeature* GetFirstFeature() { return m_pFeatures; } + CJabberSDNode* GetFirstChildNode() { return m_pChild; } + CJabberSDNode* GetNext() { return m_pNext; } + CJabberSDNode* SetNext(CJabberSDNode *pNext) { CJabberSDNode *pRetVal = m_pNext; m_pNext = pNext; return pRetVal; } + CJabberSDNode* FindByIqId(int nIqId, BOOL bInfoId = TRUE) { if ((m_nInfoRequestId == nIqId && bInfoId) || (m_nItemsRequestId == nIqId && !bInfoId)) @@ -293,58 +305,57 @@ public: } return nullptr; } - BOOL AddFeature(const char *szFeature) + + bool AddFeature(const char *szFeature) { if (!szFeature) - return FALSE; + return false; CJabberSDFeature *pFeature = new CJabberSDFeature(szFeature); if (!pFeature) - return FALSE; + return false; pFeature->SetNext(m_pFeatures); m_pFeatures = pFeature; - - return TRUE; + return true; } - BOOL AddIdentity(const char *szCategory, const char *szType, const char*szName) + + bool AddIdentity(const char *szCategory, const char *szType, const char*szName) { if (!szCategory || !szType) - return FALSE; + return false; CJabberSDIdentity *pIdentity = new CJabberSDIdentity(szCategory, szType, szName); if (!pIdentity) - return FALSE; + return false; pIdentity->SetNext(m_pIdentities); m_pIdentities = pIdentity; - - return TRUE; + return true; } - BOOL AddChildNode(const char *szJid, const char *szNode, const char *szName) + + bool AddChildNode(const char *szJid, const char *szNode, const char *szName) { if (!szJid) - return FALSE; + return false; CJabberSDNode *pNode = new CJabberSDNode(szJid, szNode, szName); if (!pNode) - return FALSE; + return false; pNode->SetNext(m_pChild); m_pChild = pNode; - return TRUE; + return true; } - BOOL SetItemsRequestErrorText(const wchar_t *szError) + void SetItemsRequestErrorText(const wchar_t *szError) { replaceStrW(m_szItemsError, szError); - return TRUE; } - BOOL SetInfoRequestErrorText(const wchar_t *szError) + void SetInfoRequestErrorText(const wchar_t *szError) { replaceStrW(m_szInfoError, szError); - return TRUE; } CMStringA GetTooltipText() diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index c7123fb2d5..d0b5b41bfe 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -90,6 +90,15 @@ void CJabberProto::FtInitiate(const char* jid, filetransfer *ft) if (wchar_t *p = wcsrchr(filename, '\\')) filename = p + 1; + // if we enabled XEP-0231, try to inline a picture + if (m_bInlinePictures && ProtoGetAvatarFileFormat(ft->std.szCurrentFile.w)) { + if (FtTryInlineFile(ft->std.szCurrentFile.w)) { + ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); + delete ft; + return; + } + } + // if we use XEP-0363, send a slot allocation request if (m_bUseHttpUpload) { ptrA szUploadService(getStringA("HttpUpload")); @@ -208,31 +217,29 @@ void CJabberProto::OnFtSiResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo } } -BOOL CJabberProto::FtSend(HNETLIBCONN hConn, filetransfer *ft) +bool CJabberProto::FtSend(HNETLIBCONN hConn, filetransfer *ft) { - int fd; - char* buffer; - int numRead; - debugLogW(L"Sending [%s]", ft->std.pszFiles.w[ft->std.currentFileNumber]); struct _stat64 statbuf; _wstat64(ft->std.pszFiles.w[ft->std.currentFileNumber], &statbuf); // file size in statbuf.st_size - if ((fd = _wopen(ft->std.pszFiles.w[ft->std.currentFileNumber], _O_BINARY | _O_RDONLY)) < 0) { + int fd = _wopen(ft->std.pszFiles.w[ft->std.currentFileNumber], _O_BINARY | _O_RDONLY); + if (fd < 0) { debugLogA("File cannot be opened"); - return FALSE; + return false; } ft->std.flags |= PFTS_SENDING; ft->std.currentFileSize = statbuf.st_size; ft->std.currentFileProgress = 0; - if ((buffer = (char*)mir_alloc(2048)) != nullptr) { + if (char *buffer = (char *)mir_alloc(2048)) { + int numRead; while ((numRead = _read(fd, buffer, 2048)) > 0) { if (Netlib_Send(hConn, buffer, numRead, 0) != numRead) { mir_free(buffer); _close(fd); - return FALSE; + return false; } ft->std.currentFileProgress += numRead; ft->std.totalProgress += numRead; @@ -241,10 +248,10 @@ BOOL CJabberProto::FtSend(HNETLIBCONN hConn, filetransfer *ft) mir_free(buffer); } _close(fd); - return TRUE; + return true; } -BOOL CJabberProto::FtIbbSend(int blocksize, filetransfer *ft) +bool CJabberProto::FtIbbSend(int blocksize, filetransfer *ft) { debugLogW(L"Sending [%s]", ft->std.pszFiles.w[ft->std.currentFileNumber]); @@ -254,7 +261,7 @@ BOOL CJabberProto::FtIbbSend(int blocksize, filetransfer *ft) int fd = _wopen(ft->std.pszFiles.w[ft->std.currentFileNumber], _O_BINARY | _O_RDONLY); if (fd < 0) { debugLogA("File cannot be opened"); - return FALSE; + return false; } ft->std.flags |= PFTS_SENDING; @@ -286,7 +293,7 @@ BOOL CJabberProto::FtIbbSend(int blocksize, filetransfer *ft) if (ft->jibb->state == JIBB_ERROR || ft->jibb->bStreamClosed || m_ThreadInfo->send(msg) == SOCKET_ERROR) { debugLogA("JabberFtIbbSend unsuccessful exit"); _close(fd); - return FALSE; + return false; } ft->jibb->dwTransferredSize += (DWORD)numRead; @@ -297,7 +304,7 @@ BOOL CJabberProto::FtIbbSend(int blocksize, filetransfer *ft) } } _close(fd); - return TRUE; + return true; } void CJabberProto::FtSendFinal(BOOL success, filetransfer *ft) @@ -439,14 +446,13 @@ void CJabberProto::FtAcceptIbbRequest(filetransfer *ft) } } -BOOL CJabberProto::FtHandleBytestreamRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) +bool CJabberProto::FtHandleBytestreamRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) { auto *queryNode = pInfo->GetChildNode(); const char *sid = XmlGetAttr(queryNode, "sid"); JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTRECV, sid); - - if ((sid ) != nullptr && (item ) != nullptr) { + if (sid && item) { // Start Bytestream session JABBER_BYTE_TRANSFER *jbt = new JABBER_BYTE_TRANSFER; jbt->iqNode = iqNode->DeepClone(&jbt->doc)->ToElement(); @@ -456,27 +462,31 @@ BOOL CJabberProto::FtHandleBytestreamRequest(const TiXmlElement *iqNode, CJabber item->ft->jbt = jbt; ForkThread((MyThreadFunc)&CJabberProto::ByteReceiveThread, jbt); ListRemove(LIST_FTRECV, sid); - return TRUE; + return true; } debugLogA("File transfer invalid bytestream initiation request received"); - return TRUE; + return true; } -BOOL CJabberProto::FtHandleIbbRequest(const TiXmlElement *iqNode, BOOL bOpen) +bool CJabberProto::FtHandleIbbRequest(const TiXmlElement *iqNode, bool bOpen) { - if (iqNode == nullptr) return FALSE; + if (iqNode == nullptr) + return false; const char *id = XmlGetAttr(iqNode, "id"); const char *from = XmlGetAttr(iqNode, "from"); const char *to = XmlGetAttr(iqNode, "to"); - if (!id || !from || !to) return FALSE; + if (!id || !from || !to) + return false; auto *ibbNode = XmlGetChildByTag(iqNode, bOpen ? "open" : "close", "xmlns", JABBER_FEAT_IBB); - if (!ibbNode) return FALSE; + if (!ibbNode) + return false; const char *sid = XmlGetAttr(ibbNode, "sid"); - if (!sid) return FALSE; + if (!sid) + return false; // already closed? JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTRECV, sid); @@ -485,7 +495,7 @@ BOOL CJabberProto::FtHandleIbbRequest(const TiXmlElement *iqNode, BOOL bOpen) XmlNodeIq("error", id, from) << XCHILD("error") << XATTRI("code", 404) << XATTR("type", "cancel") << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas")); - return FALSE; + return false; } // open event @@ -504,28 +514,27 @@ BOOL CJabberProto::FtHandleIbbRequest(const TiXmlElement *iqNode, BOOL bOpen) ForkThread((MyThreadFunc)&CJabberProto::IbbReceiveThread, jibb); m_ThreadInfo->send(XmlNodeIq("result", id, from)); - return TRUE; + return true; } // stream already open m_ThreadInfo->send( XmlNodeIq("error", id, from) << XCHILD("error") << XATTRI("code", 404) << XATTR("type", "cancel") << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas")); - return FALSE; + return false; } // close event && stream already open if (item->jibb && item->jibb->hEvent) { - item->jibb->bStreamClosed = TRUE; + item->jibb->bStreamClosed = true; SetEvent(item->jibb->hEvent); m_ThreadInfo->send(XmlNodeIq("result", id, from)); - return TRUE; + return true; } ListRemove(LIST_FTRECV, sid); - - return FALSE; + return false; } int CJabberProto::FtReceive(HNETLIBCONN, filetransfer *ft, char* buffer, int datalen) @@ -561,6 +570,8 @@ void CJabberProto::FtReceiveFinal(BOOL success, filetransfer *ft) delete ft; } +///////////////////////////////////////////////////////////////////////////////////////// + void CJabberProto::OnHttpSlotAllocated(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) { filetransfer *ft = (filetransfer *)pInfo->GetUserData(); @@ -663,3 +674,10 @@ LBL_Fail: else debugLogA("wrong or not recognizable http slot received"); goto LBL_Fail; } + +///////////////////////////////////////////////////////////////////////////////////////// + +bool CJabberProto::FtTryInlineFile(const wchar_t *pwszFileName) +{ + return false; +} diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 2c194c073f..033d56213c 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -165,14 +165,14 @@ struct JabberGcRecentInfo } private: - BOOL null_strequals(const char *str1, const char *str2) + bool null_strequals(const char *str1, const char *str2) { - if (!str1 && !str2) return TRUE; - if (!str1 && str2 && !*str2) return TRUE; - if (!str2 && str1 && !*str1) return TRUE; + if (!str1 && !str2) return true; + if (!str1 && str2 && !*str2) return true; + if (!str2 && str1 && !*str1) return true; - if (!str1 && str2) return FALSE; - if (!str2 && str1) return FALSE; + if (!str1 && str2) return false; + if (!str2 && str1) return false; return !mir_strcmp(str1, str2); } diff --git a/protocols/JabberG/src/jabber_ibb.cpp b/protocols/JabberG/src/jabber_ibb.cpp index 0550571ea7..1ce839ede7 100644 --- a/protocols/JabberG/src/jabber_ibb.cpp +++ b/protocols/JabberG/src/jabber_ibb.cpp @@ -45,14 +45,14 @@ void JabberIbbFreeJibb(JABBER_IBB_TRANSFER *jibb) } } -BOOL CJabberProto::OnFtHandleIbbIq(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) +bool CJabberProto::OnFtHandleIbbIq(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) { if (!mir_strcmp(pInfo->GetChildNodeName(), "open")) - FtHandleIbbRequest(iqNode, TRUE); + FtHandleIbbRequest(iqNode, true); else if (!mir_strcmp(pInfo->GetChildNodeName(), "close")) - FtHandleIbbRequest(iqNode, FALSE); + FtHandleIbbRequest(iqNode, false); else if (!mir_strcmp(pInfo->GetChildNodeName(), "data")) { - BOOL bOk = FALSE; + bool bOk = false; const char *sid = XmlGetAttr(pInfo->GetChildNode(), "sid"); const char *seq = XmlGetAttr(pInfo->GetChildNode(), "seq"); if (sid && seq && pInfo->GetChildNode()->GetText()) @@ -66,14 +66,14 @@ BOOL CJabberProto::OnFtHandleIbbIq(const TiXmlElement *iqNode, CJabberIqInfo *pI << XCHILD("error") << XATTRI("code", 404) << XATTR("type", "cancel") << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas")); } - return TRUE; + return true; } void CJabberProto::OnIbbInitiateResult(const TiXmlElement*, CJabberIqInfo *pInfo) { JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *)pInfo->GetUserData(); if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) - jibb->bStreamInitialized = TRUE; + jibb->bStreamInitialized = true; if (jibb->hEvent) SetEvent(jibb->hEvent); } @@ -82,7 +82,7 @@ void CJabberProto::OnIbbCloseResult(const TiXmlElement*, CJabberIqInfo *pInfo) { JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *)pInfo->GetUserData(); if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT) - jibb->bStreamClosed = TRUE; + jibb->bStreamClosed = true; if (jibb->hEvent) SetEvent(jibb->hEvent); } @@ -93,8 +93,8 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb) Thread_SetName("Jabber: IbbSendThread"); jibb->hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); - jibb->bStreamInitialized = FALSE; - jibb->bStreamClosed = FALSE; + jibb->bStreamInitialized = false; + jibb->bStreamClosed = false; jibb->state = JIBB_SENDING; m_ThreadInfo->send( @@ -141,7 +141,7 @@ void __cdecl CJabberProto::IbbReceiveThread(JABBER_IBB_TRANSFER *jibb) filetransfer *ft = jibb->ft; jibb->hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); - jibb->bStreamClosed = FALSE; + jibb->bStreamClosed = false; jibb->wPacketId = 0; jibb->dwTransferredSize = 0; jibb->state = JIBB_RECVING; @@ -165,16 +165,17 @@ void __cdecl CJabberProto::IbbReceiveThread(JABBER_IBB_TRANSFER *jibb) JabberIbbFreeJibb(jibb); } -BOOL CJabberProto::OnIbbRecvdData(const char *data, const char *sid, const char *seq) +bool CJabberProto::OnIbbRecvdData(const char *data, const char *sid, const char *seq) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTRECV, sid); - if (item == nullptr) return FALSE; + if (item == nullptr) + return false; WORD wSeq = (WORD)atoi(seq); if (wSeq != item->jibb->wPacketId) { if (item->jibb->hEvent) SetEvent(item->jibb->hEvent); - return FALSE; + return false; } item->jibb->wPacketId++; @@ -182,9 +183,9 @@ BOOL CJabberProto::OnIbbRecvdData(const char *data, const char *sid, const char size_t length; ptrA decodedData((char*)mir_base64_decode(data, &length)); if (decodedData == nullptr) - return FALSE; + return false; (this->*item->jibb->pfnRecv)(nullptr, item->ft, decodedData, (int)length); item->jibb->dwTransferredSize += (DWORD)length; - return TRUE; + return true; } diff --git a/protocols/JabberG/src/jabber_ibb.h b/protocols/JabberG/src/jabber_ibb.h index 6c67964be4..e6f31187ec 100644 --- a/protocols/JabberG/src/jabber_ibb.h +++ b/protocols/JabberG/src/jabber_ibb.h @@ -36,11 +36,11 @@ struct JABBER_IBB_TRANSFER unsigned __int64 dwTransferredSize; JABBER_IBB_STATE state; HANDLE hEvent; - BOOL bStreamInitialized; - BOOL bStreamClosed; + bool bStreamInitialized; + bool bStreamClosed; WORD wPacketId; - BOOL (CJabberProto::*pfnSend)(int blocksize, filetransfer *ft); - int (CJabberProto::*pfnRecv)(HNETLIBCONN hConn, filetransfer *ft, char* buffer, int datalen); + bool (CJabberProto::*pfnSend)(int blocksize, filetransfer *ft); + int (CJabberProto::*pfnRecv)(HNETLIBCONN hConn, filetransfer *ft, char* buffer, int datalen); void (CJabberProto::*pfnFinal)(BOOL success, filetransfer *ft); filetransfer *ft; }; diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp index 420ed4ca97..f25d7db8f0 100644 --- a/protocols/JabberG/src/jabber_icolib.cpp +++ b/protocols/JabberG/src/jabber_icolib.cpp @@ -349,16 +349,16 @@ INT_PTR __cdecl CJabberProto::JGetAdvancedStatusIcon(WPARAM hContact, LPARAM) ///////////////////////////////////////////////////////////////////////////////////////// // Transport check functions -BOOL CJabberProto::DBCheckIsTransportedContact(const char *jid, MCONTACT hContact) +bool CJabberProto::DBCheckIsTransportedContact(const char *jid, MCONTACT hContact) { // check if transport is already set if (!jid || !hContact) - return FALSE; + return false; // strip domain part from jid char *domain = (char*)strchr(jid, '@'); - BOOL isAgent = (domain == nullptr) ? TRUE : FALSE; - BOOL isTransported = FALSE; + bool isAgent = (domain == nullptr); + bool isTransported = false; if (domain != nullptr) domain = NEWSTR_ALLOCA(domain + 1); else @@ -371,7 +371,7 @@ BOOL CJabberProto::DBCheckIsTransportedContact(const char *jid, MCONTACT hContac for (auto &it : TransportProtoTable) if (MatchMask(domain, it.mask)) { GetTransportStatusIconIndex(GetTransportProtoID(domain), ID_STATUS_OFFLINE); - isTransported = TRUE; + isTransported = true; break; } diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp index 1cbebeb778..ab6d07bec2 100644 --- a/protocols/JabberG/src/jabber_iq.cpp +++ b/protocols/JabberG/src/jabber_iq.cpp @@ -75,7 +75,7 @@ void CJabberIqManager::Shutdown() if (m_bExpirerThreadShutdownRequest || !m_hExpirerThread) return; - m_bExpirerThreadShutdownRequest = TRUE; + m_bExpirerThreadShutdownRequest = true; WaitForSingleObject(m_hExpirerThread, INFINITE); CloseHandle(m_hExpirerThread); diff --git a/protocols/JabberG/src/jabber_iq.h b/protocols/JabberG/src/jabber_iq.h index 63efe6ae84..a067f75c68 100644 --- a/protocols/JabberG/src/jabber_iq.h +++ b/protocols/JabberG/src/jabber_iq.h @@ -37,7 +37,7 @@ typedef void (*IQ_USER_DATA_FREE_FUNC)(void *pUserData); #define JABBER_DEFAULT_IQ_REQUEST_TIMEOUT 120000 typedef void (CJabberProto::*JABBER_IQ_HANDLER)(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); -typedef BOOL (CJabberProto::*JABBER_PERMANENT_IQ_HANDLER)(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); +typedef bool (CJabberProto::*JABBER_PERMANENT_IQ_HANDLER)(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); #define JABBER_IQ_PARSE_CHILD_TAG_NODE (1) #define JABBER_IQ_PARSE_CHILD_TAG_NAME ((1<<1)|JABBER_IQ_PARSE_CHILD_TAG_NODE) diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp index 65c35b3f76..56a1907668 100644 --- a/protocols/JabberG/src/jabber_iq_handlers.cpp +++ b/protocols/JabberG/src/jabber_iq_handlers.cpp @@ -28,13 +28,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber_rc.h" #include "version.h" -BOOL CJabberProto::OnIqRequestVersion(const TiXmlElement*, CJabberIqInfo *pInfo) +bool CJabberProto::OnIqRequestVersion(const TiXmlElement*, CJabberIqInfo *pInfo) { if (!pInfo->GetFrom()) - return TRUE; + return true; if (!m_bAllowVersionRequests) - return FALSE; + return false; XmlNodeIq iq("result", pInfo); TiXmlElement *query = iq << XQUERY(JABBER_FEAT_VERSION); @@ -49,23 +49,23 @@ BOOL CJabberProto::OnIqRequestVersion(const TiXmlElement*, CJabberIqInfo *pInfo) } m_ThreadInfo->send(iq); - return TRUE; + return true; } // last activity (XEP-0012) support -BOOL CJabberProto::OnIqRequestLastActivity(const TiXmlElement*, CJabberIqInfo *pInfo) +bool CJabberProto::OnIqRequestLastActivity(const TiXmlElement*, CJabberIqInfo *pInfo) { m_ThreadInfo->send( XmlNodeIq("result", pInfo) << XQUERY(JABBER_FEAT_LAST_ACTIVITY) << XATTRI("seconds", m_tmJabberIdleStartTime ? time(0) - m_tmJabberIdleStartTime : 0)); - return TRUE; + return true; } // XEP-0199: XMPP Ping support -BOOL CJabberProto::OnIqRequestPing(const TiXmlElement*, CJabberIqInfo *pInfo) +bool CJabberProto::OnIqRequestPing(const TiXmlElement*, CJabberIqInfo *pInfo) { m_ThreadInfo->send(XmlNodeIq("result", pInfo) << XATTR("from", m_ThreadInfo->fullJID)); - return TRUE; + return true; } // Returns the current GMT offset in seconds @@ -96,7 +96,7 @@ int GetGMTOffset(void) } // entity time (XEP-0202) support -BOOL CJabberProto::OnIqRequestTime(const TiXmlElement*, CJabberIqInfo *pInfo) +bool CJabberProto::OnIqRequestTime(const TiXmlElement*, CJabberIqInfo *pInfo) { wchar_t stime[100]; wchar_t szTZ[10]; @@ -115,10 +115,10 @@ BOOL CJabberProto::OnIqRequestTime(const TiXmlElement*, CJabberIqInfo *pInfo) timeNode << XCHILD("tz", T2Utf(szTZName)); m_ThreadInfo->send(iq); - return TRUE; + return true; } -BOOL CJabberProto::OnIqProcessIqOldTime(const TiXmlElement*, CJabberIqInfo *pInfo) +bool CJabberProto::OnIqProcessIqOldTime(const TiXmlElement*, CJabberIqInfo *pInfo) { struct tm *gmt; time_t ltime; @@ -143,10 +143,10 @@ BOOL CJabberProto::OnIqProcessIqOldTime(const TiXmlElement*, CJabberIqInfo *pInf queryNode << XCHILD("display", dtime); m_ThreadInfo->send(iq); - return TRUE; + return true; } -BOOL CJabberProto::OnSiRequest(const TiXmlElement *node, CJabberIqInfo *pInfo) +bool CJabberProto::OnSiRequest(const TiXmlElement *node, CJabberIqInfo *pInfo) { const char *szProfile = XmlGetAttr(pInfo->GetChildNode(), "profile"); @@ -159,10 +159,10 @@ BOOL CJabberProto::OnSiRequest(const TiXmlElement *node, CJabberIqInfo *pInfo) error << XCHILD("bad-profile"); m_ThreadInfo->send(iq); } - return TRUE; + return true; } -BOOL CJabberProto::OnRosterPushRequest(const TiXmlElement*, CJabberIqInfo *pInfo) +bool CJabberProto::OnRosterPushRequest(const TiXmlElement*, CJabberIqInfo *pInfo) { auto *queryNode = pInfo->GetChildNode(); @@ -170,11 +170,11 @@ BOOL CJabberProto::OnRosterPushRequest(const TiXmlElement*, CJabberIqInfo *pInfo if (pInfo->GetFrom()) { ptrA szFrom(JabberPrepareJid(pInfo->GetFrom())); if (!szFrom) - return TRUE; + return true; ptrA szTo(JabberPrepareJid(m_ThreadInfo->fullJID)); if (!szTo) - return TRUE; + return true; char *pDelimiter = strchr(szFrom, '/'); if (pDelimiter) @@ -188,7 +188,7 @@ BOOL CJabberProto::OnRosterPushRequest(const TiXmlElement*, CJabberIqInfo *pInfo BOOL bRetVal = mir_strcmp(szFrom, szTo) == 0; if (!bRetVal) { debugLogA(" attempt to hack via roster push from %s", pInfo->GetFrom()); - return TRUE; + return true; } } @@ -265,24 +265,24 @@ BOOL CJabberProto::OnRosterPushRequest(const TiXmlElement*, CJabberIqInfo *pInfo UI_SAFE_NOTIFY(m_pDlgServiceDiscovery, WM_JABBER_TRANSPORT_REFRESH); RebuildInfoFrame(); - return TRUE; + return true; } -BOOL CJabberProto::OnIqRequestOOB(const TiXmlElement*, CJabberIqInfo *pInfo) +bool CJabberProto::OnIqRequestOOB(const TiXmlElement*, CJabberIqInfo *pInfo) { if (!pInfo->GetFrom() || !pInfo->GetHContact()) - return TRUE; + return true; const char *pszUrl = XmlGetChildText(pInfo->GetChildNode(), "url"); if (!pszUrl) - return TRUE; + return true; if (m_bBsOnlyIBB) { // reject XmlNodeIq iq("error", pInfo); TiXmlElement *e = XmlAddChildA(iq, "error", "File transfer refused"); e->SetAttribute("code", 406); m_ThreadInfo->send(iq); - return TRUE; + return true; } filetransfer *ft = new filetransfer(this); @@ -342,40 +342,40 @@ BOOL CJabberProto::OnIqRequestOOB(const TiXmlElement*, CJabberIqInfo *pInfo) m_ThreadInfo->send(iq); delete ft; } - return TRUE; + return true; } -BOOL CJabberProto::OnHandleDiscoInfoRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) +bool CJabberProto::OnHandleDiscoInfoRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) { if (!pInfo->GetChildNode()) - return TRUE; + return true; const char *szNode = XmlGetAttr(pInfo->GetChildNode(), "node"); // caps hack if (m_clientCapsManager.HandleInfoRequest(iqNode, pInfo, szNode)) - return TRUE; + return true; // ad-hoc hack: if (szNode && m_adhocManager.HandleInfoRequest(iqNode, pInfo, szNode)) - return TRUE; + return true; // another request, send empty result m_ThreadInfo->send( XmlNodeIq("error", pInfo) << XCHILD("error") << XATTRI("code", 404) << XATTR("type", "cancel") << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas")); - return TRUE; + return true; } -BOOL CJabberProto::OnHandleDiscoItemsRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) +bool CJabberProto::OnHandleDiscoItemsRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) { if (!pInfo->GetChildNode()) - return TRUE; + return true; // ad-hoc commands check: const char *szNode = XmlGetAttr(pInfo->GetChildNode(), "node"); if (szNode && m_adhocManager.HandleItemsRequest(iqNode, pInfo, szNode)) - return TRUE; + return true; // another request, send empty result XmlNodeIq iq("result", pInfo); @@ -387,10 +387,10 @@ BOOL CJabberProto::OnHandleDiscoItemsRequest(const TiXmlElement *iqNode, CJabber resultQuery << XCHILD("item") << XATTR("jid", m_ThreadInfo->fullJID) << XATTR("node", JABBER_FEAT_COMMANDS) << XATTR("name", "Ad-hoc commands"); m_ThreadInfo->send(iq); - return TRUE; + return true; } -BOOL CJabberProto::AddClistHttpAuthEvent(CJabberHttpAuthParams *pParams) +bool CJabberProto::AddClistHttpAuthEvent(CJabberHttpAuthParams *pParams) { char szService[256]; mir_snprintf(szService, "%s%s", m_szModuleName, JS_HTTP_AUTH); @@ -403,26 +403,26 @@ BOOL CJabberProto::AddClistHttpAuthEvent(CJabberHttpAuthParams *pParams) cle.pszService = szService; cle.szTooltip.w = TranslateT("Http authentication request received"); g_clistApi.pfnAddEvent(&cle); - return TRUE; + return true; } -BOOL CJabberProto::OnIqHttpAuth(const TiXmlElement *node, CJabberIqInfo *pInfo) +bool CJabberProto::OnIqHttpAuth(const TiXmlElement *node, CJabberIqInfo *pInfo) { if (!m_bAcceptHttpAuth) - return TRUE; + return true; if (!node || !pInfo->GetChildNode() || !pInfo->GetFrom() || !pInfo->GetIdStr()) - return TRUE; + return true; auto *pConfirm = XmlFirstChild(node, "confirm"); if (!pConfirm) - return TRUE; + return true; const char *szId = XmlGetAttr(pConfirm, "id"); const char *szUrl = XmlGetAttr(pConfirm, "url"); const char *szMethod = XmlGetAttr(pConfirm, "method"); if (!szId || !szMethod || !szUrl) - return TRUE; + return true; CJabberHttpAuthParams *pParams = (CJabberHttpAuthParams*)mir_calloc(sizeof(CJabberHttpAuthParams)); if (pParams) { @@ -433,5 +433,5 @@ BOOL CJabberProto::OnIqHttpAuth(const TiXmlElement *node, CJabberIqInfo *pInfo) pParams->m_szUrl = mir_strdup(szUrl); AddClistHttpAuthEvent(pParams); } - return TRUE; + return true; } diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index f045dc143f..b4dfa83cde 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -830,7 +830,7 @@ int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam) if (GetClientJID(event->hContact, jid, _countof(jid))) { pResourceStatus r(ResourceInfoFromJID(jid)); if (r && r->m_bMessageSessionActive) { - r->m_bMessageSessionActive = FALSE; + r->m_bMessageSessionActive = false; if (GetResourceCapabilities(jid) & JABBER_CAPS_CHATSTATES) m_ThreadInfo->send(XmlNode("message") << XATTR("to", jid) << XATTR("type", "chat") << XATTRID(SerialNext()) << XCHILDNS("gone", JABBER_FEAT_CHATSTATES)); diff --git a/protocols/JabberG/src/jabber_message_handlers.cpp b/protocols/JabberG/src/jabber_message_handlers.cpp index c9acde95cb..eb00c11636 100644 --- a/protocols/JabberG/src/jabber_message_handlers.cpp +++ b/protocols/JabberG/src/jabber_message_handlers.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -BOOL CJabberProto::OnMessageError(const TiXmlElement *node, ThreadData*, CJabberMessageInfo* pInfo) +bool CJabberProto::OnMessageError(const TiXmlElement *node, ThreadData*, CJabberMessageInfo* pInfo) { // we check if is message delivery failure int id = JabberGetPacketID(node); @@ -48,27 +48,27 @@ BOOL CJabberProto::OnMessageError(const TiXmlElement *node, ThreadData*, CJabber MsgPopup(0, buf, TranslateT("Error")); } } - return TRUE; + return true; } -BOOL CJabberProto::OnMessageIbb(const TiXmlElement*, ThreadData*, CJabberMessageInfo* pInfo) +bool CJabberProto::OnMessageIbb(const TiXmlElement*, ThreadData*, CJabberMessageInfo* pInfo) { - BOOL bOk = FALSE; + bool bOk = false; const char *sid = XmlGetAttr(pInfo->GetChildNode(), "sid"); const char *seq = XmlGetAttr(pInfo->GetChildNode(), "seq"); if (sid && seq && pInfo->GetChildNode()->GetText()) bOk = OnIbbRecvdData(pInfo->GetChildNode()->GetText(), sid, seq); - return TRUE; + return true; } -BOOL CJabberProto::OnMessagePubsubEvent(const TiXmlElement *node, ThreadData*, CJabberMessageInfo*) +bool CJabberProto::OnMessagePubsubEvent(const TiXmlElement *node, ThreadData*, CJabberMessageInfo*) { OnProcessPubsubEvent(node); - return TRUE; + return true; } -BOOL CJabberProto::OnMessageGroupchat(const TiXmlElement *node, ThreadData*, CJabberMessageInfo* pInfo) +bool CJabberProto::OnMessageGroupchat(const TiXmlElement *node, ThreadData*, CJabberMessageInfo* pInfo) { JABBER_LIST_ITEM *chatItem = ListGetItemPtr(LIST_CHATROOM, pInfo->GetFrom()); if (chatItem) // process GC message @@ -81,5 +81,5 @@ BOOL CJabberProto::OnMessageGroupchat(const TiXmlElement *node, ThreadData*, CJa // XmlNode p("presence"); XmlAddAttr(p, "to", conference); XmlAddAttr(p, "type", "unavailable"); // info->send(p); } - return TRUE; + return true; } diff --git a/protocols/JabberG/src/jabber_message_manager.h b/protocols/JabberG/src/jabber_message_manager.h index c915fdbdeb..4cdcbaea60 100644 --- a/protocols/JabberG/src/jabber_message_manager.h +++ b/protocols/JabberG/src/jabber_message_manager.h @@ -35,7 +35,7 @@ typedef void (*MESSAGE_USER_DATA_FREE_FUNC)(void *pUserData); class CJabberMessageInfo; -typedef BOOL (CJabberProto::*JABBER_PERMANENT_MESSAGE_HANDLER)(const TiXmlElement *messageNode, ThreadData *pThreadData, CJabberMessageInfo* pInfo); +typedef bool (CJabberProto::*JABBER_PERMANENT_MESSAGE_HANDLER)(const TiXmlElement *messageNode, ThreadData *pThreadData, CJabberMessageInfo* pInfo); #define JABBER_MESSAGE_PARSE_FROM (1<<3) #define JABBER_MESSAGE_PARSE_HCONTACT ((1<<4)|JABBER_MESSAGE_PARSE_FROM) diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 2e861fcb2d..8299e783b0 100755 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -98,10 +98,10 @@ MCONTACT CJabberProto::DBCreateContact(const char *jid, const char *nick, bool t return hNewContact; } -BOOL CJabberProto::AddDbPresenceEvent(MCONTACT hContact, BYTE btEventType) +bool CJabberProto::AddDbPresenceEvent(MCONTACT hContact, BYTE btEventType) { if (!hContact) - return FALSE; + return false; switch (btEventType) { case JABBER_DB_EVENT_PRESENCE_SUBSCRIBE: @@ -109,12 +109,12 @@ BOOL CJabberProto::AddDbPresenceEvent(MCONTACT hContact, BYTE btEventType) case JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBE: case JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBED: if (!m_bLogPresence) - return FALSE; + return false; break; case JABBER_DB_EVENT_PRESENCE_ERROR: if (!m_bLogPresenceErrors) - return FALSE; + return false; break; } @@ -126,8 +126,7 @@ BOOL CJabberProto::AddDbPresenceEvent(MCONTACT hContact, BYTE btEventType) dbei.timestamp = time(0); dbei.szModule = m_szModuleName; db_event_add(hContact, &dbei); - - return TRUE; + return true; } /////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp index 115f468f05..66e0284f72 100755 --- a/protocols/JabberG/src/jabber_omemo.cpp +++ b/protocols/JabberG/src/jabber_omemo.cpp @@ -2097,7 +2097,7 @@ void CJabberProto::OmemoOnIqResultGetBundle(const TiXmlElement *iqNode, CJabberI OmemoCheckSession(hContact); } -unsigned int CJabberProto::OmemoEncryptMessage(XmlNode &msg, const char *msg_text, MCONTACT hContact) +int CJabberProto::OmemoEncryptMessage(XmlNode &msg, const char *msg_text, MCONTACT hContact) { const EVP_CIPHER *cipher = EVP_aes_128_gcm(); unsigned char key[16], iv[12], tag[16] /*, aad[48]*/; @@ -2131,7 +2131,7 @@ unsigned int CJabberProto::OmemoEncryptMessage(XmlNode &msg, const char *msg_tex TiXmlElement *header = encrypted << XCHILD("header"); header << XATTRI64("sid", m_omemo.GetOwnDeviceId()); - unsigned int session_count = 0; + int session_count = 0; char key_plus_tag[32] = { 0 }; memcpy(key_plus_tag, key, 16); { diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index a897472fce..09039d2989 100755 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -1111,13 +1111,13 @@ protected: // clear saved password m_proto->m_savedPassword = nullptr; - BOOL bUseHostnameAsResource = FALSE; + bool bUseHostnameAsResource = false; wchar_t szCompName[MAX_COMPUTERNAME_LENGTH + 1], szResource[MAX_COMPUTERNAME_LENGTH + 1]; DWORD dwCompNameLength = MAX_COMPUTERNAME_LENGTH; if (GetComputerName(szCompName, &dwCompNameLength)) { m_cbResource.GetText(szResource, _countof(szResource)); if (!mir_wstrcmp(szCompName, szResource)) - bUseHostnameAsResource = TRUE; + bUseHostnameAsResource = true; } m_proto->m_bHostNameAsResource = bUseHostnameAsResource; @@ -1130,7 +1130,7 @@ protected: switch (m_cbType.GetItemData(m_cbType.GetCurSel())) { case ACC_PUBLIC: - m_proto->m_bUseSSL = m_proto->m_bUseTLS = FALSE; + m_proto->m_bUseSSL = m_proto->m_bUseTLS = false; break; case ACC_GTALK: @@ -1138,27 +1138,27 @@ protected: { int port = m_txtPort.GetInt(); if (port == 443 || port == 5223) { - m_proto->m_bUseSSL = TRUE; - m_proto->m_bUseTLS = FALSE; + m_proto->m_bUseSSL = true; + m_proto->m_bUseTLS = false; } else if (port == 5222) { - m_proto->m_bUseSSL = FALSE; - m_proto->m_bUseTLS = TRUE; + m_proto->m_bUseSSL = false; + m_proto->m_bUseTLS = true; } } break; case ACC_OK: - m_proto->m_bIgnoreRosterGroups = TRUE; - m_proto->m_bUseSSL = FALSE; - m_proto->m_bUseTLS = TRUE; + m_proto->m_bIgnoreRosterGroups = true; + m_proto->m_bUseSSL = false; + m_proto->m_bUseTLS = true; case ACC_TLS: case ACC_HIPCHAT: case ACC_LJTALK: case ACC_SMS: - m_proto->m_bUseSSL = FALSE; - m_proto->m_bUseTLS = TRUE; + m_proto->m_bUseSSL = false; + m_proto->m_bUseTLS = true; break; case ACC_LOL_EN: @@ -1166,13 +1166,13 @@ protected: case ACC_LOL_OC: case ACC_LOL_US: m_proto->setDword("Priority", -2); - m_proto->m_bUseSSL = TRUE; - m_proto->m_bUseTLS = FALSE; + m_proto->m_bUseSSL = true; + m_proto->m_bUseTLS = false; break; case ACC_SSL: - m_proto->m_bUseSSL = TRUE; - m_proto->m_bUseTLS = FALSE; + m_proto->m_bUseSSL = true; + m_proto->m_bUseTLS = false; break; } @@ -1183,13 +1183,13 @@ protected: m_txtManualHost.GetTextA(manualServer, _countof(manualServer)); if ((m_chkManualHost.GetState() == BST_CHECKED) && mir_strcmp(server, manualServer)) { - m_proto->m_bManualConnect = TRUE; + m_proto->m_bManualConnect = true; m_proto->setString("ManualHost", manualServer); m_proto->setWord("ManualPort", m_txtPort.GetInt()); m_proto->setWord("Port", m_txtPort.GetInt()); } else { - m_proto->m_bManualConnect = FALSE; + m_proto->m_bManualConnect = false; m_proto->delSetting("ManualHost"); m_proto->delSetting("ManualPort"); m_proto->setWord("Port", m_txtPort.GetInt()); diff --git a/protocols/JabberG/src/jabber_presence_manager.h b/protocols/JabberG/src/jabber_presence_manager.h index 26e17f9ba2..e1af99c072 100644 --- a/protocols/JabberG/src/jabber_presence_manager.h +++ b/protocols/JabberG/src/jabber_presence_manager.h @@ -35,7 +35,7 @@ typedef void (*PRESENCE_USER_DATA_FREE_FUNC)(void *pUserData); class CJabberPresenceInfo; -typedef BOOL (CJabberProto::*JABBER_PRESENCE_HANDLER)(const TiXmlElement *node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo); +typedef bool (CJabberProto::*JABBER_PRESENCE_HANDLER)(const TiXmlElement *node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo); class CJabberPresenceInfo { diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp index 02b5d99a94..57dd58ab77 100644 --- a/protocols/JabberG/src/jabber_privacy.cpp +++ b/protocols/JabberG/src/jabber_privacy.cpp @@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. const wchar_t JABBER_PL_BUSY_MSG[] = LPGENW("Sending request, please wait..."); -BOOL CJabberProto::OnIqRequestPrivacyLists(const TiXmlElement*, CJabberIqInfo *pInfo) +bool CJabberProto::OnIqRequestPrivacyLists(const TiXmlElement*, CJabberIqInfo *pInfo) { if (pInfo->GetIqType() == JABBER_IQ_TYPE_SET) { if (!m_pDlgPrivacyLists) { @@ -41,7 +41,7 @@ BOOL CJabberProto::OnIqRequestPrivacyLists(const TiXmlElement*, CJabberIqInfo *p m_ThreadInfo->send(XmlNodeIq("result", pInfo)); } - return TRUE; + return true; } void CJabberProto::OnIqResultPrivacyListModify(const TiXmlElement*, CJabberIqInfo *pInfo) @@ -51,7 +51,7 @@ void CJabberProto::OnIqResultPrivacyListModify(const TiXmlElement*, CJabberIqInf return; if (pInfo->GetIqType() != JABBER_IQ_TYPE_RESULT) - pParam->m_bAllOk = FALSE; + pParam->m_bAllOk = false; InterlockedDecrement(&pParam->m_dwCount); if (!pParam->m_dwCount) { @@ -113,9 +113,9 @@ void CJabberProto::OnIqResultPrivacyList(const TiXmlElement *iqNode, CJabberIqIn const char *itemValue = XmlGetAttr(item, "value"); const char *itemAction = XmlGetAttr(item, "action"); - BOOL bAllow = TRUE; + bool bAllow = true; if (itemAction && !mir_strcmpi(itemAction, "deny")) - bAllow = FALSE; + bAllow = false; const char *itemOrder = XmlGetAttr(item, "order"); DWORD dwOrder = 0; @@ -625,11 +625,11 @@ class CJabberDlgPrivacyLists : public CJabberDlgBase int nLbSel = SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_GETCURSEL, 0, 0); SendDlgItemMessage(m_hwnd, IDC_PL_RULES_LIST, LB_RESETCONTENT, 0, 0); - BOOL bListEmpty = TRUE; + bool bListEmpty = true; CPrivacyListRule* pRule = pList->GetFirstRule(); while (pRule) { - bListEmpty = FALSE; + bListEmpty = false; char szTypeValue[512]; switch (pRule->GetType()) { case Jid: @@ -1238,24 +1238,21 @@ lbl_return: return mir_callNextSubclass(hwnd, LstRulesSubclassProc, msg, wParam, lParam); } - BOOL CanExit() + bool CanExit() { - BOOL bModified; + bool bModified; { mir_cslock lck(m_proto->m_privacyListManager.m_cs); bModified = m_proto->m_privacyListManager.IsModified(); } if (clc_info.bChanged) - bModified = TRUE; + bModified = true; if (!bModified) - return TRUE; + return true; - if (IDYES == MessageBox(m_hwnd, TranslateT("Privacy lists are not saved, discard any changes and exit?"), TranslateT("Are you sure?"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2)) - return TRUE; - - return FALSE; + return (IDYES == MessageBox(m_hwnd, TranslateT("Privacy lists are not saved, discard any changes and exit?"), TranslateT("Are you sure?"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2)); } CCtrlMButton m_btnSimple, m_btnAdvanced, m_btnAddJid, m_btnActivate, m_btnSetDefault; diff --git a/protocols/JabberG/src/jabber_privacy.h b/protocols/JabberG/src/jabber_privacy.h index ccff118028..44dff9b022 100644 --- a/protocols/JabberG/src/jabber_privacy.h +++ b/protocols/JabberG/src/jabber_privacy.h @@ -57,8 +57,9 @@ class CPrivacyListRule { protected: friend class CPrivacyList; + public: - CPrivacyListRule(CJabberProto *ppro, PrivacyListRuleType type = Else, const char *szValue = "", BOOL bAction = TRUE, DWORD dwOrder = 90, DWORD dwPackets = 0) + CPrivacyListRule(CJabberProto *ppro, PrivacyListRuleType type = Else, const char *szValue = "", bool bAction = true, DWORD dwOrder = 90, DWORD dwPackets = 0) { m_proto = ppro; m_szValue = mir_strdup(szValue); @@ -98,58 +99,56 @@ public: { return m_nType; } - __inline BOOL SetType(PrivacyListRuleType type) + __inline void SetType(PrivacyListRuleType type) { m_nType = type; - return TRUE; } __inline char* GetValue() { return m_szValue; } - __inline BOOL SetValue(const char *szValue) + __inline void SetValue(const char *szValue) { replaceStr(m_szValue, szValue); - return TRUE; } __inline DWORD GetPackets() { return m_dwPackets; } - __inline BOOL SetPackets(DWORD dwPackets) + __inline void SetPackets(DWORD dwPackets) { m_dwPackets = dwPackets; - return TRUE; } - __inline BOOL GetAction() + __inline bool GetAction() { return m_bAction; } - __inline BOOL SetAction(BOOL bAction) + __inline void SetAction(BOOL bAction) { m_bAction = bAction; - return TRUE; } + CJabberProto* m_proto; + protected: PrivacyListRuleType m_nType; char *m_szValue; - BOOL m_bAction; + bool m_bAction; DWORD m_dwOrder; DWORD m_dwPackets; CPrivacyListRule *m_pNext; }; -class CPrivacyList; class CPrivacyList { protected: - CPrivacyListRule *m_pRules; + CPrivacyListRule *m_pRules = nullptr; + CPrivacyList *m_pNext = nullptr; char *m_szListName; - CPrivacyList *m_pNext; - BOOL m_bLoaded; - BOOL m_bModified; - BOOL m_bDeleted; + bool m_bLoaded = false; + bool m_bModified = false; + bool m_bDeleted = false; + public: CJabberProto* m_proto; @@ -157,12 +156,8 @@ public: { m_proto = ppro; m_szListName = mir_strdup(szListName); - m_pRules = nullptr; - m_pNext = nullptr; - m_bLoaded = FALSE; - m_bModified = FALSE; - m_bDeleted = FALSE; }; + ~CPrivacyList() { mir_free(m_szListName); @@ -170,56 +165,59 @@ public: if (m_pNext) delete m_pNext; }; - BOOL RemoveAllRules() + + void RemoveAllRules() { if (m_pRules) delete m_pRules; m_pRules = nullptr; - return TRUE; } + __inline char* GetListName() { return m_szListName; } + __inline CPrivacyListRule* GetFirstRule() { return m_pRules; } + __inline CPrivacyList* GetNext() { return m_pNext; } + CPrivacyList* SetNext(CPrivacyList *pNext) { CPrivacyList *pRetVal = m_pNext; m_pNext = pNext; return pRetVal; } - BOOL AddRule(PrivacyListRuleType type, const char *szValue, BOOL bAction, DWORD dwOrder, DWORD dwPackets) + + void AddRule(PrivacyListRuleType type, const char *szValue, BOOL bAction, DWORD dwOrder, DWORD dwPackets) { CPrivacyListRule *pRule = new CPrivacyListRule(m_proto, type, szValue, bAction, dwOrder, dwPackets); - if (!pRule) - return FALSE; pRule->SetNext(m_pRules); m_pRules = pRule; - return TRUE; } - BOOL AddRule(CPrivacyListRule *pRule) + + void AddRule(CPrivacyListRule *pRule) { pRule->SetNext(m_pRules); m_pRules = pRule; - return TRUE; } - BOOL RemoveRule(CPrivacyListRule *pRuleToRemove) + + bool RemoveRule(CPrivacyListRule *pRuleToRemove) { if (!m_pRules) - return FALSE; + return false; if (m_pRules == pRuleToRemove) { m_pRules = m_pRules->GetNext(); pRuleToRemove->SetNext(nullptr); delete pRuleToRemove; - return TRUE; + return true; } CPrivacyListRule *pRule = m_pRules; @@ -228,20 +226,21 @@ public: pRule->SetNext(pRule->GetNext()->GetNext()); pRuleToRemove->SetNext(nullptr); delete pRuleToRemove; - return TRUE; + return true; } pRule = pRule->GetNext(); } - return FALSE; + return false; } - BOOL Reorder() + + bool Reorder() { // 0 or 1 rules? if (!m_pRules) - return TRUE; + return true; if (!m_pRules->GetNext()) { m_pRules->SetOrder(100); - return TRUE; + return true; } // get rules count @@ -255,7 +254,7 @@ public: // create pointer array for sort procedure CPrivacyListRule **pRules = (CPrivacyListRule **)mir_alloc(dwCount * sizeof(CPrivacyListRule *)); if (!pRules) - return FALSE; + return false; DWORD dwPos = 0; pRule = m_pRules; while (pRule) { @@ -287,30 +286,30 @@ public: } *ppPtr = nullptr; mir_free(pRules); - - return TRUE; + return true; } - __inline void SetLoaded(BOOL bLoaded = TRUE) + + __inline void SetLoaded(bool bLoaded = true) { m_bLoaded = bLoaded; } - __inline BOOL IsLoaded() + __inline bool IsLoaded() { return m_bLoaded; } - __inline void SetModified(BOOL bModified = TRUE) + __inline void SetModified(bool bModified = true) { m_bModified = bModified; } - __inline BOOL IsModified() + __inline bool IsModified() { return m_bModified; } - __inline void SetDeleted(BOOL bDeleted = TRUE) + __inline void SetDeleted(bool bDeleted = true) { m_bDeleted = bDeleted; } - __inline BOOL IsDeleted() + __inline bool IsDeleted() { return m_bDeleted; } @@ -319,52 +318,54 @@ public: class CPrivacyListManager { protected: - char *m_szActiveListName; - char *m_szDefaultListName; - CPrivacyList *m_pLists; - BOOL m_bModified; + char *m_szActiveListName = nullptr; + char *m_szDefaultListName = nullptr; + CPrivacyList *m_pLists = nullptr; + bool m_bModified = false; public: CJabberProto* m_proto; mir_cs m_cs; - CPrivacyListManager(CJabberProto *ppro) + CPrivacyListManager(CJabberProto *ppro) : + m_proto(ppro) { - m_proto = ppro; - m_szActiveListName = nullptr; - m_szDefaultListName = nullptr; - m_pLists = nullptr; - m_bModified = FALSE; - }; + } + ~CPrivacyListManager() { mir_free(m_szActiveListName); mir_free(m_szDefaultListName); RemoveAllLists(); - }; + } + void SetActiveListName(const char *szListName) { replaceStr(m_szActiveListName, szListName); } + void SetDefaultListName(const char *szListName) { replaceStr(m_szDefaultListName, szListName); } + char* GetDefaultListName() { return m_szDefaultListName; } + char* GetActiveListName() { return m_szActiveListName; } - BOOL RemoveAllLists() + + void RemoveAllLists() { if (m_pLists) delete m_pLists; m_pLists = nullptr; - return TRUE; } + CPrivacyList* FindList(const char *szListName) { CPrivacyList *pList = m_pLists; @@ -375,45 +376,50 @@ public: } return nullptr; } + CPrivacyList* GetFirstList() { return m_pLists; } - BOOL AddList(const char *szListName) + + bool AddList(const char *szListName) { if (FindList(szListName)) - return FALSE; + return false; + CPrivacyList *pList = new CPrivacyList(m_proto, szListName); pList->SetNext(m_pLists); m_pLists = pList; - return TRUE; + return true; } - BOOL SetModified(BOOL bModified = TRUE) + + void SetModified(BOOL bModified = TRUE) { m_bModified = bModified; - return TRUE; } - BOOL IsModified() + + bool IsModified() { if (m_bModified) - return TRUE; + return true; CPrivacyList *pList = m_pLists; while (pList) { if (pList->IsModified()) - return TRUE; + return true; pList = pList->GetNext(); } - return FALSE; + return false; } - BOOL IsAllListsLoaded() + + bool IsAllListsLoaded() { CPrivacyList *pList = m_pLists; while (pList) { if (!pList->IsLoaded()) - return FALSE; + return false; pList = pList->GetNext(); } - return TRUE; + return true; } }; diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index bb71ff5212..75f1e735a1 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -884,7 +884,7 @@ HANDLE CJabberProto::SendFile(MCONTACT hContact, const wchar_t *szDescription, w ft->szDescription = mir_wstrdup(szDescription); ft->jid = mir_strdup(jid); - if (m_bUseHttpUpload || (jcb & JABBER_CAPS_SI_FT)) + if ((m_bInlinePictures && ProtoGetAvatarFileFormat(ft->std.szCurrentFile.w)) || m_bUseHttpUpload || (jcb & JABBER_CAPS_SI_FT)) FtInitiate(item->jid, ft); else if (jcb & JABBER_CAPS_OOB) ForkThread((MyThreadFunc)&CJabberProto::FileServerThread, ft); diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index bb18313b0f..4457f77573 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -331,77 +331,77 @@ struct CJabberProto : public PROTO, public IJabberInterface * Function declarations *******************************************************************/ - void JabberUpdateDialogs(BOOL bEnable); + void JabberUpdateDialogs(BOOL bEnable); //---- jabber_adhoc.cpp -------------------------------------------------------------- - int __cdecl ContactMenuRunCommands(WPARAM wParam, LPARAM lParam); - - HWND GetWindowFromIq(CJabberIqInfo *pInfo); - BOOL HandleAdhocCommandRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - BOOL IsRcRequestAllowedByACL(CJabberIqInfo *pInfo); - - int AdhocSetStatusHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession); - int AdhocOptionsHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession); - int AdhocForwardHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession); - int AdhocLockWSHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession); - int AdhocQuitMirandaHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession); - int AdhocLeaveGroupchatsHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession); - - void OnIqResult_ListOfCommands(const TiXmlElement *iqNode, CJabberIqInfo*); - void OnIqResult_CommandExecution(const TiXmlElement *iqNode, CJabberIqInfo*); - void AdHoc_RequestListOfCommands(char *szResponder, HWND hwndDlg); - int AdHoc_ExecuteCommand(HWND hwndDlg, char *jid, struct JabberAdHocData *dat); - int AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData *dat, char *action); - int AdHoc_AddCommandRadio(HWND hFrame, const char *labelStr, int id, int ypos, int value); - int AdHoc_OnJAHMCommandListResult(HWND hwndDlg, TiXmlElement *iqNode, JabberAdHocData *dat); - int AdHoc_OnJAHMProcessResult(HWND hwndDlg, TiXmlElement *workNode, JabberAdHocData *dat); - - void ContactMenuAdhocCommands(struct CJabberAdhocStartupParams *param); + int __cdecl ContactMenuRunCommands(WPARAM wParam, LPARAM lParam); + + HWND GetWindowFromIq(CJabberIqInfo *pInfo); + bool HandleAdhocCommandRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + bool IsRcRequestAllowedByACL(CJabberIqInfo *pInfo); + + int AdhocSetStatusHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession); + int AdhocOptionsHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession); + int AdhocForwardHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession); + int AdhocLockWSHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession); + int AdhocQuitMirandaHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession); + int AdhocLeaveGroupchatsHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession); + + void OnIqResult_ListOfCommands(const TiXmlElement *iqNode, CJabberIqInfo*); + void OnIqResult_CommandExecution(const TiXmlElement *iqNode, CJabberIqInfo*); + void AdHoc_RequestListOfCommands(char *szResponder, HWND hwndDlg); + void AdHoc_ExecuteCommand(HWND hwndDlg, char *jid, struct JabberAdHocData *dat); + void AdHoc_SubmitCommandForm(HWND hwndDlg, JabberAdHocData *dat, char *action); + int AdHoc_AddCommandRadio(HWND hFrame, const char *labelStr, int id, int ypos, int value); + void AdHoc_OnJAHMCommandListResult(HWND hwndDlg, TiXmlElement *iqNode, JabberAdHocData *dat); + void AdHoc_OnJAHMProcessResult(HWND hwndDlg, TiXmlElement *workNode, JabberAdHocData *dat); + + void ContactMenuAdhocCommands(struct CJabberAdhocStartupParams *param); //---- jabber_archive.c -------------------------------------------------------------- - void EnableArchive(bool bEnable); - void RetrieveMessageArchive(MCONTACT hContact, JABBER_LIST_ITEM *pItem); - - void OnIqResultGetCollection(const TiXmlElement *iqNode, CJabberIqInfo*); - void OnIqResultGetCollectionList(const TiXmlElement *iqNode, CJabberIqInfo*); + void EnableArchive(bool bEnable); + void RetrieveMessageArchive(MCONTACT hContact, JABBER_LIST_ITEM *pItem); + + void OnIqResultGetCollection(const TiXmlElement *iqNode, CJabberIqInfo*); + void OnIqResultGetCollectionList(const TiXmlElement *iqNode, CJabberIqInfo*); //---- jabber_bookmarks.c ------------------------------------------------------------ - INT_PTR __cdecl OnMenuHandleBookmarks(WPARAM wParam, LPARAM lParam); - - int AddEditBookmark(JABBER_LIST_ITEM *item); + INT_PTR __cdecl OnMenuHandleBookmarks(WPARAM wParam, LPARAM lParam); + + int AddEditBookmark(JABBER_LIST_ITEM *item); //---- jabber_notes.c ----------------------------------------------------------------- - void ProcessIncomingNote(CNoteItem *pNote, bool ok); - void ProcessOutgoingNote(CNoteItem *pNote, bool ok); - - bool OnIncomingNote(const char *szFrom, const TiXmlElement *hXml); - - INT_PTR __cdecl OnMenuSendNote(WPARAM, LPARAM); - INT_PTR __cdecl OnMenuHandleNotes(WPARAM, LPARAM); - INT_PTR __cdecl OnIncomingNoteEvent(WPARAM, LPARAM); + void ProcessIncomingNote(CNoteItem *pNote, bool ok); + void ProcessOutgoingNote(CNoteItem *pNote, bool ok); + + bool OnIncomingNote(const char *szFrom, const TiXmlElement *hXml); + + INT_PTR __cdecl OnMenuSendNote(WPARAM, LPARAM); + INT_PTR __cdecl OnMenuHandleNotes(WPARAM, LPARAM); + INT_PTR __cdecl OnIncomingNoteEvent(WPARAM, LPARAM); //---- jabber_byte.c ----------------------------------------------------------------- - void __cdecl ByteSendThread(JABBER_BYTE_TRANSFER *jbt); - void __cdecl ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt); - - void IqResultProxyDiscovery(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void ByteInitiateResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt); - int ByteSendParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen); - void IqResultStreamActivate(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - int ByteReceiveParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen); - int ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen); + void __cdecl ByteSendThread(JABBER_BYTE_TRANSFER *jbt); + void __cdecl ByteReceiveThread(JABBER_BYTE_TRANSFER *jbt); + + void IqResultProxyDiscovery(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void ByteInitiateResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void ByteSendViaProxy(JABBER_BYTE_TRANSFER *jbt); + int ByteSendParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen); + void IqResultStreamActivate(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + int ByteReceiveParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen); + int ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen); //---- jabber_caps.cpp --------------------------------------------------------------- - void AddDefaultCaps(); - void RequestOldCapsInfo(pResourceStatus &r, const char *fullJid); - void GetCachedCaps(const char *szNode, const char *szVer, class pResourceStatus &r); + void AddDefaultCaps(); + void RequestOldCapsInfo(pResourceStatus &r, const char *fullJid); + void GetCachedCaps(const char *szNode, const char *szVer, class pResourceStatus &r); JabberCapsBits GetTotalJidCapabilities(const char *jid); JabberCapsBits GetResourceCapabilities(const char *jid); @@ -409,98 +409,100 @@ struct CJabberProto : public PROTO, public IJabberInterface //---- jabber_captcha.cpp ------------------------------------------------------------ - void sendCaptchaResult(char* buf, ThreadData *info, const char *from, const char *challenge, const char *fromjid, const char *sid); - void sendCaptchaError(ThreadData *info, const char *from, const char *to, const char *challenge); + void sendCaptchaResult(char* buf, ThreadData *info, const char *from, const char *challenge, const char *fromjid, const char *sid); + void sendCaptchaError(ThreadData *info, const char *from, const char *to, const char *challenge); //---- jabber_chat.cpp --------------------------------------------------------------- - int GcInit(JABBER_LIST_ITEM *item); - void GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const char *resource, const char *nick, const char *jid, int action, const TiXmlElement *reason, int nStatusCode = -1); - void GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus &user, TJabberGcLogInfoType type); - void GcQuit(JABBER_LIST_ITEM* jid, int code, const TiXmlElement *reason); - - void AdminSet(const char *to, const char *ns, const char *szItem, const char *itemVal, const char *var, const char *varVal); - void AdminGet(const char *to, const char *ns, const char *var, const char *varVal, JABBER_IQ_HANDLER foo, void *pInfo = nullptr); - void AdminSetReason(const char *to, const char *ns, const char *szItem, const char *itemVal, const char *var, const char *varVal, const char *rsn); - void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char *str); - void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char *str, const char *reason); - void DeleteMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char* jid); + int GcInit(JABBER_LIST_ITEM *item); + void GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const char *resource, const char *nick, const char *jid, int action, const TiXmlElement *reason, int nStatusCode = -1); + void GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus &user, TJabberGcLogInfoType type); + void GcQuit(JABBER_LIST_ITEM* jid, int code, const TiXmlElement *reason); + + void AdminSet(const char *to, const char *ns, const char *szItem, const char *itemVal, const char *var, const char *varVal); + void AdminGet(const char *to, const char *ns, const char *var, const char *varVal, JABBER_IQ_HANDLER foo, void *pInfo = nullptr); + void AdminSetReason(const char *to, const char *ns, const char *szItem, const char *itemVal, const char *var, const char *varVal, const char *rsn); + void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char *str); + void AddMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char *str, const char *reason); + void DeleteMucListItem(JABBER_MUC_JIDLIST_INFO* jidListInfo, const char* jid); //---- jabber_omemo.cpp -------------------------------------------------------------- - bool OmemoHandleMessage(const TiXmlElement *node, const char *jid, time_t msgTime); - void OmemoPutMessageToOutgoingQueue(MCONTACT hContact, int, const char* pszSrc); - void OmemoPutMessageToIncommingQueue(const TiXmlElement *node, const char *jid, time_t msgTime); - void OmemoHandleMessageQueue(); - void OmemoHandleDeviceList(const TiXmlElement *node); - void OmemoInitDevice(); - void OmemoAnnounceDevice(); - void OmemoSendBundle(); - void OmemoPublishNodes(); - bool OmemoCheckSession(MCONTACT hContact); - unsigned int OmemoEncryptMessage(XmlNode &msg, const char *msg_text, MCONTACT hContact); - bool OmemoIsEnabled(MCONTACT hContact); - void OmemoOnIqResultGetBundle(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + bool OmemoHandleMessage(const TiXmlElement *node, const char *jid, time_t msgTime); + void OmemoPutMessageToOutgoingQueue(MCONTACT hContact, int, const char* pszSrc); + void OmemoPutMessageToIncommingQueue(const TiXmlElement *node, const char *jid, time_t msgTime); + void OmemoHandleMessageQueue(); + void OmemoHandleDeviceList(const TiXmlElement *node); + void OmemoInitDevice(); + void OmemoAnnounceDevice(); + void OmemoSendBundle(); + void OmemoPublishNodes(); + bool OmemoCheckSession(MCONTACT hContact); + int OmemoEncryptMessage(XmlNode &msg, const char *msg_text, MCONTACT hContact); + bool OmemoIsEnabled(MCONTACT hContact); + void OmemoOnIqResultGetBundle(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); omemo::omemo_impl m_omemo; //---- jabber_console.cpp ------------------------------------------------------------ INT_PTR __cdecl OnMenuHandleConsole(WPARAM wParam, LPARAM lParam); - void __cdecl ConsoleThread(void*); - - void ConsoleInit(void); - void ConsoleUninit(void); - - bool FilterXml(const TiXmlElement *node, DWORD flags); - bool RecursiveCheckFilter(const TiXmlElement *node, DWORD flags); + void __cdecl ConsoleThread(void*); + + void ConsoleInit(void); + void ConsoleUninit(void); + + bool FilterXml(const TiXmlElement *node, DWORD flags); + bool RecursiveCheckFilter(const TiXmlElement *node, DWORD flags); //---- jabber_disco.cpp -------------------------------------------------------------- - void LaunchServiceDiscovery(char *jid); - INT_PTR __cdecl OnMenuHandleServiceDiscovery(WPARAM wParam, LPARAM lParam); - INT_PTR __cdecl OnMenuHandleServiceDiscoveryMyTransports(WPARAM wParam, LPARAM lParam); - INT_PTR __cdecl OnMenuHandleServiceDiscoveryTransports(WPARAM wParam, LPARAM lParam); - INT_PTR __cdecl OnMenuHandleServiceDiscoveryConferences(WPARAM wParam, LPARAM lParam); - - void OnIqResultServiceDiscoveryInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultServiceDiscoveryItems(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultServiceDiscoveryRootInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultServiceDiscoveryRootItems(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - BOOL SendInfoRequest(CJabberSDNode *pNode, TiXmlNode *parent); - BOOL SendBothRequests(CJabberSDNode *pNode, TiXmlNode *parent = nullptr); - void PerformBrowse(HWND hwndDlg); - BOOL IsNodeRegistered(CJabberSDNode *pNode); - void ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode); - BOOL SyncTree(HTREELISTITEM hIndex, CJabberSDNode *pNode); - void ServiceDiscoveryShowMenu(CJabberSDNode *node, HTREELISTITEM hItem, POINT pt); - - void OnIqResultCapsDiscoInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - - void RegisterAgent(HWND hwndDlg, char* jid); + void LaunchServiceDiscovery(char *jid); + + INT_PTR __cdecl OnMenuHandleServiceDiscovery(WPARAM wParam, LPARAM lParam); + INT_PTR __cdecl OnMenuHandleServiceDiscoveryMyTransports(WPARAM wParam, LPARAM lParam); + INT_PTR __cdecl OnMenuHandleServiceDiscoveryTransports(WPARAM wParam, LPARAM lParam); + INT_PTR __cdecl OnMenuHandleServiceDiscoveryConferences(WPARAM wParam, LPARAM lParam); + + void OnIqResultServiceDiscoveryInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultServiceDiscoveryItems(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultServiceDiscoveryRootInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultServiceDiscoveryRootItems(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + bool SendInfoRequest(CJabberSDNode *pNode, TiXmlNode *parent); + bool SendBothRequests(CJabberSDNode *pNode, TiXmlNode *parent = nullptr); + void PerformBrowse(HWND hwndDlg); + bool IsNodeRegistered(CJabberSDNode *pNode); + void ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode); + bool SyncTree(HTREELISTITEM hIndex, CJabberSDNode *pNode); + void ServiceDiscoveryShowMenu(CJabberSDNode *node, HTREELISTITEM hItem, POINT pt); + + void OnIqResultCapsDiscoInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + + void RegisterAgent(HWND hwndDlg, char* jid); //---- jabber_file.cpp --------------------------------------------------------------- - int FileReceiveParse(filetransfer *ft, char* buffer, int datalen); - int FileSendParse(HNETLIBCONN s, filetransfer *ft, char* buffer, int datalen); - - void GroupchatJoinRoomByJid(HWND hwndParent, char *jid); - - void RenameParticipantNick(JABBER_LIST_ITEM *item, const char *oldNick, const TiXmlElement *itemNode); - void AcceptGroupchatInvite(const char *roomJid, const char *reason, const char *password); + int FileReceiveParse(filetransfer *ft, char* buffer, int datalen); + int FileSendParse(HNETLIBCONN s, filetransfer *ft, char* buffer, int datalen); + + void GroupchatJoinRoomByJid(HWND hwndParent, char *jid); + + void RenameParticipantNick(JABBER_LIST_ITEM *item, const char *oldNick, const TiXmlElement *itemNode); + void AcceptGroupchatInvite(const char *roomJid, const char *reason, const char *password); //---- jabber_ft.c ------------------------------------------------------------------- - void __cdecl FileReceiveThread(filetransfer *ft); - void __cdecl FileServerThread(filetransfer *ft); - - void FtCancel(filetransfer *ft); - void FtInitiate(const char* jid, filetransfer *ft); - void FtHandleSiRequest(const TiXmlElement *iqNode); - void FtAcceptSiRequest(filetransfer *ft); - void FtAcceptIbbRequest(filetransfer *ft); - BOOL FtHandleBytestreamRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - BOOL FtHandleIbbRequest(const TiXmlElement *iqNode, BOOL bOpen); + void __cdecl FileReceiveThread(filetransfer *ft); + void __cdecl FileServerThread(filetransfer *ft); + + void FtCancel(filetransfer *ft); + void FtInitiate(const char* jid, filetransfer *ft); + void FtHandleSiRequest(const TiXmlElement *iqNode); + void FtAcceptSiRequest(filetransfer *ft); + void FtAcceptIbbRequest(filetransfer *ft); + bool FtHandleBytestreamRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + bool FtHandleIbbRequest(const TiXmlElement *iqNode, bool bOpen); + bool FtTryInlineFile(const wchar_t *pwszFileName); //---- jabber_groupchat.c ------------------------------------------------------------ @@ -509,23 +511,23 @@ struct CJabberProto : public PROTO, public IJabberInterface INT_PTR __cdecl OnJoinChat(WPARAM wParam, LPARAM lParam); INT_PTR __cdecl OnLeaveChat(WPARAM wParam, LPARAM lParam); - void GroupchatJoinRoom(const char *server, const char *room, const char *nick, const char *password, bool autojoin = false); - void GroupchatProcessPresence(const TiXmlElement *node); - void GroupchatProcessMessage(const TiXmlElement *node); - void GroupchatProcessInvite(const char *roomJid, const char *from, const char *reason, const char *password); - void OnIqResultDiscovery(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void GroupchatJoinRoom(const char *server, const char *room, const char *nick, const char *password, bool autojoin = false); + void GroupchatProcessPresence(const TiXmlElement *node); + void GroupchatProcessMessage(const TiXmlElement *node); + void GroupchatProcessInvite(const char *roomJid, const char *from, const char *reason, const char *password); + void OnIqResultDiscovery(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); //---- jabber_icolib.cpp ------------------------------------------------------------- - int* m_transportProtoTableStartIndex; - - void IconsInit(void); - int LoadAdvancedIcons(int iID); - int GetTransportProtoID(char* TransportDomain); - int GetTransportStatusIconIndex(int iID, int Status); - BOOL DBCheckIsTransportedContact(const char *jid, MCONTACT hContact); - void CheckAllContactsAreTransported(void); - INT_PTR __cdecl JGetAdvancedStatusIcon(WPARAM wParam, LPARAM lParam); + int* m_transportProtoTableStartIndex; + + void IconsInit(void); + int LoadAdvancedIcons(int iID); + int GetTransportProtoID(char* TransportDomain); + int GetTransportStatusIconIndex(int iID, int Status); + bool DBCheckIsTransportedContact(const char *jid, MCONTACT hContact); + void CheckAllContactsAreTransported(void); + INT_PTR __cdecl JGetAdvancedStatusIcon(WPARAM wParam, LPARAM lParam); //---- jabber_iq.c ------------------------------------------------------------------- @@ -534,72 +536,72 @@ struct CJabberProto : public PROTO, public IJabberInterface return m_iqManager.AddHandler(pHandler, nIqType, szReceiver, pUserData, iPriority); } - void __cdecl ExpirerThread(void*); - - void OnIqResultBind(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultDiscoBookmarks(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultEntityTime(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultExtSearch(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultGetAuth(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultGetVCardAvatar(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultGetServerAvatar(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultGotAvatar(MCONTACT hContact, const char *pszText, const char *mimeType); - void OnIqResultGetMuc(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultGetRegister(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultGetRoster(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultGetVcard(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultLastActivity(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultMucGetAdminList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultMucGetBanList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultMucGetMemberList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultMucGetModeratorList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultMucGetOwnerList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultMucGetVoiceList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultNestedRosterGroups(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultNotes(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultSession(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultSetAuth(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultSetBookmarks(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultSetPassword(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultSetRegister(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultSetSearch(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultSetVcard(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnProcessLoginRq(ThreadData *info, DWORD rq); - void OnLoggedIn(void); + void __cdecl ExpirerThread(void*); + + void OnIqResultBind(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultDiscoBookmarks(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultEntityTime(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultExtSearch(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultGetAuth(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultGetVCardAvatar(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultGetServerAvatar(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultGotAvatar(MCONTACT hContact, const char *pszText, const char *mimeType); + void OnIqResultGetMuc(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultGetRegister(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultGetRoster(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultGetVcard(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultLastActivity(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultMucGetAdminList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultMucGetBanList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultMucGetMemberList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultMucGetModeratorList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultMucGetOwnerList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultMucGetVoiceList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultNestedRosterGroups(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultNotes(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultSession(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultSetAuth(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultSetBookmarks(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultSetPassword(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultSetRegister(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultSetSearch(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultSetVcard(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnProcessLoginRq(ThreadData *info, DWORD rq); + void OnLoggedIn(void); //---- jabber_iq_handlers.cpp ------------------------------------------------------- - BOOL OnIqRequestVersion(const TiXmlElement *node, CJabberIqInfo *pInfo); - BOOL OnIqRequestLastActivity(const TiXmlElement *node, CJabberIqInfo *pInfo); - BOOL OnIqRequestPing(const TiXmlElement *node, CJabberIqInfo *pInfo); - BOOL OnIqRequestTime(const TiXmlElement *node, CJabberIqInfo *pInfo); - BOOL OnIqProcessIqOldTime(const TiXmlElement *node, CJabberIqInfo *pInfo); - BOOL OnSiRequest(const TiXmlElement *node, CJabberIqInfo *pInfo); - BOOL OnRosterPushRequest(const TiXmlElement *node, CJabberIqInfo *pInfo); - BOOL OnIqRequestOOB(const TiXmlElement *node, CJabberIqInfo *pInfo); - BOOL OnIqHttpAuth(const TiXmlElement *node, CJabberIqInfo *pInfo); - BOOL AddClistHttpAuthEvent(CJabberHttpAuthParams *pParams); - - void __cdecl IbbSendThread(JABBER_IBB_TRANSFER *jibb); - void __cdecl IbbReceiveThread(JABBER_IBB_TRANSFER *jibb); - - void OnIbbInitiateResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIbbCloseResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - BOOL OnFtHandleIbbIq(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - BOOL OnIbbRecvdData(const char *data, const char *sid, const char *seq); - - void OnHttpSlotAllocated(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - - void OnFtSiResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - BOOL FtIbbSend(int blocksize, filetransfer *ft); - BOOL FtSend(HNETLIBCONN hConn, filetransfer *ft); - void FtSendFinal(BOOL success, filetransfer *ft); - int FtReceive(HNETLIBCONN hConn, filetransfer *ft, char* buffer, int datalen); - void FtReceiveFinal(BOOL success, filetransfer *ft); + bool OnIqRequestVersion(const TiXmlElement *node, CJabberIqInfo *pInfo); + bool OnIqRequestLastActivity(const TiXmlElement *node, CJabberIqInfo *pInfo); + bool OnIqRequestPing(const TiXmlElement *node, CJabberIqInfo *pInfo); + bool OnIqRequestTime(const TiXmlElement *node, CJabberIqInfo *pInfo); + bool OnIqProcessIqOldTime(const TiXmlElement *node, CJabberIqInfo *pInfo); + bool OnSiRequest(const TiXmlElement *node, CJabberIqInfo *pInfo); + bool OnRosterPushRequest(const TiXmlElement *node, CJabberIqInfo *pInfo); + bool OnIqRequestOOB(const TiXmlElement *node, CJabberIqInfo *pInfo); + bool OnIqHttpAuth(const TiXmlElement *node, CJabberIqInfo *pInfo); + bool AddClistHttpAuthEvent(CJabberHttpAuthParams *pParams); + + void __cdecl IbbSendThread(JABBER_IBB_TRANSFER *jibb); + void __cdecl IbbReceiveThread(JABBER_IBB_TRANSFER *jibb); + + void OnIbbInitiateResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIbbCloseResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + bool OnFtHandleIbbIq(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + bool OnIbbRecvdData(const char *data, const char *sid, const char *seq); + + void OnHttpSlotAllocated(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + + void OnFtSiResult(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + bool FtIbbSend(int blocksize, filetransfer *ft); + bool FtSend(HNETLIBCONN hConn, filetransfer *ft); + void FtSendFinal(BOOL success, filetransfer *ft); + int FtReceive(HNETLIBCONN hConn, filetransfer *ft, char* buffer, int datalen); + void FtReceiveFinal(BOOL success, filetransfer *ft); //---- jabber_iqid.cpp --------------------------------------------------------------- - void GroupchatJoinByHContact(MCONTACT hContact, bool autojoin=false); + void GroupchatJoinByHContact(MCONTACT hContact, bool autojoin=false); //---- jabber_iqid_muc.cpp ----------------------------------------------------------- @@ -607,16 +609,16 @@ struct CJabberProto : public PROTO, public IJabberInterface CJabberMucJidListDlg *m_pDlgMucBanList, *m_pDlgMucAdminList, *m_pDlgMucOwnerList; CJabberMucJidListDlg *& GetMucDlg(JABBER_MUC_JIDLIST_TYPE); - void SetMucConfig(CJabberFormDlg *pDlg, void *from); - void MucShutdown(void); - void OnIqResultMucGetJidList(const TiXmlElement *iqNode, JABBER_MUC_JIDLIST_TYPE listType, CJabberIqInfo*); + void SetMucConfig(CJabberFormDlg *pDlg, void *from); + void MucShutdown(void); + void OnIqResultMucGetJidList(const TiXmlElement *iqNode, JABBER_MUC_JIDLIST_TYPE listType, CJabberIqInfo*); //---- jabber_message_handlers.cpp --------------------------------------------------- - BOOL OnMessageError(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo); - BOOL OnMessageIbb(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo); - BOOL OnMessagePubsubEvent(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo); - BOOL OnMessageGroupchat(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo); + bool OnMessageError(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo); + bool OnMessageIbb(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo); + bool OnMessagePubsubEvent(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo); + bool OnMessageGroupchat(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo); //---- jabber_list.cpp --------------------------------------------------------------- @@ -624,23 +626,23 @@ struct CJabberProto : public PROTO, public IJabberInterface JABBER_LIST_ITEM* ListGetItemPtr(JABBER_LIST list, const char *jid); JABBER_LIST_ITEM* ListGetItemPtrFromIndex(int index); - void ListInit(void); - void ListWipe(void); - - void ListRemove(JABBER_LIST list, const char *jid); - void ListRemoveList(JABBER_LIST list); - void ListRemoveByIndex(int index); - int ListFindNext(JABBER_LIST list, int fromOffset); + void ListInit(void); + void ListWipe(void); + + void ListRemove(JABBER_LIST list, const char *jid); + void ListRemoveList(JABBER_LIST list); + void ListRemoveByIndex(int index); + int ListFindNext(JABBER_LIST list, int fromOffset); pResourceStatus ListFindResource(JABBER_LIST list, const char *jid); - bool ListAddResource(JABBER_LIST list, const char *jid, int status, const char *statusMessage, int priority = 0, const char *nick = nullptr); - void ListRemoveResource(JABBER_LIST list, const char *jid); - char* ListGetBestClientResourceNamePtr(const char *jid); - - void OnIqResultServerDiscoInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultGetVcardPhoto(const TiXmlElement *n, MCONTACT hContact, bool &hasPhoto); - void SetBookmarkRequest(XmlNodeIq &iqId); + bool ListAddResource(JABBER_LIST list, const char *jid, int status, const char *statusMessage, int priority = 0, const char *nick = nullptr); + void ListRemoveResource(JABBER_LIST list, const char *jid); + char* ListGetBestClientResourceNamePtr(const char *jid); + + void OnIqResultServerDiscoInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultGetVcardPhoto(const TiXmlElement *n, MCONTACT hContact, bool &hasPhoto); + void SetBookmarkRequest(XmlNodeIq &iqId); //---- jabber_menu.cpp --------------------------------------------------------------- @@ -655,38 +657,38 @@ struct CJabberProto : public PROTO, public IJabberInterface INT_PTR __cdecl OnMenuHandleDirectPresence(WPARAM wParam, LPARAM lParam, LPARAM res); INT_PTR __cdecl OnMenuSetPriority(WPARAM wParam, LPARAM lParam, LPARAM dwDelta); - void GlobalMenuInit(void); - void GlobalMenuUninit(void); - - void MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item); + void GlobalMenuInit(void); + void GlobalMenuUninit(void); + + void MenuUpdateSrmmIcon(JABBER_LIST_ITEM *item); + + void BuildPriorityMenu(void); + void UpdatePriorityMenu(int priority); - void BuildPriorityMenu(void); - void UpdatePriorityMenu(int priority); - - HGENMENU m_hMenuPriorityRoot; - int m_priorityMenuVal; - bool m_priorityMenuValSet; + HGENMENU m_hMenuPriorityRoot; + int m_priorityMenuVal; + bool m_priorityMenuValSet; //---- jabber_misc.c ----------------------------------------------------------------- INT_PTR __cdecl OnGetEventTextChatStates(WPARAM wParam, LPARAM lParam); INT_PTR __cdecl OnGetEventTextPresence(WPARAM wParam, LPARAM lParam); - - void AddContactToRoster(const char *jid, const char *nick, const char *grpName); - void DBAddAuthRequest(const char *jid, const char *nick); - BOOL AddDbPresenceEvent(MCONTACT hContact, BYTE btEventType); - MCONTACT DBCreateContact(const char *jid, const char *nick, bool temporary, bool stripResource); - void GetAvatarFileName(MCONTACT hContact, wchar_t *pszDest, size_t cbLen); - void ResolveTransportNicks(const char *jid); - void SetServerStatus(int iNewStatus); - void FormatMirVer(const pResourceStatus &resource, CMStringA &res); - void UpdateMirVer(JABBER_LIST_ITEM *item); - void UpdateMirVer(MCONTACT hContact, const pResourceStatus&); - void UpdateSubscriptionInfo(MCONTACT hContact, JABBER_LIST_ITEM *item); - void SetContactOfflineStatus(MCONTACT hContact); - void InitPopups(void); - void MsgPopup(MCONTACT hContact, const wchar_t *szMsg, const wchar_t *szTitle); - CMStringA ExtractImage(const TiXmlElement *node); + + void AddContactToRoster(const char *jid, const char *nick, const char *grpName); + void DBAddAuthRequest(const char *jid, const char *nick); + bool AddDbPresenceEvent(MCONTACT hContact, BYTE btEventType); + MCONTACT DBCreateContact(const char *jid, const char *nick, bool temporary, bool stripResource); + void GetAvatarFileName(MCONTACT hContact, wchar_t *pszDest, size_t cbLen); + void ResolveTransportNicks(const char *jid); + void SetServerStatus(int iNewStatus); + void FormatMirVer(const pResourceStatus &resource, CMStringA &res); + void UpdateMirVer(JABBER_LIST_ITEM *item); + void UpdateMirVer(MCONTACT hContact, const pResourceStatus&); + void UpdateSubscriptionInfo(MCONTACT hContact, JABBER_LIST_ITEM *item); + void SetContactOfflineStatus(MCONTACT hContact); + void InitPopups(void); + void MsgPopup(MCONTACT hContact, const wchar_t *szMsg, const wchar_t *szTitle); + CMStringA ExtractImage(const TiXmlElement *node); const char* GetSoftName(const char *wszName); //---- jabber_password.cpp -------------------------------------------------------------- @@ -695,58 +697,58 @@ struct CJabberProto : public PROTO, public IJabberInterface //---- jabber_privacy.cpp ------------------------------------------------------------ - INT_PTR __cdecl menuSetPrivacyList(WPARAM wParam, LPARAM lParam, LPARAM iList); - INT_PTR __cdecl OnMenuHandlePrivacyLists(WPARAM wParam, LPARAM lParam); - - void BuildPrivacyMenu(void); - void BuildPrivacyListsMenu(bool bDeleteOld); - - void QueryPrivacyLists(ThreadData *pThreadInfo = nullptr); - - BOOL OnIqRequestPrivacyLists(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultPrivacyList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultPrivacyLists(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultPrivacyListActive(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultPrivacyListDefault(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultPrivacyListModify(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + INT_PTR __cdecl menuSetPrivacyList(WPARAM wParam, LPARAM lParam, LPARAM iList); + INT_PTR __cdecl OnMenuHandlePrivacyLists(WPARAM wParam, LPARAM lParam); + + void BuildPrivacyMenu(void); + void BuildPrivacyListsMenu(bool bDeleteOld); + + void QueryPrivacyLists(ThreadData *pThreadInfo = nullptr); + + bool OnIqRequestPrivacyLists(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultPrivacyList(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultPrivacyLists(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultPrivacyListActive(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultPrivacyListDefault(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultPrivacyListModify(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); //---- jabber_proto.cpp -------------------------------------------------------------- - void __cdecl BasicSearchThread(struct JABBER_SEARCH_BASIC *jsb); - void __cdecl GetAwayMsgThread(void* hContact); - void __cdecl SendMessageAckThread(void* hContact); - - MCONTACT AddToListByJID(const char *newJid, DWORD flags); - - void InfoFrame_OnSetup(CJabberInfoFrame_Event *evt); - void InfoFrame_OnTransport(CJabberInfoFrame_Event *evt); + void __cdecl BasicSearchThread(struct JABBER_SEARCH_BASIC *jsb); + void __cdecl GetAwayMsgThread(void* hContact); + void __cdecl SendMessageAckThread(void* hContact); + + MCONTACT AddToListByJID(const char *newJid, DWORD flags); + + void InfoFrame_OnSetup(CJabberInfoFrame_Event *evt); + void InfoFrame_OnTransport(CJabberInfoFrame_Event *evt); //---- jabber_rc.cpp ----------------------------------------------------------------- - int RcGetUnreadEventsCount(void); + int RcGetUnreadEventsCount(void); //---- jabber_rostereditor.cpp ------------------------------------------------------- CRosterEditorDlg *m_hwndRosterEditor; - INT_PTR __cdecl OnMenuHandleRosterControl(WPARAM wParam, LPARAM lParam); - void _RosterHandleGetRequest(const TiXmlElement *node, CJabberIqInfo*); + INT_PTR __cdecl OnMenuHandleRosterControl(WPARAM wParam, LPARAM lParam); + void _RosterHandleGetRequest(const TiXmlElement *node, CJabberIqInfo*); //---- jabber_search.cpp ------------------------------------------------------------- - void OnIqResultAdvancedSearch(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - void OnIqResultGetSearchFields(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - int SearchRenewFields(HWND hwndDlg, JabberSearchData * dat); - void SearchDeleteFromRecent(const char *szAddr, bool deleteLastFromDB); - void SearchAddToRecent(const char *szAddr, HWND hwndDialog = nullptr); + void OnIqResultAdvancedSearch(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OnIqResultGetSearchFields(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + int SearchRenewFields(HWND hwndDlg, JabberSearchData * dat); + void SearchDeleteFromRecent(const char *szAddr, bool deleteLastFromDB); + void SearchAddToRecent(const char *szAddr, HWND hwndDialog = nullptr); //---- jabber_std.cpp ---------------------------------------------- - void JLoginFailed(int errorCode); + void JLoginFailed(int errorCode); //---- jabber_svc.c ------------------------------------------------------------------ - void CheckMenuItems(); - void EnableMenuItems(bool bEnable); + void CheckMenuItems(); + void EnableMenuItems(bool bEnable); INT_PTR __cdecl JabberGetAvatar(WPARAM wParam, LPARAM lParam); INT_PTR __cdecl JabberGetAvatarCaps(WPARAM wParam, LPARAM lParam); @@ -760,193 +762,193 @@ struct CJabberProto : public PROTO, public IJabberInterface INT_PTR __cdecl OnHttpAuthRequest(WPARAM wParam, LPARAM lParam); INT_PTR __cdecl JabberGetApi(WPARAM wParam, LPARAM lParam); - void ExternalTempIqHandler(const TiXmlElement *node, CJabberIqInfo *pInfo); - BOOL ExternalIqHandler(const TiXmlElement *node, CJabberIqInfo *pInfo); - BOOL ExternalMessageHandler(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo); - BOOL ExternalPresenceHandler(const TiXmlElement *node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo); - BOOL ExternalSendHandler(const TiXmlElement *node, ThreadData *pThreadData, CJabberSendInfo* pInfo); - - BOOL SendHttpAuthReply(CJabberHttpAuthParams *pParams, BOOL bAuthorized); + void ExternalTempIqHandler(const TiXmlElement *node, CJabberIqInfo *pInfo); + bool ExternalIqHandler(const TiXmlElement *node, CJabberIqInfo *pInfo); + bool ExternalMessageHandler(const TiXmlElement *node, ThreadData *pThreadData, CJabberMessageInfo* pInfo); + bool ExternalPresenceHandler(const TiXmlElement *node, ThreadData *pThreadData, CJabberPresenceInfo* pInfo); + bool ExternalSendHandler(const TiXmlElement *node, ThreadData *pThreadData, CJabberSendInfo* pInfo); + + bool SendHttpAuthReply(CJabberHttpAuthParams *pParams, bool bAuthorized); //---- jabber_thread.c ---------------------------------------------- - ptrW m_savedPassword; + ptrW m_savedPassword; typedef struct { - bool isPlainAvailable; - bool isPlainOldAvailable; - bool isMd5Available; - bool isScramAvailable; - bool isNtlmAvailable; - bool isSpnegoAvailable; - bool isKerberosAvailable; - bool isAuthAvailable; - bool isSessionAvailable; - char *m_gssapiHostName; + bool isPlainAvailable; + bool isPlainOldAvailable; + bool isMd5Available; + bool isScramAvailable; + bool isNtlmAvailable; + bool isSpnegoAvailable; + bool isKerberosAvailable; + bool isAuthAvailable; + bool isSessionAvailable; + char *m_gssapiHostName; } AUTHMECHS; - AUTHMECHS m_AuthMechs; - - void __cdecl ServerThread(JABBER_CONN_DATA *info); - - void OnProcessFailure(const TiXmlElement *node, ThreadData *info); - void OnProcessFailed(const TiXmlElement *node, ThreadData *info); - void OnProcessEnabled(const TiXmlElement *node, ThreadData *info); - void OnProcessError(const TiXmlElement *node, ThreadData *info); - void OnProcessSuccess(const TiXmlElement *node, ThreadData *info); - void OnProcessChallenge(const TiXmlElement *node, ThreadData *info); - void OnProcessProceed(const TiXmlElement *node, ThreadData *info); - void OnProcessCompressed(const TiXmlElement *node, ThreadData *info); - void OnProcessMessage(const TiXmlElement *node, ThreadData *info); - void OnProcessPresence(const TiXmlElement *node, ThreadData *info); - void OnProcessPresenceCapabilites(const TiXmlElement *node, pResourceStatus &resource); - void OnProcessPubsubEvent(const TiXmlElement *node); - void OnProcessStreamOpening(const TiXmlElement *node, ThreadData *info); - void OnProcessProtocol(const TiXmlElement *node, ThreadData *info); - - void UpdateJidDbSettings(const char *jid); - MCONTACT CreateTemporaryContact(const char *szJid, JABBER_LIST_ITEM* chatItem); - - void PerformRegistration(ThreadData *info); - void PerformIqAuth(ThreadData *info); - void PerformAuthentication(ThreadData *info); - void OnProcessFeatures(const TiXmlElement *node, ThreadData *info); - - void xmlStreamInitialize(char *which); - void xmlStreamInitializeNow(ThreadData *info); - - BOOL OnProcessJingle(const TiXmlElement *node); - void OnProcessIq(const TiXmlElement *node); - void SetRegConfig(CJabberFormDlg *pDlg, void *from); - void CancelRegConfig(CJabberFormDlg *pDlg, void *from); - void OnProcessRegIq(const TiXmlElement *node, ThreadData *info); - void OnPingReply(const TiXmlElement *node, CJabberIqInfo *pInfo); - - bool ProcessCaptcha(const TiXmlElement *node, const TiXmlElement *parentNode, ThreadData *info); - - void EnableCarbons(bool bEnable); + AUTHMECHS m_AuthMechs; + + void __cdecl ServerThread(JABBER_CONN_DATA *info); + + void OnProcessFailure(const TiXmlElement *node, ThreadData *info); + void OnProcessFailed(const TiXmlElement *node, ThreadData *info); + void OnProcessEnabled(const TiXmlElement *node, ThreadData *info); + void OnProcessError(const TiXmlElement *node, ThreadData *info); + void OnProcessSuccess(const TiXmlElement *node, ThreadData *info); + void OnProcessChallenge(const TiXmlElement *node, ThreadData *info); + void OnProcessProceed(const TiXmlElement *node, ThreadData *info); + void OnProcessCompressed(const TiXmlElement *node, ThreadData *info); + void OnProcessMessage(const TiXmlElement *node, ThreadData *info); + void OnProcessPresence(const TiXmlElement *node, ThreadData *info); + void OnProcessPresenceCapabilites(const TiXmlElement *node, pResourceStatus &resource); + void OnProcessPubsubEvent(const TiXmlElement *node); + void OnProcessStreamOpening(const TiXmlElement *node, ThreadData *info); + void OnProcessProtocol(const TiXmlElement *node, ThreadData *info); + + void UpdateJidDbSettings(const char *jid); + MCONTACT CreateTemporaryContact(const char *szJid, JABBER_LIST_ITEM* chatItem); + + void PerformRegistration(ThreadData *info); + void PerformIqAuth(ThreadData *info); + void PerformAuthentication(ThreadData *info); + void OnProcessFeatures(const TiXmlElement *node, ThreadData *info); + + void xmlStreamInitialize(char *which); + void xmlStreamInitializeNow(ThreadData *info); + + bool OnProcessJingle(const TiXmlElement *node); + void OnProcessIq(const TiXmlElement *node); + void SetRegConfig(CJabberFormDlg *pDlg, void *from); + void CancelRegConfig(CJabberFormDlg *pDlg, void *from); + void OnProcessRegIq(const TiXmlElement *node, ThreadData *info); + void OnPingReply(const TiXmlElement *node, CJabberIqInfo *pInfo); + + bool ProcessCaptcha(const TiXmlElement *node, const TiXmlElement *parentNode, ThreadData *info); + + void EnableCarbons(bool bEnable); //---- jabber_util.c ----------------------------------------------------------------- pResourceStatus ResourceInfoFromJID(const char *jid); - void OnGetBob(const TiXmlElement *node, CJabberIqInfo *pInfo); - - MCONTACT HContactFromJID(const char *jid, bool bStripResource = true); - MCONTACT ChatRoomHContactFromJID(const char *jid); - void SendVisibleInvisiblePresence(bool invisible); - void SendPresenceTo(int status, const char* to, const TiXmlElement *extra = nullptr, const char *msg = nullptr); - void SendPresence(int iStatus, bool bSendToAll); - - void RebuildInfoFrame(void); - void InitInfoFrame(void); + void OnGetBob(const TiXmlElement *node, CJabberIqInfo *pInfo); + + MCONTACT HContactFromJID(const char *jid, bool bStripResource = true); + MCONTACT ChatRoomHContactFromJID(const char *jid); + void SendVisibleInvisiblePresence(bool invisible); + void SendPresenceTo(int status, const char* to, const TiXmlElement *extra = nullptr, const char *msg = nullptr); + void SendPresence(int iStatus, bool bSendToAll); + + void RebuildInfoFrame(void); + void InitInfoFrame(void); // returns buf or nullptr on error - char* GetClientJID(MCONTACT hContact, char *dest, size_t destLen); - char* GetClientJID(const char *jid, char *dest, size_t destLen); - - void ComboLoadRecentStrings(HWND hwndDlg, UINT idcCombo, char *param, int recentCount = JABBER_DEFAULT_RECENT_COUNT); - void ComboAddRecentString(HWND hwndDlg, UINT idcCombo, char *param, const wchar_t *string, int recentCount = JABBER_DEFAULT_RECENT_COUNT); - BOOL EnterString(CMStringW &result, const wchar_t *caption, int type, char *windowName=nullptr, int recentCount = JABBER_DEFAULT_RECENT_COUNT, int timeout = 0); - bool IsMyOwnJID(const char *szJID); - - void __cdecl LoadHttpAvatars(void* param); + char* GetClientJID(MCONTACT hContact, char *dest, size_t destLen); + char* GetClientJID(const char *jid, char *dest, size_t destLen); + + void ComboLoadRecentStrings(HWND hwndDlg, UINT idcCombo, char *param, int recentCount = JABBER_DEFAULT_RECENT_COUNT); + void ComboAddRecentString(HWND hwndDlg, UINT idcCombo, char *param, const wchar_t *string, int recentCount = JABBER_DEFAULT_RECENT_COUNT); + BOOL EnterString(CMStringW &result, const wchar_t *caption, int type, char *windowName=nullptr, int recentCount = JABBER_DEFAULT_RECENT_COUNT, int timeout = 0); + bool IsMyOwnJID(const char *szJID); + + void __cdecl LoadHttpAvatars(void* param); //---- jabber_vcard.c ----------------------------------------------- - int m_vCardUpdates; - bool m_bPhotoChanged; - wchar_t m_szPhotoFileName[MAX_PATH]; - void OnUserInfoInit_VCard(WPARAM, LPARAM); - - int SendGetVcard(MCONTACT hContact); - void AppendVcardFromDB(TiXmlElement *n, char* tag, char* key); - void SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName); - void SaveVcardToDB(HWND hwndPage, int iPage); + int m_vCardUpdates; + bool m_bPhotoChanged; + wchar_t m_szPhotoFileName[MAX_PATH]; + void OnUserInfoInit_VCard(WPARAM, LPARAM); + + int SendGetVcard(MCONTACT hContact); + void AppendVcardFromDB(TiXmlElement *n, char* tag, char* key); + void SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName); + void SaveVcardToDB(HWND hwndPage, int iPage); //---- jabber_ws.c ------------------------------------------------- HNETLIBCONN WsConnect(char* host, WORD port); - BOOL WsInit(void); - int WsSend(HNETLIBCONN s, char* data, int datalen, int flags); - int WsRecv(HNETLIBCONN s, char* data, long datalen, int flags); + bool WsInit(void); + int WsSend(HNETLIBCONN s, char* data, int datalen, int flags); + int WsRecv(HNETLIBCONN s, char* data, long datalen, int flags); //---- jabber_xml.c ------------------------------------------------------------------ - void OnConsoleProcessXml(const TiXmlElement *node, DWORD flags); + void OnConsoleProcessXml(const TiXmlElement *node, DWORD flags); //---- jabber_xmlns.c ---------------------------------------------------------------- - BOOL OnHandleDiscoInfoRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); - BOOL OnHandleDiscoItemsRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + bool OnHandleDiscoInfoRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + bool OnHandleDiscoItemsRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); //---- jabber_xstatus.c -------------------------------------------------------------- - INT_PTR __cdecl OnSetListeningTo(WPARAM wParam, LPARAM lParams); - INT_PTR __cdecl OnGetXStatusIcon(WPARAM wParam, LPARAM lParams); - INT_PTR __cdecl OnGetXStatusEx(WPARAM wParam, LPARAM lParams); - INT_PTR __cdecl OnSetXStatusEx(WPARAM wParam, LPARAM lParams); - - HICON GetXStatusIcon(int bStatus, UINT flags); - - void RegisterAdvStatusSlot(const char *pszSlot); - void ResetAdvStatus(MCONTACT hContact, const char *pszSlot); - void WriteAdvStatus(MCONTACT hContact, const char *pszSlot, const wchar_t *pszMode, const char *pszIcon, const wchar_t *pszTitle, const wchar_t *pszText); - char* ReadAdvStatusA(MCONTACT hContact, const char *pszSlot, const char *pszValue); - wchar_t *ReadAdvStatusT(MCONTACT hContact, const char *pszSlot, const char *pszValue); - - BOOL SendPepTune(wchar_t *szArtist, wchar_t *szLength, wchar_t *szSource, wchar_t *szTitle, wchar_t *szTrack, wchar_t *szUri); - - void XStatusInit(void); - - void SetContactTune(MCONTACT hContact, const wchar_t *szArtist, const wchar_t *szLength, const wchar_t *szSource, const wchar_t *szTitle, const wchar_t *szTrack); - - void InfoFrame_OnUserMood(CJabberInfoFrame_Event *evt); - void InfoFrame_OnUserActivity(CJabberInfoFrame_Event *evt); + INT_PTR __cdecl OnSetListeningTo(WPARAM wParam, LPARAM lParams); + INT_PTR __cdecl OnGetXStatusIcon(WPARAM wParam, LPARAM lParams); + INT_PTR __cdecl OnGetXStatusEx(WPARAM wParam, LPARAM lParams); + INT_PTR __cdecl OnSetXStatusEx(WPARAM wParam, LPARAM lParams); + + HICON GetXStatusIcon(int bStatus, UINT flags); + + void RegisterAdvStatusSlot(const char *pszSlot); + void ResetAdvStatus(MCONTACT hContact, const char *pszSlot); + void WriteAdvStatus(MCONTACT hContact, const char *pszSlot, const wchar_t *pszMode, const char *pszIcon, const wchar_t *pszTitle, const wchar_t *pszText); + char* ReadAdvStatusA(MCONTACT hContact, const char *pszSlot, const char *pszValue); + wchar_t* ReadAdvStatusT(MCONTACT hContact, const char *pszSlot, const char *pszValue); + + bool SendPepTune(wchar_t *szArtist, wchar_t *szLength, wchar_t *szSource, wchar_t *szTitle, wchar_t *szTrack, wchar_t *szUri); + + void XStatusInit(void); + + void SetContactTune(MCONTACT hContact, const wchar_t *szArtist, const wchar_t *szLength, const wchar_t *szSource, const wchar_t *szTitle, const wchar_t *szTrack); + + void InfoFrame_OnUserMood(CJabberInfoFrame_Event *evt); + void InfoFrame_OnUserActivity(CJabberInfoFrame_Event *evt); CPepServiceList m_pepServices; private: - char *m_szXmlStreamToBeInitialized; + char *m_szXmlStreamToBeInitialized; - DWORD m_lastTicks; + DWORD m_lastTicks; - HANDLE m_hPopupClass; + HANDLE m_hPopupClass; - LONG m_nSerial; + LONG m_nSerial; HGENMENU m_hPrivacyMenuRoot; bool m_menuItemsStatus; LIST m_hPrivacyMenuItems; int m_nMenuResourceItems; - HGENMENU *m_phMenuResourceItems; + HGENMENU* m_phMenuResourceItems; JabberFeatCapPairDynamic* FindFeature(const char *szFeature); public: - DWORD STDMETHODCALLTYPE GetFlags() const override; // Set of JIF_* flags. - int STDMETHODCALLTYPE GetVersion() const override; // Returns version of IJabberInterface. - DWORD STDMETHODCALLTYPE GetJabberVersion() const override; // Returns Jabber plugin version. - - MCONTACT STDMETHODCALLTYPE ContactFromJID(const char *jid) override; // Returns contact handle for given JID. - char* STDMETHODCALLTYPE ContactToJID(MCONTACT hContact) override; // Returns JID of hContact. You must free the result using mir_free(). - char* STDMETHODCALLTYPE GetBestResourceName(const char *jid) override; // Returns best resource name for given JID. You must free the result using mir_free(). - char* STDMETHODCALLTYPE GetResourceList(const char *jid) override; // Returns all resource names for a given JID in format "resource1\0resource2\0resource3\0\0" (all resources are separated by \0 character and the whole string is terminated with two \0 characters). You must free the string using mir_free(). - char* STDMETHODCALLTYPE GetModuleName() const override; // Returns Jabber module name. - - int STDMETHODCALLTYPE SerialNext() override; // Returns id that can be used for next message sent through SendXmlNode(). - - HJHANDLER STDMETHODCALLTYPE AddPresenceHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority) override; - HJHANDLER STDMETHODCALLTYPE AddMessageHandler(JABBER_HANDLER_FUNC Func, int iMsgTypes, const char *szXmlns, const char *szTag, void *pUserData, int iPriority) override; - HJHANDLER STDMETHODCALLTYPE AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, const char *szXmlns, const char *szTag, void *pUserData, int iPriority) override; - HJHANDLER STDMETHODCALLTYPE AddSendHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority) override; - int STDMETHODCALLTYPE RemoveHandler(HJHANDLER hHandler) override; - - int STDMETHODCALLTYPE RegisterFeature(const char *szFeature, const char *szDescription) override; - int STDMETHODCALLTYPE AddFeatures(const char *szFeatures) override; // Adds features to the list of features returned by the client. - int STDMETHODCALLTYPE RemoveFeatures(const char *szFeatures) override; // Removes features from the list of features returned by the client. - char* STDMETHODCALLTYPE GetResourceFeatures(const char *jid) override; // Returns all features supported by JID in format "feature1\0feature2\0...\0featureN\0\0". You must free returned string using mir_free(). + DWORD STDMETHODCALLTYPE GetFlags() const override; // Set of JIF_* flags. + int STDMETHODCALLTYPE GetVersion() const override; // Returns version of IJabberInterface. + DWORD STDMETHODCALLTYPE GetJabberVersion() const override; // Returns Jabber plugin version. + + MCONTACT STDMETHODCALLTYPE ContactFromJID(const char *jid) override; // Returns contact handle for given JID. + char* STDMETHODCALLTYPE ContactToJID(MCONTACT hContact) override; // Returns JID of hContact. You must free the result using mir_free(). + char* STDMETHODCALLTYPE GetBestResourceName(const char *jid) override; // Returns best resource name for given JID. You must free the result using mir_free(). + char* STDMETHODCALLTYPE GetResourceList(const char *jid) override; // Returns all resource names for a given JID in format "resource1\0resource2\0resource3\0\0" (all resources are separated by \0 character and the whole string is terminated with two \0 characters). You must free the string using mir_free(). + char* STDMETHODCALLTYPE GetModuleName() const override; // Returns Jabber module name. + + int STDMETHODCALLTYPE SerialNext() override; // Returns id that can be used for next message sent through SendXmlNode(). + + HJHANDLER STDMETHODCALLTYPE AddPresenceHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority) override; + HJHANDLER STDMETHODCALLTYPE AddMessageHandler(JABBER_HANDLER_FUNC Func, int iMsgTypes, const char *szXmlns, const char *szTag, void *pUserData, int iPriority) override; + HJHANDLER STDMETHODCALLTYPE AddIqHandler(JABBER_HANDLER_FUNC Func, int iIqTypes, const char *szXmlns, const char *szTag, void *pUserData, int iPriority) override; + HJHANDLER STDMETHODCALLTYPE AddSendHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority) override; + int STDMETHODCALLTYPE RemoveHandler(HJHANDLER hHandler) override; + + int STDMETHODCALLTYPE RegisterFeature(const char *szFeature, const char *szDescription) override; + int STDMETHODCALLTYPE AddFeatures(const char *szFeatures) override; // Adds features to the list of features returned by the client. + int STDMETHODCALLTYPE RemoveFeatures(const char *szFeatures) override; // Removes features from the list of features returned by the client. + char* STDMETHODCALLTYPE GetResourceFeatures(const char *jid) override; // Returns all features supported by JID in format "feature1\0feature2\0...\0featureN\0\0". You must free returned string using mir_free(). HNETLIBUSER STDMETHODCALLTYPE GetHandle() override; // Returns connection handle }; diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp index 8b37b8429e..01d659a7de 100644 --- a/protocols/JabberG/src/jabber_rc.cpp +++ b/protocols/JabberG/src/jabber_rc.cpp @@ -29,77 +29,71 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "jabber_iq.h" #include "jabber_rc.h" -CJabberAdhocSession::CJabberAdhocSession(CJabberProto* global) +CJabberAdhocSession::CJabberAdhocSession(CJabberProto* _ppro) : + ppro(_ppro) { - m_pNext = nullptr; - m_pUserData = nullptr; - m_bAutofreeUserData = FALSE; - m_dwStage = 0; - ppro = global; m_szSessionId.Format("%u%u", ppro->SerialNext(), GetTickCount()); m_dwStartTime = GetTickCount(); } -BOOL CJabberProto::IsRcRequestAllowedByACL(CJabberIqInfo *pInfo) +bool CJabberProto::IsRcRequestAllowedByACL(CJabberIqInfo *pInfo) { if (!pInfo || !pInfo->GetFrom()) - return FALSE; + return false; return IsMyOwnJID(pInfo->GetFrom()); } -BOOL CJabberProto::HandleAdhocCommandRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) +bool CJabberProto::HandleAdhocCommandRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo) { if (!pInfo->GetChildNode()) - return TRUE; + return true; if (!m_bEnableRemoteControl || !IsRcRequestAllowedByACL(pInfo)) { // FIXME: send error and return - return TRUE; + return true; } const char *szNode = XmlGetAttr(pInfo->GetChildNode(), "node"); - if (!szNode) - return TRUE; - - m_adhocManager.HandleCommandRequest(iqNode, pInfo, szNode); - return TRUE; + if (szNode) + m_adhocManager.HandleCommandRequest(iqNode, pInfo, szNode); + return true; } -BOOL CJabberAdhocManager::HandleItemsRequest(const TiXmlElement*, CJabberIqInfo *pInfo, const char *szNode) +bool CJabberAdhocManager::HandleItemsRequest(const TiXmlElement*, CJabberIqInfo *pInfo, const char *szNode) { if (!szNode || !m_pProto->m_bEnableRemoteControl || !m_pProto->IsRcRequestAllowedByACL(pInfo)) - return FALSE; + return false; - if (!mir_strcmp(szNode, JABBER_FEAT_COMMANDS)) { - XmlNodeIq iq("result", pInfo); - TiXmlElement *resultQuery = iq << XQUERY(JABBER_FEAT_DISCO_ITEMS) << XATTR("node", JABBER_FEAT_COMMANDS); - { - mir_cslock lck(m_cs); + if (mir_strcmp(szNode, JABBER_FEAT_COMMANDS)) + return false; - CJabberAdhocNode* pNode = GetFirstNode(); - while (pNode) { - const char *szJid = pNode->GetJid(); - if (!szJid) - szJid = m_pProto->m_ThreadInfo->fullJID; + XmlNodeIq iq("result", pInfo); + TiXmlElement *resultQuery = iq << XQUERY(JABBER_FEAT_DISCO_ITEMS) << XATTR("node", JABBER_FEAT_COMMANDS); + { + mir_cslock lck(m_cs); - resultQuery << XCHILD("item") << XATTR("jid", szJid) - << XATTR("node", pNode->GetNode()) << XATTR("name", pNode->GetName()); + CJabberAdhocNode* pNode = GetFirstNode(); + while (pNode) { + const char *szJid = pNode->GetJid(); + if (!szJid) + szJid = m_pProto->m_ThreadInfo->fullJID; - pNode = pNode->GetNext(); - } - } + resultQuery << XCHILD("item") << XATTR("jid", szJid) + << XATTR("node", pNode->GetNode()) << XATTR("name", pNode->GetName()); - m_pProto->m_ThreadInfo->send(iq); - return TRUE; + pNode = pNode->GetNext(); + } } - return FALSE; + + m_pProto->m_ThreadInfo->send(iq); + return true; } -BOOL CJabberAdhocManager::HandleInfoRequest(const TiXmlElement*, CJabberIqInfo *pInfo, const char *szNode) +bool CJabberAdhocManager::HandleInfoRequest(const TiXmlElement*, CJabberIqInfo *pInfo, const char *szNode) { if (!szNode || !m_pProto->m_bEnableRemoteControl || !m_pProto->IsRcRequestAllowedByACL(pInfo)) - return FALSE; + return false; // FIXME: same code twice if (!mir_strcmp(szNode, JABBER_FEAT_COMMANDS)) { @@ -114,13 +108,13 @@ BOOL CJabberAdhocManager::HandleInfoRequest(const TiXmlElement*, CJabberIqInfo * resultQuery << XCHILD("feature") << XATTR("var", JABBER_FEAT_DISCO_ITEMS); m_pProto->m_ThreadInfo->send(iq); - return TRUE; + return true; } mir_cslockfull lck(m_cs); CJabberAdhocNode *pNode = FindNode(szNode); if (pNode == nullptr) - return FALSE; + return false; XmlNodeIq iq("result", pInfo); TiXmlElement *resultQuery = iq << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR("node", JABBER_FEAT_DISCO_INFO); @@ -132,10 +126,10 @@ BOOL CJabberAdhocManager::HandleInfoRequest(const TiXmlElement*, CJabberIqInfo * resultQuery << XCHILD("feature") << XATTR("var", JABBER_FEAT_DISCO_INFO); lck.unlock(); m_pProto->m_ThreadInfo->send(iq); - return TRUE; + return true; } -BOOL CJabberAdhocManager::HandleCommandRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, const char *szNode) +bool CJabberAdhocManager::HandleCommandRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, const char *szNode) { // ATTN: ACL and db settings checked in calling function @@ -151,7 +145,7 @@ BOOL CJabberAdhocManager::HandleCommandRequest(const TiXmlElement *iqNode, CJabb << XCHILD("error") << XATTR("type", "cancel") << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas")); - return FALSE; + return false; } const char *szSessionId = XmlGetAttr(commandNode, "sessionid"); @@ -167,11 +161,10 @@ BOOL CJabberAdhocManager::HandleCommandRequest(const TiXmlElement *iqNode, CJabb errorNode << XCHILDNS("bad-request", "urn:ietf:params:xml:ns:xmpp-stanzas"); errorNode << XCHILDNS("bad-sessionid", JABBER_FEAT_COMMANDS); m_pProto->m_ThreadInfo->send(iq); - return FALSE; + return false; } } - else - pSession = AddNewSession(); + else pSession = AddNewSession(); if (!pSession) { lck.unlock(); @@ -181,7 +174,7 @@ BOOL CJabberAdhocManager::HandleCommandRequest(const TiXmlElement *iqNode, CJabb << XCHILD("error") << XATTR("type", "cancel") << XCHILDNS("forbidden", "urn:ietf:params:xml:ns:xmpp-stanzas")); - return FALSE; + return false; } // session id and node exits here, call handler @@ -213,10 +206,10 @@ BOOL CJabberAdhocManager::HandleCommandRequest(const TiXmlElement *iqNode, CJabb pSession = nullptr; } - return TRUE; + return true; } -BOOL CJabberAdhocManager::FillDefaultNodes() +void CJabberAdhocManager::FillDefaultNodes() { AddNode(nullptr, JABBER_FEAT_RC_SET_STATUS, TranslateU("Set status"), &CJabberProto::AdhocSetStatusHandler); AddNode(nullptr, JABBER_FEAT_RC_SET_OPTIONS, TranslateU("Set options"), &CJabberProto::AdhocOptionsHandler); @@ -224,11 +217,9 @@ BOOL CJabberAdhocManager::FillDefaultNodes() AddNode(nullptr, JABBER_FEAT_RC_LEAVE_GROUPCHATS, TranslateU("Leave group chats"), &CJabberProto::AdhocLeaveGroupchatsHandler); AddNode(nullptr, JABBER_FEAT_RC_WS_LOCK, TranslateU("Lock workstation"), &CJabberProto::AdhocLockWSHandler); AddNode(nullptr, JABBER_FEAT_RC_QUIT_MIRANDA, TranslateU("Quit Miranda NG"), &CJabberProto::AdhocQuitMirandaHandler); - return TRUE; } - -static char *StatusModeToDbSetting(int status, const char *suffix) +static char* StatusModeToDbSetting(int status, const char *suffix) { char *prefix; static char str[64]; @@ -525,7 +516,7 @@ int CJabberProto::AdhocForwardHandler(const TiXmlElement*, CJabberIqInfo *pInfo, if (!xNode) return JABBER_ADHOC_HANDLER_STATUS_CANCEL; - BOOL bRemoveCListEvents = TRUE; + bool bRemoveCListEvents = true; // remove clist events if (auto *fieldNode = XmlGetChildByTag(xNode, "field", "var", "remove-clist-events")) diff --git a/protocols/JabberG/src/jabber_rc.h b/protocols/JabberG/src/jabber_rc.h index e6c1befcb0..fe742a78a8 100644 --- a/protocols/JabberG/src/jabber_rc.h +++ b/protocols/JabberG/src/jabber_rc.h @@ -43,13 +43,14 @@ class CJabberAdhocSession { protected: CMStringA m_szSessionId; - CJabberAdhocSession* m_pNext; + CJabberAdhocSession* m_pNext = nullptr; DWORD m_dwStartTime; - void* m_pUserData; + void* m_pUserData = nullptr; BOOL m_bAutofreeUserData; - DWORD m_dwStage; + DWORD m_dwStage = 0; + public: CJabberProto *ppro; CJabberAdhocSession(CJabberProto* global); @@ -60,64 +61,70 @@ public: if (m_pNext) delete m_pNext; } + CJabberAdhocSession* GetNext() { return m_pNext; } + CJabberAdhocSession* SetNext(CJabberAdhocSession *pNext) { CJabberAdhocSession *pRetVal = m_pNext; m_pNext = pNext; return pRetVal; } + DWORD GetSessionStartTime() { return m_dwStartTime; } + const char* GetSessionId() { return m_szSessionId; } - BOOL SetUserData(void* pUserData, BOOL bAutofree = FALSE) + + void SetUserData(void* pUserData, BOOL bAutofree = FALSE) { if (m_bAutofreeUserData && m_pUserData) mir_free(m_pUserData); m_pUserData = pUserData; m_bAutofreeUserData = bAutofree; - return TRUE; } + DWORD SetStage(DWORD dwStage) { DWORD dwRetVal = m_dwStage; m_dwStage = dwStage; return dwRetVal; } + DWORD GetStage() { return m_dwStage; } }; -class CJabberAdhocNode; class CJabberAdhocNode { protected: char *m_szJid; char *m_szNode; char *m_szName; - CJabberAdhocNode* m_pNext; + CJabberAdhocNode* m_pNext = nullptr; JABBER_ADHOC_HANDLER m_pHandler; CJabberProto *m_pProto; + public: - CJabberAdhocNode(CJabberProto* pProto, const char *szJid, const char *szNode, const char *szName, JABBER_ADHOC_HANDLER pHandler) + CJabberAdhocNode(CJabberProto* pProto, const char *szJid, const char *szNode, const char *szName, JABBER_ADHOC_HANDLER pHandler) : + m_pProto(pProto), + m_pHandler(pHandler) { - memset(this, 0, sizeof(CJabberAdhocNode)); - replaceStr(m_szJid, szJid); - replaceStr(m_szNode, szNode); - replaceStr(m_szName, szName); - m_pHandler = pHandler; - m_pProto = pProto; + m_szJid = mir_strdup(szJid); + m_szNode = mir_strdup(szNode); + m_szName = mir_strdup(szName); } + ~CJabberAdhocNode() { mir_free(m_szJid); @@ -127,32 +134,33 @@ public: if (m_pNext) delete m_pNext; } - CJabberAdhocNode* GetNext() const + + __inline CJabberAdhocNode* GetNext() const { return m_pNext; } - CJabberAdhocNode* SetNext(CJabberAdhocNode *pNext) + + __inline CJabberAdhocNode* SetNext(CJabberAdhocNode *pNext) { CJabberAdhocNode *pRetVal = m_pNext; m_pNext = pNext; return pRetVal; } - char* GetJid() const - { + + __inline char* GetJid() const { return m_szJid; } - char* GetNode() const - { + __inline char* GetNode() const { return m_szNode; } - char* GetName() const - { + __inline char* GetName() const { return m_szName; } - BOOL CallHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession) + + bool CallHandler(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, CJabberAdhocSession *pSession) { if (m_pHandler == nullptr) - return FALSE; + return false; return (m_pProto->*m_pHandler)(iqNode, pInfo, pSession); } }; @@ -161,8 +169,8 @@ class CJabberAdhocManager { protected: CJabberProto *m_pProto; - CJabberAdhocNode* m_pNodes; - CJabberAdhocSession* m_pSessions; + CJabberAdhocNode* m_pNodes = nullptr; + CJabberAdhocSession* m_pSessions = nullptr; mir_cs m_cs; CJabberAdhocSession* FindSession(const char *szSession) @@ -199,16 +207,16 @@ protected: return nullptr; } - BOOL RemoveSession(CJabberAdhocSession *pSession) + bool RemoveSession(CJabberAdhocSession *pSession) { if (!m_pSessions) - return FALSE; + return false; if (pSession == m_pSessions) { m_pSessions = m_pSessions->GetNext(); pSession->SetNext(nullptr); delete pSession; - return TRUE; + return true; } CJabberAdhocSession* pTmp = m_pSessions; @@ -217,24 +225,24 @@ protected: pTmp->SetNext(pSession->GetNext()); pSession->SetNext(nullptr); delete pSession; - return TRUE; + return true; } pTmp = pTmp->GetNext(); } - return FALSE; + return false; } - BOOL _ExpireSession(DWORD dwExpireTime) + bool _ExpireSession(DWORD dwExpireTime) { if (!m_pSessions) - return FALSE; + return false; CJabberAdhocSession *pSession = m_pSessions; if (pSession->GetSessionStartTime() < dwExpireTime) { m_pSessions = pSession->GetNext(); pSession->SetNext(nullptr); delete pSession; - return TRUE; + return true; } while (pSession->GetNext()) { @@ -243,33 +251,30 @@ protected: pSession->SetNext(pSession->GetNext()->GetNext()); pRetVal->SetNext(nullptr); delete pRetVal; - return TRUE; + return true; } pSession = pSession->GetNext(); } - return FALSE; + return false; } public: - CJabberAdhocManager(CJabberProto* pProto) - { - m_pProto = pProto; - m_pNodes = nullptr; - m_pSessions = nullptr; + CJabberAdhocManager(CJabberProto* pProto) : + m_pProto(pProto) + { } + ~CJabberAdhocManager() { delete m_pNodes; delete m_pSessions; } - BOOL FillDefaultNodes(); + void FillDefaultNodes(); - BOOL AddNode(const char *szJid, const char *szNode, const char *szName, JABBER_ADHOC_HANDLER pHandler) + void AddNode(const char *szJid, const char *szNode, const char *szName, JABBER_ADHOC_HANDLER pHandler) { CJabberAdhocNode* pNode = new CJabberAdhocNode(m_pProto, szJid, szNode, szName, pHandler); - if (!pNode) - return FALSE; mir_cslock lck(m_cs); if (!m_pNodes) @@ -280,7 +285,6 @@ public: pTmp = pTmp->GetNext(); pTmp->SetNext(pNode); } - return TRUE; } CJabberAdhocNode* GetFirstNode() @@ -288,17 +292,16 @@ public: return m_pNodes; } - BOOL HandleItemsRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, const char *szNode); - BOOL HandleInfoRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, const char *szNode); - BOOL HandleCommandRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, const char *szNode); + bool HandleItemsRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, const char *szNode); + bool HandleInfoRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, const char *szNode); + bool HandleCommandRequest(const TiXmlElement *iqNode, CJabberIqInfo *pInfo, const char *szNode); - BOOL ExpireSessions() + void ExpireSessions() { mir_cslock lck(m_cs); DWORD dwExpireTime = GetTickCount() - JABBER_ADHOC_SESSION_EXPIRE_TIME; while (_ExpireSession(dwExpireTime)) ; - return TRUE; } }; diff --git a/protocols/JabberG/src/jabber_roster.cpp b/protocols/JabberG/src/jabber_roster.cpp index f0b569c6ba..139de1076e 100644 --- a/protocols/JabberG/src/jabber_roster.cpp +++ b/protocols/JabberG/src/jabber_roster.cpp @@ -309,11 +309,11 @@ public: if (m_list.FindItem(-1, &lvfi) == -1) { ptrA tszName(db_get_utfa(hContact, "CList", "MyHandle")); ptrA tszGroup(db_get_utfa(hContact, "CList", "Group")); - _RosterInsertListItem(T2Utf(tszJid), tszName, tszGroup, nullptr, FALSE); + _RosterInsertListItem(T2Utf(tszJid), tszName, tszGroup, nullptr, false); } } - m_bReadyToDownload = FALSE; - m_bReadyToUpload = TRUE; + m_bReadyToDownload = false; + m_bReadyToUpload = true; btnDownload.SetText(TranslateT("Download")); btnUpload.SetText(TranslateT("Upload")); OnChangeStatus(); @@ -351,20 +351,20 @@ public: itemCount++; } else if (!bRemove) { - BOOL bPushed = itemRoster ? TRUE : FALSE; + bool bPushed = itemRoster != 0; if (!bPushed) { const char *rosterName = XmlGetAttr(itemRoster, "name"); if ((rosterName != nullptr || name[0] != 0) && mir_strcmpi(rosterName, szName)) - bPushed = TRUE; + bPushed = true; if (!bPushed) { rosterName = XmlGetAttr(itemRoster, "subscription"); if ((rosterName != nullptr || subscr[0] != 0) && mir_strcmpi(rosterName, T2Utf(subscr))) - bPushed = TRUE; + bPushed = true; } if (!bPushed) { auto *rosterGroup = XmlGetChildText(itemRoster, "group"); if (rosterGroup != nullptr && mir_strcmpi(rosterGroup, szGroup)) - bPushed = TRUE; + bPushed = true; } } if (bPushed) { @@ -503,7 +503,7 @@ public: const TiXmlElement *Table = TiXmlConst(&doc)["Workbook"]["Worksheet"]["Table"].ToElement(); if (Table) { for (auto *Row : TiXmlFilter(Table, "Row")) { - BOOL bAdd = FALSE; + bool bAdd = false; const char *jid = nullptr; const char *name = nullptr; const char *group = nullptr; @@ -511,15 +511,18 @@ public: auto *Cell = XmlFirstChild(Row, "Cell"); auto *Data = XmlFirstChild(Cell, "Data"); if (Data) { - if (!mir_strcmpi(Data->GetText(), "+")) bAdd = TRUE; - else if (mir_strcmpi(Data->GetText(), "-")) continue; + if (!mir_strcmpi(Data->GetText(), "+")) + bAdd = true; + else if (mir_strcmpi(Data->GetText(), "-")) + continue; Cell = Cell->NextSiblingElement("Cell"); if (Cell) Data = XmlFirstChild(Cell, "Data"); else Data = nullptr; if (Data) { jid = Data->GetText(); - if (!jid || mir_strlen(jid) == 0) continue; + if (!jid || mir_strlen(jid) == 0) + continue; } Cell = Cell->NextSiblingElement("Cell"); diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp index a76289d857..8df2fe88dc 100644 --- a/protocols/JabberG/src/jabber_search.cpp +++ b/protocols/JabberG/src/jabber_search.cpp @@ -168,7 +168,8 @@ void CJabberProto::OnIqResultGetSearchFields(const TiXmlElement *iqNode, CJabber MyData->Var = mir_utf8decodeW(chNode->Name()); MyData->defValue = mir_utf8decodeW(chNode->GetText()); MyData->Order = Order; - if (MyData->defValue) MyData->bReadOnly = TRUE; + if (MyData->defValue) + MyData->bReadOnly = true; PostMessage(searchHandleDlg, WM_USER + 10, FALSE, (LPARAM)MyData); Order++; } @@ -725,7 +726,7 @@ HWND CJabberProto::SearchAdvanced(HWND hwndDlg) return nullptr; // formating request - BOOL fRequestNotEmpty = FALSE; + bool fRequestNotEmpty = false; // get server name wchar_t szServerName[100]; @@ -742,7 +743,7 @@ HWND CJabberProto::SearchAdvanced(HWND hwndDlg) // next can be 2 cases: // Forms: XEP-0055 Example 7 if (dat->fSearchRequestIsXForm) { - fRequestNotEmpty = TRUE; + fRequestNotEmpty = true; JabberFormGetData(GetDlgItem(hwndDlg, IDC_FRAME), query, dat->xNode); } else { //and Simple fields: XEP-0055 Example 3 @@ -751,7 +752,7 @@ HWND CJabberProto::SearchAdvanced(HWND hwndDlg) GetWindowText(dat->pJSInf[i].hwndValueItem, szFieldValue, _countof(szFieldValue)); if (szFieldValue[0] != 0) { XmlAddChildA(query, T2Utf(dat->pJSInf[i].szFieldName).get(), T2Utf(szFieldValue).get()); - fRequestNotEmpty = TRUE; + fRequestNotEmpty = true; } } } diff --git a/protocols/JabberG/src/jabber_search.h b/protocols/JabberG/src/jabber_search.h index 17843b06a0..5e44b29e71 100644 --- a/protocols/JabberG/src/jabber_search.h +++ b/protocols/JabberG/src/jabber_search.h @@ -56,8 +56,8 @@ struct Data wchar_t *Label; wchar_t *Var; wchar_t *defValue; - BOOL bHidden; - BOOL bReadOnly; + bool bHidden; + bool bReadOnly; int Order; }; diff --git a/protocols/JabberG/src/jabber_send_manager.h b/protocols/JabberG/src/jabber_send_manager.h index 47fbd2c80e..5dbe2a6bdc 100644 --- a/protocols/JabberG/src/jabber_send_manager.h +++ b/protocols/JabberG/src/jabber_send_manager.h @@ -35,7 +35,7 @@ typedef void (*SEND_USER_DATA_FREE_FUNC)(void *pUserData); class CJabberSendInfo; -typedef BOOL (CJabberProto::*JABBER_SEND_HANDLER)(const TiXmlElement *node, ThreadData *pThreadData, CJabberSendInfo* pInfo); +typedef bool (CJabberProto::*JABBER_SEND_HANDLER)(const TiXmlElement *node, ThreadData *pThreadData, CJabberSendInfo* pInfo); class CJabberSendInfo { diff --git a/protocols/JabberG/src/jabber_strm_mgmt.cpp b/protocols/JabberG/src/jabber_strm_mgmt.cpp index f68c2805a5..94b89e4eae 100755 --- a/protocols/JabberG/src/jabber_strm_mgmt.cpp +++ b/protocols/JabberG/src/jabber_strm_mgmt.cpp @@ -276,7 +276,7 @@ void strm_mgmt::FinishLoginProcess(ThreadData *info) << XCHILD("resource", info->resource)); if (proto->m_AuthMechs.isSessionAvailable) - info->bIsSessionAvailable = TRUE; + info->bIsSessionAvailable = true; return; } diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index 739c9c35a1..0b4848614a 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -511,10 +511,10 @@ INT_PTR __cdecl CJabberProto::JabberSendNudge(WPARAM hContact, LPARAM) return 0; } -BOOL CJabberProto::SendHttpAuthReply(CJabberHttpAuthParams *pParams, BOOL bAuthorized) +bool CJabberProto::SendHttpAuthReply(CJabberHttpAuthParams *pParams, bool bAuthorized) { if (!m_bJabberOnline || !pParams || !m_ThreadInfo) - return FALSE; + return false; if (pParams->m_nType == CJabberHttpAuthParams::IQ) { XmlNodeIq iq(bAuthorized ? "result" : "error", pParams->m_szIqId, pParams->m_szFrom); @@ -525,8 +525,10 @@ BOOL CJabberProto::SendHttpAuthReply(CJabberHttpAuthParams *pParams, BOOL bAutho << XCHILDNS("not-authorized", "urn:ietf:params:xml:xmpp-stanzas"); } m_ThreadInfo->send(iq); + return true; } - else if (pParams->m_nType == CJabberHttpAuthParams::MSG) { + + if (pParams->m_nType == CJabberHttpAuthParams::MSG) { XmlNode msg("message"); msg << XATTR("to", pParams->m_szFrom); if (!bAuthorized) @@ -542,10 +544,9 @@ BOOL CJabberProto::SendHttpAuthReply(CJabberHttpAuthParams *pParams, BOOL bAutho << XCHILDNS("not-authorized", "urn:ietf:params:xml:xmpp-stanzas"); m_ThreadInfo->send(msg); + return true; } - else return FALSE; - - return TRUE; + return false; } class CJabberDlgHttpAuth : public CJabberDlgBase diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index dda7597d6a..87972f5cc0 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -90,7 +90,7 @@ static INT_PTR CALLBACK JabberPasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa param->pro->setByte("SavePassword", savePassword); if (savePassword) { param->pro->setWString("Password", param->onlinePassword); - param->saveOnlinePassword = TRUE; + param->saveOnlinePassword = true; } } __fallthrough; @@ -692,7 +692,7 @@ void CJabberProto::OnProcessFeatures(const TiXmlElement *node, ThreadData *info) if (!mir_strcmp(pszName, "compression") && m_bEnableZlib == TRUE) { debugLogA("Server compression available"); for (auto *c : TiXmlFilter(n, "method")) { - if (!mir_strcmp(c->GetText(), "zlib") && info->zlibInit() == TRUE) { + if (!mir_strcmp(c->GetText(), "zlib") && info->zlibInit()) { debugLogA("Requesting Zlib compression"); info->send(XmlNode("compress") << XATTR("xmlns", "http://jabber.org/protocol/compress") << XCHILD("method", "zlib")); @@ -758,7 +758,7 @@ void CJabberProto::OnProcessFeatures(const TiXmlElement *node, ThreadData *info) << XCHILD("resource", info->resource)); if (m_AuthMechs.isSessionAvailable) - info->bIsSessionAvailable = TRUE; + info->bIsSessionAvailable = true; return; } @@ -940,7 +940,7 @@ void CJabberProto::OnProcessCompressed(const TiXmlElement *node, ThreadData *inf debugLogA("Starting Zlib stream compression..."); - info->useZlib = TRUE; + info->useZlib = true; info->zRecvData = (char*)mir_alloc(ZLIB_CHUNK_SIZE); xmlStreamInitialize("after successful Zlib init"); @@ -1367,7 +1367,7 @@ void CJabberProto::OnProcessMessage(const TiXmlElement *node, ThreadData *info) if (item != nullptr) { if (pFromResource) { - pFromResource->m_bMessageSessionActive = TRUE; + pFromResource->m_bMessageSessionActive = true; JABBER_RESOURCE_STATUS *pLast = item->m_pLastSeenResource; item->m_pLastSeenResource = pFromResource; @@ -1739,13 +1739,15 @@ void CJabberProto::OnProcessPresence(const TiXmlElement *node, ThreadData *info) } } -BOOL CJabberProto::OnProcessJingle(const TiXmlElement *node) +bool CJabberProto::OnProcessJingle(const TiXmlElement *node) { const char *type; auto *child = XmlGetChildByTag(node, "jingle", "xmlns", JABBER_FEAT_JINGLE); if (child) { - if ((type = XmlGetAttr(node, "type")) == nullptr) return FALSE; + if ((type = XmlGetAttr(node, "type")) == nullptr) + return false; + if ((!mir_strcmp(type, "get") || !mir_strcmp(type, "set"))) { const char *szAction = XmlGetAttr(child, "action"); const char *idStr = XmlGetAttr(node, "id"); @@ -1768,7 +1770,7 @@ BOOL CJabberProto::OnProcessJingle(const TiXmlElement *node) jingleNode << XCHILD("reason") << XCHILD("unsupported-applications"); m_ThreadInfo->send(iq); - return TRUE; + return true; } else { // if it's something else than 'session-initiate' and noone processed it yet, reply with "unknown-session" @@ -1778,19 +1780,21 @@ BOOL CJabberProto::OnProcessJingle(const TiXmlElement *node) errNode << XCHILDNS("item-not-found", "urn:ietf:params:xml:ns:xmpp-stanzas"); errNode << XCHILDNS("unknown-session", "urn:xmpp:jingle:errors:1"); m_ThreadInfo->send(iq); - return TRUE; + return true; } } } - return FALSE; + return false; } void CJabberProto::OnProcessIq(const TiXmlElement *node) { - if (!node->Name() || mir_strcmp(node->Name(), "iq")) return; + if (!node->Name() || mir_strcmp(node->Name(), "iq")) + return; const char *type; - if ((type = XmlGetAttr(node, "type")) == nullptr) return; + if ((type = XmlGetAttr(node, "type")) == nullptr) + return; int id = JabberGetPacketID(node); @@ -1905,12 +1909,12 @@ void CJabberProto::OnProcessRegIq(const TiXmlElement *node, ThreadData *info) else if (id == iqIdRegSetReg) { info->send(""); SendMessage(info->conn.reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)TranslateT("Registration successful")); - info->reg_done = TRUE; + info->reg_done = true; } } else if (!mir_strcmp(type, "error")) { SendMessage(info->conn.reg_hwndDlg, WM_JABBER_REGDLG_UPDATE, 100, (LPARAM)JabberErrorMsg(node).c_str()); - info->reg_done = TRUE; + info->reg_done = true; info->send(""); } } diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index 0a0319f9da..c43d4a1539 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -282,7 +282,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR dat = new PhotoDlgProcData; dat->ppro = (CJabberProto*)lParam; dat->hBitmap = nullptr; - dat->ppro->m_bPhotoChanged = FALSE; + dat->ppro->m_bPhotoChanged = false; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); dat->ppro->WindowSubscribe(hwndDlg); } @@ -315,7 +315,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } } - dat->ppro->m_bPhotoChanged = FALSE; + dat->ppro->m_bPhotoChanged = false; InvalidateRect(hwndDlg, nullptr, TRUE); UpdateWindow(hwndDlg); break; @@ -332,7 +332,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR dat->hBitmap = nullptr; DeleteFile(dat->ppro->m_szPhotoFileName); dat->ppro->m_szPhotoFileName[0] = '\0'; - dat->ppro->m_bPhotoChanged = TRUE; + dat->ppro->m_bPhotoChanged = true; EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), FALSE); InvalidateRect(hwndDlg, nullptr, TRUE); UpdateWindow(hwndDlg); @@ -377,7 +377,7 @@ static INT_PTR CALLBACK PhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR dat->hBitmap = hNewBitmap; mir_wstrcpy(dat->ppro->m_szPhotoFileName, szTempFileName); - dat->ppro->m_bPhotoChanged = TRUE; + dat->ppro->m_bPhotoChanged = true; EnableWindow(GetDlgItem(hwndDlg, IDC_DELETE), TRUE); InvalidateRect(hwndDlg, nullptr, TRUE); UpdateWindow(hwndDlg); @@ -1181,7 +1181,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t *szPhotoFileName) void CJabberProto::OnUserInfoInit_VCard(WPARAM wParam, LPARAM) { m_vCardUpdates = 0; - m_bPhotoChanged = FALSE; + m_bPhotoChanged = false; m_szPhotoFileName[0] = 0; OPTIONSDIALOGPAGE odp = {}; diff --git a/protocols/JabberG/src/jabber_ws.cpp b/protocols/JabberG/src/jabber_ws.cpp index f1f5a517e6..3337490629 100644 --- a/protocols/JabberG/src/jabber_ws.cpp +++ b/protocols/JabberG/src/jabber_ws.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -BOOL CJabberProto::WsInit(void) +bool CJabberProto::WsInit(void) { m_lastTicks = ::GetTickCount(); diff --git a/protocols/JabberG/src/jabber_xstatus.cpp b/protocols/JabberG/src/jabber_xstatus.cpp index d3f3d7a0f4..a9955b335d 100644 --- a/protocols/JabberG/src/jabber_xstatus.cpp +++ b/protocols/JabberG/src/jabber_xstatus.cpp @@ -1149,10 +1149,10 @@ INT_PTR __cdecl CJabberProto::OnGetXStatusIcon(WPARAM wParam, LPARAM lParam) ///////////////////////////////////////////////////////////////////////////////////////// // SendPepMood - sends mood -BOOL CJabberProto::SendPepTune(wchar_t* szArtist, wchar_t* szLength, wchar_t* szSource, wchar_t* szTitle, wchar_t* szTrack, wchar_t* szUri) +bool CJabberProto::SendPepTune(wchar_t* szArtist, wchar_t* szLength, wchar_t* szSource, wchar_t* szTitle, wchar_t* szTrack, wchar_t* szUri) { if (!m_bJabberOnline || !m_bPepSupported) - return FALSE; + return false; XmlNodeIq iq("set", SerialNext()); TiXmlElement *tuneNode = iq << XCHILDNS("pubsub", JABBER_FEAT_PUBSUB) @@ -1168,8 +1168,7 @@ BOOL CJabberProto::SendPepTune(wchar_t* szArtist, wchar_t* szLength, wchar_t* sz if (szUri) tuneNode << XCHILD("uri", T2Utf(szUri)); } m_ThreadInfo->send(iq); - - return TRUE; + return true; } void CJabberProto::SetContactTune(MCONTACT hContact, const wchar_t *szArtist, const wchar_t *szLength, const wchar_t *szSource, const wchar_t *szTitle, const wchar_t *szTrack) diff --git a/protocols/JabberG/src/jabber_zstream.cpp b/protocols/JabberG/src/jabber_zstream.cpp index 33cb38f396..afda0c70ff 100644 --- a/protocols/JabberG/src/jabber_zstream.cpp +++ b/protocols/JabberG/src/jabber_zstream.cpp @@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -BOOL ThreadData::zlibInit(void) +bool ThreadData::zlibInit(void) { proto->debugLogA("Zlib init..."); zStreamIn.zalloc = Z_NULL; @@ -39,11 +39,11 @@ BOOL ThreadData::zlibInit(void) zStreamOut.zfree = Z_NULL; zStreamOut.opaque = Z_NULL; - if (deflateInit(&zStreamOut, Z_BEST_COMPRESSION) != Z_OK) return FALSE; - if (inflateInit(&zStreamIn) != Z_OK) return FALSE; + if (deflateInit(&zStreamOut, Z_BEST_COMPRESSION) != Z_OK) return false; + if (inflateInit(&zStreamIn) != Z_OK) return false; zRecvReady = true; - return TRUE; + return true; } void ThreadData::zlibUninit(void) diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index befa89bac6..51f577b5b9 100755 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -363,7 +363,7 @@ struct ThreadData void xmpp_client_query(void); - BOOL zlibInit(void); + bool zlibInit(void); void zlibUninit(); int zlibSend(char* data, int datalen); int zlibRecv(char* data, long datalen); -- cgit v1.2.3