summaryrefslogtreecommitdiff
path: root/test-backends.in
diff options
context:
space:
mode:
Diffstat (limited to 'test-backends.in')
-rwxr-xr-xtest-backends.in89
1 files changed, 89 insertions, 0 deletions
diff --git a/test-backends.in b/test-backends.in
new file mode 100755
index 0000000..83cde61
--- /dev/null
+++ b/test-backends.in
@@ -0,0 +1,89 @@
+#!/usr/bin/env perl
+
+use lib "@netdbusdir@";
+
+use Net::DBus;
+use Net::DBus::Reactor;
+
+sub print_tabified
+{
+ my ($tab, $str, $do_cr) = @_;
+
+ print " " x $tab;
+ print $str;
+ print "\n" if ($do_cr);
+}
+
+sub print_recursive
+{
+ my ($obj, $tab) = @_;
+
+ if (ref $obj eq "ARRAY")
+ {
+ print_tabified ($tab, "ARRAY = [", 1);
+
+ foreach $elem (@{$obj})
+ {
+ print_recursive ($elem, $tab + 2);
+ }
+
+ print_tabified ($tab, "]", 1);
+ }
+ elsif (ref $obj eq "HASH")
+ {
+ print_tabified ($tab, "HASH = {", 1);
+
+ foreach $elem (keys %$obj)
+ {
+ $sibling_ref = ref $$obj{$elem};
+
+ #print child arrays and hashes in a new line
+ print_tabified ($tab + 2, "'$elem'\t=>" , ($sibling_ref eq "ARRAY" || $sibling_ref eq "HASH"));
+ print_recursive ($$obj{$elem}, $tab + 4);
+ }
+
+ print_tabified ($tab, "}", 1);
+ }
+ else
+ {
+ print_tabified ($tab, $obj, 1);
+ }
+}
+
+sub print_object
+{
+ my ($service, $object) = @_;
+ my ($item);
+
+ my $obj = $service->get_object ("/org/freedesktop/SystemToolsBackends/$object");
+ my @arr = $obj->get ();
+
+ foreach $i (@arr) {
+ &print_recursive ($i, 0);
+ }
+}
+
+# Main program
+my $bus = Net::DBus->system;
+my $service = $bus->get_service("org.freedesktop.SystemToolsBackends");
+
+if (!$ARGV[0])
+{
+ print "Which backend object do you want to query? (i.e.: UsersConfig):\n";
+ $object = <STDIN>;
+ chomp $object;
+
+ print_object ($service, $object);
+}
+else
+{
+ foreach $i (@ARGV)
+ {
+ chomp $i;
+ print "$i\n================================\n";
+ print_object ($service, $i);
+ print "\n\n";
+ }
+}
+
+print "Have a good day!\n";