void BackgroundUpload(object sender, DoWorkEventArgs e)
        {
            var book      = (Book.Book)e.Argument;
            var languages = _languagesFlow.Controls.Cast <CheckBox>().
                            Where(b => b.Checked).Select(b => b.Tag).Cast <string>().ToList();
            var checker = new LicenseChecker();
            var message = checker.CheckBook(book, languages.ToArray());

            if (message != null)
            {
                _progressBox.WriteError(message);
                e.Result = "quiet";                 // suppress other completion/fail messages
                return;
            }

            if (_signLanguageCheckBox.Checked && !string.IsNullOrEmpty(book.CollectionSettings.SignLanguageIso639Code))
            {
                languages.Insert(0, book.CollectionSettings.SignLanguageIso639Code);
            }

            book.UpdateMetadataFeatures(
                isBlindEnabled: _blindCheckBox.Checked,
                isTalkingBookEnabled: _narrationAudioCheckBox.Checked,
                isSignLanguageEnabled: _signLanguageCheckBox.Checked,
                allowedLanguages: languages);

            var includeNarrationAudio  = _narrationAudioCheckBox.Checked;
            var includeBackgroundMusic = _backgroundMusicCheckBox.Checked;
            var result = _model.UploadOneBook(book, _progressBox, _parentView, languages.ToArray(), !includeNarrationAudio, !includeBackgroundMusic, out _parseId);

            e.Result = result;
        }
        void BackgroundUpload(object sender, DoWorkEventArgs e)
        {
            var model   = (BloomLibraryPublishModel)e.Argument;
            var book    = model.Book;
            var checker = new LicenseChecker();

            var message = checker.CheckBook(book, LanguagesCheckedToUpload.ToArray());

            if (message != null)
            {
                // Using WriteError allows users to send bug reports: this isn't a bug!
                _progressBox.WriteMessageWithColor(Color.Red, message);
                e.Result = "quiet";                 // suppress other completion/fail messages
                return;
            }

            _model.UpdateBookMetadataFeatures(
                _blindCheckBox.Checked,
                _narrationAudioCheckBox.Checked,
                _signLanguageCheckBox.Checked);

            var includeBackgroundMusic = _backgroundMusicCheckBox.Checked;
            var result = _model.UploadOneBook(book, _progressBox, _parentView, !includeBackgroundMusic, out _parseId);

            e.Result = result;
        }
Exemplo n.º 3
0
        public void CheckBook_HasMeta_NoAccessToSpreadsheet_ReportsCantTest()
        {
            var dom = MakeDomWithLicenseMeta();

            LicenseChecker.SetAllowInternetAccess(false);
            LicenseChecker.SetOfflineFolder(null);
            var checker = new LicenseChecker();

            Assert.That(checker.CheckBook(dom, new[] { "en" }), Is.EqualTo(LicenseChecker.kCannotReachLicenseServerMessage));
        }
Exemplo n.º 4
0
        public void CheckBook_NoMetaLicenseId_ReturnsNull()
        {
            var dom     = BookTestsBase.MakeDom(@"<div class='bloom-page numberedPage customPage A5Portrait'>
						<div id='testDiv' class='marginBox'>
							<div class='bloom-translationGroup bloom-trailingElement normal-style'>
								<div class='bloom-editable normal-style cke_focus bloom-content1 bloom-visibility-code-on' contenteditable='true' lang='xyz'>
										some text
								</div>
							</div>
						</div>
					</div>"                    );
            var checker = new LicenseChecker();

            LicenseChecker.SetAllowInternetAccess(false);
            LicenseChecker.SetOfflineFolder(null);
            Assert.That(checker.CheckBook(dom, new[] { "en", "fr" }), Is.Null);
            LicenseChecker.SetAllowInternetAccess(true);
            Assert.That(checker.CheckBook(dom, new[] { "en", "fr" }), Is.Null);
        }
Exemplo n.º 5
0
        public void CheckBook_MetaLicenseId_ReturnsCantUse_IfLangsNotAllowed()
        {
            var dom = MakeDomWithLicenseMeta();

            using (var folder = SetupDefaultOfflineLicenseInfo())
            {
                var checker          = new LicenseChecker();
                var expectedTemplate = LicenseChecker.kUnlicenseLanguageMessage;
                var expectedEn       = string.Format(expectedTemplate, "English");
                Assert.That(checker.CheckBook(dom, new[] { "en" }), Is.EqualTo(expectedEn));
                var expectedFr = string.Format(expectedTemplate, "français");
                Assert.That(checker.CheckBook(dom, new[] { "fr" }), Is.EqualTo(expectedFr));
                var expectedEnFr = string.Format(expectedTemplate, "English, français");
                Assert.That(checker.CheckBook(dom, new[] { "en", "fr" }), Is.EqualTo(expectedEnFr));
                // Russian and bjn ARE permitted.
                Assert.That(checker.CheckBook(dom, new[] { "ru", "bjn" }), Is.Null);
                Assert.That(checker.CheckBook(dom, new[] { "en", "fr", "ru", "bjn" }), Is.EqualTo(expectedEnFr));
                // It might make sense to test (and implement) not complaining about languages which occur in the list
                // but do not occur in the book. But in practice we don't give users any opportunity to request languages
                // that don't occur in the book, so there's no point.
            }
        }