/
xml_save_world.cpp
811 lines (612 loc) · 25.2 KB
/
xml_save_world.cpp
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
// xml_save_world.cpp : XML world serialization (saving)
//
#include "stdafx.h"
#include "..\MUSHclient.h"
#include "..\doc.h"
#include "..\MUSHview.h"
#include "..\genprint.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
extern tConfigurationNumericOption OptionsTable [];
extern tConfigurationAlphaOption AlphaOptionsTable [];
void SortAliases (CAliasMap & AliasMap,
CAliasArray & AliasArray);
void SortVariables (CVariableMap & VariableMap,
CVariableArray & VariableArray);
#define NL "\r\n"
void CMUSHclientDoc::Save_Version_And_Date_XML (CArchive& ar)
{
Save_XML_string (ar, "muclient_version", MUSHCLIENT_VERSION);
Save_XML_number (ar, "world_file_version", VERSION);
if (!m_bOmitSavedDateFromSaveFiles)
Save_XML_date (ar, "date_saved", CTime::GetCurrentTime());
} // end of CMUSHclientDoc::Save_Version_And_Date_XML
void CMUSHclientDoc::Save_World_XML (CArchive& ar,
const unsigned long iMask,
CString strComment)
{
// xml prolog
ar.WriteString ("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" NL);
// document type is world
ar.WriteString ("<!DOCTYPE muclient>" NL);
if (!m_bOmitSavedDateFromSaveFiles)
{
// when did we save it?
ar.WriteString (CFormat ("<!-- Saved on %s -->" NL,
FixHTMLString (CTime::GetCurrentTime().Format
(TranslateTime ("%A, %B %d, %Y, %#I:%M %p")))));
}
// which version was it?
ar.WriteString (CFormat
("<!-- MuClient version %s -->" NL, MUSHCLIENT_VERSION));
ar.WriteString ("<!-- Written by Nick Gammon -->" NL);
ar.WriteString ("<!-- Home Page: http://www.mushclient.com/ -->" NL);
// comment (eg. save-state for world X )
if (!strComment.IsEmpty ())
{
// cannot have "--" in comments
while (strComment.Find ("--") != -1)
strComment.Replace ("--", "-");
ar.WriteString (CFormat (NL "<!-- %s -->" NL NL, (LPCTSTR) strComment));
}
// ok - ready to go
ar.WriteString ("<muclient>" NL);
// write out any included files
if (iMask & XML_INCLUDES)
Save_Includes_XML (ar);
// general options
if (iMask & XML_GENERAL)
Save_General_XML (ar);
// triggers
if (iMask & XML_TRIGGERS)
Save_Triggers_XML (ar);
// aliases
if (iMask & XML_ALIASES)
Save_Aliases_XML (ar);
// timers
if (iMask & XML_TIMERS)
Save_Timers_XML (ar);
// macros
if (iMask & XML_MACROS)
Save_Macros_XML (ar);
// variables
if (iMask & XML_VARIABLES)
Save_Variables_XML (ar);
// colours
if (iMask & XML_COLOURS)
Save_Colours_XML (ar);
// numeric keypad
if (iMask & XML_KEYPAD)
Save_Keypad_XML (ar);
// printing stuff
if (iMask & XML_PRINTING)
Save_Printing_XML (ar);
// write out any plugin files
if (iMask & XML_PLUGINS)
Save_Plugins_XML (ar);
// last line in XML file
ar.WriteString ("</muclient>" NL);
} // end of CMUSHclientDoc::Save_World_XML
void Save_XML_number (CArchive& ar,
const char * sName,
const long iNumber,
const bool sameline)
{
// default of zero does not need to be written
if (iNumber)
ar.WriteString (CFormat ("%s%s=\"%ld\"%s",
sameline ? "" : " ",
sName,
iNumber,
sameline ? " " : NL));
} // end of Save_XML_number
void Save_XML_boolean (CArchive& ar,
const char * sName,
const long iNumber,
const bool sameline)
{
// default of false does not need to be written
if (iNumber)
ar.WriteString (CFormat ("%s%s=\"%s\"%s",
sameline ? "" : " ",
sName,
iNumber != 0 ? "y" : "n",
sameline ? " " : NL));
} // end of Save_XML_boolean
void Save_XML_string (CArchive& ar,
const char * sName,
const CString & str,
const bool sameline)
{
// shouldn't have newlines, get rid of them if there are any
if (!str.IsEmpty ())
ar.WriteString (CFormat ("%s%s=\"%s\"%s",
sameline ? "" : " ",
sName,
(LPCTSTR) FixHTMLString (Replace (str, ENDLINE, " ")),
sameline ? " " : NL));
} // end of Save_XML_string
void Save_XML_date (CArchive& ar,
const char * sName,
const CTime & date,
const bool sameline)
{
if (date.GetTime ())
Save_XML_string (ar,
sName,
FixHTMLString (date.Format ("%Y-%m-%d %H:%M:%S")),
sameline);
} // end of Save_XML_date
void Save_XML_double (CArchive& ar,
const char * sName,
const double & fNumber,
const bool sameline)
{
/*
--- THIS DIDN'T WORK, see: http://www.gammon.com.au/forum/?id=7953&page=2
// see: http://www.gammon.com.au/forum/?id=8077
char old_locale[256];
strncpy(old_locale, setlocale(LC_NUMERIC, NULL), sizeof old_locale); // store the locale
old_locale [255] = 0;
// want numbers formatted correctly
setlocale (LC_NUMERIC, "C" );
Save_XML_string (ar,
sName,
FixHTMLString (CFormat ("%.2f", fNumber)),
sameline);
setlocale(LC_NUMERIC, old_locale); // restore the old locale
*/
CString strNumber = CFormat ("%.2f", fNumber);
strNumber.Replace (",", "."); // don't want any blasted commas!
Save_XML_string (ar,
sName,
FixHTMLString (strNumber),
sameline);
} // end of Save_XML_double
void Save_XML_colour (CArchive& ar,
const char * sName,
const COLORREF & colour,
const bool sameline)
{
Save_XML_string (ar, sName, ColourToName (colour), sameline);
} // end of Save_XML_colour
void Save_XML_multi (CArchive& ar,
const char * sName,
const CString & str)
{
if (!str.IsEmpty ())
{
// note - no spaces or newlines inside the tag, as they are preserved when
// reading back in, and we don't want any extra ones
// option name - opening tag (eg. <notes> )
ar.WriteString (CFormat (" <%s>%s</%s>" NL,
sName,
(LPCTSTR) FixHTMLMultilineString (str),
sName));
} // end of not empty option
} // end of Save_XML_multi
void CMUSHclientDoc::Save_World_Numeric_Options_XML (CArchive& ar)
{
for (long i = 0; OptionsTable [i].pName; i++)
{
long iValue = GetOptionItem (i);
// skip included values that have not been changed
if (m_NumericConfiguration [i]->bInclude &&
iValue == m_NumericConfiguration [i]->iValue)
continue;
// do booleans differently so they come out as "y" or "n"
if (OptionsTable [i].iMinimum == 0 &&
OptionsTable [i].iMaximum == 0)
Save_XML_boolean (ar, OptionsTable [i].pName, iValue);
else
// RGB colours are different, also
if (OptionsTable [i].iFlags & OPT_RGB_COLOUR)
Save_XML_colour (ar, OptionsTable [i].pName, iValue);
else
Save_XML_number (ar, OptionsTable [i].pName, iValue);
} // end of looping through each option
} // end of CMUSHclientDoc::Save_World_Numeric_Options_XML
void CMUSHclientDoc::Save_World_Single_Line_Alpha_Options_XML (CArchive& ar)
{
for (int i = 0; AlphaOptionsTable [i].pName; i++)
if (!(AlphaOptionsTable [i].iFlags & OPT_MULTLINE))
{
CString strValue = GetAlphaOptionItem (i);
// skip included values that have not been changed
if (m_AlphaConfiguration [i]->bInclude &&
strValue == m_AlphaConfiguration [i]->sValue)
continue;
if ((AlphaOptionsTable [i].iFlags & OPT_PASSWORD) && !strValue.IsEmpty ())
{
strValue = encodeBase64 (strValue, false); // base 64 encoding
Save_XML_boolean (ar,
CFormat ("%s_base64", (LPCTSTR) AlphaOptionsTable [i].pName),
true);
}
Save_XML_string (ar, AlphaOptionsTable [i].pName, strValue);
} // end of looping through each option
} // end of CMUSHclientDoc::Save_World_Single_Line_Alpha_Options_XML
void CMUSHclientDoc::Save_World_Multi_Line_Alpha_Options_XML (CArchive& ar)
{
for (int i = 0; AlphaOptionsTable [i].pName; i++)
if (AlphaOptionsTable [i].iFlags & OPT_MULTLINE)
{
CString strValue = GetAlphaOptionItem (i);
// skip included values that have not been changed
if (m_AlphaConfiguration [i]->bInclude &&
strValue == m_AlphaConfiguration [i]->sValue)
continue;
Save_XML_multi (ar, AlphaOptionsTable [i].pName, strValue);
} // end of looping through each option
} // end of CMUSHclientDoc::Save_World_Multi_Line_Alpha_Options_XML
void CMUSHclientDoc::Save_General_XML (CArchive& ar)
{
ar.WriteString ("<world" NL);
// identifying stuff to help us later on
Save_Version_And_Date_XML (ar);
// blank line to separate above stuff from actual world data
ar.WriteString (NL);
// first do the fixed attributes for the whole world
// single-line alpha
Save_World_Single_Line_Alpha_Options_XML (ar);
// blank line to separate alpha from booleans :)
ar.WriteString (NL);
// numbers, booleans
Save_World_Numeric_Options_XML (ar);
ar.WriteString (" > <!-- end of general world attributes -->" NL); // end of world attributes
// multi-line alpha
Save_World_Multi_Line_Alpha_Options_XML (ar);
ar.WriteString (NL "</world>" NL);
} // end of CMUSHclientDoc::Save_General_XML
void CMUSHclientDoc::Save_Header_XML (CArchive& ar,
const char * sName,
const bool bShowVersion)
{
if (bShowVersion)
{
ar.WriteString (CFormat (NL "<!-- %s -->" NL, sName));
ar.WriteString (CFormat (NL "<%s" NL, sName));
Save_Version_And_Date_XML (ar);
ar.WriteString (" >" NL);
}
else
ar.WriteString (CFormat ("<%s>" NL, sName));
} // end of CMUSHclientDoc::Save_Header_XML
void CMUSHclientDoc::Save_Footer_XML (CArchive& ar, const char * sName)
{
ar.WriteString (CFormat ("</%s>" NL, sName));
} // end of CMUSHclientDoc::Save_Footer_XML
void CMUSHclientDoc::Save_Triggers_XML (CArchive& ar)
{
Save_Header_XML (ar, "triggers");
// make absolutely sure we have all of them in the array
SortTriggers ();
// save them in trigger sequence order
for (int i = 0; i < m_TriggerMap.GetCount (); i++)
{
CTrigger * t = m_TriggerArray [i];
if (t->bTemporary || t->bIncluded) // don't save temporary triggers
continue;
Save_One_Trigger_XML (ar, t);
} // end of loop
Save_Footer_XML (ar, "triggers");
} // end of CMUSHclientDoc::Save_Triggers_XML
void CMUSHclientDoc::Save_One_Trigger_XML (CArchive& ar, CTrigger * t)
{
ar.WriteString (" <trigger" NL);
Save_XML_number (ar, "back_colour", (t->iMatch >> 8) & 0x0F);
Save_XML_boolean (ar, "bold", t->iMatch & HILITE);
Save_XML_number (ar, "clipboard_arg", t->iClipboardArg);
if (t->colour != SAMECOLOUR) // don't write 65536 to world file
Save_XML_number (ar, "custom_colour", t->colour + 1); // + 1, to match custom colours
Save_XML_number (ar, "colour_change_type",t->iColourChangeType);
Save_XML_boolean (ar, "enabled", t->bEnabled);
Save_XML_boolean (ar, "expand_variables", t->bExpandVariables);
Save_XML_string (ar, "group", t->strGroup);
Save_XML_boolean (ar, "ignore_case", t->ignore_case);
Save_XML_boolean (ar, "inverse", t->iMatch & INVERSE);
Save_XML_boolean (ar, "italic", t->iMatch & BLINK);
Save_XML_number (ar, "lines_to_match", t->iLinesToMatch);
Save_XML_boolean (ar, "keep_evaluating", t->bKeepEvaluating);
Save_XML_boolean (ar, "make_bold", t->iStyle & HILITE);
Save_XML_boolean (ar, "make_italic", t->iStyle & BLINK);
Save_XML_boolean (ar, "make_underline", t->iStyle & UNDERLINE);
Save_XML_string (ar, "match", t->trigger);
Save_XML_boolean (ar, "match_back_colour", t->iMatch & TRIGGER_MATCH_BACK);
Save_XML_boolean (ar, "match_bold", t->iMatch & TRIGGER_MATCH_HILITE);
Save_XML_boolean (ar, "match_inverse", t->iMatch & TRIGGER_MATCH_INVERSE);
Save_XML_boolean (ar, "match_italic", t->iMatch & TRIGGER_MATCH_BLINK);
Save_XML_boolean (ar, "match_text_colour", t->iMatch & TRIGGER_MATCH_TEXT);
Save_XML_boolean (ar, "match_underline", t->iMatch & TRIGGER_MATCH_UNDERLINE);
Save_XML_boolean (ar, "multi_line", t->bMultiLine);
Save_XML_string (ar, "name", t->strLabel);
Save_XML_boolean (ar, "one_shot", t->bOneShot);
Save_XML_boolean (ar, "omit_from_log", t->omit_from_log);
Save_XML_boolean (ar, "omit_from_output", t->bOmitFromOutput);
#ifdef PANE
Save_XML_string (ar, "pane", t->strPane);
#endif // PANE
Save_XML_boolean (ar, "regexp", t->bRegexp);
Save_XML_boolean (ar, "repeat", t->bRepeat);
Save_XML_string (ar, "script", t->strProcedure);
Save_XML_number (ar, "send_to", t->iSendTo);
Save_XML_number (ar, "sequence", t->iSequence);
Save_XML_string (ar, "sound", t->sound_to_play);
Save_XML_boolean (ar, "sound_if_inactive", t->bSoundIfInactive);
Save_XML_boolean (ar, "lowercase_wildcard", t->bLowercaseWildcard);
Save_XML_boolean (ar, "temporary", t->bTemporary);
Save_XML_number (ar, "text_colour", (t->iMatch >> 4) & 0x0F);
Save_XML_number (ar, "user", t->iUserOption);
Save_XML_string (ar, "variable", t->strVariable);
// don't save black, that will be the default anyway
if (t->iOtherForeground)
Save_XML_colour (ar, "other_text_colour", t->iOtherForeground);
if (t->iOtherBackground)
Save_XML_colour (ar, "other_back_colour", t->iOtherBackground);
ar.WriteString (" >" NL);
Save_XML_multi (ar, "send", t->contents);
ar.WriteString (" </trigger>" NL);
} // end of CMUSHclientDoc::Save_One_Trigger_XML
void CMUSHclientDoc::Save_Aliases_XML (CArchive& ar)
{
Save_Header_XML (ar, "aliases");
// make absolutely sure we have all of them in the array
SortAliases ();
for (int i = 0; i < m_AliasMap.GetCount (); i++)
{
CAlias * a = m_AliasArray [i];
if (a->bTemporary || a->bIncluded) // don't save temporary aliases
continue;
Save_One_Alias_XML (ar, a);
}
Save_Footer_XML (ar, "aliases");
} // end of CMUSHclientDoc::Save_Aliases_XML
void CMUSHclientDoc::Save_One_Alias_XML (CArchive& ar, CAlias * a)
{
ar.WriteString (" <alias" NL);
Save_XML_string (ar, "name", a->strLabel);
Save_XML_string (ar, "script", a->strProcedure);
Save_XML_string (ar, "match", a->name);
Save_XML_boolean (ar, "enabled", a->bEnabled);
Save_XML_boolean (ar, "echo_alias", a->bEchoAlias);
Save_XML_boolean (ar, "expand_variables", a->bExpandVariables);
Save_XML_string (ar, "group", a->strGroup);
Save_XML_string (ar, "variable", a->strVariable);
Save_XML_boolean (ar, "omit_from_command_history", a->bOmitFromCommandHistory);
Save_XML_boolean (ar, "omit_from_log", a->bOmitFromLog);
Save_XML_boolean (ar, "regexp", a->bRegexp);
Save_XML_number (ar, "send_to", a->iSendTo);
Save_XML_boolean (ar, "omit_from_output", a->bOmitFromOutput);
Save_XML_boolean (ar, "one_shot", a->bOneShot);
Save_XML_boolean (ar, "menu", a->bMenu);
Save_XML_boolean (ar, "ignore_case", a->bIgnoreCase);
Save_XML_boolean (ar, "keep_evaluating", a->bKeepEvaluating);
Save_XML_number (ar, "sequence", a->iSequence);
Save_XML_boolean (ar, "temporary", a->bTemporary);
Save_XML_number (ar, "user", a->iUserOption);
// Save_XML_boolean (ar, "delayed", t->bDelayed);
ar.WriteString (" >" NL);
Save_XML_multi (ar, "send", a->contents);
ar.WriteString (" </alias>" NL);
} // end of CMUSHclientDoc::Save_One_Alias_XML
void CMUSHclientDoc::Save_Variables_XML (CArchive& ar)
{
Save_Header_XML (ar, "variables");
CVariableArray VariableArray; // temporary array, to get them in order
// put all of them into the array, and sort them
SortVariables (GetVariableMap (), VariableArray);
// save them
for (int i = 0; i < GetVariableMap ().GetCount (); i++)
Save_One_Variable_XML (ar, VariableArray [i]);
ar.WriteString ("</variables>" NL);
} // end of CMUSHclientDoc::Save_Variables_XML
void CMUSHclientDoc::Save_One_Variable_XML (CArchive& ar, CVariable * v)
{
ar.WriteString (CFormat (" <variable name=\"%s\">%s</variable>" NL,
(LPCTSTR) v->strLabel,
(LPCTSTR) FixHTMLMultilineString (v->strContents)));
} // end of CMUSHclientDoc::Save_One_Variable_XML
void CMUSHclientDoc::Save_Timers_XML (CArchive& ar)
{
Save_Header_XML (ar, "timers");
for (POSITION pos = m_TimerMap.GetStartPosition(); pos; )
{
CString strTimerName;
CTimer * t;
m_TimerMap.GetNextAssoc (pos, strTimerName, t);
if (t->bTemporary || t->bIncluded) // don't save temporary timers
continue;
Save_One_Timer_XML (ar, t);
} // end of looping through each timer
Save_Footer_XML (ar, "timers");
} // end of CMUSHclientDoc::Save_Timers_XML
void CMUSHclientDoc::Save_One_Timer_XML (CArchive& ar, CTimer * t)
{
ar.WriteString (" <timer ");
Save_XML_string (ar, "name", t->strLabel, true);
Save_XML_string (ar, "script", t->strProcedure, true);
Save_XML_boolean (ar, "enabled", t->bEnabled, true);
Save_XML_number (ar, "hour", (t->iType == CTimer::eAtTime ? t->iAtHour : t->iEveryHour), true);
Save_XML_number (ar, "minute", (t->iType == CTimer::eAtTime ? t->iAtMinute : t->iEveryMinute), true);
Save_XML_double (ar, "second", (t->iType == CTimer::eAtTime ? t->fAtSecond : t->fEverySecond), true);
Save_XML_number (ar, "offset_hour", t->iOffsetHour, true);
Save_XML_number (ar, "offset_minute", t->iOffsetMinute, true);
Save_XML_double (ar, "offset_second", t->fOffsetSecond, true);
Save_XML_number (ar, "send_to", t->iSendTo);
Save_XML_boolean (ar, "temporary", t->bTemporary);
Save_XML_number (ar, "user", t->iUserOption);
Save_XML_boolean (ar, "at_time", t->iType, true);
Save_XML_string (ar, "group", t->strGroup, true);
Save_XML_string (ar, "variable", t->strVariable);
Save_XML_boolean (ar, "one_shot", t->bOneShot, true);
Save_XML_boolean (ar, "omit_from_output", t->bOmitFromOutput, true);
Save_XML_boolean (ar, "omit_from_log", t->bOmitFromLog, true);
Save_XML_boolean (ar, "active_closed", t->bActiveWhenClosed, true);
ar.WriteString (">" NL);
Save_XML_multi (ar, "send", t->strContents);
ar.WriteString (NL" </timer>" NL);
} // end of CMUSHclientDoc::Save_One_Timer_XML
extern CString strMacroDescriptions [MACRO_COUNT];
void CMUSHclientDoc::Save_Macros_XML (CArchive& ar)
{
Save_Header_XML (ar, "macros");
for (int i = 0; i < NUMITEMS (strMacroDescriptions); i++)
{
// ignore ones that don't send anything
if (m_macros [i].IsEmpty ())
continue;
Save_One_Macro_XML (ar, i);
} // end of macros loop
Save_Footer_XML (ar, "macros");
} // end of CMUSHclientDoc::Save_Macros_XML
void CMUSHclientDoc::Save_One_Macro_XML (CArchive& ar, const int iIndex)
{
CString strType;
switch (m_macro_type [iIndex])
{
case REPLACE_COMMAND: strType = "replace";
break;
case SEND_NOW: strType = "send_now";
break;
case ADD_TO_COMMAND: strType = "insert";
break;
default: strType = "unknown";
break;
} // end of switch
ar.WriteString (NL " <macro ");
Save_XML_string (ar, "name", strMacroDescriptions [iIndex], true);
Save_XML_string (ar, "type", strType, true);
ar.WriteString (">" NL);
Save_XML_multi (ar, "send", m_macros [iIndex]);
ar.WriteString (NL" </macro>" NL);
} // end of Save_One_Macro_XML
void CMUSHclientDoc::Save_Colours_XML (CArchive& ar)
{
int i;
Save_Header_XML (ar, "colours");
// warning - we add 1 to sequences so they are 1-relative
ar.WriteString (NL "<ansi>" NL);
ar.WriteString (NL " <normal>" NL);
for (i = 0; i < NUMITEMS (m_normalcolour); i++)
{
ar.WriteString (" <colour ");
Save_XML_number (ar, "seq", i + 1, true);
Save_XML_colour (ar, "rgb", m_normalcolour [i], true);
ar.WriteString ("/>" NL);
}
ar.WriteString (NL " </normal>" NL);
ar.WriteString (NL " <bold>" NL);
for (i = 0; i < NUMITEMS (m_boldcolour); i++)
{
ar.WriteString (" <colour ");
Save_XML_number (ar, "seq", i + 1, true);
Save_XML_colour (ar, "rgb", m_boldcolour [i], true);
ar.WriteString ("/>" NL);
}
ar.WriteString (NL " </bold>" NL);
ar.WriteString (NL "</ansi>" NL);
ar.WriteString (NL "<custom>" NL);
for (i = 0; i < NUMITEMS (m_customtext); i++)
{
ar.WriteString (" <colour ");
Save_XML_number (ar, "seq", i + 1, true);
Save_XML_string (ar, "name", m_strCustomColourName [i], true);
Save_XML_colour (ar, "text", m_customtext [i], true);
Save_XML_colour (ar, "back", m_customback [i], true);
ar.WriteString ("/>" NL);
}
ar.WriteString (NL "</custom>" NL);
Save_Footer_XML (ar, "colours");
} // end of CMUSHclientDoc::Save_Colours_XML
extern CString strKeypadNames [eKeypad_Max_Items];
void CMUSHclientDoc::Save_One_Keypad_XML (CArchive& ar, const int iIndex)
{
ar.WriteString (NL " <key ");
Save_XML_string (ar, "name", strKeypadNames [iIndex], true);
ar.WriteString (">" NL);
Save_XML_multi (ar, "send", m_keypad [iIndex]);
ar.WriteString (" </key>" NL);
} // end of CMUSHclientDoc::Save_One_Keypad_XML
void CMUSHclientDoc::Save_Keypad_XML (CArchive& ar)
{
Save_Header_XML (ar, "keypad");
for (int i = 0; i < eKeypad_Max_Items; i++)
Save_One_Keypad_XML (ar, i);
Save_Footer_XML (ar, "keypad");
} // end of CMUSHclientDoc::Save_Keypad_XML
void CMUSHclientDoc::Save_Printing_XML (CArchive& ar)
{
int i;
Save_Header_XML (ar, "printing");
// warning - we add 1 to sequences so they are 1-relative
ar.WriteString (NL "<ansi>" NL);
ar.WriteString (NL " <normal>" NL);
for (i = 0; i < NUMITEMS (m_nNormalPrintStyle); i++)
{
// ignore ones that are normal
if (m_nNormalPrintStyle [i] == FONT_NORMAL)
continue;
ar.WriteString (" <style ");
Save_XML_number (ar, "seq", i + 1, true);
Save_XML_boolean (ar, "bold", m_nNormalPrintStyle [i] & FONT_BOLD, true);
Save_XML_boolean (ar, "italic", m_nNormalPrintStyle [i] & FONT_ITALIC, true);
Save_XML_boolean (ar, "underline", m_nNormalPrintStyle [i] & FONT_UNDERLINE, true);
ar.WriteString ("/>" NL);
}
ar.WriteString (NL " </normal>" NL);
ar.WriteString (NL " <bold>" NL);
for (i = 0; i < NUMITEMS (m_nBoldPrintStyle); i++)
{
// ignore ones that are normal
if (m_nBoldPrintStyle [i] == FONT_NORMAL)
continue;
ar.WriteString (" <style ");
Save_XML_number (ar, "seq", i + 1, true);
Save_XML_boolean (ar, "bold", m_nBoldPrintStyle [i] & FONT_BOLD, true);
Save_XML_boolean (ar, "italic", m_nBoldPrintStyle [i] & FONT_ITALIC, true);
Save_XML_boolean (ar, "underline", m_nBoldPrintStyle [i] & FONT_UNDERLINE, true);
ar.WriteString ("/>" NL);
}
ar.WriteString (NL " </bold>" NL);
ar.WriteString (NL "</ansi>" NL);
Save_Footer_XML (ar, "printing");
} // end of CMUSHclientDoc::Save_Printing_XML
void CMUSHclientDoc::Save_Includes_XML (CArchive& ar)
{
CString strFileName;
for (POSITION pos = m_strIncludeFileList.GetHeadPosition (); pos; )
{
strFileName = m_strIncludeFileList.GetNext (pos);
ar.WriteString ("<include ");
Save_XML_string (ar, "name", strFileName, true);
ar.WriteString ("/>" NL);
}
} // end of CMUSHclientDoc::Save_Includes_XML
void CMUSHclientDoc::Save_Plugins_XML (CArchive& ar)
{
if (m_PluginList.size () > 0)
ar.WriteString (NL "<!-- plugins -->" NL);
for (PluginListIterator pit = m_PluginList.begin ();
pit != m_PluginList.end ();
++pit)
{
CPlugin * p = *pit;
if (!p->m_bGlobal)
{
CString strSource = p->m_strSource;
CString strPluginsPath = Make_Absolute_Path (App.m_strPluginsDirectory);
// strip absolute path if possible
if (!strPluginsPath.IsEmpty ())
if (strSource.Left (strPluginsPath.GetLength ()) ==
strPluginsPath)
strSource = strSource.Mid (strPluginsPath.GetLength ());
ar.WriteString ("<include ");
Save_XML_string (ar, "name", strSource, true);
Save_XML_boolean (ar, "plugin", true, true);
ar.WriteString ("/>" NL);
} // end of local plugin
}
} // end of CMUSHclientDoc::Save_Plugins_XML