modified JUninstaller.java
+ Remove line from log + Delete file listed in log x made selection of last item working (hope so) modified MyFilesystemParser.java + removeLine() to remove a single line from a log
This commit is contained in:
parent
476a526fcc
commit
bc3e7005ef
@ -72,11 +72,13 @@ public class JUninstaller extends Frame implements ActionListener {
|
|||||||
Label lbTime = new Label("--:--:--", Label.CENTER);
|
Label lbTime = new Label("--:--:--", Label.CENTER);
|
||||||
|
|
||||||
Panel pnView = new Panel(new BorderLayout());
|
Panel pnView = new Panel(new BorderLayout());
|
||||||
|
Panel pnDel = new Panel(new BorderLayout());
|
||||||
Panel pnViewB = new Panel(new GridLayout(0,1,0,0));
|
Panel pnViewB = new Panel(new GridLayout(0,1,0,0));
|
||||||
Label lbView = new Label("---");
|
Label lbView = new Label("---");
|
||||||
List ltView = new List();
|
List ltView = new List();
|
||||||
Button btDetails = new Button("Details");
|
Button btDetails = new Button("Details");
|
||||||
Button btRemove = new Button("Remove");
|
Button btRemove = new Button("Remove");
|
||||||
|
Button btDelFile = new Button("Del");
|
||||||
Button btBack2 = new Button("Back");
|
Button btBack2 = new Button("Back");
|
||||||
|
|
||||||
Dimension dmScreen = Toolkit.getDefaultToolkit().getScreenSize(); // get Screen dimensions
|
Dimension dmScreen = Toolkit.getDefaultToolkit().getScreenSize(); // get Screen dimensions
|
||||||
@ -133,7 +135,7 @@ public class JUninstaller extends Frame implements ActionListener {
|
|||||||
} else {
|
} else {
|
||||||
MIP.infoPrint("Can't delete!");
|
MIP.infoPrint("Can't delete!");
|
||||||
}
|
}
|
||||||
updateList(selItem+DATAEXT);
|
updateList(selItem);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MIP.infoPrint("Select one entry!");
|
MIP.infoPrint("Select one entry!");
|
||||||
@ -142,10 +144,12 @@ public class JUninstaller extends Frame implements ActionListener {
|
|||||||
clMain.show(pnMain, "1");
|
clMain.show(pnMain, "1");
|
||||||
} else if (ae.getSource().equals(btScan)) { // Scan-Button
|
} else if (ae.getSource().equals(btScan)) { // Scan-Button
|
||||||
parseFilesys();
|
parseFilesys();
|
||||||
|
MQ.msgBox("Scan complete.", "Now install your desired application and RUN IT at least once.\n\nDO NOT INSTALL OR CHANGE ANYTHING ELSE.\n\nIf done, perform one of the two 'Find Changes'.");
|
||||||
} else if (ae.getSource().equals(btFind)) { // Find changes-Button
|
} else if (ae.getSource().equals(btFind)) { // Find changes-Button
|
||||||
compareFilesys(false);
|
compareFilesys(false);
|
||||||
} else if (ae.getSource().equals(btFUp)) { // Find changes + Update-Button
|
} else if (ae.getSource().equals(btFUp)) { // Find changes + Update-Button
|
||||||
compareFilesys(true);
|
compareFilesys(true);
|
||||||
|
MQ.msgBox("Log complete.", "You can now install+run the next application.");
|
||||||
} else if (ae.getSource().equals(btUnin)) { // Uninstall-Button
|
} else if (ae.getSource().equals(btUnin)) { // Uninstall-Button
|
||||||
String selItem = ltApps.getSelectedItem();
|
String selItem = ltApps.getSelectedItem();
|
||||||
if (selItem != null) {
|
if (selItem != null) {
|
||||||
@ -159,14 +163,7 @@ public class JUninstaller extends Frame implements ActionListener {
|
|||||||
String selItem = ltApps.getSelectedItem();
|
String selItem = ltApps.getSelectedItem();
|
||||||
if (selItem != null) {
|
if (selItem != null) {
|
||||||
lbView.setText("Details of "+selItem);
|
lbView.setText("Details of "+selItem);
|
||||||
ltView.removeAll();
|
updateDetList(selItem+DATAEXT, null);
|
||||||
MIP.busy("Reading...");
|
|
||||||
String[] entries = mfs.getEntries(selItem+DATAEXT);
|
|
||||||
MIP.busy("Building list (" + entries.length + ")...");
|
|
||||||
for (int i=0;i<entries.length;i++) {
|
|
||||||
ltView.add(entries[i]);
|
|
||||||
}
|
|
||||||
MIP.infoPrint(entries.length+" entries");
|
|
||||||
clMain.show(pnMain, "4");
|
clMain.show(pnMain, "4");
|
||||||
} else {
|
} else {
|
||||||
MIP.infoPrint("Select one entry!");
|
MIP.infoPrint("Select one entry!");
|
||||||
@ -194,7 +191,7 @@ public class JUninstaller extends Frame implements ActionListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!okay && newname!=null);
|
} while (!okay && newname!=null);
|
||||||
updateList(newname+DATAEXT);
|
updateList(newname);
|
||||||
} else {
|
} else {
|
||||||
MIP.infoPrint("Select one entry!");
|
MIP.infoPrint("Select one entry!");
|
||||||
}
|
}
|
||||||
@ -215,6 +212,33 @@ public class JUninstaller extends Frame implements ActionListener {
|
|||||||
} else {
|
} else {
|
||||||
MIP.infoPrint("Select one entry!");
|
MIP.infoPrint("Select one entry!");
|
||||||
}
|
}
|
||||||
|
} else if (ae.getSource().equals(btRemove)) { // Remove (log-entry)
|
||||||
|
String selItem = ltView.getSelectedItem();
|
||||||
|
String selFile = ltApps.getSelectedItem();
|
||||||
|
if (selItem != null && selFile != null) {
|
||||||
|
String mbt = selItem.substring(selItem.indexOf(" ")+1);
|
||||||
|
if (!mfs.removeLine(selFile+DATAEXT, mbt)) MQ.msgBox("Error", "For some reason there were problems removing this line.");
|
||||||
|
updateDetList(selFile+DATAEXT, selItem);
|
||||||
|
} else {
|
||||||
|
MIP.infoPrint("Select one entry!");
|
||||||
|
}
|
||||||
|
} else if (ae.getSource().equals(btDelFile)) { // Delete file (log-details)
|
||||||
|
String selItem = ltView.getSelectedItem();
|
||||||
|
String selFile = ltApps.getSelectedItem();
|
||||||
|
if (selItem != null && selFile != null) {
|
||||||
|
selItem = selItem.substring(selItem.indexOf(" ")+1);
|
||||||
|
if (MQ.yesnoBox("Are you sure?", "Do you really want to delete this file?\n\n"+selItem+"\n\nDeleting the wrong file may render your phone unusable!") == MQ.YES) {
|
||||||
|
File flDelMe = new File(selItem);
|
||||||
|
if (flDelMe.delete()) {
|
||||||
|
MIP.infoPrint("Deleted.");
|
||||||
|
} else {
|
||||||
|
MIP.infoPrint("Error!");
|
||||||
|
}
|
||||||
|
updateDetList(selFile+DATAEXT, selItem);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
MIP.infoPrint("Select one entry!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TODO: more events
|
// TODO: more events
|
||||||
}
|
}
|
||||||
@ -277,12 +301,15 @@ public class JUninstaller extends Frame implements ActionListener {
|
|||||||
|
|
||||||
btDetails.addActionListener(this);
|
btDetails.addActionListener(this);
|
||||||
btRemove.addActionListener(this);
|
btRemove.addActionListener(this);
|
||||||
|
btDelFile.addActionListener(this);
|
||||||
btBack2.addActionListener(this);
|
btBack2.addActionListener(this);
|
||||||
lbView.setFont(ftBold12);
|
lbView.setFont(ftBold12);
|
||||||
pnView.add(lbView, BorderLayout.NORTH);
|
pnView.add(lbView, BorderLayout.NORTH);
|
||||||
pnView.add(ltView, BorderLayout.CENTER);
|
pnView.add(ltView, BorderLayout.CENTER);
|
||||||
|
pnDel.add(btRemove, BorderLayout.CENTER);
|
||||||
|
pnDel.add(btDelFile, BorderLayout.EAST);
|
||||||
pnViewB.add(btDetails);
|
pnViewB.add(btDetails);
|
||||||
pnViewB.add(btRemove);
|
pnViewB.add(pnDel);
|
||||||
pnViewB.add(btBack2);
|
pnViewB.add(btBack2);
|
||||||
pnView.add(pnViewB, BorderLayout.SOUTH);
|
pnView.add(pnViewB, BorderLayout.SOUTH);
|
||||||
|
|
||||||
@ -324,17 +351,39 @@ public class JUninstaller extends Frame implements ActionListener {
|
|||||||
String[] apps = mfs.getMonitored(DATAEXT);
|
String[] apps = mfs.getMonitored(DATAEXT);
|
||||||
ltApps.removeAll();
|
ltApps.removeAll();
|
||||||
int selIdx = 0;
|
int selIdx = 0;
|
||||||
|
if (selItem != null) selItem = selItem.toLowerCase();
|
||||||
for (int i=0;i<apps.length;i++) {
|
for (int i=0;i<apps.length;i++) {
|
||||||
ltApps.add(apps[i]);
|
ltApps.add(apps[i]);
|
||||||
if (selItem!=null && selItem.compareTo(apps[i])>=0) {
|
if (selItem != null && apps[i].toLowerCase().compareTo(selItem)>=0) {
|
||||||
selIdx = ltApps.getItemCount();
|
selIdx = ltApps.getItemCount()-1;
|
||||||
selItem = null;
|
selItem = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ltApps.select(selIdx);
|
|
||||||
ltApps.makeVisible(selIdx);
|
ltApps.makeVisible(selIdx);
|
||||||
|
ltApps.select(selIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateDetList(String log, String selItem) {
|
||||||
|
ltView.removeAll();
|
||||||
|
MIP.busy("Reading...");
|
||||||
|
String[] entries = mfs.getEntries(log);
|
||||||
|
MIP.busy("Building list (" + entries.length + ")...");
|
||||||
|
int selIdx = 0;
|
||||||
|
if (selItem!=null) selItem = selItem.substring(selItem.indexOf(" ")+1).toLowerCase();
|
||||||
|
String cmpItem;
|
||||||
|
for (int i=0;i<entries.length;i++) {
|
||||||
|
ltView.add(entries[i]);
|
||||||
|
cmpItem = entries[i].substring(entries[i].indexOf(" ")+1).toLowerCase();
|
||||||
|
if (selItem != null && cmpItem.compareTo(selItem)>=0) {
|
||||||
|
selIdx = ltView.getItemCount()-1;
|
||||||
|
selItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ltView.makeVisible(selIdx);
|
||||||
|
ltView.select(selIdx);
|
||||||
|
MIP.infoPrint(entries.length+" entries");
|
||||||
|
}
|
||||||
|
|
||||||
private void compareFilesys(boolean redump) {
|
private void compareFilesys(boolean redump) {
|
||||||
// parse filsystem and compare with
|
// parse filsystem and compare with
|
||||||
// previously generated info
|
// previously generated info
|
||||||
@ -381,7 +430,7 @@ public class JUninstaller extends Frame implements ActionListener {
|
|||||||
MIP.infoPrint("Could not delete!");
|
MIP.infoPrint("Could not delete!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateList(newname+DATAEXT);
|
updateList(newname);
|
||||||
clMain.show(pnMain, "1");
|
clMain.show(pnMain, "1");
|
||||||
} else {
|
} else {
|
||||||
MIP.infoPrint("No diffs found.");
|
MIP.infoPrint("No diffs found.");
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -250,6 +252,39 @@ public class MyFilesystemParser {
|
|||||||
return dumpDifferences(outfile, false);
|
return dumpDifferences(outfile, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Removes a line from a log, doesn't touch the file on disk */
|
||||||
|
public boolean removeLine(String infile, String filename) {
|
||||||
|
try {
|
||||||
|
BufferedWriter tout = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream("$$mfs$$.$$$"))));
|
||||||
|
BufferedReader fin = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(infile))));
|
||||||
|
String tmp;
|
||||||
|
int tab;
|
||||||
|
String myfn;
|
||||||
|
while ((tmp = fin.readLine()) != null) {
|
||||||
|
tab = tmp.indexOf("\t");
|
||||||
|
myfn = tmp.substring(tab+1, tmp.indexOf("\t", tab+1));
|
||||||
|
if (!myfn.equals(filename)) tout.write(tmp+"\r\n");
|
||||||
|
}
|
||||||
|
tout.close();
|
||||||
|
fin.close();
|
||||||
|
File oldlog = new File(infile);
|
||||||
|
File newlog = new File("$$mfs$$.$$$");
|
||||||
|
if (oldlog.delete()) {
|
||||||
|
if (!newlog.renameTo(oldlog)) {
|
||||||
|
System.out.println("ERROR: Could not rename new log to "+logFile.getName()+".");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("ERROR: Could not delete old logfile. Redump is still there.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
ioe.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Deletes dump */
|
/** Deletes dump */
|
||||||
public boolean delDump() {
|
public boolean delDump() {
|
||||||
return logFile.delete();
|
return logFile.delete();
|
||||||
|
Reference in New Issue
Block a user