| 691 | |
| 692 | LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl); |
| 693 | LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl) |
| 694 | { |
| 695 | CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(list, nullptr); |
| 696 | if (listSnapshot == nullptr) { |
| 697 | return nullptr; |
| 698 | } |
| 699 | |
| 700 | // loop through the list of startup items and try to find the bitcoin app |
| 701 | for(int i = 0; i < CFArrayGetCount(listSnapshot); i++) { |
| 702 | LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(listSnapshot, i); |
| 703 | UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes; |
| 704 | CFURLRef currentItemURL = nullptr; |
| 705 | |
| 706 | #if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED >= 10100 |
| 707 | if(&LSSharedFileListItemCopyResolvedURL) |
| 708 | currentItemURL = LSSharedFileListItemCopyResolvedURL(item, resolutionFlags, nullptr); |
| 709 | #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED < 10100 |
| 710 | else |
| 711 | LSSharedFileListItemResolve(item, resolutionFlags, ¤tItemURL, nullptr); |
| 712 | #endif |
| 713 | #else |
| 714 | LSSharedFileListItemResolve(item, resolutionFlags, ¤tItemURL, nullptr); |
| 715 | #endif |
| 716 | |
| 717 | if(currentItemURL) { |
| 718 | if (CFEqual(currentItemURL, findUrl)) { |
| 719 | // found |
| 720 | CFRelease(listSnapshot); |
| 721 | CFRelease(currentItemURL); |
| 722 | return item; |
| 723 | } |
| 724 | CFRelease(currentItemURL); |
| 725 | } |
| 726 | } |
| 727 | |
| 728 | CFRelease(listSnapshot); |
| 729 | return nullptr; |
| 730 | } |
| 731 | |
| 732 | bool GetStartOnSystemStartup() |
| 733 | { |
no outgoing calls
no test coverage detected