diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-20 15:08:48 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-20 15:08:48 +0300 |
commit | 8a74e7495ce5ad39de4f5c25121a84d35df90c36 (patch) | |
tree | 03e5b4870f09a3163306740c2eebee47bc15b042 /plugins/GmailNotifier/src | |
parent | c5bf7d6123dd1c3b82ccb8fdb1b068077e9d56d4 (diff) |
CMPlugin to receive a reference to PLUGININFOEX
Diffstat (limited to 'plugins/GmailNotifier/src')
-rw-r--r-- | plugins/GmailNotifier/src/main.cpp | 66 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/notify.cpp | 16 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/options.cpp | 36 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/stdafx.h | 8 | ||||
-rw-r--r-- | plugins/GmailNotifier/src/utility.cpp | 8 |
5 files changed, 68 insertions, 66 deletions
diff --git a/plugins/GmailNotifier/src/main.cpp b/plugins/GmailNotifier/src/main.cpp index 13544edddd..68919fcb81 100644 --- a/plugins/GmailNotifier/src/main.cpp +++ b/plugins/GmailNotifier/src/main.cpp @@ -10,8 +10,10 @@ There is no warranty. #include "stdafx.h"
#include "version.h"
+CMPlugin g_plugin;
CLIST_INTERFACE *pcli;
int &hLangpack(g_plugin.m_hLang);
+
UINT hTimer;
HANDLE hMirandaStarted, hOptionsInitial;
HNETLIBUSER hNetlibUser;
@@ -22,6 +24,8 @@ OBJLIST<Account> g_accs(1); BOOL optionWindowIsOpen = FALSE;
short ID_STATUS_NONEW;
+/////////////////////////////////////////////////////////////////////////////////////////
+
static PLUGININFOEX pluginInfoEx =
{
sizeof(PLUGININFOEX),
@@ -36,6 +40,12 @@ static PLUGININFOEX pluginInfoEx = { 0x243955e0, 0x75d9, 0x4cc3, { 0x9b, 0x28, 0x6f, 0x9c, 0x5a, 0xf4, 0x53, 0x2d } }
};
+CMPlugin::CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
+{
+ RegisterProtocol(PROTOTYPE_VIRTUAL);
+}
+
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfoEx;
@@ -43,10 +53,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) /////////////////////////////////////////////////////////////////////////////////////////
-CMPlugin g_plugin;
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
INT_PTR GetCaps(WPARAM wParam, LPARAM)
{
if (wParam == PFLAGNUM_2 && opt.ShowCustomIcon)
@@ -62,7 +68,7 @@ INT_PTR GetStatus(WPARAM, LPARAM) INT_PTR GetName(WPARAM wParam, LPARAM lParam)
{
- mir_strncpy((char*)lParam, MODULE_NAME, wParam);
+ mir_strncpy((char*)lParam, MODULENAME, wParam);
return 0;
}
@@ -95,59 +101,59 @@ extern "C" int __declspec(dllexport) Load() NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_UNICODE;
- nlu.szSettingsModule = MODULE_NAME;
+ nlu.szSettingsModule = MODULENAME;
nlu.szDescriptiveName.w = TranslateT("Gmail Notifier connection");
hNetlibUser = Netlib_RegisterUser(&nlu);
- CreateProtoServiceFunction(MODULE_NAME, PS_GETCAPS, GetCaps);
- CreateProtoServiceFunction(MODULE_NAME, PS_GETSTATUS, GetStatus);
- CreateProtoServiceFunction(MODULE_NAME, PS_GETNAME, GetName);
+ CreateProtoServiceFunction(MODULENAME, PS_GETCAPS, GetCaps);
+ CreateProtoServiceFunction(MODULENAME, PS_GETSTATUS, GetStatus);
+ CreateProtoServiceFunction(MODULENAME, PS_GETNAME, GetName);
CreateServiceFunction("GmailMNotifier/Notifying", Notifying);
- opt.circleTime = db_get_dw(NULL, MODULE_NAME, "circleTime", 30);
- opt.notifierOnTray = db_get_dw(NULL, MODULE_NAME, "notifierOnTray", TRUE);
- opt.notifierOnPop = db_get_dw(NULL, MODULE_NAME, "notifierOnPop", TRUE);
- opt.popupDuration = db_get_dw(NULL, MODULE_NAME, "popupDuration", -1);
- opt.popupBgColor = db_get_dw(NULL, MODULE_NAME, "popupBgColor", RGB(173, 206, 247));
- opt.popupTxtColor = db_get_dw(NULL, MODULE_NAME, "popupTxtColor", RGB(0, 0, 0));
- opt.OpenUsePrg = db_get_dw(NULL, MODULE_NAME, "OpenUsePrg", 0);
- opt.ShowCustomIcon = db_get_dw(NULL, MODULE_NAME, "ShowCustomIcon", FALSE);
- opt.UseOnline = db_get_dw(NULL, MODULE_NAME, "UseOnline", FALSE);
- opt.AutoLogin = db_get_dw(NULL, MODULE_NAME, "AutoLogin", TRUE);
- opt.LogThreads = db_get_dw(NULL, MODULE_NAME, "LogThreads", FALSE);
+ opt.circleTime = db_get_dw(NULL, MODULENAME, "circleTime", 30);
+ opt.notifierOnTray = db_get_dw(NULL, MODULENAME, "notifierOnTray", TRUE);
+ opt.notifierOnPop = db_get_dw(NULL, MODULENAME, "notifierOnPop", TRUE);
+ opt.popupDuration = db_get_dw(NULL, MODULENAME, "popupDuration", -1);
+ opt.popupBgColor = db_get_dw(NULL, MODULENAME, "popupBgColor", RGB(173, 206, 247));
+ opt.popupTxtColor = db_get_dw(NULL, MODULENAME, "popupTxtColor", RGB(0, 0, 0));
+ opt.OpenUsePrg = db_get_dw(NULL, MODULENAME, "OpenUsePrg", 0);
+ opt.ShowCustomIcon = db_get_dw(NULL, MODULENAME, "ShowCustomIcon", FALSE);
+ opt.UseOnline = db_get_dw(NULL, MODULENAME, "UseOnline", FALSE);
+ opt.AutoLogin = db_get_dw(NULL, MODULENAME, "AutoLogin", TRUE);
+ opt.LogThreads = db_get_dw(NULL, MODULENAME, "LogThreads", FALSE);
DBVARIANT dbv;
- if (db_get_s(NULL, "SkinIcons", "core_status_" MODULE_NAME "4", &dbv)) {
- db_set_s(NULL, "SkinIcons", "core_status_" MODULE_NAME "0", "plugins\\GmailNotifier.dll,2");
- db_set_s(NULL, "SkinIcons", "core_status_" MODULE_NAME "1", "plugins\\GmailNotifier.dll,2");
- db_set_s(NULL, "SkinIcons", "core_status_" MODULE_NAME "2", "plugins\\GmailNotifier.dll,0");
- db_set_s(NULL, "SkinIcons", "core_status_" MODULE_NAME "4", "plugins\\GmailNotifier.dll,1");
+ if (db_get_s(NULL, "SkinIcons", "core_status_" MODULENAME "4", &dbv)) {
+ db_set_s(NULL, "SkinIcons", "core_status_" MODULENAME "0", "plugins\\GmailNotifier.dll,2");
+ db_set_s(NULL, "SkinIcons", "core_status_" MODULENAME "1", "plugins\\GmailNotifier.dll,2");
+ db_set_s(NULL, "SkinIcons", "core_status_" MODULENAME "2", "plugins\\GmailNotifier.dll,0");
+ db_set_s(NULL, "SkinIcons", "core_status_" MODULENAME "4", "plugins\\GmailNotifier.dll,1");
}
else db_free(&dbv);
BuildList();
ID_STATUS_NONEW = opt.UseOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE;
for (auto &it : g_accs)
- db_set_dw(it->hContact, MODULE_NAME, "Status", ID_STATUS_NONEW);
+ db_set_dw(it->hContact, MODULENAME, "Status", ID_STATUS_NONEW);
hTimer = SetTimer(nullptr, 0, opt.circleTime * 60000, TimerProc);
hMirandaStarted = HookEvent(ME_SYSTEM_MODULESLOADED, OnMirandaStart);
hOptionsInitial = HookEvent(ME_OPT_INITIALISE, OptInit);
- CreateServiceFunction(MODULE_NAME "/MenuCommand", PluginMenuCommand);
+ CreateServiceFunction(MODULENAME "/MenuCommand", PluginMenuCommand);
CMenuItem mi;
SET_UID(mi, 0xbe16f37, 0x17be, 0x4494, 0xaa, 0xb2, 0x3a, 0xa7, 0x38, 0xfa, 0xf9, 0xcc);
mi.position = -0x7FFFFFFF;
- mi.hIcolibItem = Skin_LoadProtoIcon(MODULE_NAME, ID_STATUS_ONLINE);
+ mi.hIcolibItem = Skin_LoadProtoIcon(MODULENAME, ID_STATUS_ONLINE);
mi.name.a = LPGEN("&Check all Gmail inboxes");
- mi.pszService = MODULE_NAME "/MenuCommand";
+ mi.pszService = MODULENAME "/MenuCommand";
Menu_AddMainMenuItem(&mi);
SET_UID(mi, 0x22c6ace1, 0xba0c, 0x44b5, 0xa4, 0xd2, 0x1, 0x7d, 0xb1, 0xe0, 0x51, 0xeb);
mi.name.a = LPGEN("&Check Gmail inbox");
mi.pszService = "/MenuCommand";
- Menu_AddContactMenuItem(&mi, MODULE_NAME);
+ Menu_AddContactMenuItem(&mi, MODULENAME);
return 0;
}
diff --git a/plugins/GmailNotifier/src/notify.cpp b/plugins/GmailNotifier/src/notify.cpp index 8222d5c4cf..359b39e926 100644 --- a/plugins/GmailNotifier/src/notify.cpp +++ b/plugins/GmailNotifier/src/notify.cpp @@ -74,7 +74,7 @@ static void __cdecl Login_ThreadFunc(Account *curAcc) int OpenBrowser(WPARAM hContact, LPARAM)
{
char *proto = GetContactProto(hContact);
- if (proto && !mir_strcmp(proto, MODULE_NAME)) {
+ if (proto && !mir_strcmp(proto, MODULENAME)) {
Account *curAcc = GetAccountByContact(hContact);
PUDeletePopup(curAcc->popUpHwnd);
pcli->pfnRemoveEvent(curAcc->hContact, 1);
@@ -82,7 +82,7 @@ int OpenBrowser(WPARAM hContact, LPARAM) return FALSE;
if (curAcc->oldResults_num != 0) {
- db_set_w(curAcc->hContact, MODULE_NAME, "Status", ID_STATUS_NONEW);
+ db_set_w(curAcc->hContact, MODULENAME, "Status", ID_STATUS_NONEW);
curAcc->oldResults_num = 0;
DeleteResults(curAcc->results.next);
curAcc->results.next = nullptr;
@@ -134,21 +134,21 @@ void NotifyUser(Account *curAcc) PUDeletePopup(curAcc->popUpHwnd);
pcli->pfnRemoveEvent(curAcc->hContact, 1);
if (curAcc->oldResults_num != 0)
- db_set_w(curAcc->hContact, MODULE_NAME, "Status", ID_STATUS_NONEW);
+ db_set_w(curAcc->hContact, MODULENAME, "Status", ID_STATUS_NONEW);
break;
case -1:
- db_set_w(curAcc->hContact, MODULE_NAME, "Status", ID_STATUS_AWAY);
+ db_set_w(curAcc->hContact, MODULENAME, "Status", ID_STATUS_AWAY);
break;
default:
- db_set_w(curAcc->hContact, MODULE_NAME, "Status", ID_STATUS_OCCUPIED);
+ db_set_w(curAcc->hContact, MODULENAME, "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 = {};
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.flags = DBEF_READ;
- dbei.szModule = MODULE_NAME;
+ dbei.szModule = MODULENAME;
dbei.timestamp = time(0);
resultLink *prst = curAcc->results.next;
@@ -166,7 +166,7 @@ void NotifyUser(Account *curAcc) cle.hContact = curAcc->hContact;
cle.hDbEvent = 1;
cle.flags = CLEF_URGENT;
- cle.hIcon = Skin_LoadProtoIcon(MODULE_NAME, ID_STATUS_OCCUPIED);
+ cle.hIcon = Skin_LoadProtoIcon(MODULENAME, ID_STATUS_OCCUPIED);
cle.pszService = "GmailMNotifier/Notifying";
cle.szTooltip.a = curAcc->results.next->content;
pcli->pfnAddEvent(&cle);
@@ -176,7 +176,7 @@ void NotifyUser(Account *curAcc) POPUPDATA ppd = { 0 };
ppd.lchContact = curAcc->hContact;
- ppd.lchIcon = Skin_LoadProtoIcon(MODULE_NAME, ID_STATUS_OCCUPIED);
+ ppd.lchIcon = Skin_LoadProtoIcon(MODULENAME, ID_STATUS_OCCUPIED);
mir_strcpy(ppd.lpzContactName, curAcc->results.content);
resultLink *prst = curAcc->results.next;
for (int i = 0; i < 5 && i < newMails; i++) {
diff --git a/plugins/GmailNotifier/src/options.cpp b/plugins/GmailNotifier/src/options.cpp index 9d15fbe1ac..d39f25ae2e 100644 --- a/plugins/GmailNotifier/src/options.cpp +++ b/plugins/GmailNotifier/src/options.cpp @@ -10,11 +10,11 @@ static void SaveButton(HWND hwndDlg, HWND hwndCombo, int curIndex) SendMessageA(hwndCombo, CB_DELETESTRING, curIndex, 0);
SendMessageA(hwndCombo, CB_INSERTSTRING, curIndex, (LPARAM)acc.name);
SendMessageA(hwndCombo, CB_SETCURSEL, curIndex, 0);
- db_set_s(acc.hContact, MODULE_NAME, "name", acc.name);
- db_set_s(acc.hContact, MODULE_NAME, "Nick", acc.name);
+ db_set_s(acc.hContact, MODULENAME, "name", acc.name);
+ db_set_s(acc.hContact, MODULENAME, "Nick", acc.name);
GetDlgItemTextA(hwndDlg, IDC_PASS, acc.pass, _countof(acc.pass));
- db_set_s(acc.hContact, MODULE_NAME, "Password", acc.pass);
+ db_set_s(acc.hContact, MODULENAME, "Password", acc.pass);
}
}
@@ -81,7 +81,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA }
{
DBVARIANT dbv;
- if (!db_get_s(NULL, MODULE_NAME, "OpenUsePrgPath", &dbv)) {
+ if (!db_get_s(NULL, MODULENAME, "OpenUsePrgPath", &dbv)) {
mir_strcpy(str, dbv.pszVal);
db_free(&dbv);
}
@@ -150,7 +150,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA {
Account *p = new Account();
p->hContact = db_add_contact();
- Proto_AddToContact(p->hContact, MODULE_NAME);
+ Proto_AddToContact(p->hContact, MODULENAME);
g_accs.insert(p);
curIndex = SendMessageA(hwndCombo, CB_ADDSTRING, 0, (LPARAM)"");
@@ -214,20 +214,20 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA if (opt.circleTime > 0) {
KillTimer(nullptr, hTimer);
hTimer = SetTimer(nullptr, 0, opt.circleTime * 60000, TimerProc);
- db_set_dw(NULL, MODULE_NAME, "circleTime", opt.circleTime);
+ db_set_dw(NULL, MODULENAME, "circleTime", opt.circleTime);
}
opt.notifierOnTray = IsDlgButtonChecked(hwndDlg, IDC_OPTTRAY);
opt.notifierOnPop = IsDlgButtonChecked(hwndDlg, IDC_OPTPOP);
- db_set_dw(NULL, MODULE_NAME, "notifierOnTray", opt.notifierOnTray);
- db_set_dw(NULL, MODULE_NAME, "notifierOnPop", opt.notifierOnPop);
+ db_set_dw(NULL, MODULENAME, "notifierOnTray", opt.notifierOnTray);
+ db_set_dw(NULL, MODULENAME, "notifierOnPop", opt.notifierOnPop);
opt.popupDuration = GetDlgItemInt(hwndDlg, IDC_DURATION, nullptr, TRUE);
- db_set_dw(NULL, MODULE_NAME, "popupDuration", opt.popupDuration);
+ db_set_dw(NULL, MODULENAME, "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, MODULE_NAME, "popupBgColor", opt.popupBgColor);
- db_set_dw(NULL, MODULE_NAME, "popupTxtColor", opt.popupTxtColor);
+ db_set_dw(NULL, MODULENAME, "popupBgColor", opt.popupBgColor);
+ db_set_dw(NULL, MODULENAME, "popupTxtColor", opt.popupTxtColor);
if (IsDlgButtonChecked(hwndDlg, IDC_SYSDEF) == BST_CHECKED)
opt.OpenUsePrg = 0;
@@ -238,8 +238,8 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA }
GetDlgItemTextA(hwndDlg, IDC_PRG, str, _countof(str));
- db_set_dw(NULL, MODULE_NAME, "OpenUsePrg", opt.OpenUsePrg);
- db_set_s(NULL, MODULE_NAME, "OpenUsePrgPath", str);
+ db_set_dw(NULL, MODULENAME, "OpenUsePrg", opt.OpenUsePrg);
+ db_set_s(NULL, MODULENAME, "OpenUsePrgPath", str);
opt.ShowCustomIcon = IsDlgButtonChecked(hwndDlg, IDC_SHOWICON);
opt.UseOnline = IsDlgButtonChecked(hwndDlg, IDC_ONLINE);
@@ -250,14 +250,14 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA else if (IsDlgButtonChecked(hwndDlg, IDC_AUTOLOGIN) == BST_INDETERMINATE)
opt.AutoLogin = 2;
opt.LogThreads = IsDlgButtonChecked(hwndDlg, IDC_LOGTHREADS);
- db_set_dw(NULL, MODULE_NAME, "ShowCustomIcon", opt.ShowCustomIcon);
- db_set_dw(NULL, MODULE_NAME, "UseOnline", opt.UseOnline);
- db_set_dw(NULL, MODULE_NAME, "AutoLogin", opt.AutoLogin);
- db_set_dw(NULL, MODULE_NAME, "LogThreads", opt.LogThreads);
+ db_set_dw(NULL, MODULENAME, "ShowCustomIcon", opt.ShowCustomIcon);
+ db_set_dw(NULL, MODULENAME, "UseOnline", opt.UseOnline);
+ db_set_dw(NULL, MODULENAME, "AutoLogin", opt.AutoLogin);
+ db_set_dw(NULL, MODULENAME, "LogThreads", opt.LogThreads);
ID_STATUS_NONEW = opt.UseOnline ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE;
for (auto &it : g_accs)
- db_set_w(it->hContact, MODULE_NAME, "Status", ID_STATUS_NONEW);
+ db_set_w(it->hContact, MODULENAME, "Status", ID_STATUS_NONEW);
}
return TRUE;
diff --git a/plugins/GmailNotifier/src/stdafx.h b/plugins/GmailNotifier/src/stdafx.h index 0012cb756c..cd60bd5335 100644 --- a/plugins/GmailNotifier/src/stdafx.h +++ b/plugins/GmailNotifier/src/stdafx.h @@ -23,7 +23,7 @@ #define WM_SHELLNOTIFY WM_USER+5
#define IDI_TRAY WM_USER+6
-#define MODULE_NAME "GmailMNotifier"
+#define MODULENAME "GmailMNotifier"
#define _MAX_DOWN_BUFFER 65536
#define LINK "https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fmail.google.com%2Fmail&service=mail&passive=true&Email="
#define FORMDATA1 "<body onload=document.gmail.submit();><form name=gmail action=https://www.google.com/a/"
@@ -93,9 +93,5 @@ Account* GetAccountByContact(MCONTACT hContact); struct CMPlugin : public PLUGIN<CMPlugin>
{
- CMPlugin() :
- PLUGIN<CMPlugin>(MODULE_NAME)
- {
- RegisterProtocol(PROTOTYPE_VIRTUAL);
- }
+ CMPlugin();
};
diff --git a/plugins/GmailNotifier/src/utility.cpp b/plugins/GmailNotifier/src/utility.cpp index 64bb3cfa11..63ab420896 100644 --- a/plugins/GmailNotifier/src/utility.cpp +++ b/plugins/GmailNotifier/src/utility.cpp @@ -4,15 +4,15 @@ void BuildList(void) {
g_accs.destroy();
- for (auto &hContact : Contacts(MODULE_NAME)) {
- ptrA szName(db_get_sa(hContact, MODULE_NAME, "name"));
+ for (auto &hContact : Contacts(MODULENAME)) {
+ ptrA szName(db_get_sa(hContact, MODULENAME, "name"));
if (szName != nullptr) {
Account *p = new Account;
p->hContact = hContact;
mir_strcpy(p->name, szName);
CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
- ptrA szPassword(db_get_sa(hContact, MODULE_NAME, "Password"));
+ ptrA szPassword(db_get_sa(hContact, MODULENAME, "Password"));
if (szPassword != nullptr)
mir_strcpy(p->pass, szPassword);
g_accs.insert(p);
@@ -40,7 +40,7 @@ BOOL GetBrowser(char *str) else if (opt.OpenUsePrg == 0)
strKey = strDefault;
else {
- if (!db_get_s(NULL, MODULE_NAME, "OpenUsePrgPath", &dbv)) {
+ if (!db_get_s(NULL, MODULENAME, "OpenUsePrgPath", &dbv)) {
mir_strcpy(str, dbv.pszVal);
db_free(&dbv);
}
|