Skip to content
Snippets Groups Projects
Commit 3bf25783 authored by Isabella Skořepová's avatar Isabella Skořepová
Browse files

Print server version on interactive start too

 + Fix history saving for ^D
parent 3e373b84
No related branches found
No related tags found
No related merge requests found
......@@ -75,7 +75,7 @@ public class InteractiveCommand : Object, Command
state.interactive = true;
stdout.printf("dserial: Serial communication program\n");
stdout.printf("License: GPL3+\n");
stdout.printf("Version: 0.5\n");
stdout.printf("Version: 0.5.1\t\t\tServer version: %s\n",Serial.get_server_version());
stdout.printf("Write help for help\n");
Readline.History.read(Environment.get_variable("HOME")+"/.dserial-history");
Readline.attempted_completion_function = readline_completion;
......@@ -87,6 +87,8 @@ public class InteractiveCommand : Object, Command
if (line == null) {
stdout.printf("\n");
run_func(state,{"exit"});
Readline.History.write(Environment.get_variable("HOME")+"/.dserial-history");
Readline.History.truncate_file(Environment.get_variable("HOME")+"/.dserial-history",256);
return 0;
}
Readline.History.add(line);
......
......@@ -112,6 +112,25 @@ public string[] get_ports() {
return {};
}
/*=====================================
* Get server version
*=====================================*/
public string get_server_version() {
if(DEBUG_OUTPUT) stdout.printf("get_server_version\n");
try {
return GLib.Bus.get_sync(BusType.SESSION).call_sync(
"info.skorepa.DSerial1",
"/controller",
"org.freedesktop.DBus.Properties",
"Get",
new Variant("(ss)","info.skorepa.DSerial1.controller", "ServerVersion"),
null,
DBusCallFlags.NONE,
1000).get_child_value(0).get_variant().get_string();
}catch(Error e) {}
return "UNKNOWN";
}
/*=====================================
* Return object name for file name
*=====================================*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment