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
This commit is contained in:
Marcus Meissner
2006-06-24 08:03:23 +00:00
parent 1183e63a54
commit f22fefbb1b
12 changed files with 195 additions and 46 deletions

View File

@@ -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.

View File

@@ -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;
}

View File

@@ -9,7 +9,8 @@ namespace LibGPhoto2
Normal,
Raw,
Audio,
Exif
Exif,
MetaData
}
public class MimeTypes

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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)

View File

@@ -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.

View File

@@ -0,0 +1,2 @@
#!/bin/sh
/usr/bin/mono $(dirname "$0")/TestGphoto2Sharp.exe

View File

@@ -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;
}
}

View File

@@ -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

View File

@@ -1,3 +1,4 @@
<configuration>
<dllmap dll="libgphoto2.so" target="libgphoto2.so.2"/>
<dllmap dll="libgphoto2_port.so" target="libgphoto2_port.so.0"/>
</configuration>

View File

@@ -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}