diff options
-rw-r--r-- | plugins/NewStory/NewStory.vcxproj | 1 | ||||
-rw-r--r-- | plugins/NewStory/NewStory.vcxproj.filters | 3 | ||||
-rw-r--r-- | plugins/NewStory/src/history.h | 1 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 2 | ||||
-rw-r--r-- | plugins/NewStory/src/history_menus.cpp | 56 | ||||
-rw-r--r-- | plugins/NewStory/src/main.cpp | 22 | ||||
-rw-r--r-- | plugins/NewStory/src/version.h | 4 |
7 files changed, 66 insertions, 23 deletions
diff --git a/plugins/NewStory/NewStory.vcxproj b/plugins/NewStory/NewStory.vcxproj index 013f83e963..9ca4c37199 100644 --- a/plugins/NewStory/NewStory.vcxproj +++ b/plugins/NewStory/NewStory.vcxproj @@ -37,6 +37,7 @@ <ClCompile Include="src\history_array.cpp" /> <ClCompile Include="src\history_control.cpp" /> <ClCompile Include="src\history_log.cpp" /> + <ClCompile Include="src\history_menus.cpp" /> <ClCompile Include="src\main.cpp" /> <ClCompile Include="src\options.cpp" /> <ClCompile Include="src\stdafx.cxx"> diff --git a/plugins/NewStory/NewStory.vcxproj.filters b/plugins/NewStory/NewStory.vcxproj.filters index 42d7b3de6d..1d8ce04786 100644 --- a/plugins/NewStory/NewStory.vcxproj.filters +++ b/plugins/NewStory/NewStory.vcxproj.filters @@ -35,6 +35,9 @@ <ClCompile Include="src\utils.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="src\history_menus.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="src\calendartool.h"> diff --git a/plugins/NewStory/src/history.h b/plugins/NewStory/src/history.h index ba34befa21..0dc28180c8 100644 --- a/plugins/NewStory/src/history.h +++ b/plugins/NewStory/src/history.h @@ -30,6 +30,7 @@ enum extern MWindowList hNewstoryWindows; void InitHistory(); +void InitMenus(); INT_PTR svcShowNewstory(WPARAM wParam, LPARAM lParam); INT_PTR svcShowSystemNewstory(WPARAM wParam, LPARAM lParam); diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index 22e515eb3f..76b8b9b2f0 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -5,7 +5,7 @@ HANDLE htuLog = 0; static WNDPROC OldEditWndProc; -static wchar_t wszDelete[] = LPGENW("Are you sure to remove all events from history?"); +wchar_t wszDelete[] = LPGENW("Are you sure to remove all events from history?"); static LRESULT CALLBACK HistoryEditWndProc(HWND, UINT, WPARAM, LPARAM); diff --git a/plugins/NewStory/src/history_menus.cpp b/plugins/NewStory/src/history_menus.cpp new file mode 100644 index 0000000000..e69296d589 --- /dev/null +++ b/plugins/NewStory/src/history_menus.cpp @@ -0,0 +1,56 @@ +#include "stdafx.h" + +static HGENMENU hmiHistory, hmiEmpty; + +static INT_PTR svcEmptyHistory(WPARAM hContact, LPARAM) +{ + extern wchar_t wszDelete[]; + if (IDYES != MessageBoxW(nullptr, TranslateW(wszDelete), _T(MODULETITLE), MB_YESNOCANCEL | MB_ICONQUESTION)) + return 1; + + DB::ECPTR pCursor(DB::Events(hContact)); + while (pCursor.FetchNext()) + pCursor.DeleteEvent(); + return 0; +} + +static int OnPrebuildContactMenu(WPARAM hContact, LPARAM) +{ + bool bShow = (db_event_first(hContact) != 0); + Menu_ShowItem(hmiEmpty, bShow); + Menu_ShowItem(hmiHistory, bShow); + return 0; +} + +void InitMenus() +{ + CMenuItem mi(&g_plugin); + + // Contact menu items + SET_UID(mi, 0xc20d7a69, 0x7607, 0x4aad, 0xa7, 0x42, 0x10, 0x86, 0xfb, 0x32, 0x49, 0x21); + mi.pszService = MS_HISTORY_SHOWCONTACTHISTORY; + mi.name.a = LPGEN("User history"); + mi.position = 1000090000; + mi.hIcon = g_plugin.getIcon(ICO_NEWSTORY); + hmiHistory = Menu_AddContactMenuItem(&mi); + CreateServiceFunction(mi.pszService, svcShowNewstory); + + SET_UID(mi, 0xc20d7a69, 0x7607, 0x4aad, 0xa7, 0x42, 0x10, 0x86, 0xfb, 0x32, 0x49, 0x21); + mi.pszService = "Newstory/EmptyHistory"; + mi.name.a = LPGEN("Empty history"); + mi.position = 1000090001; + mi.hIcon = Skin_LoadIcon(SKINICON_OTHER_DELETE); + hmiEmpty = Menu_AddContactMenuItem(&mi); + CreateServiceFunction(mi.pszService, svcEmptyHistory); + + // Main menu items + SET_UID(mi, 0xc20d7a69, 0x7607, 0x4aad, 0xa7, 0x42, 0x10, 0x86, 0xfb, 0x32, 0x49, 0x22); + mi.pszService = "Newstory/System"; + mi.name.a = LPGEN("System history"); + mi.position = 1000090000; + mi.hIcon = g_plugin.getIcon(ICO_NEWSTORY); + Menu_AddMainMenuItem(&mi); + CreateServiceFunction(mi.pszService, svcShowSystemNewstory); + + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPrebuildContactMenu); +} diff --git a/plugins/NewStory/src/main.cpp b/plugins/NewStory/src/main.cpp index a480feebd7..d86fce7cfb 100644 --- a/plugins/NewStory/src/main.cpp +++ b/plugins/NewStory/src/main.cpp @@ -77,24 +77,9 @@ static int evtModulesLoaded(WPARAM, LPARAM) InitFonts(); InitNewstoryControl(); InitHistory(); + InitMenus(); LoadTemplates(); - - CMenuItem mi(&g_plugin); - - SET_UID(mi, 0xc20d7a69, 0x7607, 0x4aad, 0xa7, 0x42, 0x10, 0x86, 0xfb, 0x32, 0x49, 0x21); - mi.pszService = MS_HISTORY_SHOWCONTACTHISTORY; - mi.name.a = LPGEN("User history"); - mi.position = 1999990000; - mi.hIcon = g_plugin.getIcon(ICO_NEWSTORY); - Menu_AddContactMenuItem(&mi); - - SET_UID(mi, 0xc20d7a69, 0x7607, 0x4aad, 0xa7, 0x42, 0x10, 0x86, 0xfb, 0x32, 0x49, 0x22); - mi.pszService = "Newstory/System"; - mi.name.a = LPGEN("System history"); - mi.position = 1999990000; - mi.hIcon = g_plugin.getIcon(ICO_NEWSTORY); - Menu_AddMainMenuItem(&mi); return 0; } @@ -113,9 +98,6 @@ int CMPlugin::Load() m_log = RegisterSrmmLog(MODULETITLE, _T(MODULENAME), NewStory_Stub); - CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY, svcShowNewstory); - CreateServiceFunction("Newstory/System", svcShowSystemNewstory); - HookEvent(ME_OPT_INITIALISE, OptionsInitialize); HookEvent(ME_SYSTEM_MODULESLOADED, evtModulesLoaded); HookEvent(ME_SYSTEM_PRESHUTDOWN, evtPreShutdown); @@ -129,4 +111,4 @@ int CMPlugin::Unload() DestroyFonts(); return 0; -}
\ No newline at end of file +} diff --git a/plugins/NewStory/src/version.h b/plugins/NewStory/src/version.h index 7e33f43f10..82b5d5505a 100644 --- a/plugins/NewStory/src/version.h +++ b/plugins/NewStory/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 -#define __MINOR_VERSION 0 +#define __MINOR_VERSION 1 #define __RELEASE_NUM 0 -#define __BUILD_NUM 4 +#define __BUILD_NUM 1 #include <stdver.h> |