### Instantiate NgPost in main() Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Creates the single NgPost instance, checks for a new version, and then either parses the command line (CMD mode) or starts the HMI. The CMD path includes SSL support check and event loop start. ```cpp app = new NgPost(argc, argv); app->checkForNewVersion(); // CMD: if (app->parseCommandLine(argc, argv)) { app->checkSupportSSL(); app->startEventLoop(); ... } // HMI: app->startHMI(); ``` -------------------------------- ### ngPost with all params Source: https://github.com/mbruel/ngpost/blob/master/README.md Command line example showing all parameters including server, authentication, groups, and archive size. ```bash ngPost_v4.16_cmd-x86_64.AppImage -t 1 -m "password=qwerty42" -m "metaKey=someValue" -h news.newshosting.com -P 443 -s -u user -p pass -n 30 -f ngPost@nowhere.com -g "alt.binaries.test,alt.binaries.test2" -a 64000 -i /tmp/folderToPost -o /tmp/folderToPost.nzb ``` -------------------------------- ### ngPost with monitoring Source: https://github.com/mbruel/ngpost/blob/master/README.md Command line example for monitoring multiple folders with auto compression and progress display. ```bash ngPost_v4.16_cmd-x86_64.AppImage --monitor /data/folder1 --monitor /data/folder2 --auto_compress --rm_posted --disp_progress files ``` -------------------------------- ### ngPost with config file Source: https://github.com/mbruel/ngpost/blob/master/README.md Command line example using a custom config file and specifying password and email. ```bash ngPost_v4.16_cmd-x86_64.AppImage -c ~/.ngPost -m "password=qwerty42" -f ngPost@nowhere.com -i /tmp/file1 -i /tmp/file2 -i /tmp/folderToPost1 -i /tmp/folderToPost2 ``` -------------------------------- ### Console posting run with NgPost main() Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Starts a console posting run, equivalent to main() with __USE_HMI__ undefined. Creates NgPost, checks for new version, parses command line, checks SSL support, starts event loop, and returns exit code. ```cpp int main(int argc, char *argv[]) { NgPost *app = new NgPost(argc, argv); app->checkForNewVersion(); if (app->parseCommandLine(argc, argv) && app->checkSupportSSL()) { app->startEventLoop(); } int exitCode = app->errCode(); delete app; return exitCode; } ``` -------------------------------- ### RAR_EXTRA configuration example Source: https://github.com/mbruel/ngpost/blob/master/README.md Example of setting RAR_EXTRA environment variable to disable compression and enable header encryption. The commented line shows alternative options for compression level, locking, and redundancy. ```bash #RAR_EXTRA = -ep1 -m0 -k -rr5p RAR_EXTRA = -mx0 -mhe=on ``` -------------------------------- ### ngPost with compression, filename obfuscation, random password and par2 Source: https://github.com/mbruel/ngpost/blob/master/README.md Command line example for posting a file and folder with compression, name and password generation, and par2. ```bash ngPost_v4.16_cmd-x86_64.AppImage -i /tmp/file1 -i /tmp/folder1 -o /nzb/myPost.nzb --compress --gen_name --gen_pass --gen_par2 ``` -------------------------------- ### Poster usage: lock queue, add connection, start threads, prepare articles Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/poster.md Shows the internal wiring of a Poster, mirroring src/PostingJob.cpp. It blocks connections while pre-filling, adds a connection (which sets the poster, moves to thread, and starts the connection), starts threads, pre-prepares 3 articles per connection, then releases the queue. ```cpp Poster *poster = new Poster(job, posterIdx); poster->lockQueue(); // block connections while we pre-fill poster->addConnection(con); // setPoster + moveToThread + startConnection poster->startThreads(); // pre-prepare 3 articles per connection, then release: poster->prepareArticlesInAdvance(); poster->unlockQueue(); ``` -------------------------------- ### ngPost with auto post Source: https://github.com/mbruel/ngpost/blob/master/README.md Command line example for auto-posting multiple folders with compression, par2, name and password generation, and rar size. ```bash ngPost_v4.16_cmd-x86_64.AppImage --auto /data/folder1 --auto /data/folder2 --compress --gen_par2 --gen_name --gen_pass --rar_size 42 --disp_progress files ``` -------------------------------- ### Start GDB with ParPar arguments Source: https://github.com/mbruel/ngpost/blob/master/parpar_abort_bt.txt Use this command to launch GDB with ParPar and its arguments, so you can debug the crash. The arguments specify slice size 1M, redundancy 8%, output file plop.par2, and input directory /tmp/testParpar. ```bash gdb --args ~/apps/bin/parpar -s 1M -r8% -o /tmp/testParpar/plop.par2 -R /tmp/testParpar ``` -------------------------------- ### FileUploader usage in NgPost::doNzbPostCMD Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/support-classes.md Shows how to create a FileUploader, connect its signals, and start the upload using a QUrl built from the NZB_UPLOAD_URL config. The readyToDie signal is wired to deleteLater with a queued connection. ```cpp FileUploader *upload = new FileUploader(_netMgr, job->nzbFilePath()); connect(upload, &FileUploader::error, this, &NgPost::onError, Qt::DirectConnection); connect(upload, &FileUploader::log, this, &NgPost::onLog, Qt::DirectConnection); connect(upload, &FileUploader::readyToDie, upload, &QObject::deleteLater, Qt::QueuedConnection); upload->startUpload(*_urlNzbUpload); // QUrl built from NZB_UPLOAD_URL config ``` -------------------------------- ### Create and start NntpConnection (PostingJob::_createNntpConnections / Poster::addConnection) Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-connection.md Shows how to instantiate NntpConnection, connect its signals to NgPost and PostingJob handlers, and add it to the poster. The comment indicates that addConnection sets the poster, moves to thread, and emits startConnection(). ```cpp NntpConnection *con = new NntpConnection(ngPost, ++conIdx, *srvParams); connect(con, &NntpConnection::log, ngPost, &NgPost::onLog, Qt::QueuedConnection); connect(con, &NntpConnection::error, ngPost, &NgPost::onError, Qt::QueuedConnection); connect(con, &NntpConnection::errorConnecting, ngPost, &NgPost::onErrorConnecting, Qt::QueuedConnection); connect(con, &NntpConnection::disconnected, job, &PostingJob::onDisconnectedConnection, Qt::QueuedConnection); poster->addConnection(con); // setPoster + moveToThread + emit startConnection() ``` -------------------------------- ### NgPost::startHMI() implementation Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/hmi.md Internal method to start the HMI. Parses default config, sets a random 'from' if empty, initializes and shows the HMI, forces language change, and runs the application event loop. ```cpp int NgPost::startHMI() { QString err = parseDefaultConfig(); if (!err.isEmpty()) _error(err); if (_from.empty()) _from = randomStdFrom(); _hmi->init(this); _hmi->show(); changeLanguage(_lang); // reforce lang set up... return _app->exec(); } ``` -------------------------------- ### Run ParPar under GDB Source: https://github.com/mbruel/ngpost/blob/master/parpar_abort_bt.txt After starting GDB, use the 'run' command to execute ParPar with the previously set arguments. The program crashes with SIGABRT after creating the PAR2 file. ```gdb run ``` -------------------------------- ### NZB XML output example Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-file.md Example of the XML output emitted by writeToNZB, abbreviated from src/nntp/NntpFile.cpp:150. Shows the file element with poster, date, subject, groups, and segments. ```xml alt.binaries.test {6f2e54e9-6a84-4eed-a811-5d9ebd0069e4}@ngPost {ebae6f34-37e7-4df2-91b8-850f82f3cc47}@ngPost ``` -------------------------------- ### languages Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Returns the list of installed translation keys (e.g., en, fr). ```APIDOC ## languages ### Description Returns the list of installed translation keys (e.g., en, fr). ### Method languages ### Signature `inline QList languages() const;` ### Returns - **QList** - List of installed translation keys. ``` -------------------------------- ### Poster class declaration (src/Poster.h) Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/poster.md Declares the Poster class with two QThreads, an ArticleBuilder, a queue of NntpArticle pointers, and a mutex. Includes friend declaration for ArticleBuilder and inline methods for queue locking, naming, and thread start. ```cpp class Poster { friend class ArticleBuilder; private: const ushort _id; NgPost *const _ngPost; PostingJob *const _job; QThread _builderThread; QThread _connectionsThread; ArticleBuilder *_articleBuilder; QVector _nntpConnections; //!< we don't own them, we just move them to _connectionsThread QQueue _articles; QMutex _secureArticles; public: Poster(PostingJob *job, ushort id); ~Poster(); void addConnection(NntpConnection *connection); NntpArticle *getNextArticle(const QString &conPrefix); inline void lockQueue(); inline void unlockQueue(); inline QString name() const; inline void startThreads(); void stopThreads(); bool prepareArticlesInAdvance(); bool isPosting() const; private: NntpArticle *_prepareNextArticle(const QString &threadName, bool fillQueue = true); }; ``` -------------------------------- ### Programmatic integration: NzbCheck class Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nzbcheck.md Mirrors the --check branch of NgPost::parseCommandLine. Creates an NzbCheck instance, parses the NZB, and if articles are found, checks them against servers with nzbCheck=true, then starts the event loop and logs the missing article count. ```cpp NzbCheck *check = new NzbCheck(); check->setDebug(0); check->setDispProgressBar(true); check->setQuiet(false); int nbArticles = check->parseNzb("/nzb/myPost.nzb"); if (nbArticles > 0) { check->checkPost(app->servers()); // only servers with nzbCheck=true are used app->startEventLoop(); qInfo() << "missing:" << check->nbMissingArticles(); } ``` -------------------------------- ### Quick post with config, meta, and fixed from Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/command-line.md Posts files using a configuration file, sets a password via meta, and specifies a fixed 'from' address. ```bash ngPost -c ~/.ngPost -m "password=qwerty42" -f ngPost@nowhere.com -i /tmp/file1 -i /tmp/folder2 ``` -------------------------------- ### Get backtrace of all threads Source: https://github.com/mbruel/ngpost/blob/master/parpar_abort_bt.txt After the crash, use 'thread apply all bt' to get a backtrace of all threads. This helps identify where the crash occurred, especially in multithreaded programs like ParPar. ```gdb thread apply all bt ``` -------------------------------- ### Build ngPost with qmake and make Source: https://github.com/mbruel/ngpost/blob/master/README.md Build steps: navigate to the src folder, run qmake to generate the Makefile, then make to compile. Requires build-essential, qt5-default, qt5-qmake, and libssl (v1.0.2 or v1.1). The executable ngPost is generated and can be copied to your PATH. ```bash qmake make ``` -------------------------------- ### Full manual server configuration Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/command-line.md Posts with full manual server settings: host, port, SSL, authentication, connections, groups, article size, and output NZB path. ```bash ngPost -t 1 -m "password=qwerty42" -h news.newshosting.com -P 443 -s -u user -p pass -n 30 \ -f ngPost@nowhere.com -g "alt.binaries.test,alt.binaries.test2" -a 64000 \ -i /tmp/folderToPost -o /tmp/folderToPost.nzb ``` -------------------------------- ### Creating an NntpFile instance and connecting signals Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-file.md Shows how to create an NntpFile object and connect its signals to PostingJob slots. The grpList may be a single random group. ```cpp NntpFile *nntpFile = new NntpFile(job, fileInfo, ++fileNum, _nbFiles, numPadding, grpList); // grpList may be a single random group connect(nntpFile, &NntpFile::allArticlesArePosted, job, &PostingJob::onNntpFilePosted, Qt::QueuedConnection); connect(nntpFile, &NntpFile::errorReadingFile, job, &PostingJob::onNntpErrorReading, Qt::QueuedConnection); _filesToUpload.enqueue(nntpFile); ``` -------------------------------- ### NgPost::ERROR_CODE enum definition Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/types.md Defines error codes used by NgPost, starting with NONE and COMPLETED_WITH_ERRORS. See errors.md for trigger conditions. ```cpp enum class ERROR_CODE : ushort {NONE=0, COMPLETED_WITH_ERRORS, ERR_CONF_FILE, ERR_WRONG_ARG, ERR_NO_INPUT, ERR_DEL_AUTO, ERR_AUTO_NO_COMPRESS, ERR_AUTO_INPUT, ERR_MONITOR_NO_COMPRESS, ERR_MONITOR_INPUT, ERR_NB_THREAD, ERR_ARTICLE_SIZE, ERR_NB_RETRY, ERR_PAR2_ARGS, ERR_SERVER_REGEX, ERR_SERVER_PORT, ERR_SERVER_CONS, ERR_INPUT_READ }; ``` -------------------------------- ### checkSupportSSL Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Logs SSL support info and returns whether Qt SSL is available. ```APIDOC ## checkSupportSSL ### Description Logs `PostingJob::sslSupportInfo()` and returns whether Qt SSL is available. ### Method checkSupportSSL ### Signature `bool checkSupportSSL();` ### Returns - **bool** - True if Qt SSL is available. ``` -------------------------------- ### Adding a Quick Post tab from a drop event Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/hmi.md Mirrors the drag-and-drop path in MainWindow::dropEvent. Creates a new Quick Post tab with dropped files, sets it, initializes it, and posts the files, building the PostingJob and handing it to NgPost. ```cpp PostingWidget *tab = _hmi->addNewQuickTab(-1, droppedFiles); // -1 = new tab _hmi->setTab(tab); tab->init(); tab->postFiles(/*updateMainParams=*/true); // builds the PostingJob and hands it to NgPost ``` -------------------------------- ### Consuming an article from a connection (NntpConnection::_sendNextArticle) Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/poster.md Shows how a connection retrieves the next article from the poster. If an article is available, it sets the posting state to SENDING_ARTICLE and writes the POST command; otherwise it sets NO_MORE_FILES and closes the connection. ```cpp _currentArticle = _poster->getNextArticle(_logPrefix); if (_currentArticle) { _postingState = PostingState::SENDING_ARTICLE; _socket->write(Nntp::POST); } else { _postingState = PostingState::NO_MORE_FILES; _closeConnection(); } ``` -------------------------------- ### NntpConnection public slots declaration Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-connection.md Declares the public slots for managing the connection lifecycle, including start, kill, connected, encrypted, disconnected, ready read, SSL errors, and socket errors. These slots are implemented in src/NntpConnection.cpp. ```cpp public slots: void onStartConnection(); void onKillConnection(); void onConnected(); void onEncrypted(); void onDisconnected(); void onReadyRead(); void onSslErrors(const QList &errors); void onErrors(QAbstractSocket::SocketError); ``` -------------------------------- ### nzbPath (with monitorFolder) Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Creates a subdirectory under the NZB path for the given monitor folder and returns the path to the NZB within it. ```APIDOC ## nzbPath (with monitorFolder) ### Description Creates the directory `_nzbPath/` and returns the path to the NZB file inside it. ### Method nzbPath ### Signature `QString nzbPath(const QString &monitorFolder);` ### Parameters - **monitorFolder** (QString) - Required - The name of the monitor folder subdirectory. ### Returns - **QString** - The path to the NZB file in the created subdirectory. ``` -------------------------------- ### CmdOrGuiApp class declaration (src/utils/CmdOrGuiApp.h) Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Declares the CmdOrGuiApp base class. With __USE_HMI__, it builds a QApplication and MainWindow when launched without arguments (_mode = HMI), otherwise a console QCoreApplication. escapeXML and xml2txt map & < > " ' to/from XML entities. ```cpp class CmdOrGuiApp { protected: enum class AppMode : bool {CMD = 0, HMI = 1}; QCoreApplication *_app; #ifdef __USE_HMI__ const AppMode _mode; MainWindow *_hmi; #endif public: explicit CmdOrGuiApp(int &argc, char *argv[]); virtual ~CmdOrGuiApp(); virtual const char *appName() = 0; virtual bool parseCommandLine(int argc, char *argv[]) = 0; virtual void checkForNewVersion(); int startEventLoop(); inline bool useHMI() const; inline static QString escapeXML(const char *str); inline static QString escapeXML(const QString &str); inline static QString xml2txt(const char *str); inline static QString xml2txt(const QString &str); }; ``` -------------------------------- ### FoldersMonitorForNewFiles class definition with FolderScan helper Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/support-classes.md Defines the FolderScan non-copyable state container and the FoldersMonitorForNewFiles QObject class. The monitor runs in its own QThread, uses QFileSystemWatcher, and emits newFileToProcess(QFileInfo) when a new file is fully written. Includes methods for adding folders, stopping listening, and handling directory changes. ```cpp using AtomicBool = QAtomicInteger; // 16 bit only (faster than using 8 bit variable...) using PathSet = QSet; class FolderScan { public: const QString path; QDateTime lastUpdate; PathSet previousScan; FolderScan(const QString &folderPath); FolderScan(const FolderScan &other) = delete; FolderScan &operator=(const FolderScan &) = delete; ~FolderScan() = default; }; class FoldersMonitorForNewFiles : public QObject { Q_OBJECT friend class NgPost; private: QFileSystemWatcher _monitor; QMap _folders; AtomicBool _stopListening; static ulong sMSleep; // default 1000 ms; changed by MONITOR_SEC_DELAY_SCAN (1..120s) public: FoldersMonitorForNewFiles(const QString &folderPath, QObject *parent = nullptr); ~FoldersMonitorForNewFiles(); bool addFolder(const QString &folderPath); void stopListening(); signals: void newFileToProcess(const QFileInfo &fileInfo); public slots: void onDirectoryChanged(const QString &folderPath); private: qint64 _pathSize(QFileInfo &fileInfo) const; qint64 _dirSize(const QString &path) const; }; ``` -------------------------------- ### Create PostingJob like NgPost::_post Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/postingjob.md Builds a PostingJob instance with the same parameters as NgPost::_post for a command-line quick post. Requires an app instance and a list of files to post. ```cpp PostingJob *job = new PostingJob(app, "/nzb/myPost.nzb", {QFileInfo("/tmp/big.iso")}, /*postWidget=*/nullptr, app->getPostingGroups(), app->from(), app->_obfuscateArticles, app->_obfuscateFileName, app->_tmpPath, app->_rarPath, app->_rarArgs, app->_rarSize, app->_useRarMax, app->_par2Pct, app->_doCompress, app->_doPar2, app->_rarName, app->_rarPass, app->_keepRar, app->_delAuto, /*overwriteNzb=*/false); app->startPostingJob(job); ``` -------------------------------- ### ngPost command line syntax and options Source: https://github.com/mbruel/ngpost/blob/master/README.md Full command line syntax and all options for ngPost. Use with -i, --auto, or --monitor. Options cover help, version, configuration, progress display, debug, language, NZB checking, quiet mode, automated posting, quick posting, compression/par2, and NNTP server settings. ```text Syntax: ngPost (options)* (-i | --auto | --monitor )+ --help : Help: display syntax -v or --version : app version -c or --conf : use configuration file (if not provided, we try to load $HOME/.ngPost) --disp_progress : display cmd progressbar: NONE (default), BAR or FILES -d or --debug : display extra information --fulldebug : display full debug information -l or --lang : application language --check : check nzb file (if articles are available on Usenet) cf https://github.com/mbruel/nzbCheck -q or --quiet : quiet mode (no output on stdout) // automated posting (scanning and/or monitoring) --auto : parse directory and post every file/folder separately. You must use --compress, should add --gen_par2, --gen_name and --gen_pass --monitor : monitor directory and post every new file/folder. You must use --compress, should add --gen_par2, --gen_name and --gen_pass --rm_posted : delete file/folder once posted. You must use --auto or --monitor with this option. // quick posting (several files/folders) -i or --input : input file to upload (single file or directory), you can use it multiple times -o or --output : output file path (nzb) -x or --obfuscate : obfuscate the subjects of the articles (CAREFUL you won't find your post if you lose the nzb file) -g or --groups : newsgroups where to post the files (coma separated without space) -m or --meta : extra meta data in header (typically "password=qwerty42") -f or --from : poster email (random one if not provided) -a or --article_size: article size (default one: 716800) -z or --msg_id : msg id signature, after the @ (default one: ngPost) -r or --retry : number of time we retry to an Article that failed (default: 5) -t or --thread : number of Threads (the connections will be distributed amongs them) --gen_from : generate a new random email for each Post (--auto or --monitor) // for compression and par2 support --tmp_dir : temporary folder where the compressed files and par2 will be stored --rar_path : RAR absolute file path (external application) --rar_size : size in MB of the RAR volumes (0 by default meaning NO split) --rar_max : maximum number of archive volumes --par2_pct : par2 redundancy percentage (0 by default meaning NO par2 generation) --par2_path : par2 absolute file path (in case of self compilation of ngPost) --auto_compress : compress inputs with random name and password and generate par2 (equivalent of --compress --gen_name --gen_pass --gen_par2) --compress : compress inputs using RAR or 7z --gen_par2 : generate par2 (to be used with --compress) --rar_name : provide the RAR file name (to be used with --compress) --rar_pass : provide the RAR password (to be used with --compress) --gen_name : generate random RAR name (to be used with --compress) --gen_pass : generate random RAR password (to be used with --compress) --length_name : length of the random RAR name (to be used with --gen_name), default: 17 --length_pass : length of the random RAR password (to be used with --gen_pass), default: 13 --rar_no_root_folder: Remove root (parent) folder when compressing Folders using RAR // you can provide servers in one string using -S and/or split the parameters for ONE SINGLE server (this will overwrite the configuration file) -S or --server : NNTP server following the format (:@@@)?:::(no)?ssl -h or --host : NNTP server hostname (or IP) -P or --port : NNTP server port -s or --ssl : use SSL -u or --user : NNTP server username -p or --pass : NNTP server password -n or --connection : number of NNTP connections ``` -------------------------------- ### enableAutoPacking Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Enables or disables --pack keywords; when disabled, forces compress, genName, genPass, and par2. ```APIDOC ## enableAutoPacking ### Description Enables or disables `--pack` keywords. When `enable` is false, forces compress, genName, genPass, and par2. ### Method enableAutoPacking ### Signature `inline void enableAutoPacking(bool enable = true);` ### Parameters - **enable** (bool) - Optional - True to enable auto-packing, false to force compress+genName+genPass+par2 (default true). ``` -------------------------------- ### Server string form (repeatable, replaces config servers) Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/command-line.md Uses a server string to specify server details; this form is repeatable and replaces servers from the configuration file. ```bash ngPost -S "user:pass@@@news.example.com:563:15:ssl" -i /tmp/file ``` -------------------------------- ### sslSupportInfo Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-connection.md Returns SSL support information including build and system library versions. ```APIDOC ## sslSupportInfo ### Description Returns SSL support information including build and system library versions. ### Method static QString sslSupportInfo(); ### Returns - **QString** - SSL support information string. ``` -------------------------------- ### ngPost configuration for 7zip (RAR_PATH and RAR_EXTRA) Source: https://github.com/mbruel/ngpost/blob/master/README.md Configuration snippet showing how to set RAR_PATH to /usr/bin/7z and RAR_EXTRA options for 7zip support. The file must exist and be executable. The first 'a' and '-idp' are added automatically, and '-hp' is added if a password is used, '-v42m' if --rar_size is used. ```ini ## RAR or 7zip absolute file path (external application) ## /!\ The file MUST EXIST and BE EXECUTABLE /!\ ## this is set for Linux environment, Windows users MUST change it #RAR_PATH = /usr/bin/rar RAR_PATH = /usr/bin/7z ## RAR EXTRA options (the first 'a' and '-idp' will be added automatically) ## -hp will be added if you use a password with --gen_pass, --rar_pass or using the HMI ## -v42m will be added with --rar_size or using the HMI ``` -------------------------------- ### FileUploader class declaration Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/support-classes.md Declares the FileUploader QObject class with a constructor taking a QNetworkAccessManager reference and NZB file path, a startUpload method, signals for lifecycle and logging, and a private slot for upload completion. ```cpp class FileUploader : public QObject { Q_OBJECT private: QNetworkAccessManager &_netMgr; QNetworkReply *_reply; QFileInfo _nzbFilePath; QFile _nzbFile; QUrl _nzbUrl; public: FileUploader(QNetworkAccessManager &netMgr, const QString &nzbFilePath); ~FileUploader(); void startUpload(const QUrl &serverUrl); signals: void readyToDie(); void error(const QString &msg); void log(const QString &msg, bool newline = true); private slots: void onUploadFinished(); private: inline QString url() const; }; ``` -------------------------------- ### Static retry budget initialization Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-article.md Initializes the static retry budget to 5, which can be changed via the --retry command-line option or the retry configuration. Located in src/nntp/NntpArticle.cpp at line 28. ```cpp ushort NntpArticle::sNbMaxTrySending = 5; // src/nntp/NntpArticle.cpp:28 ``` -------------------------------- ### parseDefaultConfig Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Loads the default configuration file. ```APIDOC ## parseDefaultConfig ### Description Loads the default configuration file. ### Method parseDefaultConfig ### Signature `QString parseDefaultConfig();` ### Returns - **QString** - The result of loading the default config file. ``` -------------------------------- ### doNzbPostCMD Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Runs the NZB_UPLOAD_URL (via FileUploader) and then each NZB_POST_CMD for the given posting job. ```APIDOC ## doNzbPostCMD ### Description Runs the `NZB_UPLOAD_URL` (via `FileUploader`) and then each `NZB_POST_CMD` for the given posting job. ### Method doNzbPostCMD ### Signature `void doNzbPostCMD(PostingJob *job);` ### Parameters - **job** (PostingJob*) - Required - The posting job for which to run the commands. ``` -------------------------------- ### Inspecting a file with failed parts Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-file.md Shows how to check for failed articles and log a warning with the file's stats and missing article count. ```cpp if (nntpFile->hasFailedArticles()) { qWarning().noquote() << nntpFile->stats() << "(fInProgress" << nntpFile->missingArticles() << ")"; } ``` -------------------------------- ### MainWindow class declaration (C++ header) Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/hmi.md The MainWindow class is the main window in HMI mode, created by CmdOrGuiApp when launched without arguments. It declares public methods for initialization, progress updates, tab management, logging, and drag-and-drop handling, along with a public slot for setting the progress bar range. ```cpp class MainWindow : public QMainWindow { Q_OBJECT private: enum class STATE {IDLE, POSTING, STOPPING}; static const bool sDefaultServerSSL = true; static const int sDefaultConnections = 5; static const int sDefaultServerPort = 563; static const int sDeleteColumnWidth = 30; public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow() override; void init(NgPost *ngPost); void updateProgressBar(uint nbArticlesTotal, uint nbArticlesUploaded, const QString &avgSpeed = "0 B/s" #ifdef __COMPUTE_IMMEDIATE_SPEED__ , const QString &immediateSpeed = "0 B/s" #endif ); void updateServers(); void updateParams(); void updateAutoPostingParams(); QString fixedArchivePassword() const; PostingWidget *addNewQuickTab(int lastTabIdx, const QFileInfoList &files = QFileInfoList()); void setTab(QWidget *postWidget); void clearJobTab(QWidget *postWidget); void updateJobTab(QWidget *postWidget, const QColor &color, const QIcon &icon, const QString &tooltip = ""); void setJobLabel(int jobNumber); void log(const QString &aMsg, bool newline = true) const; void logError(const QString &error) const; bool useFixedPassword() const; bool hasAutoCompress() const; bool hasFinishedPosts() const; inline AutoPostWidget *autoWidget() const; void closeTab(PostingWidget *postWidget); void setPauseIcon(bool pause); protected: bool eventFilter(QObject *obj, QEvent *event) override; void dragEnterEvent(QDragEnterEvent *e) override; void dropEvent(QDropEvent *e) override; void closeEvent(QCloseEvent *event) override; void changeEvent(QEvent* event) override; public slots: void onSetProgressBarRange(int nbArticles); }; ``` -------------------------------- ### Pause and resume NntpConnection set (PostingJob::pause/resume) Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-connection.md Shows how to pause a connection set by emitting killConnection() on each connection, which closes the socket and resets the current article's UUID. Later, startConnection() reconnects and resumes posting. ```cpp for (NntpConnection *con : job->_nntpConnections) emit con->killConnection(); // socket closed, current article keeps its UUID reset // ... later ... for (NntpConnection *con : job->_nntpConnections) emit con->startConnection(); // reconnect and resume posting ``` -------------------------------- ### Build article body after reading chunk Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-article.md Shows how to build the article body right after reading a chunk of the source file, as done in ArticleBuilder::getNextArticle. Calls yEncBody on the article with the buffer, which applies yEnc encoding, =ybegin/=yend framing, and CRLF terminator. ```cpp NntpArticle *article = job->_readNextArticleIntoBufferPtr(threadName, &buffer); if (article) article->yEncBody(buffer); // yEnc + =ybegin/=yend framing + CRLF terminator ``` -------------------------------- ### Writing NZB entry and scheduling deletion Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-file.md Shows how to write the file entry to the NZB after all parts are processed, remove the file from the in-progress set, and schedule deletion. ```cpp // inside PostingJob::onNntpFilePosted — same call the source makes nntpFile->writeToNZB(job->_nzbStream, QString::fromStdString(job->_from)); job->_filesInProgress.remove(nntpFile); emit nntpFile->scheduleDeletion(); ``` -------------------------------- ### Post with compression, obfuscation, and par2 Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/command-line.md Posts files with compression, generated names, generated passwords, and par2 files. ```bash ngPost -i /tmp/file1 -i /tmp/folder1 -o /nzb/myPost.nzb --compress --gen_name --gen_pass --gen_par2 ``` -------------------------------- ### write(QByteArray) Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-connection.md Writes a QByteArray buffer to the socket. ```APIDOC ## write(QByteArray) ### Description Writes a QByteArray buffer to the socket. Used by NntpArticle::write. ### Method inline void write(const QByteArray & aBuffer); ### Parameters - **aBuffer** (QByteArray) - Required - The buffer to write. ### Returns - **void** ``` -------------------------------- ### Monitor folders with auto-pack and deletion Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/command-line.md Monitors two folders, automatically compresses, removes posted files, and displays progress per file. ```bash ngPost --monitor /data/folder1 --monitor /data/folder2 --auto_compress --rm_posted --disp_progress files ``` -------------------------------- ### SignedListWidget class declaration Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/hmi.md QListWidget subclass for file lists. Provides methods to set signature, add paths, and remove items. Signals rightClick() and empty() are emitted for UI actions; clear2() and onDeleteSelectedItems() are public slots for cleanup. ```cpp class SignedListWidget : public QListWidget { Q_OBJECT public: SignedListWidget(QWidget *parent = nullptr); void setSignature(const QString &str); void addPath(const QString &path, bool isDir = false); bool addPathIfNotInList(const QString &path, int lastIndexToCheck, bool isDir = false); void removeItemWidget2(QListWidgetItem *item); signals: void rightClick(); void empty(); public slots: void clear2(); void onDeleteSelectedItems(); }; ``` -------------------------------- ### checkForNewVersion / onCheckForNewVersion Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Fetches the latest version info from GitHub and warns if a newer version is available. ```APIDOC ## checkForNewVersion / onCheckForNewVersion ### Description Fetches `https://raw.githubusercontent.com/mbruel/ngPost/master/src/ngPost.pri` and warns when `APP_VERSION` is newer. ### Method checkForNewVersion / onCheckForNewVersion ### Signatures - `void checkForNewVersion() override;` - `void onCheckForNewVersion();` ``` -------------------------------- ### PostingJob::PostingJob Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/postingjob.md Creates a PostingJob instance that manages the posting of files to Usenet. It accepts configuration for compression, par2, obfuscation, and output paths, and wires lifecycle signals to the NgPost application and PostingWidget. ```APIDOC ## PostingJob::PostingJob ### Description Creates a PostingJob instance that manages the posting of files to Usenet. It accepts configuration for compression, par2, obfuscation, and output paths, and wires lifecycle signals to the NgPost application and PostingWidget. ### Constructor ```cpp PostingJob(NgPost *ngPost, const QString &nzbFilePath, const QFileInfoList &files, PostingWidget *postWidget, const QList &grpList, const std::string &from, bool obfuscateArticles, bool obfuscateFileName, const QString &tmpPath, const QString &rarPath, const QString &rarArgs, uint rarSize, bool useRarMax, uint par2Pct, bool doCompress, bool doPar2, const QString &rarName, const QString &rarPass, bool keepRar = false, bool delFilesAfterPost = false, bool overwriteNzb = true, QObject *parent = nullptr); ``` ### Parameters #### Required Parameters - **ngPost** (`NgPost *`) - Required - application handle for config, logging - **nzbFilePath** (`const QString &`) - Required - output `.nzb` path (may get `_N` suffix if `overwriteNzb=false` and it exists) - **files** (`const QFileInfoList &`) - Required - files/folders to post (`QList`) - **postWidget** (`PostingWidget *`) - Required - HMI tab; `nullptr` in command-line mode - **grpList** (`const QList &`) - Required - newsgroups for the post - **from** (`const std::string &`) - Required - poster address used in the nzb and article `From:` - **obfuscateArticles** (`bool`) - Required - hide subjects; also passes `nullptr` as `_from` to articles - **obfuscateFileName** (`bool`) - Required - rename originals to random names before compressing - **tmpPath** (`const QString &`) - Required - where the archive folder/par2 is produced - **rarPath** (`const QString &`) - Required - RAR or 7z executable - **rarArgs** (`const QString &`) - Required - extra args (`RAR_EXTRA`/`PAR2_ARGS` style); empty → built-in defaults - **rarSize** (`uint`) - Required - volume size MB, `0` = no split - **useRarMax** (`bool`) - Required - auto-reduce volume size so `nbVolumes <= rarMax` - **par2Pct** (`uint`) - Required - redundancy percent; `0` + no `PAR2_ARGS` means no par2 - **doCompress** (`bool`) - Required - run the external compressor - **doPar2** (`bool`) - Required - run the par2 generator - **rarName** (`const QString &`) - Required - archive name (without extension) - **rarPass** (`const QString &`) - Required - archive password #### Optional Parameters - **keepRar** (`bool`) - Optional, default `false` - keep `_compressDir` after success - **delFilesAfterPost** (`bool`) - Optional, default `false` - delete original files after posting (`--rm_posted`) - **overwriteNzb** (`bool`) - Optional, default `true` - deduplicate existing nzb path - **parent** (`QObject *`) - Optional, default `nullptr` - Qt parent ### Remarks The constructor wires the job lifecycle signals: `postingStarted → NgPost::onPostingJobStarted`, `packingDone → NgPost::onPackingDone`, `postingFinished`/`noMoreConnection → NgPost::onPostingJobFinished` (and, in HMI builds, the `PostingWidget` slots). ``` -------------------------------- ### nzbPath (inline) Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Returns the full path to the NZB file, combining the NZB path and name. ```APIDOC ## nzbPath (inline) ### Description Returns the full path to the NZB file, constructed as `_nzbPath + "/" + _nzbName` (using backslash on Windows). ### Method nzbPath ### Signature `inline QString nzbPath() const;` ### Returns - **QString** - The full path to the NZB file. ``` -------------------------------- ### NzbCheck constructor and destructor Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nzbcheck.md Default constructor and destructor. No parameters. The progress-bar timer uses a refresh rate of 200 ms and a progress bar width of 50. ```cpp NzbCheck(); ~NzbCheck(); ``` -------------------------------- ### checkPost() method declarations Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nzbcheck.md Sums nbCons over servers with nzbCheck == true, caps at the number of articles, and creates NntpCheckCon objects. The inline overload sets the server list before calling checkPost(). ```cpp void checkPost(); inline void checkPost(const QList &nntpServers); // sets servers then checkPost() ``` -------------------------------- ### Check SSL support (NgPost::checkSupportSSL) Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-connection.md Checks if NntpConnection supports SSL. If not, logs the SSL support info and returns 1. ```cpp if (!NntpConnection::supportsSsl()) { qWarning().noquote() << NntpConnection::sslSupportInfo(); return 1; } ``` -------------------------------- ### CLI invocation with config file and error check Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Runs ngPost with a config file and posting options, then prints the exit code. Exit code 0 indicates success, nonzero indicates an ERR_* error (see errors.md). ```bash ngPost -c ~/.ngPost -m "password=qwerty42" -i /tmp/file1 -i /tmp/folder2 echo "ngPost exit code: $?" # 0 on success, nonzero on ERR_* (see errors.md) ``` -------------------------------- ### parseNzb() method declarations Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nzbcheck.md Parses the NZB XML with QXmlStreamReader. The inline overload sets _nzbPath before calling parseNzb(). Returns the number of articles found, -1 if the file cannot be opened, or -2 on XML parse error. ```cpp int parseNzb(); // uses the path stored in _nzbPath inline int parseNzb(const QString &nzbPath); // sets _nzbPath then parseNzb() ``` -------------------------------- ### addMonitoringFolder Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Adds a folder to the running monitor. ```APIDOC ## addMonitoringFolder ### Description Adds a folder to the running monitor. ### Method addMonitoringFolder ### Signature `void addMonitoringFolder(const QString &dirPath);` ### Parameters - **dirPath** (QString) - Required - The path of the folder to add. ``` -------------------------------- ### ngPost CLI syntax Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/command-line.md The full command-line syntax for ngPost, printed by `ngPost --help`. It shows the general form with options and one of the required input modes: `-i`, `--auto`, or `--monitor`. ```text Syntax: ngPost (options)* (-i | --auto | --monitor )+ ``` -------------------------------- ### NntpConnection constructor and destructor declarations Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-connection.md Declares the constructor taking NgPost pointer, connection id, and server parameters, and the destructor. ```cpp explicit NntpConnection(NgPost *ngPost, int id, const NntpServerParams &srvParams); ~NntpConnection(); ``` -------------------------------- ### supportsSsl Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/nntp-connection.md Checks if SSL is supported. ```APIDOC ## supportsSsl ### Description Checks if SSL is supported by calling QSslSocket::supportsSsl(). ### Method static bool supportsSsl(); ### Returns - **bool** - True if SSL is supported, false otherwise. ``` -------------------------------- ### saveConfig Source: https://github.com/mbruel/ngpost/blob/master/_autodocs/api-reference/ngpost.md Rewrites the default config file from memory. ```APIDOC ## saveConfig ### Description Rewrites the default config file from memory. ### Method saveConfig ### Signature `void saveConfig();` ```