Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
nsMIMEInfoMac Class Reference

#include <nsMIMEInfoMac.h>

Inheritance diagram for nsMIMEInfoMac:
Inheritance graph
[legend]
Collaboration diagram for nsMIMEInfoMac:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsMIMEInfoMac (const char *aMIMEType="")
 nsMIMEInfoMac (const nsACString &aMIMEType)
NS_IMETHOD LaunchWithFile (nsIFile *aFile)
NS_IMETHOD GetHasDefaultHandler (PRBool *_retval)
NS_IMETHOD GetDefaultDescription (nsAString &aDefaultDescription)
void SetDefaultApplication (nsIFile *aApp)
 Sets the default application.
NS_DECL_ISUPPORTS NS_IMETHOD GetFileExtensions (nsIUTF8StringEnumerator **_retval)
NS_IMETHOD SetFileExtensions (const nsACString &aExtensions)
NS_IMETHOD ExtensionExists (const nsACString &aExtension, PRBool *_retval)
NS_IMETHOD AppendExtension (const nsACString &aExtension)
NS_IMETHOD GetPrimaryExtension (nsACString &aPrimaryExtension)
NS_IMETHOD SetPrimaryExtension (const nsACString &aPrimaryExtension)
NS_IMETHOD GetMIMEType (nsACString &aMIMEType)
NS_IMETHOD GetDescription (nsAString &aDescription)
NS_IMETHOD SetDescription (const nsAString &aDescription)
NS_IMETHOD GetMacType (PRUint32 *aMacType)
NS_IMETHOD SetMacType (PRUint32 aMacType)
NS_IMETHOD GetMacCreator (PRUint32 *aMacCreator)
NS_IMETHOD SetMacCreator (PRUint32 aMacCreator)
NS_IMETHOD Equals (nsIMIMEInfo *aMIMEInfo, PRBool *_retval)
NS_IMETHOD GetPreferredApplicationHandler (nsIFile **aPreferredApplicationHandler)
NS_IMETHOD SetPreferredApplicationHandler (nsIFile *aPreferredApplicationHandler)
NS_IMETHOD GetApplicationDescription (nsAString &aApplicationDescription)
NS_IMETHOD SetApplicationDescription (const nsAString &aApplicationDescription)
NS_IMETHOD GetPreferredAction (nsMIMEInfoHandleAction *aPreferredAction)
NS_IMETHOD SetPreferredAction (nsMIMEInfoHandleAction aPreferredAction)
NS_IMETHOD GetAlwaysAskBeforeHandling (PRBool *aAlwaysAskBeforeHandling)
NS_IMETHOD SetAlwaysAskBeforeHandling (PRBool aAlwaysAskBeforeHandling)
void SetMIMEType (const nsACString &aMIMEType)
void SetDefaultDescription (const nsString &aDesc)
void CopyBasicDataTo (nsMIMEInfoBase *aOther)
 Copies basic data of this MIME Info Implementation to the given other MIME Info.
PRBool HasExtensions () const
 Return whether this MIMEInfo has any extensions.
nsIUTF8StringEnumerator getFileExtensions ()
 Gives you an array of file types associated with this type.
void setFileExtensions (in AUTF8String aExtensions)
 Set File Extensions.
boolean extensionExists (in AUTF8String aExtension)
 Returns whether or not the given extension is associated with this MIME info.
void appendExtension (in AUTF8String aExtension)
 Append a given extension to the set of extensions.
boolean equals (in nsIMIMEInfo aMIMEInfo)
 Returns whether or not these two MIME infos are logically equivalent maintaining the one-to-many relationship between MIME types and file extensions.
void launchWithFile (in nsIFile aFile)
 Launches the application with the specified file, in a way that depends on the value of preferredAction.

Public Attributes

attribute AUTF8String primaryExtension
 Returns the first extension association in the internal set of extensions.
readonly attribute ACString MIMEType
 The MIME type of this MIMEInfo.
attribute AString description
 A human readable description of the MIME info.
attribute PRUint32 macType
 Mac Type and creator types.
attribute PRUint32 macCreator
attribute nsIFile preferredApplicationHandler
 Returns a nsIFile that points to the application the user has said they want associated with this content type.
attribute AString applicationDescription
 A pretty name description of the preferred application.
readonly attribute boolean hasDefaultHandler
 Indicates whether a default application handler exists, i.e.
readonly attribute AString defaultDescription
 A pretty name description of the associated default application.
const long saveToDisk = 0
const long alwaysAsk = 1
const long useHelperApp = 2
const long handleInternally = 3
const long useSystemDefault = 4
attribute nsMIMEInfoHandleAction preferredAction
 preferredAction is how the user specified they would like to handle this content type: save to disk, use specified helper app, use OS default handler or handle using navigator.
attribute boolean alwaysAskBeforeHandling
 alwaysAskBeforeHandling: if true, we should always give the user a dialog asking how to dispose of this content.

Protected Member Functions

virtual NS_HIDDEN_ (nsresult) LaunchDefaultWithFile(nsIFile *aFile)
 The base class implementation is to use LaunchWithIProcess in combination with mDefaultApplication.

Protected Attributes

nsCOMPtr< nsIFilemDefaultApplication
 default application associated with this type.
static nsIFileaFile
nsCStringArray mExtensions
 array of file extensions associated w/ this MIME obj
nsString mDescription
 human readable description
PRUint32 mMacType
PRUint32 mMacCreator
 Mac file type and creator.
nsCString mMIMEType
nsCOMPtr< nsIFilemPreferredApplication
 preferred application associated with this type.
nsMIMEInfoHandleAction mPreferredAction
 preferred action to associate with this type
nsString mPreferredAppDescription
nsString mDefaultAppDescription
PRBool mAlwaysAskBeforeHandling

Detailed Description

Definition at line 42 of file nsMIMEInfoMac.h.


Constructor & Destructor Documentation

nsMIMEInfoMac::nsMIMEInfoMac ( const char *  aMIMEType = "") [inline]

Definition at line 44 of file nsMIMEInfoMac.h.

: nsMIMEInfoImpl(aMIMEType) {}
nsMIMEInfoMac::nsMIMEInfoMac ( const nsACString &  aMIMEType) [inline]

Definition at line 45 of file nsMIMEInfoMac.h.

: nsMIMEInfoImpl(aMIMEType) {}

Member Function Documentation

NS_IMETHODIMP nsMIMEInfoBase::AppendExtension ( const nsACString &  aExtension) [inherited]

Definition at line 131 of file nsMIMEInfoImpl.cpp.

{
  mExtensions.AppendCString(aExtension);
  return NS_OK;
}

Here is the caller graph for this function:

void nsIMIMEInfo::appendExtension ( in AUTF8String  aExtension) [inherited]

Append a given extension to the set of extensions.

Copies basic data of this MIME Info Implementation to the given other MIME Info.

The data consists of the MIME Type, the (default) description, the MacOS type and creator, and the extension list (this object's extension list will replace aOther's list, not append to it). This function also ensures that aOther's primary extension will be the same as the one of this object.

Definition at line 317 of file nsMIMEInfoImpl.cpp.

NS_IMETHODIMP nsMIMEInfoBase::Equals ( nsIMIMEInfo aMIMEInfo,
PRBool _retval 
) [inherited]

Definition at line 162 of file nsMIMEInfoImpl.cpp.

{
    if (!aMIMEInfo) return NS_ERROR_NULL_POINTER;

    nsCAutoString type;
    nsresult rv = aMIMEInfo->GetMIMEType(type);
    if (NS_FAILED(rv)) return rv;

    *_retval = mMIMEType.Equals(type);

    return NS_OK;
}
boolean nsIMIMEInfo::equals ( in nsIMIMEInfo  aMIMEInfo) [inherited]

Returns whether or not these two MIME infos are logically equivalent maintaining the one-to-many relationship between MIME types and file extensions.

Returns:
TRUE if the two are considered equal
NS_IMETHODIMP nsMIMEInfoBase::ExtensionExists ( const nsACString &  aExtension,
PRBool _retval 
) [inherited]

Definition at line 78 of file nsMIMEInfoImpl.cpp.

{
    NS_ASSERTION(!aExtension.IsEmpty(), "no extension");
    PRBool found = PR_FALSE;
    PRUint32 extCount = mExtensions.Count();
    if (extCount < 1) return NS_OK;

    for (PRUint8 i=0; i < extCount; i++) {
        nsCString* ext = (nsCString*)mExtensions.CStringAt(i);
        if (ext->Equals(aExtension, nsCaseInsensitiveCStringComparator())) {
            found = PR_TRUE;
            break;
        }
    }

    *_retval = found;
    return NS_OK;
}
boolean nsIMIMEInfo::extensionExists ( in AUTF8String  aExtension) [inherited]

Returns whether or not the given extension is associated with this MIME info.

Returns:
TRUE if the association exists.
NS_IMETHODIMP nsMIMEInfoBase::GetAlwaysAskBeforeHandling ( PRBool aAlwaysAskBeforeHandling) [inherited]

Definition at line 286 of file nsMIMEInfoImpl.cpp.

{
  *aAlwaysAsk = mAlwaysAskBeforeHandling;

  return NS_OK;
}
NS_IMETHODIMP nsMIMEInfoBase::GetApplicationDescription ( nsAString &  aApplicationDescription) [inherited]

Definition at line 229 of file nsMIMEInfoImpl.cpp.

{
  if (mPreferredAppDescription.IsEmpty() && mPreferredApplication) {
    // Don't want to cache this, just in case someone resets the app
    // without changing the description....
    mPreferredApplication->GetLeafName(aApplicationDescription);
  } else {
    aApplicationDescription = mPreferredAppDescription;
  }
  
  return NS_OK;
}
NS_IMETHODIMP nsMIMEInfoImpl::GetDefaultDescription ( nsAString &  aDefaultDescription) [inherited]

Reimplemented from nsMIMEInfoBase.

Definition at line 352 of file nsMIMEInfoImpl.cpp.

{
  if (mDefaultAppDescription.IsEmpty() && mDefaultApplication) {
    // Don't want to cache this, just in case someone resets the app
    // without changing the description....
    mDefaultApplication->GetLeafName(aDefaultDescription);
  } else {
    aDefaultDescription = mDefaultAppDescription;
  }
  
  return NS_OK;
}
NS_IMETHODIMP nsMIMEInfoBase::GetDescription ( nsAString &  aDescription) [inherited]

Definition at line 148 of file nsMIMEInfoImpl.cpp.

{
    aDescription = mDescription;
    return NS_OK;
}

Gives you an array of file types associated with this type.

Returns:
Number of elements in the array.
Array of extensions.

Definition at line 72 of file nsMIMEInfoImpl.cpp.

Here is the call graph for this function:

Definition at line 366 of file nsMIMEInfoImpl.cpp.

{
  *_retval = PR_FALSE;
  if (mDefaultApplication) {
    PRBool exists;
    *_retval = NS_SUCCEEDED(mDefaultApplication->Exists(&exists)) && exists;
  }
  return NS_OK;
}
NS_IMETHODIMP nsMIMEInfoBase::GetMacCreator ( PRUint32 aMacCreator) [inherited]

Definition at line 194 of file nsMIMEInfoImpl.cpp.

{
    *aMacCreator = mMacCreator;

    if (!mMacCreator)
        return NS_ERROR_NOT_INITIALIZED;

    return NS_OK;
}
NS_IMETHODIMP nsMIMEInfoBase::GetMacType ( PRUint32 aMacType) [inherited]

Definition at line 176 of file nsMIMEInfoImpl.cpp.

{
    *aMacType = mMacType;

    if (!mMacType)
        return NS_ERROR_NOT_INITIALIZED;

    return NS_OK;
}
NS_IMETHODIMP nsMIMEInfoBase::GetMIMEType ( nsACString &  aMIMEType) [inherited]

Definition at line 138 of file nsMIMEInfoImpl.cpp.

{
    if (mMIMEType.IsEmpty())
        return NS_ERROR_NOT_INITIALIZED;

    aMIMEType = mMIMEType;
    return NS_OK;
}

Definition at line 272 of file nsMIMEInfoImpl.cpp.

{
  *aPreferredAction = mPreferredAction;
  return NS_OK;
}
NS_IMETHODIMP nsMIMEInfoBase::GetPreferredApplicationHandler ( nsIFile **  aPreferredApplicationHandler) [inherited]

Definition at line 257 of file nsMIMEInfoImpl.cpp.

{
  *aPreferredAppHandler = mPreferredApplication;
  NS_IF_ADDREF(*aPreferredAppHandler);
  return NS_OK;
}
NS_IMETHODIMP nsMIMEInfoBase::GetPrimaryExtension ( nsACString &  aPrimaryExtension) [inherited]

Definition at line 98 of file nsMIMEInfoImpl.cpp.

{
    PRUint32 extCount = mExtensions.Count();
    if (extCount < 1) return NS_ERROR_NOT_INITIALIZED;

    _retval = *(mExtensions.CStringAt(0));
    return NS_OK;    
}
PRBool nsMIMEInfoBase::HasExtensions ( ) const [inline, inherited]

Return whether this MIMEInfo has any extensions.

Definition at line 117 of file nsMIMEInfoImpl.h.

{ return mExtensions.Count() != 0; }

Reimplemented from nsMIMEInfoBase.

Definition at line 47 of file nsMIMEInfoMac.cpp.

{
  nsIFile* application;

  if (mPreferredAction == useHelperApp)
    application = mPreferredApplication;
  else if (mPreferredAction == useSystemDefault)
    application = mDefaultApplication;
  else
    return NS_ERROR_INVALID_ARG;

  if (application) {
    nsresult rv;
    nsCOMPtr<nsILocalFileMac> app = do_QueryInterface(application, &rv);
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsILocalFile> docToLoad = do_QueryInterface(aFile, &rv);
    if (NS_FAILED(rv)) return rv;

    return app->LaunchWithDoc(docToLoad, PR_FALSE); 
  }
#ifdef XP_MACOSX
  // We didn't get an application to handle the file from aMIMEInfo, ask LaunchServices directly
  nsresult rv;
  nsCOMPtr <nsILocalFileMac> tempFile = do_QueryInterface(aFile, &rv);
  if (NS_FAILED(rv)) return rv;
  
  FSRef tempFileRef;
  tempFile->GetFSRef(&tempFileRef);

  FSRef appFSRef;
  if (::LSGetApplicationForItem(&tempFileRef, kLSRolesAll, &appFSRef, nsnull) == noErr)
  {
    nsCOMPtr<nsILocalFileMac> app(do_CreateInstance("@mozilla.org/file/local;1"));
    if (!app) return NS_ERROR_FAILURE;
    app->InitWithFSRef(&appFSRef);
    
    nsCOMPtr <nsILocalFile> docToLoad = do_QueryInterface(aFile, &rv);
    if (NS_FAILED(rv)) return rv;
    
    rv = app->LaunchWithDoc(docToLoad, PR_FALSE); 
  }
  return rv;
#endif
}

Here is the call graph for this function:

void nsIMIMEInfo::launchWithFile ( in nsIFile  aFile) [inherited]

Launches the application with the specified file, in a way that depends on the value of preferredAction.

preferredAction must be useHelperApp or useSystemDefault.

Parameters:
aFileThe file to launch this application with.
Exceptions:
NS_ERROR_INVALID_ARGif action is not valid for this function. Other exceptions may be thrown.
virtual nsMIMEInfoImpl::NS_HIDDEN_ ( nsresult  ) [protected, virtual, inherited]

The base class implementation is to use LaunchWithIProcess in combination with mDefaultApplication.

Subclasses can override that behaviour.

Implements nsMIMEInfoBase.

Reimplemented in nsMIMEInfoBeOS.

NS_IMETHODIMP nsMIMEInfoBase::SetAlwaysAskBeforeHandling ( PRBool  aAlwaysAskBeforeHandling) [inherited]

Definition at line 294 of file nsMIMEInfoImpl.cpp.

{
  mAlwaysAskBeforeHandling = aAlwaysAsk;
  return NS_OK;
}
NS_IMETHODIMP nsMIMEInfoBase::SetApplicationDescription ( const nsAString &  aApplicationDescription) [inherited]

Definition at line 243 of file nsMIMEInfoImpl.cpp.

{
  mPreferredAppDescription = aApplicationDescription;
  return NS_OK;
}
void nsMIMEInfoImpl::SetDefaultApplication ( nsIFile aApp) [inline, inherited]

Sets the default application.

Supposed to be only called by the OS Helper App Services; the default application is immutable after it is first set.

Definition at line 176 of file nsMIMEInfoImpl.h.

Here is the caller graph for this function:

void nsMIMEInfoBase::SetDefaultDescription ( const nsString aDesc) [inline, inherited]

Definition at line 102 of file nsMIMEInfoImpl.h.

Here is the caller graph for this function:

NS_IMETHODIMP nsMIMEInfoBase::SetDescription ( const nsAString &  aDescription) [inherited]

Definition at line 155 of file nsMIMEInfoImpl.cpp.

{
    mDescription = aDescription;
    return NS_OK;
}

Here is the caller graph for this function:

void nsIMIMEInfo::setFileExtensions ( in AUTF8String  aExtensions) [inherited]

Set File Extensions.

Input is a comma delimited list of extensions.

NS_IMETHODIMP nsMIMEInfoBase::SetFileExtensions ( const nsACString &  aExtensions) [inherited]

Definition at line 212 of file nsMIMEInfoImpl.cpp.

{
    mExtensions.Clear();
    nsCString extList( aExtensions );
    
    PRInt32 breakLocation = -1;
    while ( (breakLocation= extList.FindChar(',') )!= -1)
    {
        mExtensions.AppendCString(Substring(extList.get(), extList.get() + breakLocation));
        extList.Cut(0, breakLocation+1 );
    }
    if ( !extList.IsEmpty() )
        mExtensions.AppendCString( extList );
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 205 of file nsMIMEInfoImpl.cpp.

{
    mMacCreator = aMacCreator;
    return NS_OK;
}

Definition at line 187 of file nsMIMEInfoImpl.cpp.

{
    mMacType = aMacType;
    return NS_OK;
}
void nsMIMEInfoBase::SetMIMEType ( const nsACString &  aMIMEType) [inline, inherited]

Definition at line 100 of file nsMIMEInfoImpl.h.

{ mMIMEType = aMIMEType; }

Here is the caller graph for this function:

Definition at line 279 of file nsMIMEInfoImpl.cpp.

{
  mPreferredAction = aPreferredAction;
  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsMIMEInfoBase::SetPreferredApplicationHandler ( nsIFile aPreferredApplicationHandler) [inherited]

Definition at line 265 of file nsMIMEInfoImpl.cpp.

{
  mPreferredApplication = aPreferredAppHandler;
  return NS_OK;
}
NS_IMETHODIMP nsMIMEInfoBase::SetPrimaryExtension ( const nsACString &  aPrimaryExtension) [inherited]

Definition at line 108 of file nsMIMEInfoImpl.cpp.

{
  NS_ASSERTION(!aExtension.IsEmpty(), "no extension");
  PRUint32 extCount = mExtensions.Count();
  PRUint8 i;
  PRBool found = PR_FALSE;
  for (i=0; i < extCount; i++) {
    nsCString* ext = (nsCString*)mExtensions.CStringAt(i);
    if (ext->Equals(aExtension, nsCaseInsensitiveCStringComparator())) {
      found = PR_TRUE;
      break;
    }
  }
  if (found) {
    mExtensions.RemoveCStringAt(i);
  }

  mExtensions.InsertCStringAt(aExtension, 0);
  
  return NS_OK;
}

Member Data Documentation

nsIFile* nsMIMEInfoBase::aFile [protected, inherited]

Definition at line 139 of file nsMIMEInfoImpl.h.

Definition at line 160 of file nsIMIMEInfo.idl.

alwaysAskBeforeHandling: if true, we should always give the user a dialog asking how to dispose of this content.

Definition at line 176 of file nsIMIMEInfo.idl.

A pretty name description of the preferred application.

Definition at line 132 of file nsIMIMEInfo.idl.

readonly attribute AString nsIMIMEInfo::defaultDescription [inherited]

A pretty name description of the associated default application.

Only usable if hasDefaultHandler is true.

Definition at line 145 of file nsIMIMEInfo.idl.

attribute AString nsIMIMEInfo::description [inherited]

A human readable description of the MIME info.

Returns:
The description

Definition at line 105 of file nsIMIMEInfo.idl.

Definition at line 162 of file nsIMIMEInfo.idl.

Indicates whether a default application handler exists, i.e.

whether launchWithFile with action = useSystemDefault is possible and applicationDescription will contain usable information.

Definition at line 139 of file nsIMIMEInfo.idl.

Definition at line 111 of file nsIMIMEInfo.idl.

Mac Type and creator types.

Definition at line 110 of file nsIMIMEInfo.idl.

Definition at line 150 of file nsMIMEInfoImpl.h.

Definition at line 149 of file nsMIMEInfoImpl.h.

default application associated with this type.

Definition at line 186 of file nsMIMEInfoImpl.h.

nsString nsMIMEInfoBase::mDescription [protected, inherited]

human readable description

Definition at line 143 of file nsMIMEInfoImpl.h.

nsCStringArray nsMIMEInfoBase::mExtensions [protected, inherited]

array of file extensions associated w/ this MIME obj

Definition at line 142 of file nsMIMEInfoImpl.h.

readonly attribute ACString nsIMIMEInfo::MIMEType [inherited]

The MIME type of this MIMEInfo.

Returns:
String representing the MIME type.

Definition at line 98 of file nsIMIMEInfo.idl.

PRUint32 nsMIMEInfoBase::mMacCreator [protected, inherited]

Mac file type and creator.

Definition at line 144 of file nsMIMEInfoImpl.h.

PRUint32 nsMIMEInfoBase::mMacType [protected, inherited]

Definition at line 144 of file nsMIMEInfoImpl.h.

nsCString nsMIMEInfoBase::mMIMEType [protected, inherited]

Definition at line 145 of file nsMIMEInfoImpl.h.

preferred action to associate with this type

Definition at line 147 of file nsMIMEInfoImpl.h.

Definition at line 148 of file nsMIMEInfoImpl.h.

preferred application associated with this type.

Definition at line 146 of file nsMIMEInfoImpl.h.

preferredAction is how the user specified they would like to handle this content type: save to disk, use specified helper app, use OS default handler or handle using navigator.

Definition at line 170 of file nsIMIMEInfo.idl.

Returns a nsIFile that points to the application the user has said they want associated with this content type.

This is not always guaranteed to be set!!

Definition at line 127 of file nsIMIMEInfo.idl.

attribute AUTF8String nsIMIMEInfo::primaryExtension [inherited]

Returns the first extension association in the internal set of extensions.

Returns:
The first extension.

Definition at line 91 of file nsIMIMEInfo.idl.

Definition at line 159 of file nsIMIMEInfo.idl.

Definition at line 161 of file nsIMIMEInfo.idl.

Definition at line 163 of file nsIMIMEInfo.idl.


The documentation for this class was generated from the following files: