remove more dead code
[id3fs.git] / lib / ID3FS / Path.pm
index 4cf5fc2..dc5ea7e 100644 (file)
@@ -1,3 +1,19 @@
+# id3fs - a FUSE-based filesystem for browsing audio metadata
+# Copyright (C) 2010  Ian Beckwith <ianb@erislabs.net>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
 package ID3FS::Path;
 
 use strict;
@@ -79,7 +95,7 @@ sub dirents
 #    print "DIRENTS: FILE: $self->{path}\n";
     if($state==$STATE_ALL)
     {
-       @dents=($PATH_ALLTRACKS, $PATH_NOARTIST, $self->artists());
+       @dents=($self->filter($PATH_ALLTRACKS, $PATH_NOARTIST), $self->artists());
     }
     elsif($state==$STATE_TAG || $state==$STATE_TAGVAL)
     {
@@ -94,10 +110,7 @@ sub dirents
            {
                @dents=qw(AND OR);
            }
-           push(@dents, ($ENABLE_FILTER ?
-                         $self->filter($PATH_ALLTRACKS, $PATH_NOARTIST) :
-                         ($PATH_ALLTRACKS, $PATH_NOARTIST)));
-           push(@dents, $self->artists());
+           push(@dents, $self->filter($PATH_ALLTRACKS, $PATH_NOARTIST), $self->artists());
        }
     }
     elsif($state==$STATE_BOOLEAN)
@@ -116,7 +129,7 @@ sub dirents
     }
     elsif($state==$STATE_ALBUMS)
     {
-       @dents=($self->filter($PATH_ALLTRACKS, $PATH_NOALBUM), $self->albums());
+       @dents=$self->filter($PATH_ALLTRACKS, $PATH_NOALBUM, $self->albums());
     }
     elsif($state==$STATE_TRACKLIST)
     {
@@ -350,6 +363,9 @@ sub parse
     $self->{tagtree}=$self->elements_to_tree(\@elements);
     if($self->{tagtree})
     {
+#      use Data::Dumper;
+#      print "TREE\n";
+#      print Dumper $self->{tagtree};
 #      my ($conditions, @joins)=$self->{tagtree}->to_sql();
 #      print "CONDITIONS(", scalar(@joins), "): ", $conditions, "\n";
     }
@@ -675,7 +691,7 @@ sub filename
        print "FILENAME SQL: $sql\n" if($self->{verbose});
        my ($path, $name)=$self->{db}->cmd_onerow($sql, $id);
        my $id3fs_path=join('/', map { $_->{name}; }  @{$self->{elements}});
-       return($self->{db}->relativise($path, $name, $mountpoint));
+       return($self->{db}->relativise($path, $name, $mountpoint, $self->{path}));
     }
     # should never happen
     return "ERROR";
@@ -685,19 +701,9 @@ sub tags_subselect
 {
     my($self)=@_;
     my $hasvals=$self->expecting_values();
-    if($self->{in_all})
-    {
-       # FIXME: is this used?
-       die "IN_ALL CALLED!!\n";
-       return "\tSELECT id FROM files AS files_id\n";
-    }
     my $tree=$self->{tagtree};
-    # FIXME
-    print "UNDEF!!\n" unless($self->{tagtree});
     my $parent=$self->trailing_tag_parent();
 
-#    print "ELEMENTS: ", join('/', map { $_->{name}; } @{$self->{elements}}), "\n";
-#    print "TREE: ", $tree->print(), "\n";
     my $tag=undef;
     if($hasvals)
     {
@@ -753,48 +759,13 @@ sub sql_start
     return $sql;
 }
 
-# FIXME: remove
-sub constraints_tag_list
-{
-    my($self, @constraints)=@_;
-    my $lasttag=undef;
-    my @tags=();
-    my @tags_vals=();
-    for my $constraint (@constraints)
-    {
-#      print ref($constraint), ": ", $constraint->{name}, "\n";
-       if($self->is("tag", $constraint))
-       {
-           if(defined($lasttag))
-           {
-#              print "TAGVAL\n";
-               push(@tags_vals, [$lasttag, $constraint->id()]) if defined($constraint->id());
-               $lasttag=undef;
-           }
-           elsif($self->tag_has_values($constraint->id()))
-           {
-#              print "HASVALUES\n";
-               $lasttag=$constraint->id() if defined($constraint->id());
-           }
-           else
-           {
-#              print "NOVALUES\n";
-               push(@tags, $constraint->id()) if(defined($constraint->id()));
-           }
-       }
-    }
-    @tags=map{ "\"$_\""; } @tags;
-    @tags_vals=map( { [ map({ "\"$_\""; } @$_ ) ] } @tags_vals);
-    $lasttag="\"$lasttag\"" if defined($lasttag);
-    return(\@tags, \@tags_vals, $lasttag);
-}
-
 # we just filter $ALLTRACKS, $NOARTIST and $NOALBUM
 # filtering tags properly requires up to four levels of recursion
 # (tag/tagval/AND/NOT) and is too slow
 sub filter
 {
     my($self, @dirs)=@_;
+    return(@dirs) unless($ENABLE_FILTER);
     my $base=$self->{path};
     my @outdirs=();
     for my $dir (@dirs)