package Lire::WWW::UserAgent::Browser;
#
# $Id: Browser.pm,v 1.10 2002/06/14 16:22:01 flacoste Exp $
#
# The data in this module is taken from AWStats. (http://awstats.sf.net/)
# Rewritten by Egon Willighagen for LogReport.org (http://logreport.org/)
#
# Copyright (C) 2000, 2001 - Laurent Destailleur - eldy@users.sourceforge.net
# Copyright (C) 2001, 2002 Stichting LogReport Foundation <logreport@logreport.org>
#
#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either version 2 of the License, or
#     (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with this program (see COPYING); if not, check with
#     http://www.gnu.org/copyleft/gpl.html or write to the Free Software
#     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
#
use strict;
use vars qw/ $REVISION/;

BEGIN {
    $REVISION  = '$Id: Browser.pm,v 1.10 2002/06/14 16:22:01 flacoste Exp $';
}

# -----------------------------------------------------------------------------
# Database
# -----------------------------------------------------------------------------

my %BrowserHash = (
# msie and netscape are detected in getBrowser()
# Most frequent browsers should be first in this list
"lynx" => "Lynx",
"opera" => "Opera",
"wget" => "Wget",

#

"22acidownload" => "22AciDownload",
"aol\\-iweng" => "AOL-Iweng",
"amaya" => "Amaya",
"amigavoyager" => "AmigaVoyager",
"antfresco" => "ANT Fresco",
"bpftp" => "BPFTP",
"cyberdog" => "Cyberdog",
"dreamcast" => "Dreamcast",
"downloadagent" => "DownloadAgent",
"ecatch", "eCatch",
"emailsiphon" => "EmailSiphon",
"fetch" => "FreeBSD's fetch",
"friendlyspider" => "FriendlySpider",
"galeon" => "Galeon",
"getright" => "GetRight",
"go!zilla" => "Go!Zilla",
"headdump" => "HeadDump",
"hotjava" => "Sun HotJava",
"ibrowse" => "IBrowse",
"icab" => "iCab",
"intergo" => "InterGO",
"konqueror" => "Konqueror",
"libwww" => "LibWWW",
"linemodebrowser" => "W3C Line Mode Browser",
"links" => "Links",
"lotus-notes" => "Lotus Notes web client",
"macweb" => "MacWeb",
"ncsa_mosaic" => "NCSA Mosaic",
"netpositive" => "NetPositive",
"nutscrape", "Nutscrape",
"msfrontpageexpress" => "MS FrontPage Express",
"omniweb" => "OmniWeb",
"teleport" => "TelePort Pro (Site grabber)",
"tzgeturl" => "TZGETURL",
"viking" => "Viking",
"w3m"  => "W3m",
"webcapture" => "Acrobat (Site grabber)",
"webfetcher" => "WebFetcher",
"webexplorer" => "IBM-WebExplorer",
"webmirror" => "WebMirror",
"webvcr" => "WebVCR",

# Music only browsers

"real" => "RealAudio or compatible player",
"winamp" => "WinAmp",
"windows-media-player" => "Windows Media Player",
"audion" => "Audion",
"freeamp" => "FreeAmp",
"itunes" => "Apple iTunes",
"jetaudio" => "JetAudio",
"mint_audio" => "Mint Audio",
"mpg123" => "mpg123",
"nsplayer" => "NetShow Player",
"sonique" => "Sonique media player",
"uplayer" => "Ultra Player",
"xmms" => "XMMS",
"xaudio" => "Some XAudio Engine based MPEG player",

# Other kind of browsers
"offline_explorer" => "Offline Explorer",
"debian_apt" => "Debian APT",
"webzip" => "WebZIP",

# Other engine OS (PDA, phonecells, TV)

"mmef" => "Microsoft Mobile Explorer",
"mspie" => "MS Pocket Internet Explorer",
"webtv" => "WebTV browser",
);

# -----------------------------------------------------------------------------
# Functions
# -----------------------------------------------------------------------------

sub getBrowser {
    my ( $ua) = @_;

    # IE ? (For higher speed, we start whith IE, the most often used.
    #       This avoid other tests if found)
    if (($ua =~ /msie/) && ($ua !~ /webtv/) &&
        ($ua !~ /omniweb/) && ($ua !~ /opera/)) {
        return "MS Internet Exporer";
    }

    # Mozilla ?
    if (($ua =~ /gecko/) && ($ua !~ /galeon/)) {
        return "Mozilla";
    }

    # Netscape ?
    if (($ua =~ /mozilla/) && ($ua !~ /compatible/) &&
        ($ua !~ /opera/) && ( $ua !~ /galeon/)) {
        return "Netscape Navigator";
    }

    # Other ?
    foreach my $b (keys %BrowserHash) {
        return $BrowserHash{$b} if index( $ua, $b ) >= 0;
    }

    return undef;
}

1;

