Skip to content

Commit

Permalink
Updater: Added option for checking "At startup"; adjusted frequency l…
Browse files Browse the repository at this point in the history
…ogic

The automatic checks now only look at the calendar days, i.e., it doesn't matter
at what time of day the last check was made, as long as the week day is different.
  • Loading branch information
skyjake committed Jun 13, 2012
1 parent 9842632 commit 188d6a3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
11 changes: 9 additions & 2 deletions doomsday/engine/portable/src/updater.cpp
Expand Up @@ -60,6 +60,7 @@
#include <de/App>
#include <de/LegacyCore>
#include <de/Time>
#include <de/Date>
#include <de/Log>

static Updater* updater = 0;
Expand Down Expand Up @@ -182,6 +183,10 @@ struct Updater::Instance
float dayInterval = 30;
switch(st.frequency())
{
case UpdaterSettings::AtStartup:
dayInterval = 0;
break;

case UpdaterSettings::Daily:
dayInterval = 1;
break;
Expand All @@ -200,8 +205,10 @@ struct Updater::Instance

de::Time now;

// Check always when the day interval has passed.
if(st.lastCheckTime().deltaTo(now).asDays() >= dayInterval)
// Check always when the day interval has passed. Note that this
// doesn't check the actual time interval since the last check, but the
// difference in "calendar" days.
if(st.lastCheckTime().asDate().daysTo(de::Date()) >= dayInterval)
return true;

if(st.frequency() == UpdaterSettings::Biweekly)
Expand Down
9 changes: 5 additions & 4 deletions doomsday/engine/portable/src/updater/updatersettings.h
Expand Up @@ -9,10 +9,11 @@ class UpdaterSettings
public:
enum Frequency
{
Daily = 0,
Biweekly = 1, // 3.5 days
Weekly = 2, // 7 days
Monthly = 3 // 30 days
Daily = 0,
Biweekly = 1, // 3.5 days
Weekly = 2, // 7 days
Monthly = 3, // 30 days
AtStartup = 4
};
enum Channel
{
Expand Down
Expand Up @@ -45,10 +45,11 @@ struct UpdaterSettingsDialog::Instance
form->addRow(neverCheck);

freqList = new QComboBox;
freqList->addItem(tr("Daily"), UpdaterSettings::Daily);
freqList->addItem(tr("Biweekly"), UpdaterSettings::Biweekly);
freqList->addItem(tr("Weekly"), UpdaterSettings::Weekly);
freqList->addItem(tr("Monthly"), UpdaterSettings::Monthly);
freqList->addItem(tr("At startup"), UpdaterSettings::AtStartup);
freqList->addItem(tr("Daily"), UpdaterSettings::Daily);
freqList->addItem(tr("Biweekly"), UpdaterSettings::Biweekly);
freqList->addItem(tr("Weekly"), UpdaterSettings::Weekly);
freqList->addItem(tr("Monthly"), UpdaterSettings::Monthly);
form->addRow(tr("&Check for updates:"), freqList);

channelList = new QComboBox;
Expand Down
1 change: 1 addition & 0 deletions doomsday/libdeng2/include/de/data/date.h
Expand Up @@ -48,6 +48,7 @@ class DENG2_PUBLIC Date : public Time, public LogEntry::Arg::Base
int hours() const { return asDateTime().time().hour(); }
int minutes() const { return asDateTime().time().minute(); }
int seconds() const { return asDateTime().time().second(); }
int daysTo(const Date& other) const { return asDateTime().date().daysTo(other.asDateTime().date()); }

/**
* Forms a textual representation of the date.
Expand Down

0 comments on commit 188d6a3

Please sign in to comment.