Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2013-2016, Regents of the University of California. |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 5 | * This file is part of ChronoShare, a decentralized file sharing application over NDN. |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 6 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 7 | * 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 Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 10 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 11 | * 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 Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 14 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame^] | 15 | * 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 Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 19 | */ |
| 20 | |
Alexander Afanasyev | f4cde4e | 2016-12-25 13:42:57 -0800 | [diff] [blame] | 21 | #include "sparkle-auto-update.hpp" |
Alexander Afanasyev | 5a95a25 | 2013-02-25 12:55:48 -0800 | [diff] [blame] | 22 | #import <Foundation/Foundation.h> |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 23 | #import <AppKit/AppKit.h> |
Zhenkai Zhu | aca6cb5 | 2013-02-24 23:34:03 -0800 | [diff] [blame] | 24 | #import <Sparkle/Sparkle.h> |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 25 | |
Alexander Afanasyev | f4cde4e | 2016-12-25 13:42:57 -0800 | [diff] [blame] | 26 | #include "logging.hpp" |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 27 | |
| 28 | INIT_LOGGER ("SparkeAutoUpdate"); |
Zhenkai Zhu | aca6cb5 | 2013-02-24 23:34:03 -0800 | [diff] [blame] | 29 | |
| 30 | class SparkleAutoUpdate::Private |
| 31 | { |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 32 | public: |
| 33 | SUUpdater *updater; |
Zhenkai Zhu | aca6cb5 | 2013-02-24 23:34:03 -0800 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | SparkleAutoUpdate::SparkleAutoUpdate(const QString &updateUrl) |
| 37 | { |
| 38 | d = new Private; |
Zhenkai Zhu | 3857d71 | 2013-02-27 22:51:25 -0800 | [diff] [blame] | 39 | d->updater = [[SUUpdater sharedUpdater] retain]; |
Zhenkai Zhu | aca6cb5 | 2013-02-24 23:34:03 -0800 | [diff] [blame] | 40 | NSURL *url = [NSURL URLWithString: [NSString stringWithUTF8String: updateUrl.toUtf8().data()]]; |
| 41 | [d->updater setFeedURL: url]; |
Zhenkai Zhu | 6926792 | 2013-03-01 10:08:20 -0800 | [diff] [blame] | 42 | [d->updater setAutomaticallyChecksForUpdates: YES]; |
| 43 | [d->updater setUpdateCheckInterval: 86400]; |
Zhenkai Zhu | aca6cb5 | 2013-02-24 23:34:03 -0800 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | SparkleAutoUpdate::~SparkleAutoUpdate() |
| 47 | { |
Zhenkai Zhu | 3857d71 | 2013-02-27 22:51:25 -0800 | [diff] [blame] | 48 | [d->updater release]; |
Zhenkai Zhu | aca6cb5 | 2013-02-24 23:34:03 -0800 | [diff] [blame] | 49 | delete d; |
| 50 | // presummably SUUpdater handles garbage collection |
| 51 | } |
| 52 | |
| 53 | void SparkleAutoUpdate::checkForUpdates() |
| 54 | { |
Zhenkai Zhu | 6afa1e0 | 2013-02-28 20:37:14 -0800 | [diff] [blame] | 55 | //[d->updater checkForUpdatesInBackground]; |
| 56 | [d->updater checkForUpdates : nil]; |
Alexander Afanasyev | e8496a3 | 2013-03-03 16:10:43 -0800 | [diff] [blame] | 57 | _LOG_DEBUG ("++++++++ checking update +++++"); |
Zhenkai Zhu | aca6cb5 | 2013-02-24 23:34:03 -0800 | [diff] [blame] | 58 | } |