int main(int argc, char **argv) { Args args(argc, argv, "PATH"); const auto path = args.ExpectNextPath(); args.ExpectEnd(); Error error; FileLineReaderA reader(path, error); if (reader.error()) { fprintf(stderr, "%s\n", error.GetMessage()); return EXIT_FAILURE; } FileRepository repository; if (!ParseFileRepository(repository, reader)) { fprintf(stderr, "Failed to parse file\n"); return EXIT_FAILURE; } for (auto i = repository.begin(), end = repository.end(); i != end; ++i) { const auto &file = *i; printf("file '%s' '%s' area='%s' type=%u\n", file.GetName(), file.GetURI(), file.GetArea(), (unsigned)file.type); } return EXIT_SUCCESS; }
void ManagedFileListWidget::RefreshList() { items.clear(); bool download_active = false; for (auto i = repository.begin(), end = repository.end(); i != end; ++i) { const auto &remote_file = *i; DownloadStatus download_status; const bool is_downloading = IsDownloading(remote_file, download_status); TCHAR path[MAX_PATH]; if (LocalPath(path, remote_file) && (is_downloading || File::Exists(path))) { download_active |= is_downloading; items.append().Set(BaseName(path), is_downloading ? &download_status : NULL, HasFailed(remote_file)); } } ListControl &list = GetList(); list.SetLength(items.size()); list.Invalidate(); #ifdef HAVE_DOWNLOAD_MANAGER if (download_active && !Timer::IsActive()) Timer::Schedule(1000); #endif }
void ManagedFileListWidget::RefreshList() { items.clear(); bool download_active = false; for (auto i = repository.begin(), end = repository.end(); i != end; ++i) { const auto &remote_file = *i; DownloadStatus download_status; const bool is_downloading = IsDownloading(remote_file, download_status); const auto path = LocalPath(remote_file); if (!path.IsNull() && (is_downloading || File::Exists(path))) { download_active |= is_downloading; const Path base = path.GetBase(); if (base.IsNull()) continue; items.append().Set(base.c_str(), is_downloading ? &download_status : nullptr, HasFailed(remote_file)); } } ListControl &list = GetList(); list.SetLength(items.size()); list.Invalidate(); #ifdef HAVE_DOWNLOAD_MANAGER if (download_active && !Timer::IsActive()) Timer::Schedule(1000); #endif }
void ManagedFileListWidget::Add() { #ifdef HAVE_DOWNLOAD_MANAGER assert(Net::DownloadManager::IsAvailable()); std::vector<AvailableFile> list; for (auto i = repository.begin(), end = repository.end(); i != end; ++i) { const AvailableFile &remote_file = *i; if (IsDownloading(remote_file.GetName())) /* already downloading this file */ continue; ACPToWideConverter name(remote_file.GetName()); if (!name.IsValid()) continue; if (FindItem(name) < 0) list.push_back(remote_file); } if (list.empty()) return; add_list = &list; FunctionListItemRenderer item_renderer(OnPaintAddItem); int i = ListPicker(_("Select a file"), list.size(), 0, Layout::FastScale(18), item_renderer); add_list = NULL; if (i < 0) return; assert((unsigned)i < list.size()); const AvailableFile &remote_file = list[i]; ACPToWideConverter base(remote_file.GetName()); if (!base.IsValid()) return; Net::DownloadManager::Enqueue(remote_file.GetURI(), base); #endif }