summaryrefslogtreecommitdiff
path: root/plugins/CloudFile/src/cloud_file.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/CloudFile/src/cloud_file.h')
-rw-r--r--plugins/CloudFile/src/cloud_file.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/plugins/CloudFile/src/cloud_file.h b/plugins/CloudFile/src/cloud_file.h
new file mode 100644
index 0000000000..0d4f3def32
--- /dev/null
+++ b/plugins/CloudFile/src/cloud_file.h
@@ -0,0 +1,76 @@
+#ifndef _CLOUD_SERVICE_H_
+#define _CLOUD_SERVICE_H_
+
+enum OnConflict
+{
+ NONE,
+ RENAME,
+ REPLACE,
+};
+
+class CCloudService : public PROTO<CCloudService>
+{
+protected:
+ int id;
+ HNETLIBUSER hConnection;
+
+ // utils
+ char* PreparePath(const char *oldPath, char *newPath);
+
+ virtual char* HttpStatusToError(int status = 0);
+ virtual void HttpResponseToError(NETLIBHTTPREQUEST *response);
+ virtual void HandleHttpError(NETLIBHTTPREQUEST *response);
+ virtual void HandleJsonError(JSONNode &node) = 0;
+
+ JSONNode GetJsonResponse(NETLIBHTTPREQUEST *response);
+
+public:
+ std::map<MCONTACT, HWND> InterceptedContacts;
+
+ CCloudService(const char *protoName, const wchar_t *userName);
+ virtual ~CCloudService();
+
+ DWORD_PTR __cdecl GetCaps(int type, MCONTACT) override;
+ int __cdecl FileCancel(MCONTACT hContact, HANDLE hTransfer);
+ HANDLE __cdecl SendFile(MCONTACT hContact, const wchar_t *msg, wchar_t **ppszFiles) override;
+
+ static INT_PTR SendFileInterceptor(WPARAM wParam, LPARAM lParam);
+
+ virtual const char* GetModuleName() const = 0;
+ const char* GetAccountName() const;
+ const wchar_t* GetUserName() const;
+
+ virtual int GetIconId() const = 0;
+
+ virtual bool IsLoggedIn() = 0;
+ virtual void Login() = 0;
+ virtual void Logout() = 0;
+
+ void OpenUploadDialog(MCONTACT hContact);
+
+ virtual UINT Upload(FileTransferParam *ftp) = 0;
+
+ void Report(MCONTACT hContact, const wchar_t *data);
+};
+
+class CCloudServiceSearch : public CCloudService
+{
+protected:
+ void HandleJsonError(JSONNode&) { }
+
+public:
+ CCloudServiceSearch(const char *search)
+ : CCloudService(search, nullptr) { }
+
+ const char* GetModuleName() const override { return nullptr; }
+
+ int GetIconId() const override { return NULL; }
+
+ bool IsLoggedIn() override { return false; }
+ void Login() override { }
+ void Logout() override { }
+
+ UINT Upload(FileTransferParam*) { return 0; }
+};
+
+#endif //_CLOUD_SERVICE_H_ \ No newline at end of file