diff options
44 files changed, 2180 insertions, 2433 deletions
diff --git a/plugins/Clist_modern/clist_modern.vcxproj b/plugins/Clist_modern/clist_modern.vcxproj index 8c88af5879..da7a7228b6 100644 --- a/plugins/Clist_modern/clist_modern.vcxproj +++ b/plugins/Clist_modern/clist_modern.vcxproj @@ -25,4 +25,9 @@ <ImportGroup Label="PropertySheets">
<Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" />
</ImportGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <DisableSpecificWarnings>4458;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ </ClCompile>
+ </ItemDefinitionGroup>
</Project>
\ No newline at end of file diff --git a/plugins/ListeningTo/src/players/generic.cpp b/plugins/ListeningTo/src/players/generic.cpp index dcf7ba02df..df0a14304e 100644 --- a/plugins/ListeningTo/src/players/generic.cpp +++ b/plugins/ListeningTo/src/players/generic.cpp @@ -104,95 +104,94 @@ GenericPlayer::~GenericPlayer() void GenericPlayer::ProcessReceived()
{
- {
- mir_cslock lck(cs);
+ mir_cslockfull lck(cs);
- // Do the processing
- // L"<Status 0-stoped 1-playing>\\0<Player>\\0<Type>\\0<Title>\\0<Artist>\\0<Album>\\0<Track>\\0<Year>\\0<Genre>\\0<Length (secs)>\\0\\0"
+ // Do the processing
+ // L"<Status 0-stoped 1-playing>\\0<Player>\\0<Type>\\0<Title>\\0<Artist>\\0<Album>\\0<Track>\\0<Year>\\0<Genre>\\0<Length (secs)>\\0\\0"
- WCHAR *p1 = wcsstr(received, L"\\0");
- if (IsEmpty(received) || p1 == NULL)
- return;
+ WCHAR *p1 = wcsstr(received, L"\\0");
+ if (IsEmpty(received) || p1 == NULL)
+ return;
- // Process string
- WCHAR *parts[11] = { 0 };
- int pCount = 0;
- WCHAR *p = received;
- do {
- *p1 = _T('\0');
- parts[pCount] = p;
- pCount++;
- p = p1 + 2;
- p1 = wcsstr(p, _T("\\0"));
- } while (p1 != NULL && pCount < 10);
- if (p1 != NULL)
- *p1 = _T('\0');
+ // Process string
+ WCHAR *parts[11] = { 0 };
+ int pCount = 0;
+ WCHAR *p = received;
+ do {
+ *p1 = _T('\0');
parts[pCount] = p;
+ pCount++;
+ p = p1 + 2;
+ p1 = wcsstr(p, _T("\\0"));
+ } while (p1 != NULL && pCount < 10);
+ if (p1 != NULL)
+ *p1 = _T('\0');
+ parts[pCount] = p;
+
+ if (pCount < 5)
+ return;
- if (pCount < 5)
- return;
-
- // See if player is enabled
- Player *player = this;
- for (int i = FIRST_PLAYER; i < NUM_PLAYERS; i++) {
+ // See if player is enabled
+ Player *player = this;
+ for (int i = FIRST_PLAYER; i < NUM_PLAYERS; i++) {
- WCHAR *player_name = players[i]->name;
+ WCHAR *player_name = players[i]->name;
- if (_wcsicmp(parts[1], player_name) == 0) {
- player = players[i];
- break;
- }
+ if (_wcsicmp(parts[1], player_name) == 0) {
+ player = players[i];
+ break;
}
+ }
- player->FreeData();
+ player->FreeData();
- if (wcscmp(L"1", parts[0]) != 0 || IsEmpty(parts[1]) || (IsEmpty(parts[3]) && IsEmpty(parts[4]))) {
- // Stoped playing or not enought info
- }
- else {
- mir_cslock lck(player->GetLock());
- LISTENINGTOINFO *li = player->GetInfo();
-
- li->cbSize = sizeof(listening_info);
- li->dwFlags = LTI_TCHAR;
- li->ptszType = U2TD(parts[2], _T("Music"));
- li->ptszTitle = U2T(parts[3]);
- li->ptszArtist = U2T(parts[4]);
- li->ptszAlbum = U2T(parts[5]);
- li->ptszTrack = U2T(parts[6]);
- li->ptszYear = U2T(parts[7]);
- li->ptszGenre = U2T(parts[8]);
-
- if (player == this)
- li->ptszPlayer = mir_u2t(parts[1]);
- else
- li->ptszPlayer = mir_tstrdup(player->name);
-
- if (parts[9] != NULL) {
- long length = _wtoi(parts[9]);
- if (length > 0) {
- li->ptszLength = (TCHAR*)mir_alloc(10 * sizeof(TCHAR));
-
- int s = length % 60;
- int m = (length / 60) % 60;
- int h = (length / 60) / 60;
-
- if (h > 0)
- mir_sntprintf(li->ptszLength, 9, _T("%d:%02d:%02d"), h, m, s);
- else
- mir_sntprintf(li->ptszLength, 9, _T("%d:%02d"), m, s);
- }
+ if (wcscmp(L"1", parts[0]) != 0 || IsEmpty(parts[1]) || (IsEmpty(parts[3]) && IsEmpty(parts[4]))) {
+ // Stoped playing or not enought info
+ }
+ else {
+ mir_cslock plck(player->GetLock());
+ LISTENINGTOINFO *li = player->GetInfo();
+
+ li->cbSize = sizeof(listening_info);
+ li->dwFlags = LTI_TCHAR;
+ li->ptszType = U2TD(parts[2], _T("Music"));
+ li->ptszTitle = U2T(parts[3]);
+ li->ptszArtist = U2T(parts[4]);
+ li->ptszAlbum = U2T(parts[5]);
+ li->ptszTrack = U2T(parts[6]);
+ li->ptszYear = U2T(parts[7]);
+ li->ptszGenre = U2T(parts[8]);
+
+ if (player == this)
+ li->ptszPlayer = mir_u2t(parts[1]);
+ else
+ li->ptszPlayer = mir_tstrdup(player->name);
+
+ if (parts[9] != NULL) {
+ long length = _wtoi(parts[9]);
+ if (length > 0) {
+ li->ptszLength = (TCHAR*)mir_alloc(10 * sizeof(TCHAR));
+
+ int s = length % 60;
+ int m = (length / 60) % 60;
+ int h = (length / 60) / 60;
+
+ if (h > 0)
+ mir_sntprintf(li->ptszLength, 9, _T("%d:%02d:%02d"), h, m, s);
+ else
+ mir_sntprintf(li->ptszLength, 9, _T("%d:%02d"), m, s);
}
}
+ }
- // Put back the '\\'s
- for (int i = 1; i <= pCount; i++)
- *(parts[i] - 2) = L'\\';
- if (p1 != NULL)
- *p1 = L'\\';
+ // Put back the '\\'s
+ for (int i = 1; i <= pCount; i++)
+ *(parts[i] - 2) = L'\\';
+ if (p1 != NULL)
+ *p1 = L'\\';
- wcscpy(last_received, received);
- }
+ wcscpy(last_received, received);
+ lck.unlock();
NotifyInfoChanged();
}
diff --git a/plugins/MyDetails/src/data.cpp b/plugins/MyDetails/src/data.cpp index aaaa94358e..1bd0754b8f 100644 --- a/plugins/MyDetails/src/data.cpp +++ b/plugins/MyDetails/src/data.cpp @@ -144,8 +144,6 @@ int Protocol::GetStatus() void Protocol::SetStatus(int aStatus)
{
- TCHAR status_msg[256];
-
if (ServiceExists(MS_CS_SETSTATUSEX)) {
// BEGIN From commomstatus.cpp (KeepStatus)
int i, count, pCount;
@@ -170,6 +168,7 @@ void Protocol::SetStatus(int aStatus) pse[0]->status = aStatus;
pse[0]->szName = name;
+ TCHAR status_msg[256];
GetStatusMsg(aStatus, status_msg, _countof(status_msg));
pse[0]->szMsg = status_msg;
diff --git a/plugins/PasteIt/src/PasteToWeb.cpp b/plugins/PasteIt/src/PasteToWeb.cpp index 52f7c8f147..c57cd58c38 100644 --- a/plugins/PasteIt/src/PasteToWeb.cpp +++ b/plugins/PasteIt/src/PasteToWeb.cpp @@ -284,9 +284,9 @@ void PasteToWeb::FromClipboard() if (mir_strlen(cStr) > str.length())
{
str = L"";
- LPWSTR wStr = mir_a2u_cp(cStr, CP_ACP);
- str.append(wStr, wStr + mir_wstrlen(wStr));
- mir_free(wStr);
+ LPWSTR p = mir_a2u_cp(cStr, CP_ACP);
+ str.append(p, p + mir_wstrlen(p));
+ mir_free(p);
}
GlobalUnlock(obj);
}
diff --git a/plugins/QuickMessages/src/options.cpp b/plugins/QuickMessages/src/options.cpp index 6a21be954f..e3d2abfa1e 100644 --- a/plugins/QuickMessages/src/options.cpp +++ b/plugins/QuickMessages/src/options.cpp @@ -111,7 +111,6 @@ void SetMenuEntryProperties(HWND hdlg) {
TVITEM tvi;
HTREEITEM hItem = NULL;
- ButtonData* bd = NULL;
int pos = 0;
if (TreeView_GetCount(hButtonsList) && (tvi.hItem = TreeView_GetSelection(hButtonsList))) {
@@ -137,7 +136,7 @@ void SetMenuEntryProperties(HWND hdlg) TreeView_GetItem(hMenuTree, &tvi);
if (tvi.lParam) {
- ButtonData* bd = (ButtonData*)tvi.lParam;
+ ButtonData *bd = (ButtonData*)tvi.lParam;
TCHAR szValue[256];
GetDlgItemText(hdlg, IDC_MENUVALUE, szValue, _countof(szValue));
if (mir_tstrlen(szValue)) {
@@ -154,7 +153,7 @@ void SetMenuEntryProperties(HWND hdlg) }
while (tvi.hItem) {
TreeView_GetItem(hMenuTree, &tvi);
- bd = (ButtonData*)tvi.lParam;
+ ButtonData *bd = (ButtonData*)tvi.lParam;
bd->dwOPPos = pos++;
diff --git a/plugins/Rate/src/main.cpp b/plugins/Rate/src/main.cpp index d4e34a913e..9b8cb8a990 100644 --- a/plugins/Rate/src/main.cpp +++ b/plugins/Rate/src/main.cpp @@ -38,11 +38,11 @@ HINSTANCE g_hInst;
static HANDLE hExtraIcon = NULL;
-byte bRate = 0;
int hLangpack;
-PLUGININFOEX pluginInfo={
- sizeof(PLUGININFOEX),
+PLUGININFOEX pluginInfo =
+{
+ sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
__DESCRIPTION,
@@ -50,15 +50,15 @@ PLUGININFOEX pluginInfo={ __AUTHOREMAIL,
__COPYRIGHT,
__AUTHORWEB,
- UNICODE_AWARE,
+ UNICODE_AWARE,
// {45230488-977B-405B-856D-EA276D7083B7}
- {0x45230488, 0x977b, 0x405b, {0x85, 0x6d, 0xea, 0x27, 0x6d, 0x70, 0x83, 0xb7}}
+ {0x45230488, 0x977b, 0x405b, {0x85, 0x6d, 0xea, 0x27, 0x6d, 0x70, 0x83, 0xb7}}
};
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
{
- g_hInst = hinstDLL;
- return TRUE;
+ g_hInst = hinstDLL;
+ return TRUE;
}
// плагининфо
diff --git a/plugins/SeenPlugin/src/options.cpp b/plugins/SeenPlugin/src/options.cpp index e704a9f8c2..89aeb04247 100644 --- a/plugins/SeenPlugin/src/options.cpp +++ b/plugins/SeenPlugin/src/options.cpp @@ -76,17 +76,15 @@ INT_PTR CALLBACK OptsPopupsDlgProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lp SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
else if (HIWORD(wparam) == CPN_COLOURCHANGED) {
WORD idText, idBack;
- POPUPDATAT ppd = { 0 };
- DBVARIANT dbv = { 0 };
- DWORD temp;
if (LOWORD(wparam) > ID_STATUS_OUTTOLUNCH) // we have clicked a text color
idText = wparam, idBack = wparam - 20;
else
idText = wparam + 20, idBack = wparam;
+ POPUPDATAT ppd = { 0 };
ppd.colorBack = SendDlgItemMessage(hdlg, idBack, CPM_GETCOLOUR, 0, 0);
ppd.colorText = SendDlgItemMessage(hdlg, idText, CPM_GETCOLOUR, 0, 0);
- temp = GetDWordFromColors(ppd.colorBack, ppd.colorText);
+ DWORD temp = GetDWordFromColors(ppd.colorBack, ppd.colorText);
GetColorsFromDWord(&ppd.colorBack, &ppd.colorText, temp);
SendDlgItemMessage(hdlg, idBack, CPM_SETCOLOUR, 0, ppd.colorBack);
SendDlgItemMessage(hdlg, idText, CPM_SETCOLOUR, 0, ppd.colorText);
diff --git a/plugins/SendScreenshotPlus/SendSS.vcxproj b/plugins/SendScreenshotPlus/SendSS.vcxproj index 888122204d..666cd45526 100644 --- a/plugins/SendScreenshotPlus/SendSS.vcxproj +++ b/plugins/SendScreenshotPlus/SendSS.vcxproj @@ -27,6 +27,7 @@ </ImportGroup>
<ItemDefinitionGroup>
<ClCompile>
+ <DisableSpecificWarnings>4458;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<ExceptionHandling>Sync</ExceptionHandling>
</ClCompile>
</ItemDefinitionGroup>
diff --git a/plugins/SkypeStatusChange/src/main.cpp b/plugins/SkypeStatusChange/src/main.cpp index ab63f7ba5f..b8ab4b47ba 100644 --- a/plugins/SkypeStatusChange/src/main.cpp +++ b/plugins/SkypeStatusChange/src/main.cpp @@ -47,7 +47,7 @@ enum LPCTSTR g_pszSkypeWndClassName = _T("SkypeHelperWindow{155198f0-8749-47b7-ac53-58f2ac70844c}");
-const CMirandaStatus2SkypeStatus g_aStatusCode[10] =
+const CMirandaStatus2SkypeStatus g_aStatusCode[10] =
{
{ID_STATUS_AWAY, "AWAY",_T("Away")},
{ID_STATUS_NA, "AWAY",_T("NA")}, // removed in Skype 5
@@ -61,21 +61,21 @@ const CMirandaStatus2SkypeStatus g_aStatusCode[10] = {ID_STATUS_OUTTOLUNCH,"DND",_T("Out to lunch")}
};
-enum{INVALID_INDEX = 0xFFFFFFFF};
-
+enum { INVALID_INDEX = 0xFFFFFFFF };
+
class CStatusInfo
{
public:
- CStatusInfo() : m_nStatusIndex(INVALID_INDEX){m_szModule[0] = '\0';}
+ CStatusInfo() : m_nStatusIndex(INVALID_INDEX) { m_szModule[0] = '\0'; }
- size_t StatusIndex()const{return m_nStatusIndex;}
- void StatusIndex(size_t val){m_nStatusIndex = val;}
+ size_t StatusIndex()const { return m_nStatusIndex; }
+ void StatusIndex(size_t val) { m_nStatusIndex = val; }
- const char* Module()const{return m_szModule;}
+ const char* Module()const { return m_szModule; }
void Module(const char* val)
{
if (val)
- strncpy_s(m_szModule,val,mir_strlen(val));
+ strncpy_s(m_szModule, val, mir_strlen(val));
else
m_szModule[0] = '\0';
}
@@ -99,27 +99,26 @@ int SSC_OnProtocolAck(WPARAM, LPARAM lParam) return 0;
if (!g_Options.IsProtocolExcluded(pAckData->szModule)) {
- int nStatus = CallProtoService(pAckData->szModule,PS_GETSTATUS,0,0);
- for(size_t i = 0; i < _countof(g_aStatusCode); ++i) {
+ int nStatus = CallProtoService(pAckData->szModule, PS_GETSTATUS, 0, 0);
+ for (size_t i = 0; i < _countof(g_aStatusCode); ++i) {
const CMirandaStatus2SkypeStatus& ms = g_aStatusCode[i];
if (ms.m_nMirandaStatus == nStatus) {
int nPrevStatus;
- if ((false == g_Options.IsProtocolStatusExcluded(pAckData->szModule,nStatus))
- && ((false == g_Options.GetSyncStatusStateFlag())
- || (false == g_Options.GetPreviousStatus(pAckData->szModule,nPrevStatus))
- || (nPrevStatus != nStatus)))
- {
- {
- mir_cslock guard(g_csStatusInfo);
- g_CurrStatusInfo.StatusIndex(i);
- g_CurrStatusInfo.Module(pAckData->szModule);
- }
- if (0 == ::PostMessage(HWND_BROADCAST,g_MsgIDSkypeControlAPIDiscover,(WPARAM)g_wndMainWindow,0)) {
- mir_cslock guard(g_csStatusInfo);
- g_CurrStatusInfo.StatusIndex(INVALID_INDEX);
- g_CurrStatusInfo.Module(NULL);
- }
- else g_Options.SetPreviousStatus(pAckData->szModule,nStatus);
+ if ((false == g_Options.IsProtocolStatusExcluded(pAckData->szModule, nStatus))
+ && ((false == g_Options.GetSyncStatusStateFlag())
+ || (false == g_Options.GetPreviousStatus(pAckData->szModule, nPrevStatus))
+ || (nPrevStatus != nStatus))) {
+ {
+ mir_cslock guard(g_csStatusInfo);
+ g_CurrStatusInfo.StatusIndex(i);
+ g_CurrStatusInfo.Module(pAckData->szModule);
+ }
+ if (0 == ::PostMessage(HWND_BROADCAST, g_MsgIDSkypeControlAPIDiscover, (WPARAM)g_wndMainWindow, 0)) {
+ mir_cslock guard(g_csStatusInfo);
+ g_CurrStatusInfo.StatusIndex(INVALID_INDEX);
+ g_CurrStatusInfo.Module(NULL);
+ }
+ else g_Options.SetPreviousStatus(pAckData->szModule, nStatus);
}
break;
}
@@ -129,31 +128,31 @@ int SSC_OnProtocolAck(WPARAM, LPARAM lParam) return 0;
}
-static void ThreadFunc(void*)
-{
+static void ThreadFunc(void*)
+{
while (true) {
MSG msg;
- if (TRUE == ::PeekMessage(&msg,g_wndMainWindow,0,0,PM_NOREMOVE)) {
- while(::GetMessage(&msg,g_wndMainWindow,0,0)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
+ if (TRUE == ::PeekMessage(&msg, g_wndMainWindow, 0, 0, PM_NOREMOVE)) {
+ while (::GetMessage(&msg, g_wndMainWindow, 0, 0)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
}
else {
- DWORD dwResult = ::MsgWaitForMultipleObjects(1,&g_hEventShutdown,FALSE,INFINITE,QS_ALLEVENTS);
+ DWORD dwResult = ::MsgWaitForMultipleObjects(1, &g_hEventShutdown, FALSE, INFINITE, QS_ALLEVENTS);
_ASSERT(WAIT_FAILED != dwResult);
if (WAIT_OBJECT_0 == dwResult)
break;
}
}
-}
+}
LRESULT APIENTRY SkypeAPI_WindowProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
LRESULT lReturnCode = 0;
bool bIssueDefProc = false;
- switch(msg) {
+ switch (msg) {
case WM_DESTROY:
g_wndMainWindow = NULL;
break;
@@ -163,7 +162,7 @@ LRESULT APIENTRY SkypeAPI_WindowProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) default:
if (msg == g_MsgIDSkypeControlAPIAttach) {
- switch(lp) {
+ switch (lp) {
case SKYPECONTROLAPI_ATTACH_SUCCESS:
{
CStatusInfo si;
@@ -175,40 +174,38 @@ LRESULT APIENTRY SkypeAPI_WindowProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) const CMirandaStatus2SkypeStatus& ms = g_aStatusCode[si.StatusIndex()];
HWND wndSkypeAPIWindow = reinterpret_cast<HWND>(wp);
- enum{BUFFER_SIZE = 256};
+ enum { BUFFER_SIZE = 256 };
char szSkypeCmd[BUFFER_SIZE];
const char szSkypeCmdSetStatus[] = "SET USERSTATUS ";
- ::strncpy_s(szSkypeCmd,szSkypeCmdSetStatus,sizeof(szSkypeCmdSetStatus)/sizeof(szSkypeCmdSetStatus[0]));
+ ::strncpy_s(szSkypeCmd, szSkypeCmdSetStatus, sizeof(szSkypeCmdSetStatus) / sizeof(szSkypeCmdSetStatus[0]));
::strncat_s(szSkypeCmd, ms.m_pszSkypeStatus, _countof(szSkypeCmd) - mir_strlen(szSkypeCmd));
DWORD cLength = static_cast<DWORD>(mir_strlen(szSkypeCmd));
COPYDATASTRUCT oCopyData;
- oCopyData.dwData=0;
+ oCopyData.dwData = 0;
oCopyData.lpData = szSkypeCmd;
- oCopyData.cbData = cLength+1;
- SendMessage(wndSkypeAPIWindow,WM_COPYDATA,(WPARAM)hWnd,(LPARAM)&oCopyData);
+ oCopyData.cbData = cLength + 1;
+ SendMessage(wndSkypeAPIWindow, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&oCopyData);
if (g_Options.GetSyncStatusMsgFlag()) {
TCHAR* pszStatusMsg = NULL;
- if ( ProtoServiceExists(si.Module(), PS_GETMYAWAYMSG))
- pszStatusMsg = reinterpret_cast<TCHAR*>(CallProtoService(si.Module(),PS_GETMYAWAYMSG,(WPARAM)ms.m_nMirandaStatus,SGMA_TCHAR));
+ if (ProtoServiceExists(si.Module(), PS_GETMYAWAYMSG))
+ pszStatusMsg = reinterpret_cast<TCHAR*>(CallProtoService(si.Module(), PS_GETMYAWAYMSG, (WPARAM)ms.m_nMirandaStatus, SGMA_TCHAR));
- if ((NULL == pszStatusMsg) || (CALLSERVICE_NOTFOUND == reinterpret_cast<int>(pszStatusMsg)))
- pszStatusMsg = reinterpret_cast<TCHAR*>(CallService(MS_AWAYMSG_GETSTATUSMSGT,(WPARAM)ms.m_nMirandaStatus,0));
+ if ((NULL == pszStatusMsg) || (CALLSERVICE_NOTFOUND == INT_PTR(pszStatusMsg)))
+ pszStatusMsg = reinterpret_cast<TCHAR*>(CallService(MS_AWAYMSG_GETSTATUSMSGT, (WPARAM)ms.m_nMirandaStatus, 0));
if (pszStatusMsg && reinterpret_cast<LPARAM>(pszStatusMsg) != CALLSERVICE_NOTFOUND) {
T2Utf pMsg(pszStatusMsg);
mir_free(pszStatusMsg);
const char szSkypeCmdSetStatusMsg[] = "SET PROFILE MOOD_TEXT ";
- ::strncpy_s(szSkypeCmd,szSkypeCmdSetStatusMsg,sizeof(szSkypeCmdSetStatusMsg)/sizeof(szSkypeCmdSetStatusMsg[0]));
+ ::strncpy_s(szSkypeCmd, szSkypeCmdSetStatusMsg, sizeof(szSkypeCmdSetStatusMsg) / sizeof(szSkypeCmdSetStatusMsg[0]));
::strncat_s(szSkypeCmd, pMsg, _countof(szSkypeCmd) - mir_strlen(szSkypeCmd));
-
- DWORD cLength = static_cast<DWORD>(mir_strlen(szSkypeCmd));
- oCopyData.dwData=0;
+ oCopyData.dwData = 0;
oCopyData.lpData = szSkypeCmd;
- oCopyData.cbData = cLength+1;
- SendMessage(wndSkypeAPIWindow,WM_COPYDATA,(WPARAM)hWnd,(LPARAM)&oCopyData);
+ oCopyData.cbData = static_cast<DWORD>(mir_strlen(szSkypeCmd)) + 1;
+ SendMessage(wndSkypeAPIWindow, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&oCopyData);
}
}
}
@@ -227,12 +224,12 @@ LRESULT APIENTRY SkypeAPI_WindowProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
break;
}
- lReturnCode=1;
+ lReturnCode = 1;
}
else bIssueDefProc = true;
break;
}
-
+
if (true == bIssueDefProc)
lReturnCode = DefWindowProc(hWnd, msg, wp, lp);
@@ -245,7 +242,7 @@ int SSC_OnPreShutdown(WPARAM/* wParam*/, LPARAM/* lParam*/) BOOL b = SetEvent(g_hEventShutdown);
_ASSERT(b && "SetEvent failed");
- DWORD dwResult = ::WaitForSingleObject(g_hThread,INFINITE);
+ DWORD dwResult = ::WaitForSingleObject(g_hThread, INFINITE);
_ASSERT(WAIT_FAILED != dwResult);
b = ::CloseHandle(g_hEventShutdown);
@@ -257,7 +254,7 @@ int SSC_OnPreShutdown(WPARAM/* wParam*/, LPARAM/* lParam*/) g_wndMainWindow = NULL;
}
- UnregisterClass(g_pszSkypeWndClassName,g_hModule);
+ UnregisterClass(g_pszSkypeWndClassName, g_hModule);
return 0;
}
@@ -282,31 +279,31 @@ extern "C" int __declspec(dllexport) Load() g_MsgIDSkypeControlAPIAttach = ::RegisterWindowMessage(_T("SkypeControlAPIAttach"));
g_MsgIDSkypeControlAPIDiscover = ::RegisterWindowMessage(_T("SkypeControlAPIDiscover"));
- if ((0 == g_MsgIDSkypeControlAPIAttach)|| (0 == g_MsgIDSkypeControlAPIDiscover))
+ if ((0 == g_MsgIDSkypeControlAPIAttach) || (0 == g_MsgIDSkypeControlAPIDiscover))
return 1;
WNDCLASS oWindowClass = { 0 };
- oWindowClass.style = CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
+ oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
oWindowClass.lpfnWndProc = (WNDPROC)&SkypeAPI_WindowProc;
oWindowClass.hInstance = g_hModule;
oWindowClass.lpszClassName = g_pszSkypeWndClassName;
if (!RegisterClass(&oWindowClass))
return 1;
- g_wndMainWindow = CreateWindowEx( WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,
- g_pszSkypeWndClassName,_T(""), WS_BORDER|WS_SYSMENU|WS_MINIMIZEBOX,
+ g_wndMainWindow = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
+ g_pszSkypeWndClassName, _T(""), WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT, CW_USEDEFAULT, 128, 128, NULL, 0, g_hModule, 0);
if (g_wndMainWindow == NULL)
return 1;
-
+
g_bMirandaIsShutdown = false;
- g_hEventShutdown = ::CreateEvent(NULL,TRUE,FALSE,NULL);
+ g_hEventShutdown = ::CreateEvent(NULL, TRUE, FALSE, NULL);
g_hThread = mir_forkthread(ThreadFunc, NULL);
- HookEvent(ME_PROTO_ACK,SSC_OnProtocolAck);
- HookEvent(ME_SYSTEM_PRESHUTDOWN,SSC_OnPreShutdown);
- HookEvent(ME_OPT_INITIALISE,SSC_OptInitialise);
+ HookEvent(ME_PROTO_ACK, SSC_OnProtocolAck);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, SSC_OnPreShutdown);
+ HookEvent(ME_OPT_INITIALISE, SSC_OptInitialise);
return 0;
}
diff --git a/plugins/SplashScreen/src/bitmap_funcs.cpp b/plugins/SplashScreen/src/bitmap_funcs.cpp index 5359adc3d2..46e8ee86c7 100644 --- a/plugins/SplashScreen/src/bitmap_funcs.cpp +++ b/plugins/SplashScreen/src/bitmap_funcs.cpp @@ -133,9 +133,9 @@ bool MyBitmap::loadFromFile(TCHAR *fn) HBITMAP hBmpLoaded = (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)fn, IMGL_TCHAR);
if (!hBmpLoaded) {
-#ifdef _DEBUG
+ #ifdef _DEBUG
logMessage(_T("MyBitmap::loadFromFile"), _T("Bitmap load failed"));
-#endif
+ #endif
return false;
}
diff --git a/plugins/SplashScreen/src/main.cpp b/plugins/SplashScreen/src/main.cpp index 4f7007a5ab..88dd563466 100644 --- a/plugins/SplashScreen/src/main.cpp +++ b/plugins/SplashScreen/src/main.cpp @@ -1,21 +1,21 @@ /*
- Splash Screen Plugin for Miranda NG (www.miranda-ng.org)
- (c) 2004-2007 nullbie, (c) 2005-2007 Thief
+Splash Screen Plugin for Miranda NG (www.miranda-ng.org)
+(c) 2004-2007 nullbie, (c) 2005-2007 Thief
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
#include "stdafx.h"
@@ -62,14 +62,13 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) void SplashMain()
{
- if (bstartup)
- {
+ if (bstartup) {
// Retrive path to exe of current running Miranda is located
szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
mir_sntprintf(szhAdvaimgPath, _countof(szhAdvaimgPath), _T("%s\\plugins\\advaimg.dll"), szMirDir);
CallService(MS_SYSTEM_GETVERSIONTEXT, MAX_PATH, (LPARAM)szVersion);
-#ifdef _DEBUG
+ #ifdef _DEBUG
mir_sntprintf(szLogFile, _countof(szLogFile), _T("%s\\%s.log"), szMirDir, _T(__PLUGIN_NAME));
initLog();
TCHAR *mirandaVerString = mir_a2t(szVersion);
@@ -77,24 +76,21 @@ void SplashMain() mir_free(mirandaVerString);
logMessage(_T("Dll Name"), _T(__FILENAME));
logMessage(_T("Advaimg path"), szhAdvaimgPath);
-#endif
+ #endif
ReadDbConfig();
}
- if (bstartup & (options.active == 1))
- {
+ if (bstartup & (options.active == 1)) {
DBVARIANT dbv = { 0 };
- if (!db_get_ts(NULL, MODNAME, "VersionPrefix", &dbv))
- {
+ if (!db_get_ts(NULL, MODNAME, "VersionPrefix", &dbv)) {
mir_tstrcpy(szPrefix, dbv.ptszVal);
db_free(&dbv);
}
else
mir_tstrcpy(szPrefix, _T(""));
- if (!db_get_ts(NULL, MODNAME, "Path", &dbv))
- {
+ if (!db_get_ts(NULL, MODNAME, "Path", &dbv)) {
mir_tstrcpy(inBuf, dbv.ptszVal);
db_free(&dbv);
}
@@ -112,8 +108,7 @@ void SplashMain() else
mir_tstrcpy(szSplashFile, inBuf);
- if (!db_get_ts(NULL, MODNAME, "Sound", &dbv))
- {
+ if (!db_get_ts(NULL, MODNAME, "Sound", &dbv)) {
mir_tstrcpy(inBuf, dbv.ptszVal);
db_free(&dbv);
}
@@ -131,9 +126,9 @@ void SplashMain() else
mir_tstrcpy(szSoundFile, inBuf);
-#ifdef _DEBUG
+ #ifdef _DEBUG
logMessage(_T("SoundFilePath"), szSoundFile);
-#endif
+ #endif
TCHAR szOldPath[MAX_PATH] = { 0 };
@@ -155,30 +150,27 @@ void SplashMain() HANDLE hFind = INVALID_HANDLE_VALUE;
WIN32_FIND_DATA ffd;
hFind = FindFirstFile(szSearch, &ffd);
- if (hFind != INVALID_HANDLE_VALUE)
- {
- do
- {
- if (!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
- {
-#ifdef _DEBUG
+ if (hFind != INVALID_HANDLE_VALUE) {
+ do {
+ if (!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) {
+ #ifdef _DEBUG
logMessage(_T("Found file"), ffd.cFileName);
-#endif
+ #endif
//files = new char[mir_strlen(ffd.cFileName)];
//files[filescount] = new char[mir_strlen(ffd.cFileName)];
TCHAR ext[5];
wmemcpy(ext, ffd.cFileName + (mir_tstrlen(ffd.cFileName) - 4), 5);
-#ifdef _DEBUG
+ #ifdef _DEBUG
logMessage(_T("Extention"), ext);
-#endif
+ #endif
if (mir_tstrcmpi(ext, _T(".png")) & mir_tstrcmpi(ext, _T(".bmp")))
continue;
-#ifdef _DEBUG
+ #ifdef _DEBUG
logMessage(_T("File has valid ext"), ext);
-#endif
+ #endif
mir_tstrcpy(files[filescount++], ffd.cFileName);
} //if
} while (FindNextFile(hFind, &ffd));
@@ -189,9 +181,9 @@ void SplashMain() mir_sntprintf(szSplashFile, _countof(szSplashFile), _T("%s\\%s"), szSplashDir, files[r - 1]);
-#ifdef _DEBUG
+ #ifdef _DEBUG
logMessage(_T("final file"), szSplashFile);
-#endif
+ #endif
FindClose(hFind);
} //if
}
@@ -204,33 +196,30 @@ void SplashMain() int PlugDisableHook(WPARAM wParam, LPARAM lParam)
{
-#ifdef _DEBUG
+ #ifdef _DEBUG
TCHAR buf[128];
-#endif
+ #endif
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
TCHAR *tszModule = mir_a2t(cws->szModule), *tszSetting = mir_a2t(cws->szSetting);
- if (options.inheritGS)
- {
- if (!mir_tstrcmp(tszModule, _T("Skin")) & !mir_tstrcmp(tszSetting, _T("UseSound")))
- {
+ if (options.inheritGS) {
+ if (!mir_tstrcmp(tszModule, _T("Skin")) & !mir_tstrcmp(tszSetting, _T("UseSound"))) {
db_set_b(NULL, MODNAME, "PlaySound", cws->value.bVal);
-#ifdef _DEBUG
+ #ifdef _DEBUG
cws->value.bVal ? _DebugPopup(NULL, _T("Sounds enabled."), _T("")) : _DebugPopup(NULL, _T("Sounds disabled."), _T(""));
logMessage(_T("Module"), tszModule);
logMessage(_T("Setting"), tszSetting);
logMessage(_T("Value"), _itot(cws->value.bVal, buf, 10));
-#endif
+ #endif
}
- if (!mir_tstrcmp(tszModule, _T("PluginDisable")) & (!mir_tstrcmp(tszSetting, szDllName)))
- {
+ if (!mir_tstrcmp(tszModule, _T("PluginDisable")) & (!mir_tstrcmp(tszSetting, szDllName))) {
db_set_b(NULL, MODNAME, "Active", cws->value.bVal);
-#ifdef _DEBUG
+ #ifdef _DEBUG
cws->value.bVal ? _DebugPopup(NULL, _T("Disabled."), "") : _DebugPopup(NULL, _T("Enabled."), _T(""));
logMessage(_T("PlugDisableHook"), _T("Triggered"));
logMessage(_T("Module"), tszModule);
logMessage(_T("Setting"), tszSetting);
logMessage(_T("Value"), _itot(cws->value.bVal, buf, 10));
-#endif
+ #endif
}
}
mir_free(tszModule);
@@ -243,13 +232,11 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) {
bmodulesloaded = true; // all modules are loaded now, let other parts know about this fact
- if (hwndSplash)
- {
- if (PostMessage(hwndSplash, WM_LOADED, 0, 0))
- {
-#ifdef _DEBUG
+ if (hwndSplash) {
+ if (PostMessage(hwndSplash, WM_LOADED, 0, 0)) {
+ #ifdef _DEBUG
logMessage(_T("Posted WM_LOADED message"), _T("done"));
-#endif
+ #endif
}
}
@@ -260,9 +247,9 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) // Service to call splash
CreateServiceFunction(MS_SHOWSPLASH, ShowSplashService);
-#ifdef _DEBUG
+ #ifdef _DEBUG
logMessage(_T("Loading modules"), _T("done"));
-#endif
+ #endif
return 0;
}
@@ -293,9 +280,9 @@ extern "C" int __declspec(dllexport) Unload(void) if (hAdvaimg)
FreeLibrary(hAdvaimg);
-#ifdef _DEBUG
+ #ifdef _DEBUG
logMessage(_T("Unload"), _T("Job done"));
-#endif
+ #endif
return 0;
}
diff --git a/plugins/SplashScreen/src/options.cpp b/plugins/SplashScreen/src/options.cpp index 95a3f09e75..70f0b2bb3e 100644 --- a/plugins/SplashScreen/src/options.cpp +++ b/plugins/SplashScreen/src/options.cpp @@ -43,384 +43,350 @@ BOOL Exists(LPCTSTR strName) INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- if (!png2dibavail) {
- ShowWindow(GetDlgItem(hwndDlg, IDC_PNG2DIBWARN), SW_SHOW);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ACTIVE), false);
- EnableWindow(GetDlgItem(hwndDlg, IDC_RANDOM), false);
- EnableWindow(GetDlgItem(hwndDlg, IDC_SPLASHPATH), false);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHOOSESPLASH), false);
- EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWVERSION), false);
- EnableWindow(GetDlgItem(hwndDlg, IDC_VERSIONPREFIX), false);
- EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWTIME), false);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ST_SPIN), false);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FADEIN), false);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), false);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), false);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FADEOUT), false);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), false);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), false);
- }
- else {
- ReadDbConfig();
- TCHAR inBuf[80];
- DBVARIANT dbv = { 0 };
- if (!db_get_ts(NULL, MODNAME, "Path", &dbv))
- {
- mir_tstrcpy(inBuf, dbv.ptszVal);
- db_free(&dbv);
- }
- else
- mir_tstrcpy(inBuf, _T("splash\\splash.png"));
- SetDlgItemText(hwndDlg, IDC_SPLASHPATH, inBuf);
-
- if (!db_get_ts(NULL, MODNAME, "Sound", &dbv))
- {
- mir_tstrcpy(inBuf, dbv.ptszVal);
- db_free(&dbv);
- }
- else
- mir_tstrcpy(inBuf, _T("sounds\\startup.wav"));
- SetDlgItemText(hwndDlg, IDC_SNDPATH, inBuf);
-
- if (!db_get_ts(NULL, MODNAME, "VersionPrefix", &dbv))
- {
- mir_tstrcpy(inBuf, dbv.ptszVal);
- db_free(&dbv);
- }
- else
- mir_tstrcpy(inBuf, _T(""));
- SetDlgItemText(hwndDlg, IDC_VERSIONPREFIX, inBuf);
-
- if (options.active)
- CheckDlgButton(hwndDlg, IDC_ACTIVE, BST_CHECKED);
- if (options.playsnd && !options.inheritGS)
- CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_INDETERMINATE);
- else if (options.playsnd)
- CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_CHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_LOOPSOUND), false);
- if (options.fadein)
- CheckDlgButton(hwndDlg, IDC_FADEIN, BST_CHECKED);
- if (options.fadeout)
- CheckDlgButton(hwndDlg, IDC_FADEOUT, BST_CHECKED);
- if (options.random)
- CheckDlgButton(hwndDlg, IDC_RANDOM, BST_CHECKED);
- if (options.showversion)
- CheckDlgButton(hwndDlg, IDC_SHOWVERSION, BST_CHECKED);
-
- SetDlgItemText(hwndDlg, IDC_SHOWTIME, _itot(options.showtime, inBuf, 10));
- SetDlgItemText(hwndDlg, IDC_FISTEP, _itot(options.fisteps, inBuf, 10));
- SetDlgItemText(hwndDlg, IDC_FOSTEP, _itot(options.fosteps, inBuf, 10));
-
- SendDlgItemMessage(hwndDlg, IDC_SHOWTIME, EM_LIMITTEXT, 5, 0);
- }
-
- return TRUE;
- }
-
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDC_PREVIEW:
- {
- ShowSplash(true);
- break;
- }
-
- case IDC_ACTIVE:
- case IDC_PLAYSND:
- case IDC_LOOPSOUND:
- case IDC_FADEIN:
- case IDC_FADEOUT:
- case IDC_SHOWTIME:
- case IDC_RANDOM:
- case IDC_SHOWVERSION:
- case IDC_FISTEP:
- case IDC_FOSTEP:
{
- if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN))
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), true);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), true);
- }
- else
- {
+ TranslateDialogDefault(hwndDlg);
+ if (!png2dibavail) {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PNG2DIBWARN), SW_SHOW);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ACTIVE), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_RANDOM), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SPLASHPATH), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHOOSESPLASH), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWVERSION), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_VERSIONPREFIX), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWTIME), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ST_SPIN), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FADEIN), false);
EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), false);
EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), false);
- }
- if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT))
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), true);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), true);
- }
- else
- {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FADEOUT), false);
EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), false);
EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), false);
}
-
- if ((HWND)lParam != GetFocus())
- return 0;
else {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
+ ReadDbConfig();
+ TCHAR inBuf[80];
+ DBVARIANT dbv = { 0 };
+ if (!db_get_ts(NULL, MODNAME, "Path", &dbv)) {
+ mir_tstrcpy(inBuf, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ else
+ mir_tstrcpy(inBuf, _T("splash\\splash.png"));
+ SetDlgItemText(hwndDlg, IDC_SPLASHPATH, inBuf);
+
+ if (!db_get_ts(NULL, MODNAME, "Sound", &dbv)) {
+ mir_tstrcpy(inBuf, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ else
+ mir_tstrcpy(inBuf, _T("sounds\\startup.wav"));
+ SetDlgItemText(hwndDlg, IDC_SNDPATH, inBuf);
+
+ if (!db_get_ts(NULL, MODNAME, "VersionPrefix", &dbv)) {
+ mir_tstrcpy(inBuf, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ else
+ mir_tstrcpy(inBuf, _T(""));
+ SetDlgItemText(hwndDlg, IDC_VERSIONPREFIX, inBuf);
+
+ if (options.active)
+ CheckDlgButton(hwndDlg, IDC_ACTIVE, BST_CHECKED);
+ if (options.playsnd && !options.inheritGS)
+ CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_INDETERMINATE);
+ else if (options.playsnd)
+ CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_CHECKED);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOOPSOUND), false);
+ if (options.fadein)
+ CheckDlgButton(hwndDlg, IDC_FADEIN, BST_CHECKED);
+ if (options.fadeout)
+ CheckDlgButton(hwndDlg, IDC_FADEOUT, BST_CHECKED);
+ if (options.random)
+ CheckDlgButton(hwndDlg, IDC_RANDOM, BST_CHECKED);
+ if (options.showversion)
+ CheckDlgButton(hwndDlg, IDC_SHOWVERSION, BST_CHECKED);
+
+ SetDlgItemText(hwndDlg, IDC_SHOWTIME, _itot(options.showtime, inBuf, 10));
+ SetDlgItemText(hwndDlg, IDC_FISTEP, _itot(options.fisteps, inBuf, 10));
+ SetDlgItemText(hwndDlg, IDC_FOSTEP, _itot(options.fosteps, inBuf, 10));
+
+ SendDlgItemMessage(hwndDlg, IDC_SHOWTIME, EM_LIMITTEXT, 5, 0);
}
- break;
+
+ return TRUE;
}
- case IDC_CHOOSESPLASH:
+ case WM_COMMAND:
{
- TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH];
- TCHAR *pos;
-
- if (Exists(szSplashFile))
- {
- mir_tstrcpy(initDir, szSplashFile);
- pos = _tcsrchr(initDir, _T('\\'));
- if (pos != NULL) *pos = 0;
- }
- else
- {
- szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
- mir_tstrcpy(initDir, szMirDir);
- mir_free(szMirDir);
- }
+ switch (LOWORD(wParam)) {
+ case IDC_PREVIEW:
+ {
+ ShowSplash(true);
+ break;
+ }
- OPENFILENAME ofn = { 0 };
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
- TCHAR tmp[MAX_PATH];
- mir_sntprintf(tmp, _countof(tmp), _T("%s (*.png, *.bmp)%c*.png;*.bmp%c%c"), TranslateT("Graphic files"), 0, 0, 0);
- ofn.lpstrFilter = tmp;
- ofn.hwndOwner = 0;
- ofn.lpstrFile = szTempPath;
- ofn.nMaxFile = MAX_PATH;
- ofn.nMaxFileTitle = MAX_PATH;
- ofn.Flags = OFN_HIDEREADONLY;
- ofn.lpstrInitialDir = initDir;
- *szTempPath = '\0';
- ofn.lpstrDefExt = _T("");
-
- if (GetOpenFileName(&ofn))
- {
- mir_tstrcpy(szSplashFile, szTempPath);
-
-#ifdef _DEBUG
- logMessage(_T("Set path"), szSplashFile);
-#endif
-
- // Make path relative
- int result = PathToRelativeT(szTempPath, szPath2Spash);
- if (result && mir_tstrlen(szPath2Spash) > 0)
+ case IDC_ACTIVE:
+ case IDC_PLAYSND:
+ case IDC_LOOPSOUND:
+ case IDC_FADEIN:
+ case IDC_FADEOUT:
+ case IDC_SHOWTIME:
+ case IDC_RANDOM:
+ case IDC_SHOWVERSION:
+ case IDC_FISTEP:
+ case IDC_FOSTEP:
{
- if (options.random)
- {
- TCHAR *pos;
- pos = _tcsrchr(szPath2Spash, _T('\\'));
+ if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN)) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), true);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), true);
+ }
+ else {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), false);
+ }
+ if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT)) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), true);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), true);
+ }
+ else {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), false);
+ }
+
+ if ((HWND)lParam != GetFocus())
+ return 0;
+ else {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
+ break;
+ }
+
+ case IDC_CHOOSESPLASH:
+ {
+ TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH];
+
+ if (Exists(szSplashFile)) {
+ mir_tstrcpy(initDir, szSplashFile);
+ TCHAR *pos = _tcsrchr(initDir, _T('\\'));
if (pos != NULL)
- {
*pos = 0;
- mir_tstrcat(szPath2Spash, _T("\\"));
+ }
+ else {
+ szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
+ mir_tstrcpy(initDir, szMirDir);
+ mir_free(szMirDir);
+ }
+
+ TCHAR tmp[MAX_PATH];
+ mir_sntprintf(tmp, _countof(tmp), _T("%s (*.png, *.bmp)%c*.png;*.bmp%c%c"), TranslateT("Graphic files"), 0, 0, 0);
+
+ OPENFILENAME ofn = { 0 };
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ ofn.lpstrFilter = tmp;
+ ofn.lpstrFile = szTempPath;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.Flags = OFN_HIDEREADONLY;
+ ofn.lpstrInitialDir = initDir;
+ *szTempPath = '\0';
+ ofn.lpstrDefExt = _T("");
+
+ if (GetOpenFileName(&ofn)) {
+ mir_tstrcpy(szSplashFile, szTempPath);
+
+ #ifdef _DEBUG
+ logMessage(_T("Set path"), szSplashFile);
+ #endif
+ // Make path relative
+ int result = PathToRelativeT(szTempPath, szPath2Spash);
+ if (result && mir_tstrlen(szPath2Spash) > 0) {
+ if (options.random) {
+ TCHAR *pos = _tcsrchr(szPath2Spash, _T('\\'));
+ if (pos != NULL) {
+ *pos = 0;
+ mir_tstrcat(szPath2Spash, _T("\\"));
+ }
+ }
+
+ SetDlgItemText(hwndDlg, IDC_SPLASHPATH, szPath2Spash);
}
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- SetDlgItemText(hwndDlg, IDC_SPLASHPATH, szPath2Spash);
+ break;
}
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
-
- break;
- }
+ case IDC_CHOOSESND:
+ {
+ TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH];
+ TCHAR *pos;
- case IDC_CHOOSESND:
- {
- TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH];
- TCHAR *pos;
-
- if (Exists(szSoundFile))
- {
- mir_tstrcpy(initDir, szSoundFile);
- pos = _tcsrchr(initDir, _T('\\'));
- if (pos != NULL) *pos = 0;
- }
- else
- {
- szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
- mir_tstrcpy(initDir, szMirDir);
- mir_free(szMirDir);
- }
+ if (Exists(szSoundFile)) {
+ mir_tstrcpy(initDir, szSoundFile);
+ pos = _tcsrchr(initDir, _T('\\'));
+ if (pos != NULL) *pos = 0;
+ }
+ else {
+ szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
+ mir_tstrcpy(initDir, szMirDir);
+ mir_free(szMirDir);
+ }
- OPENFILENAME ofn = { 0 };
- ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
- TCHAR tmp[MAX_PATH];
- mir_sntprintf(tmp, _countof(tmp), _T("%s (*.wav, *.mp3)%c*.wav;*.mp3%c%c"), TranslateT("Sound Files"), 0, 0, 0);
- ofn.lpstrFilter = tmp;
- ofn.hwndOwner = 0;
- ofn.lpstrFile = szTempPath;
- ofn.nMaxFile = MAX_PATH;
- ofn.nMaxFileTitle = MAX_PATH;
- ofn.Flags = OFN_HIDEREADONLY;
- ofn.lpstrInitialDir = initDir;
- *szTempPath = '\0';
- ofn.lpstrDefExt = _T("");
-
- if (GetOpenFileName(&ofn))
- {
- mir_tstrcpy(szSoundFile, szTempPath);
-
-#ifdef _DEBUG
- logMessage(_T("Set sound path"), szSoundFile);
-#endif
-
- // Make path relative
- int result = PathToRelativeT(szTempPath, szSoundFilePath);
- if (result && mir_tstrlen(szSoundFile) > 0)
- SetDlgItemText(hwndDlg, IDC_SNDPATH, szSoundFilePath);
+ OPENFILENAME ofn = { 0 };
+ ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
+ TCHAR tmp[MAX_PATH];
+ mir_sntprintf(tmp, _countof(tmp), _T("%s (*.wav, *.mp3)%c*.wav;*.mp3%c%c"), TranslateT("Sound Files"), 0, 0, 0);
+ ofn.lpstrFilter = tmp;
+ ofn.hwndOwner = 0;
+ ofn.lpstrFile = szTempPath;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.Flags = OFN_HIDEREADONLY;
+ ofn.lpstrInitialDir = initDir;
+ *szTempPath = '\0';
+ ofn.lpstrDefExt = _T("");
+
+ if (GetOpenFileName(&ofn)) {
+ mir_tstrcpy(szSoundFile, szTempPath);
+
+ #ifdef _DEBUG
+ logMessage(_T("Set sound path"), szSoundFile);
+ #endif
+
+ // Make path relative
+ int result = PathToRelativeT(szTempPath, szSoundFilePath);
+ if (result && mir_tstrlen(szSoundFile) > 0)
+ SetDlgItemText(hwndDlg, IDC_SNDPATH, szSoundFilePath);
+
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
}
- break;
+ default:
+ {
+ if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())
+ return 0;
+ else
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
+ break;
}
- default:
- {
- if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())
- return 0;
- else
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- break;
- }
-
case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->idFrom == 0)
- switch (((LPNMHDR)lParam)->code)
{
- case PSN_APPLY:
- {
- TCHAR tmp[MAX_PATH];
+ if (((LPNMHDR)lParam)->idFrom == 0)
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ {
+ TCHAR tmp[MAX_PATH];
- GetDlgItemText(hwndDlg, IDC_SPLASHPATH, tmp, _countof(tmp));
- db_set_ts(NULL, MODNAME, "Path", tmp);
+ GetDlgItemText(hwndDlg, IDC_SPLASHPATH, tmp, _countof(tmp));
+ db_set_ts(NULL, MODNAME, "Path", tmp);
- GetDlgItemText(hwndDlg, IDC_SNDPATH, tmp, _countof(tmp));
- db_set_ts(NULL, MODNAME, "Sound", tmp);
+ GetDlgItemText(hwndDlg, IDC_SNDPATH, tmp, _countof(tmp));
+ db_set_ts(NULL, MODNAME, "Sound", tmp);
- GetDlgItemText(hwndDlg, IDC_VERSIONPREFIX, tmp, _countof(tmp));
- db_set_ts(NULL, MODNAME, "VersionPrefix", tmp);
- mir_tstrcpy(szPrefix, tmp);
+ GetDlgItemText(hwndDlg, IDC_VERSIONPREFIX, tmp, _countof(tmp));
+ db_set_ts(NULL, MODNAME, "VersionPrefix", tmp);
+ mir_tstrcpy(szPrefix, tmp);
- GetDlgItemText(hwndDlg, IDC_SHOWTIME, tmp, _countof(tmp));
- db_set_dw(NULL, MODNAME, "TimeToShow", _ttoi(tmp));
- options.showtime = _ttoi(tmp);
+ GetDlgItemText(hwndDlg, IDC_SHOWTIME, tmp, _countof(tmp));
+ db_set_dw(NULL, MODNAME, "TimeToShow", _ttoi(tmp));
+ options.showtime = _ttoi(tmp);
- GetDlgItemText(hwndDlg, IDC_FISTEP, tmp, _countof(tmp));
- db_set_dw(NULL, MODNAME, "FadeinSpeed", _ttoi(tmp));
- options.fisteps = _ttoi(tmp);
+ GetDlgItemText(hwndDlg, IDC_FISTEP, tmp, _countof(tmp));
+ db_set_dw(NULL, MODNAME, "FadeinSpeed", _ttoi(tmp));
+ options.fisteps = _ttoi(tmp);
- GetDlgItemText(hwndDlg, IDC_FOSTEP, tmp, _countof(tmp));
- db_set_dw(NULL, MODNAME, "FadeoutSpeed", _ttoi(tmp));
- options.fosteps = _ttoi(tmp);
+ GetDlgItemText(hwndDlg, IDC_FOSTEP, tmp, _countof(tmp));
+ db_set_dw(NULL, MODNAME, "FadeoutSpeed", _ttoi(tmp));
+ options.fosteps = _ttoi(tmp);
- if (IsDlgButtonChecked(hwndDlg, IDC_ACTIVE))
- {
- db_set_b(NULL, MODNAME, "Active", 1);
- options.active = 1;
- }
- else
- {
- db_set_b(NULL, MODNAME, "Active", 0);
- options.active = 0;
- }
+ if (IsDlgButtonChecked(hwndDlg, IDC_ACTIVE)) {
+ db_set_b(NULL, MODNAME, "Active", 1);
+ options.active = 1;
+ }
+ else {
+ db_set_b(NULL, MODNAME, "Active", 0);
+ options.active = 0;
+ }
- if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND))
- {
- db_set_b(NULL, MODNAME, "PlaySound", 1);
- options.playsnd = 1;
- db_set_b(NULL, MODNAME, "InheritGlobalSound", 1);
- options.inheritGS = 1;
- }
- else
- {
- db_set_b(NULL, MODNAME, "PlaySound", 0);
- options.playsnd = 0;
- db_set_b(NULL, MODNAME, "InheritGlobalSound", 0);
- options.inheritGS = 0;
- }
+ if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND)) {
+ db_set_b(NULL, MODNAME, "PlaySound", 1);
+ options.playsnd = 1;
+ db_set_b(NULL, MODNAME, "InheritGlobalSound", 1);
+ options.inheritGS = 1;
+ }
+ else {
+ db_set_b(NULL, MODNAME, "PlaySound", 0);
+ options.playsnd = 0;
+ db_set_b(NULL, MODNAME, "InheritGlobalSound", 0);
+ options.inheritGS = 0;
+ }
- if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND) == BST_INDETERMINATE)
- {
- db_set_b(NULL, MODNAME, "PlaySound", 1);
- options.playsnd = 1;
- db_set_b(NULL, MODNAME, "InheritGlobalSound", 0);
- options.inheritGS = 0;
- }
+ if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND) == BST_INDETERMINATE) {
+ db_set_b(NULL, MODNAME, "PlaySound", 1);
+ options.playsnd = 1;
+ db_set_b(NULL, MODNAME, "InheritGlobalSound", 0);
+ options.inheritGS = 0;
+ }
- /*
- if (IsDlgButtonChecked(hwndDlg, IDC_LOOPSOUND))
- {
- WritePrivateProfileString("Splash","LoopSound","1",szIniFile);
- options.loopsnd = 1;
- }
- else
- {
- WritePrivateProfileString("Splash","LoopSound","0",szIniFile);
- options.loopsnd = 0;
- }
- */
+ /*
+ if (IsDlgButtonChecked(hwndDlg, IDC_LOOPSOUND))
+ {
+ WritePrivateProfileString("Splash","LoopSound","1",szIniFile);
+ options.loopsnd = 1;
+ }
+ else
+ {
+ WritePrivateProfileString("Splash","LoopSound","0",szIniFile);
+ options.loopsnd = 0;
+ }
+ */
- if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN))
- {
- db_set_b(NULL, MODNAME, "FadeIn", 1);
- options.fadein = 1;
- }
- else
- {
- db_set_b(NULL, MODNAME, "FadeIn", 0);
- options.fadein = 0;
- }
- if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT))
- {
- db_set_b(NULL, MODNAME, "FadeOut", 1);
- options.fadeout = 1;
- }
- else
- {
- db_set_b(NULL, MODNAME, "FadeOut", 0);
- options.fadeout = 0;
- }
- if (IsDlgButtonChecked(hwndDlg, IDC_RANDOM))
- {
- db_set_b(NULL, MODNAME, "Random", 1);
- options.random = 1;
- }
- else
- {
- db_set_b(NULL, MODNAME, "Random", 0);
- options.random = 0;
- }
- if (IsDlgButtonChecked(hwndDlg, IDC_SHOWVERSION))
- {
- db_set_b(NULL, MODNAME, "ShowVersion", 1);
- options.showversion = 1;
- }
- else
- {
- db_set_b(NULL, MODNAME, "ShowVersion", 0);
- options.showversion = 0;
+ if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN)) {
+ db_set_b(NULL, MODNAME, "FadeIn", 1);
+ options.fadein = 1;
+ }
+ else {
+ db_set_b(NULL, MODNAME, "FadeIn", 0);
+ options.fadein = 0;
+ }
+ if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT)) {
+ db_set_b(NULL, MODNAME, "FadeOut", 1);
+ options.fadeout = 1;
+ }
+ else {
+ db_set_b(NULL, MODNAME, "FadeOut", 0);
+ options.fadeout = 0;
+ }
+ if (IsDlgButtonChecked(hwndDlg, IDC_RANDOM)) {
+ db_set_b(NULL, MODNAME, "Random", 1);
+ options.random = 1;
+ }
+ else {
+ db_set_b(NULL, MODNAME, "Random", 0);
+ options.random = 0;
+ }
+ if (IsDlgButtonChecked(hwndDlg, IDC_SHOWVERSION)) {
+ db_set_b(NULL, MODNAME, "ShowVersion", 1);
+ options.showversion = 1;
+ }
+ else {
+ db_set_b(NULL, MODNAME, "ShowVersion", 0);
+ options.showversion = 0;
+ }
+ return TRUE;
+ }
}
- return TRUE;
- }
}
- }
case WM_DESTROY:
break;
diff --git a/plugins/SplashScreen/src/splash.cpp b/plugins/SplashScreen/src/splash.cpp index df0f3367e9..6550f5fda0 100644 --- a/plugins/SplashScreen/src/splash.cpp +++ b/plugins/SplashScreen/src/splash.cpp @@ -263,8 +263,8 @@ void __cdecl SplashThread(void *arg) blend.SourceConstantAlpha = 255;
UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
- if (DWORD(arg) > 0) {
- if (SetTimer(hwndSplash, 6, DWORD(arg), 0)) {
+ if (DWORD_PTR(arg) > 0) {
+ if (SetTimer(hwndSplash, 6, DWORD_PTR(arg), 0)) {
#ifdef _DEBUG
logMessage(_T("Timer TimeToShow"), _T("set"));
#endif
@@ -338,4 +338,4 @@ BOOL ShowSplash(BOOL bpreview) logMessage(_T("Thread"), _T("end"));
#endif
return 1;
-}
\ No newline at end of file +}
diff --git a/plugins/StopSpamMod/src/options.cpp b/plugins/StopSpamMod/src/options.cpp index 5b05c9696b..8b1698f996 100755 --- a/plugins/StopSpamMod/src/options.cpp +++ b/plugins/StopSpamMod/src/options.cpp @@ -19,124 +19,106 @@ int CreateCListGroup(TCHAR* szGroupName);
-char * pluginDescription = LPGEN("No more spam! Robots can't go! Only human beings invited!\r\n\r\nThis plugin works pretty simple:\r\nWhile messages from users on your contact list go as there is no any anti-spam software, messages from unknown users are not delivered to you. But also they are not ignored, this plugin replies with a simple question, and if user gives the right answer, plugin adds him to your contact list so that he can contact you.");
-TCHAR const * defQuestion = TranslateT("Spammers made me to install small anti-spam system you are now speaking with.\r\nPlease reply \"nospam\" without quotes and spaces if you want to contact me.");
+char *pluginDescription = LPGEN("No more spam! Robots can't go! Only human beings invited!\r\n\r\nThis plugin works pretty simple:\r\nWhile messages from users on your contact list go as there is no any anti-spam software, messages from unknown users are not delivered to you. But also they are not ignored, this plugin replies with a simple question, and if user gives the right answer, plugin adds him to your contact list so that he can contact you.");
+TCHAR const *defQuestion = TranslateT("Spammers made me to install small anti-spam system you are now speaking with.\r\nPlease reply \"nospam\" without quotes and spaces if you want to contact me.");
INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- SetDlgItemTextA(hwnd, ID_DESCRIPTION, pluginDescription);
- TranslateDialogDefault(hwnd);
- SetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, gbMaxQuestCount, FALSE);
- CheckDlgButton(hwnd, ID_INFTALKPROT, gbInfTalkProtection ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, ID_ADDPERMANENT, gbAddPermanent ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, ID_HANDLEAUTHREQ, gbHandleAuthReq ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, ID_HIDECONTACTS, gbHideContacts ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, ID_IGNORESPAMMERS, gbIgnoreContacts ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd, ID_LOGSPAMTOFILE, gbLogToFile ? BST_CHECKED : BST_UNCHECKED);
- }
+ SetDlgItemTextA(hwnd, ID_DESCRIPTION, pluginDescription);
+ TranslateDialogDefault(hwnd);
+ SetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, gbMaxQuestCount, FALSE);
+ CheckDlgButton(hwnd, ID_INFTALKPROT, gbInfTalkProtection ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, ID_ADDPERMANENT, gbAddPermanent ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, ID_HANDLEAUTHREQ, gbHandleAuthReq ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, ID_HIDECONTACTS, gbHideContacts ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, ID_IGNORESPAMMERS, gbIgnoreContacts ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, ID_LOGSPAMTOFILE, gbLogToFile ? BST_CHECKED : BST_UNCHECKED);
return TRUE;
- case WM_COMMAND:{
- switch (LOWORD(wParam))
- {
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
case ID_MAXQUESTCOUNT:
- {
- if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus())
- return FALSE;
- break;
- }
+ if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus())
+ return FALSE;
+ break;
}
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
break;
+
case WM_NOTIFY:
- {
- NMHDR* nmhdr = (NMHDR*)lParam;
- switch (nmhdr->code)
+ NMHDR* nmhdr = (NMHDR*)lParam;
+ switch (nmhdr->code) {
+ case PSN_APPLY:
{
- case PSN_APPLY:
- {
- db_set_dw(NULL, pluginName, "maxQuestCount", gbMaxQuestCount = GetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, NULL, FALSE));
- db_set_b(NULL, pluginName, "infTalkProtection", gbInfTalkProtection = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_INFTALKPROT));
- db_set_b(NULL, pluginName, "addPermanent", gbAddPermanent = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_ADDPERMANENT));
- db_set_b(NULL, pluginName, "handleAuthReq", gbHandleAuthReq = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_HANDLEAUTHREQ));
- db_set_b(NULL, pluginName, "HideContacts", gbHideContacts = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_HIDECONTACTS));
- db_set_b(NULL, pluginName, "IgnoreContacts", gbIgnoreContacts = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_IGNORESPAMMERS));
- db_set_b(NULL, pluginName, "LogSpamToFile", gbLogToFile = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_LOGSPAMTOFILE));
- }
- return TRUE;
+ db_set_dw(NULL, pluginName, "maxQuestCount", gbMaxQuestCount = GetDlgItemInt(hwnd, ID_MAXQUESTCOUNT, NULL, FALSE));
+ db_set_b(NULL, pluginName, "infTalkProtection", gbInfTalkProtection = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_INFTALKPROT));
+ db_set_b(NULL, pluginName, "addPermanent", gbAddPermanent = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_ADDPERMANENT));
+ db_set_b(NULL, pluginName, "handleAuthReq", gbHandleAuthReq = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_HANDLEAUTHREQ));
+ db_set_b(NULL, pluginName, "HideContacts", gbHideContacts = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_HIDECONTACTS));
+ db_set_b(NULL, pluginName, "IgnoreContacts", gbIgnoreContacts = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_IGNORESPAMMERS));
+ db_set_b(NULL, pluginName, "LogSpamToFile", gbLogToFile = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_LOGSPAMTOFILE));
}
+ return TRUE;
}
- break;
+ break;
}
return FALSE;
}
INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
-
- switch(msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwnd);
- SetDlgItemText(hwnd, ID_QUESTION, gbQuestion.c_str());
- SetDlgItemText(hwnd, ID_ANSWER, gbAnswer.c_str());
- SetDlgItemText(hwnd, ID_CONGRATULATION, gbCongratulation.c_str());
- SetDlgItemText(hwnd, ID_AUTHREPL, gbAuthRepl.c_str());
- EnableWindow(GetDlgItem(hwnd, ID_ANSWER), !gbMathExpression);
- variables_skin_helpbutton(hwnd, IDC_VARS);
- gbVarsServiceExist?EnableWindow(GetDlgItem(hwnd, IDC_VARS),1):EnableWindow(GetDlgItem(hwnd, IDC_VARS),0);
- }
+ TranslateDialogDefault(hwnd);
+ SetDlgItemText(hwnd, ID_QUESTION, gbQuestion.c_str());
+ SetDlgItemText(hwnd, ID_ANSWER, gbAnswer.c_str());
+ SetDlgItemText(hwnd, ID_CONGRATULATION, gbCongratulation.c_str());
+ SetDlgItemText(hwnd, ID_AUTHREPL, gbAuthRepl.c_str());
+ EnableWindow(GetDlgItem(hwnd, ID_ANSWER), !gbMathExpression);
+ variables_skin_helpbutton(hwnd, IDC_VARS);
+ gbVarsServiceExist ? EnableWindow(GetDlgItem(hwnd, IDC_VARS), 1) : EnableWindow(GetDlgItem(hwnd, IDC_VARS), 0);
return TRUE;
+
case WM_COMMAND:
- {
- switch(LOWORD(wParam))
- {
- case ID_QUESTION:
- case ID_ANSWER:
- case ID_AUTHREPL:
- case ID_CONGRATULATION:
- {
- if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus())
- return FALSE;
- break;
- }
- case ID_RESTOREDEFAULTS:
- SetDlgItemText(hwnd, ID_QUESTION, defQuestion);
- SetDlgItemText(hwnd, ID_ANSWER, _T("nospam"));
- SetDlgItemText(hwnd, ID_AUTHREPL, TranslateT("StopSpam: send a message and reply to an anti-spam bot question."));
- SetDlgItemText(hwnd, ID_CONGRATULATION, TranslateT("Congratulations! You just passed human/robot test. Now you can write me a message."));
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- return TRUE;
- case IDC_VARS:
- variables_showhelp(hwnd, msg, VHF_FULLDLG|VHF_SETLASTSUBJECT, NULL, NULL);
- return TRUE;
- }
+ switch (LOWORD(wParam)) {
+ case ID_QUESTION:
+ case ID_ANSWER:
+ case ID_AUTHREPL:
+ case ID_CONGRATULATION:
+ if (EN_CHANGE != HIWORD(wParam) || (HWND)lParam != GetFocus())
+ return FALSE;
+ break;
+
+ case ID_RESTOREDEFAULTS:
+ SetDlgItemText(hwnd, ID_QUESTION, defQuestion);
+ SetDlgItemText(hwnd, ID_ANSWER, _T("nospam"));
+ SetDlgItemText(hwnd, ID_AUTHREPL, TranslateT("StopSpam: send a message and reply to an anti-spam bot question."));
+ SetDlgItemText(hwnd, ID_CONGRATULATION, TranslateT("Congratulations! You just passed human/robot test. Now you can write me a message."));
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ return TRUE;
+
+ case IDC_VARS:
+ variables_showhelp(hwnd, msg, VHF_FULLDLG | VHF_SETLASTSUBJECT, NULL, NULL);
+ return TRUE;
}
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
+
case WM_NOTIFY:
- {
- NMHDR* nmhdr = (NMHDR*)lParam;
- switch (nmhdr->code)
- {
- case PSN_APPLY:
- {
- db_set_ws(NULL, pluginName, "question", GetDlgItemString(hwnd, ID_QUESTION).c_str());
- gbQuestion = DBGetContactSettingStringPAN(NULL, pluginName, "question", defQuestion);
- db_set_ws(NULL, pluginName, "answer", GetDlgItemString(hwnd, ID_ANSWER).c_str());
- gbAnswer = DBGetContactSettingStringPAN(NULL, pluginName, "answer", _T("nospam"));
- db_set_ws(NULL, pluginName, "authrepl", GetDlgItemString(hwnd, ID_AUTHREPL).c_str());
- gbAuthRepl = DBGetContactSettingStringPAN(NULL, pluginName, "authrepl", TranslateT("StopSpam: send a message and reply to an anti-spam bot question."));
- db_set_ws(NULL, pluginName, "congratulation", GetDlgItemString(hwnd, ID_CONGRATULATION).c_str());
- gbCongratulation = DBGetContactSettingStringPAN(NULL, pluginName, "congratulation", TranslateT("Congratulations! You just passed human/robot test. Now you can write me a message."));
- }
- return TRUE;
- }
+ NMHDR *nmhdr = (NMHDR*)lParam;
+ switch (nmhdr->code) {
+ case PSN_APPLY:
+ db_set_ws(NULL, pluginName, "question", GetDlgItemString(hwnd, ID_QUESTION).c_str());
+ gbQuestion = DBGetContactSettingStringPAN(NULL, pluginName, "question", defQuestion);
+ db_set_ws(NULL, pluginName, "answer", GetDlgItemString(hwnd, ID_ANSWER).c_str());
+ gbAnswer = DBGetContactSettingStringPAN(NULL, pluginName, "answer", _T("nospam"));
+ db_set_ws(NULL, pluginName, "authrepl", GetDlgItemString(hwnd, ID_AUTHREPL).c_str());
+ gbAuthRepl = DBGetContactSettingStringPAN(NULL, pluginName, "authrepl", TranslateT("StopSpam: send a message and reply to an anti-spam bot question."));
+ db_set_ws(NULL, pluginName, "congratulation", GetDlgItemString(hwnd, ID_CONGRATULATION).c_str());
+ gbCongratulation = DBGetContactSettingStringPAN(NULL, pluginName, "congratulation", TranslateT("Congratulations! You just passed human/robot test. Now you can write me a message."));
+ return TRUE;
}
break;
}
@@ -145,97 +127,90 @@ INT_PTR CALLBACK MessagesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar INT_PTR CALLBACK ProtoDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwnd);
- int n;
+ int nAccs;
PROTOACCOUNT **pppd;
- Proto_EnumAccounts(&n, &pppd);
- for (int i = 0; i < n; ++i)
+ Proto_EnumAccounts(&nAccs, &pppd);
+ for (int i = 0; i < nAccs; ++i)
SendDlgItemMessageA(hwnd, (ProtoInList(pppd[i]->szModuleName) ? ID_USEDPROTO : ID_ALLPROTO), LB_ADDSTRING, 0, (LPARAM)pppd[i]->szModuleName);
return TRUE;
case WM_COMMAND:
- switch(LOWORD(wParam))
- {
+ switch (LOWORD(wParam)) {
+ WPARAM n;
case ID_ADD:
- {
- WPARAM n = (WPARAM)SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETCURSEL, 0, 0);
- if(LB_ERR != n) {
- size_t len = SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETTEXTLEN, n, 0);
- if(LB_ERR != len) {
- TCHAR * buf = new TCHAR[len + 1];
- SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETTEXT, n, (LPARAM)buf);
- SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_ADDSTRING, 0, (LPARAM)buf);
- delete []buf;
- SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_DELETESTRING, n, 0);
- }
+ n = (WPARAM)SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETCURSEL, 0, 0);
+ if (LB_ERR != n) {
+ size_t len = SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETTEXTLEN, n, 0);
+ if (LB_ERR != len) {
+ TCHAR * buf = new TCHAR[len + 1];
+ SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETTEXT, n, (LPARAM)buf);
+ SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_ADDSTRING, 0, (LPARAM)buf);
+ delete[]buf;
+ SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_DELETESTRING, n, 0);
}
}
break;
+
case ID_REMOVE:
- {
- WPARAM n = (WPARAM)SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCURSEL, 0, 0);
- if(LB_ERR != n) {
- size_t len = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETTEXTLEN, n, 0);
- if(LB_ERR != len) {
- TCHAR * buf = new TCHAR[len + 1];
- SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETTEXT, n, (LPARAM)buf);
- SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_ADDSTRING, 0, (LPARAM)buf);
- delete []buf;
- SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_DELETESTRING, n, 0);
- }
+ n = (WPARAM)SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCURSEL, 0, 0);
+ if (LB_ERR != n) {
+ size_t len = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETTEXTLEN, n, 0);
+ if (LB_ERR != len) {
+ TCHAR * buf = new TCHAR[len + 1];
+ SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETTEXT, n, (LPARAM)buf);
+ SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_ADDSTRING, 0, (LPARAM)buf);
+ delete[]buf;
+ SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_DELETESTRING, n, 0);
}
}
break;
+
case ID_ADDALL:
- for(;;)
- {
+ for (;;) {
LRESULT count = SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_GETCOUNT, 0, 0);
- if(!count || LB_ERR == count)
+ if (!count || LB_ERR == count)
break;
SendDlgItemMessage(hwnd, ID_ALLPROTO, LB_SETCURSEL, 0, 0);
SendMessage(hwnd, WM_COMMAND, ID_ADD, 0);
}
break;
+
case ID_REMOVEALL:
- for(;;)
- {
+ for (;;) {
LRESULT count = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCOUNT, 0, 0);
- if(!count || LB_ERR == count)
+ if (!count || LB_ERR == count)
break;
SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_SETCURSEL, 0, 0);
SendMessage(hwnd, WM_COMMAND, ID_REMOVE, 0);
}
break;
+
default:
return FALSE;
}
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
return TRUE;
+
case WM_NOTIFY:
- {
- NMHDR* nmhdr = (NMHDR*)lParam;
- switch (nmhdr->code)
- {
- case PSN_APPLY:
- {
- LRESULT count = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCOUNT, 0, 0);
- std::ostringstream out;
- for(int i = 0; i < count; ++i) {
- size_t len = SendDlgItemMessageA(hwnd, ID_USEDPROTO, LB_GETTEXTLEN, i, 0);
- if(LB_ERR != len) {
- char * buf = new char[len + 1];
- SendDlgItemMessageA(hwnd, ID_USEDPROTO, LB_GETTEXT, i, (LPARAM)buf);
- out << buf << "\r\n";
- delete []buf;
- }
- }
- db_set_s(NULL, pluginName, "protoList", out.str().c_str());
+ NMHDR* nmhdr = (NMHDR*)lParam;
+ switch (nmhdr->code) {
+ case PSN_APPLY:
+ LRESULT count = SendDlgItemMessage(hwnd, ID_USEDPROTO, LB_GETCOUNT, 0, 0);
+ std::ostringstream out;
+ for (int i = 0; i < count; ++i) {
+ size_t len = SendDlgItemMessageA(hwnd, ID_USEDPROTO, LB_GETTEXTLEN, i, 0);
+ if (LB_ERR != len) {
+ char * buf = new char[len + 1];
+ SendDlgItemMessageA(hwnd, ID_USEDPROTO, LB_GETTEXT, i, (LPARAM)buf);
+ out << buf << "\r\n";
+ delete[]buf;
}
- return TRUE;
}
+ db_set_s(NULL, pluginName, "protoList", out.str().c_str());
+ return TRUE;
}
break;
}
@@ -244,12 +219,12 @@ INT_PTR CALLBACK ProtoDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) INT_PTR CALLBACK AdvancedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwnd);
CheckDlgButton(hwnd, IDC_INVIS_DISABLE, gbInvisDisable ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwnd, IDC_CASE_INSENSITIVE, gbCaseInsensitive ? BST_CHECKED : BST_UNCHECKED);
- gbDosServiceExist?EnableWindow(GetDlgItem(hwnd, ID_DOS_INTEGRATION),1):EnableWindow(GetDlgItem(hwnd, ID_DOS_INTEGRATION),0);
+ gbDosServiceExist ? EnableWindow(GetDlgItem(hwnd, ID_DOS_INTEGRATION), 1) : EnableWindow(GetDlgItem(hwnd, ID_DOS_INTEGRATION), 0);
CheckDlgButton(hwnd, ID_DOS_INTEGRATION, gbDosServiceIntegration ? BST_CHECKED : BST_UNCHECKED);
SetDlgItemText(hwnd, ID_SPECIALGROUPNAME, gbSpammersGroup.c_str());
CheckDlgButton(hwnd, ID_SPECIALGROUP, gbSpecialGroup ? BST_CHECKED : BST_UNCHECKED);
@@ -273,13 +248,13 @@ INT_PTR CALLBACK AdvancedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar MessageBox(hwnd, TranslateT("If math expression is turned on, you can use following expression in message text:\nXX+XX-X/X*X\neach X will be replaced by one random number and answer will be expression result.\nMessage must contain only one expression without spaces."), TranslateT("Info"), MB_OK);
break;
- case IDC_INVIS_DISABLE:
- case IDC_CASE_INSENSITIVE:
+ case IDC_INVIS_DISABLE:
+ case IDC_CASE_INSENSITIVE:
case ID_DOS_INTEGRATION:
- case ID_SPECIALGROUPNAME:
- case ID_SPECIALGROUP:
- case ID_EXCLUDE:
- case ID_REMOVE_TMP:
+ case ID_SPECIALGROUPNAME:
+ case ID_SPECIALGROUP:
+ case ID_EXCLUDE:
+ case ID_REMOVE_TMP:
case ID_REMOVE_TMP_ALL:
case ID_IGNOREURL:
case IDC_AUTOAUTH:
@@ -299,52 +274,50 @@ INT_PTR CALLBACK AdvancedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case PSN_APPLY:
db_set_b(NULL, pluginName, "CaseInsensitive", gbCaseInsensitive = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_CASE_INSENSITIVE));
db_set_b(NULL, pluginName, "DisableInInvis", gbInvisDisable = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_INVIS_DISABLE));
- db_set_b(NULL, pluginName, "DOSIntegration", gbDosServiceIntegration = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_DOS_INTEGRATION));
+ db_set_b(NULL, pluginName, "DOSIntegration", gbDosServiceIntegration = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_DOS_INTEGRATION));
{
static tstring NewGroupName, CurrentGroupName;
NewGroupName = GetDlgItemString(hwnd, ID_SPECIALGROUPNAME);
CurrentGroupName = gbSpammersGroup = DBGetContactSettingStringPAN(NULL, pluginName, "SpammersGroup", _T("0"));
if (mir_wstrcmp(CurrentGroupName.c_str(), NewGroupName.c_str()) != 0) {
bool GroupExist = Clist_GroupExists(NewGroupName.c_str()) != NULL;
- db_set_ws(NULL,pluginName, "SpammersGroup", NewGroupName.c_str());
- gbSpammersGroup = DBGetContactSettingStringPAN(NULL,pluginName,"SpammersGroup", _T("Spammers"));
- if(!GroupExist && gbSpecialGroup)
+ db_set_ws(NULL, pluginName, "SpammersGroup", NewGroupName.c_str());
+ gbSpammersGroup = DBGetContactSettingStringPAN(NULL, pluginName, "SpammersGroup", _T("Spammers"));
+ if (!GroupExist && gbSpecialGroup)
CreateCListGroup((TCHAR*)gbSpammersGroup.c_str());
}
}
- db_set_b(NULL, pluginName, "SpecialGroup", gbSpecialGroup = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_SPECIALGROUP));
- db_set_b(NULL, pluginName, "ExcludeContacts", gbExclude = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_EXCLUDE));
- db_set_b(NULL, pluginName, "DelExcluded", gbDelExcluded = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_REMOVE_TMP));
- db_set_b(NULL, pluginName, "DelAllTempory", gbDelAllTempory = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_REMOVE_TMP_ALL));
- db_set_b(NULL, pluginName, "IgnoreURL", gbIgnoreURL = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_IGNOREURL));
-
- db_set_b(NULL, pluginName, "AutoAuth", gbAutoAuth = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_AUTOAUTH));
- db_set_b(NULL, pluginName, "AutoAddToServerList", gbAutoAddToServerList = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_ADDTOSRVLST));
- db_set_b(NULL, pluginName, "AutoReqAuth", gbAutoReqAuth = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_REQAUTH));
- db_set_b(NULL, pluginName, "RegexMatch", gbRegexMatch = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_REGEX));
- db_set_b(NULL, pluginName, "HistoryLog", gbHistoryLog = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_HISTORY_LOG));
- db_set_b(NULL, pluginName, "MathExpression", gbMathExpression = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_MATH_QUESTION));
+ db_set_b(NULL, pluginName, "SpecialGroup", gbSpecialGroup = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_SPECIALGROUP));
+ db_set_b(NULL, pluginName, "ExcludeContacts", gbExclude = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_EXCLUDE));
+ db_set_b(NULL, pluginName, "DelExcluded", gbDelExcluded = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_REMOVE_TMP));
+ db_set_b(NULL, pluginName, "DelAllTempory", gbDelAllTempory = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_REMOVE_TMP_ALL));
+ db_set_b(NULL, pluginName, "IgnoreURL", gbIgnoreURL = BST_CHECKED == IsDlgButtonChecked(hwnd, ID_IGNOREURL));
+ db_set_b(NULL, pluginName, "AutoAuth", gbAutoAuth = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_AUTOAUTH));
+ db_set_b(NULL, pluginName, "AutoAddToServerList", gbAutoAddToServerList = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_ADDTOSRVLST));
+ db_set_b(NULL, pluginName, "AutoReqAuth", gbAutoReqAuth = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_REQAUTH));
+ db_set_b(NULL, pluginName, "RegexMatch", gbRegexMatch = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_REGEX));
+ db_set_b(NULL, pluginName, "HistoryLog", gbHistoryLog = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_HISTORY_LOG));
+ db_set_b(NULL, pluginName, "MathExpression", gbMathExpression = BST_CHECKED == IsDlgButtonChecked(hwnd, IDC_MATH_QUESTION));
{
static tstring NewAGroupName, CurrentAGroupName;
NewAGroupName = GetDlgItemString(hwnd, IDC_AUTOADDGROUP);
CurrentAGroupName = gbAutoAuthGroup = DBGetContactSettingStringPAN(NULL, pluginName, "AutoAuthGroup", _T("0"));
if (mir_wstrcmp(CurrentAGroupName.c_str(), NewAGroupName.c_str()) != 0) {
bool GroupExist = Clist_GroupExists(NewAGroupName.c_str()) != NULL;
- db_set_ws(NULL,pluginName, "AutoAuthGroup", NewAGroupName.c_str());
- gbAutoAuthGroup = DBGetContactSettingStringPAN(NULL,pluginName,"AutoAuthGroup", _T("Not Spammers"));
- if(!GroupExist && gbAutoAddToServerList)
+ db_set_ws(NULL, pluginName, "AutoAuthGroup", NewAGroupName.c_str());
+ gbAutoAuthGroup = DBGetContactSettingStringPAN(NULL, pluginName, "AutoAuthGroup", _T("Not Spammers"));
+ if (!GroupExist && gbAutoAddToServerList)
CreateCListGroup((TCHAR*)gbAutoAuthGroup.c_str());
}
}
return TRUE;
}
- break;
+ break;
}
return FALSE;
}
-
HINSTANCE hInst;
MIRANDA_HOOK_EVENT(ME_OPT_INITIALISE, w, l)
{
diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp index bbbc910ed0..2cad3a82a6 100755 --- a/plugins/StopSpamMod/src/utilities.cpp +++ b/plugins/StopSpamMod/src/utilities.cpp @@ -15,17 +15,16 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
#include "stdafx.h"
tstring DBGetContactSettingStringPAN(MCONTACT hContact, char const * szModule, char const * szSetting, tstring errorValue)
{
DBVARIANT dbv;
//if(db_get(hContact, szModule, szSetting, &dbv))
- if(db_get_ts(hContact, szModule, szSetting, &dbv))
+ if (db_get_ts(hContact, szModule, szSetting, &dbv))
return errorValue;
-// if(DBVT_TCHAR == dbv.type )
- errorValue = dbv.ptszVal;
+ // if(DBVT_TCHAR == dbv.type )
+ errorValue = dbv.ptszVal;
db_free(&dbv);
return errorValue;
}
@@ -34,10 +33,10 @@ std::string DBGetContactSettingStringPAN_A(MCONTACT hContact, char const * szMod {
DBVARIANT dbv;
//if(db_get(hContact, szModule, szSetting, &dbv))
- if(db_get_s(hContact, szModule, szSetting, &dbv))
+ if (db_get_s(hContact, szModule, szSetting, &dbv))
return errorValue;
-// if(DBVT_ASCIIZ == dbv.type )
- errorValue = dbv.pszVal;
+ // if(DBVT_ASCIIZ == dbv.type )
+ errorValue = dbv.pszVal;
db_free(&dbv);
return errorValue;
}
@@ -50,7 +49,7 @@ tstring &GetDlgItemString(HWND hwnd, int id) GetWindowText(h, buf, len + 1);
static tstring s;
s = buf;
- delete []buf;
+ delete[]buf;
return s;
}
@@ -78,26 +77,27 @@ int CreateCListGroup(TCHAR* szGroupName) void DeleteCListGroupsByName(TCHAR* szGroupName)
{
BYTE ConfirmDelete = db_get_b(NULL, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT);
- if(ConfirmDelete)
+ if (ConfirmDelete)
db_set_b(NULL, "CList", "ConfirmDelete", 0);
TCHAR *szGroup;
- for (int i=1; (szGroup = pcli->pfnGetGroupName(i, NULL)) != NULL; i++)
- if( !mir_wstrcmp(szGroupName, szGroup))
+ for (int i = 1; (szGroup = pcli->pfnGetGroupName(i, NULL)) != NULL; i++)
+ if (!mir_wstrcmp(szGroupName, szGroup))
CallService(MS_CLIST_GROUPDELETE, i, 0);
- if(ConfirmDelete)
+ if (ConfirmDelete)
db_set_b(NULL, "CList", "ConfirmDelete", ConfirmDelete);
}
-int RemoveTmp(WPARAM,LPARAM)
+int RemoveTmp(WPARAM, LPARAM)
{
void CleanThread();
CleanThread();
return 0;
}
-tstring variables_parse(tstring const &tstrFormat, MCONTACT hContact){
+tstring variables_parse(tstring const &tstrFormat, MCONTACT hContact)
+{
if (gbVarsServiceExist) {
FORMATINFO fi;
TCHAR *tszParsed;
@@ -142,27 +142,25 @@ const int Stricmp(const TCHAR *str, const TCHAR *substr) TCHAR* ReqGetText(DBEVENTINFO* dbei)
{
- if ( !dbei->pBlob )
+ if (!dbei->pBlob)
return 0;
- char * ptr=(char *)&dbei->pBlob[sizeof(DWORD)*2];
- int len=dbei->cbBlob-sizeof(DWORD)*2;
- int i=0;
+ char * ptr = (char *)&dbei->pBlob[sizeof(DWORD) * 2];
+ int len = dbei->cbBlob - sizeof(DWORD) * 2;
+ int i = 0;
- while(len && (i<4))
- {
- if(!ptr[0]) i++;
+ while (len && (i < 4)) {
+ if (!ptr[0]) i++;
ptr++;
len--;
};
- if(len)
- {
- char * tstr=(char *)mir_alloc(len+1);
+ if (len) {
+ char * tstr = (char *)mir_alloc(len + 1);
memcpy(tstr, ptr, len);
- tstr[len]=0;
+ tstr[len] = 0;
WCHAR* msg = NULL;
- msg=(dbei->flags&DBEF_UTF)?mir_utf8decodeW(tstr):mir_a2u(tstr);
+ msg = (dbei->flags&DBEF_UTF) ? mir_utf8decodeW(tstr) : mir_a2u(tstr);
mir_free(tstr);
return (TCHAR *)msg;
};
@@ -171,8 +169,8 @@ TCHAR* ReqGetText(DBEVENTINFO* dbei) BOOL IsUrlContains(TCHAR * Str)
{
- const int CountUrl=11;
- const TCHAR URL[CountUrl][5]=
+ const int CountUrl = 11;
+ const TCHAR URL[CountUrl][5] =
{
L"http",
L"www",
@@ -187,12 +185,11 @@ BOOL IsUrlContains(TCHAR * Str) L".tv"
};
- if(Str && mir_tstrlen(Str)>0) {
+ if (Str && mir_tstrlen(Str) > 0) {
TCHAR *StrLower = NEWTSTR_MALLOC(Str);
CharLowerBuff(StrLower, (int)mir_tstrlen(StrLower));
- for (int i=0; i<CountUrl; i++)
- if(_tcsstr (StrLower, URL[i]))
- {
+ for (int i = 0; i < CountUrl; i++)
+ if (_tcsstr(StrLower, URL[i])) {
mir_free(StrLower);
return 1;
}
@@ -204,8 +201,8 @@ BOOL IsUrlContains(TCHAR * Str) tstring GetContactUid(MCONTACT hContact, tstring Protocol)
{
tstring Uid;
- TCHAR dUid[32]={0};
- char aUid[32]={0};
+ TCHAR dUid[32] = { 0 };
+ char aUid[32] = { 0 };
char *szProto = mir_utf8encodeW(Protocol.c_str());
CONTACTINFO ci;
memset(&ci, 0, sizeof(ci));
@@ -215,19 +212,19 @@ tstring GetContactUid(MCONTACT hContact, tstring Protocol) ci.cbSize = sizeof(ci);
ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
+ if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
switch (ci.type) {
- case CNFT_ASCIIZ:
- Uid=ci.pszVal;
- mir_free((void *)ci.pszVal);
+ case CNFT_ASCIIZ:
+ Uid = ci.pszVal;
+ mir_free((void *)ci.pszVal);
break;
- case CNFT_DWORD:
- _itoa_s(ci.dVal,aUid,32,10);
- OemToChar(aUid, dUid);
- Uid=dUid;
+ case CNFT_DWORD:
+ _itoa_s(ci.dVal, aUid, 32, 10);
+ OemToChar(aUid, dUid);
+ Uid = dUid;
break;
- default:
- Uid=_T("");
+ default:
+ Uid = _T("");
break;
};
}
@@ -240,42 +237,40 @@ void LogSpamToFile(MCONTACT hContact, tstring message) if (!gbLogToFile) return;
tstring LogStrW, LogTime, LogProtocol, LogContactId, LogContactName;
- tstring filename;
std::fstream file;
TCHAR pszName[MAX_PATH];
if (hStopSpamLogDirH)
FoldersGetCustomPathT(hStopSpamLogDirH, pszName, MAX_PATH, _T(""));
else
- mir_tstrncpy(pszName, VARST( _T("%miranda_logpath%")), _countof(pszName));
+ mir_tstrncpy(pszName, VARST(_T("%miranda_logpath%")), _countof(pszName));
- filename = pszName;
- filename = filename + _T("\\stopspam_mod.log");
-
- file.open(filename.c_str(),std::ios::out |std::ios::app);
+ tstring filename = pszName;
+ filename += _T("\\stopspam_mod.log");
+ file.open(filename.c_str(), std::ios::out | std::ios::app);
// Time Log line
time_t time_now;
- tm *TimeNow;
time(&time_now);
- TimeNow = localtime(&time_now);
- LogTime=_wasctime( TimeNow );
+
+ struct tm *TimeNow = localtime(&time_now);
+ LogTime = _wasctime(TimeNow);
// Time Log line
// Name, UID and Protocol Log line
- LogProtocol=DBGetContactSettingStringPAN(hContact,"Protocol","p",_T(""));
- LogContactName=(TCHAR*)pcli->pfnGetContactDisplayName(hContact, 0);
- LogContactId=(LogProtocol==_T(""))?_T(""):GetContactUid(hContact,LogProtocol);
+ LogProtocol = DBGetContactSettingStringPAN(hContact, "Protocol", "p", _T(""));
+ LogContactName = (TCHAR*)pcli->pfnGetContactDisplayName(hContact, 0);
+ LogContactId = (LogProtocol == _T("")) ? _T("") : GetContactUid(hContact, LogProtocol);
// Name, UID and Protocol Log line
- LogStrW=_T("[")+LogTime.substr(0,LogTime.length()-1)+_T("] ")+
- LogContactId+_T(" - ")+
- LogContactName+_T(" (")+
- LogProtocol+_T("): ")+
- message+_T("\n");
+ LogStrW = _T("[") + LogTime.substr(0, LogTime.length() - 1) + _T("] ") +
+ LogContactId + _T(" - ") +
+ LogContactName + _T(" (") +
+ LogProtocol + _T("): ") +
+ message + _T("\n");
- char * buf=mir_u2a(LogStrW.c_str());
- file.write(buf,LogStrW.length());
+ char *buf = mir_u2a(LogStrW.c_str());
+ file.write(buf, LogStrW.length());
mir_free(buf);
file.close();
@@ -285,24 +280,22 @@ boost::mutex clean_mutex; void CleanProtocolTmpThread(std::string proto)
{
- while(true)
- {
+ while (true) {
UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0);
- if(status > ID_STATUS_OFFLINE)
+ if (status > ID_STATUS_OFFLINE)
break;
boost::this_thread::sleep(boost::posix_time::seconds(2));
}
std::list<MCONTACT> contacts;
- for(MCONTACT hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str()))
- if(db_get_b(hContact, "CList", "NotOnList", 0)|| (_T("Not In List")== DBGetContactSettingStringPAN(hContact,"CList","Group",_T(""))))
+ for (MCONTACT hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str()))
+ if (db_get_b(hContact, "CList", "NotOnList", 0) || (_T("Not In List") == DBGetContactSettingStringPAN(hContact, "CList", "Group", _T(""))))
contacts.push_back(hContact);
boost::this_thread::sleep(boost::posix_time::seconds(5));
clean_mutex.lock();
std::list<MCONTACT>::iterator end = contacts.end();
- for(std::list<MCONTACT>::iterator i = contacts.begin(); i != end; ++i)
- {
+ for (std::list<MCONTACT>::iterator i = contacts.begin(); i != end; ++i) {
LogSpamToFile(*i, _T("Deleted"));
HistoryLogFunc(*i, "Deleted");
CallService(MS_DB_CONTACT_DELETE, (WPARAM)*i, 0);
@@ -312,24 +305,22 @@ void CleanProtocolTmpThread(std::string proto) void CleanProtocolExclThread(std::string proto)
{
- while(true)
- {
+ while (true) {
UINT status = CallProtoService(proto.c_str(), PS_GETSTATUS, 0, 0);
- if(status > ID_STATUS_OFFLINE)
+ if (status > ID_STATUS_OFFLINE)
break;
boost::this_thread::sleep(boost::posix_time::seconds(2));
}
std::list<MCONTACT> contacts;
- for(MCONTACT hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str()))
- if(db_get_b(hContact, "CList", "NotOnList", 0) && db_get_b(hContact, pluginName, "Excluded", 0))
+ for (MCONTACT hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str()))
+ if (db_get_b(hContact, "CList", "NotOnList", 0) && db_get_b(hContact, pluginName, "Excluded", 0))
contacts.push_back(hContact);
boost::this_thread::sleep(boost::posix_time::seconds(5));
clean_mutex.lock();
std::list<MCONTACT>::iterator end = contacts.end();
- for(std::list<MCONTACT>::iterator i = contacts.begin(); i != end; ++i)
- {
+ for (std::list<MCONTACT>::iterator i = contacts.begin(); i != end; ++i) {
LogSpamToFile(*i, _T("Deleted"));
HistoryLogFunc(*i, "Deleted");
CallService(MS_DB_CONTACT_DELETE, (WPARAM)*i, 0);
@@ -343,17 +334,15 @@ void CleanThread() int count = 0;
PROTOACCOUNT **accounts;
Proto_EnumAccounts(&count, &accounts);
- for(int i = 0; i < count; i++)
- {
- if(!strstr(accounts[i]->szModuleName, "MetaContacts") && !strstr(accounts[i]->szModuleName, "Weather")) //not real protocols
+ for (int i = 0; i < count; i++)
+ if (!strstr(accounts[i]->szModuleName, "MetaContacts") && !strstr(accounts[i]->szModuleName, "Weather")) //not real protocols
protocols.push_back(accounts[i]->szModuleName);
- }
+
std::list<std::string>::iterator end = protocols.end();
- for(std::list<std::string>::iterator i = protocols.begin(); i != end; ++i)
- {
- if(gbDelAllTempory)
+ for (std::list<std::string>::iterator i = protocols.begin(); i != end; ++i) {
+ if (gbDelAllTempory)
new boost::thread(boost::bind(&CleanProtocolTmpThread, *i));
- if(gbDelExcluded)
+ if (gbDelExcluded)
new boost::thread(boost::bind(&CleanProtocolExclThread, *i));
}
}
@@ -365,23 +354,22 @@ void HistoryLog(MCONTACT hContact, char *data, int event_type, int flags) Event.eventType = event_type;
Event.flags = flags | DBEF_UTF;
Event.timestamp = (DWORD)time(NULL);
- Event.cbBlob = (DWORD)mir_strlen(data)+1;
+ Event.cbBlob = (DWORD)mir_strlen(data) + 1;
Event.pBlob = (PBYTE)_strdup(data);
db_event_add(hContact, &Event);
}
void HistoryLogFunc(MCONTACT hContact, std::string message)
{
- if(gbHistoryLog)
- {
- if(hContact == INVALID_CONTACT_ID)
+ if (gbHistoryLog) {
+ if (hContact == INVALID_CONTACT_ID)
return;
std::string msg = message;
msg.append("\n");
msg.append("Protocol: ").append(GetContactProto(hContact)).append(" Contact: ");
msg.append(toUTF8((TCHAR*)pcli->pfnGetContactDisplayName(hContact, 0))).append(" ID: ");
- msg.append(toUTF8(GetContactUid(hContact,toUTF16(GetContactProto(hContact)))));
+ msg.append(toUTF8(GetContactUid(hContact, toUTF16(GetContactProto(hContact)))));
HistoryLog(NULL, (char*)msg.c_str(), EVENTTYPE_MESSAGE, DBEF_READ);
}
}
@@ -389,11 +377,10 @@ void HistoryLogFunc(MCONTACT hContact, std::string message) std::string toUTF8(std::wstring str)
{
std::string ustr;
- try{
- utf8::utf16to8(str.begin(), str.end(), back_inserter(ustr));
+ try {
+ utf8::utf16to8(str.begin(), str.end(), back_inserter(ustr));
}
- catch(const std::exception&)
- {
+ catch (const std::exception&) {
//TODO: handle utf8cpp exceptions
}
return ustr;
@@ -408,12 +395,11 @@ std::wstring toUTF16(std::string str) //convert as much as possible {
std::wstring ustr;
std::string tmpstr;
- try{
- utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr));
- utf8::utf8to16(tmpstr.begin(), tmpstr.end(), back_inserter(ustr));
+ try {
+ utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr));
+ utf8::utf8to16(tmpstr.begin(), tmpstr.end(), back_inserter(ustr));
}
- catch(const std::exception &)
- {
+ catch (const std::exception &) {
//TODO: handle utf8cpp exceptions
}
return ustr;
@@ -424,8 +410,8 @@ std::string get_random_num(int length) std::string chars("123456789");
std::string data;
boost::random_device rng;
- boost::variate_generator<boost::random_device&, boost::uniform_int<>> gen(rng, boost::uniform_int<>(0, (int)chars.length()-1));
- for(int i = 0; i < length; ++i)
+ boost::variate_generator<boost::random_device&, boost::uniform_int<>> gen(rng, boost::uniform_int<>(0, (int)chars.length() - 1));
+ for (int i = 0; i < length; ++i)
data += chars[gen()];
return data;
}
diff --git a/plugins/TabSRMM/src/buttonsbar.cpp b/plugins/TabSRMM/src/buttonsbar.cpp index ef5282868a..f5dba28146 100644 --- a/plugins/TabSRMM/src/buttonsbar.cpp +++ b/plugins/TabSRMM/src/buttonsbar.cpp @@ -517,7 +517,7 @@ HWND hToolBarTree = NULL; INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - HTREEITEM hti; + HTREEITEM hItem; switch (uMsg) { case WM_INITDIALOG: @@ -624,9 +624,9 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l break; case IDC_SEPARATOR: - hti = TreeView_GetSelection(hToolBarTree); - if (!hti) - hti = TVI_FIRST; + hItem = TreeView_GetSelection(hToolBarTree); + if (!hItem) + hItem = TVI_FIRST; CustomButtonData *cbd = new CustomButtonData(); cbd->m_bSeparator = cbd->m_bHidden = cbd->m_bIMButton = cbd->m_bLSided = true; @@ -638,15 +638,15 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l TVINSERTSTRUCT tvis; tvis.hParent = NULL; - tvis.hInsertAfter = hti; + tvis.hInsertAfter = hItem; tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE; tvis.item.pszText = TranslateT("<Separator>"); tvis.item.iImage = tvis.item.iSelectedImage = -1; tvis.item.lParam = (LPARAM)cbd; - hti = TreeView_InsertItem(hToolBarTree, &tvis); + hItem = TreeView_InsertItem(hToolBarTree, &tvis); - TreeView_SetCheckState(hToolBarTree, hti, (cbd->m_bIMButton || cbd->m_bChatButton)); + TreeView_SetCheckState(hToolBarTree, hItem, (cbd->m_bIMButton || cbd->m_bChatButton)); } break; @@ -660,11 +660,11 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l return 1; case PSN_APPLY: - hti = TreeView_GetSelection(hToolBarTree); - if (hti) { + hItem = TreeView_GetSelection(hToolBarTree); + if (hItem) { TVITEM tvi; tvi.mask = TVIF_HANDLE | TVIF_PARAM; - tvi.hItem = hti; + tvi.hItem = hItem; TreeView_GetItem(hToolBarTree, &tvi); if (tvi.lParam) { @@ -704,12 +704,12 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l break; case TVN_SELCHANGING: - hti = TreeView_GetSelection(hToolBarTree); - if (hti != NULL) { + hItem = TreeView_GetSelection(hToolBarTree); + if (hItem != NULL) { TCHAR strbuf[128]; TVITEM tvi; - tvi.hItem = hti; + tvi.hItem = hItem; tvi.pszText = strbuf; tvi.cchTextMax = _countof(strbuf); tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_PARAM; @@ -732,15 +732,15 @@ INT_PTR CALLBACK DlgProcToolBar(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l break; case TVN_SELCHANGED: - hti = TreeView_GetSelection(hToolBarTree); - if (hti != NULL) { + hItem = TreeView_GetSelection(hToolBarTree); + if (hItem != NULL) { TCHAR strbuf[128]; TVITEM tvi; tvi.pszText = strbuf; tvi.cchTextMax = _countof(strbuf); tvi.mask = TVIF_TEXT | TVIF_HANDLE | TVIF_PARAM; - tvi.hItem = hti; + tvi.hItem = hItem; TreeView_GetItem(hToolBarTree, &tvi); if (!TreeView_GetCheckState(hToolBarTree, tvi.hItem) || !mir_tstrcmp(tvi.pszText, MIDDLE_SEPARATOR)) { diff --git a/plugins/TipperYM/src/mir_smileys.cpp b/plugins/TipperYM/src/mir_smileys.cpp index 3aeafcb697..05095a2fea 100644 --- a/plugins/TipperYM/src/mir_smileys.cpp +++ b/plugins/TipperYM/src/mir_smileys.cpp @@ -133,13 +133,13 @@ SIZE GetTextSize(HDC hdcMem, const TCHAR *szText, SMILEYPARSEINFO info, UINT uTe info->row_height[row_count] = max(info->row_height[row_count], text_height);
if (piece->type == TEXT_PIECE_TYPE_TEXT) {
- RECT text_rc = { 0, 0, 2048, 2048 };
+ RECT rc = { 0, 0, 2048, 2048 };
- DrawText(hdcMem, szText + piece->start_pos, piece->len, &text_rc, DT_CALCRECT | uTextFormat);
- pos_x += (text_rc.right - text_rc.left);
+ DrawText(hdcMem, szText + piece->start_pos, piece->len, &rc, DT_CALCRECT | uTextFormat);
+ pos_x += (rc.right - rc.left);
if (pos_x > max_width) {
- text_size.cx = max(text_size.cx, pos_x - (text_rc.right - text_rc.left));
- pos_x = text_rc.right - text_rc.left;
+ text_size.cx = max(text_size.cx, pos_x - (rc.right - rc.left));
+ pos_x = rc.right - rc.left;
info->row_height[++row_count] = text_height;
}
@@ -148,7 +148,6 @@ SIZE GetTextSize(HDC hdcMem, const TCHAR *szText, SMILEYPARSEINFO info, UINT uTe pos_x = 0;
info->row_height[++row_count] = 0;
}
-
}
else {
double factor;
diff --git a/plugins/TopToolBar/src/toolbar.cpp b/plugins/TopToolBar/src/toolbar.cpp index 650e2d03d4..f6368d6e58 100644 --- a/plugins/TopToolBar/src/toolbar.cpp +++ b/plugins/TopToolBar/src/toolbar.cpp @@ -546,13 +546,13 @@ int OnPluginLoad(WPARAM, LPARAM lParam) int OnPluginUnload(WPARAM, LPARAM lParam)
{
- int hLangpack = GetPluginLangByInstance((HINSTANCE)lParam);
- if (hLangpack) {
+ int lang = GetPluginLangByInstance((HINSTANCE)lParam);
+ if (lang) {
bool bNeedUpdate = false;
mir_cslock lck(csButtonsHook);
for (int i = Buttons.getCount() - 1; i >= 0; i--)
- if (Buttons[i]->hLangpack == hLangpack) {
+ if (Buttons[i]->hLangpack == lang) {
TTBRemoveButton(Buttons[i]->id, 0);
bNeedUpdate = true;
}
diff --git a/plugins/UserInfoEx/src/ex_import/tinyxmlparser.cpp b/plugins/UserInfoEx/src/ex_import/tinyxmlparser.cpp index 8f38ee8ce7..3f4bc639e9 100644 --- a/plugins/UserInfoEx/src/ex_import/tinyxmlparser.cpp +++ b/plugins/UserInfoEx/src/ex_import/tinyxmlparser.cpp @@ -86,7 +86,7 @@ void TiXmlBase::ConvertUTF32ToUTF8(unsigned long input, char* output, int* lengt const unsigned long BYTE_MARK = 0x80;
const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
- if (input < 0x80)
+ if (input < 0x80)
*length = 1;
else if (input < 0x800)
*length = 2;
@@ -94,29 +94,29 @@ void TiXmlBase::ConvertUTF32ToUTF8(unsigned long input, char* output, int* lengt *length = 3;
else if (input < 0x200000)
*length = 4;
- else
- { *length = 0; return; } // This code won't covert this correctly anyway.
+ else {
+ *length = 0; return;
+ } // This code won't covert this correctly anyway.
output += *length;
// Scary scary fall throughs.
- switch (*length)
- {
- case 4:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 3:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 2:
- --output;
- *output = (char)((input | BYTE_MARK) & BYTE_MASK);
- input >>= 6;
- case 1:
- --output;
- *output = (char)(input | FIRST_BYTE_MARK[*length]);
+ switch (*length) {
+ case 4:
+ --output;
+ *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ input >>= 6;
+ case 3:
+ --output;
+ *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ input >>= 6;
+ case 2:
+ --output;
+ *output = (char)((input | BYTE_MARK) & BYTE_MASK);
+ input >>= 6;
+ case 1:
+ --output;
+ *output = (char)(input | FIRST_BYTE_MARK[*length]);
}
}
@@ -130,10 +130,10 @@ void TiXmlBase::ConvertUTF32ToUTF8(unsigned long input, char* output, int* lengt // if (encoding == TIXML_ENCODING_UTF8)
// {
- if (anyByte < 127)
- return isalpha(anyByte);
- else
- return 1; // What else to do? The unicode set is huge...get the english ones right.
+ if (anyByte < 127)
+ return isalpha(anyByte);
+ else
+ return 1; // What else to do? The unicode set is huge...get the english ones right.
// }
// else
// {
@@ -151,10 +151,10 @@ void TiXmlBase::ConvertUTF32ToUTF8(unsigned long input, char* output, int* lengt // if (encoding == TIXML_ENCODING_UTF8)
// {
- if (anyByte < 127)
- return isalnum(anyByte);
- else
- return 1; // What else to do? The unicode set is huge...get the english ones right.
+ if (anyByte < 127)
+ return isalnum(anyByte);
+ else
+ return 1; // What else to do? The unicode set is huge...get the english ones right.
// }
// else
// {
@@ -166,12 +166,12 @@ void TiXmlBase::ConvertUTF32ToUTF8(unsigned long input, char* output, int* lengt class TiXmlParsingData
{
friend class TiXmlDocument;
- public:
+public:
void Stamp(const char* now, TiXmlEncoding encoding);
- const TiXmlCursor& Cursor() { return cursor; }
+ const TiXmlCursor& Cursor() { return cursor; }
- private:
+private:
// Only used by the document!
TiXmlParsingData(const char* start, int _tabsize, int row, int col)
{
@@ -193,8 +193,7 @@ void TiXmlParsingData::Stamp(const char* now, TiXmlEncoding encoding) assert(now);
// Do nothing if the tabsize is 0.
- if (tabsize < 1)
- {
+ if (tabsize < 1) {
return;
}
@@ -204,97 +203,92 @@ void TiXmlParsingData::Stamp(const char* now, TiXmlEncoding encoding) const char* p = stamp;
assert(p);
- while (p < now)
- {
+ while (p < now) {
// Treat p as unsigned, so we have a happy compiler.
const unsigned char* pU = (const unsigned char*)p;
// Code contributed by Fletcher Dunn: (modified by lee)
switch (*pU) {
- case 0:
- // We *should* never get here, but in case we do, don't
- // advance past the terminating null character, ever
- return;
+ case 0:
+ // We *should* never get here, but in case we do, don't
+ // advance past the terminating null character, ever
+ return;
+
+ case '\r':
+ // bump down to the next line
+ ++row;
+ col = 0;
+ // Eat the character
+ ++p;
- case '\r':
- // bump down to the next line
- ++row;
- col = 0;
- // Eat the character
+ // Check for \r\n sequence, and treat this as a single character
+ if (*p == '\n') {
++p;
+ }
+ break;
- // Check for \r\n sequence, and treat this as a single character
- if (*p == '\n') {
- ++p;
- }
- break;
+ case '\n':
+ // bump down to the next line
+ ++row;
+ col = 0;
- case '\n':
- // bump down to the next line
- ++row;
- col = 0;
+ // Eat the character
+ ++p;
- // Eat the character
+ // Check for \n\r sequence, and treat this as a single
+ // character. (Yes, this bizarre thing does occur still
+ // on some arcane platforms...)
+ if (*p == '\r') {
++p;
+ }
+ break;
- // Check for \n\r sequence, and treat this as a single
- // character. (Yes, this bizarre thing does occur still
- // on some arcane platforms...)
- if (*p == '\r') {
- ++p;
- }
- break;
-
- case '\t':
- // Eat the character
- ++p;
+ case '\t':
+ // Eat the character
+ ++p;
- // Skip to next tab stop
- col = (col / tabsize + 1) * tabsize;
- break;
+ // Skip to next tab stop
+ col = (col / tabsize + 1) * tabsize;
+ break;
- case TIXML_UTF_LEAD_0:
- if (encoding == TIXML_ENCODING_UTF8)
- {
- if (*(p+1) && *(p+2))
- {
- // In these cases, don't advance the column. These are
- // 0-width spaces.
- if (*(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2)
- p += 3;
- else if (*(pU+1)==0xbfU && *(pU+2)==0xbeU)
- p += 3;
- else if (*(pU+1)==0xbfU && *(pU+2)==0xbfU)
- p += 3;
- else
- { p +=3; ++col; } // A normal character.
- }
+ case TIXML_UTF_LEAD_0:
+ if (encoding == TIXML_ENCODING_UTF8) {
+ if (*(p + 1) && *(p + 2)) {
+ // In these cases, don't advance the column. These are
+ // 0-width spaces.
+ if (*(pU + 1) == TIXML_UTF_LEAD_1 && *(pU + 2) == TIXML_UTF_LEAD_2)
+ p += 3;
+ else if (*(pU + 1) == 0xbfU && *(pU + 2) == 0xbeU)
+ p += 3;
+ else if (*(pU + 1) == 0xbfU && *(pU + 2) == 0xbfU)
+ p += 3;
+ else {
+ p += 3; ++col;
+ } // A normal character.
}
- else
- {
- ++p;
- ++col;
- }
- break;
+ }
+ else {
+ ++p;
+ ++col;
+ }
+ break;
- default:
- if (encoding == TIXML_ENCODING_UTF8)
- {
- // Eat the 1 to 4 byte utf8 character.
- int step = TiXmlBase::utf8ByteTable[*((unsigned char*)p)];
- if (step == 0)
- step = 1; // Error case from bad encoding, but handle gracefully.
- p += step;
-
- // Just advance one column, of course.
- ++col;
- }
- else
- {
- ++p;
- ++col;
- }
- break;
+ default:
+ if (encoding == TIXML_ENCODING_UTF8) {
+ // Eat the 1 to 4 byte utf8 character.
+ int step = TiXmlBase::utf8ByteTable[*((unsigned char*)p)];
+ if (step == 0)
+ step = 1; // Error case from bad encoding, but handle gracefully.
+ p += step;
+
+ // Just advance one column, of course.
+ ++col;
+ }
+ else {
+ ++p;
+ ++col;
+ }
+ break;
}
}
cursor.row = row;
@@ -308,48 +302,41 @@ void TiXmlParsingData::Stamp(const char* now, TiXmlEncoding encoding) const char* TiXmlBase::SkipWhiteSpace(const char* p, TiXmlEncoding encoding)
{
- if (!p || !*p)
- {
+ if (!p || !*p) {
return 0;
}
- if (encoding == TIXML_ENCODING_UTF8)
- {
- while (*p)
- {
+ if (encoding == TIXML_ENCODING_UTF8) {
+ while (*p) {
const unsigned char* pU = (const unsigned char*)p;
-
+
// Skip the stupid Microsoft UTF-8 Byte order marks
- if ( *(pU+0)==TIXML_UTF_LEAD_0
- && *(pU+1)==TIXML_UTF_LEAD_1
- && *(pU+2)==TIXML_UTF_LEAD_2)
- {
+ if (*(pU + 0) == TIXML_UTF_LEAD_0
+ && *(pU + 1) == TIXML_UTF_LEAD_1
+ && *(pU + 2) == TIXML_UTF_LEAD_2) {
p += 3;
continue;
}
- else if (*(pU+0)==TIXML_UTF_LEAD_0
- && *(pU+1)==0xbfU
- && *(pU+2)==0xbeU)
- {
+ else if (*(pU + 0) == TIXML_UTF_LEAD_0
+ && *(pU + 1) == 0xbfU
+ && *(pU + 2) == 0xbeU) {
p += 3;
continue;
}
- else if (*(pU+0)==TIXML_UTF_LEAD_0
- && *(pU+1)==0xbfU
- && *(pU+2)==0xbfU)
- {
+ else if (*(pU + 0) == TIXML_UTF_LEAD_0
+ && *(pU + 1) == 0xbfU
+ && *(pU + 2) == 0xbfU) {
p += 3;
continue;
}
- if (IsWhiteSpace(*p) || *p == '\n' || *p =='\r') // Still using old rules for white space.
+ if (IsWhiteSpace(*p) || *p == '\n' || *p == '\r') // Still using old rules for white space.
++p;
else
break;
}
}
- else
- {
- while (*p && IsWhiteSpace(*p) || *p == '\n' || *p =='\r')
+ else {
+ while (*p && IsWhiteSpace(*p) || *p == '\n' || *p == '\r')
++p;
}
@@ -359,8 +346,7 @@ const char* TiXmlBase::SkipWhiteSpace(const char* p, TiXmlEncoding encoding) #ifdef TIXML_USE_STL
/*static*/ bool TiXmlBase::StreamWhiteSpace(TIXML_ISTREAM * in, TIXML_STRING * tag)
{
- for (;;)
- {
+ for (;;) {
if (!in->good()) return false;
int c = in->peek();
@@ -368,15 +354,14 @@ const char* TiXmlBase::SkipWhiteSpace(const char* p, TiXmlEncoding encoding) if (!IsWhiteSpace(c) || c <= 0)
return true;
- *tag += (char) in->get();
+ *tag += (char)in->get();
}
}
/*static*/ bool TiXmlBase::StreamTo(TIXML_ISTREAM * in, int character, TIXML_STRING * tag)
{
//assert(character > 0 && character < 128); // else it won't work in utf-8
- while (in->good())
- {
+ while (in->good()) {
int c = in->peek();
if (c == character)
return true;
@@ -384,7 +369,7 @@ const char* TiXmlBase::SkipWhiteSpace(const char* p, TiXmlEncoding encoding) return false;
in->get();
- *tag += (char) c;
+ *tag += (char)c;
}
return false;
}
@@ -402,16 +387,14 @@ const char* TiXmlBase::ReadName(const char* p, TIXML_STRING * name, TiXmlEncodin // After that, they can be letters, underscores, numbers,
// hyphens, or colons. (Colons are valid ony for namespaces,
// but tinyxml can't tell namespaces from names.)
- if ( p && *p
- && (IsAlpha((unsigned char) *p, encoding) || *p == '_'))
- {
- while ( p && *p
- && ( IsAlphaNum((unsigned char) *p, encoding)
- || *p == '_'
- || *p == '-'
- || *p == '.'
- || *p == ':'))
- {
+ if (p && *p
+ && (IsAlpha((unsigned char)*p, encoding) || *p == '_')) {
+ while (p && *p
+ && (IsAlphaNum((unsigned char)*p, encoding)
+ || *p == '_'
+ || *p == '-'
+ || *p == '.'
+ || *p == ':')) {
(*name) += *p;
++p;
}
@@ -423,73 +406,66 @@ const char* TiXmlBase::ReadName(const char* p, TIXML_STRING * name, TiXmlEncodin const char* TiXmlBase::GetEntity(const char* p, char* value, int* length, TiXmlEncoding encoding)
{
// Presume an entity, and pull it out.
- TIXML_STRING ent;
+ TIXML_STRING ent;
int i;
*length = 0;
- if (*(p+1) && *(p+1) == '#' && *(p+2))
- {
+ if (*(p + 1) && *(p + 1) == '#' && *(p + 2)) {
unsigned long ucs = 0;
ptrdiff_t delta = 0;
unsigned mult = 1;
- if (*(p+2) == 'x')
- {
+ if (*(p + 2) == 'x') {
// Hexadecimal.
- if (!*(p+3)) return 0;
+ if (!*(p + 3)) return 0;
- const char* q = p+3;
+ const char* q = p + 3;
q = strchr(q, ';');
if (!q || !*q) return 0;
- delta = q-p;
+ delta = q - p;
--q;
- while (*q != 'x')
- {
+ while (*q != 'x') {
if (*q >= '0' && *q <= '9')
ucs += mult * (*q - '0');
else if (*q >= 'a' && *q <= 'f')
ucs += mult * (*q - 'a' + 10);
else if (*q >= 'A' && *q <= 'F')
ucs += mult * (*q - 'A' + 10);
- else
+ else
return 0;
mult *= 16;
--q;
}
}
- else
- {
+ else {
// Decimal.
- if (!*(p+2)) return 0;
+ if (!*(p + 2)) return 0;
- const char* q = p+2;
+ const char* q = p + 2;
q = strchr(q, ';');
if (!q || !*q) return 0;
- delta = q-p;
+ delta = q - p;
--q;
- while (*q != '#')
- {
+ while (*q != '#') {
if (*q >= '0' && *q <= '9')
ucs += mult * (*q - '0');
- else
+ else
return 0;
mult *= 10;
--q;
}
}
- if (encoding == TIXML_ENCODING_UTF8)
- {
+ if (encoding == TIXML_ENCODING_UTF8) {
// convert the UCS to UTF-8
ConvertUTF32ToUTF8(ucs, value, length);
}
- else
- {
+ else {
*value = (char)ucs;
*length = 1;
}
@@ -497,10 +473,8 @@ const char* TiXmlBase::GetEntity(const char* p, char* value, int* length, TiXmlE }
// Now try to match it.
- for (i=0; i<NUM_ENTITY; ++i)
- {
- if (strncmp(entity[i].str, p, entity[i].strLength) == 0)
- {
+ for (i = 0; i < NUM_ENTITY; ++i) {
+ if (strncmp(entity[i].str, p, entity[i].strLength) == 0) {
assert(mir_strlen(entity[i].str) == entity[i].strLength);
*value = entity[i].chr;
*length = 1;
@@ -512,29 +486,26 @@ const char* TiXmlBase::GetEntity(const char* p, char* value, int* length, TiXmlE *value = *p; // Don't put back the last one, since we return it!
//*length = 1; // Leave unrecognized entities - this doesn't really work.
// Just writes strange XML.
- return p+1;
+ return p + 1;
}
bool TiXmlBase::StringEqual(const char* p,
- const char* tag,
- bool ignoreCase,
- TiXmlEncoding encoding)
+ const char* tag,
+ bool ignoreCase,
+ TiXmlEncoding encoding)
{
assert(p);
assert(tag);
- if (!p || !*p)
- {
+ if (!p || !*p) {
assert(0);
return false;
}
const char* q = p;
- if (ignoreCase)
- {
- while (*q && *tag && ToLower(*q, encoding) == ToLower(*tag, encoding))
- {
+ if (ignoreCase) {
+ while (*q && *tag && ToLower(*q, encoding) == ToLower(*tag, encoding)) {
++q;
++tag;
}
@@ -542,10 +513,8 @@ bool TiXmlBase::StringEqual(const char* p, if (*tag == 0)
return true;
}
- else
- {
- while (*q && *tag && *q == *tag)
- {
+ else {
+ while (*q && *tag && *q == *tag) {
++q;
++tag;
}
@@ -556,53 +525,46 @@ bool TiXmlBase::StringEqual(const char* p, return false;
}
-const char* TiXmlBase::ReadText( const char* p,
- TIXML_STRING * text,
- bool trimWhiteSpace,
- const char* endTag,
- bool caseInsensitive,
- TiXmlEncoding encoding)
+const char* TiXmlBase::ReadText(const char* p,
+ TIXML_STRING * text,
+ bool trimWhiteSpace,
+ const char* endTag,
+ bool caseInsensitive,
+ TiXmlEncoding encoding)
{
- *text = "";
- if ( !trimWhiteSpace // certain tags always keep whitespace
- || !condenseWhiteSpace) // if true, whitespace is always kept
+ *text = "";
+ if (!trimWhiteSpace // certain tags always keep whitespace
+ || !condenseWhiteSpace) // if true, whitespace is always kept
{
// Keep all the white space.
- while ( p && *p
- && !StringEqual(p, endTag, caseInsensitive, encoding)
- )
- {
+ while (p && *p
+ && !StringEqual(p, endTag, caseInsensitive, encoding)
+ ) {
int len;
char cArr[4] = { 0, 0, 0, 0 };
p = GetChar(p, cArr, &len, encoding);
text->append(cArr, len);
}
}
- else
- {
+ else {
bool whitespace = false;
// Remove leading white space:
p = SkipWhiteSpace(p, encoding);
- while ( p && *p
- && !StringEqual(p, endTag, caseInsensitive, encoding))
- {
- if (*p == '\r' || *p == '\n')
- {
+ while (p && *p
+ && !StringEqual(p, endTag, caseInsensitive, encoding)) {
+ if (*p == '\r' || *p == '\n') {
whitespace = true;
++p;
}
- else if (IsWhiteSpace(*p))
- {
+ else if (IsWhiteSpace(*p)) {
whitespace = true;
++p;
}
- else
- {
+ else {
// If we've found whitespace, add it before the
// new character. Any whitespace just becomes a space.
- if (whitespace)
- {
+ if (whitespace) {
(*text) += ' ';
whitespace = false;
}
@@ -630,35 +592,29 @@ void TiXmlDocument::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag) // This "pre-streaming" will never read the closing ">" so the
// sub-tag can orient itself.
- if (!StreamTo(in, '<', tag))
- {
+ if (!StreamTo(in, '<', tag)) {
SetError(TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- while (in->good())
- {
- int tagIndex = (int) tag->length();
- while (in->good() && in->peek() != '>')
- {
+ while (in->good()) {
+ int tagIndex = (int)tag->length();
+ while (in->good() && in->peek() != '>') {
int c = in->get();
- if (c <= 0)
- {
+ if (c <= 0) {
SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
break;
}
- (*tag) += (char) c;
+ (*tag) += (char)c;
}
- if (in->good())
- {
+ if (in->good()) {
// We now have something we presume to be a node of
// some sort. Identify it, and call the node to
// continue streaming.
TiXmlNode* node = Identify(tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING);
- if (node)
- {
+ if (node) {
node->StreamIn(in, tag);
bool isElement = node->ToElement() != 0;
delete node;
@@ -666,13 +622,11 @@ void TiXmlDocument::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag) // If this is the root element, we're done. Parsing will be
// done by the >> operator.
- if (isElement)
- {
+ if (isElement) {
return;
}
}
- else
- {
+ else {
SetError(TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
@@ -691,8 +645,7 @@ const char* TiXmlDocument::Parse(const char* p, TiXmlParsingData* prevData, TiXm // Parse away, at the document level. Since a document
// contains nothing but other tags, most of what happens
// here is skipping white space.
- if (!p || !*p)
- {
+ if (!p || !*p) {
SetError(TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN);
return 0;
}
@@ -701,56 +654,47 @@ const char* TiXmlDocument::Parse(const char* p, TiXmlParsingData* prevData, TiXm // before the while space skip, so that parsing
// starts from the pointer we are given.
location.Clear();
- if (prevData)
- {
+ if (prevData) {
location.row = prevData->cursor.row;
location.col = prevData->cursor.col;
}
- else
- {
+ else {
location.row = 0;
location.col = 0;
}
TiXmlParsingData data(p, TabSize(), location.row, location.col);
location = data.Cursor();
- if (encoding == TIXML_ENCODING_UNKNOWN)
- {
+ if (encoding == TIXML_ENCODING_UNKNOWN) {
// Check for the Microsoft UTF-8 lead bytes.
const unsigned char* pU = (const unsigned char*)p;
- if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0
- && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1
- && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2)
- {
+ if (*(pU + 0) && *(pU + 0) == TIXML_UTF_LEAD_0
+ && *(pU + 1) && *(pU + 1) == TIXML_UTF_LEAD_1
+ && *(pU + 2) && *(pU + 2) == TIXML_UTF_LEAD_2) {
encoding = TIXML_ENCODING_UTF8;
useMicrosoftBOM = true;
}
}
- p = SkipWhiteSpace(p, encoding);
- if (!p)
- {
+ p = SkipWhiteSpace(p, encoding);
+ if (!p) {
SetError(TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN);
return 0;
}
- while (p && *p)
- {
+ while (p && *p) {
TiXmlNode* node = Identify(p, encoding);
- if (node)
- {
+ if (node) {
p = node->Parse(p, &data, encoding);
LinkEndChild(node);
}
- else
- {
+ else {
break;
}
// Did we get encoding info?
- if ( encoding == TIXML_ENCODING_UNKNOWN
- && node->ToDeclaration())
- {
+ if (encoding == TIXML_ENCODING_UNKNOWN
+ && node->ToDeclaration()) {
TiXmlDeclaration* dec = node->ToDeclaration();
const char* enc = dec->Encoding();
assert(enc);
@@ -761,7 +705,7 @@ const char* TiXmlDocument::Parse(const char* p, TiXmlParsingData* prevData, TiXm encoding = TIXML_ENCODING_UTF8;
else if (StringEqual(enc, "UTF8", true, TIXML_ENCODING_UNKNOWN))
encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice
- else
+ else
encoding = TIXML_ENCODING_LEGACY;
}
@@ -779,19 +723,18 @@ const char* TiXmlDocument::Parse(const char* p, TiXmlParsingData* prevData, TiXm }
void TiXmlDocument::SetError(int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding)
-{
+{
// The first error in a chain is more accurate - don't set again!
if (error)
return;
assert(err > 0 && err < TIXML_ERROR_STRING_COUNT);
- error = true;
+ error = true;
errorId = err;
- errorDesc = errorString[ errorId ];
+ errorDesc = errorString[errorId];
errorLocation.Clear();
- if (pError && data)
- {
+ if (pError && data) {
data->Stamp(pError, encoding);
errorLocation = data->Cursor();
}
@@ -803,16 +746,14 @@ TiXmlNode* TiXmlNode::Identify(const char* p, TiXmlEncoding encoding) TiXmlNode* returnNode = 0;
p = SkipWhiteSpace(p, encoding);
- if (!p || !*p || *p != '<')
- {
+ if (!p || !*p || *p != '<') {
return 0;
}
TiXmlDocument* doc = GetDocument();
p = SkipWhiteSpace(p, encoding);
- if (!p || !*p)
- {
+ if (!p || !*p) {
return 0;
}
@@ -828,59 +769,51 @@ TiXmlNode* TiXmlNode::Identify(const char* p, TiXmlEncoding encoding) const char* dtdHeader = { "<!" };
const char* cdataHeader = { "<![CDATA[" };
- if (StringEqual(p, xmlHeader, true, encoding))
- {
+ if (StringEqual(p, xmlHeader, true, encoding)) {
#ifdef DEBUG_PARSER
- TIXML_LOG("XML parsing Declaration\n");
+ TIXML_LOG("XML parsing Declaration\n");
#endif
returnNode = new TiXmlDeclaration();
}
- else if (StringEqual(p, commentHeader, false, encoding))
- {
+ else if (StringEqual(p, commentHeader, false, encoding)) {
#ifdef DEBUG_PARSER
- TIXML_LOG("XML parsing Comment\n");
+ TIXML_LOG("XML parsing Comment\n");
#endif
returnNode = new TiXmlComment();
}
- else if (StringEqual(p, cdataHeader, false, encoding))
- {
+ else if (StringEqual(p, cdataHeader, false, encoding)) {
#ifdef DEBUG_PARSER
- TIXML_LOG("XML parsing CDATA\n");
+ TIXML_LOG("XML parsing CDATA\n");
#endif
TiXmlText* text = new TiXmlText("");
text->SetCDATA(true);
returnNode = text;
}
- else if (StringEqual(p, dtdHeader, false, encoding))
- {
+ else if (StringEqual(p, dtdHeader, false, encoding)) {
#ifdef DEBUG_PARSER
- TIXML_LOG("XML parsing Unknown(1)\n");
+ TIXML_LOG("XML parsing Unknown(1)\n");
#endif
returnNode = new TiXmlUnknown();
}
- else if ( IsAlpha(*(p+1), encoding)
- || *(p+1) == '_')
- {
+ else if (IsAlpha(*(p + 1), encoding)
+ || *(p + 1) == '_') {
#ifdef DEBUG_PARSER
- TIXML_LOG("XML parsing Element\n");
+ TIXML_LOG("XML parsing Element\n");
#endif
returnNode = new TiXmlElement("");
}
- else
- {
+ else {
#ifdef DEBUG_PARSER
- TIXML_LOG("XML parsing Unknown(2)\n");
+ TIXML_LOG("XML parsing Unknown(2)\n");
#endif
returnNode = new TiXmlUnknown();
}
- if (returnNode)
- {
+ if (returnNode) {
// Set the parent, so it can report errors
returnNode->parent = this;
}
- else
- {
+ else {
if (doc)
doc->SetError(TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN);
}
@@ -889,22 +822,20 @@ TiXmlNode* TiXmlNode::Identify(const char* p, TiXmlEncoding encoding) #ifdef TIXML_USE_STL
-void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
+void TiXmlElement::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag)
{
// We're called with some amount of pre-parsing. That is, some of "this"
// element is in "tag". Go ahead and stream to the closing ">"
- while (in->good())
- {
+ while (in->good()) {
int c = in->get();
- if (c <= 0)
- {
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- (*tag) += (char) c ;
-
+ (*tag) += (char)c;
+
if (c == '>')
break;
}
@@ -914,25 +845,21 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag) // Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
// If not, identify and stream.
- if ( tag->at(tag->length() - 1) == '>'
- && tag->at(tag->length() - 2) == '/')
- {
+ if (tag->at(tag->length() - 1) == '>'
+ && tag->at(tag->length() - 2) == '/') {
// All good!
return;
}
- else if (tag->at(tag->length() - 1) == '>')
- {
+ else if (tag->at(tag->length() - 1) == '>') {
// There is more. Could be:
// text
// closing tag
// another node.
- for (;;)
- {
+ for (;;) {
StreamWhiteSpace(in, tag);
// Do we have text?
- if (in->good() && in->peek() != '<')
- {
+ if (in->good() && in->peek() != '<') {
// Yep, text.
TiXmlText text("");
text.StreamIn(in, tag);
@@ -946,33 +873,30 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag) // We should be at a "<", regardless.
if (!in->good()) return;
assert(in->peek() == '<');
- int tagIndex = (int) tag->length();
+ int tagIndex = (int)tag->length();
bool closingTag = false;
bool firstCharFound = false;
- for (;;)
- {
+ for (;;) {
if (!in->good())
return;
int c = in->peek();
- if (c <= 0)
- {
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
-
+
if (c == '>')
break;
- *tag += (char) c;
+ *tag += (char)c;
in->get();
- if (!firstCharFound && c != '<' && !IsWhiteSpace(c))
- {
+ if (!firstCharFound && c != '<' && !IsWhiteSpace(c)) {
firstCharFound = true;
if (c == '/')
closingTag = true;
@@ -980,27 +904,24 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag) }
// If it was a closing tag, then read in the closing '>' to clean up the input stream.
// If it was not, the streaming will be done by the tag.
- if (closingTag)
- {
+ if (closingTag) {
if (!in->good())
return;
int c = in->get();
- if (c <= 0)
- {
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
assert(c == '>');
- *tag += (char) c;
+ *tag += (char)c;
// We are done, once we've found our closing tag.
return;
}
- else
- {
+ else {
// If not a closing tag, id it, and stream.
const char* tagloc = tag->c_str() + tagIndex;
TiXmlNode* node = Identify(tagloc, TIXML_DEFAULT_ENCODING);
@@ -1022,64 +943,55 @@ const char* TiXmlElement::Parse(const char* p, TiXmlParsingData* data, TiXmlEnco p = SkipWhiteSpace(p, encoding);
TiXmlDocument* document = GetDocument();
- if (!p || !*p)
- {
+ if (!p || !*p) {
if (document) document->SetError(TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding);
return 0;
}
- if (data)
- {
+ if (data) {
data->Stamp(p, encoding);
location = data->Cursor();
}
- if (*p != '<')
- {
+ if (*p != '<') {
if (document) document->SetError(TIXML_ERROR_PARSING_ELEMENT, p, data, encoding);
return 0;
}
- p = SkipWhiteSpace(p+1, encoding);
+ p = SkipWhiteSpace(p + 1, encoding);
// Read the name.
const char* pErr = p;
- p = ReadName(p, &value, encoding);
- if (!p || !*p)
- {
+ p = ReadName(p, &value, encoding);
+ if (!p || !*p) {
if (document) document->SetError(TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding);
return 0;
}
- TIXML_STRING endTag ("</");
+ TIXML_STRING endTag("</");
endTag += value;
endTag += ">";
// Check for and read attributes. Also look for an empty
// tag or an end tag.
- while (p && *p)
- {
+ while (p && *p) {
pErr = p;
p = SkipWhiteSpace(p, encoding);
- if (!p || !*p)
- {
+ if (!p || !*p) {
if (document) document->SetError(TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding);
return 0;
}
- if (*p == '/')
- {
+ if (*p == '/') {
++p;
// Empty tag.
- if (*p != '>')
- {
- if (document) document->SetError(TIXML_ERROR_PARSING_EMPTY, p, data, encoding);
+ if (*p != '>') {
+ if (document) document->SetError(TIXML_ERROR_PARSING_EMPTY, p, data, encoding);
return 0;
}
- return (p+1);
+ return (p + 1);
}
- else if (*p == '>')
- {
+ else if (*p == '>') {
// Done with attributes (if there were any.)
// Read the value -- which can include other
// elements -- read the end tag, and return.
@@ -1089,33 +1001,28 @@ const char* TiXmlElement::Parse(const char* p, TiXmlParsingData* data, TiXmlEnco return 0;
// We should find the end tag now
- if (StringEqual(p, endTag.c_str(), false, encoding))
- {
+ if (StringEqual(p, endTag.c_str(), false, encoding)) {
p += endTag.length();
return p;
}
- else
- {
+ else {
if (document) document->SetError(TIXML_ERROR_READING_END_TAG, p, data, encoding);
return 0;
}
}
- else
- {
+ else {
// Try to read an attribute:
TiXmlAttribute* attrib = new TiXmlAttribute();
- if (!attrib)
- {
+ if (!attrib) {
if (document) document->SetError(TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding);
return 0;
}
attrib->SetDocument(document);
- const char* pErr = p;
+ pErr = p;
p = attrib->Parse(p, data, encoding);
- if (!p || !*p)
- {
+ if (!p || !*p) {
if (document) document->SetError(TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding);
delete attrib;
return 0;
@@ -1123,8 +1030,7 @@ const char* TiXmlElement::Parse(const char* p, TiXmlParsingData* data, TiXmlEnco // Handle the strange case of double attributes:
TiXmlAttribute* node = attributeSet.Find(attrib->NameTStr());
- if (node)
- {
+ if (node) {
node->SetValue(attrib->Value());
delete attrib;
return 0;
@@ -1145,25 +1051,20 @@ const char* TiXmlElement::ReadValue(const char* p, TiXmlParsingData* data, TiXml const char* pWithWhiteSpace = p;
p = SkipWhiteSpace(p, encoding);
- while (p && *p)
- {
- if (*p != '<')
- {
+ while (p && *p) {
+ if (*p != '<') {
// Take what we have, make a text element.
TiXmlText* textNode = new TiXmlText("");
- if (!textNode)
- {
+ if (!textNode) {
if (document) document->SetError(TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding);
- return 0;
+ return 0;
}
- if (TiXmlBase::IsWhiteSpaceCondensed())
- {
+ if (TiXmlBase::IsWhiteSpaceCondensed()) {
p = textNode->Parse(p, data, encoding);
}
- else
- {
+ else {
// Special case: we want to keep the white space
// so that leading spaces aren't removed.
p = textNode->Parse(pWithWhiteSpace, data, encoding);
@@ -1173,26 +1074,21 @@ const char* TiXmlElement::ReadValue(const char* p, TiXmlParsingData* data, TiXml LinkEndChild(textNode);
else
delete textNode;
- }
- else
- {
+ }
+ else {
// We hit a '<'
// Have we hit a new element or an end tag? This could also be
// a TiXmlText in the "CDATA" style.
- if (StringEqual(p, "</", false, encoding))
- {
+ if (StringEqual(p, "</", false, encoding)) {
return p;
}
- else
- {
+ else {
TiXmlNode* node = Identify(p, encoding);
- if (node)
- {
+ if (node) {
p = node->Parse(p, data, encoding);
LinkEndChild(node);
- }
- else
- {
+ }
+ else {
return 0;
}
}
@@ -1201,10 +1097,9 @@ const char* TiXmlElement::ReadValue(const char* p, TiXmlParsingData* data, TiXml p = SkipWhiteSpace(p, encoding);
}
- if (!p)
- {
+ if (!p) {
if (document) document->SetError(TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding);
- }
+ }
return p;
}
@@ -1212,22 +1107,19 @@ const char* TiXmlElement::ReadValue(const char* p, TiXmlParsingData* data, TiXml #ifdef TIXML_USE_STL
void TiXmlUnknown::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag)
{
- while (in->good())
- {
- int c = in->get();
- if (c <= 0)
- {
+ while (in->good()) {
+ int c = in->get();
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- (*tag) += (char) c;
+ (*tag) += (char)c;
- if (c == '>')
- {
+ if (c == '>') {
// All is well.
- return;
+ return;
}
}
}
@@ -1239,56 +1131,49 @@ const char* TiXmlUnknown::Parse(const char* p, TiXmlParsingData* data, TiXmlEnco TiXmlDocument* document = GetDocument();
p = SkipWhiteSpace(p, encoding);
- if (data)
- {
+ if (data) {
data->Stamp(p, encoding);
location = data->Cursor();
}
- if (!p || !*p || *p != '<')
- {
+ if (!p || !*p || *p != '<') {
if (document) document->SetError(TIXML_ERROR_PARSING_UNKNOWN, p, data, encoding);
return 0;
}
++p;
- value = "";
+ value = "";
- while (p && *p && *p != '>')
- {
+ while (p && *p && *p != '>') {
value += *p;
++p;
}
- if (!p)
- {
+ if (!p) {
if (document) document->SetError(TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding);
}
if (*p == '>')
- return p+1;
+ return p + 1;
return p;
}
#ifdef TIXML_USE_STL
void TiXmlComment::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag)
{
- while (in->good())
- {
- int c = in->get();
- if (c <= 0)
- {
+ while (in->good()) {
+ int c = in->get();
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- (*tag) += (char) c;
+ (*tag) += (char)c;
- if (c == '>'
- && tag->at(tag->length() - 2) == '-'
- && tag->at(tag->length() - 3) == '-')
- {
+ if (c == '>'
+ && tag->at(tag->length() - 2) == '-'
+ && tag->at(tag->length() - 3) == '-') {
// All is well.
- return;
+ return;
}
}
}
@@ -1302,16 +1187,14 @@ const char* TiXmlComment::Parse(const char* p, TiXmlParsingData* data, TiXmlEnco p = SkipWhiteSpace(p, encoding);
- if (data)
- {
+ if (data) {
data->Stamp(p, encoding);
location = data->Cursor();
}
const char* startTag = "<!--";
- const char* endTag = "-->";
+ const char* endTag = "-->";
- if (!StringEqual(p, startTag, false, encoding))
- {
+ if (!StringEqual(p, startTag, false, encoding)) {
document->SetError(TIXML_ERROR_PARSING_COMMENT, p, data, encoding);
return 0;
}
@@ -1326,63 +1209,56 @@ const char* TiXmlAttribute::Parse(const char* p, TiXmlParsingData* data, TiXmlEn p = SkipWhiteSpace(p, encoding);
if (!p || !*p) return 0;
-// int tabsize = 4;
-// if (document)
-// tabsize = document->TabSize();
+ // int tabsize = 4;
+ // if (document)
+ // tabsize = document->TabSize();
- if (data)
- {
+ if (data) {
data->Stamp(p, encoding);
location = data->Cursor();
}
// Read the name, the '=' and the value.
const char* pErr = p;
p = ReadName(p, &name, encoding);
- if (!p || !*p)
- {
+ if (!p || !*p) {
if (document) document->SetError(TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding);
return 0;
}
p = SkipWhiteSpace(p, encoding);
- if (!p || !*p || *p != '=')
- {
+ if (!p || !*p || *p != '=') {
if (document) document->SetError(TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding);
return 0;
}
++p; // skip '='
p = SkipWhiteSpace(p, encoding);
- if (!p || !*p)
- {
+ if (!p || !*p) {
if (document) document->SetError(TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding);
return 0;
}
-
+
const char* end;
const char SINGLE_QUOTE = '\'';
const char DOUBLE_QUOTE = '\"';
- if (*p == SINGLE_QUOTE)
- {
+ if (*p == SINGLE_QUOTE) {
++p;
end = "\'"; // single quote in string
p = ReadText(p, &value, false, end, false, encoding);
}
- else if (*p == DOUBLE_QUOTE)
- {
+ else if (*p == DOUBLE_QUOTE) {
++p;
end = "\""; // double quote in string
p = ReadText(p, &value, false, end, false, encoding);
}
- else
- {
+ else {
// All attribute values should be in single or double quotes.
// But this is such a common error that the parser will try
// its best, even without them.
value = "";
- while ( p && *p // existence
- && !IsWhiteSpace(*p) && *p != '\n' && *p != '\r' // whitespace
- && *p != '/' && *p != '>') // tag end
+ while (p && *p // existence
+ && !IsWhiteSpace(*p) && *p != '\n' && *p != '\r' // whitespace
+ && *p != '/' && *p != '>') // tag end
{
if (*p == SINGLE_QUOTE || *p == DOUBLE_QUOTE) {
// [ 1451649 ] Attribute values with trailing quotes not handled correctly
@@ -1401,43 +1277,37 @@ const char* TiXmlAttribute::Parse(const char* p, TiXmlParsingData* data, TiXmlEn #ifdef TIXML_USE_STL
void TiXmlText::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag)
{
- if (cdata)
- {
- int c = in->get();
- if (c <= 0)
- {
+ if (cdata) {
+ int c = in->get();
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- (*tag) += (char) c;
+ (*tag) += (char)c;
- if (c == '>'
- && tag->at(tag->length() - 2) == ']'
- && tag->at(tag->length() - 3) == ']')
- {
+ if (c == '>'
+ && tag->at(tag->length() - 2) == ']'
+ && tag->at(tag->length() - 3) == ']') {
// All is well.
- return;
+ return;
}
}
- else
- {
- while (in->good())
- {
- int c = in->peek();
+ else {
+ while (in->good()) {
+ int c = in->peek();
if (c == '<')
return;
- if (c <= 0)
- {
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- (*tag) += (char) c;
+ (*tag) += (char)c;
in->get();
}
}
@@ -1449,47 +1319,42 @@ const char* TiXmlText::Parse(const char* p, TiXmlParsingData* data, TiXmlEncodin value = "";
TiXmlDocument* document = GetDocument();
- if (data)
- {
+ if (data) {
data->Stamp(p, encoding);
location = data->Cursor();
}
const char* const startTag = "<![CDATA[";
- const char* const endTag = "]]>";
+ const char* const endTag = "]]>";
- if (cdata || StringEqual(p, startTag, false, encoding))
- {
+ if (cdata || StringEqual(p, startTag, false, encoding)) {
cdata = true;
- if (!StringEqual(p, startTag, false, encoding))
- {
+ if (!StringEqual(p, startTag, false, encoding)) {
document->SetError(TIXML_ERROR_PARSING_CDATA, p, data, encoding);
return 0;
}
p += mir_strlen(startTag);
// Keep all the white space, ignore the encoding, etc.
- while ( p && *p
- && !StringEqual(p, endTag, false, encoding)
- )
- {
+ while (p && *p
+ && !StringEqual(p, endTag, false, encoding)
+ ) {
value += *p;
++p;
}
- TIXML_STRING dummy;
+ TIXML_STRING dummy;
p = ReadText(p, &dummy, false, endTag, false, encoding);
return p;
}
- else
- {
+ else {
bool ignoreWhite = true;
const char* end = "<";
p = ReadText(p, &value, ignoreWhite, end, false, encoding);
if (p)
- return p-1; // don't truncate the '<'
+ return p - 1; // don't truncate the '<'
return 0;
}
}
@@ -1497,20 +1362,17 @@ const char* TiXmlText::Parse(const char* p, TiXmlParsingData* data, TiXmlEncodin #ifdef TIXML_USE_STL
void TiXmlDeclaration::StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag)
{
- while (in->good())
- {
+ while (in->good()) {
int c = in->get();
- if (c <= 0)
- {
+ if (c <= 0) {
TiXmlDocument* document = GetDocument();
if (document)
document->SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
return;
}
- (*tag) += (char) c;
+ (*tag) += (char)c;
- if (c == '>')
- {
+ if (c == '>') {
// All is well.
return;
}
@@ -1524,13 +1386,11 @@ const char* TiXmlDeclaration::Parse(const char* p, TiXmlParsingData* data, TiXml // Find the beginning, find the end, and look for
// the stuff in-between.
TiXmlDocument* document = GetDocument();
- if (!p || !*p || !StringEqual(p, "<?xml", true, _encoding))
- {
+ if (!p || !*p || !StringEqual(p, "<?xml", true, _encoding)) {
if (document) document->SetError(TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding);
return 0;
}
- if (data)
- {
+ if (data) {
data->Stamp(p, _encoding);
location = data->Cursor();
}
@@ -1540,35 +1400,29 @@ const char* TiXmlDeclaration::Parse(const char* p, TiXmlParsingData* data, TiXml encoding = "";
standalone = "";
- while (p && *p)
- {
- if (*p == '>')
- {
+ while (p && *p) {
+ if (*p == '>') {
++p;
return p;
}
p = SkipWhiteSpace(p, _encoding);
- if (StringEqual(p, "version", true, _encoding))
- {
+ if (StringEqual(p, "version", true, _encoding)) {
TiXmlAttribute attrib;
- p = attrib.Parse(p, data, _encoding);
+ p = attrib.Parse(p, data, _encoding);
version = attrib.Value();
}
- else if (StringEqual(p, "encoding", true, _encoding))
- {
+ else if (StringEqual(p, "encoding", true, _encoding)) {
TiXmlAttribute attrib;
- p = attrib.Parse(p, data, _encoding);
+ p = attrib.Parse(p, data, _encoding);
encoding = attrib.Value();
}
- else if (StringEqual(p, "standalone", true, _encoding))
- {
+ else if (StringEqual(p, "standalone", true, _encoding)) {
TiXmlAttribute attrib;
- p = attrib.Parse(p, data, _encoding);
+ p = attrib.Parse(p, data, _encoding);
standalone = attrib.Value();
}
- else
- {
+ else {
// Read over whatever it is.
while (p && *p && *p != '>' && !IsWhiteSpace(*p))
++p;
@@ -1579,9 +1433,8 @@ const char* TiXmlDeclaration::Parse(const char* p, TiXmlParsingData* data, TiXml bool TiXmlText::Blank() const
{
- for (unsigned i=0; i<value.length(); i++)
+ for (unsigned i = 0; i < value.length(); i++)
if (!IsWhiteSpace(value[i]))
return false;
return true;
}
-
diff --git a/plugins/UserInfoEx/src/mir_db.cpp b/plugins/UserInfoEx/src/mir_db.cpp index 2898d3980a..7b5ed883ec 100644 --- a/plugins/UserInfoEx/src/mir_db.cpp +++ b/plugins/UserInfoEx/src/mir_db.cpp @@ -386,23 +386,26 @@ BYTE ConvertString(DBVARIANT* dbv, const BYTE destType) if (dbv == NULL)
return 1;
- LPSTR tmpBuf;
switch (dbv->type) {
// source value is of type "ascii"
case DBVT_ASCIIZ:
switch (destType) {
// destination type is "utf8"
case DBVT_UTF8:
- tmpBuf = mir_utf8encode(dbv->pszVal);
- mir_free(dbv->pszVal);
- dbv->pszVal = tmpBuf;
+ {
+ LPSTR tmpBuf = mir_utf8encode(dbv->pszVal);
+ mir_free(dbv->pszVal);
+ dbv->pszVal = tmpBuf;
+ }
dbv->type = (dbv->pszVal) ? destType : DBVT_DELETED;
break;
// destination type is "wchar"
case DBVT_WCHAR:
- LPWSTR tmpBuf = mir_a2u(dbv->pszVal);
- mir_free(dbv->pszVal);
- dbv->pwszVal = tmpBuf;
+ {
+ LPWSTR tmpBuf = mir_a2u(dbv->pszVal);
+ mir_free(dbv->pszVal);
+ dbv->pwszVal = tmpBuf;
+ }
dbv->type = (dbv->pwszVal) ? destType : DBVT_DELETED;
}
break;
@@ -425,19 +428,23 @@ BYTE ConvertString(DBVARIANT* dbv, const BYTE destType) break;
// source value is of type "wchar"
case DBVT_WCHAR:
- switch (destType) {
- // destination type is "ascii"
+ switch (destType) {
+ // destination type is "ascii"
case DBVT_ASCIIZ:
- tmpBuf = mir_u2a(dbv->pwszVal);
- mir_free(dbv->pwszVal);
- dbv->pszVal = tmpBuf;
+ {
+ LPSTR tmpBuf = mir_u2a(dbv->pwszVal);
+ mir_free(dbv->pwszVal);
+ dbv->pszVal = tmpBuf;
+ }
dbv->type = (dbv->pszVal) ? destType : DBVT_DELETED;
break;
- // destination type is "utf8"
+ // destination type is "utf8"
case DBVT_UTF8:
- tmpBuf = mir_utf8encodeW(dbv->pwszVal);
- mir_free(dbv->pwszVal);
- dbv->pszVal = tmpBuf;
+ {
+ LPSTR tmpBuf = mir_utf8encodeW(dbv->pwszVal);
+ mir_free(dbv->pwszVal);
+ dbv->pszVal = tmpBuf;
+ }
dbv->type = (dbv->pszVal) ? destType : DBVT_DELETED;
}
}
@@ -459,8 +466,9 @@ BYTE dbv2String(DBVARIANT* dbv, const BYTE destType) if (dbv == NULL)
return 1;
- switch (destType) {
+ WCHAR wbuf[32];
CHAR buf[32];
+ switch (destType) {
// destination type is "utf8" or "ascii"
case DBVT_ASCIIZ:
case DBVT_UTF8:
@@ -494,23 +502,22 @@ BYTE dbv2String(DBVARIANT* dbv, const BYTE destType) // destination type is "wchar"
case DBVT_WCHAR:
switch (dbv->type) {
- WCHAR buf[32];
// source value is of type "byte"
case DBVT_BYTE:
- _ultow(dbv->bVal, buf, 10);
- dbv->pwszVal = mir_wstrdup(buf);
+ _ultow(dbv->bVal, wbuf, 10);
+ dbv->pwszVal = mir_wstrdup(wbuf);
dbv->type = (dbv->pwszVal) ? destType : DBVT_DELETED;
break;
// source value is of type "word"
case DBVT_WORD:
- _ultow(dbv->wVal, buf, 10);
- dbv->pwszVal = mir_wstrdup(buf);
+ _ultow(dbv->wVal, wbuf, 10);
+ dbv->pwszVal = mir_wstrdup(wbuf);
dbv->type = (dbv->pwszVal) ? destType : DBVT_DELETED;
break;
// source value is of type "dword"
case DBVT_DWORD:
- _ultow(dbv->dVal, buf, 10);
- dbv->pwszVal = mir_wstrdup(buf);
+ _ultow(dbv->dVal, wbuf, 10);
+ dbv->pwszVal = mir_wstrdup(wbuf);
dbv->type = (dbv->pwszVal) ? destType : DBVT_DELETED;
break;
// source value is of any string type
diff --git a/plugins/UserInfoEx/src/psp_anniversary.cpp b/plugins/UserInfoEx/src/psp_anniversary.cpp index e634756e2f..8683a347c7 100644 --- a/plugins/UserInfoEx/src/psp_anniversary.cpp +++ b/plugins/UserInfoEx/src/psp_anniversary.cpp @@ -248,7 +248,6 @@ INT_PTR CALLBACK PSPProcAnniversary(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM case RADIO_REMIND1:
case RADIO_REMIND2:
case RADIO_REMIND3:
- CAnnivEditCtrl *pDateCtrl = CAnnivEditCtrl::GetObj(hDlg, EDIT_ANNIVERSARY_DATE);
if (PtrIsValid(pDateCtrl) && HIWORD(wParam) == BN_CLICKED)
pDateCtrl->OnReminderChecked();
return FALSE;
diff --git a/plugins/Utils/mir_options.cpp b/plugins/Utils/mir_options.cpp index 2182d60ce1..eb4e36d3b2 100644 --- a/plugins/Utils/mir_options.cpp +++ b/plugins/Utils/mir_options.cpp @@ -71,7 +71,7 @@ static void PathToRelative(TCHAR *pOut, size_t outSize, const TCHAR *pSrc) if (dbPath[0] == _T('\0')) {
char tmp[1024];
CallService(MS_DB_GETPROFILEPATH, _countof(tmp), (LPARAM)tmp);
- mir_sntprintf(dbPath, _countof(dbPath), _T("%S\\"), tmp);
+ mir_sntprintf(dbPath, _T("%S\\"), tmp);
}
size_t len = mir_tstrlen(dbPath);
@@ -89,7 +89,7 @@ static void PathToAbsolute(TCHAR *pOut, size_t outSize, const TCHAR *pSrc) if (dbPath[0] == _T('\0')) {
char tmp[1024];
CallService(MS_DB_GETPROFILEPATH, _countof(tmp), (LPARAM)tmp);
- mir_sntprintf(dbPath, _countof(dbPath), _T("%S\\"), tmp);
+ mir_sntprintf(dbPath, _T("%S\\"), tmp);
}
mir_sntprintf(pOut, outSize, _T("%s%s"), dbPath, pSrc);
diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp index f110ab27d9..3ab77baea8 100644 --- a/plugins/Variables/src/contact.cpp +++ b/plugins/Variables/src/contact.cpp @@ -73,7 +73,8 @@ static builtinCnfs[] = { CCNF_PROTOID, STR_PROTOID }
};
-typedef struct {
+typedef struct
+{
TCHAR* tszContact;
MCONTACT hContact;
DWORD flags;
@@ -91,11 +92,11 @@ static HANDLE hContactSettingChangedHook; */
BYTE getContactInfoType(TCHAR* type)
{
- if (type == NULL || mir_tstrlen(type) == 0 )
+ if (type == NULL || mir_tstrlen(type) == 0)
return 0;
- for (int i=0; i < _countof(builtinCnfs); i++ )
- if (!mir_tstrcmp( builtinCnfs[i].str, type ))
+ for (int i = 0; i < _countof(builtinCnfs); i++)
+ if (!mir_tstrcmp(builtinCnfs[i].str, type))
return builtinCnfs[i].cnfCode;
return 0;
@@ -119,17 +120,19 @@ TCHAR* getContactInfoT(BYTE type, MCONTACT hContact) case CCNF_PROTOID:
return mir_a2t(szProto);
- case CCNF_ACCOUNT: {
- PROTOACCOUNT *pa = Proto_GetAccount(szProto);
- return pa ? mir_tstrdup(pa->tszAccountName) : NULL;
- }
+ case CCNF_ACCOUNT:
+ {
+ PROTOACCOUNT *pa = Proto_GetAccount(szProto);
+ return pa ? mir_tstrdup(pa->tszAccountName) : NULL;
+ }
- case CCNF_PROTOCOL: {
- char protoname[128];
- if (CallProtoService(szProto, PS_GETNAME, (WPARAM)sizeof(protoname), (LPARAM)protoname))
- return NULL;
- return mir_a2t(protoname);
- }
+ case CCNF_PROTOCOL:
+ {
+ char protoname[128];
+ if (CallProtoService(szProto, PS_GETNAME, (WPARAM)sizeof(protoname), (LPARAM)protoname))
+ return NULL;
+ return mir_a2t(protoname);
+ }
case CCNF_STATUS:
return mir_tstrdup(pcli->pfnGetStatusModeDescription(db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), 0));
@@ -143,7 +146,7 @@ TCHAR* getContactInfoT(BYTE type, MCONTACT hContact) struct in_addr in;
in.s_addr = htonl(ip);
- return mir_a2t( inet_ntoa(in));
+ return mir_a2t(inet_ntoa(in));
}
case CCNF_GROUP:
@@ -165,10 +168,10 @@ TCHAR* getContactInfoT(BYTE type, MCONTACT hContact) ci.hContact = hContact;
ci.dwFlag = type | CNF_UNICODE;
CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci);
-
+
char szVal[16];
memset(szVal, '\0', sizeof(szVal));
- switch(ci.type) {
+ switch (ci.type) {
case CNFT_BYTE:
if (type == CNF_GENDER) {
szVal[0] = (char)ci.bVal; szVal[1] = 0;
@@ -214,7 +217,7 @@ int getContactFromString(CONTACTSINFO *ci) /* search the cache */
{
mir_cslock lck(csContactCache);
- for (int i=0; i < cacheSize; i++) {
+ for (int i = 0; i < cacheSize; i++) {
if ((!mir_tstrcmp(cce[i].tszContact, tszContact)) && (ci->flags == cce[i].flags)) {
/* found in cache */
ci->hContacts = (MCONTACT*)mir_alloc(sizeof(MCONTACT));
@@ -228,21 +231,20 @@ int getContactFromString(CONTACTSINFO *ci) }
/* contact was not in cache, do a search */
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- {
- TCHAR *szFind = NULL;
- BOOL bMatch = FALSE;
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ bool bMatch = false;
// <_HANDLE_:hContact>
- size_t size = mir_tstrlen(_T(PROTOID_HANDLE)) + 36;
- szFind = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
- if (szFind != NULL)
{
- mir_sntprintf(szFind, size, _T("<%s:%p>"), _T(PROTOID_HANDLE), hContact);
- if (!_tcsncmp(tszContact, szFind, mir_tstrlen(tszContact)))
- bMatch = TRUE;
+ size_t size = mir_tstrlen(_T(PROTOID_HANDLE)) + 36;
+ TCHAR *szFind = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
+ if (szFind != NULL) {
+ mir_sntprintf(szFind, size, _T("<%s:%p>"), _T(PROTOID_HANDLE), hContact);
+ if (!_tcsncmp(tszContact, szFind, mir_tstrlen(tszContact)))
+ bMatch = true;
- mir_free(szFind);
+ mir_free(szFind);
+ }
}
char *szProto = GetContactProto(hContact);
@@ -250,82 +252,80 @@ int getContactFromString(CONTACTSINFO *ci) continue;
// <proto:id> (exact)
- if ((ci->flags & CI_PROTOID) && !bMatch)
- {
+ if ((ci->flags & CI_PROTOID) && !bMatch) {
TCHAR *cInfo = getContactInfoT(CNF_UNIQUEID, hContact);
- if (cInfo)
- {
+ if (cInfo) {
size_t size = mir_tstrlen(cInfo) + mir_strlen(szProto) + 4;
- szFind = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
+ TCHAR *szFind = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (szFind != NULL) {
mir_sntprintf(szFind, size, _T("<%S:%s>"), szProto, cInfo);
mir_free(cInfo);
if (!_tcsncmp(tszContact, szFind, mir_tstrlen(tszContact)))
- bMatch = TRUE;
+ bMatch = true;
mir_free(szFind);
}
}
}
// id (exact)
if ((ci->flags & CI_UNIQUEID) && (!bMatch)) {
- szFind = getContactInfoT(CNF_UNIQUEID, hContact);
+ TCHAR *szFind = getContactInfoT(CNF_UNIQUEID, hContact);
if (szFind != NULL) {
if (!mir_tstrcmp(tszContact, szFind))
- bMatch = TRUE;
+ bMatch = true;
mir_free(szFind);
}
}
// nick (not exact)
if ((ci->flags & CI_NICK) && (!bMatch)) {
- szFind = getContactInfoT(CNF_NICK, hContact);
+ TCHAR *szFind = getContactInfoT(CNF_NICK, hContact);
if (szFind != NULL) {
if (!mir_tstrcmp(tszContact, szFind))
- bMatch = TRUE;
+ bMatch = true;
mir_free(szFind);
}
}
// list name (not exact)
if ((ci->flags & CI_LISTNAME) && (!bMatch)) {
- szFind = getContactInfoT(CNF_DISPLAY, hContact);
+ TCHAR *szFind = getContactInfoT(CNF_DISPLAY, hContact);
if (szFind != NULL) {
if (!mir_tstrcmp(tszContact, szFind))
- bMatch = TRUE;
+ bMatch = true;
mir_free(szFind);
}
}
// firstname (exact)
if ((ci->flags & CI_FIRSTNAME) && (!bMatch)) {
- szFind = getContactInfoT(CNF_FIRSTNAME, hContact);
+ TCHAR *szFind = getContactInfoT(CNF_FIRSTNAME, hContact);
if (szFind != NULL) {
if (!mir_tstrcmp(tszContact, szFind))
- bMatch = TRUE;
+ bMatch = true;
mir_free(szFind);
}
}
// lastname (exact)
if ((ci->flags & CI_LASTNAME) && (!bMatch)) {
- szFind = getContactInfoT(CNF_LASTNAME, hContact);
+ TCHAR *szFind = getContactInfoT(CNF_LASTNAME, hContact);
if (szFind != NULL) {
if (!mir_tstrcmp(tszContact, szFind))
- bMatch = TRUE;
+ bMatch = true;
mir_free(szFind);
}
}
// email (exact)
if ((ci->flags & CI_EMAIL) && (!bMatch)) {
- szFind = getContactInfoT(CNF_EMAIL, hContact);
+ TCHAR *szFind = getContactInfoT(CNF_EMAIL, hContact);
if (szFind != NULL) {
if (!mir_tstrcmp(tszContact, szFind))
- bMatch = TRUE;
+ bMatch = true;
mir_free(szFind);
}
}
// CNF_ (exact)
if ((ci->flags & CI_CNFINFO) && (!bMatch)) {
- szFind = getContactInfoT((BYTE)(ci->flags&~(CI_CNFINFO|CI_TCHAR)), hContact);
+ TCHAR *szFind = getContactInfoT((BYTE)(ci->flags&~(CI_CNFINFO | CI_TCHAR)), hContact);
if (szFind != NULL) {
if (!mir_tstrcmp(tszContact, szFind))
- bMatch = TRUE;
+ bMatch = true;
mir_free(szFind);
}
}
@@ -341,7 +341,7 @@ int getContactFromString(CONTACTSINFO *ci) if (count == 1) { /* cache the found result */
mir_cslock lck(csContactCache);
- cce = (CONTACTCE*)mir_realloc(cce, (cacheSize+1)*sizeof(CONTACTCE));
+ cce = (CONTACTCE*)mir_realloc(cce, (cacheSize + 1)*sizeof(CONTACTCE));
if (cce != NULL) {
cce[cacheSize].hContact = ci->hContacts[0];
cce[cacheSize].flags = ci->flags;
@@ -360,28 +360,27 @@ static int contactSettingChanged(WPARAM hContact, LPARAM lParam) DBCONTACTWRITESETTING *dbw = (DBCONTACTWRITESETTING*)lParam;
mir_cslock lck(csContactCache);
- for (int i=0; i < cacheSize; i++) {
- if (hContact != cce[i].hContact && (cce[i].flags & CI_CNFINFO) == 0 )
+ for (int i = 0; i < cacheSize; i++) {
+ if (hContact != cce[i].hContact && (cce[i].flags & CI_CNFINFO) == 0)
continue;
char *szProto = GetContactProto(hContact);
if (szProto == NULL)
continue;
- char *uid = (char*)CallProtoService(szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0);
+ char *uid = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
if (((!mir_strcmp(dbw->szSetting, "Nick")) && (cce[i].flags & CI_NICK)) ||
- ((!mir_strcmp(dbw->szSetting, "FirstName")) && (cce[i].flags & CI_FIRSTNAME)) ||
- ((!mir_strcmp(dbw->szSetting, "LastName")) && (cce[i].flags & CI_LASTNAME)) ||
- ((!mir_strcmp(dbw->szSetting, "e-mail")) && (cce[i].flags & CI_EMAIL)) ||
- ((!mir_strcmp(dbw->szSetting, "MyHandle")) && (cce[i].flags & CI_LISTNAME)) ||
- (cce[i].flags & CI_CNFINFO) != 0 || // lazy; always invalidate CNF info cache entries
- (( ((INT_PTR)uid != CALLSERVICE_NOTFOUND) && (uid != NULL)) && (!mir_strcmp(dbw->szSetting, uid)) && (cce[i].flags & CI_UNIQUEID)))
- {
+ ((!mir_strcmp(dbw->szSetting, "FirstName")) && (cce[i].flags & CI_FIRSTNAME)) ||
+ ((!mir_strcmp(dbw->szSetting, "LastName")) && (cce[i].flags & CI_LASTNAME)) ||
+ ((!mir_strcmp(dbw->szSetting, "e-mail")) && (cce[i].flags & CI_EMAIL)) ||
+ ((!mir_strcmp(dbw->szSetting, "MyHandle")) && (cce[i].flags & CI_LISTNAME)) ||
+ (cce[i].flags & CI_CNFINFO) != 0 || // lazy; always invalidate CNF info cache entries
+ ((((INT_PTR)uid != CALLSERVICE_NOTFOUND) && (uid != NULL)) && (!mir_strcmp(dbw->szSetting, uid)) && (cce[i].flags & CI_UNIQUEID))) {
/* remove from cache */
mir_free(cce[i].tszContact);
if (cacheSize > 1) {
- memmove(&cce[i], &cce[cacheSize-1], sizeof(CONTACTCE));
- cce = ( CONTACTCE* )mir_realloc(cce, (cacheSize-1)*sizeof(CONTACTCE));
+ memmove(&cce[i], &cce[cacheSize - 1], sizeof(CONTACTCE));
+ cce = (CONTACTCE*)mir_realloc(cce, (cacheSize - 1)*sizeof(CONTACTCE));
cacheSize -= 1;
}
else {
@@ -430,8 +429,8 @@ MCONTACT decodeContactFromString(TCHAR *tszContact) MCONTACT hContact = INVALID_CONTACT_ID;
CONTACTSINFO ci = { sizeof(ci) };
ci.tszContact = tszContact;
- ci.flags = CI_PROTOID|CI_TCHAR;
- int count = getContactFromString( &ci );
+ ci.flags = CI_PROTOID | CI_TCHAR;
+ int count = getContactFromString(&ci);
if (count != 1) {
mir_free(ci.hContacts);
return hContact;
diff --git a/plugins/Watrack_MPD/src/main.cpp b/plugins/Watrack_MPD/src/main.cpp index 9fc1ca9c50..7fac682f62 100755 --- a/plugins/Watrack_MPD/src/main.cpp +++ b/plugins/Watrack_MPD/src/main.cpp @@ -50,7 +50,6 @@ int Parser() { static NETLIBPACKETRECVER nlpr = {0}; char *ptr; - char tmp[256]; int i; char *buf; static char ver[16]; @@ -115,6 +114,7 @@ int Parser() } nlpr.bytesUsed = nlpr.bytesAvailable; } + char tmp[256]; buf = (char*)nlpr.buffer; if(ptr = strstr(buf, "MPD")) { diff --git a/plugins/Weather/src/weather_addstn.cpp b/plugins/Weather/src/weather_addstn.cpp index f8d54ad42e..e8e8dc25c3 100644 --- a/plugins/Weather/src/weather_addstn.cpp +++ b/plugins/Weather/src/weather_addstn.cpp @@ -25,7 +25,7 @@ to the contact list. Contain code for both name and ID search. #include "stdafx.h"
// variables used for weather_addstn.c
-static int searchId = -1;
+static int sttSearchId = -1;
static TCHAR name1[256];
// ============ ADDING NEW STATION ============
@@ -133,7 +133,7 @@ BOOL CheckSearch() { // ============ BASIC ID SEARCH ============
-static TCHAR sID[32];
+static TCHAR sttSID[32];
// A timer process for the ID search (threaded)
static void __cdecl BasicSearchTimerProc(LPVOID)
@@ -141,26 +141,26 @@ static void __cdecl BasicSearchTimerProc(LPVOID) int result;
// search only when it's not current updating weather.
if (CheckSearch())
- result = IDSearch(sID, searchId);
+ result = IDSearch(sttSID, sttSearchId);
// broadcast the search result
- ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)searchId, 0);
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)sttSearchId, 0);
// exit the search
- searchId = -1;
+ sttSearchId = -1;
}
// the service function for ID search
// lParam = ID search string
INT_PTR WeatherBasicSearch(WPARAM, LPARAM lParam)
{
- if (searchId != -1) return 0; //only one search at a time
- _tcsncpy(sID, ( TCHAR* )lParam, _countof(sID));
- sID[_countof(sID)-1] = 0;
- searchId = 1;
+ if (sttSearchId != -1) return 0; //only one search at a time
+ _tcsncpy(sttSID, ( TCHAR* )lParam, _countof(sttSID));
+ sttSID[_countof(sttSID)-1] = 0;
+ sttSearchId = 1;
// create a thread for the ID search
mir_forkthread(BasicSearchTimerProc, NULL);
- return searchId;
+ return sttSearchId;
}
// ============ NAME SEARCH ============
@@ -171,13 +171,13 @@ static void __cdecl NameSearchTimerProc(LPVOID) // search only when it's not current updating weather.
if (CheckSearch())
if (name1[0] != 0)
- NameSearch(name1, searchId); // search nickname field
+ NameSearch(name1, sttSearchId); // search nickname field
// broadcast the result
- ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)searchId, 0);
+ ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)sttSearchId, 0);
// exit the search
- searchId = -1;
+ sttSearchId = -1;
}
static INT_PTR CALLBACK WeatherSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM)
@@ -207,14 +207,14 @@ INT_PTR WeatherCreateAdvancedSearchUI(WPARAM, LPARAM lParam) // service function for name search
INT_PTR WeatherAdvancedSearch(WPARAM, LPARAM lParam)
{
- if (searchId != -1) return 0; //only one search at a time
+ if (sttSearchId != -1) return 0; //only one search at a time
- searchId = 1;
+ sttSearchId = 1;
GetDlgItemText((HWND)lParam, IDC_SEARCHCITY, name1, _countof(name1));
// search for the weather station using a thread
mir_forkthread(NameSearchTimerProc, NULL);
- return searchId;
+ return sttSearchId;
}
// ============ SEARCH FOR A WEATHER STATION USING ID ============
diff --git a/plugins/Weather/src/weather_mwin.cpp b/plugins/Weather/src/weather_mwin.cpp index 4390e86058..b92291fa17 100644 --- a/plugins/Weather/src/weather_mwin.cpp +++ b/plugins/Weather/src/weather_mwin.cpp @@ -41,13 +41,12 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara {
MWinDataType *data = (MWinDataType*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- switch(msg)
- {
+ switch (msg) {
case WM_CREATE:
data = (MWinDataType*)mir_calloc(sizeof(MWinDataType));
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data);
- data->hContact = (MCONTACT)((LPCREATESTRUCT)lParam)->lpCreateParams;
+ data->hContact = (DWORD_PTR)((LPCREATESTRUCT)lParam)->lpCreateParams;
data->hAvt = CreateWindow(AVATAR_CONTROL_CLASS, TEXT(""), WS_CHILD,
0, 0, opt.AvatarSize, opt.AvatarSize, hwnd, NULL, hInst, 0);
if (data->hAvt) SendMessage(data->hAvt, AVATAR_SETCONTACT, 0, (LPARAM)data->hContact);
@@ -69,14 +68,13 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case WM_MOUSEMOVE:
{
- TRACKMOUSEEVENT tme = {0};
+ TRACKMOUSEEVENT tme = { 0 };
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.hwndTrack = hwnd;
tme.dwFlags = TME_QUERY;
TrackMouseEvent(&tme);
- if (tme.dwFlags == 0)
- {
+ if (tme.dwFlags == 0) {
tme.dwFlags = TME_HOVER | TME_LEAVE;
tme.hwndTrack = hwnd;
tme.dwHoverTime = CallService(MS_CLC_GETINFOTIPHOVERTIME, 0, 0);
@@ -88,7 +86,7 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara case WM_MOUSEHOVER:
{
POINT pt;
- CLCINFOTIP ti = {0};
+ CLCINFOTIP ti = { 0 };
GetCursorPos(&pt);
GetWindowRect(hwnd, &ti.rcItem);
@@ -106,7 +104,7 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara break;
case WM_COMMAND: //Needed by the contact's context menu
- if ( CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam),MPCF_CONTACTMENU), (LPARAM)data->hContact))
+ if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)data->hContact))
break;
return FALSE;
@@ -117,11 +115,9 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam);
case WM_NOTIFY:
- if (((LPNMHDR)lParam)->code == NM_AVATAR_CHANGED)
- {
+ if (((LPNMHDR)lParam)->code == NM_AVATAR_CHANGED) {
BOOL newava = CallService(MS_AV_GETAVATARBITMAP, (WPARAM)data->hContact, 0) != 0;
- if (newava != data->haveAvatar)
- {
+ if (newava != data->haveAvatar) {
LONG_PTR style = GetWindowLongPtr(data->hAvt, GWL_STYLE);
data->haveAvatar = newava;
SetWindowLongPtr(data->hAvt, GWL_STYLE, newava ? (style | WS_VISIBLE) : (style & ~WS_VISIBLE));
@@ -139,9 +135,8 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara {
RECT r, rc;
- if (GetUpdateRect(hwnd, &r, FALSE))
- {
- DBVARIANT dbv = {0};
+ if (GetUpdateRect(hwnd, &r, FALSE)) {
+ DBVARIANT dbv = { 0 };
PAINTSTRUCT ps;
LOGFONT lfnt, lfnt1;
COLORREF fntc, fntc1;
@@ -149,14 +144,12 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara int picSize = opt.AvatarSize;
HICON hIcon = NULL;
- if ( !data->haveAvatar)
- {
+ if (!data->haveAvatar) {
int statusIcon = db_get_w(data->hContact, WEATHERPROTONAME, "Status", 0);
picSize = GetSystemMetrics(SM_CXICON);
hIcon = Skin_LoadProtoIcon(WEATHERPROTONAME, statusIcon, true);
- if ((INT_PTR)hIcon == CALLSERVICE_NOTFOUND)
- {
+ if ((INT_PTR)hIcon == CALLSERVICE_NOTFOUND) {
picSize = GetSystemMetrics(SM_CXSMICON);
hIcon = Skin_LoadProtoIcon(WEATHERPROTONAME, statusIcon);
}
@@ -165,7 +158,7 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara clr = db_get_dw(NULL, WEATHERPROTONAME, "ColorMwinFrame", GetSysColor(COLOR_3DFACE));
{
- FontIDT fntid = {0};
+ FontIDT fntid = { 0 };
mir_tstrcpy(fntid.group, _T(WEATHERPROTONAME));
mir_tstrcpy(fntid.name, LPGENT("Frame Font"));
fntc = CallService(MS_FONT_GETT, (WPARAM)&fntid, (LPARAM)&lfnt);
@@ -180,7 +173,7 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara HDC hdc = BeginPaint(hwnd, &ps);
- if ( ServiceExists(MS_SKIN_DRAWGLYPH)) {
+ if (ServiceExists(MS_SKIN_DRAWGLYPH)) {
SKINDRAWREQUEST rq;
memset(&rq, 0, sizeof(rq));
rq.hDC = hdc;
@@ -197,16 +190,16 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara DeleteObject(hBkgBrush);
}
- if ( !data->haveAvatar)
+ if (!data->haveAvatar)
DrawIconEx(hdc, 1, 1, hIcon, 0, 0, 0, NULL, DI_NORMAL);
SetBkMode(hdc, TRANSPARENT);
HFONT hfnt = CreateFontIndirect(&lfnt1);
- HFONT hfntold = ( HFONT )SelectObject(hdc, hfnt);
+ HFONT hfntold = (HFONT)SelectObject(hdc, hfnt);
SIZE fontSize;
- TCHAR *nick = ( TCHAR* )pcli->pfnGetContactDisplayName(data->hContact, 0);
+ TCHAR *nick = (TCHAR*)pcli->pfnGetContactDisplayName(data->hContact, 0);
GetTextExtentPoint32(hdc, _T("|"), 1, &fontSize);
@@ -221,16 +214,15 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara SelectObject(hdc, hfntold);
DeleteObject(hfnt);
- if (dbv.pszVal)
- {
- HFONT hfnt = CreateFontIndirect(&lfnt);
- HFONT hfntold = ( HFONT )SelectObject(hdc, hfnt);
+ if (dbv.pszVal) {
+ HFONT hFont = CreateFontIndirect(&lfnt);
+ HFONT hFontOld = (HFONT)SelectObject(hdc, hFont);
SetTextColor(hdc, fntc);
DrawText(hdc, dbv.ptszVal, -1, &rc, DT_LEFT | DT_EXPANDTABS);
- SelectObject(hdc, hfntold);
- DeleteObject(hfnt);
+ SelectObject(hdc, hFontOld);
+ DeleteObject(hFont);
}
EndPaint(hwnd, &ps);
IcoLib_ReleaseIcon(hIcon);
@@ -254,13 +246,13 @@ static void addWindow(MCONTACT hContact) mir_sntprintf(winname, _countof(winname), _T("Weather: %s"), dbv.ptszVal);
db_free(&dbv);
- HWND hWnd = CreateWindow( _T("WeatherFrame"), _T(""), WS_CHILD | WS_VISIBLE,
+ HWND hWnd = CreateWindow(_T("WeatherFrame"), _T(""), WS_CHILD | WS_VISIBLE,
0, 0, 10, 10, pcli->hwndContactList, NULL, hInst, (void*)hContact);
WindowList_Add(hMwinWindowList, hWnd, hContact);
- CLISTFrame Frame = {0};
+ CLISTFrame Frame = { 0 };
Frame.tname = winname;
- Frame.hIcon = LoadIconEx("main",FALSE);
+ Frame.hIcon = LoadIconEx("main", FALSE);
Frame.cbSize = sizeof(Frame);
Frame.hWnd = hWnd;
Frame.align = alBottom;
@@ -302,7 +294,7 @@ INT_PTR Mwin_MenuClicked(WPARAM wParam, LPARAM) }
-int BuildContactMenu(WPARAM wparam,LPARAM)
+int BuildContactMenu(WPARAM wparam, LPARAM)
{
int flags = db_get_dw((MCONTACT)wparam, WEATHERPROTONAME, "mwin", 0) ? CMIF_CHECKED : 0;
Menu_ModifyItem(hMwinMenu, NULL, INVALID_HANDLE_VALUE, flags);
@@ -319,25 +311,25 @@ int RedrawFrame(WPARAM, LPARAM) void InitMwin(void)
{
- if ( !ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
+ if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
return;
hMwinWindowList = WindowList_Create();
WNDCLASS wndclass;
- wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
- wndclass.lpfnWndProc = wndProc;
- wndclass.cbClsExtra = 0;
- wndclass.cbWndExtra = 0;
- wndclass.hInstance = hInst;
- wndclass.hIcon = NULL;
- wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wndclass.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
+ wndclass.lpfnWndProc = wndProc;
+ wndclass.cbClsExtra = 0;
+ wndclass.cbWndExtra = 0;
+ wndclass.hInstance = hInst;
+ wndclass.hIcon = NULL;
+ wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = 0; //(HBRUSH)(COLOR_3DFACE+1);
- wndclass.lpszMenuName = NULL;
+ wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = _T("WeatherFrame");
RegisterClass(&wndclass);
- ColourIDT colourid = {0};
+ ColourIDT colourid = { 0 };
colourid.cbSize = sizeof(ColourIDT);
mir_strcpy(colourid.dbSettingsGroup, WEATHERPROTONAME);
mir_strcpy(colourid.setting, "ColorMwinFrame");
@@ -346,7 +338,7 @@ void InitMwin(void) colourid.defcolour = GetSysColor(COLOR_3DFACE);
ColourRegisterT(&colourid);
- FontIDT fontid = {0};
+ FontIDT fontid = { 0 };
fontid.cbSize = sizeof(FontIDT);
fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID;
mir_strcpy(fontid.dbSettingsGroup, WEATHERPROTONAME);
@@ -383,7 +375,7 @@ void DestroyMwin(void) if (frameId)
CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0);
}
- UnregisterClass( _T("WeatherFrame"), hInst);
+ UnregisterClass(_T("WeatherFrame"), hInst);
WindowList_Destroy(hMwinWindowList);
UnhookEvent(hFontHook);
}
diff --git a/plugins/Weather/src/weather_svcs.cpp b/plugins/Weather/src/weather_svcs.cpp index 09af852326..f1a027ae19 100644 --- a/plugins/Weather/src/weather_svcs.cpp +++ b/plugins/Weather/src/weather_svcs.cpp @@ -55,7 +55,7 @@ INT_PTR WeatherGetCaps(WPARAM wParam, LPARAM) {
INT_PTR ret = 0;
- switch(wParam) {
+ switch (wParam) {
case PFLAGNUM_1:
// support search and visible list
ret = PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_EXTSEARCH | PF1_VISLIST | PF1_MODEMSGRECV;
@@ -63,17 +63,17 @@ INT_PTR WeatherGetCaps(WPARAM wParam, LPARAM) case PFLAGNUM_2:
ret = PF2_ONLINE | PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND |
- PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
+ PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
break;
case PFLAGNUM_4:
ret = PF4_AVATARS | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_FORCEADDED |
- PF4_FORCEAUTH;
+ PF4_FORCEAUTH;
break;
case PFLAGNUM_5: /* this is PFLAGNUM_5 change when alpha SDK is released */
ret = PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND |
- PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
+ PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
break;
case PFLAG_UNIQUEIDTEXT:
@@ -88,10 +88,10 @@ INT_PTR WeatherGetCaps(WPARAM wParam, LPARAM) }
// protocol service function to get weather protocol name
-INT_PTR WeatherGetName(WPARAM wParam,LPARAM lParam)
+INT_PTR WeatherGetName(WPARAM wParam, LPARAM lParam)
{
- strncpy((char*)lParam,WEATHERPROTOTEXT,wParam-1);
- *((char*)lParam + wParam-1) = 0;
+ strncpy((char*)lParam, WEATHERPROTOTEXT, wParam - 1);
+ *((char*)lParam + wParam - 1) = 0;
return 0;
}
@@ -102,7 +102,7 @@ INT_PTR WeatherGetStatus(WPARAM, LPARAM) }
// protocol service function to get the icon of the protocol
-INT_PTR WeatherLoadIcon(WPARAM wParam,LPARAM)
+INT_PTR WeatherLoadIcon(WPARAM wParam, LPARAM)
{
return (LOWORD(wParam) == PLI_PROTOCOL) ? (INT_PTR)CopyIcon(LoadIconEx("main", FALSE)) : 0;
}
@@ -110,14 +110,14 @@ INT_PTR WeatherLoadIcon(WPARAM wParam,LPARAM) static void __cdecl AckThreadProc(HANDLE param)
{
Sleep(100);
- ProtoBroadcastAck(WEATHERPROTONAME, (MCONTACT)param, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0);
+ ProtoBroadcastAck(WEATHERPROTONAME, (DWORD_PTR)param, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
// nothing to do here because weather proto do not need to retrieve contact info form network
// so just return a 0
-INT_PTR WeatherGetInfo(WPARAM,LPARAM lParam)
+INT_PTR WeatherGetInfo(WPARAM, LPARAM lParam)
{
- CCSDATA *ccs = (CCSDATA *) lParam;
+ CCSDATA *ccs = (CCSDATA *)lParam;
mir_forkthread(AckThreadProc, (void*)ccs->hContact);
return 0;
}
@@ -129,7 +129,6 @@ static const WORD statusValue[] = { LIGHT, FOG, SSHOWER, SNOW, RSHOWER, RAIN, PC INT_PTR WeatherGetAvatarInfo(WPARAM, LPARAM lParam)
{
TCHAR szSearchPath[MAX_PATH], *chop;
- WORD status;
unsigned i;
PROTO_AVATAR_INFORMATION *pai = (PROTO_AVATAR_INFORMATION*)lParam;
@@ -139,9 +138,9 @@ INT_PTR WeatherGetAvatarInfo(WPARAM, LPARAM lParam) if (chop) *chop = '\0';
else szSearchPath[0] = 0;
- status = (WORD)db_get_w(pai->hContact, WEATHERPROTONAME, "StatusIcon",0);
- for (i=0; i<10; i++)
- if (statusValue[i] == status)
+ int iStatus = db_get_w(pai->hContact, WEATHERPROTONAME, "StatusIcon", 0);
+ for (i = 0; i < 10; i++)
+ if (statusValue[i] == iStatus)
break;
if (i >= 10)
@@ -149,12 +148,12 @@ INT_PTR WeatherGetAvatarInfo(WPARAM, LPARAM lParam) pai->format = PA_FORMAT_PNG;
mir_sntprintf(pai->filename, _countof(pai->filename), _T("%s\\Plugins\\Weather\\%s.png"), szSearchPath, statusStr[i]);
- if ( _taccess(pai->filename, 4) == 0)
+ if (_taccess(pai->filename, 4) == 0)
return GAIR_SUCCESS;
pai->format = PA_FORMAT_GIF;
mir_sntprintf(pai->filename, _countof(pai->filename), _T("%s\\Plugins\\Weather\\%s.gif"), szSearchPath, statusStr[i]);
- if ( _taccess(pai->filename, 4) == 0)
+ if (_taccess(pai->filename, 4) == 0)
return GAIR_SUCCESS;
pai->format = PA_FORMAT_UNKNOWN;
@@ -162,7 +161,6 @@ INT_PTR WeatherGetAvatarInfo(WPARAM, LPARAM lParam) return GAIR_NOAVATAR;
}
-
void AvatarDownloaded(MCONTACT hContact)
{
PROTO_AVATAR_INFORMATION ai = { 0 };
@@ -174,17 +172,17 @@ void AvatarDownloaded(MCONTACT hContact) ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0);
}
-
-static void __cdecl WeatherGetAwayMsgThread(void *hContact)
+static void __cdecl WeatherGetAwayMsgThread(void *arg)
{
Sleep(100);
+ MCONTACT hContact = (DWORD_PTR)arg;
DBVARIANT dbv;
- if (!db_get_ts((MCONTACT)hContact, "CList", "StatusMsg", &dbv)) {
- ProtoBroadcastAck(WEATHERPROTONAME, (MCONTACT)hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal);
- db_free( &dbv );
+ if (!db_get_ts(hContact, "CList", "StatusMsg", &dbv)) {
+ ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, (LPARAM)dbv.ptszVal);
+ db_free(&dbv);
}
- else ProtoBroadcastAck(WEATHERPROTONAME, (MCONTACT)hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, 0);
+ else ProtoBroadcastAck(WEATHERPROTONAME, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
static INT_PTR WeatherGetAwayMsg(WPARAM, LPARAM lParam)
@@ -251,7 +249,7 @@ void UpdatePopupMenu(BOOL State) }
// update the weather auto-update menu item when click on it
-INT_PTR EnableDisableCmd(WPARAM wParam,LPARAM lParam)
+INT_PTR EnableDisableCmd(WPARAM wParam, LPARAM lParam)
{
UpdateMenu(wParam == TRUE ? (BOOL)lParam : !opt.CAutoUpdate);
return 0;
diff --git a/plugins/WebView/src/webview.cpp b/plugins/WebView/src/webview.cpp index 6eba2c8d56..dc2adfdbf9 100644 --- a/plugins/WebView/src/webview.cpp +++ b/plugins/WebView/src/webview.cpp @@ -35,7 +35,7 @@ COLORREF BackgoundClr, TextClr; UINT_PTR timerId;
UINT_PTR Countdown;
-LOGFONT lf;
+LOGFONT g_lf;
HFONT h_font;
HWND ContactHwnd;
HINSTANCE hInst;
@@ -63,8 +63,8 @@ void ChangeMenuItemCountdown() // countdown
HICON hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_UPDATEALL));
- TCHAR countername[100];
- mir_sntprintf(countername,_countof(countername), TranslateT("%d minutes to update"), db_get_dw(NULL, MODULENAME, COUNTDOWN_KEY, 0));
+ TCHAR countername[100];
+ mir_sntprintf(countername, _countof(countername), TranslateT("%d minutes to update"), db_get_dw(NULL, MODULENAME, COUNTDOWN_KEY, 0));
Menu_ModifyItem(hMenuItemCountdown, countername, hIcon, CMIF_KEEPUNTRANSLATED);
}
@@ -72,10 +72,10 @@ void ChangeMenuItemCountdown() /*****************************************************************************/
static int CALLBACK EnumFontsProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX*, int, LPARAM lParam)
{
- if (!IsWindow((HWND) lParam))
+ if (!IsWindow((HWND)lParam))
return FALSE;
- if (SendMessage((HWND) lParam, CB_FINDSTRINGEXACT, -1, (LPARAM) lpelfe->elfLogFont.lfFaceName) == CB_ERR)
- SendMessage((HWND) lParam, CB_ADDSTRING, 0, (LPARAM) lpelfe->elfLogFont.lfFaceName);
+ if (SendMessage((HWND)lParam, CB_FINDSTRINGEXACT, -1, (LPARAM)lpelfe->elfLogFont.lfFaceName) == CB_ERR)
+ SendMessage((HWND)lParam, CB_ADDSTRING, 0, (LPARAM)lpelfe->elfLogFont.lfFaceName);
return TRUE;
}
@@ -83,11 +83,11 @@ void FillFontListThread(void *param) {
HDC hdc = GetDC((HWND)param);
- LOGFONT lf = {0};
- lf.lfCharSet = DEFAULT_CHARSET;
- lf.lfFaceName[0] = 0;
- lf.lfPitchAndFamily = 0;
- EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC) EnumFontsProc, (LPARAM) GetDlgItem((HWND)param, IDC_TYPEFACE), 0);
+ LOGFONT lf = { 0 };
+ g_lf.lfCharSet = DEFAULT_CHARSET;
+ g_lf.lfFaceName[0] = 0;
+ g_lf.lfPitchAndFamily = 0;
+ EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontsProc, (LPARAM)GetDlgItem((HWND)param, IDC_TYPEFACE), 0);
ReleaseDC((HWND)param, hdc);
}
@@ -168,7 +168,7 @@ int Doubleclick(WPARAM wParam, LPARAM) {
MCONTACT hContact = wParam;
char *szProto = GetContactProto(hContact);
- if ( mir_strcmp(MODULENAME, szProto))
+ if (mir_strcmp(MODULENAME, szProto))
return 0;
int action = db_get_b(hContact, MODULENAME, DBLE_WIN_KEY, 1);
@@ -176,7 +176,7 @@ int Doubleclick(WPARAM wParam, LPARAM) ptrT url(db_get_tsa(hContact, MODULENAME, "URL"));
Utils_OpenUrlT(url);
- db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
}
else if (action == 1) {
HWND hwndDlg = WindowList_Find(hWindowList, hContact);
@@ -185,11 +185,11 @@ int Doubleclick(WPARAM wParam, LPARAM) SetFocus(hwndDlg);
}
else {
- hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM) hContact);
+ hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM)hContact);
HWND hTopmost = db_get_b(hContact, MODULENAME, ON_TOP_KEY, 0) ? HWND_TOPMOST : HWND_NOTOPMOST;
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
- if ( db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0))
+ if (db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0))
SetWindowPos(hwndDlg, hTopmost,
db_get_dw(hContact, MODULENAME, "WVx", 100), // Xposition,
db_get_dw(hContact, MODULENAME, "WVy", 100), // Yposition,
@@ -207,7 +207,7 @@ int Doubleclick(WPARAM wParam, LPARAM) mir_forkthread(ReadFromFile, (void*)hContact);
else
mir_forkthread(GetData, (void*)hContact);
- db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
}
}
@@ -229,13 +229,13 @@ int SendToRichEdit(HWND hWindow, char *truncated, COLORREF rgbText, COLORREF rgb cfFM.cbSize = sizeof(CHARFORMAT2);
cfFM.dwMask = CFM_COLOR | CFM_CHARSET | CFM_FACE | ENM_LINK | ENM_MOUSEEVENTS | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_SIZE;
- if ( db_get_b(NULL, MODULENAME, FONT_BOLD_KEY, 0))
+ if (db_get_b(NULL, MODULENAME, FONT_BOLD_KEY, 0))
bold = CFE_BOLD;
- if ( db_get_b(NULL, MODULENAME, FONT_ITALIC_KEY, 0))
+ if (db_get_b(NULL, MODULENAME, FONT_ITALIC_KEY, 0))
italic = CFE_ITALIC;
- if ( db_get_b(NULL, MODULENAME, FONT_UNDERLINE_KEY, 0))
+ if (db_get_b(NULL, MODULENAME, FONT_UNDERLINE_KEY, 0))
underline = CFE_UNDERLINE;
cfFM.dwEffects = bold | italic | underline;
@@ -247,14 +247,14 @@ int SendToRichEdit(HWND hWindow, char *truncated, COLORREF rgbText, COLORREF rgb else mir_tstrcpy(cfFM.szFaceName, Def_font_face);
HDC hDC = GetDC(hWindow);
- cfFM.yHeight = (BYTE)MulDiv(abs(lf.lfHeight), 120, GetDeviceCaps(GetDC(hWindow), LOGPIXELSY)) * (db_get_b(NULL, MODULENAME, FONT_SIZE_KEY, 14));
+ cfFM.yHeight = (BYTE)MulDiv(abs(g_lf.lfHeight), 120, GetDeviceCaps(GetDC(hWindow), LOGPIXELSY)) * (db_get_b(NULL, MODULENAME, FONT_SIZE_KEY, 14));
ReleaseDC(hWindow, hDC);
cfFM.bCharSet = db_get_b(NULL, MODULENAME, FONT_SCRIPT_KEY, 0);
cfFM.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
cfFM.crTextColor = rgbText;
cfFM.crBackColor = rgbBack;
- SendDlgItemMessage(hWindow, IDC_DATA, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) & cfFM);
+ SendDlgItemMessage(hWindow, IDC_DATA, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)& cfFM);
SendDlgItemMessage(hWindow, IDC_DATA, EM_SETSEL, 0, -1);
SendDlgItemMessageA(hWindow, IDC_DATA, EM_REPLACESEL, FALSE, (LPARAM)truncated);
@@ -278,12 +278,12 @@ void CALLBACK timerfunc(HWND, UINT, UINT_PTR, DWORD) void CALLBACK Countdownfunc(HWND, UINT, UINT_PTR, DWORD)
{
DWORD timetemp = db_get_dw(NULL, MODULENAME, COUNTDOWN_KEY, 100);
- if(timetemp <= 0) {
+ if (timetemp <= 0) {
timetemp = db_get_dw(NULL, MODULENAME, REFRESH_KEY, TIME);
db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, timetemp);
}
- db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, timetemp-1);
+ db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, timetemp - 1);
ChangeMenuItemCountdown();
}
@@ -298,7 +298,7 @@ static int OptInitialise(WPARAM wParam, LPARAM) odp.ptszGroup = LPGENT("Network");
odp.ptszTitle = _T(MODULENAME);
odp.pfnDlgProc = DlgProcOpt;
- odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
+ odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
Options_AddPage(wParam, &odp);
// if popup service exists
@@ -314,20 +314,20 @@ static int OptInitialise(WPARAM wParam, LPARAM) /*****************************************************************************/
void FontSettings(void)
{
- lf.lfHeight = 16;
- lf.lfWidth = 0;
- lf.lfEscapement = 0;
- lf.lfOrientation = 0;
- lf.lfWeight = FW_NORMAL;
- lf.lfItalic = FALSE;
- lf.lfUnderline = FALSE;
- lf.lfStrikeOut = 0;
- lf.lfCharSet = ANSI_CHARSET;
- lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
- lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lf.lfQuality = DEFAULT_QUALITY;
- lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
- mir_tstrcpy(lf.lfFaceName, Def_font_face);
+ g_lf.lfHeight = 16;
+ g_lf.lfWidth = 0;
+ g_lf.lfEscapement = 0;
+ g_lf.lfOrientation = 0;
+ g_lf.lfWeight = FW_NORMAL;
+ g_lf.lfItalic = FALSE;
+ g_lf.lfUnderline = FALSE;
+ g_lf.lfStrikeOut = 0;
+ g_lf.lfCharSet = ANSI_CHARSET;
+ g_lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
+ g_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ g_lf.lfQuality = DEFAULT_QUALITY;
+ g_lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
+ mir_tstrcpy(g_lf.lfFaceName, Def_font_face);
}
/*****************************************************************************/
@@ -348,10 +348,10 @@ int ModulesLoaded(WPARAM, LPARAM) HookEvent(ME_OSD_ALERT, OSDAlert);
FontSettings();
- h_font = CreateFontIndirect(&lf);
+ h_font = CreateFontIndirect(&g_lf);
// get data on startup
- if ( db_get_b(NULL, MODULENAME, UPDATE_ONSTART_KEY, 0))
+ if (db_get_b(NULL, MODULENAME, UPDATE_ONSTART_KEY, 0))
mir_forkthread(StartUpdate, NULL);
return 0;
@@ -368,9 +368,9 @@ INT_PTR DataWndMenuCommand(WPARAM wParam, LPARAM) }
HWND hTopmost = db_get_b(hContact, MODULENAME, ON_TOP_KEY, 0) ? HWND_TOPMOST : HWND_NOTOPMOST;
- hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM) hContact);
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
- if ( db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0))
+ hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM)hContact);
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ if (db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0))
SetWindowPos(hwndDlg, hTopmost,
db_get_dw(hContact, MODULENAME, "WVx", 100), // Xposition,
db_get_dw(hContact, MODULENAME, "WVy", 100), // Yposition,
@@ -382,12 +382,12 @@ INT_PTR DataWndMenuCommand(WPARAM wParam, LPARAM) ShowWindow(hwndDlg, SW_SHOW);
SetActiveWindow(hwndDlg);
- if ( db_get_b(NULL, MODULENAME, UPDATE_ON_OPEN_KEY, 0)) {
- if ( db_get_b(hContact, MODULENAME, ENABLE_ALERTS_KEY, 0))
+ if (db_get_b(NULL, MODULENAME, UPDATE_ON_OPEN_KEY, 0)) {
+ if (db_get_b(hContact, MODULENAME, ENABLE_ALERTS_KEY, 0))
mir_forkthread(ReadFromFile, (void*)hContact);
else
mir_forkthread(GetData, (void*)hContact);
- db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
}
return 0;
@@ -426,14 +426,12 @@ int OnTopMenuCommand(WPARAM, LPARAM, MCONTACT singlecontact) int ontop = 0;
int done = 0;
- if (((db_get_b(singlecontact, MODULENAME, ON_TOP_KEY, 0))) && done == 0)
- {
+ if (((db_get_b(singlecontact, MODULENAME, ON_TOP_KEY, 0))) && done == 0) {
db_set_b(singlecontact, MODULENAME, ON_TOP_KEY, 0);
ontop = 0;
done = 1;
}
- if ((!(db_get_b(singlecontact, MODULENAME, ON_TOP_KEY, 0))) && done == 0)
- {
+ if ((!(db_get_b(singlecontact, MODULENAME, ON_TOP_KEY, 0))) && done == 0) {
db_set_b(singlecontact, MODULENAME, ON_TOP_KEY, 1);
ontop = 1;
done = 1;
@@ -449,7 +447,7 @@ INT_PTR WebsiteMenuCommand(WPARAM wParam, LPARAM) if (url)
Utils_OpenUrlT(url);
- db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
return 0;
}
@@ -476,7 +474,7 @@ INT_PTR CntOptionsMenuCommand(WPARAM wParam, LPARAM) return 0;
}
- hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONTACT_OPT), NULL, DlgProcContactOpt, (LPARAM) wParam);
+ hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONTACT_OPT), NULL, DlgProcContactOpt, (LPARAM)wParam);
ShowWindow(hwndDlg, SW_SHOW);
SetActiveWindow(hwndDlg);
return 0;
@@ -485,13 +483,13 @@ INT_PTR CntOptionsMenuCommand(WPARAM wParam, LPARAM) /*****************************************************************************/
INT_PTR CntAlertMenuCommand(WPARAM wParam, LPARAM)
{
- HWND hwndDlg = WindowList_Find(hWindowList, (MCONTACT) wParam);
+ HWND hwndDlg = WindowList_Find(hWindowList, (MCONTACT)wParam);
if (hwndDlg) {
DestroyWindow(hwndDlg);
return 0;
}
- hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ALRT_OPT), NULL, DlgProcAlertOpt, (LPARAM) wParam);
+ hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ALRT_OPT), NULL, DlgProcAlertOpt, (LPARAM)wParam);
ShowWindow(hwndDlg, SW_SHOW);
SetActiveWindow(hwndDlg);
return 0;
diff --git a/plugins/WebView/src/webview.h b/plugins/WebView/src/webview.h index 1767911e88..c09e9f88b8 100644 --- a/plugins/WebView/src/webview.h +++ b/plugins/WebView/src/webview.h @@ -138,7 +138,7 @@ void ReadFromFile(void *hContact); extern int Xposition, Yposition, WindowHeight, WindowWidth;
extern COLORREF BackgoundClr, TextClr;
extern UINT_PTR timerId, Countdown;
-extern LOGFONT lf;
+extern LOGFONT g_lf;
extern HFONT h_font;
extern HWND ContactHwnd;
extern HINSTANCE hInst;
diff --git a/plugins/WebView/src/webview_getdata.cpp b/plugins/WebView/src/webview_getdata.cpp index 9e38568dfa..ab59060515 100644 --- a/plugins/WebView/src/webview_getdata.cpp +++ b/plugins/WebView/src/webview_getdata.cpp @@ -29,7 +29,7 @@ int AlreadyDownloading = 0; /*******************/
void GetData(void *param)
{
- MCONTACT hContact = (MCONTACT)param;
+ MCONTACT hContact = (DWORD_PTR)param;
int statpos = 0, dispos = 0, statposend = 0;
char*pos;
DBVARIANT dbv;
@@ -140,7 +140,6 @@ void GetData(void *param) db_set_w(hContact, MODULENAME, "Status", ID_STATUS_AWAY);
TCHAR *statusText = TranslateT("The server replied with a failure code");
- HWND hwndDlg = WindowList_Find(hWindowList, hContact);
SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText);
WErrorPopup(hContact, statusText);
db_set_ts(hContact, "CList", "StatusMsg", statusText);
@@ -155,7 +154,6 @@ void GetData(void *param) if (!nlhrReply) {
db_set_w(hContact, MODULENAME, "Status", ID_STATUS_NA);
- HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
TCHAR *statusText = TranslateT("The server is down or lagging.");
SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText);
@@ -173,11 +171,8 @@ void GetData(void *param) CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) nlhrReply);
- if (DownloadSuccess) {
- HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
+ if (DownloadSuccess)
SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Download successful; about to process data..."));
- }
- ///get data in desired range
// download successful
if (DownloadSuccess) {
@@ -239,7 +234,6 @@ void GetData(void *param) else if (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 0) {
TCHAR *szStatusText = TranslateT("Invalid search parameters.");
WErrorPopup(hContact, szStatusText);
- HWND hwndDlg = WindowList_Find(hWindowList, hContact);
DownloadSuccess = 0;
SetDlgItemText(hwndDlg, IDC_STATUSBAR, szStatusText);
@@ -256,7 +250,6 @@ void GetData(void *param) WErrorPopup(hContact, statusText);
db_set_ts(hContact, "CList", "StatusMsg", statusText);
- HWND hwndDlg = WindowList_Find(hWindowList, hContact);
DownloadSuccess = 0;
SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText);
TherewasAlert = ProcessAlerts(hContact, _T2A(statusText), contactname, contactname, 1);
@@ -358,8 +351,6 @@ void GetData(void *param) RemoveTabs(truncated);
if ( db_get_b(hContact, MODULENAME, CLEAR_DISPLAY_KEY, 0)) {
- HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
-
SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 1)"));
@@ -478,7 +469,6 @@ LBL_Stop: TCHAR *statusText = TranslateT("Processing data stopped by user."); if (DownloadSuccess) { // download success
char BytesString[128];
- HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
// update window if the update only on alert option isn't ticked or
// there was an alert or the update button was clicked
diff --git a/plugins/WebView/src/webview_opts.cpp b/plugins/WebView/src/webview_opts.cpp index bc5bab421e..b4b45bd99e 100644 --- a/plugins/WebView/src/webview_opts.cpp +++ b/plugins/WebView/src/webview_opts.cpp @@ -31,19 +31,19 @@ const TCHAR *szTrackerBarDescr[] = { LPGENT("Remove all whitespace")
};
-static char *fontSizes[] = {"8", "10", "14", "16", "18", "20", "24", "28"};
+static char *fontSizes[] = { "8", "10", "14", "16", "18", "20", "24", "28" };
static TCHAR *AlertTypes[] = { LPGENT("Popup plugin"), LPGENT("Log to file"), LPGENT("Open data display window"), LPGENT("Use OSD plugin") };
static TCHAR *EventTypes[] = { LPGENT("A string is present"), LPGENT("The web page changes"), LPGENT("A specific part of web page changes") };
#define M_FILLSCRIPTCOMBO (WM_USER+16)
-void strdel(TCHAR *parBuffer, int len )
+void strdel(TCHAR *parBuffer, int len)
{
TCHAR* p;
- for (p = parBuffer+len; *p != 0; p++)
- p[ -len ] = *p;
+ for (p = parBuffer + len; *p != 0; p++)
+ p[-len] = *p;
- p[ -len ] = '\0';
+ p[-len] = '\0';
}
TCHAR* FixButtonText(TCHAR *url, size_t len)
@@ -52,9 +52,9 @@ TCHAR* FixButtonText(TCHAR *url, size_t len) _tcsncpy_s(buttontext, url, _TRUNCATE);
_tcsncpy_s(newbuttontext, url, _TRUNCATE);
- if ( _tcschr(newbuttontext, '&') != 0) {
+ if (_tcschr(newbuttontext, '&') != 0) {
while (true) {
- if ( _tcschr(newbuttontext, '&') == 0)
+ if (_tcschr(newbuttontext, '&') == 0)
break;
_tcsncpy_s(buttontext, newbuttontext, _TRUNCATE);
@@ -71,12 +71,12 @@ TCHAR* FixButtonText(TCHAR *url, size_t len) }
while (true) {
- if ( _tcschr(newbuttontext, '!') != 0) {
+ if (_tcschr(newbuttontext, '!') != 0) {
TCHAR *stringafter = _tcschr(newbuttontext, '!');
int pos = (stringafter - newbuttontext);
newbuttontext[pos] = '&';
}
- if ( _tcschr(newbuttontext, '!') == 0)
+ if (_tcschr(newbuttontext, '!') == 0)
break;
}
}
@@ -88,11 +88,10 @@ TCHAR* FixButtonText(TCHAR *url, size_t len) /*****************************************************************************/
static int CALLBACK EnumFontScriptsProc(ENUMLOGFONTEX * lpelfe, NEWTEXTMETRICEX*, int, LPARAM lParam)
{
- if (SendMessage((HWND) lParam, CB_FINDSTRINGEXACT, -1, (LPARAM) lpelfe->elfScript) == CB_ERR)
- {
- int i = SendMessage((HWND) lParam, CB_ADDSTRING, 0, (LPARAM) lpelfe->elfScript);
+ if (SendMessage((HWND)lParam, CB_FINDSTRINGEXACT, -1, (LPARAM)lpelfe->elfScript) == CB_ERR) {
+ int i = SendMessage((HWND)lParam, CB_ADDSTRING, 0, (LPARAM)lpelfe->elfScript);
- SendMessage((HWND) lParam, CB_SETITEMDATA, i, lpelfe->elfLogFont.lfCharSet);
+ SendMessage((HWND)lParam, CB_SETITEMDATA, i, lpelfe->elfLogFont.lfCharSet);
}
return TRUE;
}
@@ -147,7 +146,7 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) case WM_COMMAND:
// enable the "apply" button
- if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND) lParam)
+ if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND)lParam)
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
// These are simple clicks: we don't save, but we tell the Options Page
// to enable the "Apply" button.
@@ -190,8 +189,7 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) case IDC_DELAY:
if (HIWORD(wParam) == EN_CHANGE)
test++;
- if (test > 1)
- {
+ if (test > 1) {
//CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
}
@@ -231,7 +229,7 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) break;
case WM_NOTIFY: // Here we have pressed either the OK or the APPLY button.
- switch (((LPNMHDR) lParam)->code) {
+ switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
{
int popupdelayval = 0;
@@ -286,12 +284,11 @@ INT_PTR CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l test = 0;
TranslateDialogDefault(hwndDlg);
hContact = lParam;
-
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) hContact);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
SetWindowText(hwndDlg, TranslateT("Alert options"));
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_ALERT)));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_ALERT)));
EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 0);
@@ -437,7 +434,7 @@ INT_PTR CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l else
CheckRadioButton(hwndDlg, IDC_PREFIX, IDC_SUFFIX, IDC_SUFFIX);
- if ( db_get_b(hContact, MODULENAME, ALWAYS_LOG_KEY, 0)) {
+ if (db_get_b(hContact, MODULENAME, ALWAYS_LOG_KEY, 0)) {
if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1);
EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1);
@@ -512,7 +509,7 @@ INT_PTR CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_DATE_NAME), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)));
- if ( IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME)) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)));
EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)));
EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)));
@@ -631,8 +628,8 @@ INT_PTR CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDC_ALERT_TYPE:
if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE) {
- hContact = (MCONTACT) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- int alertIndex = SendDlgItemMessage(hwndDlg, IDC_ALERT_TYPE, CB_GETCURSEL, 0, 0);
+ hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ alertIndex = SendDlgItemMessage(hwndDlg, IDC_ALERT_TYPE, CB_GETCURSEL, 0, 0);
if (HIWORD(wParam) == CBN_SELCHANGE) {
db_set_b(hContact, MODULENAME, ALRT_INDEX_KEY, alertIndex);
@@ -678,8 +675,8 @@ INT_PTR CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDC_EVENT_TYPE:
if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE) {
- MCONTACT hContact = (MCONTACT) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- int eventIndex = SendDlgItemMessage(hwndDlg, IDC_EVENT_TYPE, CB_GETCURSEL, 0, 0);
+ hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ eventIndex = SendDlgItemMessage(hwndDlg, IDC_EVENT_TYPE, CB_GETCURSEL, 0, 0);
if (HIWORD(wParam) == CBN_SELCHANGE) {
db_set_b(hContact, MODULENAME, EVNT_INDEX_KEY, eventIndex);
@@ -709,7 +706,7 @@ INT_PTR CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l case IDC_ALERT_APPLY:
case IDC_OK2:
{
- hContact = (MCONTACT) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
TCHAR buf[MAX_PATH];
eventIndex = db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0);
@@ -821,17 +818,17 @@ INT_PTR CALLBACK DlgProcContactOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- hContact = (MCONTACT) lParam;
+ hContact = (MCONTACT)lParam;
test = 0;
test2 = 0;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) hContact);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hContact);
WindowList_Add(hWindowList, hwndDlg, hContact);
SetWindowText(hwndDlg, TranslateT("Contact options"));
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_OPTIONS)));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(IDI_OPTIONS)));
EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 0);
@@ -927,7 +924,7 @@ INT_PTR CALLBACK DlgProcContactOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case IDC_CPY_STRINGS:
{
TCHAR string[128];
- hContact = (MCONTACT) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
GetDlgItemText(hwndDlg, IDC_START, string, _countof(string));
db_set_ts(hContact, MODULENAME, ALRT_S_STRING_KEY, string);
@@ -1022,7 +1019,7 @@ INT_PTR CALLBACK DlgProcContactOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM break;
}
- hContact = (MCONTACT) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
GetDlgItemText(hwndDlg, IDC_URL, url, _countof(url));
db_set_ts(hContact, MODULENAME, URL_KEY, url);
@@ -1139,7 +1136,7 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara */
oldcolor = BackgoundClr;
- if ( db_get_b(NULL, MODULENAME, SUPPRESS_ERR_KEY, 0)) {
+ if (db_get_b(NULL, MODULENAME, SUPPRESS_ERR_KEY, 0)) {
CheckDlgButton(hwndDlg, IDC_SUPPRESS, BST_CHECKED);
EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), 0);
}
@@ -1152,7 +1149,7 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara if (ServiceExists(MS_POPUP_ADDPOPUPT) == 0)
EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), 0);
- if ( db_get_b(NULL, MODULENAME, UPDATE_ONSTART_KEY, 0)) {
+ if (db_get_b(NULL, MODULENAME, UPDATE_ONSTART_KEY, 0)) {
EnableWindow(GetDlgItem(hwndDlg, IDC_START_DELAY), 1);
EnableWindow(GetDlgItem(hwndDlg, IDC_SPIN2), 1);
EnableWindow(GetDlgItem(hwndDlg, IDC_STARTDELAYTXT), 1);
@@ -1171,7 +1168,7 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara // selection to the value for fontid wParam
{
- LOGFONT lf = {0};
+ LOGFONT lf = { 0 };
int i;
HDC hdc = GetDC(hwndDlg);
@@ -1179,12 +1176,10 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara GetDlgItemText(hwndDlg, IDC_TYPEFACE, lf.lfFaceName, _countof(lf.lfFaceName));
lf.lfPitchAndFamily = 0;
SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_RESETCONTENT, 0, 0);
- EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC) EnumFontScriptsProc, (LPARAM) GetDlgItem(hwndDlg, IDC_SCRIPT), 0);
+ EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontScriptsProc, (LPARAM)GetDlgItem(hwndDlg, IDC_SCRIPT), 0);
ReleaseDC(hwndDlg, hdc);
- for (i = SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETCOUNT, 0, 0) - 1; i >= 0; i--)
- {
- if (SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETITEMDATA, i, 0) == (BYTE)((db_get_b(NULL, MODULENAME, FONT_SCRIPT_KEY, 0))))
- {
+ for (i = SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETCOUNT, 0, 0) - 1; i >= 0; i--) {
+ if (SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETITEMDATA, i, 0) == (BYTE)((db_get_b(NULL, MODULENAME, FONT_SCRIPT_KEY, 0)))) {
SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_SETCURSEL, i, 0);
break;
}
@@ -1195,7 +1190,7 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara break;
case WM_COMMAND:
- if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND) lParam)
+ if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND)lParam)
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
switch (LOWORD(wParam)) {
@@ -1266,7 +1261,7 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara break;
case WM_NOTIFY:
- switch (((LPNMHDR) lParam)->code) {
+ switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
db_set_b(NULL, MODULENAME, MENU_OFF, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DISABLEMENU));
db_set_b(NULL, MODULENAME, SUPPRESS_ERR_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SUPPRESS));
@@ -1301,15 +1296,13 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara BackgoundClr = (SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0));
TextClr = (SendDlgItemMessage(hwndDlg, IDC_TXTCOLOR, CPM_GETCOLOUR, 0, 0));
- if ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, 0) != 0))
- {
+ if ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, 0) != 0)) {
KillTimer(NULL, timerId);
KillTimer(NULL, Countdown);
timerId = SetTimer(NULL, 0, ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, 0)) * MINUTE), timerfunc);
Countdown = SetTimer(NULL, 0, MINUTE, Countdownfunc);
}
- if ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, 0) == 0))
- {
+ if ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, 0) == 0)) {
KillTimer(NULL, timerId);
KillTimer(NULL, Countdown);
}
diff --git a/plugins/WhenWasIt/src/dlg_handlers.cpp b/plugins/WhenWasIt/src/dlg_handlers.cpp index 1083287cc2..932ba2a47f 100644 --- a/plugins/WhenWasIt/src/dlg_handlers.cpp +++ b/plugins/WhenWasIt/src/dlg_handlers.cpp @@ -398,18 +398,16 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l case WM_INITDIALOG:
TranslateDialogDefault(hWnd);
SetWindowLongPtr(hWnd, GWLP_USERDATA, lParam);
- {
- MCONTACT hContact = lParam;
- WindowList_Add(hAddBirthdayWndsList, hWnd, hContact);
- Utils_RestoreWindowPositionNoSize(hWnd, hContact, ModuleName, "BirthdayWnd");
- }
+
+ hContact = lParam;
+ WindowList_Add(hAddBirthdayWndsList, hWnd, hContact);
+ Utils_RestoreWindowPositionNoSize(hWnd, hContact, ModuleName, "BirthdayWnd");
+
SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIconByHandle(hAddBirthdayContact, 1));
- {
- for (int i = 0; i < cSaveModule; i++)
- SendDlgItemMessage(hWnd, IDC_COMPATIBILITY, CB_ADDSTRING, 0, (LPARAM)TranslateTS(szSaveModule[i]));
- SendDlgItemMessage(hWnd, IDC_COMPATIBILITY, CB_SETCURSEL, commonData.cDefaultModule, 0);
- }
+ for (int i = 0; i < cSaveModule; i++)
+ SendDlgItemMessage(hWnd, IDC_COMPATIBILITY, CB_ADDSTRING, 0, (LPARAM)TranslateTS(szSaveModule[i]));
+ SendDlgItemMessage(hWnd, IDC_COMPATIBILITY, CB_SETCURSEL, commonData.cDefaultModule, 0);
break;
case WM_SHOWWINDOW:
@@ -487,9 +485,9 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
- SYSTEMTIME st;
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hWnd, GWLP_USERDATA);
+ hContact = (MCONTACT)GetWindowLongPtr(hWnd, GWLP_USERDATA);
HWND hDate = GetDlgItem(hWnd, IDC_DATE);
+ SYSTEMTIME st;
if (DateTime_GetSystemtime(hDate, &st) == GDT_VALID) {
int mode = SendDlgItemMessage(hWnd, IDC_COMPATIBILITY, CB_GETCURSEL, 0, 0); //SAVE modes in date_utils.h are synced
SaveBirthday(hContact, st.wYear, st.wMonth, st.wDay, mode);
@@ -580,6 +578,7 @@ int UpdateBirthdayEntry(HWND hList, MCONTACT hContact, int entry, int bShowAll, currentDay = today->tm_mday + 1;
currentMonth = today->tm_mon + 1;
}
+ else currentMonth = currentDay = 0;
int year, month, day;
int module = GetContactDOB(hContact, year, month, day);
diff --git a/plugins/WhoUsesMyFiles/src/wumfplug.cpp b/plugins/WhoUsesMyFiles/src/wumfplug.cpp index d5f2df0051..f2fb9c2ad7 100644 --- a/plugins/WhoUsesMyFiles/src/wumfplug.cpp +++ b/plugins/WhoUsesMyFiles/src/wumfplug.cpp @@ -250,14 +250,14 @@ void DisableDelayOptions(HWND hwndDlg) EnableWindow(GetDlgItem(hwndDlg, IDC_TX_DELAY_SEC), FALSE);
}
-void ChooseFile(HWND hDlg)
+void ChooseFile(HWND hwndDlg)
{
TCHAR szFile[MAX_PATH]; szFile[0]=0;
// Initialize OPENFILENAME
OPENFILENAME ofn = {0}; // common dialog box structure
ofn.lStructSize = sizeof(OPENFILENAME);
- ofn.hwndOwner = hDlg;
+ ofn.hwndOwner = hwndDlg;
ofn.lpstrFile = szFile;
ofn.nMaxFile = _countof(szFile);
ofn.lpstrFilter = _T("All files (*.*)\0*.*\0Text files (*.txt)\0*.txt\0Log files (*.log)\0*.log\0\0");
@@ -267,7 +267,7 @@ void ChooseFile(HWND hDlg) if (GetSaveFileName(&ofn)) {
HANDLE hf = CreateFile(szFile,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL);
if (hf != INVALID_HANDLE_VALUE) {
- SetDlgItemText(hDlg,IDC_FILE,szFile);
+ SetDlgItemText(hwndDlg,IDC_FILE,szFile);
mir_tstrncpy(WumfOptions.LogFile, szFile, MAX_PATH);
CloseHandle(hf);
}
@@ -275,7 +275,7 @@ void ChooseFile(HWND hDlg) else if (CommDlgExtendedError() != 0) {
TCHAR str[256];
mir_sntprintf(str, _countof(str), TranslateT("Common Dialog Error 0x%lx"), CommDlgExtendedError());
- MessageBox(hDlg, str, TranslateT("Error"), MB_OK | MB_ICONSTOP);
+ MessageBox(hwndDlg, str, TranslateT("Error"), MB_OK | MB_ICONSTOP);
}
}
diff --git a/plugins/WinterSpeak/src/DialogConfigActive.cpp b/plugins/WinterSpeak/src/DialogConfigActive.cpp index 894865c17a..f6061d0258 100644 --- a/plugins/WinterSpeak/src/DialogConfigActive.cpp +++ b/plugins/WinterSpeak/src/DialogConfigActive.cpp @@ -21,59 +21,57 @@ DialogConfigActive::~DialogConfigActive() //------------------------------------------------------------------------------
INT_PTR CALLBACK DialogConfigActive::process(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
- if (!m_instance)
- {
+ if (!m_instance) {
return 1;
}
- switch (message)
- {
- case WM_INITDIALOG:
- m_instance->load(window);
+ switch (message) {
+ case WM_INITDIALOG:
+ m_instance->load(window);
break;
- case WM_NOTIFY:
- switch(((LPNMHDR)lparam)->idFrom) {
- case IDC_ACTIVE_USERS: {
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lparam)->idFrom) {
+ case IDC_ACTIVE_USERS:
+ {
m_instance->notify(window, lparam);
-
+
} break;
- case 0: {
- switch (reinterpret_cast<LPNMHDR>(lparam)->code)
- {
- case PSN_APPLY:
+ case 0:
+ {
+ switch (reinterpret_cast<LPNMHDR>(lparam)->code) {
+ case PSN_APPLY:
m_instance->save(window);
break;
- case LVN_ITEMCHANGED:
+ case LVN_ITEMCHANGED:
m_instance->changed(window);
break;
} break;
} break;
} break;
- case WM_COMMAND:
- switch (LOWORD(wparam))
- {
- case IDC_ACTIVE_OFFLINE:
- case IDC_ACTIVE_ONLINE:
- case IDC_ACTIVE_AWAY:
- case IDC_ACTIVE_DND:
- case IDC_ACTIVE_NA:
- case IDC_ACTIVE_OCCUPIED:
- case IDC_ACTIVE_FREEFORCHAT:
- case IDC_ACTIVE_INVISIBLE:
+ case WM_COMMAND:
+ switch (LOWORD(wparam)) {
+ case IDC_ACTIVE_OFFLINE:
+ case IDC_ACTIVE_ONLINE:
+ case IDC_ACTIVE_AWAY:
+ case IDC_ACTIVE_DND:
+ case IDC_ACTIVE_NA:
+ case IDC_ACTIVE_OCCUPIED:
+ case IDC_ACTIVE_FREEFORCHAT:
+ case IDC_ACTIVE_INVISIBLE:
m_instance->changed(window);
break;
- /*case IDC_ACTIVE_ALL:
- m_instance->selectAllUsers(window, true);
- break;*/
+ /*case IDC_ACTIVE_ALL:
+ m_instance->selectAllUsers(window, true);
+ break;*/
- /*case IDC_ACTIVE_NONE:
- m_instance->selectAllUsers(window, false);
- break;*/
+ /*case IDC_ACTIVE_NONE:
+ m_instance->selectAllUsers(window, false);
+ break;*/
- case IDC_ACTIVE_USERS:
+ case IDC_ACTIVE_USERS:
m_instance->changed(window);
break;
}
@@ -92,52 +90,53 @@ INT_PTR CALLBACK DialogConfigActive::process(HWND window, UINT message, WPARAM w //------------------------------------------------------------------------------
// private:
//------------------------------------------------------------------------------
-void DialogConfigActive::notify(HWND hwndDlg, LPARAM lParam) {
+void DialogConfigActive::notify(HWND hwndDlg, LPARAM lParam)
+{
switch (((LPNMHDR)lParam)->code) {
- case CLN_NEWCONTACT:
- case CLN_LISTREBUILT:
- SetAllContactIcons( GetDlgItem(hwndDlg, IDC_ACTIVE_USERS));
- //fall through
- case CLN_CONTACTMOVED:
- SetListGroupIcons( GetDlgItem(hwndDlg, IDC_ACTIVE_USERS), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_ACTIVE_USERS, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL);
- break;
- case CLN_OPTIONSCHANGED:
- ResetListOptions( GetDlgItem(hwndDlg, IDC_ACTIVE_USERS));
- break;
- case CLN_CHECKCHANGED:
- m_instance->changed(hwndDlg);
- break;
- case NM_CLICK:
- {
- NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
- if (nm->iColumn == -1)
- break;
-
- DWORD hitFlags;
- HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_ACTIVE_USERS, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y));
- if (hItem == NULL || !(hitFlags & CLCHT_ONITEMEXTRA))
- break;
-
- if (nm->iColumn == 2) { // ignore all
- for (int iImage = 0;iImage<2;iImage++)
- SetIconsForColumn( GetDlgItem(hwndDlg, IDC_ACTIVE_USERS), hItem, hItemAll, iImage, iImage+3);
- }
- else if (nm->iColumn == 3) { // ignore none
- for (int iImage = 0;iImage<2;iImage++)
- SetIconsForColumn( GetDlgItem(hwndDlg, IDC_ACTIVE_USERS), hItem, hItemAll, iImage, 0);
- }
- else {
- int iImage = SendDlgItemMessage(hwndDlg, IDC_ACTIVE_USERS, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0));
- if (iImage == 0)
- iImage = nm->iColumn+3;
- else if (iImage != EMPTY_EXTRA_ICON)
- iImage = 0;
- SetIconsForColumn( GetDlgItem(hwndDlg, IDC_ACTIVE_USERS), hItem, hItemAll, nm->iColumn, iImage);
- }
- SetListGroupIcons( GetDlgItem(hwndDlg, IDC_ACTIVE_USERS), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_ACTIVE_USERS, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL);
- m_instance->changed(hwndDlg);
+ case CLN_NEWCONTACT:
+ case CLN_LISTREBUILT:
+ SetAllContactIcons(GetDlgItem(hwndDlg, IDC_ACTIVE_USERS));
+ //fall through
+ case CLN_CONTACTMOVED:
+ SetListGroupIcons(GetDlgItem(hwndDlg, IDC_ACTIVE_USERS), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_ACTIVE_USERS, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL);
+ break;
+ case CLN_OPTIONSCHANGED:
+ ResetListOptions(GetDlgItem(hwndDlg, IDC_ACTIVE_USERS));
+ break;
+ case CLN_CHECKCHANGED:
+ m_instance->changed(hwndDlg);
+ break;
+ case NM_CLICK:
+ {
+ NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
+ if (nm->iColumn == -1)
+ break;
+
+ DWORD hitFlags;
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_ACTIVE_USERS, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y));
+ if (hItem == NULL || !(hitFlags & CLCHT_ONITEMEXTRA))
+ break;
+
+ if (nm->iColumn == 2) { // ignore all
+ for (int iImage = 0; iImage < 2; iImage++)
+ SetIconsForColumn(GetDlgItem(hwndDlg, IDC_ACTIVE_USERS), hItem, hItemAll, iImage, iImage + 3);
}
- break;
+ else if (nm->iColumn == 3) { // ignore none
+ for (int iImage = 0; iImage < 2; iImage++)
+ SetIconsForColumn(GetDlgItem(hwndDlg, IDC_ACTIVE_USERS), hItem, hItemAll, iImage, 0);
+ }
+ else {
+ int iImage = SendDlgItemMessage(hwndDlg, IDC_ACTIVE_USERS, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0));
+ if (iImage == 0)
+ iImage = nm->iColumn + 3;
+ else if (iImage != EMPTY_EXTRA_ICON)
+ iImage = 0;
+ SetIconsForColumn(GetDlgItem(hwndDlg, IDC_ACTIVE_USERS), hItem, hItemAll, nm->iColumn, iImage);
+ }
+ SetListGroupIcons(GetDlgItem(hwndDlg, IDC_ACTIVE_USERS), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_ACTIVE_USERS, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL);
+ m_instance->changed(hwndDlg);
+ }
+ break;
}
}
@@ -164,8 +163,8 @@ void DialogConfigActive::load(HWND window) ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_USERONLINE);
SendDlgItemMessage(window, IDC_ACTIVE_USERS, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml);
- for (int i=0; i < _countof(hIcons); i++)
- hIcons[i] = ImageList_GetIcon(hIml, 1+i, ILD_NORMAL);
+ for (int i = 0; i < _countof(hIcons); i++)
+ hIcons[i] = ImageList_GetIcon(hIml, 1 + i, ILD_NORMAL);
SendDlgItemMessage(window, IDC_ALLICON, STM_SETICON, (WPARAM)hIcons[0], 0);
SendDlgItemMessage(window, IDC_NONEICON, STM_SETICON, (WPARAM)hIcons[1], 0);
@@ -176,12 +175,12 @@ void DialogConfigActive::load(HWND window) SendDlgItemMessage(window, IDC_ACTIVE_USERS, CLM_SETEXTRACOLUMNS, 4, 0);
{
- CLCINFOITEM cii = {0};
+ CLCINFOITEM cii = { 0 };
cii.cbSize = sizeof(cii);
cii.flags = CLCIIF_GROUPFONT;
cii.pszText = TranslateT("** All contacts **");
hItemAll = (HANDLE)SendDlgItemMessage(window, IDC_ACTIVE_USERS, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
-
+
cii.pszText = TranslateT("** Unknown contacts **");
hItemUnknown = (HANDLE)SendDlgItemMessage(window, IDC_ACTIVE_USERS, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
ConfigDatabase::ActiveUsersMap active_users = m_db.getActiveUsers();
@@ -217,8 +216,9 @@ void DialogConfigActive::SetAllChildIcons(HWND hwndList, HANDLE hFirstItem, int }
}
-void DialogConfigActive::SetIconsForColumn(HWND hwndList, HANDLE hItem, HANDLE hItemAll, int iColumn, int iImage) {
- switch ( SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hItem, 0)) {
+void DialogConfigActive::SetIconsForColumn(HWND hwndList, HANDLE hItem, HANDLE hItem2, int iColumn, int iImage)
+{
+ switch (SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hItem, 0)) {
case CLCIT_CONTACT:
{
int oldiImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn);
@@ -227,7 +227,7 @@ void DialogConfigActive::SetIconsForColumn(HWND hwndList, HANDLE hItem, HANDLE h }
break;
case CLCIT_INFO:
- if (hItem == hItemAll)
+ if (hItem == hItem2)
SetAllChildIcons(hwndList, hItem, iColumn, iImage);
else
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage)); //hItemUnknown
@@ -240,24 +240,26 @@ void DialogConfigActive::SetIconsForColumn(HWND hwndList, HANDLE hItem, HANDLE h }
}
-void DialogConfigActive::InitialiseItem(HWND hwndList, HANDLE hItem, bool message, bool status) {
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, (message)?0:3)); //Message
-
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1, (status)?0:4)); //Online
+void DialogConfigActive::InitialiseItem(HWND hwndList, HANDLE hItem, bool message, bool status)
+{
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, (message) ? 0 : 3)); //Message
+
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1, (status) ? 0 : 4)); //Online
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(2, 1));
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(3, 2));
}
-void DialogConfigActive::SetAllContactIcons(HWND hwndList) {
+void DialogConfigActive::SetAllContactIcons(HWND hwndList)
+{
ConfigDatabase::ActiveUsersMap active_users = m_db.getActiveUsers();
ConfigDatabase::ActiveUsersMap::const_iterator iter;
- for (iter = active_users.begin(); iter != active_users.end(); ++iter)
- {
+ for (iter = active_users.begin(); iter != active_users.end(); ++iter) {
MCONTACT hContact = iter->first;
- if(hContact == 0) {
-
- } else {
+ if (hContact == 0) {
+
+ }
+ else {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
if (hItem && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1, 0)) == EMPTY_EXTRA_ICON) {
this->InitialiseItem(hwndList, hItem, iter->second.message, iter->second.status);
@@ -266,14 +268,16 @@ void DialogConfigActive::SetAllContactIcons(HWND hwndList) { }
}
-void DialogConfigActive::ResetListOptions(HWND listview) {
+void DialogConfigActive::ResetListOptions(HWND listview)
+{
SendMessage(listview, CLM_SETHIDEEMPTYGROUPS, 1, 0);
SetWindowLongPtr(listview, GWL_STYLE, GetWindowLongPtr(listview, GWL_STYLE) | CLS_SHOWHIDDEN);
}
-void DialogConfigActive::SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentItem, int *groupChildCount) {
- int iconOn[2] = {1, 1};
- int childCount[2] = {0, 0}, i;
+void DialogConfigActive::SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentItem, int *groupChildCount)
+{
+ int iconOn[2] = { 1, 1 };
+ int childCount[2] = { 0, 0 }, i;
int iImage;
HANDLE hItem, hChildItem;
@@ -284,7 +288,7 @@ void DialogConfigActive::SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HAN while (hItem) {
hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if (hChildItem) SetListGroupIcons(hwndList, hChildItem, hItem, childCount);
- for (i=0; i < _countof(iconOn); i++)
+ for (i = 0; i < _countof(iconOn); i++)
if (iconOn[i] && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i) == 0) iconOn[i] = 0;
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem);
}
@@ -292,7 +296,7 @@ void DialogConfigActive::SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HAN if (typeOfFirst == CLCIT_CONTACT) hItem = hFirstItem;
else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
while (hItem) {
- for (i=0; i < _countof(iconOn); i++) {
+ for (i = 0; i < _countof(iconOn); i++) {
iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i);
if (iconOn[i] && iImage == 0) iconOn[i] = 0;
if (iImage != EMPTY_EXTRA_ICON)
@@ -301,9 +305,9 @@ void DialogConfigActive::SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HAN hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
//set icons
- for (i=0; i < _countof(iconOn); i++) {
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, childCount[i]?(iconOn[i]?i+3:0) : EMPTY_EXTRA_ICON));
- if (groupChildCount) groupChildCount[i]+=childCount[i];
+ for (i = 0; i < _countof(iconOn); i++) {
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, childCount[i] ? (iconOn[i] ? i + 3 : 0) : EMPTY_EXTRA_ICON));
+ if (groupChildCount) groupChildCount[i] += childCount[i];
}
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(2, 1));
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(3, 2));
@@ -313,36 +317,37 @@ void DialogConfigActive::SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HAN void DialogConfigActive::save(HWND window)
{
// store the checkboxes
- m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Online, (IsDlgButtonChecked(window, IDC_ACTIVE_ONLINE) != 0));
- m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Away, (IsDlgButtonChecked(window, IDC_ACTIVE_AWAY) != 0));
- m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Dnd, (IsDlgButtonChecked(window, IDC_ACTIVE_DND) != 0));
- m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Na, (IsDlgButtonChecked(window, IDC_ACTIVE_NA) != 0));
- m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Occupied, (IsDlgButtonChecked(window, IDC_ACTIVE_OCCUPIED) != 0));
- m_db.setActiveFlag(ConfigDatabase::ActiveFlag_FreeForChat, (IsDlgButtonChecked(window, IDC_ACTIVE_FREEFORCHAT) != 0));
- m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Invisible, (IsDlgButtonChecked(window, IDC_ACTIVE_INVISIBLE) != 0));
+ m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Online, (IsDlgButtonChecked(window, IDC_ACTIVE_ONLINE) != 0));
+ m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Away, (IsDlgButtonChecked(window, IDC_ACTIVE_AWAY) != 0));
+ m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Dnd, (IsDlgButtonChecked(window, IDC_ACTIVE_DND) != 0));
+ m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Na, (IsDlgButtonChecked(window, IDC_ACTIVE_NA) != 0));
+ m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Occupied, (IsDlgButtonChecked(window, IDC_ACTIVE_OCCUPIED) != 0));
+ m_db.setActiveFlag(ConfigDatabase::ActiveFlag_FreeForChat, (IsDlgButtonChecked(window, IDC_ACTIVE_FREEFORCHAT) != 0));
+ m_db.setActiveFlag(ConfigDatabase::ActiveFlag_Invisible, (IsDlgButtonChecked(window, IDC_ACTIVE_INVISIBLE) != 0));
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendDlgItemMessage(window, IDC_ACTIVE_USERS, CLM_FINDCONTACT, hContact, 0);
- if (hItem)
+ if (hItem)
SaveItemMask(GetDlgItem(window, IDC_ACTIVE_USERS), hContact, hItem);
}
- SaveItemMask( GetDlgItem(window, IDC_ACTIVE_USERS), NULL, hItemUnknown);
+ SaveItemMask(GetDlgItem(window, IDC_ACTIVE_USERS), NULL, hItemUnknown);
m_db.save();
}
-void DialogConfigActive::SaveItemMask(HWND hwndList, MCONTACT hContact, HANDLE hItem) {
+void DialogConfigActive::SaveItemMask(HWND hwndList, MCONTACT hContact, HANDLE hItem)
+{
ConfigDatabase::act mask;
mask.message = true;
mask.status = true;
- for (int i=0; i < 2; i++) {
+ for (int i = 0; i < 2; i++) {
int iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0));
if (iImage && iImage != EMPTY_EXTRA_ICON) {
- if(i == 1) { //Online
+ if (i == 1) { //Online
mask.status = false;
- }
- if(i == 0) { //message
+ }
+ if (i == 0) { //message
mask.message = false;
}
}
@@ -354,11 +359,8 @@ void DialogConfigActive::SaveItemMask(HWND hwndList, MCONTACT hContact, HANDLE h void DialogConfigActive::selectAllUsers(HWND window, bool state)
{
HWND listview = GetDlgItem(window, IDC_ACTIVE_USERS);
-
for (int i = 0; i < ListView_GetItemCount(listview); ++i)
- {
ListView_SetCheckState(listview, i, state);
- }
changed(window);
}
diff --git a/plugins/XSoundNotify/src/dialog.cpp b/plugins/XSoundNotify/src/dialog.cpp index 142e178c95..6de7c5a28e 100644 --- a/plugins/XSoundNotify/src/dialog.cpp +++ b/plugins/XSoundNotify/src/dialog.cpp @@ -11,74 +11,73 @@ There is no warranty. static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ XSN_Data *p;
+
switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- MCONTACT hContact = lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- WindowList_Add(hChangeSoundDlgList, hwndDlg, hContact);
- Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, SETTINGSNAME, "ChangeSoundDlg");
- char* szProto = GetContactProto(hContact);
- PROTOACCOUNT *pa = Proto_GetAccount(szProto);
- char* szUniqueId = (char*)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
- if ((INT_PTR)szUniqueId != CALLSERVICE_NOTFOUND && szUniqueId != NULL) {
- DBVARIANT dbvuid = { 0 };
- if (!db_get(hContact, pa->szModuleName, szUniqueId, &dbvuid)) {
- TCHAR uid[MAX_PATH];
- switch (dbvuid.type) {
- case DBVT_DWORD:
- _itot(dbvuid.dVal, uid, 10);
- break;
-
- case DBVT_ASCIIZ:
- mir_tstrcpy(uid, _A2T(dbvuid.pszVal));
- break;
-
- case DBVT_UTF8:
- mir_tstrcpy(uid, ptrT(mir_utf8decodeT(dbvuid.pszVal)));
- break;
+ {
+ TranslateDialogDefault(hwndDlg);
+ hContact = lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ WindowList_Add(hChangeSoundDlgList, hwndDlg, hContact);
+ Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, SETTINGSNAME, "ChangeSoundDlg");
+ char* szProto = GetContactProto(hContact);
+ PROTOACCOUNT *pa = Proto_GetAccount(szProto);
+ char* szUniqueId = (char*)CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
+ if ((INT_PTR)szUniqueId != CALLSERVICE_NOTFOUND && szUniqueId != NULL) {
+ DBVARIANT dbvuid = { 0 };
+ if (!db_get(hContact, pa->szModuleName, szUniqueId, &dbvuid)) {
+ TCHAR uid[MAX_PATH];
+ switch (dbvuid.type) {
+ case DBVT_DWORD:
+ _itot(dbvuid.dVal, uid, 10);
+ break;
+
+ case DBVT_ASCIIZ:
+ mir_tstrcpy(uid, _A2T(dbvuid.pszVal));
+ break;
+
+ case DBVT_UTF8:
+ mir_tstrcpy(uid, ptrT(mir_utf8decodeT(dbvuid.pszVal)));
+ break;
+ }
+
+ TCHAR *nick = (TCHAR *)pcli->pfnGetContactDisplayName(hContact, 0);
+ TCHAR value[100];
+ mir_sntprintf(value, _countof(value), TranslateT("Custom sound for %s (%s)"), nick, uid);
+ SetWindowText(hwndDlg, value);
+ db_free(&dbvuid);
}
-
- TCHAR *nick = (TCHAR *)pcli->pfnGetContactDisplayName(hContact, 0);
- TCHAR value[100];
- mir_sntprintf(value, _countof(value), TranslateT("Custom sound for %s (%s)"), nick, uid);
- SetWindowText(hwndDlg, value);
- db_free(&dbvuid);
}
- }
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_CHOOSE_SOUND), TRUE);
- DBVARIANT dbv = { 0 };
- if (!db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), TRUE);
- SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, PathFindFileName(dbv.ptszVal));
- db_free(&dbv);
- }
- else {
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), FALSE);
- SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, TranslateT("Not set"));
- }
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_IGNORE_SOUND), TRUE);
- CheckDlgButton(hwndDlg, IDC_CONT_IGNORE_SOUND, db_get_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, 0) ? BST_CHECKED : BST_UNCHECKED);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
- if (p == NULL) {
- DBVARIANT dbv;
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_CHOOSE_SOUND), TRUE);
+ DBVARIANT dbv = { 0 };
if (!db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
- XSN_Users.insert(new XSN_Data(hContact, dbv.ptszVal, IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), TRUE);
+ SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, PathFindFileName(dbv.ptszVal));
db_free(&dbv);
}
+ else {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), FALSE);
+ SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, TranslateT("Not set"));
+ }
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_IGNORE_SOUND), TRUE);
+ CheckDlgButton(hwndDlg, IDC_CONT_IGNORE_SOUND, db_get_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ p = XSN_Users.find((XSN_Data *)&hContact);
+ if (p == NULL) {
+ ptrT name(db_get_tsa(hContact, SETTINGSNAME, SETTINGSKEY));
+ if (name != NULL)
+ XSN_Users.insert(new XSN_Data(hContact, name, IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0));
+ }
}
- }
- return TRUE;
+ return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
- {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ p = XSN_Users.find((XSN_Data *)&hContact);
if (p != NULL) {
if (mir_tstrcmpi(p->path, _T(""))) {
TCHAR shortpath[MAX_PATH];
@@ -87,55 +86,51 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP }
db_set_b(hContact, SETTINGSNAME, SETTINGSIGNOREKEY, p->ignore);
}
- }
case IDCANCEL:
DestroyWindow(hwndDlg);
break;
case IDC_CONT_BUTTON_CHOOSE_SOUND:
- {
- TCHAR FileName[MAX_PATH];
- TCHAR *tszMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
-
- OPENFILENAME ofn = { 0 };
- ofn.lStructSize = sizeof(ofn);
- TCHAR tmp[MAX_PATH];
- if (GetModuleHandle(_T("bass_interface.dll")))
- mir_sntprintf(tmp, _countof(tmp), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%c"), TranslateT("Sound files"), 0, 0, 0);
- else
- mir_sntprintf(tmp, _countof(tmp), _T("%s (*.wav)%c*.wav%c%c"), TranslateT("WAV files"), 0, 0, 0);
- ofn.lpstrFilter = tmp;
- ofn.hwndOwner = 0;
- ofn.lpstrFile = FileName;
- ofn.nMaxFile = MAX_PATH;
- ofn.nMaxFileTitle = MAX_PATH;
- ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
- ofn.lpstrInitialDir = tszMirDir;
- *FileName = '\0';
- ofn.lpstrDefExt = _T("");
-
- if (GetOpenFileName(&ofn)) {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, PathFindFileName(FileName));
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
- if (p == NULL)
- XSN_Users.insert(new XSN_Data(hContact, FileName, IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0));
- else {
- _tcsncpy(p->path, FileName, _countof(p->path));
- p->ignore = IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0;
+ {
+ TCHAR FileName[MAX_PATH];
+ TCHAR *tszMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
+
+ OPENFILENAME ofn = { 0 };
+ ofn.lStructSize = sizeof(ofn);
+ TCHAR tmp[MAX_PATH];
+ if (GetModuleHandle(_T("bass_interface.dll")))
+ mir_sntprintf(tmp, _countof(tmp), _T("%s (*.wav, *.mp3, *.ogg)%c*.wav;*.mp3;*.ogg%c%c"), TranslateT("Sound files"), 0, 0, 0);
+ else
+ mir_sntprintf(tmp, _countof(tmp), _T("%s (*.wav)%c*.wav%c%c"), TranslateT("WAV files"), 0, 0, 0);
+ ofn.lpstrFilter = tmp;
+ ofn.hwndOwner = 0;
+ ofn.lpstrFile = FileName;
+ ofn.nMaxFile = MAX_PATH;
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
+ ofn.lpstrInitialDir = tszMirDir;
+ *FileName = '\0';
+ ofn.lpstrDefExt = _T("");
+
+ if (GetOpenFileName(&ofn)) {
+ SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, PathFindFileName(FileName));
+ p = XSN_Users.find((XSN_Data *)&hContact);
+ if (p == NULL)
+ XSN_Users.insert(new XSN_Data(hContact, FileName, IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0));
+ else {
+ _tcsncpy(p->path, FileName, _countof(p->path));
+ p->ignore = IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0;
+ }
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), TRUE);
}
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), TRUE);
+ mir_free(tszMirDir);
}
- mir_free(tszMirDir);
- }
- break;
+ break;
case IDC_CONT_BUTTON_TEST_PLAY:
- {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ p = XSN_Users.find((XSN_Data *)&hContact);
isIgnoreSound = 0;
if (p == NULL) {
DBVARIANT dbv;
@@ -151,30 +146,25 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP PathToAbsoluteT(p->path, longpath);
SkinPlaySoundFile(longpath);
}
- }
- break;
+ break;
case IDC_CONT_BUTTON_RESET_SOUND:
- {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_TEST_PLAY), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_CONT_BUTTON_RESET_SOUND), FALSE);
CheckDlgButton(hwndDlg, IDC_CONT_IGNORE_SOUND, BST_UNCHECKED);
SetDlgItemText(hwndDlg, IDC_CONT_LABEL_SOUND, TranslateT("Not set"));
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+
+ p = XSN_Users.find((XSN_Data *)&hContact);
if (p != NULL) {
XSN_Users.remove(p);
delete p;
}
db_unset(hContact, SETTINGSNAME, SETTINGSKEY);
db_unset(hContact, SETTINGSNAME, SETTINGSIGNOREKEY);
- }
- break;
+ break;
case IDC_CONT_IGNORE_SOUND:
- {
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- XSN_Data *p = XSN_Users.find((XSN_Data *)&hContact);
+ p = XSN_Users.find((XSN_Data *)&hContact);
if (p == NULL) {
DBVARIANT dbv;
if (!db_get_ts(hContact, SETTINGSNAME, SETTINGSKEY, &dbv)) {
@@ -187,7 +177,6 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP }
else p->ignore = IsDlgButtonChecked(hwndDlg, IDC_CONT_IGNORE_SOUND) ? 1 : 0;
}
- }
break;
case WM_CLOSE:
@@ -195,7 +184,6 @@ static INT_PTR CALLBACK DlgProcContactsOptions(HWND hwndDlg, UINT msg, WPARAM wP break;
case WM_DESTROY:
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
Utils_SaveWindowPosition(hwndDlg, hContact, SETTINGSNAME, "ChangeSoundDlg");
WindowList_Remove(hChangeSoundDlgList, hwndDlg);
}
diff --git a/protocols/IcqOscarJ/src/fam_04message.cpp b/protocols/IcqOscarJ/src/fam_04message.cpp index 2b9c68bfca..e8afe60295 100644 --- a/protocols/IcqOscarJ/src/fam_04message.cpp +++ b/protocols/IcqOscarJ/src/fam_04message.cpp @@ -93,10 +93,10 @@ void CIcqProto::handleReplyICBM() DWORD dwFlags = 0x00000303;
#ifdef DBG_CAPHTML
- dwFlags |= 0x00000400;
+ dwFlags |= 0x00000400;
#endif
#ifdef DBG_CAPMTN
- dwFlags |= 0x00000008;
+ dwFlags |= 0x00000008;
#endif
// Set message parameters for all channels (imitate ICQ 6)
setMsgChannelParams(this, 0x0000, dwFlags);
@@ -403,11 +403,11 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, size_t wLen, DWORD dwUin, char unpackWord(&pDataBuf, &wCommand);
wTLVLen -= 2;
-
+
// Command 0x0000 - Normal message/file send request
// 0x0001 - Abort request
// 0x0002 - Acknowledge request
- debugLogA("Command is %u", wCommand);
+ debugLogA("Command is %u", wCommand);
// Some stuff we don't use
pDataBuf += 8; // dwID1 and dwID2 again
@@ -506,10 +506,8 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, size_t wLen, DWORD dwUin, char // Parse the next message level
if (tlv = chain->getTLV(0x2711, 1)) {
if (tlv->wLen == 0x1B) {
- BYTE *buf = tlv->pData;
- DWORD dwUin;
-
- unpackLEDWord(&buf, &dwUin);
+ BYTE *buf2 = tlv->pData;
+ unpackLEDWord(&buf2, &dwUin);
MCONTACT hContact = HContactFromUIN(dwUin, NULL);
if (hContact == INVALID_CONTACT_ID)
@@ -519,15 +517,15 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, size_t wLen, DWORD dwUin, char WORD wVersion;
BYTE bMode;
- unpackDWord(&buf, &dwIp);
- unpackLEDWord(&buf, &dwPort);
- unpackByte(&buf, &bMode);
- buf += 4; // unknown
+ unpackDWord(&buf2, &dwIp);
+ unpackLEDWord(&buf2, &dwPort);
+ unpackByte(&buf2, &bMode);
+ buf2 += 4; // unknown
if (dwPort)
- buf += 4; // port, again?
+ buf2 += 4; // port, again?
else
- unpackLEDWord(&buf, &dwPort);
- unpackLEWord(&buf, &wVersion);
+ unpackLEDWord(&buf2, &dwPort);
+ unpackLEWord(&buf2, &wVersion);
setDword(hContact, "IP", dwIp);
setWord(hContact, "UserPort", (WORD)dwPort);
@@ -536,7 +534,7 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, size_t wLen, DWORD dwUin, char if (wVersion > 6) {
cookie_reverse_connect *pCookie = (cookie_reverse_connect*)SAFE_MALLOC(sizeof(cookie_reverse_connect));
- unpackLEDWord(&buf, (DWORD*)&pCookie->ft);
+ unpackLEDWord(&buf2, (DWORD*)&pCookie->ft);
pCookie->dwMsgID1 = dwMsgID1;
pCookie->dwMsgID2 = dwMsgID2;
@@ -668,12 +666,12 @@ void CIcqProto::parseServRelayData(BYTE *pDataBuf, size_t wLen, MCONTACT hContac }
break;
- // Chat messages, handled by the chat module
+ // Chat messages, handled by the chat module
case MTYPE_CHAT:
// TODO: this type is deprecated
break;
- // Plugin messages, need further parsing
+ // Plugin messages, need further parsing
case MTYPE_PLUGIN:
if (wLen < wMsgLen) { // sanity check
debugLogA("Error: Malformed server Greeting message");
@@ -683,7 +681,7 @@ void CIcqProto::parseServRelayData(BYTE *pDataBuf, size_t wLen, MCONTACT hContac parseServRelayPluginData(pDataBuf + wMsgLen, wLen - wMsgLen, dwUin, szUID, dwMsgID1, dwMsgID2, wAckType, bFlags, wStatus, wCookie, wVersion);
break;
- // Everything else
+ // Everything else
default:
if (!dwUin) { // AIM cannot send this, just sanity
debugLogA("Error: Malformed UIN in packet");
@@ -1135,14 +1133,14 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, size_t wLen, DWORD dwUin, char }
if (bMsgType == MTYPE_PLUGIN) {
- size_t wLen = wTLVLen - 8;
- int typeId;
+ wLen = wTLVLen - 8;
debugLogA("Parsing Greeting message through server");
pmsg += wMsgLen;
wLen -= wMsgLen;
+ int typeId;
if (unpackPluginTypeId(&pmsg, &wLen, &typeId, NULL, FALSE) && wLen > 8) {
size_t dwLengthToEnd, dwDataLen;
@@ -1157,15 +1155,15 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, size_t wLen, DWORD dwUin, char dwDataLen = wLen;
if (typeId) {
- uid_str szUID;
- handleMessageTypes(dwUin, szUID, dwRecvTime, dwMsgID1, dwMsgID2, 0, 0, typeId, bFlags, 0, dwLengthToEnd, dwDataLen, (char*)pmsg, MTF_PLUGIN, NULL);
+ uid_str szUid;
+ handleMessageTypes(dwUin, szUid, dwRecvTime, dwMsgID1, dwMsgID2, 0, 0, typeId, bFlags, 0, dwLengthToEnd, dwDataLen, (char*)pmsg, MTF_PLUGIN, NULL);
}
else debugLogA("Unsupported plugin message type %d", typeId);
}
}
else {
- uid_str szUID;
- handleMessageTypes(dwUin, szUID, dwRecvTime, dwMsgID1, dwMsgID2, 0, 0, bMsgType, bFlags, 0, wTLVLen - 8, wMsgLen, (char*)pmsg, 0, NULL);
+ uid_str szUid;
+ handleMessageTypes(dwUin, szUid, dwRecvTime, dwMsgID1, dwMsgID2, 0, 0, bMsgType, bFlags, 0, wTLVLen - 8, wMsgLen, (char*)pmsg, 0, NULL);
}
}
}
@@ -1468,8 +1466,8 @@ void CIcqProto::sendMessageTypesAck(MCONTACT hContact, int bUnicode, message_ack {
if (pArgs) {
if ((pArgs->msgType == MTYPE_PLAIN && !CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_MESSAGE))
- || (pArgs->msgType == MTYPE_URL && !CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_URL))
- || pArgs->msgType == MTYPE_CONTACTS) {
+ || (pArgs->msgType == MTYPE_URL && !CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_URL))
+ || pArgs->msgType == MTYPE_CONTACTS) {
if (pArgs->bType == MAT_SERVER_ADVANCED) { // Only ack message packets
icq_sendAdvancedMsgAck(pArgs->dwUin, pArgs->dwMsgID1, pArgs->dwMsgID2, pArgs->wCookie, (BYTE)pArgs->msgType, pArgs->bFlags);
}
@@ -1513,7 +1511,8 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, pszMsgField[0] = szMsg;
if (type == MTYPE_URL || type == MTYPE_AUTHREQ || type == MTYPE_ADDED || type == MTYPE_CONTACTS || type == MTYPE_EEXPRESS || type == MTYPE_WWP) {
- for (char *pszMsg = szMsg, nMsgFields = 1; *pszMsg; pszMsg++) {
+ nMsgFields = 1;
+ for (char *pszMsg = szMsg; *pszMsg; pszMsg++) {
if ((BYTE)*pszMsg == 0xFE) {
*pszMsg = '\0';
pszMsgField[nMsgFields++] = pszMsg + 1;
@@ -1672,10 +1671,9 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, char* pszNContactsEnd;
int nContacts;
if (nMsgFields < 3 ||
- (nContacts = strtol(pszMsgField[0], &pszNContactsEnd, 10)) == 0 ||
- pszNContactsEnd - pszMsgField[0] != (int)mir_strlen(pszMsgField[0]) ||
- nMsgFields < nContacts * 2 + 1)
- {
+ (nContacts = strtol(pszMsgField[0], &pszNContactsEnd, 10)) == 0 ||
+ pszNContactsEnd - pszMsgField[0] != (int)mir_strlen(pszMsgField[0]) ||
+ nMsgFields < nContacts * 2 + 1) {
NetLog_Uni(bThruDC, "Malformed '%s' message", "contacts");
}
else {
@@ -1812,72 +1810,71 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, case MTYPE_AUTONA:
case MTYPE_AUTODND:
case MTYPE_AUTOFFC:
- {
- char **szMsg = MirandaStatusToAwayMsg(AwayMsgTypeToStatus(type));
- if (szMsg) {
- struct rates_status_message_response : public rates_queue_item
- {
- protected:
- virtual rates_queue_item* copyItem(rates_queue_item *aDest = NULL)
+ {
+ char **szMsgs = MirandaStatusToAwayMsg(AwayMsgTypeToStatus(type));
+ if (szMsgs) {
+ struct rates_status_message_response : public rates_queue_item
{
- rates_status_message_response *pDest = (rates_status_message_response*)aDest;
- if (!pDest)
- pDest = new rates_status_message_response(ppro, wGroup);
-
- pDest->bExtended = bExtended;
- pDest->dwMsgID1 = dwMsgID1;
- pDest->dwMsgID2 = dwMsgID2;
- pDest->wCookie = wCookie;
- pDest->wVersion = wVersion;
- pDest->nMsgType = nMsgType;
-
- return rates_queue_item::copyItem(pDest);
+ protected:
+ virtual rates_queue_item* copyItem(rates_queue_item *aDest = NULL)
+ {
+ rates_status_message_response *pDest = (rates_status_message_response*)aDest;
+ if (!pDest)
+ pDest = new rates_status_message_response(ppro, wGroup);
+
+ pDest->bExtended = bExtended;
+ pDest->dwMsgID1 = dwMsgID1;
+ pDest->dwMsgID2 = dwMsgID2;
+ pDest->wCookie = wCookie;
+ pDest->wVersion = wVersion;
+ pDest->nMsgType = nMsgType;
+
+ return rates_queue_item::copyItem(pDest);
+ };
+ public:
+ rates_status_message_response(CIcqProto *ppro, WORD wGroup) : rates_queue_item(ppro, wGroup) {};
+ virtual ~rates_status_message_response() {};
+
+ virtual void execute()
+ {
+ char **pszMsg = ppro->MirandaStatusToAwayMsg(AwayMsgTypeToStatus(nMsgType));
+ if (bExtended)
+ ppro->icq_sendAwayMsgReplyServExt(dwUin, szUid, dwMsgID1, dwMsgID2, wCookie, wVersion, nMsgType, pszMsg);
+ else if (dwUin)
+ ppro->icq_sendAwayMsgReplyServ(dwUin, dwMsgID1, dwMsgID2, wCookie, wVersion, (BYTE)nMsgType, pszMsg);
+ else
+ ppro->debugLogA("Error: Malformed UIN in packet");
+ };
+
+ BOOL bExtended;
+ DWORD dwMsgID1;
+ DWORD dwMsgID2;
+ WORD wCookie;
+ WORD wVersion;
+ int nMsgType;
};
- public:
- rates_status_message_response(CIcqProto *ppro, WORD wGroup) : rates_queue_item(ppro, wGroup) {};
- virtual ~rates_status_message_response() {};
- virtual void execute()
+ WORD wGroup;
{
- char **pszMsg = ppro->MirandaStatusToAwayMsg(AwayMsgTypeToStatus(nMsgType));
- if (bExtended)
- ppro->icq_sendAwayMsgReplyServExt(dwUin, szUid, dwMsgID1, dwMsgID2, wCookie, wVersion, nMsgType, pszMsg);
- else if (dwUin)
- ppro->icq_sendAwayMsgReplyServ(dwUin, dwMsgID1, dwMsgID2, wCookie, wVersion, (BYTE)nMsgType, pszMsg);
- else
- ppro->debugLogA("Error: Malformed UIN in packet");
- };
-
- BOOL bExtended;
- DWORD dwMsgID1;
- DWORD dwMsgID2;
- WORD wCookie;
- WORD wVersion;
- int nMsgType;
- };
+ mir_cslock l(m_ratesMutex);
+ wGroup = m_rates->getGroupFromSNAC(ICQ_MSG_FAMILY, ICQ_MSG_RESPONSE);
+ }
- WORD wGroup;
- {
- mir_cslock l(m_ratesMutex);
- wGroup = m_rates->getGroupFromSNAC(ICQ_MSG_FAMILY, ICQ_MSG_RESPONSE);
+ rates_status_message_response rr(this, wGroup);
+ rr.bExtended = (nMsgFlags & MTF_STATUS_EXTENDED) == MTF_STATUS_EXTENDED;
+ rr.hContact = hContact;
+ rr.dwUin = dwUin;
+ rr.szUid = szUID;
+ rr.dwMsgID1 = dwMsgID;
+ rr.dwMsgID2 = dwMsgID2;
+ rr.wCookie = wCookie;
+ rr.wVersion = wVersion;
+ rr.nMsgType = type;
+
+ handleRateItem(&rr, RQT_RESPONSE);
}
-
- rates_status_message_response rr(this, wGroup);
- rr.bExtended = (nMsgFlags & MTF_STATUS_EXTENDED) == MTF_STATUS_EXTENDED;
- rr.hContact = hContact;
- rr.dwUin = dwUin;
- rr.szUid = szUID;
- rr.dwMsgID1 = dwMsgID;
- rr.dwMsgID2 = dwMsgID2;
- rr.wCookie = wCookie;
- rr.wVersion = wVersion;
- rr.nMsgType = type;
-
- handleRateItem(&rr, RQT_RESPONSE);
}
-
break;
- }
case MTYPE_FILEREQ: // Never happens
default:
@@ -2192,20 +2189,20 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, size_t wLen) break;
case MTYPE_REVERSE_REQUEST:
- {
- cookie_reverse_connect *pReverse = (cookie_reverse_connect*)pCookieData;
+ {
+ cookie_reverse_connect *pReverse = (cookie_reverse_connect*)pCookieData;
- if (pReverse->ft) {
- filetransfer *ft = (filetransfer*)pReverse->ft;
+ if (pReverse->ft) {
+ filetransfer *ft = (filetransfer*)pReverse->ft;
- ProtoBroadcastAck(ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
- }
- debugLogA("Reverse Connect request failed");
- // Set DC status to failed
- setByte(hContact, "DCStatus", 2);
+ ProtoBroadcastAck(ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
+ }
+ debugLogA("Reverse Connect request failed");
+ // Set DC status to failed
+ setByte(hContact, "DCStatus", 2);
- ReleaseCookie(dwCookie);
- }
+ ReleaseCookie(dwCookie);
+ }
return;
case MTYPE_CHAT:
diff --git a/protocols/Steam/src/steam_login.cpp b/protocols/Steam/src/steam_login.cpp index 52345fef00..cddd0204e3 100644 --- a/protocols/Steam/src/steam_login.cpp +++ b/protocols/Steam/src/steam_login.cpp @@ -35,18 +35,18 @@ void CSteamProto::OnGotRsaKey(const NETLIBHTTPREQUEST *response) // encrcrypt password
ptrA base64RsaEncryptedPassword;
- ptrA password(getStringA("Password"));
+ ptrA szPassword(getStringA("Password"));
DWORD error = 0;
DWORD encryptedSize = 0;
- if ((error = RsaEncrypt(modulus.c_str(), password, NULL, encryptedSize)) != 0)
+ if ((error = RsaEncrypt(modulus.c_str(), szPassword, NULL, encryptedSize)) != 0)
{
debugLogA("CSteamProto::OnGotRsaKey: encryption error (%lu)", error);
return;
}
BYTE *encryptedPassword = (BYTE*)mir_calloc(encryptedSize);
- if ((error = RsaEncrypt(modulus.c_str(), password, encryptedPassword, encryptedSize)) != 0)
+ if ((error = RsaEncrypt(modulus.c_str(), szPassword, encryptedPassword, encryptedSize)) != 0)
{
debugLogA("CSteamProto::OnGotRsaKey: encryption error (%lu)", error);
return;
diff --git a/protocols/Tlen/src/tlen_file.cpp b/protocols/Tlen/src/tlen_file.cpp index 20de8dafee..887ef89994 100644 --- a/protocols/Tlen/src/tlen_file.cpp +++ b/protocols/Tlen/src/tlen_file.cpp @@ -38,13 +38,13 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) p = rpacket->packet;
if (rpacket->type == TLEN_FILE_PACKET_FILE_LIST) { // list of files (length & name)
ft->fileCount = (int)(*((DWORD*)p));
- ft->files = (char **) mir_alloc(sizeof(char *) * ft->fileCount);
- ft->filesSize = (long *) mir_alloc(sizeof(long) * ft->fileCount);
+ ft->files = (char **)mir_alloc(sizeof(char *) * ft->fileCount);
+ ft->filesSize = (long *)mir_alloc(sizeof(long) * ft->fileCount);
ft->currentFile = 0;
ft->allFileTotalSize = 0;
ft->allFileReceivedBytes = 0;
p += sizeof(DWORD);
- for (i=0;i<ft->fileCount;i++) {
+ for (i = 0; i < ft->fileCount; i++) {
ft->filesSize[i] = (long)(*((DWORD*)p));
ft->allFileTotalSize += ft->filesSize[i];
p += sizeof(DWORD);
@@ -52,9 +52,9 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) memcpy(ft->files[i], p, 256);
p += 256;
}
- if ((packet=TlenP2PPacketCreate(3*sizeof(DWORD))) == NULL) {
+
+ if ((packet = TlenP2PPacketCreate(3 * sizeof(DWORD))) == NULL)
ft->state = FT_ERROR;
- }
else {
TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_FILE_LIST_ACK);
TlenP2PPacketSend(ft->s, packet);
@@ -65,13 +65,11 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) }
TlenP2PPacketFree(rpacket);
}
- else {
- ft->state = FT_ERROR;
- }
+ else ft->state = FT_ERROR;
}
else if (ft->state == FT_INITIALIZING) {
char *fullFileName;
- if ((packet=TlenP2PPacketCreate(3*sizeof(DWORD))) != NULL) {
+ if ((packet = TlenP2PPacketCreate(3 * sizeof(DWORD))) != NULL) {
TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_FILE_REQUEST); // file request
TlenP2PPacketPackDword(packet, ft->currentFile);
TlenP2PPacketPackDword(packet, 0);
@@ -79,12 +77,12 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) TlenP2PPacketSend(ft->s, packet);
TlenP2PPacketFree(packet);
- fullFileName = (char *) mir_alloc(mir_strlen(ft->szSavePath) + mir_strlen(ft->files[ft->currentFile]) + 2);
+ fullFileName = (char *)mir_alloc(mir_strlen(ft->szSavePath) + mir_strlen(ft->files[ft->currentFile]) + 2);
mir_strcpy(fullFileName, ft->szSavePath);
- if (fullFileName[mir_strlen(fullFileName)-1] != '\\')
+ if (fullFileName[mir_strlen(fullFileName) - 1] != '\\')
mir_strcat(fullFileName, "\\");
mir_strcat(fullFileName, ft->files[ft->currentFile]);
- ft->fileId = _open(fullFileName, _O_BINARY|_O_WRONLY|_O_CREAT|_O_TRUNC, _S_IREAD|_S_IWRITE);
+ ft->fileId = _open(fullFileName, _O_BINARY | _O_WRONLY | _O_CREAT | _O_TRUNC, _S_IREAD | _S_IWRITE);
ft->fileReceivedBytes = 0;
ft->fileTotalSize = ft->filesSize[ft->currentFile];
ft->proto->debugLogA("Saving to [%s] [%d]", fullFileName, ft->filesSize[ft->currentFile]);
@@ -92,9 +90,7 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) ft->state = FT_RECEIVING;
ft->proto->debugLogA("Change to FT_RECEIVING");
}
- else {
- ft->state = FT_ERROR;
- }
+ else ft->state = FT_ERROR;
}
else if (ft->state == FT_RECEIVING) {
PROTOFILETRANSFERSTATUS pfts;
@@ -116,7 +112,7 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) p = rpacket->packet;
if (rpacket->type == TLEN_FILE_PACKET_FILE_DATA) { // file data
int writeSize;
- writeSize = rpacket->len - 2 * sizeof(DWORD) ; // skip file offset
+ writeSize = rpacket->len - 2 * sizeof(DWORD); // skip file offset
if (_write(ft->fileId, p + 2 * sizeof(DWORD), writeSize) != writeSize) {
ft->state = FT_ERROR;
}
@@ -125,13 +121,13 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) ft->allFileReceivedBytes += writeSize;
pfts.totalProgress = ft->allFileReceivedBytes;
pfts.currentFileProgress = ft->fileReceivedBytes;
- ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM) &pfts);
+ ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&pfts);
}
}
else if (rpacket->type == TLEN_FILE_PACKET_END_OF_FILE) { // end of file
_close(ft->fileId);
ft->proto->debugLogA("Finishing this file...");
- if (ft->currentFile >= ft->fileCount-1) {
+ if (ft->currentFile >= ft->fileCount - 1) {
ft->state = FT_DONE;
}
else {
@@ -143,9 +139,7 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) }
TlenP2PPacketFree(rpacket);
}
- else {
- ft->state = FT_ERROR;
- }
+ else ft->state = FT_ERROR;
}
}
}
@@ -159,9 +153,9 @@ static void TlenFileReceivingConnection(HANDLE hConnection, DWORD, void * pExtra ft->s = hConnection;
ft->proto->debugLogA("Set ft->s to %d (saving %d)", hConnection, slisten);
ft->proto->debugLogA("Entering send loop for this file connection... (ft->s is hConnection)");
- while (ft->state != FT_DONE && ft->state != FT_ERROR) {
+ while (ft->state != FT_DONE && ft->state != FT_ERROR)
TlenFileReceiveParse(ft);
- }
+
if (ft->state == FT_DONE)
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0);
else
@@ -169,17 +163,15 @@ static void TlenFileReceivingConnection(HANDLE hConnection, DWORD, void * pExtra ft->proto->debugLogA("Closing connection for this file transfer... (ft->s is now hBind)");
ft->s = slisten;
ft->proto->debugLogA("ft->s is restored to %d", ft->s);
- if (ft->s != hConnection) {
+
+ if (ft->s != hConnection)
Netlib_CloseHandle(hConnection);
- }
if (ft->hFileEvent != NULL)
SetEvent(ft->hFileEvent);
- } else {
- Netlib_CloseHandle(hConnection);
}
+ else Netlib_CloseHandle(hConnection);
}
-
static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft)
{
ft->proto->debugLogA("Thread started: type=file_receive server='%s' port='%d'", ft->hostName, ft->wPort);
@@ -189,19 +181,20 @@ static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft) nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
- HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->m_hNetlibUser, (LPARAM) &nloc);
+ HANDLE s = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)ft->proto->m_hNetlibUser, (LPARAM)&nloc);
if (s != NULL) {
ft->s = s;
ft->proto->debugLogA("Entering file receive loop");
TlenP2PEstablishOutgoingConnection(ft, TRUE);
- while (ft->state != FT_DONE && ft->state != FT_ERROR) {
+ while (ft->state != FT_DONE && ft->state != FT_ERROR)
TlenFileReceiveParse(ft);
- }
+
if (ft->s) {
Netlib_CloseHandle(s);
+ ft->s = NULL;
}
- ft->s = NULL;
- } else {
+ }
+ else {
ft->pfnNewConnectionV2 = TlenFileReceivingConnection;
ft->proto->debugLogA("Connection failed - receiving as server");
s = TlenP2PListen(ft);
@@ -220,7 +213,8 @@ static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft) CloseHandle(hEvent);
ft->proto->debugLogA("Finish all files");
Netlib_CloseHandle(s);
- } else {
+ }
+ else {
ft->state = FT_ERROR;
}
}
@@ -248,23 +242,22 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) char *fileBuffer;
TLEN_FILE_PACKET *packet;
-
if (ft->state == FT_CONNECTING) {
char filename[256]; // Must be 256 (0x100)
- if ((packet=TlenP2PPacketCreate(sizeof(DWORD)+(ft->fileCount*(sizeof(filename)+sizeof(DWORD))))) != NULL) {
+ if ((packet = TlenP2PPacketCreate(sizeof(DWORD) + (ft->fileCount*(sizeof(filename) + sizeof(DWORD))))) != NULL) {
// Must pause a bit, sending these two packets back to back
// will break the session because the receiver cannot take it :)
SleepEx(1000, TRUE);
TlenP2PPacketSetLen(packet, 0); // Reuse packet
TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_FILE_LIST);
- TlenP2PPacketPackDword(packet, (DWORD) ft->fileCount);
- for (i=0; i<ft->fileCount; i++) {
-// struct _stat statbuf;
-// _stat(ft->files[i], &statbuf);
-// TlenP2PPacketPackDword(packet, statbuf.st_size);
+ TlenP2PPacketPackDword(packet, (DWORD)ft->fileCount);
+ for (i = 0; i < ft->fileCount; i++) {
+ // struct _stat statbuf;
+ // _stat(ft->files[i], &statbuf);
+ // TlenP2PPacketPackDword(packet, statbuf.st_size);
TlenP2PPacketPackDword(packet, ft->filesSize[i]);
memset(filename, 0, sizeof(filename));
- if ((t=strrchr(ft->files[i], '\\')) != NULL)
+ if ((t = strrchr(ft->files[i], '\\')) != NULL)
t++;
else
t = ft->files[i];
@@ -278,9 +271,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) ft->state = FT_INITIALIZING;
ft->proto->debugLogA("Change to FT_INITIALIZING");
}
- else {
- ft->state = FT_ERROR;
- }
+ else ft->state = FT_ERROR;
}
else if (ft->state == FT_INITIALIZING) { // FT_INITIALIZING
TLEN_FILE_PACKET *rpacket = TlenP2PPacketReceive(ft->s);
@@ -312,13 +303,13 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) ft->state = FT_ERROR;
}
else {
- // _stat(ft->files[currentFile], &statbuf); // file size in statbuf.st_size
+ // _stat(ft->files[currentFile], &statbuf); // file size in statbuf.st_size
ft->proto->debugLogA("Sending [%s] [%d]", ft->files[currentFile], ft->filesSize[currentFile]);
- if ((ft->fileId=_open(ft->files[currentFile], _O_BINARY|_O_RDONLY)) < 0) {
+ if ((ft->fileId = _open(ft->files[currentFile], _O_BINARY | _O_RDONLY)) < 0) {
ft->proto->debugLogA("File cannot be opened");
ft->state = FT_ERROR;
}
- else {
+ else {
memset(&pfts, 0, sizeof(PROTOFILETRANSFERSTATUS));
pfts.cbSize = sizeof(PROTOFILETRANSFERSTATUS);
pfts.hContact = ft->hContact;
@@ -332,16 +323,16 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) pfts.currentFileSize = ft->filesSize[ft->currentFile]; //statbuf.st_size;
pfts.currentFileTime = 0;
ft->fileReceivedBytes = 0;
- if ((packet = TlenP2PPacketCreate(2*sizeof(DWORD)+2048)) == NULL) {
+ if ((packet = TlenP2PPacketCreate(2 * sizeof(DWORD) + 2048)) == NULL) {
ft->state = FT_ERROR;
}
else {
TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_FILE_DATA);
- fileBuffer = (char *) mir_alloc(2048);
+ fileBuffer = (char *)mir_alloc(2048);
ft->proto->debugLogA("Sending file data...");
- while ((numRead=_read(ft->fileId, fileBuffer, 2048)) > 0) {
+ while ((numRead = _read(ft->fileId, fileBuffer, 2048)) > 0) {
TlenP2PPacketSetLen(packet, 0); // Reuse packet
- TlenP2PPacketPackDword(packet, (DWORD) ft->fileReceivedBytes);
+ TlenP2PPacketPackDword(packet, (DWORD)ft->fileReceivedBytes);
TlenP2PPacketPackDword(packet, 0);
TlenP2PPacketPackBuffer(packet, fileBuffer, numRead);
if (TlenP2PPacketSend(ft->s, packet)) {
@@ -349,7 +340,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) ft->allFileReceivedBytes += numRead;
pfts.totalProgress = ft->allFileReceivedBytes;
pfts.currentFileProgress = ft->fileReceivedBytes;
- ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM) &pfts);
+ ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_DATA, ft, (LPARAM)&pfts);
}
else {
ft->state = FT_ERROR;
@@ -359,7 +350,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) mir_free(fileBuffer);
_close(ft->fileId);
if (ft->state != FT_ERROR) {
- if (ft->currentFile >= ft->fileCount-1)
+ if (ft->currentFile >= ft->fileCount - 1)
ft->state = FT_DONE;
else {
ft->currentFile++;
@@ -408,14 +399,13 @@ static void TlenFileSendingConnection(HANDLE hConnection, DWORD, void * pExtra) ft->proto->debugLogA("Closing connection for this file transfer... (ft->s is now hBind)");
ft->s = slisten;
ft->proto->debugLogA("ft->s is restored to %d", ft->s);
- if (ft->s != hConnection) {
+
+ if (ft->s != hConnection)
Netlib_CloseHandle(hConnection);
- }
if (ft->hFileEvent != NULL)
SetEvent(ft->hFileEvent);
- } else {
- Netlib_CloseHandle(hConnection);
}
+ else Netlib_CloseHandle(hConnection);
}
int TlenFileCancelAll(TlenProtocol *proto)
@@ -423,7 +413,7 @@ int TlenFileCancelAll(TlenProtocol *proto) HANDLE hEvent;
int i = 0;
- while ((i=TlenListFindNext(proto, LIST_FILE, 0)) >=0 ) {
+ while ((i = TlenListFindNext(proto, LIST_FILE, 0)) >= 0) {
TLEN_LIST_ITEM *item = TlenListGetItemPtrFromIndex(proto, i);
if (item != NULL) {
TLEN_FILE_TRANSFER *ft = item->ft;
@@ -440,7 +430,8 @@ int TlenFileCancelAll(TlenProtocol *proto) ft->hFileEvent = NULL;
SetEvent(hEvent);
}
- } else {
+ }
+ else {
ft->proto->debugLogA("freeing ft struct");
TlenP2PFreeFileTransfer(ft);
}
@@ -488,30 +479,31 @@ static void __cdecl TlenFileSendingThread(TLEN_FILE_TRANSFER *ft) NETLIBOPENCONNECTION nloc = { sizeof(nloc) };
nloc.szHost = ft->hostName;
nloc.wPort = ft->wPort;
- HANDLE s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->m_hNetlibUser, (LPARAM) &nloc);
- if (s != NULL) {
+ HANDLE hConn = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)ft->proto->m_hNetlibUser, (LPARAM)&nloc);
+ if (hConn != NULL) {
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0);
- ft->s = s;
+ ft->s = hConn;
TlenP2PEstablishOutgoingConnection(ft, TRUE);
ft->proto->debugLogA("Entering send loop for this file connection...");
- while (ft->state != FT_DONE && ft->state != FT_ERROR) {
+ while (ft->state != FT_DONE && ft->state != FT_ERROR)
TlenFileSendParse(ft);
- }
+
if (ft->state == FT_DONE)
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0);
else
ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
ft->proto->debugLogA("Closing connection for this file transfer... ");
- Netlib_CloseHandle(s);
- } else {
- ft->state = FT_ERROR;
+ Netlib_CloseHandle(hConn);
}
+ else ft->state = FT_ERROR;
}
- } else {
+ }
+ else {
ft->proto->debugLogA("Cannot allocate port to bind for file server thread, thread ended.");
ft->state = FT_ERROR;
}
TlenListRemove(ft->proto, LIST_FILE, ft->iqId);
+
switch (ft->state) {
case FT_DONE:
ft->proto->debugLogA("Finish successfully");
@@ -533,8 +525,9 @@ static void __cdecl TlenFileSendingThread(TLEN_FILE_TRANSFER *ft) }
-TLEN_FILE_TRANSFER *TlenFileCreateFT(TlenProtocol *proto, const char *jid) {
- TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *) mir_alloc(sizeof(TLEN_FILE_TRANSFER));
+TLEN_FILE_TRANSFER *TlenFileCreateFT(TlenProtocol *proto, const char *jid)
+{
+ TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *)mir_alloc(sizeof(TLEN_FILE_TRANSFER));
memset(ft, 0, sizeof(TLEN_FILE_TRANSFER));
ft->proto = proto;
ft->jid = mir_strdup(jid);
@@ -552,46 +545,44 @@ void TlenProcessF(XmlNode *node, ThreadData *info) int numFiles;
TLEN_LIST_ITEM *item;
-// if (!node->name || mir_strcmp(node->name, "f")) return;
+ // if (!node->name || mir_strcmp(node->name, "f")) return;
if (info == NULL) return;
- char *from=TlenXmlGetAttrValue(node, "f");
+ char *from = TlenXmlGetAttrValue(node, "f");
if (from != NULL) {
- if (strchr(from, '@') == NULL) {
+ if (strchr(from, '@') == NULL)
mir_snprintf(jid, _countof(jid), "%s@%s", from, info->server);
- } else {
+ else
strncpy_s(jid, from, _TRUNCATE);
- }
- char *e=TlenXmlGetAttrValue(node, "e");
+
+ char *e = TlenXmlGetAttrValue(node, "e");
if (e != NULL) {
if (!mir_strcmp(e, "1")) {
// FILE_RECV : e='1' : File transfer request
TLEN_FILE_TRANSFER *ft = TlenFileCreateFT(info->proto, jid);
ft->hContact = TlenHContactFromJID(info->proto, jid);
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL)
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL)
ft->iqId = mir_strdup(p);
szFilename[0] = '\0';
- if ((p=TlenXmlGetAttrValue(node, "c")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "c")) != NULL) {
numFiles = atoi(p);
if (numFiles == 1) {
- if ((p=TlenXmlGetAttrValue(node, "n")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "n")) != NULL) {
p = TlenTextDecode(p);
- strncpy(szFilename, p, sizeof(szFilename)-1);
+ strncpy(szFilename, p, sizeof(szFilename) - 1);
mir_free(p);
- } else {
- mir_strcpy(szFilename, Translate("1 File"));
}
+ else mir_strcpy(szFilename, Translate("1 File"));
}
- else if (numFiles > 1) {
+ else if (numFiles > 1)
mir_snprintf(szFilename, _countof(szFilename), Translate("%d Files"), numFiles);
- }
}
if (szFilename[0] != '\0' && ft->iqId != NULL) {
TCHAR* filenameT = mir_utf8decodeT((char*)szFilename);
- PROTORECVFILET pre = {0};
+ PROTORECVFILET pre = { 0 };
pre.dwFlags = PRFF_TCHAR;
pre.fileCount = 1;
pre.timestamp = time(NULL);
@@ -601,7 +592,8 @@ void TlenProcessF(XmlNode *node, ThreadData *info) ft->proto->debugLogA("sending chainrecv");
ProtoChainRecvFile(ft->hContact, &pre);
mir_free(filenameT);
- } else {
+ }
+ else {
// malformed <f/> request, reject
if (ft->iqId)
TlenSend(ft->proto, "<f i='%s' e='4' t='%s'/>", ft->iqId, from);
@@ -612,8 +604,8 @@ void TlenProcessF(XmlNode *node, ThreadData *info) }
else if (!mir_strcmp(e, "3")) {
// FILE_RECV : e='3' : invalid transfer error
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
if (item->ft != NULL) {
ProtoBroadcastAck(info->proto->m_szModuleName, item->ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, item->ft, 0);
info->proto->FileCancel(NULL, item->ft);
@@ -624,8 +616,8 @@ void TlenProcessF(XmlNode *node, ThreadData *info) }
else if (!mir_strcmp(e, "4")) {
// FILE_SEND : e='4' : File sending request was denied by the remote client
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
if (!mir_strcmp(item->ft->jid, jid)) {
ProtoBroadcastAck(info->proto->m_szModuleName, item->ft->hContact, ACKTYPE_FILE, ACKRESULT_DENIED, item->ft, 0);
TlenListRemove(info->proto, LIST_FILE, p);
@@ -635,22 +627,20 @@ void TlenProcessF(XmlNode *node, ThreadData *info) }
else if (!mir_strcmp(e, "5")) {
// FILE_SEND : e='5' : File sending request was accepted
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL)
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL)
if (!mir_strcmp(item->ft->jid, jid))
- forkthread((void (__cdecl *)(void*))TlenFileSendingThread, 0, item->ft);
- }
- }
+ forkthread((void(__cdecl *)(void*))TlenFileSendingThread, 0, item->ft);
}
else if (!mir_strcmp(e, "6")) {
// FILE_RECV : e='6' : IP and port information to connect to get file
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
- if ((p=TlenXmlGetAttrValue(node, "a")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "a")) != NULL) {
item->ft->hostName = mir_strdup(p);
- if ((p=TlenXmlGetAttrValue(node, "p")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "p")) != NULL) {
item->ft->wPort = atoi(p);
- forkthread((void (__cdecl *)(void*))TlenFileReceiveThread, 0, item->ft);
+ forkthread((void(__cdecl *)(void*))TlenFileReceiveThread, 0, item->ft);
}
}
}
@@ -659,12 +649,12 @@ void TlenProcessF(XmlNode *node, ThreadData *info) else if (!mir_strcmp(e, "7")) {
// FILE_RECV : e='7' : IP and port information to connect to send file
// in case the conection to the given server was not successful
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
- if ((p=TlenXmlGetAttrValue(node, "a")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "a")) != NULL) {
if (item->ft->hostName != NULL) mir_free(item->ft->hostName);
item->ft->hostName = mir_strdup(p);
- if ((p=TlenXmlGetAttrValue(node, "p")) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "p")) != NULL) {
item->ft->wPort = atoi(p);
item->ft->state = FT_SWITCH;
SetEvent(item->ft->hFileEvent);
@@ -675,14 +665,13 @@ void TlenProcessF(XmlNode *node, ThreadData *info) }
else if (!mir_strcmp(e, "8")) {
// FILE_RECV : e='8' : transfer error
- if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
- if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
+ if ((p = TlenXmlGetAttrValue(node, "i")) != NULL) {
+ if ((item = TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
item->ft->state = FT_ERROR;
- if (item->ft->hFileEvent != NULL) {
+ if (item->ft->hFileEvent != NULL)
SetEvent(item->ft->hFileEvent);
- } else {
+ else
ProtoBroadcastAck(info->proto->m_szModuleName, item->ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, item->ft, 0);
- }
}
}
}
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp index e9424a040f..0a621e1c13 100644 --- a/protocols/Twitter/src/contacts.cpp +++ b/protocols/Twitter/src/contacts.cpp @@ -19,13 +19,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
#include "proto.h"
-void TwitterProto::AddToListWorker(void *p)
+void TwitterProto::AddToListWorker(void *pArg)
{
// TODO: what happens if there is an error?
- if (p == 0)
+ if (pArg == 0)
return;
- char *name = static_cast<char*>(p);
+ char *name = static_cast<char*>(pArg);
try {
twitter_user user;
@@ -57,14 +57,15 @@ MCONTACT TwitterProto::AddToList(int, PROTOSEARCHRESULT *psr) void TwitterProto::UpdateInfoWorker(void *arg)
{
- MCONTACT hContact = (MCONTACT) arg;
+ MCONTACT hContact = (MCONTACT)(DWORD_PTR)arg;
twitter_user user;
ptrA username(getStringA(hContact, TWITTER_KEY_UN));
if (username == NULL)
return;
- { mir_cslock s(twitter_lock_);
+ {
+ mir_cslock s(twitter_lock_);
twit_.get_info(std::string(username), &user);
}
@@ -93,17 +94,18 @@ int TwitterProto::GetInfo(MCONTACT hContact, int info_type) struct search_query
{
search_query(const std::tstring &_query, bool _by_email) : query(_query), by_email(_by_email)
- {}
+ {
+ }
std::tstring query;
bool by_email;
};
-void TwitterProto::DoSearch(void *p)
+void TwitterProto::DoSearch(void *pArg)
{
- if (p == 0)
+ if (pArg == 0)
return;
- search_query *query = static_cast<search_query*>(p);
+ search_query *query = static_cast<search_query*>(pArg);
twitter_user info;
bool found = false;
@@ -155,7 +157,7 @@ HANDLE TwitterProto::SearchByEmail(const TCHAR *email) void TwitterProto::GetAwayMsgWorker(void *arg)
{
- MCONTACT hContact = (MCONTACT) arg;
+ MCONTACT hContact = (MCONTACT)(DWORD_PTR)arg;
if (hContact == 0)
return;
@@ -175,7 +177,7 @@ HANDLE TwitterProto::GetAwayMsg(MCONTACT hContact) int TwitterProto::OnContactDeleted(WPARAM wParam, LPARAM)
{
- MCONTACT hContact = (MCONTACT) wParam;
+ MCONTACT hContact = (MCONTACT)wParam;
if (m_iStatus != ID_STATUS_ONLINE)
return 0;
diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp index 4c3b45c6a7..2ad1e6c126 100644 --- a/src/core/stdchat/src/window.cpp +++ b/src/core/stdchat/src/window.cpp @@ -66,29 +66,29 @@ static LRESULT CALLBACK SplitterSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, static void InitButtons(HWND hwndDlg, SESSION_INFO *si)
{
- SendDlgItemMessage( hwndDlg, IDC_SMILEY, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx( "smiley", FALSE ));
- SendDlgItemMessage( hwndDlg, IDC_BOLD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx( "bold", FALSE ));
- SendDlgItemMessage( hwndDlg, IDC_ITALICS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx( "italics", FALSE ));
- SendDlgItemMessage( hwndDlg, IDC_UNDERLINE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx( "underline", FALSE ));
- SendDlgItemMessage( hwndDlg, IDC_COLOR, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx( "fgcol", FALSE ));
- SendDlgItemMessage( hwndDlg, IDC_BKGCOLOR, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx( "bkgcol", FALSE ));
- SendDlgItemMessage( hwndDlg, IDC_HISTORY, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx( "history", FALSE ));
- SendDlgItemMessage( hwndDlg, IDC_CHANMGR, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx( "settings", FALSE ));
- SendDlgItemMessage( hwndDlg, IDC_CLOSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx( "close", FALSE ));
- SendDlgItemMessage( hwndDlg, IDC_SHOWNICKLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx( si->bNicklistEnabled ? "nicklist" : "nicklist2", FALSE ));
- SendDlgItemMessage( hwndDlg, IDC_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx( si->bFilterEnabled ? "filter" : "filter2", FALSE ));
-
- SendDlgItemMessage( hwndDlg, IDC_SMILEY, BUTTONSETASFLATBTN, TRUE, 0 );
- SendDlgItemMessage( hwndDlg, IDC_BOLD, BUTTONSETASFLATBTN, TRUE, 0 );
- SendDlgItemMessage( hwndDlg, IDC_ITALICS, BUTTONSETASFLATBTN, TRUE, 0 );
- SendDlgItemMessage( hwndDlg, IDC_UNDERLINE, BUTTONSETASFLATBTN, TRUE, 0 );
- SendDlgItemMessage( hwndDlg, IDC_BKGCOLOR, BUTTONSETASFLATBTN, TRUE, 0 );
- SendDlgItemMessage( hwndDlg, IDC_COLOR, BUTTONSETASFLATBTN, TRUE, 0 );
- SendDlgItemMessage( hwndDlg, IDC_HISTORY, BUTTONSETASFLATBTN, TRUE, 0 );
- SendDlgItemMessage( hwndDlg, IDC_SHOWNICKLIST, BUTTONSETASFLATBTN, TRUE, 0 );
- SendDlgItemMessage( hwndDlg, IDC_CHANMGR, BUTTONSETASFLATBTN, TRUE, 0 );
- SendDlgItemMessage( hwndDlg, IDC_FILTER, BUTTONSETASFLATBTN, TRUE, 0 );
- SendDlgItemMessage( hwndDlg, IDC_CLOSE, BUTTONSETASFLATBTN, TRUE, 0 );
+ SendDlgItemMessage(hwndDlg, IDC_SMILEY, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx("smiley", FALSE));
+ SendDlgItemMessage(hwndDlg, IDC_BOLD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx("bold", FALSE));
+ SendDlgItemMessage(hwndDlg, IDC_ITALICS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx("italics", FALSE));
+ SendDlgItemMessage(hwndDlg, IDC_UNDERLINE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx("underline", FALSE));
+ SendDlgItemMessage(hwndDlg, IDC_COLOR, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx("fgcol", FALSE));
+ SendDlgItemMessage(hwndDlg, IDC_BKGCOLOR, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx("bkgcol", FALSE));
+ SendDlgItemMessage(hwndDlg, IDC_HISTORY, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx("history", FALSE));
+ SendDlgItemMessage(hwndDlg, IDC_CHANMGR, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx("settings", FALSE));
+ SendDlgItemMessage(hwndDlg, IDC_CLOSE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx("close", FALSE));
+ SendDlgItemMessage(hwndDlg, IDC_SHOWNICKLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(si->bNicklistEnabled ? "nicklist" : "nicklist2", FALSE));
+ SendDlgItemMessage(hwndDlg, IDC_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(si->bFilterEnabled ? "filter" : "filter2", FALSE));
+
+ SendDlgItemMessage(hwndDlg, IDC_SMILEY, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BOLD, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_ITALICS, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_UNDERLINE, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BKGCOLOR, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_COLOR, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_HISTORY, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_SHOWNICKLIST, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_CHANMGR, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_FILTER, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_CLOSE, BUTTONSETASFLATBTN, TRUE, 0);
SendDlgItemMessage(hwndDlg, IDC_SMILEY, BUTTONADDTOOLTIP, (WPARAM)LPGEN("Insert a smiley"), 0);
SendDlgItemMessage(hwndDlg, IDC_BOLD, BUTTONADDTOOLTIP, (WPARAM)LPGEN("Make the text bold (CTRL+B)"), 0);
@@ -188,7 +188,7 @@ static int RoomWndResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc) urc->rcItem.top = bTabs ? (bTabBottom ? 0 : rcTabs.top - 1) : 0;
urc->rcItem.left = 0;
urc->rcItem.right = bNick ? urc->dlgNewSize.cx - si->iSplitterX : urc->dlgNewSize.cx;
-LBL_CalcBottom:
+ LBL_CalcBottom:
urc->rcItem.bottom = urc->dlgNewSize.cy - si->iSplitterY;
if (bTabs && bTabBottom) urc->rcItem.bottom += 6 - TabHeight;
if (!bToolbar) urc->rcItem.bottom += 20;
@@ -367,7 +367,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LRESULT lResult = (LRESULT)SendMessage(hwnd, EM_GETSEL, 0, 0);
SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
- int start = LOWORD(lResult);
+ start = LOWORD(lResult);
end = HIWORD(lResult);
SendMessage(hwnd, EM_SETSEL, end, end);
@@ -394,7 +394,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, TCHAR *pszSelName = (TCHAR *)mir_alloc(sizeof(TCHAR)*(end - start + 1));
mir_tstrncpy(pszSelName, pszText + start, end - start + 1);
-
+
TCHAR *pszName = pci->UM_FindUserAutoComplete(Parentsi->pUsers, dat->szTabSave, pszSelName);
if (pszName == NULL) {
pszName = dat->szTabSave;
@@ -707,7 +707,7 @@ static LRESULT CALLBACK MessageSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, return mir_callNextSubclass(hwnd, MessageSubclassProc, msg, wParam, lParam);
}
-static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static SESSION_INFO *si = NULL;
switch (uMsg) {
@@ -911,7 +911,7 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR case WM_LBUTTONDBLCLK:
{
- TCHITTESTINFO tci = {0};
+ TCHITTESTINFO tci = { 0 };
tci.pt.x = (short)LOWORD(GetMessagePos());
tci.pt.y = (short)HIWORD(GetMessagePos());
tci.flags = TCHT_ONITEM;
@@ -997,9 +997,9 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO *si if (tszBuf[0] == 0)
mir_sntprintf(tszBuf, _countof(tszBuf), _T("%s: %s\r\n%s: %s\r\n%s: %s"),
- TranslateT("Nickname"), ui->pszNick,
- TranslateT("Unique ID"), ui->pszUID,
- TranslateT("Status"), pci->TM_WordToString(si->pStatuses, ui->Status));
+ TranslateT("Nickname"), ui->pszNick,
+ TranslateT("Unique ID"), ui->pszUID,
+ TranslateT("Status"), pci->TM_WordToString(si->pStatuses, ui->Status));
ti.lpszText = tszBuf;
}
@@ -1012,7 +1012,6 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO *si static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
SESSION_INFO *si = (SESSION_INFO*)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);
- int height;
switch (msg) {
case WM_ERASEBKGND:
@@ -1025,10 +1024,10 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, if (index == LB_ERR || si->nUsersInNicklist <= 0)
return 0;
- height = SendMessage(hwnd, LB_GETITEMHEIGHT, 0, 0);
+ int height = SendMessage(hwnd, LB_GETITEMHEIGHT, 0, 0);
if (height == LB_ERR)
return 0;
-
+
RECT rc = { 0 };
GetClientRect(hwnd, &rc);
@@ -1057,7 +1056,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_MEASUREITEM:
{
- MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *) lParam;
+ MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)lParam;
if (mis->CtlType == ODT_MENU)
return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam);
}
@@ -1065,7 +1064,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_DRAWITEM:
{
- DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *) lParam;
+ DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
if (dis->CtlType == ODT_MENU)
return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam);
}
@@ -1074,6 +1073,7 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_CONTEXTMENU:
TVHITTESTINFO hti;
{
+ int height = 0;
hti.pt.x = GET_X_LPARAM(lParam);
hti.pt.y = GET_Y_LPARAM(lParam);
if (hti.pt.x == -1 && hti.pt.y == -1) {
@@ -1110,7 +1110,8 @@ static LRESULT CALLBACK NicklistSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, }
DestroyGCMenu(&hMenu, 1);
return TRUE;
- } }
+ }
+ }
break;
case WM_MOUSEMOVE:
@@ -1146,7 +1147,7 @@ static int RestoreWindowPosition(HWND hwnd, MCONTACT hContact, char * szModule, WINDOWPLACEMENT wp;
wp.length = sizeof(wp);
GetWindowPlacement(hwnd, &wp);
-
+
char szSettingName[64];
mir_snprintf(szSettingName, _countof(szSettingName), "%sx", szNamePrefix);
int x = db_get_dw(hContact, szModule, szSettingName, -1);
@@ -1159,7 +1160,7 @@ static int RestoreWindowPosition(HWND hwnd, MCONTACT hContact, char * szModule, if (x == -1)
return 0;
-
+
wp.rcNormalPosition.left = x;
wp.rcNormalPosition.top = y;
wp.rcNormalPosition.right = wp.rcNormalPosition.left + width;
@@ -1191,7 +1192,7 @@ static void __cdecl phase2(void * lParam) PostMessage(si->hWnd, GC_REDRAWLOG3, 0, 0);
}
-INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
+INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
SESSION_INFO *si = (SESSION_INFO*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
RECT rc;
@@ -1219,7 +1220,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) SendDlgItemMessage(hwndDlg, IDC_LOG, EM_AUTOURLDETECT, 1, 0);
int mask = (int)SendDlgItemMessage(hwndDlg, IDC_LOG, EM_GETEVENTMASK, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETEVENTMASK, 0, mask | ENM_LINK | ENM_MOUSEEVENTS);
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_LIMITTEXT, (WPARAM)sizeof(TCHAR)* 0x7FFFFFFF, 0);
+ SendDlgItemMessage(hwndDlg, IDC_LOG, EM_LIMITTEXT, (WPARAM)sizeof(TCHAR) * 0x7FFFFFFF, 0);
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETOLECALLBACK, 0, (LPARAM)& reOleCallback);
si->hwndStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP | SBT_TOOLTIPS, 0, 0, 0, 0, hwndDlg, NULL, g_hInst, NULL);
@@ -1266,9 +1267,9 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) }
SendMessage(hwndDlg, GC_FIXTABICONS, 0, 0);
- SendMessage(si->hwndStatus, SB_SETICON, 0,(LPARAM)hIcon);
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx( "window", TRUE ));
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconEx( "window", FALSE ));
+ SendMessage(si->hwndStatus, SB_SETICON, 0, (LPARAM)hIcon);
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIconEx("window", TRUE));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIconEx("window", FALSE));
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETBKGNDCOLOR, 0, g_Settings.crLogBackground);
@@ -1283,7 +1284,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
CHARFORMAT2 cf;
cf.cbSize = sizeof(CHARFORMAT2);
- cf.dwMask = CFM_COLOR|CFM_BOLD|CFM_UNDERLINE|CFM_BACKCOLOR;
+ cf.dwMask = CFM_COLOR | CFM_BOLD | CFM_UNDERLINE | CFM_BACKCOLOR;
cf.dwEffects = 0;
cf.crTextColor = g_Settings.MessageAreaColor;
cf.crBackColor = (COLORREF)db_get_dw(NULL, CHAT_MODULE, "ColorMessageBG", GetSysColor(COLOR_WINDOW));
@@ -1292,7 +1293,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETCHARFORMAT, (WPARAM)SCF_ALL, (LPARAM)&cf);
// nicklist
- int ih = GetTextPixelSize( _T("AQGglo"), g_Settings.UserListFont,FALSE);
+ int ih = GetTextPixelSize(_T("AQGglo"), g_Settings.UserListFont, FALSE);
int ih2 = GetTextPixelSize(_T("AQGglo"), g_Settings.UserListHeadingsFont, FALSE);
int height = db_get_b(NULL, CHAT_MODULE, "NicklistRowDist", 12);
int font = ih > ih2 ? ih : ih2;
@@ -1312,7 +1313,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) case GC_UPDATETITLE:
{
TCHAR szTemp[100];
- switch(si->iType) {
+ switch (si->iType) {
case GCW_CHATROOM:
mir_sntprintf(szTemp,
(si->nUsersInNicklist == 1) ? TranslateT("%s: chat room (%u user)") : TranslateT("%s: chat room (%u users)"),
@@ -1336,25 +1337,25 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
TCHAR* ptszDispName = mi->ptszModDispName;
int x = 12;
- x += GetTextPixelSize(ptszDispName, (HFONT)SendMessage(si->hwndStatus,WM_GETFONT,0,0), TRUE);
+ x += GetTextPixelSize(ptszDispName, (HFONT)SendMessage(si->hwndStatus, WM_GETFONT, 0, 0), TRUE);
x += GetSystemMetrics(SM_CXSMICON);
int iStatusbarParts[2] = { x, -1 };
- SendMessage(si->hwndStatus,SB_SETPARTS,2 ,(LPARAM)&iStatusbarParts);
+ SendMessage(si->hwndStatus, SB_SETPARTS, 2, (LPARAM)&iStatusbarParts);
// stupid hack to make icons show. I dunno why this is needed currently
HICON hIcon = si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon;
if (!hIcon) {
pci->MM_IconsChanged();
- hIcon = si->wStatus==ID_STATUS_ONLINE?mi->hOnlineIcon:mi->hOfflineIcon;
+ hIcon = si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon;
}
- SendMessage(si->hwndStatus, SB_SETICON, 0,(LPARAM)hIcon);
+ SendMessage(si->hwndStatus, SB_SETICON, 0, (LPARAM)hIcon);
SendMessage(hwndDlg, GC_FIXTABICONS, 0, 0);
- SendMessage(si->hwndStatus, SB_SETTEXT,0,(LPARAM)ptszDispName);
+ SendMessage(si->hwndStatus, SB_SETTEXT, 0, (LPARAM)ptszDispName);
- SendMessage(si->hwndStatus, SB_SETTEXT,1,(LPARAM)(si->ptszStatusbarText ? si->ptszStatusbarText : _T("")));
- SendMessage(si->hwndStatus, SB_SETTIPTEXT,1,(LPARAM)(si->ptszStatusbarText ? si->ptszStatusbarText : _T("")));
+ SendMessage(si->hwndStatus, SB_SETTEXT, 1, (LPARAM)(si->ptszStatusbarText ? si->ptszStatusbarText : _T("")));
+ SendMessage(si->hwndStatus, SB_SETTIPTEXT, 1, (LPARAM)(si->ptszStatusbarText ? si->ptszStatusbarText : _T("")));
}
return TRUE;
@@ -1375,15 +1376,15 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) wp.rcNormalPosition.right = wp.rcNormalPosition.left + si->iWidth;
wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + si->iHeight;
wp.showCmd = SW_HIDE;
- SetWindowPlacement(hwndDlg,&wp);
+ SetWindowPlacement(hwndDlg, &wp);
break;
}
if (savePerContact) {
- if (RestoreWindowPosition(hwndDlg, g_Settings.bTabsEnable?NULL:si->hContact, CHAT_MODULE, "room", SW_HIDE))
+ if (RestoreWindowPosition(hwndDlg, g_Settings.bTabsEnable ? NULL : si->hContact, CHAT_MODULE, "room", SW_HIDE))
break;
- SetWindowPos(hwndDlg, 0, (screen.right-screen.left)/2- (550)/2,(screen.bottom-screen.top)/2- (400)/2, (550), (400), SWP_NOZORDER |SWP_HIDEWINDOW|SWP_NOACTIVATE);
+ SetWindowPos(hwndDlg, 0, (screen.right - screen.left) / 2 - (550) / 2, (screen.bottom - screen.top) / 2 - (400) / 2, (550), (400), SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
}
- else SetWindowPos(hwndDlg, 0, (screen.right-screen.left)/2- (550)/2,(screen.bottom-screen.top)/2- (400)/2, (550), (400), SWP_NOZORDER |SWP_HIDEWINDOW|SWP_NOACTIVATE);
+ else SetWindowPos(hwndDlg, 0, (screen.right - screen.left) / 2 - (550) / 2, (screen.bottom - screen.top) / 2 - (400) / 2, (550), (400), SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
if (!g_Settings.bTabsEnable && pActive && pActive->hWnd && db_get_b(NULL, CHAT_MODULE, "CascadeWindows", 1)) {
RECT rcThis, rcNew;
@@ -1396,7 +1397,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) int offset = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);
SetWindowPos((HWND)hwndDlg, 0, rcNew.left + offset, rcNew.top + offset, rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, dwFlag);
- } }
+ }
+ }
break;
case GC_SAVEWNDPOS:
@@ -1415,7 +1417,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) si->iY = g_Settings.iY;
si->iWidth = g_Settings.iWidth;
si->iHeight = g_Settings.iHeight;
- } }
+ }
+ }
break;
case WM_SIZE:
@@ -1484,13 +1487,14 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) int total = TabCtrl_GetItemCount(GetDlgItem(hwndDlg, IDC_TAB));
int i = TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TAB));
if (i != -1 && total != -1 && total != 1) {
- if (i < total -1)
+ if (i < total - 1)
i++;
else
- i=0;
+ i = 0;
TabCtrl_SetCurSel(GetDlgItem(hwndDlg, IDC_TAB), i);
- PostMessage(hwndDlg, GC_TABCLICKED, 0, 0 );
- } }
+ PostMessage(hwndDlg, GC_TABCLICKED, 0, 0);
+ }
+ }
break;
case GC_SWITCHPREVTAB:
@@ -1501,10 +1505,11 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) if (i > 0)
i--;
else
- i=total-1;
+ i = total - 1;
TabCtrl_SetCurSel(GetDlgItem(hwndDlg, IDC_TAB), i);
- PostMessage(hwndDlg, GC_TABCLICKED, 0, 0 );
- } }
+ PostMessage(hwndDlg, GC_TABCLICKED, 0, 0);
+ }
+ }
break;
case GC_SWITCHTAB:
@@ -1513,48 +1518,53 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) int i = TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TAB));
if (i != -1 && total != -1 && total != 1 && i != lParam && total > lParam) {
TabCtrl_SetCurSel(GetDlgItem(hwndDlg, IDC_TAB), lParam);
- PostMessage(hwndDlg, GC_TABCLICKED, 0, 0 );
- } }
+ PostMessage(hwndDlg, GC_TABCLICKED, 0, 0);
+ }
+ }
break;
case GC_REMOVETAB:
{
SESSION_INFO* s2;
int i = -1;
- SESSION_INFO* s1 = (SESSION_INFO*) lParam;
+ SESSION_INFO* s1 = (SESSION_INFO*)lParam;
int tabId = TabCtrl_GetItemCount(GetDlgItem(hwndDlg, IDC_TAB));
if (s1) {
if (tabId) {
for (i = 0; i < tabId; i++) {
int ii;
- TCITEM tci = {0};
- tci.mask = TCIF_PARAM ;
+ TCITEM tci = { 0 };
+ tci.mask = TCIF_PARAM;
ii = TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB), i, &tci);
if (ii != -1) {
s2 = (SESSION_INFO*)tci.lParam;
if (s1 == s2)
goto END_REMOVETAB;
- } } }
+ }
+ }
+ }
}
else i = TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TAB));
-END_REMOVETAB:
+ END_REMOVETAB:
if (i != -1 && i < tabId) {
- TCITEM id = {0};
+ TCITEM id = { 0 };
SESSION_INFO *s;
TabCtrl_DeleteItem(GetDlgItem(hwndDlg, IDC_TAB), i);
id.mask = TCIF_PARAM;
if (!TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB), i, &id)) {
- if (!TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB), i-1, &id)) {
+ if (!TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB), i - 1, &id)) {
SendMessage(hwndDlg, WM_CLOSE, 0, 0);
break;
- } }
+ }
+ }
s = (SESSION_INFO*)id.lParam;
if (s)
pci->ShowRoom(s, (WPARAM)WINDOW_VISIBLE, wParam == 1 ? FALSE : TRUE);
- } }
+ }
+ }
break;
case GC_ADDTAB:
@@ -1567,9 +1577,9 @@ END_REMOVETAB: int lastlocked = -1;
BOOL bFound = FALSE;
SESSION_INFO* s2;
- SESSION_INFO* s1 = (SESSION_INFO*) lParam;
+ SESSION_INFO* s1 = (SESSION_INFO*)lParam;
- tci.mask = TCIF_PARAM ;
+ tci.mask = TCIF_PARAM;
tabId = TabCtrl_GetItemCount(GetDlgItem(hwndDlg, IDC_TAB));
// does the tab already exist?
@@ -1581,35 +1591,37 @@ END_REMOVETAB: if (!bFound) {
bFound = TRUE;
indexfound = i;
- } }
+ }
+ }
w = db_get_w(s2->hContact, s2->pszModule, "TabPosition", 0);
if (w)
lastlocked = (int)w;
- } }
+ }
+ }
w = 0;
if (!bFound) { // create a new tab
int insertat;
- TCHAR szTemp [30];
+ TCHAR szTemp[30];
mir_tstrncpy(szTemp, s1->ptszName, 21);
- if (mir_tstrlen(s1->ptszName) >20)
- mir_tstrncpy(szTemp+20, _T("..."), 4);
+ if (mir_tstrlen(s1->ptszName) > 20)
+ mir_tstrncpy(szTemp + 20, _T("..."), 4);
- tci.mask = TCIF_TEXT|TCIF_PARAM ;
+ tci.mask = TCIF_TEXT | TCIF_PARAM;
tci.pszText = szTemp;
tci.lParam = lParam;
// determine insert position
w = db_get_w(s1->hContact, s1->pszModule, "TabPosition", 0);
if (wParam == -1)
- insertat = w == 0?tabId:(int)w-1;
+ insertat = w == 0 ? tabId : (int)w - 1;
else
insertat = (int)wParam;
- w = TabCtrl_InsertItem( GetDlgItem(hwndDlg, IDC_TAB), insertat, &tci );
+ w = TabCtrl_InsertItem(GetDlgItem(hwndDlg, IDC_TAB), insertat, &tci);
SendMessage(hwndDlg, GC_FIXTABICONS, 0, (LPARAM)s1);
}
@@ -1618,12 +1630,13 @@ END_REMOVETAB: TabCtrl_SetCurSel(GetDlgItem(hwndDlg, IDC_TAB), indexfound);
else
TabCtrl_SetCurSel(GetDlgItem(hwndDlg, IDC_TAB), w);
- } }
+ }
+ }
break;
case GC_FIXTABICONS:
{
- SESSION_INFO *s = (SESSION_INFO*) lParam;
+ SESSION_INFO *s = (SESSION_INFO*)lParam;
if (s) {
int tabId = TabCtrl_GetItemCount(GetDlgItem(hwndDlg, IDC_TAB));
for (int i = 0; i < tabId; i++) {
@@ -1644,7 +1657,9 @@ END_REMOVETAB: tci.mask = TCIF_IMAGE;
tci.iImage = image;
TabCtrl_SetItem(GetDlgItem(hwndDlg, IDC_TAB), i, &tci);
- } } }
+ }
+ }
+ }
}
else RedrawWindow(GetDlgItem(hwndDlg, IDC_TAB), NULL, NULL, RDW_INVALIDATE);
}
@@ -1652,7 +1667,7 @@ END_REMOVETAB: case GC_SETMESSAGEHIGHLIGHT:
{
- SESSION_INFO *s = (SESSION_INFO*) lParam;
+ SESSION_INFO *s = (SESSION_INFO*)lParam;
if (s) {
int tabId = TabCtrl_GetItemCount(GetDlgItem(hwndDlg, IDC_TAB));
for (int i = 0; i < tabId; i++) {
@@ -1668,7 +1683,8 @@ END_REMOVETAB: if (g_Settings.bFlashWindowHighlight && GetActiveWindow() != hwndDlg && GetForegroundWindow() != hwndDlg)
SetTimer(hwndDlg, TIMERID_FLASHWND, 900, NULL);
break;
- } }
+ }
+ }
}
else RedrawWindow(GetDlgItem(hwndDlg, IDC_TAB), NULL, NULL, RDW_INVALIDATE);
}
@@ -1676,7 +1692,7 @@ END_REMOVETAB: case GC_SETTABHIGHLIGHT:
{
- SESSION_INFO *s = (SESSION_INFO*) lParam;
+ SESSION_INFO *s = (SESSION_INFO*)lParam;
if (s) {
int tabId = TabCtrl_GetItemCount(GetDlgItem(hwndDlg, IDC_TAB));
for (int i = 0; i < tabId; i++) {
@@ -1697,7 +1713,7 @@ END_REMOVETAB: break;
case GC_TABCHANGE:
- SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(LONG_PTR)lParam);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
PostMessage(hwndDlg, GC_SCROLLTOBOTTOM, 0, 0);
break;
@@ -1705,14 +1721,14 @@ END_REMOVETAB: {
int i = TabCtrl_GetCurSel(GetDlgItem(hwndDlg, IDC_TAB));
if (i != -1) {
- TCITEM id = {0};
+ TCITEM id = { 0 };
id.mask = TCIF_PARAM;
TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB), i, &id);
SESSION_INFO *s = (SESSION_INFO*)id.lParam;
if (s) {
if (s->wState & STATE_TALK) {
s->wState &= ~STATE_TALK;
- db_set_w(s->hContact, s->pszModule ,"ApparentMode",(LPARAM) 0);
+ db_set_w(s->hContact, s->pszModule, "ApparentMode", (LPARAM)0);
}
if (s->wState & GC_EVENT_HIGHLIGHT) {
@@ -1725,20 +1741,23 @@ END_REMOVETAB: SendMessage(hwndDlg, GC_FIXTABICONS, 0, (LPARAM)s);
if (!s->hWnd) {
pci->ShowRoom(s, (WPARAM)WINDOW_VISIBLE, TRUE);
- SendMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0 );
- } } } }
+ SendMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0);
+ }
+ }
+ }
+ }
break;
case GC_DROPPEDTAB:
{
int begin = (int)lParam;
- int end = (int) wParam;
+ int end = (int)wParam;
if (begin == end)
break;
TCITEM tci;
tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB),begin, &tci);
+ TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB), begin, &tci);
SESSION_INFO *s = (SESSION_INFO*)tci.lParam;
if (s) {
TabCtrl_DeleteItem(GetDlgItem(hwndDlg, IDC_TAB), begin);
@@ -1747,17 +1766,19 @@ END_REMOVETAB: // fix the "fixed" positions
int tabId = TabCtrl_GetItemCount(GetDlgItem(hwndDlg, IDC_TAB));
- for (int i = 0; i< tabId ; i++) {
- TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB),i, &tci);
+ for (int i = 0; i < tabId; i++) {
+ TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB), i, &tci);
s = (SESSION_INFO*)tci.lParam;
if (s && s->hContact && db_get_w(s->hContact, s->pszModule, "TabPosition", 0) != 0)
db_set_w(s->hContact, s->pszModule, "TabPosition", (WORD)(i + 1));
- } } }
+ }
+ }
+ }
break;
case GC_SESSIONNAMECHANGE:
{
- SESSION_INFO* s1 = (SESSION_INFO* ) lParam;
+ SESSION_INFO* s1 = (SESSION_INFO*)lParam;
int tabId = TabCtrl_GetItemCount(GetDlgItem(hwndDlg, IDC_TAB));
for (int i = 0; i < tabId; i++) {
TCITEM tci;
@@ -1766,10 +1787,13 @@ END_REMOVETAB: if (j != -1) {
SESSION_INFO *s2 = (SESSION_INFO*)tci.lParam;
if (s1 == s2) {
- tci.mask = TCIF_TEXT ;
+ tci.mask = TCIF_TEXT;
tci.pszText = s1->ptszName;
TabCtrl_SetItem(GetDlgItem(hwndDlg, IDC_TAB), i, &tci);
- } } } }
+ }
+ }
+ }
+ }
break;
case GC_ACKMESSAGE:
@@ -1778,34 +1802,34 @@ END_REMOVETAB: return TRUE;
case WM_CTLCOLORLISTBOX:
- SetBkColor((HDC) wParam, g_Settings.crUserListBGColor);
+ SetBkColor((HDC)wParam, g_Settings.crUserListBGColor);
return (INT_PTR)pci->hListBkgBrush;
case WM_MEASUREITEM:
{
- MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *) lParam;
+ MEASUREITEMSTRUCT *mis = (MEASUREITEMSTRUCT *)lParam;
if (mis->CtlType == ODT_MENU)
return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam);
- int ih = GetTextPixelSize( _T("AQGgl'"), g_Settings.UserListFont,FALSE);
- int ih2 = GetTextPixelSize( _T("AQGg'"), g_Settings.UserListHeadingsFont,FALSE);
- int font = ih > ih2?ih:ih2;
+ int ih = GetTextPixelSize(_T("AQGgl'"), g_Settings.UserListFont, FALSE);
+ int ih2 = GetTextPixelSize(_T("AQGg'"), g_Settings.UserListHeadingsFont, FALSE);
+ int font = ih > ih2 ? ih : ih2;
int height = db_get_b(NULL, CHAT_MODULE, "NicklistRowDist", 12);
// make sure we have space for icon!
if (g_Settings.bShowContactStatus)
font = font > 16 ? font : 16;
- mis->itemHeight = height > font?height:font;
+ mis->itemHeight = height > font ? height : font;
}
return TRUE;
case WM_DRAWITEM:
{
- DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *) lParam;
+ DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
if (dis->CtlType == ODT_MENU)
return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam);
-
+
if (dis->CtlID == IDC_LIST) {
int index = dis->itemID;
USERINFO *ui = pci->SM_GetUserFromIndex(si->ptszID, si->pszModule, index);
@@ -1815,9 +1839,8 @@ END_REMOVETAB: int height = dis->rcItem.bottom - dis->rcItem.top;
if (height & 1)
height++;
-
- int offset = (height == 10) ? 0 : height/2 - 4;
- HICON hIcon = pci->SM_GetStatusIcon(si, ui);
+
+ int offset = (height == 10) ? 0 : height / 2 - 4;
HFONT hFont = (ui->iStatusEx == 0) ? g_Settings.UserListFont : g_Settings.UserListHeadingsFont;
HFONT hOldFont = (HFONT)SelectObject(dis->hDC, hFont);
SetBkMode(dis->hDC, TRANSPARENT);
@@ -1829,24 +1852,24 @@ END_REMOVETAB: if (g_Settings.bShowContactStatus && g_Settings.bContactStatusFirst && ui->ContactStatus) {
HICON hIcon = Skin_LoadProtoIcon(si->pszModule, ui->ContactStatus);
- DrawIconEx(dis->hDC, x_offset, dis->rcItem.top+offset-3,hIcon,16,16,0,NULL, DI_NORMAL);
+ DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset - 3, hIcon, 16, 16, 0, NULL, DI_NORMAL);
x_offset += 18;
}
- DrawIconEx(dis->hDC,x_offset, dis->rcItem.top + offset,hIcon,10,10,0,NULL, DI_NORMAL);
+ DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset, pci->SM_GetStatusIcon(si, ui), 10, 10, 0, NULL, DI_NORMAL);
x_offset += 12;
if (g_Settings.bShowContactStatus && !g_Settings.bContactStatusFirst && ui->ContactStatus) {
HICON hIcon = Skin_LoadProtoIcon(si->pszModule, ui->ContactStatus);
- DrawIconEx(dis->hDC, x_offset, dis->rcItem.top+offset-3,hIcon,16,16,0,NULL, DI_NORMAL);
+ DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset - 3, hIcon, 16, 16, 0, NULL, DI_NORMAL);
x_offset += 18;
}
- SetTextColor(dis->hDC, ui->iStatusEx == 0?g_Settings.crUserListColor:g_Settings.crUserListHeadingsColor);
- TextOut(dis->hDC, dis->rcItem.left+x_offset, dis->rcItem.top, ui->pszNick, (int)mir_tstrlen(ui->pszNick));
+ SetTextColor(dis->hDC, ui->iStatusEx == 0 ? g_Settings.crUserListColor : g_Settings.crUserListHeadingsColor);
+ TextOut(dis->hDC, dis->rcItem.left + x_offset, dis->rcItem.top, ui->pszNick, (int)mir_tstrlen(ui->pszNick));
SelectObject(dis->hDC, hOldFont);
if (si->pAccPropServicesForNickList) {
wchar_t *nick = mir_t2u(ui->pszNick);
- si->pAccPropServicesForNickList->SetHwndPropStr(GetDlgItem(hwndDlg,IDC_LIST), OBJID_CLIENT, dis->itemID+1, PROPID_ACC_NAME, nick);
+ si->pAccPropServicesForNickList->SetHwndPropStr(GetDlgItem(hwndDlg, IDC_LIST), OBJID_CLIENT, dis->itemID + 1, PROPID_ACC_NAME, nick);
mir_free(nick);
}
}
@@ -1864,7 +1887,7 @@ END_REMOVETAB: }
break;
- case GC_EVENT_CONTROL + WM_USER+500:
+ case GC_EVENT_CONTROL + WM_USER + 500:
switch (wParam) {
case SESSION_OFFLINE:
SendMessage(hwndDlg, GC_UPDATESTATUSBAR, 0, 0);
@@ -1913,7 +1936,7 @@ END_REMOVETAB: case WINDOW_VISIBLE:
if (IsIconic(hwndDlg))
ShowWindow(hwndDlg, SW_NORMAL);
-LABEL_SHOWWINDOW:
+ LABEL_SHOWWINDOW:
SendMessage(hwndDlg, WM_SIZE, 0, 0);
SendMessage(hwndDlg, GC_REDRAWLOG, 0, 0);
SendMessage(hwndDlg, GC_UPDATENICKLIST, 0, 0);
@@ -1929,7 +1952,7 @@ LABEL_SHOWWINDOW: {
POINT pt;
RECT rcLog;
- BOOL bFormat = IsWindowVisible(GetDlgItem(hwndDlg,IDC_SMILEY));
+ BOOL bFormat = IsWindowVisible(GetDlgItem(hwndDlg, IDC_SMILEY));
static int x = 0;
@@ -1956,9 +1979,9 @@ LABEL_SHOWWINDOW: oldSplitterY = si->iSplitterY;
si->iSplitterY = bFormat ? rc.bottom - pt.y + 1 : rc.bottom - pt.y + 20;
- if (si->iSplitterY<63)
+ if (si->iSplitterY < 63)
si->iSplitterY = 63;
- if (si->iSplitterY>rc.bottom - rc.top - 40)
+ if (si->iSplitterY > rc.bottom - rc.top - 40)
si->iSplitterY = rc.bottom - rc.top - 40;
g_Settings.iSplitterY = si->iSplitterY;
}
@@ -1994,7 +2017,7 @@ LABEL_SHOWWINDOW: HWND hwnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_FILTER), hwndDlg, FilterWndProc, (LPARAM)si);
TranslateDialogDefault(hwnd);
GetWindowRect(GetDlgItem(hwndDlg, IDC_FILTER), &rc);
- SetWindowPos(hwnd, HWND_TOP, rc.left-85, (IsWindowVisible(GetDlgItem(hwndDlg, IDC_FILTER))||IsWindowVisible(GetDlgItem(hwndDlg, IDC_BOLD)))?rc.top-206:rc.top-186, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
+ SetWindowPos(hwnd, HWND_TOP, rc.left - 85, (IsWindowVisible(GetDlgItem(hwndDlg, IDC_FILTER)) || IsWindowVisible(GetDlgItem(hwndDlg, IDC_BOLD))) ? rc.top - 206 : rc.top - 186, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
}
break;
@@ -2004,18 +2027,18 @@ LABEL_SHOWWINDOW: case GC_SCROLLTOBOTTOM:
if ((GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_STYLE) & WS_VSCROLL) != 0) {
- SCROLLINFO si = { 0 };
- si.cbSize = sizeof(si);
- si.fMask = SIF_PAGE | SIF_RANGE;
- GetScrollInfo(GetDlgItem(hwndDlg, IDC_LOG), SB_VERT, &si);
+ SCROLLINFO scroll = { 0 };
+ scroll.cbSize = sizeof(scroll);
+ scroll.fMask = SIF_PAGE | SIF_RANGE;
+ GetScrollInfo(GetDlgItem(hwndDlg, IDC_LOG), SB_VERT, &scroll);
- si.fMask = SIF_POS;
- si.nPos = si.nMax - si.nPage + 1;
- SetScrollInfo(GetDlgItem(hwndDlg, IDC_LOG), SB_VERT, &si, TRUE);
+ scroll.fMask = SIF_POS;
+ scroll.nPos = scroll.nMax - scroll.nPage + 1;
+ SetScrollInfo(GetDlgItem(hwndDlg, IDC_LOG), SB_VERT, &scroll, TRUE);
CHARRANGE sel;
sel.cpMin = sel.cpMax = GetRichTextLength(GetDlgItem(hwndDlg, IDC_LOG));
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_EXSETSEL, 0, (LPARAM) &sel);
+ SendDlgItemMessage(hwndDlg, IDC_LOG, EM_EXSETSEL, 0, (LPARAM)&sel);
PostMessage(GetDlgItem(hwndDlg, IDC_LOG), WM_VSCROLL, MAKEWPARAM(SB_BOTTOM, 0), 0);
}
break;
@@ -2056,14 +2079,14 @@ LABEL_SHOWWINDOW: }
if (uMsg != WM_ACTIVATE)
- SetFocus(GetDlgItem(hwndDlg,IDC_MESSAGE));
+ SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
pci->SetActiveSession(si->ptszID, si->pszModule);
if (KillTimer(hwndDlg, TIMERID_FLASHWND))
FlashWindow(hwndDlg, FALSE);
- if (db_get_w(si->hContact, si->pszModule ,"ApparentMode", 0) != 0)
- db_set_w(si->hContact, si->pszModule ,"ApparentMode",(LPARAM) 0);
+ if (db_get_w(si->hContact, si->pszModule, "ApparentMode", 0) != 0)
+ db_set_w(si->hContact, si->pszModule, "ApparentMode", (LPARAM)0);
if (CallService(MS_CLIST_GETEVENT, (WPARAM)si->hContact, 0))
CallService(MS_CLIST_REMOVEEVENT, (WPARAM)si->hContact, (LPARAM)GC_FAKE_EVENT);
}
@@ -2118,17 +2141,19 @@ LABEL_SHOWWINDOW: if (s)
pci->ShowRoom(s, WINDOW_VISIBLE, TRUE);
- for(tabId; tabId >= 0; tabId --) {
+ for (tabId; tabId >= 0; tabId--) {
if (tabId == i)
continue;
TabCtrl_DeleteItem(GetDlgItem(hwndDlg, IDC_TAB), tabId);
- } } }
+ }
+ }
+ }
break;
case ID_LOCKPOSITION:
TabCtrl_GetItem(GetDlgItem(hwndDlg, IDC_TAB), i, &id);
- if (s!=0) {
+ if (s != 0) {
if (!(GetMenuState(hSubMenu, ID_LOCKPOSITION, MF_BYCOMMAND)&MF_CHECKED)) {
if (s->hContact)
db_set_w(s->hContact, s->pszModule, "TabPosition", (WORD)(i + 1));
@@ -2148,8 +2173,8 @@ LABEL_SHOWWINDOW: HMENU hMenu = 0;
TCHAR pszWord[4096];
- pt.x = (short) LOWORD(((ENLINK *) lParam)->lParam);
- pt.y = (short) HIWORD(((ENLINK *) lParam)->lParam);
+ pt.x = (short)LOWORD(((ENLINK *)lParam)->lParam);
+ pt.y = (short)HIWORD(((ENLINK *)lParam)->lParam);
ClientToScreen(((LPNMHDR)lParam)->hwndFrom, &pt);
// fixing stuff for searches
@@ -2160,7 +2185,7 @@ LABEL_SHOWWINDOW: long iCharIndex = SendDlgItemMessage(hwndDlg, IDC_LOG, EM_CHARFROMPOS, 0, (LPARAM)&ptl);
if (iCharIndex < 0)
break;
-
+
long start = SendDlgItemMessage(hwndDlg, IDC_LOG, EM_FINDWORDBREAK, WB_LEFT, iCharIndex);//-iChars;
long end = SendDlgItemMessage(hwndDlg, IDC_LOG, EM_FINDWORDBREAK, WB_RIGHT, iCharIndex);//-iChars;
@@ -2175,22 +2200,22 @@ LABEL_SHOWWINDOW: tr.lpstrText = pszWord;
long iRes = SendDlgItemMessage(hwndDlg, IDC_LOG, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
if (iRes > 0)
- for (size_t iLen = mir_tstrlen(pszWord)-1;_tcschr(szTrimString, pszWord[iLen]);iLen--)
+ for (size_t iLen = mir_tstrlen(pszWord) - 1; _tcschr(szTrimString, pszWord[iLen]); iLen--)
pszWord[iLen] = 0;
}
uID = CreateGCMenu(hwndDlg, &hMenu, 1, pt, si, NULL, pszWord);
switch (uID) {
case 0:
- PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0 );
+ PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0);
break;
case ID_COPYALL:
- SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM) &sel);
- SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) & all);
+ SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM)&sel);
+ SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM)& all);
SendMessage(((LPNMHDR)lParam)->hwndFrom, WM_COPY, 0, 0);
- SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM) &sel);
- PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0 );
+ SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM)&sel);
+ PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0);
break;
case ID_CLEARLOG:
@@ -2205,7 +2230,7 @@ LABEL_SHOWWINDOW: si->LastTime = 0;
si->pLog = s->pLog;
si->pLogEnd = s->pLogEnd;
- PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0 );
+ PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0);
}
}
break;
@@ -2225,7 +2250,7 @@ LABEL_SHOWWINDOW: break;
default:
- PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0 );
+ PostMessage(hwndDlg, WM_MOUSEACTIVATE, 0, 0);
pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_LOGMENU, NULL, NULL, (LPARAM)uID);
break;
}
@@ -2235,13 +2260,13 @@ LABEL_SHOWWINDOW: case EN_LINK:
if (((LPNMHDR)lParam)->idFrom == IDC_LOG) {
- switch (((ENLINK *) lParam)->msg) {
+ switch (((ENLINK *)lParam)->msg) {
case WM_RBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
{
CHARRANGE sel;
- SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM) &sel);
+ SendMessage(((LPNMHDR)lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM)&sel);
if (sel.cpMin != sel.cpMax)
break;
@@ -2256,16 +2281,16 @@ LABEL_SHOWWINDOW: hSubMenu = GetSubMenu(g_hMenu, 2);
TranslateMenu(hSubMenu);
- pt.x = (short) LOWORD(((ENLINK *) lParam)->lParam);
- pt.y = (short) HIWORD(((ENLINK *) lParam)->lParam);
- ClientToScreen(((NMHDR *) lParam)->hwndFrom, &pt);
+ pt.x = (short)LOWORD(((ENLINK *)lParam)->lParam);
+ pt.y = (short)HIWORD(((ENLINK *)lParam)->lParam);
+ ClientToScreen(((NMHDR *)lParam)->hwndFrom, &pt);
switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL)) {
case ID_NEW:
Utils_OpenUrlT(tr.lpstrText);
break;
case ID_CURR:
- Utils_OpenUrlT(tr.lpstrText,false);
+ Utils_OpenUrlT(tr.lpstrText, false);
break;
case ID_COPY:
@@ -2275,13 +2300,14 @@ LABEL_SHOWWINDOW: break;
EmptyClipboard();
hData = GlobalAlloc(GMEM_MOVEABLE, sizeof(TCHAR)*(mir_tstrlen(tr.lpstrText) + 1));
- mir_tstrcpy(( TCHAR* )GlobalLock(hData), tr.lpstrText);
+ mir_tstrcpy((TCHAR*)GlobalLock(hData), tr.lpstrText);
GlobalUnlock(hData);
SetClipboardData(CF_UNICODETEXT, hData);
CloseClipboard();
SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
break;
- } }
+ }
+ }
mir_free(tr.lpstrText);
return TRUE;
}
@@ -2290,7 +2316,9 @@ LABEL_SHOWWINDOW: SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
mir_free(tr.lpstrText);
break;
- } } }
+ }
+ }
+ }
break;
case TTN_NEEDTEXT:
@@ -2358,7 +2386,7 @@ LABEL_SHOWWINDOW: MODULEINFO *mi = pci->MM_FindModule(si->pszModule);
if (mi == NULL)
break;
-
+
pci->SM_AddCommand(si->ptszID, si->pszModule, pszRtf);
CMString ptszText(ptrT(mir_utf8decodeT(pszRtf)));
@@ -2375,7 +2403,7 @@ LABEL_SHOWWINDOW: EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
pci->DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0);
-
+
SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
}
break;
@@ -2399,7 +2427,7 @@ LABEL_SHOWWINDOW: case IDC_SMILEY:
GetWindowRect(GetDlgItem(hwndDlg, IDC_SMILEY), &rc);
-
+
if (SmileyAddInstalled) {
SMADD_SHOWSEL3 smaddInfo = { sizeof(smaddInfo) };
smaddInfo.hwndTarget = GetDlgItem(hwndDlg, IDC_MESSAGE);
diff --git a/src/core/stdfile/src/fileexistsdlg.cpp b/src/core/stdfile/src/fileexistsdlg.cpp index 32a7ba5b8a..ea087b0f24 100644 --- a/src/core/stdfile/src/fileexistsdlg.cpp +++ b/src/core/stdfile/src/fileexistsdlg.cpp @@ -87,12 +87,12 @@ static void DoAnnoyingShellCommand(HWND hwnd, const TCHAR *szFilename, int cmd, case C_CONTEXTMENU:
HMENU hMenu = CreatePopupMenu();
if (SUCCEEDED(pContextMenu->QueryContextMenu(hMenu, 0, 1000, 65535, (GetKeyState(VK_SHIFT) & 0x8000 ? CMF_EXTENDEDVERBS : 0) | CMF_NORMAL))) {
- int cmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, ptCursor->x, ptCursor->y, 0, hwnd, NULL);
- if (cmd) {
+ int ret = TrackPopupMenu(hMenu, TPM_RETURNCMD, ptCursor->x, ptCursor->y, 0, hwnd, NULL);
+ if (ret) {
CMINVOKECOMMANDINFO ici = { 0 };
ici.cbSize = sizeof(ici);
ici.hwnd = hwnd;
- ici.lpVerb = MAKEINTRESOURCEA(cmd - 1000);
+ ici.lpVerb = MAKEINTRESOURCEA(ret - 1000);
ici.nShow = SW_SHOW;
pContextMenu->InvokeCommand(&ici);
}
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index 4a84a67281..dabe41f5f1 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -602,11 +602,11 @@ static void NotifyTyping(SrmmWindowData *dat, int mode) CallService(MS_PROTO_SELFISTYPING, (WPARAM)dat->hContact, dat->nTypeMode);
}
-INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
SrmmWindowData *dat = (SrmmWindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (msg) {
+ switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
{
@@ -1625,7 +1625,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP // save string from the editor
if (dat->hContact) {
int len = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE)) + 1;
- TCHAR *msg = (TCHAR*)alloca(sizeof(TCHAR)* len);
+ TCHAR *msg = (TCHAR*)alloca(sizeof(TCHAR)*len);
GetDlgItemText(hwndDlg, IDC_MESSAGE, msg, len);
if (msg[0])
db_set_ts(dat->hContact, SRMSGMOD, DBSAVEDMSG, msg);
diff --git a/src/core/stduserinfo/src/contactinfo.cpp b/src/core/stduserinfo/src/contactinfo.cpp index 43f064bd0b..8a679012cd 100644 --- a/src/core/stduserinfo/src/contactinfo.cpp +++ b/src/core/stduserinfo/src/contactinfo.cpp @@ -29,7 +29,7 @@ static HCURSOR hHandCursor = NULL; static INT_PTR CALLBACK EditUserEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
if (*(char*)lParam) SetWindowText(hwndDlg, TranslateT("Edit E-Mail address"));
@@ -39,7 +39,7 @@ static INT_PTR CALLBACK EditUserEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar return TRUE;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDOK:
GetDlgItemTextA(hwndDlg, IDC_EMAIL, (char*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA), 256);
//fall through
@@ -59,7 +59,7 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar {
static int noRecursion = 0;
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
{
char *szText = (char*)lParam;
@@ -68,15 +68,15 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
if (szText[0]) SetWindowText(hwndDlg, TranslateT("Edit phone number"));
TranslateDialogDefault(hwndDlg);
- if (mir_strlen(szText)>4 && !mir_strcmp(szText+mir_strlen(szText)-4, " SMS")) {
+ if (mir_strlen(szText) > 4 && !mir_strcmp(szText + mir_strlen(szText) - 4, " SMS")) {
CheckDlgButton(hwndDlg, IDC_SMS, BST_CHECKED);
- szText[mir_strlen(szText)-4] = '\0';
+ szText[mir_strlen(szText) - 4] = '\0';
}
EnableWindow(GetDlgItem(hwndDlg, IDOK), szText[0]);
SendDlgItemMessage(hwndDlg, IDC_AREA, EM_LIMITTEXT, 31, 0);
SendDlgItemMessage(hwndDlg, IDC_NUMBER, EM_LIMITTEXT, 63, 0);
CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&countryCount, (LPARAM)&countries);
- for (i=0;i<countryCount;i++) {
+ for (i = 0; i < countryCount; i++) {
if (countries[i].id == 0 || countries[i].id == 0xFFFF) continue;
item = SendDlgItemMessageA(hwndDlg, IDC_COUNTRY, CB_ADDSTRING, 0, (LPARAM)Translate(countries[i].szName));
SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_SETITEMDATA, item, countries[i].id);
@@ -86,14 +86,15 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar return TRUE;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDOK:
- { char *szText = (char*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ {
+ char *szText = (char*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
int isValid = 1;
GetDlgItemTextA(hwndDlg, IDC_PHONE, szText, 252);
- if (mir_strlen(szText)<7 || szText[0] != '+') isValid = 0;
- if (isValid) isValid = (mir_strlen(szText+1) == (int)strspn(szText+1, "0123456789 ()-"));
- if ( !isValid) {
+ if (mir_strlen(szText) < 7 || szText[0] != '+') isValid = 0;
+ if (isValid) isValid = (mir_strlen(szText + 1) == (int)strspn(szText + 1, "0123456789 ()-"));
+ if (!isValid) {
MessageBox(hwndDlg, TranslateT("The phone number should start with a + and consist of numbers, spaces, brackets and hyphens only."), TranslateT("Invalid phone number"), MB_OK);
break;
}
@@ -132,11 +133,11 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar isValid = 0;
if (isValid) {
- int country = strtol(szText+1, &pText, 10);
+ int country = strtol(szText + 1, &pText, 10);
if (pText - szText > 4)
isValid = 0;
else {
- for (i = SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETCOUNT, 0, 0)-1; i >= 0; i--)
+ for (i = SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETCOUNT, 0, 0) - 1; i >= 0; i--)
if (country == SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_GETITEMDATA, i, 0)) {
SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_SETCURSEL, i, 0);
break;
@@ -146,16 +147,16 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar }
}
if (isValid) {
- pArea = pText+strcspn(pText, "0123456789");
- pText = pArea+strspn(pArea, "0123456789");
+ pArea = pText + strcspn(pText, "0123456789");
+ pText = pArea + strspn(pArea, "0123456789");
if (*pText) {
*pText = '\0';
- pNumber = pText+1+strcspn(pText+1, "0123456789");
+ pNumber = pText + 1 + strcspn(pText + 1, "0123456789");
SetDlgItemTextA(hwndDlg, IDC_NUMBER, pNumber);
}
SetDlgItemTextA(hwndDlg, IDC_AREA, pArea);
}
- if ( !isValid) {
+ if (!isValid) {
SendDlgItemMessage(hwndDlg, IDC_COUNTRY, CB_SETCURSEL, -1, 0);
SetDlgItemTextA(hwndDlg, IDC_AREA, "");
SetDlgItemTextA(hwndDlg, IDC_NUMBER, "");
@@ -180,7 +181,7 @@ static int IsOverEmail(HWND hwndDlg, TCHAR* szEmail, int cchEmail) RECT rc;
GetClientRect(hwndEmails, &rc);
- if ( !PtInRect(&rc, hti.pt))
+ if (!PtInRect(&rc, hti.pt))
return 0;
if (ListView_SubItemHitTest(hwndEmails, &hti) == -1)
return 0;
@@ -198,7 +199,7 @@ static int IsOverEmail(HWND hwndDlg, TCHAR* szEmail, int cchEmail) SIZE textSize;
GetTextExtentPoint32(hdc, szText, (int)mir_tstrlen(szText), &textSize);
ReleaseDC(hwndEmails, hdc);
- if (hti.pt.x < rc.left+textSize.cx) {
+ if (hti.pt.x < rc.left + textSize.cx) {
if (szEmail && cchEmail)
mir_tstrncpy(szEmail, szText, cchEmail);
return 1;
@@ -211,7 +212,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP {
int i;
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
@@ -226,19 +227,20 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (hHandCursor == NULL)
hHandCursor = LoadCursor(NULL, IDC_HAND);
{
- LVCOLUMN lvc;
RECT rc;
GetClientRect(GetDlgItem(hwndDlg, IDC_EMAILS), &rc);
- rc.right-=GetSystemMetrics(SM_CXVSCROLL);
+ rc.right -= GetSystemMetrics(SM_CXVSCROLL);
+
+ LVCOLUMN lvc;
lvc.mask = LVCF_WIDTH;
ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_EMAILS), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_PHONES), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP);
- lvc.cx = rc.right/4;
+ lvc.cx = rc.right / 4;
ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 0, &lvc);
ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 0, &lvc);
- lvc.cx = rc.right-rc.right/4-40;
+ lvc.cx = rc.right - rc.right / 4 - 40;
ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 1, &lvc);
- lvc.cx = rc.right-rc.right/4-90;
+ lvc.cx = rc.right - rc.right / 4 - 90;
ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 1, &lvc);
lvc.cx = 50;
ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 2, &lvc);
@@ -266,7 +268,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP DBVARIANT dbv;
LVITEM lvi;
- lvi.mask = LVIF_TEXT|LVIF_PARAM;
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.lParam = -1;
lvi.iSubItem = 0;
lvi.iItem = 0;
@@ -282,7 +284,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break;
lvi.pszText = idstr2;
- mir_sntprintf(idstr2, _countof(idstr2), _T("%d"), i+2);
+ mir_sntprintf(idstr2, _countof(idstr2), _T("%d"), i + 2);
}
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.ptszVal);
@@ -290,13 +292,13 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP lvi.iItem++;
}
lvi.iSubItem = 0;
- for (i=0;;i++) {
+ for (i = 0;; i++) {
lvi.lParam = i;
mir_snprintf(idstr, "Mye-mail%d", i);
if (db_get_ts(hContact, "UserInfo", idstr, &dbv))
break;
lvi.pszText = idstr2;
- mir_sntprintf(idstr2, _countof(idstr2), TranslateT("Custom %d"), i+1);
+ mir_sntprintf(idstr2, _countof(idstr2), TranslateT("Custom %d"), i + 1);
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.ptszVal);
db_free(&dbv);
@@ -307,43 +309,43 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi);
//phones
ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PHONES));
- lvi.mask = LVIF_TEXT|LVIF_PARAM;
+ lvi.mask = LVIF_TEXT | LVIF_PARAM;
lvi.lParam = -1;
lvi.iSubItem = 0;
lvi.iItem = 0;
- if ( !db_get_ts(hContact, szProto, "Phone", &dbv)) {
+ if (!db_get_ts(hContact, szProto, "Phone", &dbv)) {
lvi.pszText = TranslateT("Primary");
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal);
db_free(&dbv);
lvi.iItem++;
}
- if ( !db_get_ts(hContact, szProto, "Fax", &dbv)) {
+ if (!db_get_ts(hContact, szProto, "Fax", &dbv)) {
lvi.pszText = TranslateT("Fax");
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal);
db_free(&dbv);
lvi.iItem++;
}
- if ( !db_get_ts(hContact, szProto, "Cellular", &dbv)) {
+ if (!db_get_ts(hContact, szProto, "Cellular", &dbv)) {
lvi.pszText = TranslateT("Mobile");
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
- if (mir_strlen(dbv.pszVal)>4 && !mir_strcmp(dbv.pszVal+mir_strlen(dbv.pszVal)-4, " SMS")) {
+ if (mir_strlen(dbv.pszVal) > 4 && !mir_strcmp(dbv.pszVal + mir_strlen(dbv.pszVal) - 4, " SMS")) {
ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, _T("y"));
- dbv.ptszVal[mir_tstrlen(dbv.ptszVal)-4] = '\0';
+ dbv.ptszVal[mir_tstrlen(dbv.ptszVal) - 4] = '\0';
}
ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal);
db_free(&dbv);
lvi.iItem++;
}
- if ( !db_get_ts(hContact, szProto, "CompanyPhone", &dbv)) {
+ if (!db_get_ts(hContact, szProto, "CompanyPhone", &dbv)) {
lvi.pszText = TranslateT("Work phone");
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal);
db_free(&dbv);
lvi.iItem++;
}
- if ( !db_get_ts(hContact, szProto, "CompanyFax", &dbv)) {
+ if (!db_get_ts(hContact, szProto, "CompanyFax", &dbv)) {
lvi.pszText = TranslateT("Work fax");
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal);
@@ -351,17 +353,17 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP lvi.iItem++;
}
lvi.iSubItem = 0;
- for (i=0;; i++) {
+ for (i = 0;; i++) {
lvi.lParam = i;
mir_snprintf(idstr, "MyPhone%d", i);
if (db_get_ts(hContact, "UserInfo", idstr, &dbv))
break;
lvi.pszText = idstr2;
- mir_sntprintf(idstr2, _countof(idstr2), TranslateT("Custom %d"), i+1);
+ mir_sntprintf(idstr2, _countof(idstr2), TranslateT("Custom %d"), i + 1);
ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi);
- if (mir_tstrlen(dbv.ptszVal)>4 && !mir_tstrcmp(dbv.ptszVal+mir_tstrlen(dbv.ptszVal)-4, _T(" SMS"))) {
+ if (mir_tstrlen(dbv.ptszVal) > 4 && !mir_tstrcmp(dbv.ptszVal + mir_tstrlen(dbv.ptszVal) - 4, _T(" SMS"))) {
ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, _T("y"));
- dbv.ptszVal[mir_tstrlen(dbv.ptszVal)-4] = '\0';
+ dbv.ptszVal[mir_tstrlen(dbv.ptszVal) - 4] = '\0';
}
ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.ptszVal);
db_free(&dbv);
@@ -387,119 +389,121 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP case NM_CUSTOMDRAW:
{
NMLVCUSTOMDRAW *nm = (NMLVCUSTOMDRAW*)lParam;
- switch(nm->nmcd.dwDrawStage) {
+ switch (nm->nmcd.dwDrawStage) {
case CDDS_PREPAINT:
case CDDS_ITEMPREPAINT:
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_NOTIFYSUBITEMDRAW);
return TRUE;
- case CDDS_SUBITEM|CDDS_ITEMPREPAINT:
- {
- RECT rc;
- ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc);
- if (nm->iSubItem == 1 && nm->nmcd.hdr.idFrom == IDC_EMAILS) {
- HFONT hoFont;
- TCHAR szText[256] = {0};
- ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, _countof(szText));
- hoFont = (HFONT)SelectObject(nm->nmcd.hdc, hEmailFont);
- SetTextColor(nm->nmcd.hdc, RGB(0, 0, 255));
- DrawText(nm->nmcd.hdc, szText, -1, &rc, DT_END_ELLIPSIS|DT_LEFT|DT_NOPREFIX|DT_SINGLELINE|DT_TOP);
- SelectObject(nm->nmcd.hdc, hoFont);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
- return TRUE;
- }
-
- HICON hIcon = NULL;
- if (nm->nmcd.lItemlParam == -2 && nm->iSubItem-3 == (nm->nmcd.hdr.idFrom == IDC_PHONES))
- hIcon = Skin_LoadIcon(SKINICON_OTHER_ADDCONTACT);
- else if (nm->iSubItem>1 && nm->nmcd.lItemlParam != -1 && nm->nmcd.lItemlParam != -2) {
- static int iconResources[3] = {SKINICON_OTHER_RENAME, SKINICON_OTHER_DELETE};
- if (nm->iSubItem == 2 && nm->nmcd.hdr.idFrom == IDC_PHONES) {
- TCHAR szText[2];
- ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, _countof(szText));
- if (szText[0]) hIcon = Skin_LoadIcon(SKINICON_OTHER_SMS);
- }
- else hIcon = Skin_LoadIcon(iconResources[nm->iSubItem-3+(nm->nmcd.hdr.idFrom == IDC_EMAILS)]);
- }
- else break;
- DrawIconEx(nm->nmcd.hdc, (rc.left+rc.right-GetSystemMetrics(SM_CXSMICON))/2, (rc.top+rc.bottom-GetSystemMetrics(SM_CYSMICON))/2, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
- IcoLib_ReleaseIcon(hIcon, 0);
+ case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
+ RECT rc;
+ ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc);
+ if (nm->iSubItem == 1 && nm->nmcd.hdr.idFrom == IDC_EMAILS) {
+ HFONT hoFont;
+ TCHAR szText[256] = { 0 };
+ ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, _countof(szText));
+ hoFont = (HFONT)SelectObject(nm->nmcd.hdc, hEmailFont);
+ SetTextColor(nm->nmcd.hdc, RGB(0, 0, 255));
+ DrawText(nm->nmcd.hdc, szText, -1, &rc, DT_END_ELLIPSIS | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_TOP);
+ SelectObject(nm->nmcd.hdc, hoFont);
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
return TRUE;
}
+
+ HICON hIcon = NULL;
+ if (nm->nmcd.lItemlParam == -2 && nm->iSubItem - 3 == (nm->nmcd.hdr.idFrom == IDC_PHONES))
+ hIcon = Skin_LoadIcon(SKINICON_OTHER_ADDCONTACT);
+ else if (nm->iSubItem > 1 && nm->nmcd.lItemlParam != -1 && nm->nmcd.lItemlParam != -2) {
+ static int iconResources[3] = { SKINICON_OTHER_RENAME, SKINICON_OTHER_DELETE };
+ if (nm->iSubItem == 2 && nm->nmcd.hdr.idFrom == IDC_PHONES) {
+ TCHAR szText[2];
+ ListView_GetItemText(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, szText, _countof(szText));
+ if (szText[0]) hIcon = Skin_LoadIcon(SKINICON_OTHER_SMS);
+ }
+ else hIcon = Skin_LoadIcon(iconResources[nm->iSubItem - 3 + (nm->nmcd.hdr.idFrom == IDC_EMAILS)]);
+ }
+ else break;
+ DrawIconEx(nm->nmcd.hdc, (rc.left + rc.right - GetSystemMetrics(SM_CXSMICON)) / 2, (rc.top + rc.bottom - GetSystemMetrics(SM_CYSMICON)) / 2, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL);
+ IcoLib_ReleaseIcon(hIcon, 0);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, CDRF_SKIPDEFAULT);
+ return TRUE;
}
}
break;
case NM_CLICK:
- {
- NMLISTVIEW *nm = (NMLISTVIEW*)lParam;
- LVITEM lvi;
- TCHAR szEmail[256];
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- char *szIdTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "MyPhone%d" : "Mye-mail%d";
- LVHITTESTINFO hti;
-
- if (IsOverEmail(hwndDlg, szEmail, _countof(szEmail))) {
- TCHAR szExec[264];
- mir_sntprintf(szExec, _countof(szExec), _T("mailto:%s"), szEmail);
- ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW);
- break;
- }
- if (nm->iSubItem<2) break;
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(nm->hdr.hwndFrom, &hti.pt);
- if (ListView_SubItemHitTest(nm->hdr.hwndFrom, &hti) == -1) break;
- lvi.mask = LVIF_PARAM;
- lvi.iItem = hti.iItem;
- lvi.iSubItem = 0;
- ListView_GetItem(nm->hdr.hwndFrom, &lvi);
- if (lvi.lParam == -1) break;
- if (lvi.lParam == -2) {
- if (hti.iSubItem-3 == (nm->hdr.idFrom == IDC_PHONES)) {
- //add
- char szNewData[256] = "", idstr[33];
- DBVARIANT dbv;
- if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szNewData))
- break;
- for (int i=0;; i++) {
- mir_snprintf(idstr, szIdTemplate, i);
- if (db_get_s(hContact, "UserInfo", idstr, &dbv)) break;
- db_free(&dbv);
- }
- db_set_s(hContact, "UserInfo", idstr, szNewData);
- SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
- }
- }
- else if (hti.iSubItem-3 == (nm->hdr.idFrom == IDC_PHONES)) {
- //delete
- char idstr[33];
+ NMLISTVIEW *nm = (NMLISTVIEW*)lParam;
+ MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ char *szIdTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "MyPhone%d" : "Mye-mail%d";
+
+ TCHAR szEmail[256];
+ if (IsOverEmail(hwndDlg, szEmail, _countof(szEmail))) {
+ TCHAR szExec[264];
+ mir_sntprintf(szExec, _countof(szExec), _T("mailto:%s"), szEmail);
+ ShellExecute(hwndDlg, _T("open"), szExec, NULL, NULL, SW_SHOW);
+ break;
+ }
+ if (nm->iSubItem < 2)
+ break;
+
+ LVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(nm->hdr.hwndFrom, &hti.pt);
+ if (ListView_SubItemHitTest(nm->hdr.hwndFrom, &hti) == -1)
+ break;
+
+ LVITEM lvi;
+ lvi.mask = LVIF_PARAM;
+ lvi.iItem = hti.iItem;
+ lvi.iSubItem = 0;
+ ListView_GetItem(nm->hdr.hwndFrom, &lvi);
+ if (lvi.lParam == -1)
+ break;
+
+ if (lvi.lParam == -2) {
+ if (hti.iSubItem - 3 == (nm->hdr.idFrom == IDC_PHONES)) {
+ // add
+ char szNewData[256] = "", idstr[33];
DBVARIANT dbv;
- for (i = lvi.lParam;;i++) {
- mir_snprintf(idstr, szIdTemplate, i+1);
- if (db_get_s(hContact, "UserInfo", idstr, &dbv)) break;
+ if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES ? IDD_ADDPHONE : IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES ? EditUserPhoneDlgProc : EditUserEmailDlgProc, (LPARAM)szNewData))
+ break;
+ for (i = 0;; i++) {
mir_snprintf(idstr, szIdTemplate, i);
- db_set_s(hContact, "UserInfo", idstr, dbv.pszVal);
+ if (db_get_s(hContact, "UserInfo", idstr, &dbv)) break;
db_free(&dbv);
}
- mir_snprintf(idstr, szIdTemplate, i);
- db_unset(hContact, "UserInfo", idstr);
+ db_set_s(hContact, "UserInfo", idstr, szNewData);
SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
}
- else if (hti.iSubItem-2 == (nm->hdr.idFrom == IDC_PHONES)) {
- //edit
- char szText[256], idstr[33];
- DBVARIANT dbv;
- mir_snprintf(idstr, szIdTemplate, lvi.lParam);
+ }
+ else if (hti.iSubItem - 3 == (nm->hdr.idFrom == IDC_PHONES)) {
+ // delete
+ char idstr[33];
+ DBVARIANT dbv;
+ for (i = lvi.lParam;; i++) {
+ mir_snprintf(idstr, szIdTemplate, i + 1);
if (db_get_s(hContact, "UserInfo", idstr, &dbv)) break;
- mir_strncpy(szText, dbv.pszVal, _countof(szText));
+ mir_snprintf(idstr, szIdTemplate, i);
+ db_set_s(hContact, "UserInfo", idstr, dbv.pszVal);
db_free(&dbv);
- if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES?IDD_ADDPHONE:IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES?EditUserPhoneDlgProc:EditUserEmailDlgProc, (LPARAM)szText))
- break;
- db_set_s(hContact, "UserInfo", idstr, szText);
- SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
}
+ mir_snprintf(idstr, szIdTemplate, i);
+ db_unset(hContact, "UserInfo", idstr);
+ SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
+ }
+ else if (hti.iSubItem - 2 == (nm->hdr.idFrom == IDC_PHONES)) {
+ // edit
+ char szText[256], idstr[33];
+ DBVARIANT dbv;
+ mir_snprintf(idstr, szIdTemplate, lvi.lParam);
+ if (db_get_s(hContact, "UserInfo", idstr, &dbv)) break;
+ mir_strncpy(szText, dbv.pszVal, _countof(szText));
+ db_free(&dbv);
+ if (IDOK != DialogBoxParam(hInst, MAKEINTRESOURCE(nm->hdr.idFrom == IDC_PHONES ? IDD_ADDPHONE : IDD_ADDEMAIL), hwndDlg, nm->hdr.idFrom == IDC_PHONES ? EditUserPhoneDlgProc : EditUserEmailDlgProc, (LPARAM)szText))
+ break;
+ db_set_s(hContact, "UserInfo", idstr, szText);
+ SendMessage(hwndDlg, M_REMAKELISTS, 0, 0);
}
}
}
@@ -520,7 +524,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDCANCEL:
SendMessage(GetParent(hwndDlg), msg, wParam, lParam);
break;
diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp index 86bff8146f..5f2986bf67 100644 --- a/src/mir_core/src/modules.cpp +++ b/src/mir_core/src/modules.cpp @@ -354,8 +354,8 @@ MIR_CORE_DLL(int) UnhookEvent(HANDLE hHook) if (hHook == NULL) return 0; - int hookId = (int)hHook >> 16; - int subscriberId = ((int)hHook & 0xFFFF) - 1; + int hookId = (INT_PTR)hHook >> 16; + int subscriberId = ((INT_PTR)hHook & 0xFFFF) - 1; mir_cslock lck(csHooks); |