Browse Source

mconnectctl: add send-sms command

bboozzzoo/sms
Maciek Borzecki 7 years ago
parent
commit
8adf3f4f55
3 changed files with 54 additions and 0 deletions
  1. +1
    -0
      meson.build
  2. +25
    -0
      src/mconnectctl/main.vala
  3. +28
    -0
      src/mconnectctl/telephony-iface.vala

+ 1
- 0
meson.build View File

@ -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,


+ 25
- 0
src/mconnectctl/main.vala View File

@ -74,6 +74,8 @@ namespace Mconnect {
share-url <path> <url> Share URL with device
share-text <path> <text> Share text with device
share-file <path> <file> Share file with device
send-sms <number> <message> 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<string>(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


+ 28
- 0
src/mconnectctl/telephony-iface.vala View File

@ -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 <maciek.borzecki (at] gmail.com>
*/
namespace Mconnect {
[DBus (name = "org.mconnect.Device.Telephony")]
public interface TelephonyIface : Object {
public abstract void send_sms(string number,
string message) throws IOError;
}
}

Loading…
Cancel
Save