anotherim-desktop/plugins/openpgp/vapi/gpgme.vapi
Maxim Logaev 6fd8f9a45c
Added full Windows support (#8)
* Windows compatibility Tweaks

* Add experimental windows installer

This nsis script should create a windows installer.
Although the installer worked for the first tests
you should handle it with care and consider it
highly experimental

* Prepare signing

Collected some infos regarding signing
a windows build.

* Revert "Prepare signing"

I copied the files into the wrong folder…
… it's late, sorry.

This reverts commit 7d6b9e7f4c.

* Prepare signing

Collected some infos regarding signing
a windows build.

* Fix typo in Dino slogan

* Add license to windows installer

* Add startmenu folder with several items

Added a startmenu folder with the following items:
* Dino launcher
* License
* Link to Dino website
* Uninstaller

* Prevent duplicated DLLs

* Add dino logo again

The dino logo for the startmenu was accidentally
no longer included since the last commit.

* Simplify installer script

The current build script already places the files in the right
folder structure so the installer doesn't have to do it itself

* Add german language.

* Add option to install without OpenPGP plugin

* Removed compenent section

This section was only introduced to be able to
disable the OpenPGP plugin as Dino often crashed
on Windows if OpenPGP was not installed but the
plugin enabled.

This is no more necessary as the OpenPGP plugin
is now disabled by default.

* Remove installation type "OpenPGP" support

This is no longer needed (see previous commit)
but was forgotten to remove in the previous
commit.

* Add compression to achieve smaller installer size.

* Add AppID (untested).

* Fix syntax error for setting AppID.

* Windows compatibility Tweaks

* fix build on newest MSYS2

* Do not search for the built-in libraries when compiling with MINGW

* Added _WIN32 define to VALAC on Windows

* Add missing _WIN32

* Add support for OpenPGP on Windows

* Use ShellExecute instead of AppInfo to open files on Windows

* Use slight larger font on Windows so it matches Linux style

Also fixes some fuzzy fonts.

* Fixed some Windows not appearing when opening file

* Set alternate file stream for downloaded files.

* Added information and Dino icon to Windows executable

* Set Windows executable version from PROJECT_VERSION

* Add WIN32 fonts as a plugin

* Every call to CoInitialize() must be balanced
with a call to CoUninitialize()

* Add --export-all-symbols to Windows compilation

* Add implicit link directories to package HINT path on MingW

Instead of blacklisting those libraries

* Do not hardcode GPG path on Windows

* Export all plugin symbols on Windows

* Use Dino.Util.get_content_type also on preview

* Allow 32-bit linking

Win32 apis are __stdcall

* Use last_index_of instead of index_of

* Initial notification support

* Refactor windows-notification plugin

* Clean up

* Use code from Dino.Ui.Util

* Convert C code to Vala

* Add callback support

* Allow null image_path

* Use dynamic linking instead of runtime loading

Also made me notice that the signature of the function with the callback was wrong. Oops.

* Added 32-bit wintoast linker library

* Use VAPI and generate template in-app

* Initial plugin using new notification provider

* Add support for custom actions on notification

* Add notification retraction

* Use list with all notifications

* Rename field

* Fix muc invite and voide request not working

* Do not use GLib to open links in messages

Use ShellExecute

* Add MIT licensed winrt headers

* Initial code for using winrt headers

* Initial callback support

* Initial GObject wrapper for WinRT notifications

Still missing a lot of stuff

* Initial code to allow buttons and text

* Use string_view

* Increase ref on event token

* Add toastnotifier

* Fix string conversion

* Actions can stack

* Remove unity compilation unit

* No need to enable coroutines

* Fields must be created in the private struct

Also change unordered_map to list, we do not need hashing and stuff.

* Add failed and dimissed actions

* Cleanup dismissed actions on toast notification finalizer

* Add template type enum

* Rename enums to better match what Vala expects

* Rename plugin vala file

* Add template getter

* Initial experiments with notification XML building

* Anitial builder

* Initial notification provider using WinRT

Crashes when activating actions, might be related to threads.

* Delegate `activate_action` to UI thread

* Fixed crash with multiple notifications

Sometimes an invalid function pointer was called with an invalid context

* Add comment to builder

* Use async

* Use g_new0 and g_free to generate raw strings

* Valac think that getters are always owned by the struct

* introduce try_invoke -- a logging exception catcher

* stop exceptions from crossing ABI boundary in a few places

* mark exception-safe C entry points as such

* clarify some entry points' names

* make GetCurrentModulePath and GetShortcutPath throw win32 errors

* clarify GetCurrentModulePath's name

* generalize GetShortcutPath into GetEnv

* make GetEnv more robust and not limit length of variables

* change some local functions' signatures

* constify all the things

* rewrite shortcut management code with RAII, error logging and exceptions

It actually works now.

* add restoration of shortcut's target path

* switch to runtime loading of PropVariantToStringAlloc

Now it really should work.

* Add ginvoke to CMakeLists

* Removed unused library on linker

It is loaded dynamically

* Add README.md to Windows notification plugin

* Fix notifications not hiding

* unimplement accidentally implemented wide string overloads of describe_argument

* work around GetEnvironmentVariable not resetting last error

* handle exe paths longer than 259 chars

* move some whitespace around

* use lower-case 0x prefix for hresult code formatting everywhere

* remove an unused include

* make meta-error messages more precise

* handle empty hresult_error message specially

* handle theoretical future failures of wsview_to_char

* fix UB in glib::describe_arguments called with no arguments

Makes failure logging of nullary invokables non-crashy.

* make glib::impl::varstring less explosive

* fiddle with punctuation

* add nullary version of g_try_invoke macro

* generalize glib::try_invoke to any return-by-value type and void

* protect GetTemplateContent callers from exceptions

* rewrite InitApartment and protect callers from (the rest of the) exceptions

Initializing COM by calling `winrt::init_apartment()` would always cause
stack unwinding *in practice*, which is suboptimal at best, and even using
`apartment_type::single_threaded` still would require exception filtering
*just in case*.

* handle empty menu-relative shortcut paths

* move module loading functions out of shortcutcreator.cpp

* work around a (pedantic) format specifier warning

* silence enum stringification warnings by first casting to underlying types

* fix / work around uninitialized fields warnings

* don't use FALSE as a null pointer constant

* replace C-style concurrent initialization of statics

C++ statics are thread-safe as is and are usually implemented more
efficiently. Besides, `volatile` is likely misused here anyway.

* reflow/respace

* stop checking for empty AUMIDs

The downstream code handles them just fine.

* log SetCurrentProcessExplicitAppUserModelID errors

* remove the no-longer-needed -municode compile option

* replace lists with vectors

* init `Callback` completely always

The `token` pointer was left dangerously uninitialized after construction.

* comment out unused arguments [-Wunused-parameter]

* Add support for adaptive Windows 10 notifications

* Add support for inline images to notification

* Allow null header, body, applogo, and image on notification builder

* DelegateToUi must be an owned function

* Prefer primary DirectSound device on Windows

It automatically selects the default device for use,
there is no book keeping necessary and things just work

The primary DirectSound device has a (NULL) guid, making
it wasy to be found.

* Do not allow selection of WASAPI devices

Dino would have to resample it own audio, do more book keeping and
somehow find out manually which is the default device.

* Add initial call notifications

* Use correct generic type for ArrayList

Nullable crashes Dino

* Allow devices with properties and use has_classes

* Remove YoloRT from tree

* Build YoloRT on project build

* Do not generate WinRT headers, just download them on build

* Fix compilation on gcc 11

* define _POSIX_C_SOURCE=1 on windows

Fixes "undefined reference to `localtime_r`" in, e.g., Vala's GLib.Time.local
when building on mingw-w64.

* fix call notifications buttons not working

* no need to ignore wasapi

* Ignore wasapi devices as they do not work well yet

* Removed version from Dino executable

We need a better way to get the version number

* Automatically set PANGOCAIRO_BACKEND to fontconfig on win32

* Fixed using GTK3 instead of GTK4

* Check YoloRT checksum before building

* Fix GPGME

* Added build script for windows

Signed-off-by: Maxim Logaev <maxlogaev@proton.me>

* Added README-WIN64.md

Signed-off-by: Maxim Logaev <maxlogaev@proton.me>

* Fixed dist-install dir

Signed-off-by: Maxim Logaev <maxlogaev@proton.me>

* Removed unnecessary installer files

Signed-off-by: Maxim Logaev <maxlogaev@proton.me>

* Added build-installer target to build-win64.sh

Signed-off-by: Maxim Logaev <maxlogaev@proton.me>

* Fixed build dependencies

Signed-off-by: Maxim Logaev <maxlogaev@proton.me>

* Move download yolort headers logic into prepare stage, delete yolort download script

* Added CI for MSYS2 (MINGW64) (#2)

- Use quotes in windows build script;
- Added missing gstreamer, webrtc-audio-processing and git;
- Added CI for Windows.
---------
Signed-off-by: Maxim Logaev <maxlogaev@proton.me>

---------

Signed-off-by: Maxim Logaev <maxlogaev@proton.me>
Co-authored-by: LAGonauta <lagonauta@gmail.com>
Co-authored-by: Martin Dosch <spam@mdosch.de>
Co-authored-by: Martin Dosch <martin@mdosch.de>
Co-authored-by: mjk <yuubi-san@users.noreply.github.com>
Co-authored-by: Daniel Reuther <daniel.reuther@liferay.com>
Co-authored-by: Felipe <LAGonauta@users.noreply.github.com>
Co-authored-by: Psayker <kirill970528@yandex.ru>
2024-03-18 22:51:50 +03:00

677 lines
19 KiB
Vala

/* 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
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
[CCode (lower_case_cprefix = "gpgme_", cheader_filename = "gpgme.h,gpgme_fix.h")]
namespace GPG {
public static GLib.RecMutex global_mutex;
[CCode (cname = "struct _gpgme_engine_info")]
public struct EngineInfo {
EngineInfo* next;
Protocol protocol;
string file_name;
string version;
string req_version;
string? home_dir;
}
[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 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;
string? file_name;
}
[CCode (cname = "struct _gpgme_op_sign_result")]
public struct SignResult {
InvalidKey invalid_signers;
Signature* signatures;
}
[CCode (cname = "struct _gpgme_op_encrypt_result")]
public struct EncryptResult {
InvalidKey invalid_signers;
}
[CCode (cname = "struct _gpgme_op_decrypt_result")]
public struct DecryptResult {
string unsupported_algorithm;
bool wrong_key_usage;
Recipient recipients;
string file_name;
}
[CCode (cname = "struct _gpgme_recipient")]
public struct Recipient {
Recipient *next;
string keyid;
PublicKeyAlgorithm pubkey_algo;
GPGError.Error status;
}
[CCode (cname = "struct _gpgme_invalid_key")]
public struct InvalidKey {
InvalidKey *next;
string fpr;
GPGError.Error reason;
}
[CCode (cname = "struct _gpgme_signature")]
public struct Signature {
Signature *next;
Sigsum summary;
string fpr;
GPGError.Error status;
SigNotation notations;
ulong timestamp;
ulong exp_timestamp;
bool wrong_key_usage;
PKAStatus pka_trust;
bool chain_model;
Validity validity;
GPGError.Error validity_reason;
PublicKeyAlgorithm pubkey_algo;
HashAlgorithm hash_algo;
string? pka_address;
}
public enum PKAStatus {
NOT_AVAILABLE,
BAD,
OKAY,
RFU
}
[CCode (cname = "gpgme_sigsum_t", cprefix = "GPGME_SIGSUM_")]
public enum Sigsum {
VALID,
GREEN,
RED,
KEY_REVOKED,
KEY_EXPIRED,
SIG_EXPIRED,
KEY_MISSING,
CRL_MISSING,
CRL_TOO_OLD,
BAD_POLICY,
SYS_ERROR
}
[CCode (cname = "gpgme_data_encoding_t", cprefix = "GPGME_DATA_ENCODING_")]
public enum DataEncoding {
NONE,
BINARY,
BASE64,
ARMOR,
URL,
URLESC,
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,
MD5,
SHA1,
RMD160,
MD2,
TIGER,
HAVAL,
SHA256,
SHA384,
SHA512,
MD4,
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_")]
public enum ExportMode {
EXTERN
}
[CCode (cprefix = "GPGME_AUDITLOG_")]
public enum AuditLogFlag {
HTML,
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,
ENTER,
LEAVE,
ABORT,
GOODSIG,
BADSIG,
ERRSIG,
BADARMOR,
RSA_OR_IDEA,
KEYEXPIRED,
KEYREVOKED,
TRUST_UNDEFINED,
TRUST_NEVER,
TRUST_MARGINAL,
TRUST_FULLY,
TRUST_ULTIMATE,
SHM_INFO,
SHM_GET,
SHM_GET_BOOL,
SHM_GET_HIDDEN,
NEED_PASSPHRASE,
VALIDSIG,
SIG_ID,
SIG_TO,
ENC_TO,
NODATA,
BAD_PASSPHRASE,
NO_PUBKEY,
NO_SECKEY,
NEED_PASSPHRASE_SYM,
DECRYPTION_FAILED,
DECRYPTION_OKAY,
MISSING_PASSPHRASE,
GOOD_PASSPHRASE,
GOODMDC,
BADMDC,
ERRMDC,
IMPORTED,
IMPORT_OK,
IMPORT_PROBLEM,
IMPORT_RES,
FILE_START,
FILE_DONE,
FILE_ERROR,
BEGIN_DECRYPTION,
END_DECRYPTION,
BEGIN_ENCRYPTION,
END_ENCRYPTION,
DELETE_PROBLEM,
GET_BOOL,
GET_LINE,
GET_HIDDEN,
GOT_IT,
PROGRESS,
SIG_CREATED,
SESSION_KEY,
NOTATION_NAME,
NOTATION_DATA,
POLICY_URL,
BEGIN_STREAM,
END_STREAM,
KEY_CREATED,
USERID_HINT,
UNEXPECTED,
INV_RECP,
NO_RECP,
ALREADY_SIGNED,
SIGEXPIRED,
EXPSIG,
EXPKEYSIG,
TRUNCATED,
ERROR,
NEWSIG,
REVKEYSIG,
SIG_SUBPACKET,
NEED_PASSPHRASE_PIN,
SC_OP_FAILURE,
SC_OP_SUCCESS,
CARDCTRL,
BACKUP_KEY_CREATED,
PKA_TRUST_BAD,
PKA_TRUST_GOOD,
PLAINTEXT
}
[Compact]
[CCode (cname = "struct gpgme_context", free_function = "gpgme_release", cprefix = "gpgme_")]
public class Context {
private static GPGError.Error new(out Context ctx);
public static Context create() throws GLib.Error {
Context ctx;
throw_if_error(@new(out ctx));
return ctx;
}
public GPGError.Error set_protocol(Protocol p);
public Protocol get_protocol();
public void set_armor(bool yes);
public bool get_armor();
public void set_textmode(bool yes);
public bool get_textmode();
public GPGError.Error set_keylist_mode(KeylistMode mode);
public KeylistMode get_keylist_mode();
public void set_include_certs(int nr_of_certs = -256);
public int get_include_certs();
public void set_passphrase_cb(passphrase_callback cb, void* hook_value = null);
public void get_passphrase_cb(out passphrase_callback cb, out void* hook_value);
public GPGError.Error set_locale(int category, string val);
[CCode (cname = "gpgme_ctx_get_engine_info")]
public EngineInfo* get_engine_info();
[CCode (cname = "gpgme_ctx_set_engine_info")]
public GPGError.Error set_engine_info(Protocol proto, string file_name, string home_dir);
public void signers_clear();
public GPGError.Error signers_add(Key key);
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);
[CCode (cname = "gpgme_get_key_")]
public Key get_key(string fpr, bool secret) throws GLib.Error {
Key key;
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();
[CCode (cname = "gpgme_op_sign")]
public GPGError.Error op_sign_(Data plain, Data sig, SigMode mode);
[CCode (cname = "gpgme_op_sign_")]
public Data op_sign(Data plain, SigMode mode) throws GLib.Error {
Data sig = Data.create();
throw_if_error(op_sign_(plain, sig, mode));
return sig;
}
public VerifyResult* op_verify_result();
[CCode (cname = "gpgme_op_verify")]
public GPGError.Error op_verify_(Data sig, Data signed_text, Data? plaintext);
[CCode (cname = "gpgme_op_verify_")]
public Data op_verify(Data sig, Data signed_text) throws GLib.Error {
Data plaintext = Data.create();
throw_if_error(op_verify_(sig, signed_text, plaintext));
return plaintext;
}
public EncryptResult* op_encrypt_result();
[CCode (cname = "gpgme_op_encrypt")]
public GPGError.Error op_encrypt_([CCode (array_length = false)] Key[] recp, EncryptFlags flags, Data plain, Data cipher);
[CCode (cname = "gpgme_op_encrypt_")]
public Data op_encrypt(Key[] recp, EncryptFlags flags, Data plain) throws GLib.Error {
Data cipher = Data.create();
throw_if_error(op_encrypt_(recp, flags, plain, cipher));
return cipher;
}
public DecryptResult* op_decrypt_result();
[CCode (cname = "gpgme_op_decrypt")]
public GPGError.Error op_decrypt_(Data cipher, Data plain);
[CCode (cname = "gpgme_op_decrypt_")]
public Data op_decrypt(Data cipher) throws GLib.Error {
Data plain = Data.create();
throw_if_error(op_decrypt_(cipher, plain));
return plain;
}
public GPGError.Error op_export(string? pattern, ExportMode mode, Data keydata);
public GPGError.Error op_import(Data keydata);
public unowned ImportResult op_import_result();
[CCode (cname = "gpgme_op_keylist_start")]
private GPGError.Error op_keylist_start_(string? pattern = null, int secret_only = 0);
[CCode (cname = "gpgme_op_keylist_start_")]
public void op_keylist_start(string? pattern = null, int secret_only = 0) throws GLib.Error {
throw_if_error(op_keylist_start_(pattern, secret_only));
}
[CCode (cname = "gpgme_op_keylist_next")]
private GPGError.Error op_keylist_next_(out Key key);
[CCode (cname = "gpgme_op_keylist_next_")]
public Key op_keylist_next() throws GLib.Error {
Key key;
throw_if_error(op_keylist_next_(out key));
return key;
}
[CCode (cname = "gpgme_op_keylist_end")]
private GPGError.Error op_keylist_end_();
[CCode (cname = "gpgme_op_keylist_end_")]
public void op_keylist_end() throws GLib.Error {
throw_if_error(op_keylist_end_());
}
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;
public ImportStatusFlags status;
}
[Compact]
[CCode (cname = "struct _gpgme_op_import_result")]
public class ImportResult {
public int considered;
public int no_user_id;
public int imported;
public int imported_rsa;
public int unchanged;
public int new_user_ids;
public int new_sub_keys;
public int new_signatures;
public int new_revocations;
public int secret_read;
public int secret_imported;
public int secret_unchanged;
public int not_imported;
public ImportStatus imports;
}
[Compact]
[CCode (cname = "struct _gpgme_op_keylist_result")]
public class KeylistResult {
uint truncated;
}
[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 {
Data data;
throw_if_error(@new(out data));
return data;
}
[CCode (cname = "gpgme_data_new_from_mem")]
public static GPGError.Error new_from_memory(out Data d, char[] buffer, bool copy);
public static Data create_from_memory(uint8[] buffer, bool copy) throws GLib.Error {
Data data;
throw_if_error(new_from_memory(out data, (char[]) buffer, copy));
return data;
}
[CCode (cname = "gpgme_data_new_from_file")]
public static GPGError.Error new_from_file(out Data d, string filename, int copy = 1);
public static Data create_from_file(string filename, int copy = 1) throws GLib.Error {
Data data;
throw_if_error(new_from_file(out data, filename, copy));
return data;
}
[CCode (cname = "gpgme_data_release_and_get_mem")]
public string release_and_get_mem(out size_t len);
public ssize_t read([CCode (array_length = false)] uint8[] buf, size_t len);
public ssize_t write(uint8[] buf);
public long seek(long offset, int whence=0);
public GPGError.Error set_file_name(string file_name);
public DataEncoding *get_encoding();
public GPGError.Error set_encoding(DataEncoding enc);
}
[CCode (cname = "gpgme_get_protocol_name")]
public unowned string get_protocol_name(Protocol p);
[CCode (cname = "gpgme_pubkey_algo_name")]
public unowned string get_public_key_algorithm_name(PublicKeyAlgorithm algo);
[CCode (cname = "gpgme_hash_algo_name")]
public unowned string get_hash_algorithm_name(HashAlgorithm algo);
[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_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);
[CCode (cname = "gpgme_strerror")]
public unowned string strerror(GPGError.Error err);
[CCode (cname = "gpgme_set_global_flag")]
public int set_global_flag(string name, string value);
private void throw_if_error(GPGError.Error error) throws GLib.Error {
if (error.code != GPGError.ErrorCode.NO_ERROR) {
throw new GLib.Error(-1, error.code, "%s", error.to_string());
}
}
}