Back to index

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

#include <nsInternetConfigService.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIINTERNETCONFIGSERVICE
nsresult 
GetMappingForMIMEType (const char *mimetype, const char *fileextension, ICMapEntry *entry)
 nsInternetConfigService ()
virtual ~nsInternetConfigService ()
void launchURL (in string url)
boolean hasMappingForMIMEType (in string mimetype)
boolean hasProtocolHandler (in string protocol)
void fillInMIMEInfo (in string mimetype, in string aFileExtension, out nsIMIMEInfo mimeinfo)
void getMIMEInfoFromExtension (in string aFileExt, out nsIMIMEInfo mimeinfo)
void getMIMEInfoFromTypeCreator (in PRUint32 aType, in PRUint32 aCreator, in string aFileExt, out nsIMIMEInfo mimeInfo)
long getFileMappingFlags (in FSSpecPtr fsspec, in boolean lookupByExtensionFirst)
void getDownloadFolder (out FSSpec fsspec)
ACString getString (in unsigned long keyenum)
unsigned long getColor (in unsigned long keyenum)
boolean getBoolean (in unsigned long keyenum)

Public Attributes

const unsigned long eICColor_WebBackgroundColour = 1
const unsigned long eICColor_WebReadColor = 2
const unsigned long eICColor_WebTextColor = 3
const unsigned long eICColor_WebUnreadColor = 4
const unsigned long eICBoolean_WebUnderlineLinks = 11
const unsigned long eICString_WWWHomePage = 101
const unsigned long eICString_WebSearchPagePrefs = 102
const unsigned long eICString_MacSearchHost = 103
const unsigned long eICString_FTPHost = 121
const unsigned long eICBoolean_UsePassiveFTP = 122
const unsigned long eICBoolean_UseFTPProxy = 123
const unsigned long eICString_FTPProxyUser = 124
const unsigned long eICString_FTPProxyAccount = 125
const unsigned long eICString_FTPProxyHost = 126
const unsigned long eICString_FTPProxyPassword = 127
const unsigned long eICBoolean_UseHTTPProxy = 130
const unsigned long eICString_HTTPProxyHost = 131
const unsigned long eICString_LDAPSearchbase = 201
const unsigned long eICString_LDAPServer = 202
const unsigned long eICString_SMTPHost = 221
const unsigned long eICString_Email = 222
const unsigned long eICString_MailAccount = 223
const unsigned long eICString_MailPassword = 224
const unsigned long eICText_MailHeaders = 225
const unsigned long eICText_Signature = 226
const unsigned long eICBoolean_NewMailDialog = 231
const unsigned long eICBoolean_NewMailFlashIcon = 232
const unsigned long eICBoolean_NewMailPlaySound = 233
const unsigned long eICString_NewMailSoundName = 234
const unsigned long eICString_NNTPHost = 241
const unsigned long eICString_NewsAuthUsername = 242
const unsigned long eICString_NewsAuthPassword = 243
const unsigned long eICText_NewsHeaders = 244
const unsigned long eICString_InfoMacPreferred = 245
const unsigned long eICString_Organization = 251
const unsigned long eICString_RealName = 252
const unsigned long eICText_SnailMailAddress = 253
const unsigned long eICString_QuotingString = 254
const unsigned long eICString_GopherHost = 301
const unsigned long eICBoolean_UseGopherProxy = 302
const unsigned long eICString_GopherProxy = 303
const unsigned long eICBoolean_UseSocks = 321
const unsigned long eICString_SocksHost = 322
const unsigned long eICString_TelnetHost = 331
const unsigned long eICString_IRCHost = 341
const unsigned long eICString_NTPHost = 351
const unsigned long eICString_WAISGateway = 381
const unsigned long eICString_FingerHost = 382
const unsigned long eICText_Plan = 383
const unsigned long eICString_WhoisHost = 384
const unsigned long eICString_PhHost = 385
const unsigned long eICString_ArchiePreferred = 386
const unsigned long eICString_UMichPreferred = 391
const unsigned long eIICMapFlag_BinaryMask = 1
const unsigned long eIICMapFlag_ResourceForkMask = 2
const unsigned long eIICMapFlag_DataForkMask = 4
const unsigned long eIICMapFlag_PostMask = 8
const unsigned long eIICMapFlag_NotIncomingMask = 16
const unsigned long eIICMapFlag_NotOutgoingMask = 32

Protected Member Functions

nsresult FillMIMEInfoForICEntry (ICMapEntry &entry, nsIMIMEInfo **mimeinfo)
nsresult GetICKeyPascalString (PRUint32 inIndex, const unsigned char *&outICKey)
nsresult GetICPreference (PRUint32 inKey, void *outData, long *ioSize)

Detailed Description

Definition at line 47 of file nsInternetConfigService.h.


Constructor & Destructor Documentation

Definition at line 80 of file nsInternetConfigService.cpp.

{
}

Definition at line 84 of file nsInternetConfigService.cpp.

{
}

Member Function Documentation

void nsIInternetConfigService::fillInMIMEInfo ( in string  mimetype,
in string  aFileExtension,
out nsIMIMEInfo  mimeinfo 
) [inherited]
nsresult nsInternetConfigService::FillMIMEInfoForICEntry ( ICMapEntry &  entry,
nsIMIMEInfo **  mimeinfo 
) [protected]

Definition at line 279 of file nsInternetConfigService.cpp.

{
  // create a mime info object and we'll fill it in based on the values from IC mapping entry
  nsresult  rv = NS_OK;
  nsRefPtr<nsMIMEInfoMac> info (new nsMIMEInfoMac());
  if (info)
  {
    nsCAutoString mimetype ((char *)&entry.MIMEType[1], entry.MIMEType[0]);
    // check if entry.MIMEType is empty, if so, set mime type to APPLICATION_OCTET_STREAM
    if (entry.MIMEType[0])
      info->SetMIMEType(mimetype);
    else
    { // The IC mappings seem to not be very agressive about determining the mime type if
      // all we have is a type or creator code.  This is a bandaid approach for when we
      // get a file of type 'TEXT' with no mime type mapping so that we'll display the
      // file rather than trying to download it.
      if (entry.fileType == 'TEXT')
        info->SetMIMEType(NS_LITERAL_CSTRING(TEXT_PLAIN));
      else
        info->SetMIMEType(NS_LITERAL_CSTRING(APPLICATION_OCTET_STREAM));
    }
    
    // convert entry.extension which is a Str255 
    // don't forget to remove the '.' in front of the file extension....
    nsCAutoString temp((char *)&entry.extension[2], entry.extension[0] > 0 ? (int)entry.extension[0]-1 : 0);
    info->AppendExtension(temp);
    info->SetMacType(entry.fileType);
    info->SetMacCreator(entry.fileCreator);
    temp.Assign((char *) &entry.entryName[1], entry.entryName[0]);
    info->SetDescription(NS_ConvertASCIItoUCS2(temp));
    
    temp.Assign((char *) &entry.postAppName[1], entry.postAppName[0]);
    info->SetDefaultDescription(NS_ConvertASCIItoUCS2(temp));
    
    if (entry.flags & kICMapPostMask)
    {
      // there is a post processor app
      info->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
      nsCOMPtr<nsILocalFileMac> file (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
      if (file)
      {
        rv = file->InitToAppWithCreatorCode(entry.postCreator);
        if (rv == NS_OK)
        {
          nsCOMPtr<nsIFile> nsfile = do_QueryInterface(file, &rv);
          if (rv == NS_OK)
            info->SetDefaultApplication(nsfile);
        }
      }
    }
    else
    {
      // there isn't a post processor app so set the preferred action to be save to disk.
      info->SetPreferredAction(nsIMIMEInfo::saveToDisk);
    }
    
    *mimeinfo = info;
    NS_IF_ADDREF(*mimeinfo);
  }
  else // we failed to allocate the info object...
    rv = NS_ERROR_FAILURE;
   
  return rv;
}

Here is the call graph for this function:

boolean nsIInternetConfigService::getBoolean ( in unsigned long  keyenum) [inherited]
unsigned long nsIInternetConfigService::getColor ( in unsigned long  keyenum) [inherited]
long nsIInternetConfigService::getFileMappingFlags ( in FSSpecPtr  fsspec,
in boolean  lookupByExtensionFirst 
) [inherited]
nsresult nsInternetConfigService::GetICKeyPascalString ( PRUint32  inIndex,
const unsigned char *&  outICKey 
) [protected]

Definition at line 499 of file nsInternetConfigService.cpp.

{
  nsresult  rv = NS_OK;

  switch (inIndex)
  {
    case eICColor_WebBackgroundColour: outICKey = kICWebBackgroundColour; break;
    case eICColor_WebReadColor:        outICKey = kICWebReadColor;        break;
    case eICColor_WebTextColor:        outICKey = kICWebTextColor;        break;
    case eICColor_WebUnreadColor:      outICKey = kICWebUnreadColor;      break;

    case eICBoolean_WebUnderlineLinks: outICKey = kICWebUnderlineLinks;  break;
    case eICBoolean_UseFTPProxy:       outICKey = kICUseFTPProxy;        break;
    case eICBoolean_UsePassiveFTP:     outICKey = kICUsePassiveFTP;      break;
    case eICBoolean_UseHTTPProxy:      outICKey = kICUseHTTPProxy;       break;
    case eICBoolean_NewMailDialog:     outICKey = kICNewMailDialog;      break;
    case eICBoolean_NewMailFlashIcon:  outICKey = kICNewMailFlashIcon;   break;
    case eICBoolean_NewMailPlaySound:  outICKey = kICNewMailPlaySound;   break;
    case eICBoolean_UseGopherProxy:    outICKey = kICUseGopherProxy;     break;
    case eICBoolean_UseSocks:          outICKey = kICUseSocks;           break;

    case eICString_WWWHomePage:        outICKey = kICWWWHomePage;        break;
    case eICString_WebSearchPagePrefs: outICKey = kICWebSearchPagePrefs; break;
    case eICString_MacSearchHost:      outICKey = kICMacSearchHost;      break;
    case eICString_FTPHost:            outICKey = kICFTPHost;            break;
    case eICString_FTPProxyUser:       outICKey = kICFTPProxyUser;       break;
    case eICString_FTPProxyAccount:    outICKey = kICFTPProxyAccount;    break;
    case eICString_FTPProxyHost:       outICKey = kICFTPProxyHost;       break;
    case eICString_FTPProxyPassword:   outICKey = kICFTPProxyPassword;   break;
    case eICString_HTTPProxyHost:      outICKey = kICHTTPProxyHost;      break;
    case eICString_LDAPSearchbase:     outICKey = kICLDAPSearchbase;     break;
    case eICString_LDAPServer:         outICKey = kICLDAPServer;         break;
    case eICString_SMTPHost:           outICKey = kICSMTPHost;           break;
    case eICString_Email:              outICKey = kICEmail;              break;
    case eICString_MailAccount:        outICKey = kICMailAccount;        break;
    case eICString_MailPassword:       outICKey = kICMailPassword;       break;
    case eICString_NewMailSoundName:   outICKey = kICNewMailSoundName;   break;
    case eICString_NNTPHost:           outICKey = kICNNTPHost;           break;
    case eICString_NewsAuthUsername:   outICKey = kICNewsAuthUsername;   break;
    case eICString_NewsAuthPassword:   outICKey = kICNewsAuthPassword;   break;
    case eICString_InfoMacPreferred:   outICKey = kICInfoMacPreferred;   break;
    case eICString_Organization:       outICKey = kICOrganization;       break;
    case eICString_QuotingString:      outICKey = kICQuotingString;      break;
    case eICString_RealName:           outICKey = kICRealName;           break;
    case eICString_FingerHost:         outICKey = kICFingerHost;         break;
    case eICString_GopherHost:         outICKey = kICGopherHost;         break;
    case eICString_GopherProxy:        outICKey = kICGopherProxy;        break;
    case eICString_SocksHost:          outICKey = kICSocksHost;          break;
    case eICString_TelnetHost:         outICKey = kICTelnetHost;         break;
    case eICString_IRCHost:            outICKey = kICIRCHost;            break;
    case eICString_UMichPreferred:     outICKey = kICUMichPreferred;     break;
    case eICString_WAISGateway:        outICKey = kICWAISGateway;        break;
    case eICString_WhoisHost:          outICKey = kICWhoisHost;          break;
    case eICString_PhHost:             outICKey = kICPhHost;             break;
    case eICString_NTPHost:            outICKey = kICNTPHost;            break;
    case eICString_ArchiePreferred:    outICKey = kICArchiePreferred;    break;
    
    case eICText_MailHeaders:          outICKey = kICMailHeaders;        break;
    case eICText_Signature:            outICKey = kICSignature;          break;
    case eICText_NewsHeaders:          outICKey = kICNewsHeaders;        break;
    case eICText_SnailMailAddress:     outICKey = kICSnailMailAddress;   break;
    case eICText_Plan:                 outICKey = kICPlan;               break;

    default:
      rv = NS_ERROR_INVALID_ARG;
  }
  return rv;
}

Here is the caller graph for this function:

nsresult nsInternetConfigService::GetICPreference ( PRUint32  inKey,
void outData,
long ioSize 
) [protected]

Definition at line 569 of file nsInternetConfigService.cpp.

{
  const unsigned char *icKey;
  nsresult  rv = GetICKeyPascalString(inKey, icKey);
  if (rv == NS_OK)
  {
    ICInstance  instance = nsInternetConfig::GetInstance();
    if (instance)
    {
      OSStatus  err;
      ICAttr    junk;
      err = ::ICGetPref(instance, icKey, &junk, outData, ioSize);
      if (err != noErr)
        rv = NS_ERROR_UNEXPECTED;
    }
    else
      rv = NS_ERROR_FAILURE;
  }
  return rv;
}

Here is the call graph for this function:

nsresult nsInternetConfigService::GetMappingForMIMEType ( const char *  mimetype,
const char *  fileextension,
ICMapEntry *  entry 
)

Definition at line 179 of file nsInternetConfigService.cpp.

{
  ICInstance  inst = nsInternetConfig::GetInstance();
  OSStatus    err = noErr;
  ICAttr      attr;
  Handle      prefH;
  PRBool      domimecheck = PR_TRUE;
  PRBool      gotmatch = PR_FALSE;
  ICMapEntry  ent;
  
  // if mime type is "unknown" or "octet stream" *AND* we have a file extension,
  // then disable match on mime type
  if (((nsCRT::strcasecmp(mimetype, UNKNOWN_CONTENT_TYPE) == 0) ||
       (nsCRT::strcasecmp(mimetype, APPLICATION_OCTET_STREAM) == 0)) &&
       fileextension)
    domimecheck = PR_FALSE;
  
  entry->totalLength = 0;
  if (inst)
  {
    err = ::ICBegin(inst, icReadOnlyPerm);
    if (err == noErr)
    {
      prefH = ::NewHandle(2048); // picked 2048 out of thin air
      if (prefH)
      {
        err = ::ICFindPrefHandle(inst, kICMapping, &attr, prefH);
        if (err == noErr)
        {
          long count;
          err = ::ICCountMapEntries(inst, prefH, &count);
          if (err == noErr)
          {
            long pos;
            for (long i = 1; i <= count; ++i)
            {
              err = ::ICGetIndMapEntry(inst, prefH, i, &pos, &ent);
              if (err == noErr)
              {
                // first, do mime type check
                if (domimecheck)
                {
                  nsCAutoString temp((char *)&ent.MIMEType[1], (int)ent.MIMEType[0]);
                  if (!temp.EqualsIgnoreCase(mimetype))
                  {
                    // we need to do mime check, and check failed
                    // nothing here to see, move along
                    continue;
                  }
                }
                if (fileextension)
                {
                  // if fileextension was passed in, compare that also
                  if (ent.extension[0]) // check for non-empty pascal string
                  {
                    nsCAutoString temp((char *)&ent.extension[1], (int)ent.extension[0]);
                    if (temp.EqualsIgnoreCase(fileextension))
                    {
                      // mime type and file extension match, we're outta here
                      gotmatch = PR_TRUE;
                      // copy over ICMapEntry
                      *entry = ent;
                      break;
                    }
                  }
                }
                else if(domimecheck)
                {
                  // at this point, we've got our match because
                  // domimecheck is true, the mime strings match, and fileextension isn't passed in
                  // bad thing is we'll stop on first match, but what can you do?
                  gotmatch = PR_TRUE;
                  // copy over ICMapEntry
                  *entry = ent;
                  break;
                }
              }
            }
          }
        }
        ::DisposeHandle(prefH);
      }
      else
      {
        err = memFullErr;
      }
      err = ::ICEnd(inst);
      if (err == noErr && gotmatch == PR_FALSE)
      {
        err = fnfErr; // return SOME kind of error
      }
    }
  }
  
  if (err != noErr)
    return NS_ERROR_FAILURE;
  else
    return NS_OK;
}

Here is the call graph for this function:

void nsIInternetConfigService::getMIMEInfoFromTypeCreator ( in PRUint32  aType,
in PRUint32  aCreator,
in string  aFileExt,
out nsIMIMEInfo  mimeInfo 
) [inherited]
ACString nsIInternetConfigService::getString ( in unsigned long  keyenum) [inherited]

Member Data Documentation

Definition at line 77 of file nsIInternetConfigService.idl.

Definition at line 78 of file nsIInternetConfigService.idl.

Definition at line 79 of file nsIInternetConfigService.idl.

Definition at line 68 of file nsIInternetConfigService.idl.

Definition at line 88 of file nsIInternetConfigService.idl.

Definition at line 71 of file nsIInternetConfigService.idl.

Definition at line 67 of file nsIInternetConfigService.idl.

Definition at line 89 of file nsIInternetConfigService.idl.

Definition at line 62 of file nsIInternetConfigService.idl.

Definition at line 58 of file nsIInternetConfigService.idl.

Definition at line 59 of file nsIInternetConfigService.idl.

Definition at line 60 of file nsIInternetConfigService.idl.

Definition at line 61 of file nsIInternetConfigService.idl.

Definition at line 97 of file nsIInternetConfigService.idl.

Definition at line 74 of file nsIInternetConfigService.idl.

Definition at line 94 of file nsIInternetConfigService.idl.

Definition at line 66 of file nsIInternetConfigService.idl.

Definition at line 69 of file nsIInternetConfigService.idl.

Definition at line 69 of file nsIInternetConfigService.idl.

Definition at line 70 of file nsIInternetConfigService.idl.

Definition at line 68 of file nsIInternetConfigService.idl.

Definition at line 87 of file nsIInternetConfigService.idl.

Definition at line 88 of file nsIInternetConfigService.idl.

Definition at line 71 of file nsIInternetConfigService.idl.

Definition at line 83 of file nsIInternetConfigService.idl.

Definition at line 91 of file nsIInternetConfigService.idl.

Definition at line 72 of file nsIInternetConfigService.idl.

Definition at line 72 of file nsIInternetConfigService.idl.

Definition at line 65 of file nsIInternetConfigService.idl.

Definition at line 75 of file nsIInternetConfigService.idl.

Definition at line 75 of file nsIInternetConfigService.idl.

Definition at line 79 of file nsIInternetConfigService.idl.

Definition at line 81 of file nsIInternetConfigService.idl.

Definition at line 81 of file nsIInternetConfigService.idl.

Definition at line 80 of file nsIInternetConfigService.idl.

Definition at line 92 of file nsIInternetConfigService.idl.

Definition at line 84 of file nsIInternetConfigService.idl.

Definition at line 96 of file nsIInternetConfigService.idl.

Definition at line 86 of file nsIInternetConfigService.idl.

Definition at line 84 of file nsIInternetConfigService.idl.

Definition at line 73 of file nsIInternetConfigService.idl.

Definition at line 89 of file nsIInternetConfigService.idl.

Definition at line 90 of file nsIInternetConfigService.idl.

Definition at line 98 of file nsIInternetConfigService.idl.

Definition at line 93 of file nsIInternetConfigService.idl.

Definition at line 64 of file nsIInternetConfigService.idl.

Definition at line 95 of file nsIInternetConfigService.idl.

Definition at line 63 of file nsIInternetConfigService.idl.

Definition at line 76 of file nsIInternetConfigService.idl.

Definition at line 82 of file nsIInternetConfigService.idl.

Definition at line 94 of file nsIInternetConfigService.idl.

Definition at line 76 of file nsIInternetConfigService.idl.

Definition at line 85 of file nsIInternetConfigService.idl.

Definition at line 100 of file nsIInternetConfigService.idl.

Definition at line 102 of file nsIInternetConfigService.idl.

Definition at line 104 of file nsIInternetConfigService.idl.

Definition at line 105 of file nsIInternetConfigService.idl.

Definition at line 103 of file nsIInternetConfigService.idl.

Definition at line 101 of file nsIInternetConfigService.idl.


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