diff options
author | mataes2007 <mataes2007@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb> | 2011-11-22 18:30:08 +0000 |
---|---|---|
committer | mataes2007 <mataes2007@e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb> | 2011-11-22 18:30:08 +0000 |
commit | 4101ee8ff9bc818f40dc0173b1434761f187597f (patch) | |
tree | 15ace4a23c2d13b1c4b506a54887b1ec196ee007 /GnuPG/contactmenu.cpp | |
parent | da1c34bde32e040a0a431ffb809c3b1e425dc558 (diff) |
added GnuPG
git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@197 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb
Diffstat (limited to 'GnuPG/contactmenu.cpp')
-rw-r--r-- | GnuPG/contactmenu.cpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/GnuPG/contactmenu.cpp b/GnuPG/contactmenu.cpp new file mode 100644 index 0000000..db84b78 --- /dev/null +++ b/GnuPG/contactmenu.cpp @@ -0,0 +1,89 @@ +#include "gnupgplugin.h"
+
+HANDLE useencryption;
+HANDLE sendpublickey;
+
+// service namen der menueintraege
+char *svcuseencryption="GnuPGPlugin/UseEncryption";
+char *svcsendpublickey="GnuPGPlugin/SendPublicKey";
+
+int UpdateContactMenu(WPARAM wparam, LPARAM lparam)
+{
+ DBVARIANT dbv;
+ CLISTMENUITEM cmi;
+ char keyuserid[keyuseridsize];
+ BOOL ischecked;
+
+ int error=DBGetContactSetting(NULL,pluginid,dbkeyuserid,&dbv);
+ if (!error) strcpy(keyuserid,dbv.pszVal);
+ else strcpy(keyuserid,"");
+ DBFreeVariant(&dbv);
+
+ ZeroMemory(&cmi,sizeof(cmi));
+ cmi.cbSize=sizeof(CLISTMENUITEM);
+ cmi.flags=CMIM_FLAGS|CMIF_NOTOFFLINE;
+ if (strlen(keyuserid)==0) cmi.flags|=CMIF_HIDDEN;
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)sendpublickey,(LPARAM)&cmi);
+
+ error=DBGetContactSetting((HANDLE)wparam,pluginid,dbkeyuserid,&dbv);
+ if (!error) strcpy(keyuserid,dbv.pszVal);
+ else strcpy(keyuserid,"");
+ DBFreeVariant(&dbv);
+
+ ZeroMemory(&cmi,sizeof(cmi));
+ cmi.cbSize=sizeof(CLISTMENUITEM);
+ cmi.flags=CMIM_FLAGS|CMIF_HIDDEN;
+
+ if (strlen(keyuserid)!=0)
+ {
+ cmi.flags=CMIM_FLAGS;
+
+ ischecked=DBGetContactSettingByte((HANDLE)wparam,pluginid,dbuseencryption,FALSE);
+ if (ischecked) cmi.flags|=CMIF_CHECKED;
+ }
+
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)useencryption,(LPARAM)&cmi);
+ return 0;
+}
+
+int UseEncryptionService(WPARAM wparam, LPARAM lparam)
+{
+ BOOL ischecked=DBGetContactSettingByte((HANDLE)wparam,pluginid,dbuseencryption,FALSE);
+ DBWriteContactSettingByte((HANDLE)wparam,pluginid,dbuseencryption,(BYTE)!ischecked);
+ return 0;
+}
+
+int SendPublicKeyService(WPARAM wparam, LPARAM lparam)
+{
+ int error;
+ DBVARIANT dbv;
+ char keyuserid[keyuseridsize];
+ char keybuffer[keybuffersize];
+ char keyid[keyidsize];
+ gpgResult gpgresult;
+
+ error=DBGetContactSetting(NULL,pluginid,dbkeyuserid,&dbv);
+ if (!error) strcpy(keyuserid,dbv.pszVal);
+ else strcpy(keyuserid,"");
+ DBFreeVariant(&dbv);
+
+ // sollte nicht auftreten
+ if (strlen(keyuserid)==0)
+ {
+ ErrorMessage(txterror,txtinvaliduserid,txtverifyoptions);
+ return 0;
+ }
+
+ getNextPart(keyid,keyuserid,txtidseparator);
+ ZeroMemory(keybuffer,sizeof(keybuffer));
+ gpgresult=gpgExportPublicKey(keybuffer,keyid);
+
+ if (gpgresult!=gpgSuccess)
+ {
+ ErrorMessage(txterror,txtexportpublickeyfailed,txtverifyoptions);
+ return 0;
+ }
+
+ CallService(MS_MSG_SENDMESSAGE,wparam,(LPARAM)keybuffer);
+ return 0;
+}
|