From 517a27d518ec1a0f43bd11b617448ebdac537e74 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Wed, 25 Oct 2017 22:58:07 +0200 Subject: [PATCH] mconnectctl: find-my-phone command --- meson.build | 1 + src/mconnectctl/find-my-phone-iface.vala | 26 ++++++++++++++++++++++++ src/mconnectctl/main.vala | 23 +++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/mconnectctl/find-my-phone-iface.vala diff --git a/meson.build b/meson.build index 04615e4..4bde0da 100644 --- a/meson.build +++ b/meson.build @@ -77,6 +77,7 @@ mconnectctl_src = [ 'src/mconnectctl/device-iface.vala', 'src/mconnectctl/share-iface.vala', 'src/mconnectctl/telephony-iface.vala', + 'src/mconnectctl/find-my-phone-iface.vala', ] executable('mconnectctl', mconnectctl_src, dependencies : [glib_dep, gobject_dep, diff --git a/src/mconnectctl/find-my-phone-iface.vala b/src/mconnectctl/find-my-phone-iface.vala new file mode 100644 index 0000000..437f240 --- /dev/null +++ b/src/mconnectctl/find-my-phone-iface.vala @@ -0,0 +1,26 @@ +/** + * 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.Device.FindMyPhone")] + public interface FindMyPhoneIface : Object { + + public abstract void ring () throws IOError; + } +} \ No newline at end of file diff --git a/src/mconnectctl/main.vala b/src/mconnectctl/main.vala index ebee13a..d18baf7 100644 --- a/src/mconnectctl/main.vala +++ b/src/mconnectctl/main.vala @@ -72,6 +72,8 @@ namespace Mconnect { share-file Share file with device send-sms Send SMS + + find-my-phone Find my phone """ ); opt_context.set_help_enabled (true); @@ -98,6 +100,7 @@ namespace Mconnect { Command ("share-text", 2, cl.cmd_share_text), Command ("share-file", 2, cl.cmd_share_file), Command ("send-sms", 3, cl.cmd_send_sms), + Command ("find-my-phone", 1, cl.cmd_find_my_phone), }; handle_command (remaining, commands); @@ -214,6 +217,15 @@ namespace Mconnect { }); } + private int cmd_find_my_phone (string[] args) { + return checked_dbus_call (() => { + var dp = args[0]; + var fmp = get_find_my_phone (new ObjectPath (dp)); + fmp.ring (); + return 0; + }); + } + private void print_sorted_caps (string[] caps, string format) { qsort_with_data(caps, sizeof (string), (a, b) => GLib.strcmp (a, b)); @@ -345,6 +357,17 @@ namespace Mconnect { return get_mconnect_obj_proxy (path); } + /** + * get_find_my_phone: + * + * Obtain DBus interface to FindMyPhone of given device + * + * @return interface or null + */ + private FindMyPhoneIface ? get_find_my_phone (ObjectPath path) throws IOError { + return get_mconnect_obj_proxy (path); + } + /** * print_paths: * @objs: object paths