[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3166: Add some GliderProcess helper methods for determining if it' (vidalia/trunk/src/vidalia)
Author: edmanm
Date: 2008-09-29 22:19:38 -0400 (Mon, 29 Sep 2008)
New Revision: 3166
Modified:
vidalia/trunk/src/vidalia/gliderprocess.cpp
vidalia/trunk/src/vidalia/gliderprocess.h
Log:
Add some GliderProcess helper methods for determining if it's time to check
for updates, and, if not, when we should schedule the next check for updates.
Modified: vidalia/trunk/src/vidalia/gliderprocess.cpp
===================================================================
--- vidalia/trunk/src/vidalia/gliderprocess.cpp 2008-09-30 02:18:54 UTC (rev 3165)
+++ vidalia/trunk/src/vidalia/gliderprocess.cpp 2008-09-30 02:19:38 UTC (rev 3166)
@@ -16,3 +16,24 @@
{
}
+int
+GliderProcess::checkForUpdatesInterval()
+{
+ /* XXX: Check once a day. I totally made this up. We want to do something
+ * smarter here. */
+ return 24*60*60;
+}
+
+QDateTime
+GliderProcess::nextCheckForUpdates(const QDateTime &lastCheckedAt)
+{
+ return lastCheckedAt.toUTC().addSecs(checkForUpdatesInterval());
+}
+
+bool
+GliderProcess::shouldCheckForUpdates(const QDateTime &lastCheckedAt)
+{
+ QDateTime nextCheck = nextCheckForUpdates(lastCheckedAt);
+ return (nextCheck >= QDateTime::currentDateTime().toUTC());
+}
+
Modified: vidalia/trunk/src/vidalia/gliderprocess.h
===================================================================
--- vidalia/trunk/src/vidalia/gliderprocess.h 2008-09-30 02:18:54 UTC (rev 3165)
+++ vidalia/trunk/src/vidalia/gliderprocess.h 2008-09-30 02:19:38 UTC (rev 3166)
@@ -12,6 +12,7 @@
#define _GLIDERPROCESS_H
#include <QProcess>
+#include <QDateTime>
class GliderProcess : public QProcess
@@ -19,7 +20,24 @@
Q_OBJECT
public:
+ /** Default constructor.
+ */
GliderProcess(QObject *parent = 0);
+
+ /** Return the time at which we should next check for available updates,
+ * given the last we checked was at <b>lastCheckedAt</b>.
+ */
+ static QDateTime nextCheckForUpdates(const QDateTime &lastCheckedAt);
+
+ /** Return true if we should check for available software udpates, given
+ * the last time we checked was at <b>lastCheckedAt</b>. The returned
+ * QDateTime will be in UTC.
+ */
+ static bool shouldCheckForUpdates(const QDateTime &lastCheckedAt);
+
+ /** Returns the preferred interval (in seconds) between executions of the
+ * Glider process to check for available software updates. */
+ static int checkForUpdatesInterval();
};
#endif