From 04dfd445db6f2185d3c979a3138b6dbba01c964a Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 1 Nov 2015 21:31:29 +0100 Subject: [PATCH 001/100] application: add GLib.Application() support --- Makefile.am | 3 +- src/mconnect/application.vala | 71 +++++++++++++++++++++++++++++++++++ src/mconnect/main.vala | 49 +----------------------- 3 files changed, 75 insertions(+), 48 deletions(-) create mode 100644 src/mconnect/application.vala diff --git a/Makefile.am b/Makefile.am index bed9981..b71a7bb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,7 +65,8 @@ mconnect_SOURCES = \ src/mconnect/battery.vala \ src/mconnect/telephony.vala \ src/mconnect/mousepad.vala \ - src/mconnect/config.vala + src/mconnect/config.vala \ + src/mconnect/application.vala mconnect_LDADD = \ libmconn-crypt.la \ diff --git a/src/mconnect/application.vala b/src/mconnect/application.vala new file mode 100644 index 0000000..254ce4b --- /dev/null +++ b/src/mconnect/application.vala @@ -0,0 +1,71 @@ +/* ex:ts=4:sw=4:sts=4:et */ +/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * AUTHORS + * Maciek Borzecki + */ + +namespace Mconn { + + public class Application : GLib.Application { + + private Core core = null; + + private static bool log_debug = false; + + private const GLib.OptionEntry[] options = { + {"debug", 'd', 0, OptionArg.NONE, ref log_debug, "Show debug output", null}, + {null} + }; + + public Application() { + Object(application_id: "org.bboozzoo.mconnect"); + add_main_option_entries(options); + } + + protected override void startup() { + base.startup(); + + if (log_debug == true) + Environment.set_variable("G_MESSAGES_DEBUG", "all", false); + + core = Core.instance(); + if (core == null) + error("cannot initialize core"); + + if (core.config.is_debug_on() == true) + Environment.set_variable("G_MESSAGES_DEBUG", "all", false); + + Notify.init("mconnect"); + + var discovery = new Discovery(); + var manager = new DeviceManager(); + + discovery.device_found.connect((disc, dev) => { + manager.found_device(dev); + }); + try { + discovery.listen(); + } catch (Error e) { + message("failed to setup device listener: %s", e.message); + } + } + + protected override void activate() { + hold(); + } + } +} \ No newline at end of file diff --git a/src/mconnect/main.vala b/src/mconnect/main.vala index 36b7bc4..039c032 100644 --- a/src/mconnect/main.vala +++ b/src/mconnect/main.vala @@ -17,54 +17,9 @@ * AUTHORS * Maciek Borzecki */ -private static bool log_debug = false; - -private const GLib.OptionEntry[] options = { - {"debug", 'd', 0, OptionArg.NONE, ref log_debug, "Show debug output", null}, - {null} -}; - public static int main(string[] args) { - try { - var opt_context = new OptionContext ("mconnect"); - opt_context.set_help_enabled (true); - opt_context.add_main_entries (options, null); - opt_context.parse (ref args); - } catch (OptionError e) { - stdout.printf ("error: %s\n", e.message); - stdout.printf ("Run '%s --help' to see a full list of available command line options.\n", args[0]); - return 0; - } - - if (log_debug == true) - Environment.set_variable("G_MESSAGES_DEBUG", "all", false); - - Gdk.init(ref args); - - Notify.init("mconnect"); - - var core = Core.instance(); - if (core == null) - error("cannot initialize core"); - - if (core.config.is_debug_on() == true) - Environment.set_variable("G_MESSAGES_DEBUG", "all", false); - - var loop = new MainLoop(); - var discovery = new Discovery(); - var manager = new DeviceManager(); - - discovery.device_found.connect((disc, dev) => { - manager.found_device(dev); - }); + var app = new Mconn.Application(); - try { - discovery.listen(); - } catch (Error e) { - message("failed to setup device listener: %s", e.message); - return 1; - } - loop.run(); - return 0; + return app.run(args); } \ No newline at end of file From 9ff55328bd5cc757555d85293c893733acdd18a2 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 31 May 2017 22:19:05 +0200 Subject: [PATCH 002/100] vapi/gio-2.0: remove stale gio-2.0 VAPI files Patched gio-2.0 VAPI files are no longer needed. --- vapi/gio-2.0.vapi | 5089 --------------------------------------------- 1 file changed, 5089 deletions(-) delete mode 100644 vapi/gio-2.0.vapi diff --git a/vapi/gio-2.0.vapi b/vapi/gio-2.0.vapi deleted file mode 100644 index f735f67..0000000 --- a/vapi/gio-2.0.vapi +++ /dev/null @@ -1,5089 +0,0 @@ -/* gio-2.0.vapi generated by vapigen, do not modify. */ - -[CCode (cprefix = "G", gir_namespace = "Gio", gir_version = "2.0", lower_case_cprefix = "g_")] -namespace GLib { - namespace Bus { - [CCode (cheader_filename = "gio/gio.h")] - public static async GLib.DBusConnection @get (GLib.BusType bus_type, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [CCode (cheader_filename = "gio/gio.h")] - public static async T get_proxy (GLib.BusType bus_type, string name, string object_path, GLib.DBusProxyFlags flags = 0, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [CCode (cheader_filename = "gio/gio.h")] - public static T get_proxy_sync (GLib.BusType bus_type, string name, string object_path, GLib.DBusProxyFlags flags = 0, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [CCode (cheader_filename = "gio/gio.h")] - public static GLib.DBusConnection get_sync (GLib.BusType bus_type, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [CCode (cheader_filename = "gio/gio.h", cname = "g_bus_own_name_with_closures")] - [Version (since = "2.26")] - public static uint own_name (GLib.BusType bus_type, string name, GLib.BusNameOwnerFlags flags, [CCode (type = "GClosure*")] owned GLib.BusAcquiredCallback? bus_acquired_closure = null, [CCode (type = "GClosure*")] owned GLib.BusNameAcquiredCallback? name_acquired_closure = null, [CCode (type = "GClosure*")] owned GLib.BusNameLostCallback? name_lost_closure = null); - [CCode (cheader_filename = "gio/gio.h", cname = "g_bus_own_name_on_connection_with_closures")] - [Version (since = "2.26")] - public static uint own_name_on_connection (GLib.DBusConnection connection, string name, GLib.BusNameOwnerFlags flags, [CCode (type = "GClosure*")] owned GLib.BusNameAcquiredCallback? name_acquired_closure = null, [CCode (type = "GClosure*")] owned GLib.BusNameLostCallback? name_lost_closure = null); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public static void unown_name (uint owner_id); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public static void unwatch_name (uint watcher_id); - [CCode (cheader_filename = "gio/gio.h", cname = "g_bus_watch_name_with_closures")] - [Version (since = "2.26")] - public static uint watch_name (GLib.BusType bus_type, string name, GLib.BusNameWatcherFlags flags, [CCode (type = "GClosure*")] owned GLib.BusNameAppearedCallback? name_appeared_closure = null, [CCode (type = "GClosure*")] owned GLib.BusNameVanishedCallback? name_vanished_closure = null); - [CCode (cheader_filename = "gio/gio.h", cname = "g_bus_watch_name_on_connection_with_closures")] - [Version (since = "2.26")] - public static uint watch_name_on_connection (GLib.DBusConnection connection, string name, GLib.BusNameWatcherFlags flags, [CCode (type = "GClosure*")] owned GLib.BusNameAppearedCallback? name_appeared_closure = null, [CCode (type = "GClosure*")] owned GLib.BusNameVanishedCallback? name_vanished_closure = null); - } - namespace ContentType { - [CCode (cheader_filename = "gio/gio.h")] - public static bool can_be_executable (string type); - [CCode (cheader_filename = "gio/gio.h")] - public static bool equals (string type1, string type2); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.18")] - public static string? from_mime_type (string mime_type); - [CCode (cheader_filename = "gio/gio.h")] - public static string get_description (string type); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.34")] - public static string? get_generic_icon_name (string type); - [CCode (cheader_filename = "gio/gio.h")] - public static GLib.Icon get_icon (string type); - [CCode (cheader_filename = "gio/gio.h")] - public static string? get_mime_type (string type); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.34")] - public static GLib.Icon get_symbolic_icon (string type); - [CCode (cheader_filename = "gio/gio.h")] - public static string guess (string? filename, [CCode (array_length_cname = "data_size", array_length_pos = 2.5, array_length_type = "gsize")] uint8[]? data, out bool result_uncertain); - [CCode (array_length = false, array_null_terminated = true, cheader_filename = "gio/gio.h")] - [Version (since = "2.18")] - public static string[] guess_for_tree (GLib.File root); - [CCode (cheader_filename = "gio/gio.h")] - public static bool is_a (string type, string supertype); - [CCode (cheader_filename = "gio/gio.h")] - public static bool is_unknown (string type); - [CCode (cheader_filename = "gio/gio.h", cname = "g_content_types_get_registered")] - public static GLib.List list_registered (); - } - namespace DBus { - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.36")] - public static string address_escape_value (string string); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public static async GLib.IOStream address_get_stream (string address, GLib.Cancellable? cancellable = null, out string out_guid) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public static GLib.IOStream address_get_stream_sync (string address, out string out_guid, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public static unowned string annotation_info_lookup ([CCode (array_length = false, array_null_terminated = true)] GLib.DBusAnnotationInfo[]? annotations, string name); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public static string generate_guid (); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.30")] - public static GLib.Variant gvalue_to_gvariant (GLib.Value gvalue, GLib.VariantType type); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.30")] - public static GLib.Value gvariant_to_gvalue (GLib.Variant value); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public static bool is_address (string string); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public static bool is_guid (string string); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public static bool is_interface_name (string string); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public static bool is_member_name (string string); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public static bool is_name (string string); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public static bool is_supported_address (string string) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public static bool is_unique_name (string string); - } - namespace FileAttribute { - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE")] - public const string ACCESS_CAN_DELETE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE")] - public const string ACCESS_CAN_EXECUTE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_ACCESS_CAN_READ")] - public const string ACCESS_CAN_READ; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME")] - public const string ACCESS_CAN_RENAME; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH")] - public const string ACCESS_CAN_TRASH; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE")] - public const string ACCESS_CAN_WRITE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE")] - public const string DOS_IS_ARCHIVE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_DOS_IS_SYSTEM")] - public const string DOS_IS_SYSTEM; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_ETAG_VALUE")] - public const string ETAG_VALUE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_FILESYSTEM_FREE")] - public const string FILESYSTEM_FREE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_FILESYSTEM_READONLY")] - public const string FILESYSTEM_READONLY; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_FILESYSTEM_SIZE")] - public const string FILESYSTEM_SIZE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_FILESYSTEM_TYPE")] - public const string FILESYSTEM_TYPE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_FILESYSTEM_USED")] - [Version (since = "2.32")] - public const string FILESYSTEM_USED; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW")] - public const string FILESYSTEM_USE_PREVIEW; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_GVFS_BACKEND")] - public const string GVFS_BACKEND; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_ID_FILE")] - public const string ID_FILE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_ID_FILESYSTEM")] - public const string ID_FILESYSTEM; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT")] - public const string MOUNTABLE_CAN_EJECT; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT")] - public const string MOUNTABLE_CAN_MOUNT; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL")] - [Version (since = "2.22")] - public const string MOUNTABLE_CAN_POLL; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START")] - [Version (since = "2.22")] - public const string MOUNTABLE_CAN_START; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED")] - [Version (since = "2.22")] - public const string MOUNTABLE_CAN_START_DEGRADED; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP")] - [Version (since = "2.22")] - public const string MOUNTABLE_CAN_STOP; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT")] - public const string MOUNTABLE_CAN_UNMOUNT; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI")] - public const string MOUNTABLE_HAL_UDI; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC")] - [Version (since = "2.22")] - public const string MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE")] - [Version (since = "2.22")] - public const string MOUNTABLE_START_STOP_TYPE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE")] - public const string MOUNTABLE_UNIX_DEVICE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE")] - [Version (since = "2.22")] - public const string MOUNTABLE_UNIX_DEVICE_FILE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_OWNER_GROUP")] - public const string OWNER_GROUP; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_OWNER_USER")] - public const string OWNER_USER; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_OWNER_USER_REAL")] - public const string OWNER_USER_REAL; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_PREVIEW_ICON")] - [Version (since = "2.20")] - public const string PREVIEW_ICON; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_SELINUX_CONTEXT")] - public const string SELINUX_CONTEXT; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE")] - [Version (since = "2.20")] - public const string STANDARD_ALLOCATED_SIZE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE")] - public const string STANDARD_CONTENT_TYPE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_COPY_NAME")] - public const string STANDARD_COPY_NAME; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION")] - public const string STANDARD_DESCRIPTION; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME")] - public const string STANDARD_DISPLAY_NAME; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME")] - public const string STANDARD_EDIT_NAME; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE")] - public const string STANDARD_FAST_CONTENT_TYPE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_ICON")] - public const string STANDARD_ICON; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP")] - public const string STANDARD_IS_BACKUP; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN")] - public const string STANDARD_IS_HIDDEN; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK")] - public const string STANDARD_IS_SYMLINK; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL")] - public const string STANDARD_IS_VIRTUAL; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE")] - [Version (since = "2.46")] - public const string STANDARD_IS_VOLATILE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_NAME")] - public const string STANDARD_NAME; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_SIZE")] - public const string STANDARD_SIZE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER")] - public const string STANDARD_SORT_ORDER; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON")] - [Version (since = "2.34")] - public const string STANDARD_SYMBOLIC_ICON; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET")] - public const string STANDARD_SYMLINK_TARGET; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_TARGET_URI")] - public const string STANDARD_TARGET_URI; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_STANDARD_TYPE")] - public const string STANDARD_TYPE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_THUMBNAILING_FAILED")] - public const string THUMBNAILING_FAILED; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID")] - [Version (since = "2.40")] - public const string THUMBNAIL_IS_VALID; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_THUMBNAIL_PATH")] - public const string THUMBNAIL_PATH; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_TIME_ACCESS")] - public const string TIME_ACCESS; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_TIME_ACCESS_USEC")] - public const string TIME_ACCESS_USEC; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_TIME_CHANGED")] - public const string TIME_CHANGED; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_TIME_CHANGED_USEC")] - public const string TIME_CHANGED_USEC; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_TIME_CREATED")] - public const string TIME_CREATED; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_TIME_CREATED_USEC")] - public const string TIME_CREATED_USEC; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_TIME_MODIFIED")] - public const string TIME_MODIFIED; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC")] - public const string TIME_MODIFIED_USEC; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_TRASH_DELETION_DATE")] - [Version (since = "2.24")] - public const string TRASH_DELETION_DATE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT")] - public const string TRASH_ITEM_COUNT; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_TRASH_ORIG_PATH")] - [Version (since = "2.24")] - public const string TRASH_ORIG_PATH; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_UNIX_BLOCKS")] - public const string UNIX_BLOCKS; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE")] - public const string UNIX_BLOCK_SIZE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_UNIX_DEVICE")] - public const string UNIX_DEVICE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_UNIX_GID")] - public const string UNIX_GID; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_UNIX_INODE")] - public const string UNIX_INODE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT")] - public const string UNIX_IS_MOUNTPOINT; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_UNIX_MODE")] - public const string UNIX_MODE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_UNIX_NLINK")] - public const string UNIX_NLINK; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_UNIX_RDEV")] - public const string UNIX_RDEV; - [CCode (cheader_filename = "gio/gio.h", cname = "G_FILE_ATTRIBUTE_UNIX_UID")] - public const string UNIX_UID; - } - namespace VolumeIdentifier { - [CCode (cheader_filename = "gio/gio.h", cname = "G_VOLUME_IDENTIFIER_KIND_CLASS")] - public const string CLASS; - [CCode (cheader_filename = "gio/gio.h", cname = "G_VOLUME_IDENTIFIER_KIND_HAL_UDI")] - public const string HAL_UDI; - [CCode (cheader_filename = "gio/gio.h", cname = "G_VOLUME_IDENTIFIER_KIND_LABEL")] - public const string LABEL; - [CCode (cheader_filename = "gio/gio.h", cname = "G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT")] - public const string NFS_MOUNT; - [CCode (cheader_filename = "gio/gio.h", cname = "G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE")] - public const string UNIX_DEVICE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_VOLUME_IDENTIFIER_KIND_UUID")] - public const string UUID; - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_app_info_monitor_get_type ()")] - [Version (since = "2.40")] - public class AppInfoMonitor : GLib.Object { - [CCode (has_construct_function = false)] - protected AppInfoMonitor (); - public static GLib.AppInfoMonitor @get (); - public signal void changed (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_app_launch_context_get_type ()")] - public class AppLaunchContext : GLib.Object { - [CCode (has_construct_function = false)] - public AppLaunchContext (); - public virtual string get_display (GLib.AppInfo info, GLib.List files); - [CCode (array_length = false, array_null_terminated = true)] - [Version (since = "2.32")] - public string[] get_environment (); - public virtual string get_startup_notify_id (GLib.AppInfo info, GLib.List files); - [Version (since = "2.32")] - public void setenv (string variable, string value); - [Version (since = "2.32")] - public void unsetenv (string variable); - [HasEmitter] - [Version (since = "2.36")] - public virtual signal void launch_failed (string startup_notify_id); - [Version (since = "2.36")] - public virtual signal void launched (GLib.AppInfo info, GLib.Variant platform_data); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_application_get_type ()")] - [Version (since = "2.28")] - public class Application : GLib.Object, GLib.ActionGroup, GLib.ActionMap { - [CCode (has_construct_function = false)] - public Application (string? application_id, GLib.ApplicationFlags flags); - [Version (since = "2.42")] - public void add_main_option (string long_name, char short_name, GLib.OptionFlags flags, GLib.OptionArg arg, string description, string? arg_description); - [Version (since = "2.40")] - public void add_main_option_entries ([CCode (array_length = false, array_null_terminated = true)] GLib.OptionEntry[] entries); - [Version (since = "2.40")] - public void add_option_group (owned GLib.OptionGroup group); - [NoWrapper] - public virtual void add_platform_data (GLib.VariantBuilder builder); - [NoWrapper] - public virtual void after_emit (GLib.Variant platform_data); - [NoWrapper] - public virtual void before_emit (GLib.Variant platform_data); - [Version (since = "2.44")] - public void bind_busy_property (GLib.Object object, string property); - [NoWrapper] - public virtual bool dbus_register (GLib.DBusConnection connection, string object_path) throws GLib.Error; - [NoWrapper] - public virtual void dbus_unregister (GLib.DBusConnection connection, string object_path); - public unowned string get_application_id (); - [Version (since = "2.34")] - public unowned GLib.DBusConnection get_dbus_connection (); - [Version (since = "2.34")] - public unowned string get_dbus_object_path (); - [Version (since = "2.32")] - public static unowned GLib.Application get_default (); - public GLib.ApplicationFlags get_flags (); - public uint get_inactivity_timeout (); - [Version (since = "2.44")] - public bool get_is_busy (); - public bool get_is_registered (); - public bool get_is_remote (); - [Version (since = "2.42")] - public unowned string? get_resource_base_path (); - public void hold (); - public static bool id_is_valid (string application_id); - [NoWrapper] - public virtual bool local_command_line ([CCode (array_length = false, array_null_terminated = true)] ref unowned string[] arguments, out int exit_status); - [Version (since = "2.38")] - public void mark_busy (); - [Version (since = "2.32")] - public void quit (); - [NoWrapper] - public virtual void quit_mainloop (); - public bool register (GLib.Cancellable? cancellable = null) throws GLib.Error; - public void release (); - public int run ([CCode (array_length_cname = "argc", array_length_pos = 0.5)] string[]? argv = null); - [NoWrapper] - public virtual void run_mainloop (); - [Version (since = "2.40")] - public void send_notification (string? id, GLib.Notification notification); - [Version (deprecated = true, deprecated_since = "2.32", since = "2.28")] - public void set_action_group (GLib.ActionGroup? action_group); - public void set_application_id (string? application_id); - [Version (since = "2.32")] - public void set_default (); - public void set_flags (GLib.ApplicationFlags flags); - public void set_inactivity_timeout (uint inactivity_timeout); - [Version (since = "2.42")] - public void set_resource_base_path (string? resource_path); - [Version (since = "2.44")] - public void unbind_busy_property (GLib.Object object, string property); - [Version (since = "2.38")] - public void unmark_busy (); - [Version (since = "2.40")] - public void withdraw_notification (string id); - public GLib.ActionGroup action_group { set; } - public string application_id { get; set construct; } - public GLib.ApplicationFlags flags { get; set; } - public uint inactivity_timeout { get; set; } - [Version (since = "2.44")] - public bool is_busy { get; } - public bool is_registered { get; } - public bool is_remote { get; } - public string resource_base_path { get; set; } - [HasEmitter] - public virtual signal void activate (); - public virtual signal int command_line (GLib.ApplicationCommandLine command_line); - [Version (since = "2.40")] - public virtual signal int handle_local_options (GLib.VariantDict options); - [HasEmitter] - public virtual signal void open ([CCode (array_length_cname = "n_files", array_length_pos = 1.5)] GLib.File[] files, string hint); - public virtual signal void shutdown (); - public virtual signal void startup (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_application_command_line_get_type ()")] - public class ApplicationCommandLine : GLib.Object { - [CCode (has_construct_function = false)] - protected ApplicationCommandLine (); - [Version (since = "2.36")] - public GLib.File create_file_for_arg (string arg); - [CCode (array_length_pos = 0.1)] - [Version (since = "2.28")] - public string[] get_arguments (); - [Version (since = "2.28")] - public unowned string get_cwd (); - [CCode (array_length = false, array_null_terminated = true)] - [Version (since = "2.28")] - public unowned string[] get_environ (); - [Version (since = "2.28")] - public int get_exit_status (); - [Version (since = "2.28")] - public bool get_is_remote (); - [Version (since = "2.40")] - public unowned GLib.VariantDict get_options_dict (); - [Version (since = "2.28")] - public GLib.Variant? get_platform_data (); - [Version (since = "2.34")] - public virtual GLib.InputStream get_stdin (); - [Version (since = "2.28")] - public unowned string getenv (string name); - [PrintfFormat] - [Version (since = "2.28")] - public void print (string format, ...); - [NoWrapper] - public virtual void print_literal (string message); - [PrintfFormat] - [Version (since = "2.28")] - public void printerr (string format, ...); - [NoWrapper] - public virtual void printerr_literal (string message); - [Version (since = "2.28")] - public void set_exit_status (int exit_status); - public GLib.Variant arguments { construct; } - public bool is_remote { get; } - public GLib.Variant options { construct; } - public GLib.Variant platform_data { construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_buffered_input_stream_get_type ()")] - public class BufferedInputStream : GLib.FilterInputStream, GLib.Seekable { - [CCode (has_construct_function = false, type = "GInputStream*")] - public BufferedInputStream (GLib.InputStream base_stream); - public virtual ssize_t fill (ssize_t count, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async ssize_t fill_async (ssize_t count, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public size_t get_available (); - public size_t get_buffer_size (); - public size_t peek ([CCode (array_length_cname = "count", array_length_pos = 2.1, array_length_type = "gsize")] uint8[] buffer, size_t offset = 0); - [CCode (array_length_pos = 0.1, array_length_type = "gsize")] - public unowned uint8[] peek_buffer (); - public int read_byte (GLib.Cancellable? cancellable = null) throws GLib.Error; - public void set_buffer_size (size_t size); - [CCode (has_construct_function = false, type = "GInputStream*")] - public BufferedInputStream.sized (GLib.InputStream base_stream, size_t size); - public uint buffer_size { get; set construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_buffered_output_stream_get_type ()")] - public class BufferedOutputStream : GLib.FilterOutputStream, GLib.Seekable { - [CCode (has_construct_function = false, type = "GOutputStream*")] - public BufferedOutputStream (GLib.OutputStream base_stream); - public bool get_auto_grow (); - public size_t get_buffer_size (); - public void set_auto_grow (bool auto_grow); - public void set_buffer_size (size_t size); - [CCode (has_construct_function = false, type = "GOutputStream*")] - public BufferedOutputStream.sized (GLib.OutputStream base_stream, size_t size); - public bool auto_grow { get; set; } - public uint buffer_size { get; set construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_bytes_icon_get_type ()")] - public class BytesIcon : GLib.Object, GLib.Icon, GLib.LoadableIcon { - [CCode (has_construct_function = false, type = "GIcon*")] - [Version (since = "2.38")] - public BytesIcon (GLib.Bytes bytes); - [Version (since = "2.38")] - public unowned GLib.Bytes get_bytes (); - public GLib.Bytes bytes { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_cancellable_get_type ()")] - public class Cancellable : GLib.Object { - [CCode (has_construct_function = false)] - public Cancellable (); - public void cancel (); - [Version (since = "2.22")] - public ulong connect ([CCode (type = "GCallback")] owned GLib.Func callback); - [Version (since = "2.22")] - public void disconnect (ulong handler_id); - public static unowned GLib.Cancellable? get_current (); - public int get_fd (); - public bool is_cancelled (); - [Version (since = "2.22")] - public bool make_pollfd (GLib.PollFD pollfd); - public void pop_current (); - public void push_current (); - [Version (since = "2.22")] - public void release_fd (); - public void reset (); - public bool set_error_if_cancelled () throws GLib.IOError; - [Version (since = "2.28")] - public GLib.CancellableSource source_new (); - public virtual signal void cancelled (); - } - [CCode (cheader_filename = "gio/gio.h", cname = "GSource", ref_function = "g_source_ref", unref_function = "g_source_unref")] - [Compact] - public class CancellableSource : GLib.Source { - [CCode (cname = "g_source_set_callback")] - public void set_callback ([CCode (type = "GSourceFunc")] owned GLib.CancellableSourceFunc func); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_charset_converter_get_type ()")] - public class CharsetConverter : GLib.Object, GLib.Converter, GLib.Initable { - [CCode (has_construct_function = false)] - [Version (since = "2.24")] - public CharsetConverter (string to_charset, string from_charset) throws GLib.Error; - [Version (since = "2.24")] - public uint get_num_fallbacks (); - [Version (since = "2.24")] - public bool get_use_fallback (); - [Version (since = "2.24")] - public void set_use_fallback (bool use_fallback); - [NoAccessorMethod] - public string from_charset { owned get; construct; } - [NoAccessorMethod] - public string to_charset { owned get; construct; } - public bool use_fallback { get; set construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_converter_input_stream_get_type ()")] - public class ConverterInputStream : GLib.FilterInputStream, GLib.PollableInputStream { - [CCode (has_construct_function = false, type = "GInputStream*")] - public ConverterInputStream (GLib.InputStream base_stream, GLib.Converter converter); - [Version (since = "2.24")] - public unowned GLib.Converter get_converter (); - public GLib.Converter converter { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_converter_output_stream_get_type ()")] - public class ConverterOutputStream : GLib.FilterOutputStream, GLib.PollableOutputStream { - [CCode (has_construct_function = false, type = "GOutputStream*")] - public ConverterOutputStream (GLib.OutputStream base_stream, GLib.Converter converter); - [Version (since = "2.24")] - public unowned GLib.Converter get_converter (); - public GLib.Converter converter { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_credentials_get_type ()")] - [Version (since = "2.26")] - public class Credentials : GLib.Object { - [CCode (has_construct_function = false)] - public Credentials (); - public void* get_native (GLib.CredentialsType native_type); - [Version (since = "2.36")] - public int get_unix_pid () throws GLib.Error; - public uint get_unix_user () throws GLib.Error; - public bool is_same_user (GLib.Credentials other_credentials) throws GLib.Error; - public void set_native (GLib.CredentialsType native_type, void* native); - public bool set_unix_user (uint uid) throws GLib.Error; - public string to_string (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_action_group_get_type ()")] - public class DBusActionGroup : GLib.Object, GLib.ActionGroup, GLib.RemoteActionGroup { - [CCode (has_construct_function = false)] - protected DBusActionGroup (); - [Version (since = "2.32")] - public static GLib.DBusActionGroup @get (GLib.DBusConnection connection, string bus_name, string object_path); - } - [CCode (cheader_filename = "gio/gio.h", ref_function = "g_dbus_annotation_info_ref", type_id = "g_dbus_annotation_info_get_type ()", unref_function = "g_dbus_annotation_info_unref")] - [Compact] - [Version (since = "2.26")] - public class DBusAnnotationInfo { - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusAnnotationInfo[] annotations; - public string key; - public int ref_count; - public string value; - public GLib.DBusAnnotationInfo @ref (); - public void unref (); - } - [CCode (cheader_filename = "gio/gio.h", ref_function = "g_dbus_arg_info_ref", type_id = "g_dbus_arg_info_get_type ()", unref_function = "g_dbus_arg_info_unref")] - [Compact] - [Version (since = "2.26")] - public class DBusArgInfo { - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusAnnotationInfo[] annotations; - public string name; - public int ref_count; - public string signature; - public GLib.DBusArgInfo @ref (); - public void unref (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_auth_observer_get_type ()")] - [Version (since = "2.26")] - public class DBusAuthObserver : GLib.Object { - [CCode (has_construct_function = false)] - public DBusAuthObserver (); - [HasEmitter] - [Version (since = "2.34")] - public signal bool allow_mechanism (string mechanism); - public virtual signal bool authorize_authenticated_peer (GLib.IOStream stream, GLib.Credentials? credentials); - } - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public class DBusConnection : GLib.Object, GLib.AsyncInitable, GLib.Initable, GLib.AsyncInitable, GLib.Initable { - [CCode (has_construct_function = false)] - protected DBusConnection (); - public uint add_filter (owned GLib.DBusMessageFilterFunction filter_function); - public async GLib.Variant call (string? bus_name, string object_path, string interface_name, string method_name, GLib.Variant? parameters, GLib.VariantType? reply_type, GLib.DBusCallFlags flags, int timeout_msec, GLib.Cancellable? cancellable = null) throws GLib.Error; - public GLib.Variant call_sync (string? bus_name, string object_path, string interface_name, string method_name, GLib.Variant? parameters, GLib.VariantType? reply_type, GLib.DBusCallFlags flags, int timeout_msec, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.30")] - public async GLib.Variant call_with_unix_fd_list (string? bus_name, string object_path, string interface_name, string method_name, GLib.Variant? parameters, GLib.VariantType? reply_type, GLib.DBusCallFlags flags, int timeout_msec, GLib.UnixFDList? fd_list = null, GLib.Cancellable? cancellable = null, out GLib.UnixFDList? out_fd_list = null) throws GLib.Error; - [Version (since = "2.30")] - public GLib.Variant call_with_unix_fd_list_sync (string? bus_name, string object_path, string interface_name, string method_name, GLib.Variant? parameters, GLib.VariantType? reply_type, GLib.DBusCallFlags flags, int timeout_msec, GLib.UnixFDList? fd_list = null, out GLib.UnixFDList? out_fd_list = null, GLib.Cancellable? cancellable = null) throws GLib.Error; - public async bool close (GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool close_sync (GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool emit_signal (string? destination_bus_name, string object_path, string interface_name, string signal_name, GLib.Variant? parameters) throws GLib.Error; - [Version (since = "2.32")] - public uint export_action_group (string object_path, GLib.ActionGroup action_group) throws GLib.Error; - [Version (since = "2.32")] - public uint export_menu_model (string object_path, GLib.MenuModel menu) throws GLib.Error; - public async bool flush (GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool flush_sync (GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (has_construct_function = false)] - public DBusConnection.for_address_sync (string address, GLib.DBusConnectionFlags flags, GLib.DBusAuthObserver? observer = null, GLib.Cancellable? cancellable = null) throws GLib.Error; - public GLib.DBusCapabilityFlags get_capabilities (); - public bool get_exit_on_close (); - public unowned string get_guid (); - [Version (since = "2.34")] - public uint32 get_last_serial (); - public unowned GLib.Credentials? get_peer_credentials (); - public async T get_proxy (string? name, string object_path, GLib.DBusProxyFlags flags = 0, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public T get_proxy_sync (string? name, string object_path, GLib.DBusProxyFlags flags = 0, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public unowned GLib.IOStream get_stream (); - public unowned string get_unique_name (); - public bool is_closed (); - [CCode (cname = "g_dbus_connection_new", finish_function = "g_dbus_connection_new_finish")] - public static async GLib.DBusConnection @new (GLib.IOStream stream, string guid, GLib.DBusConnectionFlags flags, GLib.DBusAuthObserver? observer = null, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (cname = "g_dbus_connection_new_for_address", finish_function = "g_dbus_connection_new_for_address_finish")] - public static async GLib.DBusConnection new_for_address (string address, GLib.DBusConnectionFlags flags, GLib.DBusAuthObserver? observer = null, GLib.Cancellable? cancellable = null) throws GLib.Error; - public uint register_object (string object_path, T object) throws GLib.IOError; - [Version (since = "2.46")] - public uint register_object_with_closures (string object_path, GLib.DBusInterfaceInfo interface_info, GLib.Closure? method_call_closure, GLib.Closure? get_property_closure, GLib.Closure? set_property_closure) throws GLib.Error; - public uint register_subtree (string object_path, GLib.DBusSubtreeVTable vtable, GLib.DBusSubtreeFlags flags, void* user_data, GLib.DestroyNotify user_data_free_func) throws GLib.Error; - public void remove_filter (uint filter_id); - public bool send_message (GLib.DBusMessage message, GLib.DBusSendMessageFlags flags, out uint32 out_serial) throws GLib.Error; - public async GLib.DBusMessage send_message_with_reply (GLib.DBusMessage message, GLib.DBusSendMessageFlags flags, int timeout_msec, uint32* out_serial = null, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public GLib.DBusMessage send_message_with_reply_sync (GLib.DBusMessage message, GLib.DBusSendMessageFlags flags, int timeout_msec, out uint32 out_serial = null, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public void set_exit_on_close (bool exit_on_close); - public uint signal_subscribe (string? sender, string? interface_name, string? member, string? object_path, string? arg0, GLib.DBusSignalFlags flags, owned GLib.DBusSignalCallback callback); - public void signal_unsubscribe (uint subscription_id); - public void start_message_processing (); - [CCode (has_construct_function = false)] - public DBusConnection.sync (GLib.IOStream stream, string? guid, GLib.DBusConnectionFlags flags, GLib.DBusAuthObserver? observer = null, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.32")] - public void unexport_action_group (uint export_id); - [Version (since = "2.32")] - public void unexport_menu_model (uint export_id); - public bool unregister_object (uint registration_id); - public bool unregister_subtree (uint registration_id); - public string address { construct; } - public GLib.DBusAuthObserver authentication_observer { construct; } - public GLib.DBusCapabilityFlags capabilities { get; } - [NoAccessorMethod] - public bool closed { get; } - public bool exit_on_close { get; set; } - public GLib.DBusConnectionFlags flags { construct; } - public string guid { get; construct; } - public GLib.IOStream stream { get; construct; } - public string unique_name { get; } - } - [CCode (cheader_filename = "gio/gio.h", ref_function = "g_dbus_interface_info_ref", type_id = "g_dbus_interface_info_get_type ()", unref_function = "g_dbus_interface_info_unref")] - [Compact] - [Version (since = "2.26")] - public class DBusInterfaceInfo { - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusAnnotationInfo[] annotations; - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusMethodInfo[] methods; - public string name; - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusPropertyInfo[] properties; - public int ref_count; - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusSignalInfo[] signals; - [Version (since = "2.30")] - public void cache_build (); - [Version (since = "2.30")] - public void cache_release (); - public void generate_xml (uint indent, GLib.StringBuilder string_builder); - public unowned GLib.DBusMethodInfo lookup_method (string name); - public unowned GLib.DBusPropertyInfo lookup_property (string name); - public unowned GLib.DBusSignalInfo lookup_signal (string name); - public GLib.DBusInterfaceInfo @ref (); - public void unref (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_interface_skeleton_get_type ()")] - [Version (since = "2.30")] - public abstract class DBusInterfaceSkeleton : GLib.Object, GLib.DBusInterface { - [CCode (has_construct_function = false)] - protected DBusInterfaceSkeleton (); - public bool export (GLib.DBusConnection connection, string object_path) throws GLib.Error; - public virtual void flush (); - public unowned GLib.DBusConnection get_connection (); - [Version (since = "2.32")] - public GLib.List get_connections (); - public GLib.DBusInterfaceSkeletonFlags get_flags (); - public virtual unowned GLib.DBusInterfaceInfo get_info (); - public unowned string get_object_path (); - public virtual GLib.Variant get_properties (); - public virtual GLib.DBusInterfaceVTable? get_vtable (); - [Version (since = "2.32")] - public bool has_connection (GLib.DBusConnection connection); - public void set_flags (GLib.DBusInterfaceSkeletonFlags flags); - public void unexport (); - [Version (since = "2.32")] - public void unexport_from_connection (GLib.DBusConnection connection); - [NoAccessorMethod] - public GLib.DBusInterfaceSkeletonFlags g_flags { get; set; } - public virtual signal bool g_authorize_method (GLib.DBusMethodInvocation invocation); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_menu_model_get_type ()")] - public class DBusMenuModel : GLib.MenuModel { - [CCode (has_construct_function = false)] - protected DBusMenuModel (); - [Version (since = "2.32")] - public static GLib.DBusMenuModel @get (GLib.DBusConnection connection, string bus_name, string object_path); - } - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public class DBusMessage : GLib.Object { - [CCode (has_construct_function = false)] - public DBusMessage (); - public static ssize_t bytes_needed ([CCode (array_length_cname = "blob_len", array_length_pos = 1.1, array_length_type = "gsize")] uint8[] blob) throws GLib.Error; - public GLib.DBusMessage copy () throws GLib.Error; - [CCode (has_construct_function = false)] - public DBusMessage.from_blob ([CCode (array_length_cname = "blob_len", array_length_pos = 1.5, array_length_type = "gsize")] uint8[] blob, GLib.DBusCapabilityFlags capabilities) throws GLib.Error; - public unowned string get_arg0 (); - public unowned GLib.Variant get_body (); - public GLib.DBusMessageByteOrder get_byte_order (); - public unowned string get_destination (); - public unowned string get_error_name (); - public GLib.DBusMessageFlags get_flags (); - public GLib.Variant get_header (GLib.DBusMessageHeaderField header_field); - [CCode (array_length = false, array_null_terminated = true)] - public uchar[] get_header_fields (); - public unowned string get_interface (); - public bool get_locked (); - public unowned string get_member (); - public GLib.DBusMessageType get_message_type (); - public uint32 get_num_unix_fds (); - public unowned string get_path (); - public uint32 get_reply_serial (); - public unowned string get_sender (); - public uint32 get_serial (); - public unowned string get_signature (); - public unowned GLib.UnixFDList get_unix_fd_list (); - public void @lock (); - [CCode (has_construct_function = false)] - public DBusMessage.method_call (string name, string path, string interface_, string method); - [CCode (has_construct_function = false)] - [PrintfFormat] - public DBusMessage.method_error (GLib.DBusMessage method_call_message, string error_name, string error_message_format, ...); - [CCode (has_construct_function = false)] - public DBusMessage.method_error_literal (GLib.DBusMessage method_call_message, string error_name, string error_message); - [CCode (has_construct_function = false)] - public DBusMessage.method_error_valist (GLib.DBusMessage method_call_message, string error_name, string error_message_format, va_list var_args); - [CCode (has_construct_function = false)] - public DBusMessage.method_reply (GLib.DBusMessage method_call_message); - public string print (uint indent = 0); - public void set_body (GLib.Variant body); - public void set_byte_order (GLib.DBusMessageByteOrder byte_order); - public void set_destination (string value); - public void set_error_name (string value); - public void set_flags (GLib.DBusMessageFlags flags); - public void set_header (GLib.DBusMessageHeaderField header_field, GLib.Variant? value); - public void set_interface (string value); - public void set_member (string value); - public void set_message_type (GLib.DBusMessageType type); - public void set_num_unix_fds (uint32 value); - public void set_path (string value); - public void set_reply_serial (uint32 value); - public void set_sender (string value); - public void set_serial (uint32 serial); - public void set_signature (string value); - public void set_unix_fd_list (GLib.UnixFDList? fd_list); - [CCode (has_construct_function = false)] - public DBusMessage.@signal (string path, string interface_, string @signal); - [CCode (array_length_pos = 0.5, array_length_type = "gsize")] - public uint8[] to_blob (GLib.DBusCapabilityFlags capabilities) throws GLib.Error; - public bool to_gerror () throws GLib.Error; - public bool locked { get; } - } - [CCode (cheader_filename = "gio/gio.h", ref_function = "g_dbus_method_info_ref", type_id = "g_dbus_method_info_get_type ()", unref_function = "g_dbus_method_info_unref")] - [Compact] - [Version (since = "2.26")] - public class DBusMethodInfo { - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusAnnotationInfo[] annotations; - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusArgInfo[] in_args; - public string name; - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusArgInfo[] out_args; - public int ref_count; - public GLib.DBusMethodInfo @ref (); - public void unref (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_method_invocation_get_type ()")] - [Version (since = "2.26")] - public class DBusMethodInvocation : GLib.Object { - [CCode (has_construct_function = false)] - protected DBusMethodInvocation (); - public unowned GLib.DBusConnection get_connection (); - public unowned string get_interface_name (); - public unowned GLib.DBusMessage get_message (); - public unowned GLib.DBusMethodInfo get_method_info (); - public unowned string get_method_name (); - public unowned string get_object_path (); - public unowned GLib.Variant get_parameters (); - [Version (since = "2.38")] - public unowned GLib.DBusPropertyInfo get_property_info (); - public unowned string get_sender (); - public void* get_user_data (); - public void return_dbus_error (string error_name, string error_message); - public void return_error (GLib.Quark domain, int code, string format, ...); - public void return_error_literal (GLib.Quark domain, int code, string message); - public void return_error_valist (GLib.Quark domain, int code, string format, [CCode (type = "va_list")] va_list var_args); - public void return_gerror (GLib.Error error); - public void return_value (GLib.Variant? parameters); - [Version (since = "2.30")] - public void return_value_with_unix_fd_list (GLib.Variant? parameters, GLib.UnixFDList? fd_list); - [Version (since = "2.30")] - public void take_error (owned GLib.Error error); - } - [CCode (cheader_filename = "gio/gio.h", ref_function = "g_dbus_node_info_ref", type_id = "g_dbus_node_info_get_type ()", unref_function = "g_dbus_node_info_unref")] - [Compact] - [Version (since = "2.26")] - public class DBusNodeInfo { - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusAnnotationInfo[] annotations; - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusInterfaceInfo[] interfaces; - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusNodeInfo[] nodes; - public string path; - public int ref_count; - [CCode (has_construct_function = false)] - public DBusNodeInfo.for_xml (string xml_data) throws GLib.Error; - public void generate_xml (uint indent, GLib.StringBuilder string_builder); - public unowned GLib.DBusInterfaceInfo lookup_interface (string name); - public GLib.DBusNodeInfo @ref (); - public void unref (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_object_manager_client_get_type ()")] - [Version (since = "2.30")] - public class DBusObjectManagerClient : GLib.Object, GLib.AsyncInitable, GLib.DBusObjectManager, GLib.Initable, GLib.AsyncInitable, GLib.DBusObjectManager, GLib.Initable { - [CCode (has_construct_function = false)] - protected DBusObjectManagerClient (); - [CCode (has_construct_function = false, type = "GDBusObjectManager*")] - public DBusObjectManagerClient.for_bus_sync (GLib.BusType bus_type, GLib.DBusObjectManagerClientFlags flags, string name, string object_path, [CCode (delegate_target_pos = 5.33333, destroy_notify_pos = 5.66667)] owned GLib.DBusProxyTypeFunc? get_proxy_type_func, GLib.Cancellable? cancellable = null) throws GLib.Error; - public unowned GLib.DBusConnection get_connection (); - public GLib.DBusObjectManagerClientFlags get_flags (); - public unowned string get_name (); - public string? get_name_owner (); - [CCode (cname = "g_dbus_object_manager_client_new", finish_function = "g_dbus_object_manager_client_new_finish")] - public static async GLib.DBusObjectManagerClient @new (GLib.DBusConnection connection, GLib.DBusObjectManagerClientFlags flags, string name, string object_path, [CCode (delegate_target_pos = 5.33333, destroy_notify_pos = 5.66667)] owned GLib.DBusProxyTypeFunc get_proxy_type_func, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (cname = "g_dbus_object_manager_client_new_for_bus", finish_function = "g_dbus_object_manager_client_new_for_bus_finish")] - public static async GLib.DBusObjectManagerClient new_for_bus (GLib.BusType bus_type, GLib.DBusObjectManagerClientFlags flags, string name, string object_path, [CCode (delegate_target_pos = 5.33333, destroy_notify_pos = 5.66667)] owned GLib.DBusProxyTypeFunc get_proxy_type_func, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (has_construct_function = false, type = "GDBusObjectManager*")] - public DBusObjectManagerClient.sync (GLib.DBusConnection connection, GLib.DBusObjectManagerClientFlags flags, string? name, string object_path, [CCode (delegate_target_pos = 5.33333, destroy_notify_pos = 5.66667)] owned GLib.DBusProxyTypeFunc? get_proxy_type_func, GLib.Cancellable? cancellable = null) throws GLib.Error; - public GLib.BusType bus_type { construct; } - public GLib.DBusConnection connection { get; construct; } - public GLib.DBusObjectManagerClientFlags flags { get; construct; } - [NoAccessorMethod] - public void* get_proxy_type_destroy_notify { get; construct; } - [NoAccessorMethod] - public void* get_proxy_type_func { get; construct; } - [NoAccessorMethod] - public void* get_proxy_type_user_data { get; construct; } - public string name { get; construct; } - public string? name_owner { owned get; } - [NoAccessorMethod] - public string object_path { owned get; construct; } - public virtual signal void interface_proxy_properties_changed (GLib.DBusObjectProxy object_proxy, GLib.DBusProxy interface_proxy, GLib.Variant changed_properties, [CCode (array_length = false, array_null_terminated = true)] string[] invalidated_properties); - public virtual signal void interface_proxy_signal (GLib.DBusObjectProxy object_proxy, GLib.DBusProxy interface_proxy, string sender_name, string signal_name, GLib.Variant parameters); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_object_manager_server_get_type ()")] - [Version (since = "2.30")] - public class DBusObjectManagerServer : GLib.Object, GLib.DBusObjectManager { - [CCode (has_construct_function = false)] - public DBusObjectManagerServer (string object_path); - public void export (GLib.DBusObjectSkeleton object); - public void export_uniquely (GLib.DBusObjectSkeleton object); - public GLib.DBusConnection get_connection (); - [Version (since = "2.34")] - public bool is_exported (GLib.DBusObjectSkeleton object); - public void set_connection (GLib.DBusConnection? connection); - public bool unexport (string object_path); - public GLib.DBusConnection connection { owned get; set; } - [NoAccessorMethod] - public string object_path { owned get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_object_proxy_get_type ()")] - [Version (since = "2.30")] - public class DBusObjectProxy : GLib.Object, GLib.DBusObject { - [CCode (has_construct_function = false)] - public DBusObjectProxy (GLib.DBusConnection connection, string object_path); - public unowned GLib.DBusConnection get_connection (); - [NoAccessorMethod] - public GLib.DBusConnection g_connection { owned get; construct; } - [NoAccessorMethod] - public string g_object_path { owned get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_object_skeleton_get_type ()")] - [Version (since = "2.30")] - public class DBusObjectSkeleton : GLib.Object, GLib.DBusObject { - [CCode (has_construct_function = false)] - public DBusObjectSkeleton (string object_path); - public void add_interface (GLib.DBusInterfaceSkeleton interface_); - public void flush (); - public void remove_interface (GLib.DBusInterfaceSkeleton interface_); - public void remove_interface_by_name (string interface_name); - public void set_object_path (string object_path); - [NoAccessorMethod] - public string g_object_path { owned get; set construct; } - public virtual signal bool authorize_method (GLib.DBusInterfaceSkeleton interface_, GLib.DBusMethodInvocation invocation); - } - [CCode (cheader_filename = "gio/gio.h", ref_function = "g_dbus_property_info_ref", type_id = "g_dbus_property_info_get_type ()", unref_function = "g_dbus_property_info_unref")] - [Compact] - [Version (since = "2.26")] - public class DBusPropertyInfo { - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusAnnotationInfo[] annotations; - public GLib.DBusPropertyInfoFlags flags; - public string name; - public int ref_count; - public string signature; - public GLib.DBusPropertyInfo @ref (); - public void unref (); - } - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.26")] - public class DBusProxy : GLib.Object, GLib.AsyncInitable, GLib.DBusInterface, GLib.Initable, GLib.AsyncInitable, GLib.DBusInterface, GLib.Initable { - [CCode (has_construct_function = false)] - protected DBusProxy (); - public async GLib.Variant call (string method_name, GLib.Variant? parameters, GLib.DBusCallFlags flags, int timeout_msec, GLib.Cancellable? cancellable = null) throws GLib.Error; - public GLib.Variant call_sync (string method_name, GLib.Variant? parameters, GLib.DBusCallFlags flags, int timeout_msec, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.30")] - public async GLib.Variant call_with_unix_fd_list (string method_name, GLib.Variant? parameters, GLib.DBusCallFlags flags, int timeout_msec, GLib.UnixFDList? fd_list = null, GLib.Cancellable? cancellable = null, out GLib.UnixFDList? out_fd_list = null) throws GLib.Error; - [Version (since = "2.30")] - public GLib.Variant call_with_unix_fd_list_sync (string method_name, GLib.Variant? parameters, GLib.DBusCallFlags flags, int timeout_msec, GLib.UnixFDList? fd_list = null, out GLib.UnixFDList? out_fd_list = null, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (cname = "g_dbus_proxy_new_for_bus", finish_function = "g_dbus_proxy_new_for_bus_finish")] - public static async GLib.DBusProxy create_for_bus (GLib.BusType bus_type, GLib.DBusProxyFlags flags, GLib.DBusInterfaceInfo? info, string name, string object_path, string interface_name, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [CCode (has_construct_function = false)] - public DBusProxy.for_bus_sync (GLib.BusType bus_type, GLib.DBusProxyFlags flags, GLib.DBusInterfaceInfo? info, string name, string object_path, string interface_name, GLib.Cancellable? cancellable = null) throws GLib.Error; - public GLib.Variant get_cached_property (string property_name); - [CCode (array_length = false, array_null_terminated = true)] - public string[] get_cached_property_names (); - public unowned GLib.DBusConnection get_connection (); - public int get_default_timeout (); - public GLib.DBusProxyFlags get_flags (); - public GLib.DBusInterfaceInfo get_interface_info (); - public unowned string get_interface_name (); - public unowned string get_name (); - public string get_name_owner (); - public unowned string get_object_path (); - [CCode (cname = "g_dbus_proxy_new", finish_function = "g_dbus_proxy_new_finish")] - public static async GLib.DBusProxy @new (GLib.DBusConnection connection, GLib.DBusProxyFlags flags, GLib.DBusInterfaceInfo? info, string? name, string object_path, string interface_name, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public void set_cached_property (string property_name, GLib.Variant? value); - public void set_default_timeout (int timeout_msec); - public void set_interface_info (GLib.DBusInterfaceInfo? info); - [CCode (has_construct_function = false)] - public DBusProxy.sync (GLib.DBusConnection connection, GLib.DBusProxyFlags flags, GLib.DBusInterfaceInfo? info, string? name, string object_path, string interface_name, GLib.Cancellable? cancellable = null) throws GLib.Error; - public GLib.BusType g_bus_type { construct; } - [NoAccessorMethod] - public GLib.DBusConnection g_connection { owned get; construct; } - [NoAccessorMethod] - public int g_default_timeout { get; set construct; } - [NoAccessorMethod] - public GLib.DBusProxyFlags g_flags { get; construct; } - [NoAccessorMethod] - public GLib.DBusInterfaceInfo g_interface_info { owned get; set; } - [NoAccessorMethod] - public string g_interface_name { owned get; construct; } - [NoAccessorMethod] - public string g_name { owned get; construct; } - [NoAccessorMethod] - public string g_name_owner { owned get; } - [NoAccessorMethod] - public string g_object_path { owned get; construct; } - public virtual signal void g_properties_changed (GLib.Variant changed_properties, [CCode (array_length = false, array_null_terminated = true)] string[] invalidated_properties); - public virtual signal void g_signal (string? sender_name, string signal_name, GLib.Variant parameters); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_server_get_type ()")] - [Version (since = "2.26")] - public class DBusServer : GLib.Object, GLib.Initable { - [CCode (has_construct_function = false)] - protected DBusServer (); - public unowned string get_client_address (); - public GLib.DBusServerFlags get_flags (); - public unowned string get_guid (); - public bool is_active (); - public void start (); - public void stop (); - [CCode (has_construct_function = false)] - public DBusServer.sync (string address, GLib.DBusServerFlags flags, string guid, GLib.DBusAuthObserver? observer = null, GLib.Cancellable? cancellable = null) throws GLib.Error; - [NoAccessorMethod] - public bool active { get; } - [NoAccessorMethod] - public string address { owned get; construct; } - [NoAccessorMethod] - public GLib.DBusAuthObserver authentication_observer { owned get; construct; } - public string client_address { get; } - public GLib.DBusServerFlags flags { get; construct; } - public string guid { get; construct; } - public signal bool new_connection (GLib.DBusConnection connection); - } - [CCode (cheader_filename = "gio/gio.h", ref_function = "g_dbus_signal_info_ref", type_id = "g_dbus_signal_info_get_type ()", unref_function = "g_dbus_signal_info_unref")] - [Compact] - [Version (since = "2.26")] - public class DBusSignalInfo { - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusAnnotationInfo[] annotations; - [CCode (array_length = false, array_null_terminated = true)] - public GLib.DBusArgInfo[] args; - public string name; - public int ref_count; - public GLib.DBusSignalInfo @ref (); - public void unref (); - } - [CCode (cheader_filename = "gio/gio.h")] - public class DataInputStream : GLib.BufferedInputStream, GLib.Seekable { - [CCode (has_construct_function = false)] - public DataInputStream (GLib.InputStream base_stream); - public GLib.DataStreamByteOrder get_byte_order (); - public GLib.DataStreamNewlineType get_newline_type (); - public uint8 read_byte (GLib.Cancellable? cancellable = null) throws GLib.IOError; - public int16 read_int16 (GLib.Cancellable? cancellable = null) throws GLib.IOError; - public int32 read_int32 (GLib.Cancellable? cancellable = null) throws GLib.IOError; - public int64 read_int64 (GLib.Cancellable? cancellable = null) throws GLib.IOError; - [CCode (array_length = false, array_null_terminated = true)] - public string? read_line (out size_t length = null, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [CCode (array_length = false, array_null_terminated = true)] - [Version (since = "2.20")] - public async string? read_line_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null, out size_t length = null) throws GLib.IOError, GLib.IOError; - [Version (since = "2.30")] - public string? read_line_utf8 (out size_t length, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [CCode (cname = "g_data_input_stream_read_line_async", finish_function = "g_data_input_stream_read_line_finish_utf8")] - public async string? read_line_utf8_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null, out size_t length) throws GLib.IOError, GLib.IOError; - public uint16 read_uint16 (GLib.Cancellable? cancellable = null) throws GLib.IOError; - public uint32 read_uint32 (GLib.Cancellable? cancellable = null) throws GLib.IOError; - public uint64 read_uint64 (GLib.Cancellable? cancellable = null) throws GLib.IOError; - public string read_until (string stop_chars, out size_t length, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [Version (since = "2.20")] - public async string read_until_async (string stop_chars, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null, out size_t length) throws GLib.IOError, GLib.IOError; - [Version (since = "2.26")] - public string read_upto (string stop_chars, ssize_t stop_chars_len, out size_t length, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [Version (since = "2.26")] - public async string read_upto_async (string stop_chars, ssize_t stop_chars_len, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null, out size_t length) throws GLib.IOError, GLib.IOError; - public void set_byte_order (GLib.DataStreamByteOrder order); - public void set_newline_type (GLib.DataStreamNewlineType type); - public GLib.DataStreamByteOrder byte_order { get; set; } - public GLib.DataStreamNewlineType newline_type { get; set; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_data_output_stream_get_type ()")] - public class DataOutputStream : GLib.FilterOutputStream, GLib.Seekable { - [CCode (has_construct_function = false)] - public DataOutputStream (GLib.OutputStream base_stream); - public GLib.DataStreamByteOrder get_byte_order (); - public bool put_byte (uint8 data, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public bool put_int16 (int16 data, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public bool put_int32 (int32 data, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public bool put_int64 (int64 data, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public bool put_string (string str, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public bool put_uint16 (uint16 data, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public bool put_uint32 (uint32 data, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public bool put_uint64 (uint64 data, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public void set_byte_order (GLib.DataStreamByteOrder order); - public GLib.DataStreamByteOrder byte_order { get; set; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_emblem_get_type ()")] - public class Emblem : GLib.Object, GLib.Icon { - [CCode (has_construct_function = false)] - [Version (since = "2.18")] - public Emblem (GLib.Icon icon); - [Version (since = "2.18")] - public unowned GLib.Icon get_icon (); - [Version (since = "2.18")] - public GLib.EmblemOrigin get_origin (); - [CCode (has_construct_function = false)] - [Version (since = "2.18")] - public Emblem.with_origin (GLib.Icon icon, GLib.EmblemOrigin origin); - public GLib.Object icon { get; construct; } - public GLib.EmblemOrigin origin { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_emblemed_icon_get_type ()")] - public class EmblemedIcon : GLib.Object, GLib.Icon { - [CCode (has_construct_function = false, type = "GIcon*")] - [Version (since = "2.18")] - public EmblemedIcon (GLib.Icon icon, GLib.Emblem? emblem); - [Version (since = "2.18")] - public void add_emblem (GLib.Emblem emblem); - [Version (since = "2.28")] - public void clear_emblems (); - [Version (since = "2.18")] - public unowned GLib.List get_emblems (); - [Version (since = "2.18")] - public unowned GLib.Icon get_icon (); - [NoAccessorMethod] - public GLib.Icon gicon { owned get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", ref_function = "g_file_attribute_info_list_ref", type_id = "g_file_attribute_info_list_get_type ()", unref_function = "g_file_attribute_info_list_unref")] - [Compact] - public class FileAttributeInfoList { - [CCode (array_length_cname = "n_infos")] - public GLib.FileAttributeInfo[] infos; - public int n_infos; - [CCode (has_construct_function = false)] - public FileAttributeInfoList (); - public void add (string name, GLib.FileAttributeType type, GLib.FileAttributeInfoFlags flags); - public GLib.FileAttributeInfoList dup (); - public unowned GLib.FileAttributeInfo? lookup (string name); - public GLib.FileAttributeInfoList @ref (); - public void unref (); - } - [CCode (cheader_filename = "gio/gio.h", ref_function = "g_file_attribute_matcher_ref", type_id = "g_file_attribute_matcher_get_type ()", unref_function = "g_file_attribute_matcher_unref")] - [Compact] - public class FileAttributeMatcher { - [CCode (has_construct_function = false)] - public FileAttributeMatcher (string attributes); - public bool enumerate_namespace (string ns); - public unowned string enumerate_next (); - public bool matches (string attribute); - public bool matches_only (string attribute); - public GLib.FileAttributeMatcher @ref (); - public GLib.FileAttributeMatcher subtract (GLib.FileAttributeMatcher subtract); - [Version (since = "2.32")] - public string to_string (); - public void unref (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_file_enumerator_get_type ()")] - public class FileEnumerator : GLib.Object { - [CCode (has_construct_function = false)] - protected FileEnumerator (); - public bool close (GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async bool close_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - [NoWrapper] - public virtual bool close_fn (GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.36")] - public GLib.File get_child (GLib.FileInfo info); - [Version (since = "2.18")] - public unowned GLib.File get_container (); - public bool has_pending (); - public bool is_closed (); - [Version (since = "2.44")] - public bool iterate (out unowned GLib.FileInfo out_info, out unowned GLib.File out_child, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual GLib.FileInfo? next_file (GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.List next_files_async (int num_files, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public void set_pending (bool pending); - public GLib.File container { construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_file_io_stream_get_type ()")] - public class FileIOStream : GLib.IOStream, GLib.Seekable { - [CCode (has_construct_function = false)] - protected FileIOStream (); - [NoWrapper] - public virtual bool can_seek (); - [NoWrapper] - public virtual bool can_truncate (); - [Version (since = "2.22")] - public virtual string get_etag (); - [Version (since = "2.22")] - public virtual GLib.FileInfo query_info (string attributes, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public virtual async GLib.FileInfo query_info_async (string attributes, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - [NoWrapper] - public virtual bool seek (int64 offset, GLib.SeekType type, GLib.Cancellable? cancellable = null) throws GLib.Error; - [NoWrapper] - public virtual int64 tell (); - [NoWrapper] - public virtual bool truncate_fn (int64 size, GLib.Cancellable? cancellable = null) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_file_icon_get_type ()")] - public class FileIcon : GLib.Object, GLib.Icon, GLib.LoadableIcon { - [CCode (has_construct_function = false, type = "GIcon*")] - public FileIcon (GLib.File file); - public unowned GLib.File get_file (); - public GLib.File file { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_file_info_get_type ()")] - public class FileInfo : GLib.Object { - [CCode (has_construct_function = false)] - public FileInfo (); - public void clear_status (); - public void copy_into (GLib.FileInfo dest_info); - public GLib.FileInfo dup (); - public string get_attribute_as_string (string attribute); - public bool get_attribute_boolean (string attribute); - public unowned string get_attribute_byte_string (string attribute); - public bool get_attribute_data (string attribute, out GLib.FileAttributeType type, out void* value_pp, out GLib.FileAttributeStatus status); - public int32 get_attribute_int32 (string attribute); - public int64 get_attribute_int64 (string attribute); - public unowned GLib.Object get_attribute_object (string attribute); - public GLib.FileAttributeStatus get_attribute_status (string attribute); - public unowned string get_attribute_string (string attribute); - [CCode (array_length = false, array_null_terminated = true)] - [Version (since = "2.22")] - public unowned string[] get_attribute_stringv (string attribute); - public GLib.FileAttributeType get_attribute_type (string attribute); - public uint32 get_attribute_uint32 (string attribute); - public uint64 get_attribute_uint64 (string attribute); - public unowned string get_content_type (); - [Version (since = "2.36")] - public GLib.DateTime get_deletion_date (); - public unowned string get_display_name (); - public unowned string get_edit_name (); - public unowned string get_etag (); - public GLib.FileType get_file_type (); - public unowned GLib.Icon get_icon (); - public bool get_is_backup (); - public bool get_is_hidden (); - public bool get_is_symlink (); - public GLib.TimeVal get_modification_time (); - public unowned string get_name (); - public int64 get_size (); - public int32 get_sort_order (); - [Version (since = "2.34")] - public unowned GLib.Icon get_symbolic_icon (); - public unowned string get_symlink_target (); - public bool has_attribute (string attribute); - [Version (since = "2.22")] - public bool has_namespace (string name_space); - [CCode (array_length = false, array_null_terminated = true)] - public string[]? list_attributes (string? name_space); - public void remove_attribute (string attribute); - public void set_attribute (string attribute, GLib.FileAttributeType type, void* value_p); - public void set_attribute_boolean (string attribute, bool attr_value); - public void set_attribute_byte_string (string attribute, string attr_value); - public void set_attribute_int32 (string attribute, int32 attr_value); - public void set_attribute_int64 (string attribute, int64 attr_value); - public void set_attribute_mask (GLib.FileAttributeMatcher mask); - public void set_attribute_object (string attribute, GLib.Object attr_value); - [Version (since = "2.22")] - public bool set_attribute_status (string attribute, GLib.FileAttributeStatus status); - public void set_attribute_string (string attribute, string attr_value); - public void set_attribute_stringv (string attribute, [CCode (array_length = false)] string[] attr_value); - public void set_attribute_uint32 (string attribute, uint32 attr_value); - public void set_attribute_uint64 (string attribute, uint64 attr_value); - public void set_content_type (string content_type); - public void set_display_name (string display_name); - public void set_edit_name (string edit_name); - public void set_file_type (GLib.FileType type); - public void set_icon (GLib.Icon icon); - public void set_is_hidden (bool is_hidden); - public void set_is_symlink (bool is_symlink); - public void set_modification_time (GLib.TimeVal mtime); - public void set_name (string name); - public void set_size (int64 size); - public void set_sort_order (int32 sort_order); - [Version (since = "2.34")] - public void set_symbolic_icon (GLib.Icon icon); - public void set_symlink_target (string symlink_target); - public void unset_attribute_mask (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_file_input_stream_get_type ()")] - public class FileInputStream : GLib.InputStream, GLib.Seekable { - [CCode (has_construct_function = false)] - protected FileInputStream (); - [NoWrapper] - public virtual bool can_seek (); - public virtual GLib.FileInfo query_info (string attributes, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.FileInfo query_info_async (string attributes, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - [NoWrapper] - public virtual bool seek (int64 offset, GLib.SeekType type, GLib.Cancellable? cancellable = null) throws GLib.Error; - [NoWrapper] - public virtual int64 tell (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_file_monitor_get_type ()")] - public abstract class FileMonitor : GLib.Object { - [CCode (has_construct_function = false)] - protected FileMonitor (); - public virtual bool cancel (); - public void emit_event (GLib.File child, GLib.File other_file, GLib.FileMonitorEvent event_type); - public bool is_cancelled (); - public void set_rate_limit (int limit_msecs); - [NoAccessorMethod] - public bool cancelled { get; } - [Version (deprecated_since = "2.46")] - public GLib.MainContext context { construct; } - [NoAccessorMethod] - public int rate_limit { get; set; } - public virtual signal void changed (GLib.File file, GLib.File? other_file, GLib.FileMonitorEvent event_type); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_file_output_stream_get_type ()")] - public class FileOutputStream : GLib.OutputStream, GLib.Seekable { - [CCode (has_construct_function = false)] - protected FileOutputStream (); - [NoWrapper] - public virtual bool can_seek (); - [NoWrapper] - public virtual bool can_truncate (); - public virtual string get_etag (); - public virtual GLib.FileInfo query_info (string attributes, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.FileInfo query_info_async (string attributes, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - [NoWrapper] - public virtual bool seek (int64 offset, GLib.SeekType type, GLib.Cancellable? cancellable = null) throws GLib.Error; - [NoWrapper] - public virtual int64 tell (); - [NoWrapper] - public virtual bool truncate_fn (int64 size, GLib.Cancellable? cancellable = null) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_filename_completer_get_type ()")] - public class FilenameCompleter : GLib.Object { - [CCode (has_construct_function = false)] - public FilenameCompleter (); - public string get_completion_suffix (string initial_text); - [CCode (array_length = false, array_null_terminated = true)] - public string[] get_completions (string initial_text); - public void set_dirs_only (bool dirs_only); - public virtual signal void got_completion_data (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_filter_input_stream_get_type ()")] - public abstract class FilterInputStream : GLib.InputStream { - [CCode (has_construct_function = false)] - protected FilterInputStream (); - public unowned GLib.InputStream get_base_stream (); - public bool get_close_base_stream (); - public void set_close_base_stream (bool close_base); - public GLib.InputStream base_stream { get; construct; } - public bool close_base_stream { get; set construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_filter_output_stream_get_type ()")] - public abstract class FilterOutputStream : GLib.OutputStream { - [CCode (has_construct_function = false)] - protected FilterOutputStream (); - public unowned GLib.OutputStream get_base_stream (); - public bool get_close_base_stream (); - public void set_close_base_stream (bool close_base); - public GLib.OutputStream base_stream { get; construct; } - public bool close_base_stream { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h")] - [Compact] - public class IOExtension { - public unowned string get_name (); - public int get_priority (); - public GLib.Type get_type (); - } - [CCode (cheader_filename = "gio/gio.h")] - [Compact] - public class IOExtensionPoint { - [CCode (cheader_filename = "gio/gio.h", cname = "G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME")] - public const string DESKTOP_APP_INFO_LOOKUP; - [CCode (cheader_filename = "gio/gio.h", cname = "G_NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME")] - public const string NATIVE_VOLUME_MONITOR; - [CCode (cheader_filename = "gio/gio.h", cname = "G_NETWORK_MONITOR_EXTENSION_POINT_NAME")] - [Version (since = "2.30")] - public const string NETWORK_MONITOR; - [CCode (cheader_filename = "gio/gio.h", cname = "G_PROXY_EXTENSION_POINT_NAME")] - [Version (since = "2.26")] - public const string PROXY; - [CCode (cheader_filename = "gio/gio.h", cname = "G_PROXY_RESOLVER_EXTENSION_POINT_NAME")] - public const string PROXY_RESOLVER; - [CCode (cheader_filename = "gio/gio.h", cname = "G_TLS_BACKEND_EXTENSION_POINT_NAME")] - public const string TLS_BACKEND; - [CCode (cheader_filename = "gio/gio.h", cname = "G_VFS_EXTENSION_POINT_NAME")] - public const string VFS; - [CCode (cheader_filename = "gio/gio.h", cname = "G_VOLUME_MONITOR_EXTENSION_POINT_NAME")] - public const string VOLUME_MONITOR; - public unowned GLib.IOExtension get_extension_by_name (string name); - public unowned GLib.List get_extensions (); - public GLib.Type get_required_type (); - [CCode (cheader_filename = "gio/gio.h")] - public static unowned GLib.IOExtension implement (string extension_point_name, GLib.Type type, string extension_name, int priority); - [CCode (cheader_filename = "gio/gio.h")] - public static unowned GLib.IOExtensionPoint lookup (string name); - [CCode (cheader_filename = "gio/gio.h")] - public static unowned GLib.IOExtensionPoint register (string name); - public void set_required_type (GLib.Type type); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_io_module_get_type ()")] - public class IOModule : GLib.TypeModule, GLib.TypePlugin { - [CCode (has_construct_function = false)] - public IOModule (string filename); - public void load (); - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_modules_load_all_in_directory")] - public static GLib.List load_all_in_directory (string dirname); - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_modules_load_all_in_directory_with_scope")] - [Version (since = "2.30")] - public static GLib.List load_all_in_directory_with_scope (string dirname, GLib.IOModuleScope scope); - [CCode (array_length = false, array_null_terminated = true)] - [Version (since = "2.24")] - public static string[] query (); - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_modules_scan_all_in_directory")] - [Version (since = "2.24")] - public static void scan_all_in_directory (string dirname); - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_modules_scan_all_in_directory_with_scope")] - [Version (since = "2.30")] - public static void scan_all_in_directory_with_scope (string dirname, GLib.IOModuleScope scope); - public void unload (); - } - [CCode (cheader_filename = "gio/gio.h")] - [Compact] - [Version (since = "2.30")] - public class IOModuleScope { - [CCode (has_construct_function = false)] - public IOModuleScope (GLib.IOModuleScopeFlags flags); - public void block (string basename); - public void free (); - } - [CCode (cheader_filename = "gio/gio.h")] - [Compact] - public class IOSchedulerJob { - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_scheduler_cancel_all_jobs")] - [Version (deprecated = true)] - public static void cancel_all (); - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_scheduler_push_job")] - [Version (deprecated = true)] - public static void push ([CCode (delegate_target_pos = 1.33333, destroy_notify_pos = 1.66667)] owned GLib.IOSchedulerJobFunc job_func, int io_priority, GLib.Cancellable? cancellable = null); - [Version (deprecated = true)] - public bool send_to_mainloop (owned GLib.SourceFunc func); - [Version (deprecated = true)] - public void send_to_mainloop_async (owned GLib.SourceFunc func); - } - [CCode (cheader_filename = "gio/gio.h")] - public abstract class IOStream : GLib.Object { - [CCode (has_construct_function = false)] - protected IOStream (); - [Version (since = "2.22")] - public void clear_pending (); - [CCode (vfunc_name = "close_fn")] - public virtual bool close (GLib.Cancellable? cancellable = null) throws GLib.IOError; - public virtual async bool close_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [Version (since = "2.22")] - public virtual unowned GLib.InputStream get_input_stream (); - [Version (since = "2.22")] - public virtual unowned GLib.OutputStream get_output_stream (); - [Version (since = "2.22")] - public bool has_pending (); - [Version (since = "2.22")] - public bool is_closed (); - [Version (since = "2.22")] - public bool set_pending () throws GLib.Error; - [Version (since = "2.28")] - public async bool splice_async (GLib.IOStream stream2, GLib.IOStreamSpliceFlags flags, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - [NoAccessorMethod] - public bool closed { get; } - public abstract GLib.InputStream input_stream { get; } - public abstract GLib.OutputStream output_stream { get; } - } - [CCode (cheader_filename = "gio/gio.h")] - [Compact] - public class IOStreamAdapter { - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_inet_address_get_type ()")] - public class InetAddress : GLib.Object { - [CCode (has_construct_function = false)] - protected InetAddress (); - [CCode (has_construct_function = false)] - [Version (since = "2.22")] - public InetAddress.any (GLib.SocketFamily family); - [Version (since = "2.30")] - public bool equal (GLib.InetAddress other_address); - [CCode (has_construct_function = false)] - [Version (since = "2.22")] - public InetAddress.from_bytes ([CCode (array_length = false)] uint8[] bytes, GLib.SocketFamily family); - [CCode (has_construct_function = false)] - [Version (since = "2.22")] - public InetAddress.from_string (string string); - [Version (since = "2.22")] - public GLib.SocketFamily get_family (); - [Version (since = "2.22")] - public bool get_is_any (); - [Version (since = "2.22")] - public bool get_is_link_local (); - [Version (since = "2.22")] - public bool get_is_loopback (); - [Version (since = "2.22")] - public bool get_is_mc_global (); - [Version (since = "2.22")] - public bool get_is_mc_link_local (); - [Version (since = "2.22")] - public bool get_is_mc_node_local (); - [Version (since = "2.22")] - public bool get_is_mc_org_local (); - [Version (since = "2.22")] - public bool get_is_mc_site_local (); - [Version (since = "2.22")] - public bool get_is_multicast (); - [Version (since = "2.22")] - public bool get_is_site_local (); - [Version (since = "2.22")] - public size_t get_native_size (); - [CCode (has_construct_function = false)] - [Version (since = "2.22")] - public InetAddress.loopback (GLib.SocketFamily family); - [CCode (array_length = false)] - [Version (since = "2.22")] - public virtual unowned uint8[] to_bytes (); - [Version (since = "2.22")] - public virtual string to_string (); - [NoAccessorMethod] - public void* bytes { get; construct; } - public GLib.SocketFamily family { get; construct; } - [Version (since = "2.22")] - public bool is_any { get; } - [Version (since = "2.22")] - public bool is_link_local { get; } - [Version (since = "2.22")] - public bool is_loopback { get; } - [Version (since = "2.22")] - public bool is_mc_global { get; } - [Version (since = "2.22")] - public bool is_mc_link_local { get; } - [Version (since = "2.22")] - public bool is_mc_node_local { get; } - [Version (since = "2.22")] - public bool is_mc_org_local { get; } - [Version (since = "2.22")] - public bool is_mc_site_local { get; } - [Version (since = "2.22")] - public bool is_multicast { get; } - [Version (since = "2.22")] - public bool is_site_local { get; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_inet_address_mask_get_type ()")] - [Version (since = "2.32")] - public class InetAddressMask : GLib.Object, GLib.Initable { - [CCode (has_construct_function = false)] - public InetAddressMask (GLib.InetAddress addr, uint length) throws GLib.Error; - public bool equal (GLib.InetAddressMask mask2); - [CCode (has_construct_function = false)] - public InetAddressMask.from_string (string mask_string) throws GLib.Error; - public unowned GLib.InetAddress get_address (); - public GLib.SocketFamily get_family (); - public uint get_length (); - public bool matches (GLib.InetAddress address); - public string to_string (); - [NoAccessorMethod] - public GLib.InetAddress address { owned get; set; } - public GLib.SocketFamily family { get; } - [NoAccessorMethod] - public uint length { get; set; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_inet_socket_address_get_type ()")] - public class InetSocketAddress : GLib.SocketAddress, GLib.SocketConnectable { - [CCode (has_construct_function = false, type = "GSocketAddress*")] - [Version (since = "2.22")] - public InetSocketAddress (GLib.InetAddress address, uint16 port); - [CCode (has_construct_function = false, type = "GSocketAddress*")] - [Version (since = "2.40")] - public InetSocketAddress.from_string (string address, uint port); - [Version (since = "2.22")] - public unowned GLib.InetAddress get_address (); - [Version (since = "2.32")] - public uint32 get_flowinfo (); - [Version (since = "2.22")] - public uint16 get_port (); - [Version (since = "2.32")] - public uint32 get_scope_id (); - public GLib.InetAddress address { get; construct; } - [Version (since = "2.32")] - public uint flowinfo { get; construct; } - public uint port { get; construct; } - public uint scope_id { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h")] - public abstract class InputStream : GLib.Object { - [CCode (has_construct_function = false)] - protected InputStream (); - public void clear_pending (); - [CCode (vfunc_name = "close_fn")] - public abstract bool close (GLib.Cancellable? cancellable = null) throws GLib.IOError; - public virtual async bool close_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public bool has_pending (); - public bool is_closed (); - [CCode (vfunc_name = "read_fn")] - public abstract ssize_t read ([CCode (array_length_type = "gsize")] uint8[] buffer, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public bool read_all ([CCode (array_length_cname = "count", array_length_pos = 1.5, array_length_type = "gsize")] uint8[] buffer, out size_t bytes_read, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [Version (since = "2.44")] - public async bool read_all_async ([CCode (array_length_cname = "count", array_length_pos = 1.5, array_length_type = "gsize")] uint8[] buffer, int io_priority, GLib.Cancellable? cancellable, out size_t bytes_read) throws GLib.Error; - public virtual async ssize_t read_async ([CCode (array_length_cname = "count", array_length_pos = 1.5, array_length_type = "gsize")] uint8[]? buffer, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [Version (since = "2.34")] - public GLib.Bytes read_bytes (size_t count, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.34")] - public async GLib.Bytes read_bytes_async (size_t count, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool set_pending () throws GLib.Error; - public virtual ssize_t skip (size_t count, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public virtual async ssize_t skip_async (size_t count, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.IOError; - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_list_store_get_type ()")] - public class ListStore : GLib.Object, GLib.ListModel { - [CCode (has_construct_function = false)] - [Version (since = "2.44")] - public ListStore (GLib.Type item_type); - [Version (since = "2.44")] - public void append (GLib.Object item); - [Version (since = "2.44")] - public void insert (uint position, GLib.Object item); - [Version (since = "2.44")] - public uint insert_sorted (GLib.Object item, GLib.CompareDataFunc compare_func); - [Version (since = "2.44")] - public void remove (uint position); - [Version (since = "2.44")] - public void remove_all (); - [Version (since = "2.46")] - public void sort (GLib.CompareDataFunc compare_func); - [Version (since = "2.44")] - public void splice (uint position, uint n_removals, [CCode (array_length_cname = "n_additions", array_length_pos = 3.1, array_length_type = "guint")] GLib.Object[] additions); - [NoAccessorMethod] - [Version (since = "2.44")] - public GLib.Type item_type { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_memory_input_stream_get_type ()")] - public class MemoryInputStream : GLib.InputStream, GLib.PollableInputStream, GLib.Seekable { - [CCode (has_construct_function = false, type = "GInputStream*")] - public MemoryInputStream (); - [Version (since = "2.34")] - public void add_bytes (GLib.Bytes bytes); - public void add_data ([CCode (array_length_cname = "len", array_length_pos = 1.5, array_length_type = "gssize")] owned uint8[] data, GLib.DestroyNotify? destroy = GLib.g_free); - [CCode (has_construct_function = false, type = "GInputStream*")] - [Version (since = "2.34")] - public MemoryInputStream.from_bytes (GLib.Bytes bytes); - [CCode (has_construct_function = false, type = "GInputStream*")] - public MemoryInputStream.from_data ([CCode (array_length_cname = "len", array_length_pos = 1.5, array_length_type = "gssize")] owned uint8[] data, GLib.DestroyNotify? destroy = GLib.g_free); - } - [CCode (cheader_filename = "gio/gio.h")] - public class MemoryOutputStream : GLib.OutputStream, GLib.PollableOutputStream, GLib.Seekable { - [CCode (has_construct_function = false, type = "GOutputStream*")] - public MemoryOutputStream ([CCode (array_length_type = "gsize")] owned uint8[]? data, GLib.ReallocFunc? realloc_function = GLib.g_realloc, GLib.DestroyNotify? destroy_function = GLib.g_free); - [CCode (array_length = false)] - public unowned uint8[] get_data (); - [Version (since = "2.18")] - public size_t get_data_size (); - public size_t get_size (); - [CCode (has_construct_function = false, type = "GOutputStream*")] - [Version (since = "2.36")] - public MemoryOutputStream.resizable (); - [Version (since = "2.34")] - public GLib.Bytes steal_as_bytes (); - [CCode (array_length = false)] - [Version (since = "2.26")] - public uint8[] steal_data (); - [Version (since = "2.24")] - public void* data { get; construct; } - [Version (since = "2.24")] - public ulong data_size { get; } - [NoAccessorMethod] - [Version (since = "2.24")] - public GLib.DestroyNotify? destroy_function { get; construct; } - [NoAccessorMethod] - [Version (since = "2.24")] - public GLib.ReallocFunc? realloc_function { get; construct; } - [Version (since = "2.24")] - public ulong size { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_menu_get_type ()")] - [Version (since = "2.32")] - public class Menu : GLib.MenuModel { - [CCode (cheader_filename = "gio/gio.h", cname = "G_MENU_ATTRIBUTE_ACTION")] - public const string ATTRIBUTE_ACTION; - [CCode (cheader_filename = "gio/gio.h", cname = "G_MENU_ATTRIBUTE_ACTION_NAMESPACE")] - [Version (since = "2.36")] - public const string ATTRIBUTE_ACTION_NAMESPACE; - [CCode (cheader_filename = "gio/gio.h", cname = "G_MENU_ATTRIBUTE_ICON")] - [Version (since = "2.38")] - public const string ATTRIBUTE_ICON; - [CCode (cheader_filename = "gio/gio.h", cname = "G_MENU_ATTRIBUTE_LABEL")] - public const string ATTRIBUTE_LABEL; - [CCode (cheader_filename = "gio/gio.h", cname = "G_MENU_ATTRIBUTE_TARGET")] - public const string ATTRIBUTE_TARGET; - [CCode (cheader_filename = "gio/gio.h", cname = "G_MENU_LINK_SECTION")] - public const string LINK_SECTION; - [CCode (cheader_filename = "gio/gio.h", cname = "G_MENU_LINK_SUBMENU")] - public const string LINK_SUBMENU; - [CCode (has_construct_function = false)] - public Menu (); - public void append (string? label, string? detailed_action); - public void append_item (GLib.MenuItem item); - public void append_section (string? label, GLib.MenuModel section); - public void append_submenu (string? label, GLib.MenuModel submenu); - public void freeze (); - public void insert (int position, string? label, string? detailed_action); - public void insert_item (int position, GLib.MenuItem item); - public void insert_section (int position, string? label, GLib.MenuModel section); - public void insert_submenu (int position, string? label, GLib.MenuModel submenu); - public void prepend (string? label, string? detailed_action); - public void prepend_item (GLib.MenuItem item); - public void prepend_section (string? label, GLib.MenuModel section); - public void prepend_submenu (string? label, GLib.MenuModel submenu); - public void remove (int position); - [Version (since = "2.38")] - public void remove_all (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_menu_attribute_iter_get_type ()")] - [Version (since = "2.32")] - public abstract class MenuAttributeIter : GLib.Object { - [CCode (has_construct_function = false)] - protected MenuAttributeIter (); - public unowned string get_name (); - public virtual bool get_next (out unowned string out_name, out GLib.Variant value); - public GLib.Variant get_value (); - public bool next (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_menu_item_get_type ()")] - [Version (since = "2.32")] - public class MenuItem : GLib.Object { - [CCode (has_construct_function = false)] - public MenuItem (string? label, string? detailed_action); - [CCode (has_construct_function = false)] - [Version (since = "2.34")] - public MenuItem.from_model (GLib.MenuModel model, int item_index); - [Version (since = "2.34")] - public GLib.Variant get_attribute_value (string attribute, GLib.VariantType? expected_type); - [Version (since = "2.34")] - public GLib.MenuModel get_link (string link); - [CCode (has_construct_function = false)] - public MenuItem.section (string? label, GLib.MenuModel section); - public void set_action_and_target (string? action, string? format_string, ...); - public void set_action_and_target_value (string? action, GLib.Variant? target_value); - public void set_attribute (string attribute, string? format_string, ...); - public void set_attribute_value (string attribute, GLib.Variant? value); - public void set_detailed_action (string detailed_action); - [Version (since = "2.38")] - public void set_icon (GLib.Icon icon); - public void set_label (string? label); - public void set_link (string link, GLib.MenuModel? model); - public void set_section (GLib.MenuModel? section); - public void set_submenu (GLib.MenuModel? submenu); - [CCode (has_construct_function = false)] - public MenuItem.submenu (string? label, GLib.MenuModel submenu); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_menu_link_iter_get_type ()")] - [Version (since = "2.32")] - public abstract class MenuLinkIter : GLib.Object { - [CCode (has_construct_function = false)] - protected MenuLinkIter (); - public unowned string get_name (); - public virtual bool get_next (out unowned string out_link, out GLib.MenuModel value); - public GLib.MenuModel get_value (); - public bool next (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_menu_model_get_type ()")] - [Version (since = "2.32")] - public abstract class MenuModel : GLib.Object { - [CCode (has_construct_function = false)] - protected MenuModel (); - public bool get_item_attribute (int item_index, string attribute, string format_string, ...); - public virtual GLib.Variant get_item_attribute_value (int item_index, string attribute, GLib.VariantType? expected_type); - [NoWrapper] - public virtual void get_item_attributes (int item_index, [CCode (type = "GHashTable**")] out GLib.HashTable? attributes); - public virtual GLib.MenuModel get_item_link (int item_index, string link); - [NoWrapper] - public virtual void get_item_links (int item_index, out GLib.HashTable links); - public virtual int get_n_items (); - public virtual bool is_mutable (); - public virtual GLib.MenuAttributeIter iterate_item_attributes (int item_index); - public virtual GLib.MenuLinkIter iterate_item_links (int item_index); - [HasEmitter] - public signal void items_changed (int position, int removed, int added); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_mount_operation_get_type ()")] - public class MountOperation : GLib.Object { - [CCode (has_construct_function = false)] - public MountOperation (); - public bool get_anonymous (); - public int get_choice (); - public unowned string get_domain (); - public unowned string get_password (); - public GLib.PasswordSave get_password_save (); - public unowned string get_username (); - public void set_anonymous (bool anonymous); - public void set_choice (int choice); - public void set_domain (string domain); - public void set_password (string password); - public void set_password_save (GLib.PasswordSave save); - public void set_username (string username); - public bool anonymous { get; set; } - public int choice { get; set; } - public string domain { get; set; } - public string password { get; set; } - public GLib.PasswordSave password_save { get; set; } - public string username { get; set; } - [Version (since = "2.20")] - public virtual signal void aborted (); - public virtual signal void ask_password (string message, string default_user, string default_domain, GLib.AskPasswordFlags flags); - public virtual signal void ask_question (string message, [CCode (array_length = false, array_null_terminated = true)] string[] choices); - [HasEmitter] - public virtual signal void reply (GLib.MountOperationResult result); - [Version (since = "2.22")] - public signal void show_processes (string message, GLib.Array processes, [CCode (array_length = false, array_null_terminated = true)] string[] choices); - [Version (since = "2.34")] - public virtual signal void show_unmount_progress (string message, int64 time_left, int64 bytes_left); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_native_socket_address_get_type ()")] - public class NativeSocketAddress : GLib.SocketAddress { - public NativeSocketAddress (void* native, size_t len); - } - [CCode (cheader_filename = "gio/gio.h")] - public abstract class NativeVolumeMonitor : GLib.VolumeMonitor { - [CCode (has_construct_function = false)] - protected NativeVolumeMonitor (); - [NoWrapper] - public abstract GLib.Mount get_mount_for_mount_path (string mount_path, GLib.Cancellable? cancellable = null); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_network_address_get_type ()")] - public class NetworkAddress : GLib.Object, GLib.SocketConnectable { - [CCode (has_construct_function = false, type = "GSocketConnectable*")] - [Version (since = "2.22")] - public NetworkAddress (string hostname, uint16 port); - [Version (since = "2.22")] - public unowned string get_hostname (); - [Version (since = "2.22")] - public uint16 get_port (); - [Version (since = "2.26")] - public unowned string get_scheme (); - [CCode (has_construct_function = false, type = "GSocketConnectable*")] - [Version (since = "2.44")] - public NetworkAddress.loopback (uint16 port); - [Version (since = "2.22")] - public static GLib.NetworkAddress parse (string host_and_port, uint16 default_port) throws GLib.Error; - [Version (since = "2.26")] - public static GLib.NetworkAddress parse_uri (string uri, uint16 default_port) throws GLib.Error; - public string hostname { get; construct; } - public uint port { get; construct; } - public string scheme { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_network_service_get_type ()")] - public class NetworkService : GLib.Object, GLib.SocketConnectable { - [CCode (has_construct_function = false, type = "GSocketConnectable*")] - [Version (since = "2.22")] - public NetworkService (string service, string protocol, string domain); - [Version (since = "2.22")] - public unowned string get_domain (); - [Version (since = "2.22")] - public unowned string get_protocol (); - [Version (since = "2.26")] - public unowned string get_scheme (); - [Version (since = "2.22")] - public unowned string get_service (); - [Version (since = "2.26")] - public void set_scheme (string scheme); - public string domain { get; construct; } - public string protocol { get; construct; } - public string scheme { get; set; } - public string service { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_notification_get_type ()")] - [Version (since = "2.40")] - public class Notification : GLib.Object { - [CCode (has_construct_function = false)] - public Notification (string title); - public void add_button (string label, string detailed_action); - public void add_button_with_target_value (string label, string action, GLib.Variant? target); - public void set_body (string? body); - public void set_default_action (string detailed_action); - public void set_default_action_and_target_value (string action, GLib.Variant? target); - public void set_icon (GLib.Icon icon); - public void set_priority (GLib.NotificationPriority priority); - public void set_title (string title); - public void set_urgent (bool urgent); - } - [CCode (cheader_filename = "gio/gio.h")] - public abstract class OutputStream : GLib.Object { - [CCode (has_construct_function = false)] - protected OutputStream (); - public void clear_pending (); - [CCode (vfunc_name = "close_fn")] - public abstract bool close (GLib.Cancellable? cancellable = null) throws GLib.IOError; - public virtual async bool close_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public virtual bool flush (GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async bool flush_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool has_pending (); - public bool is_closed (); - [Version (since = "2.24")] - public bool is_closing (); - public bool set_pending () throws GLib.Error; - public virtual ssize_t splice (GLib.InputStream source, GLib.OutputStreamSpliceFlags flags, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public virtual async ssize_t splice_async (GLib.InputStream source, GLib.OutputStreamSpliceFlags flags, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [CCode (vfunc_name = "write_fn")] - public abstract ssize_t write ([CCode (array_length_type = "gsize")] uint8[] buffer, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public bool write_all ([CCode (array_length_cname = "count", array_length_pos = 1.5, array_length_type = "gsize")] uint8[] buffer, out size_t bytes_written, GLib.Cancellable? cancellable = null) throws GLib.IOError; - [Version (since = "2.44")] - public async bool write_all_async ([CCode (array_length_cname = "count", array_length_pos = 1.5, array_length_type = "gsize")] uint8[] buffer, int io_priority, GLib.Cancellable? cancellable, out size_t bytes_written) throws GLib.Error; - public virtual async ssize_t write_async ([CCode (array_length_cname = "count", array_length_pos = 1.5, array_length_type = "gsize")] uint8[]? buffer, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public ssize_t write_bytes (GLib.Bytes bytes, GLib.Cancellable? cancellable = null) throws GLib.Error; - public async ssize_t write_bytes_async (GLib.Bytes bytes, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_permission_get_type ()")] - public abstract class Permission : GLib.Object { - [CCode (has_construct_function = false)] - protected Permission (); - [Version (since = "2.26")] - public virtual bool acquire (GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.26")] - public virtual async bool acquire_async (GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.26")] - public bool get_allowed (); - [Version (since = "2.26")] - public bool get_can_acquire (); - [Version (since = "2.26")] - public bool get_can_release (); - [Version (since = "2.26")] - public void impl_update (bool allowed, bool can_acquire, bool can_release); - [Version (since = "2.26")] - public virtual bool release (GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.26")] - public virtual async bool release_async (GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool allowed { get; } - public bool can_acquire { get; } - public bool can_release { get; } - } - [CCode (cheader_filename = "gio/gio.h", cname = "GSource", ref_function = "g_source_ref", unref_function = "g_source_unref")] - [Compact] - public class PollableSource : GLib.Source { - [CCode (type = "GSource*")] - public PollableSource (GLib.Object pollable_stream); - [CCode (type = "GSource*")] - public PollableSource.full (GLib.Object pollable_stream, GLib.Source? child_source, GLib.Cancellable? cancellable = null); - [CCode (cname = "g_source_set_callback")] - public void set_callback ([CCode (type = "GSourceFunc")] owned GLib.PollableSourceFunc func); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_property_action_get_type ()")] - [Version (since = "2.38")] - public class PropertyAction : GLib.Object, GLib.Action { - [CCode (has_construct_function = false)] - public PropertyAction (string name, GLib.Object object, string property_name); - [NoAccessorMethod] - [Version (since = "2.46")] - public bool invert_boolean { get; construct; } - public GLib.Object object { construct; } - public string property_name { construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_proxy_address_get_type ()")] - [Version (since = "2.26")] - public class ProxyAddress : GLib.InetSocketAddress, GLib.SocketConnectable { - [CCode (has_construct_function = false, type = "GSocketAddress*")] - public ProxyAddress (GLib.InetAddress inetaddr, uint16 port, string protocol, string dest_hostname, uint16 dest_port, string? username, string? password); - public unowned string get_destination_hostname (); - public uint16 get_destination_port (); - [Version (since = "2.34")] - public unowned string get_destination_protocol (); - public unowned string get_password (); - public unowned string get_protocol (); - [Version (since = "2.34")] - public unowned string get_uri (); - public unowned string get_username (); - public string destination_hostname { get; construct; } - public uint destination_port { get; construct; } - [Version (since = "2.34")] - public string destination_protocol { get; construct; } - public string password { get; construct; } - public string protocol { get; construct; } - [Version (since = "2.34")] - public string uri { get; construct; } - public string username { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_proxy_address_enumerator_get_type ()")] - public class ProxyAddressEnumerator : GLib.SocketAddressEnumerator { - [CCode (has_construct_function = false)] - protected ProxyAddressEnumerator (); - [NoAccessorMethod] - public GLib.SocketConnectable connectable { owned get; construct; } - [NoAccessorMethod] - [Version (since = "2.38")] - public uint default_port { get; construct; } - [NoAccessorMethod] - [Version (since = "2.36")] - public GLib.ProxyResolver proxy_resolver { owned get; set construct; } - [NoAccessorMethod] - public string uri { owned get; construct; } - } - [CCode (cheader_filename = "gio/gio.h")] - public class Resolver : GLib.Object { - [CCode (has_construct_function = false)] - protected Resolver (); - [Version (since = "2.22")] - public static GLib.Resolver get_default (); - [Version (since = "2.22")] - public virtual string lookup_by_address (GLib.InetAddress address, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public virtual async string lookup_by_address_async (GLib.InetAddress address, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public virtual GLib.List lookup_by_name (string hostname, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public virtual async GLib.List lookup_by_name_async (string hostname, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.34")] - public virtual GLib.List lookup_records (string rrname, GLib.ResolverRecordType record_type, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.34")] - public virtual async GLib.List lookup_records_async (string rrname, GLib.ResolverRecordType record_type, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public GLib.List lookup_service (string service, string protocol, string domain, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (finish_function = "g_resolver_lookup_service_finish")] - public async GLib.List lookup_service_async (string service, string protocol, string domain, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (vfunc_name = "lookup_service")] - [NoWrapper] - public virtual GLib.List lookup_service_fn (string rrname, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (finish_function = "g_resolver_lookup_service_finish", vfunc_name = "lookup_service_async")] - [NoWrapper] - public virtual async GLib.List lookup_service_fn_async (string rrname, GLib.Cancellable? cancellable = null); - [Version (since = "2.22")] - public void set_default (); - public virtual signal void reload (); - } - [CCode (cheader_filename = "gio/gio.h", ref_function = "g_resource_ref", type_id = "g_resource_get_type ()", unref_function = "g_resource_unref")] - [Compact] - [Version (since = "2.32")] - public class Resource { - [CCode (cname = "g_resources_register")] - public void _register (); - [CCode (cname = "g_resources_unregister")] - public void _unregister (); - [CCode (array_length = false, array_null_terminated = true)] - public string[] enumerate_children (string path, GLib.ResourceLookupFlags lookup_flags) throws GLib.Error; - [CCode (has_construct_function = false)] - public Resource.from_data (GLib.Bytes data) throws GLib.Error; - public bool get_info (string path, GLib.ResourceLookupFlags lookup_flags, out size_t size, out uint32 flags) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h")] - public static GLib.Resource load (string filename) throws GLib.Error; - public GLib.Bytes lookup_data (string path, GLib.ResourceLookupFlags lookup_flags) throws GLib.Error; - public GLib.InputStream open_stream (string path, GLib.ResourceLookupFlags lookup_flags) throws GLib.Error; - public GLib.Resource @ref (); - public void unref (); - } - [CCode (cheader_filename = "gio/gio.h")] - public class Settings : GLib.Object { - [CCode (has_construct_function = false)] - [Version (since = "2.26")] - public Settings (string schema_id); - public void apply (); - [Version (since = "2.26")] - public void bind (string key, GLib.Object object, string property, GLib.SettingsBindFlags flags); - public void bind_with_mapping (string key, GLib.Object object, string property, GLib.SettingsBindFlags flags, GLib.SettingsBindGetMappingShared get_mapping, GLib.SettingsBindSetMappingShared set_mapping, void* user_data, GLib.DestroyNotify? notify); - [Version (since = "2.26")] - public void bind_writable (string key, GLib.Object object, string property, bool inverted); - [Version (since = "2.32")] - public GLib.Action create_action (string key); - [Version (since = "2.26")] - public void delay (); - [CCode (has_construct_function = false)] - [Version (since = "2.32")] - public Settings.full (GLib.SettingsSchema schema, GLib.SettingsBackend? backend, string? path); - [CCode (sentinel = "")] - [Version (since = "2.26")] - public void @get (string key, string format, ...); - [Version (since = "2.26")] - public bool get_boolean (string key); - [Version (since = "2.26")] - public GLib.Settings get_child (string name); - [Version (since = "2.40")] - public GLib.Variant? get_default_value (string key); - [Version (since = "2.26")] - public double get_double (string key); - [Version (since = "2.26")] - public int get_enum (string key); - [Version (since = "2.26")] - public uint get_flags (string key); - [Version (since = "2.26")] - public bool get_has_unapplied (); - [Version (since = "2.26")] - public int get_int (string key); - public void* get_mapped (string key, GLib.SettingsGetMapping mapping); - [Version (deprecated = true, deprecated_since = "2.40", since = "2.28")] - public GLib.Variant get_range (string key); - [Version (since = "2.26")] - public string get_string (string key); - [CCode (array_length = false, array_null_terminated = true)] - [Version (since = "2.26")] - public string[] get_strv (string key); - [Version (since = "2.30")] - public uint get_uint (string key); - [Version (since = "2.40")] - public GLib.Variant? get_user_value (string key); - [Version (since = "2.26")] - public GLib.Variant get_value (string key); - [Version (since = "2.26")] - public bool is_writable (string name); - [CCode (array_length = false, array_null_terminated = true)] - public string[] list_children (); - [CCode (array_length = false, array_null_terminated = true)] - public string[] list_keys (); - [CCode (array_length = false, array_null_terminated = true)] - [Version (deprecated = true, deprecated_since = "2.40", since = "2.28")] - public static unowned string[] list_relocatable_schemas (); - [CCode (array_length = false, array_null_terminated = true)] - [Version (deprecated = true, deprecated_since = "2.40", since = "2.26")] - public static unowned string[] list_schemas (); - [Version (deprecated = true, deprecated_since = "2.40", since = "2.28")] - public bool range_check (string key, GLib.Variant value); - public void reset (string key); - public void revert (); - [CCode (sentinel = "")] - [Version (since = "2.26")] - public bool @set (string key, string format, ...); - [Version (since = "2.26")] - public bool set_boolean (string key, bool value); - [Version (since = "2.26")] - public bool set_double (string key, double value); - public bool set_enum (string key, int value); - public bool set_flags (string key, uint value); - [Version (since = "2.26")] - public bool set_int (string key, int value); - [Version (since = "2.26")] - public bool set_string (string key, string value); - [Version (since = "2.26")] - public bool set_strv (string key, [CCode (array_length = false, array_null_terminated = true)] string[]? value); - [Version (since = "2.30")] - public bool set_uint (string key, uint value); - [Version (since = "2.26")] - public bool set_value (string key, GLib.Variant value); - public static void sync (); - [Version (since = "2.26")] - public static void unbind (GLib.Object object, string property); - [CCode (has_construct_function = false)] - [Version (since = "2.26")] - public Settings.with_backend (string schema_id, GLib.SettingsBackend backend); - [CCode (has_construct_function = false)] - [Version (since = "2.26")] - public Settings.with_backend_and_path (string schema_id, GLib.SettingsBackend backend, string path); - [CCode (has_construct_function = false)] - [Version (since = "2.26")] - public Settings.with_path (string schema_id, string path); - [NoAccessorMethod] - public GLib.SettingsBackend backend { owned get; construct; } - [NoAccessorMethod] - [Version (since = "2.28")] - public bool delay_apply { get; } - public bool has_unapplied { get; } - [NoAccessorMethod] - public string path { owned get; construct; } - [NoAccessorMethod] - [Version (deprecated = true, deprecated_since = "2.32")] - public string schema { owned get; construct; } - [NoAccessorMethod] - public string schema_id { owned get; construct; } - [NoAccessorMethod] - public GLib.SettingsSchema settings_schema { owned get; construct; } - public virtual signal bool change_event (GLib.Quark[]? keys); - public virtual signal void changed (string key); - public virtual signal bool writable_change_event (uint key); - public virtual signal void writable_changed (string key); - } - [CCode (cheader_filename = "gio/gio.h")] - public class SettingsBackend : GLib.Object { - [CCode (has_construct_function = false)] - protected SettingsBackend (); - } - [CCode (cheader_filename = "gio/gio.h", ref_function = "g_settings_schema_ref", type_id = "g_settings_schema_get_type ()", unref_function = "g_settings_schema_unref")] - [Compact] - [Version (since = "2.32")] - public class SettingsSchema { - public unowned string get_id (); - [Version (since = "2.40")] - public GLib.SettingsSchemaKey get_key (string name); - public unowned string get_path (); - [Version (since = "2.40")] - public bool has_key (string name); - [CCode (array_length = false, array_null_terminated = true)] - [Version (since = "2.44")] - public string[] list_children (); - [CCode (array_length = false, array_null_terminated = true)] - [Version (since = "2.46")] - public string[] list_keys (); - public GLib.SettingsSchema @ref (); - public void unref (); - } - [CCode (cheader_filename = "gio/gio.h", ref_function = "g_settings_schema_key_ref", type_id = "g_settings_schema_key_get_type ()", unref_function = "g_settings_schema_key_unref")] - [Compact] - public class SettingsSchemaKey { - [Version (since = "2.40")] - public GLib.Variant get_default_value (); - [Version (since = "2.34")] - public unowned string get_description (); - [Version (since = "2.44")] - public unowned string get_name (); - [Version (since = "2.40")] - public GLib.Variant get_range (); - [Version (since = "2.34")] - public unowned string get_summary (); - [Version (since = "2.40")] - public unowned GLib.VariantType get_value_type (); - [Version (since = "2.40")] - public bool range_check (GLib.Variant value); - [Version (since = "2.40")] - public GLib.SettingsSchemaKey @ref (); - [Version (since = "2.40")] - public void unref (); - } - [CCode (cheader_filename = "gio/gio.h", ref_function = "g_settings_schema_source_ref", type_id = "g_settings_schema_source_get_type ()", unref_function = "g_settings_schema_source_unref")] - [Compact] - [Version (since = "2.32")] - public class SettingsSchemaSource { - [CCode (has_construct_function = false)] - public SettingsSchemaSource.from_directory (string directory, GLib.SettingsSchemaSource? parent, bool trusted) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h")] - public static unowned GLib.SettingsSchemaSource get_default (); - [Version (since = "2.40")] - public void list_schemas (bool recursive, [CCode (array_length = false, array_null_terminated = true)] out string[] non_relocatable, [CCode (array_length = false, array_null_terminated = true)] out string[] relocatable); - public GLib.SettingsSchema? lookup (string schema_id, bool recursive); - public GLib.SettingsSchemaSource @ref (); - public void unref (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_simple_action_get_type ()")] - public class SimpleAction : GLib.Object, GLib.Action { - [CCode (has_construct_function = false)] - [Version (since = "2.28")] - public SimpleAction (string name, GLib.VariantType? parameter_type); - [Version (since = "2.28")] - public void set_enabled (bool enabled); - [Version (since = "2.30")] - public void set_state (GLib.Variant value); - [Version (since = "2.44")] - public void set_state_hint (GLib.Variant? state_hint); - [CCode (has_construct_function = false)] - [Version (since = "2.28")] - public SimpleAction.stateful (string name, GLib.VariantType? parameter_type, GLib.Variant state); - [Version (since = "2.28")] - public signal void activate (GLib.Variant? parameter); - [Version (since = "2.30")] - public signal void change_state (GLib.Variant? value); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_simple_action_group_get_type ()")] - [Version (since = "2.28")] - public class SimpleActionGroup : GLib.Object, GLib.ActionGroup, GLib.ActionMap { - [CCode (has_construct_function = false)] - public SimpleActionGroup (); - [Version (deprecated = true, deprecated_since = "2.38", since = "2.30")] - public void add_entries ([CCode (array_length_cname = "n_entries", array_length_pos = 1.5)] GLib.ActionEntry[] entries, void* user_data); - [Version (deprecated = true, deprecated_since = "2.38", since = "2.28")] - public void insert (GLib.Action action); - [Version (deprecated = true, deprecated_since = "2.38", since = "2.28")] - public unowned GLib.Action lookup (string action_name); - [Version (deprecated = true, deprecated_since = "2.38", since = "2.28")] - public void remove (string action_name); - } - [CCode (cheader_filename = "gio/gio.h")] - public class SimpleAsyncResult : GLib.Object, GLib.AsyncResult, GLib.AsyncResult { - [CCode (has_construct_function = false)] - public SimpleAsyncResult (GLib.Object? source_object, void* source_tag); - [Version (deprecated = true, deprecated_since = "2.46")] - public void complete (); - [Version (deprecated = true, deprecated_since = "2.46")] - public void complete_in_idle (); - [CCode (has_construct_function = false)] - [PrintfFormat] - public SimpleAsyncResult.error (GLib.Object? source_object, GLib.Quark domain, int code, string format, ...); - [CCode (has_construct_function = false)] - public SimpleAsyncResult.from_error (GLib.Object? source_object, GLib.Error error); - [Version (deprecated = true, deprecated_since = "2.46")] - public bool get_op_res_gboolean (); - [CCode (simple_generics = true)] - public unowned T get_op_res_gpointer (); - [Version (deprecated = true, deprecated_since = "2.46")] - public ssize_t get_op_res_gssize (); - [Version (deprecated = true, deprecated_since = "2.46.")] - public void* get_source_tag (); - [Version (deprecated = true, deprecated_since = "2.46", since = "2.20")] - public static bool is_valid (GLib.AsyncResult result, GLib.Object? source, void* source_tag); - [Version (deprecated = true, deprecated_since = "2.46")] - public bool propagate_error () throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h", cname = "g_simple_async_report_gerror_in_idle")] - [Version (deprecated = true, deprecated_since = "2.46")] - public static async void report_gerror_in_idle (GLib.Object? object, GLib.Error error); - [Version (deprecated = true, deprecated_since = "2.46")] - public void run_in_thread (GLib.SimpleAsyncThreadFunc func, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null); - [Version (deprecated = true, deprecated_since = "2.46", since = "2.32")] - public void set_check_cancellable (GLib.Cancellable? check_cancellable); - [PrintfFormat] - [Version (deprecated = true, deprecated_since = "2.46")] - public void set_error (GLib.Quark domain, int code, string format, ...); - [Version (deprecated = true, deprecated_since = "2.46")] - public void set_error_va (GLib.Quark domain, int code, string format, va_list args); - [Version (deprecated = true, deprecated_since = "2.46")] - public void set_from_error (GLib.Error error); - [Version (deprecated = true, deprecated_since = "2.46")] - public void set_handle_cancellation (bool handle_cancellation); - [Version (deprecated = true, deprecated_since = "2.46")] - public void set_op_res_gboolean (bool op_res); - [CCode (simple_generics = true)] - public void set_op_res_gpointer (owned T op_res); - [Version (deprecated = true, deprecated_since = "2.46")] - public void set_op_res_gssize (ssize_t op_res); - [Version (deprecated = true, deprecated_since = "2.46", since = "2.28")] - public void take_error (GLib.Error error); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_simple_io_stream_get_type ()")] - [Version (since = "2.44")] - public class SimpleIOStream : GLib.IOStream { - [CCode (has_construct_function = false, type = "GIOStream*")] - public SimpleIOStream (GLib.InputStream input_stream, GLib.OutputStream output_stream); - [NoAccessorMethod] - public GLib.InputStream input_stream { owned get; construct; } - [NoAccessorMethod] - public GLib.OutputStream output_stream { owned get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_simple_permission_get_type ()")] - public class SimplePermission : GLib.Permission { - [CCode (has_construct_function = false, type = "GPermission*")] - [Version (since = "2.26")] - public SimplePermission (bool allowed); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_simple_proxy_resolver_get_type ()")] - public class SimpleProxyResolver : GLib.Object, GLib.ProxyResolver { - [CCode (has_construct_function = false)] - protected SimpleProxyResolver (); - [Version (since = "2.36")] - public static GLib.ProxyResolver @new (string? default_proxy, string? ignore_hosts); - [Version (since = "2.36")] - public void set_default_proxy (string default_proxy); - [Version (since = "2.36")] - public void set_ignore_hosts (string ignore_hosts); - [Version (since = "2.36")] - public void set_uri_proxy (string uri_scheme, string proxy); - [NoAccessorMethod] - public string default_proxy { owned get; set; } - [CCode (array_length = false, array_null_terminated = true)] - [NoAccessorMethod] - public string[] ignore_hosts { owned get; set; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_socket_get_type ()")] - [Version (since = "2.22")] - public class Socket : GLib.Object, GLib.DatagramBased, GLib.Initable { - [CCode (has_construct_function = false)] - public Socket (GLib.SocketFamily family, GLib.SocketType type, GLib.SocketProtocol protocol) throws GLib.Error; - public GLib.Socket accept (GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool bind (GLib.SocketAddress address, bool allow_reuse) throws GLib.Error; - public bool check_connect_result () throws GLib.Error; - public bool close () throws GLib.Error; - [Version (since = "2.32")] - public bool condition_timed_wait (GLib.IOCondition condition, int64 timeout, GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool connect (GLib.SocketAddress address, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (cname = "g_socket_create_source")] - public GLib.SocketSource create_socket_source (GLib.IOCondition condition, GLib.Cancellable? cancellable = null); - [CCode (has_construct_function = false)] - public Socket.from_fd (int fd) throws GLib.Error; - [Version (since = "2.32")] - public ssize_t get_available_bytes (); - public bool get_blocking (); - [Version (since = "2.32")] - public bool get_broadcast (); - [Version (since = "2.26")] - public GLib.Credentials get_credentials () throws GLib.Error; - public GLib.SocketFamily get_family (); - public int get_fd (); - public bool get_keepalive (); - public int get_listen_backlog (); - public GLib.SocketAddress get_local_address () throws GLib.Error; - [Version (since = "2.32")] - public bool get_multicast_loopback (); - [Version (since = "2.32")] - public uint get_multicast_ttl (); - [Version (since = "2.36")] - public bool get_option (int level, int optname, out int value) throws GLib.Error; - public GLib.SocketProtocol get_protocol (); - public GLib.SocketAddress get_remote_address () throws GLib.Error; - public GLib.SocketType get_socket_type (); - [Version (since = "2.26")] - public uint get_timeout (); - [Version (since = "2.32")] - public uint get_ttl (); - public bool is_closed (); - public bool is_connected (); - [Version (since = "2.32")] - public bool join_multicast_group (GLib.InetAddress group, bool source_specific, string? iface) throws GLib.Error; - [Version (since = "2.32")] - public bool leave_multicast_group (GLib.InetAddress group, bool source_specific, string? iface) throws GLib.Error; - public bool listen () throws GLib.Error; - public ssize_t receive ([CCode (array_length_cname = "size", array_length_pos = 1.5, array_length_type = "gsize")] uint8[] buffer, GLib.Cancellable? cancellable = null) throws GLib.Error; - public ssize_t receive_from (out GLib.SocketAddress address, [CCode (array_length_cname = "size", array_length_pos = 2.5, array_length_type = "gsize")] uint8[] buffer, GLib.Cancellable? cancellable = null) throws GLib.Error; - public ssize_t receive_message (out GLib.SocketAddress? address, [CCode (array_length_cname = "num_vectors", array_length_pos = 2.5)] GLib.InputVector[] vectors, [CCode (array_length_cname = "num_messages", array_length_pos = 3.5)] out GLib.SocketControlMessage[]? messages, ref int flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.26")] - public ssize_t receive_with_blocking ([CCode (array_length_cname = "size", array_length_pos = 1.5, array_length_type = "gsize")] uint8[] buffer, bool blocking, GLib.Cancellable? cancellable = null) throws GLib.Error; - public ssize_t send ([CCode (array_length_cname = "size", array_length_pos = 1.5, array_length_type = "gsize")] uint8[] buffer, GLib.Cancellable? cancellable = null) throws GLib.Error; - public ssize_t send_message (GLib.SocketAddress? address, [CCode (array_length_cname = "num_vectors", array_length_pos = 2.5)] GLib.OutputVector[] vectors, [CCode (array_length_cname = "num_messages", array_length_pos = 3.5)] GLib.SocketControlMessage[]? messages, int flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public ssize_t send_to (GLib.SocketAddress? address, [CCode (array_length_cname = "size", array_length_pos = 2.5, array_length_type = "gsize")] uint8[] buffer, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.26")] - public ssize_t send_with_blocking ([CCode (array_length_cname = "size", array_length_pos = 1.5, array_length_type = "gsize")] uint8[] buffer, bool blocking, GLib.Cancellable? cancellable = null) throws GLib.Error; - public void set_blocking (bool blocking); - [Version (since = "2.32")] - public void set_broadcast (bool broadcast); - public void set_keepalive (bool keepalive); - public void set_listen_backlog (int backlog); - [Version (since = "2.32")] - public void set_multicast_loopback (bool loopback); - [Version (since = "2.32")] - public void set_multicast_ttl (uint ttl); - [Version (since = "2.36")] - public bool set_option (int level, int optname, int value) throws GLib.Error; - [Version (since = "2.26")] - public void set_timeout (uint timeout); - [Version (since = "2.32")] - public void set_ttl (uint ttl); - public bool shutdown (bool shutdown_read, bool shutdown_write) throws GLib.Error; - public bool speaks_ipv4 (); - public bool blocking { get; set; } - [Version (since = "2.32")] - public bool broadcast { get; set; } - public GLib.SocketFamily family { get; construct; } - public int fd { get; construct; } - public bool keepalive { get; set; } - public int listen_backlog { get; set; } - public GLib.SocketAddress local_address { owned get; } - [Version (since = "2.32")] - public bool multicast_loopback { get; set; } - [Version (since = "2.32")] - public uint multicast_ttl { get; set; } - public GLib.SocketProtocol protocol { get; construct; } - public GLib.SocketAddress remote_address { owned get; } - [Version (since = "2.26")] - public uint timeout { get; set; } - [Version (since = "2.32")] - public uint ttl { get; set; } - [NoAccessorMethod] - public GLib.SocketType type { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_socket_address_get_type ()")] - public abstract class SocketAddress : GLib.Object, GLib.SocketConnectable { - [CCode (has_construct_function = false)] - protected SocketAddress (); - [CCode (has_construct_function = false)] - [Version (since = "2.22")] - public SocketAddress.from_native (void* native, size_t len); - [Version (since = "2.22")] - public virtual GLib.SocketFamily get_family (); - [Version (since = "2.22")] - public virtual ssize_t get_native_size (); - [Version (since = "2.22")] - public virtual bool to_native (void* dest, size_t destlen) throws GLib.Error; - public GLib.SocketFamily family { get; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_socket_address_enumerator_get_type ()")] - public abstract class SocketAddressEnumerator : GLib.Object { - [CCode (has_construct_function = false)] - protected SocketAddressEnumerator (); - public virtual GLib.SocketAddress next (GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.SocketAddress next_async (GLib.Cancellable? cancellable = null) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_socket_client_get_type ()")] - [Version (since = "2.22")] - public class SocketClient : GLib.Object { - [CCode (has_construct_function = false)] - public SocketClient (); - public void add_application_proxy (string protocol); - public GLib.SocketConnection connect (GLib.SocketConnectable connectable, GLib.Cancellable? cancellable = null) throws GLib.Error; - public async GLib.SocketConnection connect_async (GLib.SocketConnectable connectable, GLib.Cancellable? cancellable = null) throws GLib.Error; - public GLib.SocketConnection connect_to_host (string host_and_port, uint16 default_port, GLib.Cancellable? cancellable = null) throws GLib.Error; - public async GLib.SocketConnection connect_to_host_async (string host_and_port, uint16 default_port, GLib.Cancellable? cancellable = null) throws GLib.Error; - public GLib.SocketConnection connect_to_service (string domain, string service, GLib.Cancellable? cancellable = null) throws GLib.Error; - public async GLib.SocketConnection connect_to_service_async (string domain, string service, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.26")] - public GLib.SocketConnection connect_to_uri (string uri, uint16 default_port, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.26")] - public async GLib.SocketConnection connect_to_uri_async (string uri, uint16 default_port, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.26")] - public bool get_enable_proxy (); - public GLib.SocketFamily get_family (); - public unowned GLib.SocketAddress get_local_address (); - public GLib.SocketProtocol get_protocol (); - [Version (since = "2.36")] - public unowned GLib.ProxyResolver get_proxy_resolver (); - public GLib.SocketType get_socket_type (); - [Version (since = "2.26")] - public uint get_timeout (); - [Version (since = "2.28")] - public bool get_tls (); - [Version (since = "2.28")] - public GLib.TlsCertificateFlags get_tls_validation_flags (); - [Version (since = "2.26")] - public void set_enable_proxy (bool enable); - public void set_family (GLib.SocketFamily family); - public void set_local_address (GLib.SocketAddress? address); - public void set_protocol (GLib.SocketProtocol protocol); - [Version (since = "2.36")] - public void set_proxy_resolver (GLib.ProxyResolver? proxy_resolver); - public void set_socket_type (GLib.SocketType type); - [Version (since = "2.26")] - public void set_timeout (uint timeout); - [Version (since = "2.28")] - public void set_tls (bool tls); - [Version (since = "2.28")] - public void set_tls_validation_flags (GLib.TlsCertificateFlags flags); - public bool enable_proxy { get; set construct; } - public GLib.SocketFamily family { get; set construct; } - public GLib.SocketAddress local_address { get; set construct; } - public GLib.SocketProtocol protocol { get; set construct; } - [Version (since = "2.36")] - public GLib.ProxyResolver proxy_resolver { get; set construct; } - public uint timeout { get; set construct; } - public bool tls { get; set construct; } - public GLib.TlsCertificateFlags tls_validation_flags { get; set construct; } - [NoAccessorMethod] - public GLib.SocketType type { get; set construct; } - [Version (since = "2.32")] - public virtual signal void event (GLib.SocketClientEvent event, GLib.SocketConnectable connectable, GLib.IOStream? connection); - } - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.22")] - public class SocketConnection : GLib.IOStream { - [CCode (has_construct_function = false)] - protected SocketConnection (); - [Version (since = "2.32")] - public bool connect (GLib.SocketAddress address, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.32")] - public async bool connect_async (GLib.SocketAddress address, GLib.Cancellable? cancellable = null) throws GLib.Error; - public static GLib.SocketConnection factory_create_connection (GLib.Socket socket); - public static GLib.Type factory_lookup_type (GLib.SocketFamily family, GLib.SocketType type, int protocol_id); - public static void factory_register_type (GLib.Type g_type, GLib.SocketFamily family, GLib.SocketType type, int protocol); - public GLib.SocketAddress get_local_address () throws GLib.Error; - public GLib.SocketAddress get_remote_address () throws GLib.Error; - public unowned GLib.Socket get_socket (); - [Version (since = "2.32")] - public bool is_connected (); - public GLib.Socket socket { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_socket_control_message_get_type ()")] - public abstract class SocketControlMessage : GLib.Object { - [CCode (has_construct_function = false)] - protected SocketControlMessage (); - [Version (since = "2.22")] - public static GLib.SocketControlMessage deserialize (int level, int type, [CCode (array_length_cname = "size", array_length_pos = 2.5, array_length_type = "gsize")] uint8[] data); - [Version (since = "2.22")] - public virtual int get_level (); - [Version (since = "2.22")] - public int get_msg_type (); - [Version (since = "2.22")] - public virtual size_t get_size (); - [NoWrapper] - public virtual int get_type (); - [Version (since = "2.22")] - public virtual void serialize ([CCode (array_length = false, type = "gpointer")] uint8[] data); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_socket_listener_get_type ()")] - [Version (since = "2.22")] - public class SocketListener : GLib.Object { - [CCode (has_construct_function = false)] - public SocketListener (); - public GLib.SocketConnection accept (out unowned GLib.Object source_object = null, GLib.Cancellable? cancellable = null) throws GLib.Error; - public async GLib.SocketConnection accept_async (GLib.Cancellable? cancellable = null, out unowned GLib.Object source_object = null) throws GLib.Error; - public GLib.Socket accept_socket (out unowned GLib.Object source_object = null, GLib.Cancellable? cancellable = null) throws GLib.Error; - public async GLib.Socket accept_socket_async (GLib.Cancellable? cancellable = null, out unowned GLib.Object source_object = null) throws GLib.Error; - public bool add_address (GLib.SocketAddress address, GLib.SocketType type, GLib.SocketProtocol protocol, GLib.Object? source_object, out GLib.SocketAddress effective_address) throws GLib.Error; - [Version (since = "2.24")] - public uint16 add_any_inet_port (GLib.Object? source_object) throws GLib.Error; - public bool add_inet_port (uint16 port, GLib.Object? source_object) throws GLib.Error; - public bool add_socket (GLib.Socket socket, GLib.Object? source_object) throws GLib.Error; - [NoWrapper] - public virtual void changed (); - public void close (); - public void set_backlog (int listen_backlog); - [NoAccessorMethod] - public int listen_backlog { get; set construct; } - [Version (since = "2.46")] - public virtual signal void event (GLib.SocketListenerEvent event, GLib.Socket socket); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_socket_service_get_type ()")] - [Version (since = "2.22")] - public class SocketService : GLib.SocketListener { - [CCode (has_construct_function = false)] - public SocketService (); - public bool is_active (); - public void start (); - public void stop (); - [NoAccessorMethod] - [Version (since = "2.46")] - public bool active { get; set construct; } - public virtual signal bool incoming (GLib.SocketConnection connection, GLib.Object? source_object); - } - [CCode (cheader_filename = "gio/gio.h", cname = "GSource", ref_function = "g_source_ref", unref_function = "g_source_unref")] - [Compact] - public class SocketSource : GLib.Source { - [CCode (cname = "g_source_set_callback")] - public void set_callback ([CCode (type = "GSourceFunc")] owned GLib.SocketSourceFunc func); - } - [CCode (cheader_filename = "gio/gio.h", copy_function = "g_boxed_copy", free_function = "g_boxed_free", type_id = "g_srv_target_get_type ()")] - [Compact] - public class SrvTarget { - [CCode (has_construct_function = false)] - [Version (since = "2.22")] - public SrvTarget (string hostname, uint16 port, uint16 priority, uint16 weight); - [Version (since = "2.22")] - public GLib.SrvTarget copy (); - [Version (since = "2.22")] - public void free (); - [Version (since = "2.22")] - public unowned string get_hostname (); - [Version (since = "2.22")] - public uint16 get_port (); - [Version (since = "2.22")] - public uint16 get_priority (); - [Version (since = "2.22")] - public uint16 get_weight (); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.22")] - public static GLib.List list_sort (owned GLib.List targets); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_subprocess_get_type ()")] - [Version (since = "2.40")] - public class Subprocess : GLib.Object, GLib.Initable { - [CCode (has_construct_function = false)] - public Subprocess (GLib.SubprocessFlags flags, ...) throws GLib.Error; - public bool communicate (GLib.Bytes? stdin_buf, GLib.Cancellable? cancellable, out GLib.Bytes stdout_buf, out GLib.Bytes stderr_buf) throws GLib.Error; - public async bool communicate_async (GLib.Bytes? stdin_buf, GLib.Cancellable? cancellable, out GLib.Bytes stdout_buf, out GLib.Bytes stderr_buf) throws GLib.Error; - public bool communicate_utf8 (string? stdin_buf, GLib.Cancellable? cancellable, out string stdout_buf, out string stderr_buf) throws GLib.Error; - public async bool communicate_utf8_async (string? stdin_buf, GLib.Cancellable? cancellable, out string stdout_buf, out string stderr_buf) throws GLib.Error; - public void force_exit (); - public int get_exit_status (); - public unowned string get_identifier (); - public bool get_if_exited (); - public bool get_if_signaled (); - public int get_status (); - public unowned GLib.InputStream get_stderr_pipe (); - public unowned GLib.OutputStream get_stdin_pipe (); - public unowned GLib.InputStream get_stdout_pipe (); - public bool get_successful (); - public int get_term_sig (); - [CCode (cname = "g_subprocess_newv", has_construct_function = false)] - public Subprocess.newv ([CCode (array_length = false, array_null_terminated = true)] string[] argv, GLib.SubprocessFlags flags) throws GLib.Error; - public void send_signal (int signal_num); - public bool wait (GLib.Cancellable? cancellable = null) throws GLib.Error; - public async bool wait_async (GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool wait_check (GLib.Cancellable? cancellable = null) throws GLib.Error; - public async bool wait_check_async (GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (array_length = false, array_null_terminated = true)] - public string[] argv { construct; } - public GLib.SubprocessFlags flags { construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_subprocess_launcher_get_type ()")] - [Version (since = "2.40")] - public class SubprocessLauncher : GLib.Object { - [CCode (has_construct_function = false)] - public SubprocessLauncher (GLib.SubprocessFlags flags); - public unowned string getenv (string variable); - public void set_child_setup (owned GLib.SpawnChildSetupFunc child_setup); - public void set_cwd (string cwd); - public void set_environ (string env); - public void set_flags (GLib.SubprocessFlags flags); - public void set_stderr_file_path (string path); - public void set_stdin_file_path (string path); - public void set_stdout_file_path (string path); - public void setenv (string variable, string value, bool overwrite); - public GLib.Subprocess spawnv ([CCode (array_length = false, array_null_terminated = true)] string[] argv) throws GLib.Error; - public void take_fd (int source_fd, int target_fd); - public void take_stderr_fd (int fd); - public void take_stdin_fd (int fd); - public void take_stdout_fd (int fd); - public void unsetenv (string variable); - public GLib.SubprocessFlags flags { construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_task_get_type ()")] - public class Task : GLib.Object, GLib.AsyncResult { - [CCode (has_construct_function = false)] - [Version (since = "2.36")] - public async Task (GLib.Object? source_object, GLib.Cancellable? cancellable = null); - [Version (since = "2.36")] - public unowned GLib.Cancellable get_cancellable (); - [Version (since = "2.36")] - public bool get_check_cancellable (); - [Version (since = "2.44")] - public bool get_completed (); - [Version (since = "2.36")] - public unowned GLib.MainContext get_context (); - [Version (since = "2.36")] - public int get_priority (); - [Version (since = "2.36")] - public bool get_return_on_cancel (); - [Version (since = "2.36")] - public void* get_source_tag (); - [Version (since = "2.36")] - public void* get_task_data (); - [Version (since = "2.36")] - public bool had_error (); - [Version (since = "2.36")] - public static bool is_valid (GLib.AsyncResult result, GLib.Object? source_object); - [Version (since = "2.36")] - public bool propagate_boolean () throws GLib.Error; - [Version (since = "2.36")] - public ssize_t propagate_int () throws GLib.Error; - [Version (since = "2.36")] - public void* propagate_pointer () throws GLib.Error; - [Version (since = "2.36")] - public static async void report_error (GLib.Object? source_object, void* source_tag, owned GLib.Error error); - [Version (since = "2.36")] - public void return_boolean (bool result); - [Version (since = "2.36")] - public void return_error (owned GLib.Error error); - [Version (since = "2.36")] - public bool return_error_if_cancelled (); - [Version (since = "2.36")] - public void return_int (ssize_t result); - [Version (since = "2.36")] - public void return_pointer (owned void* result, GLib.DestroyNotify? result_destroy); - [Version (since = "2.36")] - public void set_check_cancellable (bool check_cancellable); - [Version (since = "2.36")] - public void set_priority (int priority); - [Version (since = "2.36")] - public bool set_return_on_cancel (bool return_on_cancel); - [Version (since = "2.36")] - public void set_source_tag (void* source_tag); - [Version (since = "2.36")] - public void set_task_data (void* task_data, GLib.DestroyNotify? task_data_destroy); - [Version (since = "2.44")] - public bool completed { get; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_tcp_connection_get_type ()")] - [Version (since = "2.22")] - public class TcpConnection : GLib.SocketConnection { - [CCode (has_construct_function = false)] - protected TcpConnection (); - public bool get_graceful_disconnect (); - public void set_graceful_disconnect (bool graceful_disconnect); - public bool graceful_disconnect { get; set; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_tcp_wrapper_connection_get_type ()")] - public class TcpWrapperConnection : GLib.TcpConnection { - [CCode (has_construct_function = false, type = "GSocketConnection*")] - [Version (since = "2.28")] - public TcpWrapperConnection (GLib.IOStream base_io_stream, GLib.Socket socket); - public unowned GLib.IOStream get_base_io_stream (); - public GLib.IOStream base_io_stream { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_test_dbus_get_type ()")] - [Version (since = "2.34")] - public class TestDBus : GLib.Object { - [CCode (has_construct_function = false)] - public TestDBus (GLib.TestDBusFlags flags); - public void add_service_dir (string path); - public void down (); - public unowned string? get_bus_address (); - public GLib.TestDBusFlags get_flags (); - public void stop (); - public static void unset (); - public void up (); - public GLib.TestDBusFlags flags { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_themed_icon_get_type ()")] - public class ThemedIcon : GLib.Object, GLib.Icon { - [CCode (has_construct_function = false, type = "GIcon*")] - public ThemedIcon (string iconname); - public void append_name (string iconname); - [CCode (has_construct_function = false, type = "GIcon*")] - public ThemedIcon.from_names ([CCode (array_length_cname = "len", array_length_pos = 1.1)] string[] iconnames); - [CCode (array_length = false, array_null_terminated = true)] - public unowned string[] get_names (); - [Version (since = "2.18")] - public void prepend_name (string iconname); - [CCode (has_construct_function = false, type = "GIcon*")] - public ThemedIcon.with_default_fallbacks (string iconname); - public string name { construct; } - [CCode (array_length = false, array_null_terminated = true)] - public string[] names { get; construct; } - [NoAccessorMethod] - public bool use_default_fallbacks { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_threaded_socket_service_get_type ()")] - [Version (since = "2.22")] - public class ThreadedSocketService : GLib.SocketService { - [CCode (has_construct_function = false, type = "GSocketService*")] - public ThreadedSocketService (int max_threads); - [NoAccessorMethod] - public int max_threads { get; construct; } - public virtual signal bool run (GLib.SocketConnection connection, GLib.Object source_object); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_tls_certificate_get_type ()")] - [Version (since = "2.28")] - public class TlsCertificate : GLib.Object { - [CCode (has_construct_function = false)] - protected TlsCertificate (); - [CCode (has_construct_function = false)] - public TlsCertificate.from_file (string file) throws GLib.Error; - [CCode (has_construct_function = false)] - public TlsCertificate.from_files (string cert_file, string key_file) throws GLib.Error; - [CCode (has_construct_function = false)] - public TlsCertificate.from_pem (string data, ssize_t length) throws GLib.Error; - public unowned GLib.TlsCertificate get_issuer (); - [Version (since = "2.34")] - public bool is_same (GLib.TlsCertificate cert_two); - public static GLib.List list_new_from_file (string file) throws GLib.Error; - public virtual GLib.TlsCertificateFlags verify (GLib.SocketConnectable? identity, GLib.TlsCertificate? trusted_ca); - [NoAccessorMethod] - public GLib.ByteArray certificate { owned get; construct; } - [NoAccessorMethod] - public string certificate_pem { owned get; construct; } - public GLib.TlsCertificate issuer { get; construct; } - public GLib.ByteArray private_key { construct; } - public string private_key_pem { construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_tls_connection_get_type ()")] - [Version (since = "2.28")] - public abstract class TlsConnection : GLib.IOStream { - [CCode (has_construct_function = false)] - protected TlsConnection (); - public bool emit_accept_certificate (GLib.TlsCertificate peer_cert, GLib.TlsCertificateFlags errors); - public unowned GLib.TlsCertificate get_certificate (); - [Version (since = "2.30")] - public unowned GLib.TlsDatabase get_database (); - [Version (since = "2.30")] - public unowned GLib.TlsInteraction get_interaction (); - public unowned GLib.TlsCertificate get_peer_certificate (); - public GLib.TlsCertificateFlags get_peer_certificate_errors (); - public GLib.TlsRehandshakeMode get_rehandshake_mode (); - public bool get_require_close_notify (); - [Version (deprecated = true, deprecated_since = "2.30")] - public bool get_use_system_certdb (); - public virtual bool handshake (GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async bool handshake_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public void set_certificate (GLib.TlsCertificate certificate); - [Version (since = "2.30")] - public void set_database (GLib.TlsDatabase database); - [Version (since = "2.30")] - public void set_interaction (GLib.TlsInteraction? interaction); - public void set_rehandshake_mode (GLib.TlsRehandshakeMode mode); - public void set_require_close_notify (bool require_close_notify); - [Version (deprecated = true, deprecated_since = "2.30")] - public void set_use_system_certdb (bool use_system_certdb); - [NoAccessorMethod] - public GLib.IOStream base_io_stream { owned get; construct; } - public GLib.TlsCertificate certificate { get; set; } - [Version (since = "2.30")] - public GLib.TlsDatabase database { get; set; } - [Version (since = "2.30")] - public GLib.TlsInteraction interaction { get; set; } - public GLib.TlsCertificate peer_certificate { get; } - public GLib.TlsCertificateFlags peer_certificate_errors { get; } - public GLib.TlsRehandshakeMode rehandshake_mode { get; set construct; } - public bool require_close_notify { get; set construct; } - [Version (deprecated = true, deprecated_since = "2.30")] - public bool use_system_certdb { get; set construct; } - public virtual signal bool accept_certificate (GLib.TlsCertificate peer_cert, GLib.TlsCertificateFlags errors); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_tls_database_get_type ()")] - [Version (since = "2.30")] - public abstract class TlsDatabase : GLib.Object { - [CCode (cheader_filename = "gio/gio.h", cname = "G_TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT")] - public const string PURPOSE_AUTHENTICATE_CLIENT; - [CCode (cheader_filename = "gio/gio.h", cname = "G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER")] - public const string PURPOSE_AUTHENTICATE_SERVER; - [CCode (has_construct_function = false)] - protected TlsDatabase (); - public virtual string? create_certificate_handle (GLib.TlsCertificate certificate); - public virtual GLib.TlsCertificate? lookup_certificate_for_handle (string handle, GLib.TlsInteraction? interaction, GLib.TlsDatabaseLookupFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.TlsCertificate lookup_certificate_for_handle_async (string handle, GLib.TlsInteraction? interaction, GLib.TlsDatabaseLookupFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual GLib.TlsCertificate lookup_certificate_issuer (GLib.TlsCertificate certificate, GLib.TlsInteraction? interaction, GLib.TlsDatabaseLookupFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.TlsCertificate lookup_certificate_issuer_async (GLib.TlsCertificate certificate, GLib.TlsInteraction? interaction, GLib.TlsDatabaseLookupFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual GLib.List lookup_certificates_issued_by (GLib.ByteArray issuer_raw_dn, GLib.TlsInteraction? interaction, GLib.TlsDatabaseLookupFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.List lookup_certificates_issued_by_async (GLib.ByteArray issuer_raw_dn, GLib.TlsInteraction? interaction, GLib.TlsDatabaseLookupFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual GLib.TlsCertificateFlags verify_chain (GLib.TlsCertificate chain, string purpose, GLib.SocketConnectable? identity, GLib.TlsInteraction? interaction, GLib.TlsDatabaseVerifyFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.TlsCertificateFlags verify_chain_async (GLib.TlsCertificate chain, string purpose, GLib.SocketConnectable? identity, GLib.TlsInteraction? interaction, GLib.TlsDatabaseVerifyFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_tls_interaction_get_type ()")] - [Version (since = "2.30")] - public class TlsInteraction : GLib.Object { - [CCode (has_construct_function = false)] - protected TlsInteraction (); - public virtual GLib.TlsInteractionResult ask_password (GLib.TlsPassword password, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.TlsInteractionResult ask_password_async (GLib.TlsPassword password, GLib.Cancellable? cancellable = null) throws GLib.Error; - public GLib.TlsInteractionResult invoke_ask_password (GLib.TlsPassword password, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.40")] - public GLib.TlsInteractionResult invoke_request_certificate (GLib.TlsConnection connection, GLib.TlsCertificateRequestFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.40")] - public virtual GLib.TlsInteractionResult request_certificate (GLib.TlsConnection connection, GLib.TlsCertificateRequestFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.40")] - public virtual async GLib.TlsInteractionResult request_certificate_async (GLib.TlsConnection connection, GLib.TlsCertificateRequestFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.30")] - public class TlsPassword : GLib.Object { - [CCode (has_construct_function = false)] - public TlsPassword (GLib.TlsPasswordFlags flags, string description); - [NoWrapper] - public virtual unowned string get_default_warning (); - public unowned string get_description (); - public GLib.TlsPasswordFlags get_flags (); - [CCode (array_length_pos = 0.1)] - public virtual unowned uint8[] get_value (); - public unowned string get_warning (); - public void set_description (string description); - public void set_flags (GLib.TlsPasswordFlags flags); - public void set_value ([CCode (array_length_cname = "length", array_length_pos = 1.1, array_length_type = "gssize", type = "const guchar*")] uint8[] value); - [CCode (vfunc_name = "set_value")] - public virtual void set_value_full ([CCode (array_length_cname = "length", array_length_pos = 1.5, array_length_type = "gssize", type = "guchar*")] owned uint8[] value, GLib.DestroyNotify? notify = GLib.g_free); - public void set_warning (string warning); - public string description { get; set; } - public GLib.TlsPasswordFlags flags { get; set; } - public string warning { get; set; } - } - [CCode (cheader_filename = "gio/gunixfdlist.h", type_id = "g_unix_fd_list_get_type ()")] - public class UnixFDList : GLib.Object { - [CCode (has_construct_function = false)] - [Version (since = "2.24")] - public UnixFDList (); - [Version (since = "2.24")] - public int append (int fd) throws GLib.Error; - [CCode (has_construct_function = false)] - [Version (since = "2.24")] - public UnixFDList.from_array ([CCode (array_length_cname = "n_fds", array_length_pos = 1.1)] int[] fds); - [Version (since = "2.24")] - public int @get (int index_) throws GLib.Error; - [Version (since = "2.24")] - public int get_length (); - [CCode (array_length_pos = 0.1)] - [Version (since = "2.24")] - public unowned int[] peek_fds (); - [CCode (array_length_pos = 0.1)] - [Version (since = "2.24")] - public int[] steal_fds (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_vfs_get_type ()")] - public class Vfs : GLib.Object { - [CCode (has_construct_function = false)] - protected Vfs (); - [NoWrapper] - public virtual void add_writable_namespaces (GLib.FileAttributeInfoList list); - public static unowned GLib.Vfs get_default (); - public virtual GLib.File get_file_for_path (string path); - public virtual GLib.File get_file_for_uri (string uri); - public static unowned GLib.Vfs get_local (); - [CCode (array_length = false, array_null_terminated = true)] - public virtual unowned string[] get_supported_uri_schemes (); - public virtual bool is_active (); - [NoWrapper] - public virtual void local_file_add_info (string filename, uint64 device, GLib.FileAttributeMatcher attribute_matcher, GLib.FileInfo info, GLib.Cancellable? cancellable = null, void* extra_data = null, GLib.DestroyNotify? free_extra_data = null); - [NoWrapper] - public virtual void local_file_moved (string source, string dest); - [NoWrapper] - public virtual void local_file_removed (string filename); - [NoWrapper] - public virtual bool local_file_set_attributes (string filename, GLib.FileInfo info, GLib.FileQueryInfoFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual GLib.File parse_name (string parse_name); - } - [CCode (cheader_filename = "gio/gio.h")] - public class VolumeMonitor : GLib.Object { - [CCode (has_construct_function = false)] - protected VolumeMonitor (); - [Version (deprecated = true, deprecated_since = "2.20")] - public static GLib.Volume adopt_orphan_mount (GLib.Mount mount); - public static GLib.VolumeMonitor @get (); - public virtual GLib.List get_connected_drives (); - public virtual GLib.Mount get_mount_for_uuid (string uuid); - public virtual GLib.List get_mounts (); - public virtual GLib.Volume get_volume_for_uuid (string uuid); - public virtual GLib.List get_volumes (); - [NoWrapper] - public virtual bool is_supported (); - public virtual signal void drive_changed (GLib.Drive drive); - public virtual signal void drive_connected (GLib.Drive drive); - public virtual signal void drive_disconnected (GLib.Drive drive); - [Version (since = "2.18")] - public virtual signal void drive_eject_button (GLib.Drive drive); - [Version (since = "2.22")] - public virtual signal void drive_stop_button (GLib.Drive drive); - public virtual signal void mount_added (GLib.Mount mount); - public virtual signal void mount_changed (GLib.Mount mount); - public virtual signal void mount_pre_unmount (GLib.Mount mount); - public virtual signal void mount_removed (GLib.Mount mount); - public virtual signal void volume_added (GLib.Volume volume); - public virtual signal void volume_changed (GLib.Volume volume); - public virtual signal void volume_removed (GLib.Volume volume); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_zlib_compressor_get_type ()")] - public class ZlibCompressor : GLib.Object, GLib.Converter { - [CCode (has_construct_function = false)] - [Version (since = "2.24")] - public ZlibCompressor (GLib.ZlibCompressorFormat format, int level = -1); - [Version (since = "2.26")] - public unowned GLib.FileInfo get_file_info (); - [Version (since = "2.26")] - public void set_file_info (GLib.FileInfo? file_info); - [Version (since = "2.26")] - public GLib.FileInfo file_info { get; set; } - [NoAccessorMethod] - public GLib.ZlibCompressorFormat format { get; construct; } - [NoAccessorMethod] - public int level { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_zlib_decompressor_get_type ()")] - public class ZlibDecompressor : GLib.Object, GLib.Converter { - [CCode (has_construct_function = false)] - [Version (since = "2.24")] - public ZlibDecompressor (GLib.ZlibCompressorFormat format); - [Version (since = "2.26")] - public unowned GLib.FileInfo get_file_info (); - [Version (since = "2.26")] - public GLib.FileInfo file_info { get; } - [NoAccessorMethod] - public GLib.ZlibCompressorFormat format { get; construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GActionInterface", type_id = "g_action_get_type ()")] - public interface Action : GLib.Object { - [Version (since = "2.28")] - public abstract void activate (GLib.Variant? parameter); - [Version (since = "2.30")] - public abstract void change_state (GLib.Variant value); - [Version (since = "2.28")] - public abstract bool get_enabled (); - [Version (since = "2.28")] - public abstract unowned string get_name (); - [Version (since = "2.28")] - public abstract unowned GLib.VariantType? get_parameter_type (); - [Version (since = "2.28")] - public abstract GLib.Variant get_state (); - [Version (since = "2.28")] - public abstract GLib.Variant? get_state_hint (); - [Version (since = "2.28")] - public abstract unowned GLib.VariantType? get_state_type (); - [Version (since = "2.38")] - public static bool name_is_valid (string action_name); - [Version (since = "2.38")] - public static bool parse_detailed_name (string detailed_name, out string action_name, out GLib.Variant target_value) throws GLib.Error; - [Version (since = "2.38")] - public static string print_detailed_name (string action_name, GLib.Variant? target_value); - [Version (since = "2.28")] - public abstract bool enabled { get; } - [Version (since = "2.28")] - public abstract string name { get; } - [Version (since = "2.28")] - public abstract GLib.VariantType? parameter_type { get; } - [Version (since = "2.28")] - public abstract GLib.Variant? state { owned get; } - [Version (since = "2.28")] - public abstract GLib.VariantType? state_type { get; } - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GActionGroupInterface", type_id = "g_action_group_get_type ()")] - public interface ActionGroup : GLib.Object { - [Version (since = "2.28")] - public abstract void activate_action (string action_name, GLib.Variant? parameter); - [Version (since = "2.28")] - public abstract void change_action_state (string action_name, GLib.Variant value); - [Version (since = "2.28")] - public abstract bool get_action_enabled (string action_name); - [Version (since = "2.28")] - public abstract unowned GLib.VariantType? get_action_parameter_type (string action_name); - [Version (since = "2.28")] - public abstract GLib.Variant? get_action_state (string action_name); - [Version (since = "2.28")] - public abstract GLib.Variant? get_action_state_hint (string action_name); - [Version (since = "2.28")] - public abstract unowned GLib.VariantType? get_action_state_type (string action_name); - [Version (since = "2.28")] - public abstract bool has_action (string action_name); - [CCode (array_length = false, array_null_terminated = true)] - [Version (since = "2.28")] - public abstract string[] list_actions (); - [Version (since = "2.32")] - public virtual bool query_action (string action_name, out bool enabled, out GLib.VariantType parameter_type, out GLib.VariantType state_type, out GLib.Variant state_hint, out GLib.Variant state); - [HasEmitter] - [Version (since = "2.28")] - public virtual signal void action_added (string action_name); - [HasEmitter] - [Version (since = "2.28")] - public virtual signal void action_enabled_changed (string action_name, bool enabled); - [HasEmitter] - [Version (since = "2.28")] - public virtual signal void action_removed (string action_name); - [HasEmitter] - [Version (since = "2.28")] - public virtual signal void action_state_changed (string action_name, GLib.Variant state); - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GActionMapInterface", type_id = "g_action_map_get_type ()")] - public interface ActionMap : GLib.Object { - [Version (since = "2.32")] - public abstract void add_action (GLib.Action action); - [Version (since = "2.32")] - public void add_action_entries ([CCode (array_length_cname = "n_entries", array_length_pos = 1.5)] GLib.ActionEntry[] entries, void* user_data); - [Version (since = "2.32")] - public abstract unowned GLib.Action lookup_action (string action_name); - [Version (since = "2.32")] - public abstract void remove_action (string action_name); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_app_info_get_type ()")] - public interface AppInfo : GLib.Object { - public abstract bool add_supports_type (string content_type) throws GLib.Error; - [Version (since = "2.20")] - public abstract bool can_delete (); - public abstract bool can_remove_supports_type (); - public static GLib.AppInfo create_from_commandline (string commandline, string? application_name, GLib.AppInfoCreateFlags flags) throws GLib.Error; - [CCode (vfunc_name = "do_delete")] - [Version (since = "2.20")] - public abstract bool @delete (); - public abstract GLib.AppInfo dup (); - public abstract bool equal (GLib.AppInfo appinfo2); - public static GLib.List get_all (); - public static GLib.List get_all_for_type (string content_type); - [Version (since = "2.20")] - public abstract unowned string get_commandline (); - public static GLib.AppInfo get_default_for_type (string content_type, bool must_support_uris); - public static GLib.AppInfo get_default_for_uri_scheme (string uri_scheme); - public abstract unowned string get_description (); - [Version (since = "2.24")] - public abstract unowned string get_display_name (); - public abstract unowned string get_executable (); - [Version (since = "2.28")] - public static GLib.List get_fallback_for_type (string content_type); - public abstract unowned GLib.Icon get_icon (); - public abstract unowned string get_id (); - public abstract unowned string get_name (); - [Version (since = "2.28")] - public static GLib.List get_recommended_for_type (string content_type); - [CCode (array_length = false, array_null_terminated = true)] - [Version (since = "2.34")] - public abstract unowned string[] get_supported_types (); - public abstract bool launch (GLib.List? files, GLib.AppLaunchContext? launch_context) throws GLib.Error; - public static bool launch_default_for_uri (string uri, GLib.AppLaunchContext? launch_context) throws GLib.Error; - public abstract bool launch_uris (GLib.List? uris, GLib.AppLaunchContext? launch_context) throws GLib.Error; - public abstract bool remove_supports_type (string content_type) throws GLib.Error; - [Version (since = "2.20")] - public static void reset_type_associations (string content_type); - public abstract bool set_as_default_for_extension (string extension) throws GLib.Error; - public abstract bool set_as_default_for_type (string content_type) throws GLib.Error; - public abstract bool set_as_last_used_for_type (string content_type) throws GLib.Error; - public abstract bool should_show (); - public abstract bool supports_files (); - public abstract bool supports_uris (); - } - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.22")] - public interface AsyncInitable : GLib.Object { - public virtual async bool init_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (finish_function = "g_async_initable_new_finish")] - public static async GLib.Object new_async (GLib.Type object_type, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable, ...) throws GLib.Error; - [CCode (finish_function = "g_async_initable_new_finish")] - public static async GLib.Object new_valist_async (GLib.Type object_type, string first_property_name, va_list var_args, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null); - [CCode (finish_function = "g_async_initable_new_finish")] - public static async GLib.Object newv_async (GLib.Type object_type, [CCode (array_length_pos = 1.1)] GLib.Parameter[] parameters, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_async_result_get_type ()")] - public interface AsyncResult : GLib.Object { - public abstract GLib.Object get_source_object (); - public abstract void* get_user_data (); - [Version (since = "2.34")] - public abstract bool is_tagged (void* source_tag); - [Version (since = "2.34")] - public bool legacy_propagate_error () throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_converter_get_type ()")] - [Version (since = "2.24")] - public interface Converter : GLib.Object { - public abstract GLib.ConverterResult convert ([CCode (array_length_cname = "inbuf_size", array_length_pos = 1.5, array_length_type = "gsize")] uint8[] inbuf, [CCode (array_length_cname = "outbuf_size", array_length_pos = 2.5, array_length_type = "gsize")] uint8[] outbuf, GLib.ConverterFlags flags, out size_t bytes_read, out size_t bytes_written) throws GLib.Error; - public abstract void reset (); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_interface_get_type ()")] - [Version (since = "2.30")] - public interface DBusInterface : GLib.Object { - [Version (since = "2.32")] - public abstract GLib.DBusObject dup_object (); - public abstract unowned GLib.DBusInterfaceInfo get_info (); - public abstract unowned GLib.DBusObject get_object (); - public abstract void set_object (GLib.DBusObject? object); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_object_get_type ()")] - public interface DBusObject : GLib.Object { - [Version (since = "2.30")] - public abstract GLib.DBusInterface get_interface (string interface_name); - [Version (since = "2.30")] - public abstract GLib.List get_interfaces (); - [Version (since = "2.30")] - public abstract unowned string get_object_path (); - [Version (since = "2.30")] - public virtual signal void interface_added (GLib.DBusInterface interface_); - [Version (since = "2.30")] - public virtual signal void interface_removed (GLib.DBusInterface interface_); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_dbus_object_manager_get_type ()")] - public interface DBusObjectManager : GLib.Object { - [Version (since = "2.30")] - public abstract GLib.DBusInterface get_interface (string object_path, string interface_name); - [Version (since = "2.30")] - public abstract GLib.DBusObject get_object (string object_path); - [Version (since = "2.30")] - public abstract unowned string get_object_path (); - [Version (since = "2.30")] - public abstract GLib.List get_objects (); - [Version (since = "2.30")] - public virtual signal void interface_added (GLib.DBusObject object, GLib.DBusInterface interface_); - [Version (since = "2.30")] - public virtual signal void interface_removed (GLib.DBusObject object, GLib.DBusInterface interface_); - [Version (since = "2.30")] - public virtual signal void object_added (GLib.DBusObject object); - [Version (since = "2.30")] - public virtual signal void object_removed (GLib.DBusObject object); - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GDatagramBasedInterface", type_id = "g_datagram_based_get_type ()")] - [Version (since = "2.48")] - public interface DatagramBased : GLib.Object { - public abstract GLib.IOCondition condition_check (GLib.IOCondition condition); - public abstract bool condition_wait (GLib.IOCondition condition, int64 timeout, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract GLib.Source create_source (GLib.IOCondition condition, GLib.Cancellable? cancellable = null); - public abstract int receive_messages ([CCode (array_length_cname = "num_messages", array_length_pos = 1.5, array_length_type = "guint")] GLib.InputMessage[] messages, int flags, int64 timeout, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract int send_messages ([CCode (array_length_cname = "num_messages", array_length_pos = 1.5, array_length_type = "guint")] GLib.OutputMessage[] messages, int flags, int64 timeout, GLib.Cancellable? cancellable = null) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_drive_get_type ()")] - public interface Drive : GLib.Object { - public abstract bool can_eject (); - public abstract bool can_poll_for_media (); - [Version (since = "2.22")] - public abstract bool can_start (); - [Version (since = "2.22")] - public abstract bool can_start_degraded (); - [Version (since = "2.22")] - public abstract bool can_stop (); - [Version (deprecated = true, deprecated_since = "2.22")] - public abstract async bool eject (GLib.MountUnmountFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public abstract async bool eject_with_operation (GLib.MountUnmountFlags flags, GLib.MountOperation? mount_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (array_length = false, array_null_terminated = true)] - public abstract string[] enumerate_identifiers (); - public abstract GLib.Icon get_icon (); - public abstract string get_identifier (string kind); - public abstract string get_name (); - [Version (since = "2.32")] - public virtual unowned string get_sort_key (); - [Version (since = "2.22")] - public abstract GLib.DriveStartStopType get_start_stop_type (); - [Version (since = "2.34")] - public abstract GLib.Icon get_symbolic_icon (); - public abstract GLib.List get_volumes (); - public abstract bool has_media (); - public abstract bool has_volumes (); - public abstract bool is_media_check_automatic (); - public abstract bool is_media_removable (); - public abstract async bool poll_for_media (GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public abstract async bool start (GLib.DriveStartFlags flags, GLib.MountOperation? mount_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public abstract async bool stop (GLib.MountUnmountFlags flags, GLib.MountOperation? mount_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual signal void changed (); - public virtual signal void disconnected (); - public virtual signal void eject_button (); - [Version (since = "2.22")] - public virtual signal void stop_button (); - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GDtlsClientConnectionInterface", type_id = "g_dtls_client_connection_get_type ()")] - [Version (since = "2.48")] - public interface DtlsClientConnection : GLib.DatagramBased, GLib.DtlsConnection, GLib.Object { - public GLib.List get_accepted_cas (); - public unowned GLib.SocketConnectable get_server_identity (); - public GLib.TlsCertificateFlags get_validation_flags (); - public static GLib.DtlsClientConnection @new (GLib.DatagramBased base_socket, GLib.SocketConnectable? server_identity) throws GLib.Error; - public void set_server_identity (GLib.SocketConnectable identity); - public void set_validation_flags (GLib.TlsCertificateFlags flags); - [ConcreteAccessor] - public abstract GLib.List accepted_cas { owned get; } - [ConcreteAccessor] - public abstract GLib.SocketConnectable server_identity { get; set construct; } - [ConcreteAccessor] - public abstract GLib.TlsCertificateFlags validation_flags { get; set construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GDtlsConnectionInterface", type_id = "g_dtls_connection_get_type ()")] - [Version (since = "2.48")] - public interface DtlsConnection : GLib.DatagramBased, GLib.Object { - public bool close (GLib.Cancellable? cancellable = null) throws GLib.Error; - public async bool close_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool emit_accept_certificate (GLib.TlsCertificate peer_cert, GLib.TlsCertificateFlags errors); - public unowned GLib.TlsCertificate get_certificate (); - public unowned GLib.TlsDatabase get_database (); - public unowned GLib.TlsInteraction get_interaction (); - public unowned GLib.TlsCertificate get_peer_certificate (); - public GLib.TlsCertificateFlags get_peer_certificate_errors (); - public GLib.TlsRehandshakeMode get_rehandshake_mode (); - public bool get_require_close_notify (); - public abstract bool handshake (GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract async bool handshake_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public void set_certificate (GLib.TlsCertificate certificate); - public void set_database (GLib.TlsDatabase database); - public void set_interaction (GLib.TlsInteraction? interaction); - public void set_rehandshake_mode (GLib.TlsRehandshakeMode mode); - public void set_require_close_notify (bool require_close_notify); - public abstract bool shutdown (bool shutdown_read, bool shutdown_write, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract async bool shutdown_async (bool shutdown_read, bool shutdown_write, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - [NoAccessorMethod] - public abstract GLib.DatagramBased base_socket { owned get; construct; } - [ConcreteAccessor] - public abstract GLib.TlsCertificate certificate { get; set; } - [ConcreteAccessor] - public abstract GLib.TlsDatabase database { get; set; } - [ConcreteAccessor] - public abstract GLib.TlsInteraction interaction { get; set; } - [ConcreteAccessor] - public abstract GLib.TlsCertificate peer_certificate { get; } - [ConcreteAccessor] - public abstract GLib.TlsCertificateFlags peer_certificate_errors { get; } - [ConcreteAccessor] - public abstract GLib.TlsRehandshakeMode rehandshake_mode { get; set construct; } - [ConcreteAccessor] - public abstract bool require_close_notify { get; set construct; } - public virtual signal bool accept_certificate (GLib.TlsCertificate peer_cert, GLib.TlsCertificateFlags errors); - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GDtlsServerConnectionInterface", type_id = "g_dtls_server_connection_get_type ()")] - [Version (since = "2.48")] - public interface DtlsServerConnection : GLib.DatagramBased, GLib.DtlsConnection, GLib.Object { - public static GLib.DtlsServerConnection @new (GLib.DatagramBased base_socket, GLib.TlsCertificate? certificate) throws GLib.Error; - [NoAccessorMethod] - public abstract GLib.TlsAuthenticationMode authentication_mode { get; set; } - } - [CCode (cheader_filename = "gio/gio.h")] - public interface File : GLib.Object { - public abstract GLib.FileOutputStream append_to (GLib.FileCreateFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.FileOutputStream append_to_async (GLib.FileCreateFlags flags, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract bool copy (GLib.File destination, GLib.FileCopyFlags flags, GLib.Cancellable? cancellable = null, GLib.FileProgressCallback? progress_callback = null) throws GLib.Error; - public virtual async bool copy_async (GLib.File destination, GLib.FileCopyFlags flags, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null, GLib.FileProgressCallback? progress_callback = null) throws GLib.Error; - public bool copy_attributes (GLib.File destination, GLib.FileCopyFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract GLib.FileOutputStream create (GLib.FileCreateFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.FileOutputStream create_async (GLib.FileCreateFlags flags, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public abstract GLib.FileIOStream create_readwrite (GLib.FileCreateFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public virtual async GLib.FileIOStream create_readwrite_async (GLib.FileCreateFlags flags, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (vfunc_name = "delete_file")] - public abstract bool @delete (GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (vfunc_name = "delete_file_async")] - [Version (since = "2.34")] - public virtual async bool delete_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract GLib.File dup (); - [Version (deprecated = true, deprecated_since = "2.22")] - public abstract async bool eject_mountable (GLib.MountUnmountFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public abstract async bool eject_mountable_with_operation (GLib.MountUnmountFlags flags, GLib.MountOperation? mount_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract GLib.FileEnumerator enumerate_children (string attributes, GLib.FileQueryInfoFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.FileEnumerator enumerate_children_async (string attributes, GLib.FileQueryInfoFlags flags, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract bool equal (GLib.File file2); - public abstract GLib.Mount find_enclosing_mount (GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.Mount find_enclosing_mount_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract string? get_basename (); - public GLib.File get_child (string name); - public abstract GLib.File get_child_for_display_name (string display_name) throws GLib.Error; - public abstract GLib.File? get_parent (); - public abstract string get_parse_name (); - public abstract string? get_path (); - public abstract string? get_relative_path (GLib.File descendant); - public abstract string get_uri (); - public abstract string get_uri_scheme (); - [Version (since = "2.24")] - public bool has_parent (GLib.File? parent); - [CCode (vfunc_name = "prefix_matches")] - public abstract bool has_prefix (GLib.File file); - public abstract bool has_uri_scheme (string uri_scheme); - public abstract uint hash (); - public abstract bool is_native (); - public bool load_contents (GLib.Cancellable? cancellable, [CCode (array_length_cname = "length", array_length_pos = 2.5, array_length_type = "gsize")] out uint8[] contents, out string etag_out) throws GLib.Error; - public async bool load_contents_async (GLib.Cancellable? cancellable = null, [CCode (array_length_cname = "length", array_length_pos = 2.5, array_length_type = "gsize")] out uint8[] contents, out string etag_out) throws GLib.Error; - public async bool load_partial_contents_async (GLib.Cancellable? cancellable = null, GLib.FileReadMoreCallback read_more_callback, [CCode (array_length_cname = "length", array_length_pos = 2.5, array_length_type = "gsize")] out uint8[] contents, out string etag_out) throws GLib.Error; - public abstract bool make_directory (GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.38")] - public virtual async bool make_directory_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.18")] - public bool make_directory_with_parents (GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract bool make_symbolic_link (string symlink_value, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.38")] - public virtual bool measure_disk_usage (GLib.FileMeasureFlags flags, GLib.Cancellable? cancellable, [CCode (delegate_target_pos = 3.5)] GLib.FileMeasureProgressCallback? progress_callback, out uint64 disk_usage, out uint64 num_dirs, out uint64 num_files) throws GLib.Error; - [Version (since = "2.38")] - public virtual async bool measure_disk_usage_async (GLib.FileMeasureFlags flags, int io_priority, GLib.Cancellable? cancellable, GLib.FileMeasureProgressCallback? progress_callback, out uint64 disk_usage, out uint64 num_dirs, out uint64 num_files) throws GLib.Error; - [Version (since = "2.18")] - public GLib.FileMonitor monitor (GLib.FileMonitorFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (vfunc_name = "monitor_dir")] - public abstract GLib.FileMonitor monitor_directory (GLib.FileMonitorFlags flags, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public abstract GLib.FileMonitor monitor_file (GLib.FileMonitorFlags flags, GLib.Cancellable? cancellable = null) throws GLib.IOError; - public abstract async bool mount_enclosing_volume (GLib.MountMountFlags flags, GLib.MountOperation? mount_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract async GLib.File mount_mountable (GLib.MountMountFlags flags, GLib.MountOperation? mount_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract bool move (GLib.File destination, GLib.FileCopyFlags flags, GLib.Cancellable? cancellable = null, GLib.FileProgressCallback? progress_callback = null) throws GLib.Error; - public static GLib.File new_for_commandline_arg (string arg); - [Version (since = "2.36")] - public static GLib.File new_for_commandline_arg_and_cwd (string arg, string cwd); - public static GLib.File new_for_path (string path); - public static GLib.File new_for_uri (string uri); - [Version (since = "2.32")] - public static GLib.File new_tmp (string? tmpl, out GLib.FileIOStream iostream) throws GLib.Error; - [Version (since = "2.22")] - public abstract GLib.FileIOStream open_readwrite (GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public virtual async GLib.FileIOStream open_readwrite_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public static GLib.File parse_name (string parse_name); - [Version (since = "2.22")] - public abstract async bool poll_mountable (GLib.Cancellable? cancellable = null) throws GLib.Error; - [NoWrapper] - [Version (deprecated_since = "vala-0.16", replacement = "has_prefix")] - public abstract bool prefix_matches (GLib.File file); - public GLib.AppInfo query_default_handler (GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool query_exists (GLib.Cancellable? cancellable = null); - [Version (since = "2.18")] - public GLib.FileType query_file_type (GLib.FileQueryInfoFlags flags, GLib.Cancellable? cancellable = null); - public abstract GLib.FileInfo query_filesystem_info (string attributes, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.FileInfo query_filesystem_info_async (string attributes, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract GLib.FileInfo query_info (string attributes, GLib.FileQueryInfoFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.FileInfo query_info_async (string attributes, GLib.FileQueryInfoFlags flags, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract GLib.FileAttributeInfoList query_settable_attributes (GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract GLib.FileAttributeInfoList query_writable_namespaces (GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (vfunc_name = "read_fn")] - public abstract GLib.FileInputStream read (GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.FileInputStream read_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - [NoWrapper] - [Version (deprecated_since = "vala-0.16", replacement = "read")] - public abstract unowned GLib.FileInputStream read_fn (GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract GLib.FileOutputStream replace (string? etag, bool make_backup, GLib.FileCreateFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.FileOutputStream replace_async (string? etag, bool make_backup, GLib.FileCreateFlags flags, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool replace_contents ([CCode (array_length_cname = "length", array_length_pos = 1.5, array_length_type = "gsize")] uint8[] contents, string? etag, bool make_backup, GLib.FileCreateFlags flags, out string new_etag, GLib.Cancellable? cancellable = null) throws GLib.Error; - public async bool replace_contents_async ([CCode (array_length_cname = "length", array_length_pos = 1.5, array_length_type = "gsize")] uint8[] contents, string? etag, bool make_backup, GLib.FileCreateFlags flags, GLib.Cancellable? cancellable = null, out string new_etag) throws GLib.Error; - [Version (since = "2.40")] - public async void replace_contents_bytes_async (GLib.Bytes contents, string? etag, bool make_backup, GLib.FileCreateFlags flags, GLib.Cancellable? cancellable = null); - [Version (since = "2.22")] - public abstract GLib.FileIOStream replace_readwrite (string? etag, bool make_backup, GLib.FileCreateFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public virtual async GLib.FileIOStream replace_readwrite_async (string? etag, bool make_backup, GLib.FileCreateFlags flags, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract GLib.File resolve_relative_path (string relative_path); - public abstract bool set_attribute (string attribute, GLib.FileAttributeType type, void* value_p, GLib.FileQueryInfoFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool set_attribute_byte_string (string attribute, string value, GLib.FileQueryInfoFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool set_attribute_int32 (string attribute, int32 value, GLib.FileQueryInfoFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool set_attribute_int64 (string attribute, int64 value, GLib.FileQueryInfoFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool set_attribute_string (string attribute, string value, GLib.FileQueryInfoFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool set_attribute_uint32 (string attribute, uint32 value, GLib.FileQueryInfoFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public bool set_attribute_uint64 (string attribute, uint64 value, GLib.FileQueryInfoFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async bool set_attributes_async (GLib.FileInfo info, GLib.FileQueryInfoFlags flags, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null, out GLib.FileInfo info_out) throws GLib.Error; - public abstract bool set_attributes_from_info (GLib.FileInfo info, GLib.FileQueryInfoFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract GLib.File set_display_name (string display_name, GLib.Cancellable? cancellable = null) throws GLib.Error; - public virtual async GLib.File set_display_name_async (string display_name, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public abstract async bool start_mountable (GLib.DriveStartFlags flags, GLib.MountOperation? start_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public abstract async bool stop_mountable (GLib.MountUnmountFlags flags, GLib.MountOperation? mount_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public bool supports_thread_contexts (); - public abstract bool trash (GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.38")] - public virtual async bool trash_async (int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (deprecated = true, deprecated_since = "2.22")] - public abstract async bool unmount_mountable (GLib.MountUnmountFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public abstract async bool unmount_mountable_with_operation (GLib.MountUnmountFlags flags, GLib.MountOperation? mount_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h")] - public interface Icon : GLib.Object { - [Version (since = "2.38")] - public static GLib.Icon deserialize (GLib.Variant value); - public abstract bool equal (GLib.Icon? icon2); - [NoWrapper] - public virtual GLib.Icon? from_tokens (string[] tokens, int version) throws GLib.Error; - public abstract uint hash (); - [Version (since = "2.20")] - public static GLib.Icon? new_for_string (string str) throws GLib.Error; - [Version (since = "2.38")] - public virtual GLib.Variant serialize (); - [Version (since = "2.20")] - public string? to_string (); - [NoWrapper] - public virtual bool to_tokens (GLib.GenericArray tokens, out int out_version); - } - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.22")] - public interface Initable : GLib.Object { - public abstract bool init (GLib.Cancellable? cancellable = null) throws GLib.Error; - public static GLib.Object @new (GLib.Type object_type, GLib.Cancellable? cancellable = null, ...) throws GLib.Error; - public static GLib.Object new_valist (GLib.Type object_type, string first_property_name, va_list var_args, GLib.Cancellable? cancellable = null) throws GLib.Error; - public static GLib.Object newv (GLib.Type object_type, [CCode (array_length_cname = "n_parameters", array_length_pos = 1.5, array_length_type = "guint")] GLib.Parameter[] parameters, GLib.Cancellable? cancellable = null) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GListModelInterface", type_id = "g_list_model_get_type ()")] - public interface ListModel : GLib.Object { - [Version (since = "2.44")] - public abstract GLib.Object? get_item (uint position); - [Version (since = "2.44")] - public abstract GLib.Type get_item_type (); - [Version (since = "2.44")] - public abstract uint get_n_items (); - [Version (since = "2.44")] - public GLib.Object? get_object (uint position); - [HasEmitter] - [Version (since = "2.44")] - public signal void items_changed (uint position, uint removed, uint added); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_loadable_icon_get_type ()")] - public interface LoadableIcon : GLib.Icon, GLib.Object { - public abstract GLib.InputStream load (int size, out string? type, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract async GLib.InputStream load_async (int size, GLib.Cancellable? cancellable = null, out string? type = null) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_mount_get_type ()")] - public interface Mount : GLib.Object { - public abstract bool can_eject (); - public abstract bool can_unmount (); - [Version (deprecated = true, deprecated_since = "2.22")] - public abstract async bool eject (GLib.MountUnmountFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public abstract async bool eject_with_operation (GLib.MountUnmountFlags flags, GLib.MountOperation? mount_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract GLib.File get_default_location (); - public abstract GLib.Drive get_drive (); - public abstract GLib.Icon get_icon (); - public abstract string get_name (); - public abstract GLib.File get_root (); - [Version (since = "2.32")] - public virtual unowned string get_sort_key (); - [Version (since = "2.34")] - public abstract GLib.Icon get_symbolic_icon (); - public abstract string get_uuid (); - public abstract GLib.Volume get_volume (); - [CCode (array_length = false, array_null_terminated = true)] - [Version (since = "2.18")] - public abstract async string[] guess_content_type (bool force_rescan, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (array_length = false, array_null_terminated = true)] - [Version (since = "2.18")] - public abstract string[] guess_content_type_sync (bool force_rescan, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.20")] - public bool is_shadowed (); - public abstract async bool remount (GLib.MountMountFlags flags, GLib.MountOperation? mount_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.20")] - public void shadow (); - [Version (deprecated = true, deprecated_since = "2.22")] - public abstract async bool unmount (GLib.MountUnmountFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public abstract async bool unmount_with_operation (GLib.MountUnmountFlags flags, GLib.MountOperation? mount_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.20")] - public void unshadow (); - public virtual signal void changed (); - [Version (since = "2.22")] - public virtual signal void pre_unmount (); - public virtual signal void unmounted (); - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GNetworkMonitorInterface", type_id = "g_network_monitor_get_type ()")] - [Version (since = "2.32")] - public interface NetworkMonitor : GLib.Initable, GLib.Object { - public abstract bool can_reach (GLib.SocketConnectable connectable, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract async bool can_reach_async (GLib.SocketConnectable connectable, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.44")] - public GLib.NetworkConnectivity get_connectivity (); - public static unowned GLib.NetworkMonitor get_default (); - public bool get_network_available (); - [Version (since = "2.46")] - public bool get_network_metered (); - [ConcreteAccessor] - [Version (since = "2.44")] - public abstract GLib.NetworkConnectivity connectivity { get; } - [ConcreteAccessor] - public abstract bool network_available { get; } - [ConcreteAccessor] - [Version (since = "2.46")] - public abstract bool network_metered { get; } - public virtual signal void network_changed (bool available); - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GPollableInputStreamInterface", type_id = "g_pollable_input_stream_get_type ()")] - [Version (since = "2.28")] - public interface PollableInputStream : GLib.InputStream { - public abstract bool can_poll (); - public abstract GLib.PollableSource create_source (GLib.Cancellable? cancellable = null); - public abstract bool is_readable (); - public ssize_t read_nonblocking ([CCode (array_length_cname = "count", array_length_pos = 1.5, array_length_type = "gsize")] uint8[] buffer, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (vfunc_name = "read_nonblocking")] - public abstract ssize_t read_nonblocking_fn ([CCode (array_length_cname = "count", array_length_pos = 1.1, array_length_type = "gsize")] uint8[] buffer) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GPollableOutputStreamInterface", type_id = "g_pollable_output_stream_get_type ()")] - [Version (since = "2.28")] - public interface PollableOutputStream : GLib.OutputStream { - public abstract bool can_poll (); - public abstract GLib.PollableSource create_source (GLib.Cancellable? cancellable = null); - public abstract bool is_writable (); - public abstract ssize_t write_nonblocking ([CCode (array_length_cname = "count", array_length_pos = 1.1, array_length_type = "gsize")] uint8[]? buffer) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GProxyInterface", type_id = "g_proxy_get_type ()")] - [Version (since = "2.26")] - public interface Proxy : GLib.Object { - public abstract GLib.IOStream connect (GLib.IOStream connection, GLib.ProxyAddress proxy_address, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract async GLib.IOStream connect_async (GLib.IOStream connection, GLib.ProxyAddress proxy_address, GLib.Cancellable? cancellable = null) throws GLib.Error; - public static GLib.Proxy get_default_for_protocol (string protocol); - public abstract bool supports_hostname (); - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GProxyResolverInterface", type_id = "g_proxy_resolver_get_type ()")] - [Version (since = "2.26")] - public interface ProxyResolver : GLib.Object { - public static unowned GLib.ProxyResolver get_default (); - public abstract bool is_supported (); - [CCode (array_length = false, array_null_terminated = true)] - public abstract string[] lookup (string uri, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (array_length = false, array_null_terminated = true)] - public abstract async string[] lookup_async (string uri, GLib.Cancellable? cancellable = null) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GRemoteActionGroupInterface", type_id = "g_remote_action_group_get_type ()")] - public interface RemoteActionGroup : GLib.ActionGroup, GLib.Object { - [Version (since = "2.32")] - public abstract void activate_action_full (string action_name, GLib.Variant? parameter, GLib.Variant platform_data); - [Version (since = "2.32")] - public abstract void change_action_state_full (string action_name, GLib.Variant value, GLib.Variant platform_data); - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_seekable_get_type ()")] - public interface Seekable : GLib.Object { - public abstract bool can_seek (); - public abstract bool can_truncate (); - public abstract bool seek (int64 offset, GLib.SeekType type, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract int64 tell (); - [CCode (vfunc_name = "truncate_fn")] - public abstract bool truncate (int64 offset, GLib.Cancellable? cancellable = null) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_socket_connectable_get_type ()")] - public interface SocketConnectable : GLib.Object { - [Version (since = "2.22")] - public abstract GLib.SocketAddressEnumerator enumerate (); - [Version (since = "2.26")] - public abstract GLib.SocketAddressEnumerator proxy_enumerate (); - [Version (since = "2.48")] - public abstract string to_string (); - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GTlsBackendInterface", type_id = "g_tls_backend_get_type ()")] - [Version (since = "2.28")] - public interface TlsBackend : GLib.Object { - public abstract GLib.Type get_certificate_type (); - public abstract GLib.Type get_client_connection_type (); - public static unowned GLib.TlsBackend get_default (); - [Version (since = "2.30")] - public abstract GLib.TlsDatabase get_default_database (); - [Version (since = "2.48")] - public GLib.Type get_dtls_client_connection_type (); - [Version (since = "2.48")] - public GLib.Type get_dtls_server_connection_type (); - [Version (since = "2.30")] - public abstract GLib.Type get_file_database_type (); - public abstract GLib.Type get_server_connection_type (); - [Version (since = "2.48")] - public abstract bool supports_dtls (); - public abstract bool supports_tls (); - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GTlsClientConnectionInterface", type_id = "g_tls_client_connection_get_type ()")] - [Version (since = "2.28")] - public interface TlsClientConnection : GLib.TlsConnection { - [Version (since = "2.46")] - public abstract void copy_session_state (GLib.TlsClientConnection source); - public GLib.List get_accepted_cas (); - public unowned GLib.SocketConnectable get_server_identity (); - public bool get_use_ssl3 (); - public GLib.TlsCertificateFlags get_validation_flags (); - public static GLib.TlsClientConnection? @new (GLib.IOStream base_io_stream, GLib.SocketConnectable? server_identity) throws GLib.Error; - public void set_server_identity (GLib.SocketConnectable identity); - public void set_use_ssl3 (bool use_ssl3); - public void set_validation_flags (GLib.TlsCertificateFlags flags); - [ConcreteAccessor] - public abstract GLib.List accepted_cas { owned get; } - [ConcreteAccessor] - public abstract GLib.SocketConnectable server_identity { get; set construct; } - [ConcreteAccessor] - public abstract bool use_ssl3 { get; set construct; } - [ConcreteAccessor] - public abstract GLib.TlsCertificateFlags validation_flags { get; set construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GTlsFileDatabaseInterface", type_id = "g_tls_file_database_get_type ()")] - [Version (since = "2.30")] - public interface TlsFileDatabase : GLib.TlsDatabase { - public static GLib.TlsFileDatabase? @new (string anchors) throws GLib.Error; - [NoAccessorMethod] - public abstract string anchors { owned get; set construct; } - } - [CCode (cheader_filename = "gio/gio.h", type_cname = "GTlsServerConnectionInterface", type_id = "g_tls_server_connection_get_type ()")] - [Version (since = "2.28")] - public interface TlsServerConnection : GLib.TlsConnection { - public static GLib.TlsServerConnection? @new (GLib.IOStream base_io_stream, GLib.TlsCertificate? certificate) throws GLib.Error; - [NoAccessorMethod] - public abstract GLib.TlsAuthenticationMode authentication_mode { get; set; } - } - [CCode (cheader_filename = "gio/gio.h", type_id = "g_volume_get_type ()")] - public interface Volume : GLib.Object { - public abstract bool can_eject (); - public abstract bool can_mount (); - [Version (deprecated = true, deprecated_since = "2.22")] - public abstract async bool eject (GLib.MountUnmountFlags flags, GLib.Cancellable? cancellable = null) throws GLib.Error; - [Version (since = "2.22")] - public abstract async bool eject_with_operation (GLib.MountUnmountFlags flags, GLib.MountOperation? mount_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (array_length = false, array_null_terminated = true)] - public abstract string[] enumerate_identifiers (); - [Version (since = "2.18")] - public abstract GLib.File? get_activation_root (); - public abstract GLib.Drive get_drive (); - public abstract GLib.Icon get_icon (); - public abstract string get_identifier (string kind); - public abstract GLib.Mount get_mount (); - public abstract string get_name (); - [Version (since = "2.32")] - public virtual unowned string get_sort_key (); - [Version (since = "2.34")] - public abstract GLib.Icon get_symbolic_icon (); - public abstract string get_uuid (); - [CCode (vfunc_name = "mount_fn")] - public abstract async bool mount (GLib.MountMountFlags flags, GLib.MountOperation? mount_operation, GLib.Cancellable? cancellable = null) throws GLib.Error; - public abstract bool should_automount (); - public virtual signal void changed (); - public virtual signal void removed (); - } - [CCode (cheader_filename = "gio/gio.h")] - public struct ActionEntry { - public weak string name; - [Version (deprecated = true, deprecated_since = "vala-0.26", replacement = "activate_callback")] - public GLib.SimpleActionActivateCallback? activate; - public weak string parameter_type; - public weak string state; - [Version (deprecated_since = "vala-0.26", replacement = "change_state_callback")] - public GLib.SimpleActionChangeStateCallback? change_state; - [CCode (cname = "activate")] - public GLib.SimpleActionActivateFunc activate_callback; - [CCode (cname = "change_state")] - public GLib.SimpleActionChangeStateFunc? change_state_callback; - } - [CCode (cheader_filename = "gio/gio.h", has_type_id = false)] - [Version (since = "2.26")] - public struct DBusErrorEntry { - public int error_code; - public weak string dbus_error_name; - } - [CCode (cheader_filename = "gio/gio.h", has_type_id = false)] - [Version (since = "2.26")] - public struct DBusInterfaceVTable { - public weak GLib.DBusInterfaceMethodCallFunc method_call; - public weak GLib.DBusInterfaceGetPropertyFunc get_property; - public weak GLib.DBusInterfaceSetPropertyFunc set_property; - } - [CCode (cheader_filename = "gio/gio.h", has_type_id = false)] - [Version (since = "2.26")] - public struct DBusSubtreeVTable { - public weak GLib.DBusSubtreeEnumerateFunc enumerate; - public weak GLib.DBusSubtreeIntrospectFunc introspect; - public weak GLib.DBusSubtreeDispatchFunc dispatch; - } - [CCode (cheader_filename = "gio/gio.h", has_type_id = false)] - public struct FileAttributeInfo { - public weak string name; - public GLib.FileAttributeType type; - public GLib.FileAttributeInfoFlags flags; - } - [CCode (cheader_filename = "gio/gio.h", has_type_id = false)] - [Version (since = "2.48")] - public struct InputMessage { - public weak GLib.SocketAddress address; - [CCode (array_length = false, array_null_terminated = true)] - public weak GLib.InputVector[] vectors; - public uint num_vectors; - public size_t bytes_received; - public int flags; - [CCode (array_length = false, array_null_terminated = true)] - public weak GLib.SocketControlMessage[] control_messages; - public uint num_control_messages; - } - [CCode (cheader_filename = "gio/gio.h", has_type_id = false)] - [Version (since = "2.22")] - public struct InputVector { - public void* buffer; - public size_t size; - } - [CCode (cheader_filename = "gio/gio.h", has_type_id = false)] - [Version (since = "2.44")] - public struct OutputMessage { - public weak GLib.SocketAddress address; - public GLib.OutputVector vectors; - public uint num_vectors; - public uint bytes_sent; - [CCode (array_length = false, array_null_terminated = true)] - public weak GLib.SocketControlMessage[] control_messages; - public uint num_control_messages; - } - [CCode (cheader_filename = "gio/gio.h", has_type_id = false)] - [Version (since = "2.22")] - public struct OutputVector { - public void* buffer; - public size_t size; - } - [CCode (cheader_filename = "gio/gio.h", has_type_id = false)] - public struct StaticResource { - [Version (since = "2.32")] - public void fini (); - [Version (since = "2.32")] - public unowned GLib.Resource get_resource (); - [Version (since = "2.32")] - public void init (); - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_APP_INFO_CREATE_", type_id = "g_app_info_create_flags_get_type ()")] - [Flags] - public enum AppInfoCreateFlags { - NONE, - NEEDS_TERMINAL, - SUPPORTS_URIS, - SUPPORTS_STARTUP_NOTIFICATION - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_APPLICATION_", type_id = "g_application_flags_get_type ()")] - [Flags] - [Version (since = "2.28")] - public enum ApplicationFlags { - FLAGS_NONE, - IS_SERVICE, - IS_LAUNCHER, - HANDLES_OPEN, - HANDLES_COMMAND_LINE, - SEND_ENVIRONMENT, - NON_UNIQUE, - CAN_OVERRIDE_APP_ID - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_ASK_PASSWORD_", type_id = "g_ask_password_flags_get_type ()")] - [Flags] - public enum AskPasswordFlags { - NEED_PASSWORD, - NEED_USERNAME, - NEED_DOMAIN, - SAVING_SUPPORTED, - ANONYMOUS_SUPPORTED - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_BUS_NAME_OWNER_FLAGS_", type_id = "g_bus_name_owner_flags_get_type ()")] - [Flags] - [Version (since = "2.26")] - public enum BusNameOwnerFlags { - NONE, - ALLOW_REPLACEMENT, - REPLACE - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_BUS_NAME_WATCHER_FLAGS_", type_id = "g_bus_name_watcher_flags_get_type ()")] - [Flags] - [Version (since = "2.26")] - public enum BusNameWatcherFlags { - NONE, - AUTO_START - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_BUS_TYPE_", type_id = "g_bus_type_get_type ()")] - [Version (since = "2.26")] - public enum BusType { - STARTER, - NONE, - SYSTEM, - SESSION; - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_address_get_for_bus_sync")] - public static string get_address_sync (GLib.BusType bus_type, GLib.Cancellable? cancellable = null) throws GLib.Error; - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_CONVERTER_")] - [Flags] - [Version (since = "2.24")] - public enum ConverterFlags { - [Version (deprecated_since = "vala-0.16", replacement = "ConverterFlags.NONE")] - NO_FLAGS, - [CCode (cname = "G_CONVERTER_NO_FLAGS")] - NONE, - INPUT_AT_END, - FLUSH - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_CONVERTER_", type_id = "g_converter_result_get_type ()")] - [Version (since = "2.24")] - public enum ConverterResult { - ERROR, - CONVERTED, - FINISHED, - FLUSHED - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_CREDENTIALS_TYPE_", type_id = "g_credentials_type_get_type ()")] - [Version (since = "2.26")] - public enum CredentialsType { - INVALID, - LINUX_UCRED, - FREEBSD_CMSGCRED, - OPENBSD_SOCKPEERCRED, - SOLARIS_UCRED, - NETBSD_UNPCBID - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_CALL_FLAGS_", type_id = "g_dbus_call_flags_get_type ()")] - [Flags] - [Version (since = "2.26")] - public enum DBusCallFlags { - NONE, - NO_AUTO_START, - ALLOW_INTERACTIVE_AUTHORIZATION - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_CAPABILITY_FLAGS_", type_id = "g_dbus_capability_flags_get_type ()")] - [Flags] - [Version (since = "2.26")] - public enum DBusCapabilityFlags { - NONE, - UNIX_FD_PASSING - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_CONNECTION_FLAGS_", type_id = "g_dbus_connection_flags_get_type ()")] - [Flags] - [Version (since = "2.26")] - public enum DBusConnectionFlags { - NONE, - AUTHENTICATION_CLIENT, - AUTHENTICATION_SERVER, - AUTHENTICATION_ALLOW_ANONYMOUS, - MESSAGE_BUS_CONNECTION, - DELAY_MESSAGE_PROCESSING - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_INTERFACE_SKELETON_FLAGS_", type_id = "g_dbus_interface_skeleton_flags_get_type ()")] - [Flags] - [Version (since = "2.30")] - public enum DBusInterfaceSkeletonFlags { - NONE, - HANDLE_METHOD_INVOCATIONS_IN_THREAD - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_MESSAGE_BYTE_ORDER_", type_id = "g_dbus_message_byte_order_get_type ()")] - [Version (since = "2.26")] - public enum DBusMessageByteOrder { - BIG_ENDIAN, - LITTLE_ENDIAN - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_MESSAGE_FLAGS_", type_id = "g_dbus_message_flags_get_type ()")] - [Flags] - [Version (since = "2.26")] - public enum DBusMessageFlags { - NONE, - NO_REPLY_EXPECTED, - NO_AUTO_START, - ALLOW_INTERACTIVE_AUTHORIZATION - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_MESSAGE_HEADER_FIELD_", type_id = "g_dbus_message_header_field_get_type ()")] - [Version (since = "2.26")] - public enum DBusMessageHeaderField { - INVALID, - PATH, - INTERFACE, - MEMBER, - ERROR_NAME, - REPLY_SERIAL, - DESTINATION, - SENDER, - SIGNATURE, - NUM_UNIX_FDS - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_MESSAGE_TYPE_", type_id = "g_dbus_message_type_get_type ()")] - [Version (since = "2.26")] - public enum DBusMessageType { - INVALID, - METHOD_CALL, - METHOD_RETURN, - ERROR, - SIGNAL - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_", type_id = "g_dbus_object_manager_client_flags_get_type ()")] - [Flags] - [Version (since = "2.30")] - public enum DBusObjectManagerClientFlags { - NONE, - DO_NOT_AUTO_START - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_PROPERTY_INFO_FLAGS_", type_id = "g_dbus_property_info_flags_get_type ()")] - [Flags] - [Version (since = "2.26")] - public enum DBusPropertyInfoFlags { - NONE, - READABLE, - WRITABLE - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_PROXY_FLAGS_", type_id = "g_dbus_proxy_flags_get_type ()")] - [Flags] - [Version (since = "2.26")] - public enum DBusProxyFlags { - NONE, - DO_NOT_LOAD_PROPERTIES, - DO_NOT_CONNECT_SIGNALS, - DO_NOT_AUTO_START, - GET_INVALIDATED_PROPERTIES, - DO_NOT_AUTO_START_AT_CONSTRUCTION - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_SEND_MESSAGE_FLAGS_", type_id = "g_dbus_send_message_flags_get_type ()")] - [Flags] - [Version (since = "2.26")] - public enum DBusSendMessageFlags { - NONE, - PRESERVE_SERIAL - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_SERVER_FLAGS_", type_id = "g_dbus_server_flags_get_type ()")] - [Flags] - [Version (since = "2.26")] - public enum DBusServerFlags { - NONE, - RUN_IN_THREAD, - AUTHENTICATION_ALLOW_ANONYMOUS - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_SIGNAL_FLAGS_", type_id = "g_dbus_signal_flags_get_type ()")] - [Flags] - [Version (since = "2.26")] - public enum DBusSignalFlags { - NONE, - NO_MATCH_RULE, - MATCH_ARG0_NAMESPACE, - MATCH_ARG0_PATH - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_SUBTREE_FLAGS_", type_id = "g_dbus_subtree_flags_get_type ()")] - [Flags] - [Version (since = "2.26")] - public enum DBusSubtreeFlags { - NONE, - DISPATCH_TO_UNENUMERATED_NODES - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DATA_STREAM_BYTE_ORDER_", type_id = "g_data_stream_byte_order_get_type ()")] - public enum DataStreamByteOrder { - BIG_ENDIAN, - LITTLE_ENDIAN, - HOST_ENDIAN - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DATA_STREAM_NEWLINE_TYPE_", type_id = "g_data_stream_newline_type_get_type ()")] - public enum DataStreamNewlineType { - LF, - CR, - CR_LF, - ANY - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DRIVE_START_", type_id = "g_drive_start_flags_get_type ()")] - [Flags] - [Version (since = "2.22")] - public enum DriveStartFlags { - NONE - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DRIVE_START_STOP_TYPE_", type_id = "g_drive_start_stop_type_get_type ()")] - [Version (since = "2.22")] - public enum DriveStartStopType { - UNKNOWN, - SHUTDOWN, - NETWORK, - MULTIDISK, - PASSWORD - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_EMBLEM_ORIGIN_", type_id = "g_emblem_origin_get_type ()")] - [Version (since = "2.18")] - public enum EmblemOrigin { - UNKNOWN, - DEVICE, - LIVEMETADATA, - TAG - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_FILE_ATTRIBUTE_INFO_", type_id = "g_file_attribute_info_flags_get_type ()")] - [Flags] - public enum FileAttributeInfoFlags { - NONE, - COPY_WITH_FILE, - COPY_WHEN_MOVED - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_FILE_ATTRIBUTE_STATUS_", type_id = "g_file_attribute_status_get_type ()")] - public enum FileAttributeStatus { - UNSET, - SET, - ERROR_SETTING - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_FILE_ATTRIBUTE_TYPE_", type_id = "g_file_attribute_type_get_type ()")] - public enum FileAttributeType { - INVALID, - STRING, - BYTE_STRING, - BOOLEAN, - UINT32, - INT32, - UINT64, - INT64, - OBJECT, - STRINGV - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_FILE_COPY_", type_id = "g_file_copy_flags_get_type ()")] - [Flags] - public enum FileCopyFlags { - NONE, - OVERWRITE, - BACKUP, - NOFOLLOW_SYMLINKS, - ALL_METADATA, - NO_FALLBACK_FOR_MOVE, - TARGET_DEFAULT_PERMS - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_FILE_CREATE_", type_id = "g_file_create_flags_get_type ()")] - [Flags] - public enum FileCreateFlags { - NONE, - PRIVATE, - REPLACE_DESTINATION - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_FILE_MEASURE_", type_id = "g_file_measure_flags_get_type ()")] - [Flags] - [Version (since = "2.38")] - public enum FileMeasureFlags { - NONE, - REPORT_ANY_ERROR, - APPARENT_SIZE, - NO_XDEV - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_FILE_MONITOR_EVENT_", type_id = "g_file_monitor_event_get_type ()")] - public enum FileMonitorEvent { - CHANGED, - CHANGES_DONE_HINT, - DELETED, - CREATED, - ATTRIBUTE_CHANGED, - PRE_UNMOUNT, - UNMOUNTED, - MOVED, - RENAMED, - MOVED_IN, - MOVED_OUT - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_FILE_MONITOR_", type_id = "g_file_monitor_flags_get_type ()")] - [Flags] - public enum FileMonitorFlags { - NONE, - WATCH_MOUNTS, - SEND_MOVED, - WATCH_HARD_LINKS, - WATCH_MOVES - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_FILE_QUERY_INFO_", type_id = "g_file_query_info_flags_get_type ()")] - [Flags] - public enum FileQueryInfoFlags { - NONE, - NOFOLLOW_SYMLINKS - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_FILE_TYPE_", type_id = "g_file_type_get_type ()")] - public enum FileType { - UNKNOWN, - REGULAR, - DIRECTORY, - SYMBOLIC_LINK, - SPECIAL, - SHORTCUT, - MOUNTABLE - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_FILESYSTEM_PREVIEW_TYPE_", type_id = "g_filesystem_preview_type_get_type ()")] - public enum FilesystemPreviewType { - IF_ALWAYS, - IF_LOCAL, - NEVER - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_IO_MODULE_SCOPE_", type_id = "g_io_module_scope_flags_get_type ()")] - [Version (since = "2.30")] - public enum IOModuleScopeFlags { - NONE, - BLOCK_DUPLICATES - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_IO_STREAM_SPLICE_", type_id = "g_io_stream_splice_flags_get_type ()")] - [Flags] - [Version (since = "2.28")] - public enum IOStreamSpliceFlags { - NONE, - CLOSE_STREAM1, - CLOSE_STREAM2, - WAIT_FOR_BOTH - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_MOUNT_MOUNT_", type_id = "g_mount_mount_flags_get_type ()")] - [Flags] - public enum MountMountFlags { - NONE - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_MOUNT_OPERATION_", type_id = "g_mount_operation_result_get_type ()")] - public enum MountOperationResult { - HANDLED, - ABORTED, - UNHANDLED - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_MOUNT_UNMOUNT_", type_id = "g_mount_unmount_flags_get_type ()")] - [Flags] - public enum MountUnmountFlags { - NONE, - FORCE - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_NETWORK_CONNECTIVITY_", type_id = "g_network_connectivity_get_type ()")] - [Version (since = "2.44")] - public enum NetworkConnectivity { - LOCAL, - LIMITED, - PORTAL, - FULL - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_NOTIFICATION_PRIORITY_", type_id = "g_notification_priority_get_type ()")] - [Version (since = "2.42")] - public enum NotificationPriority { - NORMAL, - LOW, - HIGH, - URGENT - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_OUTPUT_STREAM_SPLICE_", type_id = "g_output_stream_splice_flags_get_type ()")] - [Flags] - public enum OutputStreamSpliceFlags { - NONE, - CLOSE_SOURCE, - CLOSE_TARGET - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_PASSWORD_SAVE_", type_id = "g_password_save_get_type ()")] - public enum PasswordSave { - NEVER, - FOR_SESSION, - PERMANENTLY - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_RESOLVER_RECORD_", type_id = "g_resolver_record_type_get_type ()")] - [Version (since = "2.34")] - public enum ResolverRecordType { - SRV, - MX, - TXT, - SOA, - NS - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_RESOURCE_FLAGS_", type_id = "g_resource_flags_get_type ()")] - [Flags] - [Version (since = "2.32")] - public enum ResourceFlags { - NONE, - COMPRESSED - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_RESOURCE_LOOKUP_FLAGS_", type_id = "g_resource_lookup_flags_get_type ()")] - [Flags] - [Version (since = "2.32")] - public enum ResourceLookupFlags { - NONE - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_SETTINGS_BIND_", type_id = "g_settings_bind_flags_get_type ()")] - [Flags] - public enum SettingsBindFlags { - DEFAULT, - GET, - SET, - NO_SENSITIVITY, - GET_NO_CHANGES, - INVERT_BOOLEAN - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_SOCKET_CLIENT_", type_id = "g_socket_client_event_get_type ()")] - [Version (since = "2.32")] - public enum SocketClientEvent { - RESOLVING, - RESOLVED, - CONNECTING, - CONNECTED, - PROXY_NEGOTIATING, - PROXY_NEGOTIATED, - TLS_HANDSHAKING, - TLS_HANDSHAKED, - COMPLETE - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_SOCKET_FAMILY_", type_id = "g_socket_family_get_type ()")] - [Version (since = "2.22")] - public enum SocketFamily { - INVALID, - UNIX, - IPV4, - IPV6 - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_SOCKET_LISTENER_", type_id = "g_socket_listener_event_get_type ()")] - [Version (since = "2.46")] - public enum SocketListenerEvent { - BINDING, - BOUND, - LISTENING, - LISTENED - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_SOCKET_MSG_", type_id = "g_socket_msg_flags_get_type ()")] - [Flags] - [Version (since = "2.22")] - public enum SocketMsgFlags { - NONE, - OOB, - PEEK, - DONTROUTE - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_SOCKET_PROTOCOL_", type_id = "g_socket_protocol_get_type ()")] - [Version (since = "2.22")] - public enum SocketProtocol { - UNKNOWN, - DEFAULT, - TCP, - UDP, - SCTP - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_SOCKET_TYPE_", type_id = "g_socket_type_get_type ()")] - [Version (since = "2.22")] - public enum SocketType { - INVALID, - STREAM, - DATAGRAM, - SEQPACKET - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_SUBPROCESS_FLAGS_", type_id = "g_subprocess_flags_get_type ()")] - [Flags] - [Version (since = "2.40")] - public enum SubprocessFlags { - NONE, - STDIN_PIPE, - STDIN_INHERIT, - STDOUT_PIPE, - STDOUT_SILENCE, - STDERR_PIPE, - STDERR_SILENCE, - STDERR_MERGE, - INHERIT_FDS - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_TEST_DBUS_", type_id = "g_test_dbus_flags_get_type ()")] - [Flags] - [Version (since = "2.34")] - public enum TestDBusFlags { - NONE - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_TLS_AUTHENTICATION_", type_id = "g_tls_authentication_mode_get_type ()")] - [Version (since = "2.28")] - public enum TlsAuthenticationMode { - NONE, - REQUESTED, - REQUIRED - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_TLS_CERTIFICATE_", type_id = "g_tls_certificate_flags_get_type ()")] - [Flags] - [Version (since = "2.28")] - public enum TlsCertificateFlags { - UNKNOWN_CA, - BAD_IDENTITY, - NOT_ACTIVATED, - EXPIRED, - REVOKED, - INSECURE, - GENERIC_ERROR, - VALIDATE_ALL - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_TLS_CERTIFICATE_REQUEST_", type_id = "g_tls_certificate_request_flags_get_type ()")] - [Version (since = "2.40")] - public enum TlsCertificateRequestFlags { - NONE - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_TLS_DATABASE_LOOKUP_", type_id = "g_tls_database_lookup_flags_get_type ()")] - [Version (since = "2.30")] - public enum TlsDatabaseLookupFlags { - NONE, - KEYPAIR - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_TLS_DATABASE_VERIFY_", type_id = "g_tls_database_verify_flags_get_type ()")] - [Flags] - [Version (since = "2.30")] - public enum TlsDatabaseVerifyFlags { - NONE - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_TLS_INTERACTION_", type_id = "g_tls_interaction_result_get_type ()")] - [Version (since = "2.30")] - public enum TlsInteractionResult { - UNHANDLED, - HANDLED, - FAILED - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_TLS_PASSWORD_", type_id = "g_tls_password_flags_get_type ()")] - [Flags] - [Version (since = "2.30")] - public enum TlsPasswordFlags { - NONE, - RETRY, - MANY_TRIES, - FINAL_TRY - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_TLS_REHANDSHAKE_", type_id = "g_tls_rehandshake_mode_get_type ()")] - [Version (since = "2.28")] - public enum TlsRehandshakeMode { - NEVER, - SAFELY, - UNSAFELY - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_UNIX_SOCKET_ADDRESS_", type_id = "g_unix_socket_address_type_get_type ()")] - [Version (since = "2.26")] - public enum UnixSocketAddressType { - INVALID, - ANONYMOUS, - PATH, - ABSTRACT, - ABSTRACT_PADDED - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_ZLIB_COMPRESSOR_FORMAT_", type_id = "g_zlib_compressor_format_get_type ()")] - [Version (since = "2.24")] - public enum ZlibCompressorFormat { - ZLIB, - GZIP, - RAW - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_DBUS_ERROR_")] - [Version (since = "2.26")] - public errordomain DBusError { - FAILED, - NO_MEMORY, - SERVICE_UNKNOWN, - NAME_HAS_NO_OWNER, - NO_REPLY, - IO_ERROR, - BAD_ADDRESS, - NOT_SUPPORTED, - LIMITS_EXCEEDED, - ACCESS_DENIED, - AUTH_FAILED, - NO_SERVER, - TIMEOUT, - NO_NETWORK, - ADDRESS_IN_USE, - DISCONNECTED, - INVALID_ARGS, - FILE_NOT_FOUND, - FILE_EXISTS, - UNKNOWN_METHOD, - TIMED_OUT, - MATCH_RULE_NOT_FOUND, - MATCH_RULE_INVALID, - SPAWN_EXEC_FAILED, - SPAWN_FORK_FAILED, - SPAWN_CHILD_EXITED, - SPAWN_CHILD_SIGNALED, - SPAWN_FAILED, - SPAWN_SETUP_FAILED, - SPAWN_CONFIG_INVALID, - SPAWN_SERVICE_INVALID, - SPAWN_SERVICE_NOT_FOUND, - SPAWN_PERMISSIONS_INVALID, - SPAWN_FILE_INVALID, - SPAWN_NO_MEMORY, - UNIX_PROCESS_ID_UNKNOWN, - INVALID_SIGNATURE, - INVALID_FILE_CONTENT, - SELINUX_SECURITY_CONTEXT_UNKNOWN, - ADT_AUDIT_DATA_UNKNOWN, - OBJECT_PATH_IN_USE, - UNKNOWN_OBJECT, - UNKNOWN_INTERFACE, - UNKNOWN_PROPERTY, - PROPERTY_READ_ONLY; - [CCode (cheader_filename = "gio/gio.h")] - public static string encode_gerror (GLib.Error error); - [CCode (cheader_filename = "gio/gio.h")] - public static string get_remote_error (GLib.Error error); - [CCode (cheader_filename = "gio/gio.h")] - public static bool is_remote_error (GLib.Error error); - [CCode (cheader_filename = "gio/gio.h")] - public static GLib.Error new_for_dbus_error (string dbus_error_name, string dbus_error_message); - [CCode (cheader_filename = "gio/gio.h")] - public static GLib.Quark quark (); - [CCode (cheader_filename = "gio/gio.h")] - public static bool register_error (GLib.Quark error_domain, int error_code, string dbus_error_name); - [CCode (cheader_filename = "gio/gio.h")] - public static void register_error_domain (string error_domain_quark_name, size_t quark_volatile, GLib.DBusErrorEntry entries, uint num_entries); - [CCode (cheader_filename = "gio/gio.h")] - public static bool strip_remote_error (GLib.Error error); - [CCode (cheader_filename = "gio/gio.h")] - public static bool unregister_error (GLib.Quark error_domain, int error_code, string dbus_error_name); - } - [CCode (cheader_filename = "gio/gio.h", cname = "GIOErrorEnum", cprefix = "G_IO_ERROR_")] - [GIR (name = "IOErrorEnum")] - public errordomain IOError { - FAILED, - NOT_FOUND, - EXISTS, - IS_DIRECTORY, - NOT_DIRECTORY, - NOT_EMPTY, - NOT_REGULAR_FILE, - NOT_SYMBOLIC_LINK, - NOT_MOUNTABLE_FILE, - FILENAME_TOO_LONG, - INVALID_FILENAME, - TOO_MANY_LINKS, - NO_SPACE, - INVALID_ARGUMENT, - PERMISSION_DENIED, - NOT_SUPPORTED, - NOT_MOUNTED, - ALREADY_MOUNTED, - CLOSED, - CANCELLED, - PENDING, - READ_ONLY, - CANT_CREATE_BACKUP, - WRONG_ETAG, - TIMED_OUT, - WOULD_RECURSE, - BUSY, - WOULD_BLOCK, - HOST_NOT_FOUND, - WOULD_MERGE, - FAILED_HANDLED, - TOO_MANY_OPEN_FILES, - NOT_INITIALIZED, - ADDRESS_IN_USE, - PARTIAL_INPUT, - INVALID_DATA, - DBUS_ERROR, - HOST_UNREACHABLE, - NETWORK_UNREACHABLE, - CONNECTION_REFUSED, - PROXY_FAILED, - PROXY_AUTH_FAILED, - PROXY_NEED_AUTH, - PROXY_NOT_ALLOWED, - BROKEN_PIPE, - CONNECTION_CLOSED, - NOT_CONNECTED, - MESSAGE_TOO_LARGE; - [CCode (cheader_filename = "gio/gio.h")] - public static unowned GLib.IOError from_errno (int err_no); - [CCode (cheader_filename = "gio/gio.h")] - public static GLib.Quark quark (); - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_RESOLVER_ERROR_")] - [Version (since = "2.22")] - public errordomain ResolverError { - NOT_FOUND, - TEMPORARY_FAILURE, - INTERNAL; - [CCode (cheader_filename = "gio/gio.h")] - public static GLib.Quark quark (); - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_RESOURCE_ERROR_")] - [Version (since = "2.32")] - public errordomain ResourceError { - NOT_FOUND, - INTERNAL; - [CCode (cheader_filename = "gio/gio.h")] - public static GLib.Quark quark (); - } - [CCode (cheader_filename = "gio/gio.h", cprefix = "G_TLS_ERROR_")] - [Version (since = "2.28")] - public errordomain TlsError { - UNAVAILABLE, - MISC, - BAD_CERTIFICATE, - NOT_TLS, - HANDSHAKE, - CERTIFICATE_REQUIRED, - EOF - } - [CCode (cheader_filename = "gio/gio.h", instance_pos = 2.9)] - public delegate void AsyncReadyCallback (GLib.Object? source_object, GLib.AsyncResult res); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 2.9)] - [Version (since = "2.26")] - public delegate void BusAcquiredCallback (GLib.DBusConnection connection, string name); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 2.9)] - [Version (since = "2.26")] - public delegate void BusNameAcquiredCallback (GLib.DBusConnection connection, string name); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 3.9)] - [Version (since = "2.26")] - public delegate void BusNameAppearedCallback (GLib.DBusConnection connection, string name, string name_owner); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 2.9)] - [Version (since = "2.26")] - public delegate void BusNameLostCallback (GLib.DBusConnection connection, string name); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 2.9)] - [Version (since = "2.26")] - public delegate void BusNameVanishedCallback (GLib.DBusConnection connection, string name); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 1.9)] - [Version (since = "2.28")] - public delegate bool CancellableSourceFunc (GLib.Cancellable? cancellable = null); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 6.9)] - public delegate GLib.Variant DBusInterfaceGetPropertyFunc (GLib.DBusConnection connection, string sender, string object_path, string interface_name, string property_name) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h", instance_pos = 7.9)] - [Version (since = "2.26")] - public delegate void DBusInterfaceMethodCallFunc (GLib.DBusConnection connection, string sender, string object_path, string interface_name, string method_name, GLib.Variant parameters, owned GLib.DBusMethodInvocation invocation); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 7.9)] - public delegate bool DBusInterfaceSetPropertyFunc (GLib.DBusConnection connection, string sender, string object_path, string interface_name, string property_name, GLib.Variant value) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h", instance_pos = 3.9)] - [Version (since = "2.26")] - public delegate GLib.DBusMessage? DBusMessageFilterFunction (GLib.DBusConnection connection, owned GLib.DBusMessage message, bool incoming); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 3.9)] - [Version (since = "2.30")] - public delegate GLib.Type DBusProxyTypeFunc (GLib.DBusObjectManagerClient manager, string object_path, string? interface_name); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 6.9)] - [Version (since = "2.26")] - public delegate void DBusSignalCallback (GLib.DBusConnection connection, string sender_name, string object_path, string interface_name, string signal_name, GLib.Variant parameters); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 6.9)] - [Version (since = "2.26")] - public delegate unowned GLib.DBusInterfaceVTable? DBusSubtreeDispatchFunc (GLib.DBusConnection connection, string sender, string object_path, string interface_name, string node, void* out_user_data); - [CCode (array_length = false, array_null_terminated = true, cheader_filename = "gio/gio.h", instance_pos = 3.9)] - [Version (since = "2.26")] - public delegate string[] DBusSubtreeEnumerateFunc (GLib.DBusConnection connection, string sender, string object_path); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 4.9)] - [Version (since = "2.26")] - public delegate GLib.DBusInterfaceInfo DBusSubtreeIntrospectFunc (GLib.DBusConnection connection, string sender, string object_path, string node); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 2.9)] - [Version (since = "2.48")] - public delegate bool DatagramBasedSourceFunc (GLib.DatagramBased datagram_based, GLib.IOCondition condition); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 4.9)] - [Version (since = "2.38")] - public delegate void FileMeasureProgressCallback (bool reporting, uint64 current_size, uint64 num_dirs, uint64 num_files); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 2.9)] - public delegate void FileProgressCallback (int64 current_num_bytes, int64 total_num_bytes); - [CCode (cheader_filename = "gio/gio.h", has_target = false)] - public delegate bool FileReadMoreCallback (string file_contents, int64 file_size, void* callback_data); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 2.9)] - public delegate bool IOSchedulerJobFunc (GLib.IOSchedulerJob job, GLib.Cancellable? cancellable = null); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 1.9)] - [Version (since = "2.28")] - public delegate bool PollableSourceFunc (GLib.Object pollable_stream); - [CCode (cheader_filename = "gio/gio.h", has_target = false)] - public delegate void* ReallocFunc (void* data, size_t size); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 2.9)] - public delegate bool SettingsBindGetMapping (GLib.Value value, GLib.Variant variant); - [CCode (cheader_filename = "gio/gio.h", cname = "GSettingsBindGetMapping", has_target = false)] - public delegate bool SettingsBindGetMappingShared (GLib.Value value, GLib.Variant variant, void* user_data); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 2.9)] - public delegate GLib.Variant SettingsBindSetMapping (GLib.Value value, GLib.VariantType expected_type); - [CCode (cheader_filename = "gio/gio.h", cname = "GSettingsBindSetMapping", has_target = false)] - public delegate GLib.Variant SettingsBindSetMappingShared (GLib.Value value, GLib.VariantType expected_type, void* user_data); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 2.9)] - public delegate bool SettingsGetMapping (GLib.Variant value, out void* result); - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.26", replacement = "SimplActionActivateFunc")] - public delegate void SimpleActionActivateCallback (GLib.SimpleAction action, GLib.Variant? parameter); - [CCode (cheader_filename = "gio/gio.h", has_target = false)] - public delegate void SimpleActionActivateFunc (GLib.SimpleAction action, GLib.Variant? parameter, void* user_data); - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.26", replacement = "SimplActionChangeStateFunc")] - public delegate void SimpleActionChangeStateCallback (GLib.SimpleAction action, GLib.Variant value); - [CCode (cheader_filename = "gio/gio.h", has_target = false)] - public delegate void SimpleActionChangeStateFunc (GLib.SimpleAction action, GLib.Variant value, void* user_data); - [CCode (cheader_filename = "gio/gio.h", has_target = false)] - public delegate void SimpleAsyncThreadFunc (GLib.SimpleAsyncResult res, GLib.Object object, GLib.Cancellable? cancellable = null); - [CCode (cheader_filename = "gio/gio.h", instance_pos = 2.9)] - [Version (since = "2.22")] - public delegate bool SocketSourceFunc (GLib.Socket socket, GLib.IOCondition condition); - [CCode (cheader_filename = "gio/gio.h", has_target = false)] - [Version (since = "2.36")] - public delegate void TaskThreadFunc (GLib.Task task, GLib.Object source_object, void* task_data, GLib.Cancellable? cancellable = null); - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "File.equal")] - public static GLib.EqualFunc file_equal; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "File.hash")] - public static GLib.HashFunc file_hash; - [CCode (cheader_filename = "glib.h", cname = "g_realloc")] - public static GLib.ReallocFunc g_realloc; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.ACCESS_CAN_DELETE")] - public const string FILE_ATTRIBUTE_ACCESS_CAN_DELETE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.ACCESS_CAN_EXECUTE")] - public const string FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.ACCESS_CAN_READ")] - public const string FILE_ATTRIBUTE_ACCESS_CAN_READ; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.ACCESS_CAN_RENAME")] - public const string FILE_ATTRIBUTE_ACCESS_CAN_RENAME; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.ACCESS_CAN_TRASH")] - public const string FILE_ATTRIBUTE_ACCESS_CAN_TRASH; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.ACCESS_CAN_WRITE")] - public const string FILE_ATTRIBUTE_ACCESS_CAN_WRITE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.DOS_IS_ARCHIVE")] - public const string FILE_ATTRIBUTE_DOS_IS_ARCHIVE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.DOS_IS_SYSTEM")] - public const string FILE_ATTRIBUTE_DOS_IS_SYSTEM; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.ETAG_VALUE")] - public const string FILE_ATTRIBUTE_ETAG_VALUE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.FILESYSTEM_FREE")] - public const string FILE_ATTRIBUTE_FILESYSTEM_FREE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.FILESYSTEM_READONLY")] - public const string FILE_ATTRIBUTE_FILESYSTEM_READONLY; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.FILESYSTEM_SIZE")] - public const string FILE_ATTRIBUTE_FILESYSTEM_SIZE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.FILESYSTEM_TYPE")] - public const string FILE_ATTRIBUTE_FILESYSTEM_TYPE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.FILESYSTEM_USE_PREVIEW")] - public const string FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.GVFS_BACKEND")] - public const string FILE_ATTRIBUTE_GVFS_BACKEND; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.ID_FILE")] - public const string FILE_ATTRIBUTE_ID_FILE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.ID_FILESYSTEM")] - public const string FILE_ATTRIBUTE_ID_FILESYSTEM; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.MOUNTABLE_CAN_EJECT")] - public const string FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.MOUNTABLE_CAN_MOUNT")] - public const string FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.MOUNTABLE_CAN_POLL")] - public const string FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.MOUNTABLE_CAN_START")] - public const string FILE_ATTRIBUTE_MOUNTABLE_CAN_START; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.MOUNTABLE_CAN_START_DEGRADED")] - public const string FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.MOUNTABLE_CAN_STOP")] - public const string FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.MOUNTABLE_CAN_UNMOUNT")] - public const string FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.MOUNTABLE_HAL_UDI")] - public const string FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC")] - public const string FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.MOUNTABLE_START_STOP_TYPE")] - public const string FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.MOUNTABLE_UNIX_DEVICE")] - public const string FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.MOUNTABLE_UNIX_DEVICE_FILE")] - public const string FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.OWNER_GROUP")] - public const string FILE_ATTRIBUTE_OWNER_GROUP; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.OWNER_USER")] - public const string FILE_ATTRIBUTE_OWNER_USER; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.OWNER_USER_REAL")] - public const string FILE_ATTRIBUTE_OWNER_USER_REAL; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.PREVIEW_ICON")] - public const string FILE_ATTRIBUTE_PREVIEW_ICON; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.SELINUX_CONTEXT")] - public const string FILE_ATTRIBUTE_SELINUX_CONTEXT; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_ALLOCATED_SIZE")] - public const string FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_CONTENT_TYPE")] - public const string FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_COPY_NAME")] - public const string FILE_ATTRIBUTE_STANDARD_COPY_NAME; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_DESCRIPTION")] - public const string FILE_ATTRIBUTE_STANDARD_DESCRIPTION; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_DISPLAY_NAME")] - public const string FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_EDIT_NAME")] - public const string FILE_ATTRIBUTE_STANDARD_EDIT_NAME; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_FAST_CONTENT_TYPE")] - public const string FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_ICON")] - public const string FILE_ATTRIBUTE_STANDARD_ICON; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_IS_BACKUP")] - public const string FILE_ATTRIBUTE_STANDARD_IS_BACKUP; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_IS_HIDDEN")] - public const string FILE_ATTRIBUTE_STANDARD_IS_HIDDEN; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_IS_SYMLINK")] - public const string FILE_ATTRIBUTE_STANDARD_IS_SYMLINK; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_IS_VIRTUAL")] - public const string FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_NAME")] - public const string FILE_ATTRIBUTE_STANDARD_NAME; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_SIZE")] - public const string FILE_ATTRIBUTE_STANDARD_SIZE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_SORT_ORDER")] - public const string FILE_ATTRIBUTE_STANDARD_SORT_ORDER; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_SYMLINK_TARGET")] - public const string FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_TARGET_URI")] - public const string FILE_ATTRIBUTE_STANDARD_TARGET_URI; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.STANDARD_TYPE")] - public const string FILE_ATTRIBUTE_STANDARD_TYPE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.THUMBNAILING_FAILED")] - public const string FILE_ATTRIBUTE_THUMBNAILING_FAILED; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.THUMBNAIL_PATH")] - public const string FILE_ATTRIBUTE_THUMBNAIL_PATH; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.TIME_ACCESS")] - public const string FILE_ATTRIBUTE_TIME_ACCESS; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.TIME_ACCESS_USEC")] - public const string FILE_ATTRIBUTE_TIME_ACCESS_USEC; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.TIME_CHANGED")] - public const string FILE_ATTRIBUTE_TIME_CHANGED; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.TIME_CHANGED_USEC")] - public const string FILE_ATTRIBUTE_TIME_CHANGED_USEC; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.TIME_CREATED")] - public const string FILE_ATTRIBUTE_TIME_CREATED; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.TIME_CREATED_USEC")] - public const string FILE_ATTRIBUTE_TIME_CREATED_USEC; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.TIME_MODIFIED")] - public const string FILE_ATTRIBUTE_TIME_MODIFIED; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.TIME_MODIFIED_USEC")] - public const string FILE_ATTRIBUTE_TIME_MODIFIED_USEC; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.TRASH_DELETION_DATE")] - public const string FILE_ATTRIBUTE_TRASH_DELETION_DATE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.TRASH_ITEM_COUNT")] - public const string FILE_ATTRIBUTE_TRASH_ITEM_COUNT; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.TRASH_ORIG_PATH")] - public const string FILE_ATTRIBUTE_TRASH_ORIG_PATH; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.UNIX_BLOCKS")] - public const string FILE_ATTRIBUTE_UNIX_BLOCKS; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.UNIX_BLOCK_SIZE")] - public const string FILE_ATTRIBUTE_UNIX_BLOCK_SIZE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.UNIX_DEVICE")] - public const string FILE_ATTRIBUTE_UNIX_DEVICE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.UNIX_GID")] - public const string FILE_ATTRIBUTE_UNIX_GID; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.UNIX_INODE")] - public const string FILE_ATTRIBUTE_UNIX_INODE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.UNIX_IS_MOUNTPOINT")] - public const string FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.UNIX_MODE")] - public const string FILE_ATTRIBUTE_UNIX_MODE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.UNIX_NLINK")] - public const string FILE_ATTRIBUTE_UNIX_NLINK; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.UNIX_RDEV")] - public const string FILE_ATTRIBUTE_UNIX_RDEV; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "FileAttribute.UNIX_UID")] - public const string FILE_ATTRIBUTE_UNIX_UID; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "Menu.ATTRIBUTE_ACTION")] - public const string MENU_ATTRIBUTE_ACTION; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "Menu.ATTRIBUTE_LABEL")] - public const string MENU_ATTRIBUTE_LABEL; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "Menu.ATTRIBUTE_TARGET")] - public const string MENU_ATTRIBUTE_TARGET; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "Menu.LINK_SECTION_SECTION")] - public const string MENU_LINK_SECTION; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "Menu.LINK_SUBMENU")] - public const string MENU_LINK_SUBMENU; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "IOExtensionPoint.NATIVE_VOLUME_MONITOR")] - public const string NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "IOExtensionPoint.NETWORK_MONITOR")] - public const string NETWORK_MONITOR_EXTENSION_POINT_NAME; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "IOExtensionPoint.PROXY")] - public const string PROXY_EXTENSION_POINT_NAME; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "IOExtensionPoint.PROXY_RESOLVER")] - public const string PROXY_RESOLVER_EXTENSION_POINT_NAME; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "IOExtensionPoint.TLS_BACKEND")] - public const string TLS_BACKEND_EXTENSION_POINT_NAME; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "TlsDatabase.PURPOSE_AUTHENTICATE_CLIENT")] - public const string TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "TlsDatabase.PURPOSE_AUTHENTICATE_SERVER")] - public const string TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "IOExtensionPoint.VFS")] - public const string VFS_EXTENSION_POINT_NAME; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "GLib.VolumeIdentifier.HAL_UDI")] - public const string VOLUME_IDENTIFIER_KIND_HAL_UDI; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "GLib.VolumeIdentifier.LABEL")] - public const string VOLUME_IDENTIFIER_KIND_LABEL; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "GLib.VolumeIdentifier.NFS_MOUNT")] - public const string VOLUME_IDENTIFIER_KIND_NFS_MOUNT; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "GLib.VolumeIdentifier.UNIX_DEVICE")] - public const string VOLUME_IDENTIFIER_KIND_UNIX_DEVICE; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "GLib.VolumeIdentifier.UUID")] - public const string VOLUME_IDENTIFIER_KIND_UUID; - [CCode (cheader_filename = "gio/gio.h")] - [Version (deprecated_since = "vala-0.16", replacement = "IOExtensionPoint.VOLUME_MONITOR")] - public const string VOLUME_MONITOR_EXTENSION_POINT_NAME; - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.38")] - public static bool action_name_is_valid (string action_name); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.38")] - public static bool action_parse_detailed_name (string detailed_name, out string action_name, out GLib.Variant target_value) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.38")] - public static string action_print_detailed_name (string action_name, GLib.Variant? target_value); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.48")] - public static GLib.DtlsClientConnection dtls_client_connection_new (GLib.DatagramBased base_socket, GLib.SocketConnectable? server_identity) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.48")] - public static GLib.DtlsServerConnection dtls_server_connection_new (GLib.DatagramBased base_socket, GLib.TlsCertificate? certificate) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h", cname = "g_content_type_can_be_executable")] - [Version (deprecated_since = "vala-0.12", replacement = "GLib.ContentType.can_be_executable")] - public static bool g_content_type_can_be_executable (string type); - [CCode (cheader_filename = "gio/gio.h", cname = "g_content_type_equals")] - [Version (deprecated_since = "vala-0.12", replacement = "GLib.ContentType.equals")] - public static bool g_content_type_equals (string type1, string type2); - [CCode (cheader_filename = "gio/gio.h", cname = "g_content_type_from_mime_type")] - [Version (deprecated_since = "vala-0.12", replacement = "GLib.ContentType.from_mime_type")] - public static string? g_content_type_from_mime_type (string mime_type); - [CCode (cheader_filename = "gio/gio.h", cname = "g_content_type_get_description")] - [Version (deprecated_since = "vala-0.12", replacement = "GLib.ContentType.get_description")] - public static string g_content_type_get_description (string type); - [CCode (cheader_filename = "gio/gio.h", cname = "g_content_type_get_icon")] - [Version (deprecated_since = "vala-0.12", replacement = "GLib.ContentType.get_icon")] - public static GLib.Icon g_content_type_get_icon (string type); - [CCode (cheader_filename = "gio/gio.h", cname = "g_content_type_get_mime_type")] - [Version (deprecated_since = "vala-0.12", replacement = "GLib.ContentType.get_mime_type")] - public static string? g_content_type_get_mime_type (string type); - [CCode (cheader_filename = "gio/gio.h", cname = "g_content_type_guess")] - [Version (deprecated_since = "vala-0.12", replacement = "GLib.ContentType.guess")] - public static string g_content_type_guess (string filename, uchar[] data, out bool result_uncertain); - [CCode (cheader_filename = "gio/gio.h", cname = "g_content_type_guess_for_tree")] - [Version (deprecated_since = "vala-0.12", replacement = "GLib.ContentType.guess_for_tree")] - public static string g_content_type_guess_for_tree (GLib.File root); - [CCode (cheader_filename = "gio/gio.h", cname = "g_content_type_is_a")] - [Version (deprecated_since = "vala-0.12", replacement = "GLib.ContentType.is_a")] - public static bool g_content_type_is_a (string type, string supertype); - [CCode (cheader_filename = "gio/gio.h", cname = "g_content_type_is_unknown")] - [Version (deprecated_since = "vala-0.12", replacement = "GLib.ContentType.is_unknown")] - public static bool g_content_type_is_unknown (string type); - [CCode (cheader_filename = "gio/gio.h", cname = "g_content_types_get_registered")] - [Version (deprecated_since = "vala-0.16", replacement = "ContentType.list_registered")] - public static GLib.List g_content_types_get_registered (); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_address_get_for_bus_sync")] - [Version (deprecated_since = "vala-0.16", replacement = "BusType.get_address_sync")] - public static unowned string g_dbus_address_get_for_bus_sync (GLib.BusType bus_type, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_address_get_stream")] - [Version (deprecated_since = "vala-0.16", replacement = "DBus.address_get_stream")] - public static async void g_dbus_address_get_stream (string address, GLib.Cancellable? cancellable = null); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_address_get_stream_finish")] - [Version (deprecated_since = "vala-0.16", replacement = "DBus.address_get_stream_finish")] - public static unowned GLib.IOStream g_dbus_address_get_stream_finish (GLib.AsyncResult res, string out_guid) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_address_get_stream_sync")] - [Version (deprecated_since = "vala-0.16", replacement = "DBus.address_get_stream_sync")] - public static unowned GLib.IOStream g_dbus_address_get_stream_sync (string address, string out_guid, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_error_encode_gerror")] - [Version (deprecated_since = "vala-0.16", replacement = "DBusError.encode_gerror")] - public static unowned string g_dbus_error_encode_gerror (GLib.Error error); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_error_get_remote_error")] - [Version (deprecated_since = "vala-0.16", replacement = "DBusError.get_remote_error")] - public static unowned string g_dbus_error_get_remote_error (GLib.Error error); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_error_is_remote_error")] - [Version (deprecated_since = "vala-0.16", replacement = "DBusError.error_is_remote_error")] - public static bool g_dbus_error_is_remote_error (GLib.Error error); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_error_new_for_dbus_error")] - [Version (deprecated_since = "vala-0.16", replacement = "DBusError.new_for_dbus_error")] - public static unowned GLib.Error g_dbus_error_new_for_dbus_error (string dbus_error_name, string dbus_error_message); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_error_quark")] - [Version (deprecated_since = "vala-0.16", replacement = "DBusError.quark")] - public static GLib.Quark g_dbus_error_quark (); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_error_register_error")] - [Version (deprecated_since = "vala-0.16", replacement = "DBusError.register_error")] - public static bool g_dbus_error_register_error (GLib.Quark error_domain, int error_code, string dbus_error_name); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_error_register_error_domain")] - [Version (deprecated_since = "vala-0.16", replacement = "DBusError.register_error_domain")] - public static void g_dbus_error_register_error_domain (string error_domain_quark_name, size_t quark_volatile, GLib.DBusErrorEntry entries, uint num_entries); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_error_set_dbus_error")] - [Version (deprecated_since = "vala-0.16", replacement = "DBusError.set_dbus_error")] - public static void g_dbus_error_set_dbus_error (string dbus_error_name, string dbus_error_message, string format) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_error_set_dbus_error_valist")] - [Version (deprecated_since = "vala-0.16", replacement = "DBusError.set_dbus_error_valist")] - public static void g_dbus_error_set_dbus_error_valist (string dbus_error_name, string dbus_error_message, string format, void* var_args) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_error_strip_remote_error")] - [Version (deprecated_since = "vala-0.16", replacement = "DBusError.strip_remote_error")] - public static bool g_dbus_error_strip_remote_error (GLib.Error error); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_error_unregister_error")] - [Version (deprecated_since = "vala-0.16", replacement = "DBusError.unregister_error")] - public static bool g_dbus_error_unregister_error (GLib.Quark error_domain, int error_code, string dbus_error_name); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_generate_guid")] - [Version (deprecated_since = "vala-0.16", replacement = "DBus.generate_guid")] - public static unowned string g_dbus_generate_guid (); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_gvalue_to_gvariant")] - [Version (deprecated_since = "vala-0.16", replacement = "DBus.gvalue_to_gvariant")] - public static unowned GLib.Variant g_dbus_gvalue_to_gvariant (GLib.Value gvalue, GLib.VariantType type); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_gvariant_to_gvalue")] - [Version (deprecated_since = "vala-0.16", replacement = "DBus.gvariant_to_gvalue")] - public static void g_dbus_gvariant_to_gvalue (GLib.Variant value, GLib.Value out_gvalue); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_is_address")] - [Version (deprecated_since = "vala-0.16", replacement = "DBus.is_address")] - public static bool g_dbus_is_address (string str); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_is_guid")] - [Version (deprecated_since = "vala-0.16", replacement = "DBus.is_guid")] - public static bool g_dbus_is_guid (string str); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_is_interface_name")] - [Version (deprecated_since = "vala-0.16", replacement = "DBus.is_interface_name")] - public static bool g_dbus_is_interface_name (string str); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_is_member_name")] - [Version (deprecated_since = "vala-0.16", replacement = "DBus.is_member_name")] - public static bool g_dbus_is_member_name (string str); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_is_name")] - [Version (deprecated_since = "vala-0.16", replacement = "DBus.is_name")] - public static bool g_dbus_is_name (string str); - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_is_supported_address")] - [Version (deprecated_since = "vala-0.16", replacement = "DBus.is_supported_address")] - public static bool g_dbus_is_supported_address (string str) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h", cname = "g_dbus_is_unique_name")] - [Version (deprecated_since = "vala-0.16", replacement = "DBus.is_unique_name")] - public static bool g_dbus_is_unique_name (string str); - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_error_from_errno")] - [Version (deprecated_since = "vala-0.16", replacement = "IOError.from_errno")] - public static unowned GLib.IOError g_io_error_from_errno (int err_no); - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_error_quark")] - [Version (deprecated_since = "vala-0.16", replacement = "IOError.quark")] - public static GLib.Quark g_io_error_quark (); - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_modules_load_all_in_directory")] - [Version (deprecated_since = "vala-0.16", replacement = "IOModule.load_all_in_directory")] - public static GLib.List g_io_modules_load_all_in_directory (string dirname); - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_modules_load_all_in_directory_with_scope")] - [Version (deprecated_since = "vala-0.16", replacement = "IOModule.load_all_in_directory_with_scope")] - public static unowned GLib.List g_io_modules_load_all_in_directory_with_scope (string dirname, GLib.IOModuleScope scope); - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_modules_scan_all_in_directory")] - [Version (deprecated_since = "vala-0.16", replacement = "IOModule.scan_all_in_directory")] - public static void g_io_modules_scan_all_in_directory (string dirname); - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_modules_scan_all_in_directory_with_scope")] - [Version (deprecated_since = "vala-0.16", replacement = "IOModule.xscan_all_in_directory_with_scope")] - public static void g_io_modules_scan_all_in_directory_with_scope (string dirname, GLib.IOModuleScope scope); - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_scheduler_cancel_all_jobs")] - [Version (deprecated_since = "vala-0.16", replacement = "IOSchedulerJob.cancel_all")] - public static void g_io_scheduler_cancel_all_jobs (); - [CCode (cheader_filename = "gio/gio.h", cname = "g_io_scheduler_push_job")] - [Version (deprecated_since = "vala-0.16", replacement = "IOSchedulerJob.push")] - public static void g_io_scheduler_push_job (owned GLib.IOSchedulerJobFunc job_func, int io_priority = GLib.Priority.DEFAULT, GLib.Cancellable? cancellable = null); - [CCode (cheader_filename = "gio/gio.h", cname = "g_pollable_source_new")] - [Version (deprecated_since = "vala-0.16", replacement = "PollableSource")] - public static unowned GLib.TimeoutSource g_pollable_source_new (GLib.Object pollable_stream); - [CCode (cheader_filename = "gio/gio.h", cname = "g_simple_async_report_error_in_idle")] - [Version (deprecated_since = "vala-0.16", replacement = "report_error_in_idle")] - public static void g_simple_async_report_error_in_idle (GLib.Object object, GLib.AsyncReadyCallback callback, GLib.Quark domain, int code, string format); - [CCode (cheader_filename = "gio/gio.h", cname = "g_simple_async_report_gerror_in_idle")] - [Version (deprecated_since = "vala-0.16", replacement = "report_gerror_in_idle")] - public static void g_simple_async_report_gerror_in_idle (GLib.Object object, GLib.AsyncReadyCallback callback, GLib.Error error); - [CCode (cheader_filename = "gio/gio.h", cname = "g_simple_async_report_take_gerror_in_idle")] - [Version (deprecated_since = "vala-0.16", replacement = "report_take_gerror_in_idle")] - public static void g_simple_async_report_take_gerror_in_idle (GLib.Object object, GLib.AsyncReadyCallback callback, GLib.Error error); - [CCode (cheader_filename = "gio/gio.h", cname = "g_tls_error_quark")] - [Version (deprecated_since = "vala-0.16", replacement = "TlsError.quark")] - public static GLib.Quark g_tls_error_quark (); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.36")] - public static void networking_init (); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.34")] - public static ssize_t pollable_stream_read (GLib.InputStream stream, [CCode (array_length_cname = "count", array_length_pos = 2.5, array_length_type = "gsize")] uint8[] buffer, bool blocking, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.34")] - public static ssize_t pollable_stream_write (GLib.OutputStream stream, [CCode (array_length_cname = "count", array_length_pos = 2.5, array_length_type = "gsize")] uint8[] buffer, bool blocking, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.34")] - public static bool pollable_stream_write_all (GLib.OutputStream stream, [CCode (array_length_cname = "count", array_length_pos = 2.5, array_length_type = "gsize")] uint8[] buffer, bool blocking, out size_t bytes_written, GLib.Cancellable? cancellable = null) throws GLib.Error; - [CCode (array_length = false, array_null_terminated = true, cheader_filename = "gio/gio.h")] - [Version (since = "2.32")] - public static string[] resources_enumerate_children (string path, GLib.ResourceLookupFlags lookup_flags) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.32")] - public static bool resources_get_info (string path, GLib.ResourceLookupFlags lookup_flags, out size_t size, out uint32 flags) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.32")] - public static GLib.Bytes resources_lookup_data (string path, GLib.ResourceLookupFlags lookup_flags) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.32")] - public static GLib.InputStream resources_open_stream (string path, GLib.ResourceLookupFlags lookup_flags) throws GLib.Error; - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.32")] - public static void resources_register (GLib.Resource resource); - [CCode (cheader_filename = "gio/gio.h")] - [Version (since = "2.32")] - public static void resources_unregister (GLib.Resource resource); -} From d8bc0f851b0de0e218f6f08bb1d431dd478c67dd Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 31 May 2017 22:20:11 +0200 Subject: [PATCH 003/100] devicechannel, discovery: update to match latest gio-2.0 API --- src/mconnect/devicechannel.vala | 2 +- src/mconnect/discovery.vala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mconnect/devicechannel.vala b/src/mconnect/devicechannel.vala index 784ddb8..d61cbe5 100644 --- a/src/mconnect/devicechannel.vala +++ b/src/mconnect/devicechannel.vala @@ -108,7 +108,7 @@ class DeviceChannel : Object { // enable keepalive sock.set_keepalive(true); // prep source for monitoring events - var source = sock.create_socket_source(IOCondition.IN); + var source = sock.create_source(IOCondition.IN); source.set_callback((src, cond) => { return this._io_ready(cond); }); diff --git a/src/mconnect/discovery.vala b/src/mconnect/discovery.vala index 23200f3..a6dadb0 100644 --- a/src/mconnect/discovery.vala +++ b/src/mconnect/discovery.vala @@ -51,7 +51,7 @@ class Discovery : GLib.Object throw e; } - var source = socket.create_socket_source(IOCondition.IN); + var source = socket.create_source(IOCondition.IN); source.set_callback((s, c) => { this.incomingPacket(); return true; From 9753a21c2970bd4861c1b5c58758767cafa07ca1 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 31 May 2017 22:20:34 +0200 Subject: [PATCH 004/100] config, core, devicemanager: cleanup valac warnings --- src/mconnect/config.vala | 2 +- src/mconnect/core.vala | 2 +- src/mconnect/devicemanager.vala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mconnect/config.vala b/src/mconnect/config.vala index 8c07ab4..0a36650 100644 --- a/src/mconnect/config.vala +++ b/src/mconnect/config.vala @@ -19,7 +19,7 @@ */ public class Config : Object { - public static const string FILE = "mconnect.conf"; + public const string FILE = "mconnect.conf"; private KeyFile _kf = null; diff --git a/src/mconnect/core.vala b/src/mconnect/core.vala index 732add3..7fcbdf9 100644 --- a/src/mconnect/core.vala +++ b/src/mconnect/core.vala @@ -21,7 +21,7 @@ using Mconn; class Core : Object { - public static const string APP_NAME = "mconnect"; + public const string APP_NAME = "mconnect"; public Crypt crypt { get; private set; default = null; } diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 60be7f6..9ef5c91 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -21,7 +21,7 @@ using Gee; class DeviceManager : GLib.Object { - public static const string DEVICES_CACHE_FILE = "devices"; + public const string DEVICES_CACHE_FILE = "devices"; private HashMap devices; From bdcd3cf442352ad999bf24e71b3c38ef6387f787 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 08:40:19 +0200 Subject: [PATCH 005/100] device, devicemanager: add DBus intefaces, hide methods from the bus --- src/mconnect/device.vala | 14 ++++++++++++++ src/mconnect/devicemanager.vala | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index b3c675a..9d44b83 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -21,11 +21,16 @@ /** * General device wrapper. */ +[DBus (name = "org.mconnect.Device")] class Device : Object { + [DBus (visible = false)] public signal void paired(bool pair); + [DBus (visible = false)] public signal void connected(); + [DBus (visible = false)] public signal void disconnected(); + [DBus (visible = false)] public signal void message(Packet pkt); public string device_id { get; private set; default = ""; } @@ -33,6 +38,7 @@ class Device : Object { public string device_type { get; private set; default = ""; } public uint protocol_version {get; private set; default = 5; } public uint tcp_port {get; private set; default = 1714; } + [DBus (visible = false)] public InetAddress host { get; private set; default = null; } public bool is_paired { get; private set; default = false; } @@ -108,10 +114,12 @@ class Device : Object { /** * Generates a unique string for this device */ + [DBus (visible = false)] public string to_unique_string() { return this.to_string().replace(" ", "-"); } + [DBus (visible = false)] public string to_string() { return "%s-%s-%s-%u".printf(this.device_id, this.device_name, this.device_type, this.protocol_version); @@ -123,6 +131,7 @@ class Device : Object { * @cache: device cache * @name: group name */ + [DBus (visible = false)] public void to_cache(KeyFile cache, string name) { cache.set_string(name, "deviceId", this.device_id); cache.set_string(name, "deviceName", this.device_name); @@ -150,6 +159,7 @@ class Device : Object { * * @param expect_response se to true if expecting a response */ + [DBus (visible = false)] public async void pair(bool expect_response = true) { if (this.host != null) { debug("start pairing"); @@ -164,6 +174,7 @@ class Device : Object { } } + [DBus (visible = false)] public void pair_if_needed() { if (is_paired == false && _pair_in_progress == false) this.pair.begin(); @@ -175,6 +186,7 @@ class Device : Object { * Activate device. Triggers sending of #paired signal after * successfuly opening a connection. */ + [DBus (visible = false)] public void activate() { assert(_channel == null); @@ -197,6 +209,7 @@ class Device : Object { * * Deactivate device */ + [DBus (visible = false)] public void deactivate() { if (_channel != null) _channel.close.begin((c) => { @@ -214,6 +227,7 @@ class Device : Object { * * @param dev device */ + [DBus (visible = false)] public void activate_from_device(Device dev) { if (host == null) { host = dev.host; diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 9ef5c91..37f5c6c 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -19,12 +19,27 @@ */ using Gee; +[DBus (name = "org.mconnect.DeviceManager")] class DeviceManager : GLib.Object { public const string DEVICES_CACHE_FILE = "devices"; private HashMap devices; + /** + * DBus wrapper for devices + */ + private struct DeviceWrapper { + ObjectPath object_path; + Device device; + + DeviceWrapper (string path, Device device) { + this.object_path = new ObjectPath(path); + this.device = device; + } + } + + public DeviceManager() { debug("device manager.."); @@ -101,6 +116,7 @@ class DeviceManager : GLib.Object } } + [DBus (visible = false)] public void found_device(Device dev) { debug("found device: %s", dev.to_string()); From 7a814ffdc480278af5521ddfda213c34dd99d598 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 08:40:52 +0200 Subject: [PATCH 006/100] application: DBus registration, register manager object --- src/mconnect/application.vala | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/mconnect/application.vala b/src/mconnect/application.vala index 254ce4b..5e1aa6c 100644 --- a/src/mconnect/application.vala +++ b/src/mconnect/application.vala @@ -31,12 +31,20 @@ namespace Mconn { {null} }; + private Discovery discovery = null; + private DeviceManager manager = null; + public Application() { - Object(application_id: "org.bboozzoo.mconnect"); + Object(application_id: "org.mconnect"); add_main_option_entries(options); + + discovery = new Discovery(); + manager = new DeviceManager(); } protected override void startup() { + debug("startup"); + base.startup(); if (log_debug == true) @@ -51,9 +59,6 @@ namespace Mconn { Notify.init("mconnect"); - var discovery = new Discovery(); - var manager = new DeviceManager(); - discovery.device_found.connect((disc, dev) => { manager.found_device(dev); }); @@ -65,7 +70,21 @@ namespace Mconn { } protected override void activate() { + debug("activate"); hold(); } + + public override bool dbus_register(DBusConnection conn, string object_path) throws Error { + base.dbus_register(conn, object_path); + debug("dbus register, path %s", object_path); + + conn.register_object("/org/mconnect/manager", manager); + return true; + } + + public override void dbus_unregister(DBusConnection conn, string object_path) { + base.dbus_unregister(conn, object_path); + debug("dbus unregister, path %s", object_path); + } } } \ No newline at end of file From 1e664bf8af572395349d881de3b4cddb988817b6 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 09:08:41 +0200 Subject: [PATCH 007/100] application, devicemanager: restore devices from cache when application becomes active --- src/mconnect/application.vala | 2 ++ src/mconnect/devicemanager.vala | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/mconnect/application.vala b/src/mconnect/application.vala index 5e1aa6c..4dc9a41 100644 --- a/src/mconnect/application.vala +++ b/src/mconnect/application.vala @@ -71,6 +71,8 @@ namespace Mconn { protected override void activate() { debug("activate"); + // reload devices from cache + manager.load_cache(); hold(); } diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 37f5c6c..a07a34e 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -44,10 +44,6 @@ class DeviceManager : GLib.Object debug("device manager.."); this.devices = new HashMap(); - - // TODO: check for network connectivity first, possibly pass - // this through the main loop - load_cache(); } /** @@ -68,7 +64,8 @@ class DeviceManager : GLib.Object /** * Load known devices from cache and attempt pairing. */ - private void load_cache() { + [DBus (visible = false)] + public void load_cache() { debug("try loading devices from device cache"); var cache_file = get_cache_file(); From 936886f17d21c32828faeaa056f7db8875592c04 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 09:09:06 +0200 Subject: [PATCH 008/100] device: add 'allowed' cache flag --- src/mconnect/device.vala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 9d44b83..f1a2830 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -41,6 +41,7 @@ class Device : Object { [DBus (visible = false)] public InetAddress host { get; private set; default = null; } public bool is_paired { get; private set; default = false; } + public bool allowed {get; set; default = false; } // set to true if pair request was sent private bool _pair_in_progress = false; @@ -91,6 +92,7 @@ class Device : Object { dev.tcp_port = (uint) cache.get_integer(name, "tcpPort"); var last_ip_str = cache.get_string(name, "lastIPAddress"); debug("last known address: %s:%u", last_ip_str, dev.tcp_port); + dev.allowed = cache.get_boolean(name, "allowed"); var host = new InetAddress.from_string(last_ip_str); if (host == null) { @@ -139,6 +141,7 @@ class Device : Object { cache.set_integer(name, "protocolVersion", (int) this.protocol_version); cache.set_integer(name, "tcpPort", (int) this.tcp_port); cache.set_string(name, "lastIPAddress", this.host.to_string()); + cache.set_boolean(name, "allowed", this.allowed); } private async void greet() { From 39785fca9e58a9208500b87f46a28948b261c3d0 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 09:09:55 +0200 Subject: [PATCH 009/100] devicemanager: use Device.allowed flag or poke config to see if device is accepted --- src/mconnect/devicemanager.vala | 48 ++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index a07a34e..78a788a 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -119,39 +119,51 @@ class DeviceManager : GLib.Object if (device_allowed(dev) == false) { message("device %s not on whitelist", dev.to_string()); - return; } + var is_new = false; string unique = dev.to_unique_string(); debug("device key: %s", unique); + if (this.devices.has_key(unique) == false) { debug("adding new device with key: %s", unique); this.devices.@set(unique, dev); - - dev.paired.connect((d, p) => { - device_paired(d, p); - }); - - dev.disconnected.connect((d) => { - device_disconnected(d); - }); - dev.activate(); - } else { - debug("activate from device"); - var known_dev = this.devices.@get(unique); - known_dev.activate_from_device(dev); + is_new = true; } - // device in whitelist and added to currently used devices, so - // it's ok to update the device cache + // update devices cache update_cache(); + + if (dev.allowed) { + // device is allowed + + if (is_new) { + dev.paired.connect((d, p) => { + device_paired(d, p); + }); + + dev.disconnected.connect((d) => { + device_disconnected(d); + }); + dev.activate(); + } else { + debug("activate from device"); + var known_dev = this.devices.@get(unique); + known_dev.activate_from_device(dev); + } + } } private bool device_allowed(Device dev) { + if (dev.allowed) + return true; + var core = Core.instance(); - return core.config.is_device_allowed(dev.device_name, - dev.device_type); + var in_config = core.config.is_device_allowed(dev.device_name, + dev.device_type); + dev.allowed = in_config; + return in_config; } private void device_paired(Device dev, bool status) { From b16e1491d572abaca92aa85e18c1a9c475139737 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 09:11:27 +0200 Subject: [PATCH 010/100] devicemanager: allow_device, list_devices DBus methods --- src/mconnect/devicemanager.vala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 78a788a..77f990d 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -178,4 +178,24 @@ class DeviceManager : GLib.Object debug("device %s got disconnected", dev.to_string()); } + /** + * allow_device: + * @path: device object path + * + * Allow given device + */ + public void allow_device(string path) { + + } + + /** + * list_devices: + * + * Returns a list of DBus paths of all known devices + */ + public ObjectPath[] list_devices() { + ObjectPath[] devices = {}; + return devices; + } + } \ No newline at end of file From 0dabf5e7d90cc69252af42c0570114fbe8630965 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 11:39:10 +0200 Subject: [PATCH 011/100] device: do not clean host address when disconnecting --- src/mconnect/device.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index f1a2830..242934f 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -340,8 +340,8 @@ class Device : Object { * Single cleanup point after channel has been closed */ private void channel_closed_cleanup() { + debug("close cleanup"); _channel = null; - _host = null; // emit disconnected disconnected(); } From 3477d3ee859ee1fb0485b2cfb463655e2a2a2389 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 11:39:30 +0200 Subject: [PATCH 012/100] device: fix activation of device that is disconnected but its address is known --- src/mconnect/device.vala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 242934f..09bcdcb 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -223,7 +223,7 @@ class Device : Object { /** * activate_from_device: * - * Try to activate using a newly discovered device. If device is + * Try to activate using information from device @dev. If device is * already active, compare the host address to see if it * changed. If so, close the current connection and activate with * new address. @@ -242,8 +242,12 @@ class Device : Object { tcp_port = dev.tcp_port; activate(); } else { - // same host, assuming no activation needed - debug("device %s already active", dev.to_string()); + if (_channel == null) { + activate(); + } else { + // same host, assuming no activation needed + debug("device %s already active", dev.to_string()); + } } } From 3b6e7bc80c8be41ecfd5fb42d8fe8f31b604da03 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 11:40:36 +0200 Subject: [PATCH 013/100] devicemanager: list and activate devices through DBus --- src/mconnect/devicemanager.vala | 100 ++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 25 deletions(-) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 77f990d..86131c6 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -24,7 +24,8 @@ class DeviceManager : GLib.Object { public const string DEVICES_CACHE_FILE = "devices"; - private HashMap devices; + private HashMap devices; + private int device_idx = 0; /** * DBus wrapper for devices @@ -43,7 +44,7 @@ class DeviceManager : GLib.Object public DeviceManager() { debug("device manager.."); - this.devices = new HashMap(); + this.devices = new HashMap(); } /** @@ -99,7 +100,8 @@ class DeviceManager : GLib.Object var kf = new KeyFile(); - foreach (Device dev in devices.values) { + foreach (var wrapper in devices.values) { + var dev = wrapper.device; dev.to_cache(kf, dev.device_name); } @@ -113,22 +115,40 @@ class DeviceManager : GLib.Object } } + /** + * make_device_path: + * + * return device path string that can be used as ObjectPath + */ + private string make_device_path() { + var path = "/org/mconnect/device/%d".printf(this.device_idx); + + // bump device index + device_idx++; + + return path; + } + [DBus (visible = false)] public void found_device(Device dev) { debug("found device: %s", dev.to_string()); - if (device_allowed(dev) == false) { - message("device %s not on whitelist", dev.to_string()); - } - var is_new = false; string unique = dev.to_unique_string(); debug("device key: %s", unique); if (this.devices.has_key(unique) == false) { debug("adding new device with key: %s", unique); - this.devices.@set(unique, dev); + this.devices.@set(unique, + DeviceWrapper(make_device_path(), dev)); is_new = true; + } else { + var wrapper = this.devices.@get(unique); + dev = wrapper.device; + } + + if (device_allowed(dev)) { + dev.allowed = true; } // update devices cache @@ -136,24 +156,26 @@ class DeviceManager : GLib.Object if (dev.allowed) { // device is allowed - - if (is_new) { - dev.paired.connect((d, p) => { - device_paired(d, p); - }); - - dev.disconnected.connect((d) => { - device_disconnected(d); - }); - dev.activate(); - } else { - debug("activate from device"); - var known_dev = this.devices.@get(unique); - known_dev.activate_from_device(dev); - } + activate_device(dev); + } else { + message("skipping device %s activation, device not allowed", dev.to_string()); } } + private void activate_device(Device dev) { + info("activating device %s", dev.to_string()); + + dev.paired.connect((d, p) => { + device_paired(d, p); + }); + + dev.disconnected.connect((d) => { + device_disconnected(d); + }); + + dev.activate_from_device(dev); + } + private bool device_allowed(Device dev) { if (dev.allowed) return true; @@ -162,16 +184,22 @@ class DeviceManager : GLib.Object var in_config = core.config.is_device_allowed(dev.device_name, dev.device_type); - dev.allowed = in_config; return in_config; } private void device_paired(Device dev, bool status) { + info("device %s pair status change: %s", + dev.to_string(), status.to_string()); + if (status == true) { var core = Core.instance(); // register message handlers core.handlers.use_device(dev); + } else { + // we're not paired anymore, deactivate if needed + dev.deactivate(); } + } private void device_disconnected(Device dev) { @@ -185,7 +213,26 @@ class DeviceManager : GLib.Object * Allow given device */ public void allow_device(string path) { + debug("allow device %s", path); + Device dev = null; + foreach (var dw in this.devices.values) { + if (dw.object_path == path) + dev = dw.device; + } + + if (dev == null) { + warning("device with path %s not found", path); + return; + } + + dev.allowed = true; + + // update device cache + update_cache(); + + // maybe activate if needed + activate_device(dev); } /** @@ -195,7 +242,10 @@ class DeviceManager : GLib.Object */ public ObjectPath[] list_devices() { ObjectPath[] devices = {}; + + foreach (var dw in this.devices.values) { + devices += dw.object_path; + } return devices; } - } \ No newline at end of file From 14f051f675b4456f67cab1482779727b938aff70 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 18:26:01 +0200 Subject: [PATCH 014/100] mconnect: use DBus proxies for devicemanager and device --- Makefile.am | 2 + src/mconnect/application.vala | 16 +++- src/mconnect/device-proxy.vala | 41 ++++++++++ src/mconnect/devicemanager-proxy.vala | 108 ++++++++++++++++++++++++++ src/mconnect/devicemanager.vala | 84 ++++---------------- 5 files changed, 177 insertions(+), 74 deletions(-) create mode 100644 src/mconnect/device-proxy.vala create mode 100644 src/mconnect/devicemanager-proxy.vala diff --git a/Makefile.am b/Makefile.am index b71a7bb..7bfcdb4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,7 +56,9 @@ mconnect_SOURCES = \ src/mconnect/discovery.vala \ src/mconnect/packet.vala \ src/mconnect/device.vala \ + src/mconnect/device-proxy.vala \ src/mconnect/devicemanager.vala \ + src/mconnect/devicemanager-proxy.vala \ src/mconnect/devicechannel.vala \ src/mconnect/core.vala \ src/mconnect/packethandlerinterface.vala \ diff --git a/src/mconnect/application.vala b/src/mconnect/application.vala index 4dc9a41..949f75e 100644 --- a/src/mconnect/application.vala +++ b/src/mconnect/application.vala @@ -33,6 +33,7 @@ namespace Mconn { private Discovery discovery = null; private DeviceManager manager = null; + private DeviceManagerDBusProxy bus_manager = null; public Application() { Object(application_id: "org.mconnect"); @@ -60,8 +61,9 @@ namespace Mconn { Notify.init("mconnect"); discovery.device_found.connect((disc, dev) => { - manager.found_device(dev); + manager.handle_new_device(dev); }); + try { discovery.listen(); } catch (Error e) { @@ -76,15 +78,21 @@ namespace Mconn { hold(); } - public override bool dbus_register(DBusConnection conn, string object_path) throws Error { + public override bool dbus_register(DBusConnection conn, + string object_path) throws Error { + + this.bus_manager = new DeviceManagerDBusProxy.with_manager(conn, + this.manager); + this.bus_manager.publish(); base.dbus_register(conn, object_path); debug("dbus register, path %s", object_path); - conn.register_object("/org/mconnect/manager", manager); return true; } - public override void dbus_unregister(DBusConnection conn, string object_path) { + public override void dbus_unregister(DBusConnection conn, + string object_path) { + base.dbus_unregister(conn, object_path); debug("dbus unregister, path %s", object_path); } diff --git a/src/mconnect/device-proxy.vala b/src/mconnect/device-proxy.vala new file mode 100644 index 0000000..4118fa2 --- /dev/null +++ b/src/mconnect/device-proxy.vala @@ -0,0 +1,41 @@ +/* ex:ts=4:sw=4:sts=4:et */ +/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * AUTHORS + * Maciek Borzecki + */ + +/** + * General device wrapper. + */ +[DBus (name = "org.mconnect.Device")] +class DeviceDBusProxy : Object { + + public string device_id { get; private set; default = ""; } + public string device_name { get; private set; default = ""; } + public string device_type { get; private set; default = ""; } + public uint protocol_version {get; private set; default = 5; } + public string address { get; private set; default = ""; } + public bool is_paired { get; private set; default = false; } + public bool allowed {get; set; default = false; } + + [DBus (visible = false)] + public Device device {get; private set; default = null; } + + public DeviceDBusProxy.for_device(Device device) { + this.device = device; + } +} \ No newline at end of file diff --git a/src/mconnect/devicemanager-proxy.vala b/src/mconnect/devicemanager-proxy.vala new file mode 100644 index 0000000..546ca7f --- /dev/null +++ b/src/mconnect/devicemanager-proxy.vala @@ -0,0 +1,108 @@ +/* ex:ts=4:sw=4:sts=4:et */ +/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * AUTHORS + * Maciek Borzecki + */ +using Gee; + +[DBus (name = "org.mconnect.DeviceManager")] +class DeviceManagerDBusProxy : Object +{ + private DeviceManager manager; + + private const string DBUS_PATH = "/org/mconnect/manager"; + private DBusConnection bus = null; + private HashMap devices; + + private int device_idx = 0; + + public DeviceManagerDBusProxy.with_manager(DBusConnection bus, + DeviceManager manager) { + this.manager = manager; + this.bus = bus; + this.devices = new HashMap(); + + manager.found_device.connect((d) => { + this.add_device(d); + }); + } + + [DBus (visible = false)] + public void publish() throws IOError { + assert(this.bus != null); + + this.bus.register_object(DBUS_PATH, this); + } + + /** + * allow_device: + * @path: device object path + * + * Allow given device + */ + public void allow_device(string path) { + debug("allow device %s", path); + + var dev_proxy = this.devices.@get(path); + + this.manager.allow_device(dev_proxy.device); + } + + /** + * list_devices: + * + * Returns a list of DBus paths of all known devices + */ + public ObjectPath[] list_devices() { + ObjectPath[] devices = {}; + + foreach (var path in this.devices.keys) { + devices += new ObjectPath(path); + } + return devices; + } + + private void add_device(Device dev) { + var device_proxy = new DeviceDBusProxy.for_device(dev); + var path = make_device_path(); + + this.devices.@set(path, device_proxy); + + info("register device %s under path %s", + dev.to_string(), path); + try { + this.bus.register_object(path, device_proxy); + } catch (IOError err) { + warning("failed to register DBus object for device %s under path %s", + dev.to_string(), path); + } + } + + /** + * make_device_path: + * + * return device path string that can be used as ObjectPath + */ + private string make_device_path() { + var path = "/org/mconnect/device/%d".printf(this.device_idx); + + // bump device index + this.device_idx++; + + return path; + } +} \ No newline at end of file diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 86131c6..1d39a76 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -19,32 +19,18 @@ */ using Gee; -[DBus (name = "org.mconnect.DeviceManager")] class DeviceManager : GLib.Object { - public const string DEVICES_CACHE_FILE = "devices"; - - private HashMap devices; - private int device_idx = 0; - - /** - * DBus wrapper for devices - */ - private struct DeviceWrapper { - ObjectPath object_path; - Device device; + public signal void found_device(Device dev); - DeviceWrapper (string path, Device device) { - this.object_path = new ObjectPath(path); - this.device = device; - } - } + public const string DEVICES_CACHE_FILE = "devices"; + private HashMap devices; public DeviceManager() { debug("device manager.."); - this.devices = new HashMap(); + this.devices = new HashMap(); } /** @@ -100,8 +86,7 @@ class DeviceManager : GLib.Object var kf = new KeyFile(); - foreach (var wrapper in devices.values) { - var dev = wrapper.device; + foreach (var dev in devices.values) { dev.to_cache(kf, dev.device_name); } @@ -115,38 +100,24 @@ class DeviceManager : GLib.Object } } - /** - * make_device_path: - * - * return device path string that can be used as ObjectPath - */ - private string make_device_path() { - var path = "/org/mconnect/device/%d".printf(this.device_idx); - - // bump device index - device_idx++; - - return path; - } - [DBus (visible = false)] - public void found_device(Device dev) { - debug("found device: %s", dev.to_string()); + public void handle_new_device(Device new_dev) { + debug("found device: %s", new_dev.to_string()); var is_new = false; - string unique = dev.to_unique_string(); + string unique = new_dev.to_unique_string(); debug("device key: %s", unique); if (this.devices.has_key(unique) == false) { debug("adding new device with key: %s", unique); - this.devices.@set(unique, - DeviceWrapper(make_device_path(), dev)); + + this.devices.@set(unique, new_dev); + is_new = true; - } else { - var wrapper = this.devices.@get(unique); - dev = wrapper.device; } + var dev = this.devices.@get(unique); + if (device_allowed(dev)) { dev.allowed = true; } @@ -212,20 +183,7 @@ class DeviceManager : GLib.Object * * Allow given device */ - public void allow_device(string path) { - debug("allow device %s", path); - - Device dev = null; - foreach (var dw in this.devices.values) { - if (dw.object_path == path) - dev = dw.device; - } - - if (dev == null) { - warning("device with path %s not found", path); - return; - } - + public void allow_device(Device dev) { dev.allowed = true; // update device cache @@ -234,18 +192,4 @@ class DeviceManager : GLib.Object // maybe activate if needed activate_device(dev); } - - /** - * list_devices: - * - * Returns a list of DBus paths of all known devices - */ - public ObjectPath[] list_devices() { - ObjectPath[] devices = {}; - - foreach (var dw in this.devices.values) { - devices += dw.object_path; - } - return devices; - } } \ No newline at end of file From e10ff4a15c61fc39aa5c233b2a33797791dcaa50 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 22:03:06 +0200 Subject: [PATCH 015/100] device: class is no longer expored over DBus, drop all DBus related attributes --- src/mconnect/device.vala | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 09bcdcb..2fefd13 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -21,16 +21,11 @@ /** * General device wrapper. */ -[DBus (name = "org.mconnect.Device")] class Device : Object { - [DBus (visible = false)] public signal void paired(bool pair); - [DBus (visible = false)] public signal void connected(); - [DBus (visible = false)] public signal void disconnected(); - [DBus (visible = false)] public signal void message(Packet pkt); public string device_id { get; private set; default = ""; } @@ -38,7 +33,6 @@ class Device : Object { public string device_type { get; private set; default = ""; } public uint protocol_version {get; private set; default = 5; } public uint tcp_port {get; private set; default = 1714; } - [DBus (visible = false)] public InetAddress host { get; private set; default = null; } public bool is_paired { get; private set; default = false; } public bool allowed {get; set; default = false; } @@ -116,12 +110,10 @@ class Device : Object { /** * Generates a unique string for this device */ - [DBus (visible = false)] public string to_unique_string() { return this.to_string().replace(" ", "-"); } - [DBus (visible = false)] public string to_string() { return "%s-%s-%s-%u".printf(this.device_id, this.device_name, this.device_type, this.protocol_version); @@ -133,7 +125,6 @@ class Device : Object { * @cache: device cache * @name: group name */ - [DBus (visible = false)] public void to_cache(KeyFile cache, string name) { cache.set_string(name, "deviceId", this.device_id); cache.set_string(name, "deviceName", this.device_name); @@ -162,7 +153,6 @@ class Device : Object { * * @param expect_response se to true if expecting a response */ - [DBus (visible = false)] public async void pair(bool expect_response = true) { if (this.host != null) { debug("start pairing"); @@ -177,7 +167,6 @@ class Device : Object { } } - [DBus (visible = false)] public void pair_if_needed() { if (is_paired == false && _pair_in_progress == false) this.pair.begin(); @@ -189,7 +178,6 @@ class Device : Object { * Activate device. Triggers sending of #paired signal after * successfuly opening a connection. */ - [DBus (visible = false)] public void activate() { assert(_channel == null); @@ -212,7 +200,6 @@ class Device : Object { * * Deactivate device */ - [DBus (visible = false)] public void deactivate() { if (_channel != null) _channel.close.begin((c) => { @@ -230,7 +217,6 @@ class Device : Object { * * @param dev device */ - [DBus (visible = false)] public void activate_from_device(Device dev) { if (host == null) { host = dev.host; From c68ac52d97ae480a48f8799bd7d8e2fdc0c750df Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 22:05:03 +0200 Subject: [PATCH 016/100] device-proxy: cleanup exported properties --- src/mconnect/device-proxy.vala | 39 ++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/mconnect/device-proxy.vala b/src/mconnect/device-proxy.vala index 4118fa2..7215305 100644 --- a/src/mconnect/device-proxy.vala +++ b/src/mconnect/device-proxy.vala @@ -24,18 +24,45 @@ [DBus (name = "org.mconnect.Device")] class DeviceDBusProxy : Object { - public string device_id { get; private set; default = ""; } - public string device_name { get; private set; default = ""; } - public string device_type { get; private set; default = ""; } - public uint protocol_version {get; private set; default = 5; } + public string id { + get { return device.device_id; } + private set {} + default = ""; + } + public string name { + get { return device.device_name; } + private set {} + default = ""; + } + public string device_type { + get { return device.device_type; } + private set {} + default = ""; + } + public uint protocol_version { + get { return device.protocol_version; } + private set {} + default = 5; + } public string address { get; private set; default = ""; } - public bool is_paired { get; private set; default = false; } - public bool allowed {get; set; default = false; } + + public bool is_paired { + get { return device.is_paired; } + private set {} + default = false; + } + public bool allowed { + get { return device.allowed; } + private set {} + default = false; + } [DBus (visible = false)] public Device device {get; private set; default = null; } public DeviceDBusProxy.for_device(Device device) { this.device = device; + this.address = "%s:%u".printf(device.host.to_string(), + device.tcp_port); } } \ No newline at end of file From e2cd6500b2c8b46a29f256b127f657d1d9e51659 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 22:05:19 +0200 Subject: [PATCH 017/100] devicemanager: log that device is already known --- src/mconnect/devicemanager.vala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 1d39a76..7738d52 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -114,6 +114,8 @@ class DeviceManager : GLib.Object this.devices.@set(unique, new_dev); is_new = true; + } else { + debug("device %s already present", unique); } var dev = this.devices.@get(unique); From 3c3687ad59aed79ce84b95722ea3139581c088b5 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 22:12:07 +0200 Subject: [PATCH 018/100] devicemanager-proxy: check if there is a device associated with given path --- src/mconnect/devicemanager-proxy.vala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mconnect/devicemanager-proxy.vala b/src/mconnect/devicemanager-proxy.vala index 546ca7f..5682a5c 100644 --- a/src/mconnect/devicemanager-proxy.vala +++ b/src/mconnect/devicemanager-proxy.vala @@ -59,6 +59,11 @@ class DeviceManagerDBusProxy : Object var dev_proxy = this.devices.@get(path); + if (dev_proxy == null) { + warning("no device under path %s", path); + return; + } + this.manager.allow_device(dev_proxy.device); } From bb45b127514293d22482296646d570734e07773e Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 22:19:04 +0200 Subject: [PATCH 019/100] devicemanager, proxy: proper 'new device' signal --- src/mconnect/devicemanager-proxy.vala | 2 +- src/mconnect/devicemanager.vala | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mconnect/devicemanager-proxy.vala b/src/mconnect/devicemanager-proxy.vala index 5682a5c..9a962f4 100644 --- a/src/mconnect/devicemanager-proxy.vala +++ b/src/mconnect/devicemanager-proxy.vala @@ -36,7 +36,7 @@ class DeviceManagerDBusProxy : Object this.bus = bus; this.devices = new HashMap(); - manager.found_device.connect((d) => { + manager.found_new_device.connect((d) => { this.add_device(d); }); } diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 7738d52..ef01211 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -21,7 +21,7 @@ using Gee; class DeviceManager : GLib.Object { - public signal void found_device(Device dev); + public signal void found_new_device(Device dev); public const string DEVICES_CACHE_FILE = "devices"; @@ -67,7 +67,7 @@ class DeviceManager : GLib.Object var dev = Device.new_from_cache(kf, group); if (dev != null) { debug("device %s from cache", dev.to_string()); - found_device(dev); + handle_new_device(dev); } } } catch (Error e) { @@ -133,6 +133,11 @@ class DeviceManager : GLib.Object } else { message("skipping device %s activation, device not allowed", dev.to_string()); } + + // notify everyone that a new device appeared + if (is_new) { + found_new_device(dev); + } } private void activate_device(Device dev) { From 3e3bcf00830a35d11dc26a1f9372e228b7fedcf7 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 22:20:30 +0200 Subject: [PATCH 020/100] devicemanager: check if device is enabled in config only when needed --- src/mconnect/devicemanager.vala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index ef01211..7100414 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -120,7 +120,9 @@ class DeviceManager : GLib.Object var dev = this.devices.@get(unique); - if (device_allowed(dev)) { + info("allowed? %s", dev.allowed.to_string()); + // check if device is whitelisted in configuration + if (!dev.allowed && device_allowed_in_config(dev)) { dev.allowed = true; } @@ -154,7 +156,13 @@ class DeviceManager : GLib.Object dev.activate_from_device(dev); } - private bool device_allowed(Device dev) { + /** + * device_allowed_in_config: + * @dev device + * + * Returns true if a matching device is enabled via configuration file. + */ + private bool device_allowed_in_config(Device dev) { if (dev.allowed) return true; From b30ffb7ddf0964c2392cfc5233ca5622e380f09c Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 22:41:05 +0200 Subject: [PATCH 021/100] mousepad, battery: reduce chatter --- src/mconnect/battery.vala | 2 -- src/mconnect/mousepad.vala | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/mconnect/battery.vala b/src/mconnect/battery.vala index 14f31de..f8f7448 100644 --- a/src/mconnect/battery.vala +++ b/src/mconnect/battery.vala @@ -37,9 +37,7 @@ class BatteryHandler : Object, PacketHandlerInterface { public void use_device(Device dev) { debug("use device %s for battery status updates", dev.to_string()); dev.message.connect((d, pkt) => { - debug("message signal"); if (pkt.pkt_type == BATTERY) { - debug("is battery packet"); this.message(pkt); } }); diff --git a/src/mconnect/mousepad.vala b/src/mconnect/mousepad.vala index 38f3adf..4160185 100644 --- a/src/mconnect/mousepad.vala +++ b/src/mconnect/mousepad.vala @@ -48,9 +48,7 @@ class MousepadHandler : Object, PacketHandlerInterface { public void use_device(Device dev) { debug("use device %s for battery status updates", dev.to_string()); dev.message.connect((d, pkt) => { - debug("message signal"); if (pkt.pkt_type == MOUSEPAD) { - debug("mousepad packet"); this.message(pkt); } }); From 6c8bf2ee6795feecc7d94500d7d7ba9b8209d10a Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 22:57:02 +0200 Subject: [PATCH 022/100] devicechannel, device: channel close need not be async --- src/mconnect/device.vala | 20 +++++++++++++------- src/mconnect/devicechannel.vala | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 2fefd13..79bc681 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -201,10 +201,9 @@ class Device : Object { * Deactivate device */ public void deactivate() { - if (_channel != null) - _channel.close.begin((c) => { - channel_closed_cleanup(); - }); + if (_channel != null) { + close_and_cleanup(); + } } /** @@ -285,6 +284,10 @@ class Device : Object { assert(pkt.pkt_type == Packet.PAIR); bool pair = pkt.body.get_boolean_member("pair"); + + debug("pair in progress: %s is paired: %s pair: %s", + _pair_in_progress.to_string(), this.is_paired.to_string(), + pair.to_string()); if (_pair_in_progress == true) { // response to host initiated pairing if (pair == true) { @@ -319,9 +322,12 @@ class Device : Object { private void handle_disconnect() { // channel got disconnected debug("channel disconnected"); - _channel.close.begin((c) => { - channel_closed_cleanup(); - }); + close_and_cleanup(); + } + + private void close_and_cleanup() { + _channel.close(); + channel_closed_cleanup(); } /** diff --git a/src/mconnect/devicechannel.vala b/src/mconnect/devicechannel.vala index d61cbe5..493ddc7 100644 --- a/src/mconnect/devicechannel.vala +++ b/src/mconnect/devicechannel.vala @@ -118,7 +118,7 @@ class DeviceChannel : Object { return true; } - public async void close() { + public void close() { debug("closing connection"); if (_srcid > 0) { From ca4c09cb28e41243f1a302cba37481eb84a43766 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 23:01:37 +0200 Subject: [PATCH 023/100] devicemanager: device managed is not directly exported to DBus, cleanup DBus attributes --- src/mconnect/devicemanager.vala | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 7100414..819b6e5 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -51,7 +51,6 @@ class DeviceManager : GLib.Object /** * Load known devices from cache and attempt pairing. */ - [DBus (visible = false)] public void load_cache() { debug("try loading devices from device cache"); @@ -100,7 +99,6 @@ class DeviceManager : GLib.Object } } - [DBus (visible = false)] public void handle_new_device(Device new_dev) { debug("found device: %s", new_dev.to_string()); From b6ec6e455e844193835db23ed5625283c99d7502 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 23:46:17 +0200 Subject: [PATCH 024/100] packethandlers: allow releasing of a device (eg. when device is no longer paired) --- src/mconnect/battery.vala | 17 +++++++++++------ src/mconnect/mousepad.vala | 19 ++++++++++++------- src/mconnect/notification.vala | 15 +++++++++------ src/mconnect/packethandlerinterface.vala | 2 ++ src/mconnect/packethandlers.vala | 6 ++++++ src/mconnect/telephony.vala | 16 ++++++++++------ 6 files changed, 50 insertions(+), 25 deletions(-) diff --git a/src/mconnect/battery.vala b/src/mconnect/battery.vala index f8f7448..70a9e34 100644 --- a/src/mconnect/battery.vala +++ b/src/mconnect/battery.vala @@ -36,14 +36,19 @@ class BatteryHandler : Object, PacketHandlerInterface { public void use_device(Device dev) { debug("use device %s for battery status updates", dev.to_string()); - dev.message.connect((d, pkt) => { - if (pkt.pkt_type == BATTERY) { - this.message(pkt); - } - }); + dev.message.connect(this.message); } - public void message(Packet pkt) { + public void release_device(Device dev) { + debug("release device %s", dev.to_string()); + dev.message.disconnect(this.message); + } + + public void message(Device dev, Packet pkt) { + if (pkt.pkt_type != BATTERY) { + return; + } + debug("got battery packet"); int64 level = pkt.body.get_int_member("currentCharge"); diff --git a/src/mconnect/mousepad.vala b/src/mconnect/mousepad.vala index 4160185..5c7ae07 100644 --- a/src/mconnect/mousepad.vala +++ b/src/mconnect/mousepad.vala @@ -46,15 +46,20 @@ class MousepadHandler : Object, PacketHandlerInterface { } public void use_device(Device dev) { - debug("use device %s for battery status updates", dev.to_string()); - dev.message.connect((d, pkt) => { - if (pkt.pkt_type == MOUSEPAD) { - this.message(pkt); - } - }); + debug("use device %s for mouse/keyboard input", dev.to_string()); + dev.message.connect(this.message); } - public void message(Packet pkt) { + public void release_device(Device dev) { + debug("release device %s ", dev.to_string()); + dev.message.disconnect(this.message); + } + + private void message(Device dev, Packet pkt) { + if (pkt.pkt_type != MOUSEPAD) { + return; + } + debug("got mousepad packet"); if (_display == null) { diff --git a/src/mconnect/notification.vala b/src/mconnect/notification.vala index 8876465..db08f78 100644 --- a/src/mconnect/notification.vala +++ b/src/mconnect/notification.vala @@ -38,14 +38,17 @@ class NotificationHandler : Object, PacketHandlerInterface { } public void use_device(Device dev) { - dev.message.connect((d, pkt) => { - if (pkt.pkt_type == NOTIFICATION) { - this.message(pkt); - } - }); + dev.message.connect(this.message); + } + + public void release_device(Device dev) { + dev.message.disconnect(this.message); } - public void message(Packet pkt) { + public void message(Device dev, Packet pkt) { + if (pkt.pkt_type != NOTIFICATION) { + return; + } debug("got notification packet"); // get application ID diff --git a/src/mconnect/packethandlerinterface.vala b/src/mconnect/packethandlerinterface.vala index 1688d14..e814e50 100644 --- a/src/mconnect/packethandlerinterface.vala +++ b/src/mconnect/packethandlerinterface.vala @@ -24,4 +24,6 @@ interface PacketHandlerInterface : Object { public abstract void use_device(Device dev); + public abstract void release_device(Device dev); + } \ No newline at end of file diff --git a/src/mconnect/packethandlers.vala b/src/mconnect/packethandlers.vala index 3d81f0c..c40b28c 100644 --- a/src/mconnect/packethandlers.vala +++ b/src/mconnect/packethandlers.vala @@ -69,4 +69,10 @@ class PacketHandlers : Object { h.use_device(dev); }); } + + public void release_device(Device dev) { + _handlers.foreach((h) => { + h.release_device(dev); + }); + } } \ No newline at end of file diff --git a/src/mconnect/telephony.vala b/src/mconnect/telephony.vala index 407349f..9f2a9c1 100644 --- a/src/mconnect/telephony.vala +++ b/src/mconnect/telephony.vala @@ -36,14 +36,18 @@ class TelephonyHandler : Object, PacketHandlerInterface { } public void use_device(Device dev) { - dev.message.connect((d, pkt) => { - if (pkt.pkt_type == TELEPHONY) { - this.message(pkt); - } - }); + dev.message.connect(this.message); + } + + public void release_device(Device dev) { + dev.message.disconnect(this.message); } - public void message(Packet pkt) { + public void message(Device dev, Packet pkt) { + if (pkt.pkt_type != TELEPHONY) { + return; + } + debug("got telephony packet"); if (pkt.body.has_member("phoneNumber") == false || From 874f2f097169da23d7c8668e6a7e2e89f394793f Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 23:47:04 +0200 Subject: [PATCH 025/100] device: reduce chatter --- src/mconnect/device.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 79bc681..5cb479b 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -267,7 +267,6 @@ class Device : Object { paired(true); } - debug("signal packet"); // emit signal message(pkt); } From b06936c5066c03c3bc7c881f6d0e3641f39e8b3b Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 23:47:16 +0200 Subject: [PATCH 026/100] device: add is_active property indicated is communication with device is possible --- src/mconnect/device.vala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 5cb479b..b205235 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -36,6 +36,11 @@ class Device : Object { public InetAddress host { get; private set; default = null; } public bool is_paired { get; private set; default = false; } public bool allowed {get; set; default = false; } + public bool is_active { + get { return (_channel != null); } + set {} + default = false; + } // set to true if pair request was sent private bool _pair_in_progress = false; From 5145f40fdc1157f369378b410f1a1b5622e09f5f Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 1 Jun 2017 23:47:54 +0200 Subject: [PATCH 027/100] devicemanager: cleanup device signal handling, prevent duplicated signals Cleanup device signals handling. Fix a problem with duplicated signals from Device which were a result of same signal callback being registered multiple times. --- src/mconnect/devicemanager.vala | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 819b6e5..4beffa4 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -143,15 +143,12 @@ class DeviceManager : GLib.Object private void activate_device(Device dev) { info("activating device %s", dev.to_string()); - dev.paired.connect((d, p) => { - device_paired(d, p); - }); + if (!dev.is_active) { + dev.paired.connect(this.device_paired); + dev.disconnected.connect(this.device_disconnected); - dev.disconnected.connect((d) => { - device_disconnected(d); - }); - - dev.activate_from_device(dev); + dev.activate_from_device(dev); + } } /** @@ -175,11 +172,17 @@ class DeviceManager : GLib.Object info("device %s pair status change: %s", dev.to_string(), status.to_string()); + var core = Core.instance(); + if (status == true) { - var core = Core.instance(); // register message handlers core.handlers.use_device(dev); } else { + core.handlers.release_device(dev); + + // we're no longer interested in paired singnal + dev.paired.disconnect(this.device_paired); + // we're not paired anymore, deactivate if needed dev.deactivate(); } @@ -188,6 +191,7 @@ class DeviceManager : GLib.Object private void device_disconnected(Device dev) { debug("device %s got disconnected", dev.to_string()); + dev.disconnected.disconnect(this.device_disconnected); } /** From d9bd439d5d1ed228a2931d53f91d46d0c067453b Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 4 Jun 2017 12:18:27 +0200 Subject: [PATCH 028/100] device: rejected pairing should be logged as warning Otherwise debugging with G_DEBUG=fatal-criticals is not possible. --- src/mconnect/device.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index b205235..c7180f4 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -298,7 +298,7 @@ class Device : Object { debug("device is paired, pairing complete"); this.is_paired = true; } else { - critical("pairing rejected by device"); + warning("pairing rejected by device"); this.is_paired = false; } // pair completed From fa72198c408389f471fb4e3ced11370aad1b5da7 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 4 Jun 2017 12:25:04 +0200 Subject: [PATCH 029/100] build: add run-gdb target Add make target 'run-gdb' that will automatically start gdb with G_MESSAGES_DEBUG=all and G_DEBUG=fatal-criticals environment variables. --- Makefile.am | 10 ++++++++++ gdb-script.in | 4 ++++ 2 files changed, 14 insertions(+) create mode 100644 gdb-script.in diff --git a/Makefile.am b/Makefile.am index 7bfcdb4..1e53974 100644 --- a/Makefile.am +++ b/Makefile.am @@ -142,6 +142,16 @@ git-source-dist: #------------------------------------------------------------- +run-gdb: gdb-script install + gdb -x gdb-script + +.PHONY: run-gdb + +gdb-script: gdb-script.in + sed -e 's,[@]bindir[@],${bindir},g' < $< > $@ + +#------------------------------------------------------------- + GEN_FROM_VALA = $(filter %.vala,$(mconnect_SOURCES)) BUILT_SOURCES = \ mconnect.desktop \ diff --git a/gdb-script.in b/gdb-script.in new file mode 100644 index 0000000..f1051ba --- /dev/null +++ b/gdb-script.in @@ -0,0 +1,4 @@ +set environment G_MESSAGES_DEBUG = all +set environment G_DEBUG = fatal-criticals +file @bindir@/mconnect +run \ No newline at end of file From 4b2153c9f76f62a7fad09f01ef18096191dd0725 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 4 Jun 2017 12:47:55 +0200 Subject: [PATCH 030/100] discovereddevice: split device that was found through discovery process from Device --- Makefile.am | 1 + src/mconnect/application.vala | 4 +- src/mconnect/device.vala | 22 +++++------ src/mconnect/devicemanager.vala | 10 ++++- src/mconnect/discovereddevice.vala | 61 ++++++++++++++++++++++++++++++ src/mconnect/discovery.vala | 6 +-- 6 files changed, 84 insertions(+), 20 deletions(-) create mode 100644 src/mconnect/discovereddevice.vala diff --git a/Makefile.am b/Makefile.am index 1e53974..e946c95 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,6 +56,7 @@ mconnect_SOURCES = \ src/mconnect/discovery.vala \ src/mconnect/packet.vala \ src/mconnect/device.vala \ + src/mconnect/discovereddevice.vala \ src/mconnect/device-proxy.vala \ src/mconnect/devicemanager.vala \ src/mconnect/devicemanager-proxy.vala \ diff --git a/src/mconnect/application.vala b/src/mconnect/application.vala index 949f75e..3d03db2 100644 --- a/src/mconnect/application.vala +++ b/src/mconnect/application.vala @@ -60,8 +60,8 @@ namespace Mconn { Notify.init("mconnect"); - discovery.device_found.connect((disc, dev) => { - manager.handle_new_device(dev); + discovery.device_found.connect((disc, discdev) => { + manager.handle_discovered_device(discdev); }); try { diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index c7180f4..534f472 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -57,19 +57,15 @@ class Device : Object { * @param pkt identity packet * @param host source host that the packet came from */ - public Device.from_identity(Packet pkt, InetAddress host) { - - debug("got packet: %s", pkt.to_string()); - - var body = pkt.body; - this.host = host; - this.device_name = body.get_string_member("deviceName"); - this.device_id = body.get_string_member("deviceId"); - this.device_type = body.get_string_member("deviceType"); - this.protocol_version = (int) body.get_int_member("protocolVersion"); - this.tcp_port = (uint) body.get_int_member("tcpPort"); - - debug("added new device: %s", this.to_string()); + public Device.from_discovered_device(DiscoveredDevice disc) { + this.host = disc.host; + this.device_name = disc.device_name; + this.device_id = disc.device_id; + this.device_type = disc.device_type; + this.protocol_version = disc.protocol_version; + this.tcp_port = disc.tcp_port; + + debug("new device: %s", this.to_string()); } /** diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 4beffa4..5d43f64 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -99,9 +99,15 @@ class DeviceManager : GLib.Object } } - public void handle_new_device(Device new_dev) { - debug("found device: %s", new_dev.to_string()); + public void handle_discovered_device(DiscoveredDevice discovered_dev) { + debug("found device: %s", discovered_dev.to_string()); + + var new_dev = new Device.from_discovered_device(discovered_dev); + handle_new_device(new_dev); + } + + public void handle_new_device(Device new_dev) { var is_new = false; string unique = new_dev.to_unique_string(); debug("device key: %s", unique); diff --git a/src/mconnect/discovereddevice.vala b/src/mconnect/discovereddevice.vala new file mode 100644 index 0000000..cb1a7c6 --- /dev/null +++ b/src/mconnect/discovereddevice.vala @@ -0,0 +1,61 @@ +/* ex:ts=4:sw=4:sts=4:et */ +/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * AUTHORS + * Maciek Borzecki + */ + +/** + * Newly discovered device wrapper. + */ +class DiscoveredDevice : Object { + + public string device_id { get; private set; default = ""; } + public string device_name { get; private set; default = ""; } + public string device_type { get; private set; default = ""; } + public uint protocol_version {get; private set; default = 5; } + public uint tcp_port {get; private set; default = 1714; } + public InetAddress host { get; private set; default = null; } + + /** + * Constructs DiscoveredDevice based on identity packet. + * + * @param pkt identity packet + * @param host source host that the packet came from + */ + public DiscoveredDevice.from_identity(Packet pkt, InetAddress host) { + + debug("got packet: %s", pkt.to_string()); + + var body = pkt.body; + this.host = host; + this.device_name = body.get_string_member("deviceName"); + this.device_id = body.get_string_member("deviceId"); + this.device_type = body.get_string_member("deviceType"); + this.protocol_version = (int) body.get_int_member("protocolVersion"); + this.tcp_port = (uint) body.get_int_member("tcpPort"); + + debug("discovered new device: %s", this.to_string()); + } + + public string to_string() { + return "discovered-%s-%s-%s-%u".printf(this.device_id, + this.device_name, + this.device_type, + this.protocol_version); + } + +} \ No newline at end of file diff --git a/src/mconnect/discovery.vala b/src/mconnect/discovery.vala index a6dadb0..2123fcb 100644 --- a/src/mconnect/discovery.vala +++ b/src/mconnect/discovery.vala @@ -22,10 +22,10 @@ class Discovery : GLib.Object { private Socket socket = null; - public signal void device_found(Device dev); + public signal void device_found(DiscoveredDevice dev); public Discovery() { - } + } ~Discovery() { debug("cleaning up discovery..."); @@ -91,7 +91,7 @@ class Discovery : GLib.Object return; } - var dev = new Device.from_identity(pkt, host); + var dev = new DiscoveredDevice.from_identity(pkt, host); message("connection from device: \'%s\', responds at: %s:%u", dev.device_name, host.to_string(), dev.tcp_port); From 01351bac98ca5ac1b77544fce939bd21261e2557 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 4 Jun 2017 13:06:05 +0200 Subject: [PATCH 031/100] devicechannel: convert ciriticals to warnings --- src/mconnect/devicechannel.vala | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mconnect/devicechannel.vala b/src/mconnect/devicechannel.vala index 493ddc7..97201dd 100644 --- a/src/mconnect/devicechannel.vala +++ b/src/mconnect/devicechannel.vala @@ -59,7 +59,7 @@ class DeviceChannel : Object { _conn = yield client.connect_async(_isa); } catch (Error e) { // - critical("failed to connect to %s:%u: %s", + warning("failed to connect to %s:%u: %s", _isa.address.to_string(), _isa.port, e.message); // emit disconnected @@ -130,19 +130,19 @@ class DeviceChannel : Object { if (_din != null) _din.close(); } catch (Error e) { - critical("failed to close data input: %s", e.message); + warning("failed to close data input: %s", e.message); } try { if (_dout != null) _dout.close(); } catch (Error e) { - critical("failed to close data output: %s", e.message); + warning("failed to close data output: %s", e.message); } try { if (_conn != null) _conn.close(); } catch (Error e) { - critical("failed to close connection: %s", e.message); + warning("failed to close connection: %s", e.message); } _din = null; _dout = null; @@ -162,7 +162,7 @@ class DeviceChannel : Object { try { _dout.put_string(to_send); } catch (IOError e) { - critical("failed to send message: %s", e.message); + warning("failed to send message: %s", e.message); // TODO disconnect? } } @@ -183,7 +183,7 @@ class DeviceChannel : Object { // expecting \n _din.read_byte(); } catch (IOError ie) { - debug("I/O error: %s", ie.message); + warning("I/O error: %s", ie.message); } if (data == null) { @@ -195,7 +195,7 @@ class DeviceChannel : Object { Packet pkt = Packet.new_from_data(data); if (pkt == null) { - critical("failed to build packet from data"); + warning("failed to build packet from data"); // data was received, hence connection is still alive return true; } @@ -233,7 +233,7 @@ class DeviceChannel : Object { // method. Json.Array arr = pkt.body.get_array_member("data"); if (arr == null) { - critical("missing data member in encrypted packet"); + warning("missing data member in encrypted packet"); return; } @@ -253,7 +253,7 @@ class DeviceChannel : Object { debug("data length: %zu", decrypted.data.length); msgbytes.append(decrypted.data); } catch (Error e) { - critical("decryption failed: %s", e.message); + warning("decryption failed: %s", e.message); failed = true; } }); @@ -266,7 +266,7 @@ class DeviceChannel : Object { Packet dec_pkt = Packet.new_from_data(decrypted_data); if (dec_pkt == null) { - critical("failed to parse decrypted packet"); + warning("failed to parse decrypted packet"); } else { packet_received(dec_pkt); } From e6e7f8d6d365b1fda81565fc6fcc275cb2b9a4d3 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 4 Jun 2017 13:06:27 +0200 Subject: [PATCH 032/100] devicemanager: release protocol packet handlers when device disconnects This prevents a protocol handler to be fired more than once. --- src/mconnect/devicemanager.vala | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 5d43f64..ebab09e 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -178,13 +178,11 @@ class DeviceManager : GLib.Object info("device %s pair status change: %s", dev.to_string(), status.to_string()); - var core = Core.instance(); - if (status == true) { // register message handlers - core.handlers.use_device(dev); + this.enable_protocol_handlers(dev); } else { - core.handlers.release_device(dev); + this.disable_protocol_handlers(dev); // we're no longer interested in paired singnal dev.paired.disconnect(this.device_paired); @@ -195,8 +193,22 @@ class DeviceManager : GLib.Object } + private void enable_protocol_handlers(Device dev) { + var core = Core.instance(); + core.handlers.use_device(dev); + } + + private void disable_protocol_handlers(Device dev) { + var core = Core.instance(); + core.handlers.release_device(dev); + } + private void device_disconnected(Device dev) { debug("device %s got disconnected", dev.to_string()); + + this.disable_protocol_handlers(dev); + + dev.paired.disconnect(this.device_paired); dev.disconnected.disconnect(this.device_disconnected); } From cac1ac1001217a28c0bebbcd7f371e148dea0717 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 4 Jun 2017 16:38:14 +0200 Subject: [PATCH 033/100] mconnectctl: sample client app for mconnect --- Makefile.am | 15 +- src/mconnectctl/main.vala | 308 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 322 insertions(+), 1 deletion(-) create mode 100644 src/mconnectctl/main.vala diff --git a/Makefile.am b/Makefile.am index e946c95..7ec3bb5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,7 +27,8 @@ mconnectdata_DATA = \ mconnect.conf bin_PROGRAMS = \ - mconnect + mconnect \ + mconnectctl noinst_PROGRAMS = \ test-mconn-crypt \ @@ -125,6 +126,18 @@ test_mconn_crypt_vala_VALAFLAGS = \ #------------------------------------------------------------- +mconnectctl_SOURCES = \ +src/mconnectctl/main.vala + +mconnectctl_LDADD = \ + $(MCONNECT_LIBS) + +mconnectctl_CFLAGS = \ + $(MCONNECT_CFLAGS) + + +#------------------------------------------------------------- + # configure will expand bindir to ${exec_prefix}/bin, we want the # whole thing, that's why mconnect.desktop is generated here and not # in configure diff --git a/src/mconnectctl/main.vala b/src/mconnectctl/main.vala new file mode 100644 index 0000000..17b93a1 --- /dev/null +++ b/src/mconnectctl/main.vala @@ -0,0 +1,308 @@ +/* ex:ts=4:sw=4:sts=4:et */ +/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * AUTHORS + * Maciek Borzecki + */ + +namespace Mconnect { + + [DBus (name = "org.mconnect.DeviceManager")] + public interface DeviceManagerIface : Object { + + public const string OBJECT_PATH = "/org/mconnect/manager"; + + public abstract ObjectPath[] ListDevices() throws IOError; + public abstract void AllowDevice(string path) throws IOError; + } + + [DBus (name = "org.mconnect.Device")] + public interface DeviceIface : Object { + + public abstract string id { owned get;} + public abstract string name { owned get;} + public abstract string device_type { owned get;} + public abstract uint protocol_version { owned get;} + public abstract string address { owned get;} + public abstract bool is_paired { owned get;} + public abstract bool allowed { owned get;} + } + + public class Client { + + private static bool log_debug = false; + // some hints for valac about the array holding remaining args + [CCode (array_length = false, array_null_terminated = true)] + private static string[] remaining; + private BusType bus_type = BusType.SESSION; + + private const OptionEntry[] options = { + {"debug", 'd', 0, OptionArg.NONE, ref log_debug, + "Show debug output", null}, + // there's no Vala const for G_OPTION_REMAINING (which is a #define + // for "") + {"", 0, 0, OptionArg.STRING_ARRAY, ref remaining, null, + "[COMMAND ..]"}, + {null} + }; + + /** + * Command: + * + * command line 'command' wrapper + */ + private struct Command { + string command; // textual command, ex. list, show, etc. + int arg_count; // number of required parameters, not including + // command + CommandFunc clbk; // callback + + Command(string command, int arg_count, CommandFunc clbk) { + this.command = command; + this.arg_count = arg_count; + this.clbk = clbk; + } + } + // command callback + private delegate int CommandFunc(string[] args); + + public static int main(string[] args) + { + try { + var opt_context = new OptionContext(); + opt_context.set_description( + """Available commands: + list-devices List devices + allow-device Allow device + show-device Show device details +""" + ); + opt_context.set_help_enabled(true); + opt_context.add_main_entries(options, null); + opt_context.parse(ref args); + } catch (OptionError e) { + stdout.printf("error: %s\n", e.message); + stdout.printf("Run '%s --help' to see a full " + + "list of available command line options.\n", + args[0]); + return 1; + } + + if (log_debug == true) + Environment.set_variable("G_MESSAGES_DEBUG", "all", false); + + var cl = new Client(); + + debug("remaining args"); + foreach (var s in remaining) { + debug("remaininig: %s", s); + } + Command[] commands = { + Command("list-devices", 0, cl.cmd_list_devices), + Command("allow-device", 1, cl.cmd_allow_device), + Command("show-device", 1, cl.cmd_show_device), + }; + handle_command(remaining, commands); + + return 0; + } + + /** + * handle_command: + * @args: remaining command line arguments + * @commands: supported commands array + * + * @return exit status of command or -1 on error + */ + private static int handle_command(string[] args, Command[] commands) { + // extract command and it's arguments if any + string command = "list-devices"; + + if (args.length > 0) + command = remaining[0]; + debug("command is: %s", command); + + string[] command_args = {}; + if (args.length > 1) + command_args = args[1:args.length]; + + foreach (var cmden in commands) { + if (cmden.command == command) { + debug("found match for %s, args expect: %zd, have: %zd", + command, cmden.arg_count, command_args.length); + + if (command_args.length != cmden.arg_count) { + stderr.printf("Incorrect number of arguments " + + "for command %s, see --help\n", + command); + return -1; + } + + debug("running callback"); + return cmden.clbk(command_args); + } + } + + stderr.printf("Incorrect command, see --help\n"); + return -1; + } + + private int cmd_list_devices(string[] args) { + return checked_dbus_call(() => { + var manager = get_manager(); + debug("list devices"); + var devs = manager.ListDevices(); + print_paths(devs, "Devices", + (path) => { + var dp = get_device(path); + return "%s - %s".printf(dp.id, dp.name); + }); + return 0; + }); + } + + private int cmd_allow_device(string[] args) { + return checked_dbus_call(() => { + var dp = args[0]; + var manager = get_manager(); + debug("allow device device %s", dp); + manager.AllowDevice(new ObjectPath(dp)); + return 0; + }); + } + + private int cmd_show_device(string[] args) { + return checked_dbus_call(() => { + var dp = get_device(new ObjectPath(args[0])); + + stdout.printf("Device\n" + + " Name: %s\n" + + " ID: %s\n" + + " Address: %s\n" + + " Type: %s\n" + + " Allowed: %s\n" + + " Paired: %s\n", + dp.name, + dp.id, + dp.address, + dp.device_type, + dp.allowed.to_string(), + dp.is_paired.to_string()); + return 0; + }); + } + + private delegate int CheckDBusCallFunc() throws Error; + /** + * checked_dbus_call: + * @clbk: function to wrap + * + * Catch any DBus errors and return appropriate status + */ + private static int checked_dbus_call(CheckDBusCallFunc clbk) { + try { + return clbk(); + } catch (IOError e) { + warning("communication returned an error: %s", e.message); + return -1; + } catch (DBusError e) { + warning("communication with service failed: %s", e.message); + } catch (Error e) { + warning("error: %s", e.message); + } + return 0; + } + + /** + * get_mconnect_obj_proxy: + * @path: DBus object path + * + * Obtain an interface to a DBus object avaialble at + * Mconnect service under @path. + * + * @return null or interface + */ + private T? get_mconnect_obj_proxy(ObjectPath path) { + T proxy_out = null; + try { + proxy_out = Bus.get_proxy_sync(bus_type, + "org.mconnect", + path); + } catch (Error e) { + warning("failed to obtain proxy to mconnect service: %s", + e.message); + } + return proxy_out; + } + + /** + * get_manager: + * + * Obtain DBus interface to Device Manager + * + * @return interface or null + */ + private DeviceManagerIface? get_manager() { + return get_mconnect_obj_proxy( + new ObjectPath(DeviceManagerIface.OBJECT_PATH)); + } + + /** + * get_device: + * @path device object path + * + * Obtain DBus interface to Device + * + * @return interface or null + */ + private DeviceIface? get_device(ObjectPath path) { + return get_mconnect_obj_proxy(path); + } + + /** + * print_paths: + * @objs: object paths + * @header: header for printing, + * @desc_clbk: callback for producing a meaningful description + * + * Print a list of object paths, possibly adding a description + */ + private static void print_paths(ObjectPath[] objs, string header, + GetDescFunc desc_clbk) { + if (objs.length == 0) + stdout.printf("No objects were found\n"); + else { + stdout.printf(header + ":\n"); + foreach (var o in objs) { + string desc = null; + + if (desc_clbk != null) { + debug("calling description callback for obj: %s", + o.to_string()); + desc = desc_clbk(o); + } + + stdout.printf(" %s", o.to_string()); + if (desc != null) + stdout.printf(" %s", desc); + stdout.printf("\n"); + } + } + } + + private delegate string GetDescFunc(ObjectPath obj_path); + } +} From eb114687b5488baa850d6e2d00b7ad48740280d6 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 4 Jun 2017 18:28:54 +0200 Subject: [PATCH 034/100] travis: switch to building inside containers Travis host images are quite outdated, so the builds will now use containers instead. By default there's a build for Arch Linux (using base/archlinux:latest image) and Fedora (using official fedora:latest). Builds are done using extra/travis-build script. --- .travis.yml | 28 +++-------- extra/travis-build | 118 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 20 deletions(-) create mode 100755 extra/travis-build diff --git a/.travis.yml b/.travis.yml index bf4ee49..9ec8548 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,10 @@ -# default 12.04 is ancient, use trusty instead -dist: trusty -# pretend we're building C -language: c -compiler: - - gcc +services: + - docker + env: - - VALAC=valac-0.32 -before_install: - - sudo add-apt-repository -y ppa:vala-team/ppa - - sudo apt-get update -qq - - sudo apt-get install -qq ${VALAC} valac - - sudo apt-get install -qq libgirepository1.0-dev - - sudo apt-get install -qq gir1.2-gee-0.8 libgee-0.8-dev - - sudo apt-get install -qq gir1.2-json-1.0 libjson-glib-dev - - sudo apt-get install -qq gir1.2-notify-0.7 libnotify-dev - - sudo apt-get install -qq gir1.2-atspi-2.0 libatspi2.0-dev - - sudo apt-get install -qq gir1.2-gtk-3.0 libgtk-3-dev -before_script: - - autoreconf -if + matrix: + - DISTRO=fedora + - DISTRO=archlinux + script: - - ./configure && make V=1 + - ./extra/travis-build "${DISTRO}" diff --git a/extra/travis-build b/extra/travis-build new file mode 100755 index 0000000..f95c075 --- /dev/null +++ b/extra/travis-build @@ -0,0 +1,118 @@ +#!/bin/bash -xe +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# AUTHORS +# Maciek Borzecki + +# Travis build script. The script reexecs itself inside the container (setting +# IN_CONTAINER=1). The proceeds to install build dependencies and runs through +# the whole build process. Source tree is bind-mounted at /mnt and the container +# has its workdir set to /mnt +# +# NOTE: it is assumed that the script is run while at the top of source tree +# (i.e. $PWD is your checked out tree, this crucial for properly mounting the +# source code into the container). + +deps_fedora() { + dnf install --best -y --refresh \ + automake \ + autoconf \ + libtool \ + pkgconfig \ + gcc \ + vala \ + gobject-introspection-devel \ + json-glib-devel \ + libgee-devel \ + openssl-devel \ + libnotify-devel \ + at-spi2-core-devel \ + gtk3-devel +} + +deps_archlinux() { + pacman -Syu --noconfirm \ + base-devel \ + autoconf \ + automake \ + libtool \ + pkg-config \ + gcc \ + vala \ + glib2 \ + gobject-introspection \ + json-glib \ + libgee \ + openssl \ + libnotify \ + at-spi2-core \ + gtk3 +} + +install_deps() { + case "$1" in + fedora) + deps_fedora + ;; + archlinux) + deps_archlinux + ;; + *) + echo "unsupported distro $1" + exit 1 + esac +} + +build() { + autoreconf -if + # TODO: out of source builds + ./configure + make + make install +} + +build_in_container() { + install_deps $1 + + build +} + +spin_container() { + case "$1" in + fedora) + DOCKER_IMG=fedora + ;; + archlinux) + DOCKER_IMG=base/archlinux + ;; + *) + echo "unsupported distro $1" + exit 1 + esac + + # run a container, mount sources at /mnt, st + docker run --rm \ + -v $PWD:/mnt \ + -w /mnt \ + -e IN_CONTAINER=1 \ + $DOCKER_IMG \ + /mnt/extra/travis-build "$@" +} + +if [ "$IN_CONTAINER" = "1" ]; then + build_in_container "$@" +else + spin_container "$@" +fi From 5718b5033021e2b98957fa1470cf5859e9aeefb0 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Mon, 5 Jun 2017 08:57:56 +0200 Subject: [PATCH 035/100] device, mconnectctl: export and show connection status Signed-off-by: Maciek Borzecki --- src/mconnect/device-proxy.vala | 5 +++++ src/mconnectctl/main.vala | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mconnect/device-proxy.vala b/src/mconnect/device-proxy.vala index 7215305..2865d51 100644 --- a/src/mconnect/device-proxy.vala +++ b/src/mconnect/device-proxy.vala @@ -56,6 +56,11 @@ class DeviceDBusProxy : Object { private set {} default = false; } + public bool is_active { + get { return device.is_active; } + private set {} + default = false; + } [DBus (visible = false)] public Device device {get; private set; default = null; } diff --git a/src/mconnectctl/main.vala b/src/mconnectctl/main.vala index 17b93a1..777279a 100644 --- a/src/mconnectctl/main.vala +++ b/src/mconnectctl/main.vala @@ -39,6 +39,7 @@ namespace Mconnect { public abstract string address { owned get;} public abstract bool is_paired { owned get;} public abstract bool allowed { owned get;} + public abstract bool is_active { owned get;} } public class Client { @@ -194,13 +195,15 @@ namespace Mconnect { " Address: %s\n" + " Type: %s\n" + " Allowed: %s\n" + - " Paired: %s\n", + " Paired: %s\n" + + " Connected: %s\n", dp.name, dp.id, dp.address, dp.device_type, dp.allowed.to_string(), - dp.is_paired.to_string()); + dp.is_paired.to_string(), + dp.is_active.to_string()); return 0; }); } From ea97bb695bec1f7a3b089708e36f806ab46cb320 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Mon, 5 Jun 2017 19:53:39 +0200 Subject: [PATCH 036/100] device-proxy: subscribe to device property changes --- src/mconnect/device-proxy.vala | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/mconnect/device-proxy.vala b/src/mconnect/device-proxy.vala index 2865d51..834ef44 100644 --- a/src/mconnect/device-proxy.vala +++ b/src/mconnect/device-proxy.vala @@ -67,7 +67,31 @@ class DeviceDBusProxy : Object { public DeviceDBusProxy.for_device(Device device) { this.device = device; + this.update_address(); + this.device.notify.connect(this.param_changed); + } + + private void update_address() { this.address = "%s:%u".printf(device.host.to_string(), device.tcp_port); } + + private void param_changed(ParamSpec param) { + debug("parameter %s changed", param.name); + switch (param.name) { + case "host": + case "tcp-port": + this.update_address(); + break; + case "allowed": + this.allowed = device.allowed; + break; + case "is-active": + this.is_active = device.is_active; + break; + case "is-paired": + this.is_paired = device.is_paired; + break; + } + } } \ No newline at end of file From eb04795e5056f4802f4a5a2ea2e9ece1d82a77f5 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Mon, 5 Jun 2017 20:04:59 +0200 Subject: [PATCH 037/100] mconnectctl: fix copying delegates --- src/mconnectctl/main.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mconnectctl/main.vala b/src/mconnectctl/main.vala index 777279a..a9812ac 100644 --- a/src/mconnectctl/main.vala +++ b/src/mconnectctl/main.vala @@ -69,7 +69,7 @@ namespace Mconnect { string command; // textual command, ex. list, show, etc. int arg_count; // number of required parameters, not including // command - CommandFunc clbk; // callback + unowned CommandFunc clbk; // callback Command(string command, int arg_count, CommandFunc clbk) { this.command = command; From ce4d156ec668f109201c13c6742b85ebf7f88c09 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Mon, 5 Jun 2017 20:07:26 +0200 Subject: [PATCH 038/100] mconnectctl: fix IOError handling --- src/mconnectctl/main.vala | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/mconnectctl/main.vala b/src/mconnectctl/main.vala index a9812ac..5284601 100644 --- a/src/mconnectctl/main.vala +++ b/src/mconnectctl/main.vala @@ -168,8 +168,13 @@ namespace Mconnect { var devs = manager.ListDevices(); print_paths(devs, "Devices", (path) => { - var dp = get_device(path); - return "%s - %s".printf(dp.id, dp.name); + try { + var dp = get_device(path); + return "%s - %s".printf(dp.id, dp.name); + } catch (IOError e) { + warning("error occurred: %s", e.message); + return "(error)"; + } }); return 0; }); @@ -238,15 +243,16 @@ namespace Mconnect { * * @return null or interface */ - private T? get_mconnect_obj_proxy(ObjectPath path) { + private T? get_mconnect_obj_proxy(ObjectPath path) throws IOError { T proxy_out = null; try { proxy_out = Bus.get_proxy_sync(bus_type, "org.mconnect", path); - } catch (Error e) { + } catch (IOError e) { warning("failed to obtain proxy to mconnect service: %s", e.message); + throw e; } return proxy_out; } @@ -258,7 +264,7 @@ namespace Mconnect { * * @return interface or null */ - private DeviceManagerIface? get_manager() { + private DeviceManagerIface? get_manager() throws IOError { return get_mconnect_obj_proxy( new ObjectPath(DeviceManagerIface.OBJECT_PATH)); } @@ -271,7 +277,7 @@ namespace Mconnect { * * @return interface or null */ - private DeviceIface? get_device(ObjectPath path) { + private DeviceIface? get_device(ObjectPath path) throws IOError { return get_mconnect_obj_proxy(path); } From d533b9a4e4047c471690f6c6ca5f5c12ec40645d Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Mon, 5 Jun 2017 20:12:11 +0200 Subject: [PATCH 039/100] mconnectctl: remove unnecessary logs --- src/mconnectctl/main.vala | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mconnectctl/main.vala b/src/mconnectctl/main.vala index 5284601..5946179 100644 --- a/src/mconnectctl/main.vala +++ b/src/mconnectctl/main.vala @@ -107,10 +107,6 @@ namespace Mconnect { var cl = new Client(); - debug("remaining args"); - foreach (var s in remaining) { - debug("remaininig: %s", s); - } Command[] commands = { Command("list-devices", 0, cl.cmd_list_devices), Command("allow-device", 1, cl.cmd_allow_device), From 994d507e9fc148540202addcc3474f23d8d7d96d Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Mon, 5 Jun 2017 21:43:04 +0200 Subject: [PATCH 040/100] devicemanager: activate device logs --- src/mconnect/devicemanager.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index ebab09e..9d23947 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -147,7 +147,8 @@ class DeviceManager : GLib.Object } private void activate_device(Device dev) { - info("activating device %s", dev.to_string()); + info("activating device %s, active: %s", dev.to_string(), + dev.is_active.to_string()); if (!dev.is_active) { dev.paired.connect(this.device_paired); From cc461462b02d4b929db7783fe8c576075f5511dc Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Mon, 5 Jun 2017 21:44:24 +0200 Subject: [PATCH 041/100] discovereddevice, device, device-proxy: outgoing/incoming capabilities --- src/mconnect/device-proxy.vala | 35 ++++++++++++++++++++++++++++++ src/mconnect/device.vala | 22 ++++++++++++++++++- src/mconnect/discovereddevice.vala | 14 ++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/src/mconnect/device-proxy.vala b/src/mconnect/device-proxy.vala index 834ef44..2db784f 100644 --- a/src/mconnect/device-proxy.vala +++ b/src/mconnect/device-proxy.vala @@ -62,18 +62,49 @@ class DeviceDBusProxy : Object { default = false; } + public string[] incoming_capabilities { + get; + private set; + } + + public string[] outgoing_capabilities { + get; + private set; + } + [DBus (visible = false)] public Device device {get; private set; default = null; } public DeviceDBusProxy.for_device(Device device) { this.device = device; this.update_address(); + this.update_capabilities(); this.device.notify.connect(this.param_changed); } + private void update_capabilities() { + string[] caps = {}; + foreach (var cap in device.incoming_capabilities) { + caps += cap; + } + this.incoming_capabilities = caps; + + caps = {}; + + foreach (var cap in device.outgoing_capabilities) { + caps += cap; + } + this.outgoing_capabilities = caps; + } + private void update_address() { this.address = "%s:%u".printf(device.host.to_string(), device.tcp_port); + this.device.notify.connect(this.update_properties); + } + + private void update_properties(ParamSpec param) { + debug("param %s changed", param.name); } private void param_changed(ParamSpec param) { @@ -92,6 +123,10 @@ class DeviceDBusProxy : Object { case "is-paired": this.is_paired = device.is_paired; break; + case "incoming-capabilities": + case "outgoing-capabilities": + this.update_capabilities(); + break; } } } \ No newline at end of file diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 534f472..ea71e1b 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -18,6 +18,8 @@ * Maciek Borzecki */ +using Gee; + /** * General device wrapper. */ @@ -41,6 +43,16 @@ class Device : Object { set {} default = false; } + public ArrayList outgoing_capabilities { + get; + private set; + default = null; + } + public ArrayList incoming_capabilities { + get; + private set; + default = null; + } // set to true if pair request was sent private bool _pair_in_progress = false; @@ -48,7 +60,8 @@ class Device : Object { private DeviceChannel _channel = null; private Device() { - + incoming_capabilities = new ArrayList(); + outgoing_capabilities = new ArrayList(); } /** @@ -64,6 +77,8 @@ class Device : Object { this.device_type = disc.device_type; this.protocol_version = disc.protocol_version; this.tcp_port = disc.tcp_port; + this.outgoing_capabilities = new ArrayList.wrap(disc.outgoing_capabilities); + this.incoming_capabilities = new ArrayList.wrap(disc.incoming_capabilities); debug("new device: %s", this.to_string()); } @@ -341,4 +356,9 @@ class Device : Object { // emit disconnected disconnected(); } + + public bool supports_capability(string capability) { + return outgoing_capabilities.contains(capability) || + incoming_capabilities.contains(capability); + } } \ No newline at end of file diff --git a/src/mconnect/discovereddevice.vala b/src/mconnect/discovereddevice.vala index cb1a7c6..8bbba3c 100644 --- a/src/mconnect/discovereddevice.vala +++ b/src/mconnect/discovereddevice.vala @@ -29,6 +29,8 @@ class DiscoveredDevice : Object { public uint protocol_version {get; private set; default = 5; } public uint tcp_port {get; private set; default = 1714; } public InetAddress host { get; private set; default = null; } + public string[] outgoing_capabilities { get; private set; default = null; } + public string[] incoming_capabilities { get; private set; default = null; } /** * Constructs DiscoveredDevice based on identity packet. @@ -48,6 +50,18 @@ class DiscoveredDevice : Object { this.protocol_version = (int) body.get_int_member("protocolVersion"); this.tcp_port = (uint) body.get_int_member("tcpPort"); + var incoming = body.get_array_member("incomingCapabilities"); + var outgoing = body.get_array_member("outgoingCapabilities"); + this.outgoing_capabilities = new string[outgoing.get_length()]; + this.incoming_capabilities = new string[incoming.get_length()]; + + incoming.foreach_element((a, i, n) => { + this.incoming_capabilities[i] = n.get_string(); + }); + outgoing.foreach_element((a, i, n) => { + this.outgoing_capabilities[i] = n.get_string(); + }); + debug("discovered new device: %s", this.to_string()); } From b5c740174f1262bd3ce680d62a9586009df9bf60 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Mon, 5 Jun 2017 21:40:52 +0200 Subject: [PATCH 042/100] packethandlers: enable only supported capabilities --- src/mconnect/packethandlers.vala | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/mconnect/packethandlers.vala b/src/mconnect/packethandlers.vala index c40b28c..d601079 100644 --- a/src/mconnect/packethandlers.vala +++ b/src/mconnect/packethandlers.vala @@ -64,9 +64,35 @@ class PacketHandlers : Object { // return interfaces; } - public void use_device(Device dev) { + /** + * SupportedCapabilityFunc: + * @capability: capability name + * @handler: packet handler + * + * User provided callback called when enabling @capability handled + * by @handler for a particular device. + */ + public delegate void SupportedCapabilityFunc(string capability, + PacketHandlerInterface handler); + + /** + * use_device: + * @dev: device + * @cb: callback see @SupportedCapabilityFunc to details + * + * Enable protocol handlers supported by device + */ + public void use_device(Device dev, SupportedCapabilityFunc? cb) { _handlers.foreach((h) => { - h.use_device(dev); + var cap = h.get_pkt_type(); + if (dev.supports_capability(cap)) { + h.use_device(dev); + if (cb != null) { + cb(cap, h); + } + } else { + warning("capability %s not supported by device", cap); + } }); } From 0bacf652107ac5ce32ddb2d14e7d837b268458aa Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Mon, 5 Jun 2017 21:47:26 +0200 Subject: [PATCH 043/100] battery: add battery signal --- src/mconnect/battery.vala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mconnect/battery.vala b/src/mconnect/battery.vala index 70a9e34..5b4d523 100644 --- a/src/mconnect/battery.vala +++ b/src/mconnect/battery.vala @@ -54,7 +54,10 @@ class BatteryHandler : Object, PacketHandlerInterface { int64 level = pkt.body.get_int_member("currentCharge"); bool charging = pkt.body.get_boolean_member("isCharging"); - GLib.message("battery level: %u %s", (uint) level, - (charging == true) ? "charging" : ""); + debug("battery level: %u %s", (uint) level, + (charging == true) ? "charging" : ""); + battery(dev, (uint)level, charging); } + + public signal void battery(Device dev, uint level, bool charging); } \ No newline at end of file From dbdf2f8938c429fdd498e91e273ca8b895ae0739 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Mon, 5 Jun 2017 21:48:03 +0200 Subject: [PATCH 044/100] device, devicemanager: support for updating device data using another Device instance --- src/mconnect/device.vala | 10 ++++++++++ src/mconnect/devicemanager.vala | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index ea71e1b..5d6877a 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -361,4 +361,14 @@ class Device : Object { return outgoing_capabilities.contains(capability) || incoming_capabilities.contains(capability); } + + public void update_from_device(Device other_dev) { + outgoing_capabilities = other_dev.outgoing_capabilities; + incoming_capabilities = other_dev.incoming_capabilities; + foreach (var cap in outgoing_capabilities) { + warning("updated cap: %s", cap); + } + host = other_dev.host; + tcp_port = other_dev.tcp_port; + } } \ No newline at end of file diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 9d23947..9c15473 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -123,6 +123,8 @@ class DeviceManager : GLib.Object } var dev = this.devices.@get(unique); + // update device information + dev.update_from_device(new_dev); info("allowed? %s", dev.allowed.to_string()); // check if device is whitelisted in configuration From 3a82d95223b0b1d73ad592948f567ed1e5ee4c20 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Mon, 5 Jun 2017 21:48:44 +0200 Subject: [PATCH 045/100] devicemanager: signal device capabilities added --- src/mconnect/devicemanager.vala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 9c15473..120f65f 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -22,6 +22,9 @@ using Gee; class DeviceManager : GLib.Object { public signal void found_new_device(Device dev); + public signal void device_capability_added(Device dev, + string capability, + PacketHandlerInterface handler); public const string DEVICES_CACHE_FILE = "devices"; @@ -198,7 +201,9 @@ class DeviceManager : GLib.Object private void enable_protocol_handlers(Device dev) { var core = Core.instance(); - core.handlers.use_device(dev); + core.handlers.use_device(dev, (cap, handler) => { + device_capability_added(dev, cap, handler); + }); } private void disable_protocol_handlers(Device dev) { From 94be6214e12cb573df73539f085d15f4a7084ace Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Mon, 5 Jun 2017 21:49:50 +0200 Subject: [PATCH 046/100] devicemanager-proxy: register per capability bus interfaces --- src/mconnect/devicemanager-proxy.vala | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/mconnect/devicemanager-proxy.vala b/src/mconnect/devicemanager-proxy.vala index 9a962f4..33acb5d 100644 --- a/src/mconnect/devicemanager-proxy.vala +++ b/src/mconnect/devicemanager-proxy.vala @@ -39,6 +39,7 @@ class DeviceManagerDBusProxy : Object manager.found_new_device.connect((d) => { this.add_device(d); }); + manager.device_capability_added.connect(this.add_device_capability); } [DBus (visible = false)] @@ -97,6 +98,29 @@ class DeviceManagerDBusProxy : Object } } + private void add_device_capability(Device dev, + string capability, + PacketHandlerInterface iface) { + + ObjectPath path = null; + foreach (var entry in this.devices.entries) { + if (entry.value.device == dev) { + path = new ObjectPath(entry.key); + break; + } + } + + if (path == null) { + warning("no path for device?"); + return; + } + + info("add capability handler %s for device at path %s", + capability, path.to_string()); + // TODO: + // PacketHandlersProxy.register_capability(path, capability, iface); + } + /** * make_device_path: * From 1cfb7ad0a3561d371af5bef7a68497116ffe66c7 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 09:35:29 +0200 Subject: [PATCH 047/100] device: proper handling of pair timeout and device public key Signed-off-by: Maciek Borzecki --- src/mconnect/device.vala | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 5d6877a..0a059b7 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -25,6 +25,8 @@ using Gee; */ class Device : Object { + public const uint PAIR_TIMEOUT = 30; + public signal void paired(bool pair); public signal void connected(); public signal void disconnected(); @@ -53,9 +55,11 @@ class Device : Object { private set; default = null; } + public string public_key {get; private set; default = ""; } // set to true if pair request was sent private bool _pair_in_progress = false; + private uint _pair_timeout_source = 0; private DeviceChannel _channel = null; @@ -179,10 +183,27 @@ class Device : Object { if (expect_response == true) _pair_in_progress = true; + + // pairing timeout + _pair_timeout_source = Timeout.add_seconds(PAIR_TIMEOUT, + this.pair_timeout); + // send request yield _channel.send(Packet.new_pair(pubkey)); } } + private bool pair_timeout() { + warning("pair request timeout"); + + _pair_timeout_source = 0; + + // handle failed pairing + handle_pair(false, ""); + + // remove timeout source + return false; + } + public void pair_if_needed() { if (is_paired == false && _pair_in_progress == false) this.pair.begin(); @@ -299,6 +320,26 @@ class Device : Object { assert(pkt.pkt_type == Packet.PAIR); bool pair = pkt.body.get_boolean_member("pair"); + string public_key = ""; + if (pair) { + public_key = pkt.body.get_string_member("publicKey"); + } + + handle_pair(pair, public_key); + } + + /** + * handle_pair: + * @pair: pairing status + * @public_key: device public key + * + * Update device pair status. + */ + private void handle_pair(bool pair, string public_key) { + if (this._pair_timeout_source != 0) { + Source.remove(_pair_timeout_source); + this._pair_timeout_source = 0; + } debug("pair in progress: %s is paired: %s pair: %s", _pair_in_progress.to_string(), this.is_paired.to_string(), @@ -325,6 +366,13 @@ class Device : Object { } } + if (pair) { + // update public key + this.public_key = public_key; + } else { + this.public_key = ""; + } + // emit signal paired(is_paired); } From ed4c4b04e23fdb0fc662f5353ecd9f4843ac1bdf Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 09:35:46 +0200 Subject: [PATCH 048/100] device: save & load device pair status and public key to/from cache Signed-off-by: Maciek Borzecki --- src/mconnect/device.vala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 0a059b7..b15d9e2 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -107,6 +107,8 @@ class Device : Object { var last_ip_str = cache.get_string(name, "lastIPAddress"); debug("last known address: %s:%u", last_ip_str, dev.tcp_port); dev.allowed = cache.get_boolean(name, "allowed"); + dev.is_paired = cache.get_boolean(name, "paired"); + dev.public_key = cache.get_string(name, "public_key"); var host = new InetAddress.from_string(last_ip_str); if (host == null) { @@ -153,6 +155,8 @@ class Device : Object { cache.set_integer(name, "tcpPort", (int) this.tcp_port); cache.set_string(name, "lastIPAddress", this.host.to_string()); cache.set_boolean(name, "allowed", this.allowed); + cache.set_boolean(name, "paired", this.is_paired); + cache.set_string(name, "public_key", this.public_key); } private async void greet() { From 9258033af9c7bb261c5fee3dc40f65628d205c97 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 09:36:38 +0200 Subject: [PATCH 049/100] device, devicemanager: simplify device activation Signed-off-by: Maciek Borzecki --- src/mconnect/device.vala | 46 ++++++++------------------------- src/mconnect/devicemanager.vala | 2 +- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index b15d9e2..efc3d4a 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -220,7 +220,9 @@ class Device : Object { * successfuly opening a connection. */ public void activate() { - assert(_channel == null); + if (_channel != null) { + debug("device %s already active", this.to_string()); + } var core = Core.instance(); _channel = new DeviceChannel(this.host, this.tcp_port, @@ -247,36 +249,6 @@ class Device : Object { } } - /** - * activate_from_device: - * - * Try to activate using information from device @dev. If device is - * already active, compare the host address to see if it - * changed. If so, close the current connection and activate with - * new address. - * - * @param dev device - */ - public void activate_from_device(Device dev) { - if (host == null) { - host = dev.host; - tcp_port = dev.tcp_port; - activate(); - } else if (dev.host.to_string() != host.to_string()) { - deactivate(); - host = dev.host; - tcp_port = dev.tcp_port; - activate(); - } else { - if (_channel == null) { - activate(); - } else { - // same host, assuming no activation needed - debug("device %s already active", dev.to_string()); - } - } - } - /** * channel_openend: * @@ -417,10 +389,14 @@ class Device : Object { public void update_from_device(Device other_dev) { outgoing_capabilities = other_dev.outgoing_capabilities; incoming_capabilities = other_dev.incoming_capabilities; - foreach (var cap in outgoing_capabilities) { - warning("updated cap: %s", cap); + if (this.host != null && this.host.to_string() != other_dev.host.to_string()) { + debug("host address changed from %s to %s", + this.host.to_string(), other_dev.host.to_string()); + // deactivate first + this.deactivate(); + + host = other_dev.host; + tcp_port = other_dev.tcp_port; } - host = other_dev.host; - tcp_port = other_dev.tcp_port; } } \ No newline at end of file diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 120f65f..20e85b0 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -159,7 +159,7 @@ class DeviceManager : GLib.Object dev.paired.connect(this.device_paired); dev.disconnected.connect(this.device_disconnected); - dev.activate_from_device(dev); + dev.activate(); } } From 910ac09458e9eb95a95a4908d0cc364a1d52e501 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 17:38:04 +0200 Subject: [PATCH 050/100] device: setup pair timeout only if expecting a response Signed-off-by: Maciek Borzecki --- src/mconnect/device.vala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index efc3d4a..037c8be 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -185,12 +185,12 @@ class Device : Object { string pubkey = core.crypt.get_public_key_pem(); debug("public key: %s", pubkey); - if (expect_response == true) + if (expect_response == true) { _pair_in_progress = true; - - // pairing timeout - _pair_timeout_source = Timeout.add_seconds(PAIR_TIMEOUT, - this.pair_timeout); + // pairing timeout + _pair_timeout_source = Timeout.add_seconds(PAIR_TIMEOUT, + this.pair_timeout); + } // send request yield _channel.send(Packet.new_pair(pubkey)); } From e3b79fc03ee1eab514973baa8ba867adbd0b3e68 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 17:48:42 +0200 Subject: [PATCH 051/100] devicemanager: update devices cache when device pair status is changed Signed-off-by: Maciek Borzecki --- src/mconnect/devicemanager.vala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 20e85b0..ff55957 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -184,6 +184,8 @@ class DeviceManager : GLib.Object info("device %s pair status change: %s", dev.to_string(), status.to_string()); + update_cache(); + if (status == true) { // register message handlers this.enable_protocol_handlers(dev); From 6787377f59c4bb2a1bf6998b9c108dc2a50f3bb4 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 17:49:10 +0200 Subject: [PATCH 052/100] device: handle split brain Handle a scenario when we thing we are not paired, but device sends us a packet that clearly indicates we have a channel open. In this case assume that we are paired and send a pair packet ourselves. Signed-off-by: Maciek Borzecki --- src/mconnect/device.vala | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 037c8be..f9e04bf 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -274,10 +274,11 @@ class Device : Object { // we sent a pair request, but got another packet, // supposedly meaning we're alredy paired since the device // is sending us data - if (_pair_in_progress == true) { - _pair_in_progress = false; - // just to be clear, send paired signal - paired(true); + if (this.is_paired == false) { + warning("not paired and still got a packet, " + + "assuming device is paired", + Packet.PAIR); + handle_pair(true, ""); } // emit signal @@ -332,13 +333,19 @@ class Device : Object { // pair completed _pair_in_progress = false; } else { - debug("unsolicited pair change from device"); + debug("unsolicited pair change from device, pair status: %s", + pair.to_string()); if (pair == false) { // unpair from device this.is_paired = false; } else { - // pair request from device + // split brain, pair was not initiated by us, but we were called + // with information that we are paired, assume we are paired and + // send a pair packet, but not expecting a response this time + this.pair.begin(false); + + this.is_paired = true; } } From 3b4fe748431f3f4bc7652b01ffb5a756100d387a Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 17:54:27 +0200 Subject: [PATCH 053/100] devicemanager: reduce cache update chatter Signed-off-by: Maciek Borzecki --- src/mconnect/devicemanager.vala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index ff55957..96e530a 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -81,7 +81,7 @@ class DeviceManager : GLib.Object * Update contents of device cache */ private void update_cache() { - debug("update devices cache"); + // debug("update devices cache"); if (devices.size == 0) return; @@ -93,12 +93,12 @@ class DeviceManager : GLib.Object } try { - debug("saving to cache"); + // debug("saving to cache"); FileUtils.set_contents(get_cache_file(), kf.to_data()); } catch (FileError e) { - debug("failed to save to cache file %s: %s", - get_cache_file(), e.message); + warning("failed to save to cache file %s: %s", + get_cache_file(), e.message); } } From 83f5f9dfec2d5a3e511b2b5fe6106f510f9aaef9 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 18:18:08 +0200 Subject: [PATCH 054/100] ping: add ping handler --- Makefile.am | 1 + src/mconnect/packethandlers.vala | 2 ++ src/mconnect/ping.vala | 57 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 src/mconnect/ping.vala diff --git a/Makefile.am b/Makefile.am index 7ec3bb5..52ec0eb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -69,6 +69,7 @@ mconnect_SOURCES = \ src/mconnect/battery.vala \ src/mconnect/telephony.vala \ src/mconnect/mousepad.vala \ + src/mconnect/ping.vala \ src/mconnect/config.vala \ src/mconnect/application.vala diff --git a/src/mconnect/packethandlers.vala b/src/mconnect/packethandlers.vala index d601079..8603926 100644 --- a/src/mconnect/packethandlers.vala +++ b/src/mconnect/packethandlers.vala @@ -46,11 +46,13 @@ class PacketHandlers : Object { var battery = BatteryHandler.instance(); var telephony = TelephonyHandler.instance(); var mousepad = MousepadHandler.instance(); + var ping = PingHandler.instance(); hnd.append(notification); hnd.append(battery); hnd.append(telephony); hnd.append(mousepad); + hnd.append(ping); return hnd; } diff --git a/src/mconnect/ping.vala b/src/mconnect/ping.vala new file mode 100644 index 0000000..bc6976e --- /dev/null +++ b/src/mconnect/ping.vala @@ -0,0 +1,57 @@ +/* ex:ts=4:sw=4:sts=4:et */ +/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * AUTHORS + * Maciek Borzecki + */ + +class PingHandler : Object, PacketHandlerInterface { + + private const string PING = "kdeconnect.ping"; + + public string get_pkt_type() { + return PING; + } + + private PingHandler() { + + } + + public static PingHandler instance() { + return new PingHandler(); + } + + public void use_device(Device dev) { + debug("use device %s for ping", dev.to_string()); + dev.message.connect(this.message); + } + + public void release_device(Device dev) { + debug("release device %s", dev.to_string()); + dev.message.disconnect(this.message); + } + + public void message(Device dev, Packet pkt) { + if (pkt.pkt_type != PING) { + return; + } + + GLib.message("ping from device %s", dev.to_string()); + ping(dev); + } + + public signal void ping(Device dev); +} \ No newline at end of file From 4b65e59bb2cd553de3ee61dce62a7e51872ec86d Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 20:00:02 +0200 Subject: [PATCH 055/100] utils: generic helpers --- Makefile.am | 3 ++- src/mconnect/devicechannel.vala | 2 +- src/mconnect/utils.vala | 35 +++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 src/mconnect/utils.vala diff --git a/Makefile.am b/Makefile.am index 52ec0eb..4be27a2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,7 +71,8 @@ mconnect_SOURCES = \ src/mconnect/mousepad.vala \ src/mconnect/ping.vala \ src/mconnect/config.vala \ - src/mconnect/application.vala + src/mconnect/application.vala \ + src/mconnect/utils.vala mconnect_LDADD = \ libmconn-crypt.la \ diff --git a/src/mconnect/devicechannel.vala b/src/mconnect/devicechannel.vala index 97201dd..e9812d6 100644 --- a/src/mconnect/devicechannel.vala +++ b/src/mconnect/devicechannel.vala @@ -217,7 +217,7 @@ class DeviceChannel : Object { } private void handle_packet(Packet pkt) { - debug("handle packet of type: %s", pkt.pkt_type); + // debug("handle packet of type: %s", pkt.pkt_type); if (pkt.pkt_type == Packet.ENCRYPTED) { handle_encrypted_packet(pkt); } else { diff --git a/src/mconnect/utils.vala b/src/mconnect/utils.vala new file mode 100644 index 0000000..8b862f5 --- /dev/null +++ b/src/mconnect/utils.vala @@ -0,0 +1,35 @@ +/* ex:ts=4:sw=4:sts=4:et */ +/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * AUTHORS + * Maciek Borzecki + */ + +/** + * @array_list_to_list: + * @al: Gee.ArrayList + * + * Convert Gee.ArrayList to T[] + */ +T[] array_list_to_list(Gee.ArrayList al) { + T[] out_list = new T[al.size]; + int i = 0; + foreach(var v in al) { + out_list[i] = v; + i++; + } + return out_list; +} From f1d4552c571bcb0815aace25f41b2788c9cc11a5 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 20:18:07 +0200 Subject: [PATCH 056/100] utils, application: verbose debug logging --- src/mconnect/application.vala | 9 ++++++++- src/mconnect/utils.vala | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/mconnect/application.vala b/src/mconnect/application.vala index 3d03db2..498c19f 100644 --- a/src/mconnect/application.vala +++ b/src/mconnect/application.vala @@ -25,9 +25,13 @@ namespace Mconn { private Core core = null; private static bool log_debug = false; + private static bool log_debug_verbose = false; private const GLib.OptionEntry[] options = { - {"debug", 'd', 0, OptionArg.NONE, ref log_debug, "Show debug output", null}, + {"debug", 'd', 0, OptionArg.NONE, ref log_debug, + "Show debug output", null}, + {"verbose-debug", 0, 0, OptionArg.NONE, ref log_debug_verbose, + "Show verbose debug output", null}, {null} }; @@ -51,6 +55,9 @@ namespace Mconn { if (log_debug == true) Environment.set_variable("G_MESSAGES_DEBUG", "all", false); + if (log_debug_verbose == true) + enable_vdebug(); + core = Core.instance(); if (core == null) error("cannot initialize core"); diff --git a/src/mconnect/utils.vala b/src/mconnect/utils.vala index 8b862f5..45011f5 100644 --- a/src/mconnect/utils.vala +++ b/src/mconnect/utils.vala @@ -33,3 +33,25 @@ T[] array_list_to_list(Gee.ArrayList al) { } return out_list; } + +namespace DebugLog{ + public bool Verbose = false; +} + +void enable_vdebug() { + DebugLog.Verbose = true; +} + +/** + * vdebug: + * @format: format string + * + * Same as debug() but looks at verbose debug flag + */ +void vdebug(string format, ...) { + if (DebugLog.Verbose == true) { + var l = va_list(); + logv(null, LogLevelFlags.LEVEL_DEBUG, format, l); + } +} + From bc9c87e4bf9c7f1a1afd05adb75b11f70587e37e Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 20:20:10 +0200 Subject: [PATCH 057/100] mconnect, crypt: cleanup logging, use verbose debug where possible --- src/crypt/mconn-crypt.c | 4 ++-- src/mconnect/device.vala | 2 +- src/mconnect/devicechannel.vala | 10 +++++----- src/mconnect/devicemanager.vala | 13 +++++++------ src/mconnect/discovery.vala | 8 ++++---- src/mconnect/packet.vala | 2 +- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/crypt/mconn-crypt.c b/src/crypt/mconn-crypt.c index 060535d..e007493 100644 --- a/src/crypt/mconn-crypt.c +++ b/src/crypt/mconn-crypt.c @@ -129,7 +129,7 @@ GByteArray * mconn_crypt_decrypt(MconnCrypt *self, GBytes *data, GError **err) g_assert(IS_MCONN_CRYPT(self)); g_assert(self->priv->key); - g_debug("decrypt: %zu bytes of data", g_bytes_get_size(data)); + /* g_debug("decrypt: %zu bytes of data", g_bytes_get_size(data)); */ g_assert_cmpint(g_bytes_get_size(data), ==, RSA_size(self->priv->key)); @@ -143,7 +143,7 @@ GByteArray * mconn_crypt_decrypt(MconnCrypt *self, GBytes *data, GError **err) (unsigned char *)out_data->data, self->priv->key, MCONN_CRYPT_RSA_PADDING); - g_debug("decrypted size: %d", dec_size); + /* g_debug("decrypted size: %d", dec_size); */ g_assert(dec_size != -1); g_byte_array_set_size(out_data, dec_size); diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index f9e04bf..b0d2341 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -266,7 +266,7 @@ class Device : Object { } private void packet_received(Packet pkt) { - debug("got packet"); + vdebug("got packet"); if (pkt.pkt_type == Packet.PAIR) { // pairing handle_pair_packet(pkt); diff --git a/src/mconnect/devicechannel.vala b/src/mconnect/devicechannel.vala index e9812d6..f7bb3f4 100644 --- a/src/mconnect/devicechannel.vala +++ b/src/mconnect/devicechannel.vala @@ -191,7 +191,7 @@ class DeviceChannel : Object { return false; } - debug("received line: %s", data); + vdebug("received line: %s", data); Packet pkt = Packet.new_from_data(data); if (pkt == null) { @@ -244,13 +244,13 @@ class DeviceChannel : Object { if (failed == true) return; - debug("node data: %s", node.get_string()); + vdebug("node data: %s", node.get_string()); // encrypted data is base64 encoded uchar[] data = Base64.decode(node.get_string()); var dbytes = new Bytes.take(data); try { ByteArray decrypted = this._crypt.decrypt(dbytes); - debug("data length: %zu", decrypted.data.length); + vdebug("data length: %zu", decrypted.data.length); msgbytes.append(decrypted.data); } catch (Error e) { warning("decryption failed: %s", e.message); @@ -258,11 +258,11 @@ class DeviceChannel : Object { } }); // data should be complete now - debug("total length of packet data: %zu", msgbytes.len); + vdebug("total length of packet data: %zu", msgbytes.len); // make sure there is \0 at the end msgbytes.append({'\0'}); string decrypted_data = ((string)msgbytes.data).dup(); - debug("decrypted data: %s", decrypted_data); + vdebug("decrypted data: %s", decrypted_data); Packet dec_pkt = Packet.new_from_data(decrypted_data); if (dec_pkt == null) { diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 96e530a..ee720f7 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -42,7 +42,7 @@ class DeviceManager : GLib.Object private string get_cache_file() { var cache_file = Path.build_filename(Core.get_cache_dir(), DEVICES_CACHE_FILE); - debug("cache file: %s", cache_file); + vdebug("cache file: %s", cache_file); // make sure that cache dir exists DirUtils.create_with_parents(Core.get_cache_dir(), @@ -55,10 +55,10 @@ class DeviceManager : GLib.Object * Load known devices from cache and attempt pairing. */ public void load_cache() { - debug("try loading devices from device cache"); - var cache_file = get_cache_file(); + debug("try loading devices from device cache %s", cache_file); + var kf = new KeyFile(); try { kf.load_from_file(cache_file, KeyFileFlags.NONE); @@ -113,7 +113,7 @@ class DeviceManager : GLib.Object public void handle_new_device(Device new_dev) { var is_new = false; string unique = new_dev.to_unique_string(); - debug("device key: %s", unique); + vdebug("device key: %s", unique); if (this.devices.has_key(unique) == false) { debug("adding new device with key: %s", unique); @@ -129,7 +129,7 @@ class DeviceManager : GLib.Object // update device information dev.update_from_device(new_dev); - info("allowed? %s", dev.allowed.to_string()); + debug("allowed? %s", dev.allowed.to_string()); // check if device is whitelisted in configuration if (!dev.allowed && device_allowed_in_config(dev)) { dev.allowed = true; @@ -142,7 +142,8 @@ class DeviceManager : GLib.Object // device is allowed activate_device(dev); } else { - message("skipping device %s activation, device not allowed", dev.to_string()); + warning("skipping device %s activation, device not allowed", + dev.to_string()); } // notify everyone that a new device appeared diff --git a/src/mconnect/discovery.vala b/src/mconnect/discovery.vala index 2123fcb..1d3f50b 100644 --- a/src/mconnect/discovery.vala +++ b/src/mconnect/discovery.vala @@ -60,7 +60,7 @@ class Discovery : GLib.Object } private void incomingPacket() { - debug("incoming packet"); + vdebug("incoming packet"); uint8 buffer[4096]; SocketAddress sa; @@ -69,14 +69,14 @@ class Discovery : GLib.Object try { ssize_t read = this.socket.receive_from(out sa, buffer); isa = (InetSocketAddress)sa; - debug("got %zd bytes from: %s:%u", read, + vdebug("got %zd bytes from: %s:%u", read, isa.address.to_string(), isa.port); } catch (Error e) { - message("failed to receive packet: %s", e.message); + warning("failed to receive packet: %s", e.message); return; } - debug("message data: %s", (string)buffer); + vdebug("message data: %s", (string)buffer); this.parsePacketFromHost((string) buffer, isa.address); } diff --git a/src/mconnect/packet.vala b/src/mconnect/packet.vala index 0eff6f4..5d27fdb 100644 --- a/src/mconnect/packet.vala +++ b/src/mconnect/packet.vala @@ -67,7 +67,7 @@ class Packet : GLib.Object { int64 id = root_obj.get_int_member("id"); Json.Object body = root_obj.get_object_member("body"); - debug("packet type: %s", type); + vdebug("packet type: %s", type); return new Packet(type, body, id); } catch (Error e) { From dd9f395c8a0e956d77b7862abf0ccccc9e4d7166 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 20:21:01 +0200 Subject: [PATCH 058/100] device: keep track of capabilities when saving/loading from cache --- src/mconnect/device.vala | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index b0d2341..918c579 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -81,8 +81,10 @@ class Device : Object { this.device_type = disc.device_type; this.protocol_version = disc.protocol_version; this.tcp_port = disc.tcp_port; - this.outgoing_capabilities = new ArrayList.wrap(disc.outgoing_capabilities); - this.incoming_capabilities = new ArrayList.wrap(disc.incoming_capabilities); + this.outgoing_capabilities = new ArrayList.wrap( + disc.outgoing_capabilities); + this.incoming_capabilities = new ArrayList.wrap( + disc.incoming_capabilities); debug("new device: %s", this.to_string()); } @@ -109,6 +111,12 @@ class Device : Object { dev.allowed = cache.get_boolean(name, "allowed"); dev.is_paired = cache.get_boolean(name, "paired"); dev.public_key = cache.get_string(name, "public_key"); + dev.outgoing_capabilities = new ArrayList.wrap( + cache.get_string_list(name, + "outgoing_capabilities")); + dev.incoming_capabilities = new ArrayList.wrap( + cache.get_string_list(name, + "incoming_capabilities")); var host = new InetAddress.from_string(last_ip_str); if (host == null) { @@ -157,6 +165,10 @@ class Device : Object { cache.set_boolean(name, "allowed", this.allowed); cache.set_boolean(name, "paired", this.is_paired); cache.set_string(name, "public_key", this.public_key); + cache.set_string_list(name, "outgoing_capabilities", + array_list_to_list(this.outgoing_capabilities)); + cache.set_string_list(name, "incoming_capabilities", + array_list_to_list(this.incoming_capabilities)); } private async void greet() { From 90e48f23339826392b8b822a70b3db8e6022f3dd Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 20:22:13 +0200 Subject: [PATCH 059/100] device: proper pair handling if device is already paired --- src/mconnect/device.vala | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 918c579..e1f1375 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -179,7 +179,7 @@ class Device : Object { Environment.get_host_name(), core.handlers.interfaces, core.handlers.interfaces)); - this.pair_if_needed(); + this.maybe_pair(); } /** @@ -220,9 +220,19 @@ class Device : Object { return false; } - public void pair_if_needed() { - if (is_paired == false && _pair_in_progress == false) - this.pair.begin(); + /** + * maybe_pair: + * + * Trigger pairing or call handle_pair() if already paired. + */ + public void maybe_pair() { + if (is_paired == false) { + if (_pair_in_progress == false) + this.pair.begin(); + } else { + // we are already paired + handle_pair(true, this.public_key); + } } /** From 95c16fed52e9fab70cbf3677f90c8f5ec8f2cd09 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 22:22:38 +0200 Subject: [PATCH 060/100] ping, battery, mousepad: make packet types public --- src/mconnect/battery.vala | 2 +- src/mconnect/mousepad.vala | 2 +- src/mconnect/ping.vala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mconnect/battery.vala b/src/mconnect/battery.vala index 5b4d523..1407065 100644 --- a/src/mconnect/battery.vala +++ b/src/mconnect/battery.vala @@ -20,7 +20,7 @@ class BatteryHandler : Object, PacketHandlerInterface { - private const string BATTERY = "kdeconnect.battery"; + public const string BATTERY = "kdeconnect.battery"; public string get_pkt_type() { return BATTERY; diff --git a/src/mconnect/mousepad.vala b/src/mconnect/mousepad.vala index 5c7ae07..d54f7d9 100644 --- a/src/mconnect/mousepad.vala +++ b/src/mconnect/mousepad.vala @@ -20,7 +20,7 @@ class MousepadHandler : Object, PacketHandlerInterface { - private const string MOUSEPAD = "kdeconnect.mousepad"; + public const string MOUSEPAD = "kdeconnect.mousepad"; private Gdk.Display _display; diff --git a/src/mconnect/ping.vala b/src/mconnect/ping.vala index bc6976e..1733951 100644 --- a/src/mconnect/ping.vala +++ b/src/mconnect/ping.vala @@ -20,7 +20,7 @@ class PingHandler : Object, PacketHandlerInterface { - private const string PING = "kdeconnect.ping"; + public const string PING = "kdeconnect.ping"; public string get_pkt_type() { return PING; From 8dfcf6c1892ff424112f6ab2361dbd0cb2480543 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 22:24:14 +0200 Subject: [PATCH 061/100] packethanlerinterface-proxy: packet handler exported over DBus --- Makefile.am | 1 + .../packethandlerinterface-proxy.vala | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/mconnect/packethandlerinterface-proxy.vala diff --git a/Makefile.am b/Makefile.am index 4be27a2..bf4adee 100644 --- a/Makefile.am +++ b/Makefile.am @@ -64,6 +64,7 @@ mconnect_SOURCES = \ src/mconnect/devicechannel.vala \ src/mconnect/core.vala \ src/mconnect/packethandlerinterface.vala \ + src/mconnect/packethandlerinterface-proxy.vala \ src/mconnect/packethandlers.vala \ src/mconnect/notification.vala \ src/mconnect/battery.vala \ diff --git a/src/mconnect/packethandlerinterface-proxy.vala b/src/mconnect/packethandlerinterface-proxy.vala new file mode 100644 index 0000000..1a19f29 --- /dev/null +++ b/src/mconnect/packethandlerinterface-proxy.vala @@ -0,0 +1,27 @@ +/* ex:ts=4:sw=4:sts=4:et */ +/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * AUTHORS + * Maciek Borzecki + */ + +/** + * PacketHandlerInterfaceProxy: interface of DBus exported packet handler + */ +interface PacketHandlerInterfaceProxy : Object { + public abstract void bus_register(DBusConnection conn, string path) throws IOError; + public abstract void bus_unregister(DBusConnection conn) throws IOError; +} \ No newline at end of file From f8e8a30e338cf845a932917e6e267b9ab3f9b18d Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 22:25:23 +0200 Subject: [PATCH 062/100] device-proxy: keep track of per-device DBus exported packet handlers --- src/mconnect/device-proxy.vala | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mconnect/device-proxy.vala b/src/mconnect/device-proxy.vala index 2db784f..4136901 100644 --- a/src/mconnect/device-proxy.vala +++ b/src/mconnect/device-proxy.vala @@ -18,6 +18,8 @@ * Maciek Borzecki */ +using Gee; + /** * General device wrapper. */ @@ -72,11 +74,14 @@ class DeviceDBusProxy : Object { private set; } + private ArrayList handlers; + [DBus (visible = false)] public Device device {get; private set; default = null; } public DeviceDBusProxy.for_device(Device device) { this.device = device; + this.handlers = new ArrayList(); this.update_address(); this.update_capabilities(); this.device.notify.connect(this.param_changed); @@ -84,6 +89,7 @@ class DeviceDBusProxy : Object { private void update_capabilities() { string[] caps = {}; + foreach (var cap in device.incoming_capabilities) { caps += cap; } @@ -129,4 +135,9 @@ class DeviceDBusProxy : Object { break; } } + + [DBus (visible = false)] + public void add_handler(PacketHandlerInterfaceProxy h) { + this.handlers.add(h); + } } \ No newline at end of file From b89b34de8d3394c727fb5804298485c6bece7453 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 22:26:06 +0200 Subject: [PATCH 063/100] ping-proxy: DBus interface of ping packet handler --- Makefile.am | 1 + src/mconnect/ping-proxy.vala | 52 ++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/mconnect/ping-proxy.vala diff --git a/Makefile.am b/Makefile.am index bf4adee..c77837a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,6 +71,7 @@ mconnect_SOURCES = \ src/mconnect/telephony.vala \ src/mconnect/mousepad.vala \ src/mconnect/ping.vala \ + src/mconnect/ping-proxy.vala \ src/mconnect/config.vala \ src/mconnect/application.vala \ src/mconnect/utils.vala diff --git a/src/mconnect/ping-proxy.vala b/src/mconnect/ping-proxy.vala new file mode 100644 index 0000000..cc0abbf --- /dev/null +++ b/src/mconnect/ping-proxy.vala @@ -0,0 +1,52 @@ +/* ex:ts=4:sw=4:sts=4:et */ +/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * AUTHORS + * Maciek Borzecki + */ + +[DBus (name = "org.mconnect.Device.Ping")] +class PingHandlerProxy : Object, PacketHandlerInterfaceProxy { + + private Device device = null; + private PingHandler ping_handler = null; + + public PingHandlerProxy.for_device_handler(Device dev, + PacketHandlerInterface iface) { + this.device = dev; + this.ping_handler = (PingHandler) iface; + this.ping_handler.ping.connect(this.ping_cb); + } + + [DBus (visible = false)] + public void bus_register(DBusConnection conn, string path) throws IOError { + conn.register_object(path, this); + } + + [DBus (visible = false)] + public void bus_unregister(DBusConnection conn) throws IOError { + //conn.unregister_object(this); + } + + private void ping_cb(Device dev) { + if (this.device != dev) + return; + + ping(); + } + + public signal void ping(); +} \ No newline at end of file From 5accd01ee1111bbe0bf8af9854ebceda7e29ba30 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 22:26:49 +0200 Subject: [PATCH 064/100] battery-proxy: DBus interface for battery packet handler --- Makefile.am | 1 + src/mconnect/battery-proxy.vala | 54 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/mconnect/battery-proxy.vala diff --git a/Makefile.am b/Makefile.am index c77837a..23961d7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -68,6 +68,7 @@ mconnect_SOURCES = \ src/mconnect/packethandlers.vala \ src/mconnect/notification.vala \ src/mconnect/battery.vala \ + src/mconnect/battery-proxy.vala \ src/mconnect/telephony.vala \ src/mconnect/mousepad.vala \ src/mconnect/ping.vala \ diff --git a/src/mconnect/battery-proxy.vala b/src/mconnect/battery-proxy.vala new file mode 100644 index 0000000..8abcfd3 --- /dev/null +++ b/src/mconnect/battery-proxy.vala @@ -0,0 +1,54 @@ +/* ex:ts=4:sw=4:sts=4:et */ +/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * AUTHORS + * Maciek Borzecki + */ + +[DBus (name = "org.mconnect.Device.Battery")] +class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { + + private Device device = null; + private BatteryHandler battery_handler = null; + + public BatteryHandlerProxy.for_device_handler(Device dev, + PacketHandlerInterface iface) { + this.device = dev; + + this.battery_handler = (BatteryHandler) iface; + + this.battery_handler.battery.connect(this.battery_change); + } + + private void battery_change(Device dev, uint level, bool charging) { + if (this.device != dev) + return; + + battery(level, charging); + } + + [DBus (visible = false)] + public void bus_register(DBusConnection conn, string path) throws IOError { + conn.register_object(path, this); + } + + [DBus (visible = false)] + public void bus_unregister(DBusConnection conn) throws IOError { + //conn.unregister_object(this); + } + + public signal void battery(uint level, bool charging); +} \ No newline at end of file From 4f09325cb48d7ac6e87a7d6b7fa9b1b638f9476b Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 6 Jun 2017 22:27:32 +0200 Subject: [PATCH 065/100] packethandlers-proxy, devicemanager-proxy: register per-device DBus interfaces of packet handlers --- Makefile.am | 1 + src/mconnect/devicemanager-proxy.vala | 12 +++++-- src/mconnect/packethandlers-proxy.vala | 44 ++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 src/mconnect/packethandlers-proxy.vala diff --git a/Makefile.am b/Makefile.am index 23961d7..5620a01 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,6 +66,7 @@ mconnect_SOURCES = \ src/mconnect/packethandlerinterface.vala \ src/mconnect/packethandlerinterface-proxy.vala \ src/mconnect/packethandlers.vala \ + src/mconnect/packethandlers-proxy.vala \ src/mconnect/notification.vala \ src/mconnect/battery.vala \ src/mconnect/battery-proxy.vala \ diff --git a/src/mconnect/devicemanager-proxy.vala b/src/mconnect/devicemanager-proxy.vala index 33acb5d..08de425 100644 --- a/src/mconnect/devicemanager-proxy.vala +++ b/src/mconnect/devicemanager-proxy.vala @@ -103,9 +103,11 @@ class DeviceManagerDBusProxy : Object PacketHandlerInterface iface) { ObjectPath path = null; + DeviceDBusProxy dp = null; foreach (var entry in this.devices.entries) { if (entry.value.device == dev) { path = new ObjectPath(entry.key); + dp = entry.value; break; } } @@ -117,8 +119,14 @@ class DeviceManagerDBusProxy : Object info("add capability handler %s for device at path %s", capability, path.to_string()); - // TODO: - // PacketHandlersProxy.register_capability(path, capability, iface); + + var h = PacketHandlersProxy.new_device_capability_handler(dev, + capability, + iface); + if (h != null) { + h.bus_register(this.bus, path); + dp.add_handler(h); + } } /** diff --git a/src/mconnect/packethandlers-proxy.vala b/src/mconnect/packethandlers-proxy.vala new file mode 100644 index 0000000..c85a0f0 --- /dev/null +++ b/src/mconnect/packethandlers-proxy.vala @@ -0,0 +1,44 @@ +/* ex:ts=4:sw=4:sts=4:et */ +/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * AUTHORS + * Maciek Borzecki + */ + +class PacketHandlersProxy : Object { + + public static PacketHandlerInterfaceProxy? new_device_capability_handler( + Device dev, + string cap, + PacketHandlerInterface iface) { + + switch (iface.get_pkt_type()) { + case BatteryHandler.BATTERY: { + return new BatteryHandlerProxy.for_device_handler(dev, iface); + break; + } + case PingHandler.PING: { + return new PingHandlerProxy.for_device_handler(dev, iface); + break; + } + default: + warning("cannot register bus handler for %s", + iface.get_pkt_type()); + break; + } + return null; + } +} \ No newline at end of file From aa7262b89aa15c1f91dd248f5de3f4c1849bdbe7 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 7 Jun 2017 08:55:42 +0200 Subject: [PATCH 066/100] mousepad: distinguish mousepad capability and packets Signed-off-by: Maciek Borzecki --- src/mconnect/mousepad.vala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mconnect/mousepad.vala b/src/mconnect/mousepad.vala index d54f7d9..ad2f1f7 100644 --- a/src/mconnect/mousepad.vala +++ b/src/mconnect/mousepad.vala @@ -20,7 +20,8 @@ class MousepadHandler : Object, PacketHandlerInterface { - public const string MOUSEPAD = "kdeconnect.mousepad"; + public const string MOUSEPAD = "kdeconnect.mousepad.request"; + public const string MOUSEPAD_PACKET = "kdeconnect.mousepad"; private Gdk.Display _display; @@ -56,7 +57,7 @@ class MousepadHandler : Object, PacketHandlerInterface { } private void message(Device dev, Packet pkt) { - if (pkt.pkt_type != MOUSEPAD) { + if (pkt.pkt_type != MOUSEPAD_PACKET) { return; } From 725eec8214b3831d01aa57e0047c25f02c0588cc Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 7 Jun 2017 08:56:35 +0200 Subject: [PATCH 067/100] battery-proxy: track bus registration ID Signed-off-by: Maciek Borzecki --- src/mconnect/battery-proxy.vala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mconnect/battery-proxy.vala b/src/mconnect/battery-proxy.vala index 8abcfd3..83455ba 100644 --- a/src/mconnect/battery-proxy.vala +++ b/src/mconnect/battery-proxy.vala @@ -23,6 +23,7 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { private Device device = null; private BatteryHandler battery_handler = null; + private uint register_id = 0; public BatteryHandlerProxy.for_device_handler(Device dev, PacketHandlerInterface iface) { @@ -42,12 +43,15 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { [DBus (visible = false)] public void bus_register(DBusConnection conn, string path) throws IOError { - conn.register_object(path, this); + if (this.register_id == 0) + this.register_id = conn.register_object(path, this); } [DBus (visible = false)] public void bus_unregister(DBusConnection conn) throws IOError { - //conn.unregister_object(this); + if (this.register_id != 0) + conn.unregister_object(this.register_id); + this.register_id = 0; } public signal void battery(uint level, bool charging); From 47f1d819c5cbea7ef562dc61ec4c2f2bd11b0c8e Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 7 Jun 2017 08:57:47 +0200 Subject: [PATCH 068/100] device-proxy: make object path part of DeviceDBusProxy Signed-off-by: Maciek Borzecki --- src/mconnect/device-proxy.vala | 26 +++++++++++++++++++- src/mconnect/devicemanager-proxy.vala | 34 ++++++++++++--------------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/mconnect/device-proxy.vala b/src/mconnect/device-proxy.vala index 4136901..2e3b47c 100644 --- a/src/mconnect/device-proxy.vala +++ b/src/mconnect/device-proxy.vala @@ -76,11 +76,17 @@ class DeviceDBusProxy : Object { private ArrayList handlers; + private uint register_id = 0; + + [DBus (visible = false)] + public ObjectPath object_path = null; + [DBus (visible = false)] public Device device {get; private set; default = null; } - public DeviceDBusProxy.for_device(Device device) { + public DeviceDBusProxy.for_device_with_path(Device device, ObjectPath path) { this.device = device; + this.object_path = path; this.handlers = new ArrayList(); this.update_address(); this.update_capabilities(); @@ -140,4 +146,22 @@ class DeviceDBusProxy : Object { public void add_handler(PacketHandlerInterfaceProxy h) { this.handlers.add(h); } + + [DBus (visible = false)] + public void bus_register(DBusConnection conn) { + try { + this.register_id = conn.register_object(this.object_path, this); + } catch (IOError err) { + warning("failed to register DBus object for device %s under path %s", + this.device.to_string(), this.object_path.to_string()); + } + } + + [DBus (visible = false)] + public void bus_unregister(DBusConnection conn) { + if (this.register_id != 0) { + conn.unregister_object(this.register_id); + } + this.register_id = 0; + } } \ No newline at end of file diff --git a/src/mconnect/devicemanager-proxy.vala b/src/mconnect/devicemanager-proxy.vala index 08de425..8d0d3b8 100644 --- a/src/mconnect/devicemanager-proxy.vala +++ b/src/mconnect/devicemanager-proxy.vala @@ -83,49 +83,45 @@ class DeviceManagerDBusProxy : Object } private void add_device(Device dev) { - var device_proxy = new DeviceDBusProxy.for_device(dev); var path = make_device_path(); + var device_proxy = new DeviceDBusProxy.for_device_with_path(dev, + new ObjectPath(path)); this.devices.@set(path, device_proxy); info("register device %s under path %s", dev.to_string(), path); - try { - this.bus.register_object(path, device_proxy); - } catch (IOError err) { - warning("failed to register DBus object for device %s under path %s", - dev.to_string(), path); - } + device_proxy.bus_register(this.bus); } - private void add_device_capability(Device dev, - string capability, - PacketHandlerInterface iface) { - - ObjectPath path = null; + private DeviceDBusProxy? find_proxy_for_device(Device dev) { DeviceDBusProxy dp = null; foreach (var entry in this.devices.entries) { if (entry.value.device == dev) { - path = new ObjectPath(entry.key); dp = entry.value; break; } } + return dp; + } - if (path == null) { - warning("no path for device?"); - return; + private void add_device_capability(Device dev, + string capability, + PacketHandlerInterface iface) { + DeviceDBusProxy dp = find_proxy_for_device(dev); + + if (dp == null) { + warning("no bus proxy for device %s", dev.to_string()); } info("add capability handler %s for device at path %s", - capability, path.to_string()); + capability, dp.object_path.to_string()); var h = PacketHandlersProxy.new_device_capability_handler(dev, capability, iface); if (h != null) { - h.bus_register(this.bus, path); - dp.add_handler(h); + h.bus_register(this.bus, dp.object_path); } } From e4b82e1cfd818eab245a33baa12da357e599c3ac Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 8 Jun 2017 21:01:29 +0200 Subject: [PATCH 069/100] mconnect/main: initialize Gdk Mousepad handler requires Gdk to be initiazed. --- src/mconnect/main.vala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mconnect/main.vala b/src/mconnect/main.vala index 039c032..b9dc643 100644 --- a/src/mconnect/main.vala +++ b/src/mconnect/main.vala @@ -21,5 +21,8 @@ public static int main(string[] args) { var app = new Mconn.Application(); + // needed for mousepad protocol handler + Gdk.init(ref args); + return app.run(args); } \ No newline at end of file From 8aee6ecfcc5494f7ad83c5761e04e5b52e08d73c Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 8 Jun 2017 21:34:23 +0200 Subject: [PATCH 070/100] mconnectctl: print capabilities --- src/mconnectctl/main.vala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/mconnectctl/main.vala b/src/mconnectctl/main.vala index 5946179..371d392 100644 --- a/src/mconnectctl/main.vala +++ b/src/mconnectctl/main.vala @@ -40,6 +40,8 @@ namespace Mconnect { public abstract bool is_paired { owned get;} public abstract bool allowed { owned get;} public abstract bool is_active { owned get;} + public abstract string[] outgoing_capabilities { owned get;} + public abstract string[] incoming_capabilities { owned get;} } public class Client { @@ -186,6 +188,14 @@ namespace Mconnect { }); } + private void print_sorted_caps(string[] caps, string format) { + qsort_with_data(caps, sizeof(string), + (a, b) => GLib.strcmp(a, b)); + foreach (var cap in caps) { + stdout.printf(format, cap); + } + } + private int cmd_show_device(string[] args) { return checked_dbus_call(() => { var dp = get_device(new ObjectPath(args[0])); @@ -205,6 +215,10 @@ namespace Mconnect { dp.allowed.to_string(), dp.is_paired.to_string(), dp.is_active.to_string()); + stdout.printf(" Capabilities (out):\n"); + print_sorted_caps(dp.outgoing_capabilities, " %s\n"); + stdout.printf(" Capabilities (in):\n"); + print_sorted_caps(dp.incoming_capabilities, " %s\n"); return 0; }); } From ea6577b0e52c28030631a573356007617e1d6206 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 11 Jun 2017 17:47:23 +0200 Subject: [PATCH 071/100] device, discovereddevice, utils: use same method for generating 'unique' device strings --- src/mconnect/device.vala | 9 ++++++--- src/mconnect/discovereddevice.vala | 7 +++++++ src/mconnect/utils.vala | 28 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index e1f1375..2a339c4 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -141,12 +141,15 @@ class Device : Object { * Generates a unique string for this device */ public string to_unique_string() { - return this.to_string().replace(" ", "-"); + return make_unique_device_string(this.device_id, + this.device_name, + this.device_type, + this.protocol_version); } public string to_string() { - return "%s-%s-%s-%u".printf(this.device_id, this.device_name, - this.device_type, this.protocol_version); + return make_device_string(this.device_id, this.device_name, + this.device_type, this.protocol_version); } /** diff --git a/src/mconnect/discovereddevice.vala b/src/mconnect/discovereddevice.vala index 8bbba3c..587624f 100644 --- a/src/mconnect/discovereddevice.vala +++ b/src/mconnect/discovereddevice.vala @@ -72,4 +72,11 @@ class DiscoveredDevice : Object { this.protocol_version); } + public string to_unique_string() { + return make_unique_device_string(this.device_id, + this.device_name, + this.device_type, + this.protocol_version); + } + } \ No newline at end of file diff --git a/src/mconnect/utils.vala b/src/mconnect/utils.vala index 45011f5..ec67d48 100644 --- a/src/mconnect/utils.vala +++ b/src/mconnect/utils.vala @@ -55,3 +55,31 @@ void vdebug(string format, ...) { } } +/** + * make_unique_device_string: + * @id: device ID + * @name: device name + * @type: device type + * @pv: protocol version + * + * Generate device string that can be used as map index + */ +string make_unique_device_string(string id, string name, + string type, uint pv) { + return make_device_string(id, name, type, pv).replace(" ", "-"); +} + +/** + * make_device_string: + * @id: device ID + * @name: device name + * @type: device type + * @pv: protocol version + * + * Generate device string + */ +string make_device_string(string id, string name, + string type, uint pv) { + return "%s-%s-%s-%u".printf(id, name, type, pv); + +} From 462ecc3a6035a62228545382a3f65a6c7b57ba22 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 11 Jun 2017 19:37:01 +0200 Subject: [PATCH 072/100] core: formatting change --- src/mconnect/core.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mconnect/core.vala b/src/mconnect/core.vala index 7fcbdf9..5436307 100644 --- a/src/mconnect/core.vala +++ b/src/mconnect/core.vala @@ -49,8 +49,8 @@ class Core : Object { core.crypt = crypt; core.handlers = handlers; - info("supported interfaces: %s", string.joinv(", ", - handlers.interfaces)); + info("supported interfaces: %s", + string.joinv(", ", handlers.interfaces)); Core._instance = core; } From fb1108bf91ce10d7dad9c93c394d4cda99db3195 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 11 Jun 2017 19:50:57 +0200 Subject: [PATCH 073/100] device: improved device capabilty handling --- src/mconnect/device.vala | 135 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 130 insertions(+), 5 deletions(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 2a339c4..1d9039f 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -31,6 +31,20 @@ class Device : Object { public signal void connected(); public signal void disconnected(); public signal void message(Packet pkt); + /** + * capability_added: + * @cap: device capability, eg. kdeconnect.notification + * + * Device capability was added + */ + public signal void capability_added(string cap); + /** + * capability_removed: + * @cap: device capability, eg. kdeconnect.notification + * + * Device capability was removed + */ + public signal void capability_removed(string cap); public string device_id { get; private set; default = ""; } public string device_name { get; private set; default = ""; } @@ -55,6 +69,8 @@ class Device : Object { private set; default = null; } + private HashSet _capabilities = null; + public string public_key {get; private set; default = ""; } // set to true if pair request was sent @@ -63,9 +79,14 @@ class Device : Object { private DeviceChannel _channel = null; + // registered packet handlers + private HashMap _handlers; + private Device() { incoming_capabilities = new ArrayList(); outgoing_capabilities = new ArrayList(); + _capabilities = new HashSet(); + _handlers = new HashMap(); } /** @@ -75,6 +96,8 @@ class Device : Object { * @param host source host that the packet came from */ public Device.from_discovered_device(DiscoveredDevice disc) { + this(); + this.host = disc.host; this.device_name = disc.device_name; this.device_id = disc.device_id; @@ -125,6 +148,7 @@ class Device : Object { return null; } dev.host = host; + return dev; } catch (KeyFileError e) { @@ -413,14 +437,115 @@ class Device : Object { disconnected(); } - public bool supports_capability(string capability) { - return outgoing_capabilities.contains(capability) || - incoming_capabilities.contains(capability); + /** + * register_capability_handler: + * @cap: capability, eg. kdeconnect.notification + * @h: packet handler + * + * Keep track of capability handler @h that supports capability @cap. + * Register oneself with capability handler. + */ + public void register_capability_handler(string cap, + PacketHandlerInterface h) { + assert(this.has_capability_handler(cap) == false); + + this._handlers.@set(cap, h); + // make handler connect to device + h.use_device(this); + } + + /** + * has_capability_handler: + * @cap: capability, eg. kdeconnect.notification + * + * Returns true if there is a handler of capability @cap registed for this + * device. + */ + public bool has_capability_handler(string cap) { + return this._handlers.has_key(cap); + } + + /** + * unregister_capability_handler: + * @cap: capability, eg. kdeconnect.notification + * + * Unregisters a handler for capability @cap. + */ + private void unregister_capability_handler(string cap) { + PacketHandlerInterface handler; + this._handlers.unset(cap, out handler); + if (handler != null) { + // make handler release the device + handler.release_device(this); + } + } + + /** + * merge_capabilities: + * @added[out]: capabilities that were added + * @removed[out]: capabilities that were removed + * + * Merge and update existing `outgoing_capabilities` and + * `incoming_capabilities`. Returns lists of added and removed capabilities. + */ + private void merge_capabilities(out HashSet added, + out HashSet removed) { + + var caps = new HashSet(); + caps.add_all(this.outgoing_capabilities); + caps.add_all(this.incoming_capabilities); + + if (added == null) { + added = new HashSet(); + added.add_all(caps); + + // TODO: simplify capability names, eg kdeconnect.telephony.request -> + // kdeconnect.telephony + added.remove_all(this._capabilities); + } + + if (removed == null) { + removed = new HashSet(); + removed.add_all(this._capabilities); + removed.remove_all(caps); + } + + this._capabilities = caps; } + /** + * update_from_device: + * @other_dev: other device + * + * Update information/state of this device using data from @other_dev. This + * may happen in case when a discovery packet was received, or a device got + * connected. In such case, a `this` device (which was likely created from + * cached data) needs to be updated. + * + * As a side effect, updating capabilities will emit @capability_added + * and @capability_removed signals. + */ public void update_from_device(Device other_dev) { - outgoing_capabilities = other_dev.outgoing_capabilities; - incoming_capabilities = other_dev.incoming_capabilities; + this.outgoing_capabilities = other_dev.outgoing_capabilities; + this.incoming_capabilities = other_dev.incoming_capabilities; + + HashSet added; + HashSet removed; + this.merge_capabilities(out added, out removed); + + foreach (var c in added) { + debug("added: %s", c); + capability_added(c); + } + + foreach (var c in removed) { + debug("removed: %s", c); + capability_removed(c); + // remove capability handlers + this.unregister_capability_handler(c); + } + + if (this.host != null && this.host.to_string() != other_dev.host.to_string()) { debug("host address changed from %s to %s", this.host.to_string(), other_dev.host.to_string()); From c1f18c11c3049dfca880d37c60bcd92e223f578b Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 11 Jun 2017 19:53:55 +0200 Subject: [PATCH 074/100] devicemanager, packethandlers: rework device capability handling --- src/mconnect/devicemanager.vala | 37 +++++++++------- src/mconnect/packethandlers.vala | 72 ++++++++++---------------------- 2 files changed, 43 insertions(+), 66 deletions(-) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index ee720f7..8c15beb 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -121,11 +121,17 @@ class DeviceManager : GLib.Object this.devices.@set(unique, new_dev); is_new = true; + } else { debug("device %s already present", unique); } var dev = this.devices.@get(unique); + + if (is_new) { + dev.capability_added.connect(this.device_capability_added_cb); + dev.capability_removed.connect(this.device_capability_removed_cb); + } // update device information dev.update_from_device(new_dev); @@ -187,12 +193,7 @@ class DeviceManager : GLib.Object update_cache(); - if (status == true) { - // register message handlers - this.enable_protocol_handlers(dev); - } else { - this.disable_protocol_handlers(dev); - + if (status == false) { // we're no longer interested in paired singnal dev.paired.disconnect(this.device_paired); @@ -202,23 +203,29 @@ class DeviceManager : GLib.Object } - private void enable_protocol_handlers(Device dev) { + private void device_capability_added_cb(Device dev, string cap) { + info("capability %s added to device %s", cap, dev.to_string()); + + if (dev.has_capability_handler(cap)) { + return; + } + var core = Core.instance(); - core.handlers.use_device(dev, (cap, handler) => { - device_capability_added(dev, cap, handler); - }); + var h = core.handlers.get_capability_handler(cap); + if (h != null) { + dev.register_capability_handler(cap, h); + } else { + warning("no handler for capability %s", cap); + } } - private void disable_protocol_handlers(Device dev) { - var core = Core.instance(); - core.handlers.release_device(dev); + private void device_capability_removed_cb(Device dev, string cap) { + info("capability %s removed from device %s", cap, dev.to_string()); } private void device_disconnected(Device dev) { debug("device %s got disconnected", dev.to_string()); - this.disable_protocol_handlers(dev); - dev.paired.disconnect(this.device_paired); dev.disconnected.disconnect(this.device_disconnected); } diff --git a/src/mconnect/packethandlers.vala b/src/mconnect/packethandlers.vala index 8603926..e47b5e7 100644 --- a/src/mconnect/packethandlers.vala +++ b/src/mconnect/packethandlers.vala @@ -17,30 +17,24 @@ * AUTHORS * Maciek Borzecki */ +using Gee; class PacketHandlers : Object { - private List _handlers = null; + private HashMap _handlers; - public List handlers { - get { - return _handlers; - } - private set { - _handlers = handlers.copy(); - } + public string[] interfaces { + owned get { return _handlers.keys.to_array(); } + private set {} } - public string[] interfaces { get; private set; default = null; } public PacketHandlers() { _handlers = load_handlers(); - string [] ifaces; - list_handlers(out ifaces); - interfaces = ifaces; } - private static List load_handlers() { - List hnd = new List(); + private static HashMap load_handlers() { + HashMap hnd = + new HashMap(); var notification = NotificationHandler.instance(); var battery = BatteryHandler.instance(); @@ -48,24 +42,15 @@ class PacketHandlers : Object { var mousepad = MousepadHandler.instance(); var ping = PingHandler.instance(); - hnd.append(notification); - hnd.append(battery); - hnd.append(telephony); - hnd.append(mousepad); - hnd.append(ping); + hnd.@set(notification.get_pkt_type(), notification); + hnd.@set(battery.get_pkt_type(), battery); + hnd.@set(telephony.get_pkt_type(), telephony); + hnd.@set(mousepad.get_pkt_type(), mousepad); + hnd.@set(ping.get_pkt_type(), ping); return hnd; } - public void list_handlers(out string[] interfaces) { - interfaces = new string[_handlers.length()]; - // string[] interfaces = new string[_handlers.length()]; - for (int i = 0; i < _handlers.length(); i++) { - interfaces[i] = _handlers.nth_data(i).get_pkt_type(); - } - // return interfaces; - } - /** * SupportedCapabilityFunc: * @capability: capability name @@ -77,30 +62,15 @@ class PacketHandlers : Object { public delegate void SupportedCapabilityFunc(string capability, PacketHandlerInterface handler); - /** - * use_device: - * @dev: device - * @cb: callback see @SupportedCapabilityFunc to details - * - * Enable protocol handlers supported by device - */ - public void use_device(Device dev, SupportedCapabilityFunc? cb) { - _handlers.foreach((h) => { - var cap = h.get_pkt_type(); - if (dev.supports_capability(cap)) { - h.use_device(dev); - if (cb != null) { - cb(cap, h); - } - } else { - warning("capability %s not supported by device", cap); - } - }); + public PacketHandlerInterface? get_capability_handler(string cap) { + // all handlers are singletones for now + var h = this._handlers.@get(cap); + return h; } - public void release_device(Device dev) { - _handlers.foreach((h) => { - h.release_device(dev); - }); + public static string to_capability(string pkttype) { + if (pkttype.has_suffix(".request")) + return pkttype.replace(".request", ""); + return pkttype; } } \ No newline at end of file From debd2c5a534be05af111fb243a198f9daec2591f Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 11 Jun 2017 20:17:43 +0200 Subject: [PATCH 075/100] devicemanager: make sure to notify about new device before device capability signals --- src/mconnect/devicemanager.vala | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index 8c15beb..df01a50 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -128,6 +128,14 @@ class DeviceManager : GLib.Object var dev = this.devices.@get(unique); + // notify everyone that a new device appeared + if (is_new) { + // make sure that this happens before we update device data so that + // all subscribeds of found_new_device() signal have a chance to + // setup eveything they need + found_new_device(dev); + } + if (is_new) { dev.capability_added.connect(this.device_capability_added_cb); dev.capability_removed.connect(this.device_capability_removed_cb); @@ -152,10 +160,6 @@ class DeviceManager : GLib.Object dev.to_string()); } - // notify everyone that a new device appeared - if (is_new) { - found_new_device(dev); - } } private void activate_device(Device dev) { @@ -214,6 +218,9 @@ class DeviceManager : GLib.Object var h = core.handlers.get_capability_handler(cap); if (h != null) { dev.register_capability_handler(cap, h); + + device_capability_added(dev, cap, h); + } else { warning("no handler for capability %s", cap); } From 278d4ca2a4ff07c54ad7abacf9b24d357f06898e Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 7 Jun 2017 08:58:11 +0200 Subject: [PATCH 076/100] device-proxy, devicemanager-proxy: register packet handlers on DBus Signed-off-by: Maciek Borzecki --- src/mconnect/device-proxy.vala | 30 +++++++++++++++++++++++---- src/mconnect/devicemanager-proxy.vala | 5 +++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/mconnect/device-proxy.vala b/src/mconnect/device-proxy.vala index 2e3b47c..10daae6 100644 --- a/src/mconnect/device-proxy.vala +++ b/src/mconnect/device-proxy.vala @@ -74,7 +74,7 @@ class DeviceDBusProxy : Object { private set; } - private ArrayList handlers; + private HashMap handlers; private uint register_id = 0; @@ -87,7 +87,7 @@ class DeviceDBusProxy : Object { public DeviceDBusProxy.for_device_with_path(Device device, ObjectPath path) { this.device = device; this.object_path = path; - this.handlers = new ArrayList(); + this.handlers = new HashMap(); this.update_address(); this.update_capabilities(); this.device.notify.connect(this.param_changed); @@ -143,8 +143,8 @@ class DeviceDBusProxy : Object { } [DBus (visible = false)] - public void add_handler(PacketHandlerInterfaceProxy h) { - this.handlers.add(h); + public bool has_handler(string cap) { + return this.handlers.has_key(cap); } [DBus (visible = false)] @@ -164,4 +164,26 @@ class DeviceDBusProxy : Object { } this.register_id = 0; } + + [DBus (visible = false)] + public void bus_register_handler(DBusConnection conn, + string cap, + PacketHandlerInterfaceProxy handler) { + + handler.bus_register(conn, this.object_path); + this.handlers.@set(cap, handler); + } + + [DBus (visible = false)] + public void bus_unregister_handler(DBusConnection conn, + string cap) { + PacketHandlerInterfaceProxy handler; + + this.handlers.@unset(cap, out handler); + if (handler != null) { + handler.bus_unregister(conn); + } + } + + } \ No newline at end of file diff --git a/src/mconnect/devicemanager-proxy.vala b/src/mconnect/devicemanager-proxy.vala index 8d0d3b8..061f4e5 100644 --- a/src/mconnect/devicemanager-proxy.vala +++ b/src/mconnect/devicemanager-proxy.vala @@ -112,6 +112,11 @@ class DeviceManagerDBusProxy : Object if (dp == null) { warning("no bus proxy for device %s", dev.to_string()); + return; + } + + if (dp.has_handler(capability)) { + return; } info("add capability handler %s for device at path %s", From ed2c15210a83f5d022f15a79ee3acddca04d36b5 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 11 Jun 2017 20:25:40 +0200 Subject: [PATCH 077/100] battery-proxy: add Level and Charging properties to DBus interface --- src/mconnect/battery-proxy.vala | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/mconnect/battery-proxy.vala b/src/mconnect/battery-proxy.vala index 83455ba..14da156 100644 --- a/src/mconnect/battery-proxy.vala +++ b/src/mconnect/battery-proxy.vala @@ -25,6 +25,9 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { private BatteryHandler battery_handler = null; private uint register_id = 0; + public uint level { get; private set; default = 0; } + public bool charging { get; private set; default = false; } + public BatteryHandlerProxy.for_device_handler(Device dev, PacketHandlerInterface iface) { this.device = dev; @@ -38,6 +41,9 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { if (this.device != dev) return; + this.level = level; + this.charging = charging; + battery(level, charging); } From c183a1b120a116fa63431f36a7cc50303f8177aa Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 18 Jun 2017 22:27:34 +0200 Subject: [PATCH 078/100] dir-locals: add emacs setup --- .dir-locals.el | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .dir-locals.el diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..b6b1459 --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,7 @@ +((c-mode . ((c-file-style . "linux") + (indent-tabs-mode . t) + (show-trailing-whitespace . t) + (c-basic-offset . 4) + (tab-width . 4) + )) + ) From 11cd80adcf94c7c4fe2dea6a00cb5a24dc4ea7bd Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 18 Jun 2017 22:30:55 +0200 Subject: [PATCH 079/100] crypt: cleanup tabs --- src/crypt/mconn-crypt.c | 230 ++++++++++++++++++++-------------------- src/crypt/mconn-crypt.h | 46 ++++---- 2 files changed, 136 insertions(+), 140 deletions(-) diff --git a/src/crypt/mconn-crypt.c b/src/crypt/mconn-crypt.c index e007493..34bc24e 100644 --- a/src/crypt/mconn-crypt.c +++ b/src/crypt/mconn-crypt.c @@ -1,5 +1,3 @@ -/* ex:ts=4:sw=4:sts=4:et */ -/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -7,7 +5,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along @@ -25,7 +23,7 @@ /* encrypted data padding */ #define MCONN_CRYPT_RSA_PADDING RSA_PKCS1_PADDING -typedef struct _MconnCryptPrivate MconnCryptPrivate; +typedef struct _MconnCryptPrivate MconnCryptPrivate; /** * MconnCrypt: @@ -35,13 +33,13 @@ typedef struct _MconnCryptPrivate MconnCryptPrivate; struct _MconnCrypt { - GObject parent; - MconnCryptPrivate *priv; + GObject parent; + MconnCryptPrivate *priv; }; struct _MconnCryptPrivate { - RSA *key; /* RSA key wrapper */ + RSA *key; /* RSA key wrapper */ }; static void mconn_crypt_dispose (GObject *object); @@ -55,108 +53,108 @@ G_DEFINE_TYPE_WITH_PRIVATE (MconnCrypt, mconn_crypt, G_TYPE_OBJECT); static void mconn_crypt_class_init (MconnCryptClass *klass) { - GObjectClass *gobject_class = (GObjectClass *)klass; + GObjectClass *gobject_class = (GObjectClass *)klass; - gobject_class->dispose = mconn_crypt_dispose; - gobject_class->finalize = mconn_crypt_finalize; + gobject_class->dispose = mconn_crypt_dispose; + gobject_class->finalize = mconn_crypt_finalize; } static void mconn_crypt_init (MconnCrypt *self) { - g_debug("mconn-crypt: new instance"); - self->priv = mconn_crypt_get_instance_private(self); + g_debug("mconn-crypt: new instance"); + self->priv = mconn_crypt_get_instance_private(self); } static void mconn_crypt_dispose (GObject *object) { - MconnCrypt *self = (MconnCrypt *)object; + MconnCrypt *self = (MconnCrypt *)object; - if (self->priv->key != NULL) - { - RSA_free(self->priv->key); - self->priv->key = NULL; - } + if (self->priv->key != NULL) + { + RSA_free(self->priv->key); + self->priv->key = NULL; + } - G_OBJECT_CLASS (mconn_crypt_parent_class)->dispose (object); + G_OBJECT_CLASS (mconn_crypt_parent_class)->dispose (object); } static void mconn_crypt_finalize (GObject *object) { - MconnCrypt *self = (MconnCrypt *)object; + MconnCrypt *self = (MconnCrypt *)object; - g_signal_handlers_destroy (object); - G_OBJECT_CLASS (mconn_crypt_parent_class)->finalize (object); + g_signal_handlers_destroy (object); + G_OBJECT_CLASS (mconn_crypt_parent_class)->finalize (object); } MconnCrypt *mconn_crypt_new_for_key_path(const char *path) { - g_debug("mconn-crypt: new crypt for key %s", path); + g_debug("mconn-crypt: new crypt for key %s", path); - MconnCrypt *self = g_object_new(MCONN_TYPE_CRYPT, NULL); + MconnCrypt *self = g_object_new(MCONN_TYPE_CRYPT, NULL); - if (g_file_test(path, G_FILE_TEST_EXISTS) == FALSE) - __mconn_generate_key_at_path(path); + if (g_file_test(path, G_FILE_TEST_EXISTS) == FALSE) + __mconn_generate_key_at_path(path); - if (__mconn_load_key(self->priv, path) == FALSE) - { - mconn_crypt_unref(self); - return NULL; - } + if (__mconn_load_key(self->priv, path) == FALSE) + { + mconn_crypt_unref(self); + return NULL; + } - return self; + return self; } MconnCrypt * mconn_crypt_ref(MconnCrypt *self) { - g_assert(IS_MCONN_CRYPT(self)); - return MCONN_CRYPT(g_object_ref(self)); + g_assert(IS_MCONN_CRYPT(self)); + return MCONN_CRYPT(g_object_ref(self)); } void mconn_crypt_unref(MconnCrypt *self) { - if (self != NULL) - { - g_assert(IS_MCONN_CRYPT(self)); - g_object_unref(self); - } + if (self != NULL) + { + g_assert(IS_MCONN_CRYPT(self)); + g_object_unref(self); + } } GByteArray * mconn_crypt_decrypt(MconnCrypt *self, GBytes *data, GError **err) { - g_assert(IS_MCONN_CRYPT(self)); - g_assert(self->priv->key); + g_assert(IS_MCONN_CRYPT(self)); + g_assert(self->priv->key); - /* g_debug("decrypt: %zu bytes of data", g_bytes_get_size(data)); */ + /* g_debug("decrypt: %zu bytes of data", g_bytes_get_size(data)); */ - g_assert_cmpint(g_bytes_get_size(data), ==, RSA_size(self->priv->key)); + g_assert_cmpint(g_bytes_get_size(data), ==, RSA_size(self->priv->key)); - /* decrypted data is less than RSA_size() long */ - gsize out_buf_size = RSA_size(self->priv->key); - GByteArray *out_data = g_byte_array_sized_new(out_buf_size); + /* decrypted data is less than RSA_size() long */ + gsize out_buf_size = RSA_size(self->priv->key); + GByteArray *out_data = g_byte_array_sized_new(out_buf_size); - int dec_size; - dec_size = RSA_private_decrypt(g_bytes_get_size(data), - g_bytes_get_data(data, NULL), - (unsigned char *)out_data->data, - self->priv->key, - MCONN_CRYPT_RSA_PADDING); - /* g_debug("decrypted size: %d", dec_size); */ - g_assert(dec_size != -1); + int dec_size; + dec_size = RSA_private_decrypt(g_bytes_get_size(data), + g_bytes_get_data(data, NULL), + (unsigned char *)out_data->data, + self->priv->key, + MCONN_CRYPT_RSA_PADDING); + /* g_debug("decrypted size: %d", dec_size); */ + g_assert(dec_size != -1); - g_byte_array_set_size(out_data, dec_size); + g_byte_array_set_size(out_data, dec_size); - return out_data; + return out_data; } gchar *mconn_crypt_get_public_key_pem(MconnCrypt *self) { - g_assert(IS_MCONN_CRYPT(self)); - g_assert(self->priv); - g_assert(self->priv->key); - return __mconn_get_public_key_as_pem(self->priv); + g_assert(IS_MCONN_CRYPT(self)); + g_assert(self->priv); + g_assert(self->priv->key); + return __mconn_get_public_key_as_pem(self->priv); } /** @@ -164,89 +162,89 @@ gchar *mconn_crypt_get_public_key_pem(MconnCrypt *self) */ static gchar *__mconn_get_public_key_as_pem(MconnCryptPrivate *priv) { - gchar *pubkey = NULL; + gchar *pubkey = NULL; - /* memory IO */ - BIO *bm = BIO_new(BIO_s_mem()); + /* memory IO */ + BIO *bm = BIO_new(BIO_s_mem()); - /* generate PEM */ - /* PEM_write_bio_RSAPublicKey(bm, priv->key); */ - PEM_write_bio_RSA_PUBKEY(bm, priv->key); + /* generate PEM */ + /* PEM_write_bio_RSAPublicKey(bm, priv->key); */ + PEM_write_bio_RSA_PUBKEY(bm, priv->key); - /* get PEM as text */ - char *oss_pubkey = NULL; - long data = BIO_get_mem_data(bm, &oss_pubkey); - g_debug("mconn-crypt: public key length: %ld", data); - g_assert(data != 0); - g_assert(oss_pubkey != NULL); + /* get PEM as text */ + char *oss_pubkey = NULL; + long data = BIO_get_mem_data(bm, &oss_pubkey); + g_debug("mconn-crypt: public key length: %ld", data); + g_assert(data != 0); + g_assert(oss_pubkey != NULL); - /* dup the key as buffer goes away with BIO */ - pubkey = g_strndup(oss_pubkey, data); + /* dup the key as buffer goes away with BIO */ + pubkey = g_strndup(oss_pubkey, data); - BIO_set_close(bm, BIO_CLOSE); - BIO_free(bm); + BIO_set_close(bm, BIO_CLOSE); + BIO_free(bm); - return pubkey; + return pubkey; } static gboolean __mconn_load_key(MconnCryptPrivate *priv, const char *path) { - if (g_file_test(path, G_FILE_TEST_EXISTS) == FALSE) - { - g_critical("mconn-crypt: key file %s does not exist", path); - return FALSE; - } + if (g_file_test(path, G_FILE_TEST_EXISTS) == FALSE) + { + g_critical("mconn-crypt: key file %s does not exist", path); + return FALSE; + } - g_debug("mconn-crypt: loading key from %s", path); + g_debug("mconn-crypt: loading key from %s", path); - BIO *bf = BIO_new_file(path, "r"); + BIO *bf = BIO_new_file(path, "r"); - if (bf == NULL) - { - g_critical("mconn-crypt: failed to open file %s", path); - return FALSE; - } + if (bf == NULL) + { + g_critical("mconn-crypt: failed to open file %s", path); + return FALSE; + } - RSA *rsa = NULL; + RSA *rsa = NULL; - rsa = PEM_read_bio_RSAPrivateKey(bf, NULL, NULL, NULL); + rsa = PEM_read_bio_RSAPrivateKey(bf, NULL, NULL, NULL); - BIO_free(bf); + BIO_free(bf); - if (rsa == NULL) - { - g_critical("mconn-crypt: failed to read private key"); - return FALSE; - } + if (rsa == NULL) + { + g_critical("mconn-crypt: failed to read private key"); + return FALSE; + } - priv->key = rsa; + priv->key = rsa; - return TRUE; + return TRUE; } static gboolean __mconn_generate_key_at_path(const char *path) { - gboolean ret = TRUE; - RSA *rsa = NULL; + gboolean ret = TRUE; + RSA *rsa = NULL; - BIO *bf = BIO_new_file(path, "w"); - if (bf == NULL) - { - g_error("mconn-crypt: failed to open file"); - return FALSE; - } + BIO *bf = BIO_new_file(path, "w"); + if (bf == NULL) + { + g_error("mconn-crypt: failed to open file"); + return FALSE; + } - rsa = RSA_generate_key(2048, RSA_3, NULL, NULL); + rsa = RSA_generate_key(2048, RSA_3, NULL, NULL); - if (PEM_write_bio_RSAPrivateKey(bf, rsa, NULL, NULL, 0, NULL, NULL) == 0) - { - g_critical("mconn-crypt: failed to private write key to file"); - ret = FALSE; - } + if (PEM_write_bio_RSAPrivateKey(bf, rsa, NULL, NULL, 0, NULL, NULL) == 0) + { + g_critical("mconn-crypt: failed to private write key to file"); + ret = FALSE; + } - RSA_free(rsa); + RSA_free(rsa); - BIO_free(bf); + BIO_free(bf); - return ret; + return ret; } diff --git a/src/crypt/mconn-crypt.h b/src/crypt/mconn-crypt.h index 9473cb4..cb0e634 100644 --- a/src/crypt/mconn-crypt.h +++ b/src/crypt/mconn-crypt.h @@ -1,5 +1,3 @@ -/* ex:ts=4:sw=4:sts=4:et */ -/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -7,7 +5,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along @@ -25,32 +23,32 @@ G_BEGIN_DECLS -#define MCONN_TYPE_CRYPT \ +#define MCONN_TYPE_CRYPT \ (mconn_crypt_get_type()) -#define MCONN_CRYPT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - MCONN_TYPE_CRYPT, \ - MconnCrypt)) -#define MCONN_CRYPT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - MCONN_TYPE_CRYPT, \ - MconnCryptClass)) -#define IS_MCONN_CRYPT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - MCONN_TYPE_CRYPT)) -#define IS_MCONN_CRYPT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - MCONN_TYPE_CRYPT)) -#define MCONN_CRYPT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - MCONN_TYPE_CRYPT, \ - MconnCryptClass)) +#define MCONN_CRYPT(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + MCONN_TYPE_CRYPT, \ + MconnCrypt)) +#define MCONN_CRYPT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + MCONN_TYPE_CRYPT, \ + MconnCryptClass)) +#define IS_MCONN_CRYPT(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + MCONN_TYPE_CRYPT)) +#define IS_MCONN_CRYPT_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), \ + MCONN_TYPE_CRYPT)) +#define MCONN_CRYPT_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + MCONN_TYPE_CRYPT, \ + MconnCryptClass)) -typedef struct _MconnCrypt MconnCrypt; +typedef struct _MconnCrypt MconnCrypt; typedef struct _MconnCryptClass MconnCryptClass; struct _MconnCryptClass { - GObjectClass parent_class; + GObjectClass parent_class; }; GType mconn_crypt_get_type (void) G_GNUC_CONST; From 4c542bf5512aa624f3fd7c8db7d4886093e7aa3f Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 18 Jun 2017 22:34:19 +0200 Subject: [PATCH 080/100] crypt: cleanup deprecated RSA_generate_key() --- src/crypt/mconn-crypt.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/crypt/mconn-crypt.c b/src/crypt/mconn-crypt.c index 34bc24e..a6a19ff 100644 --- a/src/crypt/mconn-crypt.c +++ b/src/crypt/mconn-crypt.c @@ -224,26 +224,46 @@ static gboolean __mconn_load_key(MconnCryptPrivate *priv, const char *path) static gboolean __mconn_generate_key_at_path(const char *path) { - gboolean ret = TRUE; + gboolean ret = FALSE; RSA *rsa = NULL; + BIO *bf = NULL; + BIGNUM *e = NULL; + int res = 0; - BIO *bf = BIO_new_file(path, "w"); + rsa = RSA_new(); + g_return_val_if_fail(rsa != NULL, FALSE); + + e = BN_new(); + if (e == NULL) + { + goto cleanup; + } + + BN_set_word(e, RSA_3); + + if (RSA_generate_key_ex(rsa, 2048, e, NULL) != 1) { + g_critical("mconn-crypt: failed to generate RSA key"); + goto cleanup; + } + + bf = BIO_new_file(path, "w"); if (bf == NULL) { g_error("mconn-crypt: failed to open file"); - return FALSE; + goto cleanup; } - rsa = RSA_generate_key(2048, RSA_3, NULL, NULL); - if (PEM_write_bio_RSAPrivateKey(bf, rsa, NULL, NULL, 0, NULL, NULL) == 0) { g_critical("mconn-crypt: failed to private write key to file"); - ret = FALSE; + goto cleanup; } - RSA_free(rsa); + ret = TRUE; + cleanup: + BN_free(e); + RSA_free(rsa); BIO_free(bf); return ret; From f739c652b3b9a2aff8978a342a7f059febdb40dc Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 18 Jun 2017 22:38:56 +0200 Subject: [PATCH 081/100] test: fix implicit declaration of g_remove() --- test/mconn-crypt-test.c | 1 + 1 file changed, 1 insertion(+) diff --git a/test/mconn-crypt-test.c b/test/mconn-crypt-test.c index 65cb5c5..c6c7b0a 100644 --- a/test/mconn-crypt-test.c +++ b/test/mconn-crypt-test.c @@ -18,6 +18,7 @@ * Maciek Borzecki */ #include +#include #include "mconn-crypt.h" static void test_simple(void) From 6d911bdb717d144f6419936836d69f47f35c3a65 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 18 Jun 2017 22:41:50 +0200 Subject: [PATCH 082/100] test: cleanup indentation --- test/mconn-crypt-test.c | 44 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/test/mconn-crypt-test.c b/test/mconn-crypt-test.c index c6c7b0a..3f6f4e9 100644 --- a/test/mconn-crypt-test.c +++ b/test/mconn-crypt-test.c @@ -1,5 +1,3 @@ -/* ex:ts=4:sw=4:sts=4:et */ -/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -7,7 +5,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along @@ -23,37 +21,37 @@ static void test_simple(void) { - g_remove("/tmp/test.key"); - /* we made sure that file is removed */ - g_assert_false(g_file_test("/tmp/test.key", G_FILE_TEST_EXISTS)); + g_remove("/tmp/test.key"); + /* we made sure that file is removed */ + g_assert_false(g_file_test("/tmp/test.key", G_FILE_TEST_EXISTS)); - MconnCrypt *cr = mconn_crypt_new_for_key_path("/tmp/test.key"); - g_assert_nonnull(cr); - g_assert_true(g_file_test("/tmp/test.key", G_FILE_TEST_EXISTS)); + MconnCrypt *cr = mconn_crypt_new_for_key_path("/tmp/test.key"); + g_assert_nonnull(cr); + g_assert_true(g_file_test("/tmp/test.key", G_FILE_TEST_EXISTS)); - gchar *pubkey1 = mconn_crypt_get_public_key_pem(cr); + gchar *pubkey1 = mconn_crypt_get_public_key_pem(cr); - mconn_crypt_unref(cr); - /* file should still exit */ - g_assert_true(g_file_test("/tmp/test.key", G_FILE_TEST_EXISTS)); + mconn_crypt_unref(cr); + /* file should still exit */ + g_assert_true(g_file_test("/tmp/test.key", G_FILE_TEST_EXISTS)); - cr = mconn_crypt_new_for_key_path("/tmp/test.key"); - /* key should have been loaded */ - g_assert_nonnull(cr); - g_assert_true(g_file_test("/tmp/test.key", G_FILE_TEST_EXISTS)); + cr = mconn_crypt_new_for_key_path("/tmp/test.key"); + /* key should have been loaded */ + g_assert_nonnull(cr); + g_assert_true(g_file_test("/tmp/test.key", G_FILE_TEST_EXISTS)); - gchar *pubkey2 = mconn_crypt_get_public_key_pem(cr); + gchar *pubkey2 = mconn_crypt_get_public_key_pem(cr); - mconn_crypt_unref(cr); + mconn_crypt_unref(cr); - g_assert_cmpstr(pubkey1, ==, pubkey2); + g_assert_cmpstr(pubkey1, ==, pubkey2); } int main(int argc, char *argv[]) { - g_test_init(&argc, &argv, NULL); + g_test_init(&argc, &argv, NULL); - g_test_add_func("/mconn-crypt/init", test_simple); + g_test_add_func("/mconn-crypt/init", test_simple); - return g_test_run(); + return g_test_run(); } From a0f1ba8efa7fc5f96c47ee3caefc18bdb603b3ff Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 20 Jun 2017 10:21:58 +0200 Subject: [PATCH 083/100] mconnect/battery-proxy: send org.freedesktop.DBus.Properties.PropertiesChanged --- src/mconnect/battery-proxy.vala | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/mconnect/battery-proxy.vala b/src/mconnect/battery-proxy.vala index 14da156..cd6b08c 100644 --- a/src/mconnect/battery-proxy.vala +++ b/src/mconnect/battery-proxy.vala @@ -24,6 +24,7 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { private Device device = null; private BatteryHandler battery_handler = null; private uint register_id = 0; + private ulong notify_id = 0; public uint level { get; private set; default = 0; } public bool charging { get; private set; default = false; } @@ -51,6 +52,10 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { public void bus_register(DBusConnection conn, string path) throws IOError { if (this.register_id == 0) this.register_id = conn.register_object(path, this); + + this.notify_id = this.notify.connect((spec) => { + this.send_property_change(conn, path, spec); + }); } [DBus (visible = false)] @@ -58,7 +63,39 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { if (this.register_id != 0) conn.unregister_object(this.register_id); this.register_id = 0; + + this.disconnect(this.notify_id); + this.notify_id = 0; } public signal void battery(uint level, bool charging); + + private void send_property_change(DBusConnection conn, string path, ParamSpec p) { + var builder = new VariantBuilder (VariantType.ARRAY); + var invalid_builder = new VariantBuilder (new VariantType ("as")); + + if (p.name == "level") { + Variant i = this.level; + builder.add ("{sv}", "level", i); + } + + if (p.name == "charging") { + Variant i = this.charging; + builder.add ("{sv}", "charging", i); + } + + try { + conn.emit_signal(null, + path, + "org.freedesktop.DBus.Properties", + "PropertiesChanged", + new Variant ("(sa{sv}as)", + "org.mconnect.Device.Battery", + builder, + invalid_builder) + ); + } catch (Error e) { + warning("%s\n", e.message); + } + } } \ No newline at end of file From 74378335f529d237742841cd7bd62d1dccdcc8ec Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 20 Jun 2017 21:25:18 +0200 Subject: [PATCH 084/100] property-proxy: helper class for sending out DBus PropertiesChanged signals --- Makefile.am | 3 +- src/mconnect/property-proxy.vala | 101 +++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/mconnect/property-proxy.vala diff --git a/Makefile.am b/Makefile.am index 5620a01..4cced10 100644 --- a/Makefile.am +++ b/Makefile.am @@ -76,7 +76,8 @@ mconnect_SOURCES = \ src/mconnect/ping-proxy.vala \ src/mconnect/config.vala \ src/mconnect/application.vala \ - src/mconnect/utils.vala + src/mconnect/utils.vala \ + src/mconnect/property-proxy.vala mconnect_LDADD = \ libmconn-crypt.la \ diff --git a/src/mconnect/property-proxy.vala b/src/mconnect/property-proxy.vala new file mode 100644 index 0000000..3ab4778 --- /dev/null +++ b/src/mconnect/property-proxy.vala @@ -0,0 +1,101 @@ +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * AUTHORS + * Maciek Borzecki + */ + +/** + * DBusPropertyNotifier: + * + * Helper class for pushing out + * org.freedesktop.DBus.Properties.PropertiesChanged signals. + */ +class DBusPropertyNotifier : Object { + + private DBusConnection conn = null; + private string iface = ""; + private string path = ""; + private VariantBuilder builder = null; + private uint timeout_src = 0; + + public const uint TIMEOUT = 300; + + public DBusPropertyNotifier(DBusConnection conn, + string iface, + string path) { + this.conn = conn; + this.iface = iface; + this.path = path; + } + + /** + * queue_property_change: + * + * @name: property name (will be automatically capitalized if needed) + * @val: Variant holding property value + * + * This method will queue up property notifications for sending. By default + * it waits @TIMEOUT ms before sending the actual signal. + */ + public void queue_property_change(string name, Variant val) { + if (this.builder == null) { + this.builder = new VariantBuilder(VariantType.ARRAY); + } + + string nm = name; + if (name.get_char(0).islower()) { + nm = name.get_char(0).toupper().to_string() + name.substring(1); + } + + this.builder.add("{sv}", nm, val); + + if (this.timeout_src == 0) { + this.timeout_src = Timeout.add(300, + this.send_property_change); + } + } + + /** + * send_property_change: + * + * Send out actual PropertiesChanged signals + */ + private bool send_property_change() { + this.timeout_src = 0; + + if (this.builder == null) + return false;; + + try { + var invalid_builder = new VariantBuilder(new VariantType ("as")); + + this.conn.emit_signal(null, + this.path, + "org.freedesktop.DBus.Properties", + "PropertiesChanged", + new Variant ("(sa{sv}as)", + this.iface, + builder, + invalid_builder) + ); + } catch (Error e) { + warning("%s\n", e.message); + } + + this.builder = null; + + return false; + } +} \ No newline at end of file From 99dd419d6a3dd3a3d0a11fc11291c821a693fb55 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 20 Jun 2017 21:25:58 +0200 Subject: [PATCH 085/100] battery-proxy: use DBusPropertyNotifier helper for sending property notifications --- src/mconnect/battery-proxy.vala | 54 ++++++++++++++------------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/src/mconnect/battery-proxy.vala b/src/mconnect/battery-proxy.vala index cd6b08c..0f02e82 100644 --- a/src/mconnect/battery-proxy.vala +++ b/src/mconnect/battery-proxy.vala @@ -25,6 +25,7 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { private BatteryHandler battery_handler = null; private uint register_id = 0; private ulong notify_id = 0; + private DBusPropertyNotifier prop_notifier = null; public uint level { get; private set; default = 0; } public bool charging { get; private set; default = false; } @@ -53,9 +54,11 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { if (this.register_id == 0) this.register_id = conn.register_object(path, this); - this.notify_id = this.notify.connect((spec) => { - this.send_property_change(conn, path, spec); - }); + this.prop_notifier = new DBusPropertyNotifier(conn, + "org.mconnect.Device.Battery", + path); + + this.notify.connect(this.send_property_change); } [DBus (visible = false)] @@ -64,38 +67,27 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { conn.unregister_object(this.register_id); this.register_id = 0; - this.disconnect(this.notify_id); + this.notify.disconnect(this.send_property_change); this.notify_id = 0; } public signal void battery(uint level, bool charging); - private void send_property_change(DBusConnection conn, string path, ParamSpec p) { - var builder = new VariantBuilder (VariantType.ARRAY); - var invalid_builder = new VariantBuilder (new VariantType ("as")); - - if (p.name == "level") { - Variant i = this.level; - builder.add ("{sv}", "level", i); - } - - if (p.name == "charging") { - Variant i = this.charging; - builder.add ("{sv}", "charging", i); - } - - try { - conn.emit_signal(null, - path, - "org.freedesktop.DBus.Properties", - "PropertiesChanged", - new Variant ("(sa{sv}as)", - "org.mconnect.Device.Battery", - builder, - invalid_builder) - ); - } catch (Error e) { - warning("%s\n", e.message); - } + private void send_property_change(ParamSpec p) { + assert(this.prop_notifier != null); + + Variant v = null; + + if (p.name == "level") { + v = this.level; + } + if (p.name == "charging") { + v = this.charging; + } + + if (v == null) + return; + + this.prop_notifier.queue_property_change(p.name, v); } } \ No newline at end of file From a1bc21e07ae34f8616196dbd40d488be280eb4f0 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 20 Jun 2017 21:29:01 +0200 Subject: [PATCH 086/100] battery-proxy: remove battery(level, charing) signal --- src/mconnect/battery-proxy.vala | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/mconnect/battery-proxy.vala b/src/mconnect/battery-proxy.vala index 0f02e82..18fbfda 100644 --- a/src/mconnect/battery-proxy.vala +++ b/src/mconnect/battery-proxy.vala @@ -45,8 +45,6 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { this.level = level; this.charging = charging; - - battery(level, charging); } [DBus (visible = false)] @@ -71,8 +69,6 @@ class BatteryHandlerProxy : Object, PacketHandlerInterfaceProxy { this.notify_id = 0; } - public signal void battery(uint level, bool charging); - private void send_property_change(ParamSpec p) { assert(this.prop_notifier != null); From 3f2b15715f0f73f92f78cff675c8802dadd3ed08 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Tue, 20 Jun 2017 22:06:34 +0200 Subject: [PATCH 087/100] device-proxy: signal PropertiesChanged --- src/mconnect/device-proxy.vala | 46 +++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/mconnect/device-proxy.vala b/src/mconnect/device-proxy.vala index 10daae6..40aaa06 100644 --- a/src/mconnect/device-proxy.vala +++ b/src/mconnect/device-proxy.vala @@ -78,6 +78,8 @@ class DeviceDBusProxy : Object { private uint register_id = 0; + private DBusPropertyNotifier prop_notifier = null; + [DBus (visible = false)] public ObjectPath object_path = null; @@ -91,6 +93,7 @@ class DeviceDBusProxy : Object { this.update_address(); this.update_capabilities(); this.device.notify.connect(this.param_changed); + this.notify.connect(this.update_properties); } private void update_capabilities() { @@ -112,11 +115,48 @@ class DeviceDBusProxy : Object { private void update_address() { this.address = "%s:%u".printf(device.host.to_string(), device.tcp_port); - this.device.notify.connect(this.update_properties); } private void update_properties(ParamSpec param) { debug("param %s changed", param.name); + + string name = param.name; + Variant v = null; + switch (param.name) { + case "address": + v = this.address; + break; + case "id": + v = this.id; + break; + case "name": + v = this.name; + break; + case "device-type": + name = "DeviceType"; + v = this.device_type; + break; + case "potocol-version": + name = "ProtocolVersion"; + v = this.protocol_version; + break; + case "is-paired": + name = "IsPaired"; + v = this.is_paired; + break; + case "allowed": + v = this.allowed; + break; + case "is-active": + name = "IsActive"; + v = this.is_active; + break; + } + + if (v == null) + return; + + this.prop_notifier.queue_property_change(name, v); } private void param_changed(ParamSpec param) { @@ -151,6 +191,9 @@ class DeviceDBusProxy : Object { public void bus_register(DBusConnection conn) { try { this.register_id = conn.register_object(this.object_path, this); + this.prop_notifier = new DBusPropertyNotifier(conn, + "org.mconnect.Device", + this.object_path); } catch (IOError err) { warning("failed to register DBus object for device %s under path %s", this.device.to_string(), this.object_path.to_string()); @@ -163,6 +206,7 @@ class DeviceDBusProxy : Object { conn.unregister_object(this.register_id); } this.register_id = 0; + this.prop_notifier = null; } [DBus (visible = false)] From 64bb2741f7f51b6ee8b8c82fa756a41abf0dcd85 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 21 Jun 2017 21:02:32 +0200 Subject: [PATCH 088/100] device: emit connected() signal --- src/mconnect/device.vala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 1d9039f..16654a1 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -306,6 +306,9 @@ class Device : Object { */ private void channel_openend(bool result) { debug("channel openend: %s", result.to_string()); + + connected(); + if (result == true) { greet.begin(); } else { From c932b851df57a1aaa20b9047949ce2d65faa9346 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 21 Jun 2017 21:02:56 +0200 Subject: [PATCH 089/100] device: make is_active a simple property --- src/mconnect/device.vala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 16654a1..9df2c16 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -54,11 +54,8 @@ class Device : Object { public InetAddress host { get; private set; default = null; } public bool is_paired { get; private set; default = false; } public bool allowed {get; set; default = false; } - public bool is_active { - get { return (_channel != null); } - set {} - default = false; - } + public bool is_active { get; private set; default = false; } + public ArrayList outgoing_capabilities { get; private set; @@ -285,6 +282,8 @@ class Device : Object { _channel.open.begin((c, res) => { this.channel_openend(_channel.open.end(res)); }); + + this.is_active = true; } /** @@ -436,6 +435,9 @@ class Device : Object { private void channel_closed_cleanup() { debug("close cleanup"); _channel = null; + + this.is_active = false; + // emit disconnected disconnected(); } From 8894650a9fa814e7363dd6e2fbd8f032ef8f3158 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 21 Jun 2017 21:03:21 +0200 Subject: [PATCH 090/100] device-proxy: add is_connected (bool IsConnected) property Hook to connected()/disconnected() Device signals. --- src/mconnect/device-proxy.vala | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mconnect/device-proxy.vala b/src/mconnect/device-proxy.vala index 40aaa06..4ea47ad 100644 --- a/src/mconnect/device-proxy.vala +++ b/src/mconnect/device-proxy.vala @@ -63,6 +63,7 @@ class DeviceDBusProxy : Object { private set {} default = false; } + public bool is_connected { get; private set; default = false; } public string[] incoming_capabilities { get; @@ -93,6 +94,12 @@ class DeviceDBusProxy : Object { this.update_address(); this.update_capabilities(); this.device.notify.connect(this.param_changed); + this.device.connected.connect(() => { + this.is_connected = true; + }); + this.device.disconnected.connect(() => { + this.is_connected = false; + }); this.notify.connect(this.update_properties); } @@ -151,6 +158,10 @@ class DeviceDBusProxy : Object { name = "IsActive"; v = this.is_active; break; + case "is-connected": + name = "IsConnected"; + v = this.is_connected; + break; } if (v == null) From 60461c08ab7f32ec6263273819d5f6ccebec2ca5 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 21 Jun 2017 21:40:03 +0200 Subject: [PATCH 091/100] mconnectctl: --verbose switch Affects show-device output. --- src/mconnectctl/main.vala | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mconnectctl/main.vala b/src/mconnectctl/main.vala index 371d392..7a56326 100644 --- a/src/mconnectctl/main.vala +++ b/src/mconnectctl/main.vala @@ -47,6 +47,7 @@ namespace Mconnect { public class Client { private static bool log_debug = false; + private static bool verbose = false; // some hints for valac about the array holding remaining args [CCode (array_length = false, array_null_terminated = true)] private static string[] remaining; @@ -55,6 +56,8 @@ namespace Mconnect { private const OptionEntry[] options = { {"debug", 'd', 0, OptionArg.NONE, ref log_debug, "Show debug output", null}, + {"verbose", 'v', 0, OptionArg.NONE, ref verbose, + "Be verbose", null}, // there's no Vala const for G_OPTION_REMAINING (which is a #define // for "") {"", 0, 0, OptionArg.STRING_ARRAY, ref remaining, null, @@ -215,10 +218,12 @@ namespace Mconnect { dp.allowed.to_string(), dp.is_paired.to_string(), dp.is_active.to_string()); - stdout.printf(" Capabilities (out):\n"); - print_sorted_caps(dp.outgoing_capabilities, " %s\n"); - stdout.printf(" Capabilities (in):\n"); - print_sorted_caps(dp.incoming_capabilities, " %s\n"); + if (verbose) { + stdout.printf(" Capabilities (out):\n"); + print_sorted_caps(dp.outgoing_capabilities, " %s\n"); + stdout.printf(" Capabilities (in):\n"); + print_sorted_caps(dp.incoming_capabilities, " %s\n"); + } return 0; }); } From 50057f935b0c1c9d50b4be7d48c63d58414bc13d Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 21 Jun 2017 21:40:41 +0200 Subject: [PATCH 092/100] mconnectctl: use IsConnected property --- src/mconnectctl/main.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mconnectctl/main.vala b/src/mconnectctl/main.vala index 7a56326..d5dfe0e 100644 --- a/src/mconnectctl/main.vala +++ b/src/mconnectctl/main.vala @@ -40,6 +40,7 @@ namespace Mconnect { public abstract bool is_paired { owned get;} public abstract bool allowed { owned get;} public abstract bool is_active { owned get;} + public abstract bool is_connected { owned get;} public abstract string[] outgoing_capabilities { owned get;} public abstract string[] incoming_capabilities { owned get;} } @@ -217,7 +218,7 @@ namespace Mconnect { dp.device_type, dp.allowed.to_string(), dp.is_paired.to_string(), - dp.is_active.to_string()); + dp.is_connected.to_string()); if (verbose) { stdout.printf(" Capabilities (out):\n"); print_sorted_caps(dp.outgoing_capabilities, " %s\n"); From 9602f5a2381a27ebabbafc9bf41f174c7640bfba Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 21 Jun 2017 22:15:43 +0200 Subject: [PATCH 093/100] travis: build on opensuse --- .travis.yml | 1 + extra/travis-build | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9ec8548..2fbab36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ env: matrix: - DISTRO=fedora - DISTRO=archlinux + - DISTRO=opensuse script: - ./extra/travis-build "${DISTRO}" diff --git a/extra/travis-build b/extra/travis-build index f95c075..f27c40a 100755 --- a/extra/travis-build +++ b/extra/travis-build @@ -42,6 +42,24 @@ deps_fedora() { gtk3-devel } +deps_opensuse() { + zypper install -y \ + make \ + automake \ + autoconf \ + libtool \ + pkgconfig \ + gcc \ + vala \ + gobject-introspection-devel \ + json-glib-devel \ + libgee-devel \ + openssl-devel \ + libnotify-devel \ + at-spi2-core-devel \ + gtk3-devel +} + deps_archlinux() { pacman -Syu --noconfirm \ base-devel \ @@ -66,6 +84,9 @@ install_deps() { fedora) deps_fedora ;; + opensuse) + deps_opensuse + ;; archlinux) deps_archlinux ;; @@ -97,6 +118,9 @@ spin_container() { archlinux) DOCKER_IMG=base/archlinux ;; + opensuse) + DOCKER_IMG=opensuse:tumbleweed + ;; *) echo "unsupported distro $1" exit 1 From f8b0de37a80b636defa01a8fdcb505b115207e6b Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Sun, 2 Jul 2017 19:20:45 -0700 Subject: [PATCH 094/100] add 'disallow_device()' function to devicemanager.vala and devicemanager-proxy.vala --- src/mconnect/devicemanager-proxy.vala | 21 ++++++++++++++++++++- src/mconnect/devicemanager.vala | 15 ++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/mconnect/devicemanager-proxy.vala b/src/mconnect/devicemanager-proxy.vala index 061f4e5..22de62c 100644 --- a/src/mconnect/devicemanager-proxy.vala +++ b/src/mconnect/devicemanager-proxy.vala @@ -68,6 +68,25 @@ class DeviceManagerDBusProxy : Object this.manager.allow_device(dev_proxy.device); } + /** + * disallow_device: + * @path: device object path + * + * Disallow given device + */ + public void disallow_device(string path) { + debug("disallow device %s", path); + + var dev_proxy = this.devices.@get(path); + + if (dev_proxy == null) { + warning("no device under path %s", path); + return; + } + + this.manager.disallow_device(dev_proxy.device); + } + /** * list_devices: * @@ -143,4 +162,4 @@ class DeviceManagerDBusProxy : Object return path; } -} \ No newline at end of file +} diff --git a/src/mconnect/devicemanager.vala b/src/mconnect/devicemanager.vala index df01a50..4463f37 100644 --- a/src/mconnect/devicemanager.vala +++ b/src/mconnect/devicemanager.vala @@ -252,4 +252,17 @@ class DeviceManager : GLib.Object // maybe activate if needed activate_device(dev); } -} \ No newline at end of file + + /** + * disallow_device: + * @path: device object path + * + * Disallow given device + */ + public void disallow_device(Device dev) { + dev.allowed = false; + + // update device cache + update_cache(); + } +} From 28c8345ecae8c68b7b52167dfcbb4ac7f2a070b4 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Tue, 22 Aug 2017 23:17:48 -0700 Subject: [PATCH 095/100] add device_added, device_removed signals --- src/mconnect/devicemanager-proxy.vala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mconnect/devicemanager-proxy.vala b/src/mconnect/devicemanager-proxy.vala index 22de62c..eb44782 100644 --- a/src/mconnect/devicemanager-proxy.vala +++ b/src/mconnect/devicemanager-proxy.vala @@ -24,6 +24,10 @@ class DeviceManagerDBusProxy : Object { private DeviceManager manager; + public signal void device_added(string path); + + public signal void device_removed(string path); + private const string DBUS_PATH = "/org/mconnect/manager"; private DBusConnection bus = null; private HashMap devices; @@ -111,6 +115,7 @@ class DeviceManagerDBusProxy : Object info("register device %s under path %s", dev.to_string(), path); device_proxy.bus_register(this.bus); + device_added(path); } private DeviceDBusProxy? find_proxy_for_device(Device dev) { From 5a373602cb1c3f5d698f205c08437668be471d3c Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 22 Jun 2017 22:59:25 +0200 Subject: [PATCH 096/100] packet: support payload information --- src/mconnect/packet.vala | 41 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/mconnect/packet.vala b/src/mconnect/packet.vala index 5d27fdb..efb413f 100644 --- a/src/mconnect/packet.vala +++ b/src/mconnect/packet.vala @@ -26,6 +26,20 @@ public errordomain PacketError { class Packet : GLib.Object { + /** + * Payload: + * Wrapper for payload transfer information + */ + public struct Payload { + public uint64 size; + public uint port; + + Payload() { + this.size = 0; + this.port = 0; + } + } + public const int PROTOCOL_VERSION = 5; public const string IDENTITY = "kdeconnect.identity"; @@ -35,6 +49,7 @@ class Packet : GLib.Object { public string pkt_type { get; private set; default = ""; } public int64 id { get; private set; default = 0; } public Json.Object body { get; private set; default = null; } + public Payload? payload { get; private set; default = null; } public Packet(string type, Json.Object body, int64 id = 0) { this.pkt_type = type; @@ -69,7 +84,31 @@ class Packet : GLib.Object { vdebug("packet type: %s", type); - return new Packet(type, body, id); + var pkt = new Packet(type, body, id); + + // ignore payload info for encrypted packets + if (type != ENCRYPTED) { + if (root_obj.has_member("payloadSize") && + root_obj.has_member("payloadTransferInfo")) { + + + var size = root_obj.get_int_member("payloadSize"); + + var pti = root_obj.get_object_member("payloadTransferInfo"); + int64 port = 0; + if (pti == null) { + warning("no payload transfer info?"); + } else { + port = (int) pti.get_int_member("port"); + } + + if (size != 0 && port != 0) { + pkt.payload = {(uint64) size, (uint) port}; + } + } + } + + return pkt; } catch (Error e) { message("failed to parse message: \'%s\', error: %s", data, e.message); From 235578165f92ed3f564a4f3e3c51e4d1af30bef9 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 22 Jun 2017 22:59:45 +0200 Subject: [PATCH 097/100] device: cleanup out parameters in merge_capabilities() --- src/mconnect/device.vala | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/mconnect/device.vala b/src/mconnect/device.vala index 9df2c16..b0d02f0 100644 --- a/src/mconnect/device.vala +++ b/src/mconnect/device.vala @@ -500,20 +500,16 @@ class Device : Object { caps.add_all(this.outgoing_capabilities); caps.add_all(this.incoming_capabilities); - if (added == null) { - added = new HashSet(); - added.add_all(caps); + added = new HashSet(); + added.add_all(caps); - // TODO: simplify capability names, eg kdeconnect.telephony.request -> - // kdeconnect.telephony - added.remove_all(this._capabilities); - } + // TODO: simplify capability names, eg kdeconnect.telephony.request -> + // kdeconnect.telephony + added.remove_all(this._capabilities); - if (removed == null) { - removed = new HashSet(); - removed.add_all(this._capabilities); - removed.remove_all(caps); - } + removed = new HashSet(); + removed.add_all(this._capabilities); + removed.remove_all(caps); this._capabilities = caps; } From 33b0b9ef3a5e6cbbd074c7aa632a8ea84b63cd37 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 22 Jun 2017 23:00:11 +0200 Subject: [PATCH 098/100] mconnectctl: add active field --- src/mconnectctl/main.vala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mconnectctl/main.vala b/src/mconnectctl/main.vala index d5dfe0e..1f7d013 100644 --- a/src/mconnectctl/main.vala +++ b/src/mconnectctl/main.vala @@ -211,6 +211,7 @@ namespace Mconnect { " Type: %s\n" + " Allowed: %s\n" + " Paired: %s\n" + + " Active: %s\n" + " Connected: %s\n", dp.name, dp.id, @@ -218,6 +219,7 @@ namespace Mconnect { dp.device_type, dp.allowed.to_string(), dp.is_paired.to_string(), + dp.is_active.to_string(), dp.is_connected.to_string()); if (verbose) { stdout.printf(" Capabilities (out):\n"); From f34910669c707dd6e17e4682edf27ca4d33e2131 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 10 Sep 2017 19:58:15 +0200 Subject: [PATCH 099/100] extra/firewalld: add sample firewalld configuration --- extra/firewalld/mconnect.xml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 extra/firewalld/mconnect.xml diff --git a/extra/firewalld/mconnect.xml b/extra/firewalld/mconnect.xml new file mode 100644 index 0000000..3b4d8d5 --- /dev/null +++ b/extra/firewalld/mconnect.xml @@ -0,0 +1,6 @@ + + + mconnect + mconnect service configuration + + From c252180609ed5f1be161892f41b44336ad1089c5 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 10 Sep 2017 19:58:31 +0200 Subject: [PATCH 100/100] README: update readme --- README.md | 78 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9510184..61f245d 100644 --- a/README.md +++ b/README.md @@ -19,17 +19,21 @@ Build dependencies (using package names as found in Fedora): - libnotify-devel - at-spi2-core-devel (and at-spi2-atk) -or see `mconnect.spec` in source tree. Once build deps are in place, run: +or see `extra/travis-build` in the source tree for example installation +commands. Once build deps are in place, run: - autoreconf -if + autoreconf -if ./configure --prefix= make make install # or make DESTDIR= install if you want to inspect what # gets installed + # Configuration +**NOTE**: manual configuration file is no longer needed + A sample configuration file is provided in source tree, see `mconnect.conf`. It will get installed to `${datadir}/mconnect/` (usually corresponding to `/usr/share/mconnect/`) by default. Once @@ -43,16 +47,70 @@ Android application, only `name` and `type` are used for matching. # Usage +mconnect comes are 2 separate programs, the daemon - `mconnect` and a D-Bus +client `mconnectctl`. + +## The daemon + Start it by running: - mconnect -d +``` +$ mconnect -d +``` + +The daemon starts listens on `0.0.0.0:1714` for incoming UDP packets. Once an +identity packet (a sort of a handshake) is received, a connection to the +sender's address will be made. Known devices are cached in +`~/.cache/mconnect/devices`. + +## The client + +List discovered devices: + +``` +$ ./mconnectctl list-devices +Devices: + /org/mconnect/device/0 673ac2db27d2a331 - Motorola Moto G Maciek +``` + +Accept a device (previously done only through the configuration): + +``` +$ ./mconnectctl allow-device /org/mconnect/device/0 +``` + +Show device details: + +``` +$ ./mconnectctl show-device /org/mconnect/device/0 +Device + Name: Motorola Moto G Maciek + ID: 673ac2db27d2a331 + Address: 192.168.1.103:1716 + Type: phone + Allowed: true + Paired: true + Active: true + Connected: true +``` + +## DBus API + +The API is not documented. Use D-Feet or busctl to introspect and invoke methods +manually. + +## Gnome Shell + +A Gnome Shell extension is available here: +https://github.com/andyholmes/gnome-shell-extension-mconnect or via the GNOME +extensions page: https://extensions.gnome.org/extension/1272/mconnect/ + -# Operation +# Firewalls -The daemon starts listening on `0.0.0.0:1714` for incoming UDP -packets. Once an identity packet (a sort of a handshake) is received, -a connection at the sender's address will be made only if the device -is listed as `allowed` in `mconnect.conf` (see the sample config). -Should the device be whitelisted in configuration, pairing will happen -automatically. +It may be required to either temporarily disable the firewall or open up UDP +port 1714. +An example service definition for [firewalld](http://www.firewalld.org/) is +provided in `extra/firewalld/mconnect.xml` directory. The file needs to be +copied into `/etc/firewalld/services`.