Browse Source

many: fix build, warnings

Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
bboozzoo/fix-build-and-warnings
Maciek Borzecki 5 years ago
parent
commit
87ef75d941
23 changed files with 105 additions and 94 deletions
  1. +7
    -4
      src/mconnect/application.vala
  2. +4
    -11
      src/mconnect/device-proxy.vala
  3. +3
    -3
      src/mconnect/device.vala
  4. +4
    -3
      src/mconnect/devicechannel.vala
  5. +11
    -8
      src/mconnect/devicemanager-proxy.vala
  6. +1
    -1
      src/mconnect/discovery.vala
  7. +1
    -1
      src/mconnect/logging.vala
  8. +6
    -6
      src/mconnect/mpris-proxies.vala
  9. +5
    -4
      src/mconnect/mpris.vala
  10. +3
    -3
      src/mconnect/packethandlerinterface-proxy.vala
  11. +6
    -6
      src/mconnect/share-proxy.vala
  12. +7
    -3
      src/mconnect/share.vala
  13. +2
    -2
      src/mconnect/telephony-proxy.vala
  14. +14
    -11
      src/mconnect/transfer-download.vala
  15. +2
    -4
      src/mconnect/transfer-manager-proxy.vala
  16. +2
    -1
      src/mconnect/transfer-manager.vala
  17. +4
    -4
      src/mconnect/transfer-proxy.vala
  18. +9
    -3
      src/mconnect/transfer-upload.vala
  19. +3
    -4
      src/mconnect/utils.vala
  20. +3
    -3
      src/mconnectctl/device-manager-iface.vala
  21. +4
    -4
      src/mconnectctl/share-iface.vala
  22. +2
    -2
      src/mconnectctl/telephony-iface.vala
  23. +2
    -3
      test/mconn-crypt-vala-test.vala

+ 7
- 4
src/mconnect/application.vala View File

@ -53,12 +53,15 @@ namespace Mconn {
base.startup ();
if (log_debug_verbose == true) {
Logging.enable_vdebug ();
// enable debug logging when verbose is enabled
log_debug = true;
}
if (log_debug == true)
Environment.set_variable ("G_MESSAGES_DEBUG", "all", false);
if (log_debug_verbose == true)
Logging.enable_vdebug ();
core = Core.instance ();
if (core == null)
error ("cannot initialize core");
@ -112,4 +115,4 @@ namespace Mconn {
debug ("dbus unregister, path %s", object_path);
}
}
}
}

+ 4
- 11
src/mconnect/device-proxy.vala View File

@ -30,7 +30,6 @@ class DeviceDBusProxy : Object {
}
private set {
}
default = "";
}
public string name {
get {
@ -38,7 +37,6 @@ class DeviceDBusProxy : Object {
}
private set {
}
default = "";
}
public string device_type {
get {
@ -46,7 +44,6 @@ class DeviceDBusProxy : Object {
}
private set {
}
default = "";
}
public uint protocol_version {
get {
@ -54,7 +51,6 @@ class DeviceDBusProxy : Object {
}
private set {
}
default = 5;
}
public string address {
get; private set; default = "";
@ -66,7 +62,6 @@ class DeviceDBusProxy : Object {
}
private set {
}
default = false;
}
public bool allowed {
get {
@ -74,7 +69,6 @@ class DeviceDBusProxy : Object {
}
private set {
}
default = false;
}
public bool is_active {
get {
@ -82,10 +76,9 @@ class DeviceDBusProxy : Object {
}
private set {
}
default = false;
}
public bool is_connected {
get; private set; default = false;
get; private set;
}
public string[] incoming_capabilities {
@ -268,7 +261,7 @@ class DeviceDBusProxy : Object {
[DBus (visible = false)]
public void bus_register_handler (DBusConnection conn,
string cap,
PacketHandlerInterfaceProxy handler) {
PacketHandlerInterfaceProxy handler) throws Error {
handler.bus_register (conn, this.object_path);
this.handlers.@set (cap, handler);
@ -276,7 +269,7 @@ class DeviceDBusProxy : Object {
[DBus (visible = false)]
public void bus_unregister_handler (DBusConnection conn,
string cap) {
string cap) throws Error {
PacketHandlerInterfaceProxy handler;
this.handlers.@unset (cap, out handler);
@ -284,4 +277,4 @@ class DeviceDBusProxy : Object {
handler.bus_unregister (conn);
}
}
}
}

+ 3
- 3
src/mconnect/device.vala View File

@ -193,7 +193,7 @@ class Device : Object {
dev.host = host;
return dev;
} catch (KeyFileError e) {
} catch (Error e) {
warning ("failed to load device data from cache: %s", e.message);
return null;
}
@ -617,7 +617,7 @@ class Device : Object {
public void send (Packet pkt) {
// TODO: queue messages
if (this._channel != null) {
_channel.send (pkt);
_channel.send.begin (pkt);
}
}
}
}

+ 4
- 3
src/mconnect/devicechannel.vala View File

@ -150,10 +150,11 @@ class DeviceChannel : Object {
var cert = Core.instance ().certificate;
// wrap with TLS
var tls_conn = Utils.make_tls_connection (this._sock_conn,
TlsConnection tls_conn;
try {
tls_conn = Utils.make_tls_connection (this._sock_conn,
cert,
expected_peer);
try {
info ("attempt TLS handshake");
var res = yield tls_conn.handshake_async ();
@ -298,4 +299,4 @@ class DeviceChannel : Object {
this.packet_received (pkt);
}
}
}
}

+ 11
- 8
src/mconnect/devicemanager-proxy.vala View File

@ -25,8 +25,7 @@ class DeviceManagerDBusProxy : Object {
owned get {
return Core.instance ().certificate.certificate_pem;
}
private set {
}
private set {}
}
public signal void device_added (string path);
@ -52,7 +51,7 @@ class DeviceManagerDBusProxy : Object {
}
[DBus (visible = false)]
public void publish () throws IOError {
public void publish () throws Error {
assert (this.bus != null);
this.bus.register_object (DBUS_PATH, this);
@ -64,7 +63,7 @@ class DeviceManagerDBusProxy : Object {
*
* Allow given device
*/
public void allow_device (string path) {
public void allow_device (string path) throws Error {
debug ("allow device %s", path);
var dev_proxy = this.devices.@get (path);
@ -83,7 +82,7 @@ class DeviceManagerDBusProxy : Object {
*
* Disallow given device
*/
public void disallow_device (string path) {
public void disallow_device (string path) throws Error {
debug ("disallow device %s", path);
var dev_proxy = this.devices.@get (path);
@ -101,7 +100,7 @@ class DeviceManagerDBusProxy : Object {
*
* Returns a list of DBus paths of all known devices
*/
public ObjectPath[] list_devices () {
public ObjectPath[] list_devices () throws Error {
ObjectPath[] devices = {};
foreach (var path in this.devices.keys) {
@ -155,7 +154,11 @@ class DeviceManagerDBusProxy : Object {
capability,
iface);
if (h != null) {
h.bus_register (this.bus, dp.object_path);
try {
h.bus_register (this.bus, dp.object_path);
} catch (Error e) {
warning ("cannot register handler at path %s: %s", dp.object_path, e.message);
}
}
}
@ -172,4 +175,4 @@ class DeviceManagerDBusProxy : Object {
return path;
}
}
}

+ 1
- 1
src/mconnect/discovery.vala View File

@ -93,4 +93,4 @@ class Discovery : GLib.Object {
device_found (dev);
}
}
}

+ 1
- 1
src/mconnect/logging.vala View File

@ -41,4 +41,4 @@ void vdebug (string format, ...) {
var l = va_list ();
logv (null, LogLevelFlags.LEVEL_DEBUG, format, l);
}
}
}

+ 6
- 6
src/mconnect/mpris-proxies.vala View File

@ -19,7 +19,7 @@
[DBus (name = "org.freedesktop.DBus")]
public interface DBusProxy : Object {
public abstract string[] list_names () throws IOError;
public abstract string[] list_names () throws Error;
public signal void name_owner_changed (string name, string old_owner, string new_owner);
}
@ -33,10 +33,10 @@ public interface DBusPropertiesProxy : Object {
[DBus (name = "org.mpris.MediaPlayer2.Player")]
public interface MprisPlayerProxy : Object {
public abstract void next () throws IOError;
public abstract void previous () throws IOError;
public abstract void play_pause () throws IOError;
public abstract void seek (int64 Offset) throws IOError;
public abstract void next () throws Error;
public abstract void previous () throws Error;
public abstract void play_pause () throws Error;
public abstract void seek (int64 Offset) throws Error;
public abstract string playback_status {
owned get;
@ -76,4 +76,4 @@ public interface MprisProxy : Object {
public abstract string identity {
owned get;
}
}
}

+ 5
- 4
src/mconnect/mpris.vala View File

@ -173,13 +173,14 @@ class MprisHandler : Object, PacketHandlerInterface {
prop.can_seek = mpris_player.can_seek;
update_status (make_player_prop_packet (player_id, prop));
}
} catch (IOError e) {
} catch (Error e) {
warning ("dbus communication failed: %s", e.message);
return;
}
}
private static void get_metadata_string (HashTable<string, Variant> metadata, string meta_what, out string where) {
where = "";
if (metadata.contains (meta_what) &&
metadata.get (meta_what).is_of_type (VariantType.STRING)) {
where = metadata.get (meta_what).get_string ();
@ -369,7 +370,7 @@ class MprisHandler : Object, PacketHandlerInterface {
add_player (bus_name);
}
}
} catch (IOError e) {
} catch (Error e) {
warning ("failed to get mpris player list: %s", e.message);
}
}
@ -396,7 +397,7 @@ class MprisHandler : Object, PacketHandlerInterface {
bus_name,
"/org/mpris/MediaPlayer2");
player_list.insert (mpris.identity, bus_name);
} catch (IOError e) {
} catch (Error e) {
warning ("failed to connect to mpris player: %s", e.message);
}
}
@ -414,4 +415,4 @@ class MprisHandler : Object, PacketHandlerInterface {
player_list.remove (key);
}
}
}
}

+ 3
- 3
src/mconnect/packethandlerinterface-proxy.vala View File

@ -20,6 +20,6 @@
* 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;
}
public abstract void bus_register (DBusConnection conn, string path) throws Error;
public abstract void bus_unregister (DBusConnection conn) throws Error;
}

+ 6
- 6
src/mconnect/share-proxy.vala View File

@ -29,25 +29,25 @@ class ShareHandlerProxy : Object, PacketHandlerInterfaceProxy {
}
[DBus (visible = false)]
public void bus_register (DBusConnection conn, string path) throws IOError {
public void bus_register (DBusConnection conn, string path) throws Error {
conn.register_object (path, this);
}
[DBus (visible = false)]
public void bus_unregister (DBusConnection conn) throws IOError {
public void bus_unregister (DBusConnection conn) throws Error {
// conn.unregister_object(this);
}
public void share_file (string path) throws IOError {
public void share_file (string path) throws Error {
this.share_handler.share_file (this.device, path);
}
public void share_url (string url) throws IOError {
public void share_url (string url) throws Error {
debug ("share url %s", url);
this.share_handler.share_url (this.device, url);
}
public void share_text (string text) throws IOError {
public void share_text (string text) throws Error {
this.share_handler.share_text (this.device, text);
}
}
}

+ 7
- 3
src/mconnect/share.vala View File

@ -105,7 +105,11 @@ class ShareHandler : Object, PacketHandlerInterface {
debug ("got URL: %s, launching...", url);
Utils.show_own_notification ("Launching shared URL",
dev.device_name);
AppInfo.launch_default_for_uri (url, null);
try {
AppInfo.launch_default_for_uri (url, null);
} catch (Error e) {
warning ("cannot launch application: %s", e.message);
}
}
}
@ -161,7 +165,7 @@ class ShareHandler : Object, PacketHandlerInterface {
dev.send (make_share_packet ("text", text));
}
public void share_file (Device dev, string path) {
public void share_file (Device dev, string path) throws Error {
debug ("share file %s to device %s", path, dev.to_string ());
var file = File.new_for_path (path);
@ -206,4 +210,4 @@ class ShareHandler : Object, PacketHandlerInterface {
t.start_async.begin ();
dev.send (make_file_share_packet (file.get_basename (), size, port));
}
}
}

+ 2
- 2
src/mconnect/telephony-proxy.vala View File

@ -38,7 +38,7 @@ class TelephonyHandlerProxy : Object, PacketHandlerInterfaceProxy {
// conn.unregister_object(this);
}
public void send_sms (string number, string message) {
public void send_sms (string number, string message) throws Error {
this.telephony.send_sms (this.device, number, message);
}
}
}

+ 14
- 11
src/mconnect/transfer-download.vala View File

@ -69,13 +69,13 @@ class DownloadTransfer : TransferInterface, Object {
Utils.socket_set_keepalive (sock);
// enable TLS
this.tls_conn = Utils.make_tls_connection (this.conn,
Core.instance ().certificate,
this.device.certificate,
Utils.TlsConnectionMode.CLIENT);
try {
this.tls_conn = Utils.make_tls_connection (this.conn,
Core.instance ().certificate,
this.device.certificate,
Utils.TlsConnectionMode.CLIENT);
debug ("attempt TLS handshake");
var tls_res = yield this.tls_conn.handshake_async ();
yield this.tls_conn.handshake_async ();
debug ("TLS handshake complete");
} catch (Error e) {
@ -124,7 +124,7 @@ class DownloadTransfer : TransferInterface, Object {
if (this.foutstream != null) {
try {
this.foutstream.close ();
} catch (IOError e) {
} catch (Error e) {
warning ("failed to close file output: %s",
e.message);
}
@ -133,7 +133,7 @@ class DownloadTransfer : TransferInterface, Object {
if (this.tls_conn != null) {
try {
this.tls_conn.close ();
} catch (IOError e) {
} catch (Error e) {
warning ("failed to close TLS connection: %s",
e.message);
}
@ -141,7 +141,7 @@ class DownloadTransfer : TransferInterface, Object {
if (this.conn != null) {
try {
this.conn.close ();
} catch (IOError e) {
} catch (Error e) {
warning ("failed to close connection: %s",
e.message);
}
@ -155,8 +155,11 @@ class DownloadTransfer : TransferInterface, Object {
}
private void cleanup_error (string reason) {
this.file.@delete ();
try {
this.file.@delete ();
} catch (Error e) {
warning ("cannot remove file: %s", e.message);
}
this.cleanup ();
@ -184,4 +187,4 @@ class DownloadTransfer : TransferInterface, Object {
debug ("cancel called");
this.cancellable.cancel ();
}
}
}

+ 2
- 4
src/mconnect/transfer-manager-proxy.vala View File

@ -20,8 +20,6 @@ using Gee;
[DBus (name = "org.mconnect.TransferManager")]
class TransferManagerDBusProxy : Object {
private TransferManager manager;
private DBusConnection bus;
private int job_idx = 0;
@ -49,7 +47,7 @@ class TransferManagerDBusProxy : Object {
*
* Returns a list of DBus paths of all known transfer jobs
*/
public ObjectPath[] list_jobs () {
public ObjectPath[] list_jobs () throws Error {
ObjectPath[] jobs = {};
foreach (var path in this.jobs.keys) {
@ -108,4 +106,4 @@ class TransferManagerDBusProxy : Object {
public signal void transfer_failed (string path, string reason);
public signal void transfer_started (string path);
}
}

+ 2
- 1
src/mconnect/transfer-manager.vala View File

@ -32,6 +32,7 @@ class TransferManager : Object {
}
public SocketService ? make_listener (out uint16 listen_port) {
listen_port = 0;
var ss = new SocketService ();
for (var port = PORT_MIN; port <= PORT_MAX; port++) {
var added = false;
@ -52,4 +53,4 @@ class TransferManager : Object {
warning ("could not find a free port to listen on");
return null;
}
}
}

+ 4
- 4
src/mconnect/transfer-proxy.vala View File

@ -34,21 +34,21 @@ class TransferDBusProxy : Object {
}
[DBus (visible = false)]
public void bus_register (DBusConnection conn) {
public void bus_register (DBusConnection conn) throws Error {
debug ("register transfer at path %s", this.object_path.to_string ());
this.register_id = conn.register_object (this.object_path, this);
}
[DBus (visible = false)]
public void bus_unregister (DBusConnection conn) {
public void bus_unregister (DBusConnection conn) throws Error {
if (this.register_id != 0) {
debug ("unregister transfer at path %s", this.object_path.to_string ());
conn.unregister_object (this.register_id);
}
}
public void cancel () {
public void cancel () throws Error {
debug ("cancelling job");
this.transfer.cancel ();
}
}
}

+ 9
- 3
src/mconnect/transfer-upload.vala View File

@ -71,7 +71,13 @@ class UploadTransfer : TransferInterface, Object {
}
private async void handle_client (SocketConnection conn) {
var isa = conn.get_remote_address () as InetSocketAddress;
InetSocketAddress isa;
try {
isa = conn.get_remote_address () as InetSocketAddress;
} catch (Error e) {
warning ("cannot obtain remote address: %s", e.message);
return;
}
debug ("client connected: %s:%u", isa.address.to_string (),
isa.port);
@ -87,7 +93,7 @@ class UploadTransfer : TransferInterface, Object {
Utils.TlsConnectionMode.SERVER);
try {
debug ("attempt TLS handshake");
var tls_res = yield this.tls_conn.handshake_async ();
yield this.tls_conn.handshake_async ();
debug ("TLS handshake complete");
} catch (Error e) {
@ -183,4 +189,4 @@ class UploadTransfer : TransferInterface, Object {
debug ("cancel called");
this.cancellable.cancel ();
}
}
}

+ 3
- 4
src/mconnect/utils.vala View File

@ -70,7 +70,6 @@ namespace Utils {
option = 3;
Posix.setsockopt (sock.fd, 6, 6, &option, (Posix.socklen_t) sizeof (int));
#endif
int option = 10;
Posix.setsockopt (sock.fd, IPProto.TCP,
Posix.TCP_KEEPIDLE,
@ -109,7 +108,7 @@ namespace Utils {
TlsConnection make_tls_connection (SocketConnection sock_conn,
TlsCertificate self_cert,
TlsCertificate ? expected_peer = null,
TlsConnectionMode mode = TlsConnectionMode.SERVER) {
TlsConnectionMode mode = TlsConnectionMode.SERVER) throws Error {
TlsConnection tls_conn;
if (mode == TlsConnectionMode.SERVER) {
@ -183,7 +182,7 @@ namespace Utils {
return matches;
} catch (RegexError e) {
warning ("failed to compile regex: %s", e.message);
return null;
return {};
}
}
@ -198,4 +197,4 @@ namespace Utils {
critical ("failed to show notification: %s", e.message);
}
}
}
}

+ 3
- 3
src/mconnectctl/device-manager-iface.vala View File

@ -22,7 +22,7 @@ namespace Mconnect {
public const string OBJECT_PATH = "/org/mconnect/manager";
public abstract ObjectPath[] ListDevices () throws IOError;
public abstract void AllowDevice (string path) throws IOError;
public abstract ObjectPath[] ListDevices () throws Error;
public abstract void AllowDevice (string path) throws Error;
}
}
}

+ 4
- 4
src/mconnectctl/share-iface.vala View File

@ -21,8 +21,8 @@ namespace Mconnect {
[DBus (name = "org.mconnect.Device.Share")]
public interface ShareIface : Object {
public abstract void share_url (string url) throws IOError;
public abstract void share_text (string text) throws IOError;
public abstract void share_file (string path) throws IOError;
public abstract void share_url (string url) throws Error;
public abstract void share_text (string text) throws Error;
public abstract void share_file (string path) throws Error;
}
}
}

+ 2
- 2
src/mconnectctl/telephony-iface.vala View File

@ -22,6 +22,6 @@ namespace Mconnect {
public interface TelephonyIface : Object {
public abstract void send_sms (string number,
string message) throws IOError;
string message) throws Error;
}
}
}

+ 2
- 3
test/mconn-crypt-vala-test.vala View File

@ -31,8 +31,7 @@ void test_generate_load () {
}
try {
var cert = new TlsCertificate.from_files (cert_path,
key_path);
new TlsCertificate.from_files (cert_path, key_path);
} catch (Error e) {
warning ("load from files failed: %s", e.message);
Test.fail ();
@ -129,4 +128,4 @@ public static void main (string[] args) {
Test.add_func ("/mconn-crypt-vala/verify-cn", test_custom_cn);
Test.add_func ("/mconn-crypt-vala/fingerprint", test_fingerprint);
Test.run ();
}
}

Loading…
Cancel
Save