XoopsGallery: auto-refresh of page with photo upload?

neurophyre

Joined: 2003-01-05
Posts: 13
Posted: Fri, 2005-08-12 01:32

Hello all. I'm currently trying to hack XoopsGallery, which is based on the now-ancient 1.3.3.7 Gallery source tree, so that users can use the Gallery Remote mini-applet to upload files.

Surprisingly enough, I've got it mostly working just by pasting in drawApplet() from the 1.5 util.php, and the mini-applet code from includes/add_photos/add_applet_mini.inc! I can upload photos using the mini-applet and it works fine, tested in Safari and Firefox on OS X. This is really encouraging, as the other options (one by one by hand, upload a zipfile, or slurp a URL) are not nearly as friendly to novice users.

The one remaining problem I have is that the applet doesn't cause the main page, nor the popup window, to refresh like the regular upload forms do. I can't figure out how it's done in Gallery 1.5 either. I think it's done with javascript with the regular upload forms, but if somebody could give me a pointer as to how the parent window and/or the add_photos popup is forced to refresh by the Java mini-applet, I'd be really grateful. I'm on the verge of a great patch for XoopsGallery here, I think. A lot of Xoops users would be pleased. :)

 
neurophyre

Joined: 2003-01-05
Posts: 13
Posted: Sun, 2005-09-04 01:05

I've narrowed this down (I think) to add_photos_refresh.php never being opened in the following line in com/gallery/GalleryRemote/GRAppletMini.java:

getAppletContext().showDocument(new URL(getCodeBase().toString() + "add_photos_refresh.php"), "hack");

I added a test javascript alert in add_photos_refresh.php but it's never popping up, and of course the gallery is not being refreshed. I believe the URL is being malformed, since the gallery URL is embedded in XOOPS.

What I'm wondering is how, if possible, to run the applets from the command line. When I run it under OS X, I get:

$ java -jar GalleryRemoteApplet.jar
Failed to load Main-Class manifest attribute from GalleryRemoteApplet.jar

Any tips on this? I'd like to see the console output, if any.

 
neurophyre

Joined: 2003-01-05
Posts: 13
Posted: Sun, 2005-09-04 02:28

I've now grabbed the Gallery Remote source from cvs and Apache ant and have built a nightly with a log statement inserted before the add_photos_refresh.php line mentioned above.

However, the signjar portion of the build fails because I am lacking a keystore. When I substitute the GalleryRemoteAppletMini.jar file I built for the one I copied straight from Gallery 1.5 into my XOOPSGallery's java/ folder, the applet refuses to run and I get this message in the Java console:

Applet init
Applet start
Instanciating Gallery Remote...
java.security.AccessControlException: access denied (java.util.PropertyPermission com.apple.mrj.application.apple.menu.about.name write)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
at java.security.AccessController.checkPermission(AccessController.java:401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at java.lang.System.setProperty(System.java:654)
at com.gallery.GalleryRemote.GalleryRemote.setStaticProperties(GalleryRemote.java:192)
at com.gallery.GalleryRemote.GalleryRemote.createInstance(GalleryRemote.java:152)
at com.gallery.GalleryRemote.GRApplet.initGalleryRemote(GRApplet.java:59)
at com.gallery.GalleryRemote.GRApplet.start(GRApplet.java:32)
at sun.applet.AppletPanel.run(AppletPanel.java:391)
at java.lang.Thread.run(Thread.java:552)

Is this because the applet isn't signed? This is in Mozilla Firefox, OS X. My last post is sort of pointless because I've figured out how to get the Java console in Firefox on OS X, but I'm stuck again. I'd greatly appreciate any help from developers, or if you could just send me a GalleryRemoteAppletMini.jar with the following line inserted into GRAppletMini.java before line 149 (the add_photos_refresh.php line):

Log.log(Log.LEVEL_TRACE, MODULE, "Refresh URL: " + getCodeBase().toString() + "add_photos_refresh.php");

Basically I'm just trying to get a debugging statement printed to see what is wrong with the URL, if anything. add_photos_refresh.php is located (in XOOPSGallery) at www.domain.com/modules/xoopsgallery/add_photos_refresh.php.

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sun, 2005-09-04 03:17

If you run "ant create_keystore" it'll create a new keystore for yourself, then if you run "ant applet_jar" it'll successfully sign the jar. When you use the applet, it'll prompt you to accept the temporary signature you just created, and then you should be able to use the applet. Good luck!

 
neurophyre

Joined: 2003-01-05
Posts: 13
Posted: Sun, 2005-09-04 05:01

Thanks much, I'll try it out and report back. :)

 
neurophyre

Joined: 2003-01-05
Posts: 13
Posted: Sun, 2005-09-04 17:58

I've isolated and 'solved' the problem only to be presented with another.

In this block in GRAppletMini.java, gallery.getType() is indeed equal to Gallery.TYPE_APPLET, so my solution was to simply remove that test from the if statement, and now add_photos_refresh.php is loaded properly.

		if (! inProgress && hasHadPictures) {
			// probably finished uploading...
			try {
				// no update for G2 and for embedded applets (non-embedded applets are TYPE_STANDALONE)
				if (! (gallery.getComm(null) instanceof GalleryComm2_5) && gallery.getType() != Gallery.TYPE_APPLET) {
					getAppletContext().showDocument(new URL(getCodeBase().toString() + "add_photos_refresh.php"), "hack");
				}
			} catch (MalformedURLException e1) {
				Log.logException(Log.LEVEL_ERROR, MODULE, e1);
			}

			hasHadPictures = false;
		}

However, in add_photos_refresh.php which I just uploaded straight into my XOOPSGallery directory, parent.opener.hideProgressAndReload() isn't working because parent.opener points to add_photos.php and not view_album.php -- it's pointing to the window the applet is embedded in, not the window that opened that window. Same with parent.parent.opener (hey, I thought I'd give it a shot). This is true even though adding a test to add_photos.php shows that its opener points to view_album.php.

I'm one step closer, but still no go on getting the refresh to work right.

 
neurophyre

Joined: 2003-01-05
Posts: 13
Posted: Sun, 2005-09-04 18:29

SUCCESS.

I added a JS function _hideProgressAndReload() to add_photos.php which simply calls parent.opener.hideProgressAndReload(). Calling parent.opener._hideProgressAndReload() from add_photos_refresh.php causes the album to refresh. :)

I've made a terrible mess of my source directories, but I'll be packaging up a patch for XOOPSGallery 1.3.3.7 shortly, interested users can check the XOOPSGallery forums and bug tracker. :)