|
|
@ -780,8 +780,12 @@ bool SetStartOnSystemStartup(bool fAutoStart) |
|
|
|
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl); |
|
|
|
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl); |
|
|
|
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl) |
|
|
|
LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// loop through the list of startup items and try to find the bitcoin app
|
|
|
|
|
|
|
|
CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(list, nullptr); |
|
|
|
CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(list, nullptr); |
|
|
|
|
|
|
|
if (listSnapshot == nullptr) { |
|
|
|
|
|
|
|
return nullptr; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// loop through the list of startup items and try to find the bitcoin app
|
|
|
|
for(int i = 0; i < CFArrayGetCount(listSnapshot); i++) { |
|
|
|
for(int i = 0; i < CFArrayGetCount(listSnapshot); i++) { |
|
|
|
LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(listSnapshot, i); |
|
|
|
LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(listSnapshot, i); |
|
|
|
UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes; |
|
|
|
UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes; |
|
|
@ -798,29 +802,42 @@ LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef |
|
|
|
LSSharedFileListItemResolve(item, resolutionFlags, ¤tItemURL, nullptr); |
|
|
|
LSSharedFileListItemResolve(item, resolutionFlags, ¤tItemURL, nullptr); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
if(currentItemURL && CFEqual(currentItemURL, findUrl)) { |
|
|
|
if(currentItemURL) { |
|
|
|
|
|
|
|
if (CFEqual(currentItemURL, findUrl)) { |
|
|
|
// found
|
|
|
|
// found
|
|
|
|
|
|
|
|
CFRelease(listSnapshot); |
|
|
|
CFRelease(currentItemURL); |
|
|
|
CFRelease(currentItemURL); |
|
|
|
return item; |
|
|
|
return item; |
|
|
|
} |
|
|
|
} |
|
|
|
if(currentItemURL) { |
|
|
|
|
|
|
|
CFRelease(currentItemURL); |
|
|
|
CFRelease(currentItemURL); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CFRelease(listSnapshot); |
|
|
|
return nullptr; |
|
|
|
return nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool GetStartOnSystemStartup() |
|
|
|
bool GetStartOnSystemStartup() |
|
|
|
{ |
|
|
|
{ |
|
|
|
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle()); |
|
|
|
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle()); |
|
|
|
|
|
|
|
if (bitcoinAppUrl == nullptr) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr); |
|
|
|
LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr); |
|
|
|
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl); |
|
|
|
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CFRelease(bitcoinAppUrl); |
|
|
|
return !!foundItem; // return boolified object
|
|
|
|
return !!foundItem; // return boolified object
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool SetStartOnSystemStartup(bool fAutoStart) |
|
|
|
bool SetStartOnSystemStartup(bool fAutoStart) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle()); |
|
|
|
CFURLRef bitcoinAppUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle()); |
|
|
|
|
|
|
|
if (bitcoinAppUrl == nullptr) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr); |
|
|
|
LSSharedFileListRef loginItems = LSSharedFileListCreate(nullptr, kLSSharedFileListSessionLoginItems, nullptr); |
|
|
|
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl); |
|
|
|
LSSharedFileListItemRef foundItem = findStartupItemInList(loginItems, bitcoinAppUrl); |
|
|
|
|
|
|
|
|
|
|
@ -832,6 +849,8 @@ bool SetStartOnSystemStartup(bool fAutoStart) |
|
|
|
// remove item
|
|
|
|
// remove item
|
|
|
|
LSSharedFileListItemRemove(loginItems, foundItem); |
|
|
|
LSSharedFileListItemRemove(loginItems, foundItem); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CFRelease(bitcoinAppUrl); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
#pragma GCC diagnostic pop |
|
|
|
#pragma GCC diagnostic pop |
|
|
|