diff options
Diffstat (limited to 'plugins/GmailNotifier/src')
-rw-r--r-- | plugins/GmailNotifier/src/check.cpp | 185 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/gmail.h | 95 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/main.cpp | 157 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/notify.cpp | 206 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/options.cpp | 274 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/resource.h | 48 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/stdafx.cpp | 18 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/utility.cpp | 77 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/version.h | 14 |
9 files changed, 1074 insertions, 0 deletions
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 <stdio.h>
+
+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, "<entry>")))
+ return 0;
+
+ while (str_head = strstr(str_head, "<title>")) {
+ prst = prst->next = (resultLink *)malloc(sizeof(resultLink));
+ str_head += 7;
+ str_tail = strstr(str_head, "</title>");
+ *str_tail = '\0';
+ lstrcpynA(title, str_head, 41);
+ if (lstrlenA(title) == 40)
+ lstrcatA(title, "...");
+ *str_tail = ' ';
+
+ str_head = strstr(str_head, "<name>") + 6;
+ str_tail = strstr(str_head, "</name>");
+ *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 <windows.h>
+#include <wininet.h>
+#include <time.h>
+#include <stdio.h>
+#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 "<body onload=document.gmail.submit();><form name=gmail action=https://www.google.com/a/"
+#define FORMDATA2 "/LoginAction method=POST><input type=hidden name=continue value=https://mail.google.com/a/"
+#define FORMDATA3 "><INPUT type=hidden value=mail name=service>"
+// #define STR1 "javascript:document.write('<form name=gmail action=https://www.google.com/a/"
+// #define STR2 "/LoginAction method=post><input type=hidden name=continue value=https://mail.google.com/hosted/"
+// #define STR3 "><input type=hidden value=mail name=service><input type=hidden name=userName value="
+// #define STR4 "><input type=hidden name=password value="
+// #define STR5 ">');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, "<input type=hidden name=userName value=");
+ lstrcatA(buffer, curAcc->name);
+ if ((str_temp = strstr(buffer, "@")) != NULL)
+ *str_temp = '\0';
+ lstrcatA(buffer, "><input type=hidden name=password value=");
+ lstrcatA(buffer, curAcc->pass);
+ lstrcatA(buffer, "></form></body>");
+ 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 <http://www.gnu.org/licenses/>.
+*/
+
+#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 <stdver.h>
+
+#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"
|