summaryrefslogtreecommitdiff
path: root/plugins/NotesAndReminders/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/NotesAndReminders/src/main.cpp')
-rw-r--r--plugins/NotesAndReminders/src/main.cpp138
1 files changed, 32 insertions, 106 deletions
diff --git a/plugins/NotesAndReminders/src/main.cpp b/plugins/NotesAndReminders/src/main.cpp
index 66f764a94f..28009ca443 100644
--- a/plugins/NotesAndReminders/src/main.cpp
+++ b/plugins/NotesAndReminders/src/main.cpp
@@ -1,13 +1,10 @@
-#include "globals.h"
+#include "stdafx.h"
CMPlugin g_plugin;
HINSTANCE hmiranda = nullptr;
HMODULE hRichedDll = nullptr;
-extern TREEELEMENT *g_Stickies;
-extern TREEELEMENT *RemindersList;
-
/////////////////////////////////////////////////////////////////////////////////////////
static PLUGININFOEX pluginInfoEx =
@@ -23,71 +20,14 @@ static PLUGININFOEX pluginInfoEx =
{0x842a6668, 0xf9da, 0x4968, {0xbf, 0xd7, 0xd2, 0xbd, 0x9d, 0xf8, 0x48, 0xee}} // {842A6668-F9DA-4968-BFD7-D2BD9DF848EE}
};
-CMPlugin::CMPlugin() :
- PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
-{}
-
/////////////////////////////////////////////////////////////////////////////////////////
void RegisterFontServiceFonts();
void RegisterKeyBindings();
INT_PTR OpenTriggeredReminder(WPARAM w, LPARAM l);
-void BringAllNotesToFront(STICKYNOTE *pActive);
void CloseNotesList();
void CloseReminderList();
-INT_PTR PluginMenuCommandAddNew(WPARAM, LPARAM)
-{
- STICKYNOTE *PSN = NewNote(0,0,0,0,nullptr,nullptr,TRUE,TRUE,0);
- if(PSN)
- SetFocus(PSN->REHwnd);
- return 0;
-}
-
-INT_PTR PluginMenuCommandDeleteAll(WPARAM, LPARAM)
-{
- if (g_Stickies && MessageBox(nullptr, Translate("Are you sure you want to delete all notes?"), Translate(SECTIONNAME), MB_OKCANCEL) == IDOK)
- DeleteNotes();
- return 0;
-}
-
-static INT_PTR PluginMenuCommandShowHide(WPARAM, LPARAM)
-{
- ShowHideNotes();
- return 0;
-}
-
-static INT_PTR PluginMenuCommandViewNotes(WPARAM, LPARAM)
-{
- ListNotes();
- return 0;
-}
-
-static INT_PTR PluginMenuCommandAllBringFront(WPARAM, LPARAM)
-{
- BringAllNotesToFront(nullptr);
- return 0;
-}
-
-static INT_PTR PluginMenuCommandNewReminder(WPARAM, LPARAM)
-{
- NewReminder();
- return 0;
-}
-
-static INT_PTR PluginMenuCommandViewReminders(WPARAM, LPARAM)
-{
- ListReminders();
- return 0;
-}
-
-static INT_PTR PluginMenuCommandDeleteReminders(WPARAM, LPARAM)
-{
- if (RemindersList && MessageBox(nullptr, Translate("Are you sure you want to delete all reminders?"), Translate(SECTIONNAME), MB_OKCANCEL) == IDOK)
- DeleteReminders();
- return 0;
-}
-
IconItem iconList[] =
{
{ LPGEN("New Reminder"), "AddReminder", IDI_ADDREMINDER },
@@ -113,18 +53,6 @@ void InitIcons(void)
g_plugin.registerIcon(LPGEN("Sticky Notes"), iconList, MODULENAME);
}
-static int OnOptInitialise(WPARAM w, LPARAM)
-{
- OPTIONSDIALOGPAGE odp = {};
- odp.position = 900002000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_STNOTEOPTIONS);
- odp.szTitle.a = SECTIONNAME;
- odp.szGroup.a = LPGEN("Plugins");
- odp.pfnDlgProc = DlgProcOptions;
- g_plugin.addOptions(w, &odp);
- return 0;
-}
-
int OnTopToolBarInit(WPARAM, LPARAM)
{
TTBButton ttb = {};
@@ -142,38 +70,11 @@ int OnTopToolBarInit(WPARAM, LPARAM)
return 0;
}
-static void InitServices()
-{
- // register sounds
-
- g_plugin.addSound("AlertReminder", LPGENW("Alerts"), LPGENW("Reminder triggered"));
- g_plugin.addSound("AlertReminder2", LPGENW("Alerts"), LPGENW("Reminder triggered (Alternative 1)"));
- g_plugin.addSound("AlertReminder3", LPGENW("Alerts"), LPGENW("Reminder triggered (Alternative 2)"));
-
- // register menu command services
-
- CreateServiceFunction(MODULENAME"/MenuCommandAddNew", PluginMenuCommandAddNew);
- CreateServiceFunction(MODULENAME"/MenuCommandShowHide", PluginMenuCommandShowHide);
- CreateServiceFunction(MODULENAME"/MenuCommandViewNotes", PluginMenuCommandViewNotes);
- CreateServiceFunction(MODULENAME"/MenuCommandDeleteAll", PluginMenuCommandDeleteAll);
- CreateServiceFunction(MODULENAME"/MenuCommandBringAllFront", PluginMenuCommandAllBringFront);
-
- //
-
- CreateServiceFunction(MODULENAME"/MenuCommandNewReminder", PluginMenuCommandNewReminder);
- CreateServiceFunction(MODULENAME"/MenuCommandViewReminders", PluginMenuCommandViewReminders);
- CreateServiceFunction(MODULENAME"/MenuCommandDeleteReminders", PluginMenuCommandDeleteReminders);
-
- // register misc
-
- CreateServiceFunction(MODULENAME"/OpenTriggeredReminder", OpenTriggeredReminder);
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
static void addMenuItem(CMenuItem &mi)
{
- if (g_AddContListMI) {
+ if (g_plugin.bAddContListMI) {
HGENMENU save = mi.root; mi.root = nullptr;
Menu_AddContactMenuItem(&mi);
mi.root = save;
@@ -187,8 +88,6 @@ int OnModulesLoaded(WPARAM, LPARAM)
RegisterFontServiceFonts();
RegisterKeyBindings();
- g_AddContListMI = (BOOL)g_plugin.getDword("AddContactMenuItems", 1);
-
// register menus
CMenuItem mi(&g_plugin);
mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Notes && Reminders"), 1600000000);
@@ -200,48 +99,56 @@ int OnModulesLoaded(WPARAM, LPARAM)
mi.name.w = LPGENW("New &Note");
mi.pszService = MODULENAME"/MenuCommandAddNew";
addMenuItem(mi);
+ CreateServiceFunction(mi.pszService, PluginMenuCommandAddNew);
mi.position = 1600000001;
mi.hIcolibItem = iconList[0].hIcolib;
mi.name.w = LPGENW("New &Reminder");
mi.pszService = MODULENAME"/MenuCommandNewReminder";
addMenuItem(mi);
+ CreateServiceFunction(mi.pszService, PluginMenuCommandNewReminder);
mi.position = 1600100000;
mi.hIcolibItem = iconList[3].hIcolib;
mi.name.w = LPGENW("&Show / Hide Notes");
mi.pszService = MODULENAME"/MenuCommandShowHide";
addMenuItem(mi);
+ CreateServiceFunction(mi.pszService, PluginMenuCommandShowHide);
mi.position = 1600100001;
mi.hIcolibItem = iconList[13].hIcolib;
mi.name.w = LPGENW("Vie&w Notes");
mi.pszService = MODULENAME"/MenuCommandViewNotes";
addMenuItem(mi);
+ CreateServiceFunction(mi.pszService, PluginMenuCommandViewNotes);
mi.position = 1600100002;
mi.hIcolibItem = iconList[1].hIcolib;
mi.name.w = LPGENW("&Delete All Notes");
mi.pszService = MODULENAME"/MenuCommandDeleteAll";
addMenuItem(mi);
+ CreateServiceFunction(mi.pszService, PluginMenuCommandDeleteNotes);
mi.position = 1600100003;
mi.hIcolibItem = iconList[11].hIcolib;
mi.name.w = LPGENW("&Bring All to Front");
mi.pszService = MODULENAME"/MenuCommandBringAllFront";
addMenuItem(mi);
+ CreateServiceFunction(mi.pszService, PluginMenuCommandAllBringFront);
mi.position = 1600200000;
mi.hIcolibItem = iconList[6].hIcolib;
mi.name.w = LPGENW("&View Reminders");
mi.pszService = MODULENAME"/MenuCommandViewReminders";
addMenuItem(mi);
+ CreateServiceFunction(mi.pszService, PluginMenuCommandViewReminders);
mi.position = 1600200001;
mi.hIcolibItem = iconList[5].hIcolib;
mi.name.w = LPGENW("D&elete All Reminders");
mi.pszService = MODULENAME"/MenuCommandDeleteReminders";
addMenuItem(mi);
+ CreateServiceFunction(mi.pszService, PluginMenuCommandDeleteReminders);
// register misc
HookEvent("TopToolBar/ModuleLoaded", OnTopToolBarInit);
@@ -256,6 +163,19 @@ int OnModulesLoaded(WPARAM, LPARAM)
/////////////////////////////////////////////////////////////////////////////////////////
+CMPlugin::CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx),
+ bAddContListMI(MODULENAME, "AddContactMenuItems", true),
+ bShowNotesAtStart(MODULENAME, "ShowNotesAtStart", true),
+ bShowNoteButtons(MODULENAME, "ShowNoteButtons", true),
+ bShowScrollbar(MODULENAME, "ShowScrollbar", true),
+ bCloseAfterAddReminder(MODULENAME, "CloseAfterAddReminder", true),
+ bUseMSI(MODULENAME, "UseMCI", true)
+{
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
int CMPlugin::Load()
{
hmiranda = GetModuleHandle(nullptr);
@@ -265,14 +185,20 @@ int CMPlugin::Load()
ctrls.dwICC = ICC_DATE_CLASSES;
InitCommonControlsEx(&ctrls);
- hRichedDll = LoadLibrary("Msftedit.dll");
+ hRichedDll = LoadLibraryA("Msftedit.dll");
if (!hRichedDll) {
- if (MessageBox(nullptr, Translate("Miranda could not load the Notes & Reminders plugin, Msftedit.dll is missing. If you are using WINE, please make sure you have Msftedit.dll installed. Press 'Yes' to continue loading Miranda."), SECTIONNAME, MB_YESNO | MB_ICONINFORMATION) != IDYES)
+ if (MessageBox(nullptr, TranslateT("Miranda could not load the Notes & Reminders plugin, Msftedit.dll is missing. If you are using WINE, please make sure you have Msftedit.dll installed. Press 'Yes' to continue loading Miranda."), _A2W(SECTIONNAME), MB_YESNO | MB_ICONINFORMATION) != IDYES)
return 1;
return 0;
}
- InitServices();
+ CreateServiceFunction(MODULENAME"/OpenTriggeredReminder", OpenTriggeredReminder);
+
+ // register sounds
+ g_plugin.addSound("AlertReminder", LPGENW("Alerts"), LPGENW("Reminder triggered"));
+ g_plugin.addSound("AlertReminder2", LPGENW("Alerts"), LPGENW("Reminder triggered (Alternative 1)"));
+ g_plugin.addSound("AlertReminder3", LPGENW("Alerts"), LPGENW("Reminder triggered (Alternative 2)"));
+
WS_Init();
HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);