From 4198197bc32291f4e54a853f38ca8be55a17d798 Mon Sep 17 00:00:00 2001
From: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
Date: Thu, 4 Jun 2015 13:27:33 -0400
Subject: [PATCH] preference: enable auto startup by default

Ring is registered in startup items when the wizard creates the RING account

Refs #73111

Change-Id: I1fa3ec065e8fcdfd9e1edbe9bdf6457a7f592c14
---
 src/RingWizardWC.mm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/RingWizardWC.mm b/src/RingWizardWC.mm
index 75fbbe4c..b3b03dd6 100644
--- a/src/RingWizardWC.mm
+++ b/src/RingWizardWC.mm
@@ -102,6 +102,19 @@
     [self setCallback];
     [self performSelector:@selector(saveAccount) withObject:nil afterDelay:1];
 
+    [self registerAutoStartup];
+}
+
+/**
+ * Enable launch at startup by default
+ */
+- (void) registerAutoStartup
+{
+    LSSharedFileListRef loginItemsRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
+    if (loginItemsRef == nil) return;
+    CFURLRef appUrl = (CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
+    LSSharedFileListItemRef itemRef = LSSharedFileListInsertItemURL(loginItemsRef, kLSSharedFileListItemLast, NULL, NULL, appUrl, NULL, NULL);
+    if (itemRef) CFRelease(itemRef);
 }
 
 - (void) saveAccount
-- 
GitLab