Advertisement
Guest User

Untitled

a guest
Mar 15th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "sparkleautoupdater.h"
  2.  
  3. #include "SparkleAutoUpdaterDelegate.h"
  4.  
  5. #include <Cocoa/Cocoa.h>
  6. #include <Sparkle/Sparkle.h>
  7.  
  8. namespace app
  9. {
  10.  
  11. const QString SparkleAutoUpdater::APPCAST_URL = "https://botsapp.io/updates/appcast.xml";
  12.  
  13. SparkleAutoUpdaterDelegate *__updaterDelegate = nullptr;
  14.  
  15. class SparkleAutoUpdater::Private
  16. {
  17.     public:
  18.         SUUpdater* updater;
  19. };
  20.  
  21. SparkleAutoUpdater::SparkleAutoUpdater()
  22. {
  23.     __updaterDelegate = [SparkleAutoUpdaterDelegate new];
  24.  
  25.     d = new Private;
  26.  
  27.     d->updater = [SUUpdater sharedUpdater];
  28.     [d->updater retain];
  29.  
  30.     d->updater.delegate = __updaterDelegate;
  31.     _updaterDelegate->autoUpdater = this;
  32.  
  33.     NSURL* url = [NSURL URLWithString:
  34.             [NSString stringWithUTF8String: APPCAST_URL.toUtf8().data()]];
  35.     [d->updater setFeedURL: url];
  36. }
  37.  
  38. SparkleAutoUpdater::~SparkleAutoUpdater()
  39. {
  40.     [d->updater release];
  41.     delete d;
  42. }
  43.  
  44. void SparkleAutoUpdater::checkForUpdates()
  45. {
  46.     [d->updater setAutomaticallyChecksForUpdates: true];
  47.     [d->updater setAutomaticallyDownloadsUpdates: true];
  48.     [d->updater installUpdatesIfAvailable];
  49.     [d->updater checkForUpdatesInBackground];
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement