diff options
author | Rozhuk Ivan <rozhuk.im@gmail.com> | 2014-03-06 01:16:01 +0000 |
---|---|---|
committer | Rozhuk Ivan <rozhuk.im@gmail.com> | 2014-03-06 01:16:01 +0000 |
commit | 522586d7b8f7274fad2fe58c2615fc0d06618fcd (patch) | |
tree | 0a1e22eacb864e035af10f11021816d83163d974 | |
parent | d5adcdbd5c1fda81f1be805dadc8021837ed706d (diff) |
MRA
* Fix: SMS sending
SMS
* Fix: windows sizes then aero enabled
* Fix: ICQEVENTTYPE_SMSCONFIRMATION db event write
NewEventNotify
+ Add: support event types: ICQEVENTTYPE_SMS and ICQEVENTTYPE_SMSCONFIRMATION
git-svn-id: http://svn.miranda-ng.org/main/trunk@8423 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/NewEventNotify/src/neweventnotify.h | 5 | ||||
-rw-r--r-- | plugins/NewEventNotify/src/popup.cpp | 34 | ||||
-rw-r--r-- | plugins/SMS/src/SMSConstans.h | 44 | ||||
-rw-r--r-- | plugins/SMS/src/receive.cpp | 7 | ||||
-rw-r--r-- | plugins/SMS/src/recvdlg.cpp | 2 | ||||
-rw-r--r-- | plugins/SMS/src/senddlg.cpp | 10 | ||||
-rw-r--r-- | protocols/MRA/src/MraProto.h | 4 | ||||
-rw-r--r-- | protocols/MRA/src/MraSendCommand.cpp | 12 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_functions.cpp | 4 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_menus.cpp | 15 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_proto.cpp | 14 | ||||
-rw-r--r-- | protocols/MRA/src/Mra_svcs.cpp | 15 |
12 files changed, 104 insertions, 62 deletions
diff --git a/plugins/NewEventNotify/src/neweventnotify.h b/plugins/NewEventNotify/src/neweventnotify.h index 521ff9083a..31e6295c3d 100644 --- a/plugins/NewEventNotify/src/neweventnotify.h +++ b/plugins/NewEventNotify/src/neweventnotify.h @@ -132,6 +132,11 @@ #define POPUP_COMMENT_AUTH LPGEN("Requests your authorization")
#define POPUP_COMMENT_WEBPAGER LPGEN("ICQ Web pager")
#define POPUP_COMMENT_EMAILEXP LPGEN("ICQ Email express")
+
+#define ICQEVENTTYPE_SMSCONFIRMATION 3001
+#define POPUP_COMMENT_SMS LPGEN("SMS Message")
+#define POPUP_COMMENT_SMSCONFIRMATION LPGEN("SMS Confirmation")
+
#define POPUP_COMMENT_OTHER LPGEN("Unknown Event")
#define MENUITEM_NAME LPGEN("Notify of new events")
diff --git a/plugins/NewEventNotify/src/popup.cpp b/plugins/NewEventNotify/src/popup.cpp index d1d196dc9e..835a05102a 100644 --- a/plugins/NewEventNotify/src/popup.cpp +++ b/plugins/NewEventNotify/src/popup.cpp @@ -334,6 +334,40 @@ static TCHAR* GetEventPreview(DBEVENTINFO *dbei) commentFix = POPUP_COMMENT_EMAILEXP;
break;
+ //blob format is:
+ //ASCIIZ text, usually of the form "SMS From: +XXXXXXXX\r\nTEXT"
+ case ICQEVENTTYPE_SMS:
+ if (dbei->pBlob) {
+ if (dbei->flags & DBEF_UTF) {
+ // utf-8 in blob
+ comment1 = mir_utf8decodeT((char*)dbei->pBlob);
+ }
+ else if (dbei->cbBlob == (_tcslen((TCHAR *)dbei->pBlob)+1)*(sizeof(TCHAR)+1)) {
+ // wchar in blob (the old hack)
+ comment1 = mir_tstrdup((TCHAR*)dbei->pBlob);
+ }
+ else comment1 = mir_a2t((char *)dbei->pBlob);
+ }
+ commentFix = POPUP_COMMENT_SMS;
+ break;
+
+ //blob format is:
+ //ASCIIZ text, usually of the form "SMS Confirmation From: +XXXXXXXXXXXX\r\nSMS was sent succesfully"
+ case ICQEVENTTYPE_SMSCONFIRMATION:
+ if (dbei->pBlob) {
+ if (dbei->flags & DBEF_UTF) {
+ // utf-8 in blob
+ comment1 = mir_utf8decodeT((char*)dbei->pBlob);
+ }
+ else if (dbei->cbBlob == (_tcslen((TCHAR *)dbei->pBlob)+1)*(sizeof(TCHAR)+1)) {
+ // wchar in blob (the old hack)
+ comment1 = mir_tstrdup((TCHAR*)dbei->pBlob);
+ }
+ else comment1 = mir_a2t((char *)dbei->pBlob);
+ }
+ commentFix = POPUP_COMMENT_SMSCONFIRMATION;
+ break;
+
default:
if (ServiceExists(MS_DB_EVENT_GETTYPE)) {
DBEVENTTYPEDESCR *pei = (DBEVENTTYPEDESCR*)CallService(MS_DB_EVENT_GETTYPE, (WPARAM)dbei->szModule, (LPARAM)dbei->eventType);
diff --git a/plugins/SMS/src/SMSConstans.h b/plugins/SMS/src/SMSConstans.h index 67159180f5..d76888d622 100644 --- a/plugins/SMS/src/SMSConstans.h +++ b/plugins/SMS/src/SMSConstans.h @@ -1,21 +1,21 @@ #if !defined(AFX_SMS_CONSTANS_H__F58D13FF_F6F2_476C_B8F0_7B9E9357CF48__INCLUDED_)
#define AFX_SMS_CONSTANS_H__F58D13FF_F6F2_476C_B8F0_7B9E9357CF48__INCLUDED_
-#define PROTOCOL_NAMEA "SMSPlugin"
-#define PROTOCOL_NAME_LEN (sizeof(PROTOCOL_NAMEA)-1)
-#define PROTOCOL_NAME_SIZE sizeof(PROTOCOL_NAMEA)
-#define PROTOCOL_DISPLAY_NAME_ORIG LPGEN("SMS")
+#define PROTOCOL_NAMEA "SMSPlugin"
+#define PROTOCOL_NAME_LEN (sizeof(PROTOCOL_NAMEA)-1)
+#define PROTOCOL_NAME_SIZE sizeof(PROTOCOL_NAMEA)
+#define PROTOCOL_DISPLAY_NAME_ORIG LPGEN("SMS")
-#define TIMEOUT_MSGSEND 60000 // send sms timeout
-#define MIN_SMS_DBEVENT_LEN 4 // для фильтрации событий авторизации от джабер плагина
-#define MAX_PHONE_LEN MAX_PATH
-#define PHONES_MIN_COUNT 4 //internal // колличество элементов обязательно проверяемых при извлечении email адреса из инфы юзера
+#define TIMEOUT_MSGSEND 60000 // send sms timeout
+#define MIN_SMS_DBEVENT_LEN 4 // для фильтрации событий авторизации от джабер плагина
+#define MAX_PHONE_LEN MAX_PATH
+#define PHONES_MIN_COUNT 4 //internal // колличество элементов обязательно проверяемых при извлечении email адреса из инфы юзера
#define SMS_DEFAULT_
#define SMS_DEFAULT_SIGNATUREPOS FALSE
-#define SMS_DEFAULT_SHOWACK TRUE
+#define SMS_DEFAULT_SHOWACK TRUE
#define SMS_DEFAULT_USESIGNATURE TRUE
-#define SMS_DEFAULT_AUTOPOP FALSE
+#define SMS_DEFAULT_AUTOPOP FALSE
#define SMS_DEFAULT_SAVEWINPOS FALSE
@@ -25,8 +25,8 @@ //Fonts defenitions
-//#define SRMMMOD "SRMM"
-#define SRMMMOD "TabSRMM_Fonts"
+//#define SRMMMOD "SRMM"
+#define SRMMMOD "TabSRMM_Fonts"
#define FONTF_BOLD 1
#define FONTF_ITALIC 2
@@ -39,16 +39,16 @@ struct FontOptionsList }
static fontOptionsList[] = {
- { RGB(106, 106, 106), _T("Arial"), 0, -12},
+ { RGB(106, 106, 106), _T("Arial"), 0, -12},
};
-#define MSGFONTID_MYMSG 0
-#define MSGFONTID_YOURMSG 2
-#define MSGFONTID_MESSAGEAREA 16
+#define MSGFONTID_MYMSG 0
+#define MSGFONTID_YOURMSG 2
+#define MSGFONTID_MESSAGEAREA 16
-#define SRMSGSET_BKGCOLOUR "BkgColour"
+#define SRMSGSET_BKGCOLOUR "BkgColour"
#define SRMSGSET_INPBKGCOLOUR "inputbg"
#define SRMSGDEFSET_BKGCOLOUR GetSysColor(COLOR_WINDOW)
#define FONTF_BOLD 1
@@ -63,11 +63,11 @@ int SendSMSMenuCommand(WPARAM wParam,LPARAM lParam); -#define SMS_READ "/ReadSms"
-#define SMS_READ_ACK "/ReadSmsAck"
-#define SMS_SEND "/SendSMS"
-#define SMS_SEND_STR LPGENT("Send &SMS...")
-#define SMS_SEND_CM_STR LPGENT("&SMS Message")
+#define SMS_READ "/ReadSms"
+#define SMS_READ_ACK "/ReadSmsAck"
+#define SMS_SEND "/SendSMS"
+#define SMS_SEND_STR LPGENT("Send &SMS...")
+#define SMS_SEND_CM_STR LPGENT("&SMS Message")
// структура содержащая информацию о сервисах/функциях
struct SERVICE_ITEM
diff --git a/plugins/SMS/src/receive.cpp b/plugins/SMS/src/receive.cpp index 6ab752776a..8e77708bd0 100644 --- a/plugins/SMS/src/receive.cpp +++ b/plugins/SMS/src/receive.cpp @@ -64,8 +64,8 @@ int handleAckSMS(WPARAM wParam,LPARAM lParam) dbei.szModule=GetModuleName(hContact);
dbei.timestamp=time(NULL);
- dbei.flags=(DBEF_UTF);
- dbei.eventType=ICQEVENTTYPE_SMS;
+ 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;
@@ -94,7 +94,8 @@ int handleAckSMS(WPARAM wParam,LPARAM lParam) dbei.cbSize=sizeof(dbei);
dbei.szModule=GetModuleName(hContact);
dbei.timestamp=time(NULL);
- dbei.eventType=ICQEVENTTYPE_SMSCONFIRMATION;
+ 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);
diff --git a/plugins/SMS/src/recvdlg.cpp b/plugins/SMS/src/recvdlg.cpp index db1cdf4093..2465635c36 100644 --- a/plugins/SMS/src/recvdlg.cpp +++ b/plugins/SMS/src/recvdlg.cpp @@ -117,6 +117,8 @@ INT_PTR CALLBACK RecvSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM l GetWindowRect(hWndDlg,&rcWin);
cx = rcWin.right - rcWin.left;
cy = rcWin.bottom - rcWin.top;
+ cx -= 10; /* XXX: fix window sizes for aero. */
+ cy -= 10;
SetWindowPos(GetDlgItem(hWndDlg,IDC_MESSAGE),0,0,0,cx - 14,cy - 112,SWP_NOZORDER|SWP_NOMOVE);
SetWindowPos(GetDlgItem(hWndDlg,IDC_NAME),0,0,0,(cx*35)/100,20,SWP_NOZORDER|SWP_NOMOVE);
SetWindowPos(GetDlgItem(hWndDlg,IDC_NUMBER),0,cx - (cx*35)/100 - 11,5,(cx*35)/100,20,SWP_NOZORDER);
diff --git a/plugins/SMS/src/senddlg.cpp b/plugins/SMS/src/senddlg.cpp index b5a6285382..3f2d7f3543 100644 --- a/plugins/SMS/src/senddlg.cpp +++ b/plugins/SMS/src/senddlg.cpp @@ -181,12 +181,14 @@ INT_PTR CALLBACK SendSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM l GetWindowRect(hWndDlg,&rcWin);
if (psswdWindowData->bMultiple)
{
- cx=rcWin.right-rcWin.left-181;
- cy=rcWin.bottom-rcWin.top;
+ cx = rcWin.right-rcWin.left-181;
+ cy = rcWin.bottom-rcWin.top;
}else{
- cx=rcWin.right-rcWin.left;
- cy=rcWin.bottom-rcWin.top;
+ cx = rcWin.right-rcWin.left;
+ cy = rcWin.bottom-rcWin.top;
}
+ cx -= 10; /* XXX: fix window sizes for aero. */
+ cy -= 10;
SetWindowPos(GetDlgItem(hWndDlg,IDC_MESSAGE),0,0,0,cx - 14,cy - 132,SWP_NOZORDER|SWP_NOMOVE);
SetWindowPos(GetDlgItem(hWndDlg,IDC_NAME),0,0,0,(cx*35)/100,20,SWP_NOZORDER|SWP_NOMOVE);
SetWindowPos(GetDlgItem(hWndDlg,IDC_ACCOUNTS),0,0,0,(cx*35)/100,20,SWP_NOZORDER|SWP_NOMOVE);
diff --git a/protocols/MRA/src/MraProto.h b/protocols/MRA/src/MraProto.h index fe54da40f7..690e19e563 100644 --- a/protocols/MRA/src/MraProto.h +++ b/protocols/MRA/src/MraProto.h @@ -120,14 +120,14 @@ struct CMraProto : public PROTO<CMraProto> INT_PTR __cdecl MraSetListeningTo(WPARAM, LPARAM);
+ INT_PTR __cdecl MraSendSMS(WPARAM, LPARAM);
+
INT_PTR __cdecl MraSendNudge(WPARAM, LPARAM);
INT_PTR __cdecl MraGetAvatarCaps(WPARAM, LPARAM);
INT_PTR __cdecl MraGetAvatarInfo(WPARAM, LPARAM);
INT_PTR __cdecl MraGetMyAvatar(WPARAM, LPARAM);
- INT_PTR __cdecl MraSendSMS(WPARAM, LPARAM);
-
INT_PTR __cdecl MraGotoInbox(WPARAM, LPARAM);
INT_PTR __cdecl MraShowInboxStatus(WPARAM, LPARAM);
INT_PTR __cdecl MraEditProfile(WPARAM, LPARAM);
diff --git a/protocols/MRA/src/MraSendCommand.cpp b/protocols/MRA/src/MraSendCommand.cpp index 37341ba126..ed502a3cd9 100644 --- a/protocols/MRA/src/MraSendCommand.cpp +++ b/protocols/MRA/src/MraSendCommand.cpp @@ -443,14 +443,16 @@ DWORD CMraProto::MraSMSW(MCONTACT hContact, const CMStringA &lpszPhone, const CM {
CMStringA szPhoneLocal = "+" + CopyNumber(lpszPhone);
- OutBuffer buf, buf2;
+ OutBuffer buf;
buf.SetUL(0);
buf.SetLPS(szPhoneLocal);
buf.SetLPSW(lpwszMessage);
- buf2.SetLPS(szPhoneLocal);
- buf.SetLPSW(lpwszMessage);
- return MraSendQueueCMD(hSendQueueHandle, 0, hContact, ICQACKTYPE_SMS, buf2.Data(), buf2.Len(), MRIM_CS_SMS, buf.Data(), buf.Len());
+ LPBYTE lpbData = (LPBYTE)mir_calloc(lpszPhone.GetLength() + sizeof(size_t));
+ if (NULL == lpbData)
+ return (0);
+ memcpy(lpbData, lpszPhone, lpszPhone.GetLength());
+ return MraSendQueueCMD(hSendQueueHandle, 0, hContact, ICQACKTYPE_SMS, lpbData, lpszPhone.GetLength(), MRIM_CS_SMS, buf.Data(), buf.Len());
}
// Соединение с прокси
@@ -498,7 +500,7 @@ DWORD CMraProto::MraChangeUserBlogStatus(DWORD dwFlags, const CMStringW &wszText DWORD CMraProto::MraSendPacket(HANDLE m_hConnection, DWORD dwCMDNum, DWORD dwType, LPVOID lpData, size_t dwDataSize)
{
- LPBYTE lpbData = (LPBYTE)_alloca(dwDataSize+sizeof(mrim_packet_header_t));
+ LPBYTE lpbData = (LPBYTE)_alloca(dwDataSize + sizeof(mrim_packet_header_t));
mrim_packet_header_t *pmaHeader = (mrim_packet_header_t*)lpbData;
memset(pmaHeader, 0, sizeof(mrim_packet_header_t));
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index 22def539cd..56d22b66a5 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -1455,7 +1455,7 @@ static const size_t dwXMLSymbolsCount[] = { sizeof(TCHAR), sizeof(TCHAR), sizeof //Decode XML coded string. The function translate special xml code into standard characters.
CMStringW DecodeXML(const CMStringW &lptszMessage)
{
- CMStringW ret('\0', lptszMessage.GetLength());
+ CMStringW ret('\0', (lptszMessage.GetLength() * 4));
ReplaceInBuff((void*)lptszMessage.GetString(), lptszMessage.GetLength()*sizeof(TCHAR), SIZEOF(lpszXMLTags), (LPVOID*)lpszXMLTags, (size_t*)dwXMLTagsCount, (LPVOID*)lpszXMLSymbols, (size_t*)dwXMLSymbolsCount, ret);
return ret;
}
@@ -1463,7 +1463,7 @@ CMStringW DecodeXML(const CMStringW &lptszMessage) //Encode XML coded string. The function translate special saved xml characters into special characters.
CMStringW EncodeXML(const CMStringW &lptszMessage)
{
- CMStringW ret;
+ CMStringW ret('\0', (lptszMessage.GetLength() * 4));
ReplaceInBuff((void*)lptszMessage.GetString(), lptszMessage.GetLength()*sizeof(TCHAR), SIZEOF(lpszXMLTags), (LPVOID*)lpszXMLSymbols, (size_t*)dwXMLSymbolsCount, (LPVOID*)lpszXMLTags, (size_t*)dwXMLTagsCount, ret);
return ret;
}
diff --git a/protocols/MRA/src/Mra_menus.cpp b/protocols/MRA/src/Mra_menus.cpp index c1a0261516..d8dc3c9e33 100644 --- a/protocols/MRA/src/Mra_menus.cpp +++ b/protocols/MRA/src/Mra_menus.cpp @@ -13,21 +13,6 @@ INT_PTR CMraProto::MraShowInboxStatus(WPARAM wParam, LPARAM lParam) return 0;
}
-INT_PTR CMraProto::MraSendSMS(WPARAM wParam, LPARAM lParam)
-{
- if (!m_bLoggedIn || !wParam || !lParam)
- return 0;
-
- ptrW lpwszMessageXMLEncoded(mir_utf8decodeW((LPSTR)lParam));
- if (lpwszMessageXMLEncoded) {
- CMStringW decoded = DecodeXML(CMStringW(lpwszMessageXMLEncoded));
- if (decoded.GetLength())
- MraSMSW(NULL, CMStringA((LPSTR)wParam), decoded);
- }
-
- return 0;
-}
-
INT_PTR CMraProto::MraEditProfile(WPARAM wParam, LPARAM lParam)
{
MraMPopSessionQueueAddUrl(hMPopSessionQueue, MRA_EDIT_PROFILE_URL);
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp index 9fcea8eeb0..e1840dc275 100644 --- a/protocols/MRA/src/Mra_proto.cpp +++ b/protocols/MRA/src/Mra_proto.cpp @@ -1520,19 +1520,15 @@ bool CMraProto::MraCommandDispatcher(mrim_packet_header_t *pmaHeader) case MRIM_CS_SMS_ACK:
buf >> dwTemp;
if (MraSendQueueFind(hSendQueueHandle, pmaHeader->seq, NULL, &hContact, &dwAckType, &pByte, &dwSize) == NO_ERROR) {
+ /* pByte point to phone number ansi string. */
+ /* dwAckType = ICQACKTYPE_SMS */
CMStringA szEmail;
if (mraGetStringA(NULL, "e-mail", szEmail)) {
- DWORD dwPhoneSize = *(DWORD*)pByte;
- DWORD dwMessageSize = dwSize - (dwPhoneSize + sizeof(DWORD)+2);
- LPSTR lpszPhone = (LPSTR)pByte + sizeof(DWORD);
- LPWSTR lpwszMessage = (LPWSTR)(lpszPhone + dwPhoneSize + 1);
-
- mir_snprintf((LPSTR)szBuff, SIZEOF(szBuff),
+ mir_snprintf((LPSTR)szBuff, sizeof(szBuff),
"<sms_response><source>Mail.ru</source><deliverable>Yes</deliverable><network>Mail.ru, Russia</network><message_id>%s-1-1955988055-%s</message_id><destination>%s</destination><messages_left>0</messages_left></sms_response>\r\n",
- szEmail.c_str(), lpszPhone, lpszPhone);
- ProtoBroadcastAck(NULL, dwAckType, ACKRESULT_SENTREQUEST, (HANDLE)pmaHeader->seq, (LPARAM)szBuff);
+ szEmail.c_str(), (LPSTR)pByte, (LPSTR)pByte);
+ ProtoBroadcastAck(NULL, ICQACKTYPE_SMS, ACKRESULT_SENTREQUEST, (HANDLE)pmaHeader->seq, (LPARAM)szBuff);
}
-
mir_free(pByte);
MraSendQueueFree(hSendQueueHandle, pmaHeader->seq);
}
diff --git a/protocols/MRA/src/Mra_svcs.cpp b/protocols/MRA/src/Mra_svcs.cpp index 1ffb37e18e..73b1401a55 100644 --- a/protocols/MRA/src/Mra_svcs.cpp +++ b/protocols/MRA/src/Mra_svcs.cpp @@ -542,6 +542,21 @@ DWORD CMraProto::MraSendNewStatus(DWORD dwStatusMir, DWORD dwXStatusMir, const C return 0;
}
+INT_PTR CMraProto::MraSendSMS(WPARAM wParam, LPARAM lParam)
+{
+ if (!m_bLoggedIn || !wParam || !lParam)
+ return 0;
+
+ ptrW lpwszMessageXMLEncoded(mir_utf8decodeW((LPSTR)lParam));
+ if (lpwszMessageXMLEncoded) {
+ CMStringW decoded = DecodeXML(CMStringW(lpwszMessageXMLEncoded));
+ if (decoded.GetLength())
+ return (MraSMSW(NULL, CMStringA((LPSTR)wParam), decoded));
+ }
+
+ return 0;
+}
+
INT_PTR CMraProto::MraSendNudge(WPARAM hContact, LPARAM lParam)
{
if (m_bLoggedIn && hContact) {
|