summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-11-16 15:54:52 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-11-16 15:54:52 +0300
commitea325162c0e04fbb95d101a744ac605bac47492d (patch)
tree748adccec45d4e5ac9e433d837f342ecc1324ac2 /protocols
parent8208d3f157e8133ca958c4ba47ec9caea8a162d5 (diff)
merge
Diffstat (limited to 'protocols')
-rw-r--r--protocols/ICQ-WIM/src/proto.cpp5
-rw-r--r--protocols/ICQ-WIM/src/proto.h35
-rw-r--r--protocols/ICQ-WIM/src/server.cpp15
3 files changed, 32 insertions, 23 deletions
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp
index 63c7c7418c..e3181190e4 100644
--- a/protocols/ICQ-WIM/src/proto.cpp
+++ b/protocols/ICQ-WIM/src/proto.cpp
@@ -177,10 +177,13 @@ void CIcqProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob, void *ft)
}
}
-void CIcqProto::OnSendOfflineFile(DB::EventInfo &, DB::FILE_BLOB &blob, void *hTransfer)
+void CIcqProto::OnSendOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob, void *hTransfer)
{
auto *ft = (IcqFileTransfer *)hTransfer;
+ if (!ft->m_szMsgId.IsEmpty())
+ dbei.szId = ft->m_szMsgId;
+
auto *p = wcsrchr(ft->m_wszFileName, '\\');
if (p == nullptr)
p = ft->m_wszFileName;
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h
index b3826be1d4..05e8fca0f5 100644
--- a/protocols/ICQ-WIM/src/proto.h
+++ b/protocols/ICQ-WIM/src/proto.h
@@ -121,22 +121,6 @@ struct IcqUser : public MZeroedObject
time_t m_timer1, m_timer2;
};
-struct IcqOwnMessage
-{
- IcqOwnMessage(MCONTACT _hContact, int _msgid, const char *guid, const char *pszText) :
- m_msgid(_msgid),
- m_hContact(_hContact),
- m_szText(mir_strdup(pszText))
- {
- strncpy_s(m_guid, guid, _TRUNCATE);
- }
-
- MCONTACT m_hContact;
- int m_msgid;
- char m_guid[50];
- ptrA m_szText;
-};
-
struct IcqConn
{
HNETLIBCONN s;
@@ -147,7 +131,7 @@ struct IcqFileTransfer : public MZeroedObject
{
bool m_bCanceled = false, m_bStarted = false;
int m_fileId = -1;
- CMStringA m_szHost;
+ CMStringA m_szHost, m_szMsgId;
CMStringW m_wszFileName, m_wszDescr;
const wchar_t *m_wszShortName;
PROTOFILETRANSFERSTATUS pfts;
@@ -160,6 +144,23 @@ struct IcqFileTransfer : public MZeroedObject
void FillHeaders(AsyncHttpRequest *pReq);
};
+struct IcqOwnMessage
+{
+ IcqOwnMessage(MCONTACT _hContact, int _msgid, const char *guid, const char *pszText) :
+ m_msgid(_msgid),
+ m_hContact(_hContact),
+ m_szText(mir_strdup(pszText))
+ {
+ strncpy_s(m_guid, guid, _TRUNCATE);
+ }
+
+ MCONTACT m_hContact;
+ int m_msgid;
+ char m_guid[50];
+ ptrA m_szText;
+ IcqFileTransfer *pTransfer = nullptr;
+};
+
class CIcqProto : public PROTO<CIcqProto>
{
friend struct AsyncRapiRequest;
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index 29f3e8ed86..d85bcc3365 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -75,7 +75,14 @@ MCONTACT CIcqProto::CheckOwnMessage(const CMStringA &reqId, const CMStringA &msg
MCONTACT ret = pOwn->m_hContact;
- if (!Contact::IsGroupChat(ret))
+ if (pOwn->pTransfer) {
+ if (bRemove) {
+ pOwn->pTransfer->m_szMsgId = msgId;
+ ProtoBroadcastAck(pOwn->m_hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, pOwn->pTransfer);
+ delete pOwn->pTransfer;
+ }
+ }
+ else if (!Contact::IsGroupChat(ret))
ProtoBroadcastAck(ret, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)pOwn->m_msgid, (LPARAM)msgId.c_str());
else {
T2Utf szOwnId(m_szOwnId);
@@ -965,8 +972,6 @@ LBL_Error:
if (root.error() != 200)
goto LBL_Error;
- ProtoBroadcastAck(pTransfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, pTransfer);
-
const JSONNode &data = root.data();
CMStringW wszUrl(data["static_url"].as_mstring());
@@ -982,6 +987,7 @@ LBL_Error:
auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_POST, "/im/sendIM", &CIcqProto::OnSendMessage);
auto *pOwn = new IcqOwnMessage(pTransfer->pfts.hContact, id, pReq->m_reqId, T2Utf(wszUrl));
+ pOwn->pTransfer = pTransfer;
pReq->pUserInfo = pOwn;
{
mir_cslock lck(m_csOwnIds);
@@ -991,8 +997,6 @@ LBL_Error:
pReq << AIMSID(this) << CHAR_PARAM("a", m_szAToken) << CHAR_PARAM("k", appId()) << CHAR_PARAM("mentions", "") << WCHAR_PARAM("message", wszUrl)
<< CHAR_PARAM("offlineIM", "true") << WCHAR_PARAM("parts", wszParts) << WCHAR_PARAM("t", GetUserId(pTransfer->pfts.hContact)) << INT_PARAM("ts", TS());
Push(pReq);
-
- delete pTransfer;
return;
}
@@ -1228,6 +1232,7 @@ void CIcqProto::OnSendMessage(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
mir_cslock lck(m_csOwnIds);
m_arOwnIds.remove(ownMsg);
+ return;
}
if (g_bMessageState)