зеркало из https://github.com/mozilla/gecko-dev.git
set software notification timer to once per week. 14729 R. sgehani
Update pref name
This commit is contained in:
Родитель
14d8b9492e
Коммит
cc353be680
|
@ -1,21 +1,26 @@
|
||||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
*
|
/*
|
||||||
* The contents of this file are subject to the Netscape Public License
|
* 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
|
* Version 1.0 (the "License"); you may not use this file except in
|
||||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
* compliance with the License. You may obtain a copy of the License at
|
||||||
* http://www.mozilla.org/NPL/
|
* http://www.mozilla.org/NPL/
|
||||||
*
|
*
|
||||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
* for the specific language governing rights and limitations under the
|
* for the specific language governing rights and limitations under the
|
||||||
* NPL.
|
* License.
|
||||||
*
|
*
|
||||||
* The Initial Developer of this code under the NPL is Netscape
|
* The Original Code is Mozilla Communicator client code,
|
||||||
* Communications Corporation. Portions created by Netscape are
|
* released March 31, 1998.
|
||||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
*
|
||||||
|
* 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.
|
* Reserved.
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Doug Turner <dougt@netscape.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nsISupports.h"
|
#include "nsISupports.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
@ -189,25 +194,44 @@ nsXPINotifierImpl::NotificationEnabled(PRBool* aReturn)
|
||||||
{
|
{
|
||||||
// check to see the last time we did anything. Since flash does not have a persistant
|
// check to see the last time we did anything. Since flash does not have a persistant
|
||||||
// way to do poll invervals longer than a session, we will implemented that here by using the
|
// way to do poll invervals longer than a session, we will implemented that here by using the
|
||||||
// preferences. The interval hardcoded here is max 7 days.
|
// preferences.
|
||||||
*aReturn = value;
|
|
||||||
#if 0
|
|
||||||
PRInt32 date;
|
|
||||||
|
|
||||||
rv = prefs->GetIntPref( (const char*) XPINSTALL_NOTIFICATIONS_LASTDATE, &date);
|
PRInt32 intervalHours = 0;
|
||||||
if (NS_SUCCEEDED(rv)
|
|
||||||
|
PRTime now = 0;
|
||||||
|
PRInt32 nowSec = 0;
|
||||||
|
|
||||||
|
PRInt32 lastTime = 0;
|
||||||
|
|
||||||
|
rv = prefs->GetIntPref(XPINSTALL_NOTIFICATIONS_INTERVAL, &intervalHours);
|
||||||
|
|
||||||
|
if (NS_FAILED(rv))
|
||||||
{
|
{
|
||||||
|
intervalHours = 7*24; // default at once a week
|
||||||
|
rv = prefs->SetIntPref(XPINSTALL_NOTIFICATIONS_INTERVAL, intervalHours);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{ // it was never set.
|
|
||||||
|
|
||||||
|
rv = prefs->GetIntPref(XPINSTALL_NOTIFICATIONS_LASTDATE, &lastTime);
|
||||||
|
|
||||||
|
now = PR_Now();
|
||||||
|
|
||||||
|
// nowSec = now / 1000000
|
||||||
|
LL_DIV(nowSec, now, 1000000);
|
||||||
|
|
||||||
|
if (NS_FAILED(rv) || lastTime == 0)
|
||||||
|
{
|
||||||
|
rv = prefs->SetIntPref(XPINSTALL_NOTIFICATIONS_LASTDATE, nowSec);
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
if ((lastTime + (intervalHours*60*24)) <= nowSec)
|
||||||
|
{
|
||||||
|
*aReturn = PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_RELEASE(prefs);
|
NS_RELEASE(prefs);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче