* Initial working version of the flash gui - Renamed to goxf - Needs 'sudo' to be enabled to the user without password - Identify and ban piece files while including them in the list - Support for flashing multiple piece files - progressbar and warn/error messages handled - Supports reboot mobo command
* Make qmode be functional * Lot of hardcore fixups on squeue_open - Should work now everywhere fine asumid UID 1000 as allowed user - Reduce timeouts - Add push2 method
This commit is contained in:
1 parent
2ddb2923c6
commit
83c25d7eb2
13 files changed
+375
-114
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
all:
|
||||
gtkamlc --Xcc=-I../squeue ../squeue/squeue.c ../squeue/squeue.vapi gui.gtkaml --pkg gtk+-2.0 -o a.out
|
||||
gtkamlc --save-temps --Xcc=-I../squeue ../squeue/squeue.c ../fpid.c ../squeue/squeue.vapi gui.gtkaml extras.vapi --pkg gtk+-2.0 -o goxf
|
||||
|
||||
test:
|
||||
valac --save-temps --Xcc=-I.. squeue.vapi test.vala ../squeue.c -o v
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Extras {
|
||||
public class External {
|
||||
[CCode (cname = "system")]
|
||||
public static int system(string cmd);
|
||||
[CCode (cname = "fpid_file")]
|
||||
public static string fpid_file(string file);
|
||||
[CCode (cname = "fpid_size")]
|
||||
public static long fpid_size(string file);
|
||||
}
|
||||
}
|
||||
+133
-42
@@ -6,8 +6,14 @@
|
||||
|
||||
-->
|
||||
|
||||
<Window xmlns='Gtk' xmlns:SQueues='SQueues' xmlns:GLib='GLib' xmlns:class="http://gtkaml.org/0.2"
|
||||
class:name="MainWindow" title="0xFFFF GUI" delete-event="{OnWindow1DeleteEvent}">
|
||||
<Window xmlns="Gtk"
|
||||
xmlns:GLib="GLib"
|
||||
xmlns:Extras="Extras"
|
||||
xmlns:SQueues="SQueues"
|
||||
xmlns:class="http://gtkaml.org/0.2"
|
||||
class:name="MainWindow"
|
||||
title="0xFFFF GUI"
|
||||
delete-event="{OnWindow1DeleteEvent}">
|
||||
<VBox>
|
||||
<MenuBar expand="false">
|
||||
<MenuItem label="_File" with-mnemonic="true">
|
||||
@@ -21,6 +27,17 @@
|
||||
</submenu>
|
||||
</MenuItem>
|
||||
|
||||
<!-- Help menu -->
|
||||
<MenuItem label="_Target" with-mnemonic="true">
|
||||
<submenu>
|
||||
<Menu>
|
||||
<ImageMenuItem stock-id="gtk-connect" activate="{OnConnect}"/>
|
||||
<ImageMenuItem stock-id="gtk-info" activate="{OnGetInformation}"/>
|
||||
<ImageMenuItem label="Reset" activate="{OnReset}"/>
|
||||
</Menu>
|
||||
</submenu>
|
||||
</MenuItem>
|
||||
|
||||
<!-- Help menu -->
|
||||
<MenuItem label="_Help" with-mnemonic="true">
|
||||
<submenu>
|
||||
@@ -38,33 +55,36 @@
|
||||
</TreeView>
|
||||
</ScrolledWindow>
|
||||
|
||||
<ProgressBar class:private="pb" expand="false" />
|
||||
</VBox>
|
||||
<VBox expand="false" border-width="3" spacing="3">
|
||||
<Button label="gtk-connect" use-stock="true" expand="false" clicked="{OnConnect}"/>
|
||||
<Button label="gtk-info" use-stock="true" expand="false" clicked="{OnGetInformation}"/>
|
||||
<Label label="" />
|
||||
<!-- <Button label="Options" use-stock="false" expand="false"/>
|
||||
<Button label="Fiasco!" use-stock="false" expand="false"/>
|
||||
<Button label="Unpack!" use-stock="false" expand="false"/> -->
|
||||
<Button label="gtk-add" use-stock="true" expand="false" clicked="{OnFileOpenEvent}" />
|
||||
<Button label="gtk-remove" use-stock="true" expand="false" clicked="{list_del}"/>
|
||||
<Label label="" />
|
||||
<Button label="gtk-info" use-stock="true" expand="false" clicked="{OnGetInformation}"/>
|
||||
<Button label="Options" use-stock="false" expand="false"/>
|
||||
<Button label="Fiasco!" use-stock="false" expand="false"/>
|
||||
<Button label="Unpack!" use-stock="false" expand="false"/>
|
||||
<Button label="Go flash!" use-stock="false" expand="false"/>
|
||||
<Button label="gtk-media-record" use-stock="true" expand="false" clicked="{OnFileFlashEvent}"/>
|
||||
</VBox>
|
||||
</HBox>
|
||||
<ProgressBar class:private="pb" expand="false" />
|
||||
|
||||
<Statusbar expand="false"/>
|
||||
<!-- <Statusbar expand="false"/> -->
|
||||
</VBox>
|
||||
|
||||
<AboutDialog class:standalone="true" class:private="aboutdialog1" delete-event="{aboutdialog1.hide_on_delete}"
|
||||
border-width="5" title="About 0xFFFF gui" resizable="false" modal="true"
|
||||
window-position="{WindowPosition.CENTER_ON_PARENT}" has-separator="false"
|
||||
program-name="0xFFFF" version="0.4" copyright="Copyright (c) 2008 pancake"
|
||||
program-name="0xFFFF" version="0.3.9" copyright="Copyright (c) 2008 pancake"
|
||||
comments="The Free Nokia Internet Tablet flasher"
|
||||
website="http://www.nopcode.org/0xFFFF/"
|
||||
authors='{new string[] {"pancake (pancake@youterm.com)", null}}'>
|
||||
</AboutDialog>
|
||||
|
||||
<![CDATA[
|
||||
|
||||
|
||||
private void OnWindow1DeleteEvent ()
|
||||
{
|
||||
doCloseApplication ();
|
||||
@@ -75,19 +95,49 @@ private void doCloseApplication ()
|
||||
Gtk.main_quit ();
|
||||
}
|
||||
|
||||
private void OnReset()
|
||||
{
|
||||
q->push("reset:device", 1);
|
||||
}
|
||||
|
||||
private void OnFileFlashEvent()
|
||||
{
|
||||
ListStore ls = (ListStore)tv.get_model();
|
||||
weak string str;
|
||||
TreeIter iter;
|
||||
|
||||
int n = ls.iter_n_children(null);
|
||||
if (n >0) {
|
||||
if (showYesNo("Do you want to flash these files?")) {
|
||||
ls.get_iter_first(out iter);
|
||||
do {
|
||||
ls.get(iter, 2, out str, -1);
|
||||
//stdout.printf("polla:%s\n", str);
|
||||
q->push2("flash", str, 1);
|
||||
} while(ls.iter_next(ref iter));
|
||||
}
|
||||
} else {
|
||||
showMessage("No files selected", MessageType.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFileOpenEvent ()
|
||||
{
|
||||
FileChooserDialog fc = new FileChooserDialog("Select file to open",
|
||||
this,
|
||||
FileChooserAction.OPEN,
|
||||
"gtk-cancel",ResponseType.CANCEL,
|
||||
"gtk-open",ResponseType.ACCEPT);
|
||||
|
||||
this, FileChooserAction.OPEN,
|
||||
"gtk-cancel", ResponseType.CANCEL,
|
||||
"gtk-open", ResponseType.ACCEPT);
|
||||
int resp = fc.run ();
|
||||
fc.hide ();
|
||||
if (resp == ResponseType.ACCEPT)
|
||||
{
|
||||
add_file(fc.get_filename ());
|
||||
if (resp == ResponseType.ACCEPT) {
|
||||
string file = fc.get_filename();
|
||||
string *type = External.fpid_file(file);
|
||||
string size = "%ld".printf(External.fpid_size(file));
|
||||
if (type == null) {
|
||||
showMessage("Invalid file type", MessageType.ERROR);
|
||||
} else {
|
||||
add_file(type, size, file);
|
||||
}
|
||||
}
|
||||
fc.destroy ();
|
||||
}
|
||||
@@ -95,20 +145,28 @@ private void OnFileOpenEvent ()
|
||||
public bool loadFile( string filename )
|
||||
{
|
||||
int err = 0;
|
||||
try
|
||||
{
|
||||
try {
|
||||
string contents; int length;
|
||||
FileUtils.get_contents (filename, out contents, out length);
|
||||
//textview1.buffer.set_text (contents, length);
|
||||
}
|
||||
catch(Error e)
|
||||
{
|
||||
} catch(Error e) {
|
||||
showError ("Unexpected error while loading the file, please contact the author with the following information:\n\n" + e.message);
|
||||
err++;
|
||||
}
|
||||
return err == 0;
|
||||
}
|
||||
|
||||
public bool showYesNo(string s)
|
||||
{
|
||||
MessageDialog md = new MessageDialog (this,
|
||||
DialogFlags.DESTROY_WITH_PARENT,
|
||||
MessageType.QUESTION, ButtonsType.YES_NO, s);
|
||||
int ret = md.run ();
|
||||
md.destroy ();
|
||||
|
||||
return ret==ResponseType.YES;
|
||||
}
|
||||
|
||||
public void showMessage(string s, MessageType mt)
|
||||
{
|
||||
MessageDialog md = new MessageDialog (this,
|
||||
@@ -144,9 +202,11 @@ private void OnFileNewEvent ()
|
||||
private void OnQuitEvent ()
|
||||
{
|
||||
doCloseApplication();
|
||||
External.system("sudo pkill 0xFFFF");
|
||||
// TODO: send message to gracefully kill 0xFFFF
|
||||
// TODO: handle ^C when flashing
|
||||
}
|
||||
|
||||
|
||||
public void list_clear()
|
||||
{
|
||||
((ListStore)tv.model).clear();
|
||||
@@ -156,28 +216,31 @@ public void list_del()
|
||||
{
|
||||
TreeIter iter;
|
||||
TreeModel model;
|
||||
string str = "";
|
||||
weak string str = "";
|
||||
|
||||
TreeSelection sel = tv.get_selection();
|
||||
|
||||
if (sel.count_selected_rows() == 1) {
|
||||
sel.get_selected(out model, out iter);
|
||||
//((ListStore)tv.model)).get(ref iter, 2, out str, -1);
|
||||
|
||||
//stdout.printf("NAME IS: "+str);
|
||||
((ListStore)tv.model).remove(iter);
|
||||
}
|
||||
|
||||
//return str;
|
||||
}
|
||||
|
||||
public void add_file(string file)
|
||||
public void add_file(string type, string size, string file)
|
||||
{
|
||||
ListStore listmodel = (ListStore)tv.get_model();
|
||||
Gtk.TreeIter iter;
|
||||
listmodel.append (out iter);
|
||||
listmodel.set (iter, 0, "initfs", 1, "3M", 2, file, -1);
|
||||
listmodel.set (iter, 0, type, 1, size, 2, file, -1);
|
||||
}
|
||||
|
||||
public static void setup_treeview (Gtk.TreeView view) {
|
||||
|
||||
public static void setup_treeview (Gtk.TreeView view)
|
||||
{
|
||||
/* use liststore to hold accountname, accounttype, balance and color attribute */
|
||||
/* for more info how gtkTreeview works take a look in the GTK API */
|
||||
|
||||
@@ -191,22 +254,40 @@ public static void setup_treeview (Gtk.TreeView view) {
|
||||
cell.set ("foreground_set", true, null);
|
||||
view.insert_column_with_attributes (-1, "Name", cell, "text", 2, "foreground", 3, null);
|
||||
|
||||
Gtk.TreeIter iter;
|
||||
listmodel.append (out iter);
|
||||
listmodel.set (iter, 0, "initfs", 1, "3M", 2, "initfs.jffs", -1);
|
||||
// Gtk.TreeIter iter;
|
||||
// listmodel.append (out iter);
|
||||
// listmodel.set (iter, 0, "initfs", 1, "3M", 2, "initfs.jffs", -1);
|
||||
//listmodel.set (iter, 0, "initfs", 1, "3M", 2, "initfs.jffs", 3, "green", -1);
|
||||
|
||||
listmodel.append (out iter);
|
||||
listmodel.set (iter, 0, "rootfs", 1, "52M", 2, "rootfs.jffs", -1);
|
||||
}
|
||||
// listmodel.append (out iter);
|
||||
// listmodel.set (iter, 0, "rootfs", 1, "52M", 2, "rootfs.jffs", -1);
|
||||
}
|
||||
|
||||
public static bool readFunc()
|
||||
{
|
||||
weak string msg = p->get(0);
|
||||
//string str = "%s".printf(msg);
|
||||
|
||||
if (msg != null && msg[0]!='\0') {
|
||||
stdout.printf("chk msg found hwhe (%s)\n", msg);
|
||||
viewer.showMessage(msg, MessageType.INFO);
|
||||
stdout.printf("[<] msg received: %s\n", msg);
|
||||
string[] foo = msg.split(":",2);
|
||||
if (foo[1] != null) {
|
||||
switch(foo[0]) {
|
||||
case "bar":
|
||||
viewer.pb.fraction = foo[1].to_int() / 100;
|
||||
viewer.pb.text = foo[1]+"%";
|
||||
break;
|
||||
case "error":
|
||||
viewer.showMessage(foo[1], MessageType.ERROR);
|
||||
break;
|
||||
case "info":
|
||||
viewer.showMessage(foo[1], MessageType.INFO);
|
||||
break;
|
||||
default:
|
||||
stderr.printf("[E] Unknown message type\n");
|
||||
break;
|
||||
}
|
||||
//viewer.showMessage(msg, MessageType.INFO);
|
||||
}
|
||||
p->pop();
|
||||
}
|
||||
return true;
|
||||
@@ -217,10 +298,20 @@ static SQueue *p = null;
|
||||
|
||||
private void OnGetInformation()
|
||||
{
|
||||
stdout.printf("chking\n");
|
||||
msg("foo");
|
||||
msg("info:device");
|
||||
}
|
||||
|
||||
private void OnConnect()
|
||||
{
|
||||
//msg("connect:device");
|
||||
External.system("sudo pkill 0xFFFF");
|
||||
External.system("sudo ../0xFFFF -Q &");
|
||||
p->close();
|
||||
q->close();
|
||||
p = q = null;
|
||||
}
|
||||
|
||||
|
||||
private bool chk_queues()
|
||||
{
|
||||
if (p == null)
|
||||
@@ -260,7 +351,7 @@ static int main (string[] args)
|
||||
setup_treeview(viewer.tv);
|
||||
viewer.show_all ();
|
||||
viewer.showMessage("This software is beta and does not guaranties correct functionality", MessageType.WARNING);
|
||||
Timeout.add(600, (SourceFunc)(readFunc));
|
||||
Timeout.add(200, (SourceFunc)(readFunc));
|
||||
Gtk.main ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user