summaryrefslogtreecommitdiff
path: root/plugins/CloudFile
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/CloudFile')
-rw-r--r--plugins/CloudFile/src/cloud_service.cpp16
-rw-r--r--plugins/CloudFile/src/cloud_service.h2
-rw-r--r--plugins/CloudFile/src/file_transfer.h4
-rw-r--r--plugins/CloudFile/src/menus.cpp9
-rw-r--r--plugins/CloudFile/src/srmm.cpp9
-rw-r--r--plugins/CloudFile/src/stdafx.h1
6 files changed, 23 insertions, 18 deletions
diff --git a/plugins/CloudFile/src/cloud_service.cpp b/plugins/CloudFile/src/cloud_service.cpp
index bbee441372..f8b8b1e976 100644
--- a/plugins/CloudFile/src/cloud_service.cpp
+++ b/plugins/CloudFile/src/cloud_service.cpp
@@ -46,6 +46,22 @@ CCloudService::CCloudService(HNETLIBUSER hConnection)
{
}
+void CCloudService::OpenUploadDialog(MCONTACT hContact)
+{
+ char *proto = GetContactProto(hContact);
+ if (!mir_strcmpi(proto, META_PROTO))
+ hContact = CallService(MS_MC_GETMOSTONLINECONTACT, hContact);
+
+ auto it = InterceptedContacts.find(hContact);
+ if (it == InterceptedContacts.end())
+ {
+ HWND hwnd = (HWND)CallService(MS_FILE_SENDFILE, hContact, 0);
+ InterceptedContacts[hContact] = hwnd;
+ }
+ else
+ SetActiveWindow(it->second);
+}
+
void CCloudService::SendToContact(MCONTACT hContact, const wchar_t *data)
{
const char *szProto = GetContactProto(hContact);
diff --git a/plugins/CloudFile/src/cloud_service.h b/plugins/CloudFile/src/cloud_service.h
index 705330e386..ed35961cd6 100644
--- a/plugins/CloudFile/src/cloud_service.h
+++ b/plugins/CloudFile/src/cloud_service.h
@@ -30,6 +30,8 @@ public:
virtual void Login() = 0;
virtual void Logout() = 0;
+ void OpenUploadDialog(MCONTACT hContact);
+
virtual UINT Upload(FileTransferParam *ftp) = 0;
void SendToContact(MCONTACT hContact, const wchar_t *data);
diff --git a/plugins/CloudFile/src/file_transfer.h b/plugins/CloudFile/src/file_transfer.h
index 53c9ef0545..e7daa3a2a9 100644
--- a/plugins/CloudFile/src/file_transfer.h
+++ b/plugins/CloudFile/src/file_transfer.h
@@ -193,10 +193,10 @@ public:
{
size_t chunkSize = 1024 * 1024;
if (pfts.currentFileSize < chunkSize)
- chunkSize = min(pfts.currentFileSize, chunkSize / 4, 1);
+ chunkSize = min(pfts.currentFileSize, chunkSize / 4);
else if (pfts.currentFileSize > 20 * chunkSize)
chunkSize = chunkSize * 4;
- return chunkSize;
+ return chunkSize ? chunkSize : 1;
}
void Progress(size_t count)
diff --git a/plugins/CloudFile/src/menus.cpp b/plugins/CloudFile/src/menus.cpp
index 804facffd5..014fc35fa0 100644
--- a/plugins/CloudFile/src/menus.cpp
+++ b/plugins/CloudFile/src/menus.cpp
@@ -6,14 +6,7 @@ INT_PTR UploadMenuCommand(void *obj, WPARAM hContact, LPARAM)
{
CCloudService *service = (CCloudService*)obj;
- auto it = service->InterceptedContacts.find(hContact);
- if (it == service->InterceptedContacts.end())
- {
- HWND hwnd = (HWND)CallService(MS_FILE_SENDFILE, hContact, 0);
- service->InterceptedContacts[hContact] = hwnd;
- }
- else
- SetActiveWindow(it->second);
+ service->OpenUploadDialog(hContact);
return 0;
}
diff --git a/plugins/CloudFile/src/srmm.cpp b/plugins/CloudFile/src/srmm.cpp
index d68e0fa63c..75e1aa65ee 100644
--- a/plugins/CloudFile/src/srmm.cpp
+++ b/plugins/CloudFile/src/srmm.cpp
@@ -66,14 +66,7 @@ int OnSrmmButtonPressed(WPARAM, LPARAM lParam)
if (ind > 0) {
CCloudService *service = Services[ind - 1];
- auto it = service->InterceptedContacts.find(cbc->hContact);
- if (it == service->InterceptedContacts.end())
- {
- HWND hwnd = (HWND)CallService(MS_FILE_SENDFILE, cbc->hContact, 0);
- service->InterceptedContacts[cbc->hContact] = hwnd;
- }
- else
- SetActiveWindow(it->second);
+ service->OpenUploadDialog(cbc->hContact);
}
return 0;
diff --git a/plugins/CloudFile/src/stdafx.h b/plugins/CloudFile/src/stdafx.h
index e5cc3db535..41720df5b1 100644
--- a/plugins/CloudFile/src/stdafx.h
+++ b/plugins/CloudFile/src/stdafx.h
@@ -27,6 +27,7 @@
#include <m_chat.h>
#include <m_http.h>
#include <m_json.h>
+#include <m_metacontacts.h>
#include <m_protoint.h>
#include <m_protosvc.h>