summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2013-03-02 19:41:19 +0100
committerSebastian Reichel <sre@ring0.de>2013-03-02 19:41:19 +0100
commit1a2ebec81a74e478f4e2976882451434deb40f7a (patch)
treee33c6a191ec22112bfd5cba1d67d95be9f2c1c4a
parenta2c2a4b9e6a2dbbf103e989bebb507f4340d71e7 (diff)
downloadserial-barcode-scanner-1a2ebec81a74e478f4e2976882451434deb40f7a.tar.bz2
move specification of serial device into config file
-rw-r--r--src/main.vala29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/main.vala b/src/main.vala
index 4a14cdf..67f00ff 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -25,12 +25,10 @@ public CursesUI ui;
const OptionEntry[] option_entries = {
{ "version", 'v', OptionFlags.IN_MAIN, OptionArg.NONE, ref opt_version, "output version information and exit", null },
- { "", 0, 0, OptionArg.FILENAME_ARRAY, ref files, "serial device", "DEVICE" },
{null}
};
/* parameters */
-static string[] files;
static bool opt_version;
public static int main(string[] args) {
@@ -48,25 +46,14 @@ public static int main(string[] args) {
}
if(opt_version) {
- stdout.puts("Ktt Shop System 0.1\n");
+ stdout.puts("KtT Shop System 0.1\n");
return 0;
}
- if(files == null || files[0] == null) {
- stderr.puts("Please specify serial device!\n");
- return 1;
- }
-
/* handle unix signals */
Unix.signal_add(Posix.SIGTERM, handle_signals);
Unix.signal_add(Posix.SIGINT, handle_signals);
- dev = new Device(files[0], 9600, 8, 1);
- db = new Database("shop.db");
- audio = new AudioPlayer();
- loop = new MainLoop();
- localsession = new ScannerSession();
-
try {
cfg = new KeyFile();
cfg.load_from_file("ktt-shopsystem.cfg", KeyFileFlags.NONE);
@@ -74,6 +61,20 @@ public static int main(string[] args) {
error("Could not load configuration file: %s", e.message);
}
+ string devicefile = "";
+ try {
+ devicefile = cfg.get_string("SERIAL", "device");
+ } catch(KeyFileError e) {
+ stderr.puts("Please specify serial device in the configuration file!\n");
+ return 1;
+ }
+
+ dev = new Device(devicefile, 9600, 8, 1);
+ db = new Database("shop.db");
+ audio = new AudioPlayer();
+ loop = new MainLoop();
+ localsession = new ScannerSession();
+
pgp = new PGPKeyArchive(cfg);
dev.received_barcode.connect((data) => {