forked from peterkvt80/vbit2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttxpage.h
289 lines (229 loc) · 9.58 KB
/
ttxpage.h
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#ifndef TTXPAGE_H
#define TTXPAGE_H
#include <stdlib.h>
#include "string.h"
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <assert.h>
#include "ttxcodes.h"
#include "ttxline.h"
#include "hamm-tables.h"
#define FIRSTPAGE 0x1ff00
// MiniTED Page Status word
#define PAGESTATUS_C4_ERASEPAGE 0x4000
#define PAGESTATUS_C5_NEWSFLASH 0x0001
#define PAGESTATUS_C6_SUBTITLE 0x0002
#define PAGESTATUS_C7_SUPPRESSHDR 0x0004
#define PAGESTATUS_C8_UPDATE 0x0008
#define PAGESTATUS_C9_INTERRUPTED 0x0010
#define PAGESTATUS_C10_INHIBIT 0x0020
#define PAGESTATUS_TRANSMITPAGE 0x8000
#define PAGESTATUS_SUBSTITUTEPAGE 0x0800
#define PAGESTATUS_C11_SERIALMAG 0x0040
// Allow for enhancement packets
#define MAXROW 29
// @todo more page codings
enum PageCoding {CODING_7BIT_TEXT,CODING_8BIT_DATA,CODING_13_TRIPLETS,CODING_HAMMING_8_4};
enum PageFunction {LOP, DATABROADCAST, GPOP, POP, GDRCS, DRCS, MOT, MIP, BTT, AIT, MPT, MPT_EX};
class TTXPage
{
public:
/** Default constructor */
TTXPage();
/** Construct from a file */
TTXPage(std::string filename);
/** Default destructor */
virtual ~TTXPage();
/** Copy constructor
* \param other Object to copy from
*/
TTXPage(const TTXPage& other);
/** Assignment operator
* \param other Object to assign from
* \return A reference to this
*/
// TTXPage& operator=(const TTXPage& other);
/** Access m_SubPage which is the next page in a carousel
* \return The current value of m_SubPage
*/
TTXPage* Getm_SubPage() { return m_SubPage; }
/** Set m_SubPage
* \param val New value to set
*/
void Setm_SubPage(TTXPage* val) { m_SubPage = val; }
/** Get the page
* Warning! This is not the teletext page number. It is just an index to the pages in this list.
* \return Pointer to the page object that we want
*/
TTXPage* GetPage(unsigned int pageNumber);
/** Setter/Getter for m_pageNumber
*/
int GetPageNumber() const {return m_PageNumber;}
void SetPageNumber(int page);
/** Setter/Getter for m_pageStatus
*/
int GetPageStatus() {return m_pagestatus;}
void SetPageStatus(int ps){m_pagestatus=ps;}
/** Setter/Getter for m_description
*/
std::string GetDescription() const {return m_description;}
void SetDescription(std::string desc){m_description=desc;}
/** Setter/Getter for cycle counter/timer seconds
*/
int GetCycleTime() {return m_cycletimeseconds;}
void SetCycleTime(int time){m_cycletimeseconds=time;}
/** Setter/Getter for cycle counter/timer seconds
*/
char GetCycleTimeMode() {return m_cycletimetype;}
void SetCycleTimeMode(char mode){m_cycletimetype=mode;}
/** Setter/Getter for m_sourcepage
* This is the filename that was used to load the page
*/
std::string GetSourcePage() const {return m_sourcepage;}
void SetSourcePage(std::string fname){m_sourcepage=fname;}
/** Get the page count
* It also replaces the subcode sequence. (Is this a good idea?)
* Must only call this in the root page.
* \return Number of subpages.
*/
int GetPageCount();
/** Get a row of text
* \return The TTXLine object of the required row. Check result for NULL if there isn't an actual row.
*/
TTXLine* GetRow(unsigned int rowNumber);
/** Set row rownumber with text line.
* \return nowt
*/
void SetRow(unsigned int rownumber, std::string line);
/** Save the whole page set
* \param filename : The destination file
* \return false if the save failed
*/
bool SavePage(std::string filename);
/** Save the page set back to the original file
* \return false if the save failed
*/
bool SavePageDefault();
/** Set the subcode. Subcode is effectively the subpage nummber in a carousel
* \param subcode : A subcode value from 0000 to 3F7F (maybe we should check this!)
*/
void SetSubCode(unsigned int subcode) {m_subcode=subcode;}
/** Get the subcode
* \return Subcode value
*/
unsigned int GetSubCode() {return m_subcode;}
/** Copy the metadata from page to here.
* Metadata is everything except the actual text lines and the SubPage link.
* \param page : A TTXPage object to copy from
* \return
*/
void CopyMetaData(TTXPage* page);
/** Set the language.
* 0=Engliah, 1=German, 2=Swedish, 3=Italian, 4=French, 5=Spanish, 6=Czech
* \param language A language number 0..6 for western europe.
* \return Nothing.
*/
void SetLanguage(int language);
/** Get the language.
* \return language 0..6.
*/
int GetLanguage();
/** Set the region.
* A region is just one of the 16 sets of character sets.
* \param region : A hex value 0..f
* \return Nothing.
*/
void SetRegion(int region){m_region=region;}
/** Get the region.
* \return region 0..f.
*/
int GetRegion(){return m_region;}
/** Get a Fastext link
* \param link 0..5 where 0..3 are the main links, 5 is index and 4, nobody knows why
* \return A link number (in hex base)
*/
int GetFastextLink(int link);
/** Set a Fastext link
* \param link 0..5 where 0..3 are the main links, 5 is index and 4, nobody knows why
* \param value - The link page number. Note that out of range numbers less than 0x100 are permitted. Droidfax can use these to switch services.
*/
void SetFastextLink(int link, int value);
/** @brief Should check this before closing a page
*/
inline bool PageChanged(){return pageChanged;};
static bool pageChanged; // / True if we have done some edits
void DebugDump() const;
inline bool Loaded() const {return m_Loaded;};
unsigned int GetLastPacket() {return m_lastpacket;};
// get the function or coding of a page as the enum
PageCoding GetPageCoding() {return m_pagecoding;}
PageFunction GetPageFunction() {return m_pagefunction;}
// set the page function or coding based on their integer representations in ETS 300 706 section 9.4.2.1
void SetPageFunctionInt(int pageFunction);
void SetPageCodingInt(int pageCoding);
bool Special() {return (m_pagefunction == GPOP || m_pagefunction == POP || m_pagefunction == GDRCS || m_pagefunction == DRCS || m_pagefunction == MOT || m_pagefunction == MIP);} // more convenient way to tell if a page is 'special'.
/** @todo migrate this deep copy into the standard copy constructor
* Warning. Only deep copies the top page. Not for carousels (yet)
*/
void Copy(TTXPage* src);
/** \brief Check if any line in the page has changed.
* This can only be called once as it will clear the changed state.
* This is NOT the same as pageChanged.
*/
bool Changed();
void SetSelected(bool value){_Selected=value;}; /// Set the selected state to value
bool Selected(){return _Selected;}; /// Return the selected state
protected:
/** Load a TTI page (MRG Systems)
* \param filename : The source file
* \return true if the page was loaded
*/
bool m_LoadTTI(std::string filename);
int m_cycletimeseconds; // CT
int m_fastextlinks[6]; // FL
int m_PageNumber; // PN
private:
// Private variables
// Private objects
TTXPage* m_SubPage; //!< Member variable "m_SubPage"
/// @ todo: What about multiple enhancement packets. More than one is allowed.
TTXLine* m_pLine[MAXROW+1]; // OL. 26 and 27 can be set manually. Keep whatever people put in there.
std::string m_destination; // DS
std::string m_sourcepage; // SP
std::string m_description; // DE
char m_cycletimetype; // CT
unsigned int m_subcode; // SC
int m_pagestatus; // PS
int m_region; // RE
unsigned int m_lastpacket;
PageCoding m_pagecoding;
PageFunction m_pagefunction;
// Private functions
void m_Init();
void m_OutputLines(std::ofstream& ttxfile, TTXPage* p); /// Send ttx lines to an output stream
int instance;
std::string m_FormatPageNumber(TTXPage* p); /// \return the page number ready to write to file
int findPageNumber(char* buf);
bool m_Loaded;
/** Load an EP1 page
* \param filename : The source file
* \return true if the page was loaded
*/
bool m_LoadEP1(std::string filename);
/** Load a VTX page
* \param filename : The source file
* \return true if the page was loaded
*/
bool m_LoadVTX(std::string filename);
/** Load a TTX page (Cebra)
* \param filename : The source file
* \return true if the page was loaded
*/
bool m_LoadTTX(std::string filename);
bool _Selected; /// True if this page has been selected.
};
#endif // TTXPAGE_H