summaryrefslogtreecommitdiff
path: root/plugins/Dropbox/src/dropbox_services.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2014-02-28 11:34:57 +0000
committerAlexander Lantsev <aunsane@gmail.com>2014-02-28 11:34:57 +0000
commitc95380f9b30137a01b776f0390438908f47cc848 (patch)
tree50aba68883a1e7419f11d2f973d0677b74439371 /plugins/Dropbox/src/dropbox_services.cpp
parent3979fba7ea0009a4e416380be767475008b1f3e6 (diff)
Dropbox:
- fixed folders uploading - added commands (/content, /share, /delete) to Dropbox bot - fixed message after file sending to Dropbox bot git-svn-id: http://svn.miranda-ng.org/main/trunk@8325 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox/src/dropbox_services.cpp')
-rw-r--r--plugins/Dropbox/src/dropbox_services.cpp59
1 files changed, 52 insertions, 7 deletions
diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp
index c298974166..ec556056ff 100644
--- a/plugins/Dropbox/src/dropbox_services.cpp
+++ b/plugins/Dropbox/src/dropbox_services.cpp
@@ -85,16 +85,61 @@ INT_PTR CDropbox::ProtoSendFile(WPARAM wParam, LPARAM lParam)
return fileId;
}
-INT_PTR CDropbox::ProtoSendMessage(WPARAM wParam, LPARAM lParam)
+INT_PTR CDropbox::ProtoSendMessage(WPARAM, LPARAM lParam)
{
- //CCSDATA *pccsd = (CCSDATA*)lParam;
+ CCSDATA *pccsd = (CCSDATA*)lParam;
+
+ char *message = (char*)pccsd->lParam;
+
+ if (message[0] && message[0] == '/')
+ {
+ // parse commands
+ char *sep = strchr(message, ' ');
+ int len = strlen(message) - (sep ? strlen(sep) : 0) - 1;
+ char *cmd = (char*)mir_alloc(len + 1);
+ strncpy(cmd, message + 1, len);
+ cmd[len] = 0;
+ if (INSTANCE->commands.find(cmd) != INSTANCE->commands.end())
+ {
+ ULONG messageId = InterlockedIncrement(&INSTANCE->hMessageProcess);
+
+ MessageParam *param = new MessageParam();
+ param->hContact = pccsd->hContact;
+ param->hProcess = (HANDLE)messageId;
+ param->data = (sep ? sep + 1 : NULL);
+
+ mir_forkthread(INSTANCE->commands[cmd], param);
+
+ return messageId;
+ }
+ //mir_free(cmd);
+ }
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.szModule = MODULE;
+ dbei.timestamp = time(NULL);
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.cbBlob = strlen(message);
+ dbei.pBlob = (PBYTE)message;
+ dbei.flags = DBEF_SENT | DBEF_UTF;
+ db_event_add(pccsd->hContact, &dbei);
+
+ return 0;
+}
+
+INT_PTR CDropbox::ProtoReceiveMessage(WPARAM, LPARAM lParam)
+{
+ CCSDATA *pccsd = (CCSDATA*)lParam;
- //char *message = (char*)pccsd->lParam;
+ char *message = (char*)pccsd->lParam;
- //if (message[0] && message[0] == '/')
- //{
- // // parse commands
- //}
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.szModule = MODULE;
+ dbei.timestamp = time(NULL);
+ dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.cbBlob = strlen(message);
+ dbei.pBlob = (PBYTE)message;
+ db_event_add(pccsd->hContact, &dbei);
return 0;
}