Warning fix and source cleaning.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34447 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-05-31 12:19:04 +00:00
parent 12cca26a83
commit cb9c71ecca

View File

@@ -18,10 +18,10 @@
// to get info from a file instead/addition to current get all stuff // to get info from a file instead/addition to current get all stuff
// API so that we can use Launch Services to get mime type info. // API so that we can use Launch Services to get mime type info.
// //
// Implement geticon from one of the finder info functions - or // Implement geticon from one of the finder info functions - or
// use launch services and search that app's plist for the icon. // use launch services and search that app's plist for the icon.
// //
// Put some special juice in for the print command. // Put some special juice in for the print command.
// //
// //
// //
@@ -101,7 +101,7 @@ OSErr BuildVolumeList(Boolean includeRemote, short *vols,
long *count, long vMAttribMask) { long *count, long vMAttribMask) {
HParamBlockRec volPB; HParamBlockRec volPB;
Boolean isRemote; Boolean isRemote;
OSErr err; OSErr err = noErr;
long nlocal, nremote; long nlocal, nremote;
long vMAttrib; long vMAttrib;
@@ -341,14 +341,14 @@ bool wxFileTypeImpl::SetCommand(const wxString& cmd, const wxString& verb, bool
{ {
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") ); wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
return FALSE; return false;
} }
bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index) bool wxFileTypeImpl::SetDefaultIcon(const wxString& strIcon, int index)
{ {
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") ); wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
return FALSE; return false;
} }
bool wxFileTypeImpl::GetOpenCommand(wxString *openCmd, bool wxFileTypeImpl::GetOpenCommand(wxString *openCmd,
@@ -548,10 +548,10 @@ bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
{ {
mimeTypes.Clear(); mimeTypes.Clear();
mimeTypes.Add(s); mimeTypes.Add(s);
return TRUE; return true;
} }
else else
return FALSE; return false;
} }
bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
@@ -559,7 +559,7 @@ bool wxFileTypeImpl::GetIcon(wxIconLocation *WXUNUSED(icon)) const
wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") ); wxASSERT_MSG( m_manager != NULL , wxT("Bad wxFileType") );
// no such file type or no value or incorrect icon entry // no such file type or no value or incorrect icon entry
return FALSE; return false;
} }
size_t wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands, size_t wxFileTypeImpl::GetAllCommands(wxArrayString * verbs, wxArrayString * commands,
@@ -647,8 +647,7 @@ void wxMimeTypesManagerImpl::Initialize(int mailcapStyles, const wxString& extra
{ {
wxString cmd; wxString cmd;
impl.GetOpenCommand (&cmd, impl.GetOpenCommand (&cmd,
wxFileType::MessageParameters (wxT("http://www.google.com"), wxFileType::MessageParameters (wxT("http://www.google.com")));
_T("")));
wxPrintf(wxT("APP: [%s]\n"), cmd.c_str()); wxPrintf(wxT("APP: [%s]\n"), cmd.c_str());
} }
@@ -820,16 +819,16 @@ public:
} }
~wxCFDictionary() ~wxCFDictionary()
{ Clear(); } { Clear(); }
void Clear() void Clear()
{if(m_cfmdRef) CFRelease(m_cfmdRef);} {if(m_cfmdRef) CFRelease(m_cfmdRef);}
static const void* RetainProc(CFAllocatorRef, const void* v) static const void* RetainProc(CFAllocatorRef, const void* v)
{ return (const void*) CFRetain(v); } { return (const void*) CFRetain(v); }
static void ReleaseProc(CFAllocatorRef, const void* v) static void ReleaseProc(CFAllocatorRef, const void* v)
{ CFRelease(v); } { CFRelease(v); }
void MakeMutable(CFIndex cfiSize = 0) void MakeMutable(CFIndex cfiSize = 0)
{ {
@@ -863,13 +862,13 @@ public:
} }
operator CFTypeRef () const operator CFTypeRef () const
{ return (CFTypeRef)m_cfmdRef; } { return (CFTypeRef)m_cfmdRef; }
CFDictionaryRef GetCFDictionary() const CFDictionaryRef GetCFDictionary() const
{ return (CFDictionaryRef)m_cfmdRef; } { return (CFDictionaryRef)m_cfmdRef; }
CFMutableDictionaryRef GetCFMutableDictionary() CFMutableDictionaryRef GetCFMutableDictionary()
{ return (CFMutableDictionaryRef) m_cfmdRef; } { return (CFMutableDictionaryRef) m_cfmdRef; }
CFTypeRef operator [] (CFTypeRef cftEntry) const CFTypeRef operator [] (CFTypeRef cftEntry) const
{ {
@@ -910,7 +909,7 @@ public:
return CFDictionaryContainsKey((CFDictionaryRef)m_cfmdRef, cftKey) == true; return CFDictionaryContainsKey((CFDictionaryRef)m_cfmdRef, cftKey) == true;
} }
bool IsOk() const {return m_cfmdRef != NULL; } bool IsOk() const {return m_cfmdRef != NULL; }
bool IsValid() const bool IsValid() const
{ {
@@ -1026,7 +1025,7 @@ public:
kCFAllocatorDefault, kCFAllocatorDefault,
(CFDataRef)cfData, (CFDataRef)cfData,
kCFPropertyListMutableContainersAndLeaves, kCFPropertyListMutableContainersAndLeaves,
&cfsError ); &cfsError );
if(cfsError) if(cfsError)
{ {
if(pErrorMsg) if(pErrorMsg)
@@ -1056,10 +1055,10 @@ public:
} }
wxCFArray(CFIndex cfiSize = 0) : m_cfmaRef(NULL) wxCFArray(CFIndex cfiSize = 0) : m_cfmaRef(NULL)
{ Create(cfiSize); } { Create(cfiSize); }
~wxCFArray() ~wxCFArray()
{ Clear(); } { Clear(); }
void MakeMutable(CFIndex cfiSize = 0) void MakeMutable(CFIndex cfiSize = 0)
{ {
@@ -1095,19 +1094,19 @@ public:
{if(m_cfmaRef) CFRelease(m_cfmaRef);} {if(m_cfmaRef) CFRelease(m_cfmaRef);}
static const void* RetainProc(CFAllocatorRef, const void* v) static const void* RetainProc(CFAllocatorRef, const void* v)
{ return (const void*) CFRetain(v); } { return (const void*) CFRetain(v); }
static void ReleaseProc(CFAllocatorRef, const void* v) static void ReleaseProc(CFAllocatorRef, const void* v)
{ CFRelease(v); } { CFRelease(v); }
operator CFTypeRef () const operator CFTypeRef () const
{ return (CFTypeRef)m_cfmaRef; } { return (CFTypeRef)m_cfmaRef; }
CFArrayRef GetCFArray() const CFArrayRef GetCFArray() const
{ return (CFArrayRef)m_cfmaRef; } { return (CFArrayRef)m_cfmaRef; }
CFMutableArrayRef GetCFMutableArray() CFMutableArrayRef GetCFMutableArray()
{ return (CFMutableArrayRef) m_cfmaRef; } { return (CFMutableArrayRef) m_cfmaRef; }
CFTypeRef operator [] (CFIndex cfiIndex) const CFTypeRef operator [] (CFIndex cfiIndex) const
{ {
@@ -1141,7 +1140,7 @@ public:
CFArraySetValueAtIndex(m_cfmaRef, cfiIndex, cftValue); CFArraySetValueAtIndex(m_cfmaRef, cfiIndex, cftValue);
} }
bool IsOk() const {return m_cfmaRef != NULL; } bool IsOk() const {return m_cfmaRef != NULL; }
bool IsValid() const bool IsValid() const
{ {
@@ -1164,20 +1163,20 @@ class wxCFString
{ {
public: public:
wxCFString(CFTypeRef ref, bool bRetain = wxCF_RELEASE) : m_Holder((CFStringRef)ref, bRetain == wxCF_RELEASE) 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 wxChar* szString) : m_Holder(wxString(szString), wxLocale::GetSystemEncoding())
{ } { }
wxCFString(const wxString& sString) : m_Holder(sString, wxLocale::GetSystemEncoding()) wxCFString(const wxString& sString) : m_Holder(sString, wxLocale::GetSystemEncoding())
{ } { }
operator CFTypeRef() const operator CFTypeRef() const
{return (CFTypeRef) ((CFStringRef) m_Holder); } { return (CFTypeRef) ((CFStringRef) m_Holder); }
bool IsOk() { return ((CFTypeRef)(*this)) != NULL; } bool IsOk() { return ((CFTypeRef)(*this)) != NULL; }
wxString BuildWXString() {return m_Holder.AsString(); } wxString BuildWXString() {return m_Holder.AsString(); }
private: private:
wxMacCFStringHolder m_Holder; wxMacCFStringHolder m_Holder;
@@ -1192,8 +1191,7 @@ class wxCFNumber
public: public:
wxCFNumber(int nValue) wxCFNumber(int nValue)
{ {
m_cfnRef = CFNumberCreate(kCFAllocatorDefault, m_cfnRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &nValue);
kCFNumberIntType, &nValue);
} }
wxCFNumber(CFTypeRef ref, bool bRetain = wxCF_RELEASE) : m_cfnRef((CFNumberRef)ref) wxCFNumber(CFTypeRef ref, bool bRetain = wxCF_RELEASE) : m_cfnRef((CFNumberRef)ref)
@@ -1203,25 +1201,27 @@ public:
} }
~wxCFNumber() ~wxCFNumber()
{ if(m_cfnRef) CFRelease(m_cfnRef); } {
if(m_cfnRef)
CFRelease(m_cfnRef);
}
operator CFTypeRef() const operator CFTypeRef() const
{ return (CFTypeRef) m_cfnRef; } { return (CFTypeRef) m_cfnRef; }
int GetValue() int GetValue()
{ {
int nOut; int nOut;
CFNumberGetValue( CFNumberGetValue( m_cfnRef,
m_cfnRef, kCFNumberIntType,
kCFNumberIntType, &nOut
&nOut );
);
return nOut; return nOut;
} }
bool IsOk() { return m_cfnRef != NULL; } bool IsOk() { return m_cfnRef != NULL; }
private: private:
CFNumberRef m_cfnRef; CFNumberRef m_cfnRef;
@@ -1260,9 +1260,9 @@ public:
} }
operator CFTypeRef() const operator CFTypeRef() const
{ return (CFTypeRef)m_cfurlRef; } { return (CFTypeRef)m_cfurlRef; }
bool IsOk() { return m_cfurlRef != NULL; } bool IsOk() { return m_cfurlRef != NULL; }
private: private:
CFURLRef m_cfurlRef; CFURLRef m_cfurlRef;
}; };
@@ -1307,9 +1307,9 @@ public:
} }
operator CFTypeRef() const operator CFTypeRef() const
{ return (CFTypeRef)m_cfdaRef; } { return (CFTypeRef)m_cfdaRef; }
bool IsOk() { return m_cfdaRef != NULL; } bool IsOk() { return m_cfdaRef != NULL; }
private: private:
CFDataRef m_cfdaRef; CFDataRef m_cfdaRef;
}; };
@@ -1359,9 +1359,9 @@ void wxCFDictionary::MakeValidXML()
cfdCurrent.MakeValidXML(); cfdCurrent.MakeValidXML();
Set(pKeys[i], cfdCurrent); Set(pKeys[i], cfdCurrent);
} }
else if( ( CFGetTypeID(cfRef) == CFStringGetTypeID() || else if( ( CFGetTypeID(cfRef) == CFStringGetTypeID() ||
CFGetTypeID(cfRef) == CFNumberGetTypeID() || CFGetTypeID(cfRef) == CFNumberGetTypeID() ||
CFGetTypeID(cfRef) == CFBooleanGetTypeID() ) == false ) CFGetTypeID(cfRef) == CFBooleanGetTypeID() ) == false )
{ {
Remove(pKeys[i]); Remove(pKeys[i]);
--i; --i;
@@ -1406,9 +1406,9 @@ void wxCFArray::MakeValidXML()
cfdCurrent.MakeValidXML(); cfdCurrent.MakeValidXML();
Set(i, cfdCurrent); Set(i, cfdCurrent);
} }
else if( ( CFGetTypeID(cfRef) == CFStringGetTypeID() || else if( ( CFGetTypeID(cfRef) == CFStringGetTypeID() ||
CFGetTypeID(cfRef) == CFNumberGetTypeID() || CFGetTypeID(cfRef) == CFNumberGetTypeID() ||
CFGetTypeID(cfRef) == CFBooleanGetTypeID() ) == false ) CFGetTypeID(cfRef) == CFBooleanGetTypeID() ) == false )
{ {
Remove(i); Remove(i);
--i; --i;
@@ -1469,7 +1469,7 @@ wxFileType* wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
indictfile.Read((void*)pBuffer, cfiBufLen); indictfile.Read((void*)pBuffer, cfiBufLen);
wxCFData cfdaInDict(pBuffer, cfiBufLen); wxCFData cfdaInDict(pBuffer, cfiBufLen);
wxString sError; wxString sError;
bInfoOpenSuccess = cfdInfo.ReadAsXML(cfdaInDict, &sError); bInfoOpenSuccess = cfdInfo.ReadAsXML(cfdaInDict, &sError);
if(!bInfoOpenSuccess) if(!bInfoOpenSuccess)
wxLogDebug(sError); wxLogDebug(sError);
indictfile.Close(); indictfile.Close();
@@ -1513,7 +1513,7 @@ wxFileType* wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
dwFoundIndex = iWXExt; dwFoundIndex = iWXExt;
break; break;
} }
} //end of wxstring array } //end of wxstring array
if(bEntryFound) if(bEntryFound)
break; break;
@@ -1705,9 +1705,9 @@ wxFileType* wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
Str255 psMimeType; Str255 psMimeType;
Str255 psDescription; Str255 psDescription;
wxMacStringToPascal(wxString(wxT(".")) + ftInfo.GetExtensions()[0], psExtension); wxMacStringToPascal(wxString(wxT(".")) + ftInfo.GetExtensions()[0], psExtension);
wxMacStringToPascal(ftInfo.GetMimeType(), psMimeType); wxMacStringToPascal(ftInfo.GetMimeType(), psMimeType);
wxMacStringToPascal(ftInfo.GetDescription(), psDescription); wxMacStringToPascal(ftInfo.GetDescription(), psDescription);
Str255 psPostCreatorName; Str255 psPostCreatorName;
wxMacStringToPascal(wxT(""), psPostCreatorName); wxMacStringToPascal(wxT(""), psPostCreatorName);
@@ -1775,7 +1775,7 @@ wxMimeTypesManagerImpl::Unassociate(wxFileType *pFileType)
if(!asExtensions.GetCount()) if(!asExtensions.GetCount())
{ {
wxLogDebug(wxT("Must have extension to disassociate")); wxLogDebug(wxT("Must have extension to disassociate"));
return FALSE; return false;
} }
//Find and write to Info.plist in main bundle (note that some other //Find and write to Info.plist in main bundle (note that some other
@@ -1812,7 +1812,7 @@ wxMimeTypesManagerImpl::Unassociate(wxFileType *pFileType)
indictfile.Read((void*)pBuffer, cfiBufLen); indictfile.Read((void*)pBuffer, cfiBufLen);
wxCFData cfdaInDict(pBuffer, cfiBufLen); wxCFData cfdaInDict(pBuffer, cfiBufLen);
wxString sError; wxString sError;
bInfoOpenSuccess = cfdInfo.ReadAsXML(cfdaInDict, &sError); bInfoOpenSuccess = cfdInfo.ReadAsXML(cfdaInDict, &sError);
if(!bInfoOpenSuccess) if(!bInfoOpenSuccess)
wxLogDebug(sError); wxLogDebug(sError);
indictfile.Close(); indictfile.Close();
@@ -1853,7 +1853,7 @@ wxMimeTypesManagerImpl::Unassociate(wxFileType *pFileType)
cfdInfo.Set( wxCFString(wxT("CFBundleDocumentTypes")) , cfaDocTypes ); cfdInfo.Set( wxCFString(wxT("CFBundleDocumentTypes")) , cfaDocTypes );
break; break;
} }
} //end of wxstring array } //end of wxstring array
if(bEntryFound) if(bEntryFound)
break; break;
@@ -1937,7 +1937,7 @@ wxMimeTypesManagerImpl::Unassociate(wxFileType *pFileType)
#if defined(__DARWIN__) #if defined(__DARWIN__)
if(!bInfoSuccess) if(!bInfoSuccess)
return FALSE; return false;
#endif #endif
//this should be as easy as removing the entry from the database and then saving //this should be as easy as removing the entry from the database and then saving
@@ -1953,7 +1953,7 @@ wxMimeTypesManagerImpl::Unassociate(wxFileType *pFileType)
// kICAttrNoChange, (Handle) m_hDatabase); // kICAttrNoChange, (Handle) m_hDatabase);
// if(status == noErr) // if(status == noErr)
return TRUE; return true;
// else // else
// { // {
// wxLogDebug(wxString::Format(wxT("%i - %s"), __LINE__, wxT("ICSetPrefHandle failed."))); // wxLogDebug(wxString::Format(wxT("%i - %s"), __LINE__, wxT("ICSetPrefHandle failed.")));
@@ -1965,12 +1965,12 @@ wxMimeTypesManagerImpl::Unassociate(wxFileType *pFileType)
wxLogDebug(wxString::Format(wxT("%i - %s"), __LINE__, wxT("ICDeleteMapEntry failed."))); wxLogDebug(wxString::Format(wxT("%i - %s"), __LINE__, wxT("ICDeleteMapEntry failed.")));
} }
return FALSE; return false;
} }
/* /*
CFWriteStreamRef cfwsInfo = CFWriteStreamCreateWithFile( CFWriteStreamRef cfwsInfo = CFWriteStreamCreateWithFile(
kCFAllocatorDefault, kCFAllocatorDefault,
(CFURLRef) (CFTypeRef)cfurlInfoLoc ); (CFURLRef) (CFTypeRef)cfurlInfoLoc );
// CFShow(cfdInfo); // CFShow(cfdInfo);
if(cfwsInfo) if(cfwsInfo)