Alexander Afanasyev | 1b51bb5 | 2017-02-10 19:52:32 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2013-2017, Regents of the University of California. |
| 4 | * |
| 5 | * This file is part of ChronoShare, a decentralized file sharing application over NDN. |
| 6 | * |
| 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. |
| 10 | * |
| 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. |
| 14 | * |
| 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. |
| 19 | */ |
| 20 | |
| 21 | #include "osx-auto-update-sparkle.hpp" |
| 22 | |
| 23 | #import <AppKit/AppKit.h> |
| 24 | #import <Foundation/Foundation.h> |
| 25 | #import <Sparkle/Sparkle.h> |
| 26 | |
| 27 | namespace ndn { |
| 28 | namespace chronoshare { |
| 29 | |
| 30 | class OsxAutoUpdateSparkle::Impl |
| 31 | { |
| 32 | public: |
| 33 | SUUpdater* m_updater; |
| 34 | }; |
| 35 | |
| 36 | |
| 37 | OsxAutoUpdateSparkle::OsxAutoUpdateSparkle(const std::string& updateUrl) |
| 38 | : m_impl(make_unique<Impl>()) |
| 39 | { |
| 40 | m_impl->m_updater = [[SUUpdater sharedUpdater] retain]; |
| 41 | NSURL* url = [NSURL URLWithString:[NSString stringWithUTF8String:updateUrl.data()]]; |
| 42 | [m_impl->m_updater setFeedURL:url]; |
| 43 | [m_impl->m_updater setAutomaticallyChecksForUpdates:YES]; |
| 44 | [m_impl->m_updater setUpdateCheckInterval:86400]; |
| 45 | } |
| 46 | |
| 47 | OsxAutoUpdateSparkle::~OsxAutoUpdateSparkle() |
| 48 | { |
| 49 | [m_impl->m_updater release]; |
| 50 | // presummably SUUpdater handles garbage collection |
| 51 | } |
| 52 | |
| 53 | void |
| 54 | OsxAutoUpdateSparkle::checkForUpdates() |
| 55 | { |
| 56 | //[m_impl->m_updater checkForUpdatesInBackground]; |
| 57 | [m_impl->m_updater checkForUpdates:nil]; |
| 58 | } |
| 59 | |
| 60 | } // namespace chronoshare |
| 61 | } // namespace ndn |