You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
---|
From: <ms...@us...> - 2009-11-24 11:27:16
|
Revision: 8 http://upapplet.svn.sourceforge.net/upapplet/?rev=8&view=rev Author: msjolin Date: 2009-11-24 11:27:09 +0000 (Tue, 24 Nov 2009) Log Message: ----------- Thumbnail.java, UpApplet.jar, UpFTP.java added Added Paths: ----------- lite 0.1/Thumbnail.java lite 0.1/UpApplet.jar lite 0.1/UpFTP.java Added: lite 0.1/Thumbnail.java =================================================================== --- lite 0.1/Thumbnail.java (rev 0) +++ lite 0.1/Thumbnail.java 2009-11-24 11:27:09 UTC (rev 8) @@ -0,0 +1,73 @@ +import java.awt.Image; +import java.io.File; +import com.sun.image.codec.jpeg.JPEGCodec; +import com.sun.image.codec.jpeg.JPEGImageEncoder; +import java.awt.image.BufferedImage; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class Thumbnail { + + ////////////// generate thumbnail ///////////////////////// + // thinking about adding notify() to this function, since later it is going + // to be make it multithreads. + public static boolean convertImage(File file) { + String prefix = file.getAbsolutePath().replaceAll("\\:", ""); + prefix = prefix.replaceAll("\\\\\\\\", "_"); + prefix = prefix.replaceAll("\\/", "_"); + prefix = prefix.replaceAll("\\\\", "_"); + + if(new File(System.getProperty("user.home").replaceAll("\\\\","\\/") + "/upapplet/" + prefix + "_" + file.getName()).isFile()){ + return true; + } + + try { + Image src = javax.imageio.ImageIO.read(file); + int width = src.getWidth(null); + int height = src.getHeight(null); + if (width < 50 || height < 50) { + if (height < 50 && width < 50) { + } else if (height < 50) { + double dd = (double) (width / 50); + dd = (double) (height / dd); + height = (int) (dd); + width = 50; + } else { + double dd = (double) (height / 50); + dd = (double) (width / dd); + width = (int) (dd); + height = 50; + } + } else { + if (width >= height) { + double dd = (double) (width / 50); + dd = (double) (height / dd); + height = (int) (dd); + width = 50; + } else { + double dd = (double) (height / 50); + dd = (double) (width / dd); + width = (int) (dd); + height = 50; + } + } + BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + tag.getGraphics().drawImage(src, 0, 0, width, height, null); + // the following code suits to windows platform, need to fix it for + // lunix and mac platform too, dunno how to implement + + FileOutputStream out = new FileOutputStream(System.getProperty("user.home").replaceAll("\\\\","\\/") + "/upapplet/" + prefix + "_" + file.getName()); + JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); + encoder.encode(tag); + out.close(); + return true; + } catch (IOException ex) { + Logger.getLogger(UpApplet.class.getName()).log(Level.SEVERE, null,ex); + return false; + } + + }// end of the convertImage function +}// end of the class + Added: lite 0.1/UpApplet.jar =================================================================== (Binary files differ) Property changes on: lite 0.1/UpApplet.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: lite 0.1/UpFTP.java =================================================================== --- lite 0.1/UpFTP.java (rev 0) +++ lite 0.1/UpFTP.java 2009-11-24 11:27:09 UTC (rev 8) @@ -0,0 +1,227 @@ + +/* + * This class needs to re-write to make it belong ourselves. + * The current version is modified from SimpleFTP. + */ +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.net.Socket; +import java.util.ArrayList; +import java.util.StringTokenizer; + +public class UpFTP { + /** + * According to your domain to set up the following parameters, the user and + * pass are used for testing only. remove that when release. + * */ + private String Host; + private int Port; + private String User; + private String Pass; + private Socket socket = null; + private BufferedReader reader = null; + private BufferedWriter writer = null; + private static boolean DEBUG = false; + + public UpFTP(ArrayList<File> List, String Host, int Port, String User, + String Pass) { + this.Host = Host; + this.Port = Port; + this.User = User; + this.Pass = Pass; + } + + public synchronized void connect() throws IOException { + if (socket != null) { + throw new IOException("It is already connected. Disconnect first."); + } + + socket = new Socket(Host, Port); + reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); + writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); + + String response = readLine(); + if (!response.startsWith("220 ")) { + throw new IOException( + "FTP received an unknown response when connecting to the FTP server: " + response); + } + + sendLine("USER " + User); + + response = readLine(); + if (!response.startsWith("331 ")) { + throw new IOException( + "FTP received an unknown response after sending the user: " + response); + } + + sendLine("PASS " + Pass); + + response = readLine(); + if (!response.startsWith("230 ")) { + throw new IOException( + "FTP was unable to log in with the supplied password: " + response); + } + // Now logged in. + System.out.println("Now logged in"); + }// end of connect function + + public synchronized void disconnect() throws IOException { + try { + sendLine("QUIT"); + } finally { + socket = null; + } + } + + /** + * Returns the working directory of the FTP server it is connected to. + */ + public synchronized String pwd() throws IOException { + sendLine("PWD"); + String dir = null; + String response = readLine(); + if (response.startsWith("257 ")) { + int firstQuote = response.indexOf('\"'); + int secondQuote = response.indexOf('\"', firstQuote + 1); + if (secondQuote > 0) { + dir = response.substring(firstQuote + 1, secondQuote); + } + } + return dir; + } + + /** + * Changes the working directory (like cd). Returns true if successful. + */ + public synchronized boolean cwd(String dir) throws IOException { + sendLine("CWD " + dir); + String response = readLine(); + return (response.startsWith("250 ")); + } + + /** + * Sends a file to be stored on the FTP server. Returns true if the file + * transfer was successful. The file is sent in passive mode to avoid NAT or + * firewall problems at the client end. + */ + public synchronized boolean stor(File file) throws IOException { + if (file.isDirectory()) { + throw new IOException("FTP cannot upload a directory."); + } + + String filename = file.getName(); + + return stor(new FileInputStream(file), filename); + } + + /** + * Sends a file to be stored on the FTP server. Returns true if the file + * transfer was successful. The file is sent in passive mode to avoid NAT or + * firewall problems at the client end. + */ + public synchronized boolean stor(InputStream inputStream, String filename) + throws IOException { + + BufferedInputStream input = new BufferedInputStream(inputStream); + + sendLine("PASV"); + String response = readLine(); + if (!response.startsWith("227 ")) { + throw new IOException("FTP could not request passive mode: " + response); + } + + String ip = null; + int port = -1; + int opening = response.indexOf('('); + int closing = response.indexOf(')', opening + 1); + if (closing > 0) { + String dataLink = response.substring(opening + 1, closing); + StringTokenizer tokenizer = new StringTokenizer(dataLink, ","); + try { + ip = tokenizer.nextToken() + "." + tokenizer.nextToken() + "." + tokenizer.nextToken() + "." + tokenizer.nextToken(); + port = Integer.parseInt(tokenizer.nextToken()) * 256 + Integer.parseInt(tokenizer.nextToken()); + } catch (Exception e) { + throw new IOException( + "FTP received bad data link information: " + response); + } + } + + sendLine("STOR " + filename); + + Socket dataSocket = new Socket(ip, port); + + response = readLine(); + //if (!response.startsWith("125 ")) { + if (!response.startsWith("150 ")) { + throw new IOException("FTP was not allowed to send the file: " + response); + } + + BufferedOutputStream output = new BufferedOutputStream(dataSocket.getOutputStream()); + byte[] buffer = new byte[4096]; + int bytesRead = 0; + while ((bytesRead = input.read(buffer)) != -1) { + output.write(buffer, 0, bytesRead); + } + output.flush(); + output.close(); + input.close(); + + response = readLine(); + return response.startsWith("226 "); + } + + /** + * Enter binary mode for sending binary files. + */ + public synchronized boolean bin() throws IOException { + sendLine("TYPE I"); + String response = readLine(); + return (response.startsWith("200 ")); + } + + /** + * Enter ASCII mode for sending text files. This is usually the default + * mode. Make sure you use binary mode if you are sending images or other + * binary data, as ASCII mode is likely to corrupt them. + */ + public synchronized boolean ascii() throws IOException { + sendLine("TYPE A"); + String response = readLine(); + return (response.startsWith("200 ")); + } + + private String readLine() throws IOException { + String line = reader.readLine(); + if (DEBUG) { + System.out.println("< " + line); + } + return line; + } + + /** + * Sends a raw command to the FTP server. + */ + private void sendLine(String line) throws IOException { + if (socket == null) { + throw new IOException("FTP is not connected."); + } + try { + writer.write(line + "\r\n"); + writer.flush(); + if (DEBUG) { + System.out.println("> " + line); + } + } catch (IOException e) { + socket = null; + throw e; + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mys...@us...> - 2009-11-09 21:19:18
|
Revision: 3 http://upapplet.svn.sourceforge.net/upapplet/?rev=3&view=rev Author: myselfzjp Date: 2009-11-09 21:19:06 +0000 (Mon, 09 Nov 2009) Log Message: ----------- Added Paths: ----------- version 0.0/test.txt Added: version 0.0/test.txt =================================================================== --- version 0.0/test.txt (rev 0) +++ version 0.0/test.txt 2009-11-09 21:19:06 UTC (rev 3) @@ -0,0 +1,7 @@ +This project is launched for education purpose, which is an assignment of course Applied Free Software at IT-University of Gothenburg. +This applet is under GPL and for commercial use please contact with me: mys...@gm... +This version 0.0 is more like a startups test, I dont recommand to download this. +next version 0.1 is to be released very soon. + +Thanks for your attention. +Come back soon! \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |