summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2006-06-24 08:03:23 +0000
committerMarcus Meissner <marcus@jet.franken.de>2006-06-24 08:03:23 +0000
commitf22fefbb1b0aed4a1347b2ded7252d4905e00d0d (patch)
tree2820da23c34b861e24911a3c453fd7d40d9be164
parent1183e63a54e976a21e98d0b410cb2dfced0c28ac (diff)
downloadlibgphoto2-f22fefbb1b0aed4a1347b2ded7252d4905e00d0d.tar.gz
merged from trunk.
lots of bugfixes and buildfixes, no new features. git-svn-id: https://svn.code.sf.net/p/gphoto/code/branches/libgphoto2-2_2/libgphoto2@8953 67ed7778-7388-44ab-90cf-0a291f65f57c
-rw-r--r--bindings/csharp/AssemblyInfo.cs.in (renamed from bindings/csharp/AssemblyInfo.cs)2
-rw-r--r--bindings/csharp/Camera.cs4
-rw-r--r--bindings/csharp/CameraFile.cs3
-rw-r--r--bindings/csharp/ErrorCodes.cs2
-rw-r--r--bindings/csharp/Port.cs74
-rw-r--r--bindings/csharp/PortInfoList.cs16
-rw-r--r--bindings/csharp/README22
-rwxr-xr-xbindings/csharp/TestGphoto2Sharp2
-rw-r--r--bindings/csharp/TestGphoto2Sharp.cs45
-rw-r--r--bindings/csharp/check-camera-list.in59
-rw-r--r--bindings/csharp/libgphoto2-sharp.dll.config1
-rw-r--r--bindings/csharp/libgphoto2-sharp.pc.in11
12 files changed, 195 insertions, 46 deletions
diff --git a/bindings/csharp/AssemblyInfo.cs b/bindings/csharp/AssemblyInfo.cs.in
index f8fb8c4b3..5504c300b 100644
--- a/bindings/csharp/AssemblyInfo.cs
+++ b/bindings/csharp/AssemblyInfo.cs.in
@@ -23,7 +23,7 @@ using System.Runtime.CompilerServices;
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
-[assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("@LIBGPHOTO2_CURRENT@.@LIBGPHOTO2_REVISION@.*")]
// The following attributes specify the key for the sign of your assembly. See the
// .NET Framework documentation for more information about signing.
diff --git a/bindings/csharp/Camera.cs b/bindings/csharp/Camera.cs
index 5e53cb2b2..8cf7cffd8 100644
--- a/bindings/csharp/Camera.cs
+++ b/bindings/csharp/Camera.cs
@@ -207,7 +207,7 @@ namespace LibGPhoto2
public void Exit (Context context)
{
- Error.CheckError (gp_camera_init (this.Handle, context.Handle));
+ Error.CheckError (gp_camera_exit (this.Handle, context.Handle));
}
[DllImport ("libgphoto2.so")]
@@ -368,7 +368,7 @@ namespace LibGPhoto2
{
CameraText summary;
- Error.CheckError (Camera.gp_camera_get_summary(this.Handle, out summary, context.Handle));
+ Error.CheckError (gp_camera_get_summary(this.Handle, out summary, context.Handle));
return summary;
}
diff --git a/bindings/csharp/CameraFile.cs b/bindings/csharp/CameraFile.cs
index fb6e51fe1..d86293bdc 100644
--- a/bindings/csharp/CameraFile.cs
+++ b/bindings/csharp/CameraFile.cs
@@ -9,7 +9,8 @@ namespace LibGPhoto2
Normal,
Raw,
Audio,
- Exif
+ Exif,
+ MetaData
}
public class MimeTypes
diff --git a/bindings/csharp/ErrorCodes.cs b/bindings/csharp/ErrorCodes.cs
index 9d0b3b392..ac18675d7 100644
--- a/bindings/csharp/ErrorCodes.cs
+++ b/bindings/csharp/ErrorCodes.cs
@@ -79,7 +79,7 @@ namespace LibGPhoto2
[DllImport ("libgphoto2.so")]
internal static extern IntPtr gp_result_as_string (ErrorCode result);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern IntPtr gp_port_result_as_string (ErrorCode result);
}
diff --git a/bindings/csharp/Port.cs b/bindings/csharp/Port.cs
index 5fc5a32a2..19ee326f2 100644
--- a/bindings/csharp/Port.cs
+++ b/bindings/csharp/Port.cs
@@ -7,7 +7,9 @@ namespace LibGPhoto2
{
None = 0,
Serial = 1 << 0,
- USB = 1 << 2
+ USB = 1 << 2,
+ Disk = 1 << 3,
+ PTPIP = 1 << 4
}
public enum PortSerialParity
@@ -62,11 +64,19 @@ namespace LibGPhoto2
public int altsetting;
}
+ [StructLayout(LayoutKind.Sequential)]
+ public unsafe struct PortSettingsDisk
+ {
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)] public char[] mountpoint;
+ }
+
+
[StructLayout(LayoutKind.Explicit)]
public unsafe struct PortSettings
{
[FieldOffset(0)] public PortSettingsSerial serial;
[FieldOffset(0)] public PortSettingsUSB usb;
+ [FieldOffset(0)] public PortSettingsDisk disk;
}
#if false
@@ -83,59 +93,59 @@ namespace LibGPhoto2
PortPrivateLibrary *pl;
PortPrivateCore *pc;
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_new (out _Port *port);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_free (_Port *port);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_set_info (_Port *port, ref _PortInfo info);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_get_info (_Port *port, out _PortInfo info);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_open (_Port *port);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_close (_Port *port);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_read (_Port *port, [MarshalAs(UnmanagedType.LPTStr)] byte[] data, int size);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_write (_Port *port, [MarshalAs(UnmanagedType.LPTStr)] byte[] data, int size);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_get_settings (_Port *port, out PortSettings settings);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_set_settings (_Port *port, PortSettings settings);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_get_timeout (_Port *port, int *timeout);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_set_timeout (_Port *port, int timeout);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_get_pin (_Port *port, Pin pin, Level *level);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_set_pin (_Port *port, Pin pin, Level level);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern char* gp_port_get_error (_Port *port);
- //[DllImport ("libgphoto2.so")]
+ //[DllImport ("libgphoto2_port.so")]
//internal static extern int gp_port_set_error (_Port *port, const char *format, ...);
}
#endif
public class Port : Object
{
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_new (out IntPtr port);
public Port()
@@ -147,7 +157,7 @@ namespace LibGPhoto2
this.handle = new HandleRef (this, native);
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_free (HandleRef port);
protected override void Cleanup ()
@@ -155,7 +165,7 @@ namespace LibGPhoto2
Error.CheckError (gp_port_free (this.handle));
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_set_info (HandleRef port, ref _PortInfo info);
public void SetInfo (PortInfo info)
@@ -163,7 +173,7 @@ namespace LibGPhoto2
Error.CheckError (gp_port_set_info (this.Handle, ref info.Handle));
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_get_info (HandleRef port, out _PortInfo info);
public PortInfo GetInfo ()
@@ -175,7 +185,7 @@ namespace LibGPhoto2
return info;
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_open (HandleRef port);
public void Open ()
@@ -183,7 +193,7 @@ namespace LibGPhoto2
Error.CheckError (gp_port_open (this.Handle));
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_close (HandleRef port);
public void Close ()
@@ -191,7 +201,7 @@ namespace LibGPhoto2
Error.CheckError (gp_port_close (this.Handle));
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_read (HandleRef port, [MarshalAs(UnmanagedType.LPTStr)] byte[] data, int size);
public byte[] Read (int size)
@@ -203,7 +213,7 @@ namespace LibGPhoto2
return data;
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_write (HandleRef port, [MarshalAs(UnmanagedType.LPTStr)] byte[] data, int size);
public void Write (byte[] data)
@@ -212,7 +222,7 @@ namespace LibGPhoto2
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_set_settings (HandleRef port, PortSettings settings);
public void SetSettings (PortSettings settings)
@@ -220,7 +230,7 @@ namespace LibGPhoto2
Error.CheckError (gp_port_set_settings (this.Handle, settings));
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_get_settings (HandleRef port, out PortSettings settings);
public PortSettings GetSettings ()
@@ -232,10 +242,10 @@ namespace LibGPhoto2
return settings;
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_get_timeout (HandleRef port, out int timeout);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_set_timeout (HandleRef port, int timeout);
public int Timeout
@@ -252,13 +262,13 @@ namespace LibGPhoto2
}
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_get_pin (HandleRef port, Pin pin, out Level level);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_set_pin (HandleRef port, Pin pin, Level level);
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern string gp_port_get_error (HandleRef port);
}
}
diff --git a/bindings/csharp/PortInfoList.cs b/bindings/csharp/PortInfoList.cs
index 36e20106a..0be0a35d4 100644
--- a/bindings/csharp/PortInfoList.cs
+++ b/bindings/csharp/PortInfoList.cs
@@ -5,7 +5,7 @@ namespace LibGPhoto2
{
public class PortInfoList : Object
{
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_info_list_new (out IntPtr handle);
public PortInfoList()
@@ -17,7 +17,7 @@ namespace LibGPhoto2
this.handle = new HandleRef (this, native);
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_info_list_free (HandleRef handle);
protected override void Cleanup ()
@@ -25,7 +25,7 @@ namespace LibGPhoto2
Error.CheckError (gp_port_info_list_free (this.Handle));
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_info_list_load (HandleRef handle);
public void Load ()
@@ -36,7 +36,7 @@ namespace LibGPhoto2
throw Error.ErrorException (result);
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_info_list_count (HandleRef handle);
public int Count()
@@ -44,7 +44,7 @@ namespace LibGPhoto2
return (int) Error.CheckError (gp_port_info_list_count (this.Handle));
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal unsafe static extern ErrorCode gp_port_info_list_get_info (HandleRef handle, int n, out _PortInfo info);
public PortInfo GetInfo (int n)
@@ -56,7 +56,7 @@ namespace LibGPhoto2
return info;
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_info_list_lookup_path (HandleRef handle, [MarshalAs(UnmanagedType.LPTStr)]string path);
public int LookupPath (string path)
@@ -64,7 +64,7 @@ namespace LibGPhoto2
return (int) Error.CheckError (gp_port_info_list_lookup_path(this.handle, path));
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal static extern ErrorCode gp_port_info_list_lookup_name (HandleRef handle, string name);
public int LookupName(string name)
@@ -72,7 +72,7 @@ namespace LibGPhoto2
return (int) Error.CheckError (gp_port_info_list_lookup_name (this.Handle, name));
}
- [DllImport ("libgphoto2.so")]
+ [DllImport ("libgphoto2_port.so")]
internal unsafe static extern ErrorCode gp_port_info_list_append (HandleRef handle, _PortInfo info);
public int Append (PortInfo info)
diff --git a/bindings/csharp/README b/bindings/csharp/README
index 92acd8b1b..1e64373c5 100644
--- a/bindings/csharp/README
+++ b/bindings/csharp/README
@@ -1,4 +1,24 @@
-This code is imported from f-spot.
+This code has been imported from f-spot and adapted slightly to fit into
+the libgphoto2 build system.
http://ftp.gnome.org/Public/GNOME/sources/f-spot/0.1/f-spot-0.1.1.tar.bz2
+IMPORTANT NOTE:
+
+ This is in pre-alpha state, we still have a few things to figure
+ out before we can call this interface stable.
+
+
+TODO:
+
+ * gmcs vs. mcs
+ Libraries compiled with gmcs (C# 2.0) and mcs (C# 1.x) are not compatible.
+ Does one ship both? What should they be named, and where should they be
+ installed? And how is an application supposed to detect their respective
+ presence?
+
+ * Is there a cleaner set of automake/autoconf macros for C#/mono?
+
+ * Define special binding macros like the camlib or iolib macros, perhaps
+ even define a generic set of macros for all three.
+
diff --git a/bindings/csharp/TestGphoto2Sharp b/bindings/csharp/TestGphoto2Sharp
new file mode 100755
index 000000000..f1dc26edc
--- /dev/null
+++ b/bindings/csharp/TestGphoto2Sharp
@@ -0,0 +1,2 @@
+#!/bin/sh
+/usr/bin/mono $(dirname "$0")/TestGphoto2Sharp.exe
diff --git a/bindings/csharp/TestGphoto2Sharp.cs b/bindings/csharp/TestGphoto2Sharp.cs
new file mode 100644
index 000000000..7296659b4
--- /dev/null
+++ b/bindings/csharp/TestGphoto2Sharp.cs
@@ -0,0 +1,45 @@
+/**
+ * Short test using libgphoto2-sharp. Lists all cameras.
+ *
+ */
+
+using LibGPhoto2;
+
+class Gphoto2SharpTest {
+
+ static string basename(string filename) {
+ char [] chars = { '/', '\\' };
+ string [] components = filename.Split(chars);
+ return components[components.Length-1];
+ }
+
+ public static int Main() {
+ System.Console.WriteLine("Testing libgphoto2-sharp...");
+ Context ctx = new Context();
+ CameraAbilitiesList al = new CameraAbilitiesList();
+ al.Load(ctx);
+
+ int count = al.Count();
+
+ if (count < 0) {
+ System.Console.WriteLine("CameraAbilitiesList.Count() error: " + count);
+ return(1);
+ } else if (count == 0) {
+ System.Console.WriteLine("no camera drivers (camlibs) found in camlib dir");
+ return(1);
+ }
+
+ for (int i = 0; i < count; i++) {
+ CameraAbilities abilities = al.GetAbilities(i);
+ string camlib_basename = basename(abilities.library);
+ System.Console.WriteLine("{0,3} {3,-20} {1,-20} {2}",
+ i,
+ abilities.id,
+ abilities.model,
+ camlib_basename);
+ }
+
+ // Return non-0 when test fails
+ return 0;
+ }
+}
diff --git a/bindings/csharp/check-camera-list.in b/bindings/csharp/check-camera-list.in
new file mode 100644
index 000000000..14b48d3c6
--- /dev/null
+++ b/bindings/csharp/check-camera-list.in
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+top_builddir="@top_builddir@"
+camlibdir="@camlibdir@"
+libdir="@libdir@"
+DESTDIR="@DESTDIR@"
+MAKE="@MAKE@"
+
+echo "---------------------"
+pwd
+echo "camlibdir=$camlibdir"
+echo "libdir=$libdir"
+echo "DESTDIR=$DESTDIR"
+echo "top_builddir=$top_builddir"
+
+CAMLIBS="${DESTDIR}${camlibdir}"
+
+pwd="$(pwd)"
+if test -d "${CAMLIBS}"; then
+ echo "Found camlibs in default install dir."
+ :
+else
+ echo "Going to use our own camlib installation"
+ DESTDIR="${pwd}/_inst"
+ CAMLIBS="${DESTDIR}${camlibdir}"
+ for reldir in \
+ libgphoto2_port/libgphoto2_port \
+ libgphoto2 \
+ camlibs
+ do
+ (cd "${top_builddir}/${reldir}" && ${MAKE} DESTDIR="$DESTDIR" install)
+ done
+ ln -s "${CAMLIBS}" "_camlibs"
+ CAMLIBS="${pwd}/_camlibs"
+ if test -d "${CAMLIBS}"; then
+ echo "Test installation successful"
+ else
+ echo "Test installation failed"
+ exit 1
+ fi
+fi
+
+#LD_LIBRARY_PATH="$DESTDIR$libdir:$LD_LIBRARY_PATH"
+#export LD_LIBRARY_PATH
+export LD_LIBRARY_PATH="$top_builddir/libgphoto2/.libs${LD_LIBRARY_PATH+=:}${LD_LIBRARY_PATH}"
+echo "Using camlib dir: $CAMLIBS"
+export CAMLIBS
+
+echo "====================="
+pwd
+echo "camlibdir=$camlibdir"
+echo "libdir=$libdir"
+echo "DESTDIR=$DESTDIR"
+echo "top_builddir=$top_builddir"
+echo "CAMLIBS=$CAMLIBS"
+echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
+echo "#####################"
+
+@MONO@ $(dirname "$0")/TestGphoto2Sharp.exe
diff --git a/bindings/csharp/libgphoto2-sharp.dll.config b/bindings/csharp/libgphoto2-sharp.dll.config
index ebb75b184..9efd6e4d3 100644
--- a/bindings/csharp/libgphoto2-sharp.dll.config
+++ b/bindings/csharp/libgphoto2-sharp.dll.config
@@ -1,3 +1,4 @@
<configuration>
<dllmap dll="libgphoto2.so" target="libgphoto2.so.2"/>
+ <dllmap dll="libgphoto2_port.so" target="libgphoto2_port.so.0"/>
</configuration>
diff --git a/bindings/csharp/libgphoto2-sharp.pc.in b/bindings/csharp/libgphoto2-sharp.pc.in
new file mode 100644
index 000000000..30d441b4a
--- /dev/null
+++ b/bindings/csharp/libgphoto2-sharp.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+Libraries=@cslibdir@/libgphoto2-sharp.dll
+LibraryBase=@cslibdir@
+
+Name: libgphoto2-sharp
+Description: libgphoto2-sharp - .NET Bindings for libgphoto2 in C#
+Version: @VERSION@
+Libs: -r:${Libraries}