diff options
-rw-r--r-- | plugins/SMS/src/SMS_svc.cpp | 40 | ||||
-rw-r--r-- | plugins/SMS/src/receive.cpp | 389 | ||||
-rw-r--r-- | plugins/SMS/src/recvdlg.cpp | 125 | ||||
-rw-r--r-- | plugins/SMS/src/send.cpp | 84 | ||||
-rw-r--r-- | plugins/SMS/src/senddlg.cpp | 150 | ||||
-rw-r--r-- | protocols/MRA/src/MraSendCommand.cpp | 1 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_proto.cpp | 3 | ||||
-rw-r--r-- | protocols/MRA/src/version.h | 4 |
8 files changed, 401 insertions, 395 deletions
diff --git a/plugins/SMS/src/SMS_svc.cpp b/plugins/SMS/src/SMS_svc.cpp index 67de9d801c..4ae291fdef 100644 --- a/plugins/SMS/src/SMS_svc.cpp +++ b/plugins/SMS/src/SMS_svc.cpp @@ -94,16 +94,16 @@ int ReadMsgSMS(WPARAM wParam,LPARAM lParam) CLISTEVENT *cle = (CLISTEVENT*)lParam;
DBEVENTINFO dbei = { sizeof(dbei) };
- if ((dbei.cbBlob = db_event_getBlobSize(((CLISTEVENT*)lParam)->hDbEvent)) != -1) {
- dbei.pBlob = (PBYTE)_alloca(dbei.cbBlob);
-
- if (db_event_get(cle->hDbEvent, &dbei) == 0)
- if (dbei.eventType == ICQEVENTTYPE_SMS || dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION)
- if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN) {
- if (RecvSMSWindowAdd(cle->hContact,ICQEVENTTYPE_SMS,NULL,0,(LPSTR)dbei.pBlob,dbei.cbBlob)) {
- db_event_markRead(cle->hContact, cle->hDbEvent);
- return 0;
- }
+ if ((dbei.cbBlob = db_event_getBlobSize(((CLISTEVENT*)lParam)->hDbEvent)) == -1)
+ return 1;
+ dbei.pBlob = (PBYTE)_alloca(dbei.cbBlob);
+
+ if (db_event_get(cle->hDbEvent, &dbei) == 0)
+ if (dbei.eventType == ICQEVENTTYPE_SMS || dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION)
+ if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN) {
+ if (RecvSMSWindowAdd(cle->hContact,ICQEVENTTYPE_SMS,NULL,0,(LPSTR)dbei.pBlob,dbei.cbBlob)) {
+ db_event_markRead(cle->hContact, cle->hDbEvent);
+ return 0;
}
}
return 1;
@@ -115,16 +115,16 @@ int ReadAckSMS(WPARAM wParam,LPARAM lParam) CLISTEVENT *cle = (CLISTEVENT*)lParam;
DBEVENTINFO dbei = { sizeof(dbei) };
- if ((dbei.cbBlob = db_event_getBlobSize(cle->hDbEvent)) != -1) {
- dbei.pBlob = (PBYTE)_alloca(dbei.cbBlob);
-
- if (db_event_get(cle->hDbEvent, &dbei) == 0)
- if (dbei.eventType == ICQEVENTTYPE_SMS || dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION)
- if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN) {
- if (RecvSMSWindowAdd(cle->hContact, ICQEVENTTYPE_SMSCONFIRMATION, NULL, 0, (LPSTR)dbei.pBlob, dbei.cbBlob)) {
- db_event_delete(cle->hContact, cle->hDbEvent);
- return 0;
- }
+ if ((dbei.cbBlob = db_event_getBlobSize(cle->hDbEvent)) == -1)
+ return 1;
+ dbei.pBlob = (PBYTE)_alloca(dbei.cbBlob);
+
+ if (db_event_get(cle->hDbEvent, &dbei) == 0)
+ if (dbei.eventType == ICQEVENTTYPE_SMS || dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION)
+ if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN) {
+ if (RecvSMSWindowAdd(cle->hContact, ICQEVENTTYPE_SMSCONFIRMATION, NULL, 0, (LPSTR)dbei.pBlob, dbei.cbBlob)) {
+ db_event_delete(cle->hContact, cle->hDbEvent);
+ return 0;
}
}
return 1;
diff --git a/plugins/SMS/src/receive.cpp b/plugins/SMS/src/receive.cpp index 8e77708bd0..cec3ebd00f 100644 --- a/plugins/SMS/src/receive.cpp +++ b/plugins/SMS/src/receive.cpp @@ -1,7 +1,7 @@ /*
Miranda-IM SMS Plugin
Copyright (C) 2001-2 Richard Hughes
-Copyright (C) 2007-2009 Rozhuk Ivan
+Copyright (C) 2007-2014 Rozhuk Ivan
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -28,178 +28,182 @@ Enjoy the code and use it smartly! #include "common.h"
//This function handles the ACK received from that hooked.
-int handleAckSMS(WPARAM wParam,LPARAM lParam)
+int handleAckSMS(WPARAM wParam, LPARAM lParam)
{
- if (lParam)
- if (((ACKDATA*)lParam)->type==ICQACKTYPE_SMS)
- {
- char szPhone[MAX_PHONE_LEN]={0};
- TCHAR tszPhone[MAX_PHONE_LEN]={0};
- LPSTR lpszXML=(LPSTR)((ACKDATA*)lParam)->lParam,lpszData,lpszPhone;
- SIZE_T dwXMLSize=lstrlenA(lpszXML),dwDataSize,dwPhoneSize;
- ACKDATA *ack=((ACKDATA*)lParam);
-
- if (GetXMLFieldEx(lpszXML,dwXMLSize,&lpszData,&dwDataSize,"sms_message","text",NULL))
- {
- if (GetXMLFieldEx(lpszXML,dwXMLSize,&lpszPhone,&dwPhoneSize,"sms_message","sender",NULL))
- {
- LPSTR lpszMessageUTF;
- SIZE_T dwBuffLen,dwMessageXMLEncodedSize,dwMessageXMLDecodedSize;
- DBEVENTINFO dbei = { sizeof(dbei) };
+ if ( !lParam)
+ return 0;
+ if (((ACKDATA*)lParam)->type != ICQACKTYPE_SMS)
+ return 0;
- dwBuffLen=(dwDataSize+MAX_PATH);
- dbei.pBlob=(LPBYTE)MEMALLOC((dwBuffLen+dwPhoneSize));
- LPWSTR lpwszMessageXMLEncoded=(LPWSTR)MEMALLOC((dwBuffLen*sizeof(WCHAR)));
- LPWSTR lpwszMessageXMLDecoded=(LPWSTR)MEMALLOC((dwBuffLen*sizeof(WCHAR)));
- if (dbei.pBlob && lpwszMessageXMLEncoded && lpwszMessageXMLDecoded)
- {
- dwMessageXMLEncodedSize=MultiByteToWideChar(CP_UTF8,0,lpszData,dwDataSize,lpwszMessageXMLEncoded,dwBuffLen);
- DecodeXML(lpwszMessageXMLEncoded,dwMessageXMLEncodedSize,lpwszMessageXMLDecoded,dwBuffLen,&dwMessageXMLDecodedSize);
- lpszMessageUTF=(LPSTR)lpwszMessageXMLEncoded;
- WideCharToMultiByte(CP_UTF8,0,lpwszMessageXMLDecoded,dwMessageXMLDecodedSize,lpszMessageUTF,dwBuffLen,NULL,NULL);
+ char szPhone[MAX_PHONE_LEN] = { 0 };
+ TCHAR tszPhone[MAX_PHONE_LEN] = { 0 };
+ LPSTR lpszXML = (LPSTR)((ACKDATA*)lParam)->lParam, lpszData, lpszPhone;
+ SIZE_T dwXMLSize = 0, dwDataSize, dwPhoneSize;
+ ACKDATA *ack = ((ACKDATA*)lParam);
- dwPhoneSize=CopyNumberA(szPhone,lpszPhone,dwPhoneSize);
- dwPhoneSize=MultiByteToWideChar(CP_UTF8,0,szPhone,dwPhoneSize,tszPhone,MAX_PHONE_LEN);
- MCONTACT hContact=HContactFromPhone(tszPhone,dwPhoneSize);
+ if (lpszXML)
+ dwXMLSize = lstrlenA(lpszXML);
- dbei.szModule=GetModuleName(hContact);
- dbei.timestamp=time(NULL);
- dbei.flags = DBEF_UTF;
- dbei.eventType = ICQEVENTTYPE_SMS;
- dbei.cbBlob=(mir_snprintf((LPSTR)dbei.pBlob,((dwBuffLen+dwPhoneSize)),"SMS From: +%s\r\n%s",szPhone,lpszMessageUTF)+sizeof(DWORD));
- //dbei.pBlob=(LPBYTE)lpszBuff;
- (*((DWORD*)(dbei.pBlob+(dbei.cbBlob-sizeof(DWORD)))))=0;
- HANDLE hResult = db_event_add(hContact, &dbei);
- if (hContact==NULL) {
- if ( RecvSMSWindowAdd(NULL,ICQEVENTTYPE_SMS,tszPhone,dwPhoneSize,(LPSTR)dbei.pBlob,dbei.cbBlob)) {
- db_event_markRead(hContact, hResult);
- SkinPlaySound("RecvSMSMsg");
- }
- }
- }
- MEMFREE(lpwszMessageXMLDecoded);
- MEMFREE(lpwszMessageXMLEncoded);
- MEMFREE(dbei.pBlob);
- }
- }else
- if (GetXMLFieldEx(lpszXML,dwXMLSize,&lpszData,&dwDataSize,"sms_delivery_receipt","delivered",NULL))
+ if (GetXMLFieldEx(lpszXML,dwXMLSize,&lpszData,&dwDataSize,"sms_message", "text", NULL))
+ {
+ if (GetXMLFieldEx(lpszXML,dwXMLSize,&lpszPhone,&dwPhoneSize,"sms_message","sender",NULL))
{
- if (GetXMLFieldEx(lpszXML,dwXMLSize,&lpszPhone,&dwPhoneSize,"sms_delivery_receipt","destination",NULL))
+ LPSTR lpszMessageUTF;
+ SIZE_T dwBuffLen,dwMessageXMLEncodedSize,dwMessageXMLDecodedSize;
+ DBEVENTINFO dbei = { sizeof(dbei) };
+
+ dwBuffLen=(dwDataSize+MAX_PATH);
+ dbei.pBlob=(LPBYTE)MEMALLOC((dwBuffLen+dwPhoneSize));
+ LPWSTR lpwszMessageXMLEncoded=(LPWSTR)MEMALLOC((dwBuffLen*sizeof(WCHAR)));
+ LPWSTR lpwszMessageXMLDecoded=(LPWSTR)MEMALLOC((dwBuffLen*sizeof(WCHAR)));
+ if (dbei.pBlob && lpwszMessageXMLEncoded && lpwszMessageXMLDecoded)
{
+ dwMessageXMLEncodedSize=MultiByteToWideChar(CP_UTF8,0,lpszData,dwDataSize,lpwszMessageXMLEncoded,dwBuffLen);
+ DecodeXML(lpwszMessageXMLEncoded,dwMessageXMLEncodedSize,lpwszMessageXMLDecoded,dwBuffLen,&dwMessageXMLDecodedSize);
+ lpszMessageUTF=(LPSTR)lpwszMessageXMLEncoded;
+ WideCharToMultiByte(CP_UTF8,0,lpwszMessageXMLDecoded,dwMessageXMLDecodedSize,lpszMessageUTF,dwBuffLen,NULL,NULL);
+
dwPhoneSize=CopyNumberA(szPhone,lpszPhone,dwPhoneSize);
dwPhoneSize=MultiByteToWideChar(CP_UTF8,0,szPhone,dwPhoneSize,tszPhone,MAX_PHONE_LEN);
MCONTACT hContact=HContactFromPhone(tszPhone,dwPhoneSize);
- DBEVENTINFO dbei={0};
- dbei.cbSize=sizeof(dbei);
dbei.szModule=GetModuleName(hContact);
dbei.timestamp=time(NULL);
dbei.flags = DBEF_UTF;
- dbei.eventType = ICQEVENTTYPE_SMSCONFIRMATION;
- if (CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,dwDataSize,"yes",3)==CSTR_EQUAL)
- {
- dbei.cbBlob=(MAX_PHONE_LEN+MAX_PATH);
- dbei.pBlob=(PBYTE)MEMALLOC(dbei.cbBlob);
- if (dbei.pBlob) dbei.cbBlob=(mir_snprintf((LPSTR)dbei.pBlob,dbei.cbBlob,"SMS Confirmation From: +%s\r\nSMS was sent succesfully",szPhone)+4);
- }else{
- if (GetXMLFieldEx(lpszXML,dwXMLSize,&lpszData,&dwDataSize,"sms_delivery_receipt","error","params","param",NULL)==FALSE)
- {
- lpszData="";
- dwDataSize=0;
- }
- dbei.cbBlob=(MAX_PHONE_LEN+MAX_PATH+dwDataSize);
- dbei.pBlob=(PBYTE)MEMALLOC(dbei.cbBlob);
- if (dbei.pBlob)
- {
- dbei.cbBlob=mir_snprintf((LPSTR)dbei.pBlob,dbei.cbBlob,"SMS Confirmation From: +%s\r\nSMS was not sent succesfully: ",szPhone);
- CopyMemory((dbei.pBlob+dbei.cbBlob),lpszData,dwDataSize);
- dbei.cbBlob+=(dwDataSize+sizeof(DWORD));
- (*((DWORD*)(dbei.pBlob+(dbei.cbBlob-sizeof(DWORD)))))=0;
+ dbei.eventType = ICQEVENTTYPE_SMS;
+ dbei.cbBlob=(mir_snprintf((LPSTR)dbei.pBlob,((dwBuffLen+dwPhoneSize)),"SMS From: +%s\r\n%s",szPhone,lpszMessageUTF)+sizeof(DWORD));
+ //dbei.pBlob=(LPBYTE)lpszBuff;
+ (*((DWORD*)(dbei.pBlob+(dbei.cbBlob-sizeof(DWORD)))))=0;
+ HANDLE hResult = db_event_add(hContact, &dbei);
+ if (hContact==NULL) {
+ if ( RecvSMSWindowAdd(NULL,ICQEVENTTYPE_SMS,tszPhone,dwPhoneSize,(LPSTR)dbei.pBlob,dbei.cbBlob)) {
+ db_event_markRead(hContact, hResult);
+ SkinPlaySound("RecvSMSMsg");
}
}
+ }
+ MEMFREE(lpwszMessageXMLDecoded);
+ MEMFREE(lpwszMessageXMLEncoded);
+ MEMFREE(dbei.pBlob);
+ }
+ }else
+ if (GetXMLFieldEx(lpszXML,dwXMLSize,&lpszData,&dwDataSize,"sms_delivery_receipt","delivered",NULL))
+ {
+ if (GetXMLFieldEx(lpszXML,dwXMLSize,&lpszPhone,&dwPhoneSize,"sms_delivery_receipt","destination",NULL))
+ {
+ dwPhoneSize=CopyNumberA(szPhone,lpszPhone,dwPhoneSize);
+ dwPhoneSize=MultiByteToWideChar(CP_UTF8,0,szPhone,dwPhoneSize,tszPhone,MAX_PHONE_LEN);
+ MCONTACT hContact=HContactFromPhone(tszPhone,dwPhoneSize);
- if (dbei.pBlob) {
- if (hContact)
- db_event_add(hContact, &dbei);
- else
- RecvSMSWindowAdd(NULL,ICQEVENTTYPE_SMSCONFIRMATION,tszPhone,dwPhoneSize,(LPSTR)dbei.pBlob,dbei.cbBlob);
-
- MEMFREE(dbei.pBlob);
+ DBEVENTINFO dbei={0};
+ dbei.cbSize=sizeof(dbei);
+ dbei.szModule=GetModuleName(hContact);
+ dbei.timestamp=time(NULL);
+ dbei.flags = DBEF_UTF;
+ dbei.eventType = ICQEVENTTYPE_SMSCONFIRMATION;
+ if (CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,dwDataSize,"yes",3)==CSTR_EQUAL)
+ {
+ dbei.cbBlob=(MAX_PHONE_LEN+MAX_PATH);
+ dbei.pBlob=(PBYTE)MEMALLOC(dbei.cbBlob);
+ if (dbei.pBlob) dbei.cbBlob=(mir_snprintf((LPSTR)dbei.pBlob,dbei.cbBlob,"SMS Confirmation From: +%s\r\nSMS was sent succesfully",szPhone)+4);
+ }else{
+ if (GetXMLFieldEx(lpszXML,dwXMLSize,&lpszData,&dwDataSize,"sms_delivery_receipt","error","params","param",NULL)==FALSE)
+ {
+ lpszData="";
+ dwDataSize=0;
+ }
+ dbei.cbBlob=(MAX_PHONE_LEN+MAX_PATH+dwDataSize);
+ dbei.pBlob=(PBYTE)MEMALLOC(dbei.cbBlob);
+ if (dbei.pBlob)
+ {
+ dbei.cbBlob=mir_snprintf((LPSTR)dbei.pBlob,dbei.cbBlob,"SMS Confirmation From: +%s\r\nSMS was not sent succesfully: ",szPhone);
+ CopyMemory((dbei.pBlob+dbei.cbBlob),lpszData,dwDataSize);
+ dbei.cbBlob+=(dwDataSize+sizeof(DWORD));
+ (*((DWORD*)(dbei.pBlob+(dbei.cbBlob-sizeof(DWORD)))))=0;
}
}
- }else
- if ((ack->result==ACKRESULT_FAILED) || GetXMLFieldEx(lpszXML,dwXMLSize,&lpszData,&dwDataSize,"sms_response","deliverable",NULL))
- {
- HWND hWndDlg=SendSMSWindowHwndByHProcessGet(ack->hProcess);
- if (hWndDlg) {
- char szNetwork[MAX_PATH];
- KillTimer(hWndDlg,wParam);
- GetXMLFieldExBuff(lpszXML,dwXMLSize,szNetwork,sizeof(szNetwork),NULL,"sms_response","network",NULL);
+ if (dbei.pBlob) {
+ if (hContact)
+ db_event_add(hContact, &dbei);
+ else
+ RecvSMSWindowAdd(NULL,ICQEVENTTYPE_SMSCONFIRMATION,tszPhone,dwPhoneSize,(LPSTR)dbei.pBlob,dbei.cbBlob);
- if (ack->result==ACKRESULT_FAILED || CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,dwDataSize,"no",2)==CSTR_EQUAL) {
- char szBuff[1024];
- TCHAR tszErrorMessage[1028];
- LPSTR lpszErrorDescription;
+ MEMFREE(dbei.pBlob);
+ }
+ }
+ }else
+ if ((ack->result == ACKRESULT_FAILED) || GetXMLFieldEx(lpszXML,dwXMLSize,&lpszData,&dwDataSize,"sms_response","deliverable",NULL))
+ {
+ HWND hWndDlg = SendSMSWindowHwndByHProcessGet(ack->hProcess);
+ if (hWndDlg) {
+ char szNetwork[MAX_PATH];
- if (SendSMSWindowMultipleGet(hWndDlg)) {
- TVITEM tvi;
- tvi.mask=TVIF_TEXT;
- tvi.hItem=SendSMSWindowHItemSendGet(hWndDlg);
- tvi.pszText=tszPhone;
- tvi.cchTextMax=SIZEOF(tszPhone);
- TreeView_GetItem(GetDlgItem(hWndDlg,IDC_NUMBERSLIST),&tvi);
- }
- else GetDlgItemText(hWndDlg,IDC_ADDRESS,tszPhone,SIZEOF(szPhone));
+ KillTimer(hWndDlg, wParam);
+ GetXMLFieldExBuff(lpszXML,dwXMLSize,szNetwork,sizeof(szNetwork),NULL,"sms_response","network",NULL);
- if (ack->result == ACKRESULT_FAILED)
- lpszErrorDescription=lpszXML;
- else {
- lpszErrorDescription=szBuff;
- GetXMLFieldExBuff(lpszXML,dwXMLSize,szBuff,sizeof(szBuff),NULL,"sms_response","error","params","param",NULL);
- }
+ if (ack->result == ACKRESULT_FAILED || CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,dwDataSize,"no",2)==CSTR_EQUAL) {
+ char szBuff[1024];
+ TCHAR tszErrorMessage[1028];
+ LPSTR lpszErrorDescription;
- mir_sntprintf(tszErrorMessage,SIZEOF(tszErrorMessage),TranslateT("SMS message didn't send by %S to %s because: %S"),szNetwork,tszPhone,lpszErrorDescription);
- ShowWindow(hWndDlg,SW_SHOWNORMAL);
- EnableWindow(hWndDlg,FALSE);
- HWND hwndTimeOut=CreateDialog(ssSMSSettings.hInstance,MAKEINTRESOURCE(IDD_SENDSMSTIMEDOUT),hWndDlg,SMSTimedOutDlgProc);
- SetDlgItemText(hwndTimeOut,IDC_STATUS,tszErrorMessage);
+ if (SendSMSWindowMultipleGet(hWndDlg)) {
+ TVITEM tvi;
+ tvi.mask=TVIF_TEXT;
+ tvi.hItem=SendSMSWindowHItemSendGet(hWndDlg);
+ tvi.pszText=tszPhone;
+ tvi.cchTextMax=SIZEOF(tszPhone);
+ TreeView_GetItem(GetDlgItem(hWndDlg,IDC_NUMBERSLIST),&tvi);
}
+ else GetDlgItemText(hWndDlg,IDC_ADDRESS,tszPhone,SIZEOF(szPhone));
+
+ if (ack->result == ACKRESULT_FAILED)
+ lpszErrorDescription=lpszXML;
else {
- SendSMSWindowDBAdd(hWndDlg);
- if ( SendSMSWindowMultipleGet(hWndDlg)) {
- if ( SendSMSWindowNextHItemGet(hWndDlg,SendSMSWindowHItemSendGet(hWndDlg))) {
- SendSMSWindowAsSentSet(hWndDlg);
- SendSMSWindowHItemSendSet(hWndDlg,SendSMSWindowNextHItemGet(hWndDlg,SendSMSWindowHItemSendGet(hWndDlg)));
- SendSMSWindowNext(hWndDlg);
- }
- else SendSMSWindowRemove(hWndDlg);
+ lpszErrorDescription=szBuff;
+ GetXMLFieldExBuff(lpszXML,dwXMLSize,szBuff,sizeof(szBuff),NULL,"sms_response","error","params","param",NULL);
+ }
+
+ mir_sntprintf(tszErrorMessage,SIZEOF(tszErrorMessage),TranslateT("SMS message didn't send by %S to %s because: %S"),szNetwork,tszPhone,lpszErrorDescription);
+ ShowWindow(hWndDlg,SW_SHOWNORMAL);
+ EnableWindow(hWndDlg,FALSE);
+ HWND hwndTimeOut=CreateDialog(ssSMSSettings.hInstance,MAKEINTRESOURCE(IDD_SENDSMSTIMEDOUT),hWndDlg,SMSTimedOutDlgProc);
+ SetDlgItemText(hwndTimeOut,IDC_STATUS,tszErrorMessage);
+ }
+ else {
+ SendSMSWindowDBAdd(hWndDlg);
+ if ( SendSMSWindowMultipleGet(hWndDlg)) {
+ if ( SendSMSWindowNextHItemGet(hWndDlg,SendSMSWindowHItemSendGet(hWndDlg))) {
+ SendSMSWindowAsSentSet(hWndDlg);
+ SendSMSWindowHItemSendSet(hWndDlg,SendSMSWindowNextHItemGet(hWndDlg,SendSMSWindowHItemSendGet(hWndDlg)));
+ SendSMSWindowNext(hWndDlg);
}
- else {
- if ( CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,dwDataSize,"yes",3)==CSTR_EQUAL ||
- CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,dwDataSize,"smtp",4)==CSTR_EQUAL) {
- char szSource[MAX_PATH],szMessageID[MAX_PATH];
+ else SendSMSWindowRemove(hWndDlg);
+ }
+ else {
+ if ( CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,dwDataSize,"yes",3)==CSTR_EQUAL ||
+ CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,dwDataSize,"smtp",4)==CSTR_EQUAL) {
+ char szSource[MAX_PATH],szMessageID[MAX_PATH];
- if (DB_SMS_GetByte(NULL,"ShowACK",SMS_DEFAULT_SHOWACK)) {
- HWND hwndAccepted=CreateDialog(ssSMSSettings.hInstance,MAKEINTRESOURCE(IDD_SENDSMSACCEPT),hWndDlg,SMSAcceptedDlgProc);
- if (CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,dwDataSize,"yes",3)==CSTR_EQUAL) {
- GetXMLFieldExBuff(lpszXML,dwXMLSize,szSource,sizeof(szSource),NULL,"sms_response","source",NULL);
- GetXMLFieldExBuff(lpszXML,dwXMLSize,szMessageID,sizeof(szMessageID),NULL,"sms_response","message_id",NULL);
- }
- else {
- SetDlgItemText(hwndAccepted,IDC_ST_SOURCE,TranslateT("From:"));
- SetDlgItemText(hwndAccepted,IDC_ST_MESSAGEID,TranslateT("To:"));
- GetXMLFieldExBuff(lpszXML,dwXMLSize,szSource,sizeof(szSource),NULL,"sms_response","from",NULL);
- GetXMLFieldExBuff(lpszXML,dwXMLSize,szMessageID,sizeof(szMessageID),NULL,"sms_response","to",NULL);
- }
- SetDlgItemTextA(hwndAccepted,IDC_NETWORK,szNetwork);
- SetDlgItemTextA(hwndAccepted,IDC_SOURCE,szSource);
- SetDlgItemTextA(hwndAccepted,IDC_MESSAGEID,szMessageID);
+ if (DB_SMS_GetByte(NULL,"ShowACK",SMS_DEFAULT_SHOWACK)) {
+ HWND hwndAccepted=CreateDialog(ssSMSSettings.hInstance,MAKEINTRESOURCE(IDD_SENDSMSACCEPT),hWndDlg,SMSAcceptedDlgProc);
+ if (CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,dwDataSize,"yes",3)==CSTR_EQUAL) {
+ GetXMLFieldExBuff(lpszXML,dwXMLSize,szSource,sizeof(szSource),NULL,"sms_response","source",NULL);
+ GetXMLFieldExBuff(lpszXML,dwXMLSize,szMessageID,sizeof(szMessageID),NULL,"sms_response","message_id",NULL);
+ }
+ else {
+ SetDlgItemText(hwndAccepted,IDC_ST_SOURCE,TranslateT("From:"));
+ SetDlgItemText(hwndAccepted,IDC_ST_MESSAGEID,TranslateT("To:"));
+ GetXMLFieldExBuff(lpszXML,dwXMLSize,szSource,sizeof(szSource),NULL,"sms_response","from",NULL);
+ GetXMLFieldExBuff(lpszXML,dwXMLSize,szMessageID,sizeof(szMessageID),NULL,"sms_response","to",NULL);
}
- else SendSMSWindowRemove(hWndDlg);
+ SetDlgItemTextA(hwndAccepted,IDC_NETWORK,szNetwork);
+ SetDlgItemTextA(hwndAccepted,IDC_SOURCE,szSource);
+ SetDlgItemTextA(hwndAccepted,IDC_MESSAGEID,szMessageID);
}
else SendSMSWindowRemove(hWndDlg);
}
+ else SendSMSWindowRemove(hWndDlg);
}
}
}
@@ -213,63 +217,64 @@ int handleNewMessage(WPARAM hContact, LPARAM lParam) char szServiceFunction[MAX_PATH], *pszServiceFunctionName;
TCHAR szToolTip[MAX_PATH];
HANDLE hDbEvent = (HANDLE)lParam;
-
DBEVENTINFO dbei = { sizeof(dbei) };
- if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) != -1) {
- dbei.pBlob = (PBYTE)MEMALLOC(dbei.cbBlob);
- if (dbei.pBlob) {
- CopyMemory(szServiceFunction,PROTOCOL_NAMEA,PROTOCOL_NAME_SIZE);
- pszServiceFunctionName = szServiceFunction + PROTOCOL_NAME_LEN;
+
+ if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == -1)
+ return 0;
- if (db_event_get(hDbEvent, &dbei) == 0)
- if ((dbei.flags & DBEF_SENT) == 0)
- if (dbei.eventType == ICQEVENTTYPE_SMS) {
- if (dbei.cbBlob>MIN_SMS_DBEVENT_LEN) {
- SkinPlaySound("RecvSMSMsg");
- if (DB_SMS_GetByte(NULL,"AutoPopup",0)) {
- if (RecvSMSWindowAdd(hContact,ICQEVENTTYPE_SMS,NULL,0,(LPSTR)dbei.pBlob,dbei.cbBlob))
- db_event_markRead(hContact, hDbEvent);
- }
- else {
- CopyMemory(pszServiceFunctionName,SMS_READ,sizeof(SMS_READ));
- mir_sntprintf(szToolTip,SIZEOF(szToolTip),TranslateT("SMS Message from %s"),GetContactNameW(hContact));
+ dbei.pBlob = (PBYTE)MEMALLOC(dbei.cbBlob);
+ if ( !dbei.pBlob)
+ return 0;
+ CopyMemory(szServiceFunction,PROTOCOL_NAMEA,PROTOCOL_NAME_SIZE);
+ pszServiceFunctionName = szServiceFunction + PROTOCOL_NAME_LEN;
- CLISTEVENT cle = { sizeof(cle) };
- cle.flags = CLEF_TCHAR;
- cle.hContact = hContact;
- cle.hDbEvent = hDbEvent;
- cle.hIcon = LoadSkinnedIcon(SKINICON_OTHER_SMS);
- cle.pszService = szServiceFunction;
- cle.ptszTooltip = szToolTip;
- CallService(MS_CLIST_ADDEVENT,0,(LPARAM)&cle);
- }
- }
+ if (db_event_get(hDbEvent, &dbei) == 0)
+ if ((dbei.flags & DBEF_SENT) == 0)
+ if (dbei.eventType == ICQEVENTTYPE_SMS) {
+ if (dbei.cbBlob>MIN_SMS_DBEVENT_LEN) {
+ SkinPlaySound("RecvSMSMsg");
+ if (DB_SMS_GetByte(NULL,"AutoPopup",0)) {
+ if (RecvSMSWindowAdd(hContact,ICQEVENTTYPE_SMS,NULL,0,(LPSTR)dbei.pBlob,dbei.cbBlob))
+ db_event_markRead(hContact, hDbEvent);
}
- else if (dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION) {
- SkinPlaySound("RecvSMSConfirmation");
- if (DB_SMS_GetByte(NULL, "AutoPopup", 0)) {
- if (RecvSMSWindowAdd(hContact,ICQEVENTTYPE_SMSCONFIRMATION,NULL,0,(LPSTR)dbei.pBlob,dbei.cbBlob))
- db_event_delete(hContact, &dbei);
- }
- else {
- UINT iIcon;
- if (GetDataFromMessage((LPSTR)dbei.pBlob, dbei.cbBlob, NULL, NULL, 0, NULL, &iIcon)) {
- CopyMemory(pszServiceFunctionName,SMS_READ_ACK,sizeof(SMS_READ_ACK));
- mir_sntprintf(szToolTip,SIZEOF(szToolTip),TranslateT("SMS Confirmation from %s"),GetContactNameW(hContact));
+ else {
+ CopyMemory(pszServiceFunctionName,SMS_READ,sizeof(SMS_READ));
+ mir_sntprintf(szToolTip,SIZEOF(szToolTip),TranslateT("SMS Message from %s"),GetContactNameW(hContact));
- CLISTEVENT cle = { sizeof(cle) };
- cle.flags = CLEF_TCHAR;
- cle.hContact = hContact;
- cle.hDbEvent = hDbEvent;
- cle.hIcon = (HICON)LoadImage(ssSMSSettings.hInstance,MAKEINTRESOURCE(iIcon),IMAGE_ICON,0,0,LR_SHARED);
- cle.pszService = szServiceFunction;
- cle.ptszTooltip = szToolTip;
- CallService(MS_CLIST_ADDEVENT,0,(LPARAM)&cle);
- }
- }
+ CLISTEVENT cle = { sizeof(cle) };
+ cle.flags = CLEF_TCHAR;
+ cle.hContact = hContact;
+ cle.hDbEvent = hDbEvent;
+ cle.hIcon = LoadSkinnedIcon(SKINICON_OTHER_SMS);
+ cle.pszService = szServiceFunction;
+ cle.ptszTooltip = szToolTip;
+ CallService(MS_CLIST_ADDEVENT,0,(LPARAM)&cle);
+ }
+ }
+ }
+ else if (dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION) {
+ SkinPlaySound("RecvSMSConfirmation");
+ if (DB_SMS_GetByte(NULL, "AutoPopup", 0)) {
+ if (RecvSMSWindowAdd(hContact,ICQEVENTTYPE_SMSCONFIRMATION,NULL,0,(LPSTR)dbei.pBlob,dbei.cbBlob))
+ db_event_delete(hContact, &dbei);
+ }
+ else {
+ UINT iIcon;
+ if (GetDataFromMessage((LPSTR)dbei.pBlob, dbei.cbBlob, NULL, NULL, 0, NULL, &iIcon)) {
+ CopyMemory(pszServiceFunctionName,SMS_READ_ACK,sizeof(SMS_READ_ACK));
+ mir_sntprintf(szToolTip,SIZEOF(szToolTip),TranslateT("SMS Confirmation from %s"),GetContactNameW(hContact));
+
+ CLISTEVENT cle = { sizeof(cle) };
+ cle.flags = CLEF_TCHAR;
+ cle.hContact = hContact;
+ cle.hDbEvent = hDbEvent;
+ cle.hIcon = (HICON)LoadImage(ssSMSSettings.hInstance,MAKEINTRESOURCE(iIcon),IMAGE_ICON,0,0,LR_SHARED);
+ cle.pszService = szServiceFunction;
+ cle.ptszTooltip = szToolTip;
+ CallService(MS_CLIST_ADDEVENT,0,(LPARAM)&cle);
}
- MEMFREE(dbei.pBlob);
}
}
+ MEMFREE(dbei.pBlob);
return 0;
}
diff --git a/plugins/SMS/src/recvdlg.cpp b/plugins/SMS/src/recvdlg.cpp index 2465635c36..e112ed444c 100644 --- a/plugins/SMS/src/recvdlg.cpp +++ b/plugins/SMS/src/recvdlg.cpp @@ -1,7 +1,7 @@ /*
Miranda-IM SMS Plugin
Copyright (C) 2001-2 Richard Hughes
-Copyright (C) 2007-2009 Rozhuk Ivan
+Copyright (C) 2007-2014 Rozhuk Ivan
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -168,76 +168,75 @@ INT_PTR CALLBACK RecvSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM l //The function gets void and return the window HWND
HWND RecvSMSWindowAdd(MCONTACT hContact,DWORD dwEventType,LPWSTR lpwszPhone,SIZE_T dwPhoneSize,LPSTR lpszMessage,SIZE_T dwMessageSize)
{
- HWND hRet=NULL;
+ HWND hRet = NULL;
- if ((dwPhoneSize+dwMessageSize)>MIN_SMS_DBEVENT_LEN)
- {
- LPWSTR lpwszMessage;
+ if ((dwPhoneSize + dwMessageSize) <= MIN_SMS_DBEVENT_LEN)
+ return NULL;
+
+ LPWSTR lpwszMessage;
+ lpwszMessage = (LPWSTR)MEMALLOC(((dwMessageSize + MAX_PATH) * sizeof(WCHAR)));
+ if ( !lpwszMessage)
+ return NULL;
+
+ RECV_SMS_WINDOW_DATA *prswdWindowData;
- lpwszMessage=(LPWSTR)MEMALLOC(((dwMessageSize+MAX_PATH)*sizeof(WCHAR)));
- if (lpwszMessage)
+ prswdWindowData = (RECV_SMS_WINDOW_DATA*)MEMALLOC(sizeof(RECV_SMS_WINDOW_DATA));
+ if (prswdWindowData)
+ {
+ prswdWindowData->hContact=hContact;
+ prswdWindowData->hWnd=CreateDialogParam(ssSMSSettings.hInstance,MAKEINTRESOURCE(IDD_RECVSMS),NULL,RecvSmsDlgProc,(LPARAM)prswdWindowData);
+ if (prswdWindowData->hWnd)
{
- RECV_SMS_WINDOW_DATA *prswdWindowData;
+ HICON hIcon;
+ WCHAR wszTitle[MAX_PATH]={0},wszPhoneLocal[MAX_PHONE_LEN]={0};
+ UINT iIcon;
+ LPWSTR lpwszContactDisplayName,lpwszTitlepart;
+
+ ListMTLock(&ssSMSSettings.lmtRecvSMSWindowsListMT);
+ ListMTItemAdd(&ssSMSSettings.lmtRecvSMSWindowsListMT,&prswdWindowData->lmtListMTItem,prswdWindowData);
+ ListMTUnLock(&ssSMSSettings.lmtRecvSMSWindowsListMT);
+
+ switch(dwEventType){
+ case ICQEVENTTYPE_SMS:
+ lpwszTitlepart=TranslateT("Received SMS");
+ hIcon=LoadSkinnedIcon(SKINICON_OTHER_SMS);
+ break;
+ case ICQEVENTTYPE_SMSCONFIRMATION:
+ lpwszTitlepart=TranslateT("Received SMS Confirmation");
+ GetDataFromMessage(lpszMessage,dwMessageSize,NULL,NULL,0,NULL,&iIcon);
+ hIcon=(HICON)LoadImage(ssSMSSettings.hInstance,MAKEINTRESOURCE(iIcon),IMAGE_ICON,0,0,LR_SHARED);
+ break;
+ default:
+ lpwszTitlepart=_T("Unknown event type");
+ }
- prswdWindowData=(RECV_SMS_WINDOW_DATA*)MEMALLOC(sizeof(RECV_SMS_WINDOW_DATA));
- if (prswdWindowData)
+ wszPhoneLocal[0]='+';
+ if (dwPhoneSize)
{
- prswdWindowData->hContact=hContact;
- prswdWindowData->hWnd=CreateDialogParam(ssSMSSettings.hInstance,MAKEINTRESOURCE(IDD_RECVSMS),NULL,RecvSmsDlgProc,(LPARAM)prswdWindowData);
- if (prswdWindowData->hWnd)
- {
- HICON hIcon;
- WCHAR wszTitle[MAX_PATH]={0},wszPhoneLocal[MAX_PHONE_LEN]={0};
- UINT iIcon;
- LPWSTR lpwszContactDisplayName,lpwszTitlepart;
-
- ListMTLock(&ssSMSSettings.lmtRecvSMSWindowsListMT);
- ListMTItemAdd(&ssSMSSettings.lmtRecvSMSWindowsListMT,&prswdWindowData->lmtListMTItem,prswdWindowData);
- ListMTUnLock(&ssSMSSettings.lmtRecvSMSWindowsListMT);
-
- switch(dwEventType){
- case ICQEVENTTYPE_SMS:
- lpwszTitlepart=TranslateT("Received SMS");
- hIcon=LoadSkinnedIcon(SKINICON_OTHER_SMS);
- break;
- case ICQEVENTTYPE_SMSCONFIRMATION:
- lpwszTitlepart=TranslateT("Received SMS Confirmation");
- GetDataFromMessage(lpszMessage,dwMessageSize,NULL,NULL,0,NULL,&iIcon);
- hIcon=(HICON)LoadImage(ssSMSSettings.hInstance,MAKEINTRESOURCE(iIcon),IMAGE_ICON,0,0,LR_SHARED);
- break;
- default:
- lpwszTitlepart=_T("Unknown event type");
- }
-
- wszPhoneLocal[0]='+';
- if (dwPhoneSize)
- {
- dwPhoneSize=CopyNumberW((wszPhoneLocal+1),lpwszPhone,dwPhoneSize);
- }else{
- GetDataFromMessage(lpszMessage,dwMessageSize,NULL,(wszPhoneLocal+1),(SIZEOF(wszPhoneLocal)-1),&dwPhoneSize,NULL);
- dwPhoneSize++;
- }
-
- lpwszContactDisplayName=GetContactNameW(hContact);
- mir_sntprintf(wszTitle,SIZEOF(wszTitle),_T("%s - %s"),lpwszContactDisplayName,lpwszTitlepart);
- MultiByteToWideChar(CP_UTF8,0,lpszMessage,dwMessageSize,lpwszMessage,(dwMessageSize+MAX_PATH));
-
- SendMessageW(prswdWindowData->hWnd,WM_SETTEXT,NULL,(LPARAM)wszTitle);
- SetDlgItemText(prswdWindowData->hWnd,IDC_NAME,lpwszContactDisplayName);
- SetDlgItemText(prswdWindowData->hWnd,IDC_NUMBER,wszPhoneLocal);
- SetDlgItemText(prswdWindowData->hWnd,IDC_MESSAGE,lpwszMessage);
- SendMessage(prswdWindowData->hWnd,WM_SETICON,ICON_BIG,(LPARAM)hIcon);
-
- SetFocus(GetDlgItem(prswdWindowData->hWnd,IDC_MESSAGE));
- hRet=prswdWindowData->hWnd;
- }else{
- MEMFREE(prswdWindowData);
- }
+ dwPhoneSize=CopyNumberW((wszPhoneLocal+1),lpwszPhone,dwPhoneSize);
+ }else{
+ GetDataFromMessage(lpszMessage,dwMessageSize,NULL,(wszPhoneLocal+1),(SIZEOF(wszPhoneLocal)-1),&dwPhoneSize,NULL);
+ dwPhoneSize++;
}
- MEMFREE(lpwszMessage);
+
+ lpwszContactDisplayName=GetContactNameW(hContact);
+ mir_sntprintf(wszTitle,SIZEOF(wszTitle),_T("%s - %s"),lpwszContactDisplayName,lpwszTitlepart);
+ MultiByteToWideChar(CP_UTF8,0,lpszMessage,dwMessageSize,lpwszMessage,(dwMessageSize+MAX_PATH));
+
+ SendMessageW(prswdWindowData->hWnd,WM_SETTEXT,NULL,(LPARAM)wszTitle);
+ SetDlgItemText(prswdWindowData->hWnd,IDC_NAME,lpwszContactDisplayName);
+ SetDlgItemText(prswdWindowData->hWnd,IDC_NUMBER,wszPhoneLocal);
+ SetDlgItemText(prswdWindowData->hWnd,IDC_MESSAGE,lpwszMessage);
+ SendMessage(prswdWindowData->hWnd,WM_SETICON,ICON_BIG,(LPARAM)hIcon);
+
+ SetFocus(GetDlgItem(prswdWindowData->hWnd,IDC_MESSAGE));
+ hRet=prswdWindowData->hWnd;
+ }else{
+ MEMFREE(prswdWindowData);
}
}
-return(hRet);
+ MEMFREE(lpwszMessage);
+ return(hRet);
}
//This function close the SMS receive window that given, and remove it from the list.
diff --git a/plugins/SMS/src/send.cpp b/plugins/SMS/src/send.cpp index f843707d15..0626216c9b 100644 --- a/plugins/SMS/src/send.cpp +++ b/plugins/SMS/src/send.cpp @@ -1,7 +1,7 @@ /*
Miranda-IM SMS Plugin
Copyright (C) 2001-2 Richard Hughes
-Copyright (C) 2007-2009 Rozhuk Ivan
+Copyright (C) 2007-2014 Rozhuk Ivan
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -30,55 +30,53 @@ Enjoy the code and use it smartly! //This function gets HWND of the window, the number, and the message.
void StartSmsSend(HWND hWndDlg,SIZE_T dwModuleIndex,LPWSTR lpwszPhone,SIZE_T dwPhoneSize,LPWSTR lpwszMessage,SIZE_T dwMessageSize)
{
- if (ssSMSSettings.ppaSMSAccounts && dwModuleIndex!=-1 && dwModuleIndex<ssSMSSettings.dwSMSAccountsCount)
- {
- LPSTR lpszMessageUTF;
- LPWSTR lpwszMessageXMLEncoded;
- SIZE_T dwMessageUTFBuffSize,dwMessageXMLEncodedSize,dwBuffSize;
- DBEVENTINFO *pdbei;
+ if ( !ssSMSSettings.ppaSMSAccounts || dwModuleIndex == -1 || dwModuleIndex >= ssSMSSettings.dwSMSAccountsCount)
+ return;
- dwMessageXMLEncodedSize=((dwMessageSize+MAX_PATH)*sizeof(WCHAR)*6);
- lpwszMessageXMLEncoded=(LPWSTR)MEMALLOC(dwMessageXMLEncodedSize);
- if (lpwszMessageXMLEncoded)
- {
- EncodeXML(lpwszMessage,dwMessageSize,lpwszMessageXMLEncoded,(dwMessageXMLEncodedSize/sizeof(WCHAR)),&dwMessageXMLEncodedSize);
+ LPSTR lpszMessageUTF;
+ LPWSTR lpwszMessageXMLEncoded;
+ SIZE_T dwMessageUTFBuffSize, dwMessageXMLEncodedSize, dwBuffSize;
+ DBEVENTINFO *pdbei;
+
+ dwMessageXMLEncodedSize = ((dwMessageSize + MAX_PATH) * sizeof(WCHAR) * 6);
+ lpwszMessageXMLEncoded = (LPWSTR)MEMALLOC(dwMessageXMLEncodedSize);
+ if ( !lpwszMessageXMLEncoded)
+ return;
+
+ EncodeXML(lpwszMessage, dwMessageSize, lpwszMessageXMLEncoded, (dwMessageXMLEncodedSize / sizeof(WCHAR)), &dwMessageXMLEncodedSize);
- dwMessageUTFBuffSize=(dwMessageXMLEncodedSize+MAX_PATH);
- lpszMessageUTF=(LPSTR)MEMALLOC(dwMessageUTFBuffSize);
- if (lpszMessageUTF)
- {
- dwBuffSize=(dwPhoneSize+MAX_PATH+WideCharToMultiByte(CP_UTF8,0,lpwszMessage,dwMessageSize,lpszMessageUTF,dwMessageUTFBuffSize,NULL,NULL));
- pdbei=(DBEVENTINFO*)MEMALLOC((sizeof(DBEVENTINFO)+dwBuffSize));
- if (pdbei)
- {
- char szPhone[MAX_PHONE_LEN];
- LPSTR lpszBuff=(LPSTR)(pdbei+1);
- HANDLE hProcess;
+ dwMessageUTFBuffSize = (dwMessageXMLEncodedSize + MAX_PATH);
+ lpszMessageUTF = (LPSTR)MEMALLOC(dwMessageUTFBuffSize);
+ if (lpszMessageUTF)
+ {
+ dwBuffSize = (dwPhoneSize + MAX_PATH+WideCharToMultiByte(CP_UTF8, 0, lpwszMessage, dwMessageSize, lpszMessageUTF, dwMessageUTFBuffSize, NULL, NULL));
+ pdbei = (DBEVENTINFO*)MEMALLOC((sizeof(DBEVENTINFO) + dwBuffSize));
+ if (pdbei)
+ {
+ char szPhone[MAX_PHONE_LEN];
+ LPSTR lpszBuff = (LPSTR)(pdbei + 1);
+ HANDLE hProcess;
- WideCharToMultiByte(CP_UTF8,0,lpwszPhone,dwPhoneSize,szPhone,MAX_PHONE_LEN,NULL,NULL);
- dwPhoneSize=CopyNumberA(szPhone,szPhone,dwPhoneSize);
+ WideCharToMultiByte(CP_UTF8, 0, lpwszPhone, dwPhoneSize, szPhone, MAX_PHONE_LEN, NULL, NULL);
+ dwPhoneSize=CopyNumberA(szPhone, szPhone, dwPhoneSize);
- pdbei->timestamp=time(NULL);
- pdbei->flags=(DBEF_SENT|DBEF_UTF);
- pdbei->eventType=ICQEVENTTYPE_SMS;
- pdbei->cbBlob=(mir_snprintf(lpszBuff,dwBuffSize,"SMS To: +%s\r\n%s",szPhone,lpszMessageUTF)+4);
- pdbei->pBlob=(PBYTE)lpszBuff;
- SendSMSWindowDbeiSet(hWndDlg,pdbei);
+ pdbei->timestamp = time(NULL);
+ pdbei->flags = (DBEF_SENT | DBEF_UTF);
+ pdbei->eventType = ICQEVENTTYPE_SMS;
+ pdbei->cbBlob = (mir_snprintf(lpszBuff, dwBuffSize, "SMS To: +%s\r\n%s", szPhone, lpszMessageUTF) + 4);
+ pdbei->pBlob = (PBYTE)lpszBuff;
+ SendSMSWindowDbeiSet(hWndDlg, pdbei);
- char *szProto = ssSMSSettings.ppaSMSAccounts[dwModuleIndex]->szModuleName;
- if ( ProtoServiceExists(szProto, MS_ICQ_SENDSMS)) {
- WideCharToMultiByte(CP_UTF8,0,lpwszMessageXMLEncoded,dwMessageXMLEncodedSize,lpszMessageUTF,dwMessageUTFBuffSize,NULL,NULL);
- hProcess = (HANDLE)ProtoCallService(szProto, MS_ICQ_SENDSMS, (WPARAM)szPhone,(LPARAM)lpszMessageUTF);
- SendSMSWindowHProcessSet(hWndDlg,hProcess);
- }
- else MEMFREE(pdbei);
- }
- MEMFREE(lpszMessageUTF);
+ char *szProto = ssSMSSettings.ppaSMSAccounts[dwModuleIndex]->szModuleName;
+ if ( ProtoServiceExists(szProto, MS_ICQ_SENDSMS)) {
+ WideCharToMultiByte(CP_UTF8, 0, lpwszMessageXMLEncoded, dwMessageXMLEncodedSize, lpszMessageUTF, dwMessageUTFBuffSize, NULL, NULL);
+ hProcess = (HANDLE)ProtoCallService(szProto, MS_ICQ_SENDSMS, (WPARAM)szPhone, (LPARAM)lpszMessageUTF);
+ SendSMSWindowHProcessSet(hWndDlg, hProcess);
}
- MEMFREE(lpwszMessageXMLEncoded);
+ else MEMFREE(pdbei);
}
+ MEMFREE(lpszMessageUTF);
}
+ MEMFREE(lpwszMessageXMLEncoded);
}
-
-
diff --git a/plugins/SMS/src/senddlg.cpp b/plugins/SMS/src/senddlg.cpp index 3f2d7f3543..709055160e 100644 --- a/plugins/SMS/src/senddlg.cpp +++ b/plugins/SMS/src/senddlg.cpp @@ -1,7 +1,7 @@ /*
Miranda-IM SMS Plugin
Copyright (C) 2001-2 Richard Hughes
-Copyright (C) 2007-2009 Rozhuk Ivan
+Copyright (C) 2007-2014 Rozhuk Ivan
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -561,28 +561,28 @@ INT_PTR CALLBACK SMSAcceptedDlgProc(HWND hWndDlg,UINT msg,WPARAM wParam,LPARAM l //The function gets void and return the window HWND
HWND SendSMSWindowAdd(MCONTACT hContact)
{
- HWND hRet=NULL;
+ HWND hRet = NULL;
SEND_SMS_WINDOW_DATA *psswdWindowData=(SEND_SMS_WINDOW_DATA*)MEMALLOC(sizeof(SEND_SMS_WINDOW_DATA));
- if (psswdWindowData) {
- psswdWindowData->hMyContact = hContact;
- psswdWindowData->hWnd = CreateDialogParam(ssSMSSettings.hInstance, MAKEINTRESOURCE(IDD_SENDSMS), NULL, SendSmsDlgProc, (LPARAM)psswdWindowData);
- if (psswdWindowData->hWnd) {
- ListMTLock(&ssSMSSettings.lmtSendSMSWindowsListMT);
- ListMTItemAdd(&ssSMSSettings.lmtSendSMSWindowsListMT,&psswdWindowData->lmtListMTItem,psswdWindowData);
- ListMTUnLock(&ssSMSSettings.lmtSendSMSWindowsListMT);
-
- LPTSTR lptszContactDisplayName=GetContactNameW(hContact);
- TCHAR tszTitle[MAX_PATH];
- mir_sntprintf(tszTitle, SIZEOF(tszTitle), _T("%s - %s"), lptszContactDisplayName, TranslateT("Send SMS"));
- SetWindowText(psswdWindowData->hWnd,tszTitle);
- SendDlgItemMessage(psswdWindowData->hWnd,IDC_NAME,CB_ADDSTRING,0,(LPARAM)lptszContactDisplayName);
- SendDlgItemMessage(psswdWindowData->hWnd,IDC_NAME,CB_SETCURSEL,0,0);
- AddContactPhonesToCombo(psswdWindowData->hWnd,hContact);
- SetFocus(GetDlgItem(psswdWindowData->hWnd,IDC_MESSAGE));
- hRet=psswdWindowData->hWnd;
- }
- else MEMFREE(psswdWindowData);
+ if ( !psswdWindowData)
+ return NULL;
+ psswdWindowData->hMyContact = hContact;
+ psswdWindowData->hWnd = CreateDialogParam(ssSMSSettings.hInstance, MAKEINTRESOURCE(IDD_SENDSMS), NULL, SendSmsDlgProc, (LPARAM)psswdWindowData);
+ if (psswdWindowData->hWnd) {
+ ListMTLock(&ssSMSSettings.lmtSendSMSWindowsListMT);
+ ListMTItemAdd(&ssSMSSettings.lmtSendSMSWindowsListMT,&psswdWindowData->lmtListMTItem,psswdWindowData);
+ ListMTUnLock(&ssSMSSettings.lmtSendSMSWindowsListMT);
+
+ LPTSTR lptszContactDisplayName=GetContactNameW(hContact);
+ TCHAR tszTitle[MAX_PATH];
+ mir_sntprintf(tszTitle, SIZEOF(tszTitle), _T("%s - %s"), lptszContactDisplayName, TranslateT("Send SMS"));
+ SetWindowText(psswdWindowData->hWnd,tszTitle);
+ SendDlgItemMessage(psswdWindowData->hWnd,IDC_NAME,CB_ADDSTRING,0,(LPARAM)lptszContactDisplayName);
+ SendDlgItemMessage(psswdWindowData->hWnd,IDC_NAME,CB_SETCURSEL,0,0);
+ AddContactPhonesToCombo(psswdWindowData->hWnd,hContact);
+ SetFocus(GetDlgItem(psswdWindowData->hWnd,IDC_MESSAGE));
+ hRet=psswdWindowData->hWnd;
}
+ else MEMFREE(psswdWindowData);
return hRet;
}
@@ -674,34 +674,35 @@ void SendSMSWindowMultipleSet(HWND hWndDlg,BOOL bMultiple) {
SEND_SMS_WINDOW_DATA *psswdWindowData=GET_WINDOW_DATA(hWndDlg);
- if (psswdWindowData)
- if (psswdWindowData->bMultiple!=bMultiple)
- {
- RECT rcWin,rcList;
- WINDOWPLACEMENT wp;
+ if ( !psswdWindowData)
+ return;
+ if (psswdWindowData->bMultiple == bMultiple)
+ return;
- psswdWindowData->bMultiple=bMultiple;
- wp.length=sizeof(WINDOWPLACEMENT);
- GetWindowRect(hWndDlg,&rcWin);
- GetWindowRect(GetDlgItem(hWndDlg,IDC_NUMBERSLIST),&rcList);
- GetWindowPlacement(hWndDlg,&wp);
+ RECT rcWin,rcList;
+ WINDOWPLACEMENT wp;
- if (bMultiple)
- {
- SendSMSWindowFillTreeView(hWndDlg);
+ psswdWindowData->bMultiple=bMultiple;
+ wp.length=sizeof(WINDOWPLACEMENT);
+ GetWindowRect(hWndDlg,&rcWin);
+ GetWindowRect(GetDlgItem(hWndDlg,IDC_NUMBERSLIST),&rcList);
+ GetWindowPlacement(hWndDlg,&wp);
- EnableWindow(GetDlgItem(hWndDlg,IDC_SAVENUMBER),FALSE);
- SetDlgItemText(hWndDlg, IDC_MULTIPLE, TranslateT("<< Single"));
- if (wp.showCmd==SW_MAXIMIZE) SetWindowPos(hWndDlg, 0, 0, 0, rcWin.right - rcWin.left - (rcList.right - rcList.left + 11), rcWin.bottom - rcWin.top, SWP_NOZORDER | SWP_NOMOVE);
- SetWindowPos(hWndDlg, 0 ,rcWin.left, rcWin.top, rcWin.right - rcWin.left + (rcList.right-rcList.left) + 11, rcWin.bottom - rcWin.top, SWP_NOZORDER | SWP_NOMOVE);
- }else{
- if (psswdWindowData->hMyContact) AddContactPhonesToCombo(hWndDlg,psswdWindowData->hMyContact);
+ if (bMultiple)
+ {
+ SendSMSWindowFillTreeView(hWndDlg);
- EnableWindow(GetDlgItem(hWndDlg, IDC_SAVENUMBER), TRUE);
- SetDlgItemText(hWndDlg, IDC_MULTIPLE, TranslateT("Multiple >>"));
- SetWindowPos(hWndDlg, 0, rcWin.left, rcWin.top, rcWin.right-rcWin.left - (rcList.right-rcList.left) - 11, rcWin.bottom - rcWin.top,SWP_NOZORDER | SWP_NOMOVE);
- if (wp.showCmd==SW_MAXIMIZE) SetWindowPos(hWndDlg, 0, 0, 0, rcWin.right - rcWin.left + (rcList.right - rcList.left + 11), rcWin.bottom - rcWin.top, SWP_NOZORDER | SWP_NOMOVE);
- }
+ EnableWindow(GetDlgItem(hWndDlg,IDC_SAVENUMBER),FALSE);
+ SetDlgItemText(hWndDlg, IDC_MULTIPLE, TranslateT("<< Single"));
+ if (wp.showCmd==SW_MAXIMIZE) SetWindowPos(hWndDlg, 0, 0, 0, rcWin.right - rcWin.left - (rcList.right - rcList.left + 11), rcWin.bottom - rcWin.top, SWP_NOZORDER | SWP_NOMOVE);
+ SetWindowPos(hWndDlg, 0 ,rcWin.left, rcWin.top, rcWin.right - rcWin.left + (rcList.right-rcList.left) + 11, rcWin.bottom - rcWin.top, SWP_NOZORDER | SWP_NOMOVE);
+ }else{
+ if (psswdWindowData->hMyContact) AddContactPhonesToCombo(hWndDlg,psswdWindowData->hMyContact);
+
+ EnableWindow(GetDlgItem(hWndDlg, IDC_SAVENUMBER), TRUE);
+ SetDlgItemText(hWndDlg, IDC_MULTIPLE, TranslateT("Multiple >>"));
+ SetWindowPos(hWndDlg, 0, rcWin.left, rcWin.top, rcWin.right-rcWin.left - (rcList.right-rcList.left) - 11, rcWin.bottom - rcWin.top,SWP_NOZORDER | SWP_NOMOVE);
+ if (wp.showCmd==SW_MAXIMIZE) SetWindowPos(hWndDlg, 0, 0, 0, rcWin.right - rcWin.left + (rcList.right - rcList.left + 11), rcWin.bottom - rcWin.top, SWP_NOZORDER | SWP_NOMOVE);
}
}
@@ -870,23 +871,23 @@ void SendSMSWindowNext(HWND hWndDlg) dwMessageSize=GET_DLG_ITEM_TEXT_LENGTH(hWndDlg,IDC_MESSAGE);
LPTSTR lptszMessage=(LPTSTR)MEMALLOC(((dwMessageSize+4)*sizeof(TCHAR)));
- if (lptszMessage)
- {
- dwMessageSize=GetDlgItemText(hWndDlg,IDC_MESSAGE,lptszMessage,dwMessageSize+2);
-
- // if (SendSMSWindowNextHItemGet(hWndDlg,SendSMSWindowHItemSendGet(hWndDlg))==NULL) SendSMSWindowMultipleSet(hWndDlg,FALSE);
- tvi.mask=TVIF_TEXT;
- tvi.hItem=SendSMSWindowHItemSendGet(hWndDlg);
- tvi.pszText=tszPhone;
- tvi.cchTextMax=SIZEOF(tszPhone);
- TreeView_GetItem(GetDlgItem(hWndDlg,IDC_NUMBERSLIST),&tvi);
- TreeView_SelectItem(GetDlgItem(hWndDlg,IDC_NUMBERSLIST),tvi.hItem);
- dwPhoneSize=lstrlenW(tszPhone);
- SendSMSWindowNumberSet(hWndDlg,tszPhone,dwPhoneSize);
- StartSmsSend(hWndDlg,SendDlgItemMessage(hWndDlg,IDC_ACCOUNTS,CB_GETCURSEL,0,0),tszPhone,dwPhoneSize,lptszMessage,dwMessageSize);
- SetTimer(hWndDlg,TIMERID_MSGSEND,TIMEOUT_MSGSEND,NULL);
- MEMFREE(lptszMessage);
- }
+ if ( !lptszMessage)
+ return;
+
+ dwMessageSize=GetDlgItemText(hWndDlg,IDC_MESSAGE,lptszMessage,dwMessageSize+2);
+
+// if (SendSMSWindowNextHItemGet(hWndDlg,SendSMSWindowHItemSendGet(hWndDlg))==NULL) SendSMSWindowMultipleSet(hWndDlg,FALSE);
+ tvi.mask=TVIF_TEXT;
+ tvi.hItem=SendSMSWindowHItemSendGet(hWndDlg);
+ tvi.pszText=tszPhone;
+ tvi.cchTextMax=SIZEOF(tszPhone);
+ TreeView_GetItem(GetDlgItem(hWndDlg,IDC_NUMBERSLIST),&tvi);
+ TreeView_SelectItem(GetDlgItem(hWndDlg,IDC_NUMBERSLIST),tvi.hItem);
+ dwPhoneSize=lstrlenW(tszPhone);
+ SendSMSWindowNumberSet(hWndDlg,tszPhone,dwPhoneSize);
+ StartSmsSend(hWndDlg,SendDlgItemMessage(hWndDlg,IDC_ACCOUNTS,CB_GETCURSEL,0,0),tszPhone,dwPhoneSize,lptszMessage,dwMessageSize);
+ SetTimer(hWndDlg,TIMERID_MSGSEND,TIMEOUT_MSGSEND,NULL);
+ MEMFREE(lptszMessage);
}
@@ -899,31 +900,32 @@ void SendSMSWindowSMSContactAdd(HWND hWndDlg,MCONTACT hContact) {
SEND_SMS_WINDOW_DATA *psswdWindowData=GET_WINDOW_DATA(hWndDlg);
- if (psswdWindowData) {
- psswdWindowData->dwContactsListCount++;
- if (psswdWindowData->phContactsList)
- psswdWindowData->phContactsList = (MCONTACT*)MEMREALLOC(psswdWindowData->phContactsList,(sizeof(HANDLE)*psswdWindowData->dwContactsListCount));
- else
- psswdWindowData->phContactsList = (MCONTACT*)MEMALLOC((sizeof(HANDLE)*psswdWindowData->dwContactsListCount));
+ if ( !psswdWindowData)
+ return;
- *(psswdWindowData->phContactsList+psswdWindowData->dwContactsListCount-1)=hContact;
- }
+ psswdWindowData->dwContactsListCount++;
+ if (psswdWindowData->phContactsList)
+ psswdWindowData->phContactsList = (MCONTACT*)MEMREALLOC(psswdWindowData->phContactsList,(sizeof(HANDLE)*psswdWindowData->dwContactsListCount));
+ else
+ psswdWindowData->phContactsList = (MCONTACT*)MEMALLOC((sizeof(HANDLE)*psswdWindowData->dwContactsListCount));
+
+ *(psswdWindowData->phContactsList+psswdWindowData->dwContactsListCount-1)=hContact;
}
//This function gets the number of the given contact in the combo list and return its contact.
MCONTACT SendSMSWindowSMSContactGet(HWND hWndDlg,SIZE_T iNum)
{
- SEND_SMS_WINDOW_DATA *psswdWindowData=GET_WINDOW_DATA(hWndDlg);
+ SEND_SMS_WINDOW_DATA *psswdWindowData = GET_WINDOW_DATA(hWndDlg);
if (psswdWindowData)
- return(*((psswdWindowData->phContactsList)+iNum));
+ return (*((psswdWindowData->phContactsList) + iNum));
- return(NULL);
+ return NULL;
}
void SendSMSWindowSMSContactsRemove(HWND hWndDlg)
{
- SEND_SMS_WINDOW_DATA *psswdWindowData=GET_WINDOW_DATA(hWndDlg);
+ SEND_SMS_WINDOW_DATA *psswdWindowData = GET_WINDOW_DATA(hWndDlg);
if (psswdWindowData)
{
diff --git a/protocols/MRA/src/MraSendCommand.cpp b/protocols/MRA/src/MraSendCommand.cpp index 91e55a8401..8d5d5d47de 100644 --- a/protocols/MRA/src/MraSendCommand.cpp +++ b/protocols/MRA/src/MraSendCommand.cpp @@ -448,6 +448,7 @@ DWORD CMraProto::MraSMSW(MCONTACT hContact, const CMStringA &lpszPhone, const CM buf.SetLPS(szPhoneLocal);
buf.SetLPSW(lpwszMessage);
+ /* Save phone number for ack notify after send. */
LPBYTE lpbData = (LPBYTE)mir_calloc(lpszPhone.GetLength() + sizeof(size_t));
if (NULL == lpbData)
return (0);
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index 5ce49e47bc..3a0c9bb6c0 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -256,6 +256,7 @@ DWORD CMraProto::MraNetworkDispatcher() ProtoBroadcastAck(hContact, dwAckType, ACKRESULT_SUCCESS, (HANDLE)dwCMDNum, 0);
break;
case ICQACKTYPE_SMS:
+ ProtoBroadcastAck(NULL, dwAckType, ACKRESULT_FAILED, (HANDLE)dwCMDNum, 0);
mir_free(lpbData);
break;
}
@@ -1782,7 +1783,7 @@ DWORD CMraProto::MraRecvCommand_Message(DWORD dwTime, DWORD dwFlags, CMStringA & // found
(*lpbBufferCurPos) = 0;
- lpbBufferCurPos++;
+ lpbBufferCurPos ++;
}
ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre);
}
diff --git a/protocols/MRA/src/version.h b/protocols/MRA/src/version.h index f0bf119c1c..949589e0a1 100644 --- a/protocols/MRA/src/version.h +++ b/protocols/MRA/src/version.h @@ -8,7 +8,7 @@ #define __PLUGIN_NAME "MRA"
#define __FILENAME "MRA.dll"
#define __DESCRIPTION "Miranda Mail.ru Agent protocol plugin."
-#define __AUTHOR "Ivan Rozhuk"
+#define __AUTHOR "Rozhuk Ivan"
#define __AUTHOREMAIL "Rozhuk_I@mail.ru"
#define __AUTHORWEB "http://miranda-ng.org/p/MRA/"
-#define __COPYRIGHT "© 2005-2009 Rozhuk Ivan"
+#define __COPYRIGHT "© 2005-2014 Rozhuk Ivan"
|