SourceForge: chungles/chungles: changeset 269:305a83feab61
Updated plugin to match 0.4 api
authoralex@sniffles
Sun Sep 13 16:11:15 2009 -0500 (2 months ago)
changeset 269305a83feab61
parent 268d6add6b2fd58
child 27022650bb441e5
Updated plugin to match 0.4 api
Bundled native library in JAR, loads at runtime
chungles-growl/build.xml
chungles-growl/libchungles-growl.jnilib
chungles-growl/src/org/chungles/growl/Main.java
     1.1 --- a/chungles-growl/build.xml	Sat Aug 08 21:24:55 2009 -0500
     1.2 +++ b/chungles-growl/build.xml	Sun Sep 13 16:11:15 2009 -0500
     1.3 @@ -18,6 +18,9 @@
     1.4  			<fileset dir="${basedir}">
     1.5  				<filename name="**/images/*"/>
     1.6  			</fileset>
     1.7 +			<fileset dir="${basedir}">
     1.8 +				<filename name="**/libchungles-growl.jnilib"/>
     1.9 +			</fileset>
    1.10  		</jar>
    1.11  	</target>
    1.12  		
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/chungles-growl/libchungles-growl.jnilib	Sun Sep 13 16:11:15 2009 -0500
     2.3 @@ -0,0 +1,1 @@
     2.4 +../chungles-growl-xcode/build/Release/libchungles-growl.jnilib
     2.5 \ No newline at end of file
     3.1 --- a/chungles-growl/src/org/chungles/growl/Main.java	Sat Aug 08 21:24:55 2009 -0500
     3.2 +++ b/chungles-growl/src/org/chungles/growl/Main.java	Sun Sep 13 16:11:15 2009 -0500
     3.3 @@ -24,9 +24,23 @@
     3.4  
     3.5  	public void init()
     3.6  	{
     3.7 -		Runtime.getRuntime().load("/Users/nalex/chungles-growl/build/Release/libchungles-growl.jnilib");
     3.8  		try
     3.9  		{
    3.10 +			// Load library from JAR to temp file, then load temp file as native lib
    3.11 +			InputStream fin=getClass().getClassLoader().getResource("libchungles-growl.jnilib").openStream();
    3.12 +			File tmp=File.createTempFile("libchunglesgrowl", "jnilib");
    3.13 +			FileOutputStream fout=new FileOutputStream(tmp);
    3.14 +			int lastread=0;
    3.15 +			byte[] buf=new byte[2046];
    3.16 +			while (lastread!=-1)
    3.17 +			{
    3.18 +				lastread=fin.read(buf, 0, 2046);
    3.19 +				if (lastread!=-1) fout.write(buf, 0, lastread);
    3.20 +			}
    3.21 +			fin.close();
    3.22 +			fout.close();
    3.23 +			
    3.24 +			Runtime.getRuntime().load(tmp.getAbsolutePath());
    3.25  			InputStream in=getClass().getClassLoader().getResourceAsStream("images/chungles-32.png");
    3.26  			int size=2009;
    3.27  			byte[] image=new byte[size];
    3.28 @@ -43,23 +57,18 @@
    3.29  		
    3.30  	}
    3.31  
    3.32 -	public void notification(int type, String message)
    3.33 +	public void shutdown()
    3.34 +	{
    3.35 +		
    3.36 +	}
    3.37 +	public void notify(int type, String message)
    3.38  	{
    3.39  		String notification;
    3.40  		if (type==StandardPlugin.NOTIFICATION_ERROR)
    3.41  			notification="Error";
    3.42 -		else if (type==StandardPlugin.NOTIFICATION_GENERAL)
    3.43 +		else
    3.44  			notification="General";
    3.45 -		else if (type==StandardPlugin.NOTIFICATION_FINISH_TRANSFER)
    3.46 -			notification="Finished Transfer";
    3.47 -		else
    3.48 -			notification="Start Transfer";
    3.49  		notify(notification,notification,message);
    3.50  	}
    3.51  
    3.52 -	public void shutdown()
    3.53 -	{
    3.54 -		
    3.55 -	}
    3.56 -
    3.57  }