Add license info command "license()"
This commit is contained in:
parent
b863a76e33
commit
d5207b54b0
@ -45,10 +45,20 @@
|
|||||||
*/
|
*/
|
||||||
package net.apocalypselabs.symat;
|
package net.apocalypselabs.symat;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import static java.lang.Math.*;
|
import static java.lang.Math.*;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
import static net.apocalypselabs.symat.MainGUI.API_URL;
|
||||||
import org.matheclipse.core.eval.EvalUtilities;
|
import org.matheclipse.core.eval.EvalUtilities;
|
||||||
import org.matheclipse.core.interfaces.IExpr;
|
import org.matheclipse.core.interfaces.IExpr;
|
||||||
import org.matheclipse.parser.client.math.MathException;
|
import org.matheclipse.parser.client.math.MathException;
|
||||||
@ -109,11 +119,11 @@ public class Functions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String simplify(String expr) {
|
public String simplify(String expr) {
|
||||||
return sym("Simplify("+expr+")");
|
return sym("Simplify(" + expr + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object vpa(String expr) {
|
public Object vpa(String expr) {
|
||||||
IExpr ans = util.evaluate("N("+expr+")");
|
IExpr ans = util.evaluate("N(" + expr + ")");
|
||||||
if (ans.isNumber()) {
|
if (ans.isNumber()) {
|
||||||
return Double.parseDouble(ans.toString());
|
return Double.parseDouble(ans.toString());
|
||||||
}
|
}
|
||||||
@ -232,7 +242,6 @@ public class Functions {
|
|||||||
return FileUtils.MD5(data);
|
return FileUtils.MD5(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: Make globals work!
|
// TODO: Make globals work!
|
||||||
// /*
|
// /*
|
||||||
// Global variables are accessible across scripts.
|
// Global variables are accessible across scripts.
|
||||||
@ -311,6 +320,44 @@ public class Functions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String license() {
|
||||||
|
String expires = "Error";
|
||||||
|
if (PrefStorage.getSetting("licensetype").equals("demo")) {
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.setTime(new Date());
|
||||||
|
try {
|
||||||
|
long expire = Long.parseLong(PrefStorage.getSetting("license"));
|
||||||
|
long days = (((expire - c.getTimeInMillis())/(60*60*24))-999)/1000;
|
||||||
|
if (days < 0) {
|
||||||
|
if (days == -1) {
|
||||||
|
expires = "Today";
|
||||||
|
} else {
|
||||||
|
expires = abs(days)+" days ago";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
expires = "In "+days+" days";
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
URL url = new URL(API_URL + "expire.php?email=" + PrefStorage.getSetting("license"));
|
||||||
|
try (InputStream is = url.openStream();
|
||||||
|
BufferedReader br
|
||||||
|
= new BufferedReader(new InputStreamReader(is))) {
|
||||||
|
expires = br.readLine();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String lic = "==License Information==\n"
|
||||||
|
+ "License: " + PrefStorage.getSetting("license")
|
||||||
|
+ "\nType: " + PrefStorage.getSetting("licensetype")
|
||||||
|
+ "\nExpires: " + expires;
|
||||||
|
return lic;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make sure the graph window shows.
|
* Make sure the graph window shows.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user