diff options
author | George Hazan <ghazan@miranda.im> | 2023-03-02 13:22:29 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-03-02 13:22:29 +0300 |
commit | e6715bd0de37c9fa94dffccebe08a35bda3aaacc (patch) | |
tree | 27c48dd7124516f0feddeeed087f74aad54f8ef4 /protocols/JabberG/src | |
parent | 9a2a681890306f05bc443d71f6e70725b099a7cc (diff) |
code cleaning
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r-- | protocols/JabberG/src/jabber_bookmarks.cpp | 8 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_chat.cpp | 7 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_disco.cpp | 6 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_ft.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_groupchat.cpp | 6 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iqid.cpp | 6 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_opt.cpp | 5 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_privacy.cpp | 22 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_thread.cpp | 7 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_util.cpp | 4 |
11 files changed, 30 insertions, 45 deletions
diff --git a/protocols/JabberG/src/jabber_bookmarks.cpp b/protocols/JabberG/src/jabber_bookmarks.cpp index 48cc195e17..396861f691 100644 --- a/protocols/JabberG/src/jabber_bookmarks.cpp +++ b/protocols/JabberG/src/jabber_bookmarks.cpp @@ -324,10 +324,10 @@ public: {
m_lvBookmarks.DeleteAllItems();
- JABBER_LIST_ITEM *item = nullptr;
+ bool bEnable = false;
LISTFOREACH(i, m_proto, LIST_BOOKMARK)
{
- if (item = m_proto->ListGetItemPtrFromIndex(i)) {
+ if (auto *item = m_proto->ListGetItemPtrFromIndex(i)) {
int itemType = mir_strcmpi(item->type, "conference") ? 1 : 0;
m_proto->debugLogA("BOOKMARK #%d: %d %s", i, itemType, item->jid);
@@ -335,10 +335,12 @@ public: m_lvBookmarks.SetItem(iItem, 1, Utf2T(item->jid));
if (itemType == 0)
m_lvBookmarks.SetItem(iItem, 2, Utf2T(item->nick));
+
+ bEnable = true;
}
}
- if (item) {
+ if (bEnable) {
m_btnEdit.Enable();
m_btnRemove.Enable();
}
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 6326adf716..77506a14b7 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -1104,17 +1104,16 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* char *szInviteTo = nullptr;
int idx = gch->dwData - IDM_LINK0;
LISTFOREACH(i, ppro, LIST_CHATROOM)
- {
- if (JABBER_LIST_ITEM *pItem = ppro->ListGetItemPtrFromIndex(i)) {
+ if (auto *pItem = ppro->ListGetItemPtrFromIndex(i)) {
if (!pItem->si) continue;
if (!idx--) {
szInviteTo = pItem->jid;
break;
}
}
- }
- if (!szInviteTo) break;
+ if (!szInviteTo)
+ break;
szTitle.Format(TranslateT("Invite %s to %s"), Utf2T(him->m_szResourceName).get(), Utf2T(szInviteTo).get());
if (!ppro->EnterString(szBuffer, szTitle, ESF_MULTILINE))
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp index 50081898fd..3b1e7ed82c 100644 --- a/protocols/JabberG/src/jabber_disco.cpp +++ b/protocols/JabberG/src/jabber_disco.cpp @@ -315,10 +315,8 @@ void CJabberProto::PerformBrowse(HWND hwndDlg) mir_cslockfull lck(m_SDManager.cs());
m_SDManager.RemoveAll();
if (!mir_wstrcmp(szJid, _T(SD_FAKEJID_MYAGENTS))) {
- JABBER_LIST_ITEM *item = nullptr;
- LISTFOREACH(i, this, LIST_ROSTER)
- {
- if ((item = ListGetItemPtrFromIndex(i)) != nullptr) {
+ LISTFOREACH(i, this, LIST_ROSTER) {
+ if (auto *item = ListGetItemPtrFromIndex(i)) {
if (strchr(item->jid, '@') == nullptr && strchr(item->jid, '/') == nullptr && item->subscription != SUB_NONE) {
MCONTACT hContact = HContactFromJID(item->jid);
if (hContact != 0)
diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index e566695947..5adc5992a6 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -40,7 +40,7 @@ void CJabberProto::FtCancel(filetransfer *ft) // For file receiving session that is still in si negotiation phase
LISTFOREACH(i, this, LIST_FTRECV)
{
- JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
+ auto *item = ListGetItemPtrFromIndex(i);
if (item->ft == ft) {
debugLogA("Canceling file receiving session while in si negotiation");
ListRemoveByIndex(i);
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 96e556853a..626add3738 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -632,12 +632,10 @@ public: HMENU hMenu = CreatePopupMenu();
LISTFOREACH(i, m_proto, LIST_BOOKMARK)
- {
- JABBER_LIST_ITEM *item = nullptr;
- if (item = m_proto->ListGetItemPtrFromIndex(i))
+ if (auto *item = m_proto->ListGetItemPtrFromIndex(i))
if (!mir_strcmp(item->type, "conference"))
AppendMenu(hMenu, MF_STRING, (UINT_PTR)item, item->name);
- }
+
AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr);
AppendMenu(hMenu, MF_STRING, (UINT_PTR)-1, TranslateT("Bookmarks..."));
AppendMenu(hMenu, MF_STRING, (UINT_PTR)0, TranslateT("Cancel"));
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 305b9e8ff6..3cd1fb27c1 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -220,7 +220,7 @@ void CJabberProto::OnProcessLoginRq(ThreadData *info, uint32_t rq) LIST<JABBER_LIST_ITEM> ll(10);
LISTFOREACH(i, this, LIST_BOOKMARK)
{
- JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
+ auto *item = ListGetItemPtrFromIndex(i);
debugLogA("BOOKMARK #%d: %s %s", i, item->type, item->jid);
if (item != nullptr && !mir_strcmp(item->type, "conference") && item->bAutoJoin)
@@ -529,7 +529,7 @@ void CJabberProto::OnIqResultGetRoster(const TiXmlElement *iqNode, CJabberIqInfo if (m_bRosterSync) {
LISTFOREACH(i, this, LIST_ROSTER)
{
- JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
+ auto *item = ListGetItemPtrFromIndex(i);
if (item && item->hContact && !item->bRealContact) {
debugLogA("Syncing roster: preparing to delete %s (hContact=0x%x)", item->jid, item->hContact);
db_delete_contact(item->hContact, true);
@@ -1465,7 +1465,7 @@ void CJabberProto::SetBookmarkRequest(XmlNodeIq &iq) LISTFOREACH(i, this, LIST_BOOKMARK)
{
- JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
+ auto *item = ListGetItemPtrFromIndex(i);
if (item == nullptr || item->jid == nullptr)
continue;
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index 786d83599b..03fce21924 100644 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -743,9 +743,7 @@ public: {
BOOL bChecked = m_proto->m_bShowTransport;
LISTFOREACH(index, m_proto, LIST_ROSTER)
- {
- JABBER_LIST_ITEM *item = m_proto->ListGetItemPtrFromIndex(index);
- if (item != nullptr) {
+ if (auto *item = m_proto->ListGetItemPtrFromIndex(index)) {
if (strchr(item->jid, '@') == nullptr) {
MCONTACT hContact = m_proto->HContactFromJID(item->jid);
if (hContact != 0) {
@@ -759,7 +757,6 @@ public: }
}
}
- }
if (m_proto->m_bUseOMEMO)
m_proto->m_omemo.init();
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp index b1087fde09..a7352035ab 100644 --- a/protocols/JabberG/src/jabber_privacy.cpp +++ b/protocols/JabberG/src/jabber_privacy.cpp @@ -429,22 +429,18 @@ public: cmbValue.Hide();
cmbValues.ResetContent();
- {
- for (auto &hContact : m_proto->AccContacts()) {
- ptrW jid(m_proto->getWStringA(hContact, "jid"));
- if (jid != nullptr)
- cmbValues.AddString(jid);
- }
- // append known chatroom jids from bookmarks
- LISTFOREACH(i, m_proto, LIST_BOOKMARK)
- {
- JABBER_LIST_ITEM *item = nullptr;
- if (item = m_proto->ListGetItemPtrFromIndex(i))
- cmbValues.AddString(Utf2T(item->jid));
- }
+ for (auto &hContact : m_proto->AccContacts()) {
+ ptrW jid(m_proto->getWStringA(hContact, "jid"));
+ if (jid != nullptr)
+ cmbValues.AddString(jid);
}
+ // append known chatroom jids from bookmarks
+ LISTFOREACH(i, m_proto, LIST_BOOKMARK)
+ if (auto *item = m_proto->ListGetItemPtrFromIndex(i))
+ cmbValues.AddString(Utf2T(item->jid));
+
// FIXME: ugly code :)
if (m_pRule->GetValue()) {
Utf2T pwszValue(m_pRule->GetValue());
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index c1c50ff6da..2684ee5f9a 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -1066,8 +1066,6 @@ int CJabberProto::SetStatus(int iNewStatus) }
m_StrmMgmt.ResetState();
m_iDesiredStatus = ID_STATUS_OFFLINE;
- //m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
- //ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
}
else if (!m_ThreadInfo && !IsStatusConnecting(m_iStatus)) {
m_iStatus = ID_STATUS_CONNECTING;
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 908628ae77..eb8d34d2c9 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -153,12 +153,9 @@ void CJabberProto::CheckKeepAlive() // unfortunately there's no other way to detect if that message came online or from history
time_t now = time(0);
LISTFOREACH(i, this, LIST_CHATROOM)
- {
if (auto *item = ListGetItemPtrFromIndex(i))
if (!item->bChatLogging && now - item->iChatInitTime > 2)
item->bChatLogging = true;
- }
-
// check expired iq requests
m_iqManager.CheckExpired();
@@ -269,7 +266,7 @@ void CJabberProto::ServerThread(JABBER_CONN_DATA *pParam) // quit all chatrooms (will send quit message)
LISTFOREACH(i, this, LIST_CHATROOM)
- if (JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i))
+ if (auto *item = ListGetItemPtrFromIndex(i))
GcQuit(item, 0, nullptr);
ListRemoveList(LIST_CHATROOM);
@@ -1958,7 +1955,7 @@ void CJabberProto::OnProcessIq(const TiXmlElement *node) // Check for file transfer deny by comparing idStr with ft->iqId
LISTFOREACH(i, this, LIST_FILE)
{
- JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
+ auto *item = ListGetItemPtrFromIndex(i);
if (item->ft != nullptr && item->ft->state == FT_CONNECTING && !mir_strcmp(tszBuf, item->ft->szId)) {
debugLogA("Denying file sending request");
item->ft->state = FT_DENIED;
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 2782aef450..30b0bab275 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -328,7 +328,7 @@ void CJabberProto::SendVisibleInvisiblePresence(bool invisible) LISTFOREACH(i, this, LIST_ROSTER)
{
- JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
+ auto *item = ListGetItemPtrFromIndex(i);
if (item == nullptr)
continue;
@@ -536,7 +536,7 @@ void CJabberProto::SendPresence(int status, bool bSendToAll) if (bSendToAll) {
LISTFOREACH(i, this, LIST_CHATROOM)
{
- JABBER_LIST_ITEM *item = ListGetItemPtrFromIndex(i);
+ auto *item = ListGetItemPtrFromIndex(i);
if (item != nullptr && item->nick != nullptr)
SendPresenceTo(status == ID_STATUS_INVISIBLE ? ID_STATUS_ONLINE : status, MakeJid(item->jid, item->nick));
}
|