// License: BSD/LGPL
// Copyright (C) 2011 Thomas d'Otreppe
using System;
using System.Data;
namespace WirelessPanda.Readers
{
public class UniversalReader : Reader
{
///
/// Reader
///
private Reader _reader = null;
///
/// File type
///
/// So that we have to check it only once
private string _fileType = string.Empty;
#region Properties
///
/// DataSet containing 2 tables: "Access Points" and "Stations"
///
public override DataSet Dataset
{
get
{
return this._reader.Dataset;
}
}
///
/// Array of access points
///
public override AccessPoint[] AccessPoints
{
get
{
return this._reader.AccessPoints;
}
}
///
/// Array of stations
///
public override Station[] Stations
{
get
{
return this._reader.Stations;
}
}
///
/// Reader type
///
public override string ReaderType
{
get
{
return "Universal: Airodump-ng CSV, Kismet CSV, Kismet NetXML";
}
}
#endregion
///
/// Constructor
///
/// Filename (doesn't need to exist now but MUST when using Read() )
public UniversalReader(string filename) : base(filename) { }
///
/// Read/Update the content of the file
///
/// true if successful
public override bool Read()
{
this.ParseSuccess = false;
if (string.IsNullOrEmpty(this._fileType))
{
this._fileType = Reader.getFileType(this.Filename);
}
switch (this._fileType)
{
case "Airodump-ng CSV":
this._reader = new CsvReader(this.Filename);
break;
case "Kismet CSV":
this._reader = new KismetCsvReader(this.Filename);
break;
case "Kismet NetXML":
this._reader = new NetXMLReader(this.Filename);
break;
default:
throw new FormatException("Unknown file format, can't parse");
break;
}
this.ParseSuccess = this._reader.Read();
return this.ParseSuccess;
}
}
}