[pan2] fixed queue behaviour of stopped tasks on restart



commit 88fff93f5ddb108d00634ea1500876b7ffc6fa79
Author: Heinrich MÃller <henmull src gnome org>
Date:   Wed May 30 23:34:10 2012 +0200

    fixed queue behaviour of stopped tasks on restart

 pan/gui/task-pane.cc     |    4 ++--
 pan/tasks/nzb.cc         |    5 +++--
 pan/tasks/queue.cc       |   14 ++++++--------
 pan/tasks/task-article.h |    4 ++--
 4 files changed, 13 insertions(+), 14 deletions(-)
---
diff --git a/pan/gui/task-pane.cc b/pan/gui/task-pane.cc
index 454f56c..11cdfcc 100644
--- a/pan/gui/task-pane.cc
+++ b/pan/gui/task-pane.cc
@@ -153,9 +153,9 @@ TaskPane:: on_tooltip_query(GtkWidget  *widget,
     date = date_maker.get_date_string (ta->get_article().time_posted);
     g_snprintf(buffer,sizeof(buffer),
                _("\n<u>Download</u>\n\n<i>Subject:</i> <b>\"%s\"</b>\n<i>From:</i> <b>%s</b>\n<i>Date:</i> <b>%s</b>\n"
-                 "<i>Groups:</i> <b>%s</b>\n<i>Save Path:</i> <b>%s</b>\n"),
+                 "<i>Groups:</i> <b>%s</b>\n<i>Save Path:</i> <b>%s</b>\nPaused: %d"),
                a.subject.to_string().c_str(), escaped(a.author.to_string()).c_str(), date ? date : _("unknown"),
-               ta->get_groups().c_str(), ta->get_save_path().to_string().c_str());
+               ta->get_groups().c_str(), ta->get_save_path().to_string().c_str(), ta->start_paused());
   }
 
   task_found = tu || ta;
diff --git a/pan/tasks/nzb.cc b/pan/tasks/nzb.cc
index 5975bb7..efb791c 100644
--- a/pan/tasks/nzb.cc
+++ b/pan/tasks/nzb.cc
@@ -170,7 +170,8 @@ namespace
       }
       const StringView p (mc.path.empty() ? mc.fallback_path : StringView(mc.path));
       TaskArticle* a = new TaskArticle (mc.ranks, mc.gs, mc.a, mc.cache, mc.read, 0, TaskArticle::DECODE, p);
-      a->set_paused(mc.paused == "1");
+      if (mc.paused == "1")
+        a->set_start_paused(true);
       mc.tasks.push_back (a);
     }
 
@@ -291,7 +292,7 @@ NZB :: nzb_to_xml (std::ostream             & out,
         out << "</path>\n";
       }
       out << indent(depth) <<"<paused>";
-      out << task->get_paused() << "</paused>\n";
+      out << (task->start_paused()) << "</paused>\n";
 
       // what groups was this crossposted in?
       quarks_t groups;
diff --git a/pan/tasks/queue.cc b/pan/tasks/queue.cc
index 2d89221..cab893f 100644
--- a/pan/tasks/queue.cc
+++ b/pan/tasks/queue.cc
@@ -323,7 +323,6 @@ Queue :: process_task (Task * task)
 //    TaskArticle* t2 = dynamic_cast<TaskArticle*>(task);
 //    if (t2)
 //      give_task_a_download_slot(t2);
-
   }
   else if (state._work == Task::NEED_DECODER)
   {
@@ -546,11 +545,11 @@ Queue :: stop_tasks (const tasks_t& tasks)
     if (_tasks.index_of (task) != -1) {
       _stopped.insert (task);
       process_task (task);
+
       TaskArticle* ta = dynamic_cast<TaskArticle*>(*it);
       if (ta)
       {
-        Task* t = (Task*)*it;
-        t->get_state().set_paused();
+        ta->set_start_paused(true);
       }
     }
   }
@@ -564,11 +563,11 @@ Queue :: restart_tasks (const tasks_t& tasks)
     if (_tasks.index_of(task) != -1) {
       _stopped.erase (task);
       process_task (task);
+
       TaskArticle* ta = dynamic_cast<TaskArticle*>(*it);
       if (ta)
       {
-        Task* t = (Task*)*it;
-        t->get_state().set_working();
+        ta->set_start_paused(false);
       }
     }
   }
@@ -585,14 +584,13 @@ Queue :: add_task (Task * task, AddMode mode)
 void
 Queue :: add_tasks (const tasks_t& tasks, AddMode mode)
 {
-  tasks_t paused_tasks;
+
   foreach_const (tasks_t, tasks, it) {
     TaskArticle * ta (dynamic_cast<TaskArticle*>(*it));
     if (ta)
     {
       _mids.insert (ta->get_article().message_id);
-      const bool paused (ta->get_paused());
-      if (paused)
+      if (ta->start_paused())
       {
         _stopped.insert(*it);
       }
diff --git a/pan/tasks/task-article.h b/pan/tasks/task-article.h
index 7365f8c..b706d6f 100644
--- a/pan/tasks/task-article.h
+++ b/pan/tasks/task-article.h
@@ -72,8 +72,8 @@ namespace pan
       void  set_save_path (const Quark& q) { _save_path = q;}
       const Article& get_article () const { return _article; }
       const std::string& get_groups () const { return _groups; }
-      const bool get_paused () const { return _paused; }
-      void set_paused (bool val) { _paused = val; }
+      const bool start_paused () const { return _paused; }
+      void set_start_paused (bool val) { _paused = val; }
 
     public: // Task subclass
       unsigned long get_bytes_remaining () const;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]