kexi

kexinewstuff.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifdef HAVE_TDENEWSTUFF
21
22#include <kdebug.h>
23#include <ktar.h>
24#include <tqdir.h>
25#include <tdeaction.h>
26#include <tdeapplication.h>
27#include <tdefiledialog.h>
28#include <tdelocale.h>
29
30#include "kexinewstuff.h"
31
32KexiNewStuff::KexiNewStuff(TQWidget *parent)
33 : TDENewStuff( "kexi template"
34 , "https://www.trinitydesktop.org/ocs/providers.xml"
35 , parent)
36{
37 // Prevent GHNS to deny downloading a second time. If GHNS
38 // fails to download something, it still marks the thing as
39 // successfully downloaded and therefore we arn't able to
40 // download it again :-/
41 TDEGlobal::config()->deleteGroup("TDENewStuffStatus");
42}
43
44KexiNewStuff::~KexiNewStuff()
45{
46}
47
48bool
49KexiNewStuff::install(const TQString &fileName)
50{
51 kdDebug() << "KexiNewStuff::install(): " << fileName << endl;
52
53 KTar archive( fileName );
54 if ( !archive.open( IO_ReadOnly ) ) {
55 kdDebug() << TQString("KexiNewStuff::install: Failed to open archivefile \"%1\"").arg(fileName) << endl;
56 return false;
57 }
58 const KArchiveDirectory *archiveDir = archive.directory();
59 const TQString destDir = KFileDialog::getExistingDirectory(
60 ":DownloadExampleDatabases", parentWidget(),
61 i18n("Choose Directory Where to Install Example Database"));
62 if (destDir.isEmpty()) {
63 kdDebug() << TQString("KexiNewStuff::install: Destination-directory is empty.") << endl;
64 return false;
65 }
66 archiveDir->copyTo(destDir);
67 archive.close();
68
69 return true;
70}
71
72bool
73KexiNewStuff::createUploadFile(const TQString &)
74{
75 return true;
76}
77
78#endif