/*****************************************************************************
 * Copyright (C) 2010 S.R.Haque <srhaque@theiet.org>                         *
 * Christoph Thielecke <crissi99@gmx.de> (broken out from kvpnc.h)           *
 *                                                                           *
 * This program is free software; you can redistribute it and/or modify      *
 * it under the terms of the GNU General Public License as published by      *
 * the Free Software Foundation; either version 2 of the License, or         *
 * (at your option) any later version.                                       *
 *                                                                           *
 * This package is distributed in the hope that it will be useful,           *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
 * GNU General Public License for more details.                              *
 *                                                                           *
 * You should have received a copy of the GNU General Public License         *
 * along with this package; if not, write to the Free Software               *
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA *
 *****************************************************************************/

#include <QtCore/QString>
#include <kprocess.h>
#include "HandlerBase.h"

class QProcess;
class KPtyProcess;
class KPtyDevice;

/**
 * Cisco vpnc-based protocol handler (the free one, not the original one). The
 * vpnc software has client support for the Cisco VPN3000 Concentrator, IOS
 * and PIX.
 */
class CiscoVpncHandler:
        public HandlerBase
{
    Q_OBJECT
public:
    CiscoVpncHandler(
        class KVpnc *ui,
        class KVpncConfig *config);
    bool vpnStart(bool authenticationRetry);
    void vpnStop();
    QString pingDevice() const;
    void killProcess();

private:
    QString VpncConnectScript;
    QString VpncScript;
    QString VpncDevice;

    QString vpncConfig;
    QString VpncDisconnectScript;
    KPtyDevice *VpncPty;
    HelperPtyProcess *VpncProcess;
    HelperProgram m_tool;
    void helperParser(QString msg, const QString &source);

    /**
     * TBD: can this be shared by other handlers?
     */
    bool getAuthenticationData(bool AuthRetry);

private slots:
    void helperOutputReader();
    void helperPtyReader();
};
