diff options
author | George Hazan <george.hazan@gmail.com> | 2015-08-28 16:22:41 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-08-28 16:22:41 +0000 |
commit | c370af60855db957c5b200914bf0bde743845528 (patch) | |
tree | 0bd2ef127097c9e937c2650e8b202c3f09453323 /plugins/SMS | |
parent | 7f082bd5d4865c30b313661b7a02f048b4b137be (diff) |
mir_sntprintf / mir_snprintf: obsoleted second parameter removed wherever possible
git-svn-id: http://svn.miranda-ng.org/main/trunk@15064 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SMS')
-rw-r--r-- | plugins/SMS/src/SMS_svc.cpp | 72 | ||||
-rw-r--r-- | plugins/SMS/src/functions.cpp | 433 | ||||
-rw-r--r-- | plugins/SMS/src/receive.cpp | 280 | ||||
-rw-r--r-- | plugins/SMS/src/recvdlg.cpp | 2 | ||||
-rw-r--r-- | plugins/SMS/src/senddlg.cpp | 14 |
5 files changed, 392 insertions, 409 deletions
diff --git a/plugins/SMS/src/SMS_svc.cpp b/plugins/SMS/src/SMS_svc.cpp index 474a9194d4..2e19ef232f 100644 --- a/plugins/SMS/src/SMS_svc.cpp +++ b/plugins/SMS/src/SMS_svc.cpp @@ -2,16 +2,15 @@ int LoadServices(void)
{
- char szServiceFunction[MAX_PATH],*pszServiceFunctionName;
+ char szServiceFunction[MAX_PATH], *pszServiceFunctionName;
- memcpy(szServiceFunction,PROTOCOL_NAMEA,PROTOCOL_NAME_SIZE);
- pszServiceFunctionName=szServiceFunction+PROTOCOL_NAME_LEN;
+ memcpy(szServiceFunction, PROTOCOL_NAMEA, PROTOCOL_NAME_SIZE);
+ pszServiceFunctionName = szServiceFunction + PROTOCOL_NAME_LEN;
// Service creation
- for (size_t i=0;i<_countof(siPluginServices);i++)
- {
- memcpy(pszServiceFunctionName,siPluginServices[i].lpszName,(mir_strlen(siPluginServices[i].lpszName)+1));
- CreateServiceFunction(szServiceFunction,(MIRANDASERVICE)siPluginServices[i].lpFunc);
+ for (size_t i = 0; i < _countof(siPluginServices); i++) {
+ memcpy(pszServiceFunctionName, siPluginServices[i].lpszName, (mir_strlen(siPluginServices[i].lpszName) + 1));
+ CreateServiceFunction(szServiceFunction, (MIRANDASERVICE)siPluginServices[i].lpFunc);
}
return 0;
}
@@ -19,14 +18,14 @@ int LoadServices(void) int LoadModules(void)
{
- HookEvent(ME_OPT_INITIALISE,OptInitialise);
- HookEvent(ME_CLIST_PREBUILDCONTACTMENU,SmsRebuildContactMenu);
- HookEvent(ME_PROTO_ACK,handleAckSMS);
- HookEvent(ME_DB_EVENT_ADDED,handleNewMessage);
- HookEvent(ME_PROTO_ACCLISTCHANGED,RefreshAccountList);
+ HookEvent(ME_OPT_INITIALISE, OptInitialise);
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, SmsRebuildContactMenu);
+ HookEvent(ME_PROTO_ACK, handleAckSMS);
+ HookEvent(ME_DB_EVENT_ADDED, handleNewMessage);
+ HookEvent(ME_PROTO_ACCLISTCHANGED, RefreshAccountList);
char szServiceFunction[MAX_PATH];
- mir_snprintf(szServiceFunction,_countof(szServiceFunction),"%s%s",PROTOCOL_NAMEA,SMS_SEND);
+ mir_snprintf(szServiceFunction, "%s%s", PROTOCOL_NAMEA, SMS_SEND);
CMenuItem mi;
mi.position = 300050000;
@@ -40,13 +39,13 @@ int LoadModules(void) mi.hIcolibItem = Skin_LoadIcon(SKINICON_OTHER_SMS);
mi.name.t = SMS_SEND_CM_STR;
mi.pszService = szServiceFunction;
- mi.flags = CMIF_TCHAR;
+ mi.flags = CMIF_TCHAR;
ssSMSSettings.hContactMenuItems[0] = Menu_AddContactMenuItem(&mi);
- SkinAddNewSoundEx("RecvSMSMsg",PROTOCOL_NAMEA,LPGEN("Incoming SMS Message"));
- SkinAddNewSoundEx("RecvSMSConfirmation",PROTOCOL_NAMEA,LPGEN("Incoming SMS Confirmation"));
+ SkinAddNewSoundEx("RecvSMSMsg", PROTOCOL_NAMEA, LPGEN("Incoming SMS Message"));
+ SkinAddNewSoundEx("RecvSMSConfirmation", PROTOCOL_NAMEA, LPGEN("Incoming SMS Confirmation"));
- RefreshAccountList(NULL,NULL);
+ RefreshAccountList(NULL, NULL);
RestoreUnreadMessageAlerts();
return 0;
@@ -72,23 +71,22 @@ int SendSMSMenuCommand(WPARAM wParam, LPARAM) hwndSendSms = SendSMSWindowAdd(wParam);
}
// user clicked on the "SMS Send" in the Main Menu
- else{
+ else {
hwndSendSms = SendSMSWindowAdd(NULL);
- EnableWindow(GetDlgItem(hwndSendSms,IDC_NAME),TRUE);
- EnableWindow(GetDlgItem(hwndSendSms,IDC_SAVENUMBER),FALSE);
+ EnableWindow(GetDlgItem(hwndSendSms, IDC_NAME), TRUE);
+ EnableWindow(GetDlgItem(hwndSendSms, IDC_SAVENUMBER), FALSE);
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (GetContactPhonesCount(hContact)) {
SendDlgItemMessage(hwndSendSms, IDC_NAME, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetContactDisplayName(hContact, 0));
- SendSMSWindowSMSContactAdd(hwndSendSms,hContact);
+ SendSMSWindowSMSContactAdd(hwndSendSms, hContact);
}
}
}
return 0;
}
-
-//This function used to popup a read SMS window after the user clicked on the received SMS message.
+// This function used to popup a read SMS window after the user clicked on the received SMS message.
int ReadMsgSMS(WPARAM, LPARAM lParam)
{
CLISTEVENT *cle = (CLISTEVENT*)lParam;
@@ -99,17 +97,17 @@ int ReadMsgSMS(WPARAM, LPARAM lParam) 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.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;
}
-//This function used to popup a read SMS window after the user clicked on the received SMS confirmation.
+// This function used to popup a read SMS window after the user clicked on the received SMS confirmation.
int ReadAckSMS(WPARAM, LPARAM lParam)
{
CLISTEVENT *cle = (CLISTEVENT*)lParam;
@@ -138,16 +136,16 @@ void RestoreUnreadMessageAlerts(void) for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) {
dbei.cbBlob = 0;
if (db_event_get(hDbEvent, &dbei) == 0)
- if ((dbei.flags & (DBEF_SENT|DBEF_READ))==0 && ((dbei.eventType==ICQEVENTTYPE_SMS) || (dbei.eventType==ICQEVENTTYPE_SMSCONFIRMATION)))
- if (dbei.cbBlob>MIN_SMS_DBEVENT_LEN)
- handleNewMessage(hContact,(LPARAM)hDbEvent);
+ if ((dbei.flags & (DBEF_SENT | DBEF_READ)) == 0 && ((dbei.eventType == ICQEVENTTYPE_SMS) || (dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION)))
+ if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN)
+ handleNewMessage(hContact, (LPARAM)hDbEvent);
}
for (MEVENT hDbEvent = db_event_firstUnread(NULL); hDbEvent; hDbEvent = db_event_next(NULL, hDbEvent)) {
dbei.cbBlob = 0;
if (db_event_get(hDbEvent, &dbei) == 0)
- if ((dbei.flags & (DBEF_SENT|DBEF_READ))==0 && ((dbei.eventType==ICQEVENTTYPE_SMS) || (dbei.eventType==ICQEVENTTYPE_SMSCONFIRMATION)))
- if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN)
- handleNewMessage(NULL, (LPARAM)hDbEvent);
+ if ((dbei.flags & (DBEF_SENT | DBEF_READ)) == 0 && ((dbei.eventType == ICQEVENTTYPE_SMS) || (dbei.eventType == ICQEVENTTYPE_SMSCONFIRMATION)))
+ if (dbei.cbBlob > MIN_SMS_DBEVENT_LEN)
+ handleNewMessage(NULL, (LPARAM)hDbEvent);
}
}
diff --git a/plugins/SMS/src/functions.cpp b/plugins/SMS/src/functions.cpp index a38af8be70..7c42dc769c 100644 --- a/plugins/SMS/src/functions.cpp +++ b/plugins/SMS/src/functions.cpp @@ -1,27 +1,27 @@ #include "stdafx.h"
-BOOL DB_GetStaticStringW(MCONTACT hContact,LPSTR lpszModule,LPSTR lpszValueName,LPWSTR lpwszRetBuff,size_t dwRetBuffSize,size_t *pdwRetBuffSize)
+BOOL DB_GetStaticStringW(MCONTACT hContact, LPSTR lpszModule, LPSTR lpszValueName, LPWSTR lpwszRetBuff, size_t dwRetBuffSize, size_t *pdwRetBuffSize)
{// sizes in wchars
- BOOL bRet=FALSE;
+ BOOL bRet = FALSE;
size_t dwReadedStringLen;
- DBVARIANT dbv={0};
- if (db_get_ws(hContact, lpszModule, lpszValueName, &dbv)==0)
- {
- dwReadedStringLen=mir_wstrlen(dbv.pwszVal);
- if (lpwszRetBuff && (dwRetBuffSize>dwReadedStringLen))
- {
- memcpy(lpwszRetBuff,dbv.pszVal,(dwReadedStringLen*sizeof(WCHAR)));//include null terminated
- (*((WCHAR*)(lpwszRetBuff+dwReadedStringLen)))=0;
- bRet=TRUE;
- }else{
- if (lpwszRetBuff && dwRetBuffSize>=sizeof(WCHAR)) (*((WCHAR*)lpwszRetBuff))=0;
+ DBVARIANT dbv = { 0 };
+ if (db_get_ws(hContact, lpszModule, lpszValueName, &dbv) == 0) {
+ dwReadedStringLen = mir_wstrlen(dbv.pwszVal);
+ if (lpwszRetBuff && (dwRetBuffSize > dwReadedStringLen)) {
+ memcpy(lpwszRetBuff, dbv.pszVal, (dwReadedStringLen*sizeof(WCHAR)));//include null terminated
+ (*((WCHAR*)(lpwszRetBuff + dwReadedStringLen))) = 0;
+ bRet = TRUE;
+ }
+ else {
+ if (lpwszRetBuff && dwRetBuffSize >= sizeof(WCHAR)) (*((WCHAR*)lpwszRetBuff)) = 0;
}
- if (pdwRetBuffSize) (*pdwRetBuffSize)=dwReadedStringLen;
+ if (pdwRetBuffSize) (*pdwRetBuffSize) = dwReadedStringLen;
db_free(&dbv);
- }else{
- if (lpwszRetBuff && dwRetBuffSize>=sizeof(WCHAR)) (*((WCHAR*)lpwszRetBuff))=0;
- if (pdwRetBuffSize) (*pdwRetBuffSize)=0;
+ }
+ else {
+ if (lpwszRetBuff && dwRetBuffSize >= sizeof(WCHAR)) (*((WCHAR*)lpwszRetBuff)) = 0;
+ if (pdwRetBuffSize) (*pdwRetBuffSize) = 0;
}
return(bRet);
}
@@ -40,73 +40,71 @@ LPSTR GetModuleName(MCONTACT hContact) return lpszRet;
}
-void EnableControlsArray(HWND hWndDlg,WORD *pwControlsList,size_t dwControlsListCount,BOOL bEnabled)
+void EnableControlsArray(HWND hWndDlg, WORD *pwControlsList, size_t dwControlsListCount, BOOL bEnabled)
{
- for(size_t i=0;i<dwControlsListCount;i++) EnableWindow(GetDlgItem(hWndDlg,pwControlsList[i]),bEnabled);
+ for (size_t i = 0; i < dwControlsListCount; i++) EnableWindow(GetDlgItem(hWndDlg, pwControlsList[i]), bEnabled);
}
//This function gets a Cellular string szPhone and clean it from symbools.
-size_t CopyNumberA(LPSTR lpszOutBuff,LPSTR lpszBuff,size_t dwLen)
+size_t CopyNumberA(LPSTR lpszOutBuff, LPSTR lpszBuff, size_t dwLen)
{
BYTE btChar;
- LPBYTE lpbOutBuff=(LPBYTE)lpszOutBuff,lpbInBuff=(LPBYTE)lpszBuff;
+ LPBYTE lpbOutBuff = (LPBYTE)lpszOutBuff, lpbInBuff = (LPBYTE)lpszBuff;
- for(size_t i=0;i<dwLen;i++)
- {
- btChar=(*lpbInBuff++);
- if (btChar>='0' && btChar<='9') (*lpbOutBuff++)=btChar;
+ for (size_t i = 0; i < dwLen; i++) {
+ btChar = (*lpbInBuff++);
+ if (btChar >= '0' && btChar <= '9') (*lpbOutBuff++) = btChar;
}
- (*lpbOutBuff)=0;
+ (*lpbOutBuff) = 0;
- return((lpbOutBuff-(LPBYTE)lpszOutBuff));
+ return((lpbOutBuff - (LPBYTE)lpszOutBuff));
}
-size_t CopyNumberW(LPWSTR lpcOutBuff,LPWSTR lpcBuff,size_t dwLen)
+size_t CopyNumberW(LPWSTR lpcOutBuff, LPWSTR lpcBuff, size_t dwLen)
{
WCHAR wChar;
- LPWSTR lpwszOutBuff=lpcOutBuff,lpwszInBuff=lpcBuff;
+ LPWSTR lpwszOutBuff = lpcOutBuff, lpwszInBuff = lpcBuff;
- for(size_t i=0;i<dwLen;i++)
- {
- wChar=(*lpwszInBuff++);
- if (wChar>='0' && wChar<='9') (*lpwszOutBuff++)=wChar;
+ for (size_t i = 0; i < dwLen; i++) {
+ wChar = (*lpwszInBuff++);
+ if (wChar >= '0' && wChar <= '9') (*lpwszOutBuff++) = wChar;
}
- (*lpwszOutBuff)=0;
+ (*lpwszOutBuff) = 0;
- return((lpwszOutBuff-lpcOutBuff));
+ return((lpwszOutBuff - lpcOutBuff));
}
-bool IsPhoneW(LPWSTR lpwszString,size_t dwStringLen)
+bool IsPhoneW(LPWSTR lpwszString, size_t dwStringLen)
{
if (dwStringLen <= 1)
return false;
- for(size_t i=0; i < dwStringLen; i++) {
- WCHAR wChar=(*lpwszString++);
+ for (size_t i = 0; i < dwStringLen; i++) {
+ WCHAR wChar = (*lpwszString++);
if (wChar<'0' || wChar>'9')
- if (wChar!='+' && wChar!='S' && wChar!='M' && wChar!=' ' && wChar!='(' && wChar!=')')
+ if (wChar != '+' && wChar != 'S' && wChar != 'M' && wChar != ' ' && wChar != '(' && wChar != ')')
return false;
}
return true;
}
-DWORD GetContactPhonesCountParam(MCONTACT hContact,LPSTR lpszModule,LPSTR lpszValueName)
+DWORD GetContactPhonesCountParam(MCONTACT hContact, LPSTR lpszModule, LPSTR lpszValueName)
{
- DWORD dwRet=0;
+ DWORD dwRet = 0;
char szBuff[MAX_PATH];
WCHAR wszPhone[MAX_PHONE_LEN];
- size_t i,dwPhoneSize;
+ size_t i, dwPhoneSize;
- if ( DB_GetStaticStringW(hContact,lpszModule,lpszValueName,wszPhone,_countof(wszPhone),&dwPhoneSize))
- if ( IsPhoneW(wszPhone,dwPhoneSize))
+ if (DB_GetStaticStringW(hContact, lpszModule, lpszValueName, wszPhone, _countof(wszPhone), &dwPhoneSize))
+ if (IsPhoneW(wszPhone, dwPhoneSize))
dwRet++;
- for (i=0; i <= PHONES_MIN_COUNT; i++) {
- mir_snprintf(szBuff,_countof(szBuff),"%s%ld",lpszValueName,i);
- if ( DB_GetStaticStringW(hContact,lpszModule,szBuff,wszPhone,_countof(wszPhone),&dwPhoneSize))
- if ( IsPhoneW(wszPhone,dwPhoneSize))
+ for (i = 0; i <= PHONES_MIN_COUNT; i++) {
+ mir_snprintf(szBuff, "%s%ld", lpszValueName, i);
+ if (DB_GetStaticStringW(hContact, lpszModule, szBuff, wszPhone, _countof(wszPhone), &dwPhoneSize))
+ if (IsPhoneW(wszPhone, dwPhoneSize))
dwRet++;
}
return dwRet;
@@ -118,61 +116,61 @@ DWORD GetContactPhonesCount(MCONTACT hContact) DWORD dwRet = 0;
LPSTR lpszProto = GetContactProto(hContact);
if (lpszProto) {
- dwRet += GetContactPhonesCountParam(hContact,lpszProto,"Phone");
- dwRet += GetContactPhonesCountParam(hContact,lpszProto,"Cellular");
- dwRet += GetContactPhonesCountParam(hContact,lpszProto,"Fax");
+ dwRet += GetContactPhonesCountParam(hContact, lpszProto, "Phone");
+ dwRet += GetContactPhonesCountParam(hContact, lpszProto, "Cellular");
+ dwRet += GetContactPhonesCountParam(hContact, lpszProto, "Fax");
}
- dwRet += GetContactPhonesCountParam(hContact,"UserInfo","MyPhone");
- dwRet += GetContactPhonesCountParam(hContact,"UserInfo","Phone");
- dwRet += GetContactPhonesCountParam(hContact,"UserInfo","Cellular");
- dwRet += GetContactPhonesCountParam(hContact,"UserInfo","Fax");
+ dwRet += GetContactPhonesCountParam(hContact, "UserInfo", "MyPhone");
+ dwRet += GetContactPhonesCountParam(hContact, "UserInfo", "Phone");
+ dwRet += GetContactPhonesCountParam(hContact, "UserInfo", "Cellular");
+ dwRet += GetContactPhonesCountParam(hContact, "UserInfo", "Fax");
return dwRet;
}
-BOOL IsContactPhoneParam(MCONTACT hContact,LPSTR lpszModule,LPSTR lpszValueName,LPWSTR lpwszPhone,size_t dwPhoneSize)
+BOOL IsContactPhoneParam(MCONTACT hContact, LPSTR lpszModule, LPSTR lpszValueName, LPWSTR lpwszPhone, size_t dwPhoneSize)
{
char szBuff[MAX_PATH];
WCHAR wszPhoneLocal[MAX_PHONE_LEN];
- size_t i,dwPhoneSizeLocal;
+ size_t i, dwPhoneSizeLocal;
- if ( DB_GetStaticStringW(hContact,lpszModule,lpszValueName,wszPhoneLocal,_countof(wszPhoneLocal),&dwPhoneSizeLocal))
- if ( IsPhoneW(wszPhoneLocal,dwPhoneSizeLocal)) {
- dwPhoneSizeLocal = CopyNumberW(wszPhoneLocal,wszPhoneLocal,dwPhoneSizeLocal);
- if (MemoryCompare(wszPhoneLocal,dwPhoneSizeLocal,lpwszPhone,dwPhoneSize)==CSTR_EQUAL)
+ if (DB_GetStaticStringW(hContact, lpszModule, lpszValueName, wszPhoneLocal, _countof(wszPhoneLocal), &dwPhoneSizeLocal))
+ if (IsPhoneW(wszPhoneLocal, dwPhoneSizeLocal)) {
+ dwPhoneSizeLocal = CopyNumberW(wszPhoneLocal, wszPhoneLocal, dwPhoneSizeLocal);
+ if (MemoryCompare(wszPhoneLocal, dwPhoneSizeLocal, lpwszPhone, dwPhoneSize) == CSTR_EQUAL)
return TRUE;
}
- for (i=0; i <= PHONES_MIN_COUNT; i++) {
- mir_snprintf(szBuff,_countof(szBuff),"%s%ld",lpszValueName,i);
- if ( DB_GetStaticStringW(hContact,lpszModule,szBuff,wszPhoneLocal,_countof(wszPhoneLocal),&dwPhoneSizeLocal)) {
- if (IsPhoneW(wszPhoneLocal,dwPhoneSizeLocal)) {
- dwPhoneSizeLocal=CopyNumberW(wszPhoneLocal,wszPhoneLocal,dwPhoneSizeLocal);
- if (MemoryCompare(wszPhoneLocal,dwPhoneSizeLocal,lpwszPhone,dwPhoneSize) == CSTR_EQUAL)
- return TRUE;
- }
+ for (i = 0; i <= PHONES_MIN_COUNT; i++) {
+ mir_snprintf(szBuff, "%s%ld", lpszValueName, i);
+ if (DB_GetStaticStringW(hContact, lpszModule, szBuff, wszPhoneLocal, _countof(wszPhoneLocal), &dwPhoneSizeLocal)) {
+ if (IsPhoneW(wszPhoneLocal, dwPhoneSizeLocal)) {
+ dwPhoneSizeLocal = CopyNumberW(wszPhoneLocal, wszPhoneLocal, dwPhoneSizeLocal);
+ if (MemoryCompare(wszPhoneLocal, dwPhoneSizeLocal, lpwszPhone, dwPhoneSize) == CSTR_EQUAL)
+ return TRUE;
}
}
- return FALSE;
+ }
+ return FALSE;
}
-BOOL IsContactPhone(MCONTACT hContact,LPWSTR lpwszPhone,size_t dwPhoneSize)
+BOOL IsContactPhone(MCONTACT hContact, LPWSTR lpwszPhone, size_t dwPhoneSize)
{
- BOOL bRet=FALSE;
+ BOOL bRet = FALSE;
WCHAR wszPhoneLocal[MAX_PHONE_LEN];
- size_t dwPhoneSizeLocal = CopyNumberW(wszPhoneLocal,lpwszPhone,dwPhoneSize);
+ size_t dwPhoneSizeLocal = CopyNumberW(wszPhoneLocal, lpwszPhone, dwPhoneSize);
LPSTR lpszProto = GetContactProto(hContact);
if (lpszProto) {
- if (bRet==FALSE) bRet=IsContactPhoneParam(hContact,lpszProto,"Phone",wszPhoneLocal,dwPhoneSizeLocal);
- if (bRet==FALSE) bRet=IsContactPhoneParam(hContact,lpszProto,"Cellular",wszPhoneLocal,dwPhoneSizeLocal);
- if (bRet==FALSE) bRet=IsContactPhoneParam(hContact,lpszProto,"Fax",wszPhoneLocal,dwPhoneSizeLocal);
+ if (bRet == FALSE) bRet = IsContactPhoneParam(hContact, lpszProto, "Phone", wszPhoneLocal, dwPhoneSizeLocal);
+ if (bRet == FALSE) bRet = IsContactPhoneParam(hContact, lpszProto, "Cellular", wszPhoneLocal, dwPhoneSizeLocal);
+ if (bRet == FALSE) bRet = IsContactPhoneParam(hContact, lpszProto, "Fax", wszPhoneLocal, dwPhoneSizeLocal);
}
- if (bRet==FALSE) bRet=IsContactPhoneParam(hContact,"UserInfo","MyPhone",wszPhoneLocal,dwPhoneSizeLocal);
- if (bRet==FALSE) bRet=IsContactPhoneParam(hContact,"UserInfo","Phone",wszPhoneLocal,dwPhoneSizeLocal);
- if (bRet==FALSE) bRet=IsContactPhoneParam(hContact,"UserInfo","Cellular",wszPhoneLocal,dwPhoneSizeLocal);
- if (bRet==FALSE) bRet=IsContactPhoneParam(hContact,"UserInfo","Fax",wszPhoneLocal,dwPhoneSizeLocal);
+ if (bRet == FALSE) bRet = IsContactPhoneParam(hContact, "UserInfo", "MyPhone", wszPhoneLocal, dwPhoneSizeLocal);
+ if (bRet == FALSE) bRet = IsContactPhoneParam(hContact, "UserInfo", "Phone", wszPhoneLocal, dwPhoneSizeLocal);
+ if (bRet == FALSE) bRet = IsContactPhoneParam(hContact, "UserInfo", "Cellular", wszPhoneLocal, dwPhoneSizeLocal);
+ if (bRet == FALSE) bRet = IsContactPhoneParam(hContact, "UserInfo", "Fax", wszPhoneLocal, dwPhoneSizeLocal);
return bRet;
}
@@ -181,12 +179,12 @@ BOOL IsContactPhone(MCONTACT hContact,LPWSTR lpwszPhone,size_t dwPhoneSize) //This function get a string cellular number and return the HANDLE of the contact that has this
//number in the miranda phonebook (and marked as an SMS able) at the User Details.
//If no one has this number function returns NULL.
-MCONTACT HContactFromPhone(LPWSTR lpwszPhone,size_t dwPhoneSize)
+MCONTACT HContactFromPhone(LPWSTR lpwszPhone, size_t dwPhoneSize)
{
if (lpwszPhone && dwPhoneSize) {
//check not already on list
for (MCONTACT hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact))
- if (IsContactPhone(hContact,lpwszPhone,dwPhoneSize))
+ if (IsContactPhone(hContact, lpwszPhone, dwPhoneSize))
return hContact;
}
@@ -194,20 +192,20 @@ MCONTACT HContactFromPhone(LPWSTR lpwszPhone,size_t dwPhoneSize) }
-BOOL GetDataFromMessage(LPSTR lpszMessage,size_t dwMessageSize,DWORD *pdwEventType,LPWSTR lpwszPhone,size_t dwPhoneSize,size_t *pdwPhoneSizeRet,UINT *piIcon)
+BOOL GetDataFromMessage(LPSTR lpszMessage, size_t dwMessageSize, DWORD *pdwEventType, LPWSTR lpwszPhone, size_t dwPhoneSize, size_t *pdwPhoneSizeRet, UINT *piIcon)
{
- BOOL bRet=FALSE;
+ BOOL bRet = FALSE;
- DWORD dwEventTypeRet=0;
- size_t dwPhoneSizeRet=0;
- UINT iIconRet=0;
+ DWORD dwEventTypeRet = 0;
+ size_t dwPhoneSizeRet = 0;
+ UINT iIconRet = 0;
if (lpszMessage && dwMessageSize) {
- if ( MemoryCompare(lpszMessage,10,"SMS From: ",10) == CSTR_EQUAL) {
- LPSTR lpsz = (LPSTR)strstr(lpszMessage+10, "\r\n");
+ if (MemoryCompare(lpszMessage, 10, "SMS From: ", 10) == CSTR_EQUAL) {
+ LPSTR lpsz = (LPSTR)strstr(lpszMessage + 10, "\r\n");
if (lpsz) {
if (lpwszPhone && dwPhoneSize) {
- dwPhoneSizeRet = MultiByteToWideChar(CP_UTF8,0,(lpszMessage+10),(int)min((size_t)(lpsz-(lpszMessage+10)),dwPhoneSize),lpwszPhone,(int)dwPhoneSize);
+ dwPhoneSizeRet = MultiByteToWideChar(CP_UTF8, 0, (lpszMessage + 10), (int)min((size_t)(lpsz - (lpszMessage + 10)), dwPhoneSize), lpwszPhone, (int)dwPhoneSize);
dwPhoneSizeRet = CopyNumberW(lpwszPhone, lpwszPhone, dwPhoneSizeRet);
}
}
@@ -215,16 +213,16 @@ BOOL GetDataFromMessage(LPSTR lpszMessage,size_t dwMessageSize,DWORD *pdwEventTy dwEventTypeRet = ICQEVENTTYPE_SMS;
bRet = TRUE;
}
- else if (MemoryCompare(lpszMessage,23,"SMS Confirmation From: ",23) == CSTR_EQUAL) {
- LPSTR lpsz = (LPSTR)strstr(lpszMessage+23, "\r\n");
+ else if (MemoryCompare(lpszMessage, 23, "SMS Confirmation From: ", 23) == CSTR_EQUAL) {
+ LPSTR lpsz = (LPSTR)strstr(lpszMessage + 23, "\r\n");
if (lpsz) {
if (lpwszPhone && dwPhoneSize) {
- dwPhoneSizeRet = MultiByteToWideChar(CP_UTF8,0,(lpszMessage+23),(int)min((size_t)(lpsz-(lpszMessage+23)),dwPhoneSize),lpwszPhone,(int)dwPhoneSize);
+ dwPhoneSizeRet = MultiByteToWideChar(CP_UTF8, 0, (lpszMessage + 23), (int)min((size_t)(lpsz - (lpszMessage + 23)), dwPhoneSize), lpwszPhone, (int)dwPhoneSize);
dwPhoneSizeRet = CopyNumberW(lpwszPhone, lpwszPhone, dwPhoneSizeRet);
}
lpsz += 2;
- if (MemoryCompare(lpsz,24,"SMS was sent succesfully",24)==CSTR_EQUAL)
+ if (MemoryCompare(lpsz, 24, "SMS was sent succesfully", 24) == CSTR_EQUAL)
iIconRet = IDI_SMSSENT;
else
iIconRet = IDI_SMSNOTSENT;
@@ -241,20 +239,20 @@ BOOL GetDataFromMessage(LPSTR lpszMessage,size_t dwMessageSize,DWORD *pdwEventTy return bRet;
}
-BOOL GetXMLFieldEx(LPSTR lpszXML,size_t dwXMLSize,LPSTR *plpszData,size_t *pdwDataSize,const char *tag1,...)
+BOOL GetXMLFieldEx(LPSTR lpszXML, size_t dwXMLSize, LPSTR *plpszData, size_t *pdwDataSize, const char *tag1, ...)
{
BOOL bRet = FALSE;
int thisLevel = 0;
LPSTR lpszFindTag = (LPSTR)tag1, lpszTagEnd = lpszXML, lpszDataStart = NULL;
va_list va;
- va_start(va,tag1);
+ va_start(va, tag1);
while (TRUE) {
- LPSTR lpszTagStart = (LPSTR)MemoryFindByte(lpszTagEnd-lpszXML, lpszXML, dwXMLSize, '<');
+ LPSTR lpszTagStart = (LPSTR)MemoryFindByte(lpszTagEnd - lpszXML, lpszXML, dwXMLSize, '<');
if (!lpszTagStart)
break;
- lpszTagEnd = (LPSTR)MemoryFindByte(lpszTagStart-lpszXML, lpszXML, dwXMLSize, '>');
+ lpszTagEnd = (LPSTR)MemoryFindByte(lpszTagStart - lpszXML, lpszXML, dwXMLSize, '>');
if (!lpszTagEnd)
break;
@@ -263,19 +261,19 @@ BOOL GetXMLFieldEx(LPSTR lpszXML,size_t dwXMLSize,LPSTR *plpszData,size_t *pdwDa if ((*((BYTE*)lpszTagStart)) == '/') {
if (--thisLevel < 0) {
if (lpszDataStart) {
- if (plpszData) (*plpszData)=lpszDataStart;
- if (pdwDataSize) (*pdwDataSize)=((lpszTagStart-1)-lpszDataStart);
- bRet=TRUE;
+ if (plpszData) (*plpszData) = lpszDataStart;
+ if (pdwDataSize) (*pdwDataSize) = ((lpszTagStart - 1) - lpszDataStart);
+ bRet = TRUE;
}
break;
}
}
else {
- if (++thisLevel==1)
- if (CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszFindTag,-1,lpszTagStart,((lpszTagEnd+1)-lpszTagStart))==CSTR_EQUAL) {
- lpszFindTag=va_arg(va,LPSTR);
- if (lpszFindTag==NULL) lpszDataStart=(lpszTagEnd+2);
- thisLevel=0;
+ if (++thisLevel == 1)
+ if (CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszFindTag, -1, lpszTagStart, ((lpszTagEnd + 1) - lpszTagStart)) == CSTR_EQUAL) {
+ lpszFindTag = va_arg(va, LPSTR);
+ if (lpszFindTag == NULL) lpszDataStart = (lpszTagEnd + 2);
+ thisLevel = 0;
}
}
}
@@ -284,150 +282,145 @@ BOOL GetXMLFieldEx(LPSTR lpszXML,size_t dwXMLSize,LPSTR *plpszData,size_t *pdwDa }
-BOOL GetXMLFieldExBuff(LPSTR lpszXML,size_t dwXMLSize,LPSTR lpszBuff,size_t dwBuffSize,size_t *pdwBuffSizeRet,const char *tag1,...)
+BOOL GetXMLFieldExBuff(LPSTR lpszXML, size_t dwXMLSize, LPSTR lpszBuff, size_t dwBuffSize, size_t *pdwBuffSizeRet, const char *tag1, ...)
{
- BOOL bRet=FALSE;
- int thisLevel=0;
- LPSTR lpszFindTag=(LPSTR)tag1,lpszTagStart,lpszTagEnd=lpszXML,lpszDataStart=NULL;
+ BOOL bRet = FALSE;
+ int thisLevel = 0;
+ LPSTR lpszFindTag = (LPSTR)tag1, lpszTagStart, lpszTagEnd = lpszXML, lpszDataStart = NULL;
va_list va;
- va_start(va,tag1);
- while (TRUE)
- {
- lpszTagStart=(LPSTR)MemoryFindByte((lpszTagEnd-lpszXML),lpszXML,dwXMLSize,'<');
- if (lpszTagStart)
- {
- lpszTagEnd=(LPSTR)MemoryFindByte((lpszTagStart-lpszXML),lpszXML,dwXMLSize,'>');
- if (lpszTagEnd)
- {
+ va_start(va, tag1);
+ while (TRUE) {
+ lpszTagStart = (LPSTR)MemoryFindByte((lpszTagEnd - lpszXML), lpszXML, dwXMLSize, '<');
+ if (lpszTagStart) {
+ lpszTagEnd = (LPSTR)MemoryFindByte((lpszTagStart - lpszXML), lpszXML, dwXMLSize, '>');
+ if (lpszTagEnd) {
lpszTagStart++;
lpszTagEnd--;
- if ((*((BYTE*)lpszTagStart))=='/')
- {
- if (--thisLevel<0)
- {
- if (lpszDataStart)
- {
- size_t dwBuffSizeRet=min((dwBuffSize-2),(size_t)((lpszTagStart-1)-lpszDataStart));
- if (lpszBuff && dwBuffSize) memcpy(lpszBuff,lpszDataStart,dwBuffSizeRet);(*((WORD*)(lpszBuff+dwBuffSizeRet)))=0;
- if (pdwBuffSizeRet) (*pdwBuffSizeRet)=dwBuffSizeRet;
- bRet=TRUE;
+ if ((*((BYTE*)lpszTagStart)) == '/') {
+ if (--thisLevel < 0) {
+ if (lpszDataStart) {
+ size_t dwBuffSizeRet = min((dwBuffSize - 2), (size_t)((lpszTagStart - 1) - lpszDataStart));
+ if (lpszBuff && dwBuffSize) memcpy(lpszBuff, lpszDataStart, dwBuffSizeRet); (*((WORD*)(lpszBuff + dwBuffSizeRet))) = 0;
+ if (pdwBuffSizeRet) (*pdwBuffSizeRet) = dwBuffSizeRet;
+ bRet = TRUE;
}
break;
}
- }else{
- if (++thisLevel==1)
- if (CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszFindTag,-1,lpszTagStart,((lpszTagEnd+1)-lpszTagStart))==CSTR_EQUAL)
- {
- lpszFindTag=va_arg(va,LPSTR);
- if (lpszFindTag==NULL) lpszDataStart=(lpszTagEnd+2);
- thisLevel=0;
+ }
+ else {
+ if (++thisLevel == 1)
+ if (CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszFindTag, -1, lpszTagStart, ((lpszTagEnd + 1) - lpszTagStart)) == CSTR_EQUAL) {
+ lpszFindTag = va_arg(va, LPSTR);
+ if (lpszFindTag == NULL) lpszDataStart = (lpszTagEnd + 2);
+ thisLevel = 0;
}
}
- }else{
+ }
+ else {
break;
}
- }else{
+ }
+ else {
break;
}
}
va_end(va);
- if (bRet==FALSE)
- {
- if (lpszBuff) (*((WORD*)lpszBuff))=0;
- if (pdwBuffSizeRet) (*pdwBuffSizeRet)=0;
+ if (bRet == FALSE) {
+ if (lpszBuff) (*((WORD*)lpszBuff)) = 0;
+ if (pdwBuffSizeRet) (*pdwBuffSizeRet) = 0;
}
return(bRet);
}
-DWORD ReplaceInBuff(LPVOID lpInBuff,size_t dwInBuffSize,size_t dwReplaceItemsCount,LPVOID *plpInReplaceItems,size_t *pdwInReplaceItemsCounts,LPVOID *plpOutReplaceItems,size_t *pdwOutReplaceItemsCounts,LPVOID lpOutBuff,size_t dwOutBuffSize,size_t *pdwOutBuffSize)
+DWORD ReplaceInBuff(LPVOID lpInBuff, size_t dwInBuffSize, size_t dwReplaceItemsCount, LPVOID *plpInReplaceItems, size_t *pdwInReplaceItemsCounts, LPVOID *plpOutReplaceItems, size_t *pdwOutReplaceItemsCounts, LPVOID lpOutBuff, size_t dwOutBuffSize, size_t *pdwOutBuffSize)
{
- DWORD dwRetErrorCode=NO_ERROR;
- LPBYTE *plpszFound,lpszMessageConvertedCur,lpszMessageCur,lpszMessageCurPrev,lpszMessageConvertedMax;
- size_t i,dwFirstFoundedIndex=0,dwFoundedCount=0,dwMemPartToCopy;
+ DWORD dwRetErrorCode = NO_ERROR;
+ LPBYTE *plpszFound, lpszMessageConvertedCur, lpszMessageCur, lpszMessageCurPrev, lpszMessageConvertedMax;
+ size_t i, dwFirstFoundedIndex = 0, dwFoundedCount = 0, dwMemPartToCopy;
- plpszFound=(LPBYTE*)MEMALLOC((sizeof(LPBYTE)*dwReplaceItemsCount));
+ plpszFound = (LPBYTE*)MEMALLOC((sizeof(LPBYTE)*dwReplaceItemsCount));
- lpszMessageCurPrev=(LPBYTE)lpInBuff;
- lpszMessageConvertedCur=(LPBYTE)lpOutBuff;
- lpszMessageConvertedMax=(((LPBYTE)lpOutBuff)+dwOutBuffSize);
+ lpszMessageCurPrev = (LPBYTE)lpInBuff;
+ lpszMessageConvertedCur = (LPBYTE)lpOutBuff;
+ lpszMessageConvertedMax = (((LPBYTE)lpOutBuff) + dwOutBuffSize);
// looking for in first time
- for (i=0; i < dwReplaceItemsCount; i++) {
- plpszFound[i] = (LPBYTE)strstr((LPCSTR)lpInBuff + (lpszMessageCurPrev-(LPBYTE)lpInBuff), (LPCSTR)plpInReplaceItems[i]);
+ for (i = 0; i < dwReplaceItemsCount; i++) {
+ plpszFound[i] = (LPBYTE)strstr((LPCSTR)lpInBuff + (lpszMessageCurPrev - (LPBYTE)lpInBuff), (LPCSTR)plpInReplaceItems[i]);
if (plpszFound[i])
dwFoundedCount++;
}
while (dwFoundedCount) {
// looking for first to replace
- for(i=0; i < dwReplaceItemsCount; i++)
+ for (i = 0; i < dwReplaceItemsCount; i++)
if (plpszFound[i] && (plpszFound[i] < plpszFound[dwFirstFoundedIndex] || plpszFound[dwFirstFoundedIndex] == NULL))
dwFirstFoundedIndex = i;
// in founded
if (plpszFound[dwFirstFoundedIndex]) {
- dwMemPartToCopy=(plpszFound[dwFirstFoundedIndex]-lpszMessageCurPrev);
- if (lpszMessageConvertedMax > (lpszMessageConvertedCur+(dwMemPartToCopy+pdwInReplaceItemsCounts[dwFirstFoundedIndex]))) {
- memcpy(lpszMessageConvertedCur,lpszMessageCurPrev,dwMemPartToCopy);lpszMessageConvertedCur+=dwMemPartToCopy;
- memcpy(lpszMessageConvertedCur,plpOutReplaceItems[dwFirstFoundedIndex],pdwOutReplaceItemsCounts[dwFirstFoundedIndex]);lpszMessageConvertedCur+=pdwOutReplaceItemsCounts[dwFirstFoundedIndex];
- lpszMessageCurPrev=(plpszFound[dwFirstFoundedIndex]+pdwInReplaceItemsCounts[dwFirstFoundedIndex]);
-
- for(i=0;i<dwReplaceItemsCount;i++)
- {// loking for in next time
- if (plpszFound[i] && plpszFound[i]<lpszMessageCurPrev)
- {
+ dwMemPartToCopy = (plpszFound[dwFirstFoundedIndex] - lpszMessageCurPrev);
+ if (lpszMessageConvertedMax > (lpszMessageConvertedCur + (dwMemPartToCopy + pdwInReplaceItemsCounts[dwFirstFoundedIndex]))) {
+ memcpy(lpszMessageConvertedCur, lpszMessageCurPrev, dwMemPartToCopy); lpszMessageConvertedCur += dwMemPartToCopy;
+ memcpy(lpszMessageConvertedCur, plpOutReplaceItems[dwFirstFoundedIndex], pdwOutReplaceItemsCounts[dwFirstFoundedIndex]); lpszMessageConvertedCur += pdwOutReplaceItemsCounts[dwFirstFoundedIndex];
+ lpszMessageCurPrev = (plpszFound[dwFirstFoundedIndex] + pdwInReplaceItemsCounts[dwFirstFoundedIndex]);
+
+ for (i = 0; i < dwReplaceItemsCount; i++) {// loking for in next time
+ if (plpszFound[i] && plpszFound[i] < lpszMessageCurPrev) {
dwFoundedCount--;
- plpszFound[i] = (LPBYTE)strstr((LPCSTR)lpInBuff + (lpszMessageCurPrev-(LPBYTE)lpInBuff), (LPCSTR)plpInReplaceItems[i]);
+ plpszFound[i] = (LPBYTE)strstr((LPCSTR)lpInBuff + (lpszMessageCurPrev - (LPBYTE)lpInBuff), (LPCSTR)plpInReplaceItems[i]);
if (plpszFound[i]) dwFoundedCount++;
}
}
- }else{
- dwRetErrorCode=ERROR_BUFFER_OVERFLOW;
+ }
+ else {
+ dwRetErrorCode = ERROR_BUFFER_OVERFLOW;
DebugBreak();
break;
}
- }else{// сюда по идее никогда не попадём, на всякий случай.
+ }
+ else {// сюда по идее никогда не попадём, на всякий случай.
DebugBreak();
break;
}
}
- lpszMessageCur=(((LPBYTE)lpInBuff)+dwInBuffSize);
- memcpy(lpszMessageConvertedCur,lpszMessageCurPrev,(lpszMessageCur-lpszMessageCurPrev));lpszMessageConvertedCur+=(lpszMessageCur-lpszMessageCurPrev);
- (*((WORD*)lpszMessageConvertedCur))=0;
+ lpszMessageCur = (((LPBYTE)lpInBuff) + dwInBuffSize);
+ memcpy(lpszMessageConvertedCur, lpszMessageCurPrev, (lpszMessageCur - lpszMessageCurPrev)); lpszMessageConvertedCur += (lpszMessageCur - lpszMessageCurPrev);
+ (*((WORD*)lpszMessageConvertedCur)) = 0;
MEMFREE(plpszFound);
- if (pdwOutBuffSize) (*pdwOutBuffSize)=(lpszMessageConvertedCur-((LPBYTE)lpOutBuff));
+ if (pdwOutBuffSize) (*pdwOutBuffSize) = (lpszMessageConvertedCur - ((LPBYTE)lpOutBuff));
return(dwRetErrorCode);
}
-static const LPTSTR lpszXMLTags[] ={TEXT("'"), TEXT("""), TEXT("&"), TEXT("<"), TEXT(">")};
-static const size_t dwXMLTagsCount[] ={(6*sizeof(TCHAR)), (6*sizeof(TCHAR)), (5*sizeof(TCHAR)), (4*sizeof(TCHAR)), (4*sizeof(TCHAR))};
-static const LPTSTR lpszXMLSymbols[] ={TEXT("\'"), TEXT("\""), TEXT("&"), TEXT("<"), TEXT(">")};
-static const size_t dwXMLSymbolsCount[] ={sizeof(TCHAR), sizeof(TCHAR), sizeof(TCHAR), sizeof(TCHAR), sizeof(TCHAR)};
+static const LPTSTR lpszXMLTags[] = { TEXT("'"), TEXT("""), TEXT("&"), TEXT("<"), TEXT(">") };
+static const size_t dwXMLTagsCount[] = { (6 * sizeof(TCHAR)), (6 * sizeof(TCHAR)), (5 * sizeof(TCHAR)), (4 * sizeof(TCHAR)), (4 * sizeof(TCHAR)) };
+static const LPTSTR lpszXMLSymbols[] = { TEXT("\'"), TEXT("\""), TEXT("&"), TEXT("<"), TEXT(">") };
+static const size_t dwXMLSymbolsCount[] = { sizeof(TCHAR), sizeof(TCHAR), sizeof(TCHAR), sizeof(TCHAR), sizeof(TCHAR) };
//Decode XML coded string. The function translate special xml code into standard characters.
-DWORD DecodeXML(LPTSTR lptszMessage,size_t dwMessageSize,LPTSTR lptszMessageConverted,size_t dwMessageConvertedBuffSize,size_t *pdwMessageConvertedSize)
+DWORD DecodeXML(LPTSTR lptszMessage, size_t dwMessageSize, LPTSTR lptszMessageConverted, size_t dwMessageConvertedBuffSize, size_t *pdwMessageConvertedSize)
{
- DWORD dwRet=ReplaceInBuff(lptszMessage,(dwMessageSize*sizeof(TCHAR)),_countof(lpszXMLTags),(LPVOID*)lpszXMLTags,(size_t*)dwXMLTagsCount,(LPVOID*)lpszXMLSymbols,(size_t*)dwXMLSymbolsCount,lptszMessageConverted,(dwMessageConvertedBuffSize*sizeof(TCHAR)),pdwMessageConvertedSize);
+ DWORD dwRet = ReplaceInBuff(lptszMessage, (dwMessageSize*sizeof(TCHAR)), _countof(lpszXMLTags), (LPVOID*)lpszXMLTags, (size_t*)dwXMLTagsCount, (LPVOID*)lpszXMLSymbols, (size_t*)dwXMLSymbolsCount, lptszMessageConverted, (dwMessageConvertedBuffSize*sizeof(TCHAR)), pdwMessageConvertedSize);
- if (pdwMessageConvertedSize) (*pdwMessageConvertedSize)/=sizeof(TCHAR);
+ if (pdwMessageConvertedSize) (*pdwMessageConvertedSize) /= sizeof(TCHAR);
return(dwRet);
}
//Encode XML coded string. The function translate special saved xml characters into special characters.
-DWORD EncodeXML(LPTSTR lptszMessage,size_t dwMessageSize,LPTSTR lptszMessageConverted,size_t dwMessageConvertedBuffSize,size_t *pdwMessageConvertedSize)
+DWORD EncodeXML(LPTSTR lptszMessage, size_t dwMessageSize, LPTSTR lptszMessageConverted, size_t dwMessageConvertedBuffSize, size_t *pdwMessageConvertedSize)
{
- DWORD dwRet=ReplaceInBuff(lptszMessage,(dwMessageSize*sizeof(TCHAR)),_countof(lpszXMLTags),(LPVOID*)lpszXMLSymbols,(size_t*)dwXMLSymbolsCount,(LPVOID*)lpszXMLTags,(size_t*)dwXMLTagsCount,lptszMessageConverted,(dwMessageConvertedBuffSize*sizeof(TCHAR)),pdwMessageConvertedSize);
+ DWORD dwRet = ReplaceInBuff(lptszMessage, (dwMessageSize*sizeof(TCHAR)), _countof(lpszXMLTags), (LPVOID*)lpszXMLSymbols, (size_t*)dwXMLSymbolsCount, (LPVOID*)lpszXMLTags, (size_t*)dwXMLTagsCount, lptszMessageConverted, (dwMessageConvertedBuffSize*sizeof(TCHAR)), pdwMessageConvertedSize);
- if (pdwMessageConvertedSize) (*pdwMessageConvertedSize)/=sizeof(TCHAR);
+ if (pdwMessageConvertedSize) (*pdwMessageConvertedSize) /= sizeof(TCHAR);
return(dwRet);
}
@@ -439,53 +432,51 @@ BYTE MsgDlgGetFontDefaultCharset(const TCHAR*) }
-void LoadMsgDlgFont(int i,LOGFONT *lf,COLORREF *colour)
+void LoadMsgDlgFont(int i, LOGFONT *lf, COLORREF *colour)
{
int style;
char str[MAX_PATH];
DBVARIANT dbv;
- if (colour)
- {
- mir_snprintf(str,_countof(str),"Font%dCol",i);
- (*colour)=db_get_dw(NULL,SRMMMOD,str,fontOptionsList[0].defColour);
+ if (colour) {
+ mir_snprintf(str, "Font%dCol", i);
+ (*colour) = db_get_dw(NULL, SRMMMOD, str, fontOptionsList[0].defColour);
}
- if (lf)
- {
- if (db_get(NULL,SRMMMOD,str,&dbv))
- {
- mir_tstrncpy(lf->lfFaceName,fontOptionsList[0].szDefFace,_countof(lf->lfFaceName));
- }else{
- mir_tstrncpy(lf->lfFaceName,dbv.ptszVal,_countof(lf->lfFaceName));
+ if (lf) {
+ if (db_get(NULL, SRMMMOD, str, &dbv)) {
+ mir_tstrncpy(lf->lfFaceName, fontOptionsList[0].szDefFace, _countof(lf->lfFaceName));
+ }
+ else {
+ mir_tstrncpy(lf->lfFaceName, dbv.ptszVal, _countof(lf->lfFaceName));
db_free(&dbv);
}
- mir_snprintf(str,_countof(str),"Font%dSize",i);
- lf->lfHeight=(char)db_get_b(NULL,SRMMMOD,str,fontOptionsList[0].defSize);
- lf->lfWidth=0;
- lf->lfEscapement=0;
- lf->lfOrientation=0;
- mir_snprintf(str,_countof(str),"Font%dSty",i);
- style=db_get_b(NULL,SRMMMOD,str,fontOptionsList[0].defStyle);
- lf->lfWeight=style&FONTF_BOLD?FW_BOLD:FW_NORMAL;
- lf->lfItalic=style&FONTF_ITALIC?1:0;
- lf->lfUnderline=0;
- lf->lfStrikeOut=0;
- mir_snprintf(str,_countof(str),"Font%dSet",i);
- lf->lfCharSet=db_get_b(NULL,SRMMMOD,str,MsgDlgGetFontDefaultCharset(lf->lfFaceName));
- lf->lfOutPrecision=OUT_DEFAULT_PRECIS;
- lf->lfClipPrecision=CLIP_DEFAULT_PRECIS;
- lf->lfQuality=DEFAULT_QUALITY;
- lf->lfPitchAndFamily=DEFAULT_PITCH|FF_DONTCARE;
- mir_snprintf(str,_countof(str),"Font%d",i);
+ mir_snprintf(str, "Font%dSize", i);
+ lf->lfHeight = (char)db_get_b(NULL, SRMMMOD, str, fontOptionsList[0].defSize);
+ lf->lfWidth = 0;
+ lf->lfEscapement = 0;
+ lf->lfOrientation = 0;
+ mir_snprintf(str, "Font%dSty", i);
+ style = db_get_b(NULL, SRMMMOD, str, fontOptionsList[0].defStyle);
+ lf->lfWeight = style&FONTF_BOLD ? FW_BOLD : FW_NORMAL;
+ lf->lfItalic = style&FONTF_ITALIC ? 1 : 0;
+ lf->lfUnderline = 0;
+ lf->lfStrikeOut = 0;
+ mir_snprintf(str, "Font%dSet", i);
+ lf->lfCharSet = db_get_b(NULL, SRMMMOD, str, MsgDlgGetFontDefaultCharset(lf->lfFaceName));
+ lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
+ lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ lf->lfQuality = DEFAULT_QUALITY;
+ lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
+ mir_snprintf(str, "Font%d", i);
}
}
-LRESULT CALLBACK MessageSubclassProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
+LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message) {
- case WM_CHAR:
+ switch (message) {
+ case WM_CHAR:
if (wParam == '\n' && GetKeyState(VK_CONTROL) & 0x8000) {
PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0);
return 0;
@@ -499,17 +490,17 @@ LRESULT CALLBACK MessageSubclassProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM //It called when SMS plugin loaded and upon change in the account list.
int RefreshAccountList(WPARAM, LPARAM)
{
- int dwAccCount=0,dwSMSAccountsCount=0;
+ int dwAccCount = 0, dwSMSAccountsCount = 0;
PROTOACCOUNT **ppaAccounts;
- Proto_EnumAccounts((int*)&dwAccCount,&ppaAccounts);
+ Proto_EnumAccounts((int*)&dwAccCount, &ppaAccounts);
FreeAccountList();
- ssSMSSettings.ppaSMSAccounts=(PROTOACCOUNT**)MEMALLOC((dwAccCount*sizeof(LPVOID)));
+ ssSMSSettings.ppaSMSAccounts = (PROTOACCOUNT**)MEMALLOC((dwAccCount*sizeof(LPVOID)));
if (ssSMSSettings.ppaSMSAccounts)
- for (int i=0; i < dwAccCount; i++)
- if ( Proto_IsAccountEnabled(ppaAccounts[i]))
- if ( ProtoServiceExists(ppaAccounts[i]->szModuleName,MS_ICQ_SENDSMS))
+ for (int i = 0; i < dwAccCount; i++)
+ if (Proto_IsAccountEnabled(ppaAccounts[i]))
+ if (ProtoServiceExists(ppaAccounts[i]->szModuleName, MS_ICQ_SENDSMS))
ssSMSSettings.ppaSMSAccounts[dwSMSAccountsCount++] = ppaAccounts[i];
ssSMSSettings.dwSMSAccountsCount = dwSMSAccountsCount;
@@ -523,5 +514,5 @@ int RefreshAccountList(WPARAM, LPARAM) void FreeAccountList()
{
MEMFREE(ssSMSSettings.ppaSMSAccounts);
- ssSMSSettings.dwSMSAccountsCount=0;
+ ssSMSSettings.dwSMSAccountsCount = 0;
}
diff --git a/plugins/SMS/src/receive.cpp b/plugins/SMS/src/receive.cpp index f43a8c9fd9..775ad114a1 100644 --- a/plugins/SMS/src/receive.cpp +++ b/plugins/SMS/src/receive.cpp @@ -27,10 +27,10 @@ Enjoy the code and use it smartly! #include "stdafx.h"
-//This function handles the ACK received from that hooked.
+// This function handles the ACK received from that hooked.
int handleAckSMS(WPARAM wParam, LPARAM lParam)
{
- if ( !lParam)
+ if (!lParam)
return 0;
if (((ACKDATA*)lParam)->type != ICQACKTYPE_SMS)
return 0;
@@ -44,39 +44,36 @@ int handleAckSMS(WPARAM wParam, LPARAM lParam) if (lpszXML)
dwXMLSize = mir_strlen(lpszXML);
- if (GetXMLFieldEx(lpszXML,dwXMLSize,&lpszData,&dwDataSize,"sms_message", "text", NULL))
- {
- if (GetXMLFieldEx(lpszXML,dwXMLSize,&lpszPhone,&dwPhoneSize,"sms_message","sender",NULL))
- {
+ 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;
+ 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,(int)dwDataSize,lpwszMessageXMLEncoded,(int)dwBuffLen);
- DecodeXML(lpwszMessageXMLEncoded,dwMessageXMLEncodedSize,lpwszMessageXMLDecoded,dwBuffLen,&dwMessageXMLDecodedSize);
- lpszMessageUTF=(LPSTR)lpwszMessageXMLEncoded;
- WideCharToMultiByte(CP_UTF8,0,lpwszMessageXMLDecoded,(int)dwMessageXMLDecodedSize,lpszMessageUTF,(int)dwBuffLen,NULL,NULL);
+ 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, (int)dwDataSize, lpwszMessageXMLEncoded, (int)dwBuffLen);
+ DecodeXML(lpwszMessageXMLEncoded, dwMessageXMLEncodedSize, lpwszMessageXMLDecoded, dwBuffLen, &dwMessageXMLDecodedSize);
+ lpszMessageUTF = (LPSTR)lpwszMessageXMLEncoded;
+ WideCharToMultiByte(CP_UTF8, 0, lpwszMessageXMLDecoded, (int)dwMessageXMLDecodedSize, lpszMessageUTF, (int)dwBuffLen, NULL, NULL);
- dwPhoneSize=CopyNumberA(szPhone,lpszPhone,dwPhoneSize);
- dwPhoneSize=MultiByteToWideChar(CP_UTF8,0,szPhone,(int)dwPhoneSize,tszPhone,MAX_PHONE_LEN);
- MCONTACT hContact=HContactFromPhone(tszPhone,dwPhoneSize);
+ dwPhoneSize = CopyNumberA(szPhone, lpszPhone, dwPhoneSize);
+ dwPhoneSize = MultiByteToWideChar(CP_UTF8, 0, szPhone, (int)dwPhoneSize, tszPhone, MAX_PHONE_LEN);
+ MCONTACT hContact = HContactFromPhone(tszPhone, dwPhoneSize);
- dbei.szModule=GetModuleName(hContact);
- dbei.timestamp=time(NULL);
+ 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.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;
+ (*((DWORD*)(dbei.pBlob + (dbei.cbBlob - sizeof(DWORD))))) = 0;
MEVENT hResult = db_event_add(hContact, &dbei);
- if (hContact==NULL) {
- if ( RecvSMSWindowAdd(NULL,ICQEVENTTYPE_SMS,tszPhone,dwPhoneSize,(LPSTR)dbei.pBlob,dbei.cbBlob)) {
+ if (hContact == NULL) {
+ if (RecvSMSWindowAdd(NULL, ICQEVENTTYPE_SMS, tszPhone, dwPhoneSize, (LPSTR)dbei.pBlob, dbei.cbBlob)) {
db_event_markRead(hContact, hResult);
SkinPlaySound("RecvSMSMsg");
}
@@ -86,128 +83,125 @@ int handleAckSMS(WPARAM wParam, LPARAM lParam) 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,(int)dwPhoneSize,tszPhone,MAX_PHONE_LEN);
- MCONTACT hContact=HContactFromPhone(tszPhone,dwPhoneSize);
+ }
+ 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, (int)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,(int)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;
+ 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, (int)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);
}
- dbei.cbBlob=(int)(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);
- memcpy((dbei.pBlob+dbei.cbBlob),lpszData,dwDataSize);
- dbei.cbBlob += (int)(dwDataSize+sizeof(DWORD));
- (*((DWORD*)(dbei.pBlob+(dbei.cbBlob-sizeof(DWORD)))))=0;
+ else {
+ if (GetXMLFieldEx(lpszXML, dwXMLSize, &lpszData, &dwDataSize, "sms_delivery_receipt", "error", "params", "param", NULL) == FALSE) {
+ lpszData = "";
+ dwDataSize = 0;
+ }
+ dbei.cbBlob = (int)(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);
+ memcpy((dbei.pBlob + dbei.cbBlob), lpszData, dwDataSize);
+ dbei.cbBlob += (int)(dwDataSize + sizeof(DWORD));
+ (*((DWORD*)(dbei.pBlob + (dbei.cbBlob - sizeof(DWORD))))) = 0;
+ }
}
- }
- if (dbei.pBlob) {
- if (hContact)
- db_event_add(hContact, &dbei);
- else
- RecvSMSWindowAdd(NULL,ICQEVENTTYPE_SMSCONFIRMATION,tszPhone,dwPhoneSize,(LPSTR)dbei.pBlob,dbei.cbBlob);
+ 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);
+ 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];
+ 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);
+ KillTimer(hWndDlg, wParam);
+ GetXMLFieldExBuff(lpszXML, dwXMLSize, szNetwork, sizeof(szNetwork), NULL, "sms_response", "network", NULL);
- if (ack->result == ACKRESULT_FAILED || CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,(int)dwDataSize,"no",2)==CSTR_EQUAL) {
- char szBuff[1024];
- TCHAR tszErrorMessage[1028];
- LPSTR lpszErrorDescription;
+ if (ack->result == ACKRESULT_FAILED || CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "no", 2) == CSTR_EQUAL) {
+ char szBuff[1024];
+ TCHAR tszErrorMessage[1028];
+ LPSTR lpszErrorDescription;
- if (SendSMSWindowMultipleGet(hWndDlg)) {
- TVITEM tvi;
- tvi.mask=TVIF_TEXT;
- tvi.hItem=SendSMSWindowHItemSendGet(hWndDlg);
- tvi.pszText=tszPhone;
- tvi.cchTextMax=_countof(tszPhone);
- TreeView_GetItem(GetDlgItem(hWndDlg,IDC_NUMBERSLIST),&tvi);
- }
- else GetDlgItemText(hWndDlg,IDC_ADDRESS,tszPhone,_countof(szPhone));
+ if (SendSMSWindowMultipleGet(hWndDlg)) {
+ TVITEM tvi;
+ tvi.mask = TVIF_TEXT;
+ tvi.hItem = SendSMSWindowHItemSendGet(hWndDlg);
+ tvi.pszText = tszPhone;
+ tvi.cchTextMax = _countof(tszPhone);
+ TreeView_GetItem(GetDlgItem(hWndDlg, IDC_NUMBERSLIST), &tvi);
+ }
+ else GetDlgItemText(hWndDlg, IDC_ADDRESS, tszPhone, _countof(szPhone));
- 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)
+ lpszErrorDescription = lpszXML;
+ else {
+ lpszErrorDescription = szBuff;
+ GetXMLFieldExBuff(lpszXML, dwXMLSize, szBuff, sizeof(szBuff), NULL, "sms_response", "error", "params", "param", NULL);
+ }
- mir_sntprintf(tszErrorMessage,_countof(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);
+ mir_sntprintf(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 SendSMSWindowRemove(hWndDlg);
- }
- else {
- if ( CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,(int)dwDataSize,"yes",3)==CSTR_EQUAL ||
- CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,(int)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,(int)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 {
+ SendSMSWindowDBAdd(hWndDlg);
+ if (SendSMSWindowMultipleGet(hWndDlg)) {
+ if (SendSMSWindowNextHItemGet(hWndDlg, SendSMSWindowHItemSendGet(hWndDlg))) {
+ SendSMSWindowAsSentSet(hWndDlg);
+ SendSMSWindowHItemSendSet(hWndDlg, SendSMSWindowNextHItemGet(hWndDlg, SendSMSWindowHItemSendGet(hWndDlg)));
+ SendSMSWindowNext(hWndDlg);
}
- 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);
+ }
+ else {
+ if (CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)dwDataSize, "yes", 3) == CSTR_EQUAL ||
+ CompareStringA(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, lpszData, (int)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, (int)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);
+ }
+ else SendSMSWindowRemove(hWndDlg);
}
- SetDlgItemTextA(hwndAccepted,IDC_NETWORK,szNetwork);
- SetDlgItemTextA(hwndAccepted,IDC_SOURCE,szSource);
- SetDlgItemTextA(hwndAccepted,IDC_MESSAGEID,szMessageID);
+ else SendSMSWindowRemove(hWndDlg);
}
- else SendSMSWindowRemove(hWndDlg);
}
- else SendSMSWindowRemove(hWndDlg);
}
}
- }
- }
return 0;
}
@@ -217,28 +211,28 @@ int handleNewMessage(WPARAM hContact, LPARAM hDbEvent) char szServiceFunction[MAX_PATH], *pszServiceFunctionName;
TCHAR szToolTip[MAX_PATH];
DBEVENTINFO dbei = { sizeof(dbei) };
-
+
if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == -1)
return 0;
dbei.pBlob = (PBYTE)MEMALLOC(dbei.cbBlob);
- if ( !dbei.pBlob)
+ if (!dbei.pBlob)
return 0;
- memcpy(szServiceFunction,PROTOCOL_NAMEA,PROTOCOL_NAME_SIZE);
+ memcpy(szServiceFunction, PROTOCOL_NAMEA, PROTOCOL_NAME_SIZE);
pszServiceFunctionName = szServiceFunction + PROTOCOL_NAME_LEN;
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) {
+ 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))
+ 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 {
- memcpy(pszServiceFunctionName,SMS_READ,sizeof(SMS_READ));
- mir_sntprintf(szToolTip,_countof(szToolTip),TranslateT("SMS Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
+ memcpy(pszServiceFunctionName, SMS_READ, sizeof(SMS_READ));
+ mir_sntprintf(szToolTip, TranslateT("SMS Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
CLISTEVENT cle = { sizeof(cle) };
cle.flags = CLEF_TCHAR;
@@ -247,30 +241,30 @@ int handleNewMessage(WPARAM hContact, LPARAM hDbEvent) cle.hIcon = Skin_LoadIcon(SKINICON_OTHER_SMS);
cle.pszService = szServiceFunction;
cle.ptszTooltip = szToolTip;
- CallService(MS_CLIST_ADDEVENT,0,(LPARAM)&cle);
+ 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))
+ if (RecvSMSWindowAdd(hContact, ICQEVENTTYPE_SMSCONFIRMATION, NULL, 0, (LPSTR)dbei.pBlob, dbei.cbBlob))
db_event_delete(hContact, hDbEvent);
}
else {
UINT iIcon;
if (GetDataFromMessage((LPSTR)dbei.pBlob, dbei.cbBlob, NULL, NULL, 0, NULL, &iIcon)) {
- memcpy(pszServiceFunctionName,SMS_READ_ACK,sizeof(SMS_READ_ACK));
- mir_sntprintf(szToolTip,_countof(szToolTip),TranslateT("SMS Confirmation from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
+ memcpy(pszServiceFunctionName, SMS_READ_ACK, sizeof(SMS_READ_ACK));
+ mir_sntprintf(szToolTip, TranslateT("SMS Confirmation from %s"), pcli->pfnGetContactDisplayName(hContact, 0));
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.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);
+ CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle);
}
}
}
diff --git a/plugins/SMS/src/recvdlg.cpp b/plugins/SMS/src/recvdlg.cpp index 6cec77af40..af6cb3ae07 100644 --- a/plugins/SMS/src/recvdlg.cpp +++ b/plugins/SMS/src/recvdlg.cpp @@ -210,7 +210,7 @@ HWND RecvSMSWindowAdd(MCONTACT hContact, DWORD dwEventType, LPWSTR lpwszPhone, s }
lpwszContactDisplayName = pcli->pfnGetContactDisplayName(hContact, 0);
- mir_sntprintf(wszTitle, _countof(wszTitle), _T("%s - %s"), lpwszContactDisplayName, lpwszTitlepart);
+ mir_sntprintf(wszTitle, _T("%s - %s"), lpwszContactDisplayName, lpwszTitlepart);
MultiByteToWideChar(CP_UTF8, 0, lpszMessage, (int)dwMessageSize, lpwszMessage, (int)dwMessageSize + MAX_PATH);
SetWindowText(prswdWindowData->hWnd, wszTitle);
diff --git a/plugins/SMS/src/senddlg.cpp b/plugins/SMS/src/senddlg.cpp index 8af23dd8d3..0f9a499655 100644 --- a/plugins/SMS/src/senddlg.cpp +++ b/plugins/SMS/src/senddlg.cpp @@ -154,7 +154,7 @@ INT_PTR CALLBACK SendSmsDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARA EnableWindow(GetDlgItem(hWndDlg, IDOK), dwSignLen != 0);
}
- mir_sntprintf(tszSign, _countof(tszSign), _T("%d/%d"), dwSignLen, GetSMSMessageLenMax(hWndDlg));
+ mir_sntprintf(tszSign, _T("%d/%d"), dwSignLen, GetSMSMessageLenMax(hWndDlg));
SetDlgItemText(hWndDlg, IDC_COUNT, tszSign);
}
@@ -222,7 +222,7 @@ INT_PTR CALLBACK SendSmsDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARA else {
GetDlgItemText(hWndDlg, IDC_ADDRESS, tszPhone, _countof(tszPhone));
}
- mir_sntprintf(tszMessage, _countof(tszMessage), TranslateT("The SMS message send to %s timed out."), tszPhone);
+ mir_sntprintf(tszMessage, TranslateT("The SMS message send to %s timed out."), tszPhone);
KillTimer(hWndDlg, wParam);
ShowWindow(hWndDlg, SW_SHOWNORMAL);
EnableWindow(hWndDlg, FALSE);
@@ -386,7 +386,7 @@ INT_PTR CALLBACK SendSmsDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARA size_t dwMessageSize = GET_DLG_ITEM_TEXT_LENGTH(hWndDlg, IDC_MESSAGE);
EnableWindow(GetDlgItem(hWndDlg, IDOK), dwMessageSize != 0);
- mir_sntprintf(tszBuff, _countof(tszBuff), _T("%d/%d"), dwMessageSize, GetSMSMessageLenMax(hWndDlg));
+ mir_sntprintf(tszBuff, _T("%d/%d"), dwMessageSize, GetSMSMessageLenMax(hWndDlg));
SetDlgItemText(hWndDlg, IDC_COUNT, tszBuff);
}
break;
@@ -402,7 +402,7 @@ INT_PTR CALLBACK SendSmsDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARA if (IsContactPhone(psswdWindowData->hMyContact, tszPhone, dwPhoneSize) == FALSE) {
mir_tstrcat(tszPhone, _T(" SMS"));
for (DWORD i = 0; bCont; i++) {
- mir_snprintf(szBuff, _countof(szBuff), "MyPhone%d", i);
+ mir_snprintf(szBuff, "MyPhone%d", i);
if (db_get(psswdWindowData->hMyContact, "UserInfo", szBuff, &dbv)) bCont = FALSE;
db_free(&dbv);
}
@@ -559,7 +559,7 @@ HWND SendSMSWindowAdd(MCONTACT hContact) LPTSTR lptszContactDisplayName = pcli->pfnGetContactDisplayName(hContact, 0);
TCHAR tszTitle[MAX_PATH];
- mir_sntprintf(tszTitle, _countof(tszTitle), _T("%s - %s"), lptszContactDisplayName, TranslateT("Send SMS"));
+ mir_sntprintf(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);
@@ -964,7 +964,7 @@ void AddContactPhonesToComboToListParam(MCONTACT hContact, LPSTR lpszModule, LPS }
for (i = 0; TRUE; i++) {
- mir_snprintf(szBuff, _countof(szBuff), "%s%ld", lpszValueName, i);
+ mir_snprintf(szBuff, "%s%ld", lpszValueName, i);
if (DB_GetStaticStringW(hContact, lpszModule, szBuff, tszPhoneRaw, _countof(tszPhoneRaw), &dwPhoneSize)) {
tszPhone[0] = '+';
dwPhoneSize = CopyNumberW(tszPhone + 1, tszPhoneRaw, dwPhoneSize);
@@ -1026,7 +1026,7 @@ void AddContactPhonesToTreeViewParam(MCONTACT hContact, LPSTR lpszModule, LPSTR }
for (i = 0; TRUE; i++) {
- mir_snprintf(szBuff, _countof(szBuff), "%s%ld", lpszValueName, i);
+ mir_snprintf(szBuff, "%s%ld", lpszValueName, i);
if (DB_GetStaticStringW(hContact, lpszModule, szBuff, tszPhoneRaw, _countof(tszPhoneRaw), &dwPhoneSize)) {
tszPhone[0] = '+';
dwPhoneSize = CopyNumberW(tszPhone + 1, tszPhoneRaw, dwPhoneSize);
|