blob: 6a373e26a36d655f79bc75043f2f7313518a90ae [file] [log] [blame]
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2016, Regents of the University of California.
Alexander Afanasyev5a95a252013-02-25 12:55:48 -08004 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08005 * This file is part of ChronoShare, a decentralized file sharing application over NDN.
Alexander Afanasyev5a95a252013-02-25 12:55:48 -08006 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08007 * ChronoShare is free software: you can redistribute it and/or modify it under the terms
8 * of the GNU General Public License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080010 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -080011 * ChronoShare is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080014 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -080015 * You should have received copies of the GNU General Public License along with
16 * ChronoShare, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * See AUTHORS.md for complete list of ChronoShare authors and contributors.
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080019 */
20
Alexander Afanasyevf4cde4e2016-12-25 13:42:57 -080021#include "sparkle-auto-update.hpp"
Alexander Afanasyev5a95a252013-02-25 12:55:48 -080022#import <Foundation/Foundation.h>
Alexander Afanasyeve8496a32013-03-03 16:10:43 -080023#import <AppKit/AppKit.h>
Zhenkai Zhuaca6cb52013-02-24 23:34:03 -080024#import <Sparkle/Sparkle.h>
Alexander Afanasyeve8496a32013-03-03 16:10:43 -080025
Alexander Afanasyevf4cde4e2016-12-25 13:42:57 -080026#include "logging.hpp"
Alexander Afanasyeve8496a32013-03-03 16:10:43 -080027
28INIT_LOGGER ("SparkeAutoUpdate");
Zhenkai Zhuaca6cb52013-02-24 23:34:03 -080029
30class SparkleAutoUpdate::Private
31{
Alexander Afanasyeve8496a32013-03-03 16:10:43 -080032public:
33 SUUpdater *updater;
Zhenkai Zhuaca6cb52013-02-24 23:34:03 -080034};
35
36SparkleAutoUpdate::SparkleAutoUpdate(const QString &updateUrl)
37{
38 d = new Private;
Zhenkai Zhu3857d712013-02-27 22:51:25 -080039 d->updater = [[SUUpdater sharedUpdater] retain];
Zhenkai Zhuaca6cb52013-02-24 23:34:03 -080040 NSURL *url = [NSURL URLWithString: [NSString stringWithUTF8String: updateUrl.toUtf8().data()]];
41 [d->updater setFeedURL: url];
Zhenkai Zhu69267922013-03-01 10:08:20 -080042 [d->updater setAutomaticallyChecksForUpdates: YES];
43 [d->updater setUpdateCheckInterval: 86400];
Zhenkai Zhuaca6cb52013-02-24 23:34:03 -080044}
45
46SparkleAutoUpdate::~SparkleAutoUpdate()
47{
Zhenkai Zhu3857d712013-02-27 22:51:25 -080048 [d->updater release];
Zhenkai Zhuaca6cb52013-02-24 23:34:03 -080049 delete d;
50 // presummably SUUpdater handles garbage collection
51}
52
53void SparkleAutoUpdate::checkForUpdates()
54{
Zhenkai Zhu6afa1e02013-02-28 20:37:14 -080055 //[d->updater checkForUpdatesInBackground];
56 [d->updater checkForUpdates : nil];
Alexander Afanasyeve8496a32013-03-03 16:10:43 -080057 _LOG_DEBUG ("++++++++ checking update +++++");
Zhenkai Zhuaca6cb52013-02-24 23:34:03 -080058}