diff options
Diffstat (limited to 'plugins/CyrTranslit/src')
-rw-r--r-- | plugins/CyrTranslit/src/MirandaContact.cpp | 47 | ||||
-rw-r--r-- | plugins/CyrTranslit/src/MirandaContact.h | 18 | ||||
-rw-r--r-- | plugins/CyrTranslit/src/TransliterationProtocol.cpp | 7 |
3 files changed, 18 insertions, 54 deletions
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<HANDLE>(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);
diff --git a/plugins/CyrTranslit/src/MirandaContact.h b/plugins/CyrTranslit/src/MirandaContact.h index ab7de88407..3cf46ed10e 100644 --- a/plugins/CyrTranslit/src/MirandaContact.h +++ b/plugins/CyrTranslit/src/MirandaContact.h @@ -42,21 +42,14 @@ public: * @param hContact The handle of the contact object to be instantiated.
* @return The Miranda IM contact having the passed handle.
*/
- static MirandaContact getContact(HANDLE hContact);
+ static bool bIsActive(HANDLE hContact);
/**
* Saves this object's data to the persistent storage -- the Miranda
* database. This information may be retreived later on by means of
* getContact() factory method invocation.
*/
- void save() const;
-
- /**
- * @return True only if the Cyrillic transliteration is on for this contact.
- */
- bool shouldTransliterateOutgoingMessages() const;
-
- ~MirandaContact();
+ static void save(HANDLE hContact, bool bValue);
private:
static const char* SETTINGS_MODULE;
@@ -64,13 +57,11 @@ private: static char *MENU_ITEM_TEXT;
- MirandaContact();
-
/**
* Must be called on Miranda start-up to generate the transliteration
* command menu items for all the contacts (a contact-specific menu).
*/
- static void generateMenuItemsForAllContacts();
+ static void addMenuItem();
/**
* This is a callback function for the transliteration command menu item.
@@ -111,9 +102,6 @@ private: * @return Always returns 0.
*/
static int onPreBuildContactMenu(WPARAM wParam, LPARAM lParam);
-
- HANDLE handle;
- bool transliterateOutgoingMessages;
};
}
\ No newline at end of file diff --git a/plugins/CyrTranslit/src/TransliterationProtocol.cpp b/plugins/CyrTranslit/src/TransliterationProtocol.cpp index afba765122..4fd3fb1b29 100644 --- a/plugins/CyrTranslit/src/TransliterationProtocol.cpp +++ b/plugins/CyrTranslit/src/TransliterationProtocol.cpp @@ -18,6 +18,7 @@ */
#include "plugin.h"
+#include "MirandaContact.h"
#include "TransliterationProtocol.h"
#include "TransliterationMap.h"
@@ -96,6 +97,9 @@ void TransliterationProtocol::TranslateMessageA(WPARAM wParam, LPARAM lParam) INT_PTR TransliterationProtocol::sendMessageW(WPARAM wParam, LPARAM lParam)
{
CCSDATA *ccs = reinterpret_cast<CCSDATA*>(lParam);
+ if ( !MirandaContact::bIsActive(ccs->hContact))
+ return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
+
LPARAM oldlParam = ccs->lParam;
TranslateMessageW(wParam, lParam);
@@ -112,6 +116,9 @@ INT_PTR TransliterationProtocol::sendMessageW(WPARAM wParam, LPARAM lParam) INT_PTR TransliterationProtocol::sendMessageA(WPARAM wParam, LPARAM lParam)
{
CCSDATA *ccs = reinterpret_cast<CCSDATA*>(lParam);
+ if ( !MirandaContact::bIsActive(ccs->hContact))
+ return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
+
LPARAM oldlParam = ccs->lParam;
bool msgProcessed = true;
|