Advertisement
Guest User

Untitled

a guest
Mar 15th, 2017
87
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.  
  32.     NSURL* url = [NSURL URLWithString:
  33.             [NSString stringWithUTF8String: APPCAST_URL.toUtf8().data()]];
  34.     [d->updater setFeedURL: url];
  35. }
  36.  
  37. SparkleAutoUpdater::~SparkleAutoUpdater()
  38. {
  39.     [d->updater release];
  40.     delete d;
  41. }
  42.  
  43. void SparkleAutoUpdater::checkForUpdates()
  44. {
  45.     [d->updater setAutomaticallyChecksForUpdates: true];
  46.     [d->updater setAutomaticallyDownloadsUpdates: true];
  47.     [d->updater installUpdatesIfAvailable];
  48.     [d->updater checkForUpdatesInBackground];
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement