diff options
author | ElzorFox <elzorfox@ya.ru> | 2024-04-08 17:06:17 +0500 |
---|---|---|
committer | ElzorFox <elzorfox@ya.ru> | 2024-04-08 17:06:17 +0500 |
commit | 89424edebf983affdd417cb5767cf0e2a0171699 (patch) | |
tree | 8e54c49ba46e66aa149cb13cc3aacfa0db99a114 /protocols | |
parent | b538ebf8e9609a4e6413d48049db1360943c5c41 (diff) |
VKontakte:
fix dowload img to ты log
add minimal priority for downloads files
fix old typo
version bump
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_files.cpp | 55 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_struct.h | 2 |
5 files changed, 32 insertions, 31 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index faa534d1ef..a032ba71a1 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -451,7 +451,7 @@ bool CVkProto::CheckJsonResult(AsyncHttpRequest *pReq, const JSONNode &jnNode) case VKERR_YOU_ON_BLACKLIST:
case VKERR_USER_ON_BLACKLIST:
break;
- // See also CVkProto::SendFileFiled
+ // See also CVkProto::SendFileFailed
}
return (iErrorCode == 0);
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index e7ce682c2a..6d40a99daf 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 16
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp index 301507ec2e..441d5ecf90 100644 --- a/protocols/VKontakte/src/vk_files.cpp +++ b/protocols/VKontakte/src/vk_files.cpp @@ -52,6 +52,7 @@ CMStringW CVkProto::GetVkFileItem(CMStringW& _wszUrl, MCONTACT hContact, VKMessa pReq->m_pFunc = &CVkProto::OnGetVkFileItem;
pReq->requestType = REQUEST_GET;
pReq->m_bApiReq = false;
+ pReq->m_priority = AsyncHttpRequest::rpLowLow;
Push(pReq);
}
else {
@@ -104,7 +105,7 @@ void CVkProto::OnGetVkFileItem(MHttpResponse* reply, AsyncHttpRequest* pReq) if (out) {
fwrite(reply->body, 1, reply->body.GetLength(), out);
fclose(out);
- debugLogW(L"CVkProto::OnGetVkFileItem file %s saved", param->wszFileName);
+ debugLogW(L"CVkProto::OnGetVkFileItem file %s saved %d %d", param->wszFileName, param->hContact, param->iMsgID);
MessageWindowData mwd = {};
if (!Srmm_GetWindowData(param->hContact, mwd) && mwd.uState) {
@@ -113,7 +114,7 @@ void CVkProto::OnGetVkFileItem(MHttpResponse* reply, AsyncHttpRequest* pReq) MEVENT hDbEvent = db_event_getById(m_szModuleName, szMid);
DBEVENTINFO dbei = {};
- if (db_event_get(hDbEvent, &dbei)) {
+ if (!db_event_get(hDbEvent, &dbei)) {
int i = db_event_edit(hDbEvent, &dbei, true);
debugLogW(L"CVkProto::OnGetVkFileItem file %s even edit %d", param->wszFileName, i);
}
@@ -141,7 +142,7 @@ HANDLE CVkProto::SendFile(MCONTACT hContact, const wchar_t *desc, wchar_t **file ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, (HANDLE)fup);
if (!fup->IsAccess()) {
- SendFileFiled(fup, VKERR_FILE_NOT_EXIST);
+ SendFileFailed(fup, VKERR_FILE_NOT_EXIST);
return (HANDLE)nullptr;
}
@@ -161,7 +162,7 @@ HANDLE CVkProto::SendFile(MCONTACT hContact, const wchar_t *desc, wchar_t **file pReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/docs.getUploadServer.json", true, &CVkProto::OnReciveUploadServer);
break;
default:
- SendFileFiled(fup, VKERR_FTYPE_NOT_SUPPORTED);
+ SendFileFailed(fup, VKERR_FTYPE_NOT_SUPPORTED);
return (HANDLE)nullptr;
}
pReq->pUserInfo = fup;
@@ -173,7 +174,7 @@ HANDLE CVkProto::SendFile(MCONTACT hContact, const wchar_t *desc, wchar_t **file return (HANDLE)fup;
}
-void CVkProto::SendFileFiled(CVkFileUploadParam *fup, int ErrorCode)
+void CVkProto::SendFileFailed(CVkFileUploadParam *fup, int ErrorCode)
{
CMStringW wszError;
switch (ErrorCode) {
@@ -242,13 +243,13 @@ void CVkProto::OnReciveUploadServer(MHttpResponse *reply, AsyncHttpRequest *pReq {
CVkFileUploadParam *fup = (CVkFileUploadParam *)pReq->pUserInfo;
if (!IsOnline()) {
- SendFileFiled(fup, VKERR_OFFLINE);
+ SendFileFailed(fup, VKERR_OFFLINE);
return;
}
debugLogA("CVkProto::OnReciveUploadServer %d", reply->resultCode);
if (reply->resultCode != 200) {
- SendFileFiled(fup, VKERR_INVALID_SERVER);
+ SendFileFailed(fup, VKERR_INVALID_SERVER);
return;
}
@@ -256,19 +257,19 @@ void CVkProto::OnReciveUploadServer(MHttpResponse *reply, AsyncHttpRequest *pReq const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot);
if (!jnResponse || pReq->m_iErrorCode) {
if (!pReq->bNeedsRestart)
- SendFileFiled(fup, pReq->m_iErrorCode);
+ SendFileFailed(fup, pReq->m_iErrorCode);
return;
}
CMStringA uri(jnResponse["upload_url"].as_mstring());
if (uri.IsEmpty()) {
- SendFileFiled(fup, VKERR_INVALID_URL);
+ SendFileFailed(fup, VKERR_INVALID_URL);
return;
}
FILE *pFile = _wfopen(fup->wszFileName, L"rb");
if (pFile == nullptr) {
- SendFileFiled(fup, VKERR_ERR_OPEN_FILE);
+ SendFileFailed(fup, VKERR_ERR_OPEN_FILE);
return;
}
@@ -276,7 +277,7 @@ void CVkProto::OnReciveUploadServer(MHttpResponse *reply, AsyncHttpRequest *pReq long iFileLen = ftell(pFile); //FileSize
if (iFileLen < 1) {
fclose(pFile);
- SendFileFiled(fup, VKERR_ERR_READ_FILE);
+ SendFileFailed(fup, VKERR_ERR_READ_FILE);
return;
}
fseek(pFile, 0, SEEK_SET);
@@ -321,7 +322,7 @@ void CVkProto::OnReciveUploadServer(MHttpResponse *reply, AsyncHttpRequest *pReq fclose(pFile);
if (lBytes != iFileLen) {
- SendFileFiled(fup, VKERR_ERR_READ_FILE);
+ SendFileFailed(fup, VKERR_ERR_READ_FILE);
delete pUploadReq;
return;
}
@@ -338,13 +339,13 @@ void CVkProto::OnReciveUpload(MHttpResponse *reply, AsyncHttpRequest *pReq) {
CVkFileUploadParam *fup = (CVkFileUploadParam *)pReq->pUserInfo;
if (!IsOnline()) {
- SendFileFiled(fup, VKERR_OFFLINE);
+ SendFileFailed(fup, VKERR_OFFLINE);
return;
}
debugLogA("CVkProto::OnReciveUploadServer %d", reply->resultCode);
if (reply->resultCode != 200) {
- SendFileFiled(fup, VKERR_FILE_NOT_UPLOADED);
+ SendFileFailed(fup, VKERR_FILE_NOT_UPLOADED);
return;
}
@@ -352,12 +353,12 @@ void CVkProto::OnReciveUpload(MHttpResponse *reply, AsyncHttpRequest *pReq) CheckJsonResponse(pReq, reply, jnRoot);
if (pReq->m_iErrorCode) {
- SendFileFiled(fup, pReq->m_iErrorCode);
+ SendFileFailed(fup, pReq->m_iErrorCode);
return;
}
if ((!jnRoot["server"] || !jnRoot["hash"]) && !jnRoot["file"]) {
- SendFileFiled(fup, VKERR_INVALID_PARAMETERS);
+ SendFileFailed(fup, VKERR_INVALID_PARAMETERS);
return;
}
@@ -374,7 +375,7 @@ void CVkProto::OnReciveUpload(MHttpResponse *reply, AsyncHttpRequest *pReq) case CVkFileUploadParam::typeImg:
upload = jnRoot["photo"].as_mstring();
if (upload == L"[]") {
- SendFileFiled(fup, VKERR_INVALID_PARAMETERS);
+ SendFileFailed(fup, VKERR_INVALID_PARAMETERS);
return;
}
pUploadReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/photos.saveMessagesPhoto.json", true, &CVkProto::OnReciveUploadFile);
@@ -383,7 +384,7 @@ void CVkProto::OnReciveUpload(MHttpResponse *reply, AsyncHttpRequest *pReq) case CVkFileUploadParam::typeAudio:
upload = jnRoot["audio"].as_mstring();
if (upload == L"[]") {
- SendFileFiled(fup, VKERR_INVALID_PARAMETERS);
+ SendFileFailed(fup, VKERR_INVALID_PARAMETERS);
return;
}
pUploadReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/audio.save.json", true, &CVkProto::OnReciveUploadFile);
@@ -393,7 +394,7 @@ void CVkProto::OnReciveUpload(MHttpResponse *reply, AsyncHttpRequest *pReq) case CVkFileUploadParam::typeAudioMsg:
upload = jnRoot["file"].as_mstring();
if (upload.IsEmpty()) {
- SendFileFiled(fup, VKERR_INVALID_PARAMETERS);
+ SendFileFailed(fup, VKERR_INVALID_PARAMETERS);
return;
}
pUploadReq = new AsyncHttpRequest(this, REQUEST_GET, "/method/docs.save.json", true, &CVkProto::OnReciveUploadFile);
@@ -404,7 +405,7 @@ void CVkProto::OnReciveUpload(MHttpResponse *reply, AsyncHttpRequest *pReq) << INT_PARAM("return_tags", 0);
break;
default:
- SendFileFiled(fup, VKERR_FTYPE_NOT_SUPPORTED);
+ SendFileFailed(fup, VKERR_FTYPE_NOT_SUPPORTED);
return;
}
@@ -416,13 +417,13 @@ void CVkProto::OnReciveUploadFile(MHttpResponse *reply, AsyncHttpRequest *pReq) {
CVkFileUploadParam *fup = (CVkFileUploadParam *)pReq->pUserInfo;
if (!IsOnline()) {
- SendFileFiled(fup, VKERR_OFFLINE);
+ SendFileFailed(fup, VKERR_OFFLINE);
return;
}
debugLogA("CVkProto::OnReciveUploadFile %d", reply->resultCode);
if (reply->resultCode != 200) {
- SendFileFiled(fup, VKERR_FILE_NOT_UPLOADED);
+ SendFileFailed(fup, VKERR_FILE_NOT_UPLOADED);
return;
}
@@ -430,7 +431,7 @@ void CVkProto::OnReciveUploadFile(MHttpResponse *reply, AsyncHttpRequest *pReq) const JSONNode &jnResponse = CheckJsonResponse(pReq, reply, jnRoot);
if (!jnResponse || pReq->m_iErrorCode) {
if (!pReq->bNeedsRestart)
- SendFileFiled(fup, pReq->m_iErrorCode);
+ SendFileFailed(fup, pReq->m_iErrorCode);
return;
}
@@ -448,7 +449,7 @@ void CVkProto::OnReciveUploadFile(MHttpResponse *reply, AsyncHttpRequest *pReq) }
if ((id == 0) || (iOwnerId == 0)) {
- SendFileFiled(fup, VKERR_INVALID_PARAMETERS);
+ SendFileFailed(fup, VKERR_INVALID_PARAMETERS);
return;
}
@@ -466,7 +467,7 @@ void CVkProto::OnReciveUploadFile(MHttpResponse *reply, AsyncHttpRequest *pReq) Attachment.AppendFormat(L"doc%d_%d", iOwnerId, id);
break;
default:
- SendFileFiled(fup, VKERR_FTYPE_NOT_SUPPORTED);
+ SendFileFailed(fup, VKERR_FTYPE_NOT_SUPPORTED);
return;
}
@@ -475,7 +476,7 @@ void CVkProto::OnReciveUploadFile(MHttpResponse *reply, AsyncHttpRequest *pReq) if (isChatRoom(fup->hContact)) {
CVkChatInfo *cc = GetChatByContact(fup->hContact);
if (cc == nullptr) {
- SendFileFiled(fup, VKERR_INVALID_USER);
+ SendFileFailed(fup, VKERR_INVALID_USER);
return;
}
@@ -487,7 +488,7 @@ void CVkProto::OnReciveUploadFile(MHttpResponse *reply, AsyncHttpRequest *pReq) else {
VKUserID_t iUserId = ReadVKUserID(fup->hContact);
if (iUserId == VK_INVALID_USER || iUserId == VK_FEED_USER) {
- SendFileFiled(fup, VKERR_INVALID_USER);
+ SendFileFailed(fup, VKERR_INVALID_USER);
return;
}
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 5ef9bba4d4..9cc682425d 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -294,7 +294,7 @@ private: //==== Files Upload ==================================================================
- void SendFileFiled(CVkFileUploadParam *fup, int ErrorCode);
+ void SendFileFailed(CVkFileUploadParam *fup, int ErrorCode);
void OnReciveUploadServer(MHttpResponse*, AsyncHttpRequest*);
void OnReciveUpload(MHttpResponse*, AsyncHttpRequest*);
void OnReciveUploadFile(MHttpResponse*, AsyncHttpRequest*);
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index dfcfd994d6..03045fff21 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. struct AsyncHttpRequest : public MTHttpRequest<CVkProto>
{
- enum RequestPriority { rpLow, rpMedium, rpHigh };
+ enum RequestPriority { rpLowLow, rpLow, rpMedium, rpHigh };
AsyncHttpRequest();
AsyncHttpRequest(CVkProto*, int iRequestType, LPCSTR szUrl, bool bSecure, MTHttpRequestHandler pFunc, RequestPriority rpPriority = rpMedium);
|