diff --git a/lib/commons-codec-1.9.jar b/lib/commons-codec-1.9.jar new file mode 100644 index 0000000..ef35f1c Binary files /dev/null and b/lib/commons-codec-1.9.jar differ diff --git a/lib/commons-logging-1.2.jar b/lib/commons-logging-1.2.jar new file mode 100644 index 0000000..93a3b9f Binary files /dev/null and b/lib/commons-logging-1.2.jar differ diff --git a/lib/fluent-hc-4.5.jar b/lib/fluent-hc-4.5.jar new file mode 100644 index 0000000..88da03b Binary files /dev/null and b/lib/fluent-hc-4.5.jar differ diff --git a/lib/httpclient-4.5.jar b/lib/httpclient-4.5.jar new file mode 100644 index 0000000..970c989 Binary files /dev/null and b/lib/httpclient-4.5.jar differ diff --git a/lib/httpclient-cache-4.5.jar b/lib/httpclient-cache-4.5.jar new file mode 100644 index 0000000..5540226 Binary files /dev/null and b/lib/httpclient-cache-4.5.jar differ diff --git a/lib/httpclient-win-4.5.jar b/lib/httpclient-win-4.5.jar new file mode 100644 index 0000000..340d154 Binary files /dev/null and b/lib/httpclient-win-4.5.jar differ diff --git a/lib/httpcore-4.4.1.jar b/lib/httpcore-4.4.1.jar new file mode 100644 index 0000000..99715b6 Binary files /dev/null and b/lib/httpcore-4.4.1.jar differ diff --git a/lib/httpmime-4.5.jar b/lib/httpmime-4.5.jar new file mode 100644 index 0000000..b631ceb Binary files /dev/null and b/lib/httpmime-4.5.jar differ diff --git a/lib/jna-4.1.0.jar b/lib/jna-4.1.0.jar new file mode 100644 index 0000000..b1a3922 Binary files /dev/null and b/lib/jna-4.1.0.jar differ diff --git a/lib/jna-platform-4.1.0.jar b/lib/jna-platform-4.1.0.jar new file mode 100644 index 0000000..8d5fe3d Binary files /dev/null and b/lib/jna-platform-4.1.0.jar differ diff --git a/lib/ujmp-complete-0.2.5.jar b/lib/ujmp-complete-0.2.5.jar new file mode 100644 index 0000000..312d154 Binary files /dev/null and b/lib/ujmp-complete-0.2.5.jar differ diff --git a/nbproject/project.properties b/nbproject/project.properties index cc25f5a..9cec78e 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -35,12 +35,20 @@ endorsed.classpath= excludes= file.reference.autocomplete-2.5.4.jar=lib/autocomplete-2.5.4.jar file.reference.beautyeye_lnf.jar=lib/beautyeye_lnf.jar +file.reference.commons-codec-1.9.jar=lib/commons-codec-1.9.jar +file.reference.commons-logging-1.2.jar=lib/commons-logging-1.2.jar file.reference.flamingo-6.3.jar=lib/flamingo-6.3.jar file.reference.htmlcleaner-2.10.jar=lib/htmlcleaner-2.10.jar +file.reference.httpclient-4.5.jar=lib/httpclient-4.5.jar +file.reference.httpclient-cache-4.5.jar=lib/httpclient-cache-4.5.jar +file.reference.httpclient-win-4.5.jar=lib/httpclient-win-4.5.jar +file.reference.httpcore-4.4.1.jar=lib/httpcore-4.4.1.jar +file.reference.httpmime-4.5.jar=lib/httpmime-4.5.jar file.reference.iText-4.2.0-com.itextpdf.jar=lib/iText-4.2.0-com.itextpdf.jar file.reference.JavaPrettify-1.2.1.jar=lib\\JavaPrettify-1.2.1.jar -file.reference.JGoogleAnalytics_0.4.jar=lib\\JGoogleAnalytics_0.4.jar file.reference.jmathplot.jar=lib/jmathplot.jar +file.reference.jna-4.1.0.jar=lib/jna-4.1.0.jar +file.reference.jna-platform-4.1.0.jar=lib/jna-platform-4.1.0.jar file.reference.js-engine.jar=lib/js-engine.jar file.reference.js.jar=lib/js.jar file.reference.json-simple-1.1.1.jar=lib/json-simple-1.1.1.jar @@ -51,6 +59,7 @@ file.reference.seaglasslookandfeel-0.2.jar=lib/seaglasslookandfeel-0.2.jar file.reference.SyMAT-src=src file.reference.symja-2014-11-01.jar=lib/symja-2014-11-01.jar file.reference.trident-6.3.jar=lib/trident-6.3.jar +file.reference.ujmp-complete-0.2.5.jar=lib\\ujmp-complete-0.2.5.jar includes=** jar.archive.disabled=${jnlp.enabled} jar.compress=false @@ -72,7 +81,16 @@ javac.classpath=\ ${file.reference.symja-2014-11-01.jar}:\ ${file.reference.trident-6.3.jar}:\ ${file.reference.JavaPrettify-1.2.1.jar}:\ - ${file.reference.JGoogleAnalytics_0.4.jar} + ${file.reference.ujmp-complete-0.2.5.jar}:\ + ${file.reference.commons-codec-1.9.jar}:\ + ${file.reference.commons-logging-1.2.jar}:\ + ${file.reference.httpclient-4.5.jar}:\ + ${file.reference.httpclient-cache-4.5.jar}:\ + ${file.reference.httpclient-win-4.5.jar}:\ + ${file.reference.httpcore-4.4.1.jar}:\ + ${file.reference.httpmime-4.5.jar}:\ + ${file.reference.jna-4.1.0.jar}:\ + ${file.reference.jna-platform-4.1.0.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false @@ -93,10 +111,11 @@ javadoc.nonavbar=false javadoc.notree=false javadoc.private=false javadoc.reference.flamingo-6.3.jar=lib/flamingo-6.3-javadoc.jar +javadoc.reference.ujmp-complete-0.2.5.jar=lib\\ujmp-complete-0.2.5-javadoc.zip!/0.2.5/ujmp-core/apidocs/ javadoc.splitindex=true javadoc.use=true javadoc.version=false -javadoc.windowtitle= +javadoc.windowtitle=SyMAT Code Docs jnlp.codebase.type=no.codebase jnlp.descriptor=application jnlp.enabled=false diff --git a/src/net/apocalypselabs/symat/Main.java b/src/net/apocalypselabs/symat/Main.java index 6510a7b..18f56b0 100644 --- a/src/net/apocalypselabs/symat/Main.java +++ b/src/net/apocalypselabs/symat/Main.java @@ -99,7 +99,7 @@ public class Main extends JRibbonFrame { /** * Version name, as it should be displayed. */ - public static final String VERSION_NAME = "2.0.1"; + public static final String VERSION_NAME = "2.1"; /** * The word "SyMAT". @@ -112,7 +112,7 @@ public class Main extends JRibbonFrame { /** * Version number, for updates and //needs in scripts */ - public static final double APP_CODE = 22; + public static final double APP_CODE = 23; /** * Base URL for building API calls */ diff --git a/src/net/apocalypselabs/symat/PrefStorage.java b/src/net/apocalypselabs/symat/PrefStorage.java index 7f6336e..316afef 100644 --- a/src/net/apocalypselabs/symat/PrefStorage.java +++ b/src/net/apocalypselabs/symat/PrefStorage.java @@ -1,106 +1,124 @@ -/* - * CODE LICENSE ===================== - * Copyright (c) 2015, Apocalypse Laboratories - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * 4. You adhere to the Media License detailed below. If you do not, this license - * is automatically revoked and you must purge all copies of the software you - * possess, in source or binary form. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * MEDIA LICENSE ==================== - * All images and other graphical files (the "graphics") included with this - * software are copyright (c) 2015 Apocalypse Laboratories. You may not distribute - * the graphics or any program, source code repository, or other digital storage - * media containing them without written permission from Apocalypse Laboratories. - * This ban on distribution only applies to publicly available systems. - * A password-protected network file share, USB drive, or other storage scheme that - * cannot be easily accessed by the public is generally allowed. If in doubt, - * contact Apocalypse Laboratories. If Apocalypse Laboratories allows or denies - * you permission, that decision is considered final and binding. - */ -package net.apocalypselabs.symat; - -import java.util.prefs.BackingStoreException; -import java.util.prefs.Preferences; - -/** - * - * @author Skylar Ittner - */ -public class PrefStorage { - - private static final Preferences prefs = Preferences.userNodeForPackage(PrefStorage.class); - - public static void saveSetting(String key, String value) { - prefs.put(key, value); - } - - public static boolean isset(String key) { - return !getSetting(key, "NULL").equals("NULL"); - } - - public static void unset(String key) { - saveSetting(key, ""); - save(); - prefs.remove(key); - save(); - } - - public static String getSetting(String key) { - return prefs.get(key, ""); - } - - public static String getSetting(String key, String emptyResponse) { - return prefs.get(key, emptyResponse); - } - - public static boolean save() { - try { - prefs.flush(); - } catch (BackingStoreException ex) { - System.err.println("Settings could not be saved!"); - return false; - } - return true; - } - - /** - * Wipe all settings. - * - * @throws java.util.prefs.BackingStoreException - */ - public static void wipe() throws BackingStoreException { - prefs.clear(); - } - - // xkcd 221 compliance. - int getRandomNumber() { - return 4; // chosen by fair dice roll. - // guaranteed to be random. - } -} +/* + * CODE LICENSE ===================== + * Copyright (c) 2015, Apocalypse Laboratories + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * 4. You adhere to the Media License detailed below. If you do not, this license + * is automatically revoked and you must purge all copies of the software you + * possess, in source or binary form. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * MEDIA LICENSE ==================== + * All images and other graphical files (the "graphics") included with this + * software are copyright (c) 2015 Apocalypse Laboratories. You may not distribute + * the graphics or any program, source code repository, or other digital storage + * media containing them without written permission from Apocalypse Laboratories. + * This ban on distribution only applies to publicly available systems. + * A password-protected network file share, USB drive, or other storage scheme that + * cannot be easily accessed by the public is generally allowed. If in doubt, + * contact Apocalypse Laboratories. If Apocalypse Laboratories allows or denies + * you permission, that decision is considered final and binding. + */ +package net.apocalypselabs.symat; + +import java.util.ArrayList; +import java.util.List; +import java.util.prefs.BackingStoreException; +import java.util.prefs.Preferences; +import org.apache.http.NameValuePair; +import org.apache.http.message.BasicNameValuePair; + +/** + * + * @author Skylar Ittner + */ +public class PrefStorage { + + private static final Preferences prefs = Preferences.userNodeForPackage(PrefStorage.class); + + public static void saveSetting(String key, String value) { + prefs.put(key, value); + } + + public static boolean isset(String key) { + return !getSetting(key, "NULL").equals("NULL"); + } + + public static void unset(String key) { + saveSetting(key, ""); + save(); + prefs.remove(key); + save(); + } + + public static String getSetting(String key) { + return prefs.get(key, ""); + } + + public static String getSetting(String key, String emptyResponse) { + return prefs.get(key, emptyResponse); + } + + public static boolean save() { + try { + prefs.flush(); + } catch (BackingStoreException ex) { + System.err.println("Settings could not be saved!"); + return false; + } + return true; + } + + /** + * Wipe all settings. + * + * @throws java.util.prefs.BackingStoreException + */ + public static void wipe() throws BackingStoreException { + prefs.clear(); + } + + /** + * Get all settings in a List for a Sync. + * @return List of NameValuePairs. + * @throws BackingStoreException + */ + public static List syncdump() throws BackingStoreException { + String[] keys = prefs.keys(); + List nvps = new ArrayList<>(); + for (String key : keys) { + nvps.add(new BasicNameValuePair(key, prefs.get(key, ""))); + } + return nvps; + } + + // xkcd 221 compliance. + int getRandomNumber() { + return 4; // chosen by fair dice roll. + // guaranteed to be random. + } +} diff --git a/src/net/apocalypselabs/symat/SplashScreen.form b/src/net/apocalypselabs/symat/SplashScreen.form index 8c262cc..c0d8cd3 100644 --- a/src/net/apocalypselabs/symat/SplashScreen.form +++ b/src/net/apocalypselabs/symat/SplashScreen.form @@ -110,7 +110,7 @@ - + diff --git a/src/net/apocalypselabs/symat/SplashScreen.java b/src/net/apocalypselabs/symat/SplashScreen.java index 7f4c890..b22f73f 100644 --- a/src/net/apocalypselabs/symat/SplashScreen.java +++ b/src/net/apocalypselabs/symat/SplashScreen.java @@ -96,10 +96,8 @@ public class SplashScreen extends javax.swing.JFrame { setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("SyMAT"); setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); - setMaximumSize(new java.awt.Dimension(500, 400)); setMinimumSize(new java.awt.Dimension(500, 400)); setUndecorated(true); - setPreferredSize(new java.awt.Dimension(500, 400)); setResizable(false); setType(java.awt.Window.Type.POPUP); addComponentListener(new java.awt.event.ComponentAdapter() { @@ -132,7 +130,7 @@ public class SplashScreen extends javax.swing.JFrame { jLabel3.setFont(net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(12.0F)); jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); - jLabel3.setText("Apocalypse Laboratories"); + jLabel3.setText("Netsyms Technologies"); jLayeredPane1.add(jLabel3); jLabel3.setBounds(10, 370, 250, 30); jLayeredPane1.setLayer(jLabel3, javax.swing.JLayeredPane.POPUP_LAYER); diff --git a/src/net/apocalypselabs/symat/SyncLogin.form b/src/net/apocalypselabs/symat/SyncLogin.form new file mode 100644 index 0000000..e1373f5 --- /dev/null +++ b/src/net/apocalypselabs/symat/SyncLogin.form @@ -0,0 +1,83 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/net/apocalypselabs/symat/SyncLogin.java b/src/net/apocalypselabs/symat/SyncLogin.java new file mode 100644 index 0000000..a53891e --- /dev/null +++ b/src/net/apocalypselabs/symat/SyncLogin.java @@ -0,0 +1,123 @@ +/* + * CODE LICENSE ===================== + * Copyright (c) 2015, Apocalypse Laboratories + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * 4. You adhere to the Media License detailed below. If you do not, this license + * is automatically revoked and you must purge all copies of the software you + * possess, in source or binary form. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * MEDIA LICENSE ==================== + * All images and other graphical files (the "graphics") included with this + * software are copyright (c) 2015 Apocalypse Laboratories. You may not distribute + * the graphics or any program, source code repository, or other digital storage + * media containing them without written permission from Apocalypse Laboratories. + * This ban on distribution only applies to publicly available systems. + * A password-protected network file share, USB drive, or other storage scheme that + * cannot be easily accessed by the public is generally allowed. If in doubt, + * contact Apocalypse Laboratories. If Apocalypse Laboratories allows or denies + * you permission, that decision is considered final and binding. + */ +package net.apocalypselabs.symat; + +import java.awt.BorderLayout; +import net.apocalypselabs.symat.sync.Start; + +/** + * + * @author Skylar + */ + + +public class SyncLogin extends javax.swing.JInternalFrame { + + /** + * Creates new form SyncLogin + */ + public SyncLogin() { + initComponents(); + Start st = new Start(this); + wizPanel.add(st, BorderLayout.CENTER); + st.setVisible(true); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + wizPanel = new javax.swing.JPanel(); + + setClosable(true); + setIconifiable(true); + setMaximizable(true); + setResizable(true); + setTitle("SyMAT Sync"); + setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/icons/sync.png"))); // NOI18N + setMinimumSize(new java.awt.Dimension(400, 386)); + setPreferredSize(new java.awt.Dimension(400, 386)); + + jLabel1.setBackground(new java.awt.Color(0, 184, 255)); + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/images/SyncLogo.png"))); // NOI18N + jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + jLabel1.setOpaque(true); + + wizPanel.setMinimumSize(new java.awt.Dimension(0, 200)); + wizPanel.setPreferredSize(new java.awt.Dimension(400, 200)); + wizPanel.setLayout(new java.awt.BorderLayout()); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE) + .addComponent(wizPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(wizPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JPanel wizPanel; + // End of variables declaration//GEN-END:variables +} diff --git a/src/net/apocalypselabs/symat/icons/sync.png b/src/net/apocalypselabs/symat/icons/sync.png new file mode 100644 index 0000000..c6f69b3 Binary files /dev/null and b/src/net/apocalypselabs/symat/icons/sync.png differ diff --git a/src/net/apocalypselabs/symat/images/SyncLogo.png b/src/net/apocalypselabs/symat/images/SyncLogo.png new file mode 100644 index 0000000..2c98c17 Binary files /dev/null and b/src/net/apocalypselabs/symat/images/SyncLogo.png differ diff --git a/src/net/apocalypselabs/symat/sync/BackgroundSync.java b/src/net/apocalypselabs/symat/sync/BackgroundSync.java new file mode 100644 index 0000000..f55b478 --- /dev/null +++ b/src/net/apocalypselabs/symat/sync/BackgroundSync.java @@ -0,0 +1,83 @@ +/* + * CODE LICENSE ===================== + * Copyright (c) 2015, Apocalypse Laboratories + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * 4. You adhere to the Media License detailed below. If you do not, this license + * is automatically revoked and you must purge all copies of the software you + * possess, in source or binary form. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * MEDIA LICENSE ==================== + * All images and other graphical files (the "graphics") included with this + * software are copyright (c) 2015 Apocalypse Laboratories. You may not distribute + * the graphics or any program, source code repository, or other digital storage + * media containing them without written permission from Apocalypse Laboratories. + * This ban on distribution only applies to publicly available systems. + * A password-protected network file share, USB drive, or other storage scheme that + * cannot be easily accessed by the public is generally allowed. If in doubt, + * contact Apocalypse Laboratories. If Apocalypse Laboratories allows or denies + * you permission, that decision is considered final and binding. + */ +package net.apocalypselabs.symat.sync; + +import net.apocalypselabs.symat.Debug; +import static net.apocalypselabs.symat.Main.API_URL; +import net.apocalypselabs.symat.PrefStorage; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; + +/** + * Perform settings sync in another thread. + * + * @author Skylar + */ +public class BackgroundSync extends Thread { + + @Override + public void run() { + try { + Debug.println("Syncing profile..."); + CloseableHttpClient httpClient = HttpClients.createDefault(); + HttpPost data = new HttpPost(API_URL + "sync.php"); + + data.setEntity(new UrlEncodedFormEntity(PrefStorage.syncdump())); + CloseableHttpResponse response = httpClient.execute(data); + + + } catch (Exception e) { + Debug.stacktrace(e); + } + } + + public BackgroundSync() { + + } +} diff --git a/src/net/apocalypselabs/symat/sync/Start.form b/src/net/apocalypselabs/symat/sync/Start.form new file mode 100644 index 0000000..735dd83 --- /dev/null +++ b/src/net/apocalypselabs/symat/sync/Start.form @@ -0,0 +1,75 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/net/apocalypselabs/symat/sync/Start.java b/src/net/apocalypselabs/symat/sync/Start.java new file mode 100644 index 0000000..f883826 --- /dev/null +++ b/src/net/apocalypselabs/symat/sync/Start.java @@ -0,0 +1,195 @@ +/* + * CODE LICENSE ===================== + * Copyright (c) 2015, Apocalypse Laboratories + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * 4. You adhere to the Media License detailed below. If you do not, this license + * is automatically revoked and you must purge all copies of the software you + * possess, in source or binary form. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * MEDIA LICENSE ==================== + * All images and other graphical files (the "graphics") included with this + * software are copyright (c) 2015 Apocalypse Laboratories. You may not distribute + * the graphics or any program, source code repository, or other digital storage + * media containing them without written permission from Apocalypse Laboratories. + * This ban on distribution only applies to publicly available systems. + * A password-protected network file share, USB drive, or other storage scheme that + * cannot be easily accessed by the public is generally allowed. If in doubt, + * contact Apocalypse Laboratories. If Apocalypse Laboratories allows or denies + * you permission, that decision is considered final and binding. + */ +package net.apocalypselabs.symat.sync; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLEncoder; +import javax.swing.JInternalFrame; +import javax.swing.JOptionPane; +import net.apocalypselabs.symat.Debug; +import static net.apocalypselabs.symat.Main.API_URL; +import net.apocalypselabs.symat.PrefStorage; + +/** + * + * @author Skylar + */ +public class Start extends javax.swing.JPanel { + + private String email = ""; + private String password = ""; + private JInternalFrame parentComponent; + + /** + * Creates new form Start + */ + public Start(JInternalFrame parent) { + parentComponent = parent; + initComponents(); + setVisible(true); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel2 = new javax.swing.JLabel(); + newSyncBtn = new javax.swing.JButton(); + haveSyncBtn = new javax.swing.JButton(); + + setPreferredSize(new java.awt.Dimension(400, 200)); + + jLabel2.setFont(net.apocalypselabs.symat.Main.ubuntuRegular.deriveFont(36.0F)); + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel2.setText("Sync"); + + newSyncBtn.setText("Setup a new account"); + newSyncBtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + newSyncBtnActionPerformed(evt); + } + }); + + haveSyncBtn.setText("I already have Sync"); + haveSyncBtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + haveSyncBtnActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(haveSyncBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(newSyncBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 51, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(newSyncBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(haveSyncBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(49, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void haveSyncBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_haveSyncBtnActionPerformed + getLogin(UserLogin.LOGIN_MODE); + }//GEN-LAST:event_haveSyncBtnActionPerformed + + private void newSyncBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newSyncBtnActionPerformed + getLogin(UserLogin.SIGNUP_MODE); + }//GEN-LAST:event_newSyncBtnActionPerformed + + private void getLogin(int mode) { + UserLogin ul = new UserLogin(mode); + JOptionPane.showMessageDialog(this, + ul, + "Sync " + (mode == UserLogin.SIGNUP_MODE ? "Signup" : "Login"), + JOptionPane.PLAIN_MESSAGE); + email = ul.getEmail(); + password = ul.getPassword(); + try { + Debug.println("Signing in to Sync..."); + URL url = new URL(API_URL + + "sync" + (mode == UserLogin.SIGNUP_MODE ? "new" : "old") + + ".php?" + + "email=" + URLEncoder.encode(email, "UTF-8") + + "&password=" + URLEncoder.encode(password, "UTF-8")); + InputStream is = url.openStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + + String line = br.readLine(); + br.close(); + is.close(); + if (!line.contains("OK")) { + JOptionPane.showMessageDialog(this, + line, + "Sync Error", + JOptionPane.ERROR_MESSAGE); + } else { + PrefStorage.saveSetting("syncemail", email); + PrefStorage.saveSetting("syncpassword", password); + PrefStorage.save(); + new BackgroundSync().start(); + JOptionPane.showMessageDialog(this, + "Account setup successful. " + + "Your settings and plugins " + + "will now sync in the background.", + "Sync", + JOptionPane.INFORMATION_MESSAGE); + parentComponent.dispose(); + } + } catch (Exception e) { + JOptionPane.showMessageDialog(this, + "An error occurred while syncing your account.", + "Sync Error", + JOptionPane.ERROR_MESSAGE); + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton haveSyncBtn; + private javax.swing.JLabel jLabel2; + private javax.swing.JButton newSyncBtn; + // End of variables declaration//GEN-END:variables +} diff --git a/src/net/apocalypselabs/symat/sync/UserLogin.form b/src/net/apocalypselabs/symat/sync/UserLogin.form new file mode 100644 index 0000000..a62db70 --- /dev/null +++ b/src/net/apocalypselabs/symat/sync/UserLogin.form @@ -0,0 +1,76 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/net/apocalypselabs/symat/sync/UserLogin.java b/src/net/apocalypselabs/symat/sync/UserLogin.java new file mode 100644 index 0000000..4ca240f --- /dev/null +++ b/src/net/apocalypselabs/symat/sync/UserLogin.java @@ -0,0 +1,140 @@ +/* + * CODE LICENSE ===================== + * Copyright (c) 2015, Apocalypse Laboratories + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * 4. You adhere to the Media License detailed below. If you do not, this license + * is automatically revoked and you must purge all copies of the software you + * possess, in source or binary form. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * MEDIA LICENSE ==================== + * All images and other graphical files (the "graphics") included with this + * software are copyright (c) 2015 Apocalypse Laboratories. You may not distribute + * the graphics or any program, source code repository, or other digital storage + * media containing them without written permission from Apocalypse Laboratories. + * This ban on distribution only applies to publicly available systems. + * A password-protected network file share, USB drive, or other storage scheme that + * cannot be easily accessed by the public is generally allowed. If in doubt, + * contact Apocalypse Laboratories. If Apocalypse Laboratories allows or denies + * you permission, that decision is considered final and binding. + */ +package net.apocalypselabs.symat.sync; + +/** + * + * @author Skylar + */ + + +public class UserLogin extends javax.swing.JPanel { + + public static final int LOGIN_MODE = 0; + public static final int SIGNUP_MODE = 1; + private static final String signup_help = "Sign up for a Sync acount."; + /** + * Creates new form UserLogin + * @param mode LOGIN_MODE or SIGNUP_MODE. Sets the help string. + */ + public UserLogin(int mode) { + initComponents(); + if (mode == SIGNUP_MODE) { + helpLbl.setText(signup_help); + } + } + + public String getEmail() { + return emailBox.getText(); + } + + public String getPassword() { + return new String(passwdBox.getPassword()); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + helpLbl = new javax.swing.JLabel(); + emailBox = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + passwdBox = new javax.swing.JPasswordField(); + + helpLbl.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + helpLbl.setText("Please login to your Sync account."); + + jLabel1.setText("Email:"); + + jLabel2.setText("Password:"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(helpLbl, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(emailBox, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE) + .addComponent(passwdBox)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(helpLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(emailBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(passwdBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(0, 13, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField emailBox; + private javax.swing.JLabel helpLbl; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JPasswordField passwdBox; + // End of variables declaration//GEN-END:variables +}