blob: d64079bae9737116ee847e3572b5a33e0ae1330a [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 Afanasyeve8496a32013-03-03 16:10:43 -080022#import <AppKit/AppKit.h>
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080023#import <Foundation/Foundation.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
Alexander Afanasyev1cf5c432017-01-13 23:22:15 -080028_LOG_INIT(SparkeAutoUpdate);
Zhenkai Zhuaca6cb52013-02-24 23:34:03 -080029
30class SparkleAutoUpdate::Private
31{
Alexander Afanasyeve8496a32013-03-03 16:10:43 -080032public:
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080033 SUUpdater* updater;
Zhenkai Zhuaca6cb52013-02-24 23:34:03 -080034};
35
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080036SparkleAutoUpdate::SparkleAutoUpdate(const QString& updateUrl)
Zhenkai Zhuaca6cb52013-02-24 23:34:03 -080037{
38 d = new Private;
Zhenkai Zhu3857d712013-02-27 22:51:25 -080039 d->updater = [[SUUpdater sharedUpdater] retain];
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080040 NSURL* url = [NSURL URLWithString:[NSString stringWithUTF8String:updateUrl.toUtf8().data()]];
41 [d->updater setFeedURL:url];
42 [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
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080053void
54SparkleAutoUpdate::checkForUpdates()
Zhenkai Zhuaca6cb52013-02-24 23:34:03 -080055{
Zhenkai Zhu6afa1e02013-02-28 20:37:14 -080056 //[d->updater checkForUpdatesInBackground];
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080057 [d->updater checkForUpdates:nil];
58 _LOG_DEBUG("++++++++ checking update +++++");
Zhenkai Zhuaca6cb52013-02-24 23:34:03 -080059}