├── resources ├── icon.png ├── cursor.png └── complete.wav ├── lib ├── ftp4j-1.7.3.jar └── jnativehook-2.0.3.jar ├── .gitignore ├── src └── it │ └── ksuploader │ ├── utils │ ├── Sound.java │ ├── Zipper.java │ ├── Environment.java │ ├── MyKeyListener.java │ └── LoadConfig.java │ ├── main │ ├── Main.java │ ├── MyScreen.java │ ├── SocketUploader.java │ ├── FtpUploader.java │ └── SystemTrayMenu.java │ └── dialogs │ ├── PopupDialog.java │ └── SettingsDialog.java ├── README.md └── LICENSE /resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HermexTools/client-legacy/HEAD/resources/icon.png -------------------------------------------------------------------------------- /lib/ftp4j-1.7.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HermexTools/client-legacy/HEAD/lib/ftp4j-1.7.3.jar -------------------------------------------------------------------------------- /resources/cursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HermexTools/client-legacy/HEAD/resources/cursor.png -------------------------------------------------------------------------------- /resources/complete.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HermexTools/client-legacy/HEAD/resources/complete.wav -------------------------------------------------------------------------------- /lib/jnativehook-2.0.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HermexTools/client-legacy/HEAD/lib/jnativehook-2.0.3.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | 3 | ###################### 4 | # Eclipse 5 | ###################### 6 | 7 | *.pydevproject 8 | .metadata 9 | .project 10 | bin/** 11 | tmp/** 12 | tmp/**/* 13 | *.tmp 14 | *.bak 15 | *.swp 16 | *~.nib 17 | local.properties 18 | .classpath 19 | .settings/ 20 | .loadpath 21 | /src/main/resources/rebel.xml 22 | # External tool builders 23 | .externalToolBuilders/ 24 | 25 | # Locally stored "Eclipse launch configurations" 26 | *.launch 27 | 28 | # CDT-specific 29 | .cproject 30 | 31 | # PDT-specific 32 | .buildpath 33 | 34 | #NetBeans 35 | 36 | dist/ 37 | nbproject/ 38 | build/ 39 | store/ 40 | build.xml 41 | config.properties 42 | manifest.mf 43 | client.properties 44 | 45 | #jetbrains 46 | out/ 47 | .idea/ 48 | *.iml -------------------------------------------------------------------------------- /src/it/ksuploader/utils/Sound.java: -------------------------------------------------------------------------------- 1 | package it.ksuploader.utils; 2 | 3 | import it.ksuploader.main.Main; 4 | 5 | import javax.sound.sampled.AudioInputStream; 6 | import javax.sound.sampled.AudioSystem; 7 | import javax.sound.sampled.Clip; 8 | import javax.sound.sampled.DataLine; 9 | import java.net.URL; 10 | import java.util.Arrays; 11 | 12 | public class Sound extends Thread { 13 | 14 | private static final URL clickUrl = Sound.class.getResource("/complete.wav"); 15 | 16 | public Sound() { 17 | } 18 | 19 | @Override 20 | public void run() { 21 | AudioInputStream audioInputStream; 22 | 23 | try { 24 | audioInputStream = AudioSystem.getAudioInputStream(clickUrl); 25 | 26 | DataLine.Info info = new DataLine.Info(Clip.class, audioInputStream.getFormat()); 27 | Clip clip = (Clip) AudioSystem.getLine(info); 28 | if (clip.isRunning()) { 29 | clip.close(); 30 | } 31 | clip.open(audioInputStream); 32 | clip.start(); 33 | } catch (Exception e) { 34 | e.printStackTrace(); 35 | Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/it/ksuploader/main/Main.java: -------------------------------------------------------------------------------- 1 | package it.ksuploader.main; 2 | 3 | import it.ksuploader.dialogs.PopupDialog; 4 | import it.ksuploader.utils.Environment; 5 | import it.ksuploader.utils.LoadConfig; 6 | import it.ksuploader.utils.MyKeyListener; 7 | 8 | import javax.swing.*; 9 | import java.io.File; 10 | import java.io.FileWriter; 11 | import java.io.IOException; 12 | import java.net.URISyntaxException; 13 | import java.util.Arrays; 14 | import java.util.logging.FileHandler; 15 | import java.util.logging.Logger; 16 | import java.util.logging.SimpleFormatter; 17 | 18 | public class Main { 19 | public static Environment so = new Environment(); 20 | public static PopupDialog dialog = new PopupDialog(); 21 | public static LoadConfig config = new LoadConfig(); 22 | public static MyKeyListener keyListener; 23 | private static Logger log = Logger.getLogger("KSULog"); 24 | public static SystemTrayMenu st; 25 | 26 | public static void main(String[] args) throws IOException, URISyntaxException { 27 | FileHandler fh = new FileHandler(so.getInstallDir().getPath() + "//KSULog.txt"); 28 | fh.setFormatter(new SimpleFormatter()); 29 | log.addHandler(fh); 30 | log.setUseParentHandlers(false); 31 | startUpCheck(); 32 | keyListener = new MyKeyListener(); 33 | SwingUtilities.invokeLater(() -> st = new SystemTrayMenu()); 34 | } 35 | 36 | private static void startUpChecker(String name, String where, String target, String icon) { 37 | try { 38 | FileWriter fw = new FileWriter(where + "\\" + name); 39 | fw.write("[InternetShortcut]\n"); 40 | fw.write("URL=file://" + target + "\n"); 41 | fw.write("IDList=\n"); 42 | fw.write("HotKey=0\n"); 43 | if (!icon.equals("")) { 44 | fw.write("IconFile=" + icon + "\n"); 45 | } 46 | fw.flush(); 47 | fw.close(); 48 | myLog("[Main] Shortcut created"); 49 | } catch (IOException e) { 50 | e.printStackTrace(); 51 | myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 52 | } 53 | } 54 | 55 | public static void startUpCheck() { 56 | myLog("[Main] removing shortcut: " + new File(Main.so.getStartUpFolder(), "KSUploader_autostart.url").delete()); 57 | if (config.isStartUpEnabled()) { 58 | startUpChecker("KSUploader_autostart.url", Main.so.getStartUpFolder(), Main.class.getProtectionDomain().getCodeSource().getLocation().getPath(), ""); 59 | } 60 | } 61 | 62 | public static void myLog(String s) { 63 | System.out.println(s); 64 | log.info(s); 65 | } 66 | 67 | public static void myErr(String s) { 68 | log.severe(s); 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## KSUploader-client 2 | KSUploader is a instant sharing tool. Inspired by Puush and ScreenCloud, with this tool you can share instantly: 3 | * a partial screen 4 | * a complete desktop screen 5 | * a file (that will be zipped) 6 | * an entire file set (that will be zipped) 7 | * the clipboard 8 | obtaining immediately the direct sharing URL. 9 | 10 | You can host all files in your server (via dedicated socket [server application](https://github.com/KSUploader/KSUploader-server)) or web hosting space (via FTP). 11 | 12 | Since this project is open source and java written, feel free to fork, give suggestions or make pull requests. 13 | 14 | ### How to install 15 | Actually simply run the binary file where you want, and it will save the configurations in the correct place. 16 | 17 | ### How to configure 18 | Open KSUploader.jar, right-click on icon in the system tray, settings, and setup your client. 19 | 20 | OR 21 | 22 | Open and edit the `client.properties` file saved in `Appdata\Roaming\.ksuploader` on Windows, in your user home in the folder `.ksuploader` on Linux or in `~/Library/Application Support/.ksuploader` on OS X, then launch the client again. 23 | It contains: 24 | * `server_address`: the address where there is the server, you can use a domain (example.com) or an ip. 25 | * `password`: the password of the server that will be used during the authentication check. 26 | * `port`: the port where there is the running server. 27 | * `ftp_enabled`: set this "true" or "false" to enable o disable the FTP feature, if on "true" the socket config will be ignored. 28 | * `ftp_address`: the address for the FTP connection (es. ftp.mydomain.com). 29 | * `ftp_user`: the FTP user. 30 | * `ftp_password`: the FTP password. 31 | * `ftp_port`: the port where the FTP is listening (21 as default). 32 | * `ftp_directory`: the relative directory how to upload all files, use a dot (.) to say "this directory". To use a subfolder follow this example: "subFolder/anotherFolder". 33 | * `ftp_weburl`: the url that will be returned, write a / at the end of the it. 34 | * `save_enabled`: you can choose if save locally the pics taken, set it as true or false. 35 | * `save_dir`: the folder where all images will be saved, use a . to say "where the client is located". 36 | * `ftpes_enabled`: enable or disable (with "true" or "false") the FTPES. 37 | * `accept_all_certificates`: choose to accept all certificates or not (true/false). 38 | * `open_at_startup_enabled`: enable the autorun at os boot (Only windows). 39 | 40 | >Attention: all config properties must be not null, even if you don't use one of them. 41 | 42 | >Disclaimer: this is a project in early development stage. Since that it may change at any time. 43 | -------------------------------------------------------------------------------- /src/it/ksuploader/utils/Zipper.java: -------------------------------------------------------------------------------- 1 | package it.ksuploader.utils; 2 | 3 | import it.ksuploader.main.Main; 4 | 5 | import java.io.File; 6 | import java.io.FileInputStream; 7 | import java.io.FileOutputStream; 8 | import java.io.IOException; 9 | import java.util.Arrays; 10 | import java.util.Random; 11 | import java.util.zip.ZipEntry; 12 | import java.util.zip.ZipOutputStream; 13 | 14 | public class Zipper { 15 | 16 | public static String toZip(String method, File[] files, String root) { 17 | String fileName = null; 18 | ZipOutputStream zos; 19 | try { 20 | 21 | Main.myLog("[Zipper] file.length: " + files.length); 22 | 23 | if (method.equals("socket")) // socket or ftp 24 | fileName = "KStemp.zip"; 25 | else 26 | fileName = System.currentTimeMillis() / 1000 + new Random().nextInt(999) + ".zip"; 27 | 28 | zos = new ZipOutputStream(new FileOutputStream(Main.so.getTempDir() + File.separator + fileName)); 29 | Main.dialog.setButtonClickable(false); 30 | Main.dialog.show("Zipping...", "", false); 31 | add(zos, files, root); 32 | Main.dialog.setButtonClickable(true); 33 | zos.flush(); 34 | zos.close(); 35 | } catch (IOException e) { 36 | Main.dialog.setButtonClickable(true); 37 | e.printStackTrace(); 38 | Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 39 | } 40 | Main.myLog("[Zipper] Zipping finished: " + Main.so.getTempDir() + File.separator + fileName); 41 | return Main.so.getTempDir() + File.separator + fileName; 42 | } 43 | 44 | private static void add(ZipOutputStream zout, File[] fileSource, String root) { 45 | for (File f : fileSource) { 46 | if (f.isDirectory()) { 47 | add(zout, f.listFiles(), root); 48 | } else { 49 | try (FileInputStream fin = new FileInputStream(f)) { 50 | byte[] buffer = new byte[4096]; 51 | zout.putNextEntry(new ZipEntry(f.getPath().replace(root + File.separator, ""))); 52 | 53 | int length; 54 | long count = 0; 55 | 56 | while ((length = fin.read(buffer)) > 0) { 57 | zout.write(buffer, 0, length); 58 | count += length; 59 | Main.dialog.set((int) (count * 100 / f.length())); 60 | } 61 | zout.closeEntry(); 62 | 63 | } catch (IOException e) { 64 | Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 65 | } 66 | } 67 | } 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/it/ksuploader/utils/Environment.java: -------------------------------------------------------------------------------- 1 | package it.ksuploader.utils; 2 | 3 | import java.awt.*; 4 | import java.io.File; 5 | import java.util.Locale; 6 | 7 | public class Environment { 8 | 9 | private OS os; 10 | private Rectangle screen; 11 | 12 | public enum OS { 13 | LINUX, WINDOWS, OSX, UNKNOWN 14 | } 15 | 16 | public Environment() { 17 | os = getEnvironment(); 18 | this.screen = new Rectangle(); 19 | for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) { 20 | this.screen = this.screen.union(gd.getDefaultConfiguration().getBounds()); 21 | } 22 | 23 | } 24 | 25 | private OS getEnvironment() { 26 | String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH); 27 | 28 | if (osName.contains("linux")) { 29 | return os = OS.LINUX; 30 | } else if (osName.contains("mac")) { 31 | return os = OS.OSX; 32 | } else if (osName.contains("windows")) { 33 | return os = OS.WINDOWS; 34 | } 35 | 36 | return OS.UNKNOWN; 37 | } 38 | 39 | public String getTempDir() { 40 | 41 | switch (os) { 42 | case LINUX: 43 | case WINDOWS: 44 | case OSX: 45 | return System.getProperty("java.io.tmpdir"); 46 | default: 47 | return "UNKNOWN"; 48 | } 49 | } 50 | 51 | public File getInstallDir() { 52 | final String appData = System.getenv("AppData"); 53 | final String userHome = System.getProperty("user.home"); 54 | final String dirName = ".ksuploader"; 55 | File f; 56 | switch (os) { 57 | case LINUX: 58 | f = new File(userHome, dirName); 59 | f.mkdir(); 60 | return f; 61 | case WINDOWS: 62 | f = new File(appData, dirName); 63 | f.mkdir(); 64 | return f; 65 | case OSX: 66 | f = new File(System.getProperty("user.home"), "Library/Application Support/" + dirName); 67 | f.mkdir(); 68 | return f; 69 | default: 70 | return null; 71 | 72 | } 73 | } 74 | 75 | public String getStartUpFolder() { 76 | switch (os) { 77 | case LINUX: 78 | return "~/.config/autostart"; 79 | case WINDOWS: 80 | return System.getenv("Appdata") + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup"; 81 | case OSX: 82 | return null; 83 | default: 84 | return null; 85 | 86 | } 87 | 88 | } 89 | 90 | public Rectangle getScreenBounds() { 91 | return this.screen; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/it/ksuploader/main/MyScreen.java: -------------------------------------------------------------------------------- 1 | package it.ksuploader.main; 2 | 3 | import javax.swing.*; 4 | import java.awt.*; 5 | import java.awt.event.KeyEvent; 6 | import java.awt.event.KeyListener; 7 | import java.awt.event.MouseAdapter; 8 | import java.awt.event.MouseEvent; 9 | import java.awt.geom.Area; 10 | import java.awt.image.BufferedImage; 11 | 12 | import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE; 13 | 14 | public class MyScreen extends JPanel { 15 | 16 | private Rectangle selectionBounds; 17 | private static Color c = new Color(255, 255, 255, 128); 18 | private Robot screenRobot; 19 | private Point startPoint = null; 20 | 21 | public MyScreen() { 22 | try { 23 | this.screenRobot = new Robot(); 24 | } catch (AWTException e) { 25 | e.printStackTrace(); 26 | } 27 | this.selectionBounds = new Rectangle(); 28 | JDialog panel = new JDialog(); 29 | 30 | MouseAdapter mouseHandler = new MouseAdapter() { 31 | @Override 32 | public void mouseClicked(MouseEvent e) { 33 | 34 | } 35 | 36 | @Override 37 | public void mousePressed(MouseEvent e) { 38 | startPoint = e.getPoint(); 39 | } 40 | 41 | @Override 42 | public void mouseReleased(MouseEvent e) { 43 | panel.removeAll(); 44 | panel.dispose(); 45 | if(SwingUtilities.isRightMouseButton(e)){ 46 | Main.myLog("Right click pressed during selection"); 47 | selectionBounds = null; 48 | } 49 | 50 | } 51 | 52 | @Override 53 | public void mouseDragged(MouseEvent e) { 54 | selectionBounds.x = Math.min(startPoint.x, e.getX()); 55 | selectionBounds.y = Math.min(startPoint.y, e.getY()); 56 | selectionBounds.width = Math.max(startPoint.x - e.getX(), e.getX() - startPoint.x); 57 | selectionBounds.height = Math.max(startPoint.y - e.getY(), e.getY() - startPoint.y); 58 | repaint(); 59 | } 60 | }; 61 | this.setOpaque(false); 62 | this.addMouseListener(mouseHandler); 63 | this.addMouseMotionListener(mouseHandler); 64 | KeyListener keyHandler = new KeyListener() { 65 | @Override 66 | public void keyTyped(KeyEvent e) { 67 | 68 | } 69 | 70 | @Override 71 | public void keyPressed(KeyEvent e) { 72 | 73 | } 74 | 75 | @Override 76 | public void keyReleased(KeyEvent e) { 77 | if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { 78 | Main.myLog("Escape pressed during selection"); 79 | panel.removeAll(); 80 | panel.dispose(); 81 | } 82 | } 83 | }; 84 | panel.addKeyListener(keyHandler); 85 | panel.setModal(true); 86 | panel.setUndecorated(true); 87 | panel.setOpacity(0.5f); 88 | panel.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(new ImageIcon(MyScreen.class.getResource("/cursor.png")).getImage(), 89 | new Point(16, 16), 90 | "img")); 91 | panel.setBackground(new Color(0, 0, 0, 0)); 92 | panel.setDefaultCloseOperation(DISPOSE_ON_CLOSE); 93 | panel.setLayout(new BorderLayout()); 94 | panel.add(this); 95 | panel.setLocation(Main.so.getScreenBounds().getLocation()); 96 | panel.setSize(Main.so.getScreenBounds().getSize()); 97 | panel.setAlwaysOnTop(true); 98 | panel.setVisible(true); 99 | } 100 | 101 | @Override 102 | public void paint(Graphics g) { 103 | super.paint(g); 104 | Graphics2D g2d = (Graphics2D) g; 105 | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 106 | g2d.setColor(c); 107 | 108 | Area fill = new Area(new Rectangle(new Point(0, 0), this.getSize())); 109 | fill.subtract(new Area(selectionBounds)); 110 | g2d.fill(fill); 111 | g2d.setColor(Color.RED); 112 | g2d.draw(selectionBounds); 113 | } 114 | 115 | public BufferedImage getImage() { 116 | return this.screenRobot.createScreenCapture(Main.so.getScreenBounds()).getSubimage( 117 | selectionBounds.x, 118 | selectionBounds.y, 119 | selectionBounds.width, 120 | selectionBounds.height); 121 | 122 | } 123 | 124 | public boolean isValidScreen() { 125 | return !(selectionBounds == null || selectionBounds.width <= 2 || selectionBounds.height <= 2); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/it/ksuploader/main/SocketUploader.java: -------------------------------------------------------------------------------- 1 | package it.ksuploader.main; 2 | 3 | 4 | import java.io.*; 5 | import java.net.InetSocketAddress; 6 | import java.net.SocketAddress; 7 | import java.nio.channels.FileChannel; 8 | import java.nio.channels.SocketChannel; 9 | import java.nio.channels.UnresolvedAddressException; 10 | import java.util.Arrays; 11 | import java.util.Observable; 12 | import java.util.Observer; 13 | 14 | public class SocketUploader implements Observer { 15 | private SocketChannel socketChannel; 16 | private String link; 17 | private String filePath; 18 | private DataOutputStream dos; 19 | private DataInputStream dis; 20 | private RandomAccessFile aFile; 21 | private FileChannel inChannel; 22 | 23 | private enum Messages { 24 | OK, 25 | BAD_SYN_STRING, 26 | WRONG_PASSWORD, 27 | FILE_TOO_LARGE, 28 | SERVER_FULL, 29 | UNKNOWN_ERROR 30 | } 31 | 32 | public boolean send(String fileName) { 33 | try { 34 | this.socketChannel = createChannel(Main.config.getIp(), Main.config.getPort()); 35 | this.dos = new DataOutputStream(socketChannel != null ? socketChannel.socket().getOutputStream() : null); 36 | this.dis = new DataInputStream(socketChannel.socket().getInputStream()); 37 | 38 | // send auth 39 | Main.myLog("[SocketUploader] Sending SYN"); 40 | aFile = new RandomAccessFile(filePath, "r"); 41 | long fileLength = aFile.length(); 42 | 43 | dos.writeUTF(Main.config.getPass() + "&" + fileLength + "&" + fileName); 44 | this.link = dis.readUTF(); 45 | Main.myLog("[SocketUploader] SYN reply: " + link); 46 | 47 | switch (Messages.valueOf(this.link)) { 48 | case OK: 49 | inChannel = aFile.getChannel(); 50 | 51 | long bytesSent = 0; 52 | long bfSize = Math.min(4096, fileLength); 53 | Main.myLog("Transfer started."); 54 | 55 | Main.dialog.show("Uploading...", "", false); 56 | Main.dialog.set(0); 57 | 58 | while (bytesSent < fileLength) { 59 | bytesSent += inChannel.transferTo(bytesSent, bfSize, socketChannel); 60 | Main.dialog.set((int) (100 * bytesSent / fileLength)); 61 | } 62 | Main.myLog("Transfer ended."); 63 | inChannel.close(); 64 | aFile.close(); 65 | Main.myLog("[SocketUploader] File closed."); 66 | 67 | Main.dialog.setWait(); 68 | break; 69 | case BAD_SYN_STRING: 70 | Main.dialog.show("Fatal Error!", "Bad SYN string", false); 71 | Main.myLog("[SocketUploader] Bad SYN string"); 72 | break; 73 | case FILE_TOO_LARGE: 74 | Main.myLog("[SocketUploader] File too large"); 75 | Main.dialog.fileTooLarge(); 76 | break; 77 | case SERVER_FULL: 78 | Main.myLog("[SocketUploader] Server Full"); 79 | Main.dialog.serverFull(); 80 | break; 81 | case WRONG_PASSWORD: 82 | Main.myLog("[SocketUploader] Wrong password, closed"); 83 | Main.dialog.wrongPassword(); 84 | return false; 85 | case UNKNOWN_ERROR: 86 | Main.dialog.show("Unknown Error!", "???", false); 87 | Main.myLog("[SocketUploader] Unknown Error!"); 88 | break; 89 | } 90 | // return link 91 | Main.myLog("[SocketUploader] Waiting link..."); 92 | this.link = dis.readUTF(); 93 | Main.myLog("[SocketUploader] Returned link: " + link); 94 | Main.dialog.destroy(); 95 | 96 | } catch (IOException e) { 97 | e.printStackTrace(); 98 | Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 99 | return false; 100 | } finally { 101 | try { 102 | if (inChannel != null) inChannel.close(); 103 | if (aFile != null) aFile.close(); 104 | if (dis != null) dis.close(); 105 | if (dos != null && socketChannel != null) dos.close(); 106 | if (socketChannel != null) socketChannel.close(); 107 | } catch (IOException e) { 108 | e.printStackTrace(); 109 | } 110 | } 111 | return true; 112 | } 113 | 114 | public void stopUpload() { 115 | try { 116 | if (inChannel != null) inChannel.close(); 117 | if (aFile != null) aFile.close(); 118 | if (dos != null && socketChannel != null) dos.close(); 119 | if (dis != null) dis.close(); 120 | if (socketChannel != null) socketChannel.close(); 121 | new File(Main.so.getTempDir(), "KStemp.zip").delete(); 122 | Main.dialog.show("Stopped...", "", false); 123 | } catch (IOException e) { 124 | e.printStackTrace(); 125 | Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 126 | } 127 | } 128 | 129 | private SocketChannel createChannel(String ip, int port) { 130 | try { 131 | SocketChannel sc = SocketChannel.open(); 132 | SocketAddress socketAddress = new InetSocketAddress(ip, port); 133 | sc.connect(socketAddress); 134 | Main.myLog("[SocketUploader] Reloaded socket"); 135 | return sc; 136 | } catch (IOException | UnresolvedAddressException e) { 137 | e.printStackTrace(); 138 | Main.dialog.connectionError(); 139 | Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 140 | return null; 141 | } 142 | } 143 | 144 | public void setFilePath(String filePath) { 145 | this.filePath = filePath; 146 | } 147 | 148 | public String getLink() { 149 | return link; 150 | } 151 | 152 | @Override 153 | public void update(Observable o, Object arg) { 154 | stopUpload(); 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/it/ksuploader/dialogs/PopupDialog.java: -------------------------------------------------------------------------------- 1 | package it.ksuploader.dialogs; 2 | 3 | import it.ksuploader.main.Main; 4 | 5 | import javax.swing.*; 6 | import java.awt.*; 7 | import java.awt.event.MouseAdapter; 8 | import java.awt.geom.RoundRectangle2D; 9 | import java.io.IOException; 10 | import java.net.URI; 11 | import java.net.URISyntaxException; 12 | import java.util.Arrays; 13 | import java.util.Observable; 14 | 15 | public class PopupDialog extends Observable { 16 | private JDialog dialogFrame; 17 | private JLabel headingLabel, messageLabel; 18 | private JProgressBar progressBar; 19 | private JButton xButton; 20 | private MouseAdapter m; 21 | 22 | public PopupDialog() { 23 | this.dialogFrame = new JDialog(); 24 | try { 25 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 26 | 27 | } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { 28 | Main.myLog(ex.toString()); 29 | } 30 | 31 | dialogFrame.setSize(200, 50); 32 | dialogFrame.setCursor(new Cursor(Cursor.HAND_CURSOR)); 33 | dialogFrame.setLayout(new GridBagLayout()); 34 | 35 | GridBagConstraints constraints = new GridBagConstraints(); 36 | 37 | // heading 38 | constraints.gridx = 0; 39 | constraints.gridy = 0; 40 | constraints.weightx = 1.0; 41 | constraints.weighty = 1.0; 42 | constraints.insets = new Insets(5, 5, 5, 5); 43 | 44 | headingLabel = new JLabel(); 45 | Font f = headingLabel.getFont(); 46 | f = new Font(f.getFontName(), Font.BOLD, f.getSize()); 47 | headingLabel.setFont(f); 48 | headingLabel.setOpaque(false); 49 | dialogFrame.add(headingLabel, constraints); 50 | dialogFrame.setUndecorated(true); 51 | 52 | // Bottone 53 | constraints.gridx = 1; 54 | constraints.gridy = 0; 55 | constraints.weightx = 0; 56 | constraints.weighty = 0; 57 | 58 | xButton = new JButton("X"); 59 | xButton.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); 60 | xButton.setMargin(new Insets(1, 4, 1, 4)); 61 | xButton.setFocusable(false); 62 | dialogFrame.add(xButton, constraints); 63 | 64 | // Messaggio 65 | constraints.gridx = 0; 66 | constraints.gridy = 1; 67 | constraints.weightx = 1.0; 68 | constraints.weighty = 1.0; 69 | constraints.gridwidth = 2; 70 | 71 | messageLabel = new JLabel(); 72 | dialogFrame.add(messageLabel, constraints); 73 | 74 | progressBar = new JProgressBar(); 75 | progressBar.setMaximum(100); 76 | progressBar.setMinimum(0); 77 | Dimension dim = new Dimension(); 78 | dim.width = 130; 79 | dim.height = 20; 80 | progressBar.setMinimumSize(dim); 81 | progressBar.setStringPainted(true); 82 | progressBar.setBorderPainted(true); 83 | dialogFrame.add(progressBar, constraints); 84 | 85 | xButton.addActionListener(e -> { 86 | this.destroy(); 87 | this.setChanged(); 88 | this.notifyObservers(); 89 | }); 90 | 91 | // Click nel JDialog per mandare all'url 92 | this.m = new MouseAdapter() { 93 | public void mouseClicked(java.awt.event.MouseEvent evt) { 94 | try { 95 | Desktop.getDesktop().browse(new URI(messageLabel.getText())); 96 | } catch (IOException | URISyntaxException e) { 97 | e.printStackTrace(); 98 | Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 99 | } 100 | } 101 | }; 102 | } 103 | 104 | public void cleanObservers() { 105 | this.deleteObservers(); 106 | } 107 | 108 | private void autoPosition() { 109 | // Per il posizionamento in basso a destra 110 | Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize(); 111 | // altezza taskbar 112 | Insets toolHeight = Toolkit.getDefaultToolkit().getScreenInsets(dialogFrame.getGraphicsConfiguration()); 113 | dialogFrame.setLocation(scrSize.width - 10 - dialogFrame.getWidth(), scrSize.height - 5 - toolHeight.bottom - dialogFrame.getHeight()); 114 | } 115 | 116 | private void gridProgressBar() { 117 | this.messageLabel.setVisible(false); 118 | this.progressBar.setVisible(true); 119 | } 120 | 121 | private void gridLabel() { 122 | this.progressBar.setVisible(false); 123 | this.messageLabel.setVisible(true); 124 | } 125 | 126 | private void setClickable(boolean b) { 127 | if (b) { 128 | dialogFrame.removeMouseListener(m); 129 | dialogFrame.addMouseListener(m); 130 | } else { 131 | dialogFrame.removeMouseListener(m); 132 | } 133 | 134 | } 135 | 136 | public void show(String header, String message, boolean cliclable) { 137 | this.setClickable(cliclable); 138 | this.gridLabel(); 139 | dialogFrame.setFocusableWindowState(false); 140 | dialogFrame.setVisible(true); 141 | headingLabel.setText(header); 142 | messageLabel.setText(message); 143 | dialogFrame.setAlwaysOnTop(true); 144 | 145 | if (message.length() > 30) { 146 | int width = (message.length() * 6); 147 | dialogFrame.setSize(width, 50); 148 | dialogFrame.setShape(new RoundRectangle2D.Double(1, 1, width, 50, 20, 20)); 149 | } else { 150 | dialogFrame.setSize(200, 50); 151 | dialogFrame.setShape(new RoundRectangle2D.Double(1, 1, 200, 50, 20, 20)); 152 | } 153 | this.autoPosition(); 154 | } 155 | 156 | public void set(int n) { 157 | this.gridProgressBar(); 158 | progressBar.setValue(n); 159 | progressBar.setString(n + " %"); 160 | } 161 | 162 | public void setWait() { 163 | show("Waiting link...", "", false); 164 | } 165 | 166 | public void wrongPassword() { 167 | show("Wrong password", "Correct the password server!", false); 168 | } 169 | 170 | public void serverFull() { 171 | show("Server full!", ":(", false); 172 | } 173 | 174 | public void fileTooLarge() { 175 | show("Server: file too large!", "This file exceeds the maximum size allowed", false); 176 | } 177 | 178 | public void connectionError() { 179 | show("Connection Error!", "Check your connection or credential", false); 180 | } 181 | 182 | public void destroy() { 183 | new Thread() { 184 | @Override 185 | public void run() { 186 | try { 187 | Thread.sleep(3000); 188 | for (float i = 1.00f; i >= 0; i -= 0.01f) { 189 | dialogFrame.setOpacity(i); 190 | Thread.sleep(15); 191 | } 192 | dialogFrame.setVisible(false); 193 | dialogFrame.setOpacity(1.00f); 194 | dialogFrame.setAlwaysOnTop(false); 195 | gridProgressBar(); 196 | } catch (InterruptedException e) { 197 | e.printStackTrace(); 198 | Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 199 | } 200 | } 201 | }.start(); 202 | } 203 | 204 | public void setButtonClickable(boolean b) { 205 | this.xButton.setEnabled(b); 206 | } 207 | } 208 | -------------------------------------------------------------------------------- /src/it/ksuploader/utils/MyKeyListener.java: -------------------------------------------------------------------------------- 1 | package it.ksuploader.utils; 2 | 3 | import it.ksuploader.main.Main; 4 | import org.jnativehook.GlobalScreen; 5 | import org.jnativehook.NativeHookException; 6 | import org.jnativehook.keyboard.NativeKeyEvent; 7 | import org.jnativehook.keyboard.NativeKeyListener; 8 | 9 | import java.util.HashMap; 10 | import java.util.HashSet; 11 | import java.util.logging.Handler; 12 | import java.util.logging.Level; 13 | import java.util.logging.Logger; 14 | 15 | import static it.ksuploader.main.Main.myLog; 16 | import static it.ksuploader.main.Main.st; 17 | 18 | public class MyKeyListener { 19 | public static HashMap fromKeyToName = new HashMap<>(); 20 | public HashSet keyHashScreen; 21 | public HashSet keyHashCScreen; 22 | public HashSet keyHashFile; 23 | public HashSet keyHashClipboard; 24 | public HashSet hashKeyGlobal; 25 | private NativeKeyListener gkl; 26 | 27 | public MyKeyListener() { 28 | 29 | hashKeyGlobal = new HashSet<>(); 30 | 31 | fromKeyToName.put(NativeKeyEvent.VC_ALT_L, "ALT-L"); 32 | fromKeyToName.put(NativeKeyEvent.VC_ALT_R, "ALT-R"); 33 | fromKeyToName.put(NativeKeyEvent.VC_SHIFT_L, "SHIFT-L"); 34 | fromKeyToName.put(NativeKeyEvent.VC_SHIFT_R, "SHIFT-R"); 35 | fromKeyToName.put(NativeKeyEvent.VC_CONTROL_L, "CTRL-L"); 36 | fromKeyToName.put(NativeKeyEvent.VC_CONTROL_R, "CTRL-R"); 37 | fromKeyToName.put(NativeKeyEvent.VC_0, "0"); 38 | fromKeyToName.put(NativeKeyEvent.VC_1, "1"); 39 | fromKeyToName.put(NativeKeyEvent.VC_2, "2"); 40 | fromKeyToName.put(NativeKeyEvent.VC_3, "3"); 41 | fromKeyToName.put(NativeKeyEvent.VC_4, "4"); 42 | fromKeyToName.put(NativeKeyEvent.VC_5, "5"); 43 | fromKeyToName.put(NativeKeyEvent.VC_6, "6"); 44 | fromKeyToName.put(NativeKeyEvent.VC_7, "7"); 45 | fromKeyToName.put(NativeKeyEvent.VC_8, "8"); 46 | fromKeyToName.put(NativeKeyEvent.VC_9, "9"); 47 | fromKeyToName.put(NativeKeyEvent.VC_A, "A"); 48 | fromKeyToName.put(NativeKeyEvent.VC_B, "B"); 49 | fromKeyToName.put(NativeKeyEvent.VC_C, "C"); 50 | fromKeyToName.put(NativeKeyEvent.VC_D, "D"); 51 | fromKeyToName.put(NativeKeyEvent.VC_E, "E"); 52 | fromKeyToName.put(NativeKeyEvent.VC_F, "F"); 53 | fromKeyToName.put(NativeKeyEvent.VC_G, "G"); 54 | fromKeyToName.put(NativeKeyEvent.VC_H, "H"); 55 | fromKeyToName.put(NativeKeyEvent.VC_I, "I"); 56 | fromKeyToName.put(NativeKeyEvent.VC_J, "J"); 57 | fromKeyToName.put(NativeKeyEvent.VC_K, "K"); 58 | fromKeyToName.put(NativeKeyEvent.VC_L, "L"); 59 | fromKeyToName.put(NativeKeyEvent.VC_M, "M"); 60 | fromKeyToName.put(NativeKeyEvent.VC_N, "N"); 61 | fromKeyToName.put(NativeKeyEvent.VC_O, "O"); 62 | fromKeyToName.put(NativeKeyEvent.VC_P, "P"); 63 | fromKeyToName.put(NativeKeyEvent.VC_Q, "Q"); 64 | fromKeyToName.put(NativeKeyEvent.VC_R, "R"); 65 | fromKeyToName.put(NativeKeyEvent.VC_S, "S"); 66 | fromKeyToName.put(NativeKeyEvent.VC_T, "T"); 67 | fromKeyToName.put(NativeKeyEvent.VC_U, "U"); 68 | fromKeyToName.put(NativeKeyEvent.VC_V, "V"); 69 | fromKeyToName.put(NativeKeyEvent.VC_W, "W"); 70 | fromKeyToName.put(NativeKeyEvent.VC_X, "X"); 71 | fromKeyToName.put(NativeKeyEvent.VC_Y, "Y"); 72 | fromKeyToName.put(NativeKeyEvent.VC_Z, "Z"); 73 | fromKeyToName.put(NativeKeyEvent.VC_SPACE, "SPACE"); 74 | fromKeyToName.put(0, "<"); 75 | 76 | gkl = new NativeKeyListener() { 77 | 78 | boolean hash1Ready = false; 79 | boolean hash2Ready = false; 80 | 81 | @Override 82 | public void nativeKeyPressed(NativeKeyEvent nke) { 83 | 84 | if (hash2Ready && !hashKeyGlobal.contains(nke.getKeyCode()) 85 | && MyKeyListener.fromKeyToName.containsKey(nke.getKeyCode())) { 86 | hashKeyGlobal.add(nke.getKeyCode()); 87 | System.out.println("[MyKeyListener] Max key combination reached"); 88 | } 89 | 90 | if ((hash1Ready) 91 | && !hashKeyGlobal.contains(nke.getKeyCode()) 92 | && MyKeyListener.fromKeyToName.containsKey(nke.getKeyCode()) 93 | && (keyHashScreen.contains(nke.getKeyCode()) || keyHashCScreen.contains(nke.getKeyCode()) 94 | || keyHashFile.contains(nke.getKeyCode()) || keyHashClipboard 95 | .contains(nke.getKeyCode()) 96 | 97 | )) { 98 | myLog("[MyKeyListener] Combination received"); 99 | hashKeyGlobal.add(nke.getKeyCode()); 100 | hash2Ready = true; 101 | } 102 | 103 | if (!hashKeyGlobal.contains(nke.getKeyCode()) 104 | && MyKeyListener.fromKeyToName.containsKey(nke.getKeyCode()) 105 | && keyHashScreen.contains(nke.getKeyCode()) || keyHashCScreen.contains(nke.getKeyCode()) 106 | || keyHashFile.contains(nke.getKeyCode()) || keyHashClipboard.contains(nke.getKeyCode())) { 107 | hashKeyGlobal.add(nke.getKeyCode()); 108 | hash1Ready = true; 109 | } 110 | } 111 | 112 | @Override 113 | public void nativeKeyReleased(NativeKeyEvent nke) { 114 | 115 | if ((hash1Ready || hash2Ready) 116 | && (keyHashScreen.contains(nke.getKeyCode()) || keyHashCScreen.contains(nke.getKeyCode()) 117 | || keyHashFile.contains(nke.getKeyCode()) || keyHashClipboard 118 | .contains(nke.getKeyCode()) 119 | 120 | )) { 121 | if (keyHashScreen.equals(hashKeyGlobal)) { 122 | clearKeyComb(); 123 | st.uploadPartialScreen(); 124 | } 125 | 126 | if (keyHashCScreen.equals(hashKeyGlobal)) { 127 | clearKeyComb(); 128 | st.uploadCompleteScreen(); 129 | } 130 | 131 | if (keyHashFile.equals(hashKeyGlobal)) { 132 | clearKeyComb(); 133 | st.uploadFile(); 134 | } 135 | 136 | if (keyHashClipboard.equals(hashKeyGlobal)) { 137 | clearKeyComb(); 138 | st.uploadClipboard(); 139 | } 140 | } 141 | 142 | clearKeyComb(); 143 | } 144 | 145 | private void clearKeyComb() { 146 | // System.out.println("Combination cleared"); 147 | hash1Ready = false; 148 | hash2Ready = false; 149 | hashKeyGlobal.clear(); 150 | } 151 | 152 | @Override 153 | public void nativeKeyTyped(NativeKeyEvent nke) { 154 | } 155 | 156 | }; 157 | 158 | Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName()); 159 | logger.setLevel(Level.OFF); 160 | Handler[] handlers = Logger.getLogger("").getHandlers(); 161 | for (Handler handler : handlers) { 162 | handler.setLevel(Level.OFF); 163 | } 164 | 165 | try { 166 | GlobalScreen.registerNativeHook(); 167 | } catch (NativeHookException ex) { 168 | myLog("Unable to initialize NativeHook"); 169 | myLog(ex.getMessage()); 170 | } 171 | 172 | GlobalScreen.addNativeKeyListener(gkl); 173 | loadKeys(); 174 | } 175 | 176 | public void loadKeys() { 177 | keyHashScreen = new HashSet<>(); 178 | keyHashCScreen = new HashSet<>(); 179 | keyHashFile = new HashSet<>(); 180 | keyHashClipboard = new HashSet<>(); 181 | for (int i : Main.config.getKeyScreen()) { 182 | keyHashScreen.add(i); 183 | } 184 | 185 | for (int i : Main.config.getKeyCScreen()) { 186 | keyHashCScreen.add(i); 187 | } 188 | for (int i : Main.config.getKeyFile()) { 189 | keyHashFile.add(i); 190 | } 191 | for (int i : Main.config.getKeyClipboard()) { 192 | keyHashClipboard.add(i); 193 | } 194 | } 195 | 196 | public void enableListener() { 197 | GlobalScreen.addNativeKeyListener(gkl); 198 | } 199 | 200 | public void disableListener() { 201 | GlobalScreen.removeNativeKeyListener(gkl); 202 | } 203 | 204 | } 205 | -------------------------------------------------------------------------------- /src/it/ksuploader/main/FtpUploader.java: -------------------------------------------------------------------------------- 1 | package it.ksuploader.main; 2 | 3 | import it.sauronsoftware.ftp4j.*; 4 | 5 | import javax.net.ssl.SSLContext; 6 | import javax.net.ssl.SSLSocketFactory; 7 | import javax.net.ssl.TrustManager; 8 | import javax.net.ssl.X509TrustManager; 9 | import java.io.File; 10 | import java.io.IOException; 11 | import java.security.KeyManagementException; 12 | import java.security.NoSuchAlgorithmException; 13 | import java.security.SecureRandom; 14 | import java.security.cert.X509Certificate; 15 | import java.util.Arrays; 16 | import java.util.Observable; 17 | import java.util.Observer; 18 | 19 | public class FtpUploader extends FTPClient implements Observer { 20 | private String link; 21 | private String filePath; 22 | 23 | public FtpUploader() { 24 | } 25 | 26 | public void setFilePath(File toWrite) { 27 | this.filePath = toWrite.getPath(); 28 | } 29 | 30 | public void setFilePath(String filePath) { 31 | this.filePath = filePath; 32 | } 33 | 34 | public boolean send() { 35 | 36 | Main.myLog("[FtpUploader] FtpesEnabled: " + Main.config.getFtpesEnabled()); 37 | if (Main.config.getFtpesEnabled()) { 38 | try { 39 | // Setting up tls connection 40 | Main.myLog("[FtpUploader] AcceptAllCertificates: " + Main.config.getAcceptAllCertificates()); 41 | if (Main.config.getAcceptAllCertificates()) { 42 | 43 | TrustManager[] trustManager = new TrustManager[]{new X509TrustManager() { 44 | @Override 45 | public X509Certificate[] getAcceptedIssuers() { 46 | return null; 47 | } 48 | 49 | @Override 50 | public void checkClientTrusted(X509Certificate[] certs, String authType) { 51 | } 52 | 53 | @Override 54 | public void checkServerTrusted(X509Certificate[] certs, String authType) { 55 | } 56 | }}; 57 | 58 | SSLContext sslContext; 59 | 60 | sslContext = SSLContext.getInstance("TLS"); 61 | sslContext.init(null, trustManager, new SecureRandom()); 62 | 63 | SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); 64 | this.setSSLSocketFactory(sslSocketFactory); 65 | } else { 66 | this.setSSLSocketFactory((SSLSocketFactory) SSLSocketFactory.getDefault()); 67 | } 68 | 69 | Main.myLog("[FtpUploader] SetSecurity: SECURITY_FTPES"); 70 | this.setSecurity(FTPClient.SECURITY_FTPES); 71 | 72 | } catch (NoSuchAlgorithmException | KeyManagementException e) { 73 | 74 | e.printStackTrace(); 75 | Main.dialog.show("Connection error", "Unable to connect to the server via ftpes", false); 76 | Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 77 | return false; 78 | } 79 | } 80 | 81 | // Connection 82 | try { 83 | this.connect(Main.config.getFtpAddr(), Main.config.getFtpPort()); 84 | } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e1) { 85 | e1.printStackTrace(); 86 | Main.dialog.show("Connection error", "Unable to connect to the server", false); 87 | Main.myErr(Arrays.toString(e1.getStackTrace()).replace(",", "\n")); 88 | return false; 89 | } 90 | Main.myLog("[FtpUploader] Connected to the ftp server"); 91 | 92 | // Login 93 | try { 94 | this.login(Main.config.getFtpUser(), Main.config.getFtpPass()); 95 | } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e1) { 96 | e1.printStackTrace(); 97 | Main.myErr(Arrays.toString(e1.getStackTrace()).replace(",", "\n")); 98 | Main.dialog.show("Login error", "Unable to login to the server", false); 99 | return false; 100 | } 101 | 102 | // Change directory 103 | try { 104 | this.changeDirectory(Main.config.getFtpDir()); 105 | } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e1) { 106 | e1.printStackTrace(); 107 | Main.myErr(Arrays.toString(e1.getStackTrace()).replace(",", "\n")); 108 | Main.dialog.show("Error", "Unable to change directory", false); 109 | return false; 110 | } 111 | 112 | // Upload 113 | try { 114 | this.upload(new File(filePath), new MyTransferListener()); 115 | Main.myLog("[FtpUploader] File uploaded"); 116 | } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException | FTPDataTransferException | FTPAbortedException e1) { 117 | e1.printStackTrace(); 118 | Main.myErr(Arrays.toString(e1.getStackTrace()).replace(",", "\n")); 119 | Main.dialog.show("Upload aborted", "Upload was stopped!", false); 120 | return false; 121 | } 122 | 123 | // Link return 124 | try { 125 | this.link = Main.config.getFtpWebUrl() + new File(filePath).getName(); 126 | Main.myLog("[FtpUploader] Returning url: " + this.link); 127 | } catch (IllegalStateException e) { 128 | e.printStackTrace(); 129 | Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 130 | return false; 131 | } 132 | 133 | // Clean and Disconnect 134 | try { 135 | new File(filePath).delete(); 136 | this.disconnect(true); 137 | Main.myLog("[FtpUploader] Disconnected"); 138 | return true; 139 | } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) { 140 | e.printStackTrace(); 141 | Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 142 | Main.dialog.show("Disconnection error", "Error during the disconnection", false); 143 | return false; 144 | } 145 | 146 | } 147 | 148 | public String getLink() { 149 | return link; 150 | } 151 | 152 | @Override 153 | public void update(Observable o, Object arg) { 154 | stopUpload(); 155 | } 156 | 157 | private class MyTransferListener implements FTPDataTransferListener { 158 | 159 | long tot_trasf = 0; // in bytes 160 | 161 | public void started() { 162 | } 163 | 164 | public void transferred(int length) { 165 | 166 | Main.dialog.show("Uploading...", "", false); 167 | //Main.progressDialog.setUploader(this); 168 | int percentage_sent = (int) ((100 * (tot_trasf += length)) / new File(filePath).length()); 169 | Main.myLog("[FtpUploader] Sent: " + percentage_sent + "%"); 170 | Main.dialog.set(percentage_sent); 171 | } 172 | 173 | public void completed() { 174 | Main.dialog.destroy(); 175 | } 176 | 177 | public void aborted() { 178 | Main.myLog("Connessione ftp abortita"); 179 | } 180 | 181 | public void failed() { 182 | } 183 | 184 | } 185 | 186 | public void stopUpload() { 187 | try { 188 | this.abortCurrentDataTransfer(true); 189 | this.disconnect(true); 190 | Main.dialog.show("Stopped...", "", false); 191 | Main.myLog("Mi disconnetto dallo spazio ftp"); 192 | } catch (IllegalStateException | IOException | FTPIllegalReplyException | FTPException e) { 193 | Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 194 | } 195 | } 196 | 197 | } 198 | -------------------------------------------------------------------------------- /src/it/ksuploader/dialogs/SettingsDialog.java: -------------------------------------------------------------------------------- 1 | package it.ksuploader.dialogs; 2 | 3 | import it.ksuploader.main.Main; 4 | import it.ksuploader.utils.MyKeyListener; 5 | import org.jnativehook.GlobalScreen; 6 | import org.jnativehook.SwingDispatchService; 7 | import org.jnativehook.keyboard.NativeKeyEvent; 8 | import org.jnativehook.keyboard.NativeKeyListener; 9 | 10 | import javax.swing.*; 11 | import java.awt.event.ActionEvent; 12 | import java.awt.event.ActionListener; 13 | import java.io.File; 14 | import java.util.Arrays; 15 | import java.util.HashSet; 16 | 17 | import static it.ksuploader.main.Main.myLog; 18 | 19 | @SuppressWarnings("serial") 20 | public class SettingsDialog extends JDialog implements NativeKeyListener { 21 | private final JTextField ftpAddr, ftpPort, ftpDir, ftpWeburl, ftpUser, ftpPassw, srvAddr, srvPassw, srvPort; 22 | private final JCheckBox ftpEnabled, saveEnabled, startUpEnabled, ftpesEnabled, acceptCertificates; 23 | private JFileChooser saveDir; 24 | private final JButton btnScreen, btnCScreen, btnFile, btnClipboard; 25 | 26 | public SettingsDialog() { 27 | setDefaultCloseOperation(DISPOSE_ON_CLOSE); 28 | setTitle("Settings - r15"); 29 | setBounds(100, 100, 480, 330); 30 | setResizable(false); 31 | setModal(true); 32 | getContentPane().setLayout(null); 33 | 34 | GlobalScreen.setEventDispatcher(new SwingDispatchService()); 35 | 36 | ftpEnabled = new JCheckBox("Use FTP"); 37 | ftpEnabled.setBounds(6, 7, 130, 23); 38 | getContentPane().add(ftpEnabled); 39 | 40 | ftpEnabled.addActionListener(e -> update()); 41 | 42 | saveEnabled = new JCheckBox("Save a local copy of images"); 43 | saveEnabled.setBounds(237, 7, 200, 23); 44 | getContentPane().add(saveEnabled); 45 | 46 | saveEnabled.addActionListener(e -> { 47 | if (saveEnabled.isSelected()) { 48 | saveDir.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 49 | if (saveDir.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) 50 | saveDir.setSelectedFile(new File(".")); 51 | Main.myLog("[Settings] local save enabled"); 52 | } else { 53 | saveDir.setSelectedFile(new File(".")); 54 | Main.myLog("[Settings] local save disabled"); 55 | } 56 | }); 57 | 58 | ftpesEnabled = new JCheckBox("Use FTPES"); 59 | ftpesEnabled.setBounds(6, 33, 130, 23); 60 | getContentPane().add(ftpesEnabled); 61 | 62 | ftpesEnabled.addActionListener(new ActionListener() { 63 | @Override 64 | public void actionPerformed(ActionEvent e) { 65 | if (ftpesEnabled.isSelected()) 66 | acceptCertificates.setEnabled(true); 67 | else 68 | acceptCertificates.setEnabled(false); 69 | } 70 | }); 71 | 72 | startUpEnabled = new JCheckBox("Open at startup"); 73 | startUpEnabled.setBounds(237, 33, 150, 23); 74 | getContentPane().add(startUpEnabled); 75 | 76 | //startUpEnabled.addActionListener(e -> Main.startUpCheck()); 77 | 78 | JPanel panel = new JPanel(); 79 | panel.setBounds(0, 63, 474, 238); 80 | getContentPane().add(panel); 81 | panel.setLayout(null); 82 | 83 | JLabel labelFtpUser = new JLabel("FTP User"); 84 | labelFtpUser.setBounds(10, 111, 101, 14); 85 | panel.add(labelFtpUser); 86 | 87 | JLabel labelFtpAddr = new JLabel("FTP Address"); 88 | labelFtpAddr.setBounds(10, 11, 101, 14); 89 | panel.add(labelFtpAddr); 90 | 91 | JLabel labelFtpDir = new JLabel("FTP Directory"); 92 | labelFtpDir.setBounds(10, 61, 101, 14); 93 | panel.add(labelFtpDir); 94 | 95 | JLabel labelFtpWeburl = new JLabel("FTP Weburl"); 96 | labelFtpWeburl.setBounds(10, 86, 101, 14); 97 | panel.add(labelFtpWeburl); 98 | 99 | JLabel labelFtpPort = new JLabel("FTP Port"); 100 | labelFtpPort.setBounds(10, 36, 101, 14); 101 | panel.add(labelFtpPort); 102 | 103 | JLabel labelFtpPassw = new JLabel("FTP Password"); 104 | labelFtpPassw.setBounds(10, 136, 101, 14); 105 | panel.add(labelFtpPassw); 106 | 107 | ftpAddr = new JTextField(); 108 | ftpAddr.setBounds(100, 8, 127, 20); 109 | panel.add(ftpAddr); 110 | ftpAddr.setColumns(10); 111 | 112 | ftpPort = new JTextField(); 113 | ftpPort.setBounds(100, 33, 127, 20); 114 | panel.add(ftpPort); 115 | ftpPort.setColumns(10); 116 | 117 | ftpDir = new JTextField(); 118 | ftpDir.setBounds(100, 58, 127, 20); 119 | panel.add(ftpDir); 120 | ftpDir.setColumns(10); 121 | 122 | ftpWeburl = new JTextField(); 123 | ftpWeburl.setBounds(100, 83, 127, 20); 124 | panel.add(ftpWeburl); 125 | ftpWeburl.setColumns(10); 126 | 127 | ftpUser = new JTextField(); 128 | ftpUser.setBounds(100, 108, 127, 20); 129 | panel.add(ftpUser); 130 | ftpUser.setColumns(10); 131 | 132 | ftpPassw = new JTextField(); 133 | ftpPassw.setBounds(100, 133, 127, 20); 134 | panel.add(ftpPassw); 135 | ftpPassw.setColumns(10); 136 | 137 | acceptCertificates = new JCheckBox("Accept Certificates"); 138 | acceptCertificates.setBounds(98, 158, 127, 20); 139 | panel.add(acceptCertificates); 140 | 141 | acceptCertificates.addActionListener(e -> { 142 | }); 143 | 144 | JLabel labelSrvSrv = new JLabel("Server Address"); 145 | labelSrvSrv.setBounds(237, 11, 107, 14); 146 | panel.add(labelSrvSrv); 147 | 148 | JLabel labelSrvPassw = new JLabel("Server Password"); 149 | labelSrvPassw.setBounds(237, 36, 107, 14); 150 | panel.add(labelSrvPassw); 151 | 152 | JLabel labelSrvPort = new JLabel("Server Port"); 153 | labelSrvPort.setBounds(237, 61, 107, 14); 154 | panel.add(labelSrvPort); 155 | 156 | srvAddr = new JTextField(); 157 | srvAddr.setBounds(327, 8, 127, 20); 158 | panel.add(srvAddr); 159 | srvAddr.setColumns(10); 160 | 161 | srvPassw = new JTextField(); 162 | srvPassw.setBounds(327, 33, 127, 20); 163 | panel.add(srvPassw); 164 | srvPassw.setColumns(10); 165 | 166 | srvPort = new JTextField(); 167 | srvPort.setBounds(327, 58, 127, 20); 168 | panel.add(srvPort); 169 | srvPort.setColumns(10); 170 | 171 | JButton okButton = new JButton("OK"); 172 | okButton.setBounds(327, 204, 65, 23); 173 | panel.add(okButton); 174 | okButton.setActionCommand("OK"); 175 | 176 | okButton.addActionListener(e -> { 177 | Main.config.storeNewConfig(ftpWeburl.getText(), ftpDir.getText(), ftpPort.getText(), 178 | ftpPassw.getText(), ftpUser.getText(), ftpAddr.getText(), ftpEnabled.isSelected() + "", 179 | srvPassw.getText(), srvPort.getText(), srvAddr.getText(), saveEnabled.isSelected() + "", 180 | saveDir.getSelectedFile().getPath(), startUpEnabled.isSelected() + "", 181 | ftpesEnabled.isSelected() + "", acceptCertificates.isSelected() + ""); 182 | Main.startUpCheck(); 183 | dispose(); 184 | }); 185 | 186 | JButton cancelButton = new JButton("Cancel"); 187 | cancelButton.setBounds(402, 204, 65, 23); 188 | panel.add(cancelButton); 189 | cancelButton.setActionCommand("Cancel"); 190 | 191 | cancelButton.addActionListener(e -> setVisible(false)); 192 | 193 | btnScreen = new JButton("Change"); 194 | btnScreen.setBounds(327, 83, 127, 20); 195 | btnScreen.setFont(btnScreen.getFont().deriveFont(9f)); 196 | panel.add(btnScreen); 197 | 198 | btnScreen.addActionListener(e -> { 199 | enableListener(btnScreen); 200 | btnScreen.setEnabled(false); 201 | }); 202 | 203 | btnCScreen = new JButton("Change"); 204 | btnCScreen.setBounds(327, 108, 127, 20); 205 | btnCScreen.setFont(btnCScreen.getFont().deriveFont(9f)); 206 | panel.add(btnCScreen); 207 | 208 | btnCScreen.addActionListener(e -> { 209 | enableListener(btnCScreen); 210 | btnCScreen.setEnabled(false); 211 | }); 212 | 213 | btnFile = new JButton("Change"); 214 | btnFile.setBounds(327, 133, 127, 20); 215 | btnFile.setFont(btnFile.getFont().deriveFont(9f)); 216 | panel.add(btnFile); 217 | 218 | btnFile.addActionListener(e -> { 219 | enableListener(btnFile); 220 | btnFile.setEnabled(false); 221 | }); 222 | 223 | btnClipboard = new JButton("Change"); 224 | btnClipboard.setBounds(327, 158, 127, 20); 225 | btnClipboard.setFont(btnClipboard.getFont().deriveFont(9f)); 226 | panel.add(btnClipboard); 227 | 228 | btnClipboard.addActionListener(e -> { 229 | enableListener(btnClipboard); 230 | btnClipboard.setEnabled(false); 231 | }); 232 | 233 | JLabel lblFileShortcut = new JLabel("File shortcut"); 234 | lblFileShortcut.setBounds(237, 136, 80, 14); 235 | panel.add(lblFileShortcut); 236 | 237 | JLabel lblClipboard = new JLabel("Clipboard shortcut"); 238 | lblClipboard.setBounds(237, 161, 94, 14); 239 | panel.add(lblClipboard); 240 | 241 | JLabel lblAreaShortcut = new JLabel("Area shortcut"); 242 | lblAreaShortcut.setBounds(237, 86, 90, 14); 243 | panel.add(lblAreaShortcut); 244 | 245 | JLabel lblNewLabel = new JLabel("Desktop shortcut"); 246 | lblNewLabel.setBounds(237, 111, 87, 14); 247 | panel.add(lblNewLabel); 248 | } 249 | 250 | /* 251 | * LOADER + STATUS_UPDATER 252 | */ 253 | 254 | public void loadCurrentConfig() { 255 | try { 256 | this.ftpAddr.setText(Main.config.getFtpAddr()); 257 | this.ftpDir.setText(Main.config.getFtpDir()); 258 | this.ftpEnabled.setSelected(Main.config.getFtpEnabled()); 259 | this.ftpPassw.setText(Main.config.getFtpPass()); 260 | this.ftpPort.setText(Main.config.getFtpPort() + ""); 261 | this.ftpUser.setText(Main.config.getFtpUser()); 262 | this.ftpWeburl.setText(Main.config.getFtpWebUrl()); 263 | this.srvAddr.setText(Main.config.getIp()); 264 | this.srvPassw.setText(Main.config.getPass()); 265 | this.srvPort.setText(Main.config.getPort() + ""); 266 | this.saveEnabled.setSelected(Main.config.isSaveEnabled()); 267 | this.saveDir = new JFileChooser(); 268 | this.saveDir.setSelectedFile(new File(Main.config.getSaveDir())); 269 | this.ftpesEnabled.setSelected(Main.config.getFtpesEnabled()); 270 | this.acceptCertificates.setSelected(Main.config.getAcceptAllCertificates()); 271 | this.startUpEnabled.setSelected(Main.config.isStartUpEnabled()); 272 | } catch (Exception e) { 273 | e.printStackTrace(); 274 | Main.dialog.show("Config error", "Error during the config loading", false); 275 | Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n")); 276 | } 277 | 278 | update(); 279 | } 280 | 281 | private void update() { 282 | if (!this.ftpEnabled.isSelected()) { 283 | this.ftpAddr.setEnabled(false); 284 | this.ftpDir.setEnabled(false); 285 | this.ftpPassw.setEnabled(false); 286 | this.ftpPort.setEnabled(false); 287 | this.ftpUser.setEnabled(false); 288 | this.ftpWeburl.setEnabled(false); 289 | this.acceptCertificates.setEnabled(false); 290 | this.ftpesEnabled.setEnabled(false); 291 | 292 | this.srvAddr.setEnabled(true); 293 | this.srvPassw.setEnabled(true); 294 | this.srvPort.setEnabled(true); 295 | Main.myLog("[Settings] Server enabled, ftp disabled"); 296 | 297 | } else { 298 | this.ftpAddr.setEnabled(true); 299 | this.ftpDir.setEnabled(true); 300 | this.ftpPassw.setEnabled(true); 301 | this.ftpPort.setEnabled(true); 302 | this.ftpUser.setEnabled(true); 303 | this.ftpWeburl.setEnabled(true); 304 | this.ftpesEnabled.setEnabled(true); 305 | 306 | this.srvAddr.setEnabled(false); 307 | this.srvPassw.setEnabled(false); 308 | this.srvPort.setEnabled(false); 309 | Main.myLog("[Settings] Server disabled, ftp enabled"); 310 | } 311 | } 312 | 313 | /* 314 | * LISTENER 315 | */ 316 | private JButton callerBtn; 317 | 318 | private String newKey; 319 | private HashSet hashKeyGlobal = new HashSet<>(); 320 | private boolean hash1Ready = false; 321 | private boolean hash2Ready = false; 322 | 323 | private void enableListener(JButton btn) { 324 | System.out.println("[SettingsDialog] Listener enabled"); 325 | newKey = ""; 326 | hashKeyGlobal.clear(); 327 | hash1Ready = false; 328 | hash2Ready = false; 329 | this.callerBtn = btn; 330 | Main.keyListener.disableListener(); 331 | GlobalScreen.addNativeKeyListener(this); 332 | } 333 | 334 | private void disableListener(JButton btn) { 335 | System.out.println("[SettingsDialog] Listener disabled"); 336 | GlobalScreen.removeNativeKeyListener(this); 337 | Main.keyListener.enableListener(); 338 | btn.setEnabled(true); 339 | } 340 | 341 | @Override 342 | public void nativeKeyPressed(NativeKeyEvent arg0) { 343 | 344 | System.out.println("[SettingsDialog] Pressed: " + arg0.getKeyCode()); 345 | 346 | if (hash2Ready && !hashKeyGlobal.contains(arg0.getKeyCode()) 347 | && MyKeyListener.fromKeyToName.containsKey(arg0.getKeyCode())) { 348 | hashKeyGlobal.add(arg0.getKeyCode()); 349 | newKey += "+" + String.valueOf(arg0.getKeyCode()); 350 | callerBtn.setText(callerBtn.getText() + "+" + MyKeyListener.fromKeyToName.get(arg0.getKeyCode())); 351 | System.out.println("[MyKeyListener] Max key combination reached"); 352 | } 353 | 354 | if ((hash1Ready) && !hashKeyGlobal.contains(arg0.getKeyCode()) 355 | && MyKeyListener.fromKeyToName.containsKey(arg0.getKeyCode())) { 356 | myLog("[MyKeyListener] Combination received"); 357 | hashKeyGlobal.add(arg0.getKeyCode()); 358 | newKey += "+" + String.valueOf(arg0.getKeyCode()); 359 | callerBtn.setText(callerBtn.getText() + "+" + MyKeyListener.fromKeyToName.get(arg0.getKeyCode())); 360 | hash2Ready = true; 361 | } 362 | 363 | if (!hashKeyGlobal.contains(arg0.getKeyCode()) && MyKeyListener.fromKeyToName.containsKey(arg0.getKeyCode())) { 364 | hashKeyGlobal.add(arg0.getKeyCode()); 365 | newKey += String.valueOf(arg0.getKeyCode()); 366 | callerBtn.setText(MyKeyListener.fromKeyToName.get(arg0.getKeyCode())); 367 | hash1Ready = true; 368 | } 369 | 370 | } 371 | 372 | @Override 373 | public void nativeKeyReleased(NativeKeyEvent arg0) { 374 | if ((hash1Ready || hash2Ready)) { 375 | disableListener(callerBtn); 376 | 377 | if (callerBtn.equals(btnScreen)) { 378 | Main.config.setScreenKeys(newKey); 379 | } else if (callerBtn.equals(btnCScreen)) { 380 | Main.config.setCScreenKeys(newKey); 381 | } else if (callerBtn.equals(btnFile)) { 382 | Main.config.setFileKeys(newKey); 383 | } else if (callerBtn.equals(btnClipboard)) { 384 | Main.config.setClipboardKeys(newKey); 385 | } 386 | Main.st.updateKeys(); 387 | Main.keyListener.loadKeys(); 388 | } 389 | } 390 | 391 | @Override 392 | public void nativeKeyTyped(NativeKeyEvent arg0) { 393 | } 394 | } -------------------------------------------------------------------------------- /src/it/ksuploader/utils/LoadConfig.java: -------------------------------------------------------------------------------- 1 | package it.ksuploader.utils; 2 | 3 | 4 | import it.ksuploader.main.Main; 5 | 6 | import java.io.*; 7 | import java.util.Arrays; 8 | import java.util.Properties; 9 | 10 | @SuppressWarnings("serial") 11 | public class LoadConfig extends Properties { 12 | 13 | private String ip, pass, saveDir, ftpAddr, ftpUser, ftpPass, ftpDir, ftpWebUrl, tmp[]; 14 | private boolean saveEnabled, ftpEnabled, ftpesEnabled, startUpEnabled, acceptAllCertificates; 15 | private int port, ftpPort, keyScreen[], keyCScreen[], keyFile[], keyClip[]; 16 | 17 | public LoadConfig() { 18 | try { 19 | System.out.println("[LoadConfig] " + Main.so.getInstallDir().getPath() + "/client.properties"); 20 | 21 | if (!new File(Main.so.getInstallDir().getPath(), "client.properties").exists()) { 22 | this.store(new FileOutputStream(Main.so.getInstallDir().getPath() + "/client.properties"), null); 23 | } 24 | 25 | InputStream inputStream = new FileInputStream(Main.so.getInstallDir().getPath() + "//client.properties"); 26 | this.load(inputStream); 27 | inputStream.close(); 28 | 29 | boolean correct_config = false; 30 | 31 | // Server address 32 | if (this.getProperty("server_address") == null || this.getProperty("server_address").isEmpty()) { 33 | this.setProperty("server_address", "localhost"); 34 | correct_config = true; 35 | System.out.println("[LoadConfig] Setting default server_address"); 36 | } 37 | this.ip = this.getProperty("server_address"); 38 | 39 | // Socket password 40 | if (this.getProperty("password") == null || this.getProperty("password").isEmpty()) { 41 | this.setProperty("password", "pass"); 42 | correct_config = true; 43 | System.out.println("[LoadConfig] Setting default password"); 44 | } 45 | this.pass = this.getProperty("password"); 46 | 47 | // FTP enabled 48 | if (this.getProperty("ftp_enabled") == null || this.getProperty("ftp_enabled").isEmpty()) { 49 | this.setProperty("ftp_enabled", "false"); 50 | correct_config = true; 51 | System.out.println("[LoadConfig] Setting default ftp_enabled"); 52 | } 53 | this.ftpEnabled = Boolean.valueOf(this.getProperty("ftp_enabled")); 54 | 55 | // Socket port 56 | if (this.getProperty("port") == null || this.getProperty("port").isEmpty()) { 57 | this.setProperty("port", "4030"); 58 | correct_config = true; 59 | System.out.println("[LoadConfig] Setting default port"); 60 | } 61 | this.port = Integer.parseInt(this.getProperty("port")); 62 | 63 | // FTP address 64 | if (this.getProperty("ftp_address") == null || this.getProperty("ftp_address").isEmpty()) { 65 | this.setProperty("ftp_address", "ftp.mydomain.com"); 66 | correct_config = true; 67 | System.out.println("[LoadConfig] Setting default ftp_address"); 68 | } 69 | this.ftpAddr = this.getProperty("ftp_address"); 70 | 71 | // FTP user 72 | if (this.getProperty("ftp_user") == null || this.getProperty("ftp_user").isEmpty()) { 73 | this.setProperty("ftp_user", "user"); 74 | correct_config = true; 75 | System.out.println("[LoadConfig] Setting default ftp_user"); 76 | } 77 | this.ftpUser = this.getProperty("ftp_user"); 78 | 79 | // FTP password 80 | if (this.getProperty("ftp_password") == null || this.getProperty("ftp_password").isEmpty()) { 81 | this.setProperty("ftp_password", "pass"); 82 | correct_config = true; 83 | System.out.println("[LoadConfig] Setting default ftp_password"); 84 | } 85 | this.ftpPass = this.getProperty("ftp_password"); 86 | 87 | // FTP port 88 | if (this.getProperty("ftp_port") == null || this.getProperty("ftp_port").isEmpty()) { 89 | this.setProperty("ftp_port", "21"); 90 | correct_config = true; 91 | System.out.println("[LoadConfig] Setting default ftp_port"); 92 | } 93 | this.ftpPort = Integer.parseInt(this.getProperty("ftp_port")); 94 | 95 | // FTP directory 96 | if (this.getProperty("ftp_directory") == null || this.getProperty("ftp_directory").isEmpty()) { 97 | this.setProperty("ftp_directory", "subFolder/anotherFolder"); 98 | correct_config = true; 99 | System.out.println("[LoadConfig] Setting default ftp_directory"); 100 | } 101 | this.ftpDir = this.getProperty("ftp_directory"); 102 | 103 | // FTP weburl 104 | if (this.getProperty("ftp_weburl") == null || this.getProperty("ftp_weburl").isEmpty()) { 105 | this.setProperty("ftp_weburl", "http://mydomain.com/"); 106 | correct_config = true; 107 | System.out.println("[LoadConfig] Setting default ftp_weburl"); 108 | } 109 | this.ftpWebUrl = this.getProperty("ftp_weburl"); 110 | 111 | // Save enabled 112 | if (this.getProperty("save_enabled") == null || this.getProperty("save_enabled").isEmpty()) { 113 | this.setProperty("save_enabled", "false"); 114 | correct_config = true; 115 | System.out.println("[LoadConfig] Setting default save_enabled"); 116 | } 117 | this.saveEnabled = Boolean.valueOf(this.getProperty("save_enabled")); 118 | 119 | // Save directory 120 | if (this.getProperty("save_dir") == null || this.getProperty("save_dir").isEmpty()) { 121 | this.setProperty("save_dir", "."); 122 | correct_config = true; 123 | System.out.println("[LoadConfig] Setting default save_dir"); 124 | } 125 | this.saveDir = this.getProperty("save_dir"); 126 | 127 | // FTPES enabled 128 | if (this.getProperty("ftpes_enabled") == null || this.getProperty("ftpes_enabled").isEmpty()) { 129 | this.setProperty("ftpes_enabled", "false"); 130 | correct_config = true; 131 | System.out.println("[LoadConfig] Setting default ftpes_enabled"); 132 | } 133 | this.ftpesEnabled = Boolean.valueOf(this.getProperty("ftpes_enabled")); 134 | 135 | // StartUp enabled 136 | if (this.getProperty("open_at_startup_enabled") == null 137 | || this.getProperty("open_at_startup_enabled").isEmpty()) { 138 | this.setProperty("open_at_startup_enabled", "false"); 139 | correct_config = true; 140 | System.out.println("[LoadConfig] Setting default open_at_startup_enabled"); 141 | } 142 | this.startUpEnabled = Boolean.valueOf(this.getProperty("open_at_startup_enabled")); 143 | 144 | // accept all certificates 145 | if (this.getProperty("accept_all_certificates") == null 146 | || this.getProperty("accept_all_certificates").isEmpty()) { 147 | this.setProperty("accept_all_certificates", "false"); 148 | correct_config = true; 149 | System.out.println("[LoadConfig] Setting default accept_all_certificates"); 150 | } 151 | this.acceptAllCertificates = Boolean.valueOf(this.getProperty("accept_all_certificates")); 152 | 153 | // Keys for partial screen 154 | if (this.getProperty("key_screen") == null || this.getProperty("key_screen").isEmpty()) { 155 | this.setProperty("key_screen", "56+2"); 156 | correct_config = true; 157 | System.out.println("[LoadConfig] Setting default key_screen"); 158 | } 159 | tmp = null; 160 | tmp = this.getProperty("key_screen").split("[+]"); 161 | this.keyScreen = new int[tmp.length]; 162 | for (int i = 0; i < tmp.length; i++) { 163 | this.keyScreen[i] = Integer.parseInt(tmp[i]); 164 | } 165 | 166 | // Keys for complete screen 167 | if (this.getProperty("key_cscreen") == null || this.getProperty("key_cscreen").isEmpty()) { 168 | this.setProperty("key_cscreen", "56+3"); 169 | correct_config = true; 170 | System.out.println("[LoadConfig] Setting default key_cscreen"); 171 | } 172 | tmp = null; 173 | tmp = this.getProperty("key_cscreen").split("[+]"); 174 | this.keyCScreen = new int[tmp.length]; 175 | for (int i = 0; i < tmp.length; i++) { 176 | this.keyCScreen[i] = Integer.parseInt(tmp[i]); 177 | } 178 | 179 | // Keys for files 180 | if (this.getProperty("key_file") == null || this.getProperty("key_file").isEmpty()) { 181 | this.setProperty("key_file", "56+4"); 182 | correct_config = true; 183 | System.out.println("[LoadConfig] Setting default key_file"); 184 | } 185 | tmp = null; 186 | tmp = this.getProperty("key_file").split("[+]"); 187 | this.keyFile = new int[tmp.length]; 188 | for (int i = 0; i < tmp.length; i++) { 189 | this.keyFile[i] = Integer.parseInt(tmp[i]); 190 | } 191 | 192 | // keys for clipboard 193 | if (this.getProperty("key_clipboard") == null || this.getProperty("key_clipboard").isEmpty()) { 194 | this.setProperty("key_clipboard", "56+5"); 195 | correct_config = true; 196 | System.out.println("[LoadConfig] Setting default key_clipboard"); 197 | } 198 | tmp = null; 199 | tmp = this.getProperty("key_clipboard").split("[+]"); 200 | this.keyClip = new int[tmp.length]; 201 | for (int i = 0; i < tmp.length; i++) { 202 | this.keyClip[i] = Integer.parseInt(tmp[i]); 203 | } 204 | 205 | if (correct_config) { 206 | this.store(new FileOutputStream(Main.so.getInstallDir().getPath() + "//client.properties"), null); 207 | } 208 | 209 | } catch (Exception ex) { 210 | ex.printStackTrace(); 211 | Main.dialog.show("Config error", "Error during the config loading!", false); 212 | Main.myErr(Arrays.toString(ex.getStackTrace()).replace(",", "\n")); 213 | } 214 | 215 | } 216 | 217 | public void storeNewConfig(String ftpWeburl, String ftpDir, String ftport, String ftpPass, String ftpUser, 218 | String ftpAddr, String ftpEnabled, String srvPass, String srvPort, String srvAddr, String saveEnabled, 219 | String saveDir, String startUp, String ftpes, String allCertificates) { 220 | try { 221 | this.setProperty("ftp_weburl", ftpWeburl); 222 | this.setProperty("ftp_directory", ftpDir); 223 | this.setProperty("ftp_port", ftport); 224 | this.setProperty("ftp_password", ftpPass); 225 | this.setProperty("ftp_user", ftpUser); 226 | this.setProperty("ftp_address", ftpAddr); 227 | this.setProperty("ftp_enabled", ftpEnabled); 228 | this.setProperty("ftpes_enabled", ftpes); 229 | this.setProperty("password", srvPass); 230 | this.setProperty("port", srvPort); 231 | this.setProperty("server_address", srvAddr); 232 | this.setProperty("save_enabled", saveEnabled); 233 | this.setProperty("save_dir", saveDir); 234 | this.setProperty("open_at_startup_enabled", startUp); 235 | this.setProperty("accept_all_certificates", allCertificates); 236 | this.store(new FileOutputStream(Main.so.getInstallDir().getPath() + "//client.properties"), null); 237 | 238 | this.ip = this.getProperty("server_address"); 239 | this.pass = this.getProperty("password"); 240 | this.ftpEnabled = Boolean.valueOf(this.getProperty("ftp_enabled")); 241 | this.port = Integer.parseInt(this.getProperty("port")); 242 | this.ftpAddr = this.getProperty("ftp_address"); 243 | this.ftpUser = this.getProperty("ftp_user"); 244 | this.ftpPass = this.getProperty("ftp_password"); 245 | this.ftpPort = Integer.parseInt(this.getProperty("ftp_port")); 246 | this.ftpDir = this.getProperty("ftp_directory"); 247 | this.ftpWebUrl = this.getProperty("ftp_weburl"); 248 | this.saveEnabled = Boolean.valueOf(this.getProperty("save_enabled")); 249 | this.saveDir = this.getProperty("save_dir"); 250 | this.startUpEnabled = Boolean.valueOf(this.getProperty("open_at_startup_enabled")); 251 | this.ftpesEnabled = Boolean.valueOf(this.getProperty("ftpes_enabled")); 252 | this.acceptAllCertificates = Boolean.valueOf(this.getProperty("accept_all_certificates")); 253 | 254 | } catch (IOException ex) { 255 | ex.printStackTrace(); 256 | Main.myErr(Arrays.toString(ex.getStackTrace()).replace(",", "\n")); 257 | } 258 | 259 | } 260 | 261 | public boolean getFtpEnabled() { 262 | return ftpEnabled; 263 | } 264 | 265 | public String getFtpAddr() { 266 | return ftpAddr; 267 | } 268 | 269 | public String getFtpUser() { 270 | return ftpUser; 271 | } 272 | 273 | public String getFtpPass() { 274 | return ftpPass; 275 | } 276 | 277 | public int getFtpPort() { 278 | return ftpPort; 279 | } 280 | 281 | public String getFtpDir() { 282 | return ftpDir; 283 | } 284 | 285 | public String getFtpWebUrl() { 286 | return ftpWebUrl; 287 | } 288 | 289 | public String getIp() { 290 | return ip; 291 | } 292 | 293 | public String getPass() { 294 | return pass; 295 | } 296 | 297 | public int getPort() { 298 | return port; 299 | } 300 | 301 | public boolean isSaveEnabled() { 302 | return saveEnabled; 303 | } 304 | 305 | public String getSaveDir() { 306 | return saveDir; 307 | } 308 | 309 | public boolean getFtpesEnabled() { 310 | return ftpesEnabled; 311 | } 312 | 313 | public boolean isStartUpEnabled() { 314 | return startUpEnabled; 315 | } 316 | 317 | public boolean getAcceptAllCertificates() { 318 | return acceptAllCertificates; 319 | } 320 | 321 | public int[] getKeyScreen() { 322 | return keyScreen; 323 | } 324 | 325 | public int[] getKeyCScreen() { 326 | return keyCScreen; 327 | } 328 | 329 | public int[] getKeyFile() { 330 | return keyFile; 331 | } 332 | 333 | public int[] getKeyClipboard() { 334 | return keyClip; 335 | } 336 | 337 | public void setScreenKeys(String comb) { 338 | this.setProperty("key_screen", comb); 339 | try { 340 | this.store(new FileOutputStream(Main.so.getInstallDir().getPath() + "//client.properties"), null); 341 | } catch (IOException e) { 342 | e.printStackTrace(); 343 | } 344 | tmp = null; 345 | tmp = this.getProperty("key_screen").split("[+]"); 346 | this.keyScreen = new int[tmp.length]; 347 | for (int i = 0; i < tmp.length; i++) { 348 | this.keyScreen[i] = Integer.parseInt(tmp[i]); 349 | } 350 | } 351 | 352 | public void setCScreenKeys(String comb) { 353 | this.setProperty("key_cscreen", comb); 354 | try { 355 | this.store(new FileOutputStream(Main.so.getInstallDir().getPath() + "//client.properties"), null); 356 | } catch (IOException e) { 357 | e.printStackTrace(); 358 | } 359 | tmp = null; 360 | tmp = this.getProperty("key_cscreen").split("[+]"); 361 | this.keyCScreen = new int[tmp.length]; 362 | for (int i = 0; i < tmp.length; i++) { 363 | this.keyCScreen[i] = Integer.parseInt(tmp[i]); 364 | } 365 | } 366 | 367 | public void setFileKeys(String comb) { 368 | this.setProperty("key_file", comb); 369 | try { 370 | this.store(new FileOutputStream(Main.so.getInstallDir().getPath() + "//client.properties"), null); 371 | } catch (IOException e) { 372 | e.printStackTrace(); 373 | } 374 | tmp = null; 375 | tmp = this.getProperty("key_file").split("[+]"); 376 | this.keyFile = new int[tmp.length]; 377 | for (int i = 0; i < tmp.length; i++) { 378 | this.keyFile[i] = Integer.parseInt(tmp[i]); 379 | } 380 | } 381 | 382 | public void setClipboardKeys(String comb) { 383 | this.setProperty("key_clipboard", comb); 384 | try { 385 | this.store(new FileOutputStream(Main.so.getInstallDir().getPath() + "//client.properties"), null); 386 | } catch (IOException e) { 387 | e.printStackTrace(); 388 | } 389 | tmp = null; 390 | tmp = this.getProperty("key_clipboard").split("[+]"); 391 | this.keyClip = new int[tmp.length]; 392 | for (int i = 0; i < tmp.length; i++) { 393 | this.keyClip[i] = Integer.parseInt(tmp[i]); 394 | } 395 | } 396 | 397 | } 398 | -------------------------------------------------------------------------------- /src/it/ksuploader/main/SystemTrayMenu.java: -------------------------------------------------------------------------------- 1 | package it.ksuploader.main; 2 | 3 | 4 | import it.ksuploader.dialogs.SettingsDialog; 5 | import it.ksuploader.utils.MyKeyListener; 6 | import it.ksuploader.utils.Sound; 7 | import it.ksuploader.utils.Zipper; 8 | 9 | import javax.imageio.ImageIO; 10 | import javax.swing.*; 11 | import java.awt.*; 12 | import java.awt.datatransfer.Clipboard; 13 | import java.awt.datatransfer.DataFlavor; 14 | import java.awt.datatransfer.StringSelection; 15 | import java.awt.datatransfer.UnsupportedFlavorException; 16 | import java.io.File; 17 | import java.io.IOException; 18 | import java.io.PrintWriter; 19 | import java.net.URI; 20 | import java.net.URISyntaxException; 21 | import java.util.Arrays; 22 | import java.util.Random; 23 | 24 | import static java.awt.SystemTray.getSystemTray; 25 | import static java.awt.SystemTray.isSupported; 26 | 27 | public class SystemTrayMenu { 28 | 29 | private Clipboard clpbrd; 30 | private PopupMenu popupMenu; 31 | private final Sound suono; 32 | private SocketUploader socketUploader; 33 | private FtpUploader ftpup; 34 | private TrayIcon trayIcon; 35 | 36 | private MenuItem[] uploads; 37 | private MenuItem catturaArea; 38 | private MenuItem catturaDesktop; 39 | private MenuItem caricaFile; 40 | private MenuItem clipboard; 41 | private boolean capturing; 42 | 43 | public SystemTrayMenu() { 44 | try { 45 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 46 | 47 | } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { 48 | ex.printStackTrace(); 49 | Main.myErr(Arrays.toString(ex.getStackTrace()).replace(",", "\n")); 50 | } 51 | this.suono = new Sound(); 52 | this.uploads = new MenuItem[5]; 53 | 54 | Main.dialog.cleanObservers(); 55 | if (Main.config.getFtpEnabled()) { 56 | this.socketUploader = null; 57 | this.ftpup = new FtpUploader(); 58 | Main.dialog.addObserver(this.ftpup); 59 | } else { 60 | this.ftpup = null; 61 | this.socketUploader = new SocketUploader(); 62 | Main.dialog.addObserver(this.socketUploader); 63 | } 64 | 65 | for (int i = 0; i < uploads.length; i++) { 66 | uploads[i] = new MenuItem(); 67 | } 68 | 69 | if (isSupported()) { 70 | try { 71 | clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); 72 | SystemTray systemTray = getSystemTray(); 73 | trayIcon = new TrayIcon(new ImageIcon(SystemTrayMenu.class.getResource("/icon.png")).getImage(), "KSUploader"); 74 | trayIcon.setImageAutoSize(true); 75 | 76 | popupMenu = new PopupMenu(); 77 | catturaArea = new MenuItem(); 78 | catturaDesktop = new MenuItem(); 79 | caricaFile = new MenuItem(); 80 | clipboard = new MenuItem(); 81 | updateKeys(); 82 | MenuItem settings = new MenuItem("Settings"); 83 | MenuItem esci = new MenuItem("Quit"); 84 | 85 | popupMenu.add("Recent Uploads"); 86 | popupMenu.addSeparator(); 87 | popupMenu.addSeparator(); 88 | popupMenu.add(catturaArea); 89 | popupMenu.add(catturaDesktop); 90 | popupMenu.addSeparator(); 91 | popupMenu.add(caricaFile); 92 | popupMenu.add(clipboard); 93 | popupMenu.addSeparator(); 94 | popupMenu.add(settings); 95 | popupMenu.addSeparator(); 96 | popupMenu.add(esci); 97 | 98 | // Gestione voci menu 99 | catturaArea.addActionListener(e -> uploadPartialScreen()); 100 | catturaDesktop.addActionListener(e -> { 101 | try { 102 | Thread.sleep(320); 103 | uploadCompleteScreen(); 104 | } catch (InterruptedException e1) { 105 | e1.printStackTrace(); 106 | } 107 | }); 108 | caricaFile.addActionListener(e -> uploadFile()); 109 | clipboard.addActionListener(e -> uploadClipboard()); 110 | 111 | settings.addActionListener(e -> { 112 | SettingsDialog configPanel = new SettingsDialog(); 113 | configPanel.loadCurrentConfig(); 114 | configPanel.setVisible(true); 115 | FtpSocketSwitch(); 116 | }); 117 | 118 | esci.addActionListener(e -> { 119 | getSystemTray().remove(trayIcon); 120 | Main.startUpCheck(); 121 | System.exit(0); 122 | }); 123 | 124 | trayIcon.setPopupMenu(popupMenu); 125 | trayIcon.addActionListener(e -> uploadPartialScreen()); 126 | systemTray.add(trayIcon); 127 | } catch (AWTException ex) { 128 | ex.printStackTrace(); 129 | Main.myErr(Arrays.toString(ex.getStackTrace()).replace(",", "\n")); 130 | } 131 | } 132 | } 133 | 134 | private void FtpSocketSwitch() { 135 | Main.dialog.cleanObservers(); 136 | if (Main.config.getFtpEnabled()) { 137 | this.socketUploader = null; 138 | this.ftpup = new FtpUploader(); 139 | Main.dialog.cleanObservers(); 140 | Main.dialog.addObserver(this.ftpup); 141 | } else { 142 | this.ftpup = null; 143 | this.socketUploader = new SocketUploader(); 144 | Main.dialog.cleanObservers(); 145 | Main.dialog.addObserver(this.socketUploader); 146 | } 147 | } 148 | 149 | private void history(String link) { 150 | popupMenu.remove(uploads[uploads.length - 1]); 151 | 152 | System.arraycopy(uploads, 0, uploads, 1, uploads.length - 1); 153 | uploads[0] = new MenuItem(link); 154 | uploads[0].addActionListener(e -> { 155 | try { 156 | Desktop.getDesktop().browse(new URI(e.getActionCommand())); 157 | } catch (URISyntaxException | IOException ex) { 158 | ex.printStackTrace(); 159 | Main.myErr(Arrays.toString(ex.getStackTrace()).replace(",", "\n")); 160 | } 161 | }); 162 | popupMenu.insert(uploads[0], 2); 163 | } 164 | 165 | public void updateKeys() { 166 | catturaArea.setLabel(("Capture Area " + loadKey(Main.config.getKeyScreen()))); 167 | catturaDesktop.setLabel("Capture Desktop " + loadKey(Main.config.getKeyCScreen())); 168 | caricaFile.setLabel("Upload File " + loadKey(Main.config.getKeyFile())); 169 | clipboard.setLabel("Upload Clipboard " + loadKey(Main.config.getKeyClipboard())); 170 | } 171 | 172 | private String loadKey(int keyNumber[]) { 173 | StringBuilder ret = new StringBuilder("("); 174 | for (int e : keyNumber) { 175 | ret.append(MyKeyListener.fromKeyToName.get(e)).append("+"); 176 | } 177 | ret.replace(0, ret.length(), ret.substring(0, ret.length() - 1)); 178 | ret.append(")"); 179 | return ret.toString(); 180 | } 181 | 182 | public void uploadPartialScreen() { 183 | if (capturing) { 184 | return; 185 | } 186 | new Thread() { 187 | @Override 188 | public void run() { 189 | capturing = true; 190 | MyScreen partialScreen = new MyScreen(); 191 | capturing = false; 192 | if (!partialScreen.isValidScreen()) { 193 | Main.dialog.show("Upload Cancelled!", ":(", false); 194 | Main.dialog.destroy(); 195 | } else { 196 | if (Main.config.getFtpEnabled()) { 197 | try { 198 | 199 | File tempFile = new File(Main.so.getTempDir() + File.separator + System.currentTimeMillis() / 1000 + new Random().nextInt(999) + ".png"); 200 | 201 | if (Main.config.isSaveEnabled()) { 202 | ImageIO.write(partialScreen.getImage(), "png", new File(Main.config.getSaveDir() + File.separator + System.currentTimeMillis() / 1000 203 | + new Random().nextInt(99999) + ".png")); 204 | Main.myLog("[SocketUploader] MyScreen saved"); 205 | } 206 | 207 | ImageIO.write(partialScreen.getImage(), "png", tempFile); 208 | ftpup.setFilePath(tempFile); 209 | 210 | boolean res; 211 | res = ftpup.send(); 212 | if (res) { 213 | Main.dialog.show("Screenshot Caricato!", ftpup.getLink(), true); 214 | history(ftpup.getLink()); 215 | clpbrd.setContents(new StringSelection(ftpup.getLink()), null); 216 | tempFile.delete(); 217 | suono.run(); 218 | } 219 | } catch (IOException e) { 220 | e.printStackTrace(); 221 | } 222 | } else { 223 | 224 | File tempFile = new File(Main.so.getTempDir() + "/ksutemp.png"); 225 | try { 226 | if (Main.config.isSaveEnabled()) { 227 | ImageIO.write(partialScreen.getImage(), "png", new File(Main.config.getSaveDir() + File.separator + System.currentTimeMillis() / 1000 228 | + new Random().nextInt(999) + ".png")); 229 | Main.myLog("[SocketUploader] MyScreen saved"); 230 | } 231 | 232 | ImageIO.write(partialScreen.getImage(), "png", tempFile); 233 | socketUploader.setFilePath(tempFile.getPath()); 234 | 235 | boolean res; 236 | res = socketUploader.send("{0}.png"); 237 | if (res) { 238 | Main.dialog.show("Upload Completed!", socketUploader.getLink(), true); 239 | history(socketUploader.getLink()); 240 | clpbrd.setContents(new StringSelection(socketUploader.getLink()), null); 241 | suono.run(); 242 | tempFile.delete(); 243 | } 244 | } catch (IOException e) { 245 | e.printStackTrace(); 246 | } 247 | } 248 | } 249 | } 250 | }.start(); 251 | } 252 | 253 | public void uploadCompleteScreen() { 254 | if (capturing) { 255 | return; 256 | } 257 | new Thread() { 258 | @Override 259 | public void run() { 260 | try { 261 | boolean res; 262 | if (Main.config.getFtpEnabled()) { 263 | try { 264 | File tempFile = new File(Main.so.getTempDir() + File.separator + System.currentTimeMillis() / 1000 265 | + new Random().nextInt(999) + ".png"); 266 | 267 | if (Main.config.isSaveEnabled()) { 268 | ImageIO.write(new Robot().createScreenCapture(Main.so.getScreenBounds()), 269 | "png", 270 | new File(Main.config.getSaveDir() + File.separator + System.currentTimeMillis() / 1000 271 | + new Random().nextInt(999) + ".png")); 272 | Main.myLog("[SocketUploader] MyScreen saved"); 273 | } 274 | ImageIO.write(new Robot().createScreenCapture(Main.so.getScreenBounds()), "png", tempFile); 275 | 276 | ftpup.setFilePath(tempFile); 277 | 278 | res = ftpup.send(); 279 | if (res) { 280 | Main.dialog.show("Upload Completed!", ftpup.getLink(), true); 281 | history(ftpup.getLink()); 282 | clpbrd.setContents(new StringSelection(ftpup.getLink()), null); 283 | tempFile.delete(); 284 | suono.run(); 285 | } 286 | } catch (IOException e) { 287 | e.printStackTrace(); 288 | } 289 | // Se socket 290 | } else { 291 | 292 | File tempFile = new File(Main.so.getTempDir() + "/ksutemp.png"); 293 | 294 | try { 295 | ImageIO.write(new Robot().createScreenCapture(Main.so.getScreenBounds()), "png", tempFile); 296 | if (Main.config.isSaveEnabled()) { 297 | ImageIO.write(new Robot().createScreenCapture(Main.so.getScreenBounds()), "png", 298 | new File(Main.config.getSaveDir() + File.separator + System.currentTimeMillis() / 1000 + "" 299 | + new Random().nextInt(999) + ".png")); 300 | Main.myLog("[SocketUploader] MyScreen saved"); 301 | } 302 | 303 | socketUploader.setFilePath(tempFile.getPath()); 304 | res = socketUploader.send("{0}.png"); 305 | if (res) { 306 | Main.dialog.show("Upload Completed!", socketUploader.getLink(), true); 307 | history(socketUploader.getLink()); 308 | clpbrd.setContents(new StringSelection(socketUploader.getLink()), null); 309 | suono.run(); 310 | } 311 | tempFile.delete(); 312 | } catch (IOException e) { 313 | e.printStackTrace(); 314 | } 315 | } 316 | } catch (AWTException ex) { 317 | ex.printStackTrace(); 318 | Main.myErr(Arrays.toString(ex.getStackTrace()).replace(",", "\n")); 319 | } 320 | } 321 | }.start(); 322 | } 323 | 324 | public void uploadFile() { 325 | try { 326 | JFileChooser selFile = new JFileChooser(); 327 | selFile.setMultiSelectionEnabled(true); 328 | selFile.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); 329 | Action details = selFile.getActionMap().get("viewTypeDetails"); 330 | details.actionPerformed(null); 331 | if (selFile.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { 332 | new Thread() { 333 | @Override 334 | public void run() { 335 | boolean res = false; 336 | if (Main.config.getFtpEnabled()) { 337 | if (selFile.getSelectedFiles()[0].getName().toLowerCase().endsWith(".png") && selFile.getSelectedFiles().length == 1) { 338 | ftpup.setFilePath(selFile.getSelectedFiles()[0].getPath()); 339 | 340 | } else if (!selFile.getSelectedFiles()[0].getName().endsWith(".zip") || selFile.getSelectedFiles().length > 1) { 341 | Main.dialog.setButtonClickable(false); 342 | ftpup.setFilePath(Zipper.toZip("ftp", selFile.getSelectedFiles(), selFile.getSelectedFiles()[0].getParentFile().getPath())); 343 | Main.dialog.setButtonClickable(true); 344 | // Altrimenti se finisce con .zip O è uno solo 345 | } else if (selFile.getSelectedFiles()[0].getName().endsWith(".zip") && selFile.getSelectedFiles().length == 1) { 346 | ftpup.setFilePath(selFile.getSelectedFiles()[0].getPath()); 347 | } 348 | 349 | res = ftpup.send(); 350 | if (res) { 351 | Main.dialog.show("Upload Completed!", ftpup.getLink(), true); 352 | history(ftpup.getLink()); 353 | clpbrd.setContents(new StringSelection(ftpup.getLink()), null); 354 | suono.run(); 355 | } 356 | 357 | } else { 358 | 359 | if (selFile.getSelectedFiles().length > 1 || selFile.getSelectedFiles()[0].isDirectory()) { 360 | Main.dialog.setButtonClickable(false); 361 | socketUploader.setFilePath(Zipper.toZip("socket", selFile.getSelectedFiles(), selFile.getSelectedFiles()[0].getParentFile().getPath())); 362 | res = socketUploader.send("{0}.zip"); 363 | } else { 364 | socketUploader.setFilePath(selFile.getSelectedFile().getPath()); 365 | res = socketUploader.send(selFile.getSelectedFile().getName()); 366 | } 367 | 368 | if (res) { 369 | Main.dialog.show("Upload Completed!", socketUploader.getLink(), true); 370 | history(socketUploader.getLink()); 371 | clpbrd.setContents(new StringSelection(socketUploader.getLink()), null); 372 | suono.run(); 373 | } 374 | File f = new File(Main.so.getTempDir(), "KStemp.zip"); 375 | f.delete(); 376 | 377 | } 378 | } 379 | }.start(); 380 | } 381 | } catch (Exception ex) { 382 | ex.printStackTrace(); 383 | Main.myErr(Arrays.toString(ex.getStackTrace()).replace(",", "\n")); 384 | } 385 | } 386 | 387 | public void uploadClipboard() { 388 | new Thread() { 389 | @Override 390 | public void run() { 391 | boolean res; 392 | try { 393 | String clipboard = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor); 394 | String fileName = System.currentTimeMillis() / 1000 + "" + new Random().nextInt(999); 395 | File f = new File(Main.so.getTempDir() + File.separator + fileName + ".txt"); 396 | Main.myLog(f.getPath()); 397 | PrintWriter out = new PrintWriter(Main.so.getTempDir() + File.separator + fileName + ".txt"); 398 | out.println(clipboard); 399 | out.close(); 400 | 401 | if (Main.config.getFtpEnabled()) { 402 | ftpup.setFilePath(f); 403 | res = ftpup.send(); 404 | if (res) { 405 | Main.dialog.show("Upload Completed!", ftpup.getLink(), true); 406 | history(ftpup.getLink()); 407 | clpbrd.setContents(new StringSelection(ftpup.getLink()), null); 408 | suono.run(); 409 | } 410 | 411 | } else { 412 | 413 | socketUploader.setFilePath(f.getPath()); 414 | res = socketUploader.send("{0}.txt"); 415 | if (res) { 416 | Main.dialog.show("Upload Completed!", socketUploader.getLink(), true); 417 | history(socketUploader.getLink()); 418 | clpbrd.setContents(new StringSelection(socketUploader.getLink()), null); 419 | suono.run(); 420 | } 421 | f.delete(); 422 | } 423 | 424 | } catch (UnsupportedFlavorException | IOException ex) { 425 | ex.printStackTrace(); 426 | Main.dialog.show("Error!", "Error with clipboard!", false); 427 | Main.myErr(Arrays.toString(ex.getStackTrace()).replace(",", "\n")); 428 | } 429 | } 430 | }.start(); 431 | } 432 | } 433 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | --------------------------------------------------------------------------------