diff options
-rw-r--r-- | include/m_protosvc.h | 17 | ||||
-rw-r--r-- | plugins/SecureIM/src/main.cpp | 2 | ||||
-rw-r--r-- | plugins/SecureIM/src/svcs_proto.cpp | 149 | ||||
-rw-r--r-- | plugins/SecureIM/src/svcs_proto.h | 2 | ||||
-rw-r--r-- | src/modules/protocols/protoint.cpp | 3 |
5 files changed, 8 insertions, 165 deletions
diff --git a/include/m_protosvc.h b/include/m_protosvc.h index b65d83eb95..0ac0c7c8a1 100644 --- a/include/m_protosvc.h +++ b/include/m_protosvc.h @@ -33,19 +33,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "m_protocols.h"
-/* ***** Unicode Services note ********
-******************************************
-
-Only new style protocols (Miranda 0.9+) with m_iVersion set to 2 or higher
-support Unicode services documented below, all other support only ANSI.
-
-For all other that do not support Unicode services, Miranda core will
-convert Unicode to ANSI and call the appropriate service.
-*/
-
-/*************************** NON-CONTACT SERVICES ************************/
-// these should be called with CallProtoServiceInt(NULL,)
+/////////////////////////////////////////////////////////////////////////////////////////
+// WARNING:
+// all services from this file should be called via CallProtoService()
+/////////////////////////////////////////////////////////////////////////////////////////
// Get the capability flags of the module.
// wParam = flagNum
// lParam = 0
@@ -54,6 +46,7 @@ convert Unicode to ANSI and call the appropriate service. // Non-network-access modules should return flags to represent the things they
// actually actively use, not the values that it is known to pass through
// correctly
+
#define PFLAGNUM_1 1
#define PF1_IMSEND 0x00000001 // supports IM sending
#define PF1_IMRECV 0x00000002 // supports IM receiving
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index feb7457e77..3c77fe47c2 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -221,7 +221,6 @@ static int onModulesLoaded(WPARAM, LPARAM) HookEvent(ME_OPT_INITIALISE, onRegisterOptions);
if (bPopupExists)
HookEvent(ME_OPT_INITIALISE, onRegisterPopOptions);
- HookEvent(ME_PROTO_ACK, onProtoAck);
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, onContactSettingChanged);
HookEvent(ME_DB_CONTACT_ADDED, onContactAdded);
HookEvent(ME_DB_CONTACT_DELETED, onContactDeleted);
@@ -229,7 +228,6 @@ static int onModulesLoaded(WPARAM, LPARAM) // hook message transport
CreateProtoServiceFunction(MODULENAME, PSR_MESSAGE, onRecvMsg);
CreateProtoServiceFunction(MODULENAME, PSS_MESSAGE, onSendMsg);
- CreateProtoServiceFunction(MODULENAME, PSS_FILE, onSendFile);
// create a menu item for creating a secure im connection to the user.
g_hMenu[0] = AddMenuItem(sim301, 110000, g_hICO[ICO_CM_EST], MODULENAME"/SIM_EST", CMIF_NOTOFFLINE);
diff --git a/plugins/SecureIM/src/svcs_proto.cpp b/plugins/SecureIM/src/svcs_proto.cpp index e254f7b81e..e1b9d45e13 100644 --- a/plugins/SecureIM/src/svcs_proto.cpp +++ b/plugins/SecureIM/src/svcs_proto.cpp @@ -749,152 +749,3 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) Sent_NetLog("onSendMsg: pass unchanged to chain");
return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
}
-
-int file_idx = 0;
-
-INT_PTR __cdecl onSendFile(WPARAM wParam, LPARAM lParam)
-{
- CCSDATA *pccsd = (CCSDATA*)lParam;
-
- pUinKey ptr = getUinKey(pccsd->hContact);
- if (!ptr || !bSFT)
- return CallService(PSS_FILE, wParam, lParam);
-
- if (isContactSecured(pccsd->hContact)&SECURED) {
- char **file = (char **)pccsd->lParam;
- if (file_idx == 100) file_idx = 0;
- int i;
- for (i = 0; file[i]; i++) {
-
- if (strstr(file[i], ".AESHELL")) continue;
-
- char *name = strrchr(file[i], '\\');
- if (!name) name = file[i];
- else name++;
-
- int size = TEMP_SIZE + (int)mir_strlen(name) + 20;
- char *file_out = (char *)mir_alloc(size);
- mir_snprintf(file_out, size, "%s\\%s.AESHELL(%d)", TEMP, name, file_idx++);
-
- char buf[MAX_PATH];
- mir_snprintf(buf, SIZEOF(buf), "%s\n%s", Translate(sim011), file[i]);
- showPopup(buf, NULL, g_hPOP[POP_PU_MSS], 2);
-
- if (ptr->mode == MODE_RSAAES)
- exp->rsa_encrypt_file(ptr->cntx, file[i], file_out);
- else
- cpp_encrypt_file(ptr->cntx, file[i], file_out);
-
- mir_free(file[i]);
- file[i] = file_out;
- }
- if (ptr->fileSend) { // очистим сохраненный список
- for (int j = 0; ptr->fileSend[j]; j++)
- mir_free(ptr->fileSend[j]);
-
- SAFE_FREE(ptr->fileSend);
- }
- if (i) { // скопируем новый список
- ptr->fileSend = (char **)mir_alloc(sizeof(char*)*(i + 1));
- for (i = 0; file[i]; i++)
- ptr->fileSend[i] = mir_strdup(file[i]);
-
- ptr->fileSend[i] = NULL;
- }
- }
- return CallService(PSS_FILE, wParam, lParam);
-}
-
-int __cdecl onProtoAck(WPARAM wParam, LPARAM lParam)
-{
- ACKDATA *ack = (ACKDATA*)lParam;
- if (ack->type != ACKTYPE_FILE) return 0; //quit if not file transfer event
- PROTOFILETRANSFERSTATUS *f = (PROTOFILETRANSFERSTATUS*)ack->lParam;
- if (!f)
- return 0;
-
- pUinKey ptr = getUinKey(ack->hContact);
- if (!ptr || ((f->flags & PFTS_SENDING) && !bSFT)) return 0;
-
- if (isContactSecured(ack->hContact)&SECURED) {
- switch (ack->result) {
- case ACKRESULT_DATA:
- if (f->flags & PFTS_SENDING) {
- ptr->finFileSend = (f->currentFileSize == f->currentFileProgress);
- if (!ptr->lastFileSend)
- ptr->lastFileSend = mir_strdup(f->szCurrentFile);
- }
- else {
- ptr->finFileRecv = (f->currentFileSize == f->currentFileProgress);
- if (!ptr->lastFileRecv)
- ptr->lastFileRecv = mir_strdup(f->szCurrentFile);
- }
- break;
-
- case ACKRESULT_DENIED:
- case ACKRESULT_FAILED:
- if (ptr->lastFileRecv) {
- if (strstr(ptr->lastFileRecv, ".AESHELL")) mir_unlink(ptr->lastFileRecv);
- SAFE_FREE(ptr->lastFileRecv);
- }
- if (ptr->lastFileSend) {
- if (strstr(ptr->lastFileSend, ".AESHELL")) mir_unlink(ptr->lastFileSend);
- SAFE_FREE(ptr->lastFileSend);
- }
- if (ptr->fileSend) {
- char **file = ptr->fileSend;
- for (int j = 0; file[j]; j++) {
- if (strstr(file[j], ".AESHELL")) mir_unlink(file[j]);
- mir_free(file[j]);
- }
- SAFE_FREE(ptr->fileSend);
- }
- return 0;
-
- case ACKRESULT_NEXTFILE:
- case ACKRESULT_SUCCESS:
- if (ptr->finFileRecv && ptr->lastFileRecv) {
- if (strstr(ptr->lastFileRecv, ".AESHELL")) {
- char buf[MAX_PATH];
- LPSTR file_out = mir_strdup(ptr->lastFileRecv);
- LPSTR pos = strrchr(file_out, '.'); //find last .
- if (pos) *pos = '\0'; //remove AESHELL from name
-
- if (isFileExist(file_out)) {
- buf[0] = '\0';
- LPSTR p = strrchr(file_out, '.');
- LPSTR x = strrchr(file_out, '\\');
- if (p > x) {
- strncpy(buf, p, sizeof(buf)-1);
- pos = p;
- }
- for (int i = 1; i < 10000; i++) {
- sprintf(pos, " (%d)%s", i, buf); //!!!!!!!!!!!!!
- if (!isFileExist(file_out)) break;
- }
- }
-
- mir_snprintf(buf, SIZEOF(buf), "%s\n%s", Translate(sim012), file_out);
- showPopup(buf, NULL, g_hPOP[POP_PU_MSR], 2);
-
- if (ptr->mode == MODE_RSAAES)
- exp->rsa_decrypt_file(ptr->cntx, ptr->lastFileRecv, file_out);
- else
- cpp_decrypt_file(ptr->cntx, ptr->lastFileRecv, file_out);
-
- mir_free(file_out);
- mir_unlink(ptr->lastFileRecv);
- }
- SAFE_FREE(ptr->lastFileRecv);
- ptr->finFileRecv = false;
- }
- if (ptr->finFileSend && ptr->lastFileSend) {
- if (strstr(ptr->lastFileSend, ".AESHELL")) mir_unlink(ptr->lastFileSend);
- SAFE_FREE(ptr->lastFileSend);
- ptr->finFileSend = false;
- }
- break;
- }
- }
- return 0;
-}
diff --git a/plugins/SecureIM/src/svcs_proto.h b/plugins/SecureIM/src/svcs_proto.h index 8b7aa6e398..f679c12f9c 100644 --- a/plugins/SecureIM/src/svcs_proto.h +++ b/plugins/SecureIM/src/svcs_proto.h @@ -3,9 +3,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM,LPARAM);
INT_PTR __cdecl onSendMsg(WPARAM,LPARAM);
-INT_PTR __cdecl onSendFile(WPARAM,LPARAM);
-int __cdecl onProtoAck(WPARAM,LPARAM);
int __cdecl onContactSettingChanged(WPARAM,LPARAM);
#endif
diff --git a/src/modules/protocols/protoint.cpp b/src/modules/protocols/protoint.cpp index 809d78b0cc..3ad3337ce3 100644 --- a/src/modules/protocols/protoint.cpp +++ b/src/modules/protocols/protoint.cpp @@ -208,6 +208,9 @@ struct DEFAULT_PROTO_INTERFACE : public PROTO_INTERFACE {
CCSDATA ccs = { hContact, PSS_FILE, (WPARAM)szDescription, (LPARAM)ppszFiles };
+ if (m_iVersion > 1)
+ return (HANDLE)ProtoCallService(m_szModuleName, PSS_FILE, 0, (LPARAM)&ccs);
+
ccs.wParam = (WPARAM)mir_t2a(szDescription);
ccs.lParam = (LPARAM)Proto_FilesMatrixA(ppszFiles);
HANDLE res = (HANDLE)ProtoCallService(m_szModuleName, PSS_FILE, 0, (LPARAM)&ccs);
|