4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #include "TrafficDatabases.hpp"
27 #include "FlarmDetails.hpp"
28 #include "FlarmNetReader.hpp"
29 #include "NameFile.hpp"
30 #include "Friends.hpp"
31 #include "Components.hpp"
32 #include "MergeThread.hpp"
33 #include "IO/DataFile.hpp"
34 #include "IO/TextWriter.hpp"
35 #include "Profile/FlarmProfile.hpp"
36 #include "LogFile.hpp"
39 * Loads the FLARMnet file
42 LoadFLARMnet(FlarmNetDatabase
&db
)
44 NLineReader
*reader
= OpenDataTextFileA(_T("data.fln"));
48 unsigned num_records
= FlarmNetReader::LoadFile(*reader
, db
);
52 LogFormat("%u FLARMnet ids found", num_records
);
56 * Opens XCSoars own FLARM details file, parses it and
57 * adds its entries as FlarmLookupItems
58 * @see AddSecondaryItem
61 LoadSecondary(FlarmNameDatabase
&db
)
63 LogFormat("OpenFLARMDetails");
65 TLineReader
*reader
= OpenDataTextFile(_T("xcsoar-flarm.txt"));
67 LoadFlarmNameFile(*reader
, db
);
75 if (traffic_databases
!= nullptr)
78 traffic_databases
= new TrafficDatabases();
80 /* the MergeThread must be suspended, because it reads the FLARM
82 merge_thread
->Suspend();
84 LoadSecondary(traffic_databases
->flarm_names
);
85 LoadFLARMnet(traffic_databases
->flarm_net
);
86 Profile::Load(traffic_databases
->flarm_colors
);
88 merge_thread
->Resume();
94 if (traffic_databases
!= nullptr)
95 Profile::Save(traffic_databases
->flarm_colors
);
99 * Saves XCSoars own FLARM details into the
100 * corresponding file (xcsoar-flarm.txt)
103 SaveSecondary(FlarmNameDatabase
&flarm_names
)
105 TextWriter
*writer
= CreateDataTextFile(_T("xcsoar-flarm.txt"));
109 SaveFlarmNameFile(*writer
, flarm_names
);
116 if (traffic_databases
!= nullptr)
117 SaveSecondary(traffic_databases
->flarm_names
);
121 DeinitTrafficGlobals()
123 delete traffic_databases
;
124 traffic_databases
= nullptr;