From cd6a5eee79c6c5ceccfcfe6063311ee6b7eff33d Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Sun, 18 May 2014 13:59:55 +0000 Subject: GmailNotifier rename git-svn-id: http://svn.miranda-ng.org/main/trunk@9226 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/GmailNotifier/GmailNotifier_10.vcxproj | 206 ++++++++++++++++ .../GmailNotifier/GmailNotifier_10.vcxproj.filters | 56 +++++ plugins/GmailNotifier/GmailNotifier_12.vcxproj | 212 ++++++++++++++++ .../GmailNotifier/GmailNotifier_12.vcxproj.filters | 56 +++++ plugins/GmailNotifier/res/empty.ico | Bin 0 -> 2550 bytes plugins/GmailNotifier/res/error.ico | Bin 0 -> 2550 bytes plugins/GmailNotifier/res/iconnew.ico | Bin 0 -> 2550 bytes plugins/GmailNotifier/res/options.rc | 139 +++++++++++ plugins/GmailNotifier/res/version.rc | 38 +++ plugins/GmailNotifier/src/check.cpp | 185 ++++++++++++++ plugins/GmailNotifier/src/gmail.h | 95 +++++++ plugins/GmailNotifier/src/main.cpp | 157 ++++++++++++ plugins/GmailNotifier/src/notify.cpp | 206 ++++++++++++++++ plugins/GmailNotifier/src/options.cpp | 274 +++++++++++++++++++++ plugins/GmailNotifier/src/resource.h | 48 ++++ plugins/GmailNotifier/src/stdafx.cpp | 18 ++ plugins/GmailNotifier/src/utility.cpp | 77 ++++++ plugins/GmailNotifier/src/version.h | 14 ++ 18 files changed, 1781 insertions(+) create mode 100644 plugins/GmailNotifier/GmailNotifier_10.vcxproj create mode 100644 plugins/GmailNotifier/GmailNotifier_10.vcxproj.filters create mode 100644 plugins/GmailNotifier/GmailNotifier_12.vcxproj create mode 100644 plugins/GmailNotifier/GmailNotifier_12.vcxproj.filters create mode 100644 plugins/GmailNotifier/res/empty.ico create mode 100644 plugins/GmailNotifier/res/error.ico create mode 100644 plugins/GmailNotifier/res/iconnew.ico create mode 100644 plugins/GmailNotifier/res/options.rc create mode 100644 plugins/GmailNotifier/res/version.rc create mode 100644 plugins/GmailNotifier/src/check.cpp create mode 100644 plugins/GmailNotifier/src/gmail.h create mode 100644 plugins/GmailNotifier/src/main.cpp create mode 100644 plugins/GmailNotifier/src/notify.cpp create mode 100644 plugins/GmailNotifier/src/options.cpp create mode 100644 plugins/GmailNotifier/src/resource.h create mode 100644 plugins/GmailNotifier/src/stdafx.cpp create mode 100644 plugins/GmailNotifier/src/utility.cpp create mode 100644 plugins/GmailNotifier/src/version.h (limited to 'plugins/GmailNotifier') diff --git a/plugins/GmailNotifier/GmailNotifier_10.vcxproj b/plugins/GmailNotifier/GmailNotifier_10.vcxproj new file mode 100644 index 0000000000..65d82b37bb --- /dev/null +++ b/plugins/GmailNotifier/GmailNotifier_10.vcxproj @@ -0,0 +1,206 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + GmailNotifier + {EDAAD28B-505B-4969-A8BB-97EAE818DEEA} + + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + DynamicLibrary + Unicode + + + DynamicLibrary + Unicode + true + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Full + true + curl\include\curl\;..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + NDEBUG;_WINDOWS;_USRDLL;CURL_STATICLIB;%(PreprocessorDefinitions) + true + Use + Level3 + gmail.h + Size + + + wininet.lib;wldap32.lib;ws2_32.lib;winmm.lib;UxTheme.lib;comctl32.lib;%(AdditionalDependencies) + $(ProfileDir)..\..\bin10\lib + true + Windows + true + true + false + $(IntDir)$(TargetName).lib + /PDBALTPATH:%_PDB% + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Full + true + curl\include\curl\;..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + NDEBUG;_WINDOWS;_USRDLL;CURL_STATICLIB;%(PreprocessorDefinitions) + true + Use + Level3 + gmail.h + Size + + + wininet.lib;wldap32.lib;ws2_32.lib;winmm.lib;UxTheme.lib;comctl32.lib;%(AdditionalDependencies) + $(ProfileDir)..\..\bin10\lib + true + Windows + true + true + false + $(IntDir)$(TargetName).lib + /PDBALTPATH:%_PDB% + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Disabled + curl\include\curl\;..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + _DEBUG;_WINDOWS;_USRDLL;CURL_STATICLIB;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + gmail.h + Level3 + EditAndContinue + + + wininet.lib;wldap32.lib;ws2_32.lib;winmm.lib;UxTheme.lib;comctl32.lib;%(AdditionalDependencies) + $(ProfileDir)..\..\bin10\lib + true + Windows + false + $(IntDir)$(TargetName).lib + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Disabled + curl\include\curl\;..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + _DEBUG;_WINDOWS;_USRDLL;CURL_STATICLIB;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + gmail.h + Level3 + + + wininet.lib;wldap32.lib;ws2_32.lib;winmm.lib;UxTheme.lib;comctl32.lib;%(AdditionalDependencies) + $(ProfileDir)..\..\bin10\lib + true + Windows + $(IntDir)$(TargetName).lib + false + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + + + + + Create + + + + + + + + + + + + + + + {e2a369cd-eda3-414f-8ad0-e732cd7ee68c} + + + + + + \ No newline at end of file diff --git a/plugins/GmailNotifier/GmailNotifier_10.vcxproj.filters b/plugins/GmailNotifier/GmailNotifier_10.vcxproj.filters new file mode 100644 index 0000000000..0d4cedea34 --- /dev/null +++ b/plugins/GmailNotifier/GmailNotifier_10.vcxproj.filters @@ -0,0 +1,56 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Source Files + + + Source Files + + + 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/plugins/GmailNotifier/GmailNotifier_12.vcxproj b/plugins/GmailNotifier/GmailNotifier_12.vcxproj new file mode 100644 index 0000000000..25efb72111 --- /dev/null +++ b/plugins/GmailNotifier/GmailNotifier_12.vcxproj @@ -0,0 +1,212 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + GmailNotifier + {EDAAD28B-505B-4969-A8BB-97EAE818DEEA} + + + + DynamicLibrary + Unicode + v120_xp + + + DynamicLibrary + Unicode + true + v120_xp + + + DynamicLibrary + Unicode + v120_xp + + + DynamicLibrary + Unicode + true + v120_xp + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)\Plugins\ + $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ + $(SolutionDir)$(Configuration)64\Plugins\ + $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ + true + + + + Full + true + curl\include\curl\;..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + NDEBUG;_WINDOWS;_USRDLL;CURL_STATICLIB;%(PreprocessorDefinitions) + true + Use + Level3 + gmail.h + Size + + + Wininet.lib;wldap32.lib;ws2_32.lib;winmm.lib;UxTheme.lib;comctl32.lib;%(AdditionalDependencies) + $(ProfileDir)..\..\bin12\lib + true + Windows + true + true + false + $(IntDir)$(TargetName).lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Full + true + curl\include\curl\;..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + NDEBUG;_WINDOWS;_USRDLL;CURL_STATICLIB;%(PreprocessorDefinitions) + true + Use + Level3 + gmail.h + Size + + + Wininet.lib;wldap32.lib;ws2_32.lib;winmm.lib;UxTheme.lib;comctl32.lib;%(AdditionalDependencies) + $(ProfileDir)..\..\bin12\lib + true + Windows + true + true + false + $(IntDir)$(TargetName).lib + + + NDEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Disabled + curl\include\curl\;..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + _DEBUG;_WINDOWS;_USRDLL;CURL_STATICLIB;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + gmail.h + Level3 + EditAndContinue + + + Wininet.lib;wldap32.lib;ws2_32.lib;winmm.lib;UxTheme.lib;comctl32.lib;%(AdditionalDependencies) + $(ProfileDir)..\..\bin12\lib + true + Windows + false + $(IntDir)$(TargetName).lib + false + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + Disabled + curl\include\curl\;..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) + _DEBUG;_WINDOWS;_USRDLL;CURL_STATICLIB;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + Use + gmail.h + Level3 + + + Wininet.lib;wldap32.lib;ws2_32.lib;winmm.lib;UxTheme.lib;comctl32.lib;%(AdditionalDependencies) + $(ProfileDir)..\..\bin12\lib + true + Windows + $(IntDir)$(TargetName).lib + false + + + _DEBUG;%(PreprocessorDefinitions) + ..\..\include\msapi + + + + + + + + + + + + + + {e2a369cd-eda3-414f-8ad0-e732cd7ee68c} + + + + + + + + + Create + Create + Create + Create + + + + + + + \ No newline at end of file diff --git a/plugins/GmailNotifier/GmailNotifier_12.vcxproj.filters b/plugins/GmailNotifier/GmailNotifier_12.vcxproj.filters new file mode 100644 index 0000000000..3d0ee3898c --- /dev/null +++ b/plugins/GmailNotifier/GmailNotifier_12.vcxproj.filters @@ -0,0 +1,56 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Header Files + + + Header Files + + + Header Files + + + + + Resource Files + + + Resource Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/plugins/GmailNotifier/res/empty.ico b/plugins/GmailNotifier/res/empty.ico new file mode 100644 index 0000000000..e772add255 Binary files /dev/null and b/plugins/GmailNotifier/res/empty.ico differ diff --git a/plugins/GmailNotifier/res/error.ico b/plugins/GmailNotifier/res/error.ico new file mode 100644 index 0000000000..18ac70f769 Binary files /dev/null and b/plugins/GmailNotifier/res/error.ico differ diff --git a/plugins/GmailNotifier/res/iconnew.ico b/plugins/GmailNotifier/res/iconnew.ico new file mode 100644 index 0000000000..109ece345f Binary files /dev/null and b/plugins/GmailNotifier/res/iconnew.ico differ diff --git a/plugins/GmailNotifier/res/options.rc b/plugins/GmailNotifier/res/options.rc new file mode 100644 index 0000000000..ef093adee9 --- /dev/null +++ b/plugins/GmailNotifier/res/options.rc @@ -0,0 +1,139 @@ +//Microsoft Developer Studio generated resource script. +// + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "../src/resource.h" +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Neutral (Sys. Default) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT +#pragma code_page(936) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPT DIALOGEX 0, 0, 260, 227 +STYLE DS_CENTER | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "Tahoma" +BEGIN + LTEXT "Name:",IDC_STATIC,40,19,36,9,NOT WS_GROUP + LTEXT "Password:",IDC_STATIC,40,35,36,9,NOT WS_GROUP + LTEXT "Check Gmail Inbox every",IDC_STATIC,40,78,81,9 + LTEXT "minutes",IDC_STATIC,141,78,26,9 + LTEXT "Notifier on:",IDC_STATIC,40,93,37,9 + LTEXT "<",IDC_STATIC_LESS,133,105,8,10,NOT WS_VISIBLE | NOT + WS_GROUP + LTEXT "Duration:",IDC_STATIC_DURATION,140,100,29,9,NOT + WS_VISIBLE | NOT WS_GROUP + LTEXT "TXT|BG:",IDC_STATIC_COLOR,140,110,27,9,NOT WS_VISIBLE | + NOT WS_GROUP + LTEXT "custom program",IDC_STATIC_CUSTOM,104,146,52,9,NOT + WS_GROUP + LTEXT "sec.",IDC_STATIC_SEC,185,100,14,9,NOT WS_VISIBLE + LTEXT "On DBClick:",IDC_STATIC,40,123,38,9 + COMBOBOX IDC_NAME,77,17,100,50,CBS_DROPDOWN | CBS_AUTOHSCROLL | + WS_VSCROLL | WS_TABSTOP | 0x8000 + EDITTEXT IDC_PASS,78,33,98,11,ES_PASSWORD | ES_AUTOHSCROLL | NOT + WS_BORDER,WS_EX_STATICEDGE + PUSHBUTTON "Add",IDC_BTNADD,191,13,29,11,0,WS_EX_STATICEDGE + PUSHBUTTON "Save",IDC_BTNSAV,191,26,29,11,0,WS_EX_STATICEDGE + PUSHBUTTON "Delete",IDC_BTNDEL,191,39,29,11,0,WS_EX_STATICEDGE + EDITTEXT IDC_CIRCLE,121,77,18,10,NOT WS_BORDER,WS_EX_STATICEDGE + CONTROL "System Tray",IDC_OPTTRAY,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,78,93,56,10 + CONTROL "PopUp Plugin",IDC_OPTPOP,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,78,104,54,10 + CONTROL "Login using default browser",IDC_SYSDEF,"Button", + BS_AUTORADIOBUTTON,78,123,145,10 + CONTROL "Login using Internet Explorer",IDC_USEIE,"Button", + BS_AUTORADIOBUTTON,78,134,145,10 + CONTROL "Run",IDC_STARTPRG,"Button",BS_AUTORADIOBUTTON,78,145,24, + 10 + EDITTEXT IDC_PRG,104,145,102,10,ES_AUTOHSCROLL | NOT WS_VISIBLE | + NOT WS_BORDER,WS_EX_STATICEDGE + PUSHBUTTON "...",IDC_PRGBROWSE,208,145,12,10,NOT WS_VISIBLE, + WS_EX_STATICEDGE + CONTROL "Use online contacts when no new mail",IDC_ONLINE,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,40,160,186,10 + CONTROL "Enable icon selection and icon in status bar (restart)", + IDC_SHOWICON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40, + 172,186,10 + CONTROL "This is a shared computer so disable Auto Login", + IDC_AUTOLOGIN,"Button",BS_AUTO3STATE | WS_TABSTOP,40,184, + 186,10 + CONTROL "Log unread threads into database (enable history)", + IDC_LOGTHREADS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,40, + 196,186,10 + GROUPBOX "Gmail Account",IDC_GROUPMAIN,30,2,199,56 + GROUPBOX "Configuration",IDC_CONFIG,30,65,199,148 + EDITTEXT IDC_DURATION,170,100,14,8,NOT WS_VISIBLE | NOT WS_BORDER, + WS_EX_STATICEDGE + CONTROL "",IDC_TEXTCOLOR,"ColourPicker",NOT WS_VISIBLE | + WS_TABSTOP,170,110,9,9 + CONTROL "",IDC_BGCOLOR,"ColourPicker",NOT WS_VISIBLE | + WS_TABSTOP,180,110,9,9 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_ICONNEW ICON DISCARDABLE "iconnew.ico" +IDI_ICONERR ICON DISCARDABLE "error.ico" +IDI_ICONEPT ICON DISCARDABLE "empty.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""resource.h""\r\n" + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // Neutral (Sys. Default) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/GmailNotifier/res/version.rc b/plugins/GmailNotifier/res/version.rc new file mode 100644 index 0000000000..5bfbab4754 --- /dev/null +++ b/plugins/GmailNotifier/res/version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "afxres.h" +#include "..\src\version.h" + +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/plugins/GmailNotifier/src/check.cpp b/plugins/GmailNotifier/src/check.cpp new file mode 100644 index 0000000000..a57a12879e --- /dev/null +++ b/plugins/GmailNotifier/src/check.cpp @@ -0,0 +1,185 @@ +#include "gmail.h" + +// #include + +void CheckMailInbox(Account *curAcc) +{ + HINTERNET hHTTPOpen; // internet open handle + HINTERNET hHTTPConnection; // internet connection hadle + HINTERNET hHTTPRequest; // internet request hadle + + DBVARIANT dbv; + static char *contentType = "Content-Type: application/x-www-form-urlencoded"; + char requestBuffer[256] = "continue=https%3A%2F%2Fmail.google.com%2Fa%2F"; + char fileBuffer[_MAX_DOWN_BUFFER] = ""; + char *tail; + char str[64]; + char temp[_MAX_DOWN_BUFFER] = ""; + unsigned long bufferLength; + + if (curAcc->IsChecking) + return; + + curAcc->IsChecking = TRUE; + + if (!db_get_s(curAcc->hContact, "CList", "MyHandle", &dbv)) { + lstrcpyA(curAcc->results.content, dbv.pszVal); + db_free(&dbv); + } + else lstrcpyA(curAcc->results.content, curAcc->name); + + tail = strstr(curAcc->results.content, " ["); + if (tail) *tail = '\0'; + lstrcatA(curAcc->results.content, " ["); + + lstrcpyA(str, curAcc->results.content); + lstrcatA(str, Translate("Checking...")); + lstrcatA(str, "]"); + + db_set_s(curAcc->hContact, "CList", "MyHandle", str); + hHTTPOpen = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, "", "", 0); + if (!hHTTPOpen) { + lstrcatA(curAcc->results.content, Translate("Can't open Internet!")); + goto error_handle; + } + + if (curAcc->hosted[0]) { + hHTTPConnection = InternetConnectA(hHTTPOpen, + "www.google.com", + INTERNET_DEFAULT_HTTPS_PORT, + NULL, + NULL, + INTERNET_SERVICE_HTTP, + 0, + 0); + + if (!hHTTPConnection) { + lstrcatA(curAcc->results.content, Translate("Can't reach server!")); + goto error_handle; + } + lstrcpyA(str, "/a/"); + lstrcatA(str, curAcc->hosted); + lstrcatA(str, "/LoginAction"); + hHTTPRequest = HttpOpenRequestA(hHTTPConnection, "POST", str, HTTP_VERSIONA, NULL, NULL, INTERNET_FLAG_SECURE, 0); + lstrcatA(requestBuffer, curAcc->hosted); + lstrcatA(requestBuffer, "%2Ffeed%2Fatom&service=mail&userName="); + lstrcatA(requestBuffer, curAcc->name); + tail = strchr(requestBuffer, '@'); + *tail = '\0'; + lstrcatA(requestBuffer, "&password="); + lstrcatA(requestBuffer, curAcc->pass); + if (!HttpSendRequestA(hHTTPRequest, contentType, (int)strlen(contentType) + 1, requestBuffer, (int)strlen(requestBuffer) + 1)) { + lstrcpyA(curAcc->results.content, Translate("Can't send account data!")); + goto error_handle; + } + + InternetCloseHandle(hHTTPConnection); + InternetCloseHandle(hHTTPRequest); + } + + hHTTPConnection = InternetConnectA(hHTTPOpen, "mail.google.com", INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); + if (!hHTTPConnection) { + lstrcatA(curAcc->results.content, Translate("Can't reach server!")); + goto error_handle; + } + if (curAcc->hosted[0]) { + lstrcpyA(str, "/a/"); + lstrcatA(str, curAcc->hosted); + lstrcatA(str, "/feed/atom"); + } + else lstrcpyA(str, "/mail/feed/atom"); + + hHTTPRequest = HttpOpenRequest(hHTTPConnection, _T("GET"), _A2T(str), NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_RELOAD, 0); + InternetSetOption(hHTTPRequest, INTERNET_OPTION_USERNAME, _A2T(curAcc->name), (int)strlen(curAcc->name) + 1); + InternetSetOption(hHTTPRequest, INTERNET_OPTION_PASSWORD, _A2T(curAcc->pass), (int)strlen(curAcc->pass) + 1); + if (!HttpSendRequest(hHTTPRequest, NULL, 0, NULL, 0)) { + lstrcatA(curAcc->results.content, Translate("Can't get rss feed!")); + goto error_handle; + } + while (InternetReadFile(hHTTPRequest, temp, _MAX_DOWN_BUFFER, &bufferLength) && bufferLength > 0) { + temp[bufferLength] = '\0'; + lstrcatA(fileBuffer, temp); + } + + fileBuffer[_MAX_DOWN_BUFFER - 1] = '\0'; + curAcc->results_num = ParsePage(fileBuffer, &curAcc->results); + if (curAcc->results_num == -1) { + lstrcatA(curAcc->results.content, Translate("Wrong name or password!")); + goto error_handle; + } + InternetCloseHandle(hHTTPOpen); + InternetCloseHandle(hHTTPConnection); + InternetCloseHandle(hHTTPRequest); + + lstrcatA(curAcc->results.content, _itoa(curAcc->results_num, str, 10)); + lstrcatA(curAcc->results.content, "]"); + + curAcc->IsChecking = FALSE; + return; + +error_handle: + curAcc->results_num = -1; + InternetCloseHandle(hHTTPOpen); + InternetCloseHandle(hHTTPConnection); + InternetCloseHandle(hHTTPRequest); + + lstrcatA(curAcc->results.content, "]"); + + curAcc->IsChecking = FALSE; +} + +void __cdecl Check_ThreadFunc(LPVOID lpParam) +{ + InternetSetCookieA("https://mail.google.com/mail/", "GX", ""); + if (lpParam) { + CheckMailInbox((Account *)lpParam); + NotifyUser((Account *)lpParam); + } + else { + for (int i = 0; i < acc_num && GetContactProto(acc[i].hContact); i++) { + CheckMailInbox(&acc[i]); + NotifyUser(&acc[i]); + } + } +} + +int ParsePage(char *page, resultLink *prst) +{ + char *str_head; + char *str_tail; + char name[64], title[64]; + int num = 0; + wchar_t str[64]; + + prst->next = NULL; + if (strstr(page, "Unauthorized")) + return -1; + if (!(str_head = strstr(page, ""))) + return 0; + + while (str_head = strstr(str_head, "")) { + prst = prst->next = (resultLink *)malloc(sizeof(resultLink)); + str_head += 7; + str_tail = strstr(str_head, ""); + *str_tail = '\0'; + lstrcpynA(title, str_head, 41); + if (lstrlenA(title) == 40) + lstrcatA(title, "..."); + *str_tail = ' '; + + str_head = strstr(str_head, "") + 6; + str_tail = strstr(str_head, ""); + *str_tail = '\0'; + lstrcpynA(name, str_head, 11); + lstrcatA(name, ": "); + *str_tail = ' '; + + lstrcpyA(prst->content, name); + lstrcatA(prst->content, title); + MultiByteToWideChar(CP_UTF8, 0, prst->content, -1, str, 64); + WideCharToMultiByte(CP_ACP, 0, str, -1, prst->content, 64, NULL, NULL); + num++; + } + prst->next = NULL; + return num; +} diff --git a/plugins/GmailNotifier/src/gmail.h b/plugins/GmailNotifier/src/gmail.h new file mode 100644 index 0000000000..4f95173141 --- /dev/null +++ b/plugins/GmailNotifier/src/gmail.h @@ -0,0 +1,95 @@ +#define _CRT_SECURE_NO_WARNINGS + +#include +#include +#include +#include +#include "resource.h" + +#include "newpluginapi.h" +#include "m_clist.h" +#include "m_clui.h" +#include "m_skin.h" +#include "m_langpack.h" +#include "m_protomod.h" +#include "m_database.h" +#include "m_system.h" +#include "m_protocols.h" +#include "m_userinfo.h" +#include "m_options.h" +#include "m_protosvc.h" +#include "m_utils.h" +#include "m_ignore.h" +#include "m_clc.h" +#include "m_popup.h" +#include "m_netlib.h" + +#define WM_SHELLNOTIFY WM_USER+5 +#define IDI_TRAY WM_USER+6 +#define pluginName "GmailMNotifier" +#define _MAX_DOWN_BUFFER 65536 +#define LINK "https://www.google.com/accounts/ServiceLoginAuth?continue=https%3A%2F%2Fmail.google.com%2Fmail&service=mail&Email=" +#define FORMDATA1 "
" +// #define STR1 "javascript:document.write('');document.gmail.submit();" +//#define LINK2 "https://www.google.com/a/altmanoptik.com/LoginAction?continue=https%3A%2F%2Fmail.google.com%2Fhosted%2Faltmanoptik.com&service=mail&userName=test&password=123456" + +typedef struct s_resultLink{ + char content[64]; + struct s_resultLink *next; +}resultLink; + +typedef struct s_Account{ + char name[64]; + char pass[64]; + char hosted[64]; + MCONTACT hContact; + int oldResults_num; + int results_num; + resultLink results; + HWND popUpHwnd; + BOOL IsChecking; +}Account; + +typedef struct s_optionSettings{ + int circleTime; + BOOL notifierOnTray; + BOOL notifierOnPop; + int popupDuration; + COLORREF popupTxtColor; + COLORREF popupBgColor; + int OpenUsePrg; + BOOL ShowCustomIcon; + BOOL UseOnline; + int AutoLogin; + BOOL LogThreads; +}optionSettings; + +extern int acc_num; +extern Account *acc; +extern optionSettings opt; +extern HINSTANCE hInst; +extern UINT hTimer; +extern short ID_STATUS_NONEW; +extern BOOL optionWindowIsOpen; + +INT_PTR Notifying(WPARAM, LPARAM); +INT_PTR PluginMenuCommand(WPARAM, LPARAM); +void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD); +BOOL GetBrowser(char *); +void CheckMailInbox(Account *); +void NotifyUser(Account *); +int OptInit(WPARAM, LPARAM); +void Check_ThreadFunc(LPVOID); +void Login_ThreadFunc(LPVOID); +int OpenBrowser(WPARAM , LPARAM); +int ParsePage(char *, resultLink *); +void DeleteResults(resultLink *); +void BuildList(void); + +Account* GetAccountByContact(MCONTACT hContact); \ No newline at end of file diff --git a/plugins/GmailNotifier/src/main.cpp b/plugins/GmailNotifier/src/main.cpp new file mode 100644 index 0000000000..88ae72888e --- /dev/null +++ b/plugins/GmailNotifier/src/main.cpp @@ -0,0 +1,157 @@ +/* +Miranda plugin template, originally by Richard Hughes +http://miranda-icq.sourceforge.net/ + +This file is placed in the public domain. Anybody is free to use or +modify it as they wish with no restriction. +There is no warranty. +*/ + +#include "gmail.h" +#include "version.h" + +HINSTANCE hInst; +int hLangpack; +UINT hTimer; +HANDLE hMirandaStarted, hOptionsInitial; +NOTIFYICONDATA niData; +optionSettings opt; +int acc_num = 0; +Account *acc; +BOOL optionWindowIsOpen = FALSE; +short ID_STATUS_NONEW; + +static PLUGININFOEX pluginInfoEx = +{ + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {243955E0-75D9-4CC3-9B28-6F9C5AF4532D} + { 0x243955e0, 0x75d9, 0x4cc3, { 0x9b, 0x28, 0x6f, 0x9c, 0x5a, 0xf4, 0x53, 0x2d } } +}; + +INT_PTR GetCaps(WPARAM wParam, LPARAM lParam) +{ + if (wParam == PFLAGNUM_2 && opt.ShowCustomIcon) + return PF2_ONLINE | PF2_LIGHTDND | PF2_SHORTAWAY; + + return 0; +} + +INT_PTR GetStatus(WPARAM wParam, LPARAM lParam) +{ + return ID_STATUS_ONLINE; +} + +INT_PTR GetName(WPARAM wParam, LPARAM lParam) +{ + lstrcpynA((char*)lParam, pluginName, wParam); + return 0; +} + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + PluginMenuCommand(0, 0); +} + +INT_PTR PluginMenuCommand(WPARAM hContact, LPARAM lParam) +{ + if (!optionWindowIsOpen) + mir_forkthread(Check_ThreadFunc, GetAccountByContact(hContact)); + + return 0; +} + +static int OnMirandaStart(WPARAM wParam, LPARAM lParam) +{ + PluginMenuCommand(0, 0); + return 0; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) +{ + return &pluginInfoEx; +} + +extern "C" int __declspec(dllexport) Load() +{ + SkinAddNewSoundEx("Gmail", "Other", "Gmail: New Thread(s)"); + HookEvent(ME_CLIST_DOUBLECLICKED, OpenBrowser); + + PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE }; + pd.szName = pluginName; + pd.type = PROTOTYPE_VIRTUAL; + CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd); + + CreateServiceFunction(pluginName PS_GETCAPS, GetCaps); + CreateServiceFunction(pluginName PS_GETSTATUS, GetStatus); + CreateServiceFunction(pluginName PS_GETNAME, GetName); + CreateServiceFunction("GmailMNotifier/Notifying", Notifying); + + opt.circleTime = db_get_dw(NULL, pluginName, "circleTime", 30); + opt.notifierOnTray = db_get_dw(NULL, pluginName, "notifierOnTray", TRUE); + opt.notifierOnPop = db_get_dw(NULL, pluginName, "notifierOnPop", TRUE); + opt.popupDuration = db_get_dw(NULL, pluginName, "popupDuration", -1); + opt.popupBgColor = db_get_dw(NULL, pluginName, "popupBgColor", RGB(173, 206, 247)); + opt.popupTxtColor = db_get_dw(NULL, pluginName, "popupTxtColor", RGB(0, 0, 0)); + opt.OpenUsePrg = db_get_dw(NULL, pluginName, "OpenUsePrg", 0); + opt.ShowCustomIcon = db_get_dw(NULL, pluginName, "ShowCustomIcon", FALSE); + opt.UseOnline = db_get_dw(NULL, pluginName, "UseOnline", FALSE); + opt.AutoLogin = db_get_dw(NULL, pluginName, "AutoLogin", TRUE); + opt.LogThreads = db_get_dw(NULL, pluginName, "LogThreads", FALSE); + + DBVARIANT dbv; + if (db_get_s(NULL, "Icons", "GmailMNotifier40076", &dbv)) { + db_set_s(NULL, "Icons", "GmailMNotifier40071", "plugins\\gmailm.dll,2"); + db_set_s(NULL, "Icons", "GmailMNotifier40072", "plugins\\gmailm.dll,2"); + db_set_s(NULL, "Icons", "GmailMNotifier40076", "plugins\\gmailm.dll,0"); + db_set_s(NULL, "Icons", "GmailMNotifier40073", "plugins\\gmailm.dll,1"); + } + else db_free(&dbv); + + BuildList(); + ID_STATUS_NONEW = opt.UseOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE; + for (int i = 0; i < acc_num; i++) + db_set_dw(acc[i].hContact, pluginName, "Status", ID_STATUS_NONEW); + + hTimer = SetTimer(NULL, 0, opt.circleTime * 60000, TimerProc); + hMirandaStarted = HookEvent(ME_SYSTEM_MODULESLOADED, OnMirandaStart); + hOptionsInitial = HookEvent(ME_OPT_INITIALISE, OptInit); + CreateServiceFunction("GmailMNotifier/MenuCommand", PluginMenuCommand); + + CLISTMENUITEM mi = { sizeof(mi) }; + mi.position = -0x7FFFFFFF; + mi.flags = 0; + mi.hIcon = LoadSkinnedProtoIcon(pluginName, ID_STATUS_ONLINE); + mi.pszName = LPGEN("&Check All Gmail Inboxes"); + mi.pszContactOwner = pluginName; + mi.pszService = "GmailMNotifier/MenuCommand"; + Menu_AddMainMenuItem(&mi); + mi.pszName = LPGEN("&Check Gmail Inbox"); + Menu_AddContactMenuItem(&mi); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + if (hTimer) + KillTimer(NULL, hTimer); + for (int i = 0; i < acc_num; i++) + DeleteResults(acc[i].results.next); + free(acc); + UnhookEvent(hMirandaStarted); + UnhookEvent(hOptionsInitial); + return 0; +} diff --git a/plugins/GmailNotifier/src/notify.cpp b/plugins/GmailNotifier/src/notify.cpp new file mode 100644 index 0000000000..cce1dccc07 --- /dev/null +++ b/plugins/GmailNotifier/src/notify.cpp @@ -0,0 +1,206 @@ +#include "gmail.h" + +int OpenBrowser(WPARAM hContact, LPARAM lParam) +{ + char *proto = GetContactProto(hContact); + if (proto && !lstrcmpA(proto, pluginName)) { + Account *curAcc = GetAccountByContact(hContact); + PUDeletePopup(curAcc->popUpHwnd); + CallServiceSync(MS_CLIST_REMOVEEVENT, (WPARAM)curAcc->hContact, (LPARAM)1); + if (GetKeyState(VK_SHIFT) >> 8 || optionWindowIsOpen) + return FALSE; + + if (curAcc->oldResults_num != 0) { + db_set_w(curAcc->hContact, pluginName, "Status", ID_STATUS_NONEW); + curAcc->oldResults_num = 0; + DeleteResults(curAcc->results.next); + curAcc->results.next = NULL; + } + mir_forkthread(Login_ThreadFunc, curAcc); + } + return FALSE; +} + +INT_PTR Notifying(WPARAM wParam, LPARAM lParam) +{ + OpenBrowser(((CLISTEVENT*)lParam)->hContact, 0); + return 0; +} + +static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + MCONTACT hContact = PUGetContact(hWnd); + Account *curAcc = GetAccountByContact(hContact); + + switch (message) { + case UM_INITPOPUP: + curAcc->popUpHwnd = hWnd; + break; + + case WM_COMMAND: + if (HIWORD(wParam) == STN_CLICKED) + OpenBrowser((WPARAM)hContact, 0); + break; + + case WM_CONTEXTMENU: + PUDeletePopup(hWnd); + curAcc->popUpHwnd = NULL; + CallServiceSync(MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM)1); + } + return DefWindowProc(hWnd, message, wParam, lParam); +} + +void NotifyUser(Account *curAcc) +{ + if (optionWindowIsOpen) + return; + + db_set_s(curAcc->hContact, "CList", "MyHandle", curAcc->results.content); + switch (curAcc->results_num) { + case 0: + PUDeletePopup(curAcc->popUpHwnd); + CallServiceSync(MS_CLIST_REMOVEEVENT, (WPARAM)curAcc->hContact, (LPARAM)1); + if (curAcc->oldResults_num != 0) + db_set_w(curAcc->hContact, pluginName, "Status", ID_STATUS_NONEW); + break; + + case -1: + db_set_w(curAcc->hContact, pluginName, "Status", ID_STATUS_AWAY); + break; + + default: + db_set_w(curAcc->hContact, pluginName, "Status", ID_STATUS_OCCUPIED); + int newMails = (curAcc->oldResults_num == -1) ? (curAcc->results_num) : (curAcc->results_num - curAcc->oldResults_num); + if (opt.LogThreads&&newMails > 0) { + DBEVENTINFO dbei = { sizeof(dbei) }; + dbei.eventType = EVENTTYPE_MESSAGE; + dbei.flags = DBEF_READ; + dbei.szModule = pluginName; + dbei.timestamp = time(NULL); + + resultLink *prst = curAcc->results.next; + for (int i = 0; i < newMails; i++) { + dbei.cbBlob = lstrlenA(prst->content) + 1; + dbei.pBlob = (PBYTE)prst->content; + db_event_add(curAcc->hContact, &dbei); + prst = prst->next; + } + } + if (opt.notifierOnTray&&newMails > 0) { + CLISTEVENT cle = { sizeof(cle) }; + cle.hContact = curAcc->hContact; + cle.hDbEvent = (HANDLE)1; + cle.flags = CLEF_URGENT; + cle.hIcon = LoadSkinnedProtoIcon(pluginName, ID_STATUS_OCCUPIED); + cle.pszService = "GmailMNotifier/Notifying"; + cle.pszTooltip = curAcc->results.next->content; + CallServiceSync(MS_CLIST_REMOVEEVENT, (WPARAM)curAcc->hContact, (LPARAM)1); + CallServiceSync(MS_CLIST_ADDEVENT, (WPARAM)curAcc->hContact, (LPARAM)& cle); + } + + if (opt.notifierOnPop&&newMails > 0) { + POPUPDATA ppd = { 0 }; + + ppd.lchContact = curAcc->hContact; + ppd.lchIcon = LoadSkinnedProtoIcon(pluginName, ID_STATUS_OCCUPIED); + lstrcpyA(ppd.lpzContactName, curAcc->results.content); + resultLink *prst = curAcc->results.next; + for (int i = 0; i < 5 && i < newMails; i++) { + strcat(ppd.lpzText, prst->content); + strcat(ppd.lpzText, "\n"); + prst = prst->next; + } + ppd.colorBack = opt.popupBgColor; + ppd.colorText = opt.popupTxtColor; + ppd.PluginWindowProc = PopupDlgProc; + ppd.PluginData = NULL; + ppd.iSeconds = opt.popupDuration; + PUDeletePopup(curAcc->popUpHwnd); + CallService(MS_POPUP_ADDPOPUP, (WPARAM)&ppd, 0); + } + if (newMails > 0) + SkinPlaySound("Gmail"); + } + curAcc->oldResults_num = curAcc->results_num; + DeleteResults(curAcc->results.next); + curAcc->results.next = NULL; +} + +void DeleteResults(resultLink *prst) +{ + if (prst != NULL) { + if (prst->next != NULL) + DeleteResults(prst->next); + free(prst); + } +} + +void __cdecl Login_ThreadFunc(LPVOID lpParam) +{ + if (lpParam == NULL) + return; + + HANDLE hTempFile; + DWORD dwBytesWritten, dwBufSize = 1024; + char szTempName[MAX_PATH]; + char buffer[1024]; + char *str_temp; + char lpPathBuffer[1024]; + Account *curAcc = (Account *)lpParam; + + if (GetBrowser(lpPathBuffer)) { + if (opt.AutoLogin == 0) { + if (curAcc->hosted[0]) { + lstrcatA(lpPathBuffer, "https://mail.google.com/a/"); + lstrcatA(lpPathBuffer, curAcc->hosted); + lstrcatA(lpPathBuffer, "/?logout"); + } + else { + lstrcatA(lpPathBuffer, "https://mail.google.com/mail/?logout"); + } + } + else { + if (curAcc->hosted[0]) { + GetTempPathA(dwBufSize, buffer); + GetTempFileNameA(buffer, "gmail", 0, szTempName); + + hTempFile = CreateFileA(szTempName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + lstrcpyA(buffer, FORMDATA1); + lstrcatA(buffer, curAcc->hosted); + lstrcatA(buffer, FORMDATA2); + lstrcatA(buffer, curAcc->hosted); + lstrcatA(buffer, FORMDATA3); + lstrcatA(buffer, "
"); + WriteFile(hTempFile, buffer, lstrlenA(buffer), &dwBytesWritten, NULL); + CloseHandle(hTempFile); + lstrcatA(lpPathBuffer, szTempName); + } + else { + lstrcatA(lpPathBuffer, LINK); + lstrcatA(lpPathBuffer, mir_urlEncode(curAcc->name)); + lstrcatA(lpPathBuffer, "&Passwd="); + lstrcatA(lpPathBuffer, mir_urlEncode(curAcc->pass)); + if (opt.AutoLogin == 1) + lstrcatA(lpPathBuffer, "&PersistentCookie=yes"); + } + } + } + + STARTUPINFOA suInfo = { 0 }; + PROCESS_INFORMATION procInfo; + suInfo.cb = sizeof(suInfo); + suInfo.wShowWindow = SW_MAXIMIZE; + if (CreateProcessA(NULL, lpPathBuffer, NULL, NULL, FALSE, 0, NULL, NULL, &suInfo, &procInfo)) + CloseHandle(procInfo.hProcess); + + if (curAcc->hosted[0]) { + Sleep(30000); + DeleteFileA(szTempName); + } +} diff --git a/plugins/GmailNotifier/src/options.cpp b/plugins/GmailNotifier/src/options.cpp new file mode 100644 index 0000000000..7700c140ca --- /dev/null +++ b/plugins/GmailNotifier/src/options.cpp @@ -0,0 +1,274 @@ +#include "gmail.h" + +LRESULT WINAPI FlatComboProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + WNDPROC OldComboProc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA); + RECT rect; + HDC hDcCombo; + switch (msg) { + case WM_PAINT: + CallWindowProc(OldComboProc, hwnd, msg, wParam, lParam); + hDcCombo = GetWindowDC(hwnd); + GetClientRect(hwnd, &rect); + FrameRect(hDcCombo, &rect, GetSysColorBrush(COLOR_3DFACE)); + InflateRect(&rect, -1, -1); + DrawEdge(hDcCombo, &rect, BDR_RAISEDOUTER, BF_FLAT | BF_TOPLEFT); + InflateRect(&rect, -1, -1); + FrameRect(hDcCombo, &rect, 0); + return 0; + } + return CallWindowProc(OldComboProc, hwnd, msg, wParam, lParam); +} + +static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + int i; + int ShowControl; + char str[MAX_PATH] = { 0 }; + char *tail; + static int curIndex = 0; + HWND hwndCombo = GetDlgItem(hwndDlg, IDC_NAME); + + if (acc_num) { + EnableWindow(hwndCombo, TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_PASS), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTNSAV), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTNDEL), TRUE); + } + else { + EnableWindow(hwndCombo, FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_PASS), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTNSAV), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTNDEL), FALSE); + } + + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + optionWindowIsOpen = TRUE; + BuildList(); + // Remember old window procedure + SetWindowLongPtr(hwndCombo, GWLP_USERDATA, GetWindowLongPtr(hwndCombo, GWLP_WNDPROC)); + // Perform the subclass + SetWindowLongPtr(hwndCombo, GWLP_WNDPROC, (LONG_PTR)FlatComboProc); + + for (i = 0; i < acc_num; i++) + SendMessageA(hwndCombo, CB_ADDSTRING, 0, (LONG)(LPSTR)acc[i].name); + SendMessage(hwndCombo, CB_SETCURSEL, curIndex, 0); + if (curIndex < acc_num) + SetDlgItemTextA(hwndDlg, IDC_PASS, acc[curIndex].pass); + + SetDlgItemInt(hwndDlg, IDC_CIRCLE, opt.circleTime, FALSE); + if (opt.notifierOnTray) + CheckDlgButton(hwndDlg, IDC_OPTTRAY, BST_CHECKED); + if (opt.notifierOnPop) { + CheckDlgButton(hwndDlg, IDC_OPTPOP, BST_CHECKED); + ShowWindow(GetDlgItem(hwndDlg, IDC_DURATION), SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg, IDC_BGCOLOR), SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg, IDC_TEXTCOLOR), SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg, IDC_STATIC_DURATION), SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg, IDC_STATIC_COLOR), SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg, IDC_STATIC_LESS), SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg, IDC_STATIC_SEC), SW_SHOW); + } + + SetDlgItemInt(hwndDlg, IDC_DURATION, opt.popupDuration, TRUE); + SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, opt.popupBgColor); + SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_SETCOLOUR, 0, opt.popupTxtColor); + + if (opt.OpenUsePrg == 0) + CheckDlgButton(hwndDlg, IDC_SYSDEF, BST_CHECKED); + else if (opt.OpenUsePrg == 1) + CheckDlgButton(hwndDlg, IDC_USEIE, BST_CHECKED); + else if (opt.OpenUsePrg == 2) { + CheckDlgButton(hwndDlg, IDC_STARTPRG, BST_CHECKED); + ShowWindow(GetDlgItem(hwndDlg, IDC_PRG), SW_SHOW); + ShowWindow(GetDlgItem(hwndDlg, IDC_PRGBROWSE), SW_SHOW); + } + { + DBVARIANT dbv; + if (!db_get_s(NULL, pluginName, "OpenUsePrgPath", &dbv)) { + lstrcpyA(str, dbv.pszVal); + db_free(&dbv); + } + } + SetDlgItemTextA(hwndDlg, IDC_PRG, str); + + if (opt.UseOnline) + CheckDlgButton(hwndDlg, IDC_ONLINE, BST_CHECKED); + if (opt.ShowCustomIcon) + CheckDlgButton(hwndDlg, IDC_SHOWICON, BST_CHECKED); + if (opt.AutoLogin == 0) + CheckDlgButton(hwndDlg, IDC_AUTOLOGIN, BST_CHECKED); + else if (opt.AutoLogin == 1) + CheckDlgButton(hwndDlg, IDC_AUTOLOGIN, BST_UNCHECKED); + else if (opt.AutoLogin == 2) + CheckDlgButton(hwndDlg, IDC_AUTOLOGIN, BST_INDETERMINATE); + if (opt.LogThreads) + CheckDlgButton(hwndDlg, IDC_LOGTHREADS, BST_CHECKED); + + return TRUE; + + case WM_COMMAND: + if (LOWORD(wParam) == IDC_SYSDEF || LOWORD(wParam) == IDC_USEIE || LOWORD(wParam) == IDC_STARTPRG) { + ShowControl = IsDlgButtonChecked(hwndDlg, IDC_STARTPRG) ? SW_SHOW : SW_HIDE; + ShowWindow(GetDlgItem(hwndDlg, IDC_PRG), ShowControl); + ShowWindow(GetDlgItem(hwndDlg, IDC_PRGBROWSE), ShowControl); + } + + switch (LOWORD(wParam)) { + case IDC_OPTPOP: + ShowControl = IsDlgButtonChecked(hwndDlg, IDC_OPTPOP) ? SW_SHOW : SW_HIDE; + ShowWindow(GetDlgItem(hwndDlg, IDC_DURATION), ShowControl); + ShowWindow(GetDlgItem(hwndDlg, IDC_BGCOLOR), ShowControl); + ShowWindow(GetDlgItem(hwndDlg, IDC_TEXTCOLOR), ShowControl); + ShowWindow(GetDlgItem(hwndDlg, IDC_STATIC_DURATION), ShowControl); + ShowWindow(GetDlgItem(hwndDlg, IDC_STATIC_COLOR), ShowControl); + ShowWindow(GetDlgItem(hwndDlg, IDC_STATIC_LESS), ShowControl); + ShowWindow(GetDlgItem(hwndDlg, IDC_STATIC_SEC), ShowControl); + break; + + case IDC_PRGBROWSE: + { + OPENFILENAME OpenFileName; + TCHAR szName[_MAX_PATH]; + memset(&OpenFileName, 0, sizeof(OPENFILENAME)); + GetDlgItemText(hwndDlg, IDC_PRG, szName, _MAX_PATH); + OpenFileName.lStructSize = sizeof(OPENFILENAME); + OpenFileName.hwndOwner = hwndDlg; + OpenFileName.lpstrFilter = _T("Executables (*.exe;*.com;*.bat)\0*.exe;*.com;*.bat\0\0"); + OpenFileName.lpstrFile = szName; + OpenFileName.nMaxFile = _MAX_PATH; + OpenFileName.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; + if (!GetOpenFileName((LPOPENFILENAME)&OpenFileName)) + return 0; + SetDlgItemText(hwndDlg, IDC_PRG, szName); + } + break; + case IDC_BTNADD: + acc_num++; + acc = (Account *)realloc(acc, acc_num * sizeof(Account)); + curIndex = SendMessageA(hwndCombo, CB_ADDSTRING, 0, (LONG)(LPSTR)""); + memset(&acc[curIndex], 0, sizeof(Account)); + SendMessage(hwndCombo, CB_SETCURSEL, curIndex, 0); + SetDlgItemTextA(hwndDlg, IDC_PASS, ""); + SetFocus(hwndCombo); + acc[curIndex].hContact = CallService(MS_DB_CONTACT_ADD, 0, 0); + CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)acc[curIndex].hContact, (LPARAM)pluginName); + break; + + case IDC_BTNSAV: + GetDlgItemTextA(hwndDlg, IDC_NAME, acc[curIndex].name, 64); + tail = strstr(acc[curIndex].name, "@"); + if (tail && lstrcmpA(tail + 1, "gmail.com") != 0) + lstrcpyA(acc[curIndex].hosted, tail + 1); + SendMessageA(hwndCombo, CB_DELETESTRING, curIndex, 0); + SendMessageA(hwndCombo, CB_INSERTSTRING, curIndex, (LONG)(LPSTR)acc[curIndex].name); + SendMessageA(hwndCombo, CB_SETCURSEL, curIndex, 0); + db_set_s(acc[curIndex].hContact, pluginName, "name", acc[curIndex].name); + db_set_s(acc[curIndex].hContact, pluginName, "Nick", acc[curIndex].name); + GetDlgItemTextA(hwndDlg, IDC_PASS, acc[curIndex].pass, 64); + db_set_s(acc[curIndex].hContact, pluginName, "Password", acc[curIndex].pass); + break; + + case IDC_BTNDEL: + acc_num--; + SendMessage(hwndCombo, CB_DELETESTRING, curIndex, 0); + DeleteResults(acc[curIndex].results.next); + acc[curIndex].results.next = NULL; + CallService(MS_DB_CONTACT_DELETE, (WPARAM)(HANDLE)acc[curIndex].hContact, 0); + for (i = curIndex; i < acc_num; i++) + acc[i] = acc[i + 1]; + curIndex = 0; + SendMessage(hwndCombo, CB_SETCURSEL, 0, 0); + SetDlgItemTextA(hwndDlg, IDC_PASS, acc[0].pass); + break; + + case IDC_NAME: + if (HIWORD(wParam) == CBN_SELCHANGE) { + curIndex = SendMessage(hwndCombo, CB_GETCURSEL, 0, 0); + SetDlgItemTextA(hwndDlg, IDC_PASS, acc[curIndex].pass); + } + } + + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + return TRUE; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + SendMessage(hwndDlg, WM_COMMAND, IDC_BTNSAV, 0); + opt.circleTime = GetDlgItemInt(hwndDlg, IDC_CIRCLE, NULL, FALSE); + if (opt.circleTime > 0) { + KillTimer(NULL, hTimer); + hTimer = SetTimer(NULL, 0, opt.circleTime * 60000, TimerProc); + db_set_dw(NULL, pluginName, "circleTime", opt.circleTime); + } + opt.notifierOnTray = IsDlgButtonChecked(hwndDlg, IDC_OPTTRAY); + opt.notifierOnPop = IsDlgButtonChecked(hwndDlg, IDC_OPTPOP); + db_set_dw(NULL, pluginName, "notifierOnTray", opt.notifierOnTray); + db_set_dw(NULL, pluginName, "notifierOnPop", opt.notifierOnPop); + + opt.popupDuration = GetDlgItemInt(hwndDlg, IDC_DURATION, NULL, TRUE); + db_set_dw(NULL, pluginName, "popupDuration", opt.popupDuration); + + opt.popupBgColor = SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, opt.popupBgColor); + opt.popupTxtColor = SendDlgItemMessage(hwndDlg, IDC_TEXTCOLOR, CPM_GETCOLOUR, 0, opt.popupBgColor); + db_set_dw(NULL, pluginName, "popupBgColor", opt.popupBgColor); + db_set_dw(NULL, pluginName, "popupTxtColor", opt.popupTxtColor); + + if (IsDlgButtonChecked(hwndDlg, IDC_SYSDEF) == BST_CHECKED) + opt.OpenUsePrg = 0; + else if (IsDlgButtonChecked(hwndDlg, IDC_USEIE) == BST_CHECKED) + opt.OpenUsePrg = 1; + else if (IsDlgButtonChecked(hwndDlg, IDC_STARTPRG) == BST_CHECKED) { + opt.OpenUsePrg = 2; + } + GetDlgItemTextA(hwndDlg, IDC_PRG, str, MAX_PATH); + + db_set_dw(NULL, pluginName, "OpenUsePrg", opt.OpenUsePrg); + db_set_s(NULL, pluginName, "OpenUsePrgPath", str); + + opt.ShowCustomIcon = IsDlgButtonChecked(hwndDlg, IDC_SHOWICON); + opt.UseOnline = IsDlgButtonChecked(hwndDlg, IDC_ONLINE); + if (IsDlgButtonChecked(hwndDlg, IDC_AUTOLOGIN) == BST_CHECKED) + opt.AutoLogin = 0; + else if (IsDlgButtonChecked(hwndDlg, IDC_AUTOLOGIN) == BST_UNCHECKED) + opt.AutoLogin = 1; + else if (IsDlgButtonChecked(hwndDlg, IDC_AUTOLOGIN) == BST_INDETERMINATE) + opt.AutoLogin = 2; + opt.LogThreads = IsDlgButtonChecked(hwndDlg, IDC_LOGTHREADS); + db_set_dw(NULL, pluginName, "ShowCustomIcon", opt.ShowCustomIcon); + db_set_dw(NULL, pluginName, "UseOnline", opt.UseOnline); + db_set_dw(NULL, pluginName, "AutoLogin", opt.AutoLogin); + db_set_dw(NULL, pluginName, "LogThreads", opt.LogThreads); + + ID_STATUS_NONEW = opt.UseOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE; + for (i = 0; i < acc_num; i++) + db_set_w(acc[i].hContact, pluginName, "Status", ID_STATUS_NONEW); + } + return TRUE; + + case WM_DESTROY: + optionWindowIsOpen = FALSE; + return TRUE; + } + return FALSE; +} + +int OptInit(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp; + + ZeroMemory(&odp, sizeof(odp)); + odp.cbSize = sizeof(odp); + odp.position = -790000000; + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT); + odp.pszTitle = LPGEN("GmailMNotifier"); + odp.pszGroup = LPGEN("Network"); + odp.flags = ODPF_BOLDGROUPS; + odp.pfnDlgProc = DlgProcOpts; + Options_AddPage(wParam, &odp); + return 0; +} diff --git a/plugins/GmailNotifier/src/resource.h b/plugins/GmailNotifier/src/resource.h new file mode 100644 index 0000000000..7fdf98e866 --- /dev/null +++ b/plugins/GmailNotifier/src/resource.h @@ -0,0 +1,48 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by options.rc +// +#define IDD_OPT 101 +#define IDI_ICONNEW 106 +#define IDI_ICONERR 109 +#define IDI_ICONEPT 111 +#define IDC_GROUPMAIN 1000 +#define IDC_CONFIG 1001 +#define IDC_CONFIRM 1002 +#define IDC_OPTTRAY 1002 +#define IDC_OPTPOP 1003 +#define IDC_USEIE 1004 +#define IDC_BGCOLOR 1007 +#define IDC_TEXTCOLOR 1008 +#define IDC_PRG 1009 +#define IDC_SYSDEF 1010 +#define IDC_STARTPRG 1011 +#define IDC_PRGBROWSE 1012 +#define IDC_STATIC_COLOR 1014 +#define IDC_STATIC_DURATION 1006 +#define IDC_STATIC_LESS 1016 +#define IDC_STATIC_SEC 1017 +#define IDC_STATIC_CUSTOM 1018 +#define IDC_PASS 1020 +#define IDC_NAME 1022 +#define IDC_CIRCLE 1023 +#define IDC_DURATION 1024 +#define IDC_SHOWICON 1025 +#define IDC_AUTOLOGIN 1028 +#define IDC_LOGTHREADS 1029 +#define IDC_BTNADD 1019 +#define IDC_BTNSAV 1021 +#define IDC_BTNDEL 1026 +#define IDC_ONLINE 1036 + + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 113 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1008 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/plugins/GmailNotifier/src/stdafx.cpp b/plugins/GmailNotifier/src/stdafx.cpp new file mode 100644 index 0000000000..23a2eeb34b --- /dev/null +++ b/plugins/GmailNotifier/src/stdafx.cpp @@ -0,0 +1,18 @@ +/* +Copyright (C) 2012-14 Miranda NG project (http://miranda-ng.org) + +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 version 2 +of the License. + +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, see . +*/ + +#include "gmail.h" diff --git a/plugins/GmailNotifier/src/utility.cpp b/plugins/GmailNotifier/src/utility.cpp new file mode 100644 index 0000000000..9363f27f60 --- /dev/null +++ b/plugins/GmailNotifier/src/utility.cpp @@ -0,0 +1,77 @@ +#include "gmail.h" + +void BuildList(void) +{ + DBVARIANT dbv; + + acc_num = 0; + for (MCONTACT hContact = db_find_first(pluginName); hContact; hContact = db_find_next(hContact, pluginName)) { + if (!db_get_s(hContact, pluginName, "name", &dbv)) { + acc_num++; + acc = (Account *)realloc(acc, acc_num * sizeof(Account)); + memset(&acc[acc_num-1], 0, sizeof(Account)); + acc[acc_num-1].hContact = hContact; + lstrcpyA(acc[acc_num-1].name, dbv.pszVal); + CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE); + db_free(&dbv); + + if (!db_get_s(hContact, pluginName, "Password", &dbv)) { + lstrcpyA(acc[acc_num-1].pass, dbv.pszVal); + db_free(&dbv); + } + } + } + + for (int i = 0; i < acc_num; i++) { + char *tail = strchr(acc[i].name, '@'); + if (tail && lstrcmpA(tail + 1, "gmail.com") != 0) + lstrcpyA(acc[i].hosted, tail + 1); + acc[i].IsChecking = FALSE; + } +} + +BOOL GetBrowser(char *str) +{ + HKEY hKey = NULL; + char *strKey; + char strIE[] = "Applications\\iexplore.exe\\shell\\open\\command"; + char strDefault[] = "https\\shell\\open\\command"; + DBVARIANT dbv; + + if (opt.OpenUsePrg == 1) + strKey = strIE; + else if (opt.OpenUsePrg == 0) + strKey = strDefault; + else if (!db_get_s(NULL, pluginName, "OpenUsePrgPath", &dbv)) { + lstrcpyA(str, dbv.pszVal); + db_free(&dbv); + return FALSE; + } + + // Open the registry + if (RegOpenKeyExA(HKEY_CLASSES_ROOT, strKey, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { + // Data size + DWORD cbData = 0; + // Get the default value + if (RegQueryValueExA(hKey, NULL, NULL, NULL, NULL, &cbData) == ERROR_SUCCESS && cbData > 0) { + if (RegQueryValueExA(hKey, NULL, NULL, NULL, (LPBYTE)str, &cbData) == ERROR_SUCCESS) { + if ((strKey = strstr(str, "%1")) != NULL) + *(strKey--) = '\0'; + if ((strKey = strstr(str, "-")) != NULL) + *(strKey--) = '\0'; + RegCloseKey(hKey); + return TRUE; + } + } + } + return FALSE; +} + +Account* GetAccountByContact(MCONTACT hContact) +{ + for (int i = 0; i < acc_num; i++) + if (acc[i].hContact == hContact) + return &acc[i]; + + return NULL; +} \ No newline at end of file diff --git a/plugins/GmailNotifier/src/version.h b/plugins/GmailNotifier/src/version.h new file mode 100644 index 0000000000..91dce65806 --- /dev/null +++ b/plugins/GmailNotifier/src/version.h @@ -0,0 +1,14 @@ +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 3 +#define __RELEASE_NUM 1 +#define __BUILD_NUM 0 + +#include + +#define __PLUGIN_NAME "Gmail Multiple Notifier" +#define __FILENAME "GmailNotifier.dll" +#define __DESCRIPTION "Check your Gmail inboxes locally." +#define __AUTHOR "Mixwind" +#define __AUTHOREMAIL "mixwind@gmail.com" +#define __AUTHORWEB "http://miranda-ng.org/p/Gmailmntf/" +#define __COPYRIGHT "© 2005 Sun Zhuo" -- cgit v1.2.3