summaryrefslogtreecommitdiff
path: root/plugins/CloudFile/src/cloud_service.cpp
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2017-05-07 02:25:29 +0300
committeraunsane <aunsane@gmail.com>2017-05-07 02:25:29 +0300
commitff6a107e5f566da2644fbfe36455467beafaeb1e (patch)
tree3d5b96794ee835c8686a74da6c418c440c91c403 /plugins/CloudFile/src/cloud_service.cpp
parent453b3de91c372ee7b2661771aead6675e12fe98f (diff)
CloudFile:
- reworked options to dupport default service - added options to select conflict behavior - multiple fix and refactoring - version bump
Diffstat (limited to 'plugins/CloudFile/src/cloud_service.cpp')
-rw-r--r--plugins/CloudFile/src/cloud_service.cpp74
1 files changed, 24 insertions, 50 deletions
diff --git a/plugins/CloudFile/src/cloud_service.cpp b/plugins/CloudFile/src/cloud_service.cpp
index f8b8b1e976..3ad83d1e2f 100644
--- a/plugins/CloudFile/src/cloud_service.cpp
+++ b/plugins/CloudFile/src/cloud_service.cpp
@@ -20,23 +20,21 @@ void InitServices()
for (size_t i = 0; i < count; i++) {
CCloudService *service = Services[i];
- if (!db_get_b(NULL, service->GetModule(), "IsEnable", TRUE))
- continue;
-
- CMStringA moduleName(CMStringDataFormat::FORMAT, "%s/%s", MODULE, service->GetModule());
+ CMStringA moduleName = MODULE;
+ moduleName.AppendFormat("/%s", service->GetModule());
pd.type = PROTOTYPE_VIRTUAL;
pd.szName = moduleName.GetBuffer();
Proto_RegisterModule(&pd);
- CMStringA serviceName(CMStringDataFormat::FORMAT, "%s%s", moduleName, PSS_FILE);
+ CMStringA serviceName = moduleName + PSS_FILE;
CreateServiceFunctionObj(serviceName, ProtoSendFile, service);
- moduleName = CMStringA(CMStringDataFormat::FORMAT, "%s/%s/Interceptor", MODULE, service->GetModule());
+ moduleName += "/Interceptor";
pd.szName = moduleName.GetBuffer();
pd.type = PROTOTYPE_FILTER;
Proto_RegisterModule(&pd);
- serviceName = CMStringA(CMStringDataFormat::FORMAT, "%s%s", moduleName, PSS_FILE);
+ serviceName = moduleName + PSS_FILE;
CreateServiceFunctionObj(serviceName, ProtoSendFileInterceptor, service);
}
}
@@ -46,6 +44,16 @@ CCloudService::CCloudService(HNETLIBUSER hConnection)
{
}
+const wchar_t* CCloudService::GetText() const
+{
+ return _A2T(GetModule());
+}
+
+int CCloudService::GetIconId() const
+{
+ return 0;
+}
+
void CCloudService::OpenUploadDialog(MCONTACT hContact)
{
char *proto = GetContactProto(hContact);
@@ -62,44 +70,6 @@ void CCloudService::OpenUploadDialog(MCONTACT hContact)
SetActiveWindow(it->second);
}
-void CCloudService::SendToContact(MCONTACT hContact, const wchar_t *data)
-{
- const char *szProto = GetContactProto(hContact);
- if (db_get_b(hContact, szProto, "ChatRoom", 0) == TRUE) {
- ptrW tszChatRoom(db_get_wsa(hContact, szProto, "ChatRoomID"));
- Chat_SendUserMessage(szProto, tszChatRoom, data);
- return;
- }
-
- char *message = mir_utf8encodeW(data);
- if (ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)message) != ACKRESULT_FAILED)
- AddEventToDb(hContact, EVENTTYPE_MESSAGE, DBEF_UTF | DBEF_SENT, (DWORD)mir_strlen(message), (PBYTE)message);
-}
-
-void CCloudService::PasteToInputArea(MCONTACT hContact, const wchar_t *data)
-{
- CallService(MS_MSG_SENDMESSAGEW, hContact, (LPARAM)data);
-}
-
-void CCloudService::PasteToClipboard(const wchar_t *data)
-{
- if (OpenClipboard(NULL)) {
- EmptyClipboard();
-
- size_t size = sizeof(wchar_t) * (mir_wstrlen(data) + 1);
- HGLOBAL hClipboardData = GlobalAlloc(NULL, size);
- if (hClipboardData) {
- wchar_t *pchData = (wchar_t*)GlobalLock(hClipboardData);
- if (pchData) {
- memcpy(pchData, (wchar_t*)data, size);
- GlobalUnlock(hClipboardData);
- SetClipboardData(CF_UNICODETEXT, hClipboardData);
- }
- }
- CloseClipboard();
- }
-}
-
void CCloudService::Report(MCONTACT hContact, const wchar_t *data)
{
if (db_get_b(NULL, MODULE, "UrlAutoSend", 1))
@@ -157,16 +127,20 @@ char* CCloudService::HttpStatusToError(int status)
return "Unknown error";
}
+void CCloudService::HttpResponseToError(NETLIBHTTPREQUEST *response)
+{
+ if (response->dataLength)
+ throw Exception(response->pData);
+ throw Exception(HttpStatusToError(response->resultCode));
+}
+
void CCloudService::HandleHttpError(NETLIBHTTPREQUEST *response)
{
if (response == NULL)
throw Exception(HttpStatusToError());
- if (!HTTP_CODE_SUCCESS(response->resultCode)) {
- if (response->dataLength)
- throw Exception(response->pData);
- throw Exception(HttpStatusToError(response->resultCode));
- }
+ if (!HTTP_CODE_SUCCESS(response->resultCode))
+ HttpResponseToError(response);
}
JSONNode CCloudService::GetJsonResponse(NETLIBHTTPREQUEST *response)