KNewStuff
upload.cpp
Go to the documentation of this file.
00001 /* 00002 Copyright (c) 2007 Josef Spillner <spillner@kde.org> 00003 Copyright (C) 2007-2009 Frederik Gladhorn <gladhorn@kde.org> 00004 Copyright (c) 2009 Jeremy Whiting <jpwhiting@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include "upload.h" 00022 00023 /* 00024 bool Engine::uploadEntry(Provider *provider, const Entry& entry) 00025 { 00026 //kDebug() << "Uploading " << entry.name().representation() << "..."; 00027 00028 //if (d->uploadedentry) { 00029 // kError() << "Another upload is in progress!" << endl; 00030 // return false; 00031 //} 00032 00033 //if (!provider->uploadUrl().isValid()) { 00034 // kError() << "The provider doesn't support uploads." << endl; 00035 // return false; 00036 00037 // // FIXME: support for <noupload> will go here (file bundle creation etc.) 00038 //} 00039 00041 //d->uploadprovider = provider; 00042 //d->uploadedentry = entry; 00043 00044 //KUrl sourcepayload = KUrl(entry.payload().representation()); 00045 //KUrl destfolder = provider->uploadUrl(); 00046 00047 //destfolder.setFileName(sourcepayload.fileName()); 00048 00049 //KIO::FileCopyJob *fcjob = KIO::file_copy(sourcepayload, destfolder, -1, KIO::Overwrite | KIO::HideProgressInfo); 00050 //connect(fcjob, 00051 // SIGNAL(result(KJob*)), 00052 // SLOT(slotUploadPayloadResult(KJob*))); 00053 00054 return true; 00055 } 00056 */ 00057 /* 00058 void Engine::slotUploadPayloadResult(KJob *job) 00059 { 00060 //if (job->error()) { 00061 // kError() << "Cannot upload payload file." << endl; 00062 // kError() << job->errorString() << endl; 00063 00064 // d->uploadedentry = NULL; 00065 // d->uploadprovider = NULL; 00066 00067 // emit signalEntryFailed(); 00068 // return; 00069 //} 00070 00071 //if (d->uploadedentry.preview().representation().isEmpty()) { 00072 // // FIXME: we abuse 'job' here for the shortcut if there's no preview 00073 // slotUploadPreviewResult(job); 00074 // return; 00075 //} 00076 00077 //KUrl sourcepreview = KUrl(d->uploadedentry.preview().representation()); 00078 //KUrl destfolder = d->uploadprovider->uploadUrl(); 00079 00080 //destfolder.setFileName(sourcepreview.fileName()); 00081 00082 //KIO::FileCopyJob *fcjob = KIO::file_copy(sourcepreview, destfolder, -1, KIO::Overwrite | KIO::HideProgressInfo); 00083 //connect(fcjob, 00084 // SIGNAL(result(KJob*)), 00085 // SLOT(slotUploadPreviewResult(KJob*))); 00086 } 00087 00088 void Engine::slotUploadPreviewResult(KJob *job) 00089 { 00090 //if (job->error()) { 00091 // kError() << "Cannot upload preview file." << endl; 00092 // kError() << job->errorString() << endl; 00093 00094 // d->uploadedentry = NULL; 00095 // d->uploadprovider = NULL; 00096 00097 // emit signalEntryFailed(); 00098 // return; 00099 //} 00100 00103 00105 //KUrl sourcemeta = QString(KGlobal::dirs()->saveLocation("tmp") + KRandom::randomString(10) + ".meta"); 00106 //KUrl destfolder = d->uploadprovider->uploadUrl(); 00107 00108 //destfolder.setFileName(sourcemeta.fileName()); 00109 00110 //EntryHandler eh(*d->uploadedentry); 00111 //QDomElement exml = eh.entryXML(); 00112 00113 //QDomDocument doc; 00114 //QDomElement root = doc.createElement("ghnsupload"); 00115 //root.appendChild(exml); 00116 00117 //QFile f(sourcemeta.path()); 00118 //if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) { 00119 // kError() << "Cannot write meta information to '" << sourcemeta << "'." << endl; 00120 00121 // d->uploadedentry = NULL; 00122 // d->uploadprovider = NULL; 00123 00124 // emit signalEntryFailed(); 00125 // return; 00126 //} 00127 //QTextStream metastream(&f); 00128 //metastream << root; 00129 //f.close(); 00130 00131 //KIO::FileCopyJob *fcjob = KIO::file_copy(sourcemeta, destfolder, -1, KIO::Overwrite | KIO::HideProgressInfo); 00132 //connect(fcjob, 00133 // SIGNAL(result(KJob*)), 00134 // SLOT(slotUploadMetaResult(KJob*))); 00135 } 00136 */ 00137 00138 /* 00139 void Engine::slotUploadMetaResult(KJob *job) 00140 { 00141 if (job->error()) { 00142 kError() << "Cannot upload meta file." << endl; 00143 kError() << job->errorString() << endl; 00144 00145 d->uploadedentry = Entry(); 00146 d->uploadprovider = NULL; 00147 00148 emit signalEntryFailed(); 00149 return; 00150 } else { 00151 d->uploadedentry = Entry(); 00152 d->uploadprovider = NULL; 00153 00154 //KIO::FileCopyJob *fcjob = static_cast<KIO::FileCopyJob*>(job); 00155 emit signalEntryUploaded(); 00156 } 00157 } 00158 */ 00159 00160
KDE 4.6 API Reference