/* -*- c++ -*-
 *
 * disclaimer.cpp
 *
 * Copyright (C) 2004 Petter Stokke <ummo@hellokitty.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#include "disclaimer.h"

#include <klocale.h>
#include <kglobal.h>
#include <kconfig.h>
#include <ktextbrowser.h>
#include <qvbox.h>
#include <qcheckbox.h>

QString DisclaimerDialog::disclaimerText()
{
    return i18n( "<h2>WARNING</h2>\n"
                 "<p>Peer-to-peer networks, particularly those accessible via KMLDonkey, "
                 "may contain material which you may be legally prohibited from downloading or "
                 "redistributing. It is your responsibility to verify that any material you "
                 "download from any peer-to-peer network is being made available to you lawfully. "
                 "It is also your responsibility to verify that you have the legal right to "
                 "redistribute any material which you make available to others via any "
                 "peer-to-peer networks. In short, it is your responsibility to use this software "
                 "in accordance with applicable laws where you live, including copyright law.</p>\n"
                 "<h3>RESTRICTIONS</h3>\n"
                 "<p>The authors of this software intend it to be used for the "
                 "lawful exchange of data, art, software and other documents or works which "
                 "may be lawfully distributed to third parties. The authors will not "
                 "support, and strongly discourage, any use of this software to violate "
                 "copyright or other intellectual property laws. In particular, the authors "
                 "discourage any transmission of any material in violation of any applicable "
                 "intellectual property law or regulation. Each user is assumed to comply "
                 "with such rules and restrictions as well as the rules and restrictions "
                 "applicable to the P2P networks or services connected directly or "
                 "indirectly to this software.</p>\n"
                 "<h3>DISCLAIMER OF LIABILITY</h3>\n"
                 "<p>The authors of this software do not and cannot "
                 "exercise any control whatsoever over the content of the information "
                 "exchanged using this software. The authors make no warranties of any "
                 "kind, whether expressed or implied, for the service this software is "
                 "providing or for the data exchanged with the assistance of this software. "
                 "The authors cannot be held responsible for any claims resulting from the "
                 "user's conduct and/or use of the software which is in any manner unlawful "
                 "or which damages such user or any other party.</p>" );
}

DisclaimerDialog::DisclaimerDialog( QWidget* parent )
        : KDialogBase( parent, "DisclaimerDialog", true, i18n( "Disclaimer" ), KDialogBase::Ok )
{
    QVBox * c = new QVBox( this );
    KTextBrowser* b = new KTextBrowser( c );
    b->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
    b->setText( disclaimerText() );
    m_again = new QCheckBox( i18n( "&Do not show this message again" ), c );
    m_again->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
    setMainWidget( c );
    resize( QSize( 500, 400 ).expandedTo( minimumSizeHint() ) );
}

int DisclaimerDialog::exec()
{
    KConfig * conf = KGlobal::config();
    conf->setGroup( "DisclaimerDialog" );
    if ( conf->readBoolEntry( "DoNotShow", false ) )
        return QDialog::Accepted;
    int rv = KDialogBase::exec();
    conf->writeEntry( "DoNotShow", m_again->isChecked() );
    return rv;
}

#include "disclaimer.moc"
