Full Code of ahand/mobileesp for AI

master c02055dbe9ba cached
20 files
382.4 KB
95.6k tokens
376 symbols
1 requests
Download .txt
Showing preview only (396K chars total). Download the full file or copy to clipboard to get everything.
Repository: ahand/mobileesp
Branch: master
Commit: c02055dbe9ba
Files: 20
Total size: 382.4 KB

Directory structure:
gitextract_t1__mu8f/

├── ASP_NET/
│   ├── Sub-Classed Page Technique/
│   │   ├── MDetectPage.cs
│   │   ├── MDetect_Test.aspx
│   │   └── MDetect_Test.aspx.cs
│   └── UserControl Technique/
│       ├── MDetectControl.cs
│       ├── MobileDetectControl.ascx
│       ├── MobileDetectControl.ascx.cs
│       ├── MobileDetectControl.ascx.designer.cs
│       ├── MobileDetectTestPage.aspx
│       ├── MobileDetectTestPage.aspx.cs
│       └── MobileDetectTestPage.aspx.designer.cs
├── Cpp/
│   └── mdetect.h
├── Java/
│   └── UAgentInfo.java
├── JavaScript/
│   └── mdetect.js
├── LICENSE
├── MobileESP_UA-Test-Strings/
│   ├── MobileESP UA Test Strings - UA Strings.csv
│   └── MobileESP UA Test Strings.xlsx
├── PHP/
│   └── mdetect.php
├── Python/
│   └── mdetect.py
├── README.md
└── composer.json

================================================
FILE CONTENTS
================================================

================================================
FILE: ASP_NET/Sub-Classed Page Technique/MDetectPage.cs
================================================
/* *******************************************
// Copyright 2010-2015, Anthony Hand
//
//
// File version 2015.05.13 (May 13, 2015)
// Updates:
//	- Moved MobileESP to GitHub. https://github.com/ahand/mobileesp
//	- Opera Mobile/Mini browser has the same UA string on multiple platforms and doesn't differentiate phone vs. tablet. 
//		- Removed DetectOperaAndroidPhone(). This method is no longer reliable. 
//		- Removed DetectOperaAndroidTablet(). This method is no longer reliable. 
//	- Added support for Windows Phone 10: variable and DetectWindowsPhone10()
//	- Updated DetectWindowsPhone() to include WP10. 
//	- Added support for Firefox OS.  
//		- A variable plus DetectFirefoxOS(), DetectFirefoxOSPhone(), DetectFirefoxOSTablet()
//		- NOTE: Firefox doesn't add UA tokens to definitively identify Firefox OS vs. their browsers on other mobile platforms.
//	- Added support for Sailfish OS. Not enough info to add a tablet detection method at this time. 
//		- A variable plus DetectSailfish(), DetectSailfishPhone()
//	- Added support for Ubuntu Mobile OS. 
//		- DetectUbuntu(), DetectUbuntuPhone(), DetectUbuntuTablet()
//	- Added support for 2 smart TV OSes. They lack browsers but do have WebViews for use by HTML apps. 
//		- One variable for Samsung Tizen TVs, plus DetectTizenTV()
//		- One variable for LG WebOS TVs, plus DetectWebOSTV()
//	- Added DetectTizen(). Tests for “mobile” to disambiguate from Samsung Smart TVs.
//	- Removed variables for obsolete devices: deviceHtcFlyer, deviceXoom.
//	- Updated DetectAndroid(). No longer has a special test case for the HTC Flyer tablet. 
//	- Updated DetectAndroidPhone(). 
//		- Updated internal detection code for Android. 
//		- No longer has a special test case for the HTC Flyer tablet. 
//		- Checks against DetectOperaMobile() on Android and reports here if relevant. 
//	- Updated DetectAndroidTablet(). 
//		- No longer has a special test case for the HTC Flyer tablet. 
//		- Checks against DetectOperaMobile() on Android to exclude it from here.
//	- DetectMeego(): Changed definition for this method. Now detects any Meego OS device, not just phones. 
//	- DetectMeegoPhone(): NEW. For Meego phones. Ought to detect Opera browsers on Meego, as well.  
//	- DetectTierIphone(): Added support for phones running Sailfish, Ubuntu and Firefox Mobile. 
//	- DetectTierTablet(): Added support for tablets running Ubuntu and Firefox Mobile. 
//	- DetectSmartphone(): Added support for Meego phones. 
//	- Caught this library up to the PHP, JavaScript and Java versions. Updates include: 
//		- Added support for Bada: a variable and DetectBada(). This detects any Bada OS device, but (almost) all are phones.
//		- Refactored the Windows Phone delegate-related properties and features. Now fires for any Windows Phone, not just WP7. 
//			- The event fires now when DetectWindowsPhone() is true. 
//		- Added support for Windows Phone 8: DetectWindowsPhone8().
//		- Updated DetectWindowsMobile(). Excludes any Windows Phone device, not just WP7. 
//		- Added support for BlackBerry 10 OS phones: DetectBlackBerry10Phone().
//		- Updated DetectSonyMylo().
//		- Updated DetectSmartphone() to sync with the other libraries. 
//		- Updated DetectTierIphone() to sync with the other libraries.
//		- OnInit(EventArgs e): Fixed the user agent and httpaccept init logic.
//	- Refactored the detection logic in DetectMobileQuick() and DetectMobileLong().
//		- Moved a few detection tests for older browsers to Long. 
//
//
//
// LICENSE INFORMATION
// Licensed under the Apache License, Version 2.0 (the "License"); 
// you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at 
//        http://www.apache.org/licenses/LICENSE-2.0 
// Unless required by applicable law or agreed to in writing, 
// software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific 
// language governing permissions and limitations under the License. 
//
//
// ABOUT THIS PROJECT
//   Project Owner: Anthony Hand
//   Email: anthony.hand@gmail.com
//   Web Site: http://www.mobileesp.com
//   Source Files: https://github.com/ahand/mobileesp
//   
//   Versions of this code are available for:
//      PHP, JavaScript, Java, ASP.NET (C#), and Ruby
//
// *******************************************
*/


using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

/// <summary>
/// Subclass this page to inherit the built-in mobile device detection.
/// </summary>
public class MDetectPage : System.Web.UI.Page
{

    private string useragent = "";
    private string httpaccept = "";

    #region Fields - Detection Argument Values

    //standardized values for detection arguments.
    private const string dargsIphone = "iphone";
    private const string dargsIpod = "ipod";
    private const string dargsIpad = "ipad";
    private const string dargsIphoneOrIpod = "iphoneoripod";
    private const string dargsIos = "ios";
    private const string dargsAndroid = "android";
    private const string dargsAndroidPhone = "androidphone";
    private const string dargsAndroidTablet = "androidtablet";
    private const string dargsGoogleTV = "googletv";
    private const string dargsWebKit = "webkit";
    private const string dargsSymbianOS = "symbianos";
    private const string dargsS60 = "series60";
    private const string dargsWindowsPhone = "windowsphone";
    private const string dargsWindowsMobile = "windowsmobile";
    private const string dargsBlackBerry = "blackberry";
    private const string dargsBlackBerryWebkit = "blackberrywebkit";
    private const string dargsPalmOS = "palmos";
    private const string dargsPalmWebOS = "webos";
    private const string dargsWebOSTablet = "webostablet";
    private const string dargsSmartphone = "smartphone";
    private const string dargsBrewDevice = "brew";
    private const string dargsDangerHiptop = "dangerhiptop";
    private const string dargsOperaMobile = "operamobile";
    private const string dargsWapWml = "wapwml";
    private const string dargsKindle = "kindle";
    private const string dargsMobileQuick = "mobilequick";
    private const string dargsTierTablet = "tiertablet";
    private const string dargsTierIphone = "tieriphone";
    private const string dargsTierRichCss = "tierrichcss";
    private const string dargsTierOtherPhones = "tierotherphones";

    #endregion Fields - Detection Argument Values

    #region Fields - User Agent Keyword Values

    private const string engineWebKit = "WEBKIT";
    private const string deviceIphone = "IPHONE";
    private const string deviceIpod = "IPOD";
    private const string deviceIpad = "IPAD";
    private const string deviceMacPpc = "MACINTOSH"; //Used for disambiguation

    private const string deviceAndroid = "ANDROID";
    private const string deviceGoogleTV = "GOOGLETV";

    private const string deviceNuvifone = "NUVIFONE";  //Garmin Nuvifone
    private const string deviceBada = "BADA";  //Samsung's Bada OS    
    private const string deviceTizen = "TIZEN";  //Tizen OS    
    private const string deviceMeego = "MEEGO";  //Meego OS    
    private const string deviceSailfish = "SAILFISH";  //Sailfish OS
    private const string deviceUbuntu = "UBUNTU";  //Ubuntu Mobile OS

    private const string deviceSymbian = "SYMBIAN";
    private const string deviceS60 = "SERIES60";
    private const string deviceS70 = "SERIES70";
    private const string deviceS80 = "SERIES80";
    private const string deviceS90 = "SERIES90";

    private const string deviceWinPhone7 = "WINDOWS PHONE OS 7";
    private const string deviceWinPhone8 = "WINDOWS PHONE 8";
    private const string deviceWinPhone10 = "WINDOWS PHONE 10";
    private const string deviceWinMob = "WINDOWS CE";
    private const string deviceWindows = "WINDOWS";
    private const string deviceIeMob = "IEMOBILE";
    private const string devicePpc = "PPC"; //Stands for PocketPC
    private const string enginePie = "WM5 PIE"; //An old Windows Mobile browser

    private const string deviceBB = "BLACKBERRY";
    private const string deviceBB10 = "BB10"; //For the new BB 10 OS
    private const string vndRIM = "VND.RIM"; //Detectable when BB devices emulate IE or Firefox
    private const string deviceBBStorm = "BLACKBERRY95"; //Storm 1 and 2
    private const string deviceBBBold = "BLACKBERRY97"; //Bold 97x0 (non-touch)
    private const string deviceBBBoldTouch = "BLACKBERRY 99"; //Bold 99x0 (touchscreen)
    private const string deviceBBTour = "BLACKBERRY96"; //Tour
    private const string deviceBBCurve = "BLACKBERRY89"; //Curve2
    private const string deviceBBCurveTouch = "BLACKBERRY 938"; //Curve Touch 9380
    private const string deviceBBTorch = "BLACKBERRY 98"; //Torch
    private const string deviceBBPlaybook = "PLAYBOOK"; //PlayBook tablet

    private const string devicePalm = "PALM";
    private const string deviceWebOS = "WEBOS"; //For Palm devices
    private const string deviceWebOStv = "WEB0S"; //For LG TVs
    private const string deviceWebOShp = "HPWOS"; //For HP's line of WebOS devices

    private const string engineBlazer = "BLAZER"; //Old Palm
    private const string engineXiino = "XIINO"; //Another old Palm

    private const string deviceKindle = "KINDLE";  //Amazon Kindle, eInk one
    private const string engineSilk = "SILK";  //Amazon's accelerated Silk browser for Kindle Fire

    //Initialize private strings for mobile-specific content.
    private const string vndwap = "VND.WAP";
    private const string wml = "WML";

    //Initialize private strings for other random devices and mobile browsers.
    private const string deviceTablet = "TABLET"; //Generic term for slate and tablet devices
    private const string deviceBrew = "BREW";
    private const string deviceDanger = "DANGER";
    private const string deviceHiptop = "HIPTOP";
    private const string devicePlaystation = "PLAYSTATION";
    private const string devicePlaystationVita = "VITA";
    private const string deviceNintendoDs = "NITRO";
    private const string deviceNintendo = "NINTENDO";
    private const string deviceWii = "WII";
    private const string deviceXbox = "XBOX";
    private const string deviceArchos = "ARCHOS";

    private const string engineFirefox = "FIREFOX"; //For Firefox OS
    private const string engineOpera = "OPERA"; //Popular browser
    private const string engineNetfront = "NETFRONT"; //Common embedded OS browser
    private const string engineUpBrowser = "UP.BROWSER"; //common on some phones
    private const string engineOpenWeb = "OPENWEB"; //Transcoding by OpenWave server
    private const string deviceMidp = "MIDP"; //a mobile Java technology
    private const string uplink = "UP.LINK";
    private const string engineTelecaQ = "TELECA Q"; //a modern feature phone browser

    private const string devicePda = "PDA"; //some devices report themselves as PDAs
    private const string mini = "MINI";  //Some mobile browsers put "mini" in their names.
    private const string mobile = "MOBILE"; //Some mobile browsers put "mobile" in their user agent private strings.
    private const string mobi = "MOBI"; //Some mobile browsers put "mobi" in their user agent private strings.

    //Smart TV strings
    private const string smartTV1 = "SMART-TV"; //Samsung Tizen smart TVs
    private const string smartTV2 = "SMARTTV"; //LG WebOS smart TVs

    //Use Maemo, Tablet, and Linux to test for Nokia"s Internet Tablets.
    private const string maemo = "MAEMO";
    private const string linux = "LINUX";
    private const string qtembedded = "QT EMBEDDED"; //for Sony Mylo
    private const string mylocom2 = "COM2"; //for Sony Mylo also

    //In some UserAgents, the only clue is the manufacturer.
    private const string manuSonyEricsson = "SONYERICSSON";
    private const string manuericsson = "ERICSSON";
    private const string manuSamsung1 = "SEC-SGH";
    private const string manuSony = "SONY";
    private const string manuHtc = "HTC"; //Popular Android and WinMo manufacturer

    //In some UserAgents, the only clue is the operator.
    private const string svcDocomo = "DOCOMO";
    private const string svcKddi = "KDDI";
    private const string svcVodafone = "VODAFONE";

    //Disambiguation strings.
    private const string disUpdate = "UPDATE"; //pda vs. update

    #endregion Fields - User Agent Keyword Values

    /// <summary>
    /// To instantiate a WebPage sub-class with built-in
    /// mobile device detection delegates and events.
    /// </summary>
    public MDetectPage()
    {

    }

    /// <summary>
    /// To run the device detection methods andd fire 
    /// any existing OnDetectXXX events. 
    /// </summary>
    public void FireEvents()
    {
        if (useragent == "" && httpaccept == "")
        {
            useragent = (Request.ServerVariables["HTTP_USER_AGENT"] ?? "").ToUpper();
            httpaccept = (Request.ServerVariables["HTTP_ACCEPT"] ?? "").ToUpper();
        }

        #region Event Fire Methods

        MDetectArgs mda = null;
        if (this.DetectIpod())
        {
            mda = new MDetectArgs(dargsIpod);
            if (this.OnDetectIpod != null)
            {
                this.OnDetectIpod(this, mda);
            }
        }
        if (this.DetectIpad())
        {
            mda = new MDetectArgs(dargsIpad);
            if (this.OnDetectIpad != null)
            {
                this.OnDetectIpad(this, mda);
            }
        }
        if (this.DetectIphone())
        {
            mda = new MDetectArgs(dargsIphone);
            if (this.OnDetectIphone != null)
            {
                this.OnDetectIphone(this, mda);
            }
        }
        if (this.DetectIphoneOrIpod())
        {
            mda = new MDetectArgs(dargsIphoneOrIpod);
            if (this.OnDetectDetectIPhoneOrIpod != null)
            {
                this.OnDetectDetectIPhoneOrIpod(this, mda);
            }
        }
        if (this.DetectIos())
        {
            mda = new MDetectArgs(dargsIos);
            if (this.OnDetectIos != null)
            {
                this.OnDetectIos(this, mda);
            }
        }
        if (this.DetectAndroid())
        {
            mda = new MDetectArgs(dargsAndroid);
            if (this.OnDetectAndroid != null)
            {
                this.OnDetectAndroid(this, mda);
            }
        }
        if (this.DetectAndroidPhone())
        {
            mda = new MDetectArgs(dargsAndroidPhone);
            if (this.OnDetectAndroidPhone != null)
            {
                this.OnDetectAndroidPhone(this, mda);
            }
        }
        if (this.DetectAndroidTablet())
        {
            mda = new MDetectArgs(dargsAndroidTablet);
            if (this.OnDetectAndroidTablet != null)
            {
                this.OnDetectAndroidTablet(this, mda);
            }
        }
        if (this.DetectGoogleTV())
        {
            mda = new MDetectArgs(dargsGoogleTV);
            if (this.OnDetectGoogleTV != null)
            {
                this.OnDetectGoogleTV(this, mda);
            }
        }
        if (this.DetectWebkit())
        {
            mda = new MDetectArgs(dargsWebKit);
            if (this.OnDetectWebkit != null)
            {
                this.OnDetectWebkit(this, mda);
            }
        }
        if (this.DetectS60OssBrowser())
        {
            mda = new MDetectArgs(dargsS60);
            if (this.OnDetectS60OssBrowser != null)
            {
                this.OnDetectS60OssBrowser(this, mda);
            }
        }
        if (this.DetectSymbianOS())
        {
            mda = new MDetectArgs(dargsSymbianOS);
            if (this.OnDetectSymbianOS != null)
            {
                this.OnDetectSymbianOS(this, mda);
            }
        }
        if (this.DetectWindowsPhone())
        {
            mda = new MDetectArgs(dargsWindowsPhone);
            if (this.OnDetectWindowsPhone != null)
            {
                this.OnDetectWindowsPhone(this, mda);
            }
        }
        if (this.DetectWindowsMobile())
        {
            mda = new MDetectArgs(dargsWindowsMobile);
            if (this.OnDetectWindowsMobile != null)
            {
                this.OnDetectWindowsMobile(this, mda);
            }
        }
        if (this.DetectBlackBerry())
        {
            mda = new MDetectArgs(dargsBlackBerryWebkit);
            if (this.OnDetectBlackBerry != null)
            {
                this.OnDetectBlackBerry(this, mda);
            }
        }
        if (this.DetectBlackBerryWebKit())
        {
            mda = new MDetectArgs(dargsBlackBerryWebkit);
            if (this.OnDetectBlackBerryWebkit != null)
            {
                this.OnDetectBlackBerryWebkit(this, mda);
            }
        }
        if (this.DetectPalmOS())
        {
            mda = new MDetectArgs(dargsPalmOS);
            if (this.OnDetectPalmOS != null)
            {
                this.OnDetectPalmOS(this, mda);
            }
        }
        if (this.DetectPalmWebOS())
        {
            mda = new MDetectArgs(dargsPalmWebOS);
            if (this.OnDetectPalmWebOS != null)
            {
                this.OnDetectPalmWebOS(this, mda);
            }
        }
        if (this.DetectWebOSTablet())
        {
            mda = new MDetectArgs(dargsWebOSTablet);
            if (this.OnDetectWebOSTablet != null)
            {
                this.OnDetectWebOSTablet(this, mda);
            }
        }
        if (this.DetectSmartphone())
        {
            mda = new MDetectArgs(dargsSmartphone);
            if (this.OnDetectSmartphone != null)
            {
                this.OnDetectSmartphone(this, mda);
            }
        }
        if (this.DetectBrewDevice())
        {
            mda = new MDetectArgs(dargsBrewDevice);
            if (this.OnDetectBrewDevice != null)
            {
                this.OnDetectBrewDevice(this, mda);
            }
        }
        if (this.DetectDangerHiptop())
        {
            mda = new MDetectArgs(dargsDangerHiptop);
            if (this.OnDetectDangerHiptop != null)
            {
                this.OnDetectDangerHiptop(this, mda);
            }
        }
        if (this.DetectOperaMobile())
        {
            mda = new MDetectArgs(dargsOperaMobile);
            if (this.OnDetectOperaMobile != null)
            {
                this.OnDetectOperaMobile(this, mda);
            }
        }
        if (this.DetectWapWml())
        {
            mda = new MDetectArgs(dargsWapWml);
            if (this.OnDetectWapWml != null)
            {
                this.OnDetectWapWml(this, mda);
            }
        }
        if (this.DetectKindle())
        {
            mda = new MDetectArgs(dargsKindle);
            if (this.OnDetectKindle != null)
            {
                this.OnDetectKindle(this, mda);
            }
        }
        if (this.DetectMobileQuick())
        {
            mda = new MDetectArgs(dargsMobileQuick);
            if (this.OnDetectMobileQuick != null)
            {
                this.OnDetectMobileQuick(this, mda);
            }
        }
        if (this.DetectTierTablet())
        {
            mda = new MDetectArgs(dargsTierTablet);
            if (this.OnDetectTierTablet != null)
            {
                this.OnDetectTierTablet(this, mda);
            }
        }
        if (this.DetectTierIphone())
        {
            mda = new MDetectArgs(dargsTierIphone);
            if (this.OnDetectTierIphone != null)
            {
                this.OnDetectTierIphone(this, mda);
            }
        }
        if (this.DetectTierRichCss())
        {
            mda = new MDetectArgs(dargsTierRichCss);
            if (this.OnDetectTierRichCss != null)
            {
                this.OnDetectTierRichCss(this, mda);
            }
        }
        if (this.DetectTierOtherPhones())
        {
            mda = new MDetectArgs(dargsTierOtherPhones);
            if (this.OnDetectTierOtherPhones != null)
            {
                this.OnDetectTierOtherPhones(this, mda);
            }
        }

        #endregion Event Fire Methods

    }

    public class MDetectArgs : EventArgs
    {
        public MDetectArgs(string type)
        {
            this.Type = type;
        }

        public readonly string Type;
    }

    #region Mobile Device Detection Methods 

    //**************************
    // Detects if the current device is an iPod Touch.
    public bool DetectIpod()
    {
        if (useragent.IndexOf(deviceIpod)!= -1)
            return true;
        else
            return false;
    }

    //Ipod delegate
    public delegate void DetectIpodHandler(object page, MDetectArgs args);
    public event DetectIpodHandler OnDetectIpod;


    //**************************
    // Detects if the current device is an iPad tablet.
    public bool DetectIpad()
    {
        if (useragent.IndexOf(deviceIpad) != -1 && DetectWebkit())
            return true;
        else
            return false;
    }

    //Ipod delegate
    public delegate void DetectIpadHandler(object page, MDetectArgs args);
    public event DetectIpadHandler OnDetectIpad;


    //**************************
    // Detects if the current device is an iPhone.
    public bool DetectIphone()
    {
        if (useragent.IndexOf(deviceIphone)!= -1)
        {
            //The iPad and iPod touch say they're an iPhone! So let's disambiguate.
            if (DetectIpad() || DetectIpod())
            {
                return false;
            }
            else
                return true;
        }
        else
            return false;
    }
    //IPhone delegate
    public delegate void DetectIphoneHandler(object page, MDetectArgs args);
    public event DetectIphoneHandler OnDetectIphone;

    //**************************
    // Detects if the current device is an iPhone or iPod Touch.
    public bool DetectIphoneOrIpod()
    {
        //We repeat the searches here because some iPods may report themselves as an iPhone, which would be okay.
        if (useragent.IndexOf(deviceIphone)!= -1 ||
            useragent.IndexOf(deviceIpod)!= -1)
            return true;
        else
            return false;
    }
    //IPhoneOrIpod delegate
    public delegate void DetectIPhoneOrIpodHandler(object page, MDetectArgs args);
    public event DetectIPhoneOrIpodHandler OnDetectDetectIPhoneOrIpod;

    //**************************
    // Detects *any* iOS device: iPhone, iPod Touch, iPad.
    public bool DetectIos()
    {
        if (DetectIphoneOrIpod() || DetectIpad())
            return true;
        else
            return false;
    }

    //Ios delegate
    public delegate void DetectIosHandler(object page, MDetectArgs args);
    public event DetectIosHandler OnDetectIos;


    //**************************
    // Detects *any* Android OS-based device: phone, tablet, and multi-media player.
    // Also detects Google TV.
    public bool DetectAndroid()
    {
        if ((useragent.IndexOf(deviceAndroid) != -1) ||
            DetectGoogleTV())
            return true;
        
        return false;
    }
    //Android delegate
    public delegate void DetectAndroidHandler(object page, MDetectArgs args);
    public event DetectAndroidHandler OnDetectAndroid;

    //**************************
    // Detects if the current device is a (small-ish) Android OS-based device
    // used for calling and/or multi-media (like a Samsung Galaxy Player).
    // Google says these devices will have 'Android' AND 'mobile' in user agent.
    // Ignores tablets (Honeycomb and later).
    public bool DetectAndroidPhone()
    {
        //First, let's make sure we're on an Android device.
        if (!DetectAndroid())
            return false;

        //If it's Android and has 'mobile' in it, Google says it's a phone.
        if (useragent.IndexOf(mobile) != -1)
            return true;

        //Special check for Android devices with Opera Mobile/Mini. They should report here.
        if (DetectOperaMobile())
            return true;
        
        return false;
    }

    //Android Phone delegate
    public delegate void DetectAndroidPhoneHandler(object page, MDetectArgs args);
    public event DetectAndroidPhoneHandler OnDetectAndroidPhone;

    //**************************
    // Detects if the current device is a (self-reported) Android tablet.
    // Google says these devices will have 'Android' and NOT 'mobile' in their user agent.
    public bool DetectAndroidTablet()
    {
        //First, let's make sure we're on an Android device.
        if (!DetectAndroid())
            return false;

        //Special check for Android devices with Opera Mobile/Mini. They should NOT report here.
        if (DetectOperaMobile())
            return false;

        //Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet.
        if (useragent.IndexOf(mobile) > -1)
            return false;
        else
            return true;
    }
    
    //Android Tablet delegate
    public delegate void DetectAndroidTabletHandler(object page, MDetectArgs args);
    public event DetectAndroidTabletHandler OnDetectAndroidTablet;

    //**************************
    // Detects if the current device is a GoogleTV device.
    public bool DetectGoogleTV()
    {
        if (useragent.IndexOf(deviceGoogleTV) != -1)
            return true;
        else
            return false;
    }
    //GoogleTV delegate
    public delegate void DetectGoogleTVHandler(object page, MDetectArgs args);
    public event DetectGoogleTVHandler OnDetectGoogleTV;

    //**************************
    // Detects if the current device is an Android OS-based device and
    //   the browser is based on WebKit.
    public bool DetectAndroidWebKit()
    {
        if (DetectAndroid() && DetectWebkit())
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is based on WebKit.
    public bool DetectWebkit()
    {
        if (useragent.IndexOf(engineWebKit)!= -1)
            return true;
        else
            return false;
    }

    //Webkit delegate
    public delegate void DetectWebkitHandler(object page, MDetectArgs args);
    public event DetectWebkitHandler OnDetectWebkit;

    //**************************
    // Detects if the current browser is the Nokia S60 Open Source Browser.
    public bool DetectS60OssBrowser()
    {
        //First, test for WebKit, then make sure it's either Symbian or S60.
        if (DetectWebkit())
        {
            if (useragent.IndexOf(deviceSymbian)!= -1 ||
                useragent.IndexOf(deviceS60)!= -1)
            {
                return true;
            }
            else
                return false;
        }
        else
            return false;
    }

    //S60OssBrowser delegate
    public delegate void DetectS60OssBrowserHandler(object page, MDetectArgs args);
    public event DetectS60OssBrowserHandler OnDetectS60OssBrowser;

    //**************************
    // Detects if the current device is any Symbian OS-based device,
    //   including older S60, Series 70, Series 80, Series 90, and UIQ, 
    //   or other browsers running on these devices.
    public bool DetectSymbianOS()
    {
        if (useragent.IndexOf(deviceSymbian)!= -1 ||
            useragent.IndexOf(deviceS60)!= -1 ||
            useragent.IndexOf(deviceS70)!= -1 ||
            useragent.IndexOf(deviceS80)!= -1 ||
            useragent.IndexOf(deviceS90)!= -1)
            return true;
        else
            return false;
    }

    //SymbianOS delegate
    public delegate void DetectSymbianOSHandler(object page, MDetectArgs args);
    public event DetectSymbianOSHandler OnDetectSymbianOS;

    //**************************
    // Detects if the current browser is a 
    // Windows Phone 7, 8, or 10 device.
    public bool DetectWindowsPhone()
    {
        if (DetectWindowsPhone7() || 
        	DetectWindowsPhone8() ||
        	DetectWindowsPhone10())
            return true;
        
        return false;
    }

    //WindowsPhone delegate
    public delegate void DetectWindowsPhoneHandler(object page, MDetectArgs args);
    public event DetectWindowsPhoneHandler OnDetectWindowsPhone;

    //**************************
    // Detects if the current browser is a 
    // Windows Phone 7 device.
    public bool DetectWindowsPhone7()
    {
        if (useragent.IndexOf(deviceWinPhone7) != -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is a 
    // Windows Phone 8 device.
    public bool DetectWindowsPhone8()
    {
        if (useragent.IndexOf(deviceWinPhone8) != -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is a 
    // Windows Phone 10 device.
    public bool DetectWindowsPhone10()
    {
        if (useragent.IndexOf(deviceWinPhone10) != -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is a Windows Mobile device.
    // Excludes Windows Phone devices. 
    // Focuses on Windows Mobile 6.xx and earlier.
    public bool DetectWindowsMobile()
    {
        //Exclude new Windows Phone.
        if (DetectWindowsPhone())
            return false;
        //Most devices use 'Windows CE', but some report 'iemobile' 
        //  and some older ones report as 'PIE' for Pocket IE. 
        if (useragent.IndexOf(deviceWinMob)!= -1 ||
            useragent.IndexOf(deviceIeMob)!= -1 ||
            useragent.IndexOf(enginePie) != -1)
            return true;
        //Test for Windows Mobile PPC but not old Macintosh PowerPC.
        if (useragent.IndexOf(devicePpc) != -1 &&
            !(useragent.IndexOf(deviceMacPpc) != -1))
            return true;
        //Test for certain Windwos Mobile-based HTC devices.
        if (useragent.IndexOf(manuHtc) != -1 &&
            useragent.IndexOf(deviceWindows) != -1)
            return true;
        if (DetectWapWml() == true &&
            useragent.IndexOf(deviceWindows)!= -1)
            return true;
        else
            return false;
    }

    //WindowsMobile delegate
    public delegate void DetectWindowsMobileHandler(object page, MDetectArgs args);
    public event DetectWindowsMobileHandler OnDetectWindowsMobile;

    //**************************
    // Detects if the current browser is any BlackBerry device.
    // Includes the PlayBook.
    public bool DetectBlackBerry()
    {
        if ((useragent.IndexOf(deviceBB)!= -1) ||
            (httpaccept.IndexOf(vndRIM)!= -1))
            return true;
        else
            return false;
    }
    //BlackBerry delegate
    public delegate void DetectBlackBerryHandler(object page, MDetectArgs args);
    public event DetectBlackBerryHandler OnDetectBlackBerry;


    //**************************
    // Detects if the current browser is a BlackBerry 10 OS phone.
   	// Excludes tablets.
    public bool DetectBlackBerry10Phone()
    {
        if (useragent.IndexOf(deviceBB10) != -1 &&
            useragent.IndexOf(mobile) != -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is on a BlackBerry tablet device.
    //    Example: PlayBook
    public bool DetectBlackBerryTablet()
    {
        if (useragent.IndexOf(deviceBBPlaybook) != -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is a BlackBerry device AND uses a
    //    WebKit-based browser. These are signatures for the new BlackBerry OS 6.
    //    Examples: Torch. Includes the Playbook.
    public bool DetectBlackBerryWebKit()
    {
        if (DetectBlackBerry() && DetectWebkit())
            return true;
        else
            return false;
    }
    //BlackBerry Webkit delegate
    public delegate void DetectBlackBerryWebkitHandler(object page, MDetectArgs args);
    public event DetectBlackBerryWebkitHandler OnDetectBlackBerryWebkit;


    //**************************
    // Detects if the current browser is a BlackBerry Touch
    //    device, such as the Storm, Torch, and Bold Touch. Excludes the Playbook.
    public bool DetectBlackBerryTouch()
    {
        if (DetectBlackBerry() && 
            (useragent.IndexOf(deviceBBStorm) != -1 ||
            useragent.IndexOf(deviceBBTorch) != -1 ||
            useragent.IndexOf(deviceBBBoldTouch) != -1 ||
            useragent.IndexOf(deviceBBCurveTouch) != -1))
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is a BlackBerry device AND
    //    has a more capable recent browser. Excludes the Playbook.
    //    Examples, Storm, Bold, Tour, Curve2
    //    Excludes the new BlackBerry OS 6 and 7 browser!!
    public bool DetectBlackBerryHigh()
    {
        //Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser
        if (DetectBlackBerryWebKit())
            return false;
        if (DetectBlackBerry())
        {
            if (DetectBlackBerryTouch() ||
                useragent.IndexOf(deviceBBBold) != -1 ||
                useragent.IndexOf(deviceBBTour) != -1 ||
                useragent.IndexOf(deviceBBCurve) != -1)
                return true;
            else
                return false;
        }
        else
            return false;
    }

    //**************************
    // Detects if the current browser is a BlackBerry device AND
    //    has an older, less capable browser. 
    //    Examples: Pearl, 8800, Curve1.
    public bool DetectBlackBerryLow()
    {
        if (DetectBlackBerry())
        {
            //Assume that if it's not in the High tier, then it's Low.
            if (DetectBlackBerryHigh() || DetectBlackBerryWebKit())
                return false;
            else
                return true;
        }
        else
            return false;
    }

    //**************************
    // Detects if the current browser is on a PalmOS device.
    public bool DetectPalmOS()
    {
        //Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino.
        if (useragent.IndexOf(devicePalm) != -1 ||
            useragent.IndexOf(engineBlazer) != -1 ||
            useragent.IndexOf(engineXiino) != -1)
        {
            //Make sure it's not WebOS first
            if (DetectPalmWebOS() == true)
                return false;
            else
                return true;
        }
        else
            return false;
    }
    //PalmOS delegate
    public delegate void DetectPalmOSHandler(object page, MDetectArgs args);
    public event DetectPalmOSHandler OnDetectPalmOS;


    //**************************
    // Detects if the current browser is on a Palm device
    //    running the new WebOS.
    public bool DetectPalmWebOS()
    {
        if (useragent.IndexOf(deviceWebOS) != -1)
            return true;
        else
            return false;
    }

    //PalmWebOS delegate
    public delegate void DetectPalmWebOSHandler(object page, MDetectArgs args);
    public event DetectPalmWebOSHandler OnDetectPalmWebOS;


    //**************************
    // Detects if the current browser is on an HP tablet running WebOS.
    public bool DetectWebOSTablet()
    {
        if (useragent.IndexOf(deviceWebOShp) != -1 &&
            useragent.IndexOf(deviceTablet) != -1)
        {
            return true;
        }
        else
            return false;
    }
    //WebOS tablet delegate
    public delegate void DetectWebOSTabletHandler(object page, MDetectArgs args);
    public event DetectWebOSTabletHandler OnDetectWebOSTablet;


    //**************************
    // Detects if the current browser is on a WebOS smart TV.
    public bool DetectWebOSTV()
    {
        if (useragent.IndexOf(deviceWebOStv) != -1 &&
            useragent.IndexOf(smartTV2) != -1)
        {
            return true;
        }
        else
            return false;
    }

    //**************************
    // Detects if the current browser is Opera Mobile or Mini.
    public bool DetectOperaMobile()
    {
        if (useragent.IndexOf(engineOpera)!= -1)
        {
            if ((useragent.IndexOf(mini)!= -1) ||
             (useragent.IndexOf(mobi)!= -1))
            {
                return true;
            }
            else
                return false;
        }
        else
            return false;
    }

    //Opera Mobile delegate
    public delegate void DetectOperaMobileHandler(object page, MDetectArgs args);
    public event DetectOperaMobileHandler OnDetectOperaMobile;

    //**************************
    // Detects if the current browser is a
    //    Garmin Nuvifone.
    public bool DetectGarminNuvifone()
    {
        if (useragent.IndexOf(deviceNuvifone) != -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects a device running the Bada OS from Samsung.
    public bool DetectBada()
    {
        if (useragent.IndexOf(deviceBada) != -1)
        {
            return true;
        }
        else
            return false;
    }

    //**************************
    // Detects a device running the Tizen smartphone OS.
    public bool DetectTizen()
    {
        if (useragent.IndexOf(deviceTizen) != -1 &&
            useragent.IndexOf(mobile) != -1)
        {
            return true;
        }
        else
            return false;
    }

    //**************************
    // Detects if the current browser is on a Tizen smart TV.
    public bool DetectTizenTV()
    {
        if (useragent.IndexOf(deviceTizen) != -1 &&
            useragent.IndexOf(smartTV1) != -1)
        {
            return true;
        }
        else
            return false;
    }

    //**************************
    // Detects a device running the Meego OS.
    public bool DetectMeego()
    {
        if (useragent.IndexOf(deviceMeego) != -1)
        {
            return true;
        }
        else
            return false;
    }

    //**************************
    // Detects a phone running the Meego OS.
    public bool DetectMeegoPhone()
    {
        if (useragent.IndexOf(deviceMeego) != -1 &&
            useragent.IndexOf(mobile) != -1)
        {
            return true;
        }
        else
            return false;
    }

    //**************************
    // Detects a mobile device (probably) running the Firefox OS.
    public bool DetectFirefoxOS()
    {
        if (DetectFirefoxOSPhone() || DetectFirefoxOSTablet())
            return true;
        
        return false;
    }

    //**************************
    // Detects a phone (probably) running the Firefox OS.
    public bool DetectFirefoxOSPhone()
    {
        //First, let's make sure we're NOT on another major mobile OS.
        if (DetectIos() || 
        	DetectAndroid() ||
        	DetectSailfish())
            return false;        
        
        if ((useragent.IndexOf(engineFirefox) != -1) &&
            (useragent.IndexOf(mobile) != -1))
            return true;
        
        return false;
    }

    //**************************
    // Detects a tablet (probably) running the Firefox OS.
    public bool DetectFirefoxOSTablet()
    {
        //First, let's make sure we're NOT on another major mobile OS.
        if (DetectIos() || 
        	DetectAndroid() ||
        	DetectSailfish())
            return false;        
        
        if ((useragent.IndexOf(engineFirefox) != -1) &&
            (useragent.IndexOf(deviceTablet) != -1))
            return true;
        
        return false;
    }

    //**************************
    // Detects a device running the Sailfish OS.
    public bool DetectSailfish()
    {
        if (useragent.IndexOf(deviceSailfish) != -1)
            return true;
        else
            return false;
    }
    
    //**************************
    // Detects a phone running the Sailfish OS.
    public bool DetectSailfishPhone()
    {
        if (DetectSailfish() &&
            (useragent.IndexOf(mobile) != -1))
            return true;
        
        return false;
    }

    //**************************
    // Detects a mobile device running the Ubuntu Mobile OS.
    public bool DetectUbuntu()
    {
        if (DetectUbuntuPhone() || DetectUbuntuTablet())
            return true;
        
        return false;
    }

    //**************************
    // Detects a phone running the Ubuntu Mobile OS.
    public bool DetectUbuntuPhone()
    {
        if ((useragent.IndexOf(deviceUbuntu) != -1) &&
            (useragent.IndexOf(mobile) != -1))
            return true;
        
        return false;
    }

    //**************************
    // Detects a tablet running the Ubuntu Mobile OS.
    public bool DetectUbuntuTablet()
    {
        if ((useragent.IndexOf(deviceUbuntu) != -1) &&
            (useragent.IndexOf(deviceTablet) != -1))
            return true;
        
        return false;
    }


    //**************************
    // Detects whether the device is a Brew-powered device.
    public bool DetectBrewDevice()
    {
        if (useragent.IndexOf(deviceBrew)!= -1)
            return true;
        else
            return false;
    }

    //BrewDevice delegate
    public delegate void DetectBrewDeviceHandler(object page, MDetectArgs args);
    public event DetectBrewDeviceHandler OnDetectBrewDevice;

    //**************************
    // Detects the Danger Hiptop device.
    public bool DetectDangerHiptop()
    {
        if (useragent.IndexOf(deviceDanger)!= -1 ||
            useragent.IndexOf(deviceHiptop)!= -1)
            return true;
        else
            return false;
    }
    //DangerHiptop delegate
    public delegate void DetectDangerHiptopHandler(object page, MDetectArgs args);
    public event DetectDangerHiptopHandler OnDetectDangerHiptop;

    //**************************
    // Detects whether the device supports WAP or WML.
    public bool DetectWapWml()
    {
        if (httpaccept.IndexOf(vndwap)!= -1 ||
            httpaccept.IndexOf(wml)!= -1)
            return true;
        else
            return false;
    }
    //WapWml delegate
    public delegate void DetectWapWmlHandler(object page, MDetectArgs args);
    public event DetectWapWmlHandler OnDetectWapWml;


    //**************************
    // Detects if the current device is an Amazon Kindle (eInk devices only).
    // Note: For the Kindle Fire, use the normal Android methods. 
    public bool DetectKindle()
    {
        if (useragent.IndexOf(deviceKindle) != -1 &&
            !DetectAndroid())
            return true;
        else
            return false;
    }

    //Kindle delegate
    public delegate void DetectKindleHandler(object page, MDetectArgs args);
    public event DetectKindleHandler OnDetectKindle;


    //**************************
    // Detects if the current Amazon device is using the Silk Browser.
    // Note: Typically used by the the Kindle Fire.
    public bool DetectAmazonSilk()
    {
        if (useragent.IndexOf(engineSilk) != -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device is a Sony Playstation.
    public bool DetectSonyPlaystation()
    {
        if (useragent.IndexOf(devicePlaystation)!= -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device is a handheld gaming device with
    // a touchscreen and modern iPhone-class browser. Includes the Playstation Vita.
    public bool DetectGamingHandheld()
    {
        if (useragent.IndexOf(devicePlaystation)!= -1 &&
             useragent.IndexOf(devicePlaystationVita)!= -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device is a Nintendo game device.
    public bool DetectNintendo()
    {
        if (useragent.IndexOf(deviceNintendo)!= -1 ||
             useragent.IndexOf(deviceWii)!= -1 ||
             useragent.IndexOf(deviceNintendoDs)!= -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device is a Microsoft Xbox.
    public bool DetectXbox()
    {
        if (useragent.IndexOf(deviceXbox)!= -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device is an Internet-capable game console.
    public bool DetectGameConsole()
    {
        if (DetectSonyPlaystation())
            return true;
        else if (DetectNintendo())
            return true;
        else if (DetectXbox())
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device supports MIDP, a mobile Java technology.
    public bool DetectMidpCapable()
    {
        if (useragent.IndexOf(deviceMidp)!= -1 ||
            httpaccept.IndexOf(deviceMidp)!= -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device is on one of the Maemo-based Nokia Internet Tablets.
    public bool DetectMaemoTablet()
    {
        if (useragent.IndexOf(maemo)!= -1)
            return true;
        //For Nokia N810, must be Linux + Tablet, or else it could be something else. 
        else if (useragent.IndexOf(linux)!= -1 &&
            useragent.IndexOf(deviceTablet) != -1 &&
            !DetectWebOSTablet() &&
            !DetectAndroid())
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device is an Archos media player/Internet tablet.
    public bool DetectArchos()
    {
        if (useragent.IndexOf(deviceArchos)!= -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is a Sony Mylo device.
    public bool DetectSonyMylo()
    {
        if ((useragent.IndexOf(manuSony)!= -1) &&
        	((useragent.IndexOf(qtembedded)!= -1) ||
             (useragent.IndexOf(mylocom2)!= -1)))
			return true;        
        
        return false;
    }

	//*****************************
	// Device Classes
	//*****************************
   
    //**************************
    // Check to see whether the device is any device
    //   in the 'smartphone' category.
    // Note: It's better to use DetectTierIphone() for modern touchscreen devices. 
    public bool DetectSmartphone()
    {
        if (DetectTierIphone() ||
            DetectS60OssBrowser() ||
            DetectSymbianOS() ||
            DetectWindowsMobile() ||
            DetectBlackBerry() ||
            DetectMeegoPhone() ||
            DetectPalmOS())
            return true;
        else
            return false;
    }

    //DetectSmartphone delegate
    public delegate void DetectSmartphoneHandler(object page, MDetectArgs args);
    public event DetectSmartphoneHandler OnDetectSmartphone;

    //**************************
    //   Detects if the current device is a mobile device.
    //   This method catches most of the popular modern devices.
    //   Excludes Apple iPads and other modern tablets.
    public bool DetectMobileQuick()
    {
        //Let's exclude tablets
        if (DetectTierTablet())
            return false;

        //Most mobile browsing is done on smartphones
        if (DetectSmartphone())
            return true;

        //Catch-all for many mobile devices
        if (useragent.IndexOf(mobile) != -1)
            return true;

        if (DetectOperaMobile())
            return true;
        
        //We also look for Kindle devices
        if (DetectKindle() ||
            DetectAmazonSilk())
            return true;
        
        if (DetectWapWml() ||
            DetectMidpCapable() ||
            DetectBrewDevice())
            return true;

        if ((useragent.IndexOf(engineNetfront) != -1) ||
            (useragent.IndexOf(engineUpBrowser) != -1))
            return true;

        return false;
    }

    //DetectMobileQuick delegate
    public delegate void DetectMobileQuickHandler(object page, MDetectArgs args);
    public event DetectMobileQuickHandler OnDetectMobileQuick;


    //**************************
    // The longer and more thorough way to detect for a mobile device.
    //   Will probably detect most feature phones,
    //   smartphone-class devices, Internet Tablets, 
    //   Internet-enabled game consoles, etc.
    //   This ought to catch a lot of the more obscure and older devices, also --
    //   but no promises on thoroughness!
    public bool DetectMobileLong()
    {
        if (DetectMobileQuick())
            return true;
            
        if (DetectGameConsole())
            return true;

        if (DetectDangerHiptop() ||
            DetectMaemoTablet() ||
            DetectSonyMylo() ||
            DetectArchos())
            return true;

        if ((useragent.IndexOf(devicePda) != -1) &&
            (useragent.IndexOf(disUpdate) != -1))
            return true;

        //Detect older phones from certain manufacturers and operators. 
        if ((useragent.IndexOf(uplink) != -1)  ||
            (useragent.IndexOf(engineOpenWeb) != -1) ||
            (useragent.IndexOf(manuSamsung1) != -1) ||
            (useragent.IndexOf(manuSonyEricsson) != -1) ||
            (useragent.IndexOf(manuericsson) != -1) ||
            (useragent.IndexOf(svcDocomo) != -1) ||
            (useragent.IndexOf(svcKddi) != -1) ||
            (useragent.IndexOf(svcVodafone) != -1))
            return true;

        return false;
    }



    //*****************************
    // For Mobile Web Site Design
    //*****************************

    //**************************
    // The quick way to detect for a tier of devices.
    //   This method detects for the new generation of
    //   HTML 5 capable, larger screen tablets.
    //   Includes iPad, Android (e.g., Xoom), BB Playbook, WebOS, etc.
    public bool DetectTierTablet()
    {
        if (DetectIpad()
            || DetectAndroidTablet()
            || DetectBlackBerryTablet()
            || DetectFirefoxOSTablet()
            || DetectUbuntuTablet()
            || DetectWebOSTablet())
            return true;
        else
            return false;
    }

    //DetectTierTablet delegate
    public delegate void DetectTierTabletHandler(object page, MDetectArgs args);
    public event DetectTierTabletHandler OnDetectTierTablet;


    //**************************
    // The quick way to detect for a tier of devices.
    //   This method detects for devices which can 
    //   display iPhone-optimized web content.
    //   Includes iPhone, iPod Touch, Android, Windows Phone, BB10, Playstation Vita, etc.
    public bool DetectTierIphone()
    {
        if (DetectIphoneOrIpod() ||
            DetectAndroidPhone() ||
            DetectWindowsPhone() ||
            DetectBlackBerry10Phone() ||
            DetectPalmWebOS() ||
            DetectBada() ||
            DetectTizen() ||
            DetectFirefoxOSPhone() ||
            DetectSailfishPhone() ||
            DetectUbuntuPhone() ||
			DetectGamingHandheld())
            return true;
        else
            return false;
    }

    //DetectTierIphone delegate
    public delegate void DetectTierIphoneHandler(object page, MDetectArgs args);
    public event DetectTierIphoneHandler OnDetectTierIphone;


    //**************************
    // The quick way to detect for a tier of devices.
    //   This method detects for devices which are likely to be capable 
    //   of viewing CSS content optimized for the iPhone, 
    //   but may not necessarily support JavaScript.
    //   Excludes all iPhone Tier devices.
    public bool DetectTierRichCss()
    {
        if (DetectMobileQuick())
        {
            //Exclude iPhone Tier and e-Ink Kindle devices
            if (DetectTierIphone() || DetectKindle())
                return false;

            if (DetectWebkit() ||
                DetectS60OssBrowser())
                return true;

            //Note: 'High' BlackBerry devices ONLY
            if (DetectBlackBerryHigh() == true)
                return true;

            //Older Windows 'Mobile' isn't good enough for iPhone Tier.
            if (DetectWindowsMobile() == true)
                return true;
            if (useragent.IndexOf(engineTelecaQ) != -1)
                return true;

            else
                return false;
        }
        else
            return false;
    }

    //DetectTierRichCss delegate
    public delegate void DetectTierRichCssHandler(object page, MDetectArgs args);
    public event DetectTierRichCssHandler OnDetectTierRichCss;


    //**************************
    // The quick way to detect for a tier of devices.
    //   This method detects for all other types of phones,
    //   but excludes the iPhone and Smartphone Tier devices.
    public bool DetectTierOtherPhones()
    {
        if (DetectMobileLong() == true)
        {
            //Exclude devices in the other 2 categories
            if (DetectTierIphone() ||
                DetectTierRichCss())
                return false;
            else
                return true;
        }
        else
            return false;
    }

    //DetectTierOtherPhones delegate
    public delegate void DetectTierOtherPhonesHandler(object page, MDetectArgs args);
    public event DetectTierOtherPhonesHandler OnDetectTierOtherPhones;

    //***************************************************************
    #endregion

    //Instead of overriding OnInit(), you can override InitializeCulture()
    //  so that detection can happen earlier in page's lifecycle, if necessary. 
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        
        if (useragent == "" && httpaccept == "")
        {
            useragent = (Request.ServerVariables["HTTP_USER_AGENT"] ?? "").ToUpper();
            httpaccept = (Request.ServerVariables["HTTP_ACCEPT"] ?? "").ToUpper();
        }
    }
}


================================================
FILE: ASP_NET/Sub-Classed Page Technique/MDetect_Test.aspx
================================================
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MDetect_Test.aspx.cs" Inherits="MDetect_Test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>


================================================
FILE: ASP_NET/Sub-Classed Page Technique/MDetect_Test.aspx.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MDetect_Test : MDetectPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.FireEvents();
    }

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        //As a test, let's listen for any WebKit-based device. 
        OnDetectWebkit += new DetectWebkitHandler(MDetect_Test_OnDetectWebkit);
    }

    void MDetect_Test_OnDetectWebkit(object page, MDetectPage.MDetectArgs args)
    {
        //Write the Type value from the argument to the web page. 
        Response.Write("<b>This browser is " + args.Type + "</b>");
    }

}


================================================
FILE: ASP_NET/UserControl Technique/MDetectControl.cs
================================================
/* *******************************************
// Copyright 2010-2015, Anthony Hand
//
//
// File version 2015.05.13 (May 13, 2015)
// Updates:
//	- Moved MobileESP to GitHub. https://github.com/ahand/mobileesp
//	- Opera Mobile/Mini browser has the same UA string on multiple platforms and doesn't differentiate phone vs. tablet. 
//		- Removed DetectOperaAndroidPhone(). This method is no longer reliable. 
//		- Removed DetectOperaAndroidTablet(). This method is no longer reliable. 
//	- Added support for Windows Phone 10: variable and DetectWindowsPhone10()
//	- Updated DetectWindowsPhone() to include WP10. 
//	- Added support for Firefox OS.  
//		- A variable plus DetectFirefoxOS(), DetectFirefoxOSPhone(), DetectFirefoxOSTablet()
//		- NOTE: Firefox doesn't add UA tokens to definitively identify Firefox OS vs. their browsers on other mobile platforms.
//	- Added support for Sailfish OS. Not enough info to add a tablet detection method at this time. 
//		- A variable plus DetectSailfish(), DetectSailfishPhone()
//	- Added support for Ubuntu Mobile OS. 
//		- DetectUbuntu(), DetectUbuntuPhone(), DetectUbuntuTablet()
//	- Added support for 2 smart TV OSes. They lack browsers but do have WebViews for use by HTML apps. 
//		- One variable for Samsung Tizen TVs, plus DetectTizenTV()
//		- One variable for LG WebOS TVs, plus DetectWebOSTV()
//	- Added DetectTizen(). Tests for “mobile” to disambiguate from Samsung Smart TVs.
//	- Removed variables for obsolete devices: deviceHtcFlyer, deviceXoom.
//	- Updated DetectAndroid(). No longer has a special test case for the HTC Flyer tablet. 
//	- Updated DetectAndroidPhone(). 
//		- Updated internal detection code for Android. 
//		- No longer has a special test case for the HTC Flyer tablet. 
//		- Checks against DetectOperaMobile() on Android and reports here if relevant. 
//	- Updated DetectAndroidTablet(). 
//		- No longer has a special test case for the HTC Flyer tablet. 
//		- Checks against DetectOperaMobile() on Android to exclude it from here.
//	- DetectMeego(): Changed definition for this method. Now detects any Meego OS device, not just phones. 
//	- DetectMeegoPhone(): NEW. For Meego phones. Ought to detect Opera browsers on Meego, as well.  
//	- DetectTierIphone(): Added support for phones running Sailfish, Ubuntu and Firefox Mobile. 
//	- DetectTierTablet(): Added support for tablets running Ubuntu and Firefox Mobile. 
//	- DetectSmartphone(): Added support for Meego phones. 
//	- Caught this library up to the PHP, JavaScript and Java versions. Updates include: 
//		- Added support for Bada: a variable and DetectBada(). This detects any Bada OS device, but (almost) all are phones.
//		- Refactored the Windows Phone delegate-related properties and features. Now fires for any Windows Phone, not just WP7. 
//			- The event fires now when DetectWindowsPhone() is true. 
//		- Added support for Windows Phone 8: DetectWindowsPhone8().
//		- Updated DetectWindowsMobile(). Excludes any Windows Phone device, not just WP7. 
//		- Added support for BlackBerry 10 OS phones: DetectBlackBerry10Phone().
//		- Updated DetectSonyMylo().
//		- Updated DetectSmartphone() to sync with the other libraries. 
//		- Updated DetectTierIphone() to sync with the other libraries.
//		- OnInit(EventArgs e): Fixed the user agent and httpaccept init logic.
//	- Refactored the detection logic in DetectMobileQuick() and DetectMobileLong().
//		- Moved a few detection tests for older browsers to Long. 
//
//
//
// LICENSE INFORMATION
// Licensed under the Apache License, Version 2.0 (the "License"); 
// you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at 
//        http://www.apache.org/licenses/LICENSE-2.0 
// Unless required by applicable law or agreed to in writing, 
// software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific 
// language governing permissions and limitations under the License. 
//
//
// ABOUT THIS PROJECT
//   Project Owner: Anthony Hand
//   Email: anthony.hand@gmail.com
//   Web Site: http://www.mobileesp.com
//   Source Files: https://github.com/ahand/mobileesp
//   
//   Versions of this code are available for:
//      PHP, JavaScript, Java, ASP.NET (C#), and Ruby
//
// *******************************************
*/


using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

/// <summary>
/// Subclass this control to inherit the built-in mobile device detection.
/// </summary>
public class MDetectControl : System.Web.UI.UserControl
{

    private string useragent = "";
    private string httpaccept = "";

    #region Fields - Detection Argument Values

    //standardized values for detection arguments.
    private const string dargsIphone = "iphone";
    private const string dargsIpod = "ipod";
    private const string dargsIpad = "ipad";
    private const string dargsIphoneOrIpod = "iphoneoripod";
    private const string dargsIos = "ios";
    private const string dargsAndroid = "android";
    private const string dargsAndroidPhone = "androidphone";
    private const string dargsAndroidTablet = "androidtablet";
    private const string dargsGoogleTV = "googletv";
    private const string dargsWebKit = "webkit";
    private const string dargsSymbianOS = "symbianos";
    private const string dargsS60 = "series60";
    private const string dargsWindowsPhone = "windowsphone";
    private const string dargsWindowsMobile = "windowsmobile";
    private const string dargsBlackBerry = "blackberry";
    private const string dargsBlackBerryWebkit = "blackberrywebkit";
    private const string dargsPalmOS = "palmos";
    private const string dargsPalmWebOS = "webos";
    private const string dargsWebOSTablet = "webostablet";
    private const string dargsSmartphone = "smartphone";
    private const string dargsBrewDevice = "brew";
    private const string dargsDangerHiptop = "dangerhiptop";
    private const string dargsOperaMobile = "operamobile";
    private const string dargsWapWml = "wapwml";
    private const string dargsKindle = "kindle";
    private const string dargsMobileQuick = "mobilequick";
    private const string dargsTierTablet = "tiertablet";
    private const string dargsTierIphone = "tieriphone";
    private const string dargsTierRichCss = "tierrichcss";
    private const string dargsTierOtherPhones = "tierotherphones";

    #endregion Fields - Detection Argument Values

    #region Fields - User Agent Keyword Values

    private const string engineWebKit = "WEBKIT";
    private const string deviceIphone = "IPHONE";
    private const string deviceIpod = "IPOD";
    private const string deviceIpad = "IPAD";
    private const string deviceMacPpc = "MACINTOSH"; //Used for disambiguation

    private const string deviceAndroid = "ANDROID";
    private const string deviceGoogleTV = "GOOGLETV";

    private const string deviceNuvifone = "NUVIFONE";  //Garmin Nuvifone
    private const string deviceBada = "BADA";  //Samsung's Bada OS    
    private const string deviceTizen = "TIZEN";  //Tizen OS    
    private const string deviceMeego = "MEEGO";  //Meego OS    
    private const string deviceSailfish = "SAILFISH";  //Sailfish OS
    private const string deviceUbuntu = "UBUNTU";  //Ubuntu Mobile OS

    private const string deviceSymbian = "SYMBIAN";
    private const string deviceS60 = "SERIES60";
    private const string deviceS70 = "SERIES70";
    private const string deviceS80 = "SERIES80";
    private const string deviceS90 = "SERIES90";

    private const string deviceWinPhone7 = "WINDOWS PHONE OS 7";
    private const string deviceWinPhone8 = "WINDOWS PHONE 8";
    private const string deviceWinPhone10 = "WINDOWS PHONE 10";
    private const string deviceWinMob = "WINDOWS CE";
    private const string deviceWindows = "WINDOWS";
    private const string deviceIeMob = "IEMOBILE";
    private const string devicePpc = "PPC"; //Stands for PocketPC
    private const string enginePie = "WM5 PIE"; //An old Windows Mobile browser

    private const string deviceBB = "BLACKBERRY";
    private const string deviceBB10 = "BB10"; //For the new BB 10 OS
    private const string vndRIM = "VND.RIM"; //Detectable when BB devices emulate IE or Firefox
    private const string deviceBBStorm = "BLACKBERRY95"; //Storm 1 and 2
    private const string deviceBBBold = "BLACKBERRY97"; //Bold 97x0 (non-touch)
    private const string deviceBBBoldTouch = "BLACKBERRY 99"; //Bold 99x0 (touchscreen)
    private const string deviceBBTour = "BLACKBERRY96"; //Tour
    private const string deviceBBCurve = "BLACKBERRY89"; //Curve2
    private const string deviceBBCurveTouch = "BLACKBERRY 938"; //Curve Touch 9380
    private const string deviceBBTorch = "BLACKBERRY 98"; //Torch
    private const string deviceBBPlaybook = "PLAYBOOK"; //PlayBook tablet

    private const string devicePalm = "PALM";
    private const string deviceWebOS = "WEBOS"; //For Palm devices
    private const string deviceWebOStv = "WEB0S"; //For LG TVs
    private const string deviceWebOShp = "HPWOS"; //For HP's line of WebOS devices

    private const string engineBlazer = "BLAZER"; //Old Palm
    private const string engineXiino = "XIINO"; //Another old Palm

    private const string deviceKindle = "KINDLE";  //Amazon Kindle, eInk one
    private const string engineSilk = "SILK";  //Amazon's accelerated Silk browser for Kindle Fire

    //Initialize private strings for mobile-specific content.
    private const string vndwap = "VND.WAP";
    private const string wml = "WML";

    //Initialize private strings for other random devices and mobile browsers.
    private const string deviceTablet = "TABLET"; //Generic term for slate and tablet devices
    private const string deviceBrew = "BREW";
    private const string deviceDanger = "DANGER";
    private const string deviceHiptop = "HIPTOP";
    private const string devicePlaystation = "PLAYSTATION";
    private const string devicePlaystationVita = "VITA";
    private const string deviceNintendoDs = "NITRO";
    private const string deviceNintendo = "NINTENDO";
    private const string deviceWii = "WII";
    private const string deviceXbox = "XBOX";
    private const string deviceArchos = "ARCHOS";

    private const string engineFirefox = "FIREFOX"; //For Firefox OS
    private const string engineOpera = "OPERA"; //Popular browser
    private const string engineNetfront = "NETFRONT"; //Common embedded OS browser
    private const string engineUpBrowser = "UP.BROWSER"; //common on some phones
    private const string engineOpenWeb = "OPENWEB"; //Transcoding by OpenWave server
    private const string deviceMidp = "MIDP"; //a mobile Java technology
    private const string uplink = "UP.LINK";
    private const string engineTelecaQ = "TELECA Q"; //a modern feature phone browser

    private const string devicePda = "PDA"; //some devices report themselves as PDAs
    private const string mini = "MINI";  //Some mobile browsers put "mini" in their names.
    private const string mobile = "MOBILE"; //Some mobile browsers put "mobile" in their user agent private strings.
    private const string mobi = "MOBI"; //Some mobile browsers put "mobi" in their user agent private strings.

    //Smart TV strings
    private const string smartTV1 = "SMART-TV"; //Samsung Tizen smart TVs
    private const string smartTV2 = "SMARTTV"; //LG WebOS smart TVs

    //Use Maemo, Tablet, and Linux to test for Nokia"s Internet Tablets.
    private const string maemo = "MAEMO";
    private const string linux = "LINUX";
    private const string qtembedded = "QT EMBEDDED"; //for Sony Mylo
    private const string mylocom2 = "COM2"; //for Sony Mylo also

    //In some UserAgents, the only clue is the manufacturer.
    private const string manuSonyEricsson = "SONYERICSSON";
    private const string manuericsson = "ERICSSON";
    private const string manuSamsung1 = "SEC-SGH";
    private const string manuSony = "SONY";
    private const string manuHtc = "HTC"; //Popular Android and WinMo manufacturer

    //In some UserAgents, the only clue is the operator.
    private const string svcDocomo = "DOCOMO";
    private const string svcKddi = "KDDI";
    private const string svcVodafone = "VODAFONE";

    //Disambiguation strings.
    private const string disUpdate = "UPDATE"; //pda vs. update

    #endregion Fields - User Agent Keyword Values


    /// <summary>
    /// To instantiate a WebPage sub-class with built-in
    /// mobile device detection delegates and events.
    /// </summary>
    public MDetectControl()
    {

    }

    /// <summary>
    /// To run the device detection methods andd fire 
    /// any existing OnDetectXXX events. 
    /// </summary>
    public void FireEvents()
    {
        if (useragent == "" && httpaccept == "")
        {
            useragent = (Request.ServerVariables["HTTP_USER_AGENT"] ?? "").ToUpper();
            httpaccept = (Request.ServerVariables["HTTP_ACCEPT"] ?? "").ToUpper();
        }

        #region Event Fire Methods

        MDetectArgs mda = null;
        if (this.DetectIpod())
        {
            mda = new MDetectArgs(dargsIpod);
            if (this.OnDetectIpod != null)
            {
                this.OnDetectIpod(this, mda);
            }
        }
        if (this.DetectIpad())
        {
            mda = new MDetectArgs(dargsIpad);
            if (this.OnDetectIpad != null)
            {
                this.OnDetectIpad(this, mda);
            }
        }
        if (this.DetectIphone())
        {
            mda = new MDetectArgs(dargsIphone);
            if (this.OnDetectIphone != null)
            {
                this.OnDetectIphone(this, mda);
            }
        }
        if (this.DetectIphoneOrIpod())
        {
            mda = new MDetectArgs(dargsIphoneOrIpod);
            if (this.OnDetectDetectIPhoneOrIpod != null)
            {
                this.OnDetectDetectIPhoneOrIpod(this, mda);
            }
        }
        if (this.DetectIos())
        {
            mda = new MDetectArgs(dargsIos);
            if (this.OnDetectIos != null)
            {
                this.OnDetectIos(this, mda);
            }
        }
        if (this.DetectAndroid())
        {
            mda = new MDetectArgs(dargsAndroid);
            if (this.OnDetectAndroid != null)
            {
                this.OnDetectAndroid(this, mda);
            }
        }
        if (this.DetectAndroidPhone())
        {
            mda = new MDetectArgs(dargsAndroidPhone);
            if (this.OnDetectAndroidPhone != null)
            {
                this.OnDetectAndroidPhone(this, mda);
            }
        }
        if (this.DetectAndroidTablet())
        {
            mda = new MDetectArgs(dargsAndroidTablet);
            if (this.OnDetectAndroidTablet != null)
            {
                this.OnDetectAndroidTablet(this, mda);
            }
        }
        if (this.DetectGoogleTV())
        {
            mda = new MDetectArgs(dargsGoogleTV);
            if (this.OnDetectGoogleTV != null)
            {
                this.OnDetectGoogleTV(this, mda);
            }
        }
        if (this.DetectWebkit())
        {
            mda = new MDetectArgs(dargsWebKit);
            if (this.OnDetectWebkit != null)
            {
                this.OnDetectWebkit(this, mda);
            }
        }
        if (this.DetectS60OssBrowser())
        {
            mda = new MDetectArgs(dargsS60);
            if (this.OnDetectS60OssBrowser != null)
            {
                this.OnDetectS60OssBrowser(this, mda);
            }
        }
        if (this.DetectSymbianOS())
        {
            mda = new MDetectArgs(dargsSymbianOS);
            if (this.OnDetectSymbianOS != null)
            {
                this.OnDetectSymbianOS(this, mda);
            }
        }
        if (this.DetectWindowsPhone())
        {
            mda = new MDetectArgs(dargsWindowsPhone);
            if (this.OnDetectWindowsPhone != null)
            {
                this.OnDetectWindowsPhone(this, mda);
            }
        }
        if (this.DetectWindowsMobile())
        {
            mda = new MDetectArgs(dargsWindowsMobile);
            if (this.OnDetectWindowsMobile != null)
            {
                this.OnDetectWindowsMobile(this, mda);
            }
        }
        if (this.DetectBlackBerry())
        {
            mda = new MDetectArgs(dargsBlackBerry);
            if (this.OnDetectBlackBerry != null)
            {
                this.OnDetectBlackBerry(this, mda);
            }
        }
        if (this.DetectBlackBerryWebKit())
        {
            mda = new MDetectArgs(dargsBlackBerryWebkit);
            if (this.OnDetectBlackBerryWebkit != null)
            {
                this.OnDetectBlackBerryWebkit(this, mda);
            }
        }
        if (this.DetectPalmOS())
        {
            mda = new MDetectArgs(dargsPalmOS);
            if (this.OnDetectPalmOS != null)
            {
                this.OnDetectPalmOS(this, mda);
            }
        }
        if (this.DetectPalmWebOS())
        {
            mda = new MDetectArgs(dargsPalmWebOS);
            if (this.OnDetectPalmWebOS != null)
            {
                this.OnDetectPalmWebOS(this, mda);
            }
        }
        if (this.DetectWebOSTablet())
        {
            mda = new MDetectArgs(dargsWebOSTablet);
            if (this.OnDetectWebOSTablet != null)
            {
                this.OnDetectWebOSTablet(this, mda);
            }
        }
        if (this.DetectSmartphone())
        {
            mda = new MDetectArgs(dargsSmartphone);
            if (this.OnDetectSmartphone != null)
            {
                this.OnDetectSmartphone(this, mda);
            }
        }
        if (this.DetectBrewDevice())
        {
            mda = new MDetectArgs(dargsBrewDevice);
            if (this.OnDetectBrewDevice != null)
            {
                this.OnDetectBrewDevice(this, mda);
            }
        }
        if (this.DetectDangerHiptop())
        {
            mda = new MDetectArgs(dargsDangerHiptop);
            if (this.OnDetectDangerHiptop != null)
            {
                this.OnDetectDangerHiptop(this, mda);
            }
        }
        if (this.DetectOperaMobile())
        {
            mda = new MDetectArgs(dargsOperaMobile);
            if (this.OnDetectOperaMobile != null)
            {
                this.OnDetectOperaMobile(this, mda);
            }
        }
        if (this.DetectWapWml())
        {
            mda = new MDetectArgs(dargsWapWml);
            if (this.OnDetectWapWml != null)
            {
                this.OnDetectWapWml(this, mda);
            }
        }
        if (this.DetectKindle())
        {
            mda = new MDetectArgs(dargsKindle);
            if (this.OnDetectKindle != null)
            {
                this.OnDetectKindle(this, mda);
            }
        }
        if (this.DetectMobileQuick())
        {
            mda = new MDetectArgs(dargsMobileQuick);
            if (this.OnDetectMobileQuick != null)
            {
                this.OnDetectMobileQuick(this, mda);
            }
        }
        if (this.DetectTierTablet())
        {
            mda = new MDetectArgs(dargsTierTablet);
            if (this.OnDetectTierTablet != null)
            {
                this.OnDetectTierTablet(this, mda);
            }
        }
        if (this.DetectTierIphone())
        {
            mda = new MDetectArgs(dargsTierIphone);
            if (this.OnDetectTierIphone != null)
            {
                this.OnDetectTierIphone(this, mda);
            }
        }
        if (this.DetectTierRichCss())
        {
            mda = new MDetectArgs(dargsTierRichCss);
            if (this.OnDetectTierRichCss != null)
            {
                this.OnDetectTierRichCss(this, mda);
            }
        }
        if (this.DetectTierOtherPhones())
        {
            mda = new MDetectArgs(dargsTierOtherPhones);
            if (this.OnDetectTierOtherPhones != null)
            {
                this.OnDetectTierOtherPhones(this, mda);
            }
        }

        #endregion Event Fire Methods

    }

    public class MDetectArgs : EventArgs
    {
        public MDetectArgs(string type)
        {
            this.Type = type;
        }

        public readonly string Type;
    }

    #region Mobile Device Detection Methods 
    
    
	//*****************************
	// Start device detection
	//*****************************

    //**************************
    // Detects if the current device is an iPhone.
    public bool DetectIphone()
    {
        if (useragent.IndexOf(deviceIphone)!= -1)
        {
            //The iPad and iPod touch say they're an iPhone! So let's disambiguate.
            if (DetectIpad() || DetectIpod())
            {
                return false;
            }
            else
                return true;
        }
        else
            return false;
    }
    //IPhone delegate
    public delegate void DetectIphoneHandler(object page, MDetectArgs args);
    public event DetectIphoneHandler OnDetectIphone;


    //**************************
    // Detects if the current device is an iPod Touch.
    public bool DetectIpod()
    {
        if (useragent.IndexOf(deviceIpod)!= -1)
            return true;
        else
            return false;
    }

    //Ipod delegate
    public delegate void DetectIpodHandler(object page, MDetectArgs args);
    public event DetectIpodHandler OnDetectIpod;


    //**************************
    // Detects if the current device is an iPad tablet.
    public bool DetectIpad()
    {
        if (useragent.IndexOf(deviceIpad) != -1 && DetectWebkit())
            return true;
        else
            return false;
    }

    //Ipod delegate
    public delegate void DetectIpadHandler(object page, MDetectArgs args);
    public event DetectIpadHandler OnDetectIpad;


    //**************************
    // Detects if the current device is an iPhone or iPod Touch.
    public bool DetectIphoneOrIpod()
    {
        //We repeat the searches here because some iPods may report themselves as an iPhone, which would be okay.
        if (useragent.IndexOf(deviceIphone)!= -1 ||
            useragent.IndexOf(deviceIpod)!= -1)
            return true;
        else
            return false;
    }
    //IPhoneOrIpod delegate
    public delegate void DetectIPhoneOrIpodHandler(object page, MDetectArgs args);
    public event DetectIPhoneOrIpodHandler OnDetectDetectIPhoneOrIpod;

    //**************************
    // Detects *any* iOS device: iPhone, iPod Touch, iPad.
    public bool DetectIos()
    {
        if (DetectIphoneOrIpod() || DetectIpad())
            return true;
        else
            return false;
    }

    //Ios delegate
    public delegate void DetectIosHandler(object page, MDetectArgs args);
    public event DetectIosHandler OnDetectIos;


    //**************************
    // Detects *any* Android OS-based device: phone, tablet, and multi-media player.
    // Also detects Google TV.
    public bool DetectAndroid()
    {
        if ((useragent.IndexOf(deviceAndroid) != -1) ||
            DetectGoogleTV())
            return true;
        
        return false;
    }
    //Android delegate
    public delegate void DetectAndroidHandler(object page, MDetectArgs args);
    public event DetectAndroidHandler OnDetectAndroid;

    //**************************
    // Detects if the current device is a (small-ish) Android OS-based device
    // used for calling and/or multi-media (like a Samsung Galaxy Player).
    // Google says these devices will have 'Android' AND 'mobile' in user agent.
    // Ignores tablets (Honeycomb and later).
    public bool DetectAndroidPhone()
    {
        //First, let's make sure we're on an Android device.
        if (!DetectAndroid())
            return false;

        //If it's Android and has 'mobile' in it, Google says it's a phone.
        if (useragent.IndexOf(mobile) != -1)
            return true;

        //Special check for Android devices with Opera Mobile/Mini. They should report here.
        if (DetectOperaMobile())
            return true;
        
        return false;
    }

    //Android Phone delegate
    public delegate void DetectAndroidPhoneHandler(object page, MDetectArgs args);
    public event DetectAndroidPhoneHandler OnDetectAndroidPhone;

    //**************************
    // Detects if the current device is a (self-reported) Android tablet.
    // Google says these devices will have 'Android' and NOT 'mobile' in their user agent.
    public bool DetectAndroidTablet()
    {
        //First, let's make sure we're on an Android device.
        if (!DetectAndroid())
            return false;

        //Special check for Android devices with Opera Mobile/Mini. They should NOT report here.
        if (DetectOperaMobile())
            return false;

        //Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet.
        if (useragent.IndexOf(mobile) > -1)
            return false;
        else
            return true;
    }
    
    //Android Tablet delegate
    public delegate void DetectAndroidTabletHandler(object page, MDetectArgs args);
    public event DetectAndroidTabletHandler OnDetectAndroidTablet;

    //**************************
    // Detects if the current device is a GoogleTV device.
    public bool DetectGoogleTV()
    {
        if (useragent.IndexOf(deviceGoogleTV) != -1)
            return true;
        else
            return false;
    }
    
    //GoogleTV delegate
    public delegate void DetectGoogleTVHandler(object page, MDetectArgs args);
    public event DetectGoogleTVHandler OnDetectGoogleTV;

    //**************************
    // Detects if the current device is an Android OS-based device and
    //   the browser is based on WebKit.
    public bool DetectAndroidWebKit()
    {
        if (DetectAndroid() && DetectWebkit())
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is based on WebKit.
    public bool DetectWebkit()
    {
        if (useragent.IndexOf(engineWebKit)!= -1)
            return true;
        else
            return false;
    }

    //Webkit delegate
    public delegate void DetectWebkitHandler(object page, MDetectArgs args);
    public event DetectWebkitHandler OnDetectWebkit;

    //**************************
    // Detects if the current browser is the Nokia S60 Open Source Browser.
    public bool DetectS60OssBrowser()
    {
        //First, test for WebKit, then make sure it's either Symbian or S60.
        if (DetectWebkit())
        {
            if (useragent.IndexOf(deviceSymbian)!= -1 ||
                useragent.IndexOf(deviceS60)!= -1)
            {
                return true;
            }
            else
                return false;
        }
        else
            return false;
    }

    //S60OssBrowser delegate
    public delegate void DetectS60OssBrowserHandler(object page, MDetectArgs args);
    public event DetectS60OssBrowserHandler OnDetectS60OssBrowser;

    //**************************
    // Detects if the current device is any Symbian OS-based device,
    //   including older S60, Series 70, Series 80, Series 90, and UIQ, 
    //   or other browsers running on these devices.
    public bool DetectSymbianOS()
    {
        if (useragent.IndexOf(deviceSymbian)!= -1 ||
            useragent.IndexOf(deviceS60)!= -1 ||
            useragent.IndexOf(deviceS70)!= -1 ||
            useragent.IndexOf(deviceS80)!= -1 ||
            useragent.IndexOf(deviceS90)!= -1)
            return true;
        else
            return false;
    }

    //SymbianOS delegate
    public delegate void DetectSymbianOSHandler(object page, MDetectArgs args);
    public event DetectSymbianOSHandler OnDetectSymbianOS;
    

    //**************************
    // Detects if the current browser is a 
    // Windows Phone 7, 8, or 10 device.
    public bool DetectWindowsPhone()
    {
        if (DetectWindowsPhone7() || 
        	DetectWindowsPhone8() ||
        	DetectWindowsPhone10())
            return true;
        
        return false;
    }

    //WindowsPhone delegate
    public delegate void DetectWindowsPhoneHandler(object page, MDetectArgs args);
    public event DetectWindowsPhoneHandler OnDetectWindowsPhone;

    //**************************
    // Detects if the current browser is a 
    // Windows Phone 7 device.
    public bool DetectWindowsPhone7()
    {
        if (useragent.IndexOf(deviceWinPhone7) != -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is a 
    // Windows Phone 8 device.
    public bool DetectWindowsPhone8()
    {
        if (useragent.IndexOf(deviceWinPhone8) != -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is a 
    // Windows Phone 10 device.
    public bool DetectWindowsPhone10()
    {
        if (useragent.IndexOf(deviceWinPhone10) != -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is a Windows Mobile device.
    // Excludes Windows Phone devices. 
    // Focuses on Windows Mobile 6.xx and earlier.
    public bool DetectWindowsMobile()
    {
        //Exclude new Windows Phone.
        if (DetectWindowsPhone())
            return false;
        //Most devices use 'Windows CE', but some report 'iemobile' 
        //  and some older ones report as 'PIE' for Pocket IE. 
        if (useragent.IndexOf(deviceWinMob)!= -1 ||
            useragent.IndexOf(deviceIeMob)!= -1 ||
            useragent.IndexOf(enginePie) != -1)
            return true;
        //Test for Windows Mobile PPC but not old Macintosh PowerPC.
        if (useragent.IndexOf(devicePpc) != -1 &&
            !(useragent.IndexOf(deviceMacPpc) != -1))
            return true;
        //Test for certain Windwos Mobile-based HTC devices.
        if (useragent.IndexOf(manuHtc) != -1 &&
            useragent.IndexOf(deviceWindows) != -1)
            return true;
        if (DetectWapWml() == true &&
            useragent.IndexOf(deviceWindows)!= -1)
            return true;
        else
            return false;
    }

    //WindowsMobile delegate
    public delegate void DetectWindowsMobileHandler(object page, MDetectArgs args);
    public event DetectWindowsMobileHandler OnDetectWindowsMobile;

    //**************************
    // Detects if the current browser is any BlackBerry device.
    // Includes the PlayBook.
    public bool DetectBlackBerry()
    {
        if (useragent.IndexOf(deviceBB)!= -1)
            return true;
        if (httpaccept.IndexOf(vndRIM)!= -1)
            return true;
        else
            return false;
    }
    //BlackBerry delegate
    public delegate void DetectBlackBerryHandler(object page, MDetectArgs args);
    public event DetectBlackBerryHandler OnDetectBlackBerry;

    //**************************
    // Detects if the current browser is a BlackBerry 10 OS phone.
   	// Excludes tablets.
    public bool DetectBlackBerry10Phone()
    {
        if (useragent.IndexOf(deviceBB10) != -1 &&
            useragent.IndexOf(mobile) != -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is on a BlackBerry tablet device.
    //    Example: PlayBook
    public bool DetectBlackBerryTablet()
    {
        if (useragent.IndexOf(deviceBBPlaybook) != -1)
            return true;
        else
            return false;
    }


    //**************************
    // Detects if the current browser is a BlackBerry device AND uses a
    //    WebKit-based browser. These are signatures for the new BlackBerry OS 6.
    //    Examples: Torch. Includes the Playbook.
    public bool DetectBlackBerryWebKit()
    {
        if (DetectBlackBerry() && DetectWebkit())
            return true;
        else
            return false;
    }
    //BlackBerry Webkit delegate
    public delegate void DetectBlackBerryWebkitHandler(object page, MDetectArgs args);
    public event DetectBlackBerryWebkitHandler OnDetectBlackBerryWebkit;


    //**************************
    // Detects if the current browser is a BlackBerry Touch
    //    device, such as the Storm, Torch, and Bold Touch. Excludes the Playbook.
    public bool DetectBlackBerryTouch()
    {
        if (DetectBlackBerry() && 
            (useragent.IndexOf(deviceBBStorm) != -1 ||
            useragent.IndexOf(deviceBBTorch) != -1 ||
            useragent.IndexOf(deviceBBBoldTouch) != -1 ||
            useragent.IndexOf(deviceBBCurveTouch) != -1))
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is a BlackBerry device AND
    //    has a more capable recent browser. Excludes the Playbook.
    //    Excludes the new BlackBerry OS 6 and 7 browser!!
    public bool DetectBlackBerryHigh()
    {
        //Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser
        if (DetectBlackBerryWebKit())
            return false;
        if (DetectBlackBerry())
        {
            if (DetectBlackBerryTouch() ||
                useragent.IndexOf(deviceBBBold) != -1 ||
                useragent.IndexOf(deviceBBTour) != -1 ||
                useragent.IndexOf(deviceBBCurve) != -1)
                return true;
            else
                return false;
        }
        else
            return false;
    }

    //**************************
    // Detects if the current browser is a BlackBerry device AND
    //    has an older, less capable browser. 
    //    Examples: Pearl, 8800, Curve1.
    public bool DetectBlackBerryLow()
    {
        if (DetectBlackBerry())
        {
            //Assume that if it's not in the High tier, then it's Low.
            if (DetectBlackBerryHigh() || DetectBlackBerryWebKit())
                return false;
            else
                return true;
        }
        else
            return false;
    }


    //**************************
    // Detects if the current browser is on a PalmOS device.
    public bool DetectPalmOS()
    {
        //Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino.
        if (useragent.IndexOf(devicePalm) != -1 ||
            useragent.IndexOf(engineBlazer) != -1 ||
            useragent.IndexOf(engineXiino) != -1)
        {
            //Make sure it's not WebOS first
            if (DetectPalmWebOS() == true)
                return false;
            else
                return true;
        }
        else
            return false;
    }
    //PalmOS delegate
    public delegate void DetectPalmOSHandler(object page, MDetectArgs args);
    public event DetectPalmOSHandler OnDetectPalmOS;


    //**************************
    // Detects if the current browser is on a Palm device
    //    running the new WebOS.
    public bool DetectPalmWebOS()
    {
        if (useragent.IndexOf(deviceWebOS) != -1)
            return true;
        else
            return false;
    }

    //PalmWebOS delegate
    public delegate void DetectPalmWebOSHandler(object page, MDetectArgs args);
    public event DetectPalmWebOSHandler OnDetectPalmWebOS;


    //**************************
    // Detects if the current browser is on an HP tablet running WebOS.
    public bool DetectWebOSTablet()
    {
        if (useragent.IndexOf(deviceWebOShp) != -1 &&
            useragent.IndexOf(deviceTablet) != -1)
        {
            return true;
        }
        else
            return false;
    }
    //WebOS tablet delegate
    public delegate void DetectWebOSTabletHandler(object page, MDetectArgs args);
    public event DetectWebOSTabletHandler OnDetectWebOSTablet;


    //**************************
    // Detects if the current browser is on a WebOS smart TV.
    public bool DetectWebOSTV()
    {
        if (useragent.IndexOf(deviceWebOStv) != -1 &&
            useragent.IndexOf(smartTV2) != -1)
        {
            return true;
        }
        else
            return false;
    }

    //**************************
    // Detects if the current browser is Opera Mobile or Mini.
    public bool DetectOperaMobile()
    {
        if (useragent.IndexOf(engineOpera)!= -1)
        {
            if ((useragent.IndexOf(mini)!= -1) ||
             (useragent.IndexOf(mobi)!= -1))
            {
                return true;
            }
            else
                return false;
        }
        else
            return false;
    }

    //Opera Mobile delegate
    public delegate void DetectOperaMobileHandler(object page, MDetectArgs args);
    public event DetectOperaMobileHandler OnDetectOperaMobile;


    //**************************
    // Detects if the current browser is a
    //    Garmin Nuvifone.
    public bool DetectGarminNuvifone()
    {
        if (useragent.IndexOf(deviceNuvifone) != -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects a device running the Bada OS from Samsung.
    public bool DetectBada()
    {
        if (useragent.IndexOf(deviceBada) != -1)
        {
            return true;
        }
        else
            return false;
    }

    //**************************
    // Detects a device running the Tizen smartphone OS.
    public bool DetectTizen()
    {
        if (useragent.IndexOf(deviceTizen) != -1 &&
            useragent.IndexOf(mobile) != -1)
        {
            return true;
        }
        else
            return false;
    }

    //**************************
    // Detects if the current browser is on a Tizen smart TV.
    public bool DetectTizenTV()
    {
        if (useragent.IndexOf(deviceTizen) != -1 &&
            useragent.IndexOf(smartTV1) != -1)
        {
            return true;
        }
        else
            return false;
    }

    //**************************
    // Detects a device running the Meego OS.
    public bool DetectMeego()
    {
        if (useragent.IndexOf(deviceMeego) != -1)
        {
            return true;
        }
        else
            return false;
    }

    //**************************
    // Detects a phone running the Meego OS.
    public bool DetectMeegoPhone()
    {
        if (useragent.IndexOf(deviceMeego) != -1 &&
            useragent.IndexOf(mobile) != -1)
        {
            return true;
        }
        else
            return false;
    }

    //**************************
    // Detects a mobile device (probably) running the Firefox OS.
    public bool DetectFirefoxOS()
    {
        if (DetectFirefoxOSPhone() || DetectFirefoxOSTablet())
            return true;
        
        return false;
    }

    //**************************
    // Detects a phone (probably) running the Firefox OS.
    public bool DetectFirefoxOSPhone()
    {
        //First, let's make sure we're NOT on another major mobile OS.
        if (DetectIos() || 
        	DetectAndroid() ||
        	DetectSailfish())
            return false;        
        
        if ((useragent.IndexOf(engineFirefox) != -1) &&
            (useragent.IndexOf(mobile) != -1))
            return true;
        
        return false;
    }

    //**************************
    // Detects a tablet (probably) running the Firefox OS.
    public bool DetectFirefoxOSTablet()
    {
        //First, let's make sure we're NOT on another major mobile OS.
        if (DetectIos() || 
        	DetectAndroid() ||
        	DetectSailfish())
            return false;        
        
        if ((useragent.IndexOf(engineFirefox) != -1) &&
            (useragent.IndexOf(deviceTablet) != -1))
            return true;
        
        return false;
    }

    //**************************
    // Detects a device running the Sailfish OS.
    public bool DetectSailfish()
    {
        if (useragent.IndexOf(deviceSailfish) != -1)
            return true;
        else
            return false;
    }
    
    //**************************
    // Detects a phone running the Sailfish OS.
    public bool DetectSailfishPhone()
    {
        if (DetectSailfish() &&
            (useragent.IndexOf(mobile) != -1))
            return true;
        
        return false;
    }

    //**************************
    // Detects a mobile device running the Ubuntu Mobile OS.
    public bool DetectUbuntu()
    {
        if (DetectUbuntuPhone() || DetectUbuntuTablet())
            return true;
        
        return false;
    }

    //**************************
    // Detects a phone running the Ubuntu Mobile OS.
    public bool DetectUbuntuPhone()
    {
        if ((useragent.IndexOf(deviceUbuntu) != -1) &&
            (useragent.IndexOf(mobile) != -1))
            return true;
        
        return false;
    }

    //**************************
    // Detects a tablet running the Ubuntu Mobile OS.
    public bool DetectUbuntuTablet()
    {
        if ((useragent.IndexOf(deviceUbuntu) != -1) &&
            (useragent.IndexOf(deviceTablet) != -1))
            return true;
        
        return false;
    }

    //**************************
    // Detects whether the device is a Brew-powered device.
    public bool DetectBrewDevice()
    {
        if (useragent.IndexOf(deviceBrew)!= -1)
            return true;
        else
            return false;
    }

    //BrewDevice delegate
    public delegate void DetectBrewDeviceHandler(object page, MDetectArgs args);
    public event DetectBrewDeviceHandler OnDetectBrewDevice;

    //**************************
    // Detects the Danger Hiptop device.
    public bool DetectDangerHiptop()
    {
        if (useragent.IndexOf(deviceDanger)!= -1 ||
            useragent.IndexOf(deviceHiptop)!= -1)
            return true;
        else
            return false;
    }
    //DangerHiptop delegate
    public delegate void DetectDangerHiptopHandler(object page, MDetectArgs args);
    public event DetectDangerHiptopHandler OnDetectDangerHiptop;

    //**************************
    // Detects whether the device supports WAP or WML.
    public bool DetectWapWml()
    {
        if (httpaccept.IndexOf(vndwap)!= -1 ||
            httpaccept.IndexOf(wml)!= -1)
            return true;
        else
            return false;
    }
    //WapWml delegate
    public delegate void DetectWapWmlHandler(object page, MDetectArgs args);
    public event DetectWapWmlHandler OnDetectWapWml;


    //**************************
    // Detects if the current device is an Amazon Kindle (eInk devices only).
    // Note: For the Kindle Fire, use the normal Android methods.
    public bool DetectKindle()
    {
        if (useragent.IndexOf(deviceKindle) != -1 &&
            !DetectAndroid())
            return true;
        else
            return false;
    }

    //Kindle delegate
    public delegate void DetectKindleHandler(object page, MDetectArgs args);
    public event DetectKindleHandler OnDetectKindle;


    //**************************
    // Detects if the current Amazon device is using the Silk Browser.
    // Note: Typically used by the the Kindle Fire.
    public bool DetectAmazonSilk()
    {
        if (useragent.IndexOf(engineSilk) != -1)
            return true;
        else
            return false;
    }


    //**************************
    // Detects if the current device is a Sony Playstation.
    public bool DetectSonyPlaystation()
    {
        if (useragent.IndexOf(devicePlaystation)!= -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device is a handheld gaming device with
    // a touchscreen and modern iPhone-class browser. Includes the Playstation Vita.
    public bool DetectGamingHandheld()
    {
        if (useragent.IndexOf(devicePlaystation)!= -1 &&
             useragent.IndexOf(devicePlaystationVita)!= -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device is a Nintendo game device.
    public bool DetectNintendo()
    {
        if (useragent.IndexOf(deviceNintendo)!= -1 ||
             useragent.IndexOf(deviceWii)!= -1 ||
             useragent.IndexOf(deviceNintendoDs)!= -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device is a Microsoft Xbox.
    public bool DetectXbox()
    {
        if (useragent.IndexOf(deviceXbox)!= -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device is an Internet-capable game console.
    public bool DetectGameConsole()
    {
        if (DetectSonyPlaystation())
            return true;
        else if (DetectNintendo())
            return true;
        else if (DetectXbox())
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device supports MIDP, a mobile Java technology.
    public bool DetectMidpCapable()
    {
        if (useragent.IndexOf(deviceMidp)!= -1 ||
            httpaccept.IndexOf(deviceMidp)!= -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device is on one of the Maemo-based Nokia Internet Tablets.
    public bool DetectMaemoTablet()
    {
        if (useragent.IndexOf(maemo) != -1)
            return true;
        //For Nokia N810, must be Linux + Tablet, or else it could be something else. 
        else if (useragent.IndexOf(linux) != -1 &&
            useragent.IndexOf(deviceTablet) != -1 &&
            !DetectWebOSTablet() &&
            !DetectAndroid())
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current device is an Archos media player/Internet tablet.
    public bool DetectArchos()
    {
        if (useragent.IndexOf(deviceArchos)!= -1)
            return true;
        else
            return false;
    }

    //**************************
    // Detects if the current browser is a Sony Mylo device.
    public bool DetectSonyMylo()
    {
        if ((useragent.IndexOf(manuSony)!= -1) &&
        	((useragent.IndexOf(qtembedded)!= -1) ||
             (useragent.IndexOf(mylocom2)!= -1)))
			return true;        
        
        return false;
    }



	//*****************************
	// Device Classes
	//*****************************
   
    //**************************
    // Check to see whether the device is any device
    //   in the 'smartphone' category.
    // Note: It's better to use DetectTierIphone() for modern touchscreen devices. 
    public bool DetectSmartphone()
    {
        if (DetectTierIphone() ||
            DetectS60OssBrowser() ||
            DetectSymbianOS() ||
            DetectWindowsMobile() ||
            DetectBlackBerry() ||
            DetectMeegoPhone() ||
            DetectPalmOS())
            return true;
        else
            return false;
    }

    //DetectSmartphone delegate
    public delegate void DetectSmartphoneHandler(object page, MDetectArgs args);
    public event DetectSmartphoneHandler OnDetectSmartphone;

    //**************************
    //   Detects if the current device is a mobile device.
    //   This method catches most of the popular modern devices.
    //   Excludes Apple iPads and other modern tablets.
    public bool DetectMobileQuick()
    {
        //Let's exclude tablets
        if (DetectTierTablet())
            return false;

        //Most mobile browsing is done on smartphones
        if (DetectSmartphone())
            return true;

        //Catch-all for many mobile devices
        if (useragent.IndexOf(mobile) != -1)
            return true;

        if (DetectOperaMobile())
            return true;
        
        //We also look for Kindle devices
        if (DetectKindle() ||
            DetectAmazonSilk())
            return true;
        
        if (DetectWapWml() ||
            DetectMidpCapable() ||
            DetectBrewDevice())
            return true;

        if ((useragent.IndexOf(engineNetfront) != -1) ||
            (useragent.IndexOf(engineUpBrowser) != -1))
            return true;

        return false;
    }

    //DetectMobileQuick delegate
    public delegate void DetectMobileQuickHandler(object page, MDetectArgs args);
    public event DetectMobileQuickHandler OnDetectMobileQuick;


    //**************************
    // The longer and more thorough way to detect for a mobile device.
    //   Will probably detect most feature phones,
    //   smartphone-class devices, Internet Tablets, 
    //   Internet-enabled game consoles, etc.
    //   This ought to catch a lot of the more obscure and older devices, also --
    //   but no promises on thoroughness!
    public bool DetectMobileLong()
    {
        if (DetectMobileQuick())
            return true;
            
        if (DetectGameConsole())
            return true;

        if (DetectDangerHiptop() ||
            DetectMaemoTablet() ||
            DetectSonyMylo() ||
            DetectArchos())
            return true;

        if ((useragent.IndexOf(devicePda) != -1) &&
            (useragent.IndexOf(disUpdate) != -1))
            return true;

        //Detect older phones from certain manufacturers and operators. 
        if ((useragent.IndexOf(uplink) != -1)  ||
            (useragent.IndexOf(engineOpenWeb) != -1) ||
            (useragent.IndexOf(manuSamsung1) != -1) ||
            (useragent.IndexOf(manuSonyEricsson) != -1) ||
            (useragent.IndexOf(manuericsson) != -1) ||
            (useragent.IndexOf(svcDocomo) != -1) ||
            (useragent.IndexOf(svcKddi) != -1) ||
            (useragent.IndexOf(svcVodafone) != -1))
            return true;

        return false;
    }



    //*****************************
    // For Mobile Web Site Design
    //*****************************


    //**************************
    // The quick way to detect for a tier of devices.
    //   This method detects for the new generation of
    //   HTML 5 capable, larger screen tablets.
    //   Includes iPad, Android (e.g., Xoom), BB Playbook, WebOS, etc.
    public bool DetectTierTablet()
    {
        if (DetectIpad()
            || DetectAndroidTablet()
            || DetectBlackBerryTablet()
            || DetectFirefoxOSTablet()
            || DetectUbuntuTablet()
            || DetectWebOSTablet())
            return true;
        else
            return false;
    }

    //DetectTierTablet delegate
    public delegate void DetectTierTabletHandler(object page, MDetectArgs args);
    public event DetectTierTabletHandler OnDetectTierTablet;


    //**************************
    // The quick way to detect for a tier of devices.
    //   This method detects for devices which can 
    //   display iPhone-optimized web content.
    //   Includes iPhone, iPod Touch, Android, Windows Phone, BB10, Playstation Vita, etc.
    public bool DetectTierIphone()
    {
        if (DetectIphoneOrIpod() ||
            DetectAndroidPhone() ||
            DetectWindowsPhone() ||
            DetectBlackBerry10Phone() ||
            DetectPalmWebOS() ||
            DetectBada() ||
            DetectTizen() ||
            DetectFirefoxOSPhone() ||
            DetectSailfishPhone() ||
            DetectUbuntuPhone() ||
			DetectGamingHandheld())
            return true;
        else
            return false;
    }
    
    //DetectTierIphone delegate
    public delegate void DetectTierIphoneHandler(object page, MDetectArgs args);
    public event DetectTierIphoneHandler OnDetectTierIphone;


    //**************************
    // The quick way to detect for a tier of devices.
    //   This method detects for devices which are likely to be capable 
    //   of viewing CSS content optimized for the iPhone, 
    //   but may not necessarily support JavaScript.
    //   Excludes all iPhone Tier devices.
    public bool DetectTierRichCss()
    {
        if (DetectMobileQuick())
        {
            //Exclude iPhone Tier and e-Ink Kindle devices
            if (DetectTierIphone() || DetectKindle())
                return false;

            if (DetectWebkit() ||
                DetectS60OssBrowser())
                return true;

            //Note: 'High' BlackBerry devices ONLY
            if (DetectBlackBerryHigh() == true)
                return true;

            //Older Windows 'Mobile' isn't good enough for iPhone Tier.
            if (DetectWindowsMobile() == true)
                return true;
            if (useragent.IndexOf(engineTelecaQ) != -1)
                return true;

            else
                return false;
        }
        else
            return false;
    }

    //DetectTierRichCss delegate
    public delegate void DetectTierRichCssHandler(object page, MDetectArgs args);
    public event DetectTierRichCssHandler OnDetectTierRichCss;


    //**************************
    // The quick way to detect for a tier of devices.
    //   This method detects for all other types of phones,
    //   but excludes the iPhone and Smartphone Tier devices.
    public bool DetectTierOtherPhones()
    {
        if (DetectMobileLong() == true)
        {
            //Exclude devices in the other 2 categories
            if (DetectTierIphone() ||
                DetectTierRichCss())
                return false;
            else
                return true;
        }
        else
            return false;
    }

    //DetectTierOtherPhones delegate
    public delegate void DetectTierOtherPhonesHandler(object page, MDetectArgs args);
    public event DetectTierOtherPhonesHandler OnDetectTierOtherPhones;

    //***************************************************************
    #endregion

    //Instead of overriding OnInit(), you can override InitializeCulture()
    //  so that detection can happen earlier in page's lifecycle, if necessary. 
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        
        if (useragent == "" && httpaccept == "")
        {
            useragent = (Request.ServerVariables["HTTP_USER_AGENT"] ?? "").ToUpper();
            httpaccept = (Request.ServerVariables["HTTP_ACCEPT"] ?? "").ToUpper();
        }

    }
}


================================================
FILE: ASP_NET/UserControl Technique/MobileDetectControl.ascx
================================================
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MobileDetectControl.ascx.cs" Inherits="WebApplication1.MobileDetect.MobileDetectControl" %>


================================================
FILE: ASP_NET/UserControl Technique/MobileDetectControl.ascx.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1.MobileDetect
{
    public partial class MobileDetectControl : MDetectControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.FireEvents();
        }


        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            //As a test, let's listen for any WebKit-based device. 
            OnDetectWebkit += new DetectWebkitHandler(MobileDetectControl_OnDetectWebkit);

        }

        void MobileDetectControl_OnDetectWebkit(object page, MDetectControl.MDetectArgs args)
        {
            //Write the Type value from the argument to the web page. 
            Response.Write("<b>This browser is " + args.Type + "</b>");

        }
    }
}

================================================
FILE: ASP_NET/UserControl Technique/MobileDetectControl.ascx.designer.cs
================================================
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.42
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace WebApplication1.MobileDetect
{


    public partial class MobileDetectControl
    {
    }
}


================================================
FILE: ASP_NET/UserControl Technique/MobileDetectTestPage.aspx
================================================
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MobileDetectTestPage.aspx.cs" Inherits="WebApplication1.MobileDetect.MobileDetectTestPage" %>
<%@ Register  TagPrefix="mdc" TagName="MobileDetect" Src="MobileDetectControl.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <mdc:MobileDetect id="MDC" runat="server"></mdc:MobileDetect>
    </div>
    </form>
</body>
</html>


================================================
FILE: ASP_NET/UserControl Technique/MobileDetectTestPage.aspx.cs
================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1.MobileDetect
{
    public partial class MobileDetectTestPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}


================================================
FILE: ASP_NET/UserControl Technique/MobileDetectTestPage.aspx.designer.cs
================================================
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3607
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace WebApplication1.MobileDetect {
    
    
    public partial class MobileDetectTestPage {
        
        /// <summary>
        /// form1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlForm form1;
        
        /// <summary>
        /// MDC control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::WebApplication1.MobileDetect.MobileDetectControl MDC;
    }
}


================================================
FILE: Cpp/mdetect.h
================================================
/* *******************************************
// Copyright 2010-2015, Anthony Hand
//
//
// File version 2015.05.13 (May 13, 2015)
// Updates:
//	- Moved MobileESP to GitHub. https://github.com/ahand/mobileesp
//	- Opera Mobile/Mini browser has the same UA string on multiple platforms and doesn't differentiate phone vs. tablet. 
//		- Removed DetectOperaAndroidPhone(). This method is no longer reliable. 
//		- Removed DetectOperaAndroidTablet(). This method is no longer reliable. 
//	- Added support for Windows Phone 10: variable and DetectWindowsPhone10()
//	- Updated DetectWindowsPhone() to include WP10. 
//	- Added support for Firefox OS.  
//		- A variable plus DetectFirefoxOS(), DetectFirefoxOSPhone(), DetectFirefoxOSTablet()
//		- NOTE: Firefox doesn't add UA tokens to definitively identify Firefox OS vs. their browsers on other mobile platforms.
//	- Added support for Sailfish OS. Not enough info to add a tablet detection method at this time. 
//		- A variable plus DetectSailfish(), DetectSailfishPhone()
//	- Added support for Ubuntu Mobile OS. 
//		- DetectUbuntu(), DetectUbuntuPhone(), DetectUbuntuTablet()
//	- Added support for 2 smart TV OSes. They lack browsers but do have WebViews for use by HTML apps. 
//		- One variable for Samsung Tizen TVs, plus DetectTizenTV()
//		- One variable for LG WebOS TVs, plus DetectWebOSTV()
//	- Updated DetectTizen(). Now tests for “mobile” to disambiguate from Samsung Smart TVs
//	- Removed variables for obsolete devices: deviceHtcFlyer, deviceXoom.
//	- Updated DetectAndroid(). No longer has a special test case for the HTC Flyer tablet. 
//	- Updated DetectAndroidPhone(). 
//		- Updated internal detection code for Android. 
//		- No longer has a special test case for the HTC Flyer tablet. 
//		- Checks against DetectOperaMobile() on Android and reports here if relevant. 
//	- Updated DetectAndroidTablet(). 
//		- No longer has a special test case for the HTC Flyer tablet. 
//		- Checks against DetectOperaMobile() on Android to exclude it from here.
//	- DetectMeego(): Changed definition for this method. Now detects any Meego OS device, not just phones. 
//	- DetectMeegoPhone(): NEW. For Meego phones. Ought to detect Opera browsers on Meego, as well.  
//	- DetectTierIphone(): Added support for phones running Sailfish, Ubuntu and Firefox Mobile. 
//	- DetectTierTablet(): Added support for tablets running Ubuntu and Firefox Mobile. 
//	- DetectSmartphone(): Added support for Meego phones. 
//	- Removed the variable for Obigo, an embedded browser. The browser is on old devices. 
//		- Couldn’t find info on current Obigo embedded browser user agent strings.
//	- Refactored the detection logic in DetectMobileQuick() and DetectMobileLong().
//		- Moved a few detection tests for older browsers to Long. 
//
//
//
// File version 2014.01.24 (January 24, 2014)
//	Updates:
//	- Ported to C++ by Kiran T. Based on the PHP library.
//
//
//
// LICENSE INFORMATION
// Licensed under the Apache License, Version 2.0 (the "License"); 
// you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at 
//        http://www.apache.org/licenses/LICENSE-2.0 
// Unless required by applicable law or agreed to in writing, 
// software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific 
// language governing permissions and limitations under the License. 
//
//
// ABOUT THIS PROJECT
//   Project Owner: Anthony Hand
//   Email: anthony.hand@gmail.com
//   Web Site: http://www.mobileesp.com
//   Source Files: https://github.com/ahand/mobileesp
//   
//   Versions of this code are available for:
//      PHP, JavaScript, Java, ASP.NET (C#), C++, and Ruby
//
// *******************************************
*/
#ifndef MDETECT_H
#define MDETECT_H

#include <string>
#include <algorithm>

using namespace std;

namespace MobileESP
{
   //Initialize some initial smartphone string variables.
   const string engineWebKit = "webkit";

   const string deviceIphone = "iphone";
   const string deviceIpod = "ipod";
   const string deviceIpad = "ipad";
   const string deviceMacPpc = "macintosh"; //Used for disambiguation

   const string deviceAndroid = "android";
   const string deviceGoogleTV = "googletv";
   const string deviceHtcFlyer = "htc_flyer"; //HTC Flyer
   
   const string deviceWinPhone7 = "windows phone os 7"; 
   const string deviceWinPhone8 = "windows phone 8"; 
   const string deviceWinPhone10 = "windows phone 10"; 
   const string deviceWinMob = "windows ce";
   const string deviceWindows = "windows"; 
   const string deviceIeMob = "iemobile";
   const string devicePpc = "ppc"; //Stands for PocketPC
   const string enginePie = "wm5 pie"; //An old Windows Mobile
   
   const string deviceBB = "blackberry";   
   const string deviceBB10 = "bb10"; //For the new BB 10 OS
   const string vndRIM = "vnd.rim"; //Detectable when BB devices emulate IE or Firefox
   const string deviceBBStorm = "blackberry95";  //Storm 1 and 2
   const string deviceBBBold = "blackberry97"; //Bold 97x0 (non-touch)
   const string deviceBBBoldTouch = "blackberry 99"; //Bold 99x0 (touchscreen)
   const string deviceBBTour = "blackberry96"; //Tour
   const string deviceBBCurve = "blackberry89"; //Curve2
   const string deviceBBCurveTouch = "blackberry 938"; //Curve Touch
   const string deviceBBTorch = "blackberry 98"; //Torch
   const string deviceBBPlaybook = "playbook"; //PlayBook tablet
   
   const string deviceSymbian = "symbian";
   const string deviceS60 = "series60";
   const string deviceS70 = "series70";
   const string deviceS80 = "series80";
   const string deviceS90 = "series90";
   
   const string devicePalm = "palm";
   const string deviceWebOS = "webos"; //For Palm devices
   const string deviceWebOStv = "web0s"; //For LG TVs
   const string deviceWebOShp = "hpwos"; //For HP's line of WebOS devices
   
   const string engineBlazer = "blazer"; //Old Palm browser
   const string engineXiino = "xiino"; //Another old Palm
   
   const string deviceNuvifone = "nuvifone"; //Garmin Nuvifone
   const string deviceBada = "bada"; //Samsung's Bada OS
   const string deviceTizen = "tizen"; //Tizen OS
   const string deviceMeego = "meego"; //Meego OS
   const string deviceSailfish = "sailfish"; //Sailfish OS
   const string deviceUbuntu = "ubuntu"; //Ubuntu Mobile OS

   const string deviceKindle = "kindle"; //Amazon Kindle, eInk one
   const string engineSilk = "silk-accelerated"; //Amazon's accelerated Silk browser for Kindle Fire
   
   //Initialize variables for mobile-specific content.
   const string vndwap = "vnd.wap";
   const string wml = "wml";   
   
   //Initialize variables for other random devices and mobile browsers.
   const string deviceTablet = "tablet"; //Generic term for slate and tablet devices
   const string deviceBrew = "brew";
   const string deviceDanger = "danger";
   const string deviceHiptop = "hiptop";
   const string devicePlaystation = "playstation";
   const string devicePlaystationVita = "vita";
   const string deviceNintendoDs = "nitro";
   const string deviceNintendo = "nintendo";
   const string deviceWii = "wii";
   const string deviceXbox = "xbox";
   const string deviceArchos = "archos";
   
   const string engineFirefox = "firefox"; //For Firefox OS
   const string engineOpera = "opera"; //Popular browser
   const string engineNetfront = "netfront"; //Common embedded OS browser
   const string engineUpBrowser = "up.browser"; //common on some phones
   const string engineOpenWeb = "openweb"; //Transcoding by OpenWave server
   const string deviceMidp = "midp"; //a mobile Java technology
   const string uplink = "up.link";
   const string engineTelecaQ = "teleca q"; //a modern feature phone browser
   
   const string devicePda = "pda"; //some devices report themselves as PDAs
   const string mini = "mini";  //Some mobile browsers put 'mini' in their names.
   const string mobile = "mobile"; //Some mobile browsers put 'mobile' in their user agent strings.
   const string mobi = "mobi"; //Some mobile browsers put 'mobi' in their user agent strings.
   
   //Smart TV strings
   const string smartTV1 = "smart-tv"; //Samsung Tizen smart TVs
   const string smartTV2 = "smarttv"; //LG WebOS smart TVs

   //Use Maemo, Tablet, and Linux to test for Nokia's Internet Tablets.
   const string maemo = "maemo";
   const string llinux = "linux";
   const string qtembedded = "qt embedded"; //for Sony Mylo and others
   const string mylocom2 = "com2"; //for Sony Mylo also
   
   //In some UserAgents, the only clue is the manufacturer.
   const string manuSonyEricsson = "sonyericsson";
   const string manuericsson = "ericsson";
   const string manuSamsung1 = "sec-sgh";
   const string manuSony = "sony";
   const string manuHtc = "htc";

   //In some UserAgents, the only clue is the operator.
   const string svcDocomo = "docomo";
   const string svcKddi = "kddi";
   const string svcVodafone = "vodafone";

   //Disambiguation strings.
   const string disUpdate = "update"; //pda vs. update

//**************************
// The uagent_info class encapsulates information about
//   a browser's connection to your web site. 
//   You can use it to find out whether the browser asking for
//   your site's content is probably running on a mobile device.
//   The methods were written so you can be as granular as you want.
//   For example, enquiring whether it's as specific as an iPod Touch or
//   as general as a smartphone class device.
//   The object's methods return 1 for true, or 0 for false.
class uagent_info
{
private:
   string useragent;
   string httpaccept;
   //Let's store values for quickly accessing the same info multiple times. InitCompleted
   bool initCompleted; //Stores whether we're currently initializing the most popular functions.
   bool isWebkit; //Stores the result of DetectWebkit()
   bool isMobilePhone; //Stores the result of DetectMobileQuick()
   bool isIphone; //Stores the result of DetectIphone()
   bool isAndroid; //Stores the result of DetectAndroid()
   bool isAndroidPhone; //Stores the result of DetectAndroidPhone()
   bool isTierTablet; //Stores the result of DetectTierTablet()
   bool isTierIphone; //Stores the result of DetectTierIphone()
   bool isTierRichCss; //Stores the result of DetectTierRichCss()
   bool isTierGenericMobile; //Stores the result of DetectTierOtherPhones()

   //**************************
   // Initialize Key Stored Values.
   void InitDeviceScan()
   {
        //Save these properties to speed processing
        isWebkit = DetectWebkit();
        isIphone = DetectIphone();
        isAndroid = DetectAndroid();
        isAndroidPhone = DetectAndroidPhone();
        
        //These tiers are the most useful for web development
        isTierTablet = DetectTierTablet(); //Do first
        isTierIphone = DetectTierIphone(); //Do second
        isMobilePhone = DetectMobileQuick(); //Do third
        
        //Optional: Comment these out if you NEVER use them.
        isTierRichCss = DetectTierRichCss();
        isTierGenericMobile = DetectTierOtherPhones();
        
        initCompleted = true;
   }

public:

   //**************************
   //The constructor.
   uagent_info(const string &user_agent,const string &accept):
	useragent(user_agent),
	httpaccept(accept),
   	initCompleted(false),
  	isWebkit(false),
	isMobilePhone(false),
	isIphone(false),
	isAndroid(false),
	isAndroidPhone(false),
	isTierTablet(false),
	isTierIphone(false),
	isTierRichCss(false),
	isTierGenericMobile(false)
   { 
	 std::transform(useragent.begin(), useragent.end(),useragent.begin(), ::tolower);
	 std::transform(httpaccept.begin(), httpaccept.end(),httpaccept.begin(), ::tolower);
		
	 //Let's initialize some values to save cycles later.
	 InitDeviceScan();
   }
   
   

   //**************************
   //Returns the contents of the User Agent value, in lower case.
   string Get_Uagent()
   { 
       return useragent;
   }

   //**************************
   //Returns the contents of the HTTP Accept value, in lower case.
   string Get_HttpAccept()
   { 
       return httpaccept;
   }
   

   //**************************
   // Detects if the current device is an iPhone.
   bool DetectIphone()
   {
      if (initCompleted == true ||
          isIphone == true)
         return isIphone;
      
      if (useragent.find( MobileESP::deviceIphone) != std::string::npos)
      {
         //The iPad and iPod Touch say they're an iPhone. So let's disambiguate.
         if (DetectIpad() == true ||
             DetectIpod() == true)
            return false;
         //Yay! It's an iPhone!
         else
            return true; 
      }
      else
         return false; 
   }

   //**************************
   // Detects if the current device is an iPod Touch.
   bool DetectIpod()
   {
      if (useragent.find( MobileESP::deviceIpod) != std::string::npos)
         return true; 
      else
         return false; 
   }
   
   //**************************
   // Detects if the current device is an iPad tablet.
   bool DetectIpad()
   {
      if (useragent.find( MobileESP::deviceIpad) != std::string::npos &&
          DetectWebkit() == true)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current device is an iPhone or iPod Touch.
   bool DetectIphoneOrIpod()
   {
       //We repeat the searches here because some iPods may report themselves as an iPhone, which would be okay.
      if (DetectIphone() == true ||
             DetectIpod() == true)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects *any* iOS device: iPhone, iPod Touch, iPad.
   bool DetectIos()
   {
      if ((DetectIphoneOrIpod() == true) ||
        (DetectIpad() == true))
         return true; 
      else
         return false;
   }


   //**************************
   // Detects *any* Android OS-based device: phone, tablet, and multi-media player.
   // Also detects Google TV.
   bool DetectAndroid()
   {
      if (initCompleted == true ||
          isAndroid == true)
         return isAndroid;

      if ((useragent.find( MobileESP::deviceAndroid) != std::string::npos)
          || (DetectGoogleTV() == true))
         return true; 
         
      return false; 
   }

   //**************************
   // Detects if the current device is a (small-ish) Android OS-based device
   // used for calling and/or multi-media (like a Samsung Galaxy Player).
   // Google says these devices will have 'Android' AND 'mobile' in user agent.
   // Ignores tablets (Honeycomb and later).
   bool DetectAndroidPhone()
   {
      if (initCompleted == true ||
          isAndroidPhone == true)
         return isAndroidPhone;

      //First, let's make sure we're on an Android device.
      if (DetectAndroid() == false)
         return false; 

      //If it's Android and has 'mobile' in it, Google says it's a phone.
      if (useragent.find( MobileESP::mobile) != std::string::npos)
         return true;
      
      //Special check for Android devices with Opera Mobile/Mini. They should report here.
      if ((DetectOperaMobile() == true))
         return true; 

      return false; 
   }

   //**************************
   // Detects if the current device is a (self-reported) Android tablet.
   // Google says these devices will have 'Android' and NOT 'mobile' in their user agent.
   bool DetectAndroidTablet()
   {
      //First, let's make sure we're on an Android device.
      if (DetectAndroid() == false)
         return false; 

      //Special check for Android devices with Opera Mobile/Mini. They should NOT report here.
      if (DetectOperaMobile() == true)
         return false; 
         
      //Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet.
      if (useragent.find( MobileESP::mobile) != std::string::npos)
         return false;
         
      return true; 
   }

   //**************************
   // Detects if the current device is an Android OS-based device and
   //   the browser is based on WebKit.
   bool DetectAndroidWebKit()
   {
      if ((DetectAndroid() == true) &&
		(DetectWebkit() == true))
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current device is a GoogleTV.
   bool DetectGoogleTV()
   {
      if (useragent.find( MobileESP::deviceGoogleTV) != std::string::npos)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current browser is based on WebKit.
   bool DetectWebkit()
   {
      if (initCompleted == true ||
          isWebkit == true)
         return isWebkit;

      if (useragent.find( MobileESP::engineWebKit) != std::string::npos)
         return true; 
      else
         return false; 
   }


   //**************************
   // Detects if the current browser is a 
   // Windows Phone 7, 8, or 10 device.
   bool DetectWindowsPhone()
   {
      if ((DetectWindowsPhone7() == true)
			|| (DetectWindowsPhone8() == true)
			|| (DetectWindowsPhone10() == true))
         return true; 
      else
         return false; 
   }
   
   //**************************
   // Detects a Windows Phone 7 device (in mobile browsing mode).
   bool DetectWindowsPhone7()
   {
      if (useragent.find( MobileESP::deviceWinPhone7) != std::string::npos)
         return true; 
      else
         return false; 
   }
   
   //**************************
   // Detects a Windows Phone 8 device (in mobile browsing mode).
   bool DetectWindowsPhone8()
   {
      if (useragent.find( MobileESP::deviceWinPhone8) != std::string::npos)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects a Windows Phone 10 device (in mobile browsing mode).
   bool DetectWindowsPhone10()
   {
      if (useragent.find( MobileESP::deviceWinPhone10) != std::string::npos)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current browser is a Windows Mobile device.
   // Excludes Windows Phone 7 and later devices. 
   // Focuses on Windows Mobile 6.xx and earlier.
   bool DetectWindowsMobile()
   {
      if (DetectWindowsPhone() == true)
         return false;
      
      //Most devices use 'Windows CE', but some report 'iemobile' 
      //  and some older ones report as 'PIE' for Pocket IE. 
      if (useragent.find( MobileESP::deviceWinMob) != std::string::npos ||
          useragent.find( MobileESP::deviceIeMob) != std::string::npos ||
          useragent.find( MobileESP::enginePie) != std::string::npos)
         return true; 
      //Test for Windows Mobile PPC but not old Macintosh PowerPC.
	  if (useragent.find( MobileESP::devicePpc) != std::string::npos
		  && !(useragent.find( MobileESP::deviceMacPpc) > 1))
         return true; 
      //Test for certain Windwos Mobile-based HTC devices.
      if (useragent.find( MobileESP::manuHtc) != std::string::npos &&
          useragent.find( MobileESP::deviceWindows) != std::string::npos)
         return true; 
      if (DetectWapWml() == true &&
          useragent.find( MobileESP::deviceWindows) != std::string::npos) 
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current browser is any BlackBerry device.
   // Includes BB10 OS, but excludes the PlayBook.
   bool DetectBlackBerry()
   {
       if ((useragent.find( MobileESP::deviceBB) != std::string::npos) ||
          (httpaccept.find( MobileESP::vndRIM) != std::string::npos))
         return true;
      if (DetectBlackBerry10Phone() == true) 
         return true;       
       else
         return false; 
   }
   
   //**************************
   // Detects if the current browser is a BlackBerry 10 OS phone.
   // Excludes tablets.
   bool DetectBlackBerry10Phone()
   {
       if ((useragent.find( MobileESP::deviceBB10) != std::string::npos) &&
          (useragent.find( MobileESP::mobile) != std::string::npos))
         return true; 
       else
         return false; 
   }
   
   //**************************
   // Detects if the current browser is on a BlackBerry tablet device.
   //    Examples: PlayBook
   bool DetectBlackBerryTablet()
   {
      if ((useragent.find( MobileESP::deviceBBPlaybook) != std::string::npos))
         return true; 
      else
        return false; 
   }

   //**************************
   // Detects if the current browser is a BlackBerry phone device AND uses a
   //    WebKit-based browser. These are signatures for the new BlackBerry OS 6.
   //    Examples: Torch. Includes the Playbook.
   bool DetectBlackBerryWebKit()
   {
      if ((DetectBlackBerry() == true) &&
		(DetectWebkit() == true))
         return true; 
      else
        return false; 
   }

   //**************************
   // Detects if the current browser is a BlackBerry Touch phone device with
   //    a large screen, such as the Storm, Torch, and Bold Touch. Excludes the Playbook.
   bool DetectBlackBerryTouch()
   {  
       if ((useragent.find( MobileESP::deviceBBStorm) != std::string::npos) ||
		(useragent.find( MobileESP::deviceBBTorch) != std::string::npos) ||
		(useragent.find( MobileESP::deviceBBBoldTouch) != std::string::npos) ||
		(useragent.find( MobileESP::deviceBBCurveTouch) != std::string::npos))
         return true; 
       else
         return false; 
   }
   
   //**************************
   // Detects if the current browser is a BlackBerry OS 5 device AND
   //    has a more capable recent browser. Excludes the Playbook.
   //    Examples, Storm, Bold, Tour, Curve2
   //    Excludes the new BlackBerry OS 6 and 7 browser!!
   bool DetectBlackBerryHigh()
   {
      //Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser
      if (DetectBlackBerryWebKit() == true)
         return false; 
      if (DetectBlackBerry() == true)
      {
          if ((DetectBlackBerryTouch() == true) ||
            useragent.find( MobileESP::deviceBBBold) != std::string::npos ||
            useragent.find( MobileESP::deviceBBTour) != std::string::npos ||
            useragent.find( MobileESP::deviceBBCurve) != std::string::npos)
          {
             return true; 
          }
          else
            return false; 
      }
      else
        return false; 
   }

   //**************************
   // Detects if the current browser is a BlackBerry device AND
   //    has an older, less capable browser. 
   //    Examples: Pearl, 8800, Curve1.
   bool DetectBlackBerryLow()
   {
      if (DetectBlackBerry() == true)
      {
          //Assume that if it's not in the High tier, then it's Low.
          if ((DetectBlackBerryHigh() == true) ||
			(DetectBlackBerryWebKit() == true))
             return false; 
          else
            return true; 
      }
      else
        return false; 
   }


   //**************************
   // Detects if the current browser is the Nokia S60 Open Source Browser.
   bool DetectS60OssBrowser()
   {
      //First, test for WebKit, then make sure it's either Symbian or S60.
      if (DetectWebkit() == true)
      {
        if (useragent.find( MobileESP::deviceSymbian) != std::string::npos ||
            useragent.find( MobileESP::deviceS60) != std::string::npos)
        {
           return true;
        }
        else
           return false; 
      }
      else
         return false; 
   }
   
   //**************************
   // Detects if the current device is any Symbian OS-based device,
   //   including older S60, Series 70, Series 80, Series 90, and UIQ, 
   //   or other browsers running on these devices.
   bool DetectSymbianOS()
   {
       if (useragent.find( MobileESP::deviceSymbian) != std::string::npos || 
           useragent.find( MobileESP::deviceS60) != std::string::npos ||
           useragent.find( MobileESP::deviceS70) != std::string::npos || 
           useragent.find( MobileESP::deviceS80) != std::string::npos ||
           useragent.find( MobileESP::deviceS90) != std::string::npos)
         return true; 
      else
         return false; 
   }


   //**************************
   // Detects if the current browser is on a PalmOS device.
   bool DetectPalmOS()
   {
		//Make sure it's not WebOS first
		if (DetectPalmWebOS() == true)
			return false;

      //Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino.
      if (useragent.find( MobileESP::devicePalm) != std::string::npos ||
          useragent.find( MobileESP::engineBlazer) != std::string::npos ||
          useragent.find( MobileESP::engineXiino) != std::string::npos)
            return true; 
      else
         return false; 
   }


   //**************************
   // Detects if the current browser is on a Palm device
   //   running the new WebOS.
   bool DetectPalmWebOS()
   {
      if (useragent.find( MobileESP::deviceWebOS) != std::string::npos)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current browser is on an HP tablet running WebOS.
   bool DetectWebOSTablet()
   {
      if ((useragent.find( MobileESP::deviceWebOShp) != std::string::npos)
			&& (useragent.find( MobileESP::deviceTablet) != std::string::npos))
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current browser is on a WebOS smart TV.
   bool DetectWebOSTV()
   {
      if ((useragent.find( MobileESP::deviceWebOStv) != std::string::npos)
			&& (useragent.find( MobileESP::smartTV2) != std::string::npos))
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current browser is Opera Mobile or Mini.
   bool DetectOperaMobile()
   {
      if (useragent.find( MobileESP::engineOpera) != std::string::npos)
      {
         if ((useragent.find( MobileESP::mini) != std::string::npos) ||
          (useragent.find( MobileESP::mobi) != std::string::npos))
            return true; 
         else
            return false; 
      }
      else
         return false; 
   }

   //**************************
   // Detects if the current device is an Amazon Kindle (eInk devices only).
   // Note: For the Kindle Fire, use the normal Android methods. 
   bool DetectKindle()
   {
      if (useragent.find( MobileESP::deviceKindle) != std::string::npos &&
          DetectAndroid() == false)
         return true; 
      else
         return false; 
   }
   
   //**************************
   // Detects if the current Amazon device has turned on the Silk accelerated browsing feature.
   // Note: Typically used by the the Kindle Fire.
   bool DetectAmazonSilk()
   {
      if (useragent.find( MobileESP::engineSilk) != std::string::npos)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if a Garmin Nuvifone device.
   bool DetectGarminNuvifone()
   {
      if (useragent.find( MobileESP::deviceNuvifone) != std::string::npos)
         return true; 
      else
         return false; 
   }
   
   //**************************
   // Detects a device running the Bada smartphone OS from Samsung.
   bool DetectBada()
   {
      if (useragent.find( MobileESP::deviceBada) != std::string::npos)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects a device running the Tizen smartphone OS.
   bool DetectTizen()
   {
      if ((useragent.find( MobileESP::deviceTizen) != std::string::npos)
			&& (useragent.find( MobileESP::mobile) != std::string::npos))
         return true; 
      else
         return false; 
   }
   
    //**************************
   // Detects if the current browser is on a Tizen smart TV.
   bool DetectTizenTV()
   {
      if ((useragent.find( MobileESP::deviceTizen) != std::string::npos)
			&& (useragent.find( MobileESP::smartTV1) != std::string::npos))
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects a device running the Meego OS.
   bool DetectMeego()
   {
      if (useragent.find( MobileESP::deviceMeego) != std::string::npos)
         return true; 
      else
         return false; 
   }
   
    //**************************
   // Detects a phone running the Meego OS.
   bool DetectMeegoPhone()
   {
      if ((useragent.find( MobileESP::deviceMeego) != std::string::npos)
			&& (useragent.find( MobileESP::mobi) != std::string::npos))
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects a mobile device (probably) running the Firefox OS.
   bool DetectFirefoxOS()
   {
      if ((DetectFirefoxOSPhone() == true) || DetectFirefoxOSTablet())
         return true;
      
      return false; 
   }

   //**************************
   // Detects a phone (probably) running the Firefox OS.
   bool DetectFirefoxOSPhone()
   {
      //First, let's make sure we're NOT on another major mobile OS.
      if (DetectIos() || 
      	DetectAndroid() || 
      	DetectSailfish())
         return false;
            
      if ((useragent.find( MobileESP::engineFirefox) != std::string::npos) &&
		(useragent.find( MobileESP::mobile) != std::string::npos))
         return true;
      
      return false; 
   }

   //**************************
   // Detects a tablet (probably) running the Firefox OS.
   bool DetectFirefoxOSTablet()
   {
      //First, let's make sure we're NOT on another major mobile OS.
      if (DetectIos() || 
      	DetectAndroid() || 
      	DetectSailfish())
         return false;
            
      if ((useragent.find( MobileESP::engineFirefox) != std::string::npos) &&
		(useragent.find( MobileESP::deviceTablet) != std::string::npos))
         return true;
      
      return false; 
   }

   //**************************
   // Detects a device running the Sailfish OS.
   bool DetectSailfish()
   {
      if (useragent.find( MobileESP::deviceSailfish) != std::string::npos)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects a phone running the Sailfish OS.
   bool DetectSailfishPhone()
   {
      if ((DetectSailfish() == true) &&
		(useragent.find( MobileESP::mobile) != std::string::npos))
         return true;
      
      return false; 
   }

   //**************************
   // Detects a mobile device running the Ubuntu Mobile OS.
   bool DetectUbuntu()
   {
      if ((DetectUbuntuPhone() == true) || DetectUbuntuTablet() == true)
         return true;
      
      return false; 
   }

   //**************************
   // Detects a phone running the Ubuntu Mobile OS.
   bool DetectUbuntuPhone()
   {
      if ((useragent.find( MobileESP::deviceUbuntu) != std::string::npos) &&
		(useragent.find( MobileESP::mobile) != std::string::npos))
         return true;
      
      return false; 
   }

   //**************************
   // Detects a tablet running the Ubuntu Mobile OS.
   bool DetectUbuntuTablet()
   {
      if ((useragent.find( MobileESP::deviceUbuntu) != std::string::npos) &&
		(useragent.find( MobileESP::deviceTablet) != std::string::npos))
         return true;
      
      return false; 
   }
   
   //**************************
   // Detects the Danger Hiptop device.
   bool DetectDangerHiptop()
   {
      if (useragent.find( MobileESP::deviceDanger) != std::string::npos ||
          useragent.find( MobileESP::deviceHiptop) != std::string::npos)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current browser is a Sony Mylo device.
   bool DetectSonyMylo()
   {
      if ((useragent.find( MobileESP::manuSony) != std::string::npos) &&
         ((useragent.find( MobileESP::qtembedded) != std::string::npos) ||
          (useragent.find( MobileESP::mylocom2) != std::string::npos)))
         return true; 
      else
         return false; 
   }
   
   //**************************
   // Detects if the current device is on one of the Maemo-based Nokia Internet Tablets.
   bool DetectMaemoTablet()
   {
      if (useragent.find( MobileESP::maemo) != std::string::npos)
         return true; 
      //For Nokia N810, must be Linux + Tablet, or else it could be something else. 
      if ((useragent.find( MobileESP::llinux) != std::string::npos)
		&& (useragent.find( MobileESP::deviceTablet) != std::string::npos) 
		&& (DetectWebOSTablet() == false)
		&& (DetectAndroid() == false))
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current device is an Archos media player/Internet tablet.
   bool DetectArchos()
   {
      if (useragent.find( MobileESP::deviceArchos) != std::string::npos)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current device is an Internet-capable game console.
   // Includes many handheld consoles.
   bool DetectGameConsole()
   {
      if ((DetectSonyPlaystation() == true) ||
		 (DetectNintendo() == true) ||
		 (DetectXbox() == true))
         return true; 
      else
         return false; 
   }
   
   //**************************
   // Detects if the current device is a Sony Playstation.
   bool DetectSonyPlaystation()
   {
      if (useragent.find( MobileESP::devicePlaystation) != std::string::npos)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current device is a handheld gaming device with
   // a touchscreen and modern iPhone-class browser. Includes the Playstation Vita.
   bool DetectGamingHandheld()
   {
      if ((useragent.find( MobileESP::devicePlaystation) != std::string::npos) &&
         (useragent.find( MobileESP::devicePlaystationVita) != std::string::npos))
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current device is a Nintendo game device.
   bool DetectNintendo()
   {
      if (useragent.find( MobileESP::deviceNintendo) != std::string::npos || 
           useragent.find( MobileESP::deviceWii) != std::string::npos ||
           useragent.find( MobileESP::deviceNintendoDs) != std::string::npos)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects if the current device is a Microsoft Xbox.
   bool DetectXbox()
   {
      if (useragent.find( MobileESP::deviceXbox) != std::string::npos)
         return true; 
      else
         return false; 
   }

   //**************************
   // Detects whether the device is a Brew-powered device.
   bool DetectBrewDevice()
   {
       if (useragent.find( MobileESP::deviceBrew) != std::string::npos)
         return true; 
      else
         return false; 
   }
   
   //**************************
   // Detects whether the device supports WAP or WML.
   bool DetectWapWml()
   {
       if (httpaccept.find( MobileESP::vndwap) != std::string::npos ||
           httpaccept.find( MobileESP::wml) != std::string::npos)
         return true; 
      else
         return false; 
   }
   
   //**************************
   // Detects if the current device supports MIDP, a mobile Java technology.
   bool DetectMidpCapable()
   {
       if (useragent.find( MobileESP::deviceMidp) != std::string::npos || 
           httpaccept.find( MobileESP::deviceMidp) != std::string::npos)
         return true; 
      else
         return false; 
   }



  //*****************************
  // Device Classes
  //*****************************
   
   //**************************
   // Check to see whether the device is *any* 'smartphone'.
   //   Note: It's better to use DetectTierIphone() for modern touchscreen devices. 
   bool DetectSmartphone()
   {
      //Exclude duplicates from TierIphone
      if ((DetectTierIphone() == true)
		|| (DetectS60OssBrowser() == true)
		|| (DetectSymbianOS() == true) 
		|| (DetectWindowsMobile() == true)
		|| (DetectBlackBerry() == true)
		|| (DetectMeegoPhone() == true)
		|| (DetectPalmWebOS() == true))
         return true; 
      else
         return false; 
   }

   //**************************
   // The quick way to detect for a mobile device.
   //   Will probably detect most recent/current mid-tier Feature Phones
   //   as well as smartphone-class devices. Excludes Apple iPads and other modern tablets.
   bool DetectMobileQuick()
   {
      if (initCompleted == true ||
          isMobilePhone == true)
         return isMobilePhone;

      //Let's exclude tablets
      if (isTierTablet == true) 
         return false;
      
      //Most mobile browsing is done on smartphones
      if (DetectSmartphone() == true) 
         return true;

      //Catch-all for many mobile devices
      if (useragent.find( MobileESP::mobile) != std::string::npos)
         return true; 

      if (DetectOperaMobile() == true)
         return true;

      //We also look for Kindle devices
      if (DetectKindle() == true ||
         DetectAmazonSilk() == true) 
         return true;

      if ((DetectWapWml() == true) 
			|| (DetectMidpCapable() == true) 
			|| (DetectBrewDevice() == true))
         return true;
         
      if ((useragent.find( MobileESP::engineNetfront) != std::string::npos)
			|| (useragent.find( MobileESP::engineUpBrowser) != std::string::npos))
         return true; 
         
      else
         return false; 
   }
  
   //**************************
   // The longer and more thorough way to detect for a mobile device.
   //   Will probably detect most feature phones,
   //   smartphone-class devices, Internet Tablets, 
   //   Internet-enabled game consoles, etc.
   //   This ought to catch a lot of the more obscure and older devices, also --
   //   but no promises on thoroughness!
   bool DetectMobileLong()
   {
      if (DetectMobileQuick() == true) 
         return true; 
      if (DetectGameConsole() == true) 
         return true; 
         
      if ((DetectDangerHiptop() == true) 
			|| (DetectMaemoTablet() == true)
			|| (DetectSonyMylo() == true)
			|| (DetectArchos() == true))
         return true; 

       if ((useragent.find( MobileESP::devicePda) != std::string::npos) &&
		 !(useragent.find( MobileESP::disUpdate) != std::string::npos))
         return true;
      
       //Detect older phones from certain manufacturers and operators. 
       if ((useragent.find( MobileESP::uplink) != std::string::npos)
       		|| (useragent.find( MobileESP::engineOpenWeb) != std::string::npos)
       		|| (useragent.find( MobileESP::manuSamsung1) != std::string::npos)
       		|| (useragent.find( MobileESP::manuSonyEricsson) != std::string::npos)
       		|| (useragent.find( MobileESP::manuericsson) != std::string::npos)
       		|| (useragent.find( MobileESP::svcDocomo) != std::string::npos)
       		|| (useragent.find( MobileESP::svcKddi) != std::string::npos)
       		|| (useragent.find( MobileESP::svcVodafone) != std::string::npos))
         return true;

       return false; 
   }


  //*****************************
  // For Mobile Web Site Design
  //*****************************

   //**************************
   // The quick way to detect for a tier of devices.
   //   This method detects for the new generation of
   //   HTML 5 capable, larger screen tablets.
   //   Includes iPad, Android (e.g., Xoom), BB Playbook, WebOS, etc.
   bool DetectTierTablet()
   {
      if (initCompleted == true ||
          isTierTablet == true)
         return isTierTablet;

      if ((DetectIpad() == true) 
         || (DetectAndroidTablet() == true) 
         || (DetectBlackBerryTablet() == true) 
         || (DetectFirefoxOSTablet() == true)
         || (DetectUbuntuTablet() == true)
         || (DetectWebOSTablet() == true))
         return true; 
      else
         return false; 
   }


   //**************************
   // The quick way to detect for a tier of devices.
   //   This method detects for devices which can 
   //   display iPhone-optimized web content.
   //   Includes iPhone, iPod Touch, Android, Windows Phone 7 and 8, BB10, WebOS, Playstation Vita, etc.
   bool DetectTierIphone()
   {
      if (initCompleted == true ||
          isTierIphone == true)
         return isTierIphone;

      if ((DetectIphoneOrIpod() == true)
			|| (DetectAndroidPhone() == true)
			|| (DetectWindowsPhone() == true)
			|| (DetectBlackBerry10Phone() == true)
			|| (DetectPalmWebOS() == true)
			|| (DetectBada() == true)
			|| (DetectTizen() == true)
			|| (DetectFirefoxOSPhone() == true)
			|| (DetectSailfishPhone() == true)
			|| (DetectUbuntuPhone() == true)
			|| (DetectGamingHandheld() == true))
         return true; 
      
      //Note: BB10 phone is in the previous paragraph
      if ((DetectBlackBerryWebKit() == true) &&
		(DetectBlackBerryTouch() == true))
         return true;
      
      else
         return false; 
   }
   
   //**************************
   // The quick way to detect for a tier of devices.
   //   This method detects for devices which are likely to be capable 
   //   of viewing CSS content optimized for the iPhone, 
   //   but may not necessarily support JavaScript.
   //   Excludes all iPhone Tier devices.
   bool DetectTierRichCss()
   {
      if (initCompleted == true ||
          isTierRichCss == true)
         return isTierRichCss;

      if (DetectMobileQuick() == true) 
      {
        //Exclude iPhone Tier and e-Ink Kindle devices
        if ((DetectTierIphone() == true) ||
            (DetectKindle() == true))
           return false;
           
        //The following devices are explicitly ok.
        if (DetectWebkit() == true) //Any WebKit
           return true;
        if (DetectS60OssBrowser() == true)
           return true;
           
        //Note: 'High' BlackBerry devices ONLY
        if (DetectBlackBerryHigh() == true)
           return true;
        
        //Older Windows 'Mobile' isn't good enough for iPhone Tier. 
        if (DetectWindowsMobile() == true)
           return true;
        if (useragent.find( MobileESP::engineTelecaQ) != std::string::npos)
           return true;
         
        //default
        else
           return false;
      }
      else
         return false; 
   }

   //**************************
   // The quick way to detect for a tier of devices.
   //   This method detects for all other types of phones,
   //   but excludes the iPhone and RichCSS Tier devices.
   bool DetectTierOtherPhones()
   {
      if (initCompleted == true ||
          isTierGenericMobile == true)
         return isTierGenericMobile;

      //Exclude devices in the other 2 categories 
      if ((DetectMobileLong() == true)
		&& (DetectTierIphone() == false)
		&& (DetectTierRichCss() == false))
           return true;
      else
         return false; 
   }
};

}

/* Example code *
#include <iostream>
#include "mdetect.h"

int main(int argc, char** argv)
{
	int ret = 0;
	if(argc < 3) {
		std::cout << "Usage is mdetect [user agent string] [Accept string]" << std::endl;
	} else {
		MobileESP::uagent_info usageInfo(argv[1],argv[2]);
		if(true == usageInfo.DetectMobileQuick()) {
			std::cout << "Passed in user agent is from a mobile browser" << std::endl;
		} else {
			std::cout << "Passed in user agent is *NOT* from a mobile browser" << std::endl;
		}
	}
	return ret;
}

*/
#endif //MDETECT_H


================================================
FILE: Java/UAgentInfo.java
================================================
/* *******************************************
// Copyright 2010-2015, Anthony Hand
//
//
// File version 2015.05.13 (May 13, 2015)
// Updates:
//	- Moved MobileESP to GitHub. https://github.com/ahand/mobileesp
//	- Opera Mobile/Mini browser has the same UA string on multiple platforms and doesn't differentiate phone vs. tablet. 
//		- Removed DetectOperaAndroidPhone(). This method is no longer reliable. 
//		- Removed DetectOperaAndroidTablet(). This method is no longer reliable. 
//	- Added support for Windows Phone 10: variable and DetectWindowsPhone10()
//	- Updated DetectWindowsPhone() to include WP10. 
//	- Added support for Firefox OS.  
//		- A variable plus DetectFirefoxOS(), DetectFirefoxOSPhone(), DetectFirefoxOSTablet()
//		- NOTE: Firefox doesn't add UA tokens to definitively identify Firefox OS vs. their browsers on other mobile platforms.
//	- Added support for Sailfish OS. Not enough info to add a tablet detection method at this time. 
//		- A variable plus DetectSailfish(), DetectSailfishPhone()
//	- Added support for Ubuntu Mobile OS. 
//		- DetectUbuntu(), DetectUbuntuPhone(), DetectUbuntuTablet()
//	- Added support for 2 smart TV OSes. They lack browsers but do have WebViews for use by HTML apps. 
//		- One variable for Samsung Tizen TVs, plus DetectTizenTV()
//		- One variable for LG WebOS TVs, plus DetectWebOSTV()
//	- Updated DetectTizen(). Now tests for "mobile" to disambiguate from Samsung Smart TVs
//	- Removed variables for obsolete devices: deviceHtcFlyer, deviceXoom.
//	- Updated DetectAndroid(). No longer has a special test case for the HTC Flyer tablet. 
//	- Updated DetectAndroidPhone(). 
//		- Updated internal detection code for Android. 
//		- No longer has a special test case for the HTC Flyer tablet. 
//		- Checks against DetectOperaMobile() on Android and reports here if relevant. 
//	- Updated DetectAndroidTablet(). 
//		- No longer has a special test case for the HTC Flyer tablet. 
//		- Checks against DetectOperaMobile() on Android to exclude it from here.
//	- DetectMeego(): Changed definition for this method. Now detects any Meego OS device, not just phones. 
//	- DetectMeegoPhone(): NEW. For Meego phones. Ought to detect Opera browsers on Meego, as well.  
//	- DetectTierIphone(): Added support for phones running Sailfish, Ubuntu and Firefox Mobile. 
//	- DetectTierTablet(): Added support for tablets running Ubuntu and Firefox Mobile. 
//	- DetectSmartphone(): Added support for Meego phones. 
//	- Refactored the detection logic in DetectMobileQuick() and DetectMobileLong().
//		- Moved a few detection tests for older browsers to Long. 
//
//
//
// LICENSE INFORMATION
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//        http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific
// language governing permissions and limitations under the License. 
//
//
// ABOUT THIS PROJECT
//   Project Owner: Anthony Hand
//   Email: anthony.hand@gmail.com
//   Web Site: http://www.mobileesp.com
//   Source Files: https://github.com/ahand/mobileesp
//
//   Versions of this code are available for:
//      PHP, JavaScript, Java, ASP.NET (C#), and Ruby
//
// *******************************************
 */
package com.handinteractive.mobile;

/**
 * The DetectSmartPhone class encapsulates information about
 *   a browser's connection to your web site.
 *   You can use it to find out whether the browser asking for
 *   your site's content is probably running on a mobile device.
 *   The methods were written so you can be as granular as you want.
 *   For example, enquiring whether it's as specific as an iPod Touch or
 *   as general as a smartphone class device.
 *   The object's methods return true, or false.
 */
public class UAgentInfo {
    // User-Agent and Accept HTTP request headers

    private String userAgent = "";
    private String httpAccept = "";
    
    // Let's store values for quickly accessing the same info multiple times.
    public boolean initCompleted = false;
    public boolean isWebkit = false; //Stores the result of DetectWebkit()
    public boolean isMobilePhone = false; //Stores the result of DetectMobileQuick()
    public boolean isIphone = false; //Stores the result of DetectIphone()
    public boolean isAndroid = false; //Stores the result of DetectAndroid()
    public boolean isAndroidPhone = false; //Stores the result of DetectAndroidPhone()
    public boolean isTierTablet = false; //Stores the result of DetectTierTablet()
    public boolean isTierIphone = false; //Stores the result of DetectTierIphone()
    public boolean isTierRichCss = false; //Stores the result of DetectTierRichCss()
    public boolean isTierGenericMobile = false; //Stores the result of DetectTierOtherPhones()
    
    // Initialize some initial smartphone string variables.
    public static final String engineWebKit = "webkit";
    
    public static final String deviceIphone = "iphone";
    public static final String deviceIpod = "ipod";
    public static final String deviceIpad = "ipad";
    public static final String deviceMacPpc = "macintosh"; //Used for disambiguation
    
    public static final String deviceAndroid = "android";
    public static final String deviceGoogleTV = "googletv";
    
    public static final String deviceWinPhone7 = "windows phone os 7";
    public static final String deviceWinPhone8 = "windows phone 8";
    public static final String deviceWinPhone10 = "windows phone 10";
    public static final String deviceWinMob = "windows ce";
    public static final String deviceWindows = "windows";
    public static final String deviceIeMob = "iemobile";
    public static final String devicePpc = "ppc"; //Stands for PocketPC
    public static final String enginePie = "wm5 pie"; //An old Windows Mobile
    
    public static final String deviceBB = "blackberry";
    public static final String deviceBB10 = "bb10"; //For the new BB 10 OS
    public static final String vndRIM = "vnd.rim"; //Detectable when BB devices emulate IE or Firefox
    public static final String deviceBBStorm = "blackberry95";  //Storm 1 and 2
    public static final String deviceBBBold = "blackberry97";  //Bold 97x0 (non-touch)
    public static final String deviceBBBoldTouch = "blackberry 99";  //Bold 99x0 (touchscreen)
    public static final String deviceBBTour = "blackberry96";  //Tour
    public static final String deviceBBCurve = "blackberry89";  //Curve 2
    public static final String deviceBBCurveTouch = "blackberry 938";  //Curve Touch 9380
    public static final String deviceBBTorch = "blackberry 98";  //Torch
    public static final String deviceBBPlaybook = "playbook"; //PlayBook tablet
    
    public static final String deviceSymbian = "symbian";
    public static final String deviceS60 = "series60";
    public static final String deviceS70 = "series70";
    public static final String deviceS80 = "series80";
    public static final String deviceS90 = "series90";
    
    public static final String devicePalm = "palm";
    public static final String deviceWebOS = "webos"; //For Palm devices
    public static final String deviceWebOStv = "web0s"; //For LG TVs
    public static final String deviceWebOShp = "hpwos"; //For HP's line of WebOS devices
    
    public static final String deviceNuvifone = "nuvifone";  //Garmin Nuvifone
    public static final String deviceBada = "bada";  //Samsung's Bada OS
    public static final String deviceTizen = "tizen";  //Tizen OS
    public static final String deviceMeego = "meego";  //Meego OS
    public static final String deviceSailfish = "sailfish"; //Sailfish OS
    public static final String deviceUbuntu = "ubuntu"; //Ubuntu Mobile OS

    public static final String deviceKindle = "kindle";  //Amazon Kindle, eInk one
    public static final String engineSilk = "silk-accelerated";  //Amazon's accelerated Silk browser for Kindle Fire
    
    public static final String engineBlazer = "blazer"; //Old Palm
    public static final String engineXiino = "xiino"; //Another old Palm
    
    //Initialize variables for mobile-specific content.
    public static final String vndwap = "vnd.wap";
    public static final String wml = "wml";
    
    //Initialize variables for other random devices and mobile browsers.
    public static final String deviceTablet = "tablet"; //Generic term for slate and tablet devices
    public static final String deviceBrew = "brew";
    public static final String deviceDanger = "danger";
    public static final String deviceHiptop = "hiptop";
    public static final String devicePlaystation = "playstation";
    public static final String devicePlaystationVita = "vita";
    public static final String deviceNintendoDs = "nitro";
    public static final String deviceNintendo = "nintendo";
    public static final String deviceWii = "wii";
    public static final String deviceXbox = "xbox";
    public static final String deviceArchos = "archos";
    
    public static final String engineFirefox = "firefox"; //For Firefox OS
    public static final String engineOpera = "opera"; //Popular browser
    public static final String engineNetfront = "netfront"; //Common embedded OS browser
    public static final String engineUpBrowser = "up.browser"; //common on some phones
    public static final String engineOpenWeb = "openweb"; //Transcoding by OpenWave server
    public static final String deviceMidp = "midp"; //a mobile Java technology
    public static final String uplink = "up.link";
    public static final String engineTelecaQ = "teleca q"; //a modern feature phone browser
    public static final String devicePda = "pda"; //some devices report themselves as PDAs
    public static final String mini = "mini";  //Some mobile browsers put "mini" in their names.
    public static final String mobile = "mobile"; //Some mobile browsers put "mobile" in their user agent strings.
    public static final String mobi = "mobi"; //Some mobile browsers put "mobi" in their user agent strings.
    
    //Smart TV strings
    public static final String smartTV1 = "smart-tv"; //Samsung Tizen smart TVs
    public static final String smartTV2 = "smarttv"; //LG WebOS smart TVs

    //Use Maemo, Tablet, and Linux to test for Nokia"s Internet Tablets.
    public static final String maemo = "maemo";
    public static final String linux = "linux";
    public static final String qtembedded = "qt embedded"; //for Sony Mylo
    public static final String mylocom2 = "com2"; //for Sony Mylo also
    
    //In some UserAgents, the only clue is the manufacturer.
    public static final String manuSonyEricsson = "sonyericsson";
    public static final String manuericsson = "ericsson";
    public static final String manuSamsung1 = "sec-sgh";
    public static final String manuSony = "sony";
    public static final String manuHtc = "htc"; //Popular Android and WinMo manufacturer
    
    //In some UserAgents, the only clue is the operator.
    public static final String svcDocomo = "docomo";
    public static final String svcKddi = "kddi";
    public static final String svcVodafone = "vodafone";

    //Disambiguation strings.
    public static final String disUpdate = "update"; //pda vs. update


    /**
     * Initialize the userAgent and httpAccept variables
     *
     * @param userAgent the User-Agent header
     * @param httpAccept the Accept header
     */
    public UAgentInfo(String userAgent, String httpAccept) {
        if (userAgent != null) {
            this.userAgent = userAgent.toLowerCase();
        }
        if (httpAccept != null) {
            this.httpAccept = httpAccept.toLowerCase();
        }

        //Intialize key stored values.
        initDeviceScan();
    }

    /**
     * Return the lower case HTTP_USER_AGENT
     * @return userAgent
     */
    public String getUserAgent() {
        return userAgent;
    }

    /**
     * Return the lower case HTTP_ACCEPT
     * @return httpAccept
     */
    public String getHttpAccept() {
        return httpAccept;
    }

    /**
     * Return whether the device is an Iphone or iPod Touch
     * @return isIphone
     */
    public boolean getIsIphone() {
        return isIphone;
    }

    /**
     * Return whether the device is in the Tablet Tier.
     * @return isTierTablet
     */
    public boolean getIsTierTablet() {
        return isTierTablet;
    }

    /**
     * Return whether the device is in the Iphone Tier.
     * @return isTierIphone
     */
    public boolean getIsTierIphone() {
        return isTierIphone;
    }

    /**
     * Return whether the device is in the 'Rich CSS' tier of mobile devices.
     * @return isTierRichCss
     */
    public boolean getIsTierRichCss() {
        return isTierRichCss;
    }

    /**
     * Return whether the device is a generic, less-capable mobile device.
     * @return isTierGenericMobile
     */
    public boolean getIsTierGenericMobile() {
        return isTierGenericMobile;
    }

    /**
     * Initialize Key Stored Values.
     */
    public void initDeviceScan() {
        //Save these properties to speed processing
        this.isWebkit = detectWebkit();
        this.isIphone = detectIphone();
        this.isAndroid = detectAndroid();
        this.isAndroidPhone = detectAndroidPhone();
        
        //Generally, these tiers are the most useful for web development
        this.isMobilePhone = detectMobileQuick();
        this.isTierTablet = detectTierTablet();
        this.isTierIphone = detectTierIphone();
        
        //Optional: Comment these out if you NEVER use them
        this.isTierRichCss = detectTierRichCss();
        this.isTierGenericMobile = detectTierOtherPhones();
        
        this.initCompleted = true;
    }

    /**
     * Detects if the current device is an iPhone.
     * @return detection of an iPhone
     */
    public boolean detectIphone() {
        // The iPad and iPod touch say they're an iPhone! So let's disambiguate.
        if (userAgent.indexOf(deviceIphone) != -1 && 
                !detectIpad() && 
                !detectIpod()) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current device is an iPod Touch.
     * @return detection of an iPod Touch
     */
    public boolean detectIpod() {
        if (userAgent.indexOf(deviceIpod) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current device is an iPad tablet.
     * @return detection of an iPad
     */
    public boolean detectIpad() {
        if (userAgent.indexOf(deviceIpad) != -1
                && detectWebkit()) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current device is an iPhone or iPod Touch.
     * @return detection of an iPhone or iPod Touch
     */
    public boolean detectIphoneOrIpod() {
        //We repeat the searches here because some iPods may report themselves as an iPhone, which would be okay.
        if (userAgent.indexOf(deviceIphone) != -1
                || userAgent.indexOf(deviceIpod) != -1) {
            return true;
        }
        return false;
    }
    
    /**
     * Detects *any* iOS device: iPhone, iPod Touch, iPad.
     * @return detection of an Apple iOS device
     */
    public boolean detectIos() {
        if (detectIphoneOrIpod() || detectIpad()) {
            return true;
        }
        return false;
    }


    /**
     * Detects *any* Android OS-based device: phone, tablet, and multi-media player.
     * Also detects Google TV.
     * @return detection of an Android device
     */
    public boolean detectAndroid() {
        if ((userAgent.indexOf(deviceAndroid) != -1) ||
          detectGoogleTV()) 
            return true;
        
        return false;
    }

    /**
     * Detects if the current device is a (small-ish) Android OS-based device
     * used for calling and/or multi-media (like a Samsung Galaxy Player).
     * Google says these devices will have 'Android' AND 'mobile' in user agent.
     * Ignores tablets (Honeycomb and later).
     * @return  detection of an Android phone
     */
    public boolean detectAndroidPhone() {
        //First, let's make sure we're on an Android device.
        if (!detectAndroid())
			return false;

        //If it's Android and has 'mobile' in it, Google says it's a phone.
        if (userAgent.indexOf(mobile) != -1)
            return true;
            
        //Special check for Android devices with Opera Mobile/Mini. They should report here.
        if (detectOperaMobile()) 
            return true;
        
        return false;
    }

    /**
     * Detects if the current device is a (self-reported) Android tablet.
     * Google says these devices will have 'Android' and NOT 'mobile' in their user agent.
     * @return detection of an Android tablet
     */
    public boolean detectAndroidTablet() {
        //First, let's make sure we're on an Android device.
        if (!detectAndroid())
			return false;

        //Special check for Android devices with Opera Mobile/Mini. They should NOT report here.
        if (detectOperaMobile()) 
            return false;
    
        //Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet.
        if ((userAgent.indexOf(mobile) > -1)) 
            return false;
        else 
			return true;
    }

    /**
     * Detects if the current device is an Android OS-based device and
     * the browser is based on WebKit.
     * @return detection of an Android WebKit browser
     */
    public boolean detectAndroidWebKit() {
        if (detectAndroid() && detectWebkit()) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current device is a GoogleTV.
     * @return detection of GoogleTV
     */
    public boolean detectGoogleTV() {
        if (userAgent.indexOf(deviceGoogleTV) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current browser is based on WebKit.
     * @return detection of a WebKit browser
     */
    public boolean detectWebkit() {
        if (userAgent.indexOf(engineWebKit) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current browser is the Symbian S60 Open Source Browser.
     * @return detection of Symbian S60 Browser
     */
    public boolean detectS60OssBrowser() {
        //First, test for WebKit, then make sure it's either Symbian or S60.
        if (detectWebkit()
                && (userAgent.indexOf(deviceSymbian) != -1
                || userAgent.indexOf(deviceS60) != -1)) {
            return true;
        }
        return false;
    }

    /**
     *
     * Detects if the current device is any Symbian OS-based device,
     *   including older S60, Series 70, Series 80, Series 90, and UIQ,
     *   or other browsers running on these devices.
     * @return detection of SymbianOS
     */
    public boolean detectSymbianOS() {
        if (userAgent.indexOf(deviceSymbian) != -1
                || userAgent.indexOf(deviceS60) != -1
                || userAgent.indexOf(deviceS70) != -1
                || userAgent.indexOf(deviceS80) != -1
                || userAgent.indexOf(deviceS90) != -1) {
            return true;
        }
        return false;
    }
    
    /**
     * Detects if the current browser is a Windows Phone 7.x, 8, or 10 device
     * @return detection of Windows Phone 7.x OR 8
     */
    public boolean detectWindowsPhone() {
        if (detectWindowsPhone7() 
        	|| detectWindowsPhone8()
        	|| detectWindowsPhone10()) {
            return true;
        }
        return false;
    }

    /**
     * Detects a Windows Phone 7 device (in mobile browsing mode).
     * @return detection of Windows Phone 7
     */
    public boolean detectWindowsPhone7() {
        if (userAgent.indexOf(deviceWinPhone7) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects a Windows Phone 8 device (in mobile browsing mode).
     * @return detection of Windows Phone 8
     */
    public boolean detectWindowsPhone8() {
        if (userAgent.indexOf(deviceWinPhone8) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects a Windows Phone 10 device (in mobile browsing mode).
     * @return detection of Windows Phone 10
     */
    public boolean detectWindowsPhone10() {
        if (userAgent.indexOf(deviceWinPhone10) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current browser is a Windows Mobile device.
     * Excludes Windows Phone 7.x and 8 devices.
     * Focuses on Windows Mobile 6.xx and earlier.
     * @return detection of Windows Mobile
     */
    public boolean detectWindowsMobile() {
        if (detectWindowsPhone()) {
            return false;
        }
        //Most devices use 'Windows CE', but some report 'iemobile'
        //  and some older ones report as 'PIE' for Pocket IE.
        //  We also look for instances of HTC and Windows for many of their WinMo devices.
        if (userAgent.indexOf(deviceWinMob) != -1
                || userAgent.indexOf(deviceWinMob) != -1
                || userAgent.indexOf(deviceIeMob) != -1
                || userAgent.indexOf(enginePie) != -1
                || (userAgent.indexOf(manuHtc) != -1 && userAgent.indexOf(deviceWindows) != -1) 
                || (detectWapWml() && userAgent.indexOf(deviceWindows) != -1)) {
            return true;
        }
        
        //Test for Windows Mobile PPC but not old Macintosh PowerPC.
        if (userAgent.indexOf(devicePpc) != -1 &&
				!(userAgent.indexOf(deviceMacPpc) != -1))
            return true;
            
        return false;
    }

    /**
     * Detects if the current browser is any BlackBerry.
     * Includes BB10 OS, but excludes the PlayBook.
     * @return detection of Blackberry
     */
    public boolean detectBlackBerry() {
        if (userAgent.indexOf(deviceBB) != -1 || 
			httpAccept.indexOf(vndRIM) != -1) 
            return true;
        
        if (detectBlackBerry10Phone())
            return true;
        
        return false;
    }

    /**
     * Detects if the current browser is a BlackBerry 10 OS phone.
     * Excludes tablets.
     * @return detection of a Blackberry 10 device
     */
    public boolean detectBlackBerry10Phone() {
        if (userAgent.indexOf(deviceBB10) != -1 && 
			userAgent.indexOf(mobile) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current browser is on a BlackBerry tablet device.
     *    Example: PlayBook
     * @return detection of a Blackberry Tablet
     */
    public boolean detectBlackBerryTablet() {
        if (userAgent.indexOf(deviceBBPlaybook) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current browser is a BlackBerry device AND uses a
     *    WebKit-based browser. These are signatures for the new BlackBerry OS 6.
     *    Examples: Torch. Includes the Playbook.
     * @return detection of a Blackberry device with WebKit browser
     */
    public boolean detectBlackBerryWebKit() {
        if (detectBlackBerry() &&
			userAgent.indexOf(engineWebKit) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current browser is a BlackBerry Touch
     * device, such as the Storm, Torch, and Bold Touch. Excludes the Playbook.
     * @return detection of a Blackberry touchscreen device
     */
    public boolean detectBlackBerryTouch() {
        if (detectBlackBerry() &&
			(userAgent.indexOf(deviceBBStorm) != -1 ||
			userAgent.indexOf(deviceBBTorch) != -1 ||
			userAgent.indexOf(deviceBBBoldTouch) != -1 ||
                        userAgent.indexOf(deviceBBCurveTouch) != -1 )) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current browser is a BlackBerry device AND
     *   has a more capable recent browser. Excludes the Playbook.
     *   Examples, Storm, Bold, Tour, Curve2
     *   Excludes the new BlackBerry OS 6 and 7 browser!!
     * @return detection of a Blackberry device with a better browser
     */
    public boolean detectBlackBerryHigh() {
        //Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser
        if (detectBlackBerryWebKit()) 
			return false;
        if (detectBlackBerry()) {
            if (detectBlackBerryTouch()
                    || userAgent.indexOf(deviceBBBold) != -1
                    || userAgent.indexOf(deviceBBTour) != -1
                    || userAgent.indexOf(deviceBBCurve) != -1) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }

    /**
     * Detects if the current browser is a BlackBerry device AND
     *   has an older, less capable browser.
     *   Examples: Pearl, 8800, Curve1
     * @return detection of a Blackberry device with a poorer browser
     */
    public boolean detectBlackBerryLow() {
        if (detectBlackBerry()) {
            //Assume that if it's not in the High tier, then it's Low
            if (detectBlackBerryHigh()
					|| detectBlackBerryWebKit()) {
                return false;
            } else {
                return true;
            }
        } else {
            return false;
        }
    }

    /**
     * Detects if the current browser is on a PalmOS device.
     * @return detection of a PalmOS device
     */
    public boolean detectPalmOS() {
        //Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino.
        if (userAgent.indexOf(devicePalm) != -1
                || userAgent.indexOf(engineBlazer) != -1
                || userAgent.indexOf(engineXiino) != -1) {
            //Make sure it's not WebOS first
            if (detectPalmWebOS()) {
                return false;
            } else {
                return true;
            }
        }
        return false;
    }

    /**
     * Detects if the current browser is on a Palm device
     *    running the new WebOS.
     * @return detection of a Palm WebOS device
     */
    public boolean detectPalmWebOS() {
        if (userAgent.indexOf(deviceWebOS) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current browser is on an HP tablet running WebOS.
     * @return detection of an HP WebOS tablet
     */
    public boolean detectWebOSTablet() {
        if (userAgent.indexOf(deviceWebOShp) != -1 && 
                userAgent.indexOf(deviceTablet) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current browser is on a WebOS smart TV.
     * @return detection of a WebOS smart TV
     */
    public boolean detectWebOSTV() {
        if (userAgent.indexOf(deviceWebOStv) != -1 && 
                userAgent.indexOf(smartTV2) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects Opera Mobile or Opera Mini.
     * @return detection of an Opera browser for a mobile device
     */
    public boolean detectOperaMobile() {
        if (userAgent.indexOf(engineOpera) != -1
                && (userAgent.indexOf(mini) != -1
                || userAgent.indexOf(mobi) != -1)) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current device is an Amazon Kindle (eInk devices only).
     * Note: For the Kindle Fire, use the normal Android methods.
     * @return detection of a Kindle
     */
    public boolean detectKindle() {
        if (userAgent.indexOf(deviceKindle)!= -1 &&
            !detectAndroid()) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current Amazon device is using the Silk Browser.
     * Note: Typically used by the the Kindle Fire.
     * @return detection of an Amazon Kindle Fire in Silk mode.
     */
    public boolean detectAmazonSilk() {
        if (userAgent.indexOf(engineSilk)  != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current browser is a
     *    Garmin Nuvifone.
     * @return detection of a Garmin Nuvifone
     */
    public boolean detectGarminNuvifone() {
        if (userAgent.indexOf(deviceNuvifone) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects a device running the Bada OS from Samsung.
     * @return detection of a Bada device
     */
    public boolean detectBada() {
        if (userAgent.indexOf(deviceBada) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects a device running the Tizen smartphone OS.
     * @return detection of a Tizen device
     */
    public boolean detectTizen() {
        if (userAgent.indexOf(deviceTizen) != -1 && 
                userAgent.indexOf(mobile) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current browser is on a Tizen smart TV.
     * @return detection of a Tizen smart TV
     */
    public boolean detectTizenTV() {
        if (userAgent.indexOf(deviceTizen) != -1 && 
                userAgent.indexOf(smartTV1) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects a device running the Meego OS.
     * @return detection of a Meego device
     */
    public boolean detectMeego() {
        if (userAgent.indexOf(deviceMeego) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects a phone running the Meego OS.
     * @return detection of a Meego phone
     */
    public boolean detectMeegoPhone() {
        if (userAgent.indexOf(deviceMeego) != -1 && 
                userAgent.indexOf(mobi) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects a mobile device (probably) running the Firefox OS.
     * @return detection of a Firefox OS mobile device
     */
    public boolean detectFirefoxOS() {
        if (detectFirefoxOSPhone() || detectFirefoxOSTablet()) 
            return true;
        
        return false;
    }

    /**
     * Detects a phone (probably) running the Firefox OS.
     * @return detection of a Firefox OS phone
     */
    public boolean detectFirefoxOSPhone() {
        //First, let's make sure we're NOT on another major mobile OS.
        if (detectIos() 
        	|| detectAndroid()
        	|| detectSailfish())
            return false;
        
        if ((userAgent.indexOf(engineFirefox) != -1) 
        	&& (userAgent.indexOf(mobile) != -1)) 
            return true;
        
        return false;
    }

    /**
     * Detects a tablet (probably) running the Firefox OS.
     * @return detection of a Firefox OS tablet
     */
    public boolean detectFirefoxOSTablet() {
        //First, let's make sure we're NOT on another major mobile OS.
        if (detectIos() 
        	|| detectAndroid()
        	|| detectSailfish())
            return false;
        
        if ((userAgent.indexOf(engineFirefox) != -1) 
        	&& (userAgent.indexOf(deviceTablet) != -1)) 
            return true;
        
        return false;
    }

    /**
     * Detects a device running the Sailfish OS.
     * @return detection of a Sailfish device
     */
    public boolean detectSailfish() {
        if (userAgent.indexOf(deviceSailfish) != -1) {
            return true;
        }
        return false;
    }
    
    /**
     * Detects a phone running the Sailfish OS.
     * @return detection of a Sailfish phone
     */
    public boolean detectSailfishPhone() {
        if (detectSailfish() && (userAgent.indexOf(mobile) != -1)) 
            return true;
        
        return false;
    }

    /**
     * Detects a mobile device running the Ubuntu Mobile OS.
     * @return detection of an Ubuntu Mobile OS mobile device
     */
    public boolean detectUbuntu() {
        if (detectUbuntuPhone() || detectUbuntuTablet()) 
            return true;
        
        return false;
    }

    /**
     * Detects a phone running the Ubuntu Mobile OS.
     * @return detection of an Ubuntu Mobile OS phone
     */
    public boolean detectUbuntuPhone() {
        if ((userAgent.indexOf(deviceUbuntu) != -1) 
        	&& (userAgent.indexOf(mobile) != -1)) 
            return true;
        
        return false;
    }

    /**
     * Detects a tablet running the Ubuntu Mobile OS.
     * @return detection of an Ubuntu Mobile OS tablet
     */
    public boolean detectUbuntuTablet() {
        if ((userAgent.indexOf(deviceUbuntu) != -1) 
        	&& (userAgent.indexOf(deviceTablet) != -1)) 
            return true;
        
        return false;
    }


    /**
     * Detects the Danger Hiptop device.
     * @return detection of a Danger Hiptop
     */
    public boolean detectDangerHiptop() {
        if (userAgent.indexOf(deviceDanger) != -1
                || userAgent.indexOf(deviceHiptop) != -1) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current browser is a Sony Mylo device.
     * @return detection of a Sony Mylo device
     */
    public boolean detectSonyMylo() {
        if (userAgent.indexOf(manuSony) != -1
                && (userAgent.indexOf(qtembedded) != -1
                || userAgent.indexOf(mylocom2) != -1)) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current device is on one of the Maemo-based Nokia Internet Tablets.
     * @return detection of a Maemo OS tablet
     */
    public boolean detectMaemoTablet() {
        if (userAgent.indexOf(maemo) != -1) {
            return true;
        } else if (userAgent.indexOf(linux) != -1
                && userAgent.indexOf(deviceTablet) != -1
                && !detectWebOSTablet()
                && !detectAndroid()) {
            return true;
        }
        return false;
    }

    /**
     * Detects if the current device is an Archos media player/Internet tablet.
     * @return detection of an Archos media player
     */
    public boolean detectArchos() {
        if (userAgent.
Download .txt
gitextract_t1__mu8f/

├── ASP_NET/
│   ├── Sub-Classed Page Technique/
│   │   ├── MDetectPage.cs
│   │   ├── MDetect_Test.aspx
│   │   └── MDetect_Test.aspx.cs
│   └── UserControl Technique/
│       ├── MDetectControl.cs
│       ├── MobileDetectControl.ascx
│       ├── MobileDetectControl.ascx.cs
│       ├── MobileDetectControl.ascx.designer.cs
│       ├── MobileDetectTestPage.aspx
│       ├── MobileDetectTestPage.aspx.cs
│       └── MobileDetectTestPage.aspx.designer.cs
├── Cpp/
│   └── mdetect.h
├── Java/
│   └── UAgentInfo.java
├── JavaScript/
│   └── mdetect.js
├── LICENSE
├── MobileESP_UA-Test-Strings/
│   ├── MobileESP UA Test Strings - UA Strings.csv
│   └── MobileESP UA Test Strings.xlsx
├── PHP/
│   └── mdetect.php
├── Python/
│   └── mdetect.py
├── README.md
└── composer.json
Download .txt
SYMBOL INDEX (376 symbols across 11 files)

FILE: ASP_NET/Sub-Classed Page Technique/MDetectPage.cs
  class MDetectPage (line 88) | public class MDetectPage : System.Web.UI.Page
    method MDetectPage (line 248) | public MDetectPage()
    method FireEvents (line 257) | public void FireEvents()
    class MDetectArgs (line 513) | public class MDetectArgs : EventArgs
      method MDetectArgs (line 515) | public MDetectArgs(string type)
    method DetectIpod (line 527) | public bool DetectIpod()
    method DetectIpad (line 542) | public bool DetectIpad()
    method DetectIphone (line 557) | public bool DetectIphone()
    method DetectIphoneOrIpod (line 578) | public bool DetectIphoneOrIpod()
    method DetectIos (line 593) | public bool DetectIos()
    method DetectAndroid (line 609) | public bool DetectAndroid()
    method DetectAndroidPhone (line 626) | public bool DetectAndroidPhone()
    method DetectAndroidTablet (line 650) | public bool DetectAndroidTablet()
    method DetectGoogleTV (line 673) | public bool DetectGoogleTV()
    method DetectAndroidWebKit (line 687) | public bool DetectAndroidWebKit()
    method DetectWebkit (line 697) | public bool DetectWebkit()
    method DetectS60OssBrowser (line 711) | public bool DetectS60OssBrowser()
    method DetectSymbianOS (line 736) | public bool DetectSymbianOS()
    method DetectWindowsPhone (line 755) | public bool DetectWindowsPhone()
    method DetectWindowsPhone7 (line 772) | public bool DetectWindowsPhone7()
    method DetectWindowsPhone8 (line 783) | public bool DetectWindowsPhone8()
    method DetectWindowsPhone10 (line 794) | public bool DetectWindowsPhone10()
    method DetectWindowsMobile (line 806) | public bool DetectWindowsMobile()
    method DetectBlackBerry (line 839) | public bool DetectBlackBerry()
    method DetectBlackBerry10Phone (line 855) | public bool DetectBlackBerry10Phone()
    method DetectBlackBerryTablet (line 867) | public bool DetectBlackBerryTablet()
    method DetectBlackBerryWebKit (line 879) | public bool DetectBlackBerryWebKit()
    method DetectBlackBerryTouch (line 894) | public bool DetectBlackBerryTouch()
    method DetectBlackBerryHigh (line 911) | public bool DetectBlackBerryHigh()
    method DetectBlackBerryLow (line 934) | public bool DetectBlackBerryLow()
    method DetectPalmOS (line 950) | public bool DetectPalmOS()
    method DetectPalmWebOS (line 974) | public bool DetectPalmWebOS()
    method DetectWebOSTablet (line 989) | public bool DetectWebOSTablet()
    method DetectWebOSTV (line 1006) | public bool DetectWebOSTV()
    method DetectOperaMobile (line 1019) | public bool DetectOperaMobile()
    method DetectGarminNuvifone (line 1042) | public bool DetectGarminNuvifone()
    method DetectBada (line 1052) | public bool DetectBada()
    method DetectTizen (line 1064) | public bool DetectTizen()
    method DetectTizenTV (line 1077) | public bool DetectTizenTV()
    method DetectMeego (line 1090) | public bool DetectMeego()
    method DetectMeegoPhone (line 1102) | public bool DetectMeegoPhone()
    method DetectFirefoxOS (line 1115) | public bool DetectFirefoxOS()
    method DetectFirefoxOSPhone (line 1125) | public bool DetectFirefoxOSPhone()
    method DetectFirefoxOSTablet (line 1142) | public bool DetectFirefoxOSTablet()
    method DetectSailfish (line 1159) | public bool DetectSailfish()
    method DetectSailfishPhone (line 1169) | public bool DetectSailfishPhone()
    method DetectUbuntu (line 1180) | public bool DetectUbuntu()
    method DetectUbuntuPhone (line 1190) | public bool DetectUbuntuPhone()
    method DetectUbuntuTablet (line 1201) | public bool DetectUbuntuTablet()
    method DetectBrewDevice (line 1213) | public bool DetectBrewDevice()
    method DetectDangerHiptop (line 1227) | public bool DetectDangerHiptop()
    method DetectWapWml (line 1241) | public bool DetectWapWml()
    method DetectKindle (line 1257) | public bool DetectKindle()
    method DetectAmazonSilk (line 1274) | public bool DetectAmazonSilk()
    method DetectSonyPlaystation (line 1284) | public bool DetectSonyPlaystation()
    method DetectGamingHandheld (line 1295) | public bool DetectGamingHandheld()
    method DetectNintendo (line 1306) | public bool DetectNintendo()
    method DetectXbox (line 1318) | public bool DetectXbox()
    method DetectGameConsole (line 1328) | public bool DetectGameConsole()
    method DetectMidpCapable (line 1342) | public bool DetectMidpCapable()
    method DetectMaemoTablet (line 1353) | public bool DetectMaemoTablet()
    method DetectArchos (line 1369) | public bool DetectArchos()
    method DetectSonyMylo (line 1379) | public bool DetectSonyMylo()
    method DetectSmartphone (line 1397) | public bool DetectSmartphone()
    method DetectMobileQuick (line 1419) | public bool DetectMobileQuick()
    method DetectMobileLong (line 1465) | public bool DetectMobileLong()
    method DetectTierTablet (line 1508) | public bool DetectTierTablet()
    method DetectTierIphone (line 1531) | public bool DetectTierIphone()
    method DetectTierRichCss (line 1560) | public bool DetectTierRichCss()
    method DetectTierOtherPhones (line 1598) | public bool DetectTierOtherPhones()
    method OnInit (line 1622) | protected override void OnInit(EventArgs e)

FILE: ASP_NET/Sub-Classed Page Technique/MDetect_Test.aspx.cs
  class MDetect_Test (line 8) | public partial class MDetect_Test : MDetectPage
    method Page_Load (line 10) | protected void Page_Load(object sender, EventArgs e)
    method OnInit (line 15) | protected override void OnInit(EventArgs e)
    method MDetect_Test_OnDetectWebkit (line 23) | void MDetect_Test_OnDetectWebkit(object page, MDetectPage.MDetectArgs ...

FILE: ASP_NET/UserControl Technique/MDetectControl.cs
  class MDetectControl (line 88) | public class MDetectControl : System.Web.UI.UserControl
    method MDetectControl (line 249) | public MDetectControl()
    method FireEvents (line 258) | public void FireEvents()
    class MDetectArgs (line 514) | public class MDetectArgs : EventArgs
      method MDetectArgs (line 516) | public MDetectArgs(string type)
    method DetectIphone (line 533) | public bool DetectIphone()
    method DetectIpod (line 555) | public bool DetectIpod()
    method DetectIpad (line 570) | public bool DetectIpad()
    method DetectIphoneOrIpod (line 585) | public bool DetectIphoneOrIpod()
    method DetectIos (line 600) | public bool DetectIos()
    method DetectAndroid (line 616) | public bool DetectAndroid()
    method DetectAndroidPhone (line 633) | public bool DetectAndroidPhone()
    method DetectAndroidTablet (line 657) | public bool DetectAndroidTablet()
    method DetectGoogleTV (line 680) | public bool DetectGoogleTV()
    method DetectAndroidWebKit (line 695) | public bool DetectAndroidWebKit()
    method DetectWebkit (line 705) | public bool DetectWebkit()
    method DetectS60OssBrowser (line 719) | public bool DetectS60OssBrowser()
    method DetectSymbianOS (line 744) | public bool DetectSymbianOS()
    method DetectWindowsPhone (line 764) | public bool DetectWindowsPhone()
    method DetectWindowsPhone7 (line 781) | public bool DetectWindowsPhone7()
    method DetectWindowsPhone8 (line 792) | public bool DetectWindowsPhone8()
    method DetectWindowsPhone10 (line 803) | public bool DetectWindowsPhone10()
    method DetectWindowsMobile (line 815) | public bool DetectWindowsMobile()
    method DetectBlackBerry (line 848) | public bool DetectBlackBerry()
    method DetectBlackBerry10Phone (line 864) | public bool DetectBlackBerry10Phone()
    method DetectBlackBerryTablet (line 876) | public bool DetectBlackBerryTablet()
    method DetectBlackBerryWebKit (line 889) | public bool DetectBlackBerryWebKit()
    method DetectBlackBerryTouch (line 904) | public bool DetectBlackBerryTouch()
    method DetectBlackBerryHigh (line 920) | public bool DetectBlackBerryHigh()
    method DetectBlackBerryLow (line 943) | public bool DetectBlackBerryLow()
    method DetectPalmOS (line 960) | public bool DetectPalmOS()
    method DetectPalmWebOS (line 984) | public bool DetectPalmWebOS()
    method DetectWebOSTablet (line 999) | public bool DetectWebOSTablet()
    method DetectWebOSTV (line 1016) | public bool DetectWebOSTV()
    method DetectOperaMobile (line 1029) | public bool DetectOperaMobile()
    method DetectGarminNuvifone (line 1053) | public bool DetectGarminNuvifone()
    method DetectBada (line 1063) | public bool DetectBada()
    method DetectTizen (line 1075) | public bool DetectTizen()
    method DetectTizenTV (line 1088) | public bool DetectTizenTV()
    method DetectMeego (line 1101) | public bool DetectMeego()
    method DetectMeegoPhone (line 1113) | public bool DetectMeegoPhone()
    method DetectFirefoxOS (line 1126) | public bool DetectFirefoxOS()
    method DetectFirefoxOSPhone (line 1136) | public bool DetectFirefoxOSPhone()
    method DetectFirefoxOSTablet (line 1153) | public bool DetectFirefoxOSTablet()
    method DetectSailfish (line 1170) | public bool DetectSailfish()
    method DetectSailfishPhone (line 1180) | public bool DetectSailfishPhone()
    method DetectUbuntu (line 1191) | public bool DetectUbuntu()
    method DetectUbuntuPhone (line 1201) | public bool DetectUbuntuPhone()
    method DetectUbuntuTablet (line 1212) | public bool DetectUbuntuTablet()
    method DetectBrewDevice (line 1223) | public bool DetectBrewDevice()
    method DetectDangerHiptop (line 1237) | public bool DetectDangerHiptop()
    method DetectWapWml (line 1251) | public bool DetectWapWml()
    method DetectKindle (line 1267) | public bool DetectKindle()
    method DetectAmazonSilk (line 1284) | public bool DetectAmazonSilk()
    method DetectSonyPlaystation (line 1295) | public bool DetectSonyPlaystation()
    method DetectGamingHandheld (line 1306) | public bool DetectGamingHandheld()
    method DetectNintendo (line 1317) | public bool DetectNintendo()
    method DetectXbox (line 1329) | public bool DetectXbox()
    method DetectGameConsole (line 1339) | public bool DetectGameConsole()
    method DetectMidpCapable (line 1353) | public bool DetectMidpCapable()
    method DetectMaemoTablet (line 1364) | public bool DetectMaemoTablet()
    method DetectArchos (line 1380) | public bool DetectArchos()
    method DetectSonyMylo (line 1390) | public bool DetectSonyMylo()
    method DetectSmartphone (line 1410) | public bool DetectSmartphone()
    method DetectMobileQuick (line 1432) | public bool DetectMobileQuick()
    method DetectMobileLong (line 1478) | public bool DetectMobileLong()
    method DetectTierTablet (line 1522) | public bool DetectTierTablet()
    method DetectTierIphone (line 1545) | public bool DetectTierIphone()
    method DetectTierRichCss (line 1574) | public bool DetectTierRichCss()
    method DetectTierOtherPhones (line 1612) | public bool DetectTierOtherPhones()
    method OnInit (line 1636) | protected override void OnInit(EventArgs e)

FILE: ASP_NET/UserControl Technique/MobileDetectControl.ascx.cs
  class MobileDetectControl (line 10) | public partial class MobileDetectControl : MDetectControl
    method Page_Load (line 12) | protected void Page_Load(object sender, EventArgs e)
    method OnInit (line 18) | protected override void OnInit(EventArgs e)
    method MobileDetectControl_OnDetectWebkit (line 27) | void MobileDetectControl_OnDetectWebkit(object page, MDetectControl.MD...

FILE: ASP_NET/UserControl Technique/MobileDetectControl.ascx.designer.cs
  class MobileDetectControl (line 15) | public partial class MobileDetectControl

FILE: ASP_NET/UserControl Technique/MobileDetectTestPage.aspx.cs
  class MobileDetectTestPage (line 10) | public partial class MobileDetectTestPage : System.Web.UI.Page
    method Page_Load (line 12) | protected void Page_Load(object sender, EventArgs e)

FILE: ASP_NET/UserControl Technique/MobileDetectTestPage.aspx.designer.cs
  class MobileDetectTestPage (line 14) | public partial class MobileDetectTestPage {

FILE: Cpp/mdetect.h
  function namespace (line 82) | namespace MobileESP

FILE: Java/UAgentInfo.java
  class UAgentInfo (line 78) | public class UAgentInfo {
    method UAgentInfo (line 214) | public UAgentInfo(String userAgent, String httpAccept) {
    method getUserAgent (line 230) | public String getUserAgent() {
    method getHttpAccept (line 238) | public String getHttpAccept() {
    method getIsIphone (line 246) | public boolean getIsIphone() {
    method getIsTierTablet (line 254) | public boolean getIsTierTablet() {
    method getIsTierIphone (line 262) | public boolean getIsTierIphone() {
    method getIsTierRichCss (line 270) | public boolean getIsTierRichCss() {
    method getIsTierGenericMobile (line 278) | public boolean getIsTierGenericMobile() {
    method initDeviceScan (line 285) | public void initDeviceScan() {
    method detectIphone (line 308) | public boolean detectIphone() {
    method detectIpod (line 322) | public boolean detectIpod() {
    method detectIpad (line 333) | public boolean detectIpad() {
    method detectIphoneOrIpod (line 345) | public boolean detectIphoneOrIpod() {
    method detectIos (line 358) | public boolean detectIos() {
    method detectAndroid (line 371) | public boolean detectAndroid() {
    method detectAndroidPhone (line 386) | public boolean detectAndroidPhone() {
    method detectAndroidTablet (line 407) | public boolean detectAndroidTablet() {
    method detectAndroidWebKit (line 428) | public boolean detectAndroidWebKit() {
    method detectGoogleTV (line 439) | public boolean detectGoogleTV() {
    method detectWebkit (line 450) | public boolean detectWebkit() {
    method detectS60OssBrowser (line 461) | public boolean detectS60OssBrowser() {
    method detectSymbianOS (line 478) | public boolean detectSymbianOS() {
    method detectWindowsPhone (line 493) | public boolean detectWindowsPhone() {
    method detectWindowsPhone7 (line 506) | public boolean detectWindowsPhone7() {
    method detectWindowsPhone8 (line 517) | public boolean detectWindowsPhone8() {
    method detectWindowsPhone10 (line 528) | public boolean detectWindowsPhone10() {
    method detectWindowsMobile (line 541) | public boolean detectWindowsMobile() {
    method detectBlackBerry (line 570) | public boolean detectBlackBerry() {
    method detectBlackBerry10Phone (line 586) | public boolean detectBlackBerry10Phone() {
    method detectBlackBerryTablet (line 599) | public boolean detectBlackBerryTablet() {
    method detectBlackBerryWebKit (line 612) | public boolean detectBlackBerryWebKit() {
    method detectBlackBerryTouch (line 625) | public boolean detectBlackBerryTouch() {
    method detectBlackBerryHigh (line 643) | public boolean detectBlackBerryHigh() {
    method detectBlackBerryLow (line 667) | public boolean detectBlackBerryLow() {
    method detectPalmOS (line 685) | public boolean detectPalmOS() {
    method detectPalmWebOS (line 705) | public boolean detectPalmWebOS() {
    method detectWebOSTablet (line 716) | public boolean detectWebOSTablet() {
    method detectWebOSTV (line 728) | public boolean detectWebOSTV() {
    method detectOperaMobile (line 740) | public boolean detectOperaMobile() {
    method detectKindle (line 754) | public boolean detectKindle() {
    method detectAmazonSilk (line 767) | public boolean detectAmazonSilk() {
    method detectGarminNuvifone (line 779) | public boolean detectGarminNuvifone() {
    method detectBada (line 790) | public boolean detectBada() {
    method detectTizen (line 801) | public boolean detectTizen() {
    method detectTizenTV (line 813) | public boolean detectTizenTV() {
    method detectMeego (line 825) | public boolean detectMeego() {
    method detectMeegoPhone (line 836) | public boolean detectMeegoPhone() {
    method detectFirefoxOS (line 848) | public boolean detectFirefoxOS() {
    method detectFirefoxOSPhone (line 859) | public boolean detectFirefoxOSPhone() {
    method detectFirefoxOSTablet (line 877) | public boolean detectFirefoxOSTablet() {
    method detectSailfish (line 895) | public boolean detectSailfish() {
    method detectSailfishPhone (line 906) | public boolean detectSailfishPhone() {
    method detectUbuntu (line 917) | public boolean detectUbuntu() {
    method detectUbuntuPhone (line 928) | public boolean detectUbuntuPhone() {
    method detectUbuntuTablet (line 940) | public boolean detectUbuntuTablet() {
    method detectDangerHiptop (line 953) | public boolean detectDangerHiptop() {
    method detectSonyMylo (line 965) | public boolean detectSonyMylo() {
    method detectMaemoTablet (line 978) | public boolean detectMaemoTablet() {
    method detectArchos (line 994) | public boolean detectArchos() {
    method detectGameConsole (line 1006) | public boolean detectGameConsole() {
    method detectSonyPlaystation (line 1019) | public boolean detectSonyPlaystation() {
    method detectGamingHandheld (line 1031) | public boolean detectGamingHandheld() {
    method detectNintendo (line 1043) | public boolean detectNintendo() {
    method detectXbox (line 1056) | public boolean detectXbox() {
    method detectBrewDevice (line 1067) | public boolean detectBrewDevice() {
    method detectWapWml (line 1078) | public boolean detectWapWml() {
    method detectMidpCapable (line 1090) | public boolean detectMidpCapable() {
    method detectSmartphone (line 1109) | public boolean detectSmartphone() {
    method detectMobileQuick (line 1126) | public boolean detectMobileQuick() {
    method detectMobileLong (line 1174) | public boolean detectMobileLong() {
    method detectTierTablet (line 1220) | public boolean detectTierTablet() {
    method detectTierIphone (line 1239) | public boolean detectTierIphone() {
    method detectTierRichCss (line 1266) | public boolean detectTierRichCss() {
    method detectTierOtherPhones (line 1296) | public boolean detectTierOtherPhones() {

FILE: PHP/mdetect.php
  class uagent_info (line 82) | class uagent_info
    method __construct (line 217) | function __construct()
    method uagent_info (line 225) | function uagent_info()
    method InitDeviceScan (line 236) | function InitDeviceScan()
    method Get_Uagent (line 261) | function Get_Uagent()
    method Get_HttpAccept (line 268) | function Get_HttpAccept()
    method DetectIphone (line 280) | function DetectIphone()
    method DetectIpod (line 302) | function DetectIpod()
    method DetectIpad (line 312) | function DetectIpad()
    method DetectIphoneOrIpod (line 323) | function DetectIphoneOrIpod()
    method DetectIos (line 335) | function DetectIos()
    method DetectAndroid (line 348) | function DetectAndroid()
    method DetectAndroidPhone (line 366) | function DetectAndroidPhone()
    method DetectAndroidTablet (line 390) | function DetectAndroidTablet()
    method DetectAndroidWebKit (line 410) | function DetectAndroidWebKit()
    method DetectGoogleTV (line 421) | function DetectGoogleTV()
    method DetectWebkit (line 431) | function DetectWebkit()
    method DetectWindowsPhone (line 447) | function DetectWindowsPhone()
    method DetectWindowsPhone7 (line 459) | function DetectWindowsPhone7()
    method DetectWindowsPhone8 (line 469) | function DetectWindowsPhone8()
    method DetectWindowsPhone10 (line 479) | function DetectWindowsPhone10()
    method DetectWindowsMobile (line 491) | function DetectWindowsMobile()
    method DetectBlackBerry (line 520) | function DetectBlackBerry()
    method DetectBlackBerry10Phone (line 534) | function DetectBlackBerry10Phone()
    method DetectBlackBerryTablet (line 546) | function DetectBlackBerryTablet()
    method DetectBlackBerryWebKit (line 558) | function DetectBlackBerryWebKit()
    method DetectBlackBerryTouch (line 570) | function DetectBlackBerryTouch()
    method DetectBlackBerryHigh (line 586) | function DetectBlackBerryHigh()
    method DetectBlackBerryLow (line 611) | function DetectBlackBerryLow()
    method DetectS60OssBrowser (line 629) | function DetectS60OssBrowser()
    method DetectSymbianOS (line 650) | function DetectSymbianOS()
    method DetectPalmOS (line 665) | function DetectPalmOS()
    method DetectPalmWebOS (line 686) | function DetectPalmWebOS()
    method DetectWebOSTablet (line 696) | function DetectWebOSTablet()
    method DetectWebOSTV (line 707) | function DetectWebOSTV()
    method DetectOperaMobile (line 719) | function DetectOperaMobile()
    method DetectKindle (line 732) | function DetectKindle()
    method DetectAmazonSilk (line 744) | function DetectAmazonSilk()
    method DetectGarminNuvifone (line 754) | function DetectGarminNuvifone()
    method DetectBada (line 764) | function DetectBada()
    method DetectTizen (line 774) | function DetectTizen()
    method DetectTizenTV (line 785) | function DetectTizenTV()
    method DetectMeego (line 796) | function DetectMeego()
    method DetectMeegoPhone (line 806) | function DetectMeegoPhone()
    method DetectFirefoxOS (line 817) | function DetectFirefoxOS()
    method DetectFirefoxOSPhone (line 828) | function DetectFirefoxOSPhone()
    method DetectFirefoxOSTablet (line 845) | function DetectFirefoxOSTablet()
    method DetectSailfish (line 862) | function DetectSailfish()
    method DetectSailfishPhone (line 872) | function DetectSailfishPhone()
    method DetectUbuntu (line 883) | function DetectUbuntu()
    method DetectUbuntuPhone (line 894) | function DetectUbuntuPhone()
    method DetectUbuntuTablet (line 905) | function DetectUbuntuTablet()
    method DetectDangerHiptop (line 916) | function DetectDangerHiptop()
    method DetectSonyMylo (line 927) | function DetectSonyMylo()
    method DetectMaemoTablet (line 939) | function DetectMaemoTablet()
    method DetectArchos (line 955) | function DetectArchos()
    method DetectGameConsole (line 966) | function DetectGameConsole()
    method DetectSonyPlaystation (line 980) | function DetectSonyPlaystation()
    method DetectGamingHandheld (line 991) | function DetectGamingHandheld()
    method DetectNintendo (line 1002) | function DetectNintendo()
    method DetectXbox (line 1014) | function DetectXbox()
    method DetectBrewDevice (line 1024) | function DetectBrewDevice()
    method DetectWapWml (line 1034) | function DetectWapWml()
    method DetectMidpCapable (line 1045) | function DetectMidpCapable()
    method DetectSmartphone (line 1063) | function DetectSmartphone()
    method DetectMobileQuick (line 1082) | function DetectMobileQuick()
    method DetectMobileLong (line 1127) | function DetectMobileLong()
    method DetectTierTablet (line 1168) | function DetectTierTablet()
    method DetectTierIphone (line 1191) | function DetectTierIphone()
    method DetectTierRichCss (line 1225) | function DetectTierRichCss()
    method DetectTierOtherPhones (line 1266) | function DetectTierOtherPhones()

FILE: Python/mdetect.py
  class UAgentInfo (line 90) | class UAgentInfo(object):
    method __init__ (line 212) | def __init__(self, userAgent, httpAccept):
    method getUserAgent (line 235) | def getUserAgent(self):
    method getHttpAccept (line 239) | def getHttpAccept(self):
    method getIsIphone (line 243) | def getIsIphone(self):
    method getIsTierTablet (line 247) | def getIsTierTablet(self):
    method getIsTierIphone (line 251) | def getIsTierIphone(self):
    method getIsTierRichCss (line 255) | def getIsTierRichCss(self):
    method getIsTierGenericMobile (line 259) | def getIsTierGenericMobile(self):
    method initDeviceScan (line 264) | def initDeviceScan(self):
    method detectIphone (line 273) | def detectIphone(self):
    method detectIpod (line 283) | def detectIpod(self):
    method detectIpad (line 291) | def detectIpad(self):
    method detectIphoneOrIpod (line 299) | def detectIphoneOrIpod(self):
    method detectIos (line 308) | def detectIos(self):
    method detectAndroid (line 316) | def detectAndroid(self):
    method detectAndroidPhone (line 329) | def detectAndroidPhone(self):
    method detectAndroidTablet (line 352) | def detectAndroidTablet(self):
    method detectAndroidWebKit (line 370) | def detectAndroidWebKit(self):
    method detectGoogleTV (line 379) | def detectGoogleTV(self):
    method detectWebkit (line 387) | def detectWebkit(self):
    method detectS60OssBrowser (line 394) | def detectS60OssBrowser(self):
    method detectSymbianOS (line 404) | def detectSymbianOS(self):
    method detectWindowsPhone (line 417) | def detectWindowsPhone(self):
    method detectWindowsPhone7 (line 427) | def detectWindowsPhone7(self):
    method detectWindowsPhone8 (line 435) | def detectWindowsPhone8(self):
    method detectWindowsPhone10 (line 443) | def detectWindowsPhone10(self):
    method detectWindowsMobile (line 451) | def detectWindowsMobile(self):
    method detectBlackBerry (line 480) | def detectBlackBerry(self):
    method detectBlackBerry10Phone (line 489) | def detectBlackBerry10Phone(self):
    method detectBlackBerryTablet (line 498) | def detectBlackBerryTablet(self):
    method detectBlackBerryWebKit (line 506) | def detectBlackBerryWebKit(self):
    method detectBlackBerryTouch (line 518) | def detectBlackBerryTouch(self):
    method detectBlackBerryHigh (line 529) | def detectBlackBerryHigh(self):
    method detectBlackBerryLow (line 548) | def detectBlackBerryLow(self):
    method detectPalmOS (line 562) | def detectPalmOS(self):
    method detectPalmWebOS (line 575) | def detectPalmWebOS(self):
    method detectWebOSTablet (line 583) | def detectWebOSTablet(self):
    method detectWebOSTV (line 591) | def detectWebOSTV(self):
    method detectGarminNuvifone (line 599) | def detectGarminNuvifone(self):
    method detectBada (line 607) | def detectBada(self):
    method detectTizen (line 614) | def detectTizen(self):
    method detectTizenTV (line 622) | def detectTizenTV(self):
    method detectMeego (line 630) | def detectMeego(self):
    method detectMeegoPhone (line 637) | def detectMeegoPhone(self):
    method detectFirefoxOS (line 645) | def detectFirefoxOS(self):
    method detectFirefoxOSPhone (line 653) | def detectFirefoxOSPhone(self):
    method detectFirefoxOSTablet (line 669) | def detectFirefoxOSTablet(self):
    method detectSailfish (line 685) | def detectSailfish(self):
    method detectSailfishPhone (line 692) | def detectSailfishPhone(self):
    method detectUbuntu (line 703) | def detectUbuntu(self):
    method detectUbuntuPhone (line 711) | def detectUbuntuPhone(self):
    method detectUbuntuTablet (line 722) | def detectUbuntuTablet(self):
    method detectBrewDevice (line 734) | def detectBrewDevice(self):
    method detectDangerHiptop (line 741) | def detectDangerHiptop(self):
    method detectOperaMobile (line 749) | def detectOperaMobile(self):
    method detectWapWml (line 759) | def detectWapWml(self):
    method detectKindle (line 767) | def detectKindle(self):
    method detectAmazonSilk (line 776) | def detectAmazonSilk(self):
    method detectSonyPlaystation (line 784) | def detectSonyPlaystation(self):
    method detectGamingHandheld (line 791) | def detectGamingHandheld(self):
    method detectNintendo (line 800) | def detectNintendo(self):
    method detectXbox (line 809) | def detectXbox(self):
    method detectGameConsole (line 816) | def detectGameConsole(self):
    method detectMidpCapable (line 825) | def detectMidpCapable(self):
    method detectMaemoTablet (line 833) | def detectMaemoTablet(self):
    method detectArchos (line 846) | def detectArchos(self):
    method detectSonyMylo (line 853) | def detectSonyMylo(self):
    method detectSmartphone (line 865) | def detectSmartphone(self):
    method detectMobileQuick (line 879) | def detectMobileQuick(self):
    method detectMobileLong (line 917) | def detectMobileLong(self):
    method detectTierTablet (line 956) | def detectTierTablet(self):
    method detectTierIphone (line 971) | def detectTierIphone(self):
    method detectTierRichCss (line 991) | def detectTierRichCss(self):
    method detectTierOtherPhones (line 1017) | def detectTierOtherPhones(self):
Condensed preview — 20 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (415K chars).
[
  {
    "path": "ASP_NET/Sub-Classed Page Technique/MDetectPage.cs",
    "chars": 56266,
    "preview": "/* *******************************************\r\n// Copyright 2010-2015, Anthony Hand\r\n//\r\n//\r\n// File version 2015.05.1"
  },
  {
    "path": "ASP_NET/Sub-Classed Page Technique/MDetect_Test.aspx",
    "chars": 438,
    "preview": "<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeFile=\"MDetect_Test.aspx.cs\" Inherits=\"MDetect_Test\" %>\r\n\r\n<!DOCTYPE h"
  },
  {
    "path": "ASP_NET/Sub-Classed Page Technique/MDetect_Test.aspx.cs",
    "chars": 777,
    "preview": "using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Web;\r\nusing System.Web.UI;\r\nusing Sy"
  },
  {
    "path": "ASP_NET/UserControl Technique/MDetectControl.cs",
    "chars": 56390,
    "preview": "/* *******************************************\r\n// Copyright 2010-2015, Anthony Hand\r\n//\r\n//\r\n// File version 2015.05.1"
  },
  {
    "path": "ASP_NET/UserControl Technique/MobileDetectControl.ascx",
    "chars": 155,
    "preview": "<%@ Control Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"MobileDetectControl.ascx.cs\" Inherits=\"WebApplication1.Mob"
  },
  {
    "path": "ASP_NET/UserControl Technique/MobileDetectControl.ascx.cs",
    "chars": 924,
    "preview": "using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Web;\r\nusing System.Web.UI;\r\nusing Sy"
  },
  {
    "path": "ASP_NET/UserControl Technique/MobileDetectControl.ascx.designer.cs",
    "chars": 515,
    "preview": "//------------------------------------------------------------------------------\r\n// <auto-generated>\r\n//     This code"
  },
  {
    "path": "ASP_NET/UserControl Technique/MobileDetectTestPage.aspx",
    "chars": 635,
    "preview": "<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"MobileDetectTestPage.aspx.cs\" Inherits=\"WebApplication1.Mobil"
  },
  {
    "path": "ASP_NET/UserControl Technique/MobileDetectTestPage.aspx.cs",
    "chars": 362,
    "preview": "using System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Web;\r\nusing System.Web.UI;\r\nusing Sy"
  },
  {
    "path": "ASP_NET/UserControl Technique/MobileDetectTestPage.aspx.designer.cs",
    "chars": 1175,
    "preview": "//------------------------------------------------------------------------------\r\n// <auto-generated>\r\n//     This code"
  },
  {
    "path": "Cpp/mdetect.h",
    "chars": 44871,
    "preview": "/* *******************************************\r\n// Copyright 2010-2015, Anthony Hand\r\n//\r\n//\r\n// File version 2015.05.13"
  },
  {
    "path": "Java/UAgentInfo.java",
    "chars": 45337,
    "preview": "/* *******************************************\r\n// Copyright 2010-2015, Anthony Hand\r\n//\r\n//\r\n// File version 2015.05.13"
  },
  {
    "path": "JavaScript/mdetect.js",
    "chars": 35695,
    "preview": "/* *******************************************\n// Copyright 2010-2015, Anthony Hand\n//\n// BETA NOTICE\n// Previous versi"
  },
  {
    "path": "LICENSE",
    "chars": 11358,
    "preview": "                                 Apache License\n                           Version 2.0, January 2004\n                   "
  },
  {
    "path": "MobileESP_UA-Test-Strings/MobileESP UA Test Strings - UA Strings.csv",
    "chars": 43932,
    "preview": "UA Type,Device OEM,Device Name,Device Platform,Browser,UA String,Matched Sub-Strings,MobileESP Detection Methods,MobileE"
  },
  {
    "path": "PHP/mdetect.php",
    "chars": 46247,
    "preview": "<?php\r\n\r\n/* *******************************************\r\n// Copyright 2010-2015, Anthony Hand\r\n//\r\n//\r\n// File version 2"
  },
  {
    "path": "Python/mdetect.py",
    "chars": 37921,
    "preview": "# *******************************************\n# Copyright 2010-2016, Anthony Hand\n#\n#\n# File version 2016.01.07 (May 13,"
  },
  {
    "path": "README.md",
    "chars": 7224,
    "preview": "# MobileESP\n[![License](https://img.shields.io/hexpm/l/plug.svg?style=flat)](http://blog.mobileesp.com/?page_id=13)\n\n[!["
  },
  {
    "path": "composer.json",
    "chars": 1374,
    "preview": "{\n    \"name\": \"ahand/mobileesp\",\n    \"type\": \"library\",\n    \"version\": \"3.0.0\",\n    \"description\": \"Since 2008, MobileES"
  }
]

// ... and 1 more files (download for full content)

About this extraction

This page contains the full source code of the ahand/mobileesp GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 20 files (382.4 KB), approximately 95.6k tokens, and a symbol index with 376 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!