다음을 통해 공유


IStorageProviderKnownFolderSyncInfoSource 인터페이스

정의

클라우드 공급자가 알려진 폴더의 동기화 상태 대한 정보를 제공하기 위해 구현하는 인터페이스입니다.

public interface class IStorageProviderKnownFolderSyncInfoSource
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Storage.Provider.CloudFilesContract, 458752)]
/// [Windows.Foundation.Metadata.Guid(1362465602, 63424, 21456, 187, 182, 28, 220, 9, 142, 189, 169)]
struct IStorageProviderKnownFolderSyncInfoSource
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Storage.Provider.CloudFilesContract), 458752)]
[Windows.Foundation.Metadata.Guid(1362465602, 63424, 21456, 187, 182, 28, 220, 9, 142, 189, 169)]
public interface IStorageProviderKnownFolderSyncInfoSource
Public Interface IStorageProviderKnownFolderSyncInfoSource
특성

Windows 요구 사항

디바이스 패밀리
Windows 11 Insider Preview (10.0.23504.0에서 도입되었습니다.)
API contract
Windows.Storage.Provider.CloudFilesContract (v7.0에서 도입되었습니다.)

예제

다음 예제에서는 스토리지 공급자의 IStorageProviderKnownFolderSyncInfoSource 구현을 보여 줍니다.

namespace winrt::CloudMirror::implementation
{
    struct MyKnownFolderInfoSource : implements<MyKnownFolderInfoSource,
            winrt::CloudMirror::IStorageProviderKnownFolderSyncInfoSource>
    {
        MyKnownFolderInfoSource();

        StorageProviderKnownFolderSyncInfo GetKnownFolderSyncInfo();

        winrt::event_token KnownFolderSyncInfoChanged(
            winrt::Windows::Foundation::TypedEventHandler<IStorageProviderKnownFolderSyncInfoSource,
            winrt::Windows::Foundation::IInspectable> const& handler);
        void KnownFolderSyncInfoChanged(winrt::event_token const& token) noexcept;

    private:
        winrt::hstring GetProviderDisplayName();
        winrt::Uri GetAvailableIcon();
        winrt::Uri GetEnrollingIcon();
        void NotifyStateChanged();

    winrt::event<winrt::TypedEventHandler<IStorageProviderKnownFolderSyncInfoSource, IInspectable>> m_changedEvent;
        std::vector<StorageProviderKnownFolderEntry> m_knownFolderEntries;
    };
}

...

using namespace winrt::Windows::Storage::Provider;

namespace winrt::CloudMirror::implementation
{
    MyKnownFolderInfoSource::MyKnownFolderInfoSource()
    {
        // The cloud provider would assess its current state and use it to
        // inform File Explorer. In this example, Documents is available for
        // backup, Pictures is currently enrolling, and Downloads is already
        // backed up (enrolled).
        winrt::StorageProviderKnownFolderEntry documents{};
        documents.KnownFolderId(FOLDERID_Documents);
        documents.Status(StorageProviderKnownFolderSyncStatus::Available);
        m_knownFolderState.push_back(documents);

        winrt::StorageProviderKnownFolderEntry pictures{};
        pictures.KnownFolderId(FOLDERID_Pictures);
        pictures.Status(StorageProviderKnownFolderSyncStatus::Enrolling);
        m_knownFolderState.push_back(pictures);

        winrt::StorageProviderKnownFolderEntry downloads{};
        downloads.KnownFolderId(FOLDERID_Downloads);
        downloads.Status(StorageProviderKnownFolderSyncStatus::Enrolled);
        m_knownFolderState.push_back(downloads);
    }

    // GetKnownFolderSyncInfo is called by File Explorer whenever it needs to get the
    // latest known folder sync status from the cloud provider. Once returned, the
    // StorageProviderKnownFolderSyncInfo is considered immutable.
    //
    // A SyncRequested handler must be set on the returned object to be considered valid
    // and to be displayed in File Explorer.
    StorageProviderKnownFolderSyncInfo MyKnownFolderInfoSource::GetKnownFolderSyncInfo()
    {
        winrt::StorageProviderKnownFolderSyncInfo info{};
        info.ProviderDisplayName(GetProviderDisplayName());
        // Setting a SyncRequested handler to respond to user action.
        auto syncRequestHandler = [](
            winrt::CloudMirror::StorageProviderKnownFolderSyncRequestArgs const& args)
        {
            // The user wants to sync some known folders with our cloud provider.
            // We can show some UI to sign in, confirm their choice, etc.
            MyStorageProviderSyncManager::ShowFolderEnrollmentUI(args.KnownFolders(), args.Source());

            // Or we can immediately start syncing the requested folders.
            MyStorageProviderSyncManager::StartSyncingFolders(args.KnownFolders(), args.Source());
        };

        info.SyncRequested(syncRequestHandler);
        info.KnownFolderEntries().ReplaceAll(m_knownFolderEntries);
        return info;
    }
}

설명

파일 탐색기 GetKnownFolderSyncInfoSource를 호출하여 지정된 공급자에 대한 IStorageProviderKnownFolderSyncInfoSource의 instance 가져옵니다.

이 인터페이스는 KnownFolderSyncInfoChanged 이벤트를 제공합니다. 이 이벤트는 표시 이름을 포함하여 속성 또는 폴더 상태 변경되면 앱이 발생합니다. 클라우드 공급자는 GetKnownFolderSyncInfoSource 가 이벤트를 발생시키는 즉시 호출될 것으로 예상해서는 안 됩니다. 파일 탐색기 필요에 따라 새 개체만 요청합니다.

메서드

GetKnownFolderSyncInfo()

GetKnownFolderSyncInfo는 클라우드 공급자로부터 알려진 최신 폴더 동기화 상태 가져와야 할 때마다 파일 탐색기 호출됩니다.

이벤트

KnownFolderSyncInfoChanged

알려진 폴더의 동기화 상태 변경될 때 발생하는 이벤트입니다.

적용 대상

추가 정보