diff options
author | George Hazan <george.hazan@gmail.com> | 2023-09-27 10:31:03 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-09-27 10:31:03 +0300 |
commit | 82d166baff3cf2926cf8e95c8b41a43cae612c0a (patch) | |
tree | 7565266abf97d15b9daebb3bcf204dc01a57d57c | |
parent | 5bf6e61b1d63c64109b495b30d3609fe0f057884 (diff) |
code cleaning
-rw-r--r-- | protocols/JabberG/src/jabber_proto.cpp | 18 | ||||
-rw-r--r-- | src/mir_app/src/db_events.cpp | 14 |
2 files changed, 11 insertions, 21 deletions
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index c0b8d4b93c..993e0faf2f 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -441,23 +441,13 @@ int CJabberProto::AuthDeny(MEVENT hDbEvent, const wchar_t*) debugLogA("Entering AuthDeny");
DB::EventInfo dbei(hDbEvent);
- if (!dbei)
- return 1;
-
- if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
+ if (!dbei || dbei.eventType != EVENTTYPE_AUTHREQUEST || mir_strcmp(dbei.szModule, m_szModuleName))
return 1;
- if (mir_strcmp(dbei.szModule, m_szModuleName))
- return 1;
-
- char *nick = (char*)(dbei.pBlob + sizeof(uint32_t) * 2);
- char *firstName = nick + mir_strlen(nick) + 1;
- char *lastName = firstName + mir_strlen(firstName) + 1;
- char *jid = lastName + mir_strlen(lastName) + 1;
-
- debugLogA("Send 'authorization denied' to %s", jid);
+ DB::AUTH_BLOB auth(dbei.pBlob);
+ debugLogA("Send 'authorization denied' to %s", auth.get_email());
- ptrA newJid(dbei.flags & DBEF_UTF ? mir_strdup(jid) : mir_utf8encode(jid));
+ ptrA newJid(dbei.flags & DBEF_UTF ? mir_strdup(auth.get_email()) : mir_utf8encode(auth.get_email()));
m_ThreadInfo->send(XmlNode("presence") << XATTR("to", newJid) << XATTR("type", "unsubscribed"));
return 0;
}
diff --git a/src/mir_app/src/db_events.cpp b/src/mir_app/src/db_events.cpp index b31742623c..dd8f7ed5b9 100644 --- a/src/mir_app/src/db_events.cpp +++ b/src/mir_app/src/db_events.cpp @@ -369,17 +369,17 @@ DB::AUTH_BLOB::AUTH_BLOB(MCONTACT hContact, LPCSTR nick, LPCSTR fname, LPCSTR ln DB::AUTH_BLOB::AUTH_BLOB(uint8_t *blob)
{
- uint8_t *pCurBlob = blob;
+ char *pCurBlob = (char *)blob;
m_dwUin = *(uint32_t*)pCurBlob;
pCurBlob += sizeof(uint32_t);
m_hContact = *(uint32_t*)pCurBlob;
pCurBlob += sizeof(uint32_t);
- m_szNick = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
- m_szFirstName = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
- m_szLastName = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
- m_szEmail = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
- m_szReason = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
- m_size = uint32_t(pCurBlob - blob);
+ m_szNick = mir_strdup(pCurBlob); pCurBlob += mir_strlen(pCurBlob) + 1;
+ m_szFirstName = mir_strdup(pCurBlob); pCurBlob += mir_strlen(pCurBlob) + 1;
+ m_szLastName = mir_strdup(pCurBlob); pCurBlob += mir_strlen(pCurBlob) + 1;
+ m_szEmail = mir_strdup(pCurBlob); pCurBlob += mir_strlen(pCurBlob) + 1;
+ m_szReason = mir_strdup(pCurBlob); pCurBlob += mir_strlen(pCurBlob) + 1;
+ m_size = uint32_t(pCurBlob - (char *)blob);
}
DB::AUTH_BLOB::~AUTH_BLOB()
|