Fix parser
This commit is contained in:
parent
e7623353aa
commit
e79228942d
@ -27,12 +27,6 @@ int main (string[] args) {
|
|||||||
var window = builder.get_object ("window") as Window;
|
var window = builder.get_object ("window") as Window;
|
||||||
var browse = builder.get_object ("browse") as Button;
|
var browse = builder.get_object ("browse") as Button;
|
||||||
|
|
||||||
browse.clicked.connect (() => {
|
|
||||||
|
|
||||||
browse.label = "Soon";
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
var yggdrasil = builder.get_object ("yggdrasil") as Button;
|
var yggdrasil = builder.get_object ("yggdrasil") as Button;
|
||||||
|
|
||||||
yggdrasil.clicked.connect (() => {
|
yggdrasil.clicked.connect (() => {
|
||||||
@ -69,6 +63,31 @@ int main (string[] args) {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var ip = builder.get_object ("label_ip") as Entry;
|
||||||
|
|
||||||
|
ip.notify["text"].connect (() => {
|
||||||
|
|
||||||
|
browse.label = "OK";
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
string yggconf;
|
||||||
|
Process.spawn_command_line_sync ("yggdrasil -genconf -json", out yggconf);
|
||||||
|
|
||||||
|
browse.clicked.connect (() => {
|
||||||
|
|
||||||
|
if (browse.label == "OK") {
|
||||||
|
|
||||||
|
parse (yggconf, ip);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
browse.label = "Soon";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
window.show_all ();
|
window.show_all ();
|
||||||
Gtk.main ();
|
Gtk.main ();
|
||||||
|
|
||||||
@ -120,7 +139,9 @@ int update () {
|
|||||||
string temp_dir = Utils.mktempdir ();
|
string temp_dir = Utils.mktempdir ();
|
||||||
|
|
||||||
if (repo_url == null) {
|
if (repo_url == null) {
|
||||||
|
|
||||||
repo_url = "https://git.macaw.me/plant_1312/Yggtk.git";
|
repo_url = "https://git.macaw.me/plant_1312/Yggtk.git";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Process.spawn_command_line_sync (@"git clone $repo_url $temp_dir");
|
Process.spawn_command_line_sync (@"git clone $repo_url $temp_dir");
|
||||||
@ -182,10 +203,25 @@ int start () {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int parse (string yggconf) {
|
int parse (string yggconf, Entry ip) {
|
||||||
|
|
||||||
/*var parser = new Json.Parser ();
|
try {
|
||||||
parser.load_from_data (yggconf, -1);*/
|
|
||||||
|
var node = Json.from_string (yggconf);
|
||||||
|
var obj = node.get_object ();
|
||||||
|
obj.set_string_member ("Peers", ip.text);
|
||||||
|
string ptext = Json.to_string (node,true);
|
||||||
|
|
||||||
|
string file = "yggdrasil.conf";
|
||||||
|
FileUtils.set_contents (file, ptext);
|
||||||
|
|
||||||
|
Process.spawn_command_line_sync ("pkexec cp yggdrasil.conf /etc");
|
||||||
|
|
||||||
|
} catch (Error e) {
|
||||||
|
|
||||||
|
print ("Error parse JSON: %s\n", e.message);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user