зеркало из https://github.com/mozilla/pjs.git
Landing of nsITimeBomb. It still needs to be tested on unix and the mac as
well as peer reviwed. For these reasons it is not hooked up yet. bug 1542.
This commit is contained in:
Родитель
e56cba2b2e
Коммит
cc85a37898
|
@ -0,0 +1,63 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.org code.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
|
||||
|
||||
DEPTH = ..\..\..
|
||||
MODULE = tbmb
|
||||
DLL = .\$(OBJDIR)\$(MODULE).dll
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
DIRS = tools resources
|
||||
|
||||
EXPORTS = \
|
||||
.\nsTimeBomb.h \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsITimeBomb.idl \
|
||||
$(NULL)
|
||||
|
||||
|
||||
LINCS = \
|
||||
-I$(PUBLIC)/xpcom \
|
||||
$(NULL)
|
||||
|
||||
LLIBS = \
|
||||
$(LIBNSPR) \
|
||||
$(DIST)\lib\js3250.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(NULL)
|
||||
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\nsTimeBomb.obj \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(MODULE).dll $(DIST)\bin\components
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\components\$(MODULE).dll
|
|
@ -0,0 +1,110 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (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.org code.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Doug Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/****************************************************************
|
||||
Time Bomb
|
||||
|
||||
In order to use timebombs, you must set the preference:
|
||||
|
||||
timebomb.enabled
|
||||
|
||||
This must be set to true for the time bomb to be activated.
|
||||
|
||||
There are two type of timebombs. The first is an absolute
|
||||
timebomb which expires on a given date regardless of build
|
||||
date. These absolute dates are set in the preferences:
|
||||
|
||||
timebomb.expiration_time
|
||||
timebomb.warning_time
|
||||
|
||||
The values are relative to the epoch, midnight, January 1,
|
||||
1970 UTC in microseconds. This is basically a PRTime.
|
||||
|
||||
The second form of timebomb is naturally relative. It take
|
||||
a start date and an two offset.
|
||||
|
||||
The first relative check is agains the build time preference:
|
||||
|
||||
timebomb.build_time
|
||||
|
||||
The two offsets are:
|
||||
|
||||
timebomb.expiration_offset
|
||||
timebomb.warning_offset
|
||||
|
||||
The next relative check is against the first launch. The
|
||||
preferences for first run is:
|
||||
|
||||
timebomb.first_launch_time
|
||||
|
||||
It will be set for you the first time nsITimeBomb is called.
|
||||
|
||||
If you only want to preform a time bomb after the
|
||||
first launch, simply do not define timebomb.build_time.
|
||||
|
||||
|
||||
Since these preferences are set in a plain text
|
||||
javascript file and there currently is not pref
|
||||
locking in mozilla, a user could simply remove
|
||||
any one of these setting.
|
||||
|
||||
When the application does expire, you can specify a
|
||||
URL to load.
|
||||
|
||||
timebomb.timebombURL
|
||||
|
||||
|
||||
****************************************************************/
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(93fabc84-e1bf-11d3-ac71-00c04fa0d26b)]
|
||||
|
||||
interface nsITimeBomb : nsISupports
|
||||
{
|
||||
void init();
|
||||
|
||||
void checkWithUI(out boolean expired);
|
||||
void loadUpdateURL();
|
||||
|
||||
readonly attribute boolean expired;
|
||||
readonly attribute boolean warned;
|
||||
|
||||
readonly attribute boolean enabled;
|
||||
|
||||
readonly attribute PRTime expirationTime;
|
||||
readonly attribute PRTime warningTime;
|
||||
|
||||
readonly attribute PRTime buildTime;
|
||||
readonly attribute PRTime firstLaunch;
|
||||
readonly attribute PRInt64 warningOffset;
|
||||
readonly attribute PRInt64 expirationOffset;
|
||||
|
||||
readonly attribute string timebombURL;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_TIMEBOMB_PROGID "component://netscape/timebomb"
|
||||
%}
|
||||
|
|
@ -0,0 +1,372 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Doug Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsTimeBomb.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nspr.h"
|
||||
#include "plstr.h"
|
||||
|
||||
#include "nsIWebShellWindow.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsIBrowserWindow.h"
|
||||
|
||||
#include "nsIIOService.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
|
||||
|
||||
static nsresult DisplayURI(const char *urlStr, PRBool block)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> URL;
|
||||
|
||||
rv = NS_NewURI(getter_AddRefs(URL), (const char *)urlStr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIWebShellWindow> window;
|
||||
rv = appShell->CreateTopLevelWindow(nsnull,
|
||||
URL,
|
||||
PR_TRUE,
|
||||
PR_TRUE,
|
||||
NS_CHROME_ALL_CHROME,
|
||||
nsnull,
|
||||
NS_SIZETOCONTENT, // width
|
||||
NS_SIZETOCONTENT, // height
|
||||
getter_AddRefs(window));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
/*
|
||||
* Start up the main event loop...
|
||||
*/
|
||||
if (block)
|
||||
rv = appShell->Run();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
class nsTimeBomb : public nsITimeBomb
|
||||
{
|
||||
public:
|
||||
|
||||
nsTimeBomb();
|
||||
virtual ~nsTimeBomb();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSITIMEBOMB
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIPref> mPrefs;
|
||||
nsresult GetInt64ForPref(const char* pref, PRInt64* time);
|
||||
};
|
||||
|
||||
nsTimeBomb::nsTimeBomb()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsTimeBomb::~nsTimeBomb()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsTimeBomb, NS_GET_IID(nsITimeBomb));
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimeBomb::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = nsServiceManager::GetService(kPrefCID, NS_GET_IID(nsIPref), getter_AddRefs(mPrefs));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get prefs");
|
||||
|
||||
PRTime time = LL_Zero();
|
||||
rv = GetFirstLaunch(&time);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
time = PR_Now();
|
||||
char buffer[30];
|
||||
PR_snprintf(buffer, 30, "%lld", time);
|
||||
mPrefs->SetCharPref("timebomb.first_launch_time", buffer);
|
||||
rv = NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimeBomb::CheckWithUI(PRBool *expired)
|
||||
{
|
||||
*expired = PR_FALSE;
|
||||
|
||||
PRBool val;
|
||||
nsresult rv = GetEnabled(&val);
|
||||
|
||||
if (NS_FAILED(rv) && !val)
|
||||
{
|
||||
// was not set or not enabled.
|
||||
// no problems. just return okay.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = GetExpired(&val);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && val)
|
||||
{
|
||||
printf("******** Expired version ********\n");
|
||||
DisplayURI("chrome://timebomb/content/expireText.xul", PR_TRUE);
|
||||
*expired = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = GetWarned(&val);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && val)
|
||||
{
|
||||
printf("******** ABOUT TO EXPIRE ********\n");
|
||||
DisplayURI("chrome://timebomb/content/warnText.xul", PR_TRUE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimeBomb::LoadUpdateURL()
|
||||
{
|
||||
char* url;
|
||||
GetTimebombURL(&url);
|
||||
nsresult rv = DisplayURI(url, PR_FALSE);
|
||||
nsAllocator::Free(url);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimeBomb::GetExpired(PRBool *expired)
|
||||
{
|
||||
*expired = PR_FALSE;
|
||||
|
||||
PRTime bombTime = LL_Zero();
|
||||
PRTime currentTime = PR_Now();
|
||||
|
||||
// check absolute expiration;
|
||||
|
||||
nsresult rv = GetExpirationTime(&bombTime);
|
||||
|
||||
if (NS_FAILED(rv)) return NS_OK;
|
||||
|
||||
if (LL_CMP(bombTime, <, currentTime))
|
||||
{
|
||||
*expired = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// try relative expiration;
|
||||
|
||||
PRTime offsetTime = LL_Zero();
|
||||
PRTime offset = LL_Zero();
|
||||
|
||||
rv = GetBuildTime(&bombTime);
|
||||
if (NS_FAILED(rv)) return NS_OK;
|
||||
rv = GetExpirationOffset(&offset);
|
||||
if (NS_FAILED(rv)) return NS_OK;
|
||||
|
||||
LL_ADD(offsetTime, bombTime, offset);
|
||||
if (LL_CMP(offsetTime, <, currentTime))
|
||||
{
|
||||
*expired = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = GetFirstLaunch(&bombTime);
|
||||
if (NS_FAILED(rv)) return NS_OK;
|
||||
|
||||
LL_ADD(offsetTime, bombTime, offset);
|
||||
if (LL_CMP(offsetTime, <, currentTime))
|
||||
{
|
||||
*expired = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimeBomb::GetWarned(PRBool *warn)
|
||||
{
|
||||
*warn = PR_FALSE;
|
||||
|
||||
PRTime bombTime = LL_Zero();
|
||||
PRTime currentTime = PR_Now();
|
||||
|
||||
// check absolute expiration;
|
||||
|
||||
nsresult rv = GetWarningTime(&bombTime);
|
||||
|
||||
if (NS_FAILED(rv)) return NS_OK;
|
||||
|
||||
if (LL_CMP(bombTime, <, currentTime))
|
||||
{
|
||||
*warn = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// try relative expiration;
|
||||
|
||||
PRTime offsetTime = LL_Zero();
|
||||
PRTime offset = LL_Zero();
|
||||
|
||||
rv = GetBuildTime(&bombTime);
|
||||
if (NS_FAILED(rv)) return NS_OK;
|
||||
rv = GetWarningOffset(&offset);
|
||||
if (NS_FAILED(rv)) return NS_OK;
|
||||
|
||||
LL_ADD(offsetTime, bombTime, offset);
|
||||
if (LL_CMP(offsetTime, <, currentTime))
|
||||
{
|
||||
*warn = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = GetFirstLaunch(&bombTime);
|
||||
if (NS_FAILED(rv)) return NS_OK;
|
||||
|
||||
LL_ADD(offsetTime, bombTime, offset);
|
||||
if (LL_CMP(offsetTime, <, currentTime))
|
||||
{
|
||||
*warn = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimeBomb::GetEnabled(PRBool *enabled)
|
||||
{
|
||||
return mPrefs->GetBoolPref("timebomb.enabled",enabled);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimeBomb::GetExpirationTime(PRTime *time)
|
||||
{
|
||||
return GetInt64ForPref("timebomb.expiration_time", time);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimeBomb::GetWarningTime(PRTime *time)
|
||||
{
|
||||
return GetInt64ForPref("timebomb.warning_time", time);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimeBomb::GetBuildTime(PRTime *time)
|
||||
{
|
||||
return GetInt64ForPref("timebomb.build_time", time);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimeBomb::GetFirstLaunch(PRTime *time)
|
||||
{
|
||||
return GetInt64ForPref("timebomb.first_launch_time", time);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimeBomb::GetWarningOffset(PRInt64 *offset)
|
||||
{
|
||||
return GetInt64ForPref("timebomb.warning_offset", offset);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimeBomb::GetExpirationOffset(PRInt64 *offset)
|
||||
{
|
||||
return GetInt64ForPref("timebomb.expiration_offset", offset);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimeBomb::GetTimebombURL(char* *url)
|
||||
{
|
||||
char* string;
|
||||
nsresult rv = mPrefs->CopyCharPref("timebomb.update_url", &string);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
*url = (char*)nsAllocator::Clone(string, (strlen(string)+1)*sizeof(char));
|
||||
if(*url)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
string = "http://www.mozilla.org/projects/seamonkey/";
|
||||
*url = (char*)nsAllocator::Clone(string, (strlen(string)+1)*sizeof(char));
|
||||
|
||||
if(*url)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsTimeBomb::GetInt64ForPref(const char* pref, PRInt64* time)
|
||||
{
|
||||
char* string;
|
||||
nsresult rv = mPrefs->CopyCharPref(pref, &string);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
PR_sscanf(string, "%lld", time);
|
||||
PL_strfree(string);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimeBomb)
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "Netscape TimeBomb",
|
||||
NS_TIMEBOMB_CID,
|
||||
NS_TIMEBOMB_PROGID,
|
||||
nsTimeBombConstructor
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("nsTimeBomb", components)
|
|
@ -0,0 +1,26 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Doug Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsITimeBomb.h"
|
||||
|
||||
#define NS_TIMEBOMB_CID { 0x141917dc, 0xe1c3, 0x11d3, {0xac, 0x71, 0x00, 0xc0, 0x4f, 0xa0, 0xd2, 0x6b}}
|
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.org code.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
EXPORT_RESOURCE_CONTENT = \
|
||||
$(srcdir)/warn.xul \
|
||||
$(srcdir)/expireText.xul \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
install::
|
||||
$(INSTALL) $(EXPORT_RESOURCE_CONTENT) $(DIST)/bin/chrome/timebomb/content/default
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- The contents of this file are subject to the Netscape Public
|
||||
License Version 1.1 (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.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Doug Turner (dougt@netscape.com)
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://timebomb/locale/timebomb.dtd">
|
||||
|
||||
<window title="&title.label;"
|
||||
id="timebomb-window"
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<box align="vertical">
|
||||
<html:td align="center">
|
||||
<html:label>&expireText.label;</html:label>
|
||||
</html:td>
|
||||
<html:td align="center">
|
||||
<html:button onclick="return window.close();">&okButton.label;</html:button>
|
||||
</html:td>
|
||||
</box>
|
||||
|
||||
</window>
|
|
@ -0,0 +1,31 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.org code.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..\..
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install::
|
||||
$(MAKE_INSTALL) warn.xul $(DIST)\bin\chrome\timebomb\content\default
|
||||
$(MAKE_INSTALL) expireText.xul $(DIST)\bin\chrome\timebomb\content\default
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\chrome\timebomb\content\default\*.*
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- The contents of this file are subject to the Netscape Public
|
||||
License Version 1.1 (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.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Doug Turner (dougt@netscape.com)
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE window SYSTEM "chrome://timebomb/locale/timebomb.dtd">
|
||||
|
||||
<window title="&title.label;"
|
||||
id="timebomb-window"
|
||||
xmlns:html="http://www.w3.org/TR/REC-html40"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<box align="vertical">
|
||||
<html:td align="center">
|
||||
<html:label>&warnText.label;</html:label>
|
||||
</html:td>
|
||||
<html:td align="center">
|
||||
<html:button onclick="return window.close();">&okButton.label;</html:button>
|
||||
</html:td>
|
||||
</box>
|
||||
|
||||
</window>
|
|
@ -0,0 +1,37 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.org code.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
EXPORT_RESOURCE_CONTENT = \
|
||||
$(srcdir)/timebomb.dtd \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
install::
|
||||
$(INSTALL) $(EXPORT_RESOURCE_CONTENT) $(DIST)/bin/chrome/timebomb/locale/en-US
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.org code.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..\..\..
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install::
|
||||
$(MAKE_INSTALL) timebomb.dtd $(DIST)\bin\chrome\timebomb\locale\en-US
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\bin\chrome\timebomb\locale\en-US\*.*
|
|
@ -0,0 +1,4 @@
|
|||
<!ENTITY title.label "Time Bomb Version">
|
||||
<!ENTITY okButton.label "OK">
|
||||
<!ENTITY warnText.label "This is a warning that this product will expire. Please visit http://www.mozilla.org for newer versions.">
|
||||
<!ENTITY expireText.label "This is a version has expired. You must download a newer version at http://www.mozilla.org.">
|
|
@ -0,0 +1,61 @@
|
|||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.org code.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
PROG1 = .\$(OBJDIR)\timebombgen.exe
|
||||
|
||||
PROGRAMS = \
|
||||
$(PROG1) \
|
||||
$(NULL)
|
||||
|
||||
DEFINES=-DWIN32_LEAN_AND_MEAN
|
||||
MODULE=raptor
|
||||
|
||||
|
||||
LINCS=-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\base \
|
||||
$(NULL)
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
# These are the libraries we need to link with to create the exe
|
||||
LLIBS= \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(LIBNSPR) \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(PROGRAMS)
|
||||
-for %p in ($(PROGRAMS)) do $(MAKE_INSTALL) %p $(DIST)\bin
|
||||
|
||||
clobber::
|
||||
-for %p in ($(PROGRAMS)) do $(RM) %p $(DIST)\bin\%p
|
||||
|
||||
|
||||
$(PROG1): $(OBJDIR) timebombgen.cpp
|
|
@ -0,0 +1,83 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (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.org code.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Doug Turner <dougt@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nspr.h"
|
||||
|
||||
int PrintTime(PRTime* time)
|
||||
{
|
||||
char buffer[30];
|
||||
|
||||
PR_snprintf(buffer, 30, "%lld", *time);
|
||||
|
||||
printf("time: %s", buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ParseTime(const char* string, PRTime* time)
|
||||
{
|
||||
PRStatus status = PR_ParseTimeString (string, PR_FALSE, time);
|
||||
|
||||
if (status == PR_FAILURE)
|
||||
printf("ERROR: Could not parse time. \n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Usage()
|
||||
{
|
||||
printf("Usage: timebombgen [-ct] string\n");
|
||||
printf(" All time relative to local time zone.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
PRTime time = LL_Zero();
|
||||
|
||||
if (argc < 2)
|
||||
return Usage();
|
||||
|
||||
char *command = argv[1];
|
||||
|
||||
if (command && command[0] == '-')
|
||||
{
|
||||
if (command[1] == 'c')
|
||||
{
|
||||
time = PR_Now();
|
||||
return PrintTime(&time);
|
||||
}
|
||||
else if (command[1] == 't')
|
||||
{
|
||||
char * timeString = argv[2];
|
||||
|
||||
if (argc < 3 || !timeString || timeString[0] == '\0')
|
||||
return Usage();
|
||||
|
||||
ParseTime(timeString, &time);
|
||||
return PrintTime(&time);
|
||||
}
|
||||
}
|
||||
|
||||
return Usage();
|
||||
}
|
Загрузка…
Ссылка в новой задаче