Files
Mozilla/mozilla/xpinstall/src/nsWinProfileItem.cpp
ssu%netscape.com 07229a4b3a fixing bug #8227 and #10955
git-svn-id: svn://10.0.0.236/trunk@44470 18797224-902f-48f8-a5cc-f745e15eee43
1999-08-25 07:51:33 +00:00

118 lines
2.8 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 "nsWinProfileItem.h"
#include "nspr.h"
#include <windows.h>
/* Public Methods */
nsWinProfileItem::nsWinProfileItem(nsWinProfile* profileObj,
nsString sectionName,
nsString keyName,
nsString val,
PRInt32 *aReturn) : nsInstallObject(profileObj->InstallObject())
{
mProfile = profileObj;
mSection = new nsString(sectionName);
mKey = new nsString(keyName);
mValue = new nsString(val);
*aReturn = nsInstall::SUCCESS;
if((mSection == nsnull) ||
(mKey == nsnull) ||
(mValue == nsnull))
{
*aReturn = nsInstall::OUT_OF_MEMORY;
}
}
nsWinProfileItem::~nsWinProfileItem()
{
if (mSection) delete mSection;
if (mKey) delete mKey;
if (mValue) delete mValue;
}
PRInt32 nsWinProfileItem::Complete()
{
if (mProfile)
mProfile->FinalWriteString(*mSection, *mKey, *mValue);
return NS_OK;
}
char* nsWinProfileItem::toString()
{
char* resultCString;
nsString* filename = new nsString(*mProfile->GetFilename());
nsString* result = new nsString("Write ");
if (filename == nsnull || result == nsnull)
return nsnull;
result->Append(*filename);
result->Append(": [");
result->Append(*mSection);
result->Append("] ");
result->Append(*mKey);
result->Append("=");
result->Append(*mValue);
resultCString = result->ToNewCString();
if (result) delete result;
if (filename) delete filename;
return resultCString;
}
void nsWinProfileItem::Abort()
{
}
PRInt32 nsWinProfileItem::Prepare()
{
return nsnull;
}
/* CanUninstall
* WinProfileItem() does not install any files which can be uninstalled,
* hence this function returns false.
*/
PRBool
nsWinProfileItem::CanUninstall()
{
return PR_FALSE;
}
/* RegisterPackageNode
* WinProfileItem() installs files which need to be registered,
* hence this function returns true.
*/
PRBool
nsWinProfileItem::RegisterPackageNode()
{
return PR_TRUE;
}