1 /* 2 * This file is part of nzbget. See <http://nzbget.net>. 3 * 4 * Copyright (C) 2004 Sven Henkel <sidddy@users.sourceforge.net> 5 * Copyright (C) 2007-2016 Andrey Prygunkov <hugbug@users.sourceforge.net> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 22 #ifndef NZBFILE_H 23 #define NZBFILE_H 24 25 #include "NString.h" 26 #include "DownloadInfo.h" 27 28 class NzbFile 29 { 30 public: 31 NzbFile(const char* fileName, const char* category); 32 bool Parse(); GetFileName()33 const char* GetFileName() const { return m_fileName; } DetachNzbInfo()34 std::unique_ptr<NzbInfo> DetachNzbInfo() { return std::move(m_nzbInfo); } GetPassword()35 const char* GetPassword() { return m_password; } 36 37 void LogDebugInfo(); 38 39 private: 40 std::unique_ptr<NzbInfo> m_nzbInfo; 41 CString m_fileName; 42 CString m_password; 43 44 void AddArticle(FileInfo* fileInfo, std::unique_ptr<ArticleInfo> articleInfo); 45 void AddFileInfo(std::unique_ptr<FileInfo> fileInfo); 46 void ParseSubject(FileInfo* fileInfo, bool TryQuotes); 47 void BuildFilenames(); 48 void ProcessFiles(); 49 void CalcHashes(); 50 bool HasDuplicateFilenames(); 51 void ReadPassword(); 52 #ifdef WIN32 53 bool ParseNzb(IUnknown* nzb); 54 static void EncodeUrl(const char* filename, char* url, int bufLen); 55 #else 56 std::unique_ptr<FileInfo> m_fileInfo; 57 ArticleInfo* m_article = nullptr; 58 StringBuilder m_tagContent; 59 bool m_ignoreNextError; 60 bool m_hasPassword = false; 61 62 static void SAX_StartElement(NzbFile* file, const char *name, const char **atts); 63 static void SAX_EndElement(NzbFile* file, const char *name); 64 static void SAX_characters(NzbFile* file, const char * xmlstr, int len); 65 static void* SAX_getEntity(NzbFile* file, const char * name); 66 static void SAX_error(NzbFile* file, const char *msg, ...); 67 void Parse_StartElement(const char *name, const char **atts); 68 void Parse_EndElement(const char *name); 69 void Parse_Content(const char *buf, int len); 70 #endif 71 }; 72 73 #endif 74