Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Shorten the gnu gpl licence-texts
Use macro for logging in WhatsappTray.cpp
Move logging functions in hook in seperate class
  • Loading branch information
d4koon committed Nov 14, 2020
1 parent e8c7336 commit f86cf1b
Show file tree
Hide file tree
Showing 25 changed files with 161 additions and 435 deletions.
22 changes: 2 additions & 20 deletions WhatsappTray/AboutDialog.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
/*
*
* WhatsappTray
* Copyright (C) 1998-2018 Sebastian Amann
*
* 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.
*
* 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
*
*/
/* SPDX-License-Identifier: GPL-3.0-only */
/* Copyright(C) 1998 - 2018 WhatsappTray Sebastian Amann */

#include "stdafx.h"

Expand Down
22 changes: 2 additions & 20 deletions WhatsappTray/AboutDialog.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
/*
*
* WhatsappTray
* Copyright (C) 1998-2018 Sebastian Amann
*
* 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.
*
* 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
*
*/
/* SPDX-License-Identifier: GPL-3.0-only */
/* Copyright(C) 1998 - 2018 WhatsappTray Sebastian Amann */

#pragma once

Expand Down
23 changes: 3 additions & 20 deletions WhatsappTray/AppData.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
/*
*
* WhatsappTray
* Copyright (C) 1998-2017 Sebastian Amann, Nikolay Redko, J.D. Purcell
*
* 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.
*
* 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
*
*/
/* SPDX-License-Identifier: GPL-3.0-only */
/* Copyright(C) 2018 - 2018 WhatsappTray Sebastian Amann */

#include "stdafx.h"

#include "AppData.h"
Expand Down
22 changes: 2 additions & 20 deletions WhatsappTray/AppData.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
/*
*
* WhatsappTray
* Copyright (C) 1998-2017 Sebastian Amann
*
* 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.
*
* 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
*
*/
/* SPDX-License-Identifier: GPL-3.0-only */
/* Copyright(C) 2019 - 2020 WhatsappTray Sebastian Amann */

#pragma once
#include "Enum.h"
Expand Down
22 changes: 2 additions & 20 deletions WhatsappTray/Helper.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
/*
*
* WhatsappTray
* Copyright (C) 1998-2018 Sebastian Amann
*
* 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.
*
* 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
*
*/
/* SPDX-License-Identifier: GPL-3.0-only */
/* Copyright(C) 1998 - 2018 WhatsappTray Sebastian Amann */

#include "stdafx.h"
#include "Helper.h"
Expand Down
22 changes: 2 additions & 20 deletions WhatsappTray/Helper.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
/*
*
* WhatsappTray
* Copyright (C) 1998-2018 Sebastian Amann
*
* 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.
*
* 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
*
*/
/* SPDX-License-Identifier: GPL-3.0-only */
/* Copyright(C) 1998 - 2018 WhatsappTray Sebastian Amann */

#pragma once

Expand Down
56 changes: 6 additions & 50 deletions WhatsappTray/Hook.cpp
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
/*
*
* WhatsappTray
* Copyright (C) 1998-2017 Sebastian Amann, Nikolay Redko, J.D. Purcell
*
* 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.
*
* 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
*
*/
/* SPDX-License-Identifier: GPL-3.0-only */
/* Copyright(C) 1998 - 2017 WhatsappTray Sebastian Amann */

#include "SharedDefines.h"
#include "WindowsMessage.h"
#include "WinSockClient.h"
#include "WinSockLogger.h"

#include <windows.h>
#include <iostream>
#include <sstream>
#include <windows.h>
#include <psapi.h> // OpenProcess()
//#include <shellscalingapi.h> // For dpi-scaling stuff

Expand Down Expand Up @@ -75,13 +57,9 @@ static std::string WideToUtf8(const std::wstring& inputString);
static std::string GetEnviromentVariable(const std::string& inputString);
static POINT LParamToPoint(LPARAM lParam);
static bool SendMessageToWhatsappTray(UINT message, WPARAM wParam = 0, LPARAM lParam = 0);
static void TraceString(std::string traceString);
static void TraceStream(std::ostringstream& traceBuffer);

static void StartInitThread();

#define LogString(logString, ...) TraceString(MODULE_NAME + std::string("::") + std::string(__func__) + ": " + string_format(logString, __VA_ARGS__))

/**
* @brief The entry point for the dll
*
Expand Down Expand Up @@ -183,7 +161,7 @@ static LRESULT APIENTRY RedirectedWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, L
traceBuffer << "windowTitle='" << GetWindowTitle(hwnd) << "' ";
traceBuffer << "hwnd=0x'" << std::uppercase << std::hex << hwnd << "' ";
traceBuffer << "wParam=0x'" << std::uppercase << std::hex << wParam << "' ";
TraceStream(traceBuffer);
WinSockLogger::TraceStream(traceBuffer);
}
#endif

Expand Down Expand Up @@ -447,28 +425,6 @@ static bool SendMessageToWhatsappTray(UINT message, WPARAM wParam, LPARAM lParam
return PostMessage(FindWindow(NAME, NAME), message, wParam, lParam);
}

static void TraceString(std::string traceString)
{
SocketSendMessage(traceString.c_str());

//#ifdef _DEBUG
// OutputDebugStringA(traceString.c_str());
//#endif
}

static void TraceStream(std::ostringstream& traceBuffer)
{
SocketSendMessage(traceBuffer.str().c_str());
traceBuffer.clear();
traceBuffer.str(std::string());

//#ifdef _DEBUG
// OutputDebugStringA(traceBuffer.str().c_str());
// traceBuffer.clear();
// traceBuffer.str(std::string());
//#endif
}

/**
* @brief Starts the hook-init in an seperate thread
*
Expand All @@ -489,7 +445,7 @@ void StartInitThread()

// Check the return value for success.
if (threadHandle == NULL) {
//OutputDebugStringA("Thread could not be created in Hook init-function-starter");
MessageBox(NULL, "Hook.dll::StartInitThread: Thread could not be created.", "WhatsappTray (Hook.dll)", MB_OK);
}

// Close thread handle. NOTE(SAM): For now i do not clean up the thread handle because it shouldn't be such a big deal...
Expand Down
2 changes: 2 additions & 0 deletions WhatsappTray/Hook.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@
<ItemGroup>
<ClCompile Include="WinSockClient.cpp" />
<ClCompile Include="Hook.cpp" />
<ClCompile Include="WinSockLogger.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="SharedDefines.h" />
<ClInclude Include="WinSockClient.h" />
<ClInclude Include="WinSockLogger.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
6 changes: 6 additions & 0 deletions WhatsappTray/Hook.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<ClCompile Include="WinSockClient.cpp">
<Filter>Files</Filter>
</ClCompile>
<ClCompile Include="WinSockLogger.cpp">
<Filter>Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="SharedDefines.h">
Expand All @@ -21,5 +24,8 @@
<ClInclude Include="WinSockClient.h">
<Filter>Files</Filter>
</ClInclude>
<ClInclude Include="WinSockLogger.h">
<Filter>Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
Loading

0 comments on commit f86cf1b

Please sign in to comment.