From 8adf3f4f55789c08171ac5a0b26fee7f2d94bee2 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sat, 21 Oct 2017 22:26:16 +0200 Subject: [PATCH] mconnectctl: add send-sms command --- meson.build | 1 + src/mconnectctl/main.vala | 25 +++++++++++++++++++++++++ src/mconnectctl/telephony-iface.vala | 28 ++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 src/mconnectctl/telephony-iface.vala diff --git a/meson.build b/meson.build index 20aa50c..6b8d02f 100644 --- a/meson.build +++ b/meson.build @@ -74,6 +74,7 @@ mconnectctl_src = [ 'src/mconnectctl/device-manager-iface.vala', 'src/mconnectctl/device-iface.vala', 'src/mconnectctl/share-iface.vala', + 'src/mconnectctl/telephony-iface.vala', ] executable('mconnectctl', mconnectctl_src, dependencies : [glib_dep, gobject_dep, diff --git a/src/mconnectctl/main.vala b/src/mconnectctl/main.vala index ff9582e..4c24c70 100644 --- a/src/mconnectctl/main.vala +++ b/src/mconnectctl/main.vala @@ -74,6 +74,8 @@ namespace Mconnect { share-url Share URL with device share-text Share text with device share-file Share file with device + + send-sms Send SMS """ ); opt_context.set_help_enabled(true); @@ -99,6 +101,7 @@ namespace Mconnect { Command("share-url", 2, cl.cmd_share_url), Command("share-text", 2, cl.cmd_share_text), Command("share-file", 2, cl.cmd_share_file), + Command("send-sms", 3, cl.cmd_send_sms), }; handle_command(remaining, commands); @@ -204,6 +207,17 @@ namespace Mconnect { }); } + private int cmd_send_sms(string[] args) { + return checked_dbus_call(() => { + var dp = args[0]; + var number = args[1]; + var message = args[2]; + var telephony = get_telephony(new ObjectPath(dp)); + telephony.send_sms(number, message); + return 0; + }); + } + private void print_sorted_caps(string[] caps, string format) { qsort_with_data(caps, sizeof(string), (a, b) => GLib.strcmp(a, b)); @@ -323,6 +337,17 @@ namespace Mconnect { return get_mconnect_obj_proxy(path); } + /** + * get_telephony: + * + * Obtain DBus interface to Telephony of given device + * + * @return interface or null + */ + private TelephonyIface? get_telephony(ObjectPath path) throws IOError { + return get_mconnect_obj_proxy(path); + } + /** * print_paths: * @objs: object paths diff --git a/src/mconnectctl/telephony-iface.vala b/src/mconnectctl/telephony-iface.vala new file mode 100644 index 0000000..680b6ce --- /dev/null +++ b/src/mconnectctl/telephony-iface.vala @@ -0,0 +1,28 @@ +/** + * 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.Telephony")] + public interface TelephonyIface : Object { + + public abstract void send_sms(string number, + string message) throws IOError; + } + +} \ No newline at end of file