[pan2/testing: 28/279] :e bla
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/testing: 28/279] :e bla
- Date: Sat, 3 Dec 2011 22:27:44 +0000 (UTC)
commit 8d2bd8ece833989bf7978d59d2361fb77ecfcc31
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date: Sat May 21 17:31:27 2011 +0200
:e
bla
pan/general/file-util.cc | 6 +++
pan/general/file-util.h | 4 ++
pan/general/string-view.h | 6 +-
pan/general/worker-pool.cc | 1 +
pan/gui/dl-headers-ui.cc | 4 +-
pan/gui/gui.cc | 1 +
pan/gui/post-ui.cc | 98 ++++++++++++++++++++++++-------------------
pan/gui/post-ui.h | 2 +-
pan/gui/prefs.h | 4 +-
pan/gui/task-pane.cc | 1 +
pan/tasks/decoder.cc | 14 +++----
pan/tasks/nntp.cc | 8 ++++
pan/tasks/nntp.h | 5 ++
pan/tasks/queue.h | 3 +
pan/tasks/task.cc | 4 +-
15 files changed, 101 insertions(+), 60 deletions(-)
---
diff --git a/pan/general/file-util.cc b/pan/general/file-util.cc
index 55d3dd0..fc5cd50 100644
--- a/pan/general/file-util.cc
+++ b/pan/general/file-util.cc
@@ -49,6 +49,12 @@ using namespace pan;
***/
std::string
+file :: get_pan_uulib_dir()
+{
+ return std::string("/home/imhotep/.pan2/uulib-encode-cache");
+}
+
+std::string
file :: get_pan_home ()
{
static std::string pan_home;
diff --git a/pan/general/file-util.h b/pan/general/file-util.h
index a81f751..6e6d3a6 100644
--- a/pan/general/file-util.h
+++ b/pan/general/file-util.h
@@ -49,6 +49,10 @@ namespace pan
*/
namespace file
{
+
+ /** Returns the directory for encoded files, should be temporary */
+ std::string get_pan_uulib_dir ();
+
/** just like strerror but never returns NULL */
const char * pan_strerror (int error_number);
diff --git a/pan/general/string-view.h b/pan/general/string-view.h
index 9b5c2d9..c7fb901 100644
--- a/pan/general/string-view.h
+++ b/pan/general/string-view.h
@@ -28,7 +28,7 @@
namespace pan
{
/**
- * A shallow copy a C string, plus utilities to let us
+ * A shallow copy a C string, plus utilities to let us
* substring, tokenize, walk, search, or otherwise
* manipulate it without having to modify the original or
* allocate new strings.
@@ -43,12 +43,12 @@ namespace pan
size_t str_a_len,
const char * str_b,
size_t str_b_len);
-
+
static char* strchr (const char * haystack,
size_t haystack_len,
char needle)
{ return (char*) memchr (haystack, needle, haystack_len); }
-
+
static char* strrchr (const char * haystack,
size_t haystack_len,
char needle);
diff --git a/pan/general/worker-pool.cc b/pan/general/worker-pool.cc
index 6ff4b76..bdbf809 100644
--- a/pan/general/worker-pool.cc
+++ b/pan/general/worker-pool.cc
@@ -63,6 +63,7 @@ WorkerPool :: push_work (Worker *w, Worker::Listener *l, bool delete_worker)
w->silent = false;
w->pool = this;
w->listener = l;
+ if (!l) std::cerr<<"oops, listener in push_work is null!\n";
w->delete_worker = delete_worker;
my_workers.insert (w);
g_thread_pool_push (tpool, w, 0); // jump to worker_thread_func
diff --git a/pan/gui/dl-headers-ui.cc b/pan/gui/dl-headers-ui.cc
index 383a863..689c0e5 100644
--- a/pan/gui/dl-headers-ui.cc
+++ b/pan/gui/dl-headers-ui.cc
@@ -66,7 +66,7 @@ namespace
if (response == GTK_RESPONSE_ACCEPT)
{
const bool mark_read (state->prefs.get_flag ("mark-group-read-before-xover", false));
-
+ // xzver
foreach_const (quarks_t, state->groups, it) {
Task * task;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(state->all_headers_rb)))
@@ -112,7 +112,7 @@ pan :: headers_dialog (Data& data, Prefs& prefs, Queue& queue,
g_snprintf (buf, sizeof(buf), _("%d Groups"), (int)groups.size());
title += buf;
}
-
+
State * state = new State (data, prefs, queue);
state->groups = groups;
state->dialog = gtk_dialog_new_with_buttons (
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 67b802f..bfce0ae 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -1804,6 +1804,7 @@ GUI :: set_queue_size_label (unsigned int running,
_queue.get_stats (queued, unused, stopped,
KiB_remain, KiBps,
hr, min, sec);
+
g_snprintf (tip, sizeof(tip), _("%lu tasks, %s, %.1f KiBps, ETA %d:%02d:%02d"),
(running+queued), render_bytes(KiB_remain), KiBps, hr, min, sec);
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index e308328..4271798 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -491,6 +491,17 @@ PostUI :: send_now ()
g_object_unref (G_OBJECT(message));
}
+//void
+//PostUI :: send_binfiles_now()
+//{
+// if (!check_charset())
+// return;
+// GMimeMessage * message (new_message_from_ui (POSTING));
+//
+// //change headers according to
+// g_object_unref (G_OBJECT(message));
+//}
+
void
PostUI :: done_sending_message (GMimeMessage * message, bool ok)
{
@@ -579,14 +590,33 @@ PostUI :: maybe_mail_message (GMimeMessage * message)
void
PostUI :: on_progress_finished (Progress&, int status) // posting finished
{
+ int bufsz=2048;
+ char buf[bufsz];
+
_post_task->remove_listener (this);
gtk_widget_destroy (_post_dialog);
- GMimeMessage * message (_post_task->get_message ());
- if (status != OK) // error posting.. stop.
- done_sending_message (message, false);
- else
- maybe_mail_message (message);
+ if (_file_queue_empty) {
+ GMimeMessage * message (((TaskPost*)_post_task)->get_message ());
+ if (status != OK) // error posting.. stop.
+ done_sending_message (message, false);
+ else
+ maybe_mail_message (message);
+ }
+// else
+// {
+// GMimeMessage * message (((TaskUpload*)_upload_task)->get_message ());
+// const char* g = _upload_task->get_groups();
+// const char* f = _upload_task->get_filename();
+// // log server response
+// if (status == OK) {
+// g_snprintf(buf, bufsz,_("Error uploading file \"%s\" to group(s) \"%s\" : %s"), f, g, message);
+// Log :: add_err(buf);
+// } else {
+// g_snprintf(buf, bufsz,_("Successfully uploaded \"%s\" to group(s) \"%s\"."), f, g);
+// Log :: add_info(buf);
+// }
+// }
}
void
@@ -630,14 +660,14 @@ PostUI :: maybe_post_message (GMimeMessage * message)
**/
if (!check_message (server, message))
- return false;
+ return false;
/**
*** If this is email only, skip the rest of the posting...
*** we only stayed this long to get check_message()
**/
const StringView groups (g_mime_object_get_header ((GMimeObject *) message, "Newsgroups"));
- if (groups.empty()) {
+ if (groups.empty() && _file_queue_empty) {
maybe_mail_message (message);
return true;
}
@@ -686,26 +716,28 @@ PostUI :: maybe_post_message (GMimeMessage * message)
_post_dialog = d;
g_signal_connect (_post_dialog, "destroy", G_CALLBACK(gtk_widget_destroyed), &_post_dialog);
gtk_widget_show_all (d);
- }
- if (_file_queue_empty)
- {
_post_task = new TaskPost (server, message);
_post_task->add_listener (this);
_queue.add_task (_post_task, Queue::TOP);
} else
{
+ unsigned long i(0);
+ FileQueue::articles_it it = _file_queue.begin();
- _post_task = new TaskUpload (_file_queue,profile.posting_server,
- new_message_from_ui(POSTING),0,TaskUpload::YENC);
- _post_task->add_listener (this);
- _queue.add_task (_post_task, Queue::BOTTOM);
- close_window(true);
+ for (; it != _file_queue.end(); it, ++it, ++i) {
+ GMimeMessage* msg = new_message_from_ui(POSTING);
+ _queue.add_task (new TaskUpload (*it,profile.posting_server,msg
+ ,0,TaskUpload::YENC,i),
+ Queue::BOTTOM);
+ }
+ //dbg
+// close_window(true); // dont wait for the upload queue
}
/**
- *** Maybe remember the charsets.
+ *** Maybe remember the charsets
**/
if (remember_charsets) {
const char * text = gtk_entry_get_text (GTK_ENTRY(_groups_entry));
@@ -974,9 +1006,6 @@ namespace
GMimeMessage*
PostUI :: new_message_from_ui (Mode mode)
{
-
- std::cerr<<" new message from ui\n";
-
GMimeMessage * msg (g_mime_message_new (false));
// headers from the ui: From
@@ -1192,7 +1221,6 @@ PostUI :: update_profile_combobox ()
GtkComboBox * combo (GTK_COMBO_BOX (_from_combo));
char * active_text = gtk_combo_box_get_active_text (combo);
- std::cerr<<" update_profile combobox\n";
// if there's not already a selection,
// pull the default for the newsgroup
if (!active_text)
@@ -1580,7 +1608,6 @@ PostUI :: set_message (GMimeMessage * message)
g_object_unref (G_OBJECT(_message));
_message = message;
- std::cerr<<" set message \n";
// update subject, newsgroups, to fields
std::string s = utf8ize (g_mime_message_get_subject (message));
gtk_entry_set_text (GTK_ENTRY(_subject_entry), s.c_str());
@@ -1689,7 +1716,6 @@ PostUI :: group_entry_changed_idle (gpointer ui_gpointer)
PostUI * ui (static_cast<PostUI*>(ui_gpointer));
std::string charset;
- std::cerr<<" group entry changed idle\n";
// find the first posting charset in the newsgroups in _groups_entry.
const char * text = gtk_entry_get_text (GTK_ENTRY(ui->_groups_entry));
StringView line(text), groupname;
@@ -1785,19 +1811,10 @@ PostUI :: create_main_tab ()
// Subject
++row;
- char str[512];
- char tip[512];
- g_snprintf (tip, sizeof(tip), _("The subject of the messsage can contain following regular expressions\n \
- That are replaced automatically:\n \
- $1 - File number of current file in queue\n\
- $2 - Total queuesize\n\
- $f - Filename\n\
- $s - Filesize of current file"));
g_snprintf (buf, sizeof(buf), "<b>%s:</b>", _("_Subject"));
l = gtk_label_new_with_mnemonic (buf);
gtk_label_set_use_markup (GTK_LABEL(l), true);
gtk_misc_set_alignment (GTK_MISC(l), 0.0f, 0.5f);
- gtk_widget_set_tooltip_text (l, tip);
gtk_table_attach (GTK_TABLE(t), l, 0, 1, row, row+1, GTK_FILL, GTK_FILL, 0, 0);
w = _subject_entry = gtk_entry_new ();
@@ -1944,7 +1961,7 @@ gtk_widget_set_tooltip_text (w, _("The email account where mail replies to your
return t;
}
-// todo scroll,translations
+// todo scroll
GtkWidget*
PostUI :: create_filequeue_tab ()
{
@@ -1968,9 +1985,9 @@ PostUI :: create_filequeue_tab ()
// add columns
renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (w), -1, "Filename", renderer,"text", 0,NULL);
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (w), -1, (_("Filename")), renderer,"text", 0,NULL);
renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (w), -1, "Size (kB)",renderer,"text", 1,NULL);
+ gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (w), -1, (_("Size (kB)")),renderer,"text", 1,NULL);
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(w),TRUE);
@@ -1987,15 +2004,14 @@ PostUI :: update_filequeue_tab()
gtk_list_store_clear(store);
FileQueue::articles_it it = _file_queue.begin();
- std::cerr<<" filequeue tab\n";
- int i(0);
+ int i(0);
for (; it != _file_queue.end(); ++it, ++i )
{
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
- 0, (*it).filename.str,
- 1, (*it).byte_count,
+ 0, (*it)->basename,
+ 1, (*it)->byte_count,
-1);
}
@@ -2143,11 +2159,7 @@ PostUI :: prompt_user_for_queueable_files (FileQueue& queue, GtkWindow * parent,
for (; cur; cur = cur->next)
{
- const StringView filename((char*)cur->data);
- stat(filename.str,&stat_buf);
-
- _file_queue.add(subject, StringView(profile.username),
- filename, (unsigned int)stat_buf.st_size/1024, 0, FileQueue::END); //kB
+ _file_queue.add((char*)cur->data, FileQueue::END);
}
g_slist_free (tmp_list);
}
diff --git a/pan/gui/post-ui.h b/pan/gui/post-ui.h
index b5d15ed..43b16bf 100644
--- a/pan/gui/post-ui.h
+++ b/pan/gui/post-ui.h
@@ -114,7 +114,7 @@ namespace pan
std::string _current_signature;
GtkWidget * _post_dialog;
TaskPost * _post_task;
- TaskUpload * _upload_task;
+ TaskUpload* _upload_task;
typedef std::map<std::string, std::string> str2str_t;
str2str_t _hidden_headers;
str2str_t _profile_headers;
diff --git a/pan/gui/prefs.h b/pan/gui/prefs.h
index 0969fca..d475b8f 100644
--- a/pan/gui/prefs.h
+++ b/pan/gui/prefs.h
@@ -25,7 +25,9 @@
#include <string>
#include <vector>
#include <pan/general/string-view.h>
-#include <gtk/gtk.h>
+extern "C" {
+ #include <gtk/gtk.h>
+}
namespace pan
{
diff --git a/pan/gui/task-pane.cc b/pan/gui/task-pane.cc
index 8c8c0aa..8e7c938 100644
--- a/pan/gui/task-pane.cc
+++ b/pan/gui/task-pane.cc
@@ -240,6 +240,7 @@ TaskPane :: update_status (const task_states_t& tasks)
minutes = tmp % 60ul; tmp /= 60ul;
hours = tmp;
}
+
g_snprintf (buf, sizeof(buf), _("%lu tasks, %s, %.1f KiBps, ETA %d:%02d:%02d"),
task_count, render_bytes(bytes), KiBps, hours, minutes, seconds);
std::string line (buf);
diff --git a/pan/tasks/decoder.cc b/pan/tasks/decoder.cc
index 5e8bfa8..01616fd 100644
--- a/pan/tasks/decoder.cc
+++ b/pan/tasks/decoder.cc
@@ -171,8 +171,8 @@ Decoder :: do_work()
file :: ensure_dir_exists (save_path.c_str());
// find a unique filename...
- char * fname = file::get_unique_fname(save_path.c_str(),
- (item->filename
+ char * fname = file::get_unique_fname(save_path.c_str(),
+ (item->filename
&& *item->filename)
? item->filename
: "pan-saved-file" );
@@ -296,13 +296,11 @@ Decoder :: progress_update_timer_func (gpointer decoder)
if (!task || self->was_cancelled()) return false;
self->mut.lock();
- const double percent (self->percent);
- const std::string f (content_to_utf8 (self->current_file));
+ const double percent (self->percent);
+ const std::string f (content_to_utf8 (self->current_file));
+ task->set_step(int(percent));
+ task->set_status_va (_("Decoding %s"), f.c_str());
self->mut.unlock();
-
- task->set_step(int(percent));
- task->set_status_va (_("Decoding %s"), f.c_str());
-
return true; // keep timer func running
}
diff --git a/pan/tasks/nntp.cc b/pan/tasks/nntp.cc
index c2378dc..2d45eaa 100644
--- a/pan/tasks/nntp.cc
+++ b/pan/tasks/nntp.cc
@@ -333,6 +333,14 @@ NNTP :: write_next_command ()
***/
void
+NNTP :: help (Listener * l)
+{
+ _listener = l;
+ _commands.push_back ("HELP \r\n");
+ write_next_command();
+}
+
+void
NNTP :: xzver (const Quark & group,
uint64_t low,
uint64_t high,
diff --git a/pan/tasks/nntp.h b/pan/tasks/nntp.h
index b8ebd99..01480cc 100644
--- a/pan/tasks/nntp.h
+++ b/pan/tasks/nntp.h
@@ -113,6 +113,11 @@ namespace pan
public:
/**
+ * Lists all available commands.
+ */
+ void help (Listener * l);
+
+ /**
* Executes a handshake command.
*
* This is actually an empty string, but the
diff --git a/pan/tasks/queue.h b/pan/tasks/queue.h
index 008ee7e..f155358 100644
--- a/pan/tasks/queue.h
+++ b/pan/tasks/queue.h
@@ -32,6 +32,7 @@
#include <pan/tasks/socket.h>
#include <pan/tasks/adaptable-set.h>
#include <pan/tasks/task.h>
+#include <pan/tasks/encoder.h>
#include <pan/tasks/task-weak-ordering.h>
namespace pan
@@ -39,6 +40,8 @@ namespace pan
class NNTP;
class ServerInfo;
class WorkerPool;
+ struct Encoder;
+ struct Decoder;
/**
* A Queue helper that saves tasks to disk and restores them from disk.
diff --git a/pan/tasks/task.cc b/pan/tasks/task.cc
index 397e3c7..0caa968 100644
--- a/pan/tasks/task.cc
+++ b/pan/tasks/task.cc
@@ -81,13 +81,13 @@ Task :: give_encoder (EncoderSource* s, Encoder* d)
void
Task :: use_decoder (Decoder * d UNUSED)
{
- abort ();
+ assert(0 && "oops, child class task.cc called!\n");
}
void
Task :: use_encoder (Encoder * d UNUSED)
{
- abort ();
+ assert(0 && "oops, child class task.cc called!\n");
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]