1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
/*
KNode, the KDE newsreader
Copyright (c) 1999-2005 the KNode authors.
See file AUTHORS for details
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
*/
#include <klocale.h>
#include "kndisplayedheader.h"
// some standard headers
static const char *predef[] = { "Approved","Content-Transfer-Encoding","Content-Type","Control","Date","Distribution",
"Expires","Followup-To","From","Lines","Mail-Copies-To","Message-ID","Mime-Version","NNTP-Posting-Host",
"Newsgroups","Organization","Path","References","Reply-To", "Sender","Subject",
"Supersedes","To", "User-Agent","X-Mailer","X-Newsreader","X-No-Archive","XRef",0 };
// default display names KNode uses
static const char *disp[] = { "Groups", 0 };
void dummyHeader()
{
i18n("collection of article headers","Approved");
i18n("collection of article headers","Content-Transfer-Encoding");
i18n("collection of article headers","Content-Type");
i18n("collection of article headers","Control");
i18n("collection of article headers","Date");
i18n("collection of article headers","Distribution");
i18n("collection of article headers","Expires");
i18n("collection of article headers","Followup-To");
i18n("collection of article headers","From");
i18n("collection of article headers","Lines");
i18n("collection of article headers","Mail-Copies-To");
i18n("collection of article headers","Message-ID");
i18n("collection of article headers","Mime-Version");
i18n("collection of article headers","NNTP-Posting-Host");
i18n("collection of article headers","Newsgroups");
i18n("collection of article headers","Organization");
i18n("collection of article headers","Path");
i18n("collection of article headers","References");
i18n("collection of article headers","Reply-To");
i18n("collection of article headers","Sender");
i18n("collection of article headers","Subject");
i18n("collection of article headers","Supersedes");
i18n("collection of article headers","To");
i18n("collection of article headers","User-Agent");
i18n("collection of article headers","X-Mailer");
i18n("collection of article headers","X-Newsreader");
i18n("collection of article headers","X-No-Archive");
i18n("collection of article headers","XRef");
i18n("collection of article headers","Groups");
}
//=============================================================================================================
KNDisplayedHeader::KNDisplayedHeader()
: t_ranslateName(true)
{
f_lags.fill(false, 8);
f_lags[1] = true; // header name bold by default
}
KNDisplayedHeader::~KNDisplayedHeader()
{
}
// some common headers
const char** KNDisplayedHeader::predefs()
{
return predef;
}
// *tries* to translate the name
TQString KNDisplayedHeader::translatedName()
{
if (t_ranslateName) {
// major hack alert !!!
if (!n_ame.isEmpty()) {
if (i18n("collection of article headers",n_ame.local8Bit())!=n_ame.local8Bit().data()) // try to guess if this english or not
return i18n("collection of article headers",n_ame.local8Bit());
else
return n_ame;
} else
return TQString();
} else
return n_ame;
}
// *tries* to retranslate the name to english
void KNDisplayedHeader::setTranslatedName(const TQString &s)
{
bool retranslated = false;
for (const char **c=predef;(*c)!=0;c++) { // ok, first the standard header names
if (s==i18n("collection of article headers",*c)) {
n_ame = TQString::fromLatin1(*c);
retranslated = true;
break;
}
}
if (!retranslated) {
for (const char **c=disp;(*c)!=0;c++) // now our standard display names
if (s==i18n("collection of article headers",*c)) {
n_ame = TQString::fromLatin1(*c);
retranslated = true;
break;
}
}
if (!retranslated) { // ok, we give up and store the maybe non-english string
n_ame = s;
t_ranslateName = false; // and don't try to translate it, so a german user *can* use the original english name
} else
t_ranslateName = true;
}
void KNDisplayedHeader::createTags()
{
const char *tokens[] = { "<big>","</big>","<b>","</b>",
"<i>","</i>","<u>","</u>" };
for(int i=0; i<4; i++) t_ags[i]=TQString();
if(f_lags.at(0)) { // <big>
t_ags[0]=tokens[0];
t_ags[1]=tokens[1];
}
if(f_lags.at(4)) {
t_ags[2]=tokens[0];
t_ags[3]=tokens[1];
}
if(f_lags.at(1)) { // <b>
t_ags[0]+=(tokens[2]);
t_ags[1].prepend(tokens[3]);
}
if(f_lags.at(5)) {
t_ags[2]+=tokens[2];
t_ags[3].prepend(tokens[3]);
}
if(f_lags.at(2)) { // <i>
t_ags[0]+=tokens[4];
t_ags[1].prepend(tokens[5]);
}
if(f_lags.at(6)) {
t_ags[2]+=tokens[4];
t_ags[3].prepend(tokens[5]);
}
if(f_lags.at(3)) { // <u>
t_ags[0]+=tokens[6];
t_ags[1].prepend(tokens[7]);
}
if(f_lags.at(7)) {
t_ags[2]+=tokens[6];
t_ags[3].prepend(tokens[7]);
}
}
|