diff --git a/mozilla/xpfe/components/timebomb/makefile.win b/mozilla/xpfe/components/timebomb/makefile.win new file mode 100644 index 00000000000..68a23129c96 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/makefile.win @@ -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 diff --git a/mozilla/xpfe/components/timebomb/nsITimeBomb.idl b/mozilla/xpfe/components/timebomb/nsITimeBomb.idl new file mode 100644 index 00000000000..49213b507f8 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/nsITimeBomb.idl @@ -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 + */ + + + +/**************************************************************** + 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" +%} + diff --git a/mozilla/xpfe/components/timebomb/nsTimeBomb.cpp b/mozilla/xpfe/components/timebomb/nsTimeBomb.cpp new file mode 100644 index 00000000000..8e036a7f488 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/nsTimeBomb.cpp @@ -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 + */ + +#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 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 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 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) \ No newline at end of file diff --git a/mozilla/xpfe/components/timebomb/nsTimeBomb.h b/mozilla/xpfe/components/timebomb/nsTimeBomb.h new file mode 100644 index 00000000000..d2a3e174e81 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/nsTimeBomb.h @@ -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 + */ + +#include "nsITimeBomb.h" + +#define NS_TIMEBOMB_CID { 0x141917dc, 0xe1c3, 0x11d3, {0xac, 0x71, 0x00, 0xc0, 0x4f, 0xa0, 0xd2, 0x6b}} diff --git a/mozilla/xpfe/components/timebomb/resources/Makefile.in b/mozilla/xpfe/components/timebomb/resources/Makefile.in new file mode 100644 index 00000000000..1d58468949a --- /dev/null +++ b/mozilla/xpfe/components/timebomb/resources/Makefile.in @@ -0,0 +1,32 @@ +# +# 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 + +DIRS = content locale + +include $(topsrcdir)/config/rules.mk + diff --git a/mozilla/xpfe/components/timebomb/resources/content/MANIFEST b/mozilla/xpfe/components/timebomb/resources/content/MANIFEST new file mode 100644 index 00000000000..22630b2cecd --- /dev/null +++ b/mozilla/xpfe/components/timebomb/resources/content/MANIFEST @@ -0,0 +1,2 @@ +warn.xul +expireText.xul diff --git a/mozilla/xpfe/components/timebomb/resources/content/Makefile.in b/mozilla/xpfe/components/timebomb/resources/content/Makefile.in new file mode 100644 index 00000000000..a13cada0d09 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/resources/content/Makefile.in @@ -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 + diff --git a/mozilla/xpfe/components/timebomb/resources/content/expireText.xul b/mozilla/xpfe/components/timebomb/resources/content/expireText.xul new file mode 100644 index 00000000000..011ce1e60d3 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/resources/content/expireText.xul @@ -0,0 +1,42 @@ + + + + + + + + + + + + + &expireText.label; + + + &okButton.label; + + + + diff --git a/mozilla/xpfe/components/timebomb/resources/content/makefile.win b/mozilla/xpfe/components/timebomb/resources/content/makefile.win new file mode 100644 index 00000000000..9cccb0c3481 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/resources/content/makefile.win @@ -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\*.* diff --git a/mozilla/xpfe/components/timebomb/resources/content/warn.xul b/mozilla/xpfe/components/timebomb/resources/content/warn.xul new file mode 100644 index 00000000000..a406536e6ec --- /dev/null +++ b/mozilla/xpfe/components/timebomb/resources/content/warn.xul @@ -0,0 +1,42 @@ + + + + + + + + + + + + + &warnText.label; + + + &okButton.label; + + + + diff --git a/mozilla/xpfe/components/timebomb/resources/locale/Makefile.in b/mozilla/xpfe/components/timebomb/resources/locale/Makefile.in new file mode 100644 index 00000000000..196a33733d0 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/resources/locale/Makefile.in @@ -0,0 +1,32 @@ +# +# 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 + +DIRS = en-US + +include $(topsrcdir)/config/rules.mk + diff --git a/mozilla/xpfe/components/timebomb/resources/locale/en-US/MANIFEST b/mozilla/xpfe/components/timebomb/resources/locale/en-US/MANIFEST new file mode 100644 index 00000000000..a313f4b5750 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/resources/locale/en-US/MANIFEST @@ -0,0 +1 @@ +timebomb.dtd \ No newline at end of file diff --git a/mozilla/xpfe/components/timebomb/resources/locale/en-US/Makefile.in b/mozilla/xpfe/components/timebomb/resources/locale/en-US/Makefile.in new file mode 100644 index 00000000000..8e9c525ddec --- /dev/null +++ b/mozilla/xpfe/components/timebomb/resources/locale/en-US/Makefile.in @@ -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 + diff --git a/mozilla/xpfe/components/timebomb/resources/locale/en-US/makefile.win b/mozilla/xpfe/components/timebomb/resources/locale/en-US/makefile.win new file mode 100644 index 00000000000..363d0e9a304 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/resources/locale/en-US/makefile.win @@ -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\*.* diff --git a/mozilla/xpfe/components/timebomb/resources/locale/en-US/timebomb.dtd b/mozilla/xpfe/components/timebomb/resources/locale/en-US/timebomb.dtd new file mode 100644 index 00000000000..61ef4edebf9 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/resources/locale/en-US/timebomb.dtd @@ -0,0 +1,4 @@ + + + + diff --git a/mozilla/xpfe/components/timebomb/resources/locale/makefile.win b/mozilla/xpfe/components/timebomb/resources/locale/makefile.win new file mode 100644 index 00000000000..fd8b8ebd1a5 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/resources/locale/makefile.win @@ -0,0 +1,29 @@ +#!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=..\..\..\..\.. + +DIRS= en-US + +include <$(DEPTH)\config\rules.mak> + diff --git a/mozilla/xpfe/components/timebomb/resources/makefile.win b/mozilla/xpfe/components/timebomb/resources/makefile.win new file mode 100644 index 00000000000..fe443ed5ac5 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/resources/makefile.win @@ -0,0 +1,29 @@ +#!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=..\..\..\.. + +DIRS= content locale + +include <$(DEPTH)\config\rules.mak> + diff --git a/mozilla/xpfe/components/timebomb/tools/makefile.win b/mozilla/xpfe/components/timebomb/tools/makefile.win new file mode 100644 index 00000000000..c4764c6ebed --- /dev/null +++ b/mozilla/xpfe/components/timebomb/tools/makefile.win @@ -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 diff --git a/mozilla/xpfe/components/timebomb/tools/timebombgen.cpp b/mozilla/xpfe/components/timebomb/tools/timebombgen.cpp new file mode 100644 index 00000000000..37db4d8a6c1 --- /dev/null +++ b/mozilla/xpfe/components/timebomb/tools/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 + */ + +#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(); +} \ No newline at end of file