/* */ package quicktime.app.view;
/* */
/* */ import java.io.File;
/* */ import java.io.FileNotFoundException;
/* */ import java.io.IOException;
/* */ import java.io.InputStream;
/* */ import java.security.AccessController;
/* */ import java.security.PrivilegedAction;
/* */ import java.util.Enumeration;
/* */ import java.util.Vector;
/* */ import quicktime.QTException;
/* */ import quicktime.QTSession;
/* */ import quicktime.io.OpenMovieFile;
/* */ import quicktime.io.QTFile;
/* */ import quicktime.std.StdQTException;
/* */ import quicktime.std.image.GraphicsImporter;
/* */ import quicktime.std.movies.Movie;
/* */ import quicktime.std.movies.MovieController;
/* */ import quicktime.std.movies.Track;
/* */ import quicktime.std.movies.media.DataRef;
/* */ import quicktime.std.movies.media.Media;
/* */ import quicktime.std.qtcomponents.MovieImporter;
/* */ import quicktime.util.QTHandle;
/* */
/* */ public final class QTFactory
/* */ {
/* 46 */ private static boolean apriori = QTSession.apriori();
/* */ private static Vector classPaths;
/* */ private static final boolean debug = false;
/* */
/* */ public static QTComponent makeQTComponent(Movie paramMovie)
/* */ throws QTException
/* */ {
/* 59 */ Movie localMovie = paramMovie;
/* */
/* 63 */ if ((QTSession.isCurrentOS(4)) && (QTSession.getJavaVersion() >= 65540))
/* */ {
/* 79 */ Object local1PrivelegedAction = new Object()
/* */ {
/* 65 */ QTComponent comp = null;
/* */
/* 67 */ void establish() { AccessController.doPrivileged(new PrivilegedAction() {
/* */ public Object run() {
/* 69 */ QTFactory.1PrivelegedAction.this.comp = new QTJavaCocoaCanvas(QTFactory.1PrivelegedAction.this.val$mov);
/* 70 */ return QTFactory.1PrivelegedAction.this.comp;
/* */ }
/* */ }); }
/* */
/* */ QTComponent getComponent()
/* */ {
/* 76 */ return this.comp;
/* */ }
/* */ };
/* 80 */ local1PrivelegedAction.establish();
/* 81 */ return local1PrivelegedAction.getComponent();
/* */ }
/* 83 */ return new QTJavaAWTCanvas(paramMovie);
/* */ }
/* */
/* */ public static QTComponent makeQTComponent(MovieController paramMovieController)
/* */ throws QTException
/* */ {
/* 95 */ MovieController localMovieController = paramMovieController;
/* */
/* 98 */ if ((QTSession.isCurrentOS(4)) && (QTSession.getJavaVersion() >= 65540))
/* */ {
/* 116 */ Object local2PrivelegedAction = new Object()
/* */ {
/* 100 */ QTComponent comp = null;
/* */
/* 102 */ void establish() { AccessController.doPrivileged(new PrivilegedAction() {
/* */ public Object run() {
/* */ try {
/* 105 */ QTFactory.2PrivelegedAction.this.comp = new QTJavaCocoaCanvas(QTFactory.2PrivelegedAction.this.val$controller); } catch (QTException localQTException) {
/* */ }
/* 107 */ return QTFactory.2PrivelegedAction.this.comp;
/* */ }
/* */ }); }
/* */
/* */ QTComponent getComponent()
/* */ {
/* 113 */ return this.comp;
/* */ }
/* */ };
/* 117 */ local2PrivelegedAction.establish();
/* 118 */ return local2PrivelegedAction.getComponent();
/* */ }
/* */
/* 122 */ return new QTJavaAWTCanvas(localMovieController);
/* */ }
/* */
/* */ public static QTComponent makeQTComponent(GraphicsImporter paramGraphicsImporter)
/* */ throws QTException
/* */ {
/* 133 */ GraphicsImporter localGraphicsImporter = paramGraphicsImporter;
/* 134 */ if ((QTSession.isCurrentOS(4)) && (QTSession.getJavaVersion() >= 65540))
/* */ {
/* 152 */ Object local3PrivelegedAction = new Object()
/* */ {
/* 138 */ QTComponent comp = null;
/* */
/* 140 */ void establish() { AccessController.doPrivileged(new PrivilegedAction() {
/* */ public Object run() {
/* 142 */ QTFactory.3PrivelegedAction.this.comp = new QTJavaCocoaCanvas(QTFactory.3PrivelegedAction.this.val$gi);
/* 143 */ return QTFactory.3PrivelegedAction.this.comp;
/* */ }
/* */ }); }
/* */
/* */ QTComponent getComponent()
/* */ {
/* 149 */ return this.comp;
/* */ }
/* */ };
/* 153 */ local3PrivelegedAction.establish();
/* 154 */ return local3PrivelegedAction.getComponent();
/* */ }
/* */
/* 158 */ return new QTJavaAWTCanvas(paramGraphicsImporter);
/* */ }
/* */
/* */ public static QTJComponent makeQTJComponent(GraphicsImporterDrawer paramGraphicsImporterDrawer)
/* */ throws QTException
/* */ {
/* 249 */ return new JQTCanvas(paramGraphicsImporterDrawer);
/* */ }
/* */
/* */ public static QTJComponent makeQTJComponent(MoviePlayer paramMoviePlayer)
/* */ throws QTException
/* */ {
/* 258 */ return new JQTCanvas(paramMoviePlayer);
/* */ }
/* */
/* */ public static File findInSystemPaths(String paramString)
/* */ throws IOException
/* */ {
/* 285 */ if (classPaths == null) buildClassPathsVector();
/* 286 */ return _doFISP(paramString, false);
/* */ }
/* */
/* */ public static void addDirectory(File paramFile)
/* */ throws IOException
/* */ {
/* 297 */ if (!paramFile.exists()) throw new IOException(paramFile + ",does not exist");
/* 298 */ if (!paramFile.isDirectory()) throw new IOException(paramFile + ",must be a directory");
/* */
/* 300 */ if (classPaths == null) buildClassPathsVector();
/* */
/* 302 */ String str = paramFile.getCanonicalPath();
/* 303 */ str = str.replace('/', File.separatorChar);
/* 304 */ if (str.charAt(str.length() - 1) != '/') str = str + "/";
/* */
/* 306 */ if (classPaths.contains(str)) return;
/* */
/* 308 */ classPaths.addElement(str);
/* */ }
/* */
/* */ public static void removeDirectory(File paramFile)
/* */ throws IOException
/* */ {
/* 317 */ if (!paramFile.exists()) return;
/* 318 */ if (!paramFile.isDirectory()) return;
/* */
/* 320 */ if (classPaths == null) return;
/* */
/* 322 */ String str = paramFile.getCanonicalPath();
/* 323 */ str = str.replace('/', File.separatorChar);
/* 324 */ if (str.charAt(str.length() - 1) != '/') str = str + "/";
/* */
/* 326 */ classPaths.removeElement(str);
/* */ }
/* */
/* */ public static File findAbsolutePath(String paramString)
/* */ throws IOException
/* */ {
/* 343 */ paramString = paramString.replace('/', File.separatorChar);
/* 344 */ if (classPaths == null) buildClassPathsVector();
/* */
/* 346 */ Enumeration localEnumeration = classPaths.elements();
/* 347 */ while (localEnumeration.hasMoreElements()) {
/* 348 */ String str1 = (String)localEnumeration.nextElement();
/* */
/* 350 */ String str2 = returnExistingFile(str1 + paramString);
/* 351 */ if (str2 != null)
/* */ {
/* 353 */ return new File(str2);
/* */ }
/* */ }
/* 356 */ throw new FileNotFoundException(paramString);
/* */ }
/* */
/* */ private static File _doFISP(String paramString, boolean paramBoolean)
/* */ throws IOException
/* */ {
/* 362 */ String str1 = paramString;
/* 363 */ int i = str1.length();
/* 364 */ while (i > 0)
/* */ {
/* 367 */ i = str1.substring(0, i).lastIndexOf('/');
/* 368 */ String str2 = (i == -1) || (i == 0) ? str1 : str1.substring(i + 1);
/* */
/* 372 */ for (int j = classPaths.size() - 1; j >= 0; j--) {
/* 373 */ String str3 = (String)classPaths.elementAt(j);
/* */
/* 375 */ String str4 = returnExistingFile(str3 + str2);
/* 376 */ if (str4 != null) return new File(str4);
/* */ }
/* */ }
/* */
/* 380 */ throw new FileNotFoundException(paramString);
/* */ }
/* */
/* */ private static void buildClassPathsVector() throws IOException {
/* 384 */ classPaths = new Vector(8);
/* */
/* 386 */ String str1 = System.getProperty("java.class.path");
/* 387 */ while (str1 != null) {
/* 388 */ int i = str1.indexOf(File.pathSeparatorChar);
/* 389 */ String str3 = null;
/* 390 */ if (i == -1) {
/* 391 */ str3 = str1;
/* 392 */ str1 = null;
/* */ }
/* */ else {
/* 395 */ str3 = str1.substring(0, i);
/* 396 */ str1 = str1.substring(i + 1);
/* */ }
/* */
/* 400 */ str3 = returnExistingFile(str3);
/* 401 */ if (str3 != null) {
/* 402 */ str3 = str3.substring(0, str3.lastIndexOf(File.separatorChar) + 1);
/* 403 */ if ((!classPaths.contains(str3)) && (str3.length() > 0))
/* */ {
/* 405 */ classPaths.addElement(str3);
/* */ }
/* */ }
/* */ }
/* 408 */ String str2 = System.getProperty("user.dir");
/* 409 */ str2 = returnExistingFile(str2);
/* */
/* 411 */ if (str2 != null)
/* 412 */ classPaths.addElement(str2);
/* */ }
/* */
/* */ private static String returnExistingFile(String paramString) throws IOException {
/* 416 */ File localFile = new File(paramString);
/* 417 */ if (!localFile.exists()) return null;
/* 418 */ if ((localFile.isDirectory()) &&
/* 419 */ (paramString.charAt(paramString.length() - 1) != File.separatorChar)) {
/* 420 */ return paramString + File.separatorChar;
/* */ }
/* 422 */ return localFile.getCanonicalPath();
/* */ }
/* */
/* */ private static String getFileExtension(String paramString) {
/* 426 */ int i = paramString.lastIndexOf('.');
/* 427 */ return i == -1 ? "" : paramString.substring(i + 1);
/* */ }
/* */
/* */ private static QTHandle readBytesIntoHandle(InputStream paramInputStream) throws IOException, QTException {
/* 431 */ byte[] arrayOfByte = new byte[paramInputStream.available()];
/* 432 */ int i = paramInputStream.read(arrayOfByte);
/* 433 */ if ((i < 0) || (i != arrayOfByte.length)) throw new IOException("Problem in reading bytes from InputStream");
/* 434 */ return new QTHandle(arrayOfByte);
/* */ }
/* */
/* */ private static GraphicsImporter openAsImage(QTFile paramQTFile) throws QTException {
/* */ try {
/* 439 */ return new GraphicsImporter(paramQTFile); } catch (StdQTException localStdQTException) {
/* */ }
/* 441 */ return null;
/* */ }
/* */
/* */ private static GraphicsImporter openAsImage(DataRef paramDataRef) throws QTException {
/* */ try {
/* 446 */ return new GraphicsImporter(paramDataRef); } catch (StdQTException localStdQTException) {
/* */ }
/* 448 */ return null;
/* */ }
/* */
/* */ private static GraphicsImporter importImage(DataRef paramDataRef) throws QTException {
/* */ try {
/* 453 */ return new GraphicsImporter(paramDataRef);
/* */ } catch (QTException localQTException) {
/* */ }
/* 456 */ return null;
/* */ }
/* */
/* */ private static Movie checkIfMovie(QTFile paramQTFile) throws QTException {
/* 460 */ return checkMovie(Movie.fromFile(OpenMovieFile.asRead(paramQTFile), 0, null));
/* */ }
/* */
/* */ private static Movie checkIfMovie(DataRef paramDataRef) throws QTException {
/* */ try {
/* 465 */ return checkMovie(Movie.fromDataRef(paramDataRef, 0));
/* */ } catch (QTException localQTException) {
/* */ }
/* 468 */ return null;
/* */ }
/* */
/* */ private static Movie checkMovie(Movie paramMovie) throws QTException {
/* */ try {
/* 473 */ if (paramMovie.getTrackCount() > 1) return paramMovie;
/* 474 */ Track localTrack = paramMovie.getIndTrack(1);
/* 475 */ Media localMedia = Media.getTrackMedia(localTrack);
/* 476 */ if (localMedia.getSampleCount() > 1) {
/* 477 */ paramMovie.setActive(true);
/* 478 */ return paramMovie;
/* */ }
/* */
/* 481 */ localMedia.disposeQTObject();
/* 482 */ localTrack.disposeQTObject();
/* 483 */ paramMovie.disposeQTObject(); } catch (QTException localQTException) {
/* */ }
/* 485 */ return null;
/* */ }
/* */
/* */ private static Movie openAsMovie(QTFile paramQTFile) throws QTException {
/* 489 */ OpenMovieFile localOpenMovieFile = OpenMovieFile.asRead(paramQTFile);
/* */ try {
/* 491 */ return Movie.fromFile(localOpenMovieFile); } catch (StdQTException localStdQTException) {
/* */ }
/* 493 */ return null;
/* */ }
/* */
/* */ private static Movie openAsMovie(DataRef paramDataRef) throws QTException {
/* */ try {
/* 498 */ return Movie.fromDataRef(paramDataRef, 1); } catch (QTException localQTException) {
/* */ }
/* 500 */ return null;
/* */ }
/* */
/* */ private static Movie importMovie(QTHandle paramQTHandle, int paramInt) throws QTException {
/* 504 */ if (paramInt == 0) throw new QTException(-2003); try
/* */ {
/* 506 */ MovieImporter localMovieImporter = new MovieImporter(paramInt);
/* 507 */ Movie localMovie = new Movie(1);
/* 508 */ localMovie.setDefaultDataRef(new DataRef(new QTHandle()));
/* 509 */ localMovieImporter.fromHandle(paramQTHandle, localMovie, null, 0, 1);
/* 510 */ return localMovie; } catch (QTException localQTException) {
/* */ }
/* 512 */ return null;
/* */ }
/* */ }
/* Location: Z:\System\Library\Java\Extensions\QTJava.zip
* Qualified Name: quicktime.app.view.QTFactory
* JD-Core Version: 0.6.2
*/