kexi

kexinewstuff.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifdef HAVE_KNEWSTUFF
00021 
00022 #include <kdebug.h>
00023 #include <ktar.h>
00024 #include <qdir.h>
00025 #include <kaction.h>
00026 #include <kapplication.h>
00027 #include <kfiledialog.h>
00028 #include <klocale.h>
00029 #include <kdeversion.h>
00030 
00031 #include "kexinewstuff.h"
00032 
00033 KexiNewStuff::KexiNewStuff(QWidget *parent)
00034  : KNewStuff( "kexi/template"
00035 #if KDE_IS_VERSION(3,3,0)
00036     , "http://download.kde.org/khotnewstuff/kexi-providers.xml"
00037 #endif
00038     , parent)
00039 {
00040     // Prevent GHNS to deny downloading a second time. If GHNS
00041     // fails to download something, it still marks the thing as
00042     // successfully downloaded and therefore we arn't able to
00043     // download it again :-/
00044     KGlobal::config()->deleteGroup("KNewStuffStatus");
00045 }
00046 
00047 KexiNewStuff::~KexiNewStuff()
00048 {
00049 }
00050 
00051 bool
00052 KexiNewStuff::install(const QString &fileName)
00053 {
00054     kdDebug() << "KexiNewStuff::install(): " << fileName << endl;
00055 
00056     KTar archive( fileName );
00057     if ( !archive.open( IO_ReadOnly ) ) {
00058         kdDebug() << QString("KexiNewStuff::install: Failed to open archivefile \"%1\"").arg(fileName) << endl;
00059         return false;
00060     }
00061     const KArchiveDirectory *archiveDir = archive.directory();
00062     const QString destDir = KFileDialog::getExistingDirectory(
00063         ":DownloadExampleDatabases", parentWidget(),
00064         i18n("Choose Directory Where to Install Example Database"));
00065     if (destDir.isEmpty()) {
00066         kdDebug() << QString("KexiNewStuff::install: Destination-directory is empty.") << endl;
00067         return false;
00068     }
00069     archiveDir->copyTo(destDir);
00070     archive.close();
00071 
00072     return true;
00073 }
00074 
00075 bool
00076 KexiNewStuff::createUploadFile(const QString &)
00077 {
00078     return true;
00079 }
00080 
00081 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys