summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-08-08 16:08:56 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-08-08 16:08:56 +0300
commit8280bdbb5b6fb83a2d1b4ce5276cb77e437a4447 (patch)
tree2eee37fdcdaab71ce23bf12904eac8e92d3906e2
parenteecf5c454298ea207831c5ef22bd9913cfcd573f (diff)
modified: init.cpp
modified: utilities.cpp
-rw-r--r--init.cpp29
-rw-r--r--utilities.cpp38
2 files changed, 44 insertions, 23 deletions
diff --git a/init.cpp b/init.cpp
index ea509cb..a36db70 100644
--- a/init.cpp
+++ b/init.cpp
@@ -18,7 +18,7 @@
HINSTANCE hInst;
-static HANDLE hLoadPubKey;
+HANDLE hLoadPubKey = NULL, hToggleEncryption = NULL, hOnPreBuildContactMenu = NULL;
PLUGINLINK *pluginLink;
static int OnModulesLoaded(WPARAM wParam,LPARAM lParam);
extern char *date();
@@ -93,16 +93,18 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
mi.hIcon=LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
mi.pszName="Toggle GPG encryption";
mi.pszService="/ToggleEncryption";
- hLoadPubKey = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&mi);
+ hToggleEncryption = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&mi);
return 0;
}
-int GpgOptInit(WPARAM wParam,LPARAM lParam);
-int gpg_init();
static int OnModulesLoaded(WPARAM wParam,LPARAM lParam)
{
+ int GpgOptInit(WPARAM wParam,LPARAM lParam);
+ int gpg_init();
+ int OnPreBuildContactMenu(WPARAM w, LPARAM l);
HookEvent(ME_OPT_INITIALISE, GpgOptInit);
+ hOnPreBuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPreBuildContactMenu);
gpg_init();
return 0;
}
@@ -112,22 +114,3 @@ extern "C" int __declspec(dllexport) Unload(void)
{
return 0;
}
-
-void ShowLoadPublicKeyDialog();
-
-int LoadKey(WPARAM w, LPARAM l)
-{
- extern std::map<int, HANDLE> user_data;
- extern int item_num;
- item_num = 0; //black magic here
- user_data[1] = (HANDLE)w;
- ShowLoadPublicKeyDialog();
-// MessageBox(0, _T("Load GPG key function called"), _T("INFO"), MB_OK);
- return 0;
-}
-int ToggleEncryption(WPARAM w, LPARAM l)
-{
- HANDLE hContact = (HANDLE)w;
- MessageBox(0, _T("Toggle GPG encryption function called"), _T("INFO"), MB_OK);
- return 0;
-} \ No newline at end of file
diff --git a/utilities.cpp b/utilities.cpp
index 0e4fc06..3f03297 100644
--- a/utilities.cpp
+++ b/utilities.cpp
@@ -148,3 +148,41 @@ void GetFolderPath(TCHAR *WindowTittle, char *szSetting)
}
}
}
+
+int LoadKey(WPARAM w, LPARAM l)
+{
+ void ShowLoadPublicKeyDialog();
+ extern std::map<int, HANDLE> user_data;
+ extern int item_num;
+ item_num = 0; //black magic here
+ user_data[1] = (HANDLE)w;
+ ShowLoadPublicKeyDialog();
+ return 0;
+}
+
+ extern HANDLE hLoadPublicKey, hToggleEncryption;
+
+int ToggleEncryption(WPARAM w, LPARAM l)
+{
+ HANDLE hContact = (HANDLE)w;
+ BYTE enc = DBGetContactSettingByte(hContact, szModuleName, "GPGEncryption", 0);
+ enc?DBWriteContactSettingByte(hContact, szModuleName, "GPGEncryption", 0):DBWriteContactSettingByte(hContact, szModuleName, "GPGEncryption", 1);
+ enc?enc = 0:enc = 1;
+ CLISTMENUITEM mi = {0};
+ mi.cbSize=sizeof(mi);
+ mi.flags = CMIM_NAME;
+ enc?mi.pszName="Turn on GPG encryption":mi.pszName="Turn off GPG encryption";
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hToggleEncryption, (LPARAM)&mi);
+ return 0;
+}
+
+int OnPreBuildContactMenu(WPARAM w, LPARAM l)
+{
+ HANDLE hContact = (HANDLE)w;
+ CLISTMENUITEM mi = {0};
+ mi.cbSize=sizeof(mi);
+ mi.flags = CMIM_NAME;
+ DBGetContactSettingByte(hContact, szModuleName, "GPGEncryption", 0)?mi.pszName="Turn on GPG encryption":mi.pszName="Turn off GPG encryption";
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hToggleEncryption, (LPARAM)&mi);
+ return 0;
+}