Skip to content

Commit

Permalink
Abstracted/Refactored much of the inner workings - it's possible now …
Browse files Browse the repository at this point in the history
…to also expose other libraries (iPods!) via the same interface without much effort (I guess).
  • Loading branch information
znek committed May 22, 2007
1 parent eebd857 commit 19ebb5b
Show file tree
Hide file tree
Showing 12 changed files with 362 additions and 173 deletions.
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.1</string>
<string>1.0.2</string>
<key>FUSEFileSystemClass</key>
<string>iTunesFileSystem</string>
<key>NSMainNibFile</key>
Expand Down
11 changes: 11 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ DetailedTrackNames | BOOL | NO | If YES, use very detailed information
track number, etc.)


TODO / IDEAS
============

- Expose Library and iPods at root mount point
- need to be able to identify (easy) and parse (more difficult, but already
did that for PodLifter) iPod databases
- abstract iTunesLibrary (superclass: Library) and add iPodLibrary
- Refresh libraries upon changes (need watchdog for this)
- Listen for attached/detached iPods


References
==========

Expand Down
4 changes: 2 additions & 2 deletions Resources/English.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Localized versions of Info.plist keys */

CFBundleName = "iTunesFS";
CFBundleShortVersionString = "1.0.1";
CFBundleGetInfoString = "iTunesFS version 1.0.1, Copyright 2007 Mulle kybernetiK.";
CFBundleShortVersionString = "1.0.2";
CFBundleGetInfoString = "iTunesFS version 1.0.2, Copyright 2007 Mulle kybernetiK.";
NSHumanReadableCopyright = "Copyright 2007 Mulle kybernetiK.";
2 changes: 1 addition & 1 deletion Version
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

MAJOR_VERSION=1
MINOR_VERSION=0
SUBMINOR_VERSION=1
SUBMINOR_VERSION=2
12 changes: 12 additions & 0 deletions iTunesFS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
7F74EF2D0B4C1BEC00CFA0C0 /* iTunesFileSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7F74EF2C0B4C1BEC00CFA0C0 /* iTunesFileSystem.m */; };
7FEAC1D10B446B70008EF420 /* FUSEFileSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 7FEAC1C50B446B70008EF420 /* FUSEFileSystem.m */; };
7FEAC1D30B446B70008EF420 /* FUSEMain.m in Sources */ = {isa = PBXBuildFile; fileRef = 7FEAC1C80B446B70008EF420 /* FUSEMain.m */; };
AD15A2190C03208500345C9E /* iTunesPlaylist.m in Sources */ = {isa = PBXBuildFile; fileRef = AD15A2180C03208500345C9E /* iTunesPlaylist.m */; };
AD15A22C0C03248C00345C9E /* iTunesTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = AD15A22B0C03248C00345C9E /* iTunesTrack.m */; };
AD37A2040C01C58000DF1291 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = AD37A2030C01C58000DF1291 /* MainMenu.nib */; };
AD37A2970C01C87E00DF1291 /* iTunesLibrary.m in Sources */ = {isa = PBXBuildFile; fileRef = AD37A2960C01C87E00DF1291 /* iTunesLibrary.m */; };
ADBDA9200C02CF48004CF795 /* Version in Resources */ = {isa = PBXBuildFile; fileRef = ADBDA91F0C02CF48004CF795 /* Version */; };
Expand Down Expand Up @@ -47,6 +49,10 @@
7FEAC1C40B446B70008EF420 /* FUSEFileSystem.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FUSEFileSystem.h; sourceTree = "<group>"; };
7FEAC1C50B446B70008EF420 /* FUSEFileSystem.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FUSEFileSystem.m; sourceTree = "<group>"; };
7FEAC1C80B446B70008EF420 /* FUSEMain.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FUSEMain.m; sourceTree = "<group>"; };
AD15A2170C03208500345C9E /* iTunesPlaylist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iTunesPlaylist.h; sourceTree = "<group>"; };
AD15A2180C03208500345C9E /* iTunesPlaylist.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iTunesPlaylist.m; sourceTree = "<group>"; };
AD15A22A0C03248C00345C9E /* iTunesTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iTunesTrack.h; sourceTree = "<group>"; };
AD15A22B0C03248C00345C9E /* iTunesTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iTunesTrack.m; sourceTree = "<group>"; };
AD37A1FB0C01C57400DF1291 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = "<group>"; };
AD37A2950C01C87E00DF1291 /* iTunesLibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = iTunesLibrary.h; sourceTree = "<group>"; };
AD37A2960C01C87E00DF1291 /* iTunesLibrary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = iTunesLibrary.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -107,6 +113,10 @@
7F74EF2C0B4C1BEC00CFA0C0 /* iTunesFileSystem.m */,
AD37A2950C01C87E00DF1291 /* iTunesLibrary.h */,
AD37A2960C01C87E00DF1291 /* iTunesLibrary.m */,
AD15A2170C03208500345C9E /* iTunesPlaylist.h */,
AD15A2180C03208500345C9E /* iTunesPlaylist.m */,
AD15A22A0C03248C00345C9E /* iTunesTrack.h */,
AD15A22B0C03248C00345C9E /* iTunesTrack.m */,
ADBDABA70C02FF10004CF795 /* NSString+Extensions.h */,
ADBDABA80C02FF10004CF795 /* NSString+Extensions.m */,
);
Expand Down Expand Up @@ -271,6 +281,8 @@
7F3627720B8521EE0020679E /* NSString+CarbonFSRefCreation.m in Sources */,
AD37A2970C01C87E00DF1291 /* iTunesLibrary.m in Sources */,
ADBDABA90C02FF10004CF795 /* NSString+Extensions.m in Sources */,
AD15A2190C03208500345C9E /* iTunesPlaylist.m in Sources */,
AD15A22C0C03248C00345C9E /* iTunesTrack.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
18 changes: 9 additions & 9 deletions iTunesFileSystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,35 +91,36 @@ - (BOOL)fileExistsAtPath:(NSString *)path isDirectory:(BOOL *)isDirectory {
else if (count == 2) { /* playlist */
return [[self->lib playlistNames] containsObject:[components lastObject]];
}
return [self->lib isValidTrackName:[components objectAtIndex:2]];
return [self->lib isValidTrackName:[components objectAtIndex:2]
inPlaylistNamed:[components objectAtIndex:1]];
}

- (NSDictionary *)fileAttributesAtPath:(NSString *)_path {
NSArray *components;
unsigned count;
NSString *plName, *name, *trackID;
NSString *plName, *name;

components = [_path pathComponents];
count = [components count];
if (count < 3) return [super fileAttributesAtPath:_path];
plName = [components objectAtIndex:1];
name = [components lastObject];
trackID = [self->lib trackIDForPrettyTrackName:name inPlaylistNamed:plName];
return [self->lib fileAttributesForTrackWithID:trackID];
return [self->lib fileAttributesForTrackWithPrettyName:name
inPlaylistNamed:plName];
}

- (NSData *)contentsAtPath:(NSString *)_path {
NSArray *components;
unsigned count;
NSString *plName, *name, *trackID;
NSString *plName, *name;

components = [_path pathComponents];
count = [components count];
if (count < 3) return nil;
plName = [components objectAtIndex:1];
name = [components lastObject];
trackID = [self->lib trackIDForPrettyTrackName:name inPlaylistNamed:plName];
return [self->lib dataForTrackWithID:trackID];
return [self->lib fileContentForTrackWithPrettyName:name
inPlaylistNamed:plName];
}

/* optional */
Expand All @@ -135,8 +136,7 @@ - (BOOL)usesResourceForks {
}

- (NSString *)iconFileForPath:(NSString *)_path {
if ([_path isEqualToString:@"/"])
return fsIconPath;
if ([_path isEqualToString:@"/"]) return fsIconPath;
return nil;
}

Expand Down
13 changes: 6 additions & 7 deletions iTunesLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,23 @@

@interface iTunesLibrary : NSObject
{
NSDictionary *lib;
NSArray *playlists; // retained by lib!
NSDictionary *tracks; // retained by lib!
NSMutableDictionary *plMap;
}

- (void)reload;

- (NSString *)libraryPath;

- (NSArray *)playlistNames;
- (NSArray *)trackNamesForPlaylistNamed:(NSString *)_plName;

- (BOOL)isValidTrackName:(NSString *)_ptn;
- (NSString *)trackIDForPrettyTrackName:(NSString *)_ptn
- (BOOL)isValidTrackName:(NSString *)_ptn inPlaylistNamed:(NSString *)_plName;

- (NSData *)fileContentForTrackWithPrettyName:(NSString *)_ptn
inPlaylistNamed:(NSString *)_plName;

- (NSData *)dataForTrackWithID:(NSString *)_trackID;
- (NSDictionary *)fileAttributesForTrackWithID:(NSString *)_trackID;
- (NSDictionary *)fileAttributesForTrackWithPrettyName:(NSString *)_ptn
inPlaylistNamed:(NSString *)_plName;

@end /* iTunesLibrary */

Expand Down
Loading

0 comments on commit 19ebb5b

Please sign in to comment.