[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pan-devel] [PATCH] Downloading headers from the command line
From: |
Eric Lauriault |
Subject: |
[Pan-devel] [PATCH] Downloading headers from the command line |
Date: |
Sun, 25 Mar 2007 23:34:41 -0400 |
User-agent: |
Thunderbird 1.5.0.10 (X11/20070308) |
Hi guys,
I've attached a small patch to download headers from the command line.
I've wanted to do this to download headers for a few groups
automatically without a gui while I'm away using crond. It's pretty much
the same idea as using pan as an nzb reader. The problem I'm
experiencing is that when the queue empties, the process just hangs
around until it gets receives a signal. The same behavior can be
observed while downloading using an nzb file from the command line. Is
this expected?
Eric
--- trunk/pan/gui/pan.cc 2007-03-25 23:14:30.000000000 -0400
+++ trunk-modified/pan/gui/pan.cc 2007-03-25 23:02:47.000000000 -0400
@@ -29,6 +29,7 @@
#include <pan/general/file-util.h>
#include <pan/tasks/socket-impl-gio.h>
#include <pan/tasks/task-groups.h>
+#include <pan/tasks/task-xover.h>
#include <pan/tasks/nzb.h>
#include <pan/data-impl/data-impl.h>
#include <pan/icons/pan-pixbufs.h>
@@ -167,6 +168,7 @@
"URL Options\n"
" news:message-id Show the specified article.\n"
" news:group.name Show the specified newsgroup.\n"
+" headers:group.name Download new headers for the specified
newsgroup.\n"
" --no-gui On news:message-id, dump the article to stdout.\n"
"\n"
"NZB Batch Options\n"
@@ -189,6 +191,7 @@
bool gui(true), nzb(false);
std::string url;
+ std::string group;
std::string nzb_output_path;
typedef std::vector<std::string> strings_t;
strings_t nzb_files;
@@ -196,6 +199,8 @@
for (int i=1; i<argc; ++i)
{
const char * tok (argv[i]);
+ if (!memcmp(tok,"headers:", 8))
+ group = tok+8;
if (!memcmp(tok,"news:", 5))
url = tok;
else if (!strcmp(tok,"--no-gui") || !strcmp(tok,"--nogui"))
@@ -248,20 +253,30 @@
Queue queue (data, data, &socket_creator,
prefs.get_flag("work-online",true));
g_timeout_add (5000, queue_upkeep_timer_cb, &queue);
- if (nzb)
+ if (nzb || ! group.empty())
{
+
+ if (! group.empty()){
+ std::cerr << group << "\n";
+ Task* header_task;
+ const Quark* group_q = new Quark(group);
+ header_task = new TaskXOver ( data, *group_q, TaskXOver::NEW);
+ queue.add_task (header_task, Queue::BOTTOM);
+ delete group_q;
+ }else{
+
// if no save path was specified, either prompt for one or
// use the user's home directory as a fallback.
if (nzb_output_path.empty() && gui)
nzb_output_path = GUI::prompt_user_for_save_path (NULL, prefs);
if (nzb_output_path.empty()) // user pressed `cancel' when prompted
return 0;
-
// load the nzb files...
std::vector<Task*> tasks;
foreach_const (strings_t, nzb_files, it)
NZB :: tasks_from_nzb_file (*it, nzb_output_path, cache, data, data,
data, tasks);
queue.add_tasks (tasks, Queue::BOTTOM);
+ }
// don't open the full-blown Pan, just act as a nzb client,
// with a gui or without.
@@ -276,6 +291,7 @@
}
register_shutdown_signals ();
mainloop ();
+ return 0;
}
else
{
- [Pan-devel] [PATCH] Downloading headers from the command line,
Eric Lauriault <=