"ma acc --list" and "ma acc --modify" should work foerste
authorMatthias Förste foerste@schlittermann.de
Fri, 25 Nov 2011 13:22:20 +0100
branchfoerste
changeset 43 231984cb81a7
parent 42 b90dc89e8c66
child 44 35441e1ae083
"ma acc --list" and "ma acc --modify" should work
account.pm
--- a/account.pm	Thu Nov 24 14:37:23 2011 +0100
+++ b/account.pm	Fri Nov 25 13:22:20 2011 +0100
@@ -413,30 +413,29 @@
 	    #print " INTERNAL";
 	#}
 
+
         $imap->login("$uid*" . $Cf->imap_admin, $imap_password ) or die $@;
-        my $m = $imap->list('', '*') or die $@;
-        use Data::Dumper;
-verbose Dumper $m;
-        my $q = $imap->getquotaroot($m->[0]->[2]) or die $@;
-verbose Dumper $q;
-        $q = $imap->getquota($m->[0]->[2]) or die $@;
-verbose Dumper $q;
+        my $folders = $imap->list('', '*') or die $@;
+        my %q;
+        for my $f(@{$folders}) {
+            # single folder sieht wie folgt aus: [[flag1, flag2, ...], separator, foldername]
+            my $q = $imap->getquotaroot($f->[2]) or die $@;
+            delete $q->{quotaroot};
+            %q = ( %q, %{$q} );
+        }
 
-	MBOX: {
-	    if (!$imap->list()) {
-		print ", no mbox";
-		last MBOX;
-	    }
-	    print ", mbox";
-	    my %q = $imap->listquota();
-	    my ($used, $max) = map { int($_ / 1024) } @{$q{STORAGE}};
-
-	    if (!$max) {
-		print ", no quota";
-		last MBOX;
-	    }
-	    print ", quota ($used/$max): " . int(100 * $used/$max) . "%";
-	}
+        # da wir uns anmelden konnten haben wir auch eine 'mbox'
+        print ", mbox";
+        my $has_quota;
+        for my $qr(keys %q) {
+            my @q = @{$q{$qr}};
+            my $elem = '';
+            $elem = shift @q while defined $elem and $elem ne 'STORAGE';
+            my ($used, $max) = map { int($_ / 1024) } @q[0..1];
+            print ", quota '$qr': $used/${max}MB " . int(100 * $used/$max) . "%";
+            $has_quota = 1;
+        }
+        print ", no quota" unless $has_quota;
 	print "\n";
 
 	print "\tPassword: ", $> == 0 ? $e->get_value("userPassword") : "*", "\n";