diff options
author | hrxi <hrrrxi@gmail.com> | 2023-06-04 09:24:16 +0200 |
---|---|---|
committer | fiaxh <fiaxh@users.noreply.github.com> | 2023-10-06 15:25:12 +0200 |
commit | e2d801b5f74b60c38a75310066c48468c8a4bc93 (patch) | |
tree | 169183325003f0478f0f61620fb9cef12b932f03 | |
parent | dd0038f5e2916b21f58d83dabe9675994635e41f (diff) | |
download | dino-e2d801b5f74b60c38a75310066c48468c8a4bc93.tar.gz dino-e2d801b5f74b60c38a75310066c48468c8a4bc93.zip |
Merge `gpgme-vala` into `openpgp` plugin
There's no reason for it to be a statically linked library anymore, it
can be directly compiled into the plugin.
-rw-r--r-- | plugins/CMakeLists.txt | 3 | ||||
-rw-r--r-- | plugins/gpgme-vala/CMakeLists.txt | 52 | ||||
-rw-r--r-- | plugins/gpgme-vala/vapi/gpgme.deps | 1 | ||||
-rw-r--r-- | plugins/gpgme-vala/vapi/gpgme_public.vapi | 162 | ||||
-rw-r--r-- | plugins/openpgp/CMakeLists.txt | 12 | ||||
-rw-r--r-- | plugins/openpgp/src/gpgme_fix.c (renamed from plugins/gpgme-vala/src/gpgme_fix.c) | 0 | ||||
-rw-r--r-- | plugins/openpgp/src/gpgme_fix.h (renamed from plugins/gpgme-vala/src/gpgme_fix.h) | 0 | ||||
-rw-r--r-- | plugins/openpgp/src/gpgme_helper.vala (renamed from plugins/gpgme-vala/src/gpgme_helper.vala) | 0 | ||||
-rw-r--r-- | plugins/openpgp/vapi/gpg-error.vapi (renamed from plugins/gpgme-vala/vapi/gpg-error.vapi) | 8 | ||||
-rw-r--r-- | plugins/openpgp/vapi/gpgme.vapi (renamed from plugins/gpgme-vala/vapi/gpgme.vapi) | 210 |
10 files changed, 192 insertions, 256 deletions
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 4322232b..3ce96815 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -2,8 +2,5 @@ foreach(plugin ${PLUGINS}) if ("omemo" STREQUAL ${plugin}) add_subdirectory(signal-protocol) endif () - if ("openpgp" STREQUAL ${plugin}) - add_subdirectory(gpgme-vala) - endif () add_subdirectory(${plugin}) endforeach(plugin) diff --git a/plugins/gpgme-vala/CMakeLists.txt b/plugins/gpgme-vala/CMakeLists.txt deleted file mode 100644 index 5255bac4..00000000 --- a/plugins/gpgme-vala/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -find_package(GPGME REQUIRED) -find_packages(GPGME_VALA_PACKAGES REQUIRED - Gee - GLib - GObject -) - -vala_precompile(GPGME_VALA_C -SOURCES - "src/gpgme_helper.vala" -CUSTOM_VAPIS - "${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme.vapi" - "${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi" - "${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpg-error.vapi" -PACKAGES - ${GPGME_VALA_PACKAGES} -GENERATE_VAPI - gpgme-vala -GENERATE_HEADER - gpgme-vala -) - -add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/exports/gpgme_fix.h" -COMMAND - cp "${CMAKE_CURRENT_SOURCE_DIR}/src/gpgme_fix.h" "${CMAKE_BINARY_DIR}/exports/gpgme_fix.h" -DEPENDS - "${CMAKE_CURRENT_SOURCE_DIR}/src/gpgme_fix.h" -COMMENT - Copy header file gpgme_fix.h -) - -add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/exports/gpgme.vapi -COMMAND - cat "${CMAKE_BINARY_DIR}/exports/gpgme-vala.vapi" "${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi" > "${CMAKE_BINARY_DIR}/exports/gpgme.vapi" -DEPENDS - ${CMAKE_BINARY_DIR}/exports/gpgme-vala.vapi - ${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme_public.vapi -) - -add_custom_target(gpgme-vapi -DEPENDS - ${CMAKE_BINARY_DIR}/exports/gpgme_fix.h - ${CMAKE_BINARY_DIR}/exports/gpgme.vapi -) - -set(CFLAGS ${VALA_CFLAGS} -I${CMAKE_CURRENT_SOURCE_DIR}/src) -add_definitions(${CFLAGS}) -add_library(gpgme-vala STATIC ${GPGME_VALA_C} src/gpgme_fix.c) -add_dependencies(gpgme-vala gpgme-vapi) -target_link_libraries(gpgme-vala ${GPGME_VALA_PACKAGES} gpgme) -set_property(TARGET gpgme-vala PROPERTY POSITION_INDEPENDENT_CODE ON) - diff --git a/plugins/gpgme-vala/vapi/gpgme.deps b/plugins/gpgme-vala/vapi/gpgme.deps deleted file mode 100644 index a0f4f82b..00000000 --- a/plugins/gpgme-vala/vapi/gpgme.deps +++ /dev/null @@ -1 +0,0 @@ -gpg-error diff --git a/plugins/gpgme-vala/vapi/gpgme_public.vapi b/plugins/gpgme-vala/vapi/gpgme_public.vapi deleted file mode 100644 index bcf12569..00000000 --- a/plugins/gpgme-vala/vapi/gpgme_public.vapi +++ /dev/null @@ -1,162 +0,0 @@ -[CCode (lower_case_cprefix = "gpgme_", cheader_filename = "gpgme.h,gpgme_fix.h")] -namespace GPG { - -[CCode (cname = "gpgme_check_version")] -public unowned string check_version(string? required_version = null); - -[Compact] -[CCode (cname = "struct _gpgme_key", ref_function = "gpgme_key_ref_vapi", unref_function = "gpgme_key_unref_vapi", free_function = "gpgme_key_release")] -public class Key { - public bool revoked; - public bool expired; - public bool disabled; - public bool invalid; - public bool can_encrypt; - public bool can_sign; - public bool can_certify; - public bool can_authenticate; - public bool is_qualified; - public bool secret; - public Protocol protocol; - public string issuer_serial; - public string issuer_name; - public string chain_id; - public Validity owner_trust; - [CCode(array_null_terminated = true)] - public SubKey[] subkeys; - [CCode(array_null_terminated = true)] - public UserID[] uids; - public KeylistMode keylist_mode; - // public string fpr; // requires gpgme >= 1.7.0 - public string fpr { get { return subkeys[0].fpr; } } -} - -[CCode (cname = "struct _gpgme_user_id")] -public struct UserID { - UserID* next; - - bool revoked; - bool invalid; - Validity validity; - string uid; - string name; - string email; - string comment; - KeySig signatures; -} - -[CCode (cname = "struct _gpgme_key_sig")] -public struct KeySig { - KeySig* next; - bool invoked; - bool expired; - bool invalid; - bool exportable; - PublicKeyAlgorithm algo; - string keyid; - long timestamp; - long expires; -// GPGError.Error status; - string uid; - string name; - string email; - string comment; - uint sig_class; - SigNotation notations; -} - -[CCode (cname = "struct _gpgme_subkey")] -public struct SubKey { - SubKey* next; - bool revoked; - bool expired; - bool disabled; - bool invalid; - bool can_encrypt; - bool can_sign; - bool can_certify; - bool secret; - bool can_authenticate; - bool is_qualified; - bool is_cardkey; - PublicKeyAlgorithm algo; - uint length; - string keyid; - - string fpr; - long timestamp; - long expires; - string? cardnumber; -} - -[CCode (cname = "struct _gpgme_sig_notation")] -public struct SigNotation { - SigNotation* next; - string? name; - string value; - int name_len; - int value_len; - SigNotationFlags flags; - bool human_readable; - bool critical; -} - -[CCode (cname = "gpgme_sig_notation_flags_t", cprefix = "GPGME_SIG_NOTATION_")] -public enum SigNotationFlags { - HUMAN_READABLE, - CRITICAL -} - -[CCode (cname = "gpgme_sig_mode_t", cprefix = "GPGME_SIG_MODE_")] -public enum SigMode { - NORMAL, - DETACH, - CLEAR -} - -[CCode (cname = "gpgme_encrypt_flags_t", cprefix = "GPGME_ENCRYPT_")] -public enum EncryptFlags { - ALWAYS_TRUST, - NO_ENCRYPT_TO -} - -[CCode (cname = "gpgme_pubkey_algo_t", cprefix = "GPGME_PK_")] -public enum PublicKeyAlgorithm { - RSA, - RSA_E, - RSA_S, - ELG_E, - DSA, - ELG -} - -[CCode (cname = "gpgme_protocol_t", cprefix = "GPGME_PROTOCOL_")] -public enum Protocol { - OpenPGP, - CMS, - GPGCONF, - ASSUAN, - UNKNOWN -} - -[CCode (cname = "gpgme_keylist_mode_t", cprefix = "GPGME_KEYLIST_MODE_")] -public enum KeylistMode { - LOCAL, - EXTERN, - SIGS, - SIG_NOTATIONS, - EPHEMERAL, - VALIDATE -} - -[CCode (cname = "gpgme_validity_t", cprefix = "GPGME_VALIDITY_")] -public enum Validity { - UNKNOWN, - UNDEFINED, - NEVER, - MARGINAL, - FULL, - ULTIMATE -} - -}
\ No newline at end of file diff --git a/plugins/openpgp/CMakeLists.txt b/plugins/openpgp/CMakeLists.txt index 649a55ad..6ed7bf53 100644 --- a/plugins/openpgp/CMakeLists.txt +++ b/plugins/openpgp/CMakeLists.txt @@ -1,3 +1,5 @@ +find_package(GPGME REQUIRED) + set(GETTEXT_PACKAGE "dino-openpgp") find_package(Gettext) include(${GETTEXT_USE_FILE}) @@ -28,6 +30,8 @@ compile_gresources( vala_precompile(OPENPGP_VALA_C SOURCES + src/gpgme_helper.vala + src/file_transfer/file_decryptor.vala src/file_transfer/file_encryptor.vala @@ -42,7 +46,8 @@ SOURCES src/stream_module.vala src/util.vala CUSTOM_VAPIS - ${CMAKE_BINARY_DIR}/exports/gpgme.vapi + ${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpgme.vapi + ${CMAKE_CURRENT_SOURCE_DIR}/vapi/gpg-error.vapi ${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi ${CMAKE_BINARY_DIR}/exports/qlite.vapi ${CMAKE_BINARY_DIR}/exports/dino.vapi @@ -53,9 +58,10 @@ GRESOURCES ) add_definitions(${VALA_CFLAGS} -DG_LOG_DOMAIN="OpenPGP" -DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\" -DLOCALE_INSTALL_DIR=\"${LOCALE_INSTALL_DIR}\") -add_library(openpgp SHARED ${OPENPGP_VALA_C} ${OPENPGP_GRESOURCES_TARGET}) +add_library(openpgp SHARED ${OPENPGP_VALA_C} ${OPENPGP_GRESOURCES_TARGET} src/gpgme_fix.c) add_dependencies(openpgp ${GETTEXT_PACKAGE}-translations) -target_link_libraries(openpgp libdino gpgme-vala ${OPENPGP_PACKAGES}) +target_include_directories(openpgp PRIVATE src) +target_link_libraries(openpgp libdino gpgme ${OPENPGP_PACKAGES}) set_target_properties(openpgp PROPERTIES PREFIX "") set_target_properties(openpgp PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/) diff --git a/plugins/gpgme-vala/src/gpgme_fix.c b/plugins/openpgp/src/gpgme_fix.c index bf457a6c..bf457a6c 100644 --- a/plugins/gpgme-vala/src/gpgme_fix.c +++ b/plugins/openpgp/src/gpgme_fix.c diff --git a/plugins/gpgme-vala/src/gpgme_fix.h b/plugins/openpgp/src/gpgme_fix.h index 714614fc..714614fc 100644 --- a/plugins/gpgme-vala/src/gpgme_fix.h +++ b/plugins/openpgp/src/gpgme_fix.h diff --git a/plugins/gpgme-vala/src/gpgme_helper.vala b/plugins/openpgp/src/gpgme_helper.vala index f28bc6d6..f28bc6d6 100644 --- a/plugins/gpgme-vala/src/gpgme_helper.vala +++ b/plugins/openpgp/src/gpgme_helper.vala diff --git a/plugins/gpgme-vala/vapi/gpg-error.vapi b/plugins/openpgp/vapi/gpg-error.vapi index 2c915c8a..3ad6c580 100644 --- a/plugins/gpgme-vala/vapi/gpg-error.vapi +++ b/plugins/openpgp/vapi/gpg-error.vapi @@ -441,11 +441,5 @@ namespace GPGError { public Error.from_errno (ErrorSource source, int err); public ErrorCode code { [CCode (cname = "gpg_err_code")] get; } public ErrorSource source { [CCode (cname = "gpg_err_source")] get; } - - [CCode (cname = "gpg_strerror")] - public unowned string to_string (); - - [CCode (cname = "gpg_strsource")] - public unowned string source_to_string (); } -}
\ No newline at end of file +} diff --git a/plugins/gpgme-vala/vapi/gpgme.vapi b/plugins/openpgp/vapi/gpgme.vapi index 8723bd81..10fdb89d 100644 --- a/plugins/gpgme-vala/vapi/gpgme.vapi +++ b/plugins/openpgp/vapi/gpgme.vapi @@ -1,6 +1,7 @@ /* libgpgme.vapi * * Copyright (C) 2009 Sebastian Reichel <sre@ring0.de> + * Copyright (C) 2022 Itay Grudev <itay+git2022@grudev.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -36,6 +37,100 @@ namespace GPG { string? home_dir; } + [Compact] + [CCode (cname = "struct _gpgme_key", ref_function = "gpgme_key_ref", ref_function_void = true, unref_function = "gpgme_key_unref", free_function = "gpgme_key_release")] + public class Key { + public bool revoked; + public bool expired; + public bool disabled; + public bool invalid; + public bool can_encrypt; + public bool can_sign; + public bool can_certify; + public bool secret; + public bool can_authenticate; + public bool is_qualified; + public Protocol protocol; + public string issuer_serial; + public string issuer_name; + public string chain_id; + public Validity owner_trust; + [CCode(array_null_terminated = true)] + public SubKey[] subkeys; + [CCode(array_null_terminated = true)] + public UserID[] uids; + public KeylistMode keylist_mode; + public string fpr { get { return subkeys[0].fpr; } } + } + + [CCode (cname = "struct _gpgme_sig_notation")] + public struct SigNotation { + SigNotation* next; + string? name; + string value; + int name_len; + int value_len; + SigNotationFlags flags; + bool human_readable; + bool critical; + } + + [CCode (cname = "struct _gpgme_subkey")] + public struct SubKey { + SubKey* next; + bool revoked; + bool expired; + bool disabled; + bool invalid; + bool can_encrypt; + bool can_sign; + bool can_certify; + bool secret; + bool can_authenticate; + bool is_qualified; + bool is_cardkey; + PublicKeyAlgorithm algo; + uint length; + string keyid; + string fpr; + long timestamp; + long expires; + string? card_number; + } + + [CCode (cname = "struct _gpgme_key_sig")] + public struct KeySig { + KeySig* next; + bool revoked; + bool expired; + bool invalid; + bool exportable; + PublicKeyAlgorithm algo; + string keyid; + long timestamp; + long expires; + GPGError.Error status; + string uid; + string name; + string email; + string comment; + uint sig_class; + SigNotation notations; + } + + [CCode (cname = "struct _gpgme_user_id")] + public struct UserID { + UserID* next; + bool revoked; + bool invalid; + Validity validity; + string uid; + string name; + string email; + string comment; + KeySig signatures; + } + [CCode (cname = "struct _gpgme_op_verify_result")] public struct VerifyResult { Signature* signatures; @@ -92,7 +187,7 @@ namespace GPG { GPGError.Error validity_reason; PublicKeyAlgorithm pubkey_algo; HashAlgorithm hash_algo; - string? pka_adress; + string? pka_address; } public enum PKAStatus { @@ -128,6 +223,16 @@ namespace GPG { URL0 } + [CCode (cname = "gpgme_pubkey_algo_t", cprefix = "GPGME_PK_")] + public enum PublicKeyAlgorithm { + RSA, + RSA_E, + RSA_S, + ELG_E, + DSA, + ELG + } + [CCode (cname = "gpgme_hash_algo_t", cprefix = "GPGME_MD_")] public enum HashAlgorithm { NONE, @@ -141,9 +246,45 @@ namespace GPG { SHA384, SHA512, MD4, - MD_CRC32, - MD_CRC32_RFC1510, - MD_CRC24_RFC2440 + CRC32, + CRC32_RFC1510, + CRC24_RFC2440 + } + + [CCode (cname = "gpgme_sig_mode_t", cprefix = "GPGME_SIG_MODE_")] + public enum SigMode { + NORMAL, + DETACH, + CLEAR + } + + [CCode (cname = "gpgme_validity_t", cprefix = "GPGME_VALIDITY_")] + public enum Validity { + UNKNOWN, + UNDEFINED, + NEVER, + MARGINAL, + FULL, + ULTIMATE + } + + [CCode (cname = "gpgme_protocol_t", cprefix = "GPGME_PROTOCOL_")] + public enum Protocol { + OpenPGP, + CMS, + GPGCONF, + ASSUAN, + UNKNOWN + } + + [CCode (cname = "gpgme_keylist_mode_t", cprefix = "GPGME_KEYLIST_MODE_")] + public enum KeylistMode { + LOCAL, + EXTERN, + SIGS, + SIG_NOTATIONS, + EPHEMERAL, + VALIDATE } [CCode (cname = "gpgme_export_mode_t", cprefix = "GPGME_EXPORT_MODE_")] @@ -157,6 +298,18 @@ namespace GPG { WITH_HELP } + [CCode (cname = "gpgme_sig_notation_flags_t", cprefix = "GPGME_SIG_NOTATION_")] + public enum SigNotationFlags { + HUMAN_READABLE, + CRITICAL + } + + [CCode (cname = "gpgme_encrypt_flags_t", cprefix = "GPGME_ENCRYPT_")] + public enum EncryptFlags { + ALWAYS_TRUST, + NO_ENCRYPT_TO + } + [CCode (cname = "gpgme_status_code_t", cprefix = "GPGME_STATUS_")] public enum StatusCode { EOF, @@ -244,21 +397,6 @@ namespace GPG { PLAINTEXT } - [Flags] - [CCode (cname="unsigned int")] - public enum ImportStatusFlags { - [CCode (cname = "GPGME_IMPORT_NEW")] - NEW, - [CCode (cname = "GPGME_IMPORT_UID")] - UID, - [CCode (cname = "GPGME_IMPORT_SIG")] - SIG, - [CCode (cname = "GPGME_IMPORT_SUBKEY")] - SUBKEY, - [CCode (cname = "GPGME_IMPORT_SECRET")] - SECRET - } - [Compact] [CCode (cname = "struct gpgme_context", free_function = "gpgme_release", cprefix = "gpgme_")] public class Context { @@ -305,11 +443,11 @@ namespace GPG { public Key* signers_enum(int n); public void sig_notation_clear(); - + public GPGError.Error sig_notation_add(string name, string val, SigNotationFlags flags); public SigNotation* sig_notation_get(); - + [CCode (cname = "gpgme_get_key")] private GPGError.Error get_key_(string fpr, out Key key, bool secret); @@ -319,7 +457,7 @@ namespace GPG { throw_if_error(get_key_(fpr, out key, secret)); return key; } - + public Context* wait(out GPGError.Error status, bool hang); public SignResult* op_sign_result(); @@ -405,10 +543,24 @@ namespace GPG { public KeylistResult op_keylist_result(); } + [Flags] + [CCode (cname="unsigned int")] + public enum ImportStatusFlags { + [CCode (cname = "GPGME_IMPORT_NEW")] + NEW, + [CCode (cname = "GPGME_IMPORT_UID")] + UID, + [CCode (cname = "GPGME_IMPORT_SIG")] + SIG, + [CCode (cname = "GPGME_IMPORT_SUBKEY")] + SUBKEY, + [CCode (cname = "GPGME_IMPORT_SECRET")] + SECRET + } + [Compact] [CCode (cname = "struct _gpgme_import_status")] public class ImportStatus { - public ImportStatus? next; public string fpr; public GPGError.Error result; @@ -443,7 +595,7 @@ namespace GPG { [Compact] [CCode (cname = "struct gpgme_data", free_function = "gpgme_data_release", cprefix = "gpgme_data_")] public class Data { - + public static GPGError.Error new(out Data d); public static Data create() throws GLib.Error { @@ -452,7 +604,6 @@ namespace GPG { return data; } - [CCode (cname = "gpgme_data_new_from_mem")] public static GPGError.Error new_from_memory(out Data d, char[] buffer, bool copy); @@ -482,7 +633,7 @@ namespace GPG { public GPGError.Error set_file_name(string file_name); - public DataEncoding* get_encoding(); + public DataEncoding *get_encoding(); public GPGError.Error set_encoding(DataEncoding enc); } @@ -499,11 +650,14 @@ namespace GPG { [CCode (cname = "gpgme_passphrase_cb_t", has_target = false)] public delegate GPGError.Error passphrase_callback(void* hook, string uid_hint, string passphrase_info, bool prev_was_bad, int fd); + [CCode (cname = "gpgme_check_version")] + public unowned string check_version(string? required_version = null); + [CCode (cname = "gpgme_engine_check_version")] public GPGError.Error engine_check_version(Protocol proto); - [CCode (cname = "gpgme_get_engine_information")] - public GPGError.Error get_engine_information(out EngineInfo engine_info); + [CCode (cname = "gpgme_get_engine_info")] + public GPGError.Error get_engine_info(out EngineInfo? engine_info); [CCode (cname = "gpgme_strerror_r")] public int strerror_r(GPGError.Error err, uint8[] buf); |