internal GlobalSyncDetail GenerateGlobalSyncDetail()
        {
            try
            {
                GlobalSyncDetail global_sync_detail = new GlobalSyncDetail();

                // Build the initial knowledge of our libraries
                StatusManager.Instance.UpdateStatusBusy(StatusCodes.SYNC_META_GLOBAL, "Getting your library details", 0, 1);
                List <WebLibraryDetail> web_library_details = WebLibraryManager.Instance.WebLibraryDetails_WorkingWebLibraries_All;
                foreach (WebLibraryDetail web_library_detail in web_library_details)
                {
                    // Create the new LibrarySyncDetail
                    LibrarySyncDetail library_sync_detail = new LibrarySyncDetail();
                    global_sync_detail.library_sync_details.Add(library_sync_detail);

                    // Store our knowledge about the web library detail
                    library_sync_detail.web_library_detail = web_library_detail;
                }

                // Now get the local details of each library
                {
                    StatusManager.Instance.UpdateStatusBusy(StatusCodes.SYNC_META_GLOBAL, String.Format("Gather local library details"));
                    for (int i = 0; i < global_sync_detail.library_sync_details.Count; ++i)
                    {
                        LibrarySyncDetail library_sync_detail = global_sync_detail.library_sync_details[i];
                        StatusManager.Instance.UpdateStatusBusy(StatusCodes.SYNC_META_GLOBAL, String.Format("Getting the local library details for {0}", library_sync_detail.web_library_detail.Title), i, global_sync_detail.library_sync_details.Count);
                        library_sync_detail.local_library_sync_detail = GetLocalLibrarySyncDetail(library_sync_detail.web_library_detail.library);
                    }
                }


                // Work out if they are allowed to sync this record
                StatusManager.Instance.UpdateStatusBusy(StatusCodes.SYNC_META_GLOBAL, String.Format("Determining sync allowances"));
                foreach (LibrarySyncDetail library_sync_detail in global_sync_detail.library_sync_details)
                {
                    //  Eagerly sync metadata
                    library_sync_detail.sync_decision = new LibrarySyncDetail.SyncDecision();
                    library_sync_detail.sync_decision.can_sync_metadata = true;

                    // Else initiator
                    if (false)
                    {
                    }

                    // Never guests
                    else if (library_sync_detail.web_library_detail.IsLocalGuestLibrary)
                    {
                        library_sync_detail.sync_decision.can_sync          = false;
                        library_sync_detail.sync_decision.can_sync_metadata = false;
                        library_sync_detail.sync_decision.is_readonly       = library_sync_detail.web_library_detail.IsReadOnly;
                    }

                    // Intranets are dependent on premium
                    else if (library_sync_detail.web_library_detail.IsIntranetLibrary)
                    {
                        library_sync_detail.sync_decision.can_sync          = true;
                        library_sync_detail.sync_decision.can_sync_metadata = true;
                        library_sync_detail.sync_decision.is_readonly       = library_sync_detail.web_library_detail.IsReadOnly;
                    }

                    // Bundles can never sync
                    else if (library_sync_detail.web_library_detail.IsBundleLibrary)
                    {
                        library_sync_detail.sync_decision.can_sync          = false;
                        library_sync_detail.sync_decision.can_sync_metadata = false;
                        library_sync_detail.sync_decision.is_readonly       = library_sync_detail.web_library_detail.IsReadOnly;
                    }

                    // Unknown library types
                    else
                    {
                        library_sync_detail.sync_decision.can_sync          = false;
                        library_sync_detail.sync_decision.can_sync_metadata = false;
                        library_sync_detail.sync_decision.is_readonly       = true;
                    }
                }

                return(global_sync_detail);
            }

            finally
            {
                // Clear the status bar
                StatusManager.Instance.ClearStatus(StatusCodes.SYNC_META_GLOBAL);
            }
        }
Esempio n. 2
0
        internal static GlobalSyncDetail GenerateGlobalSyncDetail(bool tally_library_storage_size)
        {
            WPFDoEvents.AssertThisCodeIs_NOT_RunningInTheUIThread();

            try
            {
                GlobalSyncDetail global_sync_detail = new GlobalSyncDetail();

                // Build the initial knowledge of our libraries
                StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META_GLOBAL, "Getting your library details");
                List <WebLibraryDetail> web_library_details = WebLibraryManager.Instance.WebLibraryDetails_WorkingWebLibraries;
                foreach (WebLibraryDetail web_library_detail in web_library_details)
                {
                    // Create the new LibrarySyncDetail
                    LibrarySyncDetail library_sync_detail = new LibrarySyncDetail();
                    global_sync_detail.library_sync_details.Add(library_sync_detail);

                    // Store our knowledge about the web library detail
                    library_sync_detail.web_library_detail = web_library_detail;
                }

                // Now get the local details of each library
                {
                    StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META_GLOBAL, String.Format("Gather local library details"));
                    for (int i = 0; i < global_sync_detail.library_sync_details.Count; ++i)
                    {
                        LibrarySyncDetail library_sync_detail = global_sync_detail.library_sync_details[i];
                        StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META_GLOBAL, String.Format("Getting the local library details for {0}", library_sync_detail.web_library_detail.Title), i, global_sync_detail.library_sync_details.Count);
                        library_sync_detail.local_library_sync_detail = GetLocalLibrarySyncDetail(library_sync_detail.web_library_detail, tally_library_storage_size);
                    }
                }

                // Work out if they are allowed to sync this record
                StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_META_GLOBAL, String.Format("Determining sync allowances"));
                foreach (LibrarySyncDetail library_sync_detail in global_sync_detail.library_sync_details)
                {
                    //  Eagerly sync metadata
                    LibrarySyncDetail.SyncDecision d = library_sync_detail.sync_decision = new LibrarySyncDetail.SyncDecision();

                    // We do not care what type of (commercial) library this has been:
                    // you are now free to choose and do as you like.
                    //
                    // Hence it should be possible for 'Guest' libraries (and everything else)
                    // to be assigned a sync target directory or URI to sync your libraries anywhere.
                    //
                    // When you think about user access rights to your library, THAT SUBJECT
                    // should be taken care of at the sync target itself: if you have
                    // WRITE access, you should be able to update the library, period.
                    d.can_sync    = true;
                    d.is_readonly = false;

                    // Bundles can never sync
                    if (library_sync_detail.web_library_detail.IsReadOnlyLibrary)
                    {
                        d.can_sync    = false;
                        d.is_readonly = true;
                    }
                }

                return(global_sync_detail);
            }
            finally
            {
                // Clear the status bar
                StatusManager.Instance.ClearStatus(StatusCodes.SYNC_META_GLOBAL);
            }
        }