Commits

Marcin Kasperski  committed 10dabf3

Experiments

  • Participants
  • Parent commits 179cc79

Comments (0)

Files changed (2)

File experiments/kwallet_by_dbus.pl

+#!/usr/bin/perl -w
+
+# See http://stderr.org/doc/kde/HTML/en/kdelibs-apidocs/kwallet/html/classKWallet_1_1Wallet.html
+
+use strict;
+use Net::DBus;
+use Data::Dumper;
+use feature 'say';
+
+my $APP_NAME = "DBUStest";
+
+my $dbus = Net::DBus->session()
+  or die("KWallet not available (can't access DBus)");
+#print "dbus: ", Dumper($dbus);
+say "DBus connected"; 
+
+my $kwallet_svc = $dbus->get_service('org.kde.kwalletd')
+  or die("KWallet not available (can't access KWallet, likely kwalletd not running)");
+#print "kwalletd: ", Dumper($kwallet_svc);
+say "org.kde.kwalletd connected";
+
+my $kwallet = $kwallet_svc->get_object('/modules/kwalletd', 'org.kde.KWallet')
+  or die("Kwallet not available (can't find wallet)");
+#print "kwallet: ", Dumper($kwallet);
+say "/modules/kwalletd connected";
+# $kwallet = $kwallet->as_interface(...);
+
+# This is text name
+my $net_wallet = $kwallet->networkWallet()
+  or die "No net wallet";
+say "net_wallet id: $net_wallet";
+
+my $handle = $kwallet->open($net_wallet, 0, $APP_NAME)
+  or die "No handle";
+say "Opened, handle = $handle";
+
+say "*****************************************************************";
+say "* API information";
+say "*****************************************************************";
+
+use List::MoreUtils qw(pairwise zip);
+
+say "Supported interfaces:\n    ", join("\n    ", keys(%{$kwallet->{introspector}->{interfaces}}));
+say "org.kde.KWallet methods:";
+my $methods = $kwallet->{introspector}->{interfaces}->{'org.kde.KWallet'}->{methods};
+foreach my $methodName (sort keys %$methods) {
+    my $spec = $methods->{$methodName};
+    say "- $methodName ", $spec->{deprecated} ? "DEPRECATED" : "";
+    say "    Params:";
+    foreach my $paramSpec (pairwise {"$a: $b"} @{$spec->{paramnames}}, @{$spec->{params}}) {
+        say "      $paramSpec";
+    }
+    unless($spec->{no_reply}) {
+        say "    Returns:";
+        foreach my $retSpec (pairwise {($a || ''). ": $b"} @{$spec->{returnnames}}, @{$spec->{returns}}) {
+            say "      $retSpec";
+        }
+    } else {
+        say "    No reply";
+    }
+    #print Dumper($spec);
+}
+
+say "*****************************************************************";
+
+
+my $is_open = $kwallet->isOpen($handle);
+say "is open: $is_open";
+
+my $folders = $kwallet->folderList($handle, $APP_NAME);
+say "Folders = ", join(", ", @$folders);
+
+
+$kwallet->close($handle, 'force');
+say "Closed $handle";
+
+$is_open = $kwallet->isOpen($handle);
+say "is open($handle): $is_open";
+
+
+__END__
+
+
+$kwallet->createFolder($kwallet_handle, "Test Folder", $APP_NAME);
+
+$kwallet->writePassword( handle, folder, key, value, appid ):
+#???$kwallet->changePassword($kwallet_handle
+
+$kwallet->close();
+
+
+my $pwd = $KWallet->readPassword($kwallet_handle, 'Test Folder', 'Some Key', $APP_NAME);
+
+my $pwd = $KWallet->readPasswordList($kwallet_handle, 'Test Folder', 'Some Key', $APP_NAME);
+
+# entryList( handle, folder, appid )
+# entryType( handle, folder, key, appid)
+# hasEntry( handle, folder, key, appid )
+# hasFolder( handle, folder, appid )
+# removeFolder( handle, folder, appid )
+# isEnabled
+# isOpen(handle)
+# readEntry(handle, folder, key, appid)
+# readEntryList(handle, folder, key, appid)

File lib/Passwd/Keyring/KDEWallet.pm

 
 our $VERSION = '0.21';
 
+our $APP_NAME = "Passwd::Keyring";
+
 =head1 SYNOPSIS
 
 KDE Wallet based implementation of L<Passwd::Keyring>.
       or croak("KWallet not available (can't access KWallet, likely kwalletd not running)");
     my $kwallet = $self->{kwallet_svc}->get_object('/modules/kwalletd', 'org.kde.KWallet')
       or croak("Kwallet not available (can't find wallet)");
+
+    use Data::Dumper;
+    print Dumper($kwallet);
+
     $self->{kwallet} = $kwallet->networkWallet();
-
-    print "Network Wallet = $networkWallet\n";
+    print Dumper($self->{kwallet});
+    print "Wallet = $self->{kwallet}\n";
 
     # TODO: later
-    my $kwallet_handle = $KWallet->open($self->{kwallet}, 0, $app_name);
+    my $kwallet_handle = $self->{kwallet}->open($self->{kwallet}, 0, $APP_NAME);
     print "Opened = $kwallet_handle\n";
 
-    my $folders = $KWallet->folderList($kwallet_handle,$app_name);
+    my $folders = $self->{kwallet}->folderList($kwallet_handle, $APP_NAME);
     print "Folders = ", dump($folders);
 
     return $self;
 
 sub get_password {
     my ($self, $user_name, $domain) = @_;
-    my $u = $KWallet->readPassword($kwallet_handle, 'MyFolder','Some_Userid_Key', $app_name);
-    say "Password = ", dump($p);
+#    my $pwd = $KWallet->readPassword($kwallet_handle, 'MyFolder','Some_Userid_Key', $APP_NAME);
+#    print "Password = ", dump($pwd), "\n";
 }
 
 =head2 clear_password($user_name, $domain)