当前位置: 首页>>代码示例>>C++>>正文


C++ LSSharedFileListItemResolve函数代码示例

本文整理汇总了C++中LSSharedFileListItemResolve函数的典型用法代码示例。如果您正苦于以下问题:C++ LSSharedFileListItemResolve函数的具体用法?C++ LSSharedFileListItemResolve怎么用?C++ LSSharedFileListItemResolve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了LSSharedFileListItemResolve函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindLoginItemForCurrentBundle

LSSharedFileListItemRef FindLoginItemForCurrentBundle(CFArrayRef currentLoginItems)
{
  CFURLRef mainBundleURL = CFBundleCopyBundleURL( CFBundleGetMainBundle() );

  for( int i = 0, end = CFArrayGetCount( currentLoginItems ); i < end; ++i ) {
    LSSharedFileListItemRef item = ( LSSharedFileListItemRef )CFArrayGetValueAtIndex( currentLoginItems, i );

    UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes;
    CFURLRef url = NULL;
    OSStatus err = LSSharedFileListItemResolve( item, resolutionFlags, &url, NULL );

    if( err == noErr ) {
      bool foundIt = CFEqual( url, mainBundleURL );
      CFRelease( url );

      if( foundIt ) {
        CFRelease( mainBundleURL );
        return item;
      }
    }
  }

  CFRelease( mainBundleURL );
  return NULL;
}
开发者ID:CodeSheng,项目名称:track-o-bot,代码行数:25,代码来源:Autostart.cpp

示例2: defined

bool Utility::hasLaunchOnStartup(const QString &appName)
{
#if defined(Q_OS_WIN)
    QString runPath = QLatin1String(runPathC);
    QSettings settings(runPath, QSettings::NativeFormat);
    return settings.contains(appName);
#elif defined(Q_OS_MAC)
    // this is quite some duplicate code with setLaunchOnStartup, at some point we should fix this FIXME.
    bool returnValue = false;
    QString filePath = QDir(QCoreApplication::applicationDirPath()+QLatin1String("/../..")).absolutePath();
    CFStringRef folderCFStr = CFStringCreateWithCString(0, filePath.toUtf8().data(), kCFStringEncodingUTF8);
    CFURLRef urlRef = CFURLCreateWithFileSystemPath (0, folderCFStr, kCFURLPOSIXPathStyle, true);
    LSSharedFileListRef loginItems = LSSharedFileListCreate(0, kLSSharedFileListSessionLoginItems, 0);
    if (loginItems) {
        // We need to iterate over the items and check which one is "ours".
        UInt32 seedValue;
        CFArrayRef itemsArray = LSSharedFileListCopySnapshot(loginItems, &seedValue);
        CFStringRef appUrlRefString = CFURLGetString(urlRef); // no need for release
        for (int i = 0; i < CFArrayGetCount(itemsArray); i++) {
            LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(itemsArray, i);
            CFURLRef itemUrlRef = NULL;

            if (LSSharedFileListItemResolve(item, 0, &itemUrlRef, NULL) == noErr) {
                CFStringRef itemUrlString = CFURLGetString(itemUrlRef);
                if (CFStringCompare(itemUrlString,appUrlRefString,0) == kCFCompareEqualTo) {
                    returnValue = true;
                }
                CFRelease(itemUrlRef);
            }
        }
        CFRelease(itemsArray);
    }
    CFRelease(loginItems);
    CFRelease(folderCFStr);
    CFRelease(urlRef);
    return returnValue;
#elif defined(Q_OS_UNIX)
    QString userAutoStartPath = QDir::homePath()+QLatin1String("/.config/autostart/");
    QString desktopFileLocation = userAutoStartPath+appName+QLatin1String(".desktop");
    return QFile::exists(desktopFileLocation);
#endif
}
开发者ID:Greyhatno,项目名称:mirall,代码行数:42,代码来源:utility.cpp

示例3: findStartupItemInList

LSSharedFileListItemRef findStartupItemInList(LSSharedFileListRef list, CFURLRef findUrl)
{
    // loop through the list of startup items and try to find the patacoin app
    CFArrayRef listSnapshot = LSSharedFileListCopySnapshot(list, NULL);
    for(int i = 0; i < CFArrayGetCount(listSnapshot); i++) {
        LSSharedFileListItemRef item = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(listSnapshot, i);
        UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes;
        CFURLRef currentItemURL = NULL;
        LSSharedFileListItemResolve(item, resolutionFlags, &currentItemURL, NULL);
        if(currentItemURL && CFEqual(currentItemURL, findUrl)) {
            // found
            CFRelease(currentItemURL);
            return item;
        }
        if(currentItemURL) {
            CFRelease(currentItemURL);
        }
    }
    return NULL;
}
开发者ID:Patacoin,项目名称:patacoin,代码行数:20,代码来源:guiutil.cpp

示例4: defined

void AsemanAutoStartManager::save()
{
#if defined(Q_OS_LINUX) || defined(Q_OS_OPENBSD)
    const QString &pathDir = QDir::homePath() + "/.config/autostart";
    const QString &path = pathDir + "/" + p->source + ".desktop";

    QDir().mkpath(pathDir);

    QString data = QString("[Desktop Entry]") +
            "\nHidden=" + (p->active?"false":"true") +
            "\nX-GNOME-Autostart-enabled=" + (p->active?"true":"false") +
            "\nName=" + p->name +
            "\nName[en_US]=" + p->name +
            "\nComment=" + p->comment +
            "\nComment[en_US]=" + p->comment +
            "\nType=" + p->type +
            "\nExec=" + p->command +
            "\nNoDisplay=false\n";

    QFile file(path);
    if(!file.open(QFile::WriteOnly))
        return;

    file.write(data.toUtf8());
    file.close();
#elif defined(Q_OS_WIN)
    QSettings autoStartSettings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);

    if(p->active)
    {
        autoStartSettings.setValue(p->source, QDir::toNativeSeparators(QDir::cleanPath(p->command)));
    }
    else
    {
        autoStartSettings.remove(p->source);
    }
#elif defined(Q_OS_MAC) && defined(OSX_CORE_SERVICES_AVAILABLE)
    CFURLRef url = prepareURL(p->command);
    if (!url)
    {
        qWarning("unable to create CFURLRef");
        return;
    }

    LSSharedFileListRef login_items = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
    if (!login_items)
    {
        qWarning("unable to get login items");
        return;
    }

    CFArrayRef login_items_array = LSSharedFileListCopySnapshot(login_items, NULL);
    if (!login_items_array)
    {
        qWarning("unable to get login items array");
        CFRelease(login_items);
        return;
    }
    CFIndex count = CFArrayGetCount(login_items_array);
    CFStringRef url_string = CFURLGetString(url);
    CFURLRef item_url = NULL;
    for (CFIndex i = 0; i < count; i += 1)
    {
        LSSharedFileListItemRef item = (LSSharedFileListItemRef) CFArrayGetValueAtIndex(login_items_array, i);
        if (LSSharedFileListItemResolve(item, 0, &item_url, NULL) != 0)
        {
            qWarning("unable to resolve login item");
            CFRelease(login_items_array);
            CFRelease(login_items);
            return;
        }
        CFStringRef item_url_string = CFURLGetString(item_url);

        CFComparisonResult result = CFStringCompare(url_string, item_url_string, 0);
        CFRelease(item_url);
        if (result == kCFCompareEqualTo)
        {
            if (!p->active)
            {
                LSSharedFileListItemRemove(login_items, item);
                CFRelease(login_items_array);
                CFRelease(login_items);
                return;
            }

            qWarning("found in login items already");
            CFRelease(login_items_array);
            CFRelease(login_items);
            return;
        }
    }

    if (p->active)
    {
        LSSharedFileListItemRef item = LSSharedFileListInsertItemURL(
            login_items, kLSSharedFileListItemLast, p->name.toCFString(), NULL, url, NULL, NULL);
        if (!item)
        {
            qWarning("Unable to add to login items");
            CFRelease(login_items_array);
//.........这里部分代码省略.........
开发者ID:Aseman-Land,项目名称:aseman-qt-tools,代码行数:101,代码来源:asemanautostartmanager.cpp


注:本文中的LSSharedFileListItemResolve函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。