#include <CoreServices.h>
#endif
-
+#ifndef __LP64__
// START CODE SAMPLE FROM TECHNOTE 1002 (http://developer.apple.com/technotes/tn/tn1002.html)
// IsRemoteVolume can be used to find out if the
return result;
}
-
+#endif // LP64
//
// On the mac there are two ways to open a file - one is through apple events and the
// finder, another is through mime types.
//
// debug helper
-inline void wxLogMimeDebug(const wxChar* szMsg, OSStatus status)
+inline void wxLogMimeDebug(const wxChar* WXUNUSED_UNLESS_DEBUG(szMsg), OSStatus WXUNUSED_UNLESS_DEBUG(status))
{
wxLogDebug(wxString::Format(wxT("%s LINE:%i OSERROR:%i"), szMsg, __LINE__, (int)status));
}
// in case we're compiling in non-GUI mode
-class WXDLLEXPORT wxIcon;
+class WXDLLIMPEXP_FWD_CORE wxIcon;
-bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool overwriteprompt)
+bool wxFileTypeImpl::SetCommand(const wxString& WXUNUSED(cmd), const wxString& WXUNUSED(verb), bool WXUNUSED(overwriteprompt))
{
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
return false;
}
-bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
+bool wxFileTypeImpl::SetDefaultIcon(const wxString& WXUNUSED(strIcon), int WXUNUSED(index))
{
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
// we need to go straight to launch services
//
-#if defined(__DARWIN__)
-
//on darwin, use launch services
+
#include <ApplicationServices/ApplicationServices.h>
wxString wxFileTypeImpl::GetCommand(const wxString& verb) const
CFURLRef cfurlAppPath;
OSStatus status = LSGetApplicationForInfo( kLSUnknownType,
kLSUnknownCreator,
- wxMacCFStringHolder(sCurrentExtension, wxLocale::GetSystemEncoding()),
+ wxCFStringRef(sCurrentExtension, wxLocale::GetSystemEncoding()),
kLSRolesAll,
NULL,
&cfurlAppPath );
resultStr =
wxString(wxT("'"))
- + wxMacCFStringHolder(cfsUnixPath).AsString(wxLocale::GetSystemEncoding())
+ + wxCFStringRef(cfsUnixPath).AsString(wxLocale::GetSystemEncoding())
+ wxString(wxT("'"));
return resultStr;
return wxEmptyString;
}
-#else //carbon/classic implementation
-
-wxString wxFileTypeImpl::GetCommand(const wxString& verb) const
-{
- wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
-
- if (verb == wxT("open"))
- {
- ICMapEntry entry;
- ICGetMapEntry( (ICInstance) m_manager->m_hIC,
- (Handle) m_manager->m_hDatabase,
- m_lIndex, &entry);
-
- //The entry in the mimetype database only contains the app
- //that's registered - it may not exist... we need to remap the creator
- //type and find the right application
-
- // THIS IS REALLY COMPLICATED :\.
- // There are a lot of conversions going on here.
- Str255 outName;
- FSSpec outSpec;
- OSErr err = FindApplication( entry.fileCreator, false, outName, &outSpec );
- if (err != noErr)
- return wxEmptyString;
-
- Handle outPathHandle;
- short outPathSize;
- err = FSpGetFullPath( &outSpec, &outPathSize, &outPathHandle );
- if (err == noErr)
- {
- char* szPath = *outPathHandle;
- wxString sClassicPath(szPath, wxConvLocal, outPathSize);
-
-#if defined(__DARWIN__)
- // Classic Path --> Unix (OSX) Path
- CFURLRef finalURL = CFURLCreateWithFileSystemPath(
- kCFAllocatorDefault,
- wxMacCFStringHolder(sClassicPath, wxLocale::GetSystemEncoding()),
- kCFURLHFSPathStyle,
- false ); //false == not a directory
-
- //clean up memory from the classic path handle
- DisposeHandle( outPathHandle );
-
- if (finalURL)
- {
- CFStringRef cfsUnixPath = CFURLCopyFileSystemPath(finalURL, kCFURLPOSIXPathStyle);
- CFRelease(finalURL);
-
- // PHEW! Success!
- if (cfsUnixPath)
- return wxMacCFStringHolder(cfsUnixPath).AsString(wxLocale::GetSystemEncoding());
- }
-#else //classic HFS path acceptable
- return sClassicPath;
-#endif
- }
- else
- {
- wxLogMimeDebug(wxT("FSpGetFullPath failed."), (OSStatus)err);
- }
- }
-
- return wxEmptyString;
-}
-#endif //!DARWIN
-
bool wxFileTypeImpl::GetDescription(wxString *desc) const
{
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
return ulCount;
}
-void wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extraDir)
+void wxMimeTypesManagerImpl::Initialize(int WXUNUSED(mailcapStyles), const wxString& WXUNUSED(extraDir))
{
wxASSERT_MSG(m_hIC == NULL, wxT("Already initialized wxMimeTypesManager!"));
infoRec.processInfoLength = sizeof(ProcessInfoRec);
infoRec.processName = NULL;
+#ifndef __LP64__
infoRec.processAppSpec = NULL;
+#endif
if ( pPSN == NULL )
{
class wxCFDictionary
{
public:
- wxCFDictionary(CFTypeRef ref, bool bRetain = wxCF_RELEASE)
+ wxCFDictionary(CFTypeRef ref)
{
m_cfmdRef = (CFMutableDictionaryRef) ref;
- if (bRetain == wxCF_RETAIN && ref)
- CFRetain(ref);
}
wxCFDictionary(CFIndex cfiSize = 0)
for (CFIndex i = 0; i < cfiCount; ++i)
{
- wxString sKey = wxMacCFStringHolder(CFCopyTypeIDDescription(CFGetTypeID(pKeys[i]))).AsString();
- wxString sValue = wxMacCFStringHolder(CFCopyTypeIDDescription(CFGetTypeID(pValues[i]))).AsString();
+ wxString sKey = wxCFStringRef(CFCopyTypeIDDescription(CFGetTypeID(pKeys[i]))).AsString();
+ wxString sValue = wxCFStringRef(CFCopyTypeIDDescription(CFGetTypeID(pValues[i]))).AsString();
sMessage <<
wxString::Format(wxT("[{#%d} Key : %s]"), (int) i,
{
for (CFIndex i = 0; i < CFArrayGetCount(cfaRef); ++i)
{
- wxString sValue = wxMacCFStringHolder(CFCopyTypeIDDescription(CFGetTypeID(
+ wxString sValue = wxCFStringRef(CFCopyTypeIDDescription(CFGetTypeID(
CFArrayGetValueAtIndex(cfaRef, i)
))).AsString();
if (sValue == wxT("CFString"))
{
- sMessage << wxMacCFStringHolder((CFStringRef)cfRef, false).AsString();
+ sMessage << wxCFStringRef(wxCFRetain((CFStringRef)cfRef)).AsString();
}
else if (sValue == wxT("CFNumber"))
{
}
else if (sValue == wxT("CFURL"))
{
- sMessage << wxMacCFStringHolder(CFURLCopyPath((CFURLRef) cfRef)).AsString();
+ sMessage << wxCFStringRef(CFURLCopyPath((CFURLRef) cfRef)).AsString();
}
else
{
if (cfsError)
{
if (pErrorMsg)
- *pErrorMsg = wxMacCFStringHolder(cfsError).AsString();
+ *pErrorMsg = wxCFStringRef(cfsError).AsString();
else
CFRelease(cfsError);
}
class wxCFArray
{
public:
- wxCFArray(CFTypeRef ref, bool bRetain = wxCF_RELEASE)
+ wxCFArray(CFTypeRef ref)
{
m_cfmaRef = (CFMutableArrayRef)ref;
- if (bRetain == wxCF_RETAIN && ref)
- CFRetain(ref);
}
wxCFArray(CFIndex cfiSize = 0) : m_cfmaRef(NULL)
CFMutableArrayRef m_cfmaRef;
};
-// ----------------------------------------------------------------------------
-// wxCFString
-// ----------------------------------------------------------------------------
-
-class wxCFString
-{
-public:
- wxCFString(CFTypeRef ref, bool bRetain = wxCF_RELEASE) : m_Holder((CFStringRef)ref, bRetain == wxCF_RELEASE)
- {}
-
- wxCFString(const wxChar* szString) : m_Holder(wxString(szString), wxLocale::GetSystemEncoding())
- {}
-
- wxCFString(const wxString& sString) : m_Holder(sString, wxLocale::GetSystemEncoding())
- {}
-
- virtual ~wxCFString() {}
-
- operator CFTypeRef() const
- { return (CFTypeRef) ((CFStringRef) m_Holder); }
-
- bool IsOk()
- { return ((CFTypeRef)(*this)) != NULL; }
-
- wxString BuildWXString()
- { return m_Holder.AsString(); }
-
-private:
- wxMacCFStringHolder m_Holder;
-};
-
// ----------------------------------------------------------------------------
// wxCFNumber
// ----------------------------------------------------------------------------
m_cfnRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &nValue);
}
- wxCFNumber(CFTypeRef ref, bool bRetain = wxCF_RELEASE) : m_cfnRef((CFNumberRef)ref)
+ wxCFNumber(CFTypeRef ref) : m_cfnRef((CFNumberRef)ref)
{
- if (bRetain == wxCF_RETAIN && ref)
- CFRetain(ref);
}
virtual ~wxCFNumber()
class wxCFURL
{
public:
- wxCFURL(CFTypeRef ref = NULL, bool bRetain = wxCF_RELEASE) : m_cfurlRef((CFURLRef)ref)
+ wxCFURL(CFTypeRef ref = NULL) : m_cfurlRef((CFURLRef)ref)
{
- if (bRetain == wxCF_RETAIN && ref)
- CFRetain(ref);
}
- wxCFURL(const wxCFString& URLString, CFTypeRef BaseURL = NULL)
+ wxCFURL(const wxCFStringRef& URLString, CFTypeRef BaseURL = NULL)
{
Create(URLString, BaseURL);
}
- void Create(const wxCFString& URLString, CFTypeRef BaseURL = NULL)
+ void Create(const wxCFStringRef& URLString, CFTypeRef BaseURL = NULL)
{
m_cfurlRef = CFURLCreateWithString(
kCFAllocatorDefault,
wxString BuildWXString()
{
- return wxCFString(CFURLCopyPath(m_cfurlRef)).BuildWXString();
+ return wxCFStringRef(CFURLCopyPath(m_cfurlRef)).AsString();
}
operator CFTypeRef() const
class wxCFData
{
public:
- wxCFData(CFTypeRef ref, bool bRetain = wxCF_RELEASE) : m_cfdaRef((CFDataRef)ref)
+ wxCFData(CFTypeRef ref) : m_cfdaRef((CFDataRef)ref)
{
- if (bRetain == wxCF_RETAIN && ref)
- CFRetain(ref);
}
wxCFData(const UInt8* pBytes, CFIndex len, bool bKeep = wxCFDATA_RELEASEBUFFER)
{
cfdInfo.MakeMutable( cfdInfo.GetCount() + 1 );
- wxCFArray cfaDocTypes( cfdInfo[ wxCFString(wxT("CFBundleDocumentTypes")) ], wxCF_RETAIN );
+ wxCFArray cfaDocTypes( wxCFRetain( cfdInfo[ wxCFStringRef(wxT("CFBundleDocumentTypes")) ] ) );
bool bAddDocTypesArrayToDictionary = !cfaDocTypes.IsOk();
if (bAddDocTypesArrayToDictionary)
CFIndex i;
for (i = 0; i < cfaDocTypes.GetCount(); ++i)
{
- wxCFDictionary cfdDocTypeEntry( cfaDocTypes[i], wxCF_RETAIN );
+ wxCFDictionary cfdDocTypeEntry( wxCFRetain( cfaDocTypes[i] ) );
// A lot of apps don't support MIME types for some reason
// so we go by extensions only
- wxCFArray cfaExtensions( cfdDocTypeEntry[ wxCFString(wxT("CFBundleTypeExtensions")) ],
- wxCF_RETAIN );
+ wxCFArray cfaExtensions( wxCFRetain( cfdDocTypeEntry[ wxCFStringRef(wxT("CFBundleTypeExtensions")) ] ) );
if (!cfaExtensions.IsOk())
continue;
for (size_t iWXExt = 0; iWXExt < asExtensions.GetCount(); ++iWXExt)
{
if (asExtensions[iWXExt] ==
- wxCFString(cfaExtensions[iExt], wxCF_RETAIN).BuildWXString())
+ wxCFStringRef( wxCFRetain( (CFStringRef) cfaExtensions[iExt] ) ).AsString())
{
bEntryFound = true;
dwFoundIndex = iWXExt;
if (!ftInfo.GetDescription().empty())
{
- cfdNewEntry.Add( wxCFString(wxT("CFBundleTypeName")),
- wxCFString(ftInfo.GetDescription()) );
+ cfdNewEntry.Add( wxCFStringRef(wxT("CFBundleTypeName")),
+ wxCFStringRef(ftInfo.GetDescription()) );
}
if (!ftInfo.GetIconFile().empty())
{
- cfdNewEntry.Add( wxCFString(wxT("CFBundleTypeIconFile")),
- wxCFString(ftInfo.GetIconFile()) );
+ cfdNewEntry.Add( wxCFStringRef(wxT("CFBundleTypeIconFile")),
+ wxCFStringRef(ftInfo.GetIconFile()) );
}
wxCFArray cfaOSTypes;
wxCFArray cfaMimeTypes;
//OSTypes is a cfarray of four-char-codes - '****' for unrestricted
- cfaOSTypes.Add( wxCFString(wxT("****")) );
- cfdNewEntry.Add( wxCFString(wxT("CFBundleTypeOSTypes")), cfaOSTypes );
+ cfaOSTypes.Add( wxCFStringRef(wxT("****")) );
+ cfdNewEntry.Add( wxCFStringRef(wxT("CFBundleTypeOSTypes")), cfaOSTypes );
//'*' for unrestricted
if (ftInfo.GetExtensionsCount() != 0)
{
for (size_t iExtension = 0; iExtension < ftInfo.GetExtensionsCount(); ++iExtension)
{
- cfaExtensions.Add( wxCFString( asExtensions[iExtension] ) );
+ cfaExtensions.Add( wxCFStringRef( asExtensions[iExtension] ) );
}
- cfdNewEntry.Add( wxCFString(wxT("CFBundleTypeExtensions")), cfaExtensions );
+ cfdNewEntry.Add( wxCFStringRef(wxT("CFBundleTypeExtensions")), cfaExtensions );
}
if (!ftInfo.GetMimeType().empty())
{
- cfaMimeTypes.Add( wxCFString(ftInfo.GetMimeType()) );
- cfdNewEntry.Add( wxCFString(wxT("CFBundleTypeMIMETypes")), cfaMimeTypes );
+ cfaMimeTypes.Add( wxCFStringRef(ftInfo.GetMimeType()) );
+ cfdNewEntry.Add( wxCFStringRef(wxT("CFBundleTypeMIMETypes")), cfaMimeTypes );
}
// Editor - can perform all actions
// Viewer - all actions except manipulation/saving
// None - can perform no actions
- cfdNewEntry.Add( wxCFString(wxT("CFBundleTypeRole")), wxCFString(wxT("Editor")) );
+ cfdNewEntry.Add( wxCFStringRef(wxT("CFBundleTypeRole")), wxCFStringRef(wxT("Editor")) );
// Is application bundled?
- cfdNewEntry.Add( wxCFString(wxT("LSTypeIsPackage")), kCFBooleanTrue );
+ cfdNewEntry.Add( wxCFStringRef(wxT("LSTypeIsPackage")), kCFBooleanTrue );
if (bEntryFound)
cfaDocTypes.Set(i, cfdNewEntry);
// set the doc types array in the muted dictionary
if (bAddDocTypesArrayToDictionary)
- cfdInfo.Add(wxCFString(wxT("CFBundleDocumentTypes")), cfaDocTypes);
+ cfdInfo.Add(wxCFStringRef(wxT("CFBundleDocumentTypes")), cfaDocTypes);
else
- cfdInfo.Set(wxCFString(wxT("CFBundleDocumentTypes")), cfaDocTypes);
+ cfdInfo.Set(wxCFStringRef(wxT("CFBundleDocumentTypes")), cfaDocTypes);
cfdInfo.MakeValidXML();
wxLogDebug(wxT("No main bundle"));
}
-#if defined(__DARWIN__)
if (!bInfoSuccess)
return NULL;
-#endif
// on mac you have to embed it into the mac's file reference resource ('FREF' I believe)
// or, alternately, you could just add an entry to m_hDatabase, but you'd need to get
if (status == noErr)
{
Str255 psCreatorName;
+#ifndef __LP64__
FSSpec dummySpec;
status = FindApplication(creator, false, psCreatorName, &dummySpec);
+#else
+ FSRef fsref;
+ status = LSFindApplicationForInfo( creator, NULL, NULL, &fsref ,NULL);
+ HFSUniStr255 name;
+ status = FSGetCatalogInfo(&fsref, kFSCatInfoNone, NULL, &name, NULL, NULL);
+ CFStringRef str = FSCreateStringFromHFSUniStr( 0 , &name );
+ CFStringGetPascalString(str, psCreatorName, 256, CFStringGetSystemEncoding());
+ CFRelease( str );
+#endif
if (status == noErr)
{
{
cfdInfo.MakeMutable( cfdInfo.GetCount() + 1 );
- wxCFArray cfaDocTypes( cfdInfo[ wxCFString(wxT("CFBundleDocumentTypes")) ], wxCF_RETAIN );
+ wxCFArray cfaDocTypes( wxCFRetain( cfdInfo[ wxCFStringRef(wxT("CFBundleDocumentTypes")) ] ) );
if (cfaDocTypes.IsOk())
{
CFIndex i;
for (i = 0; i < cfaDocTypes.GetCount(); ++i)
{
- wxCFDictionary cfdDocTypeEntry( cfaDocTypes[i], wxCF_RETAIN );
+ wxCFDictionary cfdDocTypeEntry( wxCFRetain( cfaDocTypes[i] ) );
//A lot of apps dont do to mime types for some reason
//so we go by extensions only
- wxCFArray cfaExtensions( cfdDocTypeEntry[ wxCFString(wxT("CFBundleTypeExtensions")) ],
- wxCF_RETAIN );
+ wxCFArray cfaExtensions( wxCFRetain( cfdDocTypeEntry[ wxCFStringRef(wxT("CFBundleTypeExtensions")) ]) );
if (!cfaExtensions.IsOk())
continue;
for (size_t iWXExt = 0; iWXExt < asExtensions.GetCount(); ++iWXExt)
{
if (asExtensions[iWXExt] ==
- wxCFString(cfaExtensions[iExt], wxCF_RETAIN).BuildWXString())
+ wxCFStringRef( wxCFRetain( (CFStringRef) cfaExtensions[iExt] ) ).AsString())
{
bEntryFound = true;
cfaDocTypes.Remove(i);
- cfdInfo.Set( wxCFString(wxT("CFBundleDocumentTypes")) , cfaDocTypes );
+ cfdInfo.Set( wxCFStringRef(wxT("CFBundleDocumentTypes")) , cfaDocTypes );
break;
}
} //end of wxstring array
wxLogDebug(wxT("No main bundle"));
}
-#if defined(__DARWIN__)
if (!bInfoSuccess)
return false;
-#endif
// this should be as easy as removing the entry from the database
// and then saving the database
&cfsError);
if (cfsError && cfiWritten == 0)
{
- wxLogDebug(wxCFString(cfsError).BuildWXString());
+ wxLogDebug(wxCFStringRef(cfsError).BuildWXString());
wxString sMessage;
cfdInfo.PrintOut(sMessage);
wxLogDebug(sMessage);