summaryrefslogtreecommitdiffstats
path: root/tdeioslave/trash/tdefile-plugin/tdefile_trash.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:02:02 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:02:02 -0600
commitde7e5867a65e0a46f1388e3e50bc7eeddd1aecbf (patch)
treedbb3152c372f8620f9290137d461f3d9f9eba1cb /tdeioslave/trash/tdefile-plugin/tdefile_trash.cpp
parent936d3cec490c13f2c5f7dd14f5e364fddaa6da71 (diff)
downloadtdebase-de7e5867a65e0a46f1388e3e50bc7eeddd1aecbf.tar.gz
tdebase-de7e5867a65e0a46f1388e3e50bc7eeddd1aecbf.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdeioslave/trash/tdefile-plugin/tdefile_trash.cpp')
-rw-r--r--tdeioslave/trash/tdefile-plugin/tdefile_trash.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/tdeioslave/trash/tdefile-plugin/tdefile_trash.cpp b/tdeioslave/trash/tdefile-plugin/tdefile_trash.cpp
new file mode 100644
index 000000000..cf4487d06
--- /dev/null
+++ b/tdeioslave/trash/tdefile-plugin/tdefile_trash.cpp
@@ -0,0 +1,93 @@
+/* This file is part of the KDE project
+ * Copyright (C) 2004 David Faure <faure@kde.org>
+ * Based on tdefile_txt.cpp by Nadeem Hasan <nhasan@kde.org>
+ *
+ * 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 version 2.
+ *
+ * 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; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "tdefile_trash.h"
+
+#include <kgenericfactory.h>
+#include <kdebug.h>
+
+#include <tqfile.h>
+#include <tqstringlist.h>
+#include <tqdatetime.h>
+
+typedef KGenericFactory<KTrashPlugin> TrashFactory;
+
+K_EXPORT_COMPONENT_FACTORY(tdefile_trash, TrashFactory("tdefile_trash"))
+
+KTrashPlugin::KTrashPlugin(TQObject *parent, const char *name,
+ const TQStringList &args) : KFilePlugin(parent, name, args)
+{
+ TDEGlobal::locale()->insertCatalogue( "kio_trash" );
+
+ kdDebug(7034) << "Trash file meta info plugin\n";
+
+ makeMimeTypeInfo("trash");
+ makeMimeTypeInfo("system");
+
+ (void)impl.init();
+}
+
+void KTrashPlugin::makeMimeTypeInfo(const TQString& mimeType)
+{
+ KFileMimeTypeInfo* info = addMimeTypeInfo( mimeType );
+
+ KFileMimeTypeInfo::GroupInfo* group =
+ addGroupInfo(info, "General", i18n("General"));
+
+ KFileMimeTypeInfo::ItemInfo* item;
+ item = addItemInfo(group, "OriginalPath", i18n("Original Path"), TQVariant::String);
+ item = addItemInfo(group, "DateOfDeletion", i18n("Date of Deletion"), TQVariant::DateTime);
+}
+
+bool KTrashPlugin::readInfo(KFileMetaInfo& info, uint)
+{
+ KURL url = info.url();
+
+ if ( url.protocol()=="system"
+ && url.path().startsWith("/trash") )
+ {
+ TQString path = url.path();
+ path.remove(0, 6);
+ url.setProtocol("trash");
+ url.setPath(path);
+ }
+
+ //kdDebug() << k_funcinfo << info.url() << endl;
+ if ( url.protocol() != "trash" )
+ return false;
+
+ int trashId;
+ TQString fileId;
+ TQString relativePath;
+ if ( !TrashImpl::parseURL( url, trashId, fileId, relativePath ) )
+ return false;
+
+ TrashImpl::TrashedFileInfo trashInfo;
+ if ( !impl.infoForFile( trashId, fileId, trashInfo ) )
+ return false;
+
+ KFileMetaInfoGroup group = appendGroup(info, "General");
+ appendItem(group, "OriginalPath", trashInfo.origPath);
+ appendItem(group, "DateOfDeletion", trashInfo.deletionDate);
+
+ return true;
+}
+
+#include "tdefile_trash.moc"