summaryrefslogtreecommitdiff
path: root/src/modules/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-06 14:44:59 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-06 14:44:59 +0000
commit1ed1296853c671fc557599c6daf5fba88d52a21f (patch)
treee67180dcb6c6b3362d0ec4a597c334353337a644 /src/modules/protocols
parente255337491b93977d00bd364d31ef943e821d22a (diff)
+ stdauth + stdfile;
NEWSTR_ALLOCA / NEWTSTR_ALLOCA / NEWWSTR_ALLOCA moved to m_system.h git-svn-id: http://svn.miranda-ng.org/main/trunk@792 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/protocols')
-rw-r--r--src/modules/protocols/protocols.cpp89
-rw-r--r--src/modules/protocols/protoint.cpp20
2 files changed, 19 insertions, 90 deletions
diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp
index 8a12239c48..b490b0188c 100644
--- a/src/modules/protocols/protocols.cpp
+++ b/src/modules/protocols/protocols.cpp
@@ -144,92 +144,6 @@ static INT_PTR Proto_RegisterModule(WPARAM, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
// Basic core services
-static INT_PTR Proto_RecvFile(WPARAM, LPARAM lParam)
-{
- CCSDATA* ccs = (CCSDATA*)lParam;
- PROTORECVEVENT* pre = (PROTORECVEVENT*)ccs->lParam;
- char* szFile = pre->szMessage + sizeof(DWORD);
- char* szDescr = szFile + strlen(szFile) + 1;
-
- // Suppress the standard event filter
- if (pre->lParam != NULL)
- *(DWORD*)pre->szMessage = 0;
-
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
- dbei.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0);
- dbei.timestamp = pre->timestamp;
- dbei.flags = (pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0;
- dbei.flags |= (pre->flags & PREF_UTF) ? DBEF_UTF : 0;
- dbei.eventType = EVENTTYPE_FILE;
- dbei.cbBlob = (DWORD)(sizeof(DWORD) + strlen(szFile) + strlen(szDescr) + 2);
- dbei.pBlob = (PBYTE)pre->szMessage;
- HANDLE hdbe = (HANDLE)CallService(MS_DB_EVENT_ADD, (WPARAM)ccs->hContact, (LPARAM)&dbei);
-
- if (pre->lParam != NULL)
- PushFileEvent(ccs->hContact, hdbe, pre->lParam);
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-static void sttRecvCreateBlob(DBEVENTINFO& dbei, int fileCount, char** pszFiles, char* szDescr)
-{
- dbei.cbBlob = sizeof(DWORD);
- {
- for (int i=0; i < fileCount; i++)
- dbei.cbBlob += lstrlenA(pszFiles[i]) + 1;
- }
-
- dbei.cbBlob += lstrlenA(szDescr) + 1;
-
- if ((dbei.pBlob = (BYTE*)mir_alloc(dbei.cbBlob)) == 0)
- return;
-
- *(DWORD*)dbei.pBlob = 0;
- BYTE* p = dbei.pBlob + sizeof(DWORD);
- for (int i=0; i < fileCount; i++) {
- strcpy((char*)p, pszFiles[i]);
- p += lstrlenA(pszFiles[i]) + 1;
- }
- strcpy((char*)p, (szDescr == NULL) ? "" : szDescr);
-}
-
-static INT_PTR Proto_RecvFileT(WPARAM, LPARAM lParam)
-{
- CCSDATA* ccs = (CCSDATA*)lParam;
- PROTORECVFILET* pre = (PROTORECVFILET*)ccs->lParam;
- if (pre->fileCount == 0)
- return 0;
-
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
- dbei.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0);
- dbei.timestamp = pre->timestamp;
- dbei.flags = (pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0;
- dbei.eventType = EVENTTYPE_FILE;
-
- char** pszFiles = (char**)alloca(pre->fileCount * sizeof(char*));
- {
- for (int i=0; i < pre->fileCount; i++)
- pszFiles[i] = Utf8EncodeT(pre->ptszFiles[i]);
- }
- char* szDescr = Utf8EncodeT(pre->tszDescription);
- dbei.flags |= DBEF_UTF;
- sttRecvCreateBlob(dbei, pre->fileCount, pszFiles, szDescr);
- {
- for (int i=0; i < pre->fileCount; i++)
- mir_free(pszFiles[i]);
- }
- mir_free(szDescr);
-
- HANDLE hdbe = (HANDLE)CallService(MS_DB_EVENT_ADD, (WPARAM)ccs->hContact, (LPARAM)&dbei);
-
- PushFileEvent(ccs->hContact, hdbe, pre->lParam);
- mir_free(dbei.pBlob);
- return 0;
-}
-
static INT_PTR Proto_RecvMessage(WPARAM, LPARAM lParam)
{
CCSDATA *ccs = (CCSDATA*)lParam;
@@ -766,7 +680,6 @@ int LoadProtocolsModule(void)
InsertServiceListItem(109, PS_SEARCHBYNAMEW);
InsertServiceListItem(110, PS_SEARCHBYEMAILW);
-
hAckEvent = CreateHookableEvent(ME_PROTO_ACK);
hTypeEvent = CreateHookableEvent(ME_PROTO_CONTACTISTYPING);
hAccListChanged = CreateHookableEvent(ME_PROTO_ACCLISTCHANGED);
@@ -778,8 +691,6 @@ int LoadProtocolsModule(void)
CreateServiceFunction(MS_PROTO_SELFISTYPING, Proto_SelfIsTyping);
CreateServiceFunction(MS_PROTO_CONTACTISTYPING, Proto_ContactIsTyping);
- CreateServiceFunction(MS_PROTO_RECVFILE, Proto_RecvFile);
- CreateServiceFunction(MS_PROTO_RECVFILET, Proto_RecvFileT);
CreateServiceFunction(MS_PROTO_RECVMSG, Proto_RecvMessage);
CreateServiceFunction("Proto/EnumProtocols", Proto_EnumAccounts);
diff --git a/src/modules/protocols/protoint.cpp b/src/modules/protocols/protoint.cpp
index 8470ef308a..041132c1f5 100644
--- a/src/modules/protocols/protoint.cpp
+++ b/src/modules/protocols/protoint.cpp
@@ -24,7 +24,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\..\core\commonheaders.h"
char** __fastcall Proto_FilesMatrixA(TCHAR **files);
-void FreeFilesMatrix(TCHAR ***files);
+
+void FreeFilesMatrix(TCHAR ***files)
+{
+ if (*files == NULL)
+ return;
+
+ // Free each filename in the pointer array
+ TCHAR **pFile = *files;
+ while (*pFile != NULL)
+ {
+ mir_free(*pFile);
+ *pFile = NULL;
+ pFile++;
+ }
+
+ // Free the array itself
+ mir_free(*files);
+ *files = NULL;
+}
INT_PTR __fastcall MyCallProtoService(const char *szModule, const char *szService, WPARAM wParam, LPARAM lParam)
{