outfd.puts(" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd\">\n");
outfd.puts(" <metadata>\n");
outfd.printf(" <name>%s</name>\n", Markup.escape_text(title));
+ outfd.printf(" <keywords>%s</keywords>\n", Markup.escape_text(tag));
outfd.puts(" </metadata>\n");
if (track != null) writeTrack(outfd);
if (entries != null) writeEntries(outfd);
break;
}
}
+ else if (name == "keywords")
+ {
+ result.tag = cur_text;
+ }
else if (name == "time")
{
Time t = Time();
{
protected List<Log> logs;
+ public signal void entries_changed();
+
public Logger()
{
logs = null;
pop(log);
log.save();
if (logs == null) end_trace();
+ entries_changed();
}
public Log load(string fname)
return parser.result;
}
- protected size_t list_dir(string dir, ref List<string> res)
+ public void set_acknowledged(string name, bool acked)
+ {
+ string from, to;
+ if (acked)
+ {
+ from = config.homedir + "/log/" + name;
+ to = config.homedir + "/archive/" + name;
+ DirUtils.create(config.homedir + "/archive", 0777);
+ } else {
+ from = config.homedir + "/archive/" + name;
+ to = config.homedir + "/log/" + name;
+ DirUtils.create(config.homedir + "/log", 0777);
+ }
+ if (FileUtils.test(from, FileTest.EXISTS))
+ {
+ FileUtils.rename(from, to);
+ entries_changed();
+ }
+ }
+
+ public delegate bool EntriesVisitor(string dir, string name);
+
+ protected void list_dir(string dir, EntriesVisitor visitor)
{
- size_t count = 0;
var d = File.new_for_path(dir);
var enumerator = d.enumerate_children(FILE_ATTRIBUTE_STANDARD_NAME, 0, null);
FileInfo file_info;
while ((file_info = enumerator.next_file(null)) != null)
{
if (!file_info.get_name().has_suffix(".gpx")) continue;
- res.append(file_info.get_name());
- ++count;
+ if (!visitor(dir, file_info.get_name()))
+ break;
}
- return count;
}
- public string[] list_entries(bool only_unacked=true)
+ public void list_entries(EntriesVisitor visitor, bool only_unacked=true)
{
- size_t count = 0;
- List<string> entries = new List<string>();
if (!only_unacked)
- count += list_dir(config.homedir + "/archive", ref entries);
- count += list_dir(config.homedir + "/log", ref entries);
- string[] res = new string[count+1];
- size_t cur = 0;
- for (weak List<string> i = entries; i != null; i = i.next)
- res[cur++] = i.data;
- res[cur] = null;
- return res;
+ list_dir(config.homedir + "/archive", visitor);
+ list_dir(config.homedir + "/log", visitor);
}
public void instant(string tag, string msg)