gecko-dev/uriloader/exthandler/nsMIMEInfoImpl.cpp
mccabe%netscape.com 4f7990cd94 Fix to 7610. Modify xpidl compiler to add 'const' to the method signature for generated attribute setter methods for string, wstring and nsid attributes.
As this changed the generated interface signatures, I had to change all of the uses to avoid bustage.  Any corners of the browser that aren't built by default, or that I haven't discovered how to build, may be at risk of bustage if they use string or wstring attributes.  (This could mean blackwood; sorry, guys!)

Many thanks to Alec Flett (alecf@netscape.com) for preparing diffs for the mailnews portion of the signature changes; thanks also to Ariel Backenroth (arielb@rice.edu) and Mike Shaver (shaver@mozilla.org) for help with updating the tree with NS_DECL_NSIFOO macros; everwhere where one of these macros was used was one less place I had to manually add 'const'.

Also removed extraneous space from generated method signatures, leftover from Brendan's capitalization spam, and made 'const decl must be of type short or long' an error rather than just a warning.
1999-09-19 23:46:35 +00:00

104 lines
3.0 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsMIMEInfoImpl.h"
#include "nsCRT.h"
// nsISupports methods
NS_IMPL_ISUPPORTS(nsMIMEInfoImpl, NS_GET_IID(nsIMIMEInfo));
// nsMIMEInfoImpl methods
nsMIMEInfoImpl::nsMIMEInfoImpl(const char *aMIMEType, const char *aFileExtensions, const char *aDescription) {
NS_INIT_REFCNT();
mMIMEType = NS_NewAtom(aMIMEType);
mFileExtensions.SetString(aFileExtensions);
mDescription.SetString(aDescription);
}
nsMIMEInfoImpl::~nsMIMEInfoImpl() {
NS_RELEASE(mMIMEType);
}
PRBool
nsMIMEInfoImpl::InExtensions(nsIAtom* anIAtom) {
nsAutoString extension;
anIAtom->ToString(extension);
// XXX this is broken. need to use gessner's tokenizer stuff to delimit the commas
if (mFileExtensions.Find(extension) == -1)
return PR_FALSE;
return PR_TRUE;
}
// nsIMIMEInfo methods
NS_IMETHODIMP
nsMIMEInfoImpl::GetFileExtensions(char * *aFileExtensions) {
if (!aFileExtensions) return NS_ERROR_NULL_POINTER;
*aFileExtensions = mFileExtensions.ToNewCString();
if (!*aFileExtensions)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsMIMEInfoImpl::SetFileExtensions(const char * aFileExtensions) {
mFileExtensions.SetString(aFileExtensions);
return NS_OK;
}
NS_IMETHODIMP
nsMIMEInfoImpl::GetMIMEType(char * *aMIMEType) {
if (!aMIMEType) return NS_ERROR_NULL_POINTER;
nsAutoString strMIMEType;
mMIMEType->ToString(strMIMEType);
*aMIMEType = strMIMEType.ToNewCString();
if (!*aMIMEType) return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsMIMEInfoImpl::SetMIMEType(const char * aMIMEType) {
NS_RELEASE(mMIMEType);
mMIMEType = NS_NewAtom(aMIMEType);
if (!mMIMEType) return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsMIMEInfoImpl::GetDescription(PRUnichar * *aDescription) {
if (!aDescription) return NS_ERROR_NULL_POINTER;
*aDescription = mDescription.ToNewUnicode();
if (!*aDescription) return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
NS_IMETHODIMP
nsMIMEInfoImpl::SetDescription(const PRUnichar * aDescription) {
mDescription.SetString(aDescription);
return NS_OK;
}
NS_IMETHODIMP
nsMIMEInfoImpl::Equals(nsIMIMEInfo *aMIMEInfo, PRBool *_retval) {
return NS_ERROR_NOT_IMPLEMENTED;
}