Permalink
Browse files

Initial export

  • Loading branch information...
0 parents commit ec9c9c3a8c672249b402df0decef65c51f7c215c espylacopa committed May 28, 2010
Showing with 4,719 additions and 0 deletions.
  1. +10 −0 .classpath
  2. +17 −0 .project
  3. +12 −0 .settings/org.eclipse.jdt.core.prefs
  4. +674 −0 COPYING
  5. +42 −0 src/net/sf/jcablib/CabConstants.java
  6. +166 −0 src/net/sf/jcablib/CabEntry.java
  7. +40 −0 src/net/sf/jcablib/CabException.java
  8. +1 −0 src/net/sf/jcablib/CabFile.java
  9. +191 −0 src/net/sf/jcablib/CabFileInputStream.java
  10. +108 −0 src/net/sf/jcablib/CabFolder.java
  11. +126 −0 src/net/sf/jcablib/MSZipInputStream.java
  12. +36 −0 src/org/jtomtom/Constant.java
  13. +563 −0 src/org/jtomtom/GlobalPositioningSystem.java
  14. +47 −0 src/org/jtomtom/InitialErrorRun.java
  15. +111 −0 src/org/jtomtom/JTomTomUtils.java
  16. +209 −0 src/org/jtomtom/JTomtom.java
  17. +50 −0 src/org/jtomtom/JTomtomException.java
  18. +143 −0 src/org/jtomtom/TomTomax.java
  19. +12 −0 src/org/jtomtom/conf/jtomtom.properties
  20. +6 −0 src/org/jtomtom/conf/logger.properties
  21. +103 −0 src/org/jtomtom/gui/JTomtomFenetre.java
  22. +120 −0 src/org/jtomtom/gui/PatienterDialog.java
  23. +107 −0 src/org/jtomtom/gui/TabGeneral.java
  24. +166 −0 src/org/jtomtom/gui/TabParametres.java
  25. +116 −0 src/org/jtomtom/gui/TabQuickFix.java
  26. +219 −0 src/org/jtomtom/gui/TabRadars.java
  27. +148 −0 src/org/jtomtom/gui/TabSauvegarde.java
  28. +34 −0 src/org/jtomtom/gui/action/ActionResult.java
  29. +254 −0 src/org/jtomtom/gui/action/MajQuickFixAction.java
  30. +240 −0 src/org/jtomtom/gui/action/MajRadarsAction.java
  31. +47 −0 src/org/jtomtom/gui/action/QuitterAction.java
  32. +195 −0 src/org/jtomtom/gui/action/SauvegardeAction.java
  33. BIN src/org/jtomtom/gui/resources/general.png
  34. BIN src/org/jtomtom/gui/resources/parametres.png
  35. BIN src/org/jtomtom/gui/resources/quickfix.png
  36. BIN src/org/jtomtom/gui/resources/radars.png
  37. BIN src/org/jtomtom/gui/resources/sauvegarde.png
  38. +40 −0 src/org/jtomtom/junit/AllTests.java
  39. +138 −0 src/org/jtomtom/junit/TestActions.java
  40. +112 −0 src/org/jtomtom/junit/TestGPS.java
  41. +55 −0 src/org/jtomtom/junit/TestJTTUtils.java
  42. +61 −0 src/org/jtomtom/junit/TestTomtomax.java
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="lib" path="log4j-1.2.16.jar"/>
+ <classpathentry kind="lib" path="iso9660.jar"/>
+ <classpathentry kind="lib" path="sabre.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jTomTom</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,12 @@
+#Thu May 06 19:20:32 CEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Oops, something went wrong.
@@ -0,0 +1,42 @@
+package net.sf.jcablib;
+/*
+* CabLib, a library for extracting MS cabinets
+* Copyright (C) 1999, 2002 David V. Himelright
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Library General Public
+* License as published by the Free Software Foundation; either
+* version 2 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Library General Public License for more details.
+*
+* You should have received a copy of the GNU Library General Public
+* License along with this library; if not, write to the
+* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+* Boston, MA 02111-1307, USA.
+*
+* David Himelright can be reached at:
+* <david@litfit.org>
+*/
+/**
+* Constants that are useful throughout the package
+* @author David Himelright <a href="mailto:david@litfit.org">david@litfit.org</a>
+*/
+public
+interface CabConstants {
+ // Constants -------------------
+ public static final int
+ MSCF = 0x4D534346; //hex value 'MSCF'
+ public static final short
+ kNoCompression = 0x0000,
+ kMszipCompression = 0x0001,
+ kQuantumCompression = 0x0002,
+ kLzxCompression = 0x0003,
+ kInvalidFolder = 0x000F,
+ kFlagHasPrev = 0x0001,
+ kFlagHasNext = 0x0002,
+ kFlagReserve = 0x0004;
+}
@@ -0,0 +1,166 @@
+package net.sf.jcablib;
+/*
+* CabLib, a library for extracting MS cabinets
+* Copyright (C) 1999, 2002 David V. Himelright
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Library General Public
+* License as published by the Free Software Foundation; either
+* version 2 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Library General Public License for more details.
+*
+* You should have received a copy of the GNU Library General Public
+* License along with this library; if not, write to the
+* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+* Boston, MA 02111-1307, USA.
+*
+* David Himelright can be reached at:
+* <david@litfit.org>
+*/
+import java.io.File;
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+* This object represents a file inside a Cabinet archive.
+* @author David Himelright <a href="mailto:david@litfit.org">david@litfit.org</a>
+*/
+public
+class CabEntry
+implements CabConstants {
+
+ private String mName;
+ private int mInflatedSize, //inflated_size,
+ mInflatedOffset, //inflated_offset,
+ mTimestamp;
+ private short mFolderIndex, // file control id (CAB_FILE_*)
+ mAttributes; // file attributes (CAB_ATTRIB_*)
+ private CabFolder mCabFolder;
+
+
+ public CabEntry(String inName, int inSize, int inOffset,
+ int inTimestamp, short inFolderIndex, short inAttributes,
+ CabFolder inCabFolder) {
+
+ mName = inName;
+ mInflatedSize = inSize;
+ mInflatedOffset = inOffset;
+ mTimestamp = inTimestamp;
+ mFolderIndex = inFolderIndex; // iFolder
+ mAttributes = inAttributes;
+ mCabFolder = inCabFolder;
+
+ mCabFolder.addEntry(this);
+ }
+
+ /**
+ * @return The name of the file this entry refers to, a DOS path.
+ */
+ public String getName() {
+ return mName;
+ }
+
+ /**
+ * @return Size of this entry when inflated
+ */
+ public int getInflatedSize() {
+ return mInflatedSize;
+ }
+
+ /**
+ * @return The compression method for this entry's folder as defined in CabConstants.
+ */
+ public short getMethod() {
+ return mCabFolder.getMethod();
+ }
+
+
+ public Date getTimestamp() {
+ return new Date(dosToJavaTime((long)mTimestamp));
+ }
+
+ /**
+ * @return The contents of the attributes field as a short.
+ */
+ public short getAttributes() {
+ return mAttributes;
+ }
+
+ /**
+ * @return The CabFolder which contains this entry.
+ */
+ public CabFolder getCabFolder() {
+ return mCabFolder;
+ }
+
+ public short getFolderIndex() {
+ return mFolderIndex;
+ }
+
+ /**
+ * @return The offset of this entry's file in this entry's folder when inflated.
+ */
+ public int getOffset() {
+ return mInflatedOffset;
+ }
+
+ /**
+ * @return True if compresson scheme is supported by this library.
+
+ public boolean canExtract() {
+ return folder.canExtract();
+ }*/
+
+ /**
+ * @return The file this entry is stored in.
+ */
+ public File getArchiveFile() {
+ return mCabFolder.getArchiveFile();
+ }
+
+ /**
+ * Converts DOS time to Java time (number of milliseconds since epoch)
+ * @param dosTime
+ * @return
+ */
+ private static final long dosToJavaTime(long dosTime) {
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.YEAR, (int) ((dosTime >> 25) & 0x7f) + 1980);
+ cal.set(Calendar.MONTH, (int) ((dosTime >> 21) & 0x0f) - 1);
+ cal.set(Calendar.DATE, (int) (dosTime >> 16) & 0x1f);
+ cal.set(Calendar.HOUR_OF_DAY, (int) (dosTime >> 11) & 0x1f);
+ cal.set(Calendar.MINUTE, (int) (dosTime >> 5) & 0x3f);
+ cal.set(Calendar.SECOND, (int) (dosTime << 1) & 0x3e);
+ cal.set(Calendar.MILLISECOND, 0);
+
+ return cal.getTimeInMillis();
+ }
+
+
+ /**
+ * Converts Java time to DOS time
+ * @param time
+ * @return
+ */
+ @SuppressWarnings("unused")
+ private static final long javaToDosTime(long time) {
+ Calendar cal = Calendar.getInstance();
+ cal.setTimeInMillis(time);
+
+ int year = cal.get(Calendar.YEAR);
+ if (year < 1980) {
+ return (1 << 21) | (1 << 16);
+ }
+ return (year - 1980) << 25
+ | (cal.get(Calendar.MONTH) + 1) << 21
+ | cal.get(Calendar.DAY_OF_MONTH) << 16
+ | cal.get(Calendar.HOUR_OF_DAY) << 11
+ | cal.get(Calendar.MINUTE) << 5
+ | cal.get(Calendar.SECOND) >> 1;
+ }
+
+}
@@ -0,0 +1,40 @@
+package net.sf.jcablib;
+/*
+* CabLib, a library for extracting MS cabinets
+* Copyright (C) 1999, 2002 David V. Himelright
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Library General Public
+* License as published by the Free Software Foundation; either
+* version 2 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Library General Public License for more details.
+*
+* You should have received a copy of the GNU Library General Public
+* License along with this library; if not, write to the
+* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+* Boston, MA 02111-1307, USA.
+*
+* David Himelright can be reached at:
+* <david@litfit.org>
+*/
+import java.io.*;
+/**
+* CabException is thrown by classes in the net.sf.jcablib package when format
+* errors and other strangeness happen.
+* @author David Himelright <a href="mailto:david@litfit.org">david@litfit.org</a>
+*/
+public
+class CabException
+extends IOException {
+ private static final long serialVersionUID = 1L;
+ public CabException() {
+ super();
+ }
+ public CabException(String s) {
+ super(s);
+ }
+}
@@ -0,0 +1 @@
+package net.sf.jcablib;/** CabLib, a library for extracting MS cabinets* Copyright (C) 1999, 2002 David V. Himelright** This library is free software; you can redistribute it and/or* modify it under the terms of the GNU Library General Public* License as published by the Free Software Foundation; either* version 2 of the License, or (at your option) any later version.** This library is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Library General Public License for more details.** You should have received a copy of the GNU Library General Public* License along with this library; if not, write to the* Free Software Foundation, Inc., 59 Temple Place - Suite 330,* Boston, MA 02111-1307, USA.** David Himelright can be reached at:* <david@litfit.org> */import java.io.*;import java.util.*;/*** This class presents cabinet files via the familar java.util.zip interface.* @author David Himelright <a href="mailto:david@litfit.org">david@litfit.org</a>*/publicclass CabFileimplements CabConstants { // Globals -------------------- public CabEntry[] entries; CabFolder[] folders; File mFile; // Cab data ------------------- public short cab_version, cab_folders, cab_files, cab_flags, cab_setid, //cab set id cab_icab; //zero-based cabinet number (huh???) public int cab_signature, //file signature 'MSCF' cab_header_checksum, cab_file_size, cab_folder_checksum, cab_entry_offset, //offset of first cab entry cab_file_checksum, file_size; public boolean hasprev = false, hasnext = false; String prevname, nextname, prevnum, nextnum; /** * @param inFile A reference to a Cabinet file. * @exception CabException When the file header is malformed. * @exception IOException thrown by the IO classes. */ public CabFile(File inFile) throws IOException { this.mFile = inFile; readHeader(); } /** * @param name A path to a Cabinet file. * @exception CabException When the file header is malformed. * @exception IOException thrown by the IO classes. */ public CabFile(String name) throws IOException { this(new File(name)); } /** * @exception CabException When the file header is malformed. * @exception IOException thrown by the IO classes. */ private synchronized void readHeader() throws IOException { RandomAccessFile raf = new RandomAccessFile(mFile, "r"); CabFolder crapFolder = new CabFolder(null, 0, (short)0, kInvalidFolder, -1); file_size = (int)raf.length(); //read HEADER cab_signature = raf.readInt(); cab_header_checksum = raf.readInt(); cab_file_size = Integer.reverseBytes(raf.readInt()); cab_folder_checksum = raf.readInt(); cab_entry_offset = Integer.reverseBytes(raf.readInt()); cab_file_checksum = raf.readInt(); cab_version = Short.reverseBytes(raf.readShort()); cab_folders = Short.reverseBytes(raf.readShort()); cab_files = Short.reverseBytes(raf.readShort()); cab_flags = Short.reverseBytes(raf.readShort()); cab_setid = Short.reverseBytes(raf.readShort()); cab_icab = Short.reverseBytes(raf.readShort()); //detect errors if(cab_signature != MSCF) throw new CabException(mFile.getName() + " has an invalid signature."); if(cab_files < 1 || cab_folders < 1) throw new CabException(mFile.getName() + " has less than zero files (invalid header)."); //read series data (if a cab is a part of an installer or series) if((kFlagHasPrev & cab_flags) == kFlagHasPrev) { this.hasprev = true; prevname = readCString(raf); prevnum = readCString(raf); } if((kFlagHasNext & cab_flags) == kFlagHasNext) { this.hasnext = true; nextname = readCString(raf); nextnum = readCString(raf); } if((kFlagReserve & cab_flags) == kFlagReserve) raf.seek(cab_entry_offset - (8 * cab_folders)); //read cabfolders (compressed chunks) folders = new CabFolder[cab_folders]; for(int i=0; i<cab_folders; i++) { folders[i] = new CabFolder(this.mFile, //self reference Integer.reverseBytes(raf.readInt()), //folder offset Short.reverseBytes(raf.readShort()), //folder data Short.reverseBytes(raf.readShort()), //folder compression method i); //folder number } //read entries entries = new CabEntry[cab_files]; raf.seek(cab_entry_offset); int inflated_size; int inflated_offset; short folder_ix; int timestamp; short attribs; String name; CabFolder cabfolder; for(int i=0; i<entries.length; i++) { inflated_size = Integer.reverseBytes(raf.readInt()); inflated_offset = Integer.reverseBytes(raf.readInt()); folder_ix = Short.reverseBytes(raf.readShort()); timestamp = Integer.reverseBytes(raf.readInt()); attribs = raf.readShort(); name = readCString(raf); if(folder_ix >= 0) cabfolder = folders[folder_ix]; else cabfolder = crapFolder; entries[i] = new CabEntry(name, inflated_size, inflated_offset, timestamp, folder_ix, attribs, cabfolder); } raf.close(); } /** * @return the name of the cabinet file */ public String getName() { return mFile.getName(); } /** * @return the file */ public File getFile() { return mFile; } /** * Reads bytes til an empty byte is encountered, then returns them as a string. * XXXMaximum length is 256 characters, shouldn't be a problem for now, that's the * maximum length of a DOS path as I understand it. * @param in the DataInput to read your string from * @return The chunk of data before the next empty byte as a String. * @exception IOException Thrown by DataInput. */ public static String readCString(DataInput in) throws IOException { int i = 0; byte[] temp = new byte[256]; byte nil = 0x00; while(true) { temp[i] = in.readByte(); if(temp[i] == nil || i>255) break; i++; } return new String(temp).substring(0, i); } /** * Included for parity with java.util.zip.ZipFile interface. * @return an enumeration containing references to this file's CabEntries */ public Enumeration<CabEntry> entries() { return Collections.enumeration(Arrays.asList(entries)); } /** * @return all CabEntries in this file as an array */ public CabEntry[] getEntries() { return entries; } /** * unique to CabFile * @return an enumeration containing references to this file's CabFolders */ public Enumeration<CabFolder> folders() { return Collections.enumeration(Arrays.asList(folders)); } /** * @return all CabFolders in this file as an array */ public CabFolder[] getFolders() { return folders; } /** * Included for parity with java.util.zip.ZipFile interface. * @param name the name of the CabEntry to match * @return a CabEntry whose name matches the string provided */ public CabEntry getEntry(String name) { int i = 0; while(true) { if(entries[i].getName().equals(name)) return entries[i]; i++; } } /** * Included for parity with java.util.zip.ZipFile interface. * This method does nothing at all, the RandomAccessFile is opened and closed in * the readHeader method. */ public void close() {} /** * Create a new CabFileInputStream for reading the current entry. This is the * slow way of doing things, but it was added to provide an interface identical * to java.util.zip.ZipFile * @param ce retrieve an InputStream to this entry * @return an InputStream that returns uncompressed data * @exception CabException thrown by CabFileInputStream constructor * @exception IOException thrown by CabFileInputStream constructor */ public InputStream getInputStream(CabEntry ce) throws IOException { return new CabFileInputStream(ce); } /** * Create a new CabFileInputStream for reading the current entry. This is the * slow way of doing things, but it was added to provide an interface identical * to java.util.zip.ZipFile * @param cf retrieve an InputStream to this folder * @return an InputStream that returns uncompressed data * @exception CabException thrown by CabFileInputStream constructor * @exception IOException thrown by CabFileInputStream constructor */ public InputStream getInputStream(CabFolder cf) throws IOException { return new CabFileInputStream(cf); }}
Oops, something went wrong.

0 comments on commit ec9c9c3

Please sign in to comment.