Adding files for Progress support
git-svn-id: svn://10.0.0.236/trunk@31501 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
42ca8e31b1
commit
a72605dabc
117
mozilla/xpinstall/src/nsLoggingProgressNotifier.cpp
Normal file
117
mozilla/xpinstall/src/nsLoggingProgressNotifier.cpp
Normal file
@ -0,0 +1,117 @@
|
||||
/* -*- 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 "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIXPInstallProgressNotifier.h"
|
||||
#include "nsLoggingProgressNotifier.h"
|
||||
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
|
||||
#include "nspr.h"
|
||||
|
||||
|
||||
|
||||
nsLoggingProgressNotifier::nsLoggingProgressNotifier()
|
||||
{
|
||||
nsSpecialSystemDirectory logFile(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
|
||||
logFile += "Install.log";
|
||||
|
||||
mLogStream = new nsOutputFileStream(logFile, PR_WRONLY | PR_CREATE_FILE | PR_APPEND, 0744 );
|
||||
mLogStream->seek(logFile.GetFileSize());
|
||||
}
|
||||
|
||||
nsLoggingProgressNotifier::~nsLoggingProgressNotifier()
|
||||
{
|
||||
mLogStream->close();
|
||||
delete mLogStream;
|
||||
}
|
||||
|
||||
void
|
||||
nsLoggingProgressNotifier::BeforeJavascriptEvaluation(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
nsLoggingProgressNotifier::AfterJavascriptEvaluation(void)
|
||||
{
|
||||
char* time;
|
||||
GetTime(&time);
|
||||
|
||||
*mLogStream << nsEndl;
|
||||
*mLogStream << " Finished Installation " << time << nsEndl << nsEndl;
|
||||
|
||||
PL_strfree(time);
|
||||
}
|
||||
|
||||
void
|
||||
nsLoggingProgressNotifier::InstallStarted(const char* UIPackageName)
|
||||
{
|
||||
char* time;
|
||||
GetTime(&time);
|
||||
|
||||
*mLogStream << "---------------------------------------------------------------------------" << nsEndl;
|
||||
*mLogStream << UIPackageName << nsEndl;
|
||||
*mLogStream << "---------------------------------------------------------------------------" << nsEndl;
|
||||
*mLogStream << nsEndl;
|
||||
*mLogStream << " Starting Installation at " << nsAutoCString(time) << nsEndl;
|
||||
*mLogStream << nsEndl;
|
||||
|
||||
|
||||
PL_strfree(time);
|
||||
}
|
||||
|
||||
long
|
||||
nsLoggingProgressNotifier::ItemScheduled(const char* message )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
nsLoggingProgressNotifier::InstallFinalization(const char* message, long itemNum, long totNum )
|
||||
{
|
||||
*mLogStream << " " << message << nsEndl;
|
||||
}
|
||||
|
||||
void
|
||||
nsLoggingProgressNotifier::InstallAborted(void)
|
||||
{
|
||||
char* time;
|
||||
GetTime(&time);
|
||||
|
||||
*mLogStream << " Aborted Installation at " << time << nsEndl << nsEndl;
|
||||
|
||||
PL_strfree(time);
|
||||
}
|
||||
|
||||
void
|
||||
nsLoggingProgressNotifier::GetTime(char** aString)
|
||||
{
|
||||
PRExplodedTime et;
|
||||
char line[256];
|
||||
PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &et);
|
||||
PR_FormatTimeUSEnglish(line, sizeof(line), "%m/%d/%Y %H:%M:%S", &et);
|
||||
*aString = PL_strdup(line);
|
||||
}
|
||||
|
||||
53
mozilla/xpinstall/src/nsLoggingProgressNotifier.h
Normal file
53
mozilla/xpinstall/src/nsLoggingProgressNotifier.h
Normal file
@ -0,0 +1,53 @@
|
||||
/* -*- 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 "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef nsLoggingProgressNotifier_H__
|
||||
#define nsLoggingProgressNotifier_H__
|
||||
|
||||
#include "nsIXPInstallProgressNotifier.h"
|
||||
#include "nsFileStream.h"
|
||||
|
||||
|
||||
class nsLoggingProgressNotifier : public nsIXPInstallProgressNotifier
|
||||
{
|
||||
public:
|
||||
|
||||
nsLoggingProgressNotifier();
|
||||
virtual ~nsLoggingProgressNotifier();
|
||||
|
||||
void BeforeJavascriptEvaluation(void);
|
||||
void AfterJavascriptEvaluation(void);
|
||||
void InstallStarted(const char* UIPackageName);
|
||||
long ItemScheduled(const char* message );
|
||||
void InstallFinalization(const char* message, long itemNum, long totNum );
|
||||
void InstallAborted(void);
|
||||
|
||||
private:
|
||||
void GetTime(char** aString);
|
||||
nsOutputFileStream *mLogStream;
|
||||
};
|
||||
|
||||
#endif
|
||||
159
mozilla/xpinstall/src/nsTopProgressNotifier.cpp
Normal file
159
mozilla/xpinstall/src/nsTopProgressNotifier.cpp
Normal file
@ -0,0 +1,159 @@
|
||||
/* -*- 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 "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsIXPInstallProgressNotifier.h"
|
||||
#include "nsTopProgressNotifier.h"
|
||||
|
||||
nsTopProgressNotifier::nsTopProgressNotifier()
|
||||
{
|
||||
mNotifiers = new nsVector();
|
||||
}
|
||||
|
||||
nsTopProgressNotifier::~nsTopProgressNotifier()
|
||||
{
|
||||
if (mNotifiers)
|
||||
{
|
||||
PRUint32 i=0;
|
||||
for (; i < mNotifiers->GetSize(); i++)
|
||||
{
|
||||
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
|
||||
delete element;
|
||||
}
|
||||
|
||||
mNotifiers->RemoveAll();
|
||||
delete (mNotifiers);
|
||||
}
|
||||
}
|
||||
|
||||
long
|
||||
nsTopProgressNotifier::RegisterNotifier(nsIXPInstallProgressNotifier * newNotifier)
|
||||
{
|
||||
return mNotifiers->Add( newNotifier );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsTopProgressNotifier::UnregisterNotifier(long id)
|
||||
{
|
||||
mNotifiers->Set(id, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
nsTopProgressNotifier::BeforeJavascriptEvaluation(void)
|
||||
{
|
||||
if (mNotifiers)
|
||||
{
|
||||
PRUint32 i=0;
|
||||
for (; i < mNotifiers->GetSize(); i++)
|
||||
{
|
||||
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
|
||||
if (element != NULL)
|
||||
element->BeforeJavascriptEvaluation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTopProgressNotifier::AfterJavascriptEvaluation(void)
|
||||
{
|
||||
if (mNotifiers)
|
||||
{
|
||||
PRUint32 i=0;
|
||||
for (; i < mNotifiers->GetSize(); i++)
|
||||
{
|
||||
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
|
||||
if (element != NULL)
|
||||
element->AfterJavascriptEvaluation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTopProgressNotifier::InstallStarted(const char* UIPackageName)
|
||||
{
|
||||
if (mNotifiers)
|
||||
{
|
||||
PRUint32 i=0;
|
||||
for (; i < mNotifiers->GetSize(); i++)
|
||||
{
|
||||
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
|
||||
if (element != NULL)
|
||||
element->InstallStarted(UIPackageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long
|
||||
nsTopProgressNotifier::ItemScheduled( const char* message )
|
||||
{
|
||||
long rv = 0;
|
||||
|
||||
if (mNotifiers)
|
||||
{
|
||||
PRUint32 i=0;
|
||||
for (; i < mNotifiers->GetSize(); i++)
|
||||
{
|
||||
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
|
||||
if (element != NULL)
|
||||
if (element->ItemScheduled( message ) != 0)
|
||||
rv = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
nsTopProgressNotifier::InstallFinalization( const char* message, long itemNum, long totNum )
|
||||
{
|
||||
if (mNotifiers)
|
||||
{
|
||||
PRUint32 i=0;
|
||||
for (; i < mNotifiers->GetSize(); i++)
|
||||
{
|
||||
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
|
||||
if (element != NULL)
|
||||
element->InstallFinalization( message, itemNum, totNum );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTopProgressNotifier::InstallAborted(void)
|
||||
{
|
||||
if (mNotifiers)
|
||||
{
|
||||
PRUint32 i=0;
|
||||
for (; i < mNotifiers->GetSize(); i++)
|
||||
{
|
||||
nsIXPInstallProgressNotifier* element = (nsIXPInstallProgressNotifier*)mNotifiers->Get(i);
|
||||
if (element != NULL)
|
||||
element->InstallAborted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
54
mozilla/xpinstall/src/nsTopProgressNotifier.h
Normal file
54
mozilla/xpinstall/src/nsTopProgressNotifier.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* -*- 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 "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code,
|
||||
* released March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Contributors:
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef nsTopProgressNotifier_h__
|
||||
#define nsTopProgressNotifier_h__
|
||||
|
||||
#include "nsIXPInstallProgressNotifier.h"
|
||||
#include "nsVector.h"
|
||||
|
||||
|
||||
class nsTopProgressNotifier : public nsIXPInstallProgressNotifier
|
||||
{
|
||||
public:
|
||||
|
||||
nsTopProgressNotifier();
|
||||
virtual ~nsTopProgressNotifier();
|
||||
|
||||
long RegisterNotifier(nsIXPInstallProgressNotifier * newNotifier);
|
||||
void UnregisterNotifier(long id);
|
||||
|
||||
void BeforeJavascriptEvaluation(void);
|
||||
void AfterJavascriptEvaluation(void);
|
||||
void InstallStarted(const char* UIPackageName);
|
||||
long ItemScheduled(const char* message );
|
||||
void InstallFinalization(const char* message, long itemNum, long totNum );
|
||||
void InstallAborted(void);
|
||||
|
||||
private:
|
||||
nsVector *mNotifiers;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user