public SkyDriveAuthorizationService(ILiveLogin liveLogin, ICatalogRepository catalogRepository,
                                     CatalogModel catalog)
 {
     _liveLogin = liveLogin;
     _catalog = catalog;
     _catalogRepository = catalogRepository;
 }
 public void Deauthorize()
 {
     var catalog = _catalogRepository.Get(_catalogModel.Id);
     catalog.AuthorizationString = null;
     _catalogRepository.Save(catalog);
     _catalogModel = catalog;
 }
        public ICatalogReader Create(CatalogModel catalog)
        {
            if (catalog == null)
            {
                throw new ArgumentNullException("catalog");
            }

            if (catalog.Type == CatalogType.Cops)
            {
                return new CopsCatalogReader(catalog, _storageStateSaver, _webClient);
            }
            if (catalog.Type == CatalogType.SDCard)
            {
                return new SdCardCatalogReader(_sdStorage, catalog);
            }
            if (catalog.Type == CatalogType.SkyDrive)
            {
                return new SkyDriveCatalogReader(catalog, _liveLogin, _storageStateSaver, _downloadController, _catalogRepository);
            }
            if (catalog.Type == CatalogType.Litres)
            {
                return new LitresCatalogReader(catalog, _storageStateSaver, _webClient);
            }

            return new OpdsCatalogReader(catalog, _storageStateSaver, _webClient);
        }
        protected override void OnViewLoaded(object view)
        {
            base.OnViewLoaded(view);

            if (CatalogId <= 0)
            {
                throw new ArgumentException("CatalogId is not set in CatalogPageViewModel.");
            }

            _catalog = CatalogRepository.Get(CatalogId);
            if (_catalog == null)
            {
                return;
            }

            _catalogAuthorizationService = _catalogAuthorizationFactory.GetAuthorizationService(_catalog);
            NotifyOfPropertyChange("IsAuthorized");

            CatalogReader = CatalogReaderFactory.Create(_catalog);

            if (SavedInTombstone)
            {
                LoadState(ToString());
            }

            LoadItems();
        }
        private void AddDefaultCatalogs(BookDataContext dataContext)
        {
            /*
            var catalog = new CatalogModel
            {
                Url = "http://data.fbreader.org/catalogs/litres2/index.php5",
                Title = "FBReader_Litres",
                Description = "description",
                IconLocalPath = "/Resources/Icons/litres_icon.jpg",
                SearchUrl = "http://data.fbreader.org/catalogs/litres2/search.php5?query={0}",
                Type = CatalogType.Litres
            };
            dataContext.Catalogs.InsertOnSubmit(catalog);
            /*/
            var catalog = new CatalogModel
            {
                Url = "http://sopdsbook.ru:8081/",
                Title ="Ѕиблиотеке",
                Description = "description",
                IconLocalPath = "/Resources/Icons/cops_icon.jpg",
                SearchUrl = "http://sopdsbook.ru:8081/?searchType=books&searchTerm={0}",
                OpenSearchDescriptionUrl = "http://sopdsbook.ru:8081/web?id=07",

                Type = CatalogType.OPDS
            };
            dataContext.Catalogs.InsertOnSubmit(catalog);
            //*/

            dataContext.SubmitChanges();
        }
Esempio n. 6
0
 public void Add(CatalogModel catalog)
 {
     using (BookDataContext context = BookDataContext.Connect())
     {
         context.Catalogs.InsertOnSubmit(catalog);
         context.SubmitChanges();
     }
 }
 public void Deauthorize()
 {
     _liveLogin.Logout();
     var catalog = _catalogRepository.Get(_catalog.Id);
     catalog.AccessDenied = true;
     _catalogRepository.Save(catalog);
     _catalog = catalog;
 }
Esempio n. 8
0
 public void Save(CatalogModel catalog)
 {
     using (BookDataContext context = BookDataContext.Connect())
     {
         context.Catalogs.Attach(catalog);
         context.Refresh(0, catalog);
         context.SubmitChanges();
     }
 }
Esempio n. 9
0
        public static CatalogModel ToCatalogModel(this CatalogDto catalogDto, string url = null)
        {
            var catalogModel = new CatalogModel { Title = catalogDto.Title};

            if (!string.IsNullOrEmpty(catalogDto.SubTitle))
            {
                var desc = catalogDto.SubTitle;
                for (var i = 0; i < desc.Length; ++i)
                {
                    if (desc[i].Equals('\n') || desc[i].Equals('\t') || desc[i].Equals(' '))
                    {
                        continue;
                    }
                    desc = desc.Substring(i);
                    break;
                }
                catalogModel.Description = desc;
            }

            catalogModel.IconLocalPath = "DesignBookCover.jpg"; // is for test. Remove or change when some stub for opds catalog will be ready.

            if (url != null)
            {
                catalogModel.Url = url;
            }
            else
            {
                var selfLink = catalogDto.Links.SingleOrDefault(l => l.Rel.Equals("self"));
                if (selfLink != null)
                {
                    catalogModel.Url = selfLink.Href;
                }
            }

            var searchLink = catalogDto.Links.SingleOrDefault(l => "search".Equals(l.Rel) && !string.IsNullOrEmpty(l.Href) && OPEN_SEARCH_LINK_TYPE.Equals(l.Type));
            if (searchLink != null)
            {
                Uri searchDescriptionUri;
                if (Uri.TryCreate(new Uri(catalogModel.Url, UriKind.RelativeOrAbsolute), searchLink.Href, out searchDescriptionUri))
                {
                    catalogModel.OpenSearchDescriptionUrl = searchDescriptionUri.ToString();
                }
                else
                {
                    catalogModel.OpenSearchDescriptionUrl = GetValidUrl(searchLink.Href, catalogModel.Url);
                }
                return catalogModel;
            }

            searchLink = catalogDto.Links.SingleOrDefault(l => "search".Equals(l.Rel));
            if (searchLink != null)
            {
                catalogModel.SearchUrl = GetValidUrl(ValidateSearchUrlTemplate(searchLink.Href), catalogModel.Url);
            }

            return catalogModel;
        }
Esempio n. 10
0
        public CatalogDataModel ToCatalogDataModel(CatalogModel catalog)
        {
            var dataModel = new CatalogDataModel
            {
                Catalog = catalog,
                Icon = catalog.IconLocalPath,
                Title = catalog.Title,
                Description = catalog.Description
            };

            return dataModel;
        }
Esempio n. 11
0
 public void Remove(CatalogModel catalog)
 {
     using (BookDataContext context = BookDataContext.Connect())
     {
         CatalogModel model = context.Catalogs.FirstOrDefault(t => t.Id == catalog.Id);
         if (model != null)
         {
             context.Catalogs.DeleteOnSubmit(model);
             context.SubmitChanges();
         }
     }
 }
        public ICatalogAuthorizationService GetAuthorizationService(CatalogModel catalog)
        {
            switch (catalog.Type)
            {
                case CatalogType.OPDS:
                    return new HttpAuthorizationService(_webClient, _catalogRepository, catalog);
                case CatalogType.Litres:
                    return new LitresAuthorizationService(_webClient, _catalogRepository, catalog);
                case CatalogType.SkyDrive:
                    return new SkyDriveAuthorizationService(_liveLogin, _catalogRepository, catalog);
            }

            return new DummyAuthorizationService();
        }
 public SkyDriveCatalogReader(
     CatalogModel catalog, 
     ILiveLogin liveLogin, 
     IStorageStateSaver storageStateSaver,
     DownloadController downloadController,
     ICatalogRepository catalogRepository)
 {
     _catalog = catalog;
     _liveLogin = liveLogin;
     _storageStateSaver = storageStateSaver;
     _downloadController = downloadController;
     _catalogRepository = catalogRepository;
     CatalogId = catalog.Id;
 }
Esempio n. 14
0
        public CatalogDataModel ToCatalogDataModel(CatalogModel catalog)
        {
            var dataModel = new CatalogDataModel();
            dataModel.Catalog = catalog;
            dataModel.Icon = catalog.IconLocalPath;
            dataModel.Title = catalog.Title;
            dataModel.Description = catalog.Description;

            switch (catalog.Type)
            {
                case CatalogType.SDCard:
                    dataModel.Title = UIStrings.SDCard_Catalog_Title;
                    dataModel.Description = UIStrings.SDCard_Catalog_Description;
                    break;
                case CatalogType.SkyDrive:
                    dataModel.Title = UIStrings.SkyDrive_Catalog_Title;
                    dataModel.Description = UIStrings.SkyDrive_Catalog_Description;
                    break;
            }
            switch (catalog.Title)
            {
                case "FBReader_Litres":
                    dataModel.Title = UIStrings.Litres_Catalog_Title;
                    dataModel.Description = UIStrings.Litres_Catalog_Descritption;
                    break;
                case "FBReader_Flibusta":
                    dataModel.Title = UIStrings.Flibusta_Catalog_Title;
                    dataModel.Description = UIStrings.Flibusta_Catalog_Description;
                    break;
                case "FBReader_Manybooks":
                    dataModel.Title = UIStrings.Catalog_Manybooks_Title;
                    dataModel.Description = UIStrings.Catalog_Manybooks_Description;
                    break;
                case "FBReader_Prochtenie":
                    dataModel.Title = UIStrings.Catalog_Prochtenie_Title;
                    dataModel.Description = UIStrings.Catalog_Prochtenie_Description;
                    break;
            }
            return dataModel;
        }
Esempio n. 15
0
 public string GetCatalogTitle(CatalogModel catalog)
 {
     switch (catalog.Type)
     {
         case CatalogType.SDCard:
             return UIStrings.SDCard_Catalog_Title;
         case CatalogType.SkyDrive:
             return UIStrings.SkyDrive_Catalog_Title;
     }
     switch (catalog.Title)
     {
         case "FBReader_Litres":
             return UIStrings.Litres_Catalog_Title;
         case "FBReader_Flibusta":
             return UIStrings.Flibusta_Catalog_Title;
         case "FBReader_Manybooks":
             return UIStrings.Catalog_Manybooks_Title;
         case "FBReader_Prochtenie":
             return UIStrings.Catalog_Prochtenie_Title;
     }
     return catalog.Title;
 }
Esempio n. 16
0
        public OpdsCatalogReader(CatalogModel catalogModel, IStorageStateSaver storageStateSaver, 
            IWebClient webClient)
        {
            CatalogModel = catalogModel;
            _storageStateSaver = storageStateSaver;
            WebClient = webClient;

            _opdsFilters = new IOpdsBadFormatFilter[]
                               {
                                   new UnescapedAmpersandsFilter(), 
                                   new UnescapedCdataFilter(),
                                   new UnescapedQuotesFilter(), 
                                   new UnescapedSignsFilter(),
                                   new UnescapedHtmlDescriptionFilter(),
                                   new AcquisitionBuyFilter(),
                                   new UrlWithoutProtocolFilter(), 
                               };

            CurrentFolder = new CatalogFolderModel
                                 {
                                     BaseUrl = catalogModel.Url,
                                     Items = new List<CatalogItemModel>()
                                 };
        }
 public HttpAuthorizationService(IWebClient webClient, ICatalogRepository catalogRepository, CatalogModel catalogModel)
     : base(catalogRepository, catalogModel)
 {
     _webClient = webClient;
 }
 protected OpdsAuthorizationServiceBase(ICatalogRepository catalogRepository, CatalogModel catalogModel)
 {
     _catalogRepository = catalogRepository;
     _catalogModel = catalogModel;
 }
Esempio n. 19
0
 public SdCardCatalogReader(ISdCardStorage sdCardStorage, CatalogModel catalogModel)
 {
     _sdCardStorage = sdCardStorage;
     _catalogModel = catalogModel;
 }
Esempio n. 20
0
        private void AddDefaultCatalogs(BookDataContext dataContext)
        {
            var catalog = new CatalogModel
            {
                Url = "http://data.fbreader.org/catalogs/litres2/index.php5",
                Title = "FBReader_Litres",
                Description = "description",
                IconLocalPath = "/Resources/Icons/litres_icon.jpg",
                SearchUrl = "http://data.fbreader.org/catalogs/litres2/search.php5?query={0}",
                Type = CatalogType.Litres
            };
            dataContext.Catalogs.InsertOnSubmit(catalog);
            
//            catalog = new CatalogModel
//            {
//                Url = "http://flibusta.net/opds",
//                Title = "FBReader_Flibusta",
//                Description = "description",
//                IconLocalPath = "/Resources/Icons/flibusta_icon.jpg",
//                SearchUrl = "http://flibusta.net/opds/search?searchTerm={0}&searchType=books",
//                Type = CatalogType.OPDS
//            };
//            dataContext.Catalogs.InsertOnSubmit(catalog);

            catalog = new CatalogModel
            {
                Url = "http://manybooks.net/opds/index.php",
                Title = "FBReader_Manybooks",
                Description = "description",
                IconLocalPath = "/Resources/Icons/Manybooks.png",
                Type = CatalogType.OPDS
            };
            dataContext.Catalogs.InsertOnSubmit(catalog);

            catalog = new CatalogModel
            {
                Url = "http://data.fbreader.org/catalogs/prochtenie/index.xml",
                Title = "FBReader_Prochtenie",
                Description = "description",
                IconLocalPath = "/Resources/Icons/prochtenie_catalog.png",
                Type = CatalogType.OPDS
            };
            dataContext.Catalogs.InsertOnSubmit(catalog);

            catalog = new CatalogModel
						{
								Title = UIStrings.SkyDrive_Catalog_Title,
								Description = UIStrings.SkyDrive_Catalog_Description,
								IconLocalPath = "/Resources/Icons/skydrive.png",
								Type = CatalogType.SkyDrive,
								AccessDenied = true
						};
            dataContext.Catalogs.InsertOnSubmit(catalog);

           
            catalog = new CatalogModel
            {
                Title = UIStrings.SDCard_Catalog_Title,
                Description = UIStrings.SDCard_Catalog_Description,
                IconLocalPath = "/Resources/Icons/sd_card.png",
                Type = CatalogType.SDCard
            };

            dataContext.Catalogs.InsertOnSubmit(catalog);
            

            dataContext.SubmitChanges();
        }
Esempio n. 21
0
 public string GetCatalogDescription(CatalogModel catalog)
 {
     return catalog.Description;
 }
Esempio n. 22
0
 public string GetCatalogTitle(CatalogModel catalog)
 {
     return catalog.Title;
 }
Esempio n. 23
0
 public LitresCatalogReader(CatalogModel catalogModel, IStorageStateSaver storageStateSaver, IWebClient webClient) 
     : base(catalogModel, storageStateSaver, webClient)
 {
 }