Landing #169667 - Clean up InternetConfigService and use LaunchServices APIs where appropriate. r=ccarlen,sr=sfraser

This commit is contained in:
sdagley%netscape.com 2002-09-26 23:38:08 +00:00
Родитель 51e6604e46
Коммит e571c5e2c2
8 изменённых файлов: 382 добавлений и 343 удалений

Просмотреть файл

@ -119,31 +119,3 @@ nsInternetConfig::~nsInternetConfig()
sInstance = NULL;
}
}
nsresult nsInternetConfig::GetString( ConstStr255Param inKey, char** outString )
{
nsresult result = NS_ERROR_FAILURE;
ICInstance instance = nsInternetConfig::GetInstance();
if ( instance )
{
OSStatus err;
char buffer[256];
ICAttr junk;
long size = 256;
err = ::ICGetPref( instance, inKey, &junk, buffer, &size );
if ( err == noErr )
{
if (size == 0) {
*outString = nsnull;
return NS_OK;
}
// Buffer is a Pascal string
nsCString temp( &buffer[1], buffer[0] );
*outString = ToNewCString(temp);
result = NS_OK;
}
}
return result;
}

Просмотреть файл

@ -47,7 +47,6 @@ class nsInternetConfig
public:
nsInternetConfig();
~nsInternetConfig();
nsresult GetString( ConstStr255Param inKey, char** outString );
static ICInstance GetInstance();
static PRBool HasSeedChanged();

Просмотреть файл

@ -20,6 +20,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Steve Dagley <sdagley@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -40,26 +41,33 @@
#include "nsIMIMEInfo.h"
#include "nsIFactory.h"
#include "nsIComponentManager.h"
#include "nsLocalFileMac.h"
#include "nsIURL.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsILocalFileMac.h"
#include "nsMimeTypes.h"
#include <TextUtils.h>
#include "nsColor.h"
#include <CodeFragments.h>
#include <Processes.h>
#include <Gestalt.h>
#include <CFURL.h>
#include <Finder.h>
#include <LaunchServices.h>
// helper converter function.....
static void ConvertCharStringToStr255(const char* inString, Str255& outString)
{
if (inString == NULL)
return;
PRInt32 len = strlen(inString);
NS_ASSERTION(len <= 255 , " String is too big");
if (len> 255)
{
len = 255;
}
memcpy(&outString[1], inString, len);
outString[0] = len;
@ -71,6 +79,11 @@ static NS_DEFINE_CID(kICServiceCID, NS_INTERNETCONFIGSERVICE_CID);
nsInternetConfigService::nsInternetConfigService()
{
NS_INIT_ISUPPORTS();
long version;
OSErr err;
mRunningOSX = ((err = ::Gestalt(gestaltSystemVersion, &version)) == noErr && version >= 0x00001000);
mRunningJaguar = (err == noErr && version >= 0x00001200);
}
nsInternetConfigService::~nsInternetConfigService()
@ -81,35 +94,43 @@ nsInternetConfigService::~nsInternetConfigService()
/*
* Implement the nsISupports methods...
*/
NS_IMPL_THREADSAFE_ADDREF(nsInternetConfigService)
NS_IMPL_THREADSAFE_RELEASE(nsInternetConfigService)
NS_INTERFACE_MAP_BEGIN(nsInternetConfigService)
NS_INTERFACE_MAP_ENTRY(nsIInternetConfigService)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIInternetConfigService)
NS_INTERFACE_MAP_END_THREADSAFE
NS_IMPL_ISUPPORTS1(nsInternetConfigService, nsIInternetConfigService)
// void LaunchURL (in string url);
// given a url string, call ICLaunchURL using url
// Given a url string, call ICLaunchURL using url
// Under OS X use LaunchServices instead of IC
NS_IMETHODIMP nsInternetConfigService::LaunchURL(const char *url)
{
nsresult result;
nsresult rv = NS_ERROR_FAILURE;
#if defined(TARGET_CARBON) || defined(XP_MACOSX)
if (mRunningOSX && ((UInt32)LSOpenCFURLRef != (UInt32)kUnresolvedCFragSymbolAddress))
{
CFURLRef myURLRef = ::CFURLCreateWithBytes(
kCFAllocatorDefault,
(const UInt8*)url,
strlen(url),
kCFStringEncodingUTF8, NULL);
if (myURLRef)
{
rv = ::LSOpenCFURLRef(myURLRef, NULL);
::CFRelease(myURLRef);
}
}
else
#endif
{
size_t len = strlen(url);
long selStart = 0, selEnd = len;
ICInstance inst = nsInternetConfig::GetInstance();
if (inst)
{
result = ::ICLaunchURL(inst, "\p", (Ptr)url, (long)len, &selStart, &selEnd);
if (result == noErr)
return NS_OK;
else
return NS_ERROR_FAILURE;
if (::ICLaunchURL(inst, "\p", (Ptr)url, (long)len, &selStart, &selEnd) == noErr)
rv = NS_OK;
}
else
{
return NS_ERROR_FAILURE;
}
return rv;
}
// boolean HasMappingForMIMEType (in string mimetype);
@ -130,27 +151,78 @@ NS_IMETHODIMP nsInternetConfigService::HasMappingForMIMEType(const char *mimetyp
// protocol handler for protocol
NS_IMETHODIMP nsInternetConfigService::HasProtocolHandler(const char *protocol, PRBool *_retval)
{
*_retval = PR_FALSE;
*_retval = PR_FALSE; // Presume failure
nsresult rv = NS_ERROR_FAILURE; // Ditto
#if defined(TARGET_CARBON) || defined(XP_MACOSX)
// Use LaunchServices directly when we're running under OS X to avoid the problem of some protocols
// apparently not being reflected into the IC mappings (webcal for one). Even better it seems
// LaunchServices under 10.1.x will often fail to find an app when using LSGetApplicationForURL
// so we only use it for 10.2 or later.
// Since protocol comes in with _just_ the protocol we have to add a ':' to the end of it or
// LaunchServices will be very unhappy with the CFURLRef created from it (crashes trying to look
// up a handler for it with LSGetApplicationForURL, at least under 10.2.1)
if (mRunningJaguar)
{
nsCAutoString scheme(protocol);
scheme += ":";
CFURLRef myURLRef = ::CFURLCreateWithBytes(
kCFAllocatorDefault,
(const UInt8 *)scheme.get(),
scheme.Length(),
kCFStringEncodingUTF8, NULL);
if (myURLRef)
{
FSRef appFSRef;
if (::LSGetApplicationForURL(myURLRef, kLSRolesAll, &appFSRef, NULL) == noErr)
{ // Now see if the FSRef for the found app == the running app
ProcessSerialNumber psn;
if (::GetCurrentProcess(&psn) == noErr)
{
FSRef runningAppFSRef;
if (::GetProcessBundleLocation(&psn, &runningAppFSRef) == noErr)
{
if (::FSCompareFSRefs(&appFSRef, &runningAppFSRef) == noErr)
{ // Oops, the current app is the handler which would cause infinite recursion
rv = NS_ERROR_NOT_AVAILABLE;
}
else
{
*_retval = PR_TRUE;
rv = NS_OK;
}
}
}
}
::CFRelease(myURLRef);
}
}
else
#endif
{
// look for IC pref "\pHelper¥<protocol>"
Str255 pref = kICHelper;
if (strlen(protocol) > 248)
return NS_ERROR_OUT_OF_MEMORY;
memcpy(pref + pref[0] + 1, protocol, strlen(protocol));
pref[0] = pref[0] + strlen(protocol);
if (nsCRT::strlen(protocol) > 248)
rv = NS_ERROR_OUT_OF_MEMORY;
else
{
memcpy(pref + pref[0] + 1, protocol, nsCRT::strlen(protocol));
pref[0] = pref[0] + nsCRT::strlen(protocol);
ICInstance instance = nsInternetConfig::GetInstance();
if ( !instance )
return NS_ERROR_FAILURE;
if (instance)
{
OSStatus err;
ICAttr junk;
ICAppSpec spec;
long ioSize = sizeof(ICAppSpec);
err = ::ICGetPref(instance, pref, &junk, (void *)&spec, &ioSize);
if ( err != noErr )
return NS_ERROR_FAILURE;
if (err == noErr)
{
// check if registered protocol helper is us
// if so, return PR_FALSE because we'll go into infinite recursion
// continually launching back into ourselves
@ -166,17 +238,19 @@ NS_IMETHODIMP nsInternetConfigService::HasProtocolHandler(const char *protocol,
if (err == noErr)
{
if (info.processSignature != spec.fCreator)
{
*_retval = PR_TRUE;
else
return NS_ERROR_NOT_AVAILABLE;
rv = NS_OK;
}
else
return NS_ERROR_FAILURE;
rv = NS_ERROR_NOT_AVAILABLE;
}
else
return NS_ERROR_FAILURE;
return NS_OK;
}
}
}
}
}
return rv;
}
// This method does the dirty work of traipsing through IC mappings database
@ -187,7 +261,8 @@ nsresult nsInternetConfigService::GetMappingForMIMEType(const char *mimetype, co
OSStatus err = noErr;
ICAttr attr;
Handle prefH;
PRBool domimecheck = PR_TRUE, gotmatch = PR_FALSE;
PRBool domimecheck = PR_TRUE;
PRBool gotmatch = PR_FALSE;
ICMapEntry ent;
// if mime type is "unknown" or "octet stream" *AND* we have a file extension,
@ -214,7 +289,7 @@ nsresult nsInternetConfigService::GetMappingForMIMEType(const char *mimetype, co
if (err == noErr)
{
long pos;
for(long i = 1; i <= count; i++)
for (long i = 1; i <= count; ++i)
{
err = ::ICGetIndMapEntry(inst, prefH, i, &pos, &ent);
if (err == noErr)
@ -273,6 +348,7 @@ nsresult nsInternetConfigService::GetMappingForMIMEType(const char *mimetype, co
}
}
}
if (err != noErr)
return NS_ERROR_FAILURE;
else
@ -317,8 +393,7 @@ nsresult nsInternetConfigService::FillMIMEInfoForICEntry(ICMapEntry& entry, nsIM
{
// there is a post processor app
info->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
nsCID cid = NS_LOCAL_FILE_CID;
nsCOMPtr<nsILocalFileMac> file (do_CreateInstance(cid));
nsCOMPtr<nsILocalFileMac> file (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
if (file)
{
rv = file->InitToAppWithCreatorCode(entry.postCreator);
@ -366,15 +441,12 @@ NS_IMETHODIMP nsInternetConfigService::FillInMIMEInfo(const char *mimetype, cons
{
rv = GetMappingForMIMEType(mimetype, nsnull, &entry);
}
if (rv == NS_OK)
{
rv = FillMIMEInfoForICEntry(entry, mimeinfo);
}
if (rv == NS_OK)
rv = FillMIMEInfoForICEntry(entry, mimeinfo);
else
{
rv = NS_ERROR_FAILURE;
}
return rv;
}
@ -395,7 +467,6 @@ NS_IMETHODIMP nsInternetConfigService::GetMIMEInfoFromExtension(const char *aFil
rv = FillMIMEInfoForICEntry(entry, _retval);
}
}
return rv;
}
@ -415,7 +486,6 @@ NS_IMETHODIMP nsInternetConfigService::GetMIMEInfoFromTypeCreator(PRUint32 aType
if (err == noErr)
rv = FillMIMEInfoForICEntry(entry,_retval);
}
return rv;
}
@ -449,7 +519,6 @@ NS_IMETHODIMP nsInternetConfigService::GetFileMappingFlags(FSSpec* fsspec, PRBoo
rv = NS_OK;
}
return rv;
}
@ -507,135 +576,144 @@ NS_IMETHODIMP nsInternetConfigService::GetDownloadFolder(FSSpec *fsspec)
return rv;
}
nsresult nsInternetConfigService::GetICKeyPascalString(PRUint32 inIndex, unsigned char **outICKey)
nsresult nsInternetConfigService::GetICKeyPascalString(PRUint32 inIndex, const unsigned char*& outICKey)
{
nsresult result = NS_OK;
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 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 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 = kICWWWHomePage; 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 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 = kICWWWHomePage; 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;
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:
result = NS_ERROR_INVALID_ARG;
rv = NS_ERROR_INVALID_ARG;
}
return result;
return rv;
}
nsresult nsInternetConfigService::GetICPreference(PRUint32 inKey,
void *outData, long *ioSize)
{
unsigned char *icKey;
nsresult result = GetICKeyPascalString( inKey, &icKey );
if (NS_FAILED(result))
return result;
const unsigned char *icKey;
nsresult rv = GetICKeyPascalString(inKey, icKey);
if (rv == NS_OK)
{
ICInstance instance = nsInternetConfig::GetInstance();
if ( !instance )
return NS_ERROR_FAILURE;
if (instance)
{
OSStatus err;
ICAttr junk;
err = ::ICGetPref(instance, icKey, &junk, outData, ioSize);
if ( err )
return NS_ERROR_UNEXPECTED;
return NS_OK;
if (err != noErr)
rv = NS_ERROR_UNEXPECTED;
}
else
rv = NS_ERROR_FAILURE;
}
return rv;
}
NS_IMETHODIMP nsInternetConfigService::GetString(PRUint32 inKey, char **value)
NS_IMETHODIMP nsInternetConfigService::GetString(PRUint32 inKey, nsACString& value)
{
long size = 256;
char buffer[256];
nsresult result = GetICPreference( inKey, (void *)&buffer, &size );
if ( result == NS_OK ) {
if ( size == 0 ) {
*value = nsnull;
return NS_ERROR_UNEXPECTED;
nsresult rv = GetICPreference(inKey, (void *)&buffer, &size);
if (rv == NS_OK)
{
if (size == 0)
{
value = "";
rv = NS_ERROR_UNEXPECTED;
}
// Buffer is a Pascal string; convert it to a c-string
nsCString temp( &buffer[1], buffer[0] );
*value = ToNewCString(temp);
else
{ // Buffer is a Pascal string so adjust for length byte when assigning
value.Assign(&buffer[1], (unsigned char)buffer[0]);
}
return result;
}
return rv;
}
NS_IMETHODIMP nsInternetConfigService::GetColor(PRUint32 inKey, PRUint32 *outColor)
{
// We're 'borrowing' this macro from nscolor.h so that uriloader doesn't depend on gfx.
// Make a color out of r,g,b values. This assumes that the r,g,b values are
// properly constrained to 0-255. This also assumes that a is 255.
#define MAKE_NS_RGB(_r,_g,_b) \
((PRUint32) ((255 << 24) | ((_b)<<16) | ((_g)<<8) | (_r)))
RGBColor buffer;
long size = sizeof(RGBColor);
nsresult result = GetICPreference( inKey, &buffer, &size );
if ( result == NS_OK ) {
if ( size != sizeof(RGBColor) ) {
*outColor = NS_RGB(0xff, 0xff, 0xff); // default to white if we didn't get the right size
return NS_OK;
nsresult rv = GetICPreference(inKey, &buffer, &size);
if (rv == NS_OK)
{
if (size != sizeof(RGBColor))
{ // default to white if we didn't get the right size
*outColor = MAKE_NS_RGB(0xff, 0xff, 0xff);
}
// convert to a web color
*outColor = NS_RGB( buffer.red>>8, buffer.green>>8, buffer.blue>>8 );
else
{ // convert to a web color
*outColor = MAKE_NS_RGB(buffer.red >> 8, buffer.green >> 8, buffer.blue >> 8);
}
return result;
}
return rv;
}
@ -643,22 +721,13 @@ NS_IMETHODIMP nsInternetConfigService::GetBoolean(PRUint32 inKey, PRBool *outFla
{
Boolean buffer;
long size = sizeof(Boolean);
nsresult result = GetICPreference( inKey, (void *)&buffer, &size );
if ( result == NS_OK ) {
if ( size < sizeof(Boolean) ) {
*outFlag = PR_FALSE; // default to false if we didn't get the right amount of data
return NS_OK;
}
*outFlag = buffer;
result = NS_OK;
}
return result;
}
NS_IMETHODIMP nsInternetConfigService::GetText(PRUint32 inKey, PRUint32 *ioLength, PRUnichar **outText)
nsresult rv = GetICPreference(inKey, (void *)&buffer, &size);
if (rv == NS_OK)
{
return NS_ERROR_NOT_IMPLEMENTED;
if ((size_t)size < sizeof(Boolean))
*outFlag = PR_FALSE; // default to false if we didn't get the right amount of data
else
*outFlag = buffer;
}
return rv;
}

Просмотреть файл

@ -59,8 +59,11 @@ protected:
// some private helper methods...
nsresult FillMIMEInfoForICEntry(ICMapEntry& entry, nsIMIMEInfo ** mimeinfo);
nsresult GetICKeyPascalString(PRUint32 inIndex, unsigned char **outICKey);
nsresult GetICKeyPascalString(PRUint32 inIndex, const unsigned char*& outICKey);
nsresult GetICPreference(PRUint32 inKey, void *outData, long *ioSize);
PRBool mRunningOSX;
PRBool mRunningJaguar;
};
#endif

Просмотреть файл

@ -123,11 +123,9 @@ interface nsIInternetConfigService : nsISupports
[noscript] void getDownloadFolder(out FSSpec fsspec);
string getString(in unsigned long keyenum);
ACString getString(in unsigned long keyenum);
unsigned long getColor(in unsigned long keyenum);
boolean getBoolean(in unsigned long keyenum);
wstring getText(in unsigned long keyenum, out unsigned long length);
};

Просмотреть файл

@ -65,6 +65,8 @@
#include "nsSound.h"
#include "nsString.h"
//#define SOUND_DEBUG
#pragma mark nsSoundRequest
@ -433,8 +435,8 @@ nsSound::GetSoundResourceName(const char* inSoundName, StringPtr outResourceName
if (NS_FAILED(rv))
return rv;
nsXPIDLCString newMailSound;
rv = icService->GetString(nsIInternetConfigService::eICString_NewMailSoundName, getter_Copies(newMailSound));
nsCAutoString newMailSound;
rv = icService->GetString(nsIInternetConfigService::eICString_NewMailSoundName, newMailSound);
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -60,14 +60,12 @@ nsUserInfo::GetFullname(PRUnichar **aFullname)
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
{
char* cName;
result = icService->GetString(nsIInternetConfigService::eICString_RealName, &cName);
nsCAutoString cName;
result = icService->GetString(nsIInternetConfigService::eICString_RealName, cName);
if ( NS_SUCCEEDED ( result ) )
{
nsString fullName;
fullName.AssignWithConversion( cName );
nsMemory::Free( cName );
*aFullname = ToNewUnicode(fullName);
*aFullname = ToNewUnicode(cName);
}
}
return result;
@ -81,7 +79,11 @@ nsUserInfo::GetEmailAddress(char * *aEmailAddress)
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
{
result = icService->GetString(nsIInternetConfigService::eICString_Email, aEmailAddress);
nsCAutoString tempString;
result = icService->GetString(nsIInternetConfigService::eICString_Email, tempString);
if (NS_SUCCEEDED(result))
*aEmailAddress = ToNewCString(tempString);
}
return result;
}
@ -91,16 +93,14 @@ nsUserInfo::GetUsername(char * *aUsername)
{
*aUsername = nsnull;
char* cString;
nsCAutoString tempString;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
rv = icService->GetString(nsIInternetConfigService::eICString_Email, &cString);
rv = icService->GetString(nsIInternetConfigService::eICString_Email, tempString);
if ( NS_FAILED( rv ) ) return rv;
nsCAutoString tempString(cString);
nsMemory::Free( cString );
const char* atString = "@";
PRInt32 atOffset = tempString.Find(atString);
if (atOffset != kNotFound)
@ -114,14 +114,12 @@ NS_IMETHODIMP
nsUserInfo::GetDomain(char * *aDomain)
{
*aDomain = nsnull;
char* cString;
nsCAutoString tempString;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
rv = icService->GetString(nsIInternetConfigService::eICString_Email, &cString);
rv = icService->GetString(nsIInternetConfigService::eICString_Email, tempString);
if ( NS_FAILED( rv ) ) return rv;
nsCAutoString tempString( cString);
nsMemory::Free( cString );
const char* atString = "@";
PRInt32 atOffset = tempString.Find(atString);
if (atOffset != kNotFound)

Просмотреть файл

@ -60,14 +60,12 @@ nsUserInfo::GetFullname(PRUnichar **aFullname)
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
{
char* cName;
result = icService->GetString(nsIInternetConfigService::eICString_RealName, &cName);
nsCAutoString cName;
result = icService->GetString(nsIInternetConfigService::eICString_RealName, cName);
if ( NS_SUCCEEDED ( result ) )
{
nsString fullName;
fullName.AssignWithConversion( cName );
nsMemory::Free( cName );
*aFullname = ToNewUnicode(fullName);
*aFullname = ToNewUnicode(cName);
}
}
return result;
@ -81,7 +79,11 @@ nsUserInfo::GetEmailAddress(char * *aEmailAddress)
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
{
result = icService->GetString(nsIInternetConfigService::eICString_Email, aEmailAddress);
nsCAutoString tempString;
result = icService->GetString(nsIInternetConfigService::eICString_Email, tempString);
if (NS_SUCCEEDED(result))
*aEmailAddress = ToNewCString(tempString);
}
return result;
}
@ -91,16 +93,14 @@ nsUserInfo::GetUsername(char * *aUsername)
{
*aUsername = nsnull;
char* cString;
nsCAutoString tempString;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
rv = icService->GetString(nsIInternetConfigService::eICString_Email, &cString);
rv = icService->GetString(nsIInternetConfigService::eICString_Email, tempString);
if ( NS_FAILED( rv ) ) return rv;
nsCAutoString tempString(cString);
nsMemory::Free( cString );
const char* atString = "@";
PRInt32 atOffset = tempString.Find(atString);
if (atOffset != kNotFound)
@ -114,14 +114,12 @@ NS_IMETHODIMP
nsUserInfo::GetDomain(char * *aDomain)
{
*aDomain = nsnull;
char* cString;
nsCAutoString tempString;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
rv = icService->GetString(nsIInternetConfigService::eICString_Email, &cString);
rv = icService->GetString(nsIInternetConfigService::eICString_Email, tempString);
if ( NS_FAILED( rv ) ) return rv;
nsCAutoString tempString( cString);
nsMemory::Free( cString );
const char* atString = "@";
PRInt32 atOffset = tempString.Find(atString);
if (atOffset != kNotFound)