blob: e3e3c3e1b584b6ab124005b9ac5ab4aec32b953e [file] [log] [blame]
Alexander Afanasyev1b51bb52017-02-10 19:52:32 -08001/* -*- 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
27namespace ndn {
28namespace chronoshare {
29
30class OsxAutoUpdateSparkle::Impl
31{
32public:
33 SUUpdater* m_updater;
34};
35
36
37OsxAutoUpdateSparkle::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
47OsxAutoUpdateSparkle::~OsxAutoUpdateSparkle()
48{
49 [m_impl->m_updater release];
50 // presummably SUUpdater handles garbage collection
51}
52
53void
54OsxAutoUpdateSparkle::checkForUpdates()
55{
56 //[m_impl->m_updater checkForUpdatesInBackground];
57 [m_impl->m_updater checkForUpdates:nil];
58}
59
60} // namespace chronoshare
61} // namespace ndn