diff options
23 files changed, 2246 insertions, 0 deletions
| diff --git a/plugins/ConnectionNotify/ConnectionNotify_10.vcxproj b/plugins/ConnectionNotify/ConnectionNotify_10.vcxproj new file mode 100644 index 0000000000..f066ddbe86 --- /dev/null +++ b/plugins/ConnectionNotify/ConnectionNotify_10.vcxproj @@ -0,0 +1,220 @@ +<?xml version="1.0" encoding="utf-8"?>
 +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 +  <ItemGroup Label="ProjectConfigurations">
 +    <ProjectConfiguration Include="Debug|Win32">
 +      <Configuration>Debug</Configuration>
 +      <Platform>Win32</Platform>
 +    </ProjectConfiguration>
 +    <ProjectConfiguration Include="Debug|x64">
 +      <Configuration>Debug</Configuration>
 +      <Platform>x64</Platform>
 +    </ProjectConfiguration>
 +    <ProjectConfiguration Include="Release|Win32">
 +      <Configuration>Release</Configuration>
 +      <Platform>Win32</Platform>
 +    </ProjectConfiguration>
 +    <ProjectConfiguration Include="Release|x64">
 +      <Configuration>Release</Configuration>
 +      <Platform>x64</Platform>
 +    </ProjectConfiguration>
 +  </ItemGroup>
 +  <ItemGroup>
 +    <ClCompile Include="src\ConnectionNotify.cpp" />
 +    <ClCompile Include="src\debug.cpp" />
 +    <ClCompile Include="src\filter.cpp" />
 +    <ClCompile Include="src\netstat.cpp" />
 +    <ClCompile Include="src\pid2name.cpp" />
 +  </ItemGroup>
 +  <ItemGroup>
 +    <ClInclude Include="src\ConnectionNotify.h" />
 +    <ClInclude Include="src\debug.h" />
 +    <ClInclude Include="src\filter.h" />
 +    <ClInclude Include="src\netstat.h" />
 +    <ClInclude Include="src\pid2name.h" />
 +    <ClInclude Include="src\resource.h" />
 +    <ClInclude Include="src\version.h" />
 +  </ItemGroup>
 +  <ItemGroup>
 +    <None Include="res\add.ico" />
 +    <None Include="res\arrowdown.ico" />
 +    <None Include="res\arrowup.ico" />
 +    <None Include="res\delete_item.ico" />
 +    <None Include="res\icon1.ico" />
 +    <None Include="res\icon2.ico" />
 +  </ItemGroup>
 +  <ItemGroup>
 +    <ResourceCompile Include="res\ConnectionNotify.rc" />
 +  </ItemGroup>
 +  <PropertyGroup Label="Globals">
 +    <ProjectName>ConnectionNotify</ProjectName>
 +    <ProjectGuid>{B6FC188B-8E54-4197-9444-8BADE9AA75E2}</ProjectGuid>
 +  </PropertyGroup>
 +  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
 +    <ConfigurationType>DynamicLibrary</ConfigurationType>
 +    <CharacterSet>Unicode</CharacterSet>
 +    <WholeProgramOptimization>true</WholeProgramOptimization>
 +  </PropertyGroup>
 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
 +    <ConfigurationType>DynamicLibrary</ConfigurationType>
 +    <CharacterSet>Unicode</CharacterSet>
 +  </PropertyGroup>
 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
 +    <ConfigurationType>DynamicLibrary</ConfigurationType>
 +    <WholeProgramOptimization>true</WholeProgramOptimization>
 +    <CharacterSet>Unicode</CharacterSet>
 +  </PropertyGroup>
 +  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
 +    <ConfigurationType>DynamicLibrary</ConfigurationType>
 +    <CharacterSet>Unicode</CharacterSet>
 +  </PropertyGroup>
 +  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
 +  <ImportGroup Label="ExtensionSettings">
 +  </ImportGroup>
 +  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
 +  </ImportGroup>
 +  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
 +  </ImportGroup>
 +  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
 +  </ImportGroup>
 +  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
 +    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
 +  </ImportGroup>
 +  <PropertyGroup Label="UserMacros" />
 +  <PropertyGroup>
 +    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
 +    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
 +    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
 +    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
 +    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
 +    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
 +    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
 +    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
 +    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
 +    <IgnoreImportLibrary>true</IgnoreImportLibrary>
 +  </PropertyGroup>
 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
 +    <ClCompile>
 +      <Optimization>Disabled</Optimization>
 +      <AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
 +      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 +      <MinimalRebuild>true</MinimalRebuild>
 +      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
 +      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
 +      <WarningLevel>Level3</WarningLevel>
 +      <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
 +      <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
 +      <PrecompiledHeader>NotUsing</PrecompiledHeader>
 +      <ExceptionHandling>false</ExceptionHandling>
 +      <PrecompiledHeaderFile>
 +      </PrecompiledHeaderFile>
 +    </ClCompile>
 +    <Link>
 +      <GenerateDebugInformation>true</GenerateDebugInformation>
 +      <SubSystem>Windows</SubSystem>
 +      <RandomizedBaseAddress>false</RandomizedBaseAddress>
 +      <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
 +      <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
 +      <AdditionalDependencies>Iphlpapi.lib;Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
 +    </Link>
 +    <ResourceCompile>
 +      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 +      <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
 +    </ResourceCompile>
 +  </ItemDefinitionGroup>
 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
 +    <ClCompile>
 +      <Optimization>Full</Optimization>
 +      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
 +      <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
 +      <AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
 +      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 +      <StringPooling>true</StringPooling>
 +      <BufferSecurityCheck>false</BufferSecurityCheck>
 +      <FloatingPointModel>Fast</FloatingPointModel>
 +      <WarningLevel>Level3</WarningLevel>
 +      <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
 +      <PrecompiledHeader>NotUsing</PrecompiledHeader>
 +      <ExceptionHandling>false</ExceptionHandling>
 +      <PrecompiledHeaderFile>
 +      </PrecompiledHeaderFile>
 +    </ClCompile>
 +    <Link>
 +      <GenerateDebugInformation>true</GenerateDebugInformation>
 +      <SubSystem>Windows</SubSystem>
 +      <OptimizeReferences>true</OptimizeReferences>
 +      <EnableCOMDATFolding>true</EnableCOMDATFolding>
 +      <RandomizedBaseAddress>false</RandomizedBaseAddress>
 +      <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
 +      <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
 +      <AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
 +      <AdditionalDependencies>Iphlpapi.lib;Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
 +    </Link>
 +    <ResourceCompile>
 +      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 +      <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
 +    </ResourceCompile>
 +  </ItemDefinitionGroup>
 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
 +    <ClCompile>
 +      <Optimization>Full</Optimization>
 +      <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
 +      <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
 +      <AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
 +      <PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 +      <StringPooling>true</StringPooling>
 +      <WarningLevel>Level3</WarningLevel>
 +      <PrecompiledHeader>NotUsing</PrecompiledHeader>
 +      <ExceptionHandling>false</ExceptionHandling>
 +      <PrecompiledHeaderFile>
 +      </PrecompiledHeaderFile>
 +    </ClCompile>
 +    <Link>
 +      <OptimizeReferences>true</OptimizeReferences>
 +      <EnableCOMDATFolding>true</EnableCOMDATFolding>
 +      <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
 +      <GenerateDebugInformation>true</GenerateDebugInformation>
 +      <SubSystem>Windows</SubSystem>
 +      <RandomizedBaseAddress>false</RandomizedBaseAddress>
 +      <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
 +      <AdditionalOptions>/PDBALTPATH:%_PDB%</AdditionalOptions>
 +      <AdditionalDependencies>Iphlpapi.lib;Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
 +    </Link>
 +    <ResourceCompile>
 +      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 +      <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
 +    </ResourceCompile>
 +  </ItemDefinitionGroup>
 +  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
 +    <ClCompile>
 +      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
 +      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
 +      <AdditionalIncludeDirectories>..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
 +      <PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 +      <Optimization>Disabled</Optimization>
 +      <WarningLevel>Level3</WarningLevel>
 +      <PrecompiledHeader>NotUsing</PrecompiledHeader>
 +      <ExceptionHandling>false</ExceptionHandling>
 +      <PrecompiledHeaderFile>
 +      </PrecompiledHeaderFile>
 +    </ClCompile>
 +    <Link>
 +      <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
 +      <RandomizedBaseAddress>false</RandomizedBaseAddress>
 +      <GenerateDebugInformation>true</GenerateDebugInformation>
 +      <SubSystem>Windows</SubSystem>
 +      <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
 +      <AdditionalDependencies>Iphlpapi.lib;Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
 +    </Link>
 +    <ResourceCompile>
 +      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
 +      <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
 +    </ResourceCompile>
 +  </ItemDefinitionGroup>
 +  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
 +  <ImportGroup Label="ExtensionTargets">
 +  </ImportGroup>
 +</Project>
\ No newline at end of file diff --git a/plugins/ConnectionNotify/ConnectionNotify_10.vcxproj.filters b/plugins/ConnectionNotify/ConnectionNotify_10.vcxproj.filters new file mode 100644 index 0000000000..322d0062aa --- /dev/null +++ b/plugins/ConnectionNotify/ConnectionNotify_10.vcxproj.filters @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="utf-8"?>
 +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 +  <ItemGroup>
 +    <Filter Include="Source files">
 +      <UniqueIdentifier>{cf1940c5-1f67-4b6c-8964-345adcdc30c1}</UniqueIdentifier>
 +    </Filter>
 +    <Filter Include="Resource files">
 +      <UniqueIdentifier>{2f3c4c59-a0c6-4bfb-ae62-634579279aa6}</UniqueIdentifier>
 +    </Filter>
 +    <Filter Include="Header files">
 +      <UniqueIdentifier>{6a763351-ef34-466b-a73f-2ce593c607a8}</UniqueIdentifier>
 +    </Filter>
 +  </ItemGroup>
 +  <ItemGroup>
 +    <ClCompile Include="src\ConnectionNotify.cpp">
 +      <Filter>Source files</Filter>
 +    </ClCompile>
 +    <ClCompile Include="src\debug.cpp">
 +      <Filter>Source files</Filter>
 +    </ClCompile>
 +    <ClCompile Include="src\filter.cpp">
 +      <Filter>Source files</Filter>
 +    </ClCompile>
 +    <ClCompile Include="src\netstat.cpp">
 +      <Filter>Source files</Filter>
 +    </ClCompile>
 +    <ClCompile Include="src\pid2name.cpp">
 +      <Filter>Source files</Filter>
 +    </ClCompile>
 +  </ItemGroup>
 +  <ItemGroup>
 +    <ClInclude Include="src\ConnectionNotify.h">
 +      <Filter>Header files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="src\debug.h">
 +      <Filter>Header files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="src\filter.h">
 +      <Filter>Header files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="src\netstat.h">
 +      <Filter>Header files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="src\pid2name.h">
 +      <Filter>Header files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="src\version.h">
 +      <Filter>Header files</Filter>
 +    </ClInclude>
 +    <ClInclude Include="src\resource.h">
 +      <Filter>Header files</Filter>
 +    </ClInclude>
 +  </ItemGroup>
 +  <ItemGroup>
 +    <None Include="res\add.ico">
 +      <Filter>Resource files</Filter>
 +    </None>
 +    <None Include="res\arrowdown.ico">
 +      <Filter>Resource files</Filter>
 +    </None>
 +    <None Include="res\arrowup.ico">
 +      <Filter>Resource files</Filter>
 +    </None>
 +    <None Include="res\delete_item.ico">
 +      <Filter>Resource files</Filter>
 +    </None>
 +    <None Include="res\icon1.ico">
 +      <Filter>Resource files</Filter>
 +    </None>
 +    <None Include="res\icon2.ico">
 +      <Filter>Resource files</Filter>
 +    </None>
 +  </ItemGroup>
 +  <ItemGroup>
 +    <ResourceCompile Include="res\ConnectionNotify.rc">
 +      <Filter>Resource files</Filter>
 +    </ResourceCompile>
 +  </ItemGroup>
 +</Project>
\ No newline at end of file diff --git a/plugins/ConnectionNotify/res/ConnectionNotify.rc b/plugins/ConnectionNotify/res/ConnectionNotify.rc new file mode 100644 index 0000000000..941157b6bc --- /dev/null +++ b/plugins/ConnectionNotify/res/ConnectionNotify.rc @@ -0,0 +1,141 @@ +// Generated by ResEdit 1.5.11
 +// Copyright (C) 2006-2012
 +// http://www.resedit.net
 +
 +#include <windows.h>
 +#include <commctrl.h>
 +#include <richedit.h>
 +#include "..\src\resource.h"
 +#include "..\src\version.h"
 +
 +
 +
 +
 +//
 +// Dialog resources
 +//
 +
 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 +IDD_OPT_DIALOG DIALOGEX 0, 0, 314, 239
 +STYLE DS_MODALFRAME | DS_SHELLFONT | WS_BORDER | WS_POPUP | WS_SYSMENU
 +EXSTYLE WS_EX_WINDOWEDGE
 +FONT 8, "Ms Shell Dlg", 400, 0, 1
 +{
 +
 +    AUTOCHECKBOX    "Set popup colours", IDC_SETCOLOURS, 20, 174, 132, 10, WS_GROUP | BS_PUSHLIKE
 +    CONTROL         "Custom1", IDC_BGCOLOR, "ColourPicker", 0x50030000, 18, 185, 10, 10
 +    CONTROL         "Custom1", IDC_FGCOLOR, "ColourPicker", 0x50030000, 78, 185, 10, 9
 +    GROUPBOX        "Popup options", IDC_STATIC, 10, 164, 187, 52, WS_GROUP
 +    LTEXT           "Background", IDC_STATIC, 34, 186, 43, 8, SS_LEFT
 +    LTEXT           "Text", IDC_STATIC, 94, 187, 41, 8, SS_LEFT
 +    EDITTEXT        IDC_INTERVAL1, 60, 195, 21, 12, WS_GROUP | ES_AUTOHSCROLL
 +    RTEXT           "Close after: ", IDC_STATIC, 12, 197, 47, 9, SS_RIGHT
 +    LTEXT           "sec.(0 default, -1 disabled)", IDC_STATIC, 84, 197, 111, 8, SS_LEFT
 +    CONTROL         "", IDC_LIST_EXCEPTIONS, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_REPORT, 5, 14, 292, 104
 +    CTEXT           "", IDC_VERSION, 39, 222, 52, 9, SS_CENTER, WS_EX_STATICEDGE
 +    CONTROL         "", IDC_STATUS, WC_LISTVIEW, WS_TABSTOP | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | LVS_NOLABELWRAP | LVS_NOSORTHEADER | LVS_REPORT, 209, 131, 96, 99, WS_EX_CLIENTEDGE
 +    GROUPBOX        "Settings", IDC_STATIC, 5, 118, 196, 101
 +    AUTOCHECKBOX    "try resolve addresses", IDC_RESOLVEIP, 12, 143, 185, 8
 +    EDITTEXT        IDC_INTERVAL, 10, 154, 21, 12, ES_AUTOHSCROLL
 +    RTEXT           "Version:", IDC_STATIC, 5, 223, 34, 8, SS_RIGHT
 +    AUTOCHECKBOX    "Show notification if no filter defined", ID_CHK_DEFAULTACTION, 12, 131, 187, 8
 +    LTEXT           "Attempt interval (ms.)", IDC_STATIC, 35, 155, 163, 8, SS_LEFT
 +    PUSHBUTTON      "X", ID_DELETE, 297, 68, 16, 16, BS_ICON, WS_EX_CLIENTEDGE
 +    LTEXT           "Online mean", IDC_STATIC, 211, 122, 92, 8, SS_LEFT
 +    LTEXT           "Filters", IDC_STATIC, 6, 5, 289, 8, SS_LEFT
 +    PUSHBUTTON      "DN", ID_DOWN, 297, 52, 16, 16, BS_ICON, WS_EX_CLIENTEDGE
 +    PUSHBUTTON      "UP", ID_UP, 297, 37, 16, 16, BS_ICON, WS_EX_CLIENTEDGE
 +    PUSHBUTTON      "UP", ID_ADD, 297, 22, 16, 16, BS_ICON, WS_EX_CLIENTEDGE
 +}
 +
 +
 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 +IDD_FILTER_DIALOG DIALOG 0, 0, 266, 108
 +STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SETFOREGROUND | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
 +CAPTION "Rule editor"
 +FONT 8, "Ms Shell Dlg"
 +{
 +    LTEXT           "Application name", -1, 8, 6, 61, 8, SS_LEFT
 +    EDITTEXT        ID_TEXT_NAME, 72, 4, 140, 13, ES_AUTOHSCROLL
 +    LTEXT           "Local IP:Port", -1, 8, 24, 42, 8, SS_LEFT
 +    LTEXT           ":", -1, 213, 24, 8, 8, SS_LEFT
 +    LTEXT           ":", -1, 214, 43, 8, 8, SS_LEFT
 +    EDITTEXT        ID_TXT_LOCAL_IP, 72, 22, 140, 13, ES_AUTOHSCROLL
 +    EDITTEXT        ID_TXT_LOCAL_PORT, 217, 22, 45, 13, ES_AUTOHSCROLL
 +    EDITTEXT        ID_TXT_REMOTE_IP, 72, 40, 140, 13, ES_AUTOHSCROLL
 +    EDITTEXT        ID_TXT_REMOTE_PORT, 217, 40, 45, 13, ES_AUTOHSCROLL
 +    COMBOBOX        ID_CBO_ACTION, 72, 57, 140, 48, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWNLIST
 +    LTEXT           "Action:", -1, 8, 59, 23, 8, SS_LEFT
 +    DEFPUSHBUTTON   "OK", ID_OK, 153, 87, 52, 16
 +    PUSHBUTTON      "Cancel", ID_CANCEL, 209, 87, 52, 16
 +    LTEXT           "* and ? wildcard characters also available (for port enter number or *)", -1, 8, 76, 253, 8, SS_LEFT
 +    LTEXT           "Remote IP:Port", -1, 8, 42, 49, 8, SS_LEFT
 +}
 +
 +
 +
 +
 +
 +//
 +// Icon resources
 +//
 +LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT
 +IDI_ICON1          ICON           "icon1.ico"
 +
 +
 +LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT
 +IDI_ICON2          ICON           "icon2.ico"
 +
 +
 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 +IDI_ICON3          ICON           ".\\delete_item.ico"
 +
 +
 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 +IDI_ICON4          ICON           ".\\arrowdown.ico"
 +
 +
 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 +IDI_ICON5          ICON           ".\\arrowup.ico"
 +
 +
 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 +IDI_ICON6          ICON           ".\\add.ico"
 +
 +
 +
 +//
 +// Version Information resources
 +//
 +LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT
 +VS_VERSION_INFO VERSIONINFO
 + FILEVERSION __PLUGINVERSION_STRING
 + PRODUCTVERSION __PLUGINVERSION_STRING
 + FILEFLAGSMASK 0x17L
 +#ifdef _DEBUG
 + FILEFLAGS 0x1L
 +#else
 + FILEFLAGS 0x0L
 +#endif
 + FILEOS 0x4L
 + FILETYPE 0x2L
 + FILESUBTYPE 0x0L
 +BEGIN
 +    BLOCK "StringFileInfo"
 +    BEGIN
 +        BLOCK "000004b0"
 +        BEGIN
 +            VALUE "CompanyName", __AUTHOR
 +            VALUE "FileDescription", __DESCRIPTION
 +            VALUE "InternalName", __PLUGIN_DISPLAY_NAME
 +            VALUE "LegalCopyright", __COPYRIGHT
 +            VALUE "LegalTrademarks", __COPYRIGHT
 +            VALUE "FileVersion", __VERSION_STRING
 +            VALUE "ProductVersion", __VERSION_STRING
 +        END
 +    END
 +    BLOCK "VarFileInfo"
 +    BEGIN
 +        VALUE "Translation", 0x0, 1200
 +    END
 +END
 diff --git a/plugins/ConnectionNotify/res/ConnectionNotify.~res b/plugins/ConnectionNotify/res/ConnectionNotify.~resBinary files differ new file mode 100644 index 0000000000..b8e1388b9a --- /dev/null +++ b/plugins/ConnectionNotify/res/ConnectionNotify.~res diff --git a/plugins/ConnectionNotify/res/add.ico b/plugins/ConnectionNotify/res/add.icoBinary files differ new file mode 100644 index 0000000000..f268257851 --- /dev/null +++ b/plugins/ConnectionNotify/res/add.ico diff --git a/plugins/ConnectionNotify/res/arrowdown.ico b/plugins/ConnectionNotify/res/arrowdown.icoBinary files differ new file mode 100644 index 0000000000..6d78998710 --- /dev/null +++ b/plugins/ConnectionNotify/res/arrowdown.ico diff --git a/plugins/ConnectionNotify/res/arrowup.ico b/plugins/ConnectionNotify/res/arrowup.icoBinary files differ new file mode 100644 index 0000000000..42200e793d --- /dev/null +++ b/plugins/ConnectionNotify/res/arrowup.ico diff --git a/plugins/ConnectionNotify/res/connectionnotify.png b/plugins/ConnectionNotify/res/connectionnotify.pngBinary files differ new file mode 100644 index 0000000000..95288d0cce --- /dev/null +++ b/plugins/ConnectionNotify/res/connectionnotify.png diff --git a/plugins/ConnectionNotify/res/delete_item.ico b/plugins/ConnectionNotify/res/delete_item.icoBinary files differ new file mode 100644 index 0000000000..235b015610 --- /dev/null +++ b/plugins/ConnectionNotify/res/delete_item.ico diff --git a/plugins/ConnectionNotify/res/icon1.ico b/plugins/ConnectionNotify/res/icon1.icoBinary files differ new file mode 100644 index 0000000000..a67cf791ee --- /dev/null +++ b/plugins/ConnectionNotify/res/icon1.ico diff --git a/plugins/ConnectionNotify/res/icon2.ico b/plugins/ConnectionNotify/res/icon2.icoBinary files differ new file mode 100644 index 0000000000..7166008d03 --- /dev/null +++ b/plugins/ConnectionNotify/res/icon2.ico diff --git a/plugins/ConnectionNotify/src/ConnectionNotify.cpp b/plugins/ConnectionNotify/src/ConnectionNotify.cpp new file mode 100644 index 0000000000..797a458851 --- /dev/null +++ b/plugins/ConnectionNotify/src/ConnectionNotify.cpp @@ -0,0 +1,1097 @@ +#include <windows.h>
 +//#include <stdio.h>
 +#include <tchar.h>
 +#include <Commctrl.h>
 +#include <assert.h>
 +#include "pid2name.h"
 +
 +
 +#ifdef _DEBUG
 +#include "debug.h"
 +#endif
 +
 +#include "resource.h"
 +
 +
 +#include <newpluginapi.h>
 +
 +#include <m_clist.h>
 +#include <m_skin.h>
 +#include <m_database.h>
 +#include <m_langpack.h>
 +//#include <m_plugins.h>
 +#include <m_options.h>
 +#include <m_popup.h>
 +#include <m_utils.h>
 +#include <m_protomod.h>
 +#include <m_protosvc.h>
 +#include <m_system.h>
 +//#include <m_updater.h>
 +
 +#include "ConnectionNotify.h"
 +#include "netstat.h"
 +#include "filter.h"
 +#include "version.h"
 +
 +#define MAX_SETTING_STR 512
 +#define PLUGINNAME "ConnectionNotify"
 +
 +#define STATUS_COUNT 9
 +
 +HINSTANCE hInst;
 +
 +//PLUGINLINK *pluginLink=NULL;
 +HANDLE hOptInit=NULL;
 +static HWND hTimerWnd = (HWND)NULL;
 +static UINT TID = (UINT)12021;
 +//HANDLE hHookModulesLoaded=NULL;
 +HANDLE hCheckEvent=NULL;
 +HANDLE hCheckHook=NULL;
 +HANDLE hHookModulesLoaded=NULL;
 +HANDLE hHookPreShutdown=NULL;
 +HANDLE hConnectionCheckThread = NULL;
 +HANDLE hFilterOptionsThread=NULL;
 +HANDLE killCheckThreadEvent=NULL;
 +HANDLE hExceptionsMutex=NULL;
 +//HANDLE hCurrentEditMutex=NULL;
 +int hLangpack=0;
 +
 +DWORD FilterOptionsThreadId;
 +DWORD ConnectionCheckThreadId;
 +BYTE settingSetColours=0;
 +COLORREF settingBgColor;
 +COLORREF settingFgColor;
 +int settingInterval=0;
 +int settingInterval1=0;
 +BYTE settingResolveIp=0;
 +BOOL settingStatus[STATUS_COUNT];
 +int settingFiltersCount=0;
 +BOOL settingDefaultAction=TRUE;
 +WORD settingStatusMask=0;
 +
 +struct CONNECTION *first=NULL;
 +struct CONNECTION *connExceptions=NULL;
 +struct CONNECTION *connCurrentEdit;
 +struct CONNECTION *connExceptionsTmp=NULL;
 +struct CONNECTION *connCurrentEditModal=NULL;
 +int currentStatus = ID_STATUS_OFFLINE,diffstat=0;
 +BOOL bOptionsOpen=FALSE;
 +TCHAR *tcpStates[]={_T("CLOSED"),_T("LISTEN"),_T("SYN_SENT"),_T("SYN_RCVD"),_T("ESTAB"),_T("FIN_WAIT1"),_T("FIN_WAIT2"),_T("CLOSE_WAIT"),_T("CLOSING"),_T("LAST_ACK"),_T("TIME_WAIT"),_T("DELETE_TCB")};
 +PLUGININFOEX pluginInfo={
 +	sizeof(PLUGININFOEX),
 +	PLUGINNAME,
 +	PLUGIN_MAKE_VERSION(0,1,0,5),
 +	"Notify with popup if some connection established",
 +	"MaKaR",
 +	"makar@poczta.of.pl",
 +	"© 2011-2013 MaKaRSoFT",
 +	"http://maciej.wycik.pl/miranda",
 +	UNICODE_AWARE,		//not transient
 +	//	4BB5B4AA-C364-4F23-9746-D5B708A286A5
 +	{0x4bb5b4aa, 0xc364, 0x4f23, { 0x97, 0x46, 0xd5, 0xb7, 0x8, 0xa2, 0x86, 0xa5 } }
 +};
 +
 +extern "C" __declspec(dllexport) const MUUID interfaces[]={MIID_CONNECTIONNOTIFY,MIID_PROTOCOL, MIID_LAST};
 +
 +// authentication callback futnction from extension manager
 +// ======================================
 +//=========================================================================================
 +
 +
 +BOOL strrep(TCHAR *src,TCHAR *needle,TCHAR *newstring)
 +{
 +	TCHAR *found,begining[MAX_SETTING_STR],tail[MAX_SETTING_STR];
 +	int pos=0;
 +
 +	//strset(begining,' ');
 +	//strset(tail,' ');
 +	if(!(found=_tcsstr(src,needle)))
 +		return FALSE;
 +
 +	pos=(int)(found-src);
 +	_tcsncpy_s(begining,_countof(begining),src,pos);
 +	begining[pos]='\0';
 +
 +	pos=pos+(int)_tcslen(needle);
 +	_tcsncpy_s(tail,_countof(tail),src+pos,sizeof(tail));
 +	begining[pos]='\0';
 +
 +	pos=mir_sntprintf(src,_tcslen(src),_T("%s%s%s"),begining,newstring,tail);
 +	return TRUE;
 +}
 +/*miranda IM
 +__declspec(dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion)
 +{
 +	if(mirandaVersion<PLUGIN_MAKE_VERSION(0,1,0,1)) return NULL;
 +	pluginInfo.cbSize=sizeof(PLUGININFO); // needed as v0.6 does equality check 
 +	return (PLUGININFO*)&pluginInfo;
 +}
 +*/
 +
 +extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
 +{
 +	pluginInfo.cbSize=sizeof(PLUGININFOEX);
 +	return &pluginInfo;
 +}
 +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
 +{
 +	return interfaces;
 +}
 +void saveSettingsConnections(struct CONNECTION *connHead)
 +{
 +	char buff[128];
 +	int i=0;
 +	struct CONNECTION *tmp=connHead;
 +	while(tmp!=NULL)
 +	{
 +
 +		mir_snprintf(buff,sizeof(buff), "%dFilterIntIp", i);
 +		db_set_ts(NULL, PLUGINNAME, buff, tmp->strIntIp);
 +		mir_snprintf(buff,sizeof(buff), "%dFilterExtIp", i);
 +		db_set_ts(NULL, PLUGINNAME, buff, tmp->strExtIp);
 +		mir_snprintf(buff,sizeof(buff), "%dFilterPName", i);
 +		db_set_ws(NULL, PLUGINNAME, buff, tmp->PName);
 +		mir_snprintf(buff,sizeof(buff), "%dFilterIntPort", i);
 +		db_set_dw(NULL, PLUGINNAME, buff, tmp->intIntPort);
 +		mir_snprintf(buff,sizeof(buff), "%dFilterExtPort", i);
 +		db_set_dw(NULL, PLUGINNAME, buff, tmp->intExtPort);
 +		mir_snprintf(buff,sizeof(buff), "%dFilterAction", i);
 +		db_set_dw(NULL, PLUGINNAME, buff, tmp->Pid);
 +		i++;
 +		tmp=tmp->next;
 +	}
 +	settingFiltersCount=i;
 +	db_set_dw(NULL, PLUGINNAME, "FiltersCount", settingFiltersCount );
 +	
 +}
 +//load filters from db
 +struct CONNECTION* LoadSettingsConnections()
 +{
 +	struct CONNECTION *connHead=NULL;
 +	DBVARIANT dbv;
 +	char buff[128];
 +	int i=0;
 +	for(i=settingFiltersCount-1;i>=0;i--)
 +	{
 +		struct CONNECTION *conn=(struct CONNECTION*)mir_alloc(sizeof(struct CONNECTION));
 +		mir_snprintf(buff,sizeof(buff), "%dFilterIntIp", i);
 +		if(!db_get_ts(NULL, PLUGINNAME, buff, &dbv))
 +		wcsncpy(conn->strIntIp,dbv.ptszVal,_countof(conn->strIntIp) );
 +		db_free(&dbv);
 +		mir_snprintf(buff,sizeof(buff), "%dFilterExtIp", i);
 +		if(!db_get_ts(NULL, PLUGINNAME, buff, &dbv))
 +		wcsncpy(conn->strExtIp,dbv.ptszVal,_countof(conn->strExtIp) );
 +		db_free(&dbv);
 +		mir_snprintf(buff,sizeof(buff), "%dFilterPName", i);
 +		if(!db_get_ts(NULL, PLUGINNAME, buff, &dbv))
 +		wcsncpy(conn->PName,dbv.ptszVal,_countof(conn->PName) );
 +		db_free(&dbv);
 +				
 +		mir_snprintf(buff,sizeof(buff), "%dFilterIntPort", i);
 +		conn->intIntPort = db_get_dw(0, PLUGINNAME, buff, -1);
 +		
 +		mir_snprintf(buff,sizeof(buff), "%dFilterExtPort", i);
 +		conn->intExtPort = db_get_dw(0, PLUGINNAME, buff, -1);
 +
 +		mir_snprintf(buff,sizeof(buff), "%dFilterAction", i);
 +		conn->Pid = db_get_dw(0, PLUGINNAME, buff, 0);
 +
 +		conn->next = connHead;
 +		connHead=conn;
 +	}
 +	return connHead;
 +}
 +//called to load settings from database
 +void LoadSettings()
 +{
 +	char buff[128];
 +	int i;
 +	settingInterval=(INT)db_get_dw(NULL, PLUGINNAME, "Interval", 500);
 +	settingInterval1=(INT)db_get_dw (NULL, PLUGINNAME, "PopupInterval", 0);
 +	settingResolveIp=db_get_b  (NULL, PLUGINNAME, "ResolveIp",TRUE);
 +	settingDefaultAction=db_get_b  (NULL, PLUGINNAME, "FilterDefaultAction",TRUE);
 +	
 +	settingSetColours=db_get_b  (NULL, PLUGINNAME, "PopupSetColours",0);
 +	settingBgColor = (COLORREF)db_get_dw(NULL, PLUGINNAME, "PopupBgColor", (DWORD)0xFFFFFF);
 +	settingFgColor = (COLORREF)db_get_dw(NULL, PLUGINNAME, "PopupFgColor", (DWORD)0x000000);
 +	settingFiltersCount=(INT)db_get_dw (NULL, PLUGINNAME, "FiltersCount", 0);
 +	settingStatusMask=(WORD)db_get_w(NULL, PLUGINNAME, "StatusMask", 16);
 +	for(i = 0; i < STATUS_COUNT; i++) 
 +	{
 +		mir_snprintf(buff,sizeof(buff), "Status%d", i);
 +		settingStatus[i] = (db_get_b(0, PLUGINNAME, buff, 0) == 1);
 +	}
 +	//lookupLotusDefaultSettings();
 +}
 +
 +void fillExceptionsListView(HWND hwndDlg)
 +{
 +	HWND hwndList=NULL;
 +	LVITEM lvI={0};
 +
 +	int i=0;
 +	struct CONNECTION *tmp=connExceptionsTmp;
 +	hwndList = GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS);
 +	ListView_DeleteAllItems(hwndList);
 +
 +	// Some code to create the list-view control.
 +	// Initialize LVITEM members that are common to all
 +	// items. 
 +	lvI.mask = LVIF_TEXT;
 +	i=0;
 +	while(tmp)
 +	{
 +		TCHAR tmpAddress[25];
 +		lvI.iItem=i++;
 +		lvI.iSubItem=0;
 +		lvI.pszText=tmp->PName;
 +		ListView_InsertItem(hwndList, &lvI);
 +		lvI.iSubItem=1;
 +		if(tmp->intIntPort==-1)
 +			mir_sntprintf(tmpAddress,_countof(tmpAddress),_T("%s:*"),tmp->strIntIp);
 +		else
 +			mir_sntprintf(tmpAddress,_countof(tmpAddress),_T("%s:%d"),tmp->strIntIp,tmp->intIntPort);
 +		lvI.pszText=tmpAddress;
 +		ListView_SetItem(hwndList, &lvI);
 +		lvI.iSubItem=2;
 +		if(tmp->intExtPort==-1)
 +			mir_sntprintf(tmpAddress,_countof(tmpAddress),_T("%s:*"),tmp->strExtIp);
 +		else
 +			mir_sntprintf(tmpAddress,_countof(tmpAddress),_T("%s:%d"),tmp->strExtIp,tmp->intExtPort);
 +		lvI.pszText=tmpAddress;
 +		ListView_SetItem(hwndList, &lvI);
 +		lvI.iSubItem=3;
 +		lvI.pszText=mir_a2t(tmp->Pid?"Show":"Hide");
 +		ListView_SetItem(hwndList, &lvI);
 +
 +		tmp=tmp->next;
 +	}
 +			
 +}
 +//filter editor dialog box procedure opened modally from options dialog
 +static int CALLBACK FilterEditProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 +{
 +	switch(message) 
 +	{
 +		case WM_INITDIALOG:
 +			{
 +			struct CONNECTION *conn=(struct CONNECTION*)lParam;
 +			TranslateDialogDefault(hWnd);
 +			connCurrentEditModal=conn;
 +			SetDlgItemText(hWnd, ID_TEXT_NAME,conn->PName);
 +			SetDlgItemText(hWnd, ID_TXT_LOCAL_IP,conn->strIntIp);
 +			SetDlgItemText(hWnd, ID_TXT_REMOTE_IP,conn->strExtIp);
 +
 +			if(conn->intIntPort==-1)
 +				SetDlgItemText(hWnd, ID_TXT_LOCAL_PORT,_T("*"));
 +			else
 +				SetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT,conn->intIntPort,FALSE);
 +
 +			if(conn->intExtPort==-1)
 +				SetDlgItemText(hWnd, ID_TXT_REMOTE_PORT,_T("*"));
 +			else
 +				SetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT,conn->intExtPort,FALSE);
 +
 +			SendDlgItemMessage(hWnd, ID_CBO_ACTION , CB_ADDSTRING, 0, (LPARAM)TranslateT("Always show popup"));
 +			SendDlgItemMessage(hWnd, ID_CBO_ACTION , CB_ADDSTRING, 0, (LPARAM)TranslateT("Never show popup"));
 +			SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_SETCURSEL ,conn->Pid==0?1:0,0);
 +			return TRUE;
 +			}
 +		case WM_COMMAND:
 +			switch(LOWORD(wParam))
 +				{
 +				case ID_OK:
 +					{
 +					TCHAR tmpPort[6];
 +					GetDlgItemText(hWnd, ID_TXT_LOCAL_PORT, tmpPort, sizeof(tmpPort));
 +					if (tmpPort[0]=='*')
 +						connCurrentEditModal->intIntPort=-1;
 +					else
 +						connCurrentEditModal->intIntPort=GetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT, NULL, FALSE);
 +					GetDlgItemText(hWnd, ID_TXT_REMOTE_PORT, tmpPort, sizeof(tmpPort));
 +					if (tmpPort[0]=='*')
 +						connCurrentEditModal->intExtPort=-1;
 +					else
 +						connCurrentEditModal->intExtPort = GetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT, NULL, FALSE);
 +					
 +					GetDlgItemText(hWnd, ID_TXT_LOCAL_IP, connCurrentEditModal->strIntIp, sizeof(connCurrentEditModal->strIntIp));
 +					GetDlgItemText(hWnd, ID_TXT_REMOTE_IP, connCurrentEditModal->strExtIp, sizeof(connCurrentEditModal->strExtIp));
 +					GetDlgItemText(hWnd, ID_TEXT_NAME, connCurrentEditModal->PName, sizeof(connCurrentEditModal->PName));
 +
 +					connCurrentEditModal->Pid=!(BOOL)SendMessage(GetDlgItem(hWnd,ID_CBO_ACTION),CB_GETCURSEL, 0, 0);
 +					
 +					connCurrentEditModal=NULL;
 +					EndDialog(hWnd,IDOK);
 +					return TRUE;
 +					}
 +				case ID_CANCEL:
 +					connCurrentEditModal=NULL;
 +					EndDialog(hWnd,IDCANCEL);
 +					return TRUE;
 +				}
 +			return FALSE;
 +			break;
 +		case WM_CLOSE:
 +		{
 +			connCurrentEditModal=NULL;
 +			EndDialog(hWnd,IDCANCEL);
 +			break;
 +		}
 +	}
 +	return FALSE;
 +}
 +
 +//options page on miranda called
 +BOOL CALLBACK DlgProcConnectionNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 +{
 +	HWND hwndList;
 +	switch(msg)
 +	{
 +		case WM_INITDIALOG://initialize dialog, so set properties from db.
 +		{
 +
 +			LVCOLUMN lvc={0};
 +			LVITEM lvI={0};
 +			char *strptr;
 +			char buff[256];
 +			int i=0;
 +			struct CONNECTION *tmp=connExceptions;
 +			bOptionsOpen=TRUE;
 +			TranslateDialogDefault(hwndDlg);//translate miranda function
 +			mir_snprintf(buff,sizeof(buff),"%d.%d.%d.%d", HIBYTE(HIWORD(pluginInfo.version)), LOBYTE(HIWORD(pluginInfo.version)), HIBYTE(LOWORD(pluginInfo.version)), LOBYTE(LOWORD(pluginInfo.version)));
 +#ifdef WIN64
 +			strncat(buff,"/64",strlen("/64"));
 +#else
 +			strncat(buff,"/32",strlen("/32"));
 +#endif
 +			SetDlgItemText(hwndDlg, IDC_VERSION, mir_a2t(buff));
 +			LoadSettings();
 +			//connExceptionsTmp=LoadSettingsConnections();
 +			SetDlgItemInt(hwndDlg, IDC_INTERVAL , settingInterval,FALSE);
 +			SetDlgItemInt(hwndDlg, IDC_INTERVAL1 , settingInterval1,TRUE);
 +			CheckDlgButton(hwndDlg, IDC_SETCOLOURS, settingSetColours ? TRUE : FALSE);
 +			CheckDlgButton(hwndDlg, IDC_RESOLVEIP, settingResolveIp ? TRUE : FALSE);
 +			CheckDlgButton(hwndDlg, ID_CHK_DEFAULTACTION, settingDefaultAction ? TRUE : FALSE);
 +
 +			SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingBgColor);
 +			SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingFgColor);
 +			if(!settingSetColours) 
 +			{
 +				HWND hwnd = GetDlgItem(hwndDlg, IDC_BGCOLOR);
 +				CheckDlgButton(hwndDlg, IDC_SETCOLOURS, FALSE);
 +				EnableWindow(hwnd, FALSE);
 +				hwnd = GetDlgItem(hwndDlg, IDC_FGCOLOR);
 +				EnableWindow(hwnd, FALSE);
 +			}
 +			SendDlgItemMessage(hwndDlg, ID_ADD, BM_SETIMAGE, (WPARAM)IMAGE_ICON, ( LPARAM )LoadImage(hInst,MAKEINTRESOURCE(IDI_ICON6),IMAGE_ICON,16,16,0));
 +			SendDlgItemMessage(hwndDlg, ID_DELETE, BM_SETIMAGE, (WPARAM)IMAGE_ICON, ( LPARAM )LoadImage(hInst,MAKEINTRESOURCE(IDI_ICON3),IMAGE_ICON,16,16,0));	
 +			SendDlgItemMessage(hwndDlg, ID_DOWN, BM_SETIMAGE, (WPARAM)IMAGE_ICON, ( LPARAM )LoadImage(hInst,MAKEINTRESOURCE(IDI_ICON4),IMAGE_ICON,16,16,0));
 +			SendDlgItemMessage(hwndDlg, ID_UP, BM_SETIMAGE, (WPARAM)IMAGE_ICON, ( LPARAM )LoadImage(hInst,MAKEINTRESOURCE(IDI_ICON5),IMAGE_ICON,16,16,0));
 +			// initialise and fill listbox
 +			hwndList = GetDlgItem(hwndDlg, IDC_STATUS);
 +			ListView_DeleteAllItems(hwndList);
 +			SendMessage(hwndList,LVM_SETEXTENDEDLISTVIEWSTYLE, 0,LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
 +			// Initialize the LVCOLUMN structure.
 +			// The mask specifies that the format, width, text, and
 +			// subitem members of the structure are valid. 
 +			lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; 
 +			lvc.fmt = LVCFMT_LEFT;
 +			lvc.iSubItem = 0;
 +			lvc.pszText = mir_a2t(Translate("Status"));	
 +			lvc.cx = 120;     // width of column in pixels
 +			ListView_InsertColumn(hwndList, 0, &lvc);
 +			// Some code to create the list-view control.
 +			// Initialize LVITEM members that are common to all
 +			// items. 
 +			lvI.mask = LVIF_TEXT;
 +			for(i = 0; i < STATUS_COUNT; i++) 
 +			{
 +				strptr = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)(ID_STATUS_ONLINE + i), (LPARAM)0);
 +				//MultiByteToWideChar((int)CallService(MS_LANGPACK_GETCODEPAGE, 0, 0), 0, strptr, -1, buff, 256);
 +				lvI.pszText= mir_a2t(strptr);
 +				lvI.iItem = i;
 +				ListView_InsertItem(hwndList, &lvI);
 +				ListView_SetCheckState(hwndList, i, settingStatus[i]);
 +			}
 +
 +
 +			connExceptionsTmp=LoadSettingsConnections();
 +			hwndList = GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS);
 +			SendMessage(hwndList,LVM_SETEXTENDEDLISTVIEWSTYLE, 0,LVS_EX_FULLROWSELECT);
 +
 +			lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; 
 +			lvc.fmt = LVCFMT_LEFT;
 +			lvc.iSubItem = 0;
 +			lvc.cx = 120;     // width of column in pixels
 +			lvc.pszText = mir_a2t(Translate("Application"));
 +			ListView_InsertColumn(hwndList, 1, &lvc);
 +			lvc.pszText = mir_a2t(Translate("Internal socket"));	
 +			ListView_InsertColumn(hwndList, 2, &lvc);
 +			lvc.pszText = mir_a2t(Translate("External socket"));
 +			ListView_InsertColumn(hwndList, 3, &lvc);
 +			lvc.pszText = mir_a2t(Translate("Action"));
 +			lvc.cx = 50;
 +			ListView_InsertColumn(hwndList, 4, &lvc);
 +
 +			//fill exceptions list
 +			fillExceptionsListView(hwndDlg);
 +				
 +			break;
 +		}
 +		case WM_COMMAND://user changed something, so get changes to variables
 +			PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
 +			switch(LOWORD(wParam))
 +			{
 +				case IDC_INTERVAL: settingInterval =GetDlgItemInt(hwndDlg, IDC_INTERVAL, NULL, FALSE); break;
 +				case IDC_INTERVAL1: settingInterval1 =GetDlgItemInt(hwndDlg, IDC_INTERVAL1, NULL, TRUE); break;
 +				case IDC_RESOLVEIP: settingResolveIp=(BYTE) IsDlgButtonChecked(hwndDlg, IDC_RESOLVEIP); break;
 +				case ID_CHK_DEFAULTACTION: settingDefaultAction=(BYTE) IsDlgButtonChecked(hwndDlg, ID_CHK_DEFAULTACTION); break;
 +				case ID_ADD:
 +				{
 +					struct CONNECTION *cur=(struct CONNECTION *)mir_alloc(sizeof(struct CONNECTION));
 +					memset(cur,0,sizeof(struct CONNECTION));
 +					cur->intExtPort=-1;
 +					cur->intIntPort=-1;
 +					cur->Pid=0;
 +					cur->PName[0]='*';
 +					cur->strExtIp[0]='*';
 +					cur->strIntIp[0]='*';
 +
 +					if(DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), hwndDlg, (DLGPROC)FilterEditProc, (LPARAM)cur)==IDCANCEL)
 +					{
 +						mir_free(cur);
 +						cur=NULL;
 +					}
 +					else
 +					{
 +						cur->next=connExceptionsTmp;
 +						connExceptionsTmp=cur;
 +					}
 +
 +					fillExceptionsListView(hwndDlg);
 +					ListView_SetItemState(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS),0,LVNI_FOCUSED|LVIS_SELECTED , LVNI_FOCUSED|LVIS_SELECTED );
 +					SetFocus(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS));
 +					break;
 +				}
 +				case ID_DELETE: 
 +				{
 +					int pos,pos1;
 +					struct CONNECTION *cur=NULL,*pre=NULL;
 +
 +					cur=connExceptionsTmp;
 +
 +					pos=(int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS),-1,LVNI_FOCUSED );
 +					if(pos==-1)break;
 +					pos1=pos;
 +					while(pos--)
 +					{
 +						pre=cur;
 +						cur=cur->next;
 +					}
 +					if (pre==NULL)
 +						connExceptionsTmp=connExceptionsTmp->next;
 +					else
 +						(pre)->next=cur->next;
 +					mir_free(cur);
 +					fillExceptionsListView(hwndDlg);
 +					ListView_SetItemState(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS),pos1,LVNI_FOCUSED|LVIS_SELECTED , LVNI_FOCUSED|LVIS_SELECTED );
 +					SetFocus(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS));
 +					break;
 +				}
 +				case ID_UP: 
 +				{
 +					int pos,pos1;
 +					struct CONNECTION *cur=NULL,*pre=NULL,*prepre=NULL;
 +
 +					cur=connExceptionsTmp;
 +
 +					pos=(int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS),-1,LVNI_FOCUSED );
 +					if(pos==-1)break;
 +					pos1=pos;
 +					while(pos--)
 +					{
 +						prepre=pre;
 +						pre=cur;
 +						cur=cur->next;
 +					}
 +					if (prepre!=NULL)
 +						{
 +							pre->next=cur->next;
 +							cur->next=pre;
 +							prepre->next=cur;
 +						}
 +					else if(pre!=NULL)
 +						{
 +							pre->next=cur->next;
 +							cur->next=pre;
 +							connExceptionsTmp=cur;							
 +						}
 +					fillExceptionsListView(hwndDlg);
 +					ListView_SetItemState(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS),pos1-1,LVNI_FOCUSED|LVIS_SELECTED , LVNI_FOCUSED|LVIS_SELECTED );
 +					SetFocus(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS));
 +					break;
 +				}
 +				case ID_DOWN: 
 +				{
 +					int pos,pos1;
 +					struct CONNECTION *cur=NULL,*pre=NULL;
 +
 +					cur=connExceptionsTmp;
 +
 +					pos=(int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS),-1,LVNI_FOCUSED );
 +					if(pos==-1)break;
 +					pos1=pos;
 +					while(pos--)
 +					{
 +						pre=cur;
 +						cur=cur->next;
 +					}
 +					if (cur==connExceptionsTmp&&cur->next!=NULL)
 +						{
 +							connExceptionsTmp=cur->next;
 +							cur->next=cur->next->next;
 +							connExceptionsTmp->next=cur;
 +						}
 +					else if (cur->next!=NULL)
 +						{
 +							struct CONNECTION *tmp=cur->next->next;
 +							pre->next=cur->next;
 +							cur->next->next=cur;
 +							cur->next=tmp;
 +						}
 +					fillExceptionsListView(hwndDlg);
 +					ListView_SetItemState(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS),pos1+1,LVNI_FOCUSED|LVIS_SELECTED , LVNI_FOCUSED|LVIS_SELECTED );
 +					SetFocus(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS));
 +					break;
 +				}				
 +				case IDC_SETCOLOURS:
 +				{
 +					HWND hwnd = GetDlgItem(hwndDlg, IDC_BGCOLOR);
 +					settingSetColours=IsDlgButtonChecked(hwndDlg, IDC_SETCOLOURS);
 +					EnableWindow(hwnd,settingSetColours );
 +					hwnd = GetDlgItem(hwndDlg, IDC_FGCOLOR);
 +					EnableWindow(hwnd, settingSetColours);
 +					break;
 +				}
 +				case IDC_BGCOLOR: settingBgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0);break;
 +				case IDC_FGCOLOR: settingFgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_GETCOLOUR, 0, 0);break;
 +
 +			}
 +			break;
 +
 +			case WM_NOTIFY://apply changes so write it to db
 +			switch(((LPNMHDR)lParam)->idFrom)
 +			{
 +				case 0:
 +				{
 +					switch (((LPNMHDR)lParam)->code)
 +					{
 +						case PSN_RESET:
 +						LoadSettings();
 +							deleteConnectionsTable(connExceptionsTmp);
 +							connExceptionsTmp=LoadSettingsConnections();
 +							return TRUE;
 +						case PSN_APPLY:
 +						{
 +							char buff[128];
 +							int i=0;
 +							db_set_dw (NULL, PLUGINNAME, "Interval", settingInterval );
 +							db_set_dw (NULL, PLUGINNAME, "PopupInterval", settingInterval1 );
 +							db_set_b(NULL, PLUGINNAME, "PopupSetColours", settingSetColours);
 +							db_set_dw(NULL, PLUGINNAME, "PopupBgColor", (DWORD)settingBgColor);
 +							db_set_dw(NULL, PLUGINNAME, "PopupFgColor", (DWORD)settingFgColor);
 +							db_set_b(NULL, PLUGINNAME, "ResolveIp", settingResolveIp);
 +							db_set_b(NULL, PLUGINNAME, "FilterDefaultAction", settingDefaultAction);
 +								
 +							for(i = 0; i < STATUS_COUNT ; i++) 
 +							{
 +								mir_snprintf(buff,_countof(buff), "Status%d", i);
 +								settingStatus[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_STATUS), i) ? TRUE : FALSE);
 +								db_set_b(0, PLUGINNAME, buff, settingStatus[i] ? 1 : 0);
 +							}
 +							if( WAIT_OBJECT_0 == WaitForSingleObject( hExceptionsMutex, 100 ) )
 +							{
 +								deleteConnectionsTable(connExceptions);
 +								saveSettingsConnections(connExceptionsTmp);
 +								connExceptions=connExceptionsTmp;
 +								connExceptionsTmp=LoadSettingsConnections();
 +								ReleaseMutex(hExceptionsMutex);
 +							}
 +						}//case PSN_APPLY
 +							
 +
 +						return TRUE;
 +						break;
 +					}//switch ->code
 +					break;
 +				}//case 0
 +			}//id from
 +			if (GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS)==((LPNMHDR) lParam)->hwndFrom)
 +			{
 +				switch (((LPNMHDR) lParam)->code)
 +				{
 +					case NM_DBLCLK:
 +					{
 +						int pos,pos1;
 +						struct CONNECTION *cur=NULL;
 +
 +						cur=connExceptionsTmp;
 +
 +						pos=(int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS),-1,LVNI_FOCUSED );
 +						if(pos==-1)break;
 +						pos1=pos;
 +						while(pos--)
 +						{
 +							cur=cur->next;
 +						}
 +						DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), hwndDlg, (DLGPROC)FilterEditProc, (LPARAM)cur);
 +						fillExceptionsListView(hwndDlg);
 +						ListView_SetItemState(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS),pos1,LVNI_FOCUSED|LVIS_SELECTED , LVNI_FOCUSED|LVIS_SELECTED );
 +						SetFocus(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS));
 +						break;
 +					}
 +				}
 +			}
 +			if (GetDlgItem(hwndDlg, IDC_STATUS)==((LPNMHDR) lParam)->hwndFrom)
 +			{
 +				switch (((LPNMHDR) lParam)->code)
 +				{
 +					case LVN_ITEMCHANGED:
 +					{
 +						NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
 +						if((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK)
 +						{
 +							SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
 +						}
 +						break;
 +							
 +					}
 +					break;
 +				}
 +			}
 +			break;//switch(msg)
 +		case WM_DESTROY:
 +			{
 +				bOptionsOpen=FALSE;
 +				deleteConnectionsTable(connExceptionsTmp);
 +				connExceptionsTmp=NULL;
 +				return TRUE;
 +			}
 +		}//end switch(msg)
 +	return 0;
 +}
 +//options page on miranda called
 +int ConnectionNotifyOptInit(WPARAM wParam,LPARAM lParam)
 +{
 +	OPTIONSDIALOGPAGE odp={0};
 +	//ZeroMemory(&odp,sizeof(odp));
 +	odp.cbSize = sizeof(odp);
 +	odp.hInstance = hInst;
 +	odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_DIALOG);
 +	odp.ptszTitle = LPGENT(PLUGINNAME);
 +	odp.ptszGroup = LPGENT("Plugins");
 +	odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
 +	odp.pfnDlgProc = (DLGPROC)DlgProcConnectionNotifyOpts;//callback function name
 +//	CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp);//add page to options menu pages
 +	Options_AddPage(wParam, &odp);
 +	return 0;
 +}
 +
 +
 +//gives protocol avainable statuses
 +int GetCaps(WPARAM wParam,LPARAM lParam)
 +{
 +	if(wParam==PFLAGNUM_1)
 +		return 0;
 +	if(wParam==PFLAGNUM_2)
 +		return PF2_ONLINE; // add the possible statuses here.
 +	if(wParam==PFLAGNUM_3)
 +		return 0;
 +	return 0;
 +}
 +//gives  name to protocol module
 +int GetName(WPARAM wParam,LPARAM lParam)
 +{
 +	lstrcpynA((char*)lParam,PLUGINNAME,wParam);
 +	return 0;
 +}
 +
 +//gives icon for proto module
 +int TMLoadIcon(WPARAM wParam,LPARAM lParam)
 +{
 +	UINT id;
 +
 +	switch(wParam & 0xFFFF) {
 +		case PLI_ONLINE:
 +		case PLI_PROTOCOL: id=IDI_ICON1; break; // IDI_TM is the main icon for the protocol
 +		case PLI_OFFLINE: id=IDI_ICON2; break;
 +		default: return 0;	
 +	}
 +	return (int)LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON, GetSystemMetrics(wParam&PLIF_SMALL?SM_CXSMICON:SM_CXICON), GetSystemMetrics(wParam&PLIF_SMALL?SM_CYSMICON:SM_CYICON), 0);
 +}
 +//=======================================================
 +//SetStatus
 +//=======================================================
 +int SetStatus(WPARAM wParam,LPARAM lParam)
 +{
 +	if (wParam == ID_STATUS_OFFLINE)
 +	{
 +		diffstat=0;
 +		//PostThreadMessage(ConnectionCheckThreadId,WM_QUIT ,(WPARAM)0, (LPARAM)0);
 +		SetEvent(killCheckThreadEvent);
 +
 +	}
 +	else if (wParam == ID_STATUS_ONLINE)
 +	{
 +		diffstat=0;
 +		ResetEvent(killCheckThreadEvent);
 +		if(!hConnectionCheckThread)
 +			hConnectionCheckThread = (HANDLE)mir_forkthreadex(checkthread, 0, (unsigned int*)&ConnectionCheckThreadId);
 +	}
 +	else
 +	{
 +		int retv=0;
 +		
 +		if(settingStatus[wParam - ID_STATUS_ONLINE])
 +			retv= SetStatus(ID_STATUS_OFFLINE,lParam);
 +		else
 +			retv= SetStatus(ID_STATUS_ONLINE,lParam);
 +		//LNEnableMenuItem(hMenuHandle ,TRUE);
 +		diffstat=wParam;
 +		return retv;
 +
 +		// the status has been changed to unknown  (maybe run some more code)
 +	}
 +	//broadcast the message
 +	
 +	//oldStatus = currentStatus;
 +	if(currentStatus!=wParam)
 +		ProtoBroadcastAck(PLUGINNAME,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)currentStatus,wParam);
 +	currentStatus = wParam;
 +	return 0;
 +
 +}
 +//=======================================================
 +//GetStatus
 +//=======================================================
 +int GetStatus(WPARAM wParam,LPARAM lParam)
 +{
 +	return currentStatus;
 +	if (diffstat )
 +		return diffstat;
 +	else
 +		return currentStatus ;
 +
 +}
 +/*
 +void updaterRegister()
 +{
 +
 +	Update update = {0}; // for c you'd use memset or ZeroMemory...
 +	//ZeroMemory(&update,sizeof(update));
 +	TCHAR buff[256];
 +#ifdef _DEBUG
 +	_OutputDebugString("Registering updater...");
 +#endif
 +	update.cbSize = sizeof(Update);
 +
 +	update.szComponentName = pluginInfo.shortName;
 +	mir_snprintf(buff,sizeof(buff),"%d.%d.%d.%d", HIBYTE(HIWORD(pluginInfo.version)), LOBYTE(HIWORD(pluginInfo.version)), HIBYTE(LOWORD(pluginInfo.version)), LOBYTE(LOWORD(pluginInfo.version)));
 +	update.pbVersion = (BYTE*)buff;
 +	update.cpbVersion = _tcslen((TCHAR *)update.pbVersion);
 +
 +	update.szUpdateURL=UPDATER_AUTOREGISTER;
 +
 +#ifdef WIN64
 +	update.szBetaUpdateURL = _T("http://maciej.wycik.pl/miranda/getconnectionnotifybeta.php?dl=64");
 +	update.pbBetaVersionPrefix = (BYTE *)"beta version ";
 +#else
 +	update.szBetaUpdateURL = _T("http://maciej.wycik.pl/miranda/getconnectionnotifybeta.php?dl=");
 +	update.pbBetaVersionPrefix = (BYTE *)"beta version ";
 +#endif
 +	update.szBetaVersionURL  = _T("http://maciej.wycik.pl/connectionnotify.php");
 +	update.cpbBetaVersionPrefix = _tcslen((TCHAR *)update.pbBetaVersionPrefix);
 +	
 +
 +	// do the same for the beta versions of the above struct members if you wish to allow beta updates from another URL
 +
 +	CallService(MS_UPDATE_REGISTER, 0, (WPARAM)&update);
 +
 +	return;
 +}
 +*/
 +
 +//thread function with connections check loop
 +static unsigned __stdcall checkthread(void *dummy)
 +{
 +
 +#ifdef _DEBUG
 +	_OutputDebugString(_T("check thread started"));
 +#endif
 +	while(1)
 +	{
 +		struct CONNECTION* conn=NULL,*connOld=first,*cur=NULL;
 +#ifdef _DEBUG
 +	_OutputDebugString(_T("checking connections table..."));
 +#endif
 +	if(WAIT_OBJECT_0 == WaitForSingleObject(killCheckThreadEvent,100))
 +	{
 +		hConnectionCheckThread=NULL;
 +		return 0;
 +	}
 +	//TranslateMessage(&msg);
 +		//DispatchMessage(&msg);
 +	
 +//		if(currentStatus==ID_STATUS_OFFLINE)
 +//			continue;//if status lets to check
 +
 +		conn=GetConnectionsTable();
 +		cur=conn;
 +		while(cur!=NULL)
 +		{	
 +			if (searchConnection(first,cur->strIntIp,cur->strExtIp,cur->intIntPort,cur->intExtPort,cur->state)==NULL && settingStatusMask&1<<cur->state-1)
 +			{
 +				
 +
 +#ifdef _DEBUG
 +	TCHAR msg[1024];
 +	mir_sntprintf(msg,_countof(msg),_T("%s:%d\n%s:%d"),cur->strIntIp,cur->intIntPort,cur->strExtIp,cur->intExtPort);
 +	_OutputDebugString(_T("New connection: %s"),msg);
 +#endif
 +				pid2name(cur->Pid,cur->PName);
 +				if( WAIT_OBJECT_0 == WaitForSingleObject( hExceptionsMutex, 100 ) )
 +				{
 +					if(checkFilter(connExceptions,cur))
 +						showMsg(cur->PName,cur->Pid,cur->strIntIp,cur->strExtIp,cur->intIntPort,cur->intExtPort,cur->state);
 +					ReleaseMutex(hExceptionsMutex);
 +				}
 +			}
 +			cur=cur->next;
 +		}
 +
 +		first=conn;
 +		deleteConnectionsTable(connOld);
 +		Sleep(settingInterval);
 +	}
 +	hConnectionCheckThread=NULL;
 +	return 1;
 +}
 +
 +//popup reactions
 +static int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 +{
 +	switch(message) 
 +	{
 +		case WM_COMMAND:
 +			{
 +				if (HIWORD(wParam) == STN_CLICKED)//client clicked on popup with left mouse button
 +				{
 +					struct CONNECTION *conn,*mpd=NULL;
 +
 +					conn = (struct CONNECTION*)mir_alloc(sizeof(struct CONNECTION));
 +					mpd=(struct CONNECTION*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd,(LPARAM)mpd);
 +					
 +					memcpy(conn,mpd,sizeof(struct CONNECTION));
 +					PUDeletePopup(hWnd);
 +					PostThreadMessage(FilterOptionsThreadId,WM_ADD_FILTER,(WPARAM)0, (LPARAM)conn);
 +					
 +
 +				}
 +				break;
 +			}
 +
 +		case WM_RBUTTONUP:
 +			{
 +				PUDeletePopup(hWnd);
 +				break;
 +			}		
 +
 +		case UM_INITPOPUP:
 +			{
 +				//struct CONNECTON *conn=NULL;
 +				//conn = (struct CONNECTION*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd,(LPARAM)conn);
 +				//MessageBox(NULL,conn->extIp);
 +				//PUDeletePopUp(hWnd);
 +				break;
 +			}
 +
 +		case UM_FREEPLUGINDATA: 
 +			{
 +				struct CONNECTION * mpd = NULL;
 +				mpd = (struct CONNECTION*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd,(LPARAM)mpd);
 +				if (mpd > 0) mir_free(mpd);
 +				return TRUE; //TRUE or FALSE is the same, it gets ignored.
 +			}
 +		default:
 +			break;
 +	}
 +	return DefWindowProc(hWnd, message, wParam, lParam);
 +}
 +
 +
 +//show popup
 +void showMsg(TCHAR *pName, DWORD pid,TCHAR *intIp,TCHAR *extIp,int intPort,int extPort,int state)
 +{
 +
 +	POPUPDATAT ppd;
 +	TCHAR hostName[128];
 +	//hContact = A_VALID_HANDLE_YOU_GOT_FROM_SOMEWHERE;
 +	//hIcon = A_VALID_HANDLE_YOU_GOT_SOMEWHERE;
 +	//char * lpzContactName = (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)lhContact,0);
 +	//99% of the times you'll just copy this line.
 +	//1% of the times you may wish to change the contact's name. I don't know why you should, but you can.
 +	//char * lpzText;
 +	//The text for the second line. You could even make something like: char lpzText[128]; lstrcpy(lpzText, "Hello world!"); It's your choice.
 +
 +	struct CONNECTION *mpd = (struct CONNECTION*)mir_alloc(sizeof(struct CONNECTION));
 +	//MessageBox(NULL,"aaa","aaa",1);
 +	ZeroMemory(&ppd, sizeof(ppd)); //This is always a good thing to do.
 +	ppd.lchContact = NULL;//(HANDLE)hContact; //Be sure to use a GOOD handle, since this will not be checked.
 +	ppd.lchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1));
 +	if(settingResolveIp)
 +		getDnsName(extIp,hostName);
 +
 +	mir_sntprintf(ppd.lpwzText,_countof(ppd.lpwzText),_T("%s:%d\n%s:%d"),(settingResolveIp?hostName:extIp),extPort,intIp,intPort);
 +	mir_sntprintf(ppd.lpwzContactName,_countof(ppd.lpwzContactName),_T("%s (%s)"),pName,tcpStates[state-1]);
 +	//lstrcpy(ppd.lpzText, text);
 +	if(settingSetColours)
 +	{
 +		ppd.colorBack = settingBgColor; 
 +		ppd.colorText = settingFgColor;
 +	}
 +	ppd.PluginWindowProc = (WNDPROC)PopupDlgProc;
 +
 +	ppd.iSeconds=settingInterval1;
 +	//Now the "additional" data.
 +	mir_sntprintf(mpd->strIntIp,_countof(mpd->strIntIp),_T("%s"),intIp);
 +	mir_sntprintf(mpd->strExtIp,_countof(mpd->strExtIp),_T("%s"),extIp);
 +	mir_sntprintf(mpd->PName,_countof(mpd->PName),_T("%s"),pName);
 +	mpd->intIntPort = intPort;
 +	mpd->intExtPort = extPort;
 +	mpd->Pid=pid;
 +
 +
 +	//mpd->newStatus = ID_STATUS_ONLINE;
 +
 +	//Now that the plugin data has been filled, we add it to the PopUpData.
 +	ppd.PluginData = mpd;
 +
 +	//Now that every field has been filled, we want to see the popup.
 +	//CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&ppd, 0);
 +	PUAddPopupT(&ppd);
 +}
 +
 +
 +
 +//called after all plugins loaded.
 +//all Connection staff will be called, that will not hang miranda on startup
 +static int modulesloaded(WPARAM wParam,LPARAM lParam)
 +{
 +	
 +#ifdef _DEBUG
 +	_OutputDebugString(_T("Modules loaded, lets start TN..."));
 +#endif
 +//	hConnectionCheckThread = (HANDLE)mir_forkthreadex(checkthread, 0, 0, ConnectionCheckThreadId);
 +
 +//#ifdef _DEBUG
 +//	_OutputDebugString("started check thread %d",hConnectionCheckThread);
 +//#endif
 +	killCheckThreadEvent=CreateEvent(NULL,FALSE,FALSE,_T("killCheckThreadEvent"));
 +	hFilterOptionsThread=startFilterThread();
 +	//updaterRegister();
 +	
 +	return 0;
 +}
 +//function hooks before unload
 +static int preshutdown(WPARAM wParam,LPARAM lParam)
 +{
 +
 +	deleteConnectionsTable(first);
 +	deleteConnectionsTable(connExceptions);
 +	deleteConnectionsTable(connExceptionsTmp);
 +
 +	PostThreadMessage(ConnectionCheckThreadId,WM_QUIT ,(WPARAM)0, (LPARAM)0);
 +	PostThreadMessage(FilterOptionsThreadId,WM_QUIT ,(WPARAM)0, (LPARAM)0);
 +	
 +	return 0;
 +}
 +
 +extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
 +{
 +	hInst=hinstDLL;
 +	return TRUE;
 +}
 +extern "C" int __declspec(dllexport) Load(void)
 +{
 +	char service[100]={""};
 +
 +	PROTOCOLDESCRIPTOR pd={ PROTOCOLDESCRIPTOR_V3_SIZE };
 +
 +#ifdef _DEBUG
 +	_OutputDebugString(_T("Entering Load dll"));
 +#endif
 +
 +	mir_getLP( &pluginInfo );
 +	//hCurrentEditMutex=CreateMutex(NULL,FALSE,_T("CurrentEditMutex"));
 +	hExceptionsMutex=CreateMutex(NULL,FALSE,_T("ExceptionsMutex"));
 +
 +	LoadSettings();
 +	connExceptions=LoadSettingsConnections();
 +//create protocol
 +	//ZeroMemory(&pd,sizeof(pd));
 +	//pd.cbSize=sizeof(pd);
 + 	pd.szName=PLUGINNAME;
 +	pd.type=PROTOTYPE_PROTOCOL;
 +	CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd);
 +	//set all contacts to offline
 +	{	
 +		HANDLE hContact;
 +		hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
 +		while(hContact!=NULL) {
 +			if(!lstrcmpA(PLUGINNAME,(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0))) {
 +				db_set_w(hContact,PLUGINNAME,"status",ID_STATUS_OFFLINE);
 +			}
 +			hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
 +		}
 +	}
 +	mir_snprintf(service,sizeof(service), "%s%s", PLUGINNAME, PS_GETCAPS);
 +	CreateServiceFunction(service, (MIRANDASERVICE)GetCaps);
 +	mir_snprintf(service,sizeof(service), "%s%s", PLUGINNAME, PS_GETNAME);
 +	CreateServiceFunction(service, (MIRANDASERVICE)GetName);
 +	mir_snprintf(service,sizeof(service), "%s%s", PLUGINNAME, PS_LOADICON);
 +	CreateServiceFunction(service, (MIRANDASERVICE)TMLoadIcon);
 +	mir_snprintf(service,sizeof(service), "%s%s", PLUGINNAME, PS_SETSTATUS);
 +	CreateServiceFunction(service, (MIRANDASERVICE)SetStatus);
 +	mir_snprintf(service,sizeof(service), "%s%s", PLUGINNAME, PS_GETSTATUS);
 +	CreateServiceFunction(service, (MIRANDASERVICE)GetStatus);
 +
 +
 +	SkinAddNewSound(PLUGINNAME,Translate("ConnectionNotify: New Connection Notification"),NULL);
 +	hOptInit = HookEvent(ME_OPT_INITIALISE, ConnectionNotifyOptInit);//register service to hook option call
 +	assert(hOptInit);
 +	hHookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, modulesloaded);//hook event that all plugins are loaded
 +	assert(hHookModulesLoaded);
 +	hHookPreShutdown = HookEvent(ME_SYSTEM_PRESHUTDOWN, preshutdown);
 +	return 0;
 +}
 +
 +extern "C" int __declspec(dllexport) Unload(void)
 +{
 +	WaitForSingleObjectEx(hConnectionCheckThread, INFINITE, FALSE);
 +        if(hConnectionCheckThread )CloseHandle(hConnectionCheckThread);
 +	if(hCheckEvent)DestroyHookableEvent(hCheckEvent);
 +	if (hOptInit) UnhookEvent(hOptInit);
 +	if (hCheckHook)UnhookEvent(hCheckHook);
 +	if(hHookModulesLoaded)UnhookEvent(hHookModulesLoaded);
 +	if(hHookPreShutdown)UnhookEvent(hHookPreShutdown);
 +	if(killCheckThreadEvent)
 +		CloseHandle(killCheckThreadEvent);
 +	//if(hCurrentEditMutex) CloseHandle(hCurrentEditMutex);
 +	if(hExceptionsMutex) CloseHandle(hExceptionsMutex);
 +
 +#ifdef _DEBUG
 +	_OutputDebugString(_T("Unloaded"));
 +#endif
 +	return 0;
 +}
 +
 diff --git a/plugins/ConnectionNotify/src/ConnectionNotify.h b/plugins/ConnectionNotify/src/ConnectionNotify.h new file mode 100644 index 0000000000..d60e8d0cef --- /dev/null +++ b/plugins/ConnectionNotify/src/ConnectionNotify.h @@ -0,0 +1,13 @@ +
 +#if !defined(MIID_CONNECTIONNOTIFY)
 +	#define MIID_CONNECTIONNOTIFY  {0x4bb5b4aa, 0xc364, 0x4f23, { 0x97, 0x46, 0xd5, 0xb7, 0x8, 0xa2, 0x86, 0xa5 } }
 +#endif
 +// 4BB5B4AA-C364-4F23-9746-D5B708A286A5
 +
 +
 +void showMsg(TCHAR *pName,DWORD pid,TCHAR *intIp,TCHAR *extIp,int intPort,int extPort,int state);
 +//int __declspec(dllexport) Load(PLUGINLINK *link);
 +extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
 +static unsigned __stdcall checkthread(void *dummy);
 +struct CONNECTION * LoadSettingsConnections();
 +void saveSettingsConnections(struct CONNECTION *connHead);
 diff --git a/plugins/ConnectionNotify/src/debug.cpp b/plugins/ConnectionNotify/src/debug.cpp new file mode 100644 index 0000000000..d6bff90fe1 --- /dev/null +++ b/plugins/ConnectionNotify/src/debug.cpp @@ -0,0 +1,75 @@ +#include "debug.h"
 +
 +#define MAX_LENGTH 512
 +
 +
 +void _OutputDebugString(TCHAR* lpOutputString, ... )
 +{
 +    TCHAR OutMsg[MAX_LENGTH];
 +    TCHAR format[MAX_LENGTH];
 +	int i,j;
 +    va_list argptr;    
 +    
 +    va_start( argptr, lpOutputString );            
 +    
 +
 +    
 +    for(i=0,j=0;lpOutputString[i] != '\0';i++) 
 +    {
 +        format[j++] = lpOutputString[i];
 +		format[j] = '\0';
 +        // If escape character
 +        //if(lpOutputString[i] == '\\')
 +        //{
 +        //    i++;
 +        //    continue;
 +        //}
 +        // if not a substitutal character
 +        if(lpOutputString[i] != '%')
 +            continue;
 +        
 +        format[j++] = lpOutputString[++i];
 +        format[j] = '\0';
 +        switch(lpOutputString[i])
 +        {
 +            // string
 +        case 's':
 +            {
 +                TCHAR* s = va_arg( argptr, TCHAR * );
 +                _stprintf(OutMsg,format,s);
 +                _tcsncpy(format,OutMsg,_countof(OutMsg));
 +                j = _tcslen(format);
 +                _tcscat(format,_T(" "));
 +                break;
 +            }
 +            // character
 +        case 'c':
 +            {
 +                char c = (char) va_arg( argptr, int );
 +                _stprintf(OutMsg,format,c);
 +                _tcsncpy(format,OutMsg,_countof(OutMsg));
 +                j = _tcslen(format);
 +                _tcscat(format,_T(" "));
 +                break;
 +            }
 +            // integer
 +        case 'd':
 +            {
 +                int d = va_arg( argptr, int );
 +                _stprintf(OutMsg,format,d);
 +                _tcsncpy(format,OutMsg,_countof(OutMsg));
 +                j = _tcslen(format);
 +                _tcscat(format,_T(" "));
 +                break;
 +            }
 +        }
 +		format[j+1] = '\0';
 +    }
 +	_tcscat(format,_T("\n"));
 +    OutputDebugString(format);
 +
 +    va_end( argptr );
 +
 +}
 +
 +
 diff --git a/plugins/ConnectionNotify/src/debug.h b/plugins/ConnectionNotify/src/debug.h new file mode 100644 index 0000000000..fd5b070c9e --- /dev/null +++ b/plugins/ConnectionNotify/src/debug.h @@ -0,0 +1,10 @@ +#pragma once
 +#ifndef _INC_DEBUG
 +#define _INC_DEBUG
 +
 +#include <windows.h>
 +#include <stdio.h>
 +#include <tchar.h>
 +
 +void _OutputDebugString(TCHAR* lpOutputString, ... );
 +#endif
\ No newline at end of file diff --git a/plugins/ConnectionNotify/src/filter.cpp b/plugins/ConnectionNotify/src/filter.cpp new file mode 100644 index 0000000000..aa30b460d1 --- /dev/null +++ b/plugins/ConnectionNotify/src/filter.cpp @@ -0,0 +1,155 @@ +
 +#include <Windows.h>
 +#include <newpluginapi.h>
 +#include <m_system.h>
 +#include <m_langpack.h>
 +
 +#include "resource.h"
 +#include "netstat.h"
 +#include "Filter.h"
 +#include "ConnectionNotify.h"
 +
 +HWND filterAddDlg=NULL;
 +extern HINSTANCE hInst;
 +extern struct CONNECTION *connExceptions;
 +extern HANDLE hFilterOptionsThread;
 +extern DWORD FilterOptionsThreadId;
 +extern struct CONNECTION *connCurrentEdit;
 +extern BOOL settingDefaultAction;
 +extern HANDLE hExceptionsMutex;
 +extern BOOL bOptionsOpen;
 +static unsigned __stdcall filterQueue(void *dummy);
 +static int CALLBACK ConnectionFilterEditProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
 +
 +HANDLE startFilterThread()
 +{
 +	return (HANDLE)mir_forkthreadex(filterQueue, 0, (unsigned int*)&FilterOptionsThreadId);
 +}
 +
 +static unsigned __stdcall filterQueue(void *dummy)
 +{
 +	BOOL bRet;
 +	MSG msg;
 +	//while(1)
 +	while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
 +	{
 +		if(msg.message==WM_ADD_FILTER )
 +		{
 +			struct CONNECTION *conn=(struct CONNECTION *)msg.lParam;
 +			filterAddDlg=CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), NULL , (DLGPROC)ConnectionFilterEditProc,(LPARAM)conn);
 +					//SetWindowLongPtr( GetDlgItem(filterAddDlg, ID_TXT_LOCAL_IP), GWL_WNDPROC, (LONG)ConnectionFilterEditProc );
 +			ShowWindow(filterAddDlg,SW_SHOW);
 +
 +		}
 +		if (NULL == filterAddDlg || !IsDialogMessage(filterAddDlg, &msg))
 +		{
 +			TranslateMessage(&msg);
 +			DispatchMessage(&msg);
 +		}
 +	}
 +	hFilterOptionsThread=NULL;
 +	return TRUE;
 +}
 +
 +static int CALLBACK ConnectionFilterEditProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 +{
 +	switch(message) 
 +	{
 +		case WM_INITDIALOG:
 +			{
 +			struct CONNECTION *conn=(struct CONNECTION*)lParam;
 +			TranslateDialogDefault(hWnd);
 +			
 +			SetDlgItemText(hWnd, ID_TEXT_NAME,conn->PName);
 +			SetDlgItemText(hWnd, ID_TXT_LOCAL_IP,conn->strIntIp);
 +			SetDlgItemText(hWnd, ID_TXT_REMOTE_IP,conn->strExtIp);
 +			SetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT,conn->intIntPort,FALSE);
 +			SetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT,conn->intExtPort,FALSE);
 +			SendDlgItemMessage(hWnd, ID_CBO_ACTION , CB_ADDSTRING, 0, (LPARAM)TranslateT("Always show popup"));
 +			SendDlgItemMessage(hWnd, ID_CBO_ACTION , CB_ADDSTRING, 0, (LPARAM)TranslateT("Never show popup"));
 +			SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_SETCURSEL ,0,0);
 +			mir_free(conn);
 +			return TRUE;
 +			}
 +		case WM_ACTIVATE:
 +            if (0 == wParam)             // becoming inactive
 +               filterAddDlg = NULL;
 +            else                         // becoming active
 +               filterAddDlg = hWnd;
 +            return FALSE;
 +		case WM_COMMAND:
 +			switch(LOWORD(wParam))
 +				{
 +				case ID_OK:
 +					{
 +					TCHAR tmpPort[6];
 +					if (bOptionsOpen==TRUE)
 +					{
 +						MessageBox(hWnd,TranslateT("First close options window"),_T("ConnectionNotify"),MB_OK | MB_ICONSTOP);
 +						break;
 +					}
 +						if( WAIT_OBJECT_0 == WaitForSingleObject( hExceptionsMutex, 100 ) )
 +						{
 +							if (connCurrentEdit==NULL)
 +							{
 +								connCurrentEdit=(struct CONNECTION*)mir_alloc(sizeof(struct CONNECTION));
 +								connCurrentEdit->next=connExceptions;
 +								connExceptions=connCurrentEdit;
 +							}
 +							GetDlgItemText(hWnd, ID_TXT_LOCAL_PORT, tmpPort, sizeof(tmpPort));
 +							if (tmpPort[0]=='*')
 +								connCurrentEdit->intIntPort=-1;
 +							else
 +								connCurrentEdit->intIntPort=GetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT, NULL, FALSE);
 +							GetDlgItemText(hWnd, ID_TXT_REMOTE_PORT, tmpPort, sizeof(tmpPort));
 +							if (tmpPort[0]=='*')
 +								connCurrentEdit->intExtPort=-1;
 +							else
 +								connCurrentEdit->intExtPort = GetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT, NULL, FALSE);
 +					
 +							GetDlgItemText(hWnd, ID_TXT_LOCAL_IP, connCurrentEdit->strIntIp, sizeof(connCurrentEdit->strIntIp));
 +							GetDlgItemText(hWnd, ID_TXT_REMOTE_IP, connCurrentEdit->strExtIp, sizeof(connCurrentEdit->strExtIp));
 +							GetDlgItemText(hWnd, ID_TEXT_NAME, connCurrentEdit->PName, sizeof(connCurrentEdit->PName));
 +
 +							connCurrentEdit->Pid=!(BOOL)SendMessage(GetDlgItem(hWnd,ID_CBO_ACTION),CB_GETCURSEL, 0, 0);
 +							connCurrentEdit=NULL;
 +							saveSettingsConnections(connExceptions);
 +							ReleaseMutex(hExceptionsMutex);
 +					}
 +					//EndDialog(hWnd,IDOK);
 +					DestroyWindow(hWnd);
 +					return TRUE;
 +					}
 +				case ID_CANCEL:
 +					connCurrentEdit=NULL;
 +					DestroyWindow(hWnd);
 +					//EndDialog(hWnd,IDCANCEL);
 +					return TRUE;
 +				}
 +			return FALSE;
 +
 +			break;
 +		case WM_CLOSE:
 +			DestroyWindow(hWnd);
 +		case WM_DESTROY:
 +			filterAddDlg=NULL;
 +			connCurrentEdit=NULL;
 +			//DestroyWindow(hWnd);
 +			//PostQuitMessage(0);
 +			break;
 +	}
 +	return FALSE;
 +}
 +
 +BOOL checkFilter(struct CONNECTION *head,struct CONNECTION *conn)
 +{
 +	struct CONNECTION *cur=head;
 +	while(cur!=NULL)
 +	{
 +		if(wildcmp(cur->PName,conn->PName)&&wildcmp(cur->strIntIp,conn->strIntIp)&&wildcmp(cur->strExtIp,conn->strExtIp)&&(cur->intIntPort==-1||cur->intIntPort==conn->intIntPort)&&(cur->intExtPort==-1||cur->intExtPort==conn->intExtPort))
 +			return cur->Pid;
 +		cur=cur->next;
 +	}
 +	return settingDefaultAction;
 +}
 +
 diff --git a/plugins/ConnectionNotify/src/filter.h b/plugins/ConnectionNotify/src/filter.h new file mode 100644 index 0000000000..0d40a4cf73 --- /dev/null +++ b/plugins/ConnectionNotify/src/filter.h @@ -0,0 +1,9 @@ +#pragma once
 +#ifndef _INC_FILTER
 +#define _INC_FILTER
 +
 +HANDLE startFilterThread();
 +BOOL checkFilter(struct CONNECTION *head,struct CONNECTION *conn);
 +
 +#define WM_ADD_FILTER	(WM_APP + 1)
 +#endif
 diff --git a/plugins/ConnectionNotify/src/netstat.cpp b/plugins/ConnectionNotify/src/netstat.cpp new file mode 100644 index 0000000000..2dd190c823 --- /dev/null +++ b/plugins/ConnectionNotify/src/netstat.cpp @@ -0,0 +1,220 @@ +// GetTcpTable.cpp : Defines the entry point for the console application.
 +//
 +
 +// Link to Ws2_32.lib
 +//#include <winsock2.h>
 +#include <ws2tcpip.h>
 +// Link to Iphlpapi.lib
 +#include <iphlpapi.h>
 +#include <stdio.h>
 +#include <tchar.h>
 +#include <m_core.h>
 +#include "netstat.h"
 +// Note: could also use malloc() and free()
 +#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
 +#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
 + 
 +struct CONNECTION* GetConnectionsTable()
 +{
 +    // Declare and initialize variables
 +    MIB_TCPTABLE_OWNER_PID *pTcpTable;
 +    DWORD dwSize = 0;
 +    DWORD dwRetVal = 0;
 +    struct in_addr IpAddr;
 +    int i;
 +	struct CONNECTION *connHead=NULL;
 +
 +    pTcpTable = (MIB_TCPTABLE_OWNER_PID *) MALLOC(sizeof (MIB_TCPTABLE_OWNER_PID));
 +    if (pTcpTable == NULL)
 +    {
 +        //printf("Error allocating memory!\n");
 +        return NULL;
 +    }
 + 
 +    dwSize = sizeof (MIB_TCPTABLE_OWNER_PID);
 +    // Make an initial call to GetTcpTable to
 +    // get the necessary size into the dwSize variable
 +    if ((dwRetVal = GetExtendedTcpTable(pTcpTable, &dwSize, TRUE,AF_INET,TCP_TABLE_OWNER_PID_ALL,0)) ==  ERROR_INSUFFICIENT_BUFFER)
 +    {
 +        FREE(pTcpTable);
 +        pTcpTable = (MIB_TCPTABLE_OWNER_PID *) MALLOC(dwSize);
 +        if (pTcpTable == NULL)
 +        {
 +            //printf("Error allocating memory\n");
 +            return NULL;
 +        }
 +    }
 + 
 +    // Make a second call to GetTcpTable to get
 +    // the actual data we require
 +    if ((dwRetVal = GetExtendedTcpTable(pTcpTable, &dwSize, TRUE,AF_INET,TCP_TABLE_OWNER_PID_ALL,0)) == NO_ERROR)
 +    {
 +        //printf("\tLocal Addr\tLocal Port\tRemote Addr\tRemote Port\n");
 +        //printf("Number of entries: %d\n", (int) pTcpTable->dwNumEntries);
 +		
 +
 +        for (i = 0; i < (int) pTcpTable->dwNumEntries; i++)
 +        {
 +			struct CONNECTION* newConn=(struct CONNECTION*)mir_alloc(sizeof(struct CONNECTION));
 +			memset(newConn,0,sizeof(struct CONNECTION));
 +			//pid2name(pTcpTable->table[i].dwOwningPid,&newConn->Pname);
 +			
 +			if(pTcpTable->table[i].dwLocalAddr)
 +			{
 +				IpAddr.S_un.S_addr = (ULONG) pTcpTable->table[i].dwLocalAddr;
 +				//_snprintf(newConn->strIntIp,_countof(newConn->strIntIp),"%d.%d.%d.%d",IpAddr.S_un.S_un_b.s_b1,IpAddr.S_un.S_un_b.s_b2,IpAddr.S_un.S_un_b.s_b3,IpAddr.S_un.S_un_b.s_b4);
 +				wcsncpy(newConn->strIntIp, mir_a2t(inet_ntoa(IpAddr)),_tcslen(mir_a2t(inet_ntoa(IpAddr))));
 +			}
 +			
 +			if(pTcpTable->table[i].dwRemoteAddr)
 +			{
 +				IpAddr.S_un.S_addr = (u_long) pTcpTable->table[i].dwRemoteAddr;
 +				wcsncpy(newConn->strExtIp, mir_a2t(inet_ntoa(IpAddr)),_tcslen(mir_a2t(inet_ntoa(IpAddr))));
 +			}
 +            newConn->state = pTcpTable->table[i].dwState;
 +			newConn->intIntPort =ntohs((u_short)pTcpTable->table[i].dwLocalPort);
 +			newConn->intExtPort =ntohs((u_short)pTcpTable->table[i].dwRemotePort);
 +			newConn->Pid=pTcpTable->table[i].dwOwningPid;
 +			
 +			switch (pTcpTable->table[i].dwState)
 +            {
 +            case MIB_TCP_STATE_CLOSED:
 +                //printf("CLOSED\n");
 +                break;
 +            case MIB_TCP_STATE_LISTEN:
 +                //printf("LISTEN\n");
 +                break;
 +            case MIB_TCP_STATE_SYN_SENT:
 +                //printf("SYN-SENT\n");
 +                break;
 +            case MIB_TCP_STATE_SYN_RCVD:
 +                //printf("SYN-RECEIVED\n");
 +                break;
 +            case MIB_TCP_STATE_ESTAB:
 +                //printf("ESTABLISHED\n");
 +                break;
 +            case MIB_TCP_STATE_FIN_WAIT1:
 +                //printf("FIN-WAIT-1\n");
 +                break;
 +            case MIB_TCP_STATE_FIN_WAIT2:
 +                //printf("FIN-WAIT-2 \n");
 +                break;
 +            case MIB_TCP_STATE_CLOSE_WAIT:
 +                //printf("CLOSE-WAIT\n");
 +                break;
 +            case MIB_TCP_STATE_CLOSING:
 +                //printf("CLOSING\n");
 +                break;
 +            case MIB_TCP_STATE_LAST_ACK:
 +                //printf("LAST-ACK\n");
 +                break;
 +            case MIB_TCP_STATE_TIME_WAIT:
 +                //printf("TIME-WAIT\n");
 +                break;
 +            case MIB_TCP_STATE_DELETE_TCB:
 +                //printf("DELETE-TCB\n");
 +                break;
 +            default:
 +                //printf("UNKNOWN dwState value\n");
 +                break;
 +            }
 +			newConn->next = connHead;
 +			connHead=newConn;
 + 
 +          //printf("TCP[%d]:%s%15d%20s%15d\n", i, szLocalAddr,ntohs((u_short)pTcpTable->table[i].dwLocalPort), szRemoteAddr,ntohs((u_short)pTcpTable->table[i].dwRemotePort));
 + 
 +            //printf("\tTCP[%d] Local Addr: %s\n", i, szLocalAddr);
 +            // printf("\tTCP[%d] Local Port: %d \n", i, ntohs((u_short)pTcpTable->table[i].dwLocalPort));
 +            //printf("\tTCP[%d] Remote Addr: %s\n", i, szRemoteAddr);
 +            //printf("\tTCP[%d] Remote Port: %d\n", i, ntohs((u_short)pTcpTable->table[i].dwRemotePort));
 +        }
 +   }
 +   else
 +   {
 +        //printf("\tGetTcpTable() failed with return value %d\n", dwRetVal);
 +        FREE(pTcpTable);
 +        return NULL;
 +    }
 +	if (pTcpTable != NULL) 
 +	{
 +        FREE(pTcpTable);
 +        pTcpTable = NULL;
 +    } 
 +    return connHead;
 +}
 +
 +void deleteConnectionsTable(struct CONNECTION* head)
 +{
 +	struct CONNECTION *cur=head,*del;
 +	while(cur!=NULL)
 +	{	
 +		del=cur;
 +		cur=cur->next;
 +		mir_free(del);
 +		head=cur;
 +	}
 +	head=NULL;
 +}
 +
 +struct CONNECTION* searchConnection(struct CONNECTION* head,TCHAR *intIp,TCHAR *extIp,int intPort,int extPort,int state)
 +{
 +	struct CONNECTION *cur=head;
 +	while(cur!=NULL)
 +	{
 +		if(wcscmp(cur->strIntIp,intIp)==0 && wcscmp(cur->strExtIp,extIp)==0 && cur->intExtPort==extPort && cur->intIntPort==intPort && cur->state==state)
 +			return cur;
 +		cur=cur->next;
 +	}
 +	return NULL;
 +}
 +
 +void getDnsName(TCHAR *strIp,TCHAR *strHostName)
 +{
 +	struct in_addr iaHost;
 +	struct hostent *h;
 +
 +	iaHost.s_addr = inet_addr(mir_t2a(strIp));
 +	if ((h = gethostbyaddr ((char *)&iaHost, sizeof(struct in_addr), AF_INET))== NULL)
 +		{  // get the host info error
 +			_stprintf(strHostName,_T("%s"), strIp);
 +            return;
 +        }
 +	_stprintf(strHostName,_T("%s"),mir_a2t(h->h_name));
 +	//_tcsncpy_s(strHostName,128, h->h_name,_tcslen(h->h_name));
 +
 +}
 +
 +int wildcmp(const TCHAR *wild, const TCHAR *string) {
 +  // Written by Jack Handy - jakkhandy@hotmail.com
 +
 +  const TCHAR *cp = NULL, *mp = NULL;
 +
 +  while ((*string) && (*wild != '*')) {
 +    if ((*wild != *string) && (*wild != '?')) {
 +      return 0;
 +    }
 +    wild++;
 +    string++;
 +  }
 +
 +  while (*string) {
 +    if (*wild == '*') {
 +      if (!*++wild) {
 +        return 1;
 +      }
 +      mp = wild;
 +      cp = string+1;
 +    } else if ((*wild == *string) || (*wild == '?')) {
 +      wild++;
 +      string++;
 +    } else {
 +      wild = mp;
 +      string = cp++;
 +    }
 +  }
 +
 +  while (*wild == '*') {
 +    wild++;
 +  }
 +  return !*wild;
 +}
 diff --git a/plugins/ConnectionNotify/src/netstat.h b/plugins/ConnectionNotify/src/netstat.h new file mode 100644 index 0000000000..ccabf3df4b --- /dev/null +++ b/plugins/ConnectionNotify/src/netstat.h @@ -0,0 +1,21 @@ +#pragma once
 + 
 +
 +
 +struct CONNECTION
 +{
 +	TCHAR strIntIp[16];
 +	TCHAR strExtIp[16];
 +	int intIntPort;
 +	int intExtPort;
 +	int state;
 +	DWORD Pid;
 +	TCHAR PName[260];
 +	struct CONNECTION *next;
 +};
 +
 +struct CONNECTION* GetConnectionsTable();
 +void deleteConnectionsTable(struct CONNECTION* head);
 +struct CONNECTION* searchConnection(struct CONNECTION* head,TCHAR *intIp,TCHAR *extIp,int intPort,int extPort,int state);
 +void getDnsName(TCHAR *strIp,TCHAR *strHostName);
 +int wildcmp(const TCHAR *wild, const TCHAR *string);
\ No newline at end of file diff --git a/plugins/ConnectionNotify/src/pid2name.cpp b/plugins/ConnectionNotify/src/pid2name.cpp new file mode 100644 index 0000000000..46c51202c7 --- /dev/null +++ b/plugins/ConnectionNotify/src/pid2name.cpp @@ -0,0 +1,119 @@ +#include <Windows.h>
 +// one can also use Winternl.h if needed
 +//#include <Winternl.h> // for UNICODE_STRING and SYSTEM_INFORMATION_CLASS
 +#include <stdio.h>
 +#include <tchar.h>
 +//#include <stdlib.h>
 +
 +#include <Tlhelp32.h>
 +#include "pid2name.h"
 +
 +void pid2name(DWORD procid,TCHAR* buffer)
 +{
 +    HANDLE hSnap = INVALID_HANDLE_VALUE;
 +    HANDLE hProcess = INVALID_HANDLE_VALUE;
 +    PROCESSENTRY32 ProcessStruct;
 +    ProcessStruct.dwSize = sizeof(PROCESSENTRY32);
 +    hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
 +    if(hSnap == INVALID_HANDLE_VALUE)
 +        return;
 +    if(Process32First(hSnap, &ProcessStruct) == FALSE)
 +        return;
 +    do
 +    {
 +		if(ProcessStruct.th32ProcessID==procid)
 +		{
 +			_stprintf(buffer,_T("%s"),ProcessStruct.szExeFile);
 +            break;
 +        }
 +    }
 +    while( Process32Next( hSnap, &ProcessStruct ) );
 +    
 +	CloseHandle( hSnap );
 +}
 +
 +/*
 +#define STATUS_SUCCESS               ((NTSTATUS)0x00000000L)
 +#define STATUS_INFO_LENGTH_MISMATCH  ((NTSTATUS)0xC0000004L)
 +
 +typedef enum _SYSTEM_INFORMATION_CLASS {
 +    SystemProcessInformation = 5
 +} SYSTEM_INFORMATION_CLASS;
 +
 +typedef struct _UNICODE_STRING {
 +    USHORT Length;
 +    USHORT MaximumLength;
 +    PWSTR  Buffer;
 +} UNICODE_STRING;
 +
 +typedef LONG KPRIORITY; // Thread priority
 +
 +typedef struct _SYSTEM_PROCESS_INFORMATION_DETAILD {
 +    ULONG NextEntryOffset;
 +    ULONG NumberOfThreads;
 +    LARGE_INTEGER SpareLi1;
 +    LARGE_INTEGER SpareLi2;
 +    LARGE_INTEGER SpareLi3;
 +    LARGE_INTEGER CreateTime;
 +    LARGE_INTEGER UserTime;
 +    LARGE_INTEGER KernelTime;
 +    UNICODE_STRING ImageName;
 +    KPRIORITY BasePriority;
 +    HANDLE UniqueProcessId;
 +    ULONG InheritedFromUniqueProcessId;
 +    ULONG HandleCount;
 +    BYTE Reserved4[4];
 +    PVOID Reserved5[11];
 +    SIZE_T PeakPagefileUsage;
 +    SIZE_T PrivatePageCount;
 +    LARGE_INTEGER Reserved6[6];
 +} SYSTEM_PROCESS_INFORMATION_DETAILD, *PSYSTEM_PROCESS_INFORMATION_DETAILD;
 +
 +typedef NTSTATUS (WINAPI *PFN_NT_QUERY_SYSTEM_INFORMATION)(
 +  IN       SYSTEM_INFORMATION_CLASS SystemInformationClass,
 +  IN OUT   PVOID SystemInformation,
 +  IN       ULONG SystemInformationLength,
 +  OUT OPTIONAL  PULONG ReturnLength
 +);
 +
 +void pid2name(DWORD procid,TCHAR* buffer)
 +{
 +	size_t bufferSize = 102400;
 +    PSYSTEM_PROCESS_INFORMATION_DETAILD pspid=(PSYSTEM_PROCESS_INFORMATION_DETAILD) malloc (bufferSize);
 +    ULONG ReturnLength;
 +    PFN_NT_QUERY_SYSTEM_INFORMATION pfnNtQuerySystemInformation = (PFN_NT_QUERY_SYSTEM_INFORMATION)GetProcAddress (GetModuleHandle(TEXT("ntdll.dll")), "NtQuerySystemInformation");
 +    NTSTATUS status;
 +
 +    while (TRUE) 
 +	{
 +        status = pfnNtQuerySystemInformation (SystemProcessInformation, (PVOID)pspid, bufferSize, &ReturnLength);
 +        if (status == STATUS_SUCCESS)
 +            break;
 +        else if (status != STATUS_INFO_LENGTH_MISMATCH) 
 +		{ // 0xC0000004L
 +            //_tprintf (TEXT("ERROR 0x%X\n"), status);
 +			goto error_block;
 +        }
 +
 +        bufferSize *= 2;
 +        pspid = (PSYSTEM_PROCESS_INFORMATION_DETAILD) realloc ((PVOID)pspid, bufferSize);
 +    }
 +
 +    for (;;pspid=(PSYSTEM_PROCESS_INFORMATION_DETAILD)(pspid->NextEntryOffset + (PBYTE)pspid)) {
 +		if (pspid->UniqueProcessId == (HANDLE)procid)
 +		{
 +			_stprintf(buffer,"%ls",pspid->ImageName.Buffer);
 +			break;
 +		}
 +        //_tprintf (TEXT("ProcessId: %d, ImageFileName: %ls\n"), pspid->UniqueProcessId,(pspid->ImageName.Length && pspid->ImageName.Buffer)? pspid->ImageName.Buffer: L"");
 +        if (pspid->NextEntryOffset == 0) break;
 +    }
 +error_block:
 +if (pspid!=NULL)
 +{
 +	free(pspid);
 +	pspid=NULL;
 +}
 +return;
 +}
 +*/
\ No newline at end of file diff --git a/plugins/ConnectionNotify/src/pid2name.h b/plugins/ConnectionNotify/src/pid2name.h new file mode 100644 index 0000000000..a3e46fca25 --- /dev/null +++ b/plugins/ConnectionNotify/src/pid2name.h @@ -0,0 +1,8 @@ +#pragma once
 +
 +#ifndef _INC_PID2NAME
 +#define _INC_PID2NAME
 +
 +void pid2name(DWORD,TCHAR* );
 +#endif
 +
 diff --git a/plugins/ConnectionNotify/src/resource.h b/plugins/ConnectionNotify/src/resource.h new file mode 100644 index 0000000000..19b940548b --- /dev/null +++ b/plugins/ConnectionNotify/src/resource.h @@ -0,0 +1,34 @@ +#ifndef IDC_STATIC
 +#define IDC_STATIC (-1)
 +#endif
 +
 +#define IDI_ICON1                               101
 +#define IDD_OPT_DIALOG                          102
 +#define IDI_ICON2                               103
 +#define IDD_FILTER_DIALOG                       105
 +#define IDI_ICON3                               110
 +#define IDI_ICON4                               111
 +#define IDI_ICON5                               114
 +#define IDI_ICON6                               115
 +#define ID_TEXT_NAME                            1000
 +#define IDC_RESOLVEIP                           1001
 +#define IDC_LIST_EXCEPTIONS                     1002
 +#define IDC_INTERVAL                            1003
 +#define ID_CHK_DEFAULTACTION                    1004
 +#define ID_DELETE                               1005
 +#define ID_DOWN                                 1006
 +#define ID_ADD                                  1007
 +#define ID_UP                                   1008
 +#define IDC_SETCOLOURS                          1009
 +#define IDC_INTERVAL1                           1010
 +#define IDC_BGCOLOR                             1011
 +#define IDC_FGCOLOR                             1012
 +#define IDC_STATUS                              1016
 +#define IDC_VERSION                             1017
 +#define ID_TXT_LOCAL_IP                         1070
 +#define ID_TXT_REMOTE_IP                        1071
 +#define ID_CBO_ACTION                           1074
 +#define ID_TXT_REMOTE_PORT                      1075
 +#define ID_TXT_LOCAL_PORT                       1076
 +#define ID_CANCEL                               1077
 +#define ID_OK                                   1078
 diff --git a/plugins/ConnectionNotify/src/version.h b/plugins/ConnectionNotify/src/version.h new file mode 100644 index 0000000000..2a08e4521e --- /dev/null +++ b/plugins/ConnectionNotify/src/version.h @@ -0,0 +1,45 @@ +/*
 +Exchange notifier plugin for Miranda IM
 +
 +Copyright © 2006 Cristian Libotean, Attila Vajda
 +
 +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.
 +*/
 +
 +#ifndef M_NONNECTIONNOTIFY_VERSION_H
 +#define M_NONNECTIONNOTIFY_VERSION_H
 +
 +#define __MAJOR_VERSION   0
 +#define __MINOR_VERSION   1
 +#define __RELEASE_NUM     0
 +#define __BUILD_NUM       5
 +
 +#define VERSION PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM)
 +
 +#define __PLUGINVERSION_STRING      __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
 +#define __PLUGINVERSION_STRING_DOTS	__MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
 +#define __STRINGIFY_(x) #x
 +#define __STRINGIFY(x) __STRINGIFY_(x)
 +#define __VERSION_STRING            __STRINGIFY(__PLUGINVERSION_STRING_DOTS)
 +
 +#define __DESCRIPTION           "Notify with popup if some connection established"
 +#define __AUTHOR                "MaKaR"
 +#define __AUTHOREMAIL           "makar@poczta.of.pl"
 +#define __COPYRIGHT             "© 2011-2013 MaKaRSoFT"
 +#define __AUTHORWEB             "http://maciej.wycik.pl/miranda"
 +
 +#define __PLUGIN_DISPLAY_NAME   "ConnectionNotify"
 +
 +#endif //M_EXCHANGE_VERSION_H
 | 
