diff options
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;
+}
|