From 52a779c43192b3b3824f6ade3a11f4eec969f6c9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 11 Oct 2012 20:30:43 +0000 Subject: final fix for CyrTranslit git-svn-id: http://svn.miranda-ng.org/main/trunk@1876 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/CyrTranslit/src/MirandaContact.cpp | 47 +++++------------------------- 1 file changed, 8 insertions(+), 39 deletions(-) (limited to 'plugins/CyrTranslit/src/MirandaContact.cpp') diff --git a/plugins/CyrTranslit/src/MirandaContact.cpp b/plugins/CyrTranslit/src/MirandaContact.cpp index 166ec8cfa7..750ee9ffbc 100644 --- a/plugins/CyrTranslit/src/MirandaContact.cpp +++ b/plugins/CyrTranslit/src/MirandaContact.cpp @@ -37,24 +37,10 @@ HANDLE MirandaContact::hTransliterateCmdMenuItem = 0; //------------------------------------------------------------------------------ -MirandaContact::MirandaContact() - : handle(0), - transliterateOutgoingMessages(false) -{ -} - -//------------------------------------------------------------------------------ - -MirandaContact::~MirandaContact() -{ -} - -//------------------------------------------------------------------------------ - void MirandaContact::initialize() { CreateServiceFunction(MENU_COMMAND_CALLBACK_SERVICE,onMenuCommandTransliterate); - generateMenuItemsForAllContacts(); + addMenuItem(); HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPreBuildContactMenu); @@ -63,34 +49,21 @@ void MirandaContact::initialize() //------------------------------------------------------------------------------ -MirandaContact MirandaContact::getContact(HANDLE hContact) +bool MirandaContact::bIsActive(HANDLE hContact) { - int b = db_get_b(hContact, SETTINGS_MODULE, SETTING_SHOULD_TRANSLITERATE, 0); - - MirandaContact ret; - ret.handle = hContact; - ret.transliterateOutgoingMessages = (b != 0); - - return ret; + return db_get_b(hContact, SETTINGS_MODULE, SETTING_SHOULD_TRANSLITERATE, 0) != 0; } //------------------------------------------------------------------------------ -void MirandaContact::save() const +void MirandaContact::save(HANDLE hContact, bool bValue) { - db_set_b(handle, SETTINGS_MODULE, SETTING_SHOULD_TRANSLITERATE, transliterateOutgoingMessages); + db_set_b(hContact, SETTINGS_MODULE, SETTING_SHOULD_TRANSLITERATE, bValue); } //------------------------------------------------------------------------------ -bool MirandaContact::shouldTransliterateOutgoingMessages() const -{ - return transliterateOutgoingMessages; -} - -//------------------------------------------------------------------------------ - -void MirandaContact::generateMenuItemsForAllContacts() +void MirandaContact::addMenuItem() { CLISTMENUITEM mi; mi.cbSize = sizeof(CLISTMENUITEM); @@ -114,9 +87,7 @@ INT_PTR MirandaContact::onMenuCommandTransliterate(WPARAM wParam, LPARAM lParam) if (!CallService(MS_DB_CONTACT_IS, wParam, 0)) return 0; - MirandaContact mc = getContact(hContact); - mc.transliterateOutgoingMessages = !mc.transliterateOutgoingMessages; - mc.save(); + save(hContact, !bIsActive(hContact)); return 0; } @@ -128,11 +99,9 @@ int MirandaContact::onPreBuildContactMenu(WPARAM wParam, LPARAM lParam) HANDLE hContact = reinterpret_cast(wParam); if (!CallService(MS_DB_CONTACT_IS, wParam, 0)) return 0; - MirandaContact mc = getContact(hContact); - CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_FLAGS; - if (mc.shouldTransliterateOutgoingMessages()) + if ( bIsActive(hContact)) mi.flags |= CMIF_CHECKED; CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hTransliterateCmdMenuItem, (LPARAM)&mi); -- cgit v1.2.3