|
Revision 1a970cd0640f976f152341597a5249ec22acbba7, 2.6 KB
(checked in by Antti-Juhani Kaijanaho <antti-juhani@…>, 21 months ago)
|
|
[msg::msg] Separate out db::msg and let msg::entity handle the rest
Signed-off-by: Antti-Juhani Kaijanaho <antti-juhani@…>
|
-
Property mode set to
100644
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | #include "connection.hh" |
|---|
| 21 | |
|---|
| 22 | #include "../db/group.hh" |
|---|
| 23 | #include "../db/msg.hh" |
|---|
| 24 | |
|---|
| 25 | namespace nntp |
|---|
| 26 | { |
|---|
| 27 | class last : public connection::command |
|---|
| 28 | { |
|---|
| 29 | public: |
|---|
| 30 | last(const char *s) { |
|---|
| 31 | connection::register_command(s, this); |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | connection::continuation::ptr |
|---|
| 35 | perform(connection::cb, const std::string [], size_t) const; |
|---|
| 36 | }; |
|---|
| 37 | |
|---|
| 38 | connection::continuation::ptr |
|---|
| 39 | last::perform(connection::cb c, const std::string[], size_t nargs) const |
|---|
| 40 | { |
|---|
| 41 | if (nargs > 0) { |
|---|
| 42 | c.send_line("501 syntax error"); |
|---|
| 43 | return c.dispatch(); |
|---|
| 44 | } |
|---|
| 45 | if (!c.current_group()) { |
|---|
| 46 | c.send_line("412 no group selected"); |
|---|
| 47 | return c.dispatch(); |
|---|
| 48 | } |
|---|
| 49 | db::group::number low = c.current_group()->low_mark(); |
|---|
| 50 | if (c.current_article() < low || |
|---|
| 51 | c.current_article() > c.current_group()->high_mark()) { |
|---|
| 52 | c.send_line("420 no current article"); |
|---|
| 53 | return c.dispatch(); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | db::group::number n = c.current_article(); |
|---|
| 57 | do --n; while (n >= low && !c.current_group()->is_article(n)); |
|---|
| 58 | |
|---|
| 59 | if (!c.current_group()->is_article(n)) { |
|---|
| 60 | c.send_line("422 already at the first article"); |
|---|
| 61 | return c.dispatch(); |
|---|
| 62 | } |
|---|
| 63 | std::ostringstream ss; |
|---|
| 64 | ss << "223 " |
|---|
| 65 | << n |
|---|
| 66 | << ' ' |
|---|
| 67 | << c.current_group()->get_article(n)->msgid() |
|---|
| 68 | << " selected"; |
|---|
| 69 | c.current_article() = n; |
|---|
| 70 | c.send_line(ss.str()); |
|---|
| 71 | return c.dispatch(); |
|---|
| 72 | } |
|---|
| 73 | } |
|---|
| 74 | namespace { |
|---|
| 75 | nntp::last last("last"); |
|---|
| 76 | } |
|---|