[pan2/refreshxovers] https://bugzilla.gnome.org/show_bug.cgi?id=677741
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/refreshxovers] https://bugzilla.gnome.org/show_bug.cgi?id=677741
- Date: Sun, 10 Jun 2012 16:11:42 +0000 (UTC)
commit 37cf148a8fa6db0082d67626870419699ba9fde6
Author: Heinrich MÃller <henmull src gnome org>
Date: Sat Jun 9 17:31:18 2012 +0200
https://bugzilla.gnome.org/show_bug.cgi?id=677741
pan/data-impl/data-impl.cc | 5 ++-
pan/data-impl/server.cc | 1 -
pan/data/data.h | 3 +-
pan/gui/actions.cc | 9 +++++-
pan/gui/group-pane.cc | 18 ++++++++---
pan/gui/gui.cc | 9 ++++++
pan/gui/gui.h | 1 +
pan/gui/pan-ui.h | 1 +
pan/gui/pan.ui.h | 3 ++
pan/gui/pan.ui.ssl.h | 3 ++
pan/icons/Makefile.am | 37 ++++++++++++-----------
pan/tasks/nntp.cc | 5 +--
pan/tasks/task-xover.cc | 1 -
pan/tasks/task-xoverinfo.cc | 66 +++++++++++++++++++++++++++++++++---------
pan/tasks/task-xoverinfo.h | 5 +--
15 files changed, 118 insertions(+), 49 deletions(-)
---
diff --git a/pan/data-impl/data-impl.cc b/pan/data-impl/data-impl.cc
index e204f5c..b2eca15 100644
--- a/pan/data-impl/data-impl.cc
+++ b/pan/data-impl/data-impl.cc
@@ -147,7 +147,6 @@ DataImpl :: password_encrypt (const PasswordData& pw)
}
-// TODO use gnome_keyring_memory_new etc
GnomeKeyringResult
DataImpl :: password_decrypt (PasswordData& pw) const
{
@@ -167,6 +166,10 @@ DataImpl :: password_decrypt (PasswordData& pw) const
pw.pw = gnome_keyring_memory_strdup(pwd);
gnome_keyring_free_password(pwd);
}
+ if (!pw.pw) // empty on fail of gkr
+ {
+ pw.pw = "";
+ }
return (pw.pw ? GNOME_KEYRING_RESULT_OK : GNOME_KEYRING_RESULT_DENIED) ;
}
diff --git a/pan/data-impl/server.cc b/pan/data-impl/server.cc
index 40f27c0..0956383 100644
--- a/pan/data-impl/server.cc
+++ b/pan/data-impl/server.cc
@@ -257,7 +257,6 @@ DataImpl :: get_server_auth (const Quark & server,
break;
case GNOME_KEYRING_RESULT_OK:
-// setme_password.assign(pw.pw.str, pw.pw.len);
setme_password = pw.pw;
s->gkr_pw = pw.pw;
break;
diff --git a/pan/data/data.h b/pan/data/data.h
index e76a26a..9ea72a9 100644
--- a/pan/data/data.h
+++ b/pan/data/data.h
@@ -178,7 +178,6 @@ namespace pan
{
Quark server;
StringView user;
-// StringView pw;
gchar* pw;
};
@@ -316,6 +315,8 @@ namespace pan
void fire_group_read (const Quark&);
+ public:
+
void fire_group_counts (const Quark&,
unsigned long unread,
unsigned long total);
diff --git a/pan/gui/actions.cc b/pan/gui/actions.cc
index 1419708..f6fa945 100644
--- a/pan/gui/actions.cc
+++ b/pan/gui/actions.cc
@@ -74,7 +74,8 @@ namespace pan
{ icon_score, "ICON_SCORE" },
{ icon_search_pulldown, "ICON_SEARCH_PULLDOWN" },
{ icon_red_flag, "ICON_FLAGGED"},
- { icon_get_flagged, "ICON_GET_FLAGGED" }
+ { icon_get_flagged, "ICON_GET_FLAGGED" },
+ { icon_refresh, "ICON_REFRESH" }
};
void
@@ -107,6 +108,7 @@ namespace pan
void do_clear_selected_groups (GtkAction*) { pan_ui->do_clear_selected_groups(); }
void do_xover_selected_groups (GtkAction*) { pan_ui->do_xover_selected_groups(); }
void do_xover_subscribed_groups (GtkAction*) { pan_ui->do_xover_subscribed_groups(); }
+ void do_xover_count_subscribed_groups(GtkAction*) { pan_ui->do_xover_count_subscribed_groups(); }
void do_download_headers (GtkAction*) { pan_ui->do_download_headers(); }
void do_refresh_groups (GtkAction*) { pan_ui->do_refresh_groups(); }
void do_subscribe_selected_groups (GtkAction*) { pan_ui->do_subscribe_selected_groups(); }
@@ -302,6 +304,11 @@ namespace pan
N_("Delete Selected Groups' Articles"),
G_CALLBACK(do_clear_selected_groups) },
+ { "refresh-xovers-in-subscribed-groups", "ICON_REFRESH",
+ N_("Refresh group counts for all subscribed groups"), "Y",
+ N_("Refresh group counts for all subscribed groups"),
+ G_CALLBACK(do_xover_count_subscribed_groups) },
+
{ "get-new-headers-in-selected-groups", "ICON_GET_SELECTED",
N_("Get New _Headers in Selected Groups"), "A",
N_("Get New Headers in Selected Groups"),
diff --git a/pan/gui/group-pane.cc b/pan/gui/group-pane.cc
index 6f9f0f5..529070f 100644
--- a/pan/gui/group-pane.cc
+++ b/pan/gui/group-pane.cc
@@ -43,6 +43,7 @@ namespace
enum ModelColumns
{
COL_UNREAD,
+ COL_TOTAL,
COL_QTY
};
@@ -51,13 +52,18 @@ namespace
public:
Quark groupname;
unsigned long unread;
+ unsigned long total;
public:
virtual void get_value (int column, GValue* setme) {
switch (column) {
case COL_UNREAD: set_value_ulong (setme, unread); break;
}
+ switch (column) {
+ case COL_TOTAL: set_value_ulong (setme, total); break;
+ }
}
+ MyRow() : unread(0), total(0) {}
};
Quark * sub_title_quark (0);
@@ -449,8 +455,7 @@ GroupPane :: refresh_dirty_groups ()
MyRow * row (find_row (*it));
if (row)
{
- unsigned long unused;
- _data.get_group_counts (row->groupname, row->unread, unused);
+ _data.get_group_counts (row->groupname, row->unread, row->total);
_tree_store->row_changed (row);
}
}
@@ -693,11 +698,14 @@ namespace
GtkTreeIter * iter,
gpointer gp)
{
- GroupPane* pane (static_cast<GroupPane*>(gp));
+
+ GroupPane* pane (static_cast<GroupPane*>(gp));
PanTreeStore * tree (PAN_TREE_STORE(model));
MyRow * row (dynamic_cast<MyRow*>(tree->get_row (iter)));
+
const unsigned long& unread (row->unread);
- //const unsigned long& total (row->total);
+ const unsigned long& total (row->total);
+
const Quark& name (row->groupname);
const bool is_g (is_group(name));
@@ -705,7 +713,7 @@ namespace
std::string group_name (do_shorten ? get_short_name(StringView(name)) : name.to_string());
if (is_g && unread) {
char buf[64];
- g_snprintf (buf, sizeof(buf), " (%lu)", unread);
+ g_snprintf (buf, sizeof(buf), " (%lu) (%lu)", unread, total);
group_name += buf;
}
g_object_set (renderer, "text", group_name.c_str(),
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 041397f..28551b3 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -38,6 +38,7 @@ extern "C" {
#include <pan/tasks/task-article.h>
#include <pan/tasks/task-groups.h>
#include <pan/tasks/task-xover.h>
+#include <pan/tasks/task-xoverinfo.h>
#include <pan/tasks/nzb.h>
#include <pan/icons/pan-pixbufs.h>
#include "actions.h"
@@ -2078,6 +2079,14 @@ void GUI :: do_xover_subscribed_groups ()
_queue.add_task (new TaskXOver (_data, *it, TaskXOver::NEW), Queue::TOP);
}
}
+void GUI :: do_xover_count_subscribed_groups ()
+{
+ typedef std::vector<Quark> quarks_v;
+ quarks_v groups;
+ _data.get_subscribed_groups (groups);
+ foreach_const_r (quarks_v, groups, it)
+ _queue.add_task (new TaskXOverInfo (_data, *it), Queue::TOP);
+}
void GUI :: do_download_headers ()
{
diff --git a/pan/gui/gui.h b/pan/gui/gui.h
index 09de6c3..76e5106 100644
--- a/pan/gui/gui.h
+++ b/pan/gui/gui.h
@@ -185,6 +185,7 @@ namespace pan
virtual void do_clear_selected_groups ();
virtual void do_xover_selected_groups ();
virtual void do_xover_subscribed_groups ();
+ virtual void do_xover_count_subscribed_groups ();
virtual void do_download_headers ();
virtual void do_refresh_groups ();
virtual void do_subscribe_selected_groups ();
diff --git a/pan/gui/pan-ui.h b/pan/gui/pan-ui.h
index 98c4d13..79dfa98 100644
--- a/pan/gui/pan-ui.h
+++ b/pan/gui/pan-ui.h
@@ -105,6 +105,7 @@ namespace pan
virtual void do_clear_selected_groups () = 0;
virtual void do_xover_selected_groups () = 0;
virtual void do_xover_subscribed_groups () = 0;
+ virtual void do_xover_count_subscribed_groups () = 0;
virtual void do_download_headers () = 0;
virtual void do_refresh_groups () = 0;
virtual void do_subscribe_selected_groups () = 0;
diff --git a/pan/gui/pan.ui.h b/pan/gui/pan.ui.h
index 64a0fbd..1b12b44 100644
--- a/pan/gui/pan.ui.h
+++ b/pan/gui/pan.ui.h
@@ -99,6 +99,7 @@ const char * fallback_ui_file =
" <menuitem action='download-headers' />\n"
" <menuitem action='get-new-headers-in-selected-groups' />\n"
" <menuitem action='get-new-headers-in-subscribed-groups'/>\n"
+" <menuitem action='refresh-xovers-in-subscribed-groups'/>\n"
" <separator />\n"
" <menuitem action='show-group-preferences-dialog' />\n"
" <separator />\n"
@@ -162,6 +163,7 @@ const char * fallback_ui_file =
" <toolitem action='download-headers' />\n"
" <toolitem action='get-new-headers-in-subscribed-groups'/>\n"
" <toolitem action='get-new-headers-in-selected-groups'/>\n"
+" <toolitem action='refresh-xovers-in-subscribed-groups'/>\n"
" <separator />\n"
" <placeholder name='group-pane-filter'/>\n"
" <separator />\n"
@@ -226,6 +228,7 @@ const char * fallback_ui_file =
" <menuitem action='download-headers' />\n"
" <menuitem action='get-new-headers-in-selected-groups' />\n"
" <menuitem action='get-new-headers-in-subscribed-groups'/>\n"
+" <menuitem action='refresh-xovers-in-subscribed-groups'/>\n"
" <separator />\n"
" <menuitem action='post' />\n"
" <separator />\n"
diff --git a/pan/gui/pan.ui.ssl.h b/pan/gui/pan.ui.ssl.h
index ce1e573..7f2a9bf 100644
--- a/pan/gui/pan.ui.ssl.h
+++ b/pan/gui/pan.ui.ssl.h
@@ -100,6 +100,7 @@ const char * fallback_ui_file =
" <menuitem action='download-headers' />\n"
" <menuitem action='get-new-headers-in-selected-groups' />\n"
" <menuitem action='get-new-headers-in-subscribed-groups'/>\n"
+" <menuitem action='refresh-xovers-in-subscribed-groups'/>\n"
" <separator />\n"
" <menuitem action='show-group-preferences-dialog' />\n"
" <separator />\n"
@@ -163,6 +164,7 @@ const char * fallback_ui_file =
" <toolitem action='download-headers' />\n"
" <toolitem action='get-new-headers-in-subscribed-groups'/>\n"
" <toolitem action='get-new-headers-in-selected-groups'/>\n"
+" <toolitem action='refresh-xovers-in-subscribed-groups'/>\n"
" <separator />\n"
" <placeholder name='group-pane-filter'/>\n"
" <separator />\n"
@@ -227,6 +229,7 @@ const char * fallback_ui_file =
" <menuitem action='download-headers' />\n"
" <menuitem action='get-new-headers-in-selected-groups' />\n"
" <menuitem action='get-new-headers-in-subscribed-groups'/>\n"
+" <menuitem action='refresh-xovers-in-subscribed-groups'/>\n"
" <separator />\n"
" <menuitem action='post' />\n"
" <separator />\n"
diff --git a/pan/icons/Makefile.am b/pan/icons/Makefile.am
index 4677c27..3909f18 100644
--- a/pan/icons/Makefile.am
+++ b/pan/icons/Makefile.am
@@ -48,24 +48,25 @@ stock_images = \
icon_plain.png \
icon_cert.png \
icon_status_online.png \
- icon_status_offline.png \
- icon_status_active.png \
- icon_status_queue_empty.png \
- icon_status_error.png \
- icon_status_idle.png \
- icon_status_new_articles.png \
- icon_sig_ok.png \
- icon_sig_fail.png \
- icon_prefs_applications.png \
- icon_prefs_extras.png \
- icon_prefs_hotkeys.png \
- icon_prefs_behavior.png \
- icon_prefs_fonts.png \
- icon_prefs_upload.png \
- icon_prefs_colors.png \
- icon_prefs_headers.png \
- icon_prefs_layout.png \
- icon_prefs_actions.png
+ icon_status_offline.png \
+ icon_status_active.png \
+ icon_status_queue_empty.png \
+ icon_status_error.png \
+ icon_status_idle.png \
+ icon_status_new_articles.png \
+ icon_sig_ok.png \
+ icon_sig_fail.png \
+ icon_prefs_applications.png \
+ icon_prefs_extras.png \
+ icon_prefs_hotkeys.png \
+ icon_prefs_behavior.png \
+ icon_prefs_fonts.png \
+ icon_prefs_upload.png \
+ icon_prefs_colors.png \
+ icon_prefs_headers.png \
+ icon_prefs_layout.png \
+ icon_prefs_actions.png \
+ icon_refresh.png
EXTRA_DIST = \
pan-template.xcf \
diff --git a/pan/tasks/nntp.cc b/pan/tasks/nntp.cc
index fc6b560..a46e694 100644
--- a/pan/tasks/nntp.cc
+++ b/pan/tasks/nntp.cc
@@ -330,10 +330,7 @@ NNTP :: xover_count_only (const Quark & group,
{
_listener = l;
- get_group(group);
-
- _commands.push_back (build_command ("XOVER"));
-
+ _commands.push_back (build_command ("GROUP %s\r\n",group.c_str()));
write_next_command ();
}
diff --git a/pan/tasks/task-xover.cc b/pan/tasks/task-xover.cc
index 34a5a69..2482a25 100644
--- a/pan/tasks/task-xover.cc
+++ b/pan/tasks/task-xover.cc
@@ -179,7 +179,6 @@ TaskXOver :: use_nntp (NNTP* nntp)
****
***/
-///TODO show low and high in UI (is this already there?)
void
TaskXOver :: on_nntp_group (NNTP * nntp,
const Quark & group,
diff --git a/pan/tasks/task-xoverinfo.cc b/pan/tasks/task-xoverinfo.cc
index 5d19e25..0636974 100644
--- a/pan/tasks/task-xoverinfo.cc
+++ b/pan/tasks/task-xoverinfo.cc
@@ -81,13 +81,11 @@ namespace
}
TaskXOverInfo :: TaskXOverInfo (Data & data,
- const Quark & group,
- std::map<Quark,xover_t>& xovers) :
+ const Quark & group) :
Task("XOVER", get_description(group)),
_data (data),
_group (group),
- _short_group_name (get_short_name (StringView (group.c_str()))),
- _xovers(xovers)
+ _short_group_name (get_short_name (StringView (group.c_str())))
{
debug ("ctor for " << group);
@@ -99,21 +97,22 @@ TaskXOverInfo :: TaskXOverInfo (Data & data,
_data.group_get_servers (group, servers);
foreach_const (quarks_t, servers, it)
- {
if (_data.get_server_limits(*it))
- {
_server_to_minitasks[*it].push_front (group_minitask);
- std::pair<uint64_t,uint64_t>& p (xovers[*it]);
- p.first = data.get_xover_high (group, *it);
- }
- }
+
init_steps (0);
update_work ();
}
TaskXOverInfo :: ~TaskXOverInfo ()
-{}
+{
+ foreach (server_to_high_t, _high, it)
+ {
+ std::cerr<<_data.get_xover_high(_group, it->first)-it->second<<"\n";
+// _data.set_xover_high (_group, it->first, it->second);
+ }
+}
void
TaskXOverInfo :: use_nntp (NNTP* nntp)
@@ -121,7 +120,20 @@ TaskXOverInfo :: use_nntp (NNTP* nntp)
const Quark& server (nntp->_server);
debug ("got an nntp from " << nntp->_server);
- nntp->xover_count_only (_group, this);
+ MiniTasks_t& minitasks (_server_to_minitasks[server]);
+ if (minitasks.empty())
+ {
+ debug ("That's interesting, I got a socket for " << server << " but have no use for it!");
+ _state._servers.erase (server);
+ check_in (nntp, OK);
+ }
+ else
+ {
+ const MiniTask mt (minitasks.front());
+ minitasks.pop_front ();
+ nntp->xover_count_only (_group, this);
+ update_work ();
+ }
}
/***
@@ -169,10 +181,36 @@ void
TaskXOverInfo :: on_nntp_line (NNTP * nntp,
const StringView & line)
{
- uint64_t new_high(atoi(line.str));
-// nntp
+
+}
+
+void
+TaskXOverInfo :: on_nntp_group (NNTP * nntp,
+ const Quark & group,
+ unsigned long qty,
+ uint64_t low,
+ uint64_t high)
+{
+ const Quark& servername (nntp->_server);
+
+ std::cerr<< "got GROUP result from " << nntp->_server << " (" << nntp << "): "
+ << " qty " << qty
+ << " low " << low
+ << " high " << high;
+
+ uint64_t l(low);
+ _data.set_xover_low (group, nntp->_server, low);
+
+ uint64_t xh (_data.get_xover_high (group, nntp->_server));
+ l = std::max (xh+1, low);
+
+ if (l > high)
+ {
+ _high[nntp->_server] = high;
+ }
}
+
void
TaskXOverInfo :: on_nntp_done (NNTP * nntp,
Health health,
diff --git a/pan/tasks/task-xoverinfo.h b/pan/tasks/task-xoverinfo.h
index afb134c..9ce36ed 100644
--- a/pan/tasks/task-xoverinfo.h
+++ b/pan/tasks/task-xoverinfo.h
@@ -42,7 +42,7 @@ namespace pan
typedef std::pair<uint64_t,uint64_t> xover_t;
- TaskXOverInfo (Data& data, const Quark& group, std::map<Quark,xover_t>& xovers);
+ TaskXOverInfo (Data& data, const Quark& group);
virtual ~TaskXOverInfo ();
public: // task subclass
@@ -74,14 +74,13 @@ namespace pan
std::string _short_group_name;
typedef std::map<Quark,uint64_t> server_to_high_t;
server_to_high_t _high;
+ bool _group_xover_is_reffed;
void update_work (bool subtract_one_from_nntp_count=false);
std::set<Quark> _servers_that_got_xover_minitasks;
std::map<NNTP*,uint64_t> _last_xover_number;
unsigned long _bytes_so_far;
unsigned long _parts_so_far;
unsigned long _articles_so_far;
- unsigned long _total_minitasks;
- std::map<Quark,xover_t>& _xovers;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]