diff options
Diffstat (limited to 'plugins/SMS')
-rw-r--r-- | plugins/SMS/src/AdditionalFunctions/BuffToLowerCase.h | 56 | ||||
-rw-r--r-- | plugins/SMS/src/AdditionalFunctions/ListMT.h | 4 | ||||
-rw-r--r-- | plugins/SMS/src/AdditionalFunctions/MemoryCompare.h | 175 | ||||
-rw-r--r-- | plugins/SMS/src/AdditionalFunctions/MemoryFind.h | 81 | ||||
-rw-r--r-- | plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h | 60 | ||||
-rw-r--r-- | plugins/SMS/src/SMS_svc.cpp | 8 | ||||
-rw-r--r-- | plugins/SMS/src/common.h | 78 | ||||
-rw-r--r-- | plugins/SMS/src/functions.cpp | 322 | ||||
-rw-r--r-- | plugins/SMS/src/main.cpp | 6 | ||||
-rw-r--r-- | plugins/SMS/src/options.cpp | 86 | ||||
-rw-r--r-- | plugins/SMS/src/receive.cpp | 55 | ||||
-rw-r--r-- | plugins/SMS/src/recvdlg.cpp | 39 | ||||
-rw-r--r-- | plugins/SMS/src/senddlg.cpp | 96 | ||||
-rw-r--r-- | plugins/SMS/src/senddlg.h | 57 |
14 files changed, 332 insertions, 791 deletions
diff --git a/plugins/SMS/src/AdditionalFunctions/BuffToLowerCase.h b/plugins/SMS/src/AdditionalFunctions/BuffToLowerCase.h deleted file mode 100644 index d2bb7a6671..0000000000 --- a/plugins/SMS/src/AdditionalFunctions/BuffToLowerCase.h +++ /dev/null @@ -1,56 +0,0 @@ -#if !defined(AFX_BUFFTOLOWERCASE__H__INCLUDED_)
-#define AFX_BUFFTOLOWERCASE__H__INCLUDED_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-
-
-__inline DWORD BuffToLowerCase(LPCVOID lpcOutBuff,LPCVOID lpcBuff,SIZE_T dwLen)
-{
- DWORD dwRetErrorCode=NO_ERROR;
-
- __asm
- {
- mov ecx,dwLen
- test ecx,ecx
- jz short end_func
-
- push ebx // сохраняем регистр
- push edi // сохраняем регистр
- push esi // сохраняем регистр
- mov esi,lpcBuff
- mov edi,lpcOutBuff
- mov bl,'A'
- mov bh,'Z'
- mov ah,32
- cld
-
- lowcaseloop:
- lodsb
- cmp al,bl
- jl short savebyte
- cmp al,bh
- jg short savebyte
- or al,ah
-
- savebyte:
- stosb
-
- dec ecx
- jnz short lowcaseloop
-
- pop esi // восстанавливаем содержимое регистра
- pop edi // восстанавливаем содержимое регистра
- pop ebx // восстанавливаем содержимое регистра
- end_func:
- }
-
-return(dwRetErrorCode);
-}
-
-
-
-
-#endif // !defined(AFX_BUFFTOLOWERCASE__H__INCLUDED_)
\ No newline at end of file diff --git a/plugins/SMS/src/AdditionalFunctions/ListMT.h b/plugins/SMS/src/AdditionalFunctions/ListMT.h index fd9ab3baaf..7d7884ec66 100644 --- a/plugins/SMS/src/AdditionalFunctions/ListMT.h +++ b/plugins/SMS/src/AdditionalFunctions/ListMT.h @@ -67,7 +67,7 @@ __inline DWORD ListMTInitialize(PCLIST_MT pclmtListMT,DWORD dwSpinCount) if (TRUE)
#endif
{
- InterlockedExchangePointer(&pclmtListMT->nCount,NULL);
+ InterlockedExchangePointer((volatile PVOID*)&pclmtListMT->nCount,NULL);
pclmtListMT->plmtiFirst=NULL;
pclmtListMT->plmtiLast=NULL;
dwRetErrorCode=NO_ERROR;
@@ -80,7 +80,7 @@ return(dwRetErrorCode); __inline void ListMTDestroy(PCLIST_MT pclmtListMT)
{
- InterlockedExchangePointer(&pclmtListMT->nCount,NULL);
+ InterlockedExchangePointer((volatile PVOID*)&pclmtListMT->nCount,NULL);
pclmtListMT->plmtiFirst=NULL;
pclmtListMT->plmtiLast=NULL;
DeleteCriticalSection(&pclmtListMT->cs);
diff --git a/plugins/SMS/src/AdditionalFunctions/MemoryCompare.h b/plugins/SMS/src/AdditionalFunctions/MemoryCompare.h index de663c6d8a..3fdb5e08b3 100644 --- a/plugins/SMS/src/AdditionalFunctions/MemoryCompare.h +++ b/plugins/SMS/src/AdditionalFunctions/MemoryCompare.h @@ -5,173 +5,32 @@ #pragma once
#endif // _MSC_VER > 1000
-
-// If the string pointed to by lpString1 is less than the string pointed
-// to by lpString2, the return value is negative.
-// If the string pointed to by lpString1 is greater than the string pointed
-// to by lpString2, the return value is positive.
-// If the strings are equal, the return value is zero.
-//
-// lpString1<lpString2 >> ret=1=CSTR_LESS_THAN
-// lpString1=lpString2 >> ret=2=CSTR_EQUAL
-// lpString1>lpString2 >> ret=3=CSTR_GREATER_THAN
-
-
-/*__inline DWORD MemoryCompare(LPCVOID lpcSource1,SIZE_T dwSource1Size,LPCVOID lpcSource2,SIZE_T dwSource2Size)
-{
- DWORD dwRet;
-
- __asm
- {
- mov ecx,dwSource1Size //; ecx = Source string 1 Size
- cmp ecx,dwSource2Size //; сверяем длинны участков памяти
- jg short greater_than
- jl short less_than
- test ecx,ecx
- jz short equal //; NULL=NULL
-
- mov esi,lpcSource1 //; edi = Source string 1
- mov edi,lpcSource2 //; esi = Source string 2
- cmp edi,esi //; сверяем указатели на участки памяти
- je short equal //; это один и тотже участок, они естественно равны
-
- test esi,esi //; lpcSource1=NULL, lpcSource1<lpcSource2
- jz short less_than //; CSTR_LESS_THAN
-
- test edi,edi //; lpcSource2=NULL, lpcSource1>lpcSource2
- jz short greater_than //; CSTR_GREATER_THAN
-
- //cld //; сканируя в прямом направлении
-
- repe cmpsb //; цикл сравнения.
- cmp_loop:
- //sub ecx,4
- //jz short equal
-
- //inc esi
- //inc edi
- //mov al,byte ptr [esi]
- //cmpsd
- //cmp al,byte ptr [edi]
- //je short cmp_loop
- jg short greater_than
- jl short less_than
-
- equal: //; если мы попали сюда, значит, они
- mov dwRet,CSTR_EQUAL //; совпадают (match)
- jmp end_func
- less_than: //; не совпадают
- mov dwRet,CSTR_LESS_THAN
- jmp end_func
- greater_than:
- mov dwRet,CSTR_GREATER_THAN
-
- end_func:
- }
-return(dwRet);
-}//*/
-
__inline DWORD MemoryCompare(LPCVOID lpcSource1,SIZE_T dwSource1Size,LPCVOID lpcSource2,SIZE_T dwSource2Size)
{
- DWORD dwRet;
+ if (dwSource1Size == dwSource2Size) {
+ if (lpcSource1 == lpcSource2)
+ return CSTR_EQUAL;
- if (dwSource1Size==dwSource2Size)
- {
- if (lpcSource1==lpcSource2)
- {
- dwRet=CSTR_EQUAL;
- }else{
- if (lpcSource1 && lpcSource2)
- {
+ if (lpcSource1 && lpcSource2) {
#ifdef _INC_MEMORY
- dwRet=(2+memcmp(lpcSource1,lpcSource2,dwSource1Size));
+ return 2 + memcmp(lpcSource1,lpcSource2,dwSource1Size));
#else
- SIZE_T dwDiffPosition;
-
- //dwDiffPosition=RtlCompareMemory(lpcSource1,lpcSource2,dwSource1Size);
- for(dwDiffPosition=0; (dwDiffPosition<dwSource1Size) && (((const BYTE*)lpcSource1)[dwDiffPosition]==((const BYTE*)lpcSource2)[dwDiffPosition]); dwDiffPosition++);
- if (dwDiffPosition==dwSource1Size)
- {
- dwRet=CSTR_EQUAL;
- }else{
- if ((*((BYTE*)(((SIZE_T)lpcSource1)+dwDiffPosition)))>(*((BYTE*)(((SIZE_T)lpcSource2)+dwDiffPosition))))
- {
- dwRet=CSTR_GREATER_THAN;
- }else{
- dwRet=CSTR_LESS_THAN;
- }
- }
-#endif
- }else{
- if (lpcSource1)
- {//lpcSource2==NULL
- dwRet=CSTR_GREATER_THAN;
- }else{//lpcSource1==NULL
- dwRet=CSTR_LESS_THAN;
- }
- }
- }
- }else{
- if (dwSource1Size<dwSource2Size)
- {
- dwRet=CSTR_LESS_THAN;
- }else{
- dwRet=CSTR_GREATER_THAN;
- }
- }
-return(dwRet);
-}//*/
+ SIZE_T dwDiffPosition;
+ //dwDiffPosition=RtlCompareMemory(lpcSource1,lpcSource2,dwSource1Size);
+ for(dwDiffPosition=0; (dwDiffPosition<dwSource1Size) && (((const BYTE*)lpcSource1)[dwDiffPosition]==((const BYTE*)lpcSource2)[dwDiffPosition]); dwDiffPosition++);
+ if (dwDiffPosition==dwSource1Size)
+ return CSTR_EQUAL;
-/*
-__inline DWORD MemoryCompareEx(LPCVOID lpcSource1,SIZE_T dwSource1Size,LPCVOID lpcSource2,SIZE_T dwSource2Size,SIZE_T *pdwDiffPosition)
-{
- DWORD dwRet;
-
- if (dwSource1Size==dwSource2Size)
- {
- if (lpcSource1==lpcSource2)
- {
- dwRet=CSTR_EQUAL;
- }else{
- if (lpcSource1 && lpcSource2)
- {
- SIZE_T dwDiffPosition;
-
- dwDiffPosition=RtlCompareMemory(lpcSource1,lpcSource2,dwSource1Size);
- if (dwDiffPosition==dwSource1Size)
- {
- dwRet=CSTR_EQUAL;
- }else{
- if ((*((BYTE*)(((SIZE_T)lpcSource1)+dwDiffPosition)))>(*((BYTE*)(((SIZE_T)lpcSource2)+dwDiffPosition))))
- {
- dwRet=CSTR_GREATER_THAN;
- }else{
- dwRet=CSTR_LESS_THAN;
- }
- }
-
- if (pdwDiffPosition) (*pdwDiffPosition)=dwDiffPosition;
- }else{
- if (lpcSource1)
- {//lpcSource2==NULL
- dwRet=CSTR_GREATER_THAN;
- }else{//lpcSource1==NULL
- dwRet=CSTR_LESS_THAN;
- }
- }
- }
- }else{
- if (dwSource1Size<dwSource2Size)
- {
- dwRet=CSTR_LESS_THAN;
- }else{
- dwRet=CSTR_GREATER_THAN;
+ if ((*((BYTE*)(((SIZE_T)lpcSource1)+dwDiffPosition)))>(*((BYTE*)(((SIZE_T)lpcSource2)+dwDiffPosition))))
+ return CSTR_GREATER_THAN;
+
+ return CSTR_LESS_THAN;
+#endif
}
+ return (lpcSource1) ? CSTR_GREATER_THAN : CSTR_LESS_THAN;
}
-return(dwRet);
+ return (dwSource1Size < dwSource2Size) ? CSTR_LESS_THAN : CSTR_GREATER_THAN;
}
-*/
-
#endif // !defined(AFX_MEMORYCOMPARE__H__INCLUDED_)
diff --git a/plugins/SMS/src/AdditionalFunctions/MemoryFind.h b/plugins/SMS/src/AdditionalFunctions/MemoryFind.h deleted file mode 100644 index dbc5f1a2d1..0000000000 --- a/plugins/SMS/src/AdditionalFunctions/MemoryFind.h +++ /dev/null @@ -1,81 +0,0 @@ -#if !defined(AFX_MEMORYFIND__H__INCLUDED_)
-#define AFX_MEMORYFIND__H__INCLUDED_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-__inline LPVOID MemoryFind(SIZE_T dwFrom,LPCVOID lpcSource,SIZE_T dwSourceSize,LPCVOID lpcWhatFind,SIZE_T dwWhatFindSize)
-{
- LPVOID lpRet=NULL;
-
- __asm
- {
- push ebx // сохраняем регистр
- push edi // сохраняем регистр
- push esi // сохраняем регистр
-
- mov ecx,dwSourceSize //; ecx = Source string Size
- test ecx,ecx // is size unknown?
- jz short end_func
-
- mov edx,dwWhatFindSize //; edx = WhatFind string Size
- test edx,edx // is size unknown?
- jz short end_func
-
- mov ebx,dwFrom // ebx - start pos in Source string
- mov edi,lpcSource //; edi = Source string
- mov esi,lpcWhatFind //; esi = WhatFind string
-
- cmp ebx,ecx // проверка ecx(=len)=>ulFrom
- jae short end_func
-
- add edi,ebx // сдвигаем начало на ulFrom(нач смещен)
- sub ecx,ebx // уменьшаем длинну SourceSize на ulFrom(нач смещен)
-
- cmp ecx,edx // проверка NEWSourceSize ??? ulWhatFindSize
- je short begin_memorycompare // NEWulSourceSize==ulWhatFindSize, Source ??? WhatFind
- jl short end_func // NEWulSourceSize<ulWhatFindSize, => Source!=WhatFind
-
- sub ecx,edx // уменьшаем длинну SourceSize на ulWhatFindSize
- inc ecx
-
- mov al,[esi] //; al=search byte
- dec edi
- cld //; сканируя в прямом направлении
-
- find_loop:
- test ecx,ecx
- jz short end_func
- inc edi
- repne scasb //; find that byte
- dec edi //; di points to byte which stopped scan
-
- cmp [edi],al //; see if we have a hit
- jne short end_func //; yes, point to byte
-
- begin_memorycompare:
- push esi
- push edi
- push ecx
- mov ecx,edx //; ulWhatFindSize байтов (CX используется в REPE),
- repe cmpsb //; сравниваем их.
- pop ecx
- pop edi
- pop esi
- jne short find_loop //; признак ZF = 0, если сравниваемые
- //; строки не совпадают (mismatch) match:
- //; если мы попали сюда, значит, они
- //; совпадают (match)
- mov lpRet,edi //; ax=pointer to byte
- end_func:
-
- pop esi // восстанавливаем содержимое регистра
- pop edi // восстанавливаем содержимое регистра
- pop ebx // восстанавливаем содержимое регистра
- }
-return(lpRet);
-}
-
-
-#endif // !defined(AFX_MEMORYFIND__H__INCLUDED_)
diff --git a/plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h b/plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h index 002f76e44c..83ca9c5468 100644 --- a/plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h +++ b/plugins/SMS/src/AdditionalFunctions/MemoryFindByte.h @@ -5,67 +5,13 @@ #pragma once
#endif // _MSC_VER > 1000
-
-
__inline LPVOID MemoryFindByte(SIZE_T dwFrom,LPCVOID lpcSource,SIZE_T dwSourceSize,unsigned char chWhatFind)
{
- LPVOID lpRet=NULL;
-
if (lpcSource && dwSourceSize)
- {
- if (dwFrom<dwSourceSize)
- {
- lpRet=(LPVOID)memchr((LPCVOID)(((SIZE_T)lpcSource)+dwFrom),chWhatFind,(dwSourceSize-dwFrom));
- }
- }
-return(lpRet);
-}
-
-
-
-__inline LPVOID MemoryFindByteReverse(SIZE_T dwFrom,LPCVOID lpcSource,SIZE_T dwSourceSize,unsigned char chWhatFind)
-{
- LPVOID lpRet=NULL;
+ if (dwFrom < dwSourceSize)
+ return memchr((BYTE*)lpcSource + dwFrom, chWhatFind, dwSourceSize-dwFrom);
- __asm
- {
- push ebx // сохраняем регистр
- push edi // сохраняем регистр
- push esi // сохраняем регистр
-
- mov ecx,dwSourceSize
- test ecx,ecx //; проверка входного параметра, он !=0
- je short end_func
-
- mov edi,lpcSource //; di = string
- test edi,edi //; проверка входного параметра, он !=0
- jz short end_func
-
- mov eax,dwFrom
-
-/////////////////////////////////////////////
- cmp eax,ecx //; проверка ecx(=len)=>dwFrom
- jae short end_func
-
- std //; count 'up' on string this time
- sub ecx,eax //; уменьшаем длинну на dwFrom(нач смещен)
- add edi,ecx //; сдвигаем начало на dwSourceSize(на конец)
- mov al,chWhatFind //; al=search byte
- repne scasb //; find that byte
- inc edi //; di points to byte which stopped scan
- cmp [edi],al //; see if we have a hit
- jne short end_func //; yes, point to byte
- mov lpRet,edi //; ax=pointer to byte
- end_func:
-
- cld
- pop esi // восстанавливаем содержимое регистра
- pop edi // восстанавливаем содержимое регистра
- pop ebx // восстанавливаем содержимое регистра
- }
-return(lpRet);
+ return NULL;
}
-
-
#endif // !defined(AFX_MEMORYFINDBYTE__H__INCLUDED_)
diff --git a/plugins/SMS/src/SMS_svc.cpp b/plugins/SMS/src/SMS_svc.cpp index 489f9f4dbd..0264d43139 100644 --- a/plugins/SMS/src/SMS_svc.cpp +++ b/plugins/SMS/src/SMS_svc.cpp @@ -15,7 +15,7 @@ int LoadServices(void) CopyMemory(pszServiceFunctionName,siPluginServices[i].lpszName,(lstrlenA(siPluginServices[i].lpszName)+1));
CreateServiceFunction(szServiceFunction,(MIRANDASERVICE)siPluginServices[i].lpFunc);
}
-return(0);
+ return 0;
}
@@ -56,7 +56,7 @@ int LoadModules(void) RestoreUnreadMessageAlerts();
-return(0);
+ return 0;
}
@@ -101,7 +101,7 @@ void UnloadServices() int SmsRebuildContactMenu(WPARAM wParam,LPARAM lParam)
{
CListShowMenuItem(ssSMSSettings.hContactMenuItems[0],(BOOL)GetContactPhonesCount((HANDLE)wParam));
-return(0);
+ return 0;
}
@@ -133,7 +133,7 @@ int SendSMSMenuCommand(WPARAM wParam,LPARAM lParam) }
}
}
-return(0);
+ return 0;
}
diff --git a/plugins/SMS/src/common.h b/plugins/SMS/src/common.h index b65c11e5c5..799d287c9f 100644 --- a/plugins/SMS/src/common.h +++ b/plugins/SMS/src/common.h @@ -40,18 +40,11 @@ #include <commctrl.h>
#include <stdio.h>
#include <time.h>
-/*#ifdef NDEBUG
- #include <..\minicrt\minicrt.h>
-#else
- #include <..\minicrt\timefuncs.h>
-#endif //_DEBUG*/
#include "AdditionalFunctions/ListMT.h"
#include "AdditionalFunctions/DebugFunctions.h"
#include "AdditionalFunctions/MemoryCompare.h"
-#include "AdditionalFunctions/MemoryFind.h"
#include "AdditionalFunctions/MemoryFindByte.h"
-#include "AdditionalFunctions/BuffToLowerCase.h"
#include <newpluginapi.h>
#include <m_database.h>
@@ -179,53 +172,46 @@ BOOL DB_SetStringExW(HANDLE hContact,LPSTR lpszModule,LPSTR lpszValueName,LPWSTR #define DB_SMS_SetStringW(Contact,valueName,parValue) DBWriteContactSettingWString(Contact,PROTOCOL_NAMEA,valueName,parValue)
#define DB_SMS_SetStringExW(Contact,valueName,parValue,parValueSize) DB_SetStringExW(Contact,PROTOCOL_NAMEA,valueName,parValue,parValueSize)
+LRESULT CALLBACK MessageSubclassProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
-LPSTR GetModuleName (HANDLE hContact);
-void EnableControlsArray (HWND hWndDlg,WORD *pwControlsList,SIZE_T dwControlsListCount,BOOL bEnabled);
-void CListShowMenuItem (HANDLE hMenuItem,BOOL bShow);
-//Decleration of function that returns received string with only numbers
-SIZE_T CopyNumberA (LPSTR lpszOutBuff,LPSTR lpszBuff,SIZE_T dwLen);
-SIZE_T CopyNumberW (LPWSTR lpcOutBuff,LPWSTR lpcBuff,SIZE_T dwLen);
-BOOL IsPhoneW (LPWSTR lpwszString,SIZE_T dwStringLen);
-DWORD GetContactPhonesCount (HANDLE hContact);
-BOOL IsContactPhone (HANDLE hContact,LPWSTR lpwszPhone,SIZE_T dwPhoneSize);
-//Decleration of function that returns HANDLE of contact by his cellular number
-HANDLE 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);
-//Decleration of function that gets a XML string and return the asked tag.
-BOOL GetXMLFieldEx (LPSTR lpszXML,SIZE_T dwXMLSize,LPSTR *plpszData,SIZE_T *pdwDataSize,const char *tag1,...);
-BOOL GetXMLFieldExBuff (LPSTR lpszXML,SIZE_T dwXMLSize,LPSTR lpszBuff,SIZE_T dwBuffSize,SIZE_T *pdwBuffSizeRet,const char *tag1,...);
-//BOOL GetXMLFieldExW (LPWSTR lpwszXML,SIZE_T dwXMLSize,LPWSTR *plpwszData,SIZE_T *pdwDataSize,const WCHAR *tag1,...);
-//BOOL GetXMLFieldExBuffW (LPWSTR lpwszXML,SIZE_T dwXMLSize,LPWSTR lpwszBuff,SIZE_T dwBuffSize,SIZE_T *pdwBuffSizeRet,const WCHAR *tag1,...);
-DWORD DecodeXML (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);
-void LoadMsgDlgFont (int i,LOGFONT *lf,COLORREF *colour);
-LRESULT CALLBACK MessageSubclassProc (HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
-int RefreshAccountList (WPARAM eventCode,LPARAM lParam);
-void FreeAccountList ();
-//BOOL IsModuleInAccountList (LPSTR lpszModule);
-
-
-
-
-int OptInitialise (WPARAM wParam,LPARAM lParam);
+LPSTR GetModuleName(HANDLE hContact);
+void EnableControlsArray(HWND hWndDlg,WORD *pwControlsList,SIZE_T dwControlsListCount,BOOL bEnabled);
+void CListShowMenuItem(HANDLE hMenuItem,BOOL bShow);
-int LoadServices ();
-int LoadModules ();
-void UnloadModules ();
-void UnloadServices ();
+// Declaration of function that returns received string with only numbers
+SIZE_T CopyNumberA(LPSTR lpszOutBuff,LPSTR lpszBuff,SIZE_T dwLen);
+SIZE_T CopyNumberW(LPWSTR lpcOutBuff,LPWSTR lpcBuff,SIZE_T dwLen);
+bool IsPhoneW(LPWSTR lpwszString,SIZE_T dwStringLen);
+DWORD GetContactPhonesCount(HANDLE hContact);
+BOOL IsContactPhone(HANDLE hContact,LPWSTR lpwszPhone,SIZE_T dwPhoneSize);
-int handleAckSMS(WPARAM wParam,LPARAM lParam);
-int handleNewMessage(WPARAM wParam,LPARAM lParam);
-void RestoreUnreadMessageAlerts();
+// Declaration of function that returns HANDLE of contact by his cellular number
+HANDLE 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);
-//Decleration of Menu SMS send click function
-int SmsRebuildContactMenu(WPARAM wParam,LPARAM lParam);
+// Declaration of function that gets a XML string and return the asked tag.
+BOOL GetXMLFieldEx(LPSTR lpszXML,SIZE_T dwXMLSize,LPSTR *plpszData,SIZE_T *pdwDataSize,const char *tag1,...);
+BOOL GetXMLFieldExBuff(LPSTR lpszXML,SIZE_T dwXMLSize,LPSTR lpszBuff,SIZE_T dwBuffSize,SIZE_T *pdwBuffSizeRet,const char *tag1,...);
+DWORD DecodeXML(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);
+void LoadMsgDlgFont(int i,LOGFONT *lf,COLORREF *colour);
+int RefreshAccountList(WPARAM eventCode,LPARAM lParam);
+void FreeAccountList();
+int OptInitialise(WPARAM wParam,LPARAM lParam);
-void StartSmsSend(HWND hWndDlg,SIZE_T dwModuleIndex,LPWSTR lpwszPhone,SIZE_T dwPhoneSize,LPWSTR lpwszMessage,SIZE_T dwMessageSize);
+int LoadServices();
+int LoadModules();
+void UnloadModules();
+void UnloadServices();
+int handleAckSMS(WPARAM wParam,LPARAM lParam);
+int handleNewMessage(WPARAM wParam,LPARAM lParam);
+void RestoreUnreadMessageAlerts();
+// Declaration of Menu SMS send click function
+int SmsRebuildContactMenu(WPARAM wParam,LPARAM lParam);
+void StartSmsSend(HWND hWndDlg,SIZE_T dwModuleIndex,LPWSTR lpwszPhone,SIZE_T dwPhoneSize,LPWSTR lpwszMessage,SIZE_T dwMessageSize);
#endif
\ No newline at end of file diff --git a/plugins/SMS/src/functions.cpp b/plugins/SMS/src/functions.cpp index 07a592c67d..2fc592a9ae 100644 --- a/plugins/SMS/src/functions.cpp +++ b/plugins/SMS/src/functions.cpp @@ -131,33 +131,21 @@ return((lpwszOutBuff-lpcOutBuff)); }
-BOOL IsPhoneW(LPWSTR lpwszString,SIZE_T dwStringLen)
+bool IsPhoneW(LPWSTR lpwszString,SIZE_T dwStringLen)
{
- BOOL bRet;
-
- if (dwStringLen>1)
- {// country code
- WCHAR wChar;
+ if (dwStringLen <= 1)
+ return false;
- bRet=TRUE;
- for(SIZE_T i=0;i<dwStringLen;i++)
- {
- wChar=(*lpwszString++);
- if (wChar<'0' || wChar>'9')
+ 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!=')')
- {
- bRet=FALSE;
- break;
- }
- }
- }else{
- bRet=FALSE;
+ return false;
}
-return(bRet);
+ return true;
}
-
DWORD GetContactPhonesCountParam(HANDLE hContact,LPSTR lpszModule,LPSTR lpszValueName)
{
DWORD dwRet=0;
@@ -165,82 +153,61 @@ DWORD GetContactPhonesCountParam(HANDLE hContact,LPSTR lpszModule,LPSTR lpszValu WCHAR wszPhone[MAX_PHONE_LEN];
SIZE_T i,dwPhoneSize;
- if (DB_GetStaticStringW(hContact,lpszModule,lpszValueName,wszPhone,SIZEOF(wszPhone),&dwPhoneSize))
- {
- if (IsPhoneW(wszPhone,dwPhoneSize)) dwRet++;
- }
+ if ( DB_GetStaticStringW(hContact,lpszModule,lpszValueName,wszPhone,SIZEOF(wszPhone),&dwPhoneSize))
+ if ( IsPhoneW(wszPhone,dwPhoneSize))
+ dwRet++;
- for (i=0;TRUE;i++)
- {
+ for (i=0; i <= PHONES_MIN_COUNT; i++) {
mir_snprintf(szBuff,sizeof(szBuff),"%s%ld",lpszValueName,i);
- if (DB_GetStaticStringW(hContact,lpszModule,szBuff,wszPhone,SIZEOF(wszPhone),&dwPhoneSize))
- {
- if (IsPhoneW(wszPhone,dwPhoneSize)) dwRet++;
- }else{
- if (i>PHONES_MIN_COUNT) break;
- }
+ if ( DB_GetStaticStringW(hContact,lpszModule,szBuff,wszPhone,SIZEOF(wszPhone),&dwPhoneSize))
+ if ( IsPhoneW(wszPhone,dwPhoneSize))
+ dwRet++;
}
-return(dwRet);
+ return dwRet;
}
DWORD GetContactPhonesCount(HANDLE hContact)
{
- DWORD dwRet=0;
- LPSTR lpszProto;
-
- lpszProto=(LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
- if (lpszProto)
- {
- dwRet+=GetContactPhonesCountParam(hContact,lpszProto,"Phone");
- dwRet+=GetContactPhonesCountParam(hContact,lpszProto,"Cellular");
- dwRet+=GetContactPhonesCountParam(hContact,lpszProto,"Fax");
+ 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,"UserInfo","MyPhone");
- dwRet+=GetContactPhonesCountParam(hContact,"UserInfo","Phone");
- dwRet+=GetContactPhonesCountParam(hContact,"UserInfo","Cellular");
- dwRet+=GetContactPhonesCountParam(hContact,"UserInfo","Fax");
-
-return(dwRet);
+ dwRet += GetContactPhonesCountParam(hContact,"UserInfo","MyPhone");
+ dwRet += GetContactPhonesCountParam(hContact,"UserInfo","Phone");
+ dwRet += GetContactPhonesCountParam(hContact,"UserInfo","Cellular");
+ dwRet += GetContactPhonesCountParam(hContact,"UserInfo","Fax");
+ return dwRet;
}
BOOL IsContactPhoneParam(HANDLE hContact,LPSTR lpszModule,LPSTR lpszValueName,LPWSTR lpwszPhone,SIZE_T dwPhoneSize)
{
- BOOL bRet=FALSE;
char szBuff[MAX_PATH];
WCHAR wszPhoneLocal[MAX_PHONE_LEN];
SIZE_T i,dwPhoneSizeLocal;
- if (DB_GetStaticStringW(hContact,lpszModule,lpszValueName,wszPhoneLocal,SIZEOF(wszPhoneLocal),&dwPhoneSizeLocal))
- if (IsPhoneW(wszPhoneLocal,dwPhoneSizeLocal))
- {
- dwPhoneSizeLocal=CopyNumberW(wszPhoneLocal,wszPhoneLocal,dwPhoneSizeLocal);
+ if ( DB_GetStaticStringW(hContact,lpszModule,lpszValueName,wszPhoneLocal,SIZEOF(wszPhoneLocal),&dwPhoneSizeLocal))
+ if ( IsPhoneW(wszPhoneLocal,dwPhoneSizeLocal)) {
+ dwPhoneSizeLocal = CopyNumberW(wszPhoneLocal,wszPhoneLocal,dwPhoneSizeLocal);
if (MemoryCompare(wszPhoneLocal,dwPhoneSizeLocal,lpwszPhone,dwPhoneSize)==CSTR_EQUAL)
- {
- bRet=TRUE;
- }
+ return TRUE;
}
- for (i=0;bRet==FALSE;i++)
- {
+ for (i=0; i <= PHONES_MIN_COUNT; i++) {
mir_snprintf(szBuff,sizeof(szBuff),"%s%ld",lpszValueName,i);
- if (DB_GetStaticStringW(hContact,lpszModule,szBuff,wszPhoneLocal,SIZEOF(wszPhoneLocal),&dwPhoneSizeLocal))
- {
- if (IsPhoneW(wszPhoneLocal,dwPhoneSizeLocal))
- {
+ if ( DB_GetStaticStringW(hContact,lpszModule,szBuff,wszPhoneLocal,SIZEOF(wszPhoneLocal),&dwPhoneSizeLocal)) {
+ if (IsPhoneW(wszPhoneLocal,dwPhoneSizeLocal)) {
dwPhoneSizeLocal=CopyNumberW(wszPhoneLocal,wszPhoneLocal,dwPhoneSizeLocal);
- if (MemoryCompare(wszPhoneLocal,dwPhoneSizeLocal,lpwszPhone,dwPhoneSize)==CSTR_EQUAL)
- {
- bRet=TRUE;
- break;
- }
+ if (MemoryCompare(wszPhoneLocal,dwPhoneSizeLocal,lpwszPhone,dwPhoneSize) == CSTR_EQUAL)
+ return TRUE;
}
- }else{
- if (i>PHONES_MIN_COUNT) break;
}
}
-return(bRet);
+ return FALSE;
}
@@ -253,8 +220,7 @@ BOOL IsContactPhone(HANDLE hContact,LPWSTR lpwszPhone,SIZE_T dwPhoneSize) dwPhoneSizeLocal=CopyNumberW(wszPhoneLocal,lpwszPhone,dwPhoneSize);
lpszProto=(LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
- if (lpszProto)
- {
+ 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);
@@ -264,7 +230,7 @@ BOOL IsContactPhone(HANDLE hContact,LPWSTR lpwszPhone,SIZE_T dwPhoneSize) if (bRet==FALSE) bRet=IsContactPhoneParam(hContact,"UserInfo","Cellular",wszPhoneLocal,dwPhoneSizeLocal);
if (bRet==FALSE) bRet=IsContactPhoneParam(hContact,"UserInfo","Fax",wszPhoneLocal,dwPhoneSizeLocal);
-return(bRet);
+ return bRet;
}
@@ -273,17 +239,14 @@ return(bRet); //If no one has this number function returns NULL.
HANDLE HContactFromPhone(LPWSTR lpwszPhone,SIZE_T dwPhoneSize)
{
- HANDLE hContact=NULL;
-
- if (lpwszPhone && dwPhoneSize)
- {
+ if (lpwszPhone && dwPhoneSize) {
//check not already on list
- for(hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);hContact!=NULL;hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0))
- {
- if (IsContactPhone(hContact,lpwszPhone,dwPhoneSize)) break;
- }
+ for (HANDLE hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact))
+ if (IsContactPhone(hContact,lpwszPhone,dwPhoneSize))
+ return hContact;
}
-return(hContact);
+
+ return NULL;
}
@@ -295,104 +258,85 @@ BOOL GetDataFromMessage(LPSTR lpszMessage,SIZE_T dwMessageSize,DWORD *pdwEventTy SIZE_T dwPhoneSizeRet=0;
UINT iIconRet=0;
- if (lpszMessage && dwMessageSize)
- {
- LPSTR lpsz;
-
- if (MemoryCompare(lpszMessage,10,"SMS From: ",10)==CSTR_EQUAL)
- {
- lpsz=(LPSTR)MemoryFind(10,lpszMessage,dwMessageSize,"\r\n",2);
- if (lpsz)
- {
- if (lpwszPhone && dwPhoneSize)
- {
- dwPhoneSizeRet=MultiByteToWideChar(CP_UTF8,0,(lpszMessage+10),min((SIZE_T)(lpsz-(lpszMessage+10)),dwPhoneSize),lpwszPhone,dwPhoneSize);
- dwPhoneSizeRet=CopyNumberW(lpwszPhone,lpwszPhone,dwPhoneSizeRet);
+ if (lpszMessage && dwMessageSize) {
+ 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),min((SIZE_T)(lpsz-(lpszMessage+10)),dwPhoneSize),lpwszPhone,dwPhoneSize);
+ dwPhoneSizeRet = CopyNumberW(lpwszPhone, lpwszPhone, dwPhoneSizeRet);
}
}
- iIconRet=0;
- dwEventTypeRet=ICQEVENTTYPE_SMS;
- bRet=TRUE;
- }else
- if (MemoryCompare(lpszMessage,23,"SMS Confirmation From: ",23)==CSTR_EQUAL)
- {
- lpsz=(LPSTR)MemoryFind(23,lpszMessage,dwMessageSize,"\r\n",2);
- if (lpsz)
- {
- if (lpwszPhone && dwPhoneSize)
- {
- dwPhoneSizeRet=MultiByteToWideChar(CP_UTF8,0,(lpszMessage+23),min((SIZE_T)(lpsz-(lpszMessage+23)),dwPhoneSize),lpwszPhone,dwPhoneSize);
- dwPhoneSizeRet=CopyNumberW(lpwszPhone,lpwszPhone,dwPhoneSizeRet);
+ iIconRet = 0;
+ dwEventTypeRet = ICQEVENTTYPE_SMS;
+ bRet = TRUE;
+ }
+ 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),min((SIZE_T)(lpsz-(lpszMessage+23)),dwPhoneSize),lpwszPhone,dwPhoneSize);
+ dwPhoneSizeRet = CopyNumberW(lpwszPhone, lpwszPhone, dwPhoneSizeRet);
}
- lpsz+=2;
+ lpsz += 2;
if (MemoryCompare(lpsz,24,"SMS was sent succesfully",24)==CSTR_EQUAL)
- {
- iIconRet=IDI_SMSSENT;
- }else{
- iIconRet=IDI_SMSNOTSENT;
- }
+ iIconRet = IDI_SMSSENT;
+ else
+ iIconRet = IDI_SMSNOTSENT;
}
- dwEventTypeRet=ICQEVENTTYPE_SMSCONFIRMATION;
- bRet=TRUE;
+ dwEventTypeRet = ICQEVENTTYPE_SMSCONFIRMATION;
+ bRet = TRUE;
}
}
- if (pdwPhoneSizeRet) (*pdwPhoneSizeRet)=dwPhoneSizeRet;
- if (pdwEventType) (*pdwEventType)=dwEventTypeRet;
- if (piIcon) (*piIcon)=iIconRet;
+ if (pdwPhoneSizeRet) *pdwPhoneSizeRet = dwPhoneSizeRet;
+ if (pdwEventType) *pdwEventType = dwEventTypeRet;
+ if (piIcon) *piIcon = iIconRet;
-return(bRet);
+ return bRet;
}
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,lpszTagStart,lpszTagEnd=lpszXML,lpszDataStart=NULL;
- va_list va;
+ BOOL bRet = FALSE;
+ int thisLevel = 0;
+ LPSTR lpszFindTag = (LPSTR)tag1, 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)
- {
- lpszTagStart++;
- lpszTagEnd--;
- if ((*((BYTE*)lpszTagStart))=='/')
- {
- if (--thisLevel<0)
- {
- if (lpszDataStart)
- {
- 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;
- }
+ while (TRUE) {
+ LPSTR lpszTagStart = (LPSTR)MemoryFindByte(lpszTagEnd-lpszXML, lpszXML, dwXMLSize, '<');
+ if (!lpszTagStart)
+ break;
+
+ lpszTagEnd = (LPSTR)MemoryFindByte(lpszTagStart-lpszXML, lpszXML, dwXMLSize, '>');
+ if (!lpszTagEnd)
+ break;
+
+ lpszTagStart++;
+ lpszTagEnd--;
+ if ((*((BYTE*)lpszTagStart)) == '/') {
+ if (--thisLevel < 0) {
+ if (lpszDataStart) {
+ if (plpszData) (*plpszData)=lpszDataStart;
+ if (pdwDataSize) (*pdwDataSize)=((lpszTagStart-1)-lpszDataStart);
+ bRet=TRUE;
}
- }else{
break;
}
- }else{
- 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;
+ }
}
}
va_end(va);
-return(bRet);
+ return bRet;
}
@@ -405,7 +349,7 @@ BOOL GetXMLFieldExBuff(LPSTR lpszXML,SIZE_T dwXMLSize,LPSTR lpszBuff,SIZE_T dwBu va_start(va,tag1);
- while(TRUE)
+ while (TRUE)
{
lpszTagStart=(LPSTR)MemoryFindByte((lpszTagEnd-lpszXML),lpszXML,dwXMLSize,'<');
if (lpszTagStart)
@@ -465,7 +409,7 @@ return(bRet); va_list va;
va_start(va,tag1);
- while(TRUE)
+ while (TRUE)
{
lpwszTagStart=(LPWSTR)MemoryFind((lpwszTagEnd-lpwszXML),lpwszXML,dwXMLSize,L"<",2);
if (lpwszTagStart)
@@ -532,51 +476,43 @@ 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 dwRetErrorCode=NO_ERROR;
- LPBYTE *plpszFounded,lpszMessageConvertedCur,lpszMessageCur,lpszMessageCurPrev,lpszMessageConvertedMax;
+ LPBYTE *plpszFound,lpszMessageConvertedCur,lpszMessageCur,lpszMessageCurPrev,lpszMessageConvertedMax;
SIZE_T i,dwFirstFoundedIndex=0,dwFoundedCount=0,dwMemPartToCopy;
-#ifdef _DEBUG //check tables
- for(i=0;i<dwReplaceItemsCount;i++)
- {
- if (lstrlen((LPTSTR)plpInReplaceItems[i])!=(pdwInReplaceItemsCounts[i]/sizeof(TCHAR))) DebugBreak();
- if (lstrlen((LPTSTR)plpOutReplaceItems[i])!=(pdwOutReplaceItemsCounts[i]/sizeof(TCHAR))) DebugBreak();
- }
-#endif
-
- plpszFounded=(LPBYTE*)MEMALLOC((sizeof(LPBYTE)*dwReplaceItemsCount));
+ plpszFound=(LPBYTE*)MEMALLOC((sizeof(LPBYTE)*dwReplaceItemsCount));
lpszMessageCurPrev=(LPBYTE)lpInBuff;
lpszMessageConvertedCur=(LPBYTE)lpOutBuff;
lpszMessageConvertedMax=(((LPBYTE)lpOutBuff)+dwOutBuffSize);
- for(i=0;i<dwReplaceItemsCount;i++)
- {// loking for in first time
- plpszFounded[i]=(LPBYTE)MemoryFind((lpszMessageCurPrev-(LPBYTE)lpInBuff),lpInBuff,dwInBuffSize,plpInReplaceItems[i],pdwInReplaceItemsCounts[i]);
- if (plpszFounded[i]) dwFoundedCount++;
+
+ // looking for in first time
+ for (i=0; i < dwReplaceItemsCount; i++) {
+ plpszFound[i] = (LPBYTE)strstr((LPCSTR)lpInBuff + (lpszMessageCurPrev-(LPBYTE)lpInBuff), (LPCSTR)plpInReplaceItems[i]);
+ if (plpszFound[i])
+ dwFoundedCount++;
}
- while(dwFoundedCount)
- {
- for(i=0;i<dwReplaceItemsCount;i++)
- {// looking for first to replace
- if (plpszFounded[i] && (plpszFounded[i]<plpszFounded[dwFirstFoundedIndex] || plpszFounded[dwFirstFoundedIndex]==NULL)) dwFirstFoundedIndex=i;
- }
+ while (dwFoundedCount) {
+ // looking for first to replace
+ for(i=0; i < dwReplaceItemsCount; i++)
+ if (plpszFound[i] && (plpszFound[i] < plpszFound[dwFirstFoundedIndex] || plpszFound[dwFirstFoundedIndex] == NULL))
+ dwFirstFoundedIndex = i;
- if (plpszFounded[dwFirstFoundedIndex])
- {// in founded
- dwMemPartToCopy=(plpszFounded[dwFirstFoundedIndex]-lpszMessageCurPrev);
- if (lpszMessageConvertedMax>(lpszMessageConvertedCur+(dwMemPartToCopy+pdwInReplaceItemsCounts[dwFirstFoundedIndex])))
- {
+ // in founded
+ if (plpszFound[dwFirstFoundedIndex]) {
+ dwMemPartToCopy=(plpszFound[dwFirstFoundedIndex]-lpszMessageCurPrev);
+ if (lpszMessageConvertedMax > (lpszMessageConvertedCur+(dwMemPartToCopy+pdwInReplaceItemsCounts[dwFirstFoundedIndex]))) {
CopyMemory(lpszMessageConvertedCur,lpszMessageCurPrev,dwMemPartToCopy);lpszMessageConvertedCur+=dwMemPartToCopy;
CopyMemory(lpszMessageConvertedCur,plpOutReplaceItems[dwFirstFoundedIndex],pdwOutReplaceItemsCounts[dwFirstFoundedIndex]);lpszMessageConvertedCur+=pdwOutReplaceItemsCounts[dwFirstFoundedIndex];
- lpszMessageCurPrev=(plpszFounded[dwFirstFoundedIndex]+pdwInReplaceItemsCounts[dwFirstFoundedIndex]);
+ lpszMessageCurPrev=(plpszFound[dwFirstFoundedIndex]+pdwInReplaceItemsCounts[dwFirstFoundedIndex]);
for(i=0;i<dwReplaceItemsCount;i++)
{// loking for in next time
- if (plpszFounded[i] && plpszFounded[i]<lpszMessageCurPrev)
+ if (plpszFound[i] && plpszFound[i]<lpszMessageCurPrev)
{
dwFoundedCount--;
- plpszFounded[i]=(LPBYTE)MemoryFind((lpszMessageCurPrev-(LPBYTE)lpInBuff),lpInBuff,dwInBuffSize,plpInReplaceItems[i],pdwInReplaceItemsCounts[i]);
- if (plpszFounded[i]) dwFoundedCount++;
+ plpszFound[i] = (LPBYTE)strstr((LPCSTR)lpInBuff + (lpszMessageCurPrev-(LPBYTE)lpInBuff), (LPCSTR)plpInReplaceItems[i]);
+ if (plpszFound[i]) dwFoundedCount++;
}
}
}else{
@@ -593,7 +529,7 @@ DWORD ReplaceInBuff(LPVOID lpInBuff,SIZE_T dwInBuffSize,SIZE_T dwReplaceItemsCou CopyMemory(lpszMessageConvertedCur,lpszMessageCurPrev,(lpszMessageCur-lpszMessageCurPrev));lpszMessageConvertedCur+=(lpszMessageCur-lpszMessageCurPrev);
(*((WORD*)lpszMessageConvertedCur))=0;
- MEMFREE(plpszFounded);
+ MEMFREE(plpszFound);
if (pdwOutBuffSize) (*pdwOutBuffSize)=(lpszMessageConvertedCur-((LPBYTE)lpOutBuff));
@@ -679,14 +615,14 @@ void LoadMsgDlgFont(int i,LOGFONT *lf,COLORREF *colour) LRESULT CALLBACK MessageSubclassProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
LRESULT lrRet=0;
- WNDPROC OldMessageEditProc=(WNDPROC)GetWindowLongPtr(hwnd,GWL_USERDATA);
+ WNDPROC OldMessageEditProc=(WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA);
switch(message){
case WM_CHAR:
if (wParam=='\n' && GetKeyState(VK_CONTROL)&0x8000)
{
PostMessage(GetParent(hwnd),WM_COMMAND,IDOK,0);
- return(0);
+ return 0;
}
break;
}
@@ -729,7 +665,7 @@ int RefreshAccountList(WPARAM eventCode,LPARAM lParam) ssSMSSettings.dwSMSAccountsCount=dwSMSAccountsCount;
SendSMSWindowsUpdateAllAccountLists();
-return(0);
+return 0;
}
//This function free the global account list.
diff --git a/plugins/SMS/src/main.cpp b/plugins/SMS/src/main.cpp index bbf821ed03..2467838e46 100644 --- a/plugins/SMS/src/main.cpp +++ b/plugins/SMS/src/main.cpp @@ -193,7 +193,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance,DWORD dwReason,LPVOID lpvReserved) break;
}
- return(TRUE);
+ return TRUE;
}
extern "C" int __declspec(dllexport) Load(void)
@@ -229,7 +229,7 @@ int OnModulesLoaded(WPARAM wParam,LPARAM lParam) LoadModules();
- return(0);
+ return 0;
}
@@ -241,7 +241,7 @@ int OnPreShutdown(WPARAM wParam,LPARAM lParam) SendSMSWindowDestroy();
FreeAccountList();
-return(0);
+ return 0;
}
diff --git a/plugins/SMS/src/options.cpp b/plugins/SMS/src/options.cpp index d34d5187eb..eef93bf2d3 100644 --- a/plugins/SMS/src/options.cpp +++ b/plugins/SMS/src/options.cpp @@ -26,44 +26,35 @@ Enjoy the code and use it smartly! */
#include "common.h"
+WORD wSMSSignControlsList[] = { IDC_BEGIN, IDC_END, IDC_SIGNATURE, IDC_SIGNGROUP };
-
-WORD wSMSSignControlsList[]={
- IDC_BEGIN,
- IDC_END,
- IDC_SIGNATURE,
- IDC_SIGNGROUP
-};
-
-
-BOOL CALLBACK DlgProcEditorOptions(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgProcEditorOptions(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ WCHAR wszSign[1024];
+
switch(msg){
case WM_INITDIALOG:
TranslateDialogDefault(hWndDlg);
- {
- WCHAR wszSign[1024];
- BOOL bSignBebefore,bUseSign;
- if (DB_SMS_GetStaticStringW(NULL,"Signature",wszSign,SIZEOF(wszSign),NULL)==FALSE)
- {
- mir_sntprintf(wszSign,SIZEOF(wszSign),TranslateW(L"From %s:\r\n\r\n"),GetContactNameW(NULL));
- }
- SET_DLG_ITEM_TEXTW(hWndDlg,IDC_SIGNATURE,wszSign);
+ if (DB_SMS_GetStaticStringW(NULL,"Signature",wszSign,SIZEOF(wszSign),NULL)==FALSE)
+ mir_sntprintf(wszSign,SIZEOF(wszSign),TranslateW(L"From %s:\r\n\r\n"),GetContactNameW(NULL));
- bUseSign=DB_SMS_GetByte(NULL,"UseSignature",SMS_DEFAULT_USESIGNATURE);
+ SET_DLG_ITEM_TEXTW(hWndDlg,IDC_SIGNATURE,wszSign);
+ {
+ BOOL bUseSign = DB_SMS_GetByte(NULL,"UseSignature",SMS_DEFAULT_USESIGNATURE);
CHECK_DLG_BUTTON(hWndDlg,IDC_USESIGNATURE,bUseSign);
EnableControlsArray(hWndDlg,(WORD*)&wSMSSignControlsList,SIZEOF(wSMSSignControlsList),bUseSign);
- bSignBebefore=DB_SMS_GetByte(NULL,"SignaturePos",SMS_DEFAULT_SIGNATUREPOS);
+ BOOL bSignBebefore=DB_SMS_GetByte(NULL,"SignaturePos",SMS_DEFAULT_SIGNATUREPOS);
CHECK_DLG_BUTTON(hWndDlg,IDC_BEGIN,bSignBebefore);
CHECK_DLG_BUTTON(hWndDlg,IDC_END,(!bSignBebefore));
-
- CHECK_DLG_BUTTON(hWndDlg,IDC_SHOWACK,DB_SMS_GetByte(NULL,"ShowACK",SMS_DEFAULT_SHOWACK));
- CHECK_DLG_BUTTON(hWndDlg,IDC_AUTOPOP,DB_SMS_GetByte(NULL,"AutoPopup",SMS_DEFAULT_AUTOPOP));
- CHECK_DLG_BUTTON(hWndDlg,IDC_SAVEWINPOS,DB_SMS_GetByte(NULL,"SavePerContact",SMS_DEFAULT_SAVEWINPOS));
}
- return(TRUE);
+
+ CHECK_DLG_BUTTON(hWndDlg,IDC_SHOWACK,DB_SMS_GetByte(NULL,"ShowACK",SMS_DEFAULT_SHOWACK));
+ CHECK_DLG_BUTTON(hWndDlg,IDC_AUTOPOP,DB_SMS_GetByte(NULL,"AutoPopup",SMS_DEFAULT_AUTOPOP));
+ CHECK_DLG_BUTTON(hWndDlg,IDC_SAVEWINPOS,DB_SMS_GetByte(NULL,"SavePerContact",SMS_DEFAULT_SAVEWINPOS));
+ return TRUE;
+
case WM_COMMAND:
SendMessage(GetParent(hWndDlg),PSM_CHANGED,0,0);
switch(LOWORD(wParam)){
@@ -72,45 +63,38 @@ BOOL CALLBACK DlgProcEditorOptions(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM break;
}
break;
+
case WM_NOTIFY:
switch(((LPNMHDR)lParam)->idFrom){
case 0:
switch (((LPNMHDR)lParam)->code){
case PSN_APPLY:
- {
- WCHAR wszSign[1024];
-
- GET_DLG_ITEM_TEXTW(hWndDlg,IDC_SIGNATURE,wszSign,SIZEOF(wszSign));
- DB_SMS_SetStringW(NULL,"Signature",wszSign);
-
- DB_SMS_SetByte(NULL,"UseSignature",IS_DLG_BUTTON_CHECKED(hWndDlg,IDC_USESIGNATURE));
- DB_SMS_SetByte(NULL,"SignaturePos",IS_DLG_BUTTON_CHECKED(hWndDlg,IDC_BEGIN));
- DB_SMS_SetByte(NULL,"ShowACK",IS_DLG_BUTTON_CHECKED(hWndDlg,IDC_SHOWACK));
- DB_SMS_SetByte(NULL,"AutoPopup",IS_DLG_BUTTON_CHECKED(hWndDlg,IDC_AUTOPOP));
- DB_SMS_SetByte(NULL,"SavePerContact",IS_DLG_BUTTON_CHECKED(hWndDlg,IDC_SAVEWINPOS));
- }
- return(TRUE);
+ GET_DLG_ITEM_TEXTW(hWndDlg,IDC_SIGNATURE,wszSign,SIZEOF(wszSign));
+ DB_SMS_SetStringW(NULL,"Signature",wszSign);
+
+ DB_SMS_SetByte(NULL,"UseSignature",IS_DLG_BUTTON_CHECKED(hWndDlg,IDC_USESIGNATURE));
+ DB_SMS_SetByte(NULL,"SignaturePos",IS_DLG_BUTTON_CHECKED(hWndDlg,IDC_BEGIN));
+ DB_SMS_SetByte(NULL,"ShowACK",IS_DLG_BUTTON_CHECKED(hWndDlg,IDC_SHOWACK));
+ DB_SMS_SetByte(NULL,"AutoPopup",IS_DLG_BUTTON_CHECKED(hWndDlg,IDC_AUTOPOP));
+ DB_SMS_SetByte(NULL,"SavePerContact",IS_DLG_BUTTON_CHECKED(hWndDlg,IDC_SAVEWINPOS));
+ return TRUE;
}
- break;
}
break;
}
-return(FALSE);
+ return FALSE;
}
int OptInitialise(WPARAM wParam,LPARAM lParam)
{
- OPTIONSDIALOGPAGE odp={0};
-
- odp.cbSize=sizeof(odp);
- odp.position=910000000;
- odp.hInstance=ssSMSSettings.hInstance;
- odp.ptszGroup=TranslateW(L"Events");
- odp.flags=(ODPF_BOLDGROUPS|ODPF_UNICODE);
- odp.pszTemplate=MAKEINTRESOURCEA(IDD_OPT_SMSPLUGIN);
- odp.ptszTitle=PROTOCOL_DISPLAY_NAME_ORIGW;
- odp.pfnDlgProc=DlgProcEditorOptions;
-
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
+ odp.position = 910000000;
+ odp.hInstance = ssSMSSettings.hInstance;
+ odp.pszGroup = "Events";
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_SMSPLUGIN);
+ odp.ptszTitle = PROTOCOL_DISPLAY_NAME_ORIGW;
+ odp.pfnDlgProc = DlgProcEditorOptions;
Options_AddPage(wParam, &odp);
return 0;
}
diff --git a/plugins/SMS/src/receive.cpp b/plugins/SMS/src/receive.cpp index fe7fd9848c..254eb9938a 100644 --- a/plugins/SMS/src/receive.cpp +++ b/plugins/SMS/src/receive.cpp @@ -141,36 +141,31 @@ int handleAckSMS(WPARAM wParam,LPARAM lParam) if ((ack->result==ACKRESULT_FAILED) || GetXMLFieldEx(lpszXML,dwXMLSize,&lpszData,&dwDataSize,"sms_response","deliverable",NULL))
{
HWND hWndDlg=SendSMSWindowHwndByHProcessGet(ack->hProcess);
- if (hWndDlg)
- {
+ if (hWndDlg) {
char szNetwork[MAX_PATH];
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,dwDataSize,"no",2)==CSTR_EQUAL)
- {
+ if (ack->result==ACKRESULT_FAILED || CompareStringA(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),NORM_IGNORECASE,lpszData,dwDataSize,"no",2)==CSTR_EQUAL) {
HWND hwndTimeOut;
char szBuff[1024];
WCHAR wszErrorMessage[1028];
LPSTR lpszErrorDescription;
- if (SendSMSWindowMultipleGet(hWndDlg))
- {
+ if (SendSMSWindowMultipleGet(hWndDlg)) {
TVITEM tvi;
tvi.mask=TVIF_TEXT;
tvi.hItem=SendSMSWindowHItemSendGet(hWndDlg);
tvi.pszText=wszPhone;
tvi.cchTextMax=SIZEOF(wszPhone);
TreeView_GetItem(GetDlgItem(hWndDlg,IDC_NUMBERSLIST),&tvi);
- }else{
- GET_DLG_ITEM_TEXTW(hWndDlg,IDC_ADDRESS,wszPhone,SIZEOF(szPhone));
}
+ else GET_DLG_ITEM_TEXTW(hWndDlg,IDC_ADDRESS,wszPhone,SIZEOF(szPhone));
- if (ack->result==ACKRESULT_FAILED)
- {
+ if (ack->result == ACKRESULT_FAILED)
lpszErrorDescription=lpszXML;
- }else{
+ else {
lpszErrorDescription=szBuff;
GetXMLFieldExBuff(lpszXML,dwXMLSize,szBuff,sizeof(szBuff),NULL,"sms_response","error","params","param",NULL);
}
@@ -180,31 +175,29 @@ int handleAckSMS(WPARAM wParam,LPARAM lParam) EnableWindow(hWndDlg,FALSE);
hwndTimeOut=CreateDialog(ssSMSSettings.hInstance,MAKEINTRESOURCE(IDD_SENDSMSTIMEDOUT),hWndDlg,SMSTimedOutDlgProc);
SET_DLG_ITEM_TEXTW(hwndTimeOut,IDC_STATUS,wszErrorMessage);
- }else{
+ }
+ else {
SendSMSWindowDBAdd(hWndDlg);
- if (SendSMSWindowMultipleGet(hWndDlg))
- {
- if (SendSMSWindowNextHItemGet(hWndDlg,SendSMSWindowHItemSendGet(hWndDlg)))
- {
+ if ( SendSMSWindowMultipleGet(hWndDlg)) {
+ if ( SendSMSWindowNextHItemGet(hWndDlg,SendSMSWindowHItemSendGet(hWndDlg))) {
SendSMSWindowAsSentSet(hWndDlg);
SendSMSWindowHItemSendSet(hWndDlg,SendSMSWindowNextHItemGet(hWndDlg,SendSMSWindowHItemSendGet(hWndDlg)));
SendSMSWindowNext(hWndDlg);
- }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)
- {
+ 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))
- {
+ 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)
- {
+ 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{
+ }
+ else {
SET_DLG_ITEM_TEXTW(hwndAccepted,IDC_ST_SOURCE,TranslateW(L"From:"));
SET_DLG_ITEM_TEXTW(hwndAccepted,IDC_ST_MESSAGEID,TranslateW(L"To:"));
GetXMLFieldExBuff(lpszXML,dwXMLSize,szSource,sizeof(szSource),NULL,"sms_response","from",NULL);
@@ -213,18 +206,16 @@ int handleAckSMS(WPARAM wParam,LPARAM lParam) SET_DLG_ITEM_TEXTA(hwndAccepted,IDC_NETWORK,szNetwork);
SET_DLG_ITEM_TEXTA(hwndAccepted,IDC_SOURCE,szSource);
SET_DLG_ITEM_TEXTA(hwndAccepted,IDC_MESSAGEID,szMessageID);
- }else{
- SendSMSWindowRemove(hWndDlg);
}
- }else{
- SendSMSWindowRemove(hWndDlg);
+ else SendSMSWindowRemove(hWndDlg);
}
+ else SendSMSWindowRemove(hWndDlg);
}
}
}
}
}
-return(0);
+ return 0;
}
//Handles new SMS messages added to the database
@@ -304,7 +295,7 @@ int handleNewMessage(WPARAM wParam,LPARAM lParam) MEMFREE(dbei.pBlob);
}
}
-return(0);
+ return 0;
}
diff --git a/plugins/SMS/src/recvdlg.cpp b/plugins/SMS/src/recvdlg.cpp index 58c33d044e..33a1a3145a 100644 --- a/plugins/SMS/src/recvdlg.cpp +++ b/plugins/SMS/src/recvdlg.cpp @@ -37,15 +37,9 @@ typedef struct HANDLE hContact;
} RECV_SMS_WINDOW_DATA;
-
-
-BOOL CALLBACK RecvSmsDlgProc (HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lParam);
-#define GET_WINDOW_DATA(hWndDlg) ((RECV_SMS_WINDOW_DATA*)GetWindowLongPtr(hWndDlg,GWL_USERDATA))
-
-
-
-
-
+INT_PTR CALLBACK RecvSmsDlgProc (HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lParam);
+#define GET_WINDOW_DATA(hWndDlg) ((RECV_SMS_WINDOW_DATA*)GetWindowLongPtr(hWndDlg,GWLP_USERDATA))
+
DWORD RecvSMSWindowInitialize()
{
DWORD dwRetErrorCode;
@@ -60,7 +54,7 @@ void RecvSMSWindowDestroy() RECV_SMS_WINDOW_DATA *prswdWindowData;
ListMTLock(&ssSMSSettings.lmtRecvSMSWindowsListMT);
- while(ListMTItemGetFirst(&ssSMSSettings.lmtRecvSMSWindowsListMT,NULL,(LPVOID*)&prswdWindowData)==NO_ERROR)
+ while (ListMTItemGetFirst(&ssSMSSettings.lmtRecvSMSWindowsListMT,NULL,(LPVOID*)&prswdWindowData)==NO_ERROR)
{// цикл
RecvSMSWindowRemove(prswdWindowData->hWnd);
}
@@ -69,7 +63,7 @@ void RecvSMSWindowDestroy() }
-BOOL CALLBACK RecvSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lParam)
+INT_PTR CALLBACK RecvSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
RECV_SMS_WINDOW_DATA *prswdWindowData=GET_WINDOW_DATA(hWndDlg);
@@ -78,15 +72,11 @@ BOOL CALLBACK RecvSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lPar TranslateDialogDefault(hWndDlg); //Translate intially - bid
prswdWindowData=(RECV_SMS_WINDOW_DATA*)lParam;
- SetWindowLongPtr(hWndDlg,GWL_USERDATA,(LONG_PTR)lParam);
-
+ SetWindowLongPtr(hWndDlg,GWLP_USERDATA,(LONG_PTR)lParam);
{
- WNDPROC OldEditWndProc;
-
- OldEditWndProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hWndDlg,IDC_MESSAGE),GWL_WNDPROC,(LONG_PTR)MessageSubclassProc);
- SetWindowLongPtr(GetDlgItem(hWndDlg,IDC_MESSAGE),GWL_USERDATA,(LONG_PTR)OldEditWndProc);
+ WNDPROC OldEditWndProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hWndDlg,IDC_MESSAGE),GWLP_WNDPROC,(LONG_PTR)MessageSubclassProc);
+ SetWindowLongPtr(GetDlgItem(hWndDlg,IDC_MESSAGE),GWLP_USERDATA,(LONG_PTR)OldEditWndProc);
}
-
{
HFONT hFont;
LOGFONT lf;
@@ -106,9 +96,9 @@ BOOL CALLBACK RecvSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lPar }
InvalidateRect(GetDlgItem(hWndDlg,IDC_MESSAGE),NULL,FALSE);
break;
+
case WM_CTLCOLORSTATIC:
- if ((HWND)lParam==GetDlgItem(hWndDlg,IDC_MESSAGE))
- {
+ if ((HWND)lParam==GetDlgItem(hWndDlg,IDC_MESSAGE)) {
COLORREF colour;
LoadMsgDlgFont(MSGFONTID_YOURMSG,NULL,&colour);
@@ -117,10 +107,12 @@ BOOL CALLBACK RecvSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lPar return((BOOL)prswdWindowData->hBkgBrush);
}
break;
+
case WM_GETMINMAXINFO:
((LPMINMAXINFO)lParam)->ptMinTrackSize.x=300;
((LPMINMAXINFO)lParam)->ptMinTrackSize.y=230;
break;
+
case WM_SIZE:
{
int cx,cy;
@@ -151,9 +143,8 @@ BOOL CALLBACK RecvSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lPar hContact=HContactFromPhone(wszPhone,GET_DLG_ITEM_TEXTW(hWndDlg,IDC_NUMBER,wszPhone,SIZEOF(wszPhone)));
hwndSendSms=SendSMSWindowIsOtherInstanceHContact(hContact);
if (hwndSendSms)
- {
SetFocus(hwndSendSms);
- }else{
+ else {
hwndSendSms=SendSMSWindowAdd(prswdWindowData->hContact);
SET_DLG_ITEM_TEXTW(hwndSendSms,IDC_ADDRESS,wszPhone);
}
@@ -163,12 +154,14 @@ BOOL CALLBACK RecvSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lPar break;
}
break;
+
case WM_CLOSE:
DeleteObject(prswdWindowData->hBkgBrush);
RecvSMSWindowRemove(hWndDlg);
break;
}
-return(FALSE);
+
+ return FALSE;
}
//SMS Receive window list functions
diff --git a/plugins/SMS/src/senddlg.cpp b/plugins/SMS/src/senddlg.cpp index 6836a6fa09..237c2ec476 100644 --- a/plugins/SMS/src/senddlg.cpp +++ b/plugins/SMS/src/senddlg.cpp @@ -51,24 +51,15 @@ typedef struct DBEVENTINFO *pdbei;
} SEND_SMS_WINDOW_DATA;
-
-
void AddContactPhonesToCombo (HWND hWnd,HANDLE hContact);
void SendSMSWindowFillTreeView (HWND hWnd);
SIZE_T GetSMSMessageLenMax (HWND hWndDlg);
-#define GET_WINDOW_DATA(hWndDlg) ((SEND_SMS_WINDOW_DATA*)GetWindowLongPtr(hWndDlg,GWL_USERDATA))
-
-
-
-
+#define GET_WINDOW_DATA(hWndDlg) ((SEND_SMS_WINDOW_DATA*)GetWindowLongPtr(hWndDlg,GWLP_USERDATA))
DWORD SendSMSWindowInitialize()
{
- DWORD dwRetErrorCode;
-
- dwRetErrorCode=ListMTInitialize(&ssSMSSettings.lmtSendSMSWindowsListMT,0);
-return(dwRetErrorCode);
+ return ListMTInitialize(&ssSMSSettings.lmtSendSMSWindowsListMT, 0);
}
void SendSMSWindowDestroy()
@@ -76,17 +67,14 @@ void SendSMSWindowDestroy() SEND_SMS_WINDOW_DATA *psswdWindowData;
ListMTLock(&ssSMSSettings.lmtSendSMSWindowsListMT);
- while(ListMTItemGetFirst(&ssSMSSettings.lmtSendSMSWindowsListMT,NULL,(LPVOID*)&psswdWindowData)==NO_ERROR)
- {// цикл
+ while (ListMTItemGetFirst(&ssSMSSettings.lmtSendSMSWindowsListMT, NULL, (LPVOID*)&psswdWindowData) == NO_ERROR)
SendSMSWindowRemove(psswdWindowData->hWnd);
- }
+
ListMTUnLock(&ssSMSSettings.lmtSendSMSWindowsListMT);
ListMTDestroy(&ssSMSSettings.lmtSendSMSWindowsListMT);
}
-
-
-BOOL CALLBACK SendSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lParam)
+INT_PTR CALLBACK SendSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
SEND_SMS_WINDOW_DATA *psswdWindowData=GET_WINDOW_DATA(hWndDlg);
@@ -96,15 +84,11 @@ BOOL CALLBACK SendSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lPar ////////AddWinHandle(GetDlgItem(hWndDlg,IDC_MESSAGE));
psswdWindowData=(SEND_SMS_WINDOW_DATA*)lParam;
- SetWindowLongPtr(hWndDlg,GWL_USERDATA,(LONG_PTR)lParam);
-
+ SetWindowLongPtr(hWndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
{
- WNDPROC OldEditWndProc;
-
- OldEditWndProc=(WNDPROC)SetWindowLongPtr(GetDlgItem(hWndDlg,IDC_MESSAGE),GWL_WNDPROC,(LONG_PTR)MessageSubclassProc);
- SetWindowLongPtr(GetDlgItem(hWndDlg,IDC_MESSAGE),GWL_USERDATA,(LONG_PTR)OldEditWndProc);
+ WNDPROC OldEditWndProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hWndDlg,IDC_MESSAGE), GWLP_WNDPROC, (LONG_PTR)MessageSubclassProc);
+ SetWindowLongPtr(GetDlgItem(hWndDlg,IDC_MESSAGE), GWLP_USERDATA, (LONG_PTR)OldEditWndProc);
}
-
SendMessage(hWndDlg,WM_SETICON,ICON_BIG,(LPARAM)LoadSkinnedIcon(SKINICON_OTHER_SMS));
SEND_DLG_ITEM_MESSAGE(hWndDlg,IDC_HISTORY,BM_SETIMAGE,IMAGE_ICON,(LPARAM)LoadSkinnedIcon(SKINICON_OTHER_HISTORY));
{
@@ -181,7 +165,7 @@ BOOL CALLBACK SendSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lPar SetWindowPos(hWndDlg,0,200,200,400,350,SWP_NOZORDER);
}
InvalidateRect(GetDlgItem(hWndDlg,IDC_MESSAGE),NULL,FALSE);
- return(TRUE);
+ return TRUE;
case WM_GETMINMAXINFO:
if (psswdWindowData->bMultiple)
{
@@ -322,25 +306,25 @@ BOOL CALLBACK SendSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lPar case IDC_MULTIPLE:
SendSMSWindowMultipleSet(hWndDlg,!psswdWindowData->bMultiple);
break;
+
case IDC_ADDNUMBER:
{
WCHAR wszPhone[MAX_PHONE_LEN];
- if (IsPhoneW(wszPhone,GET_DLG_ITEM_TEXTW(hWndDlg,IDC_ADDRESS,wszPhone,SIZEOF(wszPhone))))
- {
- TVINSERTSTRUCT tvis={0};
-
- tvis.item.mask=(TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE);
- tvis.hInsertAfter=TVI_SORT;
- tvis.item.pszText=wszPhone;
- TreeView_InsertItem(GetDlgItem(hWndDlg,IDC_NUMBERSLIST),&tvis);
- }else{
- MessageBox(hWndDlg,TranslateW(L"The phone szPhone should start with a + and consist of numbers, spaces, brackets and hyphens only."),TranslateW(L"Invalid Phone Number"),MB_OK);
+ if (IsPhoneW(wszPhone,GET_DLG_ITEM_TEXTW(hWndDlg,IDC_ADDRESS,wszPhone,SIZEOF(wszPhone)))) {
+ TVINSERTSTRUCT tvis = {0};
+ tvis.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+ tvis.hInsertAfter = TVI_SORT;
+ tvis.item.pszText = wszPhone;
+ TreeView_InsertItem( GetDlgItem(hWndDlg,IDC_NUMBERSLIST), &tvis);
}
+ else MessageBox(hWndDlg,TranslateW(L"The phone szPhone should start with a + and consist of numbers, spaces, brackets and hyphens only."),TranslateW(L"Invalid Phone Number"),MB_OK);
}
break;
+
case IDC_HISTORY:
CallService(MS_HISTORY_SHOWCONTACTHISTORY,(WPARAM)psswdWindowData->hMyContact,0);
break;
+
case IDOK:
if ((SIZE_T)GET_DLG_ITEM_TEXT_LENGTH(hWndDlg,IDC_MESSAGE) > GetSMSMessageLenMax(hWndDlg))
{
@@ -521,10 +505,10 @@ BOOL CALLBACK SendSmsDlgProc(HWND hWndDlg,UINT message,WPARAM wParam,LPARAM lPar SendSMSWindowRemove(hWndDlg);
break;
}
-return(FALSE);
+return FALSE;
}
-BOOL CALLBACK SMSTimedOutDlgProc(HWND hWndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+INT_PTR CALLBACK SMSTimedOutDlgProc(HWND hWndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg){
case WM_INITDIALOG:
@@ -536,7 +520,7 @@ BOOL CALLBACK SMSTimedOutDlgProc(HWND hWndDlg,UINT msg,WPARAM wParam,LPARAM lPar SetWindowPos(hWndDlg,0,(rcParent.left+rcParent.right-(rc.right-rc.left))/2,(rcParent.top+rcParent.bottom-(rc.bottom-rc.top))/2,0,0,SWP_NOZORDER|SWP_NOSIZE);
KillTimer(GetParent(hWndDlg),TIMERID_MSGSEND);
}
- return(TRUE);
+ return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam)){
case IDOK:
@@ -550,23 +534,24 @@ BOOL CALLBACK SMSTimedOutDlgProc(HWND hWndDlg,UINT msg,WPARAM wParam,LPARAM lPar }
break;
}
-return(FALSE);
+ return FALSE;
}
-BOOL CALLBACK SMSAcceptedDlgProc(HWND hWndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+INT_PTR CALLBACK SMSAcceptedDlgProc(HWND hWndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg){
case WM_INITDIALOG:
+ TranslateDialogDefault(hWndDlg);
{
RECT rc,rcParent;
- TranslateDialogDefault(hWndDlg);
GetWindowRect(hWndDlg,&rc);
GetWindowRect(GetParent(hWndDlg),&rcParent);
SetWindowPos(hWndDlg,0,(rcParent.left+rcParent.right-(rc.right-rc.left))/2,(rcParent.top+rcParent.bottom-(rc.bottom-rc.top))/2,0,0,SWP_NOZORDER|SWP_NOSIZE);
}
- return(TRUE);
+ return TRUE;
+
case WM_COMMAND:
- switch(LOWORD(wParam)){
+ switch(LOWORD(wParam)) {
case IDOK:
SendSMSWindowRemove(GetParent(hWndDlg));
DestroyWindow(hWndDlg);
@@ -574,7 +559,7 @@ BOOL CALLBACK SMSAcceptedDlgProc(HWND hWndDlg,UINT msg,WPARAM wParam,LPARAM lPar }
break;
}
-return(FALSE);
+ return FALSE;
}
//SMS Send window list functions
@@ -587,12 +572,10 @@ HWND SendSMSWindowAdd(HANDLE hContact) SEND_SMS_WINDOW_DATA *psswdWindowData;
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)
- {
+ if (psswdWindowData) {
+ psswdWindowData->hMyContact = hContact;
+ psswdWindowData->hWnd = CreateDialogParam(ssSMSSettings.hInstance, MAKEINTRESOURCE(IDD_SENDSMS), NULL, SendSmsDlgProc, (LPARAM)psswdWindowData);
+ if (psswdWindowData->hWnd) {
WCHAR wszTitle[MAX_PATH];
LPWSTR lpwszContactDisplayName;
@@ -608,18 +591,17 @@ HWND SendSMSWindowAdd(HANDLE hContact) AddContactPhonesToCombo(psswdWindowData->hWnd,hContact);
SetFocus(GetDlgItem(psswdWindowData->hWnd,IDC_MESSAGE));
hRet=psswdWindowData->hWnd;
- }else{
- MEMFREE(psswdWindowData);
}
+ else MEMFREE(psswdWindowData);
}
-return(hRet);
+ return hRet;
}
//This function close the SMS send window that given, and remove it from the list.
//The function gets the HWND of the window that should be removed and return void
void SendSMSWindowRemove(HWND hWndDlg)
{
- SEND_SMS_WINDOW_DATA *psswdWindowData=GET_WINDOW_DATA(hWndDlg);
+ SEND_SMS_WINDOW_DATA *psswdWindowData = GET_WINDOW_DATA(hWndDlg);
if (psswdWindowData)
{
@@ -675,7 +657,7 @@ HWND SendSMSWindowHwndByHProcessGet(HANDLE hProcess) hRet=psswdWindowData->hWnd;
break;
}
- }while(ListMTIteratorMoveNext(&lmtiIterator));
+ }while (ListMTIteratorMoveNext(&lmtiIterator));
ListMTUnLock(&ssSMSSettings.lmtSendSMSWindowsListMT);
return(hRet);
}
@@ -886,7 +868,7 @@ HWND SendSMSWindowIsOtherInstanceHContact(HANDLE hContact) hRet=psswdWindowData->hWnd;
break;
}
- }while(ListMTIteratorMoveNext(&lmtiIterator));
+ }while (ListMTIteratorMoveNext(&lmtiIterator));
ListMTUnLock(&ssSMSSettings.lmtSendSMSWindowsListMT);
return(hRet);
}
@@ -1000,7 +982,7 @@ void SendSMSWindowsUpdateAllAccountLists() {
SendSMSWindowUpdateAccountList(psswdWindowData->hWnd);
}
- }while(ListMTIteratorMoveNext(&lmtiIterator));
+ }while (ListMTIteratorMoveNext(&lmtiIterator));
ListMTUnLock(&ssSMSSettings.lmtSendSMSWindowsListMT);
}
//////////////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/SMS/src/senddlg.h b/plugins/SMS/src/senddlg.h index 225cf80f28..f17458a7fc 100644 --- a/plugins/SMS/src/senddlg.h +++ b/plugins/SMS/src/senddlg.h @@ -6,35 +6,36 @@ #pragma once
#endif // _MSC_VER > 1000
-
-DWORD SendSMSWindowInitialize ();
-void SendSMSWindowDestroy ();
+DWORD SendSMSWindowInitialize();
+void SendSMSWindowDestroy();
//Decleration of SMS send window list
-BOOL CALLBACK SMSAcceptedDlgProc (HWND hWndDlg,UINT msg,WPARAM wParam,LPARAM lParam);
-BOOL CALLBACK SMSTimedOutDlgProc (HWND hWndDlg,UINT msg,WPARAM wParam,LPARAM lParam);
-HWND SendSMSWindowAdd (HANDLE hContact);
-void SendSMSWindowRemove (HWND hWndDlg);
-HANDLE SendSMSWindowHContactGet (HWND hWndDlg);
-void SendSMSWindowHContactSet (HWND hWndDlg,HANDLE hContact);
-HWND SendSMSWindowHwndByHProcessGet (HANDLE hProcess);
-void SendSMSWindowHProcessSet (HWND hWndDlg,HANDLE hProcess);
-BOOL SendSMSWindowMultipleGet (HWND hWndDlg);
-void SendSMSWindowMultipleSet (HWND hWndDlg,BOOL bMultiple);
-void SendSMSWindowNumberSet (HWND hWndDlg,LPWSTR lpwszPhone,SIZE_T dwPhoneSize);
-void SendSMSWindowAsSentSet (HWND hWndDlg);
-void SendSMSWindowDbeiSet (HWND hWndDlg,DBEVENTINFO *pdbei);
-void SendSMSWindowDBAdd (HWND hWndDlg);
-void SendSMSWindowHItemSendSet (HWND hWndDlg,HTREEITEM hItemSend);
-HTREEITEM SendSMSWindowHItemSendGet (HWND hWndDlg);
-HTREEITEM SendSMSWindowNextHItemGet (HWND hWndDlg,HTREEITEM hItem);
-HWND SendSMSWindowIsOtherInstanceHContact(HANDLE hContact);
-void SendSMSWindowNext (HWND hWndDlg);
-
-void SendSMSWindowSMSContactAdd (HWND hWndDlg,HANDLE hContact);
-HANDLE SendSMSWindowSMSContactGet (HWND hWndDlg,SIZE_T iNum);
-void SendSMSWindowSMSContactsRemove (HWND hWndDlg);
-void SendSMSWindowUpdateAccountList (HWND hWndDlg);
-void SendSMSWindowsUpdateAllAccountLists ();
+INT_PTR CALLBACK SMSAcceptedDlgProc(HWND hWndDlg,UINT msg,WPARAM wParam,LPARAM lParam);
+INT_PTR CALLBACK SMSTimedOutDlgProc(HWND hWndDlg,UINT msg,WPARAM wParam,LPARAM lParam);
+
+HTREEITEM SendSMSWindowHItemSendGet(HWND hWndDlg);
+HTREEITEM SendSMSWindowNextHItemGet(HWND hWndDlg,HTREEITEM hItem);
+
+HWND SendSMSWindowAdd(HANDLE hContact);
+void SendSMSWindowRemove(HWND hWndDlg);
+HANDLE SendSMSWindowHContactGet(HWND hWndDlg);
+void SendSMSWindowHContactSet(HWND hWndDlg,HANDLE hContact);
+HWND SendSMSWindowHwndByHProcessGet(HANDLE hProcess);
+void SendSMSWindowHProcessSet(HWND hWndDlg,HANDLE hProcess);
+BOOL SendSMSWindowMultipleGet(HWND hWndDlg);
+void SendSMSWindowMultipleSet(HWND hWndDlg,BOOL bMultiple);
+void SendSMSWindowNumberSet(HWND hWndDlg,LPWSTR lpwszPhone,SIZE_T dwPhoneSize);
+void SendSMSWindowAsSentSet(HWND hWndDlg);
+void SendSMSWindowDbeiSet(HWND hWndDlg,DBEVENTINFO *pdbei);
+void SendSMSWindowDBAdd(HWND hWndDlg);
+void SendSMSWindowHItemSendSet(HWND hWndDlg,HTREEITEM hItemSend);
+HWND SendSMSWindowIsOtherInstanceHContact(HANDLE hContact);
+void SendSMSWindowNext(HWND hWndDlg);
+
+void SendSMSWindowSMSContactAdd(HWND hWndDlg,HANDLE hContact);
+HANDLE SendSMSWindowSMSContactGet(HWND hWndDlg,SIZE_T iNum);
+void SendSMSWindowSMSContactsRemove(HWND hWndDlg);
+void SendSMSWindowUpdateAccountList(HWND hWndDlg);
+void SendSMSWindowsUpdateAllAccountLists();
#endif // !defined(AFX_SMS_SENDDLG_H__F58D13FF_F6F2_476C_B8F0_7B9E9357CF48__INCLUDED_)
|