summaryrefslogtreecommitdiffstats
path: root/src/serial-device
diff options
context:
space:
mode:
Diffstat (limited to 'src/serial-device')
-rw-r--r--src/serial-device/.gitignore1
-rw-r--r--src/serial-device/Makefile10
-rw-r--r--src/serial-device/main.vala24
-rw-r--r--src/serial-device/serial-device.vala22
4 files changed, 26 insertions, 31 deletions
diff --git a/src/serial-device/.gitignore b/src/serial-device/.gitignore
deleted file mode 100644
index e455d42..0000000
--- a/src/serial-device/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-serial-device
diff --git a/src/serial-device/Makefile b/src/serial-device/Makefile
deleted file mode 100644
index d80279d..0000000
--- a/src/serial-device/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-all: serial-device
- @echo > /dev/null
-
-serial-device: main.vala serial-device.vala ../input-device/input-device-interface.vala ../config/config-interface.vala
- valac -X -w -o $@ --pkg linux --pkg posix --pkg gio-2.0 $^
-
-clean:
- rm -rf serial-device
-
-.PHONY: all clean
diff --git a/src/serial-device/main.vala b/src/serial-device/main.vala
index 0dea907..95926b5 100644
--- a/src/serial-device/main.vala
+++ b/src/serial-device/main.vala
@@ -1,4 +1,5 @@
/* Copyright 2013, Sebastian Reichel <sre@ring0.de>
+ * Copyright 2017-2018, Johannes Rudolph <johannes.rudolph@gmx.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -13,35 +14,40 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-Device dev;
+Device scanner;
public static int main(string[] args) {
+ Intl.setlocale(LocaleCategory.ALL, "");
+ Intl.textdomain("shopsystem");
+
try {
Config cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config");
- dev = new Device(cfg.get_string("INPUT", "device"), 9600, 8, 1);
+ scanner = new Device(cfg.get_string("INPUT", "barcodescanner"), 9600, 8, 1);
} catch(IOError e) {
- error("IOError: %s\n", e.message);
+ error(_("IO Error: %s\n"), e.message);
} catch(KeyFileError e) {
- error("Config Error: %s\n", e.message);
+ error(_("Config Error: %s\n"), e.message);
+ } catch(DBusError e) {
+ error(_("DBus Error: %s\n"), e.message);
}
Bus.own_name(
BusType.SYSTEM,
"io.mainframe.shopsystem.InputDevice",
BusNameOwnerFlags.NONE,
- on_bus_aquired,
+ on_bus_acquired,
() => {},
- () => stderr.printf("Could not aquire name\n"));
+ () => stderr.printf(_("Could not acquire name\n")));
new MainLoop().run();
return 0;
}
-void on_bus_aquired(DBusConnection con) {
+void on_bus_acquired(DBusConnection con) {
try {
- con.register_object("/io/mainframe/shopsystem/device", dev);
+ con.register_object("/io/mainframe/shopsystem/devicescanner", scanner);
} catch(IOError e) {
- stderr.printf("Could not register service\n");
+ stderr.printf(_("Could not register service\n"));
}
}
diff --git a/src/serial-device/serial-device.vala b/src/serial-device/serial-device.vala
index 549cd74..3900128 100644
--- a/src/serial-device/serial-device.vala
+++ b/src/serial-device/serial-device.vala
@@ -36,11 +36,11 @@ public class Device {
if(lockfile.load_contents(null, out data, null)) {
pid = int.parse((string) data);
} else {
- error("Can't read lock file!\n");
+ error(_("Can't read lock file!\n"));
}
if(Posix.kill(pid, 0) == 0) {
- error("serial device is locked!\n");
+ error(_("serial device is locked!\n"));
}
}
@@ -52,11 +52,11 @@ public class Device {
if(fd < 0) {
fd = -1;
lockfile.delete();
- error("Could not open device!\n");
+ error(_("Could not open device!\n"));
}
} catch(Error e) {
- error("Could not create lock file: %s!\n", e.message);
+ error(_("Could not create lock file: %s!\n"), e.message);
}
@@ -160,12 +160,12 @@ public class Device {
io_read = new IOChannel.unix_new(fd);
io_read.set_line_term("\r\n", 2);
if(io_read.set_encoding(null) != IOStatus.NORMAL)
- error("Failed to set encoding");
+ error(_("Failed to set encoding"));
if(!(io_read.add_watch(IOCondition.IN | IOCondition.HUP, device_read) != 0)) {
- error("Could not bind IOChannel");
+ error(_("Could not bind IOChannel"));
}
} catch(IOChannelError e) {
- error("IOChannel: %s", e.message);
+ error(_("IOChannel: %s"), e.message);
}
}
@@ -186,7 +186,7 @@ public class Device {
size_t len, term_char;
if((cond & IOCondition.HUP) == IOCondition.HUP)
- error("Lost device");
+ error(_("Lost device"));
try {
ret = gio.read_line(out msg, out len, out term_char);
@@ -204,11 +204,11 @@ public class Device {
received_barcode(msg);
}
catch(IOChannelError e) {
- stderr.printf("IOChannel Error: %s", e.message);
+ stderr.printf(_("IOChannel Error: %s"), e.message);
return false;
}
catch(ConvertError e) {
- stderr.printf("Convert Error: %s", e.message);
+ stderr.printf(_("Convert Error: %s"), e.message);
return false;
}
return true;
@@ -272,7 +272,7 @@ public class Device {
/**
* @param duration duration of the blink in 0.1 seconds
*/
- public void blink(uint duration) {
+ public void blink(uint duration) throws IOError, DBusError {
uint size = (byterate/1000) * duration;
var msg = new uint8[size];
Posix.memset(msg, 0xFF, msg.length);