From d4b95c46e963cf742adaad520f15af4bcd867e6d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 6 Jul 2012 12:51:52 +0000 Subject: stdemail + stdurl git-svn-id: http://svn.miranda-ng.org/main/trunk@790 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/modules.cpp | 6 +- src/core/stdemail/commonheaders.cpp | 2 + src/core/stdemail/commonheaders.h | 93 ++++ src/core/stdemail/email.cpp | 83 ++++ src/core/stdemail/main.cpp | 72 +++ src/core/stdemail/resource.rc | 120 +++++ src/core/stdemail/stdemail_10.vcxproj | 216 +++++++++ src/core/stdemail/stdemail_10.vcxproj.filters | 44 ++ src/core/stdemail/version.h | 14 + src/core/stdemail/version.rc | 38 ++ src/core/stdurl/commonheaders.cpp | 2 + src/core/stdurl/commonheaders.h | 93 ++++ src/core/stdurl/main.cpp | 77 +++ src/core/stdurl/resource.rc | 120 +++++ src/core/stdurl/stdurl_10.vcxproj | 218 +++++++++ src/core/stdurl/stdurl_10.vcxproj.filters | 50 ++ src/core/stdurl/url.cpp | 182 +++++++ src/core/stdurl/url.h | 40 ++ src/core/stdurl/urldialogs.cpp | 664 ++++++++++++++++++++++++++ src/core/stdurl/version.h | 14 + src/core/stdurl/version.rc | 38 ++ src/core/stduserinfo/main.cpp | 2 +- 22 files changed, 2182 insertions(+), 6 deletions(-) create mode 100644 src/core/stdemail/commonheaders.cpp create mode 100644 src/core/stdemail/commonheaders.h create mode 100644 src/core/stdemail/email.cpp create mode 100644 src/core/stdemail/main.cpp create mode 100644 src/core/stdemail/resource.rc create mode 100644 src/core/stdemail/stdemail_10.vcxproj create mode 100644 src/core/stdemail/stdemail_10.vcxproj.filters create mode 100644 src/core/stdemail/version.h create mode 100644 src/core/stdemail/version.rc create mode 100644 src/core/stdurl/commonheaders.cpp create mode 100644 src/core/stdurl/commonheaders.h create mode 100644 src/core/stdurl/main.cpp create mode 100644 src/core/stdurl/resource.rc create mode 100644 src/core/stdurl/stdurl_10.vcxproj create mode 100644 src/core/stdurl/stdurl_10.vcxproj.filters create mode 100644 src/core/stdurl/url.cpp create mode 100644 src/core/stdurl/url.h create mode 100644 src/core/stdurl/urldialogs.cpp create mode 100644 src/core/stdurl/version.h create mode 100644 src/core/stdurl/version.rc (limited to 'src/core') diff --git a/src/core/modules.cpp b/src/core/modules.cpp index d33fc47a84..8fa59f8a4d 100644 --- a/src/core/modules.cpp +++ b/src/core/modules.cpp @@ -42,8 +42,6 @@ int LoadProtocolsModule(void); // core: protocol manager int LoadAccountsModule(void); // core: account manager int LoadIgnoreModule(void); // protocol filter: ignore -int LoadSendRecvUrlModule(void); //send/recv -int LoadSendRecvEMailModule(void); //send/recv int LoadSendRecvAuthModule(void); //send/recv int LoadSendRecvFileModule(void); //send/recv @@ -146,7 +144,7 @@ int LoadDefaultModules(void) if ( LoadIgnoreModule()) return 1; if ( LoadVisibilityModule()) return 1; - for (int i=0; i < 1; i++) { + for (int i=0; i < 3; i++) { if ( pluginDefault[i].pImpl ) continue; @@ -154,8 +152,6 @@ int LoadDefaultModules(void) return 1; } - if ( !pluginDefault[ 1].pImpl) if ( LoadSendRecvUrlModule()) return 1; - if ( !pluginDefault[ 2].pImpl) if ( LoadSendRecvEMailModule()) return 1; if ( !pluginDefault[ 3].pImpl) if ( LoadSendRecvAuthModule()) return 1; if ( !pluginDefault[ 4].pImpl) if ( LoadSendRecvFileModule()) return 1; if ( !pluginDefault[ 5].pImpl) if ( LoadHelpModule()) return 1; diff --git a/src/core/stdemail/commonheaders.cpp b/src/core/stdemail/commonheaders.cpp new file mode 100644 index 0000000000..95b2201163 --- /dev/null +++ b/src/core/stdemail/commonheaders.cpp @@ -0,0 +1,2 @@ +#include "commonheaders.h" + diff --git a/src/core/stdemail/commonheaders.h b/src/core/stdemail/commonheaders.h new file mode 100644 index 0000000000..c9ed5a65d2 --- /dev/null +++ b/src/core/stdemail/commonheaders.h @@ -0,0 +1,93 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +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. +*/ + +// to enable all 0.9.0 core functions +#define MIRANDA_VER 0x0A00 + +#define WINVER 0x0700 +#define _WIN32_WINNT 0x0700 +#define _WIN32_IE 0x0601 + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "version.h" + +#include "../../resource.h" +#include "../stdplug.h" + +extern HINSTANCE hInst; diff --git a/src/core/stdemail/email.cpp b/src/core/stdemail/email.cpp new file mode 100644 index 0000000000..23694dbddb --- /dev/null +++ b/src/core/stdemail/email.cpp @@ -0,0 +1,83 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +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. +*/ +#include "commonheaders.h" + +static HANDLE hEMailMenuItem; + +void SendEmailThread(void *szUrl) +{ + ShellExecuteA(NULL, "open", (char*)szUrl, "", "", SW_SHOW); + mir_free(szUrl); + return; +} + +static INT_PTR SendEMailCommand(WPARAM wParam, LPARAM lParam) +{ + DBVARIANT dbv; + char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + if (szProto == NULL || DBGetContactSettingString((HANDLE)wParam, szProto, "e-mail", &dbv)) { + if (DBGetContactSettingString((HANDLE)wParam, "UserInfo", "Mye-mail0", &dbv)) { + MessageBox((HWND)lParam, TranslateT("User has not registered an e-mail address"), TranslateT("Send e-mail"), MB_OK); + return 1; + } + } + char *szUrl = (char*)mir_alloc(lstrlenA(dbv.pszVal)+8); + lstrcpyA(szUrl, "mailto:"); + lstrcatA(szUrl, dbv.pszVal); + mir_free(dbv.pszVal); + forkthread(SendEmailThread, 0, szUrl); + return 0; +} + +static int EMailPreBuildMenu(WPARAM wParam, LPARAM) +{ + CLISTMENUITEM mi = { 0 }; + mi.cbSize = sizeof(mi); + mi.flags = CMIM_FLAGS; + + DBVARIANT dbv = { 0 }; + char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + if (szProto == NULL || DBGetContactSettingString((HANDLE)wParam, szProto, "e-mail", & dbv)) + if (DBGetContactSettingString((HANDLE)wParam, "UserInfo", "Mye-mail0", &dbv)) + mi.flags = CMIM_FLAGS | CMIF_HIDDEN; + + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hEMailMenuItem, (LPARAM)&mi); + if (dbv.pszVal) DBFreeVariant(&dbv); + return 0; +} + +int LoadSendRecvEMailModule(void) +{ + CLISTMENUITEM mi = { 0 }; + mi.cbSize = sizeof(mi); + mi.position = -2000010000; + mi.flags = CMIF_ICONFROMICOLIB; + mi.icolibItem = GetSkinIconHandle(SKINICON_OTHER_SENDEMAIL); + mi.pszName = LPGEN("&E-mail"); + mi.pszService = MS_EMAIL_SENDEMAIL; + hEMailMenuItem = Menu_AddContactMenuItem(&mi); + + CreateServiceFunction(MS_EMAIL_SENDEMAIL, SendEMailCommand); + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, EMailPreBuildMenu); + return 0; +} diff --git a/src/core/stdemail/main.cpp b/src/core/stdemail/main.cpp new file mode 100644 index 0000000000..87ac53085c --- /dev/null +++ b/src/core/stdemail/main.cpp @@ -0,0 +1,72 @@ +/* + +Standard URL plugin for Myranda IM + +Copyright (C) 2012 George Hazan + +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., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "commonheaders.h" + +int LoadSendRecvEMailModule(void); + +HINSTANCE hInst; +int hLangpack; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + MIRANDA_VERSION_DWORD, + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {b774d10a-c761-11e1-8405-27e76188709b} + {0xb774d10a, 0xc761, 0x11e1, {0x84, 0x05, 0x27, 0xe7, 0x61, 0x88, 0x70, 0x9b }} +}; + +static const MUUID interfaces[] = { MIID_SREMAIL, MIID_LAST }; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + + LoadSendRecvEMailModule(); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + return 0; +} diff --git a/src/core/stdemail/resource.rc b/src/core/stdemail/resource.rc new file mode 100644 index 0000000000..16f290a120 --- /dev/null +++ b/src/core/stdemail/resource.rc @@ -0,0 +1,120 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\..\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include +#include + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_URLRECV DIALOGEX 0, 0, 215, 140 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "URL Received" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "&Open URL",IDOK,"MButtonClass",WS_TABSTOP,11,120,57,14,WS_EX_NOACTIVATE | 0x10000000L + PUSHBUTTON "&Reply",IDC_REPLY,82,120,50,14 + PUSHBUTTON "&Close",IDCANCEL,148,120,50,14 + CONTROL "",IDC_PROTOCOL,"Button",BS_OWNERDRAW | WS_TABSTOP,5,7,12,12 + LTEXT "",IDC_NAME,19,7,118,9,SS_NOPREFIX | SS_CENTERIMAGE + CONTROL "&A",IDC_ADD,"MButtonClass",WS_TABSTOP,140,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "6",IDC_USERMENU,"MButtonClass",WS_TABSTOP,158,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "&D",IDC_DETAILS,"MButtonClass",WS_TABSTOP,176,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "&H",IDC_HISTORY,"MButtonClass",WS_TABSTOP,194,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + LTEXT "Date:",IDC_STATIC,5,21,29,8 + EDITTEXT IDC_DATE,34,21,176,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "URL:",IDC_STATIC,5,33,205,8 + EDITTEXT IDC_URL,5,43,205,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Description:",IDC_ST_ENTERMSG,5,60,205,8 + EDITTEXT IDC_MSG,5,70,205,44,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL +END + +IDD_URLSEND DIALOGEX 0, 0, 215, 126 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + COMBOBOX IDC_URLS,5,30,205,92,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_MESSAGE,5,57,205,44,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL + DEFPUSHBUTTON "&Send",IDOK,54,107,50,14 + PUSHBUTTON "&Cancel",IDCANCEL,113,107,50,14 + CONTROL "",IDC_PROTOCOL,"Button",BS_OWNERDRAW | WS_TABSTOP,5,7,12,12 + LTEXT "",IDC_NAME,19,7,118,9,SS_NOPREFIX | SS_CENTERIMAGE + CONTROL "&A",IDC_ADD,"MButtonClass",WS_TABSTOP,140,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "6",IDC_USERMENU,"MButtonClass",WS_TABSTOP,158,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "&D",IDC_DETAILS,"MButtonClass",WS_TABSTOP,176,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "&H",IDC_HISTORY,"MButtonClass",WS_TABSTOP,194,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + LTEXT "Enter URL:",IDC_ST_ENTERURL,5,20,205,8 + LTEXT "Enter description:",IDC_ST_ENTERMSG,5,47,205,8 +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED + IDD_URLRECV, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 210 + TOPMARGIN, 5 + BOTTOMMARGIN, 135 + END + + IDD_URLSEND, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 210 + TOPMARGIN, 5 + BOTTOMMARGIN, 121 + END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\..\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include \r\n" + "#include \r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED diff --git a/src/core/stdemail/stdemail_10.vcxproj b/src/core/stdemail/stdemail_10.vcxproj new file mode 100644 index 0000000000..029c0bef3f --- /dev/null +++ b/src/core/stdemail/stdemail_10.vcxproj @@ -0,0 +1,216 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + stdemail + {A5B558C6-C767-11E1-A335-F6EB6188709B} + + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + EditAndContinue + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/core/stdemail/stdemail_10.vcxproj.filters b/src/core/stdemail/stdemail_10.vcxproj.filters new file mode 100644 index 0000000000..6d0ae999f0 --- /dev/null +++ b/src/core/stdemail/stdemail_10.vcxproj.filters @@ -0,0 +1,44 @@ + + + + + {5c074c9e-6c66-4233-bbd3-a50170fccf47} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {e30af2c4-42d4-4342-8eb9-2dbca157c6bb} + h;hpp;hxx;hm;inl + + + {9208a050-ffae-47fa-bc98-4ca4f79d37d7} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/src/core/stdemail/version.h b/src/core/stdemail/version.h new file mode 100644 index 0000000000..546634f19d --- /dev/null +++ b/src/core/stdemail/version.h @@ -0,0 +1,14 @@ + +#include + +#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION +#define __VERSION_STRING MIRANDA_VERSION_STRING + +#define __PLUGIN_NAME "stdemail" +#define __INTERNAL_NAME "stdemail" +#define __FILENAME "stdemail.dll" +#define __DESCRIPTION "Core module for e-mail handling." +#define __AUTHOR "Myranda team" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "http://nightly.miranda.im" +#define __COPYRIGHT "© 2012 Myranda team" diff --git a/src/core/stdemail/version.rc b/src/core/stdemail/version.rc new file mode 100644 index 0000000000..e637f0cb33 --- /dev/null +++ b/src/core/stdemail/version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#include "afxres.h" +#include "version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/src/core/stdurl/commonheaders.cpp b/src/core/stdurl/commonheaders.cpp new file mode 100644 index 0000000000..95b2201163 --- /dev/null +++ b/src/core/stdurl/commonheaders.cpp @@ -0,0 +1,2 @@ +#include "commonheaders.h" + diff --git a/src/core/stdurl/commonheaders.h b/src/core/stdurl/commonheaders.h new file mode 100644 index 0000000000..c9ed5a65d2 --- /dev/null +++ b/src/core/stdurl/commonheaders.h @@ -0,0 +1,93 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +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. +*/ + +// to enable all 0.9.0 core functions +#define MIRANDA_VER 0x0A00 + +#define WINVER 0x0700 +#define _WIN32_WINNT 0x0700 +#define _WIN32_IE 0x0601 + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "version.h" + +#include "../../resource.h" +#include "../stdplug.h" + +extern HINSTANCE hInst; diff --git a/src/core/stdurl/main.cpp b/src/core/stdurl/main.cpp new file mode 100644 index 0000000000..dbcaa34ec0 --- /dev/null +++ b/src/core/stdurl/main.cpp @@ -0,0 +1,77 @@ +/* + +Standard URL plugin for Myranda IM + +Copyright (C) 2012 George Hazan + +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., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "commonheaders.h" + +int LoadSendRecvUrlModule(void); + +CLIST_INTERFACE* pcli; +TIME_API tmi; +HINSTANCE hInst; +int hLangpack; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + MIRANDA_VERSION_DWORD, + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {b774d10a-c761-11e1-8405-27e76188709b} + {0xb774d10a, 0xc761, 0x11e1, {0x84, 0x05, 0x27, 0xe7, 0x61, 0x88, 0x70, 0x9b }} +}; + +static const MUUID interfaces[] = { MIID_SRURL, MIID_LAST }; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + mir_getTMI(&tmi); + + pcli = ( CLIST_INTERFACE* )CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, (LPARAM)hInst); + + LoadSendRecvUrlModule(); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + return 0; +} diff --git a/src/core/stdurl/resource.rc b/src/core/stdurl/resource.rc new file mode 100644 index 0000000000..16f290a120 --- /dev/null +++ b/src/core/stdurl/resource.rc @@ -0,0 +1,120 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\..\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include +#include + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_URLRECV DIALOGEX 0, 0, 215, 140 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "URL Received" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + CONTROL "&Open URL",IDOK,"MButtonClass",WS_TABSTOP,11,120,57,14,WS_EX_NOACTIVATE | 0x10000000L + PUSHBUTTON "&Reply",IDC_REPLY,82,120,50,14 + PUSHBUTTON "&Close",IDCANCEL,148,120,50,14 + CONTROL "",IDC_PROTOCOL,"Button",BS_OWNERDRAW | WS_TABSTOP,5,7,12,12 + LTEXT "",IDC_NAME,19,7,118,9,SS_NOPREFIX | SS_CENTERIMAGE + CONTROL "&A",IDC_ADD,"MButtonClass",WS_TABSTOP,140,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "6",IDC_USERMENU,"MButtonClass",WS_TABSTOP,158,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "&D",IDC_DETAILS,"MButtonClass",WS_TABSTOP,176,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "&H",IDC_HISTORY,"MButtonClass",WS_TABSTOP,194,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + LTEXT "Date:",IDC_STATIC,5,21,29,8 + EDITTEXT IDC_DATE,34,21,176,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER + LTEXT "URL:",IDC_STATIC,5,33,205,8 + EDITTEXT IDC_URL,5,43,205,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Description:",IDC_ST_ENTERMSG,5,60,205,8 + EDITTEXT IDC_MSG,5,70,205,44,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL +END + +IDD_URLSEND DIALOGEX 0, 0, 215, 126 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + COMBOBOX IDC_URLS,5,30,205,92,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP + EDITTEXT IDC_MESSAGE,5,57,205,44,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL + DEFPUSHBUTTON "&Send",IDOK,54,107,50,14 + PUSHBUTTON "&Cancel",IDCANCEL,113,107,50,14 + CONTROL "",IDC_PROTOCOL,"Button",BS_OWNERDRAW | WS_TABSTOP,5,7,12,12 + LTEXT "",IDC_NAME,19,7,118,9,SS_NOPREFIX | SS_CENTERIMAGE + CONTROL "&A",IDC_ADD,"MButtonClass",WS_TABSTOP,140,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "6",IDC_USERMENU,"MButtonClass",WS_TABSTOP,158,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "&D",IDC_DETAILS,"MButtonClass",WS_TABSTOP,176,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + CONTROL "&H",IDC_HISTORY,"MButtonClass",WS_TABSTOP,194,5,16,14,WS_EX_NOACTIVATE | 0x10000000L + LTEXT "Enter URL:",IDC_ST_ENTERURL,5,20,205,8 + LTEXT "Enter description:",IDC_ST_ENTERMSG,5,47,205,8 +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED + IDD_URLRECV, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 210 + TOPMARGIN, 5 + BOTTOMMARGIN, 135 + END + + IDD_URLSEND, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 210 + TOPMARGIN, 5 + BOTTOMMARGIN, 121 + END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\..\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include \r\n" + "#include \r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED diff --git a/src/core/stdurl/stdurl_10.vcxproj b/src/core/stdurl/stdurl_10.vcxproj new file mode 100644 index 0000000000..ebc2b835ad --- /dev/null +++ b/src/core/stdurl/stdurl_10.vcxproj @@ -0,0 +1,218 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + stdurl + {769FAC86-C761-11E1-A66F-0BE76188709B} + + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Core\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Core\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + EditAndContinue + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda32.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Full + OnlyExplicitInline + Size + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + true + false + true + Fast + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + true + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Disabled + ..\..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;ADDCONTACTPLUS_EXPORTS;%(PreprocessorDefinitions) + false + true + EnableFastChecks + MultiThreadedDebugDLL + true + Level3 + 4996;%(DisableSpecificWarnings) + Use + commonheaders.h + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\..\include\msapi;..\..\..\include + + + miranda64.lib;ws2_32.lib;comctl32.lib;%(AdditionalDependencies) + true + 0x3ae00000 + false + $(IntDir)$(TargetName).lib + Windows + $(SolutionDir)\lib + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/core/stdurl/stdurl_10.vcxproj.filters b/src/core/stdurl/stdurl_10.vcxproj.filters new file mode 100644 index 0000000000..046e56322f --- /dev/null +++ b/src/core/stdurl/stdurl_10.vcxproj.filters @@ -0,0 +1,50 @@ + + + + + {5c074c9e-6c66-4233-bbd3-a50170fccf47} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {e30af2c4-42d4-4342-8eb9-2dbca157c6bb} + h;hpp;hxx;hm;inl + + + {9208a050-ffae-47fa-bc98-4ca4f79d37d7} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + \ No newline at end of file diff --git a/src/core/stdurl/url.cpp b/src/core/stdurl/url.cpp new file mode 100644 index 0000000000..618de1c55f --- /dev/null +++ b/src/core/stdurl/url.cpp @@ -0,0 +1,182 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +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. +*/ +#include "commonheaders.h" +#include +#include "url.h" + +HANDLE hUrlWindowList = NULL; +static HANDLE hEventContactSettingChange = NULL; +static HANDLE hContactDeleted = NULL; +static HANDLE hSRUrlMenuItem = NULL; + +INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + +static INT_PTR ReadUrlCommand(WPARAM, LPARAM lParam) +{ + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_URLRECV), NULL, DlgProcUrlRecv, lParam); + return 0; +} + +static int UrlEventAdded(WPARAM wParam, LPARAM lParam) +{ + CLISTEVENT cle; + DBEVENTINFO dbei; + TCHAR szTooltip[256]; + + ZeroMemory(&dbei, sizeof(dbei)); + dbei.cbSize = sizeof(dbei); + dbei.cbBlob = 0; + CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei); + if (dbei.flags&(DBEF_SENT|DBEF_READ) || dbei.eventType != EVENTTYPE_URL) return 0; + + SkinPlaySound("RecvUrl"); + ZeroMemory(&cle, sizeof(cle)); + cle.cbSize = sizeof(cle); + cle.flags = CLEF_TCHAR; + cle.hContact = (HANDLE)wParam; + cle.hDbEvent = (HANDLE)lParam; + cle.hIcon = LoadSkinIcon(SKINICON_EVENT_URL); + cle.pszService = "SRUrl/ReadUrl"; + mir_sntprintf(szTooltip, SIZEOF(szTooltip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName((HANDLE)wParam, 0)); + cle.ptszTooltip = szTooltip; + CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); + return 0; +} + +static INT_PTR SendUrlCommand(WPARAM wParam, LPARAM) +{ + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_URLSEND), NULL, DlgProcUrlSend, wParam); + return 0; +} + +static void RestoreUnreadUrlAlerts(void) +{ + CLISTEVENT cle = {0}; + DBEVENTINFO dbei = {0}; + TCHAR toolTip[256]; + HANDLE hDbEvent, hContact; + + dbei.cbSize = sizeof(dbei); + cle.cbSize = sizeof(cle); + cle.hIcon = LoadSkinIcon(SKINICON_EVENT_URL); + cle.pszService = "SRUrl/ReadUrl"; + + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + while (hContact) { + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM)hContact, 0); + while (hDbEvent) { + dbei.cbBlob = 0; + CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei); + if ( !(dbei.flags&(DBEF_SENT|DBEF_READ)) && dbei.eventType == EVENTTYPE_URL) { + cle.hContact = hContact; + cle.hDbEvent = hDbEvent; + cle.flags = CLEF_TCHAR; + mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("URL from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); + cle.ptszTooltip = toolTip; + CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); + } + hDbEvent = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDbEvent, 0); + } + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } +} + +static int ContactSettingChanged(WPARAM wParam, LPARAM lParam) +{ + DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; + char *szProto; + + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + if (lstrcmpA(cws->szModule, "CList") && (szProto == NULL || lstrcmpA(cws->szModule, szProto))) return 0; + WindowList_Broadcast(hUrlWindowList, DM_UPDATETITLE, 0, 0); + return 0; +} + +static int SRUrlPreBuildMenu(WPARAM wParam, LPARAM) +{ + CLISTMENUITEM mi = { 0 }; + mi.cbSize = sizeof(mi); + mi.flags = CMIM_FLAGS | CMIF_HIDDEN; + + char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + if (szProto != NULL) + if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_URLSEND) + mi.flags = CMIM_FLAGS; + + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hSRUrlMenuItem, (LPARAM)&mi); + return 0; +} + +static int SRUrlModulesLoaded(WPARAM, LPARAM) +{ + CLISTMENUITEM mi = { 0 }; + mi.cbSize = sizeof(mi); + mi.position = -2000040000; + mi.flags = CMIF_ICONFROMICOLIB; + mi.icolibItem = GetSkinIconHandle(SKINICON_EVENT_URL); + mi.pszName = LPGEN("Web Page Address (&URL)"); + mi.pszService = MS_URL_SENDURL; + hSRUrlMenuItem = Menu_AddContactMenuItem(&mi); + + RestoreUnreadUrlAlerts(); + return 0; +} + +static int SRUrlShutdown(WPARAM, LPARAM) +{ + if (hEventContactSettingChange) + UnhookEvent(hEventContactSettingChange); + + if (hContactDeleted) + UnhookEvent(hContactDeleted); + + if (hUrlWindowList) + WindowList_BroadcastAsync(hUrlWindowList, WM_CLOSE, 0, 0); + + return 0; +} + +int UrlContactDeleted(WPARAM wParam, LPARAM) +{ + HWND h = WindowList_Find(hUrlWindowList, (HANDLE)wParam); + if (h) + SendMessage(h, WM_CLOSE, 0, 0); + + return 0; +} + +int LoadSendRecvUrlModule(void) +{ + hUrlWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0); + HookEvent(ME_SYSTEM_MODULESLOADED, SRUrlModulesLoaded); + HookEvent(ME_DB_EVENT_ADDED, UrlEventAdded); + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, SRUrlPreBuildMenu); + hEventContactSettingChange = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ContactSettingChanged); + hContactDeleted = HookEvent(ME_DB_CONTACT_DELETED, UrlContactDeleted); + HookEvent(ME_SYSTEM_PRESHUTDOWN, SRUrlShutdown); + CreateServiceFunction(MS_URL_SENDURL, SendUrlCommand); + CreateServiceFunction("SRUrl/ReadUrl", ReadUrlCommand); + SkinAddNewSoundEx("RecvUrl", LPGEN("URL"), LPGEN("Incoming")); + return 0; +} diff --git a/src/core/stdurl/url.h b/src/core/stdurl/url.h new file mode 100644 index 0000000000..98cbee51fe --- /dev/null +++ b/src/core/stdurl/url.h @@ -0,0 +1,40 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +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. +*/ + +#define TIMEOUT_URLSEND 9000 +#define HM_EVENTSENT (WM_USER+10) +#define DM_UPDATETITLE (WM_USER+11) + +#define DDEMESSAGETIMEOUT 1000 + +struct UrlRcvData { + HANDLE hContact; + HANDLE hDbEvent; +}; + +struct UrlSendData { + HANDLE hContact; + HANDLE hSendId; + HANDLE hAckEvent; + char *sendBuffer; +}; diff --git a/src/core/stdurl/urldialogs.cpp b/src/core/stdurl/urldialogs.cpp new file mode 100644 index 0000000000..b0b8fa00b2 --- /dev/null +++ b/src/core/stdurl/urldialogs.cpp @@ -0,0 +1,664 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +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. +*/ +#include "commonheaders.h" +#include "url.h" + +INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); + +extern HANDLE hUrlWindowList; + +static void sttUpdateTitle(HWND hwndDlg, HANDLE hContact) +{ + TCHAR newtitle[256], oldtitle[256]; + TCHAR *szStatus, *contactName, *pszNewTitleStart = TranslateT("Send URL to"); + char *szProto; + + if (hContact) { + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + if (szProto) { + CONTACTINFO ci; + int hasName = 0; + char buf[128]; + ZeroMemory(&ci, sizeof(ci)); + + ci.cbSize = sizeof(ci); + ci.hContact = hContact; + ci.szProto = szProto; + ci.dwFlag = CNF_UNIQUEID; + if ( !CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { + switch(ci.type) { + case CNFT_ASCIIZ: + hasName = 1; + mir_snprintf(buf, SIZEOF(buf), "%s", ci.pszVal); + mir_free(ci.pszVal); + break; + case CNFT_DWORD: + hasName = 1; + mir_snprintf(buf, SIZEOF(buf), "%u", ci.dVal); + break; + } } + + contactName = pcli->pfnGetContactDisplayName(hContact, 0); + if (hasName) + SetDlgItemTextA(hwndDlg, IDC_NAME, buf); + else + SetDlgItemText(hwndDlg, IDC_NAME, contactName); + + szStatus = pcli->pfnGetStatusModeDescription(szProto == NULL ? ID_STATUS_OFFLINE : DBGetContactSettingWord(hContact, szProto, "Status", ID_STATUS_OFFLINE), 0); + mir_sntprintf(newtitle, SIZEOF(newtitle), _T("%s %s (%s)"), pszNewTitleStart, contactName, szStatus); + } + } + else lstrcpyn(newtitle, pszNewTitleStart, SIZEOF(newtitle)); + + GetWindowText(hwndDlg, oldtitle, SIZEOF(oldtitle)); + + if (lstrcmp(newtitle, oldtitle)) //swt() flickers even if the title hasn't actually changed + SetWindowText(hwndDlg, newtitle); +} + +INT_PTR CALLBACK DlgProcUrlRecv(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + struct UrlRcvData *dat = (struct UrlRcvData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_URL); + Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add Contact Permanently to List")); + Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View User's Details")); + Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View User's History")); + Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User Menu")); + + dat = (struct UrlRcvData*)mir_alloc(sizeof(struct UrlRcvData)); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); + + dat->hContact = ((CLISTEVENT*)lParam)->hContact; + dat->hDbEvent = ((CLISTEVENT*)lParam)->hDbEvent; + + WindowList_Add(hUrlWindowList, hwndDlg, dat->hContact); + { + DBEVENTINFO dbei; + TCHAR* contactName; + TCHAR msg[128]; + + ZeroMemory(&dbei, sizeof(dbei)); + dbei.cbSize = sizeof(dbei); + dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)dat->hDbEvent, 0); + dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob); + CallService(MS_DB_EVENT_GET, (WPARAM)dat->hDbEvent, (LPARAM)&dbei); + SetDlgItemTextA(hwndDlg, IDC_URL, (char*)dbei.pBlob); + SetDlgItemTextA(hwndDlg, IDC_MSG, (char*)dbei.pBlob+lstrlenA((char*)dbei.pBlob)+1); + mir_free(dbei.pBlob); + + CallService(MS_DB_EVENT_MARKREAD, (WPARAM)dat->hContact, (LPARAM)dat->hDbEvent); + + contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0); + mir_sntprintf(msg, SIZEOF(msg), TranslateT("URL from %s"), contactName); + SetWindowText(hwndDlg, msg); + SetDlgItemText(hwndDlg, IDC_FROM, contactName); + SendDlgItemMessage(hwndDlg, IDOK, BUTTONSETARROW, 1, 0); + { TCHAR str[128]; + tmi.printTimeStamp(NULL, dbei.timestamp, _T("t d"), str, SIZEOF(str), 0); + SetDlgItemText(hwndDlg, IDC_DATE, str); + } } + + // From message dlg + if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) + ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); + + SendMessage(hwndDlg, DM_UPDATETITLE, 0, 0); + // From message dlg end + + Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "SRUrl", "recv"); + return TRUE; + + case WM_MEASUREITEM: + return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); + + case WM_DRAWITEM: + { + LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; + if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { + char *szProto; + + szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); + if (szProto) { + HICON hIcon; + + hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); + if (hIcon) { + DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); + DestroyIcon(hIcon); + } } } } + return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); + + case DM_UPDATETITLE: + sttUpdateTitle(hwndDlg, dat->hContact); + break; + + case WM_COMMAND: + if (dat) + if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) + break; + switch(LOWORD(wParam)) { + case IDOK: + { HMENU hMenu, hSubMenu; + RECT rc; + char url[256]; + + hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXT)); + hSubMenu = GetSubMenu(hMenu, 6); + TranslateMenu(hSubMenu); + GetWindowRect((HWND)lParam, &rc); + GetDlgItemTextA(hwndDlg, IDC_URL, url, SIZEOF(url)); + switch(TrackPopupMenu(hSubMenu, TPM_RETURNCMD, rc.left, rc.bottom, 0, hwndDlg, NULL)) { + case IDM_OPENNEW: + CallService(MS_UTILS_OPENURL, 1, (LPARAM)url); + break; + case IDM_OPENEXISTING: + CallService(MS_UTILS_OPENURL, 0, (LPARAM)url); + break; + case IDM_COPYLINK: + { HGLOBAL hData; + if ( !OpenClipboard(hwndDlg)) break; + EmptyClipboard(); + hData = GlobalAlloc(GMEM_MOVEABLE, lstrlenA(url)+1); + lstrcpyA((char*)GlobalLock(hData), url); + GlobalUnlock(hData); + SetClipboardData(CF_TEXT, hData); + CloseClipboard(); + break; + } + } + DestroyMenu(hMenu); + } + return TRUE; + + case IDC_USERMENU: + { + RECT rc; + HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); + GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc); + TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); + DestroyMenu(hMenu); + } + break; + + case IDC_HISTORY: + CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); + break; + + case IDC_DETAILS: + CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); + break; + + case IDC_ADD: + { + ADDCONTACTSTRUCT acs = {0}; + + acs.handle = dat->hContact; + acs.handleType = HANDLE_CONTACT; + acs.szProto = 0; + CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); + } + if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) { + ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); + } + break; + + case IDC_REPLY: + CallService(MS_MSG_SENDMESSAGE, (WPARAM)dat->hContact, 0); + //fall through + case IDCANCEL: + DestroyWindow(hwndDlg); + return TRUE; + } + break; + + case WM_DESTROY: + Window_FreeIcon_IcoLib(hwndDlg); + Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); + Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); + Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY); + Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU); + + WindowList_Remove(hUrlWindowList, hwndDlg); + mir_free(dat); + Utils_SaveWindowPosition(hwndDlg, NULL, "SRUrl", "recv"); + break; + } + return FALSE; +} + +static int ddeAcked, ddeData; +static ATOM hSzDdeData; +static HWND hwndDde; +static HGLOBAL hGlobalDdeData; +static LRESULT DdeMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + UINT_PTR hSzItem; + + switch(msg) { + case WM_DDE_ACK: + ddeAcked = 1; + hwndDde = (HWND)wParam; + break; + + case WM_DDE_DATA: + UnpackDDElParam(msg, lParam, (PUINT_PTR)&hGlobalDdeData, (PUINT_PTR)&hSzItem); + ddeData = 1; + if (hGlobalDdeData) { + DDEDATA* data = (DDEDATA*)GlobalLock(hGlobalDdeData); + if (data->fAckReq) { + DDEACK ack = {0}; + PostMessage((HWND)wParam, WM_DDE_ACK, (WPARAM)hwndDlg, PackDDElParam(WM_DDE_ACK, *(PUINT)&ack, hSzItem)); + } + else GlobalDeleteAtom((ATOM)hSzItem); + GlobalUnlock(hGlobalDdeData); + } + else GlobalDeleteAtom((ATOM)hSzItem); + break; + } + return 0; +} + +static HGLOBAL DoDdeRequest(const char *szItemName, HWND hwndDlg) +{ + ATOM hSzItemName; + DWORD timeoutTick, thisTick; + MSG msg; + + hSzItemName = GlobalAddAtomA(szItemName); + if ( !PostMessage(hwndDde, WM_DDE_REQUEST, (WPARAM)hwndDlg, MAKELPARAM(CF_TEXT, hSzItemName))) { + GlobalDeleteAtom(hSzItemName); + return NULL; + } + timeoutTick = GetTickCount()+5000; + ddeData = 0; ddeAcked = 0; + do { + if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + if (ddeData || ddeAcked) break; + thisTick = GetTickCount(); + if (thisTick>timeoutTick) break; + } + while (MsgWaitForMultipleObjects(0, NULL, FALSE, timeoutTick-thisTick, QS_ALLINPUT) == WAIT_OBJECT_0); + + if ( !ddeData) { + GlobalDeleteAtom(hSzItemName); + return NULL; + } + + return hGlobalDdeData; +} + +static void FreeDdeRequestData(HGLOBAL hData) +{ + DDEDATA *data; + data = (DDEDATA*)GlobalLock(hData); + if (data->fRelease) { + GlobalUnlock(hData); + GlobalFree(hData); + } + else GlobalUnlock(hData); +} + +static void AddBrowserPageToCombo(char *url, HWND hwndCombo) +{ + char *title, *frame, *end; + + if (url[0] != '"') return; + url++; + title = strchr(url, '"'); + if (title == NULL) return; + *title = '\0'; title++; + if (*title) { + title+=2; + frame = strchr(title, '"'); + if (frame == NULL) return; + *frame = '\0'; frame++; + if (*frame) { + frame+=2; + end = strchr(frame, '"'); + if (end == NULL) return; + *end = '\0'; + } + else frame = NULL; + } + else title = frame = NULL; + if (frame == NULL || *frame == 0) { + char *szItemData; + int i; + char szExistingUrl[1024]; + + for (i = SendMessage(hwndCombo, CB_GETCOUNT, 0, 0)-1;i>=0;i--) { + if (SendMessage(hwndCombo, CB_GETLBTEXTLEN, i, 0) >= SIZEOF(szExistingUrl)) + continue; + SendMessageA(hwndCombo, CB_GETLBTEXT, i, (LPARAM)szExistingUrl); + if ( !lstrcmpA(szExistingUrl, url)) return; + } + i = SendMessageA(hwndCombo, CB_ADDSTRING, 0, (LPARAM)url); + szItemData = mir_strdup(title); + SendMessage(hwndCombo, CB_SETITEMDATA, i, (LPARAM)szItemData); + } +} + +//see Q160957 and http://developer.netscape.com/docs/manuals/communicator/DDE/index.htm +static void GetOpenBrowserUrlsForBrowser(const char *szBrowser, HWND hwndDlg, HWND hwndCombo) +{ + ATOM hSzBrowser, hSzTopic; + int windowCount, i; + DWORD *windowId; + DWORD dwResult; + HGLOBAL hData; + DDEDATA *data; + int dataLength; + + hSzBrowser = GlobalAddAtomA(szBrowser); + + hSzTopic = GlobalAddAtomA("WWW_ListWindows"); + ddeAcked = 0; + if ( !SendMessageTimeout(HWND_BROADCAST, WM_DDE_INITIATE, (WPARAM)hwndDlg, MAKELPARAM(hSzBrowser, hSzTopic), SMTO_ABORTIFHUNG|SMTO_NORMAL, DDEMESSAGETIMEOUT, (PDWORD_PTR)&dwResult) + || !ddeAcked) { + GlobalDeleteAtom(hSzTopic); + GlobalDeleteAtom(hSzBrowser); + return; + } + hData = DoDdeRequest("WWW_ListWindows", hwndDlg); + if (hData == NULL) { + GlobalDeleteAtom(hSzTopic); + GlobalDeleteAtom(hSzBrowser); + return; + } + dataLength = GlobalSize(hData)-offsetof(DDEDATA, Value); + data = (DDEDATA*)GlobalLock(hData); + windowCount = dataLength/sizeof(DWORD); + windowId = (PDWORD)mir_alloc(sizeof(DWORD)*windowCount); + memcpy(windowId, data->Value, windowCount*sizeof(DWORD)); + GlobalUnlock(hData); + FreeDdeRequestData(hData); + PostMessage(hwndDde, WM_DDE_TERMINATE, (WPARAM)hwndDlg, 0); + GlobalDeleteAtom(hSzTopic); + + hSzTopic = GlobalAddAtomA("WWW_GetWindowInfo"); + ddeAcked = 0; + if ( !SendMessageTimeout(HWND_BROADCAST, WM_DDE_INITIATE, (WPARAM)hwndDlg, MAKELPARAM(hSzBrowser, hSzTopic), SMTO_ABORTIFHUNG|SMTO_NORMAL, DDEMESSAGETIMEOUT, (PDWORD_PTR)&dwResult) + || !ddeAcked) { + GlobalDeleteAtom(hSzTopic); + GlobalDeleteAtom(hSzBrowser); + mir_free(windowId); + return; + } + for (i=0;iValue, hwndCombo); + GlobalUnlock(hData); + FreeDdeRequestData(hData); + } + } + PostMessage(hwndDde, WM_DDE_TERMINATE, (WPARAM)hwndDlg, 0); + GlobalDeleteAtom(hSzTopic); + GlobalDeleteAtom(hSzBrowser); + mir_free(windowId); +} + +static void GetOpenBrowserUrls(HWND hwndDlg, HWND hwndCombo) +{ + GetOpenBrowserUrlsForBrowser("opera", hwndDlg, hwndCombo); + GetOpenBrowserUrlsForBrowser("netscape", hwndDlg, hwndCombo); + GetOpenBrowserUrlsForBrowser("iexplore", hwndDlg, hwndCombo); +} + +static WNDPROC OldSendEditProc; +static LRESULT CALLBACK SendEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_CHAR: + if (wParam == '\n' && GetKeyState(VK_CONTROL)&0x8000) { + PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0); + return 0; + } + break; + case WM_SYSCHAR: + if ((wParam == 's' || wParam == 'S') && GetKeyState(VK_MENU)&0x8000) { + PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0); + return 0; + } + break; + } + return CallWindowProc(OldSendEditProc, hwnd, msg, wParam, lParam); +} + +INT_PTR CALLBACK DlgProcUrlSend(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + struct UrlSendData* dat = (struct UrlSendData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + Window_SetIcon_IcoLib(hwndDlg, SKINICON_EVENT_URL); + Button_SetIcon_IcoLib(hwndDlg, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add Contact Permanently to List")); + Button_SetIcon_IcoLib(hwndDlg, IDC_DETAILS, SKINICON_OTHER_USERDETAILS, LPGEN("View User's Details")); + Button_SetIcon_IcoLib(hwndDlg, IDC_HISTORY, SKINICON_OTHER_HISTORY, LPGEN("View User's History")); + Button_SetIcon_IcoLib(hwndDlg, IDC_USERMENU, SKINICON_OTHER_DOWNARROW, LPGEN("User Menu")); + + SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_LIMITTEXT, 450, 0); + dat = (struct UrlSendData*)mir_alloc(sizeof(struct UrlSendData)); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); + dat->hContact = (HANDLE)lParam; + dat->hAckEvent = NULL; + dat->hSendId = NULL; + dat->sendBuffer = NULL; + + WindowList_Add(hUrlWindowList, hwndDlg, dat->hContact); + { + TCHAR *str = pcli->pfnGetContactDisplayName(dat->hContact, 0); + SetDlgItemText(hwndDlg, IDC_NAME, str); + } + + GetOpenBrowserUrls(hwndDlg, GetDlgItem(hwndDlg, IDC_URLS)); + SendDlgItemMessage(hwndDlg, IDC_URLS, CB_SETCURSEL, 0, 0); + if (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0))SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_URLS, CBN_SELCHANGE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDOK), (SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0) == CB_ERR)?FALSE:TRUE); + Utils_RestoreWindowPositionNoSize(hwndDlg, NULL, "SRUrl", "send"); + OldSendEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWLP_WNDPROC, (LONG_PTR)SendEditSubclassProc); + OldSendEditProc = (WNDPROC)SetWindowLongPtr(GetWindow(GetDlgItem(hwndDlg, IDC_URLS), GW_CHILD), GWLP_WNDPROC, (LONG_PTR)SendEditSubclassProc); + + // From message dlg + if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) + ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE); + + SendMessage(hwndDlg, DM_UPDATETITLE, 0, 0); + // From message dlg end + return TRUE; + + case WM_DDE_DATA: + case WM_DDE_ACK: + return DdeMessage(hwndDlg, msg, wParam, lParam); + + case WM_TIMER: + if (wParam == 0) { + //ICQ sendurl timed out + KillTimer(hwndDlg, 0); + MessageBox(hwndDlg, TranslateT("Send timed out"), _T(""), MB_OK); + EnableWindow(GetDlgItem(hwndDlg, IDOK), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_URLS), TRUE); + SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETREADONLY, FALSE, 0); + } + break; + + case WM_MEASUREITEM: + return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam); + + case WM_DRAWITEM: + { + LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; + if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_PROTOCOL)) { + char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); + if (szProto) { + HICON hIcon = (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); + if (hIcon) { + DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, NULL, DI_NORMAL); + DestroyIcon(hIcon); + } } } } + return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam); + + case DM_UPDATETITLE: + sttUpdateTitle(hwndDlg, dat->hContact); + break; + + case WM_COMMAND: + if (CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)dat->hContact)) + break; + switch (LOWORD(wParam)) + { + case IDOK: + { + char *body, *url; + int bodySize, urlSize; + + urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS))+1; + url = (char*)mir_alloc(urlSize); + GetDlgItemTextA(hwndDlg, IDC_URLS, url, urlSize); + if (url[0] == 0) { + mir_free(url); + break; + } + bodySize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE))+1; + body = (char*)mir_alloc(bodySize); + GetDlgItemTextA(hwndDlg, IDC_MESSAGE, body, bodySize); + + dat->sendBuffer = (char*)mir_realloc(dat->sendBuffer, lstrlenA(url)+lstrlenA(body)+2); + lstrcpyA(dat->sendBuffer, url); + lstrcpyA(dat->sendBuffer+lstrlenA(url)+1, body); + dat->hAckEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_EVENTSENT); + dat->hSendId = (HANDLE)CallContactService(dat->hContact, PSS_URL, 0, (LPARAM)dat->sendBuffer); + mir_free(url); + mir_free(body); + + //create a timeout timer + SetTimer(hwndDlg, 0, TIMEOUT_URLSEND, NULL); + EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_URLS), FALSE); + SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETREADONLY, TRUE, 0); + + return TRUE; + } + + case IDCANCEL: + DestroyWindow(hwndDlg); + return TRUE; + case IDC_URLS: + if (HIWORD(wParam) == CBN_SELCHANGE) { + int i, urlSize; + char *title; + i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCURSEL, 0, 0); + title = (char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, (WPARAM)i, 0); + SetDlgItemTextA(hwndDlg, IDC_MESSAGE, title); + urlSize = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETLBTEXTLEN, (WPARAM)i, 0); + EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0)); + } + else if (HIWORD(wParam) == CBN_EDITCHANGE) { + int urlSize = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URLS)); + EnableWindow(GetDlgItem(hwndDlg, IDOK), (urlSize>0)); + } + break; + case IDC_USERMENU: + { RECT rc; + HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->hContact, 0); + GetWindowRect(GetDlgItem(hwndDlg, IDC_USERMENU), &rc); + TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL); + DestroyMenu(hMenu); + } + break; + case IDC_HISTORY: + CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->hContact, 0); + break; + case IDC_DETAILS: + CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->hContact, 0); + break; + case IDC_ADD: + { ADDCONTACTSTRUCT acs = {0}; + + acs.handle = dat->hContact; + acs.handleType = HANDLE_CONTACT; + acs.szProto = 0; + CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs); + } + if ( !DBGetContactSettingByte(dat->hContact, "CList", "NotOnList", 0)) { + ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), FALSE); + } + break; + } + break; + case HM_EVENTSENT: + { ACKDATA *ack = (ACKDATA*)lParam; + DBEVENTINFO dbei; + if (ack->hProcess != dat->hSendId) break; + if (ack->hContact != dat->hContact) break; + if (ack->type != ACKTYPE_URL || ack->result != ACKRESULT_SUCCESS) break; + + ZeroMemory(&dbei, sizeof(dbei)); + dbei.cbSize = sizeof(dbei); + dbei.eventType = EVENTTYPE_URL; + dbei.flags = DBEF_SENT; + dbei.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); + dbei.timestamp = time(NULL); + dbei.cbBlob = (DWORD)(strlen(dat->sendBuffer)+strlen(dat->sendBuffer+strlen(dat->sendBuffer)+1)+2); + dbei.pBlob = (PBYTE)dat->sendBuffer; + CallService(MS_DB_EVENT_ADD, (WPARAM)dat->hContact, (LPARAM)&dbei); + KillTimer(hwndDlg, 0); + DestroyWindow(hwndDlg); + break; + } + case WM_DESTROY: + Window_FreeIcon_IcoLib(hwndDlg); + Button_FreeIcon_IcoLib(hwndDlg, IDC_ADD); + Button_FreeIcon_IcoLib(hwndDlg, IDC_DETAILS); + Button_FreeIcon_IcoLib(hwndDlg, IDC_HISTORY); + Button_FreeIcon_IcoLib(hwndDlg, IDC_USERMENU); + + WindowList_Remove(hUrlWindowList, hwndDlg); + SetWindowLongPtr(GetWindow(GetDlgItem(hwndDlg, IDC_URLS), GW_CHILD), GWLP_WNDPROC, (LONG_PTR)OldSendEditProc); + SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWLP_WNDPROC, (LONG_PTR)OldSendEditProc); + if (dat->hAckEvent) UnhookEvent(dat->hAckEvent); + if (dat->sendBuffer != NULL) mir_free(dat->sendBuffer); + mir_free(dat); + Utils_SaveWindowPosition(hwndDlg, NULL, "SRUrl", "send"); + { int i; + for (i = SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETCOUNT, 0, 0)-1;i>=0;i--) + mir_free((char*)SendDlgItemMessage(hwndDlg, IDC_URLS, CB_GETITEMDATA, i, 0)); + } + break; + } + + return FALSE; +} diff --git a/src/core/stdurl/version.h b/src/core/stdurl/version.h new file mode 100644 index 0000000000..7aa5b8216e --- /dev/null +++ b/src/core/stdurl/version.h @@ -0,0 +1,14 @@ + +#include + +#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION +#define __VERSION_STRING MIRANDA_VERSION_STRING + +#define __PLUGIN_NAME "stdurl" +#define __INTERNAL_NAME "stdurl" +#define __FILENAME "stdurl.dll" +#define __DESCRIPTION "Core module for URL handling." +#define __AUTHOR "Myranda team" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "http://nightly.miranda.im" +#define __COPYRIGHT "© 2012 Myranda team" diff --git a/src/core/stdurl/version.rc b/src/core/stdurl/version.rc new file mode 100644 index 0000000000..e637f0cb33 --- /dev/null +++ b/src/core/stdurl/version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#include "afxres.h" +#include "version.h" + +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL +#endif //_WIN32 + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/src/core/stduserinfo/main.cpp b/src/core/stduserinfo/main.cpp index 594f5ba805..88ed31e921 100644 --- a/src/core/stduserinfo/main.cpp +++ b/src/core/stduserinfo/main.cpp @@ -31,7 +31,7 @@ int hLangpack; pfnEnableThemeDialogTexture enableThemeDialogTexture; PLUGININFOEX pluginInfo = { - sizeof(PLUGININFOEX), + sizeof(PLUGININFOEX), __PLUGIN_NAME, MIRANDA_VERSION_DWORD, __DESCRIPTION, -- cgit v1.2.3