1/* 2 * Copyright (c) 2003-2008 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24 25//----------------------------------------------------------------------------- 26// Includes 27//----------------------------------------------------------------------------- 28 29#define DEBUG_ASSERT_COMPONENT_NAME_STRING "CDDATrackName" 30#include <AssertMacros.h> 31 32#include <CoreFoundation/CoreFoundation.h> 33#include <sys/param.h> 34#include <sys/types.h> 35 36// private includes 37#include "CDDATrackName.h" 38 39 40//----------------------------------------------------------------------------- 41// Macros 42//----------------------------------------------------------------------------- 43 44#define DEBUG 0 45 46#if DEBUG 47#define PRINT(x) printf x 48#else 49#define PRINT(x) 50#endif 51 52 53#define kCDDAFSUtilBundlePath "/System/Library/Filesystems/cddafs.fs" 54#define kArtistString "Artist" 55#define kTitleString "Title" 56#define kAudioCDString "Audio CD" 57#define kTrackNameString "Audio Track" 58#define kSeparatorString "Separator" 59 60 61//----------------------------------------------------------------------------- 62// Constructor [PUBLIC] 63//----------------------------------------------------------------------------- 64 65CDDATrackName::CDDATrackName ( void ) : 66 fBundle ( NULL ), 67 fTrackNameStringRef ( NULL ), 68 fAlbumStringRef ( NULL ), 69 fArtistStringRef ( NULL ), 70 fSeparatorStringRef ( NULL ) 71{ 72 73 CFURLRef urlRef = NULL; 74 CFBundleRef bundleRef = NULL; 75 76 PRINT ( ( "CDDATrackName constructor called\n" ) ); 77 78 urlRef = ::CFURLCreateWithFileSystemPath ( kCFAllocatorDefault, 79 CFSTR ( kCDDAFSUtilBundlePath ), 80 kCFURLPOSIXPathStyle, 81 true ); 82 83 if ( urlRef != NULL ) 84 { 85 86 #if DEBUG 87 ::CFShow ( urlRef ); 88 #endif 89 90 bundleRef = ::CFBundleCreate ( kCFAllocatorDefault, urlRef ); 91 ::CFRelease ( urlRef ); 92 urlRef = 0; 93 94 } 95 96 if ( bundleRef != NULL ) 97 { 98 99 #if DEBUG 100 ::CFShow ( bundleRef ); 101 #endif 102 103 fBundle = new TBundle ( bundleRef ); 104 105 fArtistStringRef = fBundle->CopyLocalizedStringForKey ( 106 CFSTR ( kArtistString ), 107 CFSTR ( kArtistString ), 108 NULL ); // defaults to Localizable.strings 109 110 fAlbumStringRef = fBundle->CopyLocalizedStringForKey ( 111 CFSTR ( kTitleString ), 112 CFSTR ( kAudioCDString ), 113 NULL ); // defaults to Localizable.strings 114 115 fTrackNameStringRef = fBundle->CopyLocalizedStringForKey ( 116 CFSTR ( kTrackNameString ), 117 CFSTR ( kTrackNameString ), 118 NULL ); // defaults to Localizable.strings 119 120 fSeparatorStringRef = fBundle->CopyLocalizedStringForKey ( 121 CFSTR ( kSeparatorString ), 122 CFSTR ( kSeparatorString ), 123 NULL ); // defaults to Localizable.strings 124 125 ::CFRelease ( bundleRef ); 126 bundleRef = NULL; 127 128 } 129 130} 131 132 133//----------------------------------------------------------------------------- 134// Destructor [PROTECTED] 135//----------------------------------------------------------------------------- 136 137CDDATrackName::~CDDATrackName ( void ) 138{ 139 140 PRINT ( ( "CDDATrackName destructor called\n" ) ); 141 142 #if DEBUG 143 144 ::CFShow ( fArtistStringRef ); 145 ::CFShow ( fAlbumStringRef ); 146 ::CFShow ( fTrackNameStringRef ); 147 ::CFShow ( fSeparatorStringRef ); 148 149 #endif 150 151 ::CFRelease ( fArtistStringRef ); 152 ::CFRelease ( fAlbumStringRef ); 153 ::CFRelease ( fTrackNameStringRef ); 154 ::CFRelease ( fSeparatorStringRef ); 155 156 fArtistStringRef = 0; 157 fAlbumStringRef = 0; 158 fTrackNameStringRef = 0; 159 fSeparatorStringRef = 0; 160 161 if ( fBundle != NULL ) 162 { 163 164 delete fBundle; 165 fBundle = NULL; 166 167 } 168 169} 170 171 172//----------------------------------------------------------------------------- 173// Init [PUBLIC] 174//----------------------------------------------------------------------------- 175 176SInt32 177CDDATrackName::Init ( const char * bsdDevNode, const void * TOCData ) 178{ 179 return 0; 180} 181 182 183//----------------------------------------------------------------------------- 184// GetArtistName [PUBLIC] 185//----------------------------------------------------------------------------- 186 187CFStringRef 188CDDATrackName::GetArtistName ( void ) 189{ 190 ::CFRetain ( fArtistStringRef ); 191 return fArtistStringRef; 192} 193 194 195//----------------------------------------------------------------------------- 196// GetAlbumName [PUBLIC] 197//----------------------------------------------------------------------------- 198 199CFStringRef 200CDDATrackName::GetAlbumName ( void ) 201{ 202 ::CFRetain ( fAlbumStringRef ); 203 return fAlbumStringRef; 204} 205 206 207//----------------------------------------------------------------------------- 208// GetTrackName [PUBLIC] 209//----------------------------------------------------------------------------- 210 211CFStringRef 212CDDATrackName::GetTrackName ( UInt8 trackNumber ) 213{ 214 ::CFRetain ( fTrackNameStringRef ); 215 return fTrackNameStringRef; 216} 217 218 219//----------------------------------------------------------------------------- 220// GetSeparatorString [PUBLIC] 221//----------------------------------------------------------------------------- 222 223CFStringRef 224CDDATrackName::GetSeparatorString ( void ) 225{ 226 ::CFRetain ( fSeparatorStringRef ); 227 return fSeparatorStringRef; 228} 229 230 231//----------------------------------------------------------------------------- 232// End Of File 233//----------------------------------------------------------------------------- 234