debian/0000755000000000000000000000000011706635406007176 5ustar debian/libgnome-keyring1.0-cil.install0000644000000000000000000000024411615622404015005 0ustar /usr/lib/mono/gac/Gnome.Keyring/1.0.*/Gnome.Keyring.dll* /usr/lib/cli/Gnome.Keyring-1.0/ /usr/lib/libgnome-keyring-sharp-glue.so /usr/lib/cli/Gnome.Keyring-1.0/ debian/monodoc-gnome-keyring-manual.install0000644000000000000000000000004411615622404016237 0ustar debian/tmp/usr/lib/monodoc/sources/ debian/copyright0000644000000000000000000000276511615622404011134 0ustar This package was debianized by Laurent Bigonville on Wed, 03 Oct 2007 13:21:34 +0200 It was downloaded from: Upstream Authors: Gonzalo Paniagua Javier Alp Toker Copyright: Copyright © 2005-2006 Novell, Inc. Copyright © 2007 Alp Toker License: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. The Debian packaging is © 2007, Laurent Bigonville and is licensed under the GPL, see `/usr/share/common-licenses/GPL'. debian/changelog0000644000000000000000000000715511706635361011060 0ustar gnome-keyring-sharp (1.0.0-4) unstable; urgency=low * debian/rules: + Update debian/rules for DH8-compatible "--with cli" -- Jo Shields Sat, 21 Jan 2012 22:23:20 +0000 gnome-keyring-sharp (1.0.0-3) unstable; urgency=low * Move to source format 3.0 (quilt) * debian/patches/02_gnome_2.30_compatibility.patch: + Replace socket use with a wrapper around libgnome-keyring. Makes gnome-keyring-sharp able to work on GNOME 2.30. (LP: #536925) * debian/rules: + Move to using override_dh_* + Run autoreconf before configure, and clean up afterwards in clean + Remove the bz2 -> gzip conversion from get-orig-source; 3.0 handles bz2 orig tarballs for us. + Override dh_makeshlibs, as it gets confused by the private glue library. * debian/control: + Bump debhelper depends to 7.0.50~ for override_dh_* + Now arch: any, due to libgnome-keyring-sharp-glue.so + Add new build-depends: libgnome-keyring-dev, automake, libtool, glib-sharp. + Drop unneded ndesk-dbus build-depends. + Bump Standards-Version. No changes needed after move to 3.0 (quilt) * debian/libgnome-keyring1.0-cil.install: + Also install libgnome-keyring-sharp-glue.so and Gnome.Keyring.dll.config * debian/copyright: + Replace (c) → ©. Fixes lintian warning. -- Christopher James Halse Rogers Tue, 30 Mar 2010 17:58:48 +1100 gnome-keyring-sharp (1.0.0-2) unstable; urgency=low * debian/libgnome-keyring1.0-cil.install, debian/libgnome-keyring1.0-cil.installcligac, debian/libgnome-keyring1.0-cil-dev.install, debian/patches/01pkgconfig-path.dpatch, debian/control: + Create new -dev package for pkg-config file * debian/libgnome-keyring1.0-cil.install, debian/libgnome-keyring1.0-cil.installcligac: + CLI Policy 0.7 install dir for library * debian/control, debian/rules: + Use mono-csc from mono-devel 2.4.2.3+ * debian/rules: + Policy-compliant location for get-orig-source rule * debian/monodoc-gnome-keyring-manual.postinst: + Delete - this is handled by triggers now * debian/control: + No-change bump to Standards 3.8.3 + Use -dev packages to build -- Jo Shields Fri, 20 Nov 2009 14:42:38 +0000 gnome-keyring-sharp (1.0.0-1) unstable; urgency=low [ Jo Shields ] * Update to "release" tarball rather than SVN * debian/control: + Bump to standards version 3.8.1 (no changes needed) * debian/rules: + Remove rules specific to packaging from SVN + Implement proper get-orig-source rule [ Laurent Bigonville ] * debian/control: + remove my name from Uploaders (Closes: #514724) -- Jo Shields Wed, 06 May 2009 14:21:33 +0100 gnome-keyring-sharp (1.0.0~svn.r87622-2) unstable; urgency=low [ Mirco Bauer ] * debian/rules: + Migrated from cdbs to debhelper v7 minimalistic style. * debian/control: + Replaced cdbs build-dependency with debhelper >= 7 and cli-common-dev >= 0.5.7. + Added dpatch to build-dependencies. * debian/compat: + Bumped to 7 * debian/patches/01pkgconfig-path.dpatch: + Converted patch to dpatch. [ Iain Lane ] * debian/control: Update build-deps for Mono 2.0 transition * debian/control: Update Vcs-Svn * debian/control: Add ${misc:Depends} to -manual -- Mirco Bauer Wed, 04 Mar 2009 00:02:51 +0100 gnome-keyring-sharp (1.0.0~svn.r87622-1) unstable; urgency=low * Initial release. (Closes: #442121) * debian/patches/01pkgconfig-path.patch: fix pkg-config installation path -- Laurent Bigonville Fri, 11 Jan 2008 21:04:14 +0100 debian/watch0000644000000000000000000000015611615622404010222 0ustar version=3 http://ftp.novell.com/pub/mono/sources/gnome-keyring-sharp/ gnome-keyring-sharp-([.\d]+)\.tar\.bz2 debian/libgnome-keyring1.0-cil-dev.install0000644000000000000000000000005611615622404015562 0ustar /usr/lib/pkgconfig/gnome-keyring-sharp-1.0.pc debian/source/0000755000000000000000000000000011706635406010476 5ustar debian/source/format0000644000000000000000000000001411615622404011675 0ustar 3.0 (quilt) debian/rules0000755000000000000000000000221411706635222010251 0ustar #!/usr/bin/make -f #export DH_VERBOSE=1 DEB_CLI_API_VERSION = 1.0.0 MAKEFILE = $(firstword $(MAKEFILE_LIST)) DEBIAN_DIR = $(dir $(MAKEFILE)) SOURCE_DIR = $(DEBIAN_DIR)/.. DEB_VERSION = $(shell dpkg-parsechangelog -l$(DEBIAN_DIR)/changelog | grep ^Version | cut -d" " -f2) DEB_SOURCE_NAME = $(shell dpkg-parsechangelog -l$(DEBIAN_DIR)/changelog | grep ^Source | cut -d" " -f2) VERSION = $(shell echo $(DEB_VERSION) | cut -d"-" -f1 | sed 's/+dfsg.*//') override_dh_auto_configure: autoreconf -v -i -s dh_auto_configure -- CSC=/usr/bin/mono-csc override_dh_makeclilibs: dh_makeclilibs -m $(DEB_CLI_API_VERSION) override_dh_clean: dh_clean # delete generated autofoo stuff from above find . -name "Makefile.in" | xargs rm -rf rm -f config.status config.sub config.guess configure ltmain.sh override_dh_makeshlibs: # Do nothing. dh_makeshlibs gets confused by the private glue library %: dh $@ --with cli get-orig-source: mkdir -p ../tarballs uscan \ --package $(DEB_SOURCE_NAME) \ --watchfile $(DEBIAN_DIR)/watch \ --upstream-version $(VERSION) \ --download-version $(VERSION) \ --destdir ../tarballs \ --force-download \ --rename debian/compat0000644000000000000000000000000211615622404010365 0ustar 7 debian/libgnome-keyring1.0-cil.installcligac0000644000000000000000000000006111615622404016145 0ustar /usr/lib/cli/Gnome.Keyring-1.0/Gnome.Keyring.dll debian/patches/0000755000000000000000000000000011706635406010625 5ustar debian/patches/01pkgconfig-path.patch0000644000000000000000000000122111615622404014675 0ustar #! /bin/sh /usr/share/dpatch/dpatch-run ## 01pkgconfig-path.dpatch ## ## All lines beginning with ## DP:' are a description of the patch. ## DP: No description. @DPATCH@ --- gnome-keyring-sharp-1.0.0~svn20080110/src/gnome-keyring-sharp-1.0.pc.in 2007-10-14 03:53:29.000000000 +1000 +++ gnome-keyring-sharp-1.0.0~svn20080110.new/src/gnome-keyring-sharp-1.0.pc.in 2008-01-10 18:04:26.000000000 +1100 @@ -5,4 +5,4 @@ Name: Gnome.Keyring Description: Client library to access the GNOME Keyring daemon Version: @VERSION@ -Libs: -r:${libdir}/mono/@PACKAGE@-@API_VERSION@/Gnome.Keyring.dll +Libs: -r:${libdir}/cli/Gnome.Keyring-@API_VERSION@/Gnome.Keyring.dll debian/patches/02_gnome_2.30_compatibility.patch0000755000000000000000000014432411615622404016653 0ustar Description: Reimplement using libgnome-keyring GNOME Keyring daemon in 2.30 no longer exports the socket interface which gnome-keyring-sharp used. This makes gnome-keyring-sharp totally useless. . This patch reimplements the gnome-keyring-sharp functions as a p/invoke wrapper around libgnome-keyring. API and ABI is unchanged. Author: Christopher Halse Rogers Bug-Launchpad: https://bugs.edge.launchpad.net/ubuntu/lucid/+source/gnome-keyring-sharp/+bug/536925 Bug: https://bugzilla.novell.com/show_bug.cgi?id=589166 diff -urNad gnome-keyring-sharp-1.0.0~/Makefile.am gnome-keyring-sharp-1.0.0/Makefile.am --- gnome-keyring-sharp-1.0.0~/Makefile.am 2008-08-09 03:36:12.000000000 +1000 +++ gnome-keyring-sharp-1.0.0/Makefile.am 2010-03-30 17:32:02.733918042 +1100 @@ -1,3 +1,2 @@ -SUBDIRS=src docs sample +SUBDIRS=src gnome-keyring-sharp-glue docs sample EXTRA_DIST=Gnome.Keyring.snk - diff -urNad gnome-keyring-sharp-1.0.0~/autogen.sh gnome-keyring-sharp-1.0.0/autogen.sh --- gnome-keyring-sharp-1.0.0~/autogen.sh 1970-01-01 10:00:00.000000000 +1000 +++ gnome-keyring-sharp-1.0.0/autogen.sh 2010-03-30 17:32:02.733918042 +1100 @@ -0,0 +1,4 @@ +#! /bin/sh + +autoreconf -v -i -s +./configure $* \ No newline at end of file diff -urNad gnome-keyring-sharp-1.0.0~/configure.ac gnome-keyring-sharp-1.0.0/configure.ac --- gnome-keyring-sharp-1.0.0~/configure.ac 2008-08-09 03:36:12.000000000 +1000 +++ gnome-keyring-sharp-1.0.0/configure.ac 2010-03-30 17:32:02.733918042 +1100 @@ -3,6 +3,9 @@ AC_INIT(src/Gnome.Keyring/Ring.cs) AC_CANONICAL_SYSTEM +AC_PROG_CC +AC_PROG_LIBTOOL + API_VERSION=1.0 VERSION=$API_VERSION.0 @@ -47,28 +50,13 @@ GACUTIL_FLAGS='/gacdir $(DESTDIR)$(prefix)' AC_SUBST(GACUTIL_FLAGS) -# -# Use D-Bus as a fallback to get the keyring socket address -# -AC_ARG_ENABLE(dbus, - [ --enable-dbus[[=no/yes]] compile with D-Bus support [[default: yes]]], - ENABLE_DBUS="$enableval") -AM_CONDITIONAL(ENABLE_DBUS, test "x$ENABLE_DBUS" != "xno") - -CSFLAGS= -DBUS_LIBS= -if test "x$ENABLE_DBUS" != "xno" ; then - PKG_CHECK_MODULES(DBUS, ndesk-dbus-1.0 >= 0.4, HAVE_DBUS="yes", HAVE_DBUS="no") - - if test "x$HAVE_DBUS" = "xno"; then - AC_MSG_ERROR($DBUS_PKG_ERRORS: consider passing --enable-dbus=no to configure) - fi +PKG_CHECK_MODULES(GLIB_SHARP, [glib-sharp-2.0]) +PKG_CHECK_MODULES(GNOME_KEYRING, [gnome-keyring-1]) - CSFLAGS=" -d:WITH_DBUS " -fi AC_SUBST(CSFLAGS) -AC_SUBST(DBUS_LIBS) - +AC_SUBST(GLIB_SHARP_LIBS) +AC_SUBST(GNOME_KEYRING_CFLAGS) +AC_SUBST(GNOME_KEYRING_LIBS) AC_PATH_PROG(MDASSEMBLER, mdassembler, no) AC_PATH_PROG(MONODOCER, monodocer, no) @@ -91,6 +79,7 @@ src/gnome-keyring-sharp-1.0.pc src/Gnome.Keyring/Makefile src/Gnome.Keyring/AssemblyInfo.cs + gnome-keyring-sharp-glue/Makefile docs/Makefile sample/Makefile ]) diff -urNad gnome-keyring-sharp-1.0.0~/gnome-keyring-sharp-glue/Makefile.am gnome-keyring-sharp-1.0.0/gnome-keyring-sharp-glue/Makefile.am --- gnome-keyring-sharp-1.0.0~/gnome-keyring-sharp-glue/Makefile.am 1970-01-01 10:00:00.000000000 +1000 +++ gnome-keyring-sharp-1.0.0/gnome-keyring-sharp-glue/Makefile.am 2010-03-30 17:32:02.733918042 +1100 @@ -0,0 +1,6 @@ +lib_LTLIBRARIES = libgnome-keyring-sharp-glue.la + +libgnome_keyring_sharp_glue_la_SOURCES = glue.c +libgnome_keyring_sharp_glue_la_LDFLAGS = -module -avoid-version -no-undefined +libgnome_keyring_sharp_glue_la_LIBADD = $(GNOME_KEYRING_LIBS) +libgnome_keyring_sharp_glue_la_CFLAGS = $(GNOME_KEYRING_CFLAGS) diff -urNad gnome-keyring-sharp-1.0.0~/gnome-keyring-sharp-glue/glue.c gnome-keyring-sharp-1.0.0/gnome-keyring-sharp-glue/glue.c --- gnome-keyring-sharp-1.0.0~/gnome-keyring-sharp-glue/glue.c 1970-01-01 10:00:00.000000000 +1000 +++ gnome-keyring-sharp-1.0.0/gnome-keyring-sharp-glue/glue.c 2010-03-30 17:32:02.733918042 +1100 @@ -0,0 +1,36 @@ +#include + +gpointer gks_attribute_list_new () +{ + return gnome_keyring_attribute_list_new (); +} + +gint32 gks_item_attribute_list_get_length (GnomeKeyringAttributeList *attrs) +{ + return (*attrs).len; +} + +gboolean gks_item_attribute_list_index_is_string (GnomeKeyringAttributeList *attrs, gint32 index) +{ + return gnome_keyring_attribute_list_index (attrs, index).type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING; +} + +gboolean gks_item_attribute_list_index_is_uint32 (GnomeKeyringAttributeList *attrs, gint32 index) +{ + return gnome_keyring_attribute_list_index (attrs, index).type == GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32; +} + +char * gks_item_attribute_list_get_index_string (GnomeKeyringAttributeList *attrs, gint32 index) +{ + return gnome_keyring_attribute_list_index (attrs, index).value.string; +} + +guint32 gks_item_attribute_list_get_index_uint32 (GnomeKeyringAttributeList *attrs, gint32 index) +{ + return gnome_keyring_attribute_list_index (attrs, index).value.integer; +} + +char * gks_item_attribute_list_get_index_key (GnomeKeyringAttributeList *attrs, gint32 index) +{ + return gnome_keyring_attribute_list_index (attrs, index).name; +} diff -urNad gnome-keyring-sharp-1.0.0~/src/Gnome.Keyring/Makefile.am gnome-keyring-sharp-1.0.0/src/Gnome.Keyring/Makefile.am --- gnome-keyring-sharp-1.0.0~/src/Gnome.Keyring/Makefile.am 2008-08-09 03:36:12.000000000 +1000 +++ gnome-keyring-sharp-1.0.0/src/Gnome.Keyring/Makefile.am 2010-03-30 17:32:02.733918042 +1100 @@ -10,8 +10,5 @@ KeyringInfo.cs \ NetItemData.cs \ NoteItemData.cs \ - Operation.cs \ - RequestMessage.cs \ - ResponseMessage.cs \ ResultCode.cs \ Ring.cs diff -urNad gnome-keyring-sharp-1.0.0~/src/Gnome.Keyring/Operation.cs gnome-keyring-sharp-1.0.0/src/Gnome.Keyring/Operation.cs --- gnome-keyring-sharp-1.0.0~/src/Gnome.Keyring/Operation.cs 2008-08-09 03:36:12.000000000 +1000 +++ gnome-keyring-sharp-1.0.0/src/Gnome.Keyring/Operation.cs 1970-01-01 10:00:00.000000000 +1000 @@ -1,54 +0,0 @@ -// -// Gnome.Keyring.Operation.cs -// -// Authors: -// Gonzalo Paniagua Javier (gonzalo@ximian.com) -// -// (C) Copyright 2006 Novell, Inc. (http://www.novell.com) -// - -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -namespace Gnome.Keyring { - enum Operation { - LockAll, - SetDefaultKeyring, - GetDefaultKeyring, - ListKeyrings, - CreateKeyring, - LockKeyring, - UnlockKeyring, - DeleteKeyring, - GetKeyringInfo, - SetKeyringInfo, - ListItems, - Find, - CreateItem, - DeleteItem, - GetItemInfo, - SetItemInfo, - GetItemAttributes, - SetItemAttributes, - GetItemACL, - SetItemACL - } -} - diff -urNad gnome-keyring-sharp-1.0.0~/src/Gnome.Keyring/RequestMessage.cs gnome-keyring-sharp-1.0.0/src/Gnome.Keyring/RequestMessage.cs --- gnome-keyring-sharp-1.0.0~/src/Gnome.Keyring/RequestMessage.cs 2008-08-09 03:36:12.000000000 +1000 +++ gnome-keyring-sharp-1.0.0/src/Gnome.Keyring/RequestMessage.cs 1970-01-01 10:00:00.000000000 +1000 @@ -1,173 +0,0 @@ -// -// Gnome.Keyring.RequestMessage.cs -// -// Authors: -// Gonzalo Paniagua Javier (gonzalo@ximian.com) -// -// (C) Copyright 2006 Novell, Inc. (http://www.novell.com) -// - -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections; -using System.IO; -using System.Text; - -namespace Gnome.Keyring { - class RequestMessage { - MemoryStream stream = new MemoryStream (); - int op_start = -1; - - public MemoryStream Stream { - get { return stream; } - } - - public void CreateSimpleOperation (Operation op) - { - StartOperation (op); - EndOperation (); - } - - public void CreateSimpleOperation (Operation op, string str1) - { - StartOperation (op); - Write (str1); - EndOperation (); - } - - public void CreateSimpleOperation (Operation op, string str1, string str2) - { - StartOperation (op); - Write (str1); - Write (str2); - EndOperation (); - } - - public void CreateSimpleOperation (Operation op, string str1, int i1) - { - StartOperation (op); - Write (str1); - Write (i1); - EndOperation (); - } - - public void StartOperation (Operation op) - { - string appname = Ring.ApplicationName; - BinaryWriter writer = new BinaryWriter (stream); - writer.Write (0); - - Write (appname); - int curpos = (int) stream.Position; - stream.Position = 0; - writer = new BinaryWriter (stream); - writer.Write (SwapBytes (curpos)); - stream.Position = curpos; - - op_start = (int) stream.Length; - writer.Write (0); - writer.Write (SwapBytes ((int) op)); - } - - public void EndOperation () - { - int current = (int) stream.Length; - int size = SwapBytes (current - op_start); - stream.Position = op_start; - BinaryWriter writer = new BinaryWriter (stream); - writer.Write (size); - } - - public void Write (string str) - { - WriteString (new BinaryWriter (stream), str); - } - - static void WriteString (BinaryWriter writer, string str) - { - if (str == null) { - writer.Write ((int) -1); - return; - } - byte [] bytes = Encoding.UTF8.GetBytes (str); - writer.Write (SwapBytes (bytes.Length)); - writer.Write (bytes); - } - - public void Write (int i) - { - BinaryWriter writer = new BinaryWriter (stream); - writer.Write (SwapBytes (i)); - } - - public void WriteAttributes (Hashtable atts) - { - Hashtable copy = new Hashtable (); - foreach (string key in atts.Keys) { - object o = atts [key]; - if (o != null) - copy [key] = o; - - } - BinaryWriter writer = new BinaryWriter (stream); - writer.Write (SwapBytes (copy.Count)); - foreach (string key in copy.Keys) { - object o = atts [key]; - if (o is string) { - EncodeAttribute (writer, key, (string) o); - } else if (o is int) { - int i = (int) o; - if (key == "port" && i == 0) - continue; - EncodeAttribute (writer, key, i); - } else { - throw new Exception ("Should not happen."); - } - } - } - - static void EncodeAttribute (BinaryWriter writer, string name, string val) - { - WriteString (writer, name); - writer.Write (SwapBytes ((int) AttributeType.String)); - WriteString (writer, val); - } - - static void EncodeAttribute (BinaryWriter writer, string name, int val) - { - WriteString (writer, name); - writer.Write (SwapBytes ((int) AttributeType.UInt32)); - writer.Write (SwapBytes (val)); - } - - static int SwapBytes (int i) - { - byte b0 = (byte) ((i >> 24) & 0xFF); - byte b1 = (byte) ((i >> 16) & 0xFF); - byte b2 = (byte) ((i >> 8) & 0xFF); - byte b3 = (byte) (i & 0xFF); - return b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); - } - - } -} - diff -urNad gnome-keyring-sharp-1.0.0~/src/Gnome.Keyring/ResponseMessage.cs gnome-keyring-sharp-1.0.0/src/Gnome.Keyring/ResponseMessage.cs --- gnome-keyring-sharp-1.0.0~/src/Gnome.Keyring/ResponseMessage.cs 2008-08-09 03:36:12.000000000 +1000 +++ gnome-keyring-sharp-1.0.0/src/Gnome.Keyring/ResponseMessage.cs 1970-01-01 10:00:00.000000000 +1000 @@ -1,108 +0,0 @@ -// -// Gnome.Keyring.ResponseMessage.cs -// -// Authors: -// Gonzalo Paniagua Javier (gonzalo@ximian.com) -// -// (C) Copyright 2006 Novell, Inc. (http://www.novell.com) -// - -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections; -using System.IO; -using System.Text; - -using Mono.Unix.Native; - -namespace Gnome.Keyring { - class ResponseMessage { - byte [] buffer; - MemoryStream stream; - - public ResponseMessage (byte [] buffer) - { - this.buffer = buffer; - stream = new MemoryStream (buffer); - } - - public bool DataAvailable { - get { return (stream.Position < stream.Length); } - } - - public string [] GetStringList () - { - int nstrings = GetInt32 (); - string [] list = new string [nstrings]; - for (int i = 0; i < nstrings; i++) { - list [i] = GetString (); - } - - return list; - } - - public string GetString () - { - int len = GetInt32 (); - if (len == -1) { - return null; - } - int offset = (int) stream.Position; - string result = Encoding.UTF8.GetString (buffer, offset, len); - stream.Position += len; - return result; - } - - public int GetInt32 () - { - byte b3 = (byte) stream.ReadByte (); - byte b2 = (byte) stream.ReadByte (); - byte b1 = (byte) stream.ReadByte (); - byte b0 = (byte) stream.ReadByte (); - return (b0 + (b1 << 8) + (b2 << 16) + (b3 << 24)); - } - - public DateTime GetDateTime () - { - return NativeConvert.FromTimeT ((GetInt32 () << 32) + GetInt32 ()); - } - - public void ReadAttributes (Hashtable tbl) - { - int natts = GetInt32 (); - for (int i = 0; i < natts; i++) { - object val; - string name = GetString (); - AttributeType type = (AttributeType) GetInt32 (); - if (AttributeType.String == type) { - val = GetString (); - } else if (type == AttributeType.UInt32) { - val = GetInt32 (); - } else { - throw new Exception ("This should not happen: " + type); - } - tbl [name] = val; - } - } - } -} - diff -urNad gnome-keyring-sharp-1.0.0~/src/Gnome.Keyring/Ring.cs gnome-keyring-sharp-1.0.0/src/Gnome.Keyring/Ring.cs --- gnome-keyring-sharp-1.0.0~/src/Gnome.Keyring/Ring.cs 2008-08-09 03:36:12.000000000 +1000 +++ gnome-keyring-sharp-1.0.0/src/Gnome.Keyring/Ring.cs 2010-03-30 17:32:02.733918042 +1100 @@ -31,16 +31,16 @@ using System; using System.Collections; +using System.Collections.Generic; using System.IO; using System.Net; using System.Net.Sockets; using System.Reflection; +using System.Runtime.InteropServices; using Mono.Unix; -#if WITH_DBUS -using NDesk.DBus; -#endif +using GLib; namespace Gnome.Keyring { public class Ring { @@ -70,394 +70,579 @@ } } + [DllImport ("libgnome-keyring.dll")] + static extern bool gnome_keyring_is_available (); + public static bool Available { get { - Socket sock = Connect (); - if (sock != null) { - sock.Close (); - return true; - } - return false; - } - } - - static Socket Connect () - { - string filename; - Socket sock; - - filename = Environment.GetEnvironmentVariable ("GNOME_KEYRING_SOCKET"); - sock = Connect (filename); - -#if WITH_DBUS - if (sock == null) { - try { - filename = Bus.Session.GetObject ("org.gnome.keyring", new ObjectPath ("/org/gnome/keyring/daemon")).GetSocketPath (); - } catch (Exception) { - filename = null; - } - sock = Connect (filename); - } -#endif - - return sock; - } - - static Socket Connect (string filename) - { - if (filename == null || filename == "") - return null; - - EndPoint ep = new UnixEndPoint (filename); - Socket sock = new Socket (AddressFamily.Unix, SocketType.Stream, ProtocolType.IP); - try { - sock.Connect (ep); - } catch (Exception) { - sock.Close (); - return null; - } - return sock; - } - - static int GetInt32 (Socket sock) - { - byte [] cuatro = new byte [4]; - if (sock.Receive (cuatro) != 4) - throw new KeyringException (ResultCode.IOError); - return (cuatro [3] + (cuatro [2] << 8) + (cuatro [1] << 16) + (cuatro [0] << 24)); - } - - static byte [] one = new byte [1]; - static ResponseMessage SendRequest (MemoryStream stream) - { - Socket sock = Connect (); - if (sock == null) - throw new KeyringException (ResultCode.NoKeyringDaemon); - - try { - sock.Send (one); // Credentials byte - byte [] buffer = stream.ToArray (); - sock.Send (buffer); - int packet_size = GetInt32 (sock) - 4; - if (packet_size < 0) - throw new KeyringException (ResultCode.IOError); - byte [] response = new byte [packet_size]; - int nbytes = sock.Receive (response); - if (nbytes != response.Length) - throw new KeyringException (ResultCode.IOError); - ResponseMessage resp = new ResponseMessage (response); - ResultCode result = (ResultCode) resp.GetInt32 (); - if (result != 0) - throw new KeyringException (result); - - return resp; - } finally { - sock.Close (); + return gnome_keyring_is_available (); } } + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_lock_all_sync (); + public static void LockAll () { - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.LockAll); - SendRequest (req.Stream); + ResultCode result = gnome_keyring_lock_all_sync (); + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } } + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_set_default_keyring_sync (string keyring); + public static void SetDefaultKeyring (string newKeyring) { if (newKeyring == null) throw new ArgumentNullException ("newKeyring"); - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.SetDefaultKeyring, newKeyring); - SendRequest (req.Stream); + ResultCode result = gnome_keyring_set_default_keyring_sync (newKeyring); + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } } + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_get_default_keyring_sync (out IntPtr keyring); + public static string GetDefaultKeyring () { - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.GetDefaultKeyring); - ResponseMessage resp = SendRequest (req.Stream); - return resp.GetString (); + IntPtr keyring_name; + ResultCode result = gnome_keyring_get_default_keyring_sync (out keyring_name); + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } + return GLib.Marshaller.PtrToStringGFree (keyring_name); } - public static string [] GetKeyrings () + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_list_keyring_names_sync (out IntPtr keyringList); + + [DllImport ("libgnome-keyring.dll")] + static extern void gnome_keyring_string_list_free (IntPtr stringList); + + public static string[] GetKeyrings () { - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.ListKeyrings); - ResponseMessage resp = SendRequest (req.Stream); - return resp.GetStringList (); + IntPtr keyring_list; + ResultCode result = gnome_keyring_list_keyring_names_sync (out keyring_list); + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } + var retval = (string[])GLib.Marshaller.ListPtrToArray (keyring_list, typeof(GLib.List), false, false, typeof(string)); + gnome_keyring_string_list_free (keyring_list); + return retval; } + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_create_sync (string keyringName, string password); + public static void CreateKeyring (string name, string password) { - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.CreateKeyring, name, password); - SendRequest (req.Stream); + ResultCode result = gnome_keyring_create_sync (name, password); + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } } - + + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_lock_sync (string keyring); + public static void Lock (string keyring) { if (keyring == null) throw new ArgumentNullException ("keyring"); - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.LockKeyring, keyring); - SendRequest (req.Stream); + ResultCode result = gnome_keyring_lock_sync (keyring); + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } } + + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_unlock_sync (string keyring, string password); public static void Unlock (string keyring, string password) { - if (keyring == null) - throw new ArgumentNullException ("keyring"); - - if (password == null) - throw new ArgumentNullException ("password"); - - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.UnlockKeyring, keyring, password); - try { - SendRequest (req.Stream); - } catch (KeyringException ke) { - if (ke.ResultCode != ResultCode.AlreadyUnlocked) - throw; + ResultCode result = gnome_keyring_unlock_sync (keyring, password); + + if (!(result == ResultCode.Ok || result == ResultCode.AlreadyUnlocked)) { + throw new KeyringException (result); } } + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_delete_sync (string keyring); + public static void DeleteKeyring (string keyring) { if (keyring == null) throw new ArgumentNullException ("keyring"); - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.DeleteKeyring, keyring); - SendRequest (req.Stream); + ResultCode result = gnome_keyring_delete_sync (keyring); + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } } - public static int [] ListItemIDs (string keyring) + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_list_item_ids_sync (string keyring, out IntPtr ids); + + public static int[] ListItemIDs (string keyring) { if (keyring == null) throw new ArgumentNullException ("keyring"); - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.ListItems, keyring); - ResponseMessage resp = SendRequest (req.Stream); - int len = resp.GetInt32 (); - int [] result = new int [len]; - for (int i = 0; i < len; i++) { - result [i] = resp.GetInt32 (); + IntPtr idlist; + ResultCode result = gnome_keyring_list_item_ids_sync (keyring, out idlist); + + if (result != ResultCode.Ok) { + throw new KeyringException (result); } - - return result; + + IntPtr[] ptrArray = (IntPtr[])GLib.Marshaller.ListPtrToArray (idlist, typeof(GLib.List), true, false, typeof(IntPtr)); + int[] ids = new int[ptrArray.Length]; + for (int i = 0; i < ptrArray.Length; i++) { + ids[i] = ptrArray[i].ToInt32 (); + } + + return ids; } + + static void NativeListFromAttributes (IntPtr attrList, Hashtable attributes) + { + foreach (string key in attributes.Keys) { + if (attributes[key] is string) { + gnome_keyring_attribute_list_append_string (attrList, key, (string)attributes[key]); + } else if (attributes[key] is int) { + gnome_keyring_attribute_list_append_uint32 (attrList, key, (uint)((int)attributes[key])); + } else { + throw new ArgumentException (String.Format ("Attribute \"{0}\" has invalid parameter type: {1}", key, attributes[key].GetType ())); + } + } + } + + static void AttributesFromNativeList (IntPtr attrList, Hashtable attributes) + { + int listLength = gks_item_attribute_list_get_length (attrList); + for (int i = 0; i < listLength; i++) { + string key = Marshal.PtrToStringAnsi (gks_item_attribute_list_get_index_key (attrList, i)); + if (gks_item_attribute_list_index_is_string (attrList, i)) { + attributes[key] = Marshal.PtrToStringAnsi (gks_item_attribute_list_get_index_string (attrList, i)); + } else if (gks_item_attribute_list_index_is_uint32 (attrList, i)) { + attributes[key] = (int)gks_item_attribute_list_get_index_uint32 (attrList, i); + } + } + } + + [StructLayout(LayoutKind.Sequential)] + struct GnomeKeyringFound + { + public IntPtr keyring; + public UInt32 item_id; + public IntPtr attrList; + public IntPtr secret; + } + + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_find_items_sync (ItemType type, IntPtr attrList, out IntPtr foundList); + [DllImport ("libgnome-keyring.dll")] + static extern void gnome_keyring_found_list_free (IntPtr foundList); + static ItemData [] empty_item_data = new ItemData [0]; - public static ItemData [] Find (ItemType type, Hashtable atts) + public static ItemData[] Find (ItemType type, Hashtable atts) { if (atts == null) throw new ArgumentNullException ("atts"); - RequestMessage req = new RequestMessage (); - req.StartOperation (Operation.Find); - req.Write ((int) type); - req.WriteAttributes (atts); - req.EndOperation (); - - ResponseMessage resp = null; - try { - resp = SendRequest (req.Stream); - } catch (KeyringException ke) { - if (ke.ResultCode == ResultCode.Denied) - return empty_item_data; - throw; + + IntPtr passwordList; + IntPtr attrList = gks_attribute_list_new (); + + NativeListFromAttributes (attrList, atts); + + ResultCode result = gnome_keyring_find_items_sync (type, attrList, out passwordList); + + if (result == ResultCode.Denied) { + return empty_item_data; + } + + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } + + IntPtr[] passwordStructs = (IntPtr[])GLib.Marshaller.ListPtrToArray (passwordList, typeof(GLib.List), false, false, typeof(IntPtr)); + List passwords = new List (); + + foreach (IntPtr ptr in passwordStructs) { + passwords.Add ((GnomeKeyringFound)Marshal.PtrToStructure (ptr, typeof(GnomeKeyringFound))); } ArrayList list = new ArrayList (); - while (resp.DataAvailable) { + foreach (var password in passwords) { ItemData found = ItemData.GetInstanceFromItemType (type); - found.Keyring = resp.GetString (); - found.ItemID = resp.GetInt32 (); - found.Secret = resp.GetString (); + found.ItemID = (int)password.item_id; + found.Secret = Marshal.PtrToStringAnsi (password.secret); + found.Keyring = Marshal.PtrToStringAnsi (password.keyring); found.Attributes = new Hashtable (); - resp.ReadAttributes (found.Attributes); + AttributesFromNativeList (password.attrList, found.Attributes); found.SetValuesFromAttributes (); list.Add (found); } + gnome_keyring_found_list_free (passwordList); + gnome_keyring_attribute_list_free (attrList); + return (ItemData []) list.ToArray (typeof (ItemData)); } + [StructLayout (LayoutKind.Sequential)] + struct GnomeKeyringNetworkPasswordData + { + public IntPtr keyring; + public UInt32 item_id; + + public IntPtr protocol; + public IntPtr server; + public IntPtr @object; + public IntPtr authtype; + public UInt32 port; + + public IntPtr user; + public IntPtr domain; + public IntPtr password; + } + + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_find_network_password_sync (string user, string domain, string server, + string @object, string protocol, string authtype, UInt32 port, out IntPtr passwordList); + static NetItemData [] empty_net_item_data = new NetItemData [0]; - public static NetItemData [] FindNetworkPassword (string user, string domain, string server, string obj, + public static NetItemData[] FindNetworkPassword (string user, string domain, string server, string obj, string protocol, string authtype, int port) { - RequestMessage req = new RequestMessage (); - req.StartOperation (Operation.Find); - req.Write ((int) ItemType.NetworkPassword); - Hashtable tbl = new Hashtable (); - tbl ["user"] = user; - tbl ["domain"] = domain; - tbl ["server"] = server; - tbl ["object"] = obj; - tbl ["protocol"] = protocol; - tbl ["authtype"] = authtype; - if (port != 0) - tbl ["port"] = port; - req.WriteAttributes (tbl); - req.EndOperation (); - - ResponseMessage resp = null; - try { - resp = SendRequest (req.Stream); - } catch (KeyringException ke) { - if (ke.ResultCode == ResultCode.Denied) - return empty_net_item_data; - throw; + IntPtr passwordList; + + ResultCode result = gnome_keyring_find_network_password_sync (user, domain, server, obj, protocol, authtype, (uint)port, out passwordList); + + if (result == ResultCode.Denied) { + return empty_net_item_data; + } + + if (result != ResultCode.Ok) { + throw new KeyringException (result); } + + IntPtr[] passwordStructs = (IntPtr[])GLib.Marshaller.ListPtrToArray (passwordList, typeof(GLib.List), false, false, typeof(IntPtr)); + List passwords = new List (); + + foreach (IntPtr ptr in passwordStructs) { + passwords.Add ((GnomeKeyringNetworkPasswordData)Marshal.PtrToStructure (ptr, typeof(GnomeKeyringNetworkPasswordData))); + } + ArrayList list = new ArrayList (); - while (resp.DataAvailable) { + foreach (var password in passwords) { NetItemData found = new NetItemData (); - found.Keyring = resp.GetString (); - found.ItemID = resp.GetInt32 (); - found.Secret = resp.GetString (); + found.Keyring = Marshal.PtrToStringAnsi (password.keyring); + found.ItemID = (int)password.item_id; + found.Secret = Marshal.PtrToStringAnsi (password.password); found.Attributes = new Hashtable (); - resp.ReadAttributes (found.Attributes); + + SetAttributeIfNonNull (found.Attributes, "protocol", password.protocol); + SetAttributeIfNonNull (found.Attributes, "server", password.server); + SetAttributeIfNonNull (found.Attributes, "object", password.@object); + SetAttributeIfNonNull (found.Attributes, "authtype", password.authtype); + SetAttributeIfNonNull (found.Attributes, "user", password.user); + SetAttributeIfNonNull (found.Attributes, "domain", password.domain); + + if (password.port != 0) { + found.Attributes["port"] = (int)password.port; + } + found.SetValuesFromAttributes (); list.Add (found); } return (NetItemData []) list.ToArray (typeof (NetItemData)); } + + static void SetAttributeIfNonNull (Hashtable attrs, string key, IntPtr maybeString) + { + if (maybeString != IntPtr.Zero) { + attrs[key] = Marshal.PtrToStringAnsi (maybeString); + } + } + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_item_create_sync (string keyring, + ItemType type, + string displayName, + IntPtr attributes, + IntPtr secret, + bool updateIfExists, + out UInt32 itemId); + + [DllImport ("libgnome-keyring.dll")] + static extern IntPtr gnome_keyring_memory_strdup (string str); + [DllImport ("libgnome-keyring.dll")] + static extern void gnome_keyring_memory_free (IntPtr str); + [DllImport ("libgnome-keyring.dll")] + static extern void gnome_keyring_attribute_list_append_string (IntPtr attributes, string name, string val); + [DllImport("libgnome-keyring.dll")] + static extern void gnome_keyring_attribute_list_append_uint32 (IntPtr attributes, string name, UInt32 val); + [DllImport ("libgnome-keyring.dll")] + static extern void gnome_keyring_attribute_list_free (IntPtr attributes); + [DllImport ("gnome-keyring-sharp-glue.dll")] + static extern IntPtr gks_attribute_list_new (); + public static int CreateItem (string keyring, ItemType type, string displayName, Hashtable attributes, string secret, bool updateIfExists) { - RequestMessage req = new RequestMessage (); - req.StartOperation (Operation.CreateItem); - req.Write (keyring); - req.Write (displayName); - req.Write (secret); - req.WriteAttributes (attributes); - req.Write ((int) type); - req.Write (updateIfExists ? 1 : 0); - req.EndOperation (); - ResponseMessage resp = SendRequest (req.Stream); - return resp.GetInt32 (); + uint id; + IntPtr secure_secret = gnome_keyring_memory_strdup (secret); + IntPtr attrs = gks_attribute_list_new (); + + NativeListFromAttributes (attrs, attributes); + + ResultCode result = gnome_keyring_item_create_sync (keyring, type, displayName, attrs, secure_secret, updateIfExists, out id); + + gnome_keyring_attribute_list_free (attrs); + gnome_keyring_memory_free (secure_secret); + + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } + + return (int)id; } + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_item_delete_sync (string keyring, UInt32 id); + public static void DeleteItem (string keyring, int id) { if (keyring == null) throw new ArgumentNullException ("keyring"); - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.DeleteItem, keyring, id); - SendRequest (req.Stream); + ResultCode result = gnome_keyring_item_delete_sync (keyring, (uint)id); + + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } } + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_set_network_password_sync (string keyring, + string user, + string domain, + string server, + string @object, + string protocol, + string authType, + UInt32 port, + string password, + out UInt32 id); + public static int CreateOrModifyNetworkPassword (string keyring, string user, string domain, string server, string obj, string protocol, string authtype, int port, string password) { - Hashtable tbl = new Hashtable (); - tbl ["user"] = user; - tbl ["domain"] = domain; - tbl ["server"] = server; - tbl ["object"] = obj; - tbl ["protocol"] = protocol; - tbl ["authtype"] = authtype; - if (port != 0) - tbl ["port"] = port; - - string display_name; - if (port != 0) - display_name = String.Format ("{0}@{1}:{3}/{2}", user, server, obj, port); - else - display_name = String.Format ("{0}@{1}/{2}", user, server, obj); - - return CreateItem (keyring, ItemType.NetworkPassword, display_name, tbl, password, true); + uint id; + ResultCode result = gnome_keyring_set_network_password_sync (keyring, user, domain, server, obj, protocol, authtype, (uint)port, password, out id); + + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } + + return (int)id; } + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_item_get_info_sync (string keyring, UInt32 id, out IntPtr itemInfo); + [DllImport ("libgnome-keyring.dll")] + static extern ItemType gnome_keyring_item_info_get_type (IntPtr itemInfo); + [DllImport("libgnome-keyring.dll")] + static extern IntPtr gnome_keyring_item_info_get_ctime (IntPtr itemInfo); + [DllImport("libgnome-keyring.dll")] + static extern IntPtr gnome_keyring_item_info_get_mtime (IntPtr itemInfo); + [DllImport("libgnome-keyring.dll")] + static extern IntPtr gnome_keyring_item_info_get_display_name (IntPtr itemInfo); + [DllImport("libgnome-keyring.dll")] + static extern IntPtr gnome_keyring_item_info_get_secret (IntPtr itemInfo); + [DllImport("libgnome-keyring.dll")] + static extern void gnome_keyring_item_info_free (IntPtr itemInfo); + public static ItemData GetItemInfo (string keyring, int id) { if (keyring == null) throw new ArgumentNullException ("keyring"); - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.GetItemInfo, keyring, id); - ResponseMessage resp = SendRequest (req.Stream); - ItemType itype = (ItemType) resp.GetInt32 (); - ItemData item = ItemData.GetInstanceFromItemType (itype); - string name = resp.GetString (); - string secret = resp.GetString (); - DateTime mtime = resp.GetDateTime (); - DateTime ctime = resp.GetDateTime (); + IntPtr itemInfo; + + ResultCode result = gnome_keyring_item_get_info_sync (keyring, (uint)id, out itemInfo); + + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } + + ItemData item = ItemData.GetInstanceFromItemType (gnome_keyring_item_info_get_type (itemInfo)); + item.Attributes = new Hashtable (); + item.Attributes["keyring_ctime"] = GLib.Marshaller.time_tToDateTime (gnome_keyring_item_info_get_ctime (itemInfo)); + item.Attributes["keyring_mtime"] = GLib.Marshaller.time_tToDateTime (gnome_keyring_item_info_get_mtime (itemInfo)); + item.Attributes["name"] = Marshal.PtrToStringAnsi (gnome_keyring_item_info_get_display_name (itemInfo)); + item.Keyring = keyring; item.ItemID = id; - item.Secret = secret; - Hashtable tbl = new Hashtable (); - tbl ["name"] = name; - tbl ["keyring_ctime"] = ctime; - tbl ["keyring_mtime"] = mtime; - item.Attributes = tbl; + item.Secret = Marshal.PtrToStringAnsi (gnome_keyring_item_info_get_secret (itemInfo)); + item.SetValuesFromAttributes (); + + gnome_keyring_item_info_free (itemInfo); + return item; } + + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_item_set_info_sync (string keyring, UInt32 id, IntPtr itemInfo); + [DllImport ("libgnome-keyring.dll")] + static extern IntPtr gnome_keyring_item_info_new (); + [DllImport ("libgnome-keyring.dll")] + static extern void gnome_keyring_item_info_set_display_name (IntPtr itemInfo, string displayName); + [DllImport("libgnome-keyring.dll")] + static extern void gnome_keyring_item_info_set_type (IntPtr itemInfo, ItemType type); + [DllImport("libgnome-keyring.dll")] + static extern void gnome_keyring_item_info_set_secret (IntPtr itemInfo, string secret); public static void SetItemInfo (string keyring, int id, ItemType type, string displayName, string secret) { if (keyring == null) throw new ArgumentNullException ("keyring"); - RequestMessage req = new RequestMessage (); - req.StartOperation (Operation.SetItemInfo); - req.Write (keyring); - req.Write (id); - req.Write ((int) type); - req.Write (displayName); - req.Write (secret); - req.EndOperation (); - SendRequest (req.Stream); + IntPtr itemInfo = gnome_keyring_item_info_new (); + gnome_keyring_item_info_set_display_name (itemInfo, displayName); + gnome_keyring_item_info_set_type (itemInfo, type); + gnome_keyring_item_info_set_secret (itemInfo, secret); + + ResultCode result = gnome_keyring_item_set_info_sync (keyring, (uint)id, itemInfo); + + gnome_keyring_item_info_free (itemInfo); + + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } } + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_item_get_attributes_sync (string keyring, UInt32 id, out IntPtr attributes); + [DllImport ("gnome-keyring-sharp-glue.dll")] + static extern int gks_item_attribute_list_get_length (IntPtr attrList); + [DllImport ("gnome-keyring-sharp-glue.dll")] + static extern bool gks_item_attribute_list_index_is_string (IntPtr attrList, int index); + [DllImport("gnome-keyring-sharp-glue.dll")] + static extern bool gks_item_attribute_list_index_is_uint32 (IntPtr attrList, int index); + [DllImport ("gnome-keyring-sharp-glue.dll")] + static extern IntPtr gks_item_attribute_list_get_index_string (IntPtr attrList, int index); + [DllImport ("gnome-keyring-sharp-glue.dll")] + static extern UInt32 gks_item_attribute_list_get_index_uint32 (IntPtr attrList, int index); + [DllImport ("gnome-keyring-sharp-glue.dll")] + static extern IntPtr gks_item_attribute_list_get_index_key (IntPtr attrList, int index); + public static Hashtable GetItemAttributes (string keyring, int id) { if (keyring == null) throw new ArgumentNullException ("keyring"); - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.GetItemAttributes, keyring, id); - ResponseMessage resp = SendRequest (req.Stream); - Hashtable tbl = new Hashtable (); - resp.ReadAttributes (tbl); - return tbl; + IntPtr attributes; + Hashtable retVal = new Hashtable (); + + ResultCode result = gnome_keyring_item_get_attributes_sync (keyring, (uint)id, out attributes); + + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } + + AttributesFromNativeList (attributes, retVal); + + gnome_keyring_attribute_list_free (attributes); + + return retVal; } + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_item_set_attributes_sync (string keyring, UInt32 id, IntPtr attrList); + public static void SetItemAttributes (string keyring, int id, Hashtable atts) { if (keyring == null) throw new ArgumentNullException ("keyring"); - RequestMessage req = new RequestMessage (); - req.StartOperation (Operation.SetItemAttributes); - req.Write (keyring); - req.Write (id); - req.WriteAttributes (atts); - req.EndOperation (); - SendRequest (req.Stream); + IntPtr attrList = gks_attribute_list_new (); + foreach (string key in atts.Keys) { + if (atts[key] is string) { + gnome_keyring_attribute_list_append_string (attrList, key, (string)atts[key]); + } else if (atts[key] is int) { + gnome_keyring_attribute_list_append_uint32 (attrList, key, (uint)((int)atts[key])); + } else { + throw new ArgumentException (String.Format ("Attribute \"{0}\" has invalid parameter type: {1}", key, atts[key].GetType ())); + } + } + + ResultCode result = gnome_keyring_item_set_attributes_sync (keyring, (uint)id, attrList); + + gnome_keyring_attribute_list_free (attrList); + + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } } + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_get_info_sync (string keyringName, out IntPtr keyringInfo); + [DllImport ("libgnome-keyring.dll")] + static extern void gnome_keyring_info_free (IntPtr keyringInfo); + [DllImport ("libgnome-keyring.dll")] + static extern IntPtr gnome_keyring_info_get_ctime (IntPtr keyringInfo); + [DllImport ("libgnome-keyring.dll")] + static extern IntPtr gnome_keyring_info_get_mtime (IntPtr keyringInfo); + [DllImport ("libgnome-keyring.dll")] + static extern int gnome_keyring_info_get_lock_timeout (IntPtr keyringInfo); + [DllImport("libgnome-keyring.dll")] + static extern bool gnome_keyring_info_get_is_locked (IntPtr keyringInfo); + [DllImport("libgnome-keyring.dll")] + static extern bool gnome_keyring_info_get_lock_on_idle (IntPtr keyringInfo); + public static KeyringInfo GetKeyringInfo (string keyring) { if (keyring == null) throw new ArgumentNullException ("keyring"); - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.GetKeyringInfo, keyring); - ResponseMessage resp = SendRequest (req.Stream); - return new KeyringInfo (keyring, (resp.GetInt32 () != 0), - resp.GetInt32 (), - resp.GetDateTime (), - resp.GetDateTime (), - (resp.GetInt32 () != 0)); + IntPtr keyring_info = IntPtr.Zero; + ResultCode result = gnome_keyring_get_info_sync (keyring, out keyring_info); + + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } + + DateTime ctime = GLib.Marshaller.time_tToDateTime (gnome_keyring_info_get_ctime (keyring_info)); + DateTime mtime = GLib.Marshaller.time_tToDateTime (gnome_keyring_info_get_mtime (keyring_info)); + KeyringInfo retval = new KeyringInfo (keyring, + gnome_keyring_info_get_lock_on_idle (keyring_info), + gnome_keyring_info_get_lock_timeout (keyring_info), + mtime, + ctime, + gnome_keyring_info_get_is_locked (keyring_info) + ); + + + gnome_keyring_info_free (keyring_info); + return retval; } + + [DllImport ("libgnome-keyring.dll")] + static extern ResultCode gnome_keyring_set_info_sync (string keyring, IntPtr keyringInfo); + [DllImport ("libgnome-keyring.dll")] + static extern void gnome_keyring_info_set_lock_timeout (IntPtr keyringInfo, UInt32 timeout); + [DllImport ("libgnome-keyring.dll")] + static extern void gnome_keyring_info_set_lock_on_idle (IntPtr keyringInfo, bool lockOnIdle); public static void SetKeyringInfo (string keyring, KeyringInfo info) { @@ -467,41 +652,47 @@ if (info == null) throw new ArgumentNullException ("info"); - RequestMessage req = new RequestMessage (); - req.StartOperation (Operation.SetKeyringInfo); - req.Write (keyring); - req.Write (info.LockOnIdle ? 1 : 0); - req.Write (info.LockTimeoutSeconds); - req.EndOperation (); - SendRequest (req.Stream); + + IntPtr keyring_info; + ResultCode result = gnome_keyring_get_info_sync (keyring, out keyring_info); + + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } + + gnome_keyring_info_set_lock_timeout (keyring_info, (uint)info.LockTimeoutSeconds); + gnome_keyring_info_set_lock_on_idle (keyring_info, info.LockOnIdle); + + result = gnome_keyring_set_info_sync (keyring, keyring_info); + + gnome_keyring_info_free (keyring_info); + + if (result != ResultCode.Ok) { + throw new KeyringException (result); + } } + [Obsolete ("Item ACLs are deprecated. GetItemACL never returns any ACLs")] public static ArrayList GetItemACL (string keyring, int id) { if (keyring == null) throw new ArgumentNullException ("keyring"); - RequestMessage req = new RequestMessage (); - req.CreateSimpleOperation (Operation.GetItemACL, keyring, id); - ResponseMessage resp = SendRequest (req.Stream); - int count = resp.GetInt32 (); - ArrayList list = new ArrayList (count); - for (int i = 0; i < count; i++) { - list.Add (new ItemACL (resp.GetString (), resp.GetString (), (AccessRights) resp.GetInt32 ())); - } - return list; + return new ArrayList (); } + [Obsolete("Item ACLs are deprecated. SetItemACL has no effect.")] public static void SetItemACL (string keyring, int id, ICollection acls) { if (acls == null) throw new ArgumentNullException ("acls"); - ItemACL [] arr = new ItemACL [acls.Count]; + ItemACL[] arr = new ItemACL[acls.Count]; acls.CopyTo (arr, 0); SetItemACL (keyring, id, arr); } - + + [Obsolete("Item ACLs are deprecated. SetItemACL has no effect.")] public static void SetItemACL (string keyring, int id, ItemACL [] acls) { if (keyring == null) @@ -512,28 +703,6 @@ if (acls.Length == 0) throw new ArgumentException ("Empty ACL set.", "acls"); - - RequestMessage req = new RequestMessage (); - req.StartOperation (Operation.SetItemACL); - req.Write (keyring); - req.Write (id); - req.Write (acls.Length); - foreach (ItemACL acl in acls) { - req.Write (acl.DisplayName); - req.Write (acl.FullPath); - req.Write ((int) acl.Access); - } - req.EndOperation (); - SendRequest (req.Stream); } } - -#if WITH_DBUS - [Interface ("org.gnome.keyring.Daemon")] - interface IDaemon - { - string GetSocketPath (); - } -#endif } - diff -urNad gnome-keyring-sharp-1.0.0~/src/Gnome.Keyring.dll.config gnome-keyring-sharp-1.0.0/src/Gnome.Keyring.dll.config --- gnome-keyring-sharp-1.0.0~/src/Gnome.Keyring.dll.config 1970-01-01 10:00:00.000000000 +1000 +++ gnome-keyring-sharp-1.0.0/src/Gnome.Keyring.dll.config 2010-03-30 17:34:12.346423305 +1100 @@ -0,0 +1,4 @@ + + + + diff -urNad gnome-keyring-sharp-1.0.0~/src/Makefile.am gnome-keyring-sharp-1.0.0/src/Makefile.am --- gnome-keyring-sharp-1.0.0~/src/Makefile.am 2008-08-09 03:36:12.000000000 +1000 +++ gnome-keyring-sharp-1.0.0/src/Makefile.am 2010-03-30 17:32:02.733918042 +1100 @@ -5,13 +5,13 @@ SNK=$(ASSEMBLY_NAME).snk pkgconfigdir=$(libdir)/pkgconfig -CSFLAGS+= -debug+ -debug:full -nologo -r:Mono.Posix.dll +CSFLAGS += -debug+ -debug:full -nologo -r:Mono.Posix.dll pkgconfig_DATA = gnome-keyring-sharp-1.0.pc -CLEANFILES = $(ASSEMBLY_NAME).* +CLEANFILES = $(ASSEMBLY_NAME).dll $(ASSEMBLY_NAME).dll.mdb $(ASSEMBLY_NAME).snk -gnomekeyring_references = $(DBUS_LIBS) +gnomekeyring_references = $(GLIB_SHARP_LIBS) gnomekeyring_sources = \ Gnome.Keyring/AccessRights.cs \ @@ -24,9 +24,6 @@ Gnome.Keyring/KeyringInfo.cs \ Gnome.Keyring/NetItemData.cs \ Gnome.Keyring/NoteItemData.cs \ - Gnome.Keyring/Operation.cs \ - Gnome.Keyring/RequestMessage.cs \ - Gnome.Keyring/ResponseMessage.cs \ Gnome.Keyring/ResultCode.cs \ Gnome.Keyring/Ring.cs @@ -50,3 +47,4 @@ echo "$(GACUTIL) /u $(ASSEMBLY_NAME) $(GACUTIL_FLAGS)"; \ $(GACUTIL) /u $(ASSEMBLY_NAME) /package $(PACKAGE)-$(API_VERSION) $(GACUTIL_FLAGS) || exit 1; +EXTRA_DIST=Gnome.Keyring.dll.config debian/patches/series0000644000000000000000000000007111615622404012031 0ustar 01pkgconfig-path.patch 02_gnome_2.30_compatibility.patch debian/control0000644000000000000000000000420111615622404010567 0ustar Source: gnome-keyring-sharp Section: gnome Priority: optional Maintainer: Debian CLI Libraries Team Uploaders: Mirco Bauer Build-Depends: debhelper (>= 7.0.50~), cli-common-dev (>= 0.5.7), automake, libtool, pkg-config (>= 0.9.0), mono-devel (>= 2.4.2.3), libglib2.0-cil-dev, monodoc-base, libgnome-keyring-dev Standards-Version: 3.8.4 Vcs-Browser: http://svn.debian.org/wsvn/pkg-cli-libs/packages/gnome-keyring-sharp/trunk/ Vcs-Svn: svn+ssh://svn.debian.org/svn/pkg-cli-libs/packages/gnome-keyring-sharp/trunk Package: libgnome-keyring1.0-cil Section: libs Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, ${cli:Depends} Description: CLI library to access the GNOME Keyring daemon GNOME Keyring is a system which allows you to store passwords and other sensitive data across GNOME applications. It provides an API to access this information, as well as a daemon to manage it. . gnome-keyring-sharp is a CIL library for the GNOME Keyring API, written in C#. . This package contains the gnome-keyring-sharp library Package: libgnome-keyring1.0-cil-dev Section: libs Architecture: any Depends: libgnome-keyring1.0-cil (= ${binary:Version}), ${misc:Depends} Replaces: libgnome-keyring1.0-cil (<< 1.0.0-2) Description: CLI library to access the GNOME Keyring daemon GNOME Keyring is a system which allows you to store passwords and other sensitive data across GNOME applications. It provides an API to access this information, as well as a daemon to manage it. . gnome-keyring-sharp is a CIL library for the GNOME Keyring API, written in C#. . This package contains development files for the gnome-keyring-sharp library Package: monodoc-gnome-keyring-manual Section: doc Architecture: all Depends: monodoc-manual, ${misc:Depends} Description: CLI library to access the GNOME Keyring daemon - manual GNOME Keyring is a system which allows you to store passwords and other sensitive data across GNOME applications. It provides an API to access this information, as well as a daemon to manage it. . This package contains the monodoc manual for the gnome-keyring CLI library