Commit 9bdd57f1 authored by Markus Bauer's avatar Markus Bauer
Browse files

Hint for the online conditions

parent 176274f7
......@@ -400,6 +400,19 @@ public class GUI extends JFrame {
@Override
public void actionPerformed(ActionEvent arg0) {
// Warn the user
if (!Start.config.containsKey("AllowOnline") || !Start.config.get("AllowOnline").equals("true")){
if (JOptionPane.showConfirmDialog(GUI.this, "If you continue, the file will be uploaded to the server, "+
"and published under a random id. \nAnyone knowing or guessing this id, and the server operators, "+
"can read your file. \nThere is no possibility for you to delete it. Your IP address might be logged "+
"if you share files.\nBy continuing, you agree with this conditions.\n\nDo you want to continue?",
"pseuco.com", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION)
return;
Start.config.put("AllowOnline", "true");
Start.saveConfig();
}
// submit the project
String filename = currentProject;
if (!filename.isEmpty())
filename = new File(filename).getName();
......
......@@ -11,9 +11,12 @@ import gui.WorkspaceDialog;
import java.awt.EventQueue;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
......@@ -28,6 +31,7 @@ public class Start {
public static String workspace = "";
public static final boolean debug = false;
private static LockApplication lock = new LockApplication();
public static HashMap<String, String> config;
private static BufferedReader reader = null;
......@@ -82,21 +86,42 @@ public class Start {
}
private static boolean loadConfig() throws IOException {
boolean res = true;
if (new File(".config").exists()) {
config = loadConfigFile();
if (config.containsKey("Workspace"))
Start.workspace = config.get("Workspace");
if (config.containsKey("AskAgain"))
return Boolean.valueOf(config.get("AskAgain"));
return true;
}
private static HashMap<String, String> loadConfigFile() throws IOException{
HashMap<String, String> map = new HashMap<String, String>();
if (new File(".config").exists()){
reader = new BufferedReader(new FileReader(".config"));
String line;
while ((line = reader.readLine()) != null) {
String[] single = line.split("=");
if (single[0].equals("Workspace")) {
Start.workspace = single[1];
String[] single = line.split("=", 2);
if (single.length == 2){
map.put(single[0], single[1]);
}
if (single[0].equals("AskAgain")) {
res = Boolean.valueOf(single[1]);
}
}
}
return res;
return map;
}
public static void saveConfig(){
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(".config"));
for(String key: config.keySet()){
writer.write(key);
writer.write("=");
writer.write(config.get(key));
writer.write(System.getProperty("line.separator"));
}
writer.close();
} catch (IOException e) {
if (Start.debug) e.printStackTrace();
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment