1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * Pan - A Newsreader for Gtk+
4  * Copyright (C) 2002-2006  Charles Kerr <charles@rebelbase.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 
20 #ifndef __Text_Massager_h__
21 #define __Text_Massager_h__
22 
23 #include <string>
24 #include <climits>
25 #include <set>
26 #include <pan/general/string-view.h>
27 #include <pan/general/quark.h>
28 #include <pan/data/article.h>
29 
30 namespace pan
31 {
32   /**
33    * Used for manipluating text in ways that a newsreader might need:
34    * <ul>
35    * <li>rot13'ing text
36    * <li>muting quoted text
37    * <li>'filling' text to wrap at 78 cols
38    * </ul>
39    *
40    * @ingroup usenet_utils
41    */
42   class TextMassager {
43     public:
44       TextMassager ();
45       ~TextMassager ();
46     public:
47       static char* rot13_inplace (char * text);
48       std::string mute_quotes (const StringView& text) const;
49       std::string fill (const StringView& text, bool flowed = false) const;
get_wrap_column()50       int get_wrap_column () const { return _wrap_column; }
51       bool is_quote_character (unsigned int unichar) const;
52       std::set<char> get_quote_characters () const;
set_wrap_column(int column)53       void set_wrap_column (int column) { _wrap_column = column; }
54       void set_quote_characters (const std::set<char>& quote_chars);
55     private:
56       int _wrap_column;
57       char * _quote_characters;
58   };
59 
60  /**
61    * Used to convert a subject line to a path for saving articles.
62    *
63    * @ingroup usenet_utils
64    */
65    std::string subject_to_path (const char * subjectline, bool full_subj, const std::string &separator);
66 
67    std::string expand_download_dir_subject (const char * dir, const char * subjectline, const std::string &sep);
68    std::string expand_download_dir (const char * dir, const StringView& group);
69    std::string expand_attachment_headers(const Quark& path, const Article& article);
70 
71    std::pair<std::string,std::string> get_email_address(std::string& s);
72 
73 }
74 
75 #endif
76