Skip to content

Commit

Permalink
Merge development branch
Browse files Browse the repository at this point in the history
  • Loading branch information
abythell committed Feb 6, 2015
2 parents 52e2ead + 52de893 commit 1ef0c72
Show file tree
Hide file tree
Showing 24 changed files with 209 additions and 104 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2015-02-06 Andrew Bythell abythell@ieee.org

* version 1.3
* return valid string filename after capture (efimovkd)
* support JNA 4.1 (efimovkd)
* removed depreciated functions (efimovkd)
* build releases with 'ant dist'

2014-11-06 Andrew Bythell abythell@ieee.org

* version 1.2
Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ library that by no means implements all of libgphoto2 features.

Build
---
To build this library you will need the Java 7 SDK and Apache Ant. Run 'ant' to
build ./dist/libgphoto2-jna.jar and ./dist/javadoc. To run tests, attach a camera and run
'ant test'.
To build this library you will need git, the Java 7 SDK, JNA, and Apache Ant:

Alternatively, you can open and build the library using the Netbeans IDE.
git clone https://github.com/angryelectron/libgphoto2-jna.git
cd libgphoto2-jna
ant
ant test # optional - attach camera first

Alternatively, you can open and build the library using the Netbeans IDE or
downlod a [binary
release](https://github.com/angryelectron/libgphoto2-jna/releases).

Use
---
Expand Down
14 changes: 14 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,18 @@
</copy>
</target>

<property name="version" value="1.3"/>

<target depends="jar,javadoc" name="dist">
<jar compress="${jar.compress}" basedir="${src.dir}" jarfile="${dist.dir}/${application.title}-${version}-sources.jar"/>
<jar compress="${jar.compress}" basedir="${test.src.dir}" jarfile="${dist.dir}/${application.title}-${version}-test.jar"/>
<jar compress="${jar.compress}" basedir="${dist.javadoc.dir}" jarfile="${dist.dir}/${application.title}-${version}-javadoc.jar"/>
<move file="${dist.dir}/${application.title}.jar" tofile="${dist.dir}/${application.title}-${version}.jar" />
<delete file="${dist.dir}/README.TXT" />
<copy file="README.md" todir="${dist.dir}" />
<zip destfile="${application.title}-${version}.zip">
<zipfileset dir="${dist.dir}" prefix="${application.title}-${version}" />
</zip>
</target>

</project>
18 changes: 12 additions & 6 deletions nbproject/build-impl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ is divided into following sections:
</and>
</condition>
<condition property="do.archive">
<not>
<istrue value="${jar.archive.disabled}"/>
</not>
<or>
<not>
<istrue value="${jar.archive.disabled}"/>
</not>
<istrue value="${not.archive.disabled}"/>
</or>
</condition>
<condition property="do.mkdist">
<and>
Expand Down Expand Up @@ -1224,11 +1227,14 @@ is divided into following sections:
</not>
</and>
</condition>
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
<condition else="" property="bug5101868workaround" value="*.java">
<matches pattern="1\.[56](\..*)?" string="${java.version}"/>
</condition>
<javadoc additionalparam="-J-Dfile.encoding=${file.encoding} ${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<fileset dir="${src.dir}" excludes="${bug5101868workaround},${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
Expand Down Expand Up @@ -1302,7 +1308,7 @@ is divided into following sections:
<mkdir dir="${build.test.results.dir}"/>
</target>
<target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
<j2seproject3:test testincludes="**/*Test.java"/>
<j2seproject3:test includes="${includes}" testincludes="**/*Test.java"/>
</target>
<target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
Expand Down
4 changes: 2 additions & 2 deletions nbproject/genfiles.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=8064a381@1.68.1.46
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=01c0fc33
nbproject/build-impl.xml.script.CRC32=71c965e5
nbproject/build-impl.xml.stylesheet.CRC32=5a01deb7@1.68.1.46
nbproject/build-impl.xml.script.CRC32=2bcdf3c5
nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
2 changes: 1 addition & 1 deletion src/com/angryelectron/gphoto2/GPhoto2.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public void close() {
*/
public String capture() throws IOException {
CameraFilePath path = captureImage();
return path.name.toString();
return new String(path.name);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/com/angryelectron/gphoto2/GPhoto2Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ private void validateResult(String msg, int rc) throws IOException {
private CameraWidget getParameterWidget(String param) throws IOException {
Pointer name = new Memory(param.length() + 1);
name.setString(0, param);
PointerByReference refChild = new PointerByReference();
int rc = gphoto2.gp_widget_get_child_by_name(cameraWidget, name, refChild);
CameraWidget[] childs = new CameraWidget[1];
int rc = gphoto2.gp_widget_get_child_by_name(cameraWidget, name, childs);
validateResult("gp_widget_get_child_by_name", rc);
return new Gphoto2Library.CameraWidget(refChild.getValue());
return childs[0];
}

/**
Expand Down Expand Up @@ -185,10 +185,10 @@ private void setParameterValue(CameraWidget paramWidget, String value) throws IO
* @throws IOException If the configuration cannot be read.
*/
public void readConfig() throws IOException {
PointerByReference refWidget = new PointerByReference();
int rc = gphoto2.gp_camera_get_config(camera, refWidget, context);
CameraWidget[] camWidg=new CameraWidget[1];
int rc = gphoto2.gp_camera_get_config(camera, camWidg, context);
validateResult("gp_camera_get_config", rc);
cameraWidget = new Gphoto2Library.CameraWidget(refWidget.getValue());
cameraWidget = camWidg[0];
}

/**
Expand Down
14 changes: 9 additions & 5 deletions src/com/angryelectron/libgphoto2/CameraAbilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* libphoto2-jna. If not, see <http://www.gnu.org/licenses/>.
*/
package com.angryelectron.libgphoto2;
import java.util.Arrays;
import java.util.List;

import com.sun.jna.Structure;
/**
* <i>native declaration : /usr/include/gphoto2/gphoto2-abilities-list.h:675</i><br>
Expand Down Expand Up @@ -112,15 +115,16 @@ public class CameraAbilities extends Structure {
public int reserved8;
public CameraAbilities() {
super();
initFieldOrder();
}
protected void initFieldOrder() {
setFieldOrder(new String[]{"model", "status", "port", "speed", "operations", "file_operations", "folder_operations", "usb_vendor", "usb_product", "usb_class", "usb_subclass", "usb_protocol", "library", "id", "device_type", "reserved2", "reserved3", "reserved4", "reserved5", "reserved6", "reserved7", "reserved8"});
}

public static class ByReference extends CameraAbilities implements Structure.ByReference {

};
public static class ByValue extends CameraAbilities implements Structure.ByValue {

};
}
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[]{"model", "status", "port", "speed", "operations", "file_operations", "folder_operations", "usb_vendor", "usb_product", "usb_class", "usb_subclass", "usb_protocol", "library", "id", "device_type", "reserved2", "reserved3", "reserved4", "reserved5", "reserved6", "reserved7", "reserved8"});
};
}
15 changes: 9 additions & 6 deletions src/com/angryelectron/libgphoto2/CameraFileInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* libphoto2-jna. If not, see <http://www.gnu.org/licenses/>.
*/
package com.angryelectron.libgphoto2;
import java.util.Arrays;
import java.util.List;

import com.sun.jna.Structure;
/**
* <i>native declaration : /usr/include/gphoto2/gphoto2-filesys.h:901</i><br>
Expand All @@ -32,10 +35,6 @@ public class CameraFileInfo extends Structure {
public CameraFileInfoAudio audio;
public CameraFileInfo() {
super();
initFieldOrder();
}
protected void initFieldOrder() {
setFieldOrder(new String[]{"preview", "file", "audio"});
}
/**
* @param preview C type : CameraFileInfoPreview<br>
Expand All @@ -47,12 +46,16 @@ public CameraFileInfo(CameraFileInfoPreview preview, CameraFileInfoFile file, Ca
this.preview = preview;
this.file = file;
this.audio = audio;
initFieldOrder();
}
public static class ByReference extends CameraFileInfo implements Structure.ByReference {

};
public static class ByValue extends CameraFileInfo implements Structure.ByValue {

};
}
@SuppressWarnings("rawtypes")
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[]{"preview", "file", "audio"});
};
}
16 changes: 10 additions & 6 deletions src/com/angryelectron/libgphoto2/CameraFileInfoAudio.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* libphoto2-jna. If not, see <http://www.gnu.org/licenses/>.
*/
package com.angryelectron.libgphoto2;
import java.util.Arrays;
import java.util.List;

import com.sun.jna.NativeLong;
import com.sun.jna.Structure;
/**
Expand Down Expand Up @@ -46,10 +49,6 @@ public class CameraFileInfoAudio extends Structure {
public byte[] type = new byte[64];
public CameraFileInfoAudio() {
super();
initFieldOrder();
}
protected void initFieldOrder() {
setFieldOrder(new String[]{"fields", "status", "size", "type"});
}
/**
* @param fields @see CameraFileInfoFields<br>
Expand All @@ -70,12 +69,17 @@ public CameraFileInfoAudio(int fields, int status, NativeLong size, byte type[])
if (type.length != this.type.length)
throw new IllegalArgumentException("Wrong array size !");
this.type = type;
initFieldOrder();
}
public static class ByReference extends CameraFileInfoAudio implements Structure.ByReference {

};
public static class ByValue extends CameraFileInfoAudio implements Structure.ByValue {

};
}
@SuppressWarnings("rawtypes")
@Override
protected List getFieldOrder() {
// TODO Auto-generated method stub
return Arrays.asList(new String[]{"fields", "status", "size", "type"});
};
}
15 changes: 10 additions & 5 deletions src/com/angryelectron/libgphoto2/CameraFileInfoFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* libphoto2-jna. If not, see <http://www.gnu.org/licenses/>.
*/
package com.angryelectron.libgphoto2;
import java.util.Arrays;
import java.util.List;

import com.angryelectron.libgphoto2.Gphoto2Library.time_t;
import com.sun.jna.NativeLong;
import com.sun.jna.Structure;
Expand Down Expand Up @@ -67,11 +70,14 @@ public class CameraFileInfoFile extends Structure {
public time_t mtime;
public CameraFileInfoFile() {
super();
initFieldOrder();
}
protected void initFieldOrder() {
setFieldOrder(new String[]{"fields", "status", "size", "type", "width", "height", "name", "permissions", "mtime"});
}
@SuppressWarnings("rawtypes")
@Override
protected List getFieldOrder() {
// TODO Auto-generated method stub
return Arrays.asList(new String[]{"fields", "status", "size", "type", "width", "height", "name", "permissions", "mtime"});
};

/**
* @param fields @see CameraFileInfoFields<br>
* < \brief Bitmask containing the set members.<br>
Expand Down Expand Up @@ -107,7 +113,6 @@ public CameraFileInfoFile(int fields, int status, NativeLong size, byte type[],
this.name = name;
this.permissions = permissions;
this.mtime = mtime;
initFieldOrder();
}
public static class ByReference extends CameraFileInfoFile implements Structure.ByReference {

Expand Down
15 changes: 10 additions & 5 deletions src/com/angryelectron/libgphoto2/CameraFileInfoPreview.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* libphoto2-jna. If not, see <http://www.gnu.org/licenses/>.
*/
package com.angryelectron.libgphoto2;
import java.util.Arrays;
import java.util.List;

import com.sun.jna.NativeLong;
import com.sun.jna.Structure;
/**
Expand Down Expand Up @@ -50,11 +53,14 @@ public class CameraFileInfoPreview extends Structure {
public int height;
public CameraFileInfoPreview() {
super();
initFieldOrder();
}
protected void initFieldOrder() {
setFieldOrder(new String[]{"fields", "status", "size", "type", "width", "height"});
}
@SuppressWarnings("rawtypes")
@Override
protected List getFieldOrder() {
// TODO Auto-generated method stub
return Arrays.asList(new String[]{"fields", "status", "size", "type", "width", "height"});
};

/**
* @param fields @see CameraFileInfoFields<br>
* < \brief Bitmask containing the set members.<br>
Expand All @@ -78,7 +84,6 @@ public CameraFileInfoPreview(int fields, int status, NativeLong size, byte type[
this.type = type;
this.width = width;
this.height = height;
initFieldOrder();
}
public static class ByReference extends CameraFileInfoPreview implements Structure.ByReference {

Expand Down
14 changes: 9 additions & 5 deletions src/com/angryelectron/libgphoto2/CameraFilePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* libphoto2-jna. If not, see <http://www.gnu.org/licenses/>.
*/
package com.angryelectron.libgphoto2;
import java.util.Arrays;
import java.util.List;

import com.sun.jna.Structure;
/**
* <i>native declaration : /usr/include/gphoto2/gphoto2-camera.h:1100</i><br>
Expand All @@ -36,11 +39,13 @@ public class CameraFilePath extends Structure {
public byte[] folder = new byte[1024];
public CameraFilePath() {
super();
initFieldOrder();
}
protected void initFieldOrder() {
setFieldOrder(new String[]{"name", "folder"});
}
@SuppressWarnings("rawtypes")
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[]{"name", "folder"});
};

/**
* @param name < \brief Name of the captured file.<br>
* C type : char[128]<br>
Expand All @@ -55,7 +60,6 @@ public CameraFilePath(byte name[], byte folder[]) {
if (folder.length != this.folder.length)
throw new IllegalArgumentException("Wrong array size !");
this.folder = folder;
initFieldOrder();
}
public static class ByReference extends CameraFilePath implements Structure.ByReference {

Expand Down
13 changes: 9 additions & 4 deletions src/com/angryelectron/libgphoto2/CameraFilesystemFuncs.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* libphoto2-jna. If not, see <http://www.gnu.org/licenses/>.
*/
package com.angryelectron.libgphoto2;
import java.util.Arrays;
import java.util.List;

import com.angryelectron.libgphoto2.Gphoto2Library.CameraFilesystemDeleteAllFunc;
import com.angryelectron.libgphoto2.Gphoto2Library.CameraFilesystemDeleteFileFunc;
import com.angryelectron.libgphoto2.Gphoto2Library.CameraFilesystemDirFunc;
Expand Down Expand Up @@ -63,11 +66,13 @@ public class CameraFilesystemFuncs extends Structure {
public Pointer[] unused = new Pointer[31];
public CameraFilesystemFuncs() {
super();
initFieldOrder();
}
protected void initFieldOrder() {
setFieldOrder(new String[]{"file_list_func", "folder_list_func", "put_file_func", "delete_all_func", "get_info_func", "set_info_func", "make_dir_func", "remove_dir_func", "get_file_func", "del_file_func", "storage_info_func", "unused"});
}
@SuppressWarnings("rawtypes")
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[]{"file_list_func", "folder_list_func", "put_file_func", "delete_all_func", "get_info_func", "set_info_func", "make_dir_func", "remove_dir_func", "get_file_func", "del_file_func", "storage_info_func", "unused"});
};

public static class ByReference extends CameraFilesystemFuncs implements Structure.ByReference {

};
Expand Down
Loading

0 comments on commit 1ef0c72

Please sign in to comment.