[SCM] ktp-filetransfer-handler packaging branch, master, updated. debian/15.12.1-2-226-g825cd93
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:11:20 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-filetransfer-handler.git;a=commitdiff;h=487dcc0
The following commit has been merged in the master branch:
commit 487dcc0c717ece4d42d2ecef95eff78b94b7ac3c
Author: Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
Date: Tue Jun 14 19:59:31 2011 +0200
Better error handling
---
src/handle-incoming-file-transfer-channel-job.cpp | 41 ++++++++++++++-------
src/handle-outgoing-file-transfer-channel-job.cpp | 43 ++++++++++++++---------
src/telepathy-base-job.h | 20 ++++++++++-
3 files changed, 74 insertions(+), 30 deletions(-)
diff --git a/src/handle-incoming-file-transfer-channel-job.cpp b/src/handle-incoming-file-transfer-channel-job.cpp
index e33341a..120199e 100644
--- a/src/handle-incoming-file-transfer-channel-job.cpp
+++ b/src/handle-incoming-file-transfer-channel-job.cpp
@@ -64,17 +64,17 @@ HandleIncomingFileTransferChannelJob::HandleIncomingFileTransferChannelJob(Tp::I
if (channel.isNull())
{
- kError() << "Channel cannot be NULL"; // TODO print a serious message
- d->__k__onInvalidated();
- // TODO set error
+ kError() << "Channel cannot be NULL";
+ setError(KTelepathy::NullChannel);
+ setErrorText(i18n("Invalid channel"));
}
Tp::Features features = Tp::Features() << Tp::FileTransferChannel::FeatureCore;
if (!channel->isReady(Tp::Features() << Tp::FileTransferChannel::FeatureCore))
{
- kError() << "Channel must be ready with Tp::FileTransferChannel::FeatureCore"; // TODO print a serious message
- d->__k__onInvalidated();
- // TODO set error
+ kError() << "Channel must be ready with Tp::FileTransferChannel::FeatureCore";
+ setError(KTelepathy::FeatureNotReady);
+ setErrorText(i18n("Channel is not ready"));
}
d->channel = channel;
@@ -108,6 +108,11 @@ void HandleIncomingFileTransferChannelJobPrivate::__k__start()
kDebug();
Q_Q(HandleIncomingFileTransferChannelJob);
+ if (q->error()) {
+ QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
+ return;
+ }
+
q->connect(channel.data(), SIGNAL(invalidated(Tp::DBusProxy *, const QString &, const QString &)),
q, SLOT(__k__onInvalidated()));
q->connect(channel.data(),
@@ -141,7 +146,8 @@ void HandleIncomingFileTransferChannelJobPrivate::__k__start()
{
case KIO::R_CANCEL:
// TODO Cancel file transfer and close channel
- __k__doEmitResult();
+ channel->cancel();
+ QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
return;
case KIO::R_RENAME:
url = renameDialog.newDestUrl();
@@ -150,7 +156,10 @@ void HandleIncomingFileTransferChannelJobPrivate::__k__start()
break;
default:
//TODO Set error
- __k__doEmitResult();
+ kWarning() << "Unknown Error";
+ q->setError(KTelepathy::KTelepathyError);
+ q->setErrorText(i18n("Unknown Error"));
+ QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
}
}
@@ -161,7 +170,6 @@ void HandleIncomingFileTransferChannelJobPrivate::__k__start()
file = new QFile(url.toLocalFile(), q->parent());
kDebug() << "Saving file as" << file->fileName();
-
Tp::PendingOperation* setUrlOperation = channel->setUri(url.url());
q->connect(setUrlOperation, SIGNAL(finished(Tp::PendingOperation*)),
q, SLOT(__k__onSetUrlOperationFinished(Tp::PendingOperation*)));
@@ -175,7 +183,9 @@ void HandleIncomingFileTransferChannelJobPrivate::__k__onSetUrlOperationFinished
if (op->isError()) {
kWarning() << "Unable to set the URI -" <<
op->errorName() << ":" << op->errorMessage();
- __k__onInvalidated();
+ q->setError(KTelepathy::SetUriFailed);
+ q->setErrorText(i18n("Unable to set the URI"));
+ QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
return;
}
@@ -190,6 +200,7 @@ void HandleIncomingFileTransferChannelJobPrivate::__k__onFileTransferChannelStat
kDebug();
Q_Q(HandleIncomingFileTransferChannelJob);
+ //TODO Handle other states
kDebug() << "File transfer channel state changed to" << state << "with reason" << stateReason;
transferCompleted = (state == Tp::FileTransferStateCompleted);
if (transferCompleted) {
@@ -213,13 +224,17 @@ void HandleIncomingFileTransferChannelJobPrivate::__k__onFileTransferChannelTran
void HandleIncomingFileTransferChannelJobPrivate::__k__onAcceptFileFinished(Tp::PendingOperation* op)
{
+ // This method is called when the "acceptFile" operation is finished,
+ // therefore the file was not received yet.
kDebug();
+ Q_Q(HandleIncomingFileTransferChannelJob);
+
if (op->isError()) {
kWarning() << "Unable to accept file -" <<
op->errorName() << ":" << op->errorMessage();
- //TODO set error
- __k__onInvalidated();
- return;
+ q->setError(KTelepathy::AcceptFileError);
+ q->setErrorText(i18n("Unable to accept file"));
+ QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
}
}
diff --git a/src/handle-outgoing-file-transfer-channel-job.cpp b/src/handle-outgoing-file-transfer-channel-job.cpp
index dbddf10..226a6d4 100644
--- a/src/handle-outgoing-file-transfer-channel-job.cpp
+++ b/src/handle-outgoing-file-transfer-channel-job.cpp
@@ -58,17 +58,17 @@ HandleOutgoingFileTransferChannelJob::HandleOutgoingFileTransferChannelJob(Tp::O
if (channel.isNull())
{
- kError() << "Channel cannot be NULL"; // TODO print a serious message
- // TODO set error
- d->__k__onInvalidated();
+ kError() << "Channel cannot be NULL";
+ setError(KTelepathy::NullChannel);
+ setErrorText(i18n("Invalid channel"));
}
Tp::Features features = Tp::Features() << Tp::FileTransferChannel::FeatureCore;
if (!channel->isReady(Tp::Features() << Tp::FileTransferChannel::FeatureCore))
{
- kError() << "Channel must be ready with Tp::FileTransferChannel::FeatureCore"; // TODO print a serious message
- // TODO set error
- d->__k__onInvalidated();
+ kError() << "Channel must be ready with Tp::FileTransferChannel::FeatureCore";
+ setError(KTelepathy::FeatureNotReady);
+ setErrorText(i18n("Channel is not ready"));
}
connect(channel.data(),
@@ -76,7 +76,6 @@ HandleOutgoingFileTransferChannelJob::HandleOutgoingFileTransferChannelJob(Tp::O
SLOT(__k__onInvalidated()));
d->channel = channel;
- kDebug() << "END";
}
HandleOutgoingFileTransferChannelJob::~HandleOutgoingFileTransferChannelJob()
@@ -106,6 +105,11 @@ void HandleOutgoingFileTransferChannelJobPrivate::__k__start()
kDebug();
Q_Q(HandleOutgoingFileTransferChannelJob);
+ if (q->error()) {
+ QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
+ return;
+ }
+
q->connect(channel.data(),
SIGNAL(stateChanged(Tp::FileTransferState, Tp::FileTransferStateChangeReason)),
SLOT(__k__onFileTransferChannelStateChanged(Tp::FileTransferState, Tp::FileTransferStateChangeReason)));
@@ -114,7 +118,7 @@ void HandleOutgoingFileTransferChannelJobPrivate::__k__start()
SLOT(__k__onFileTransferChannelTransferredBytesChanged(qulonglong)));
if (channel->state() == Tp::FileTransferStateAccepted) {
- __k__provideFile();
+ QTimer::singleShot(0, q, SLOT(__k__provideFile()));
}
}
@@ -131,7 +135,8 @@ void HandleOutgoingFileTransferChannelJobPrivate::__k__onFileTransferChannelStat
case Tp::FileTransferStateNone:
// This is bad
kWarning() << "An error occurred.";
- q->setError(KTelepathy::InvalidOperationError);
+ q->setError(KTelepathy::TelepathyErrorError);
+ q->setErrorText(i18n("An error occurred"));
QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
case Tp::FileTransferStateCompleted:
kDebug() << "Transfer completed";
@@ -140,7 +145,7 @@ void HandleOutgoingFileTransferChannelJobPrivate::__k__onFileTransferChannelStat
break;
case Tp::FileTransferStateCancelled:
kWarning() << "Transfer was canceled.";
- q->setError(KTelepathy::InvalidOperationError); //TODO
+ q->setError(KTelepathy::FileTransferCancelled); //TODO
q->setErrorText(i18n("Transfer was canceled."));
QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
break;
@@ -162,14 +167,16 @@ void HandleOutgoingFileTransferChannelJobPrivate::__k__provideFile()
if (uri.isEmpty())
{
qWarning() << "URI property missing";
- // TODO set error
+ q->setError(KTelepathy::UriPropertyMissing);
+ q->setErrorText(i18n("URI property is missing"));
QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
}
if (uri.scheme() != QLatin1String("file"))
{
- qWarning() << "Not a local file";
// TODO handle this!
- // TODO set error
+ qWarning() << "Not a local file";
+ q->setError(KTelepathy::NotALocalFile);
+ q->setErrorText(i18n("This is not a local file"));
QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
}
@@ -194,13 +201,17 @@ void HandleOutgoingFileTransferChannelJobPrivate::__k__onFileTransferChannelTran
void HandleOutgoingFileTransferChannelJobPrivate::__k__onProvideFileFinished(Tp::PendingOperation* op)
{
+ // This method is called when the "provideFile" operation is finished,
+ // therefore the file was not sent yet.
kDebug();
+ Q_Q(HandleOutgoingFileTransferChannelJob);
+
if (op->isError()) {
kWarning() << "Unable to provide file - " <<
op->errorName() << ":" << op->errorMessage();
- //TODO Set error
- __k__onInvalidated();
- return;
+ q->setError(KTelepathy::ProvideFileError);
+ q->setErrorText(i18n("Cannot provide file"));
+ QTimer::singleShot(0, q, SLOT(__k__doEmitResult()));
}
}
diff --git a/src/telepathy-base-job.h b/src/telepathy-base-job.h
index 03cde05..a009f69 100644
--- a/src/telepathy-base-job.h
+++ b/src/telepathy-base-job.h
@@ -59,8 +59,26 @@ namespace KTelepathy {
AccountNotOnlineError = 106,
/** An operation attempted to create a nepomuk resource which already exists */
ResourceAlreadyExistsError = 107,
+ /** A channel is null */
+ NullChannel = 108,
+ /** A required Tp::Feature is not ready */
+ FeatureNotReady = 109,
+ /** Cannot set the URI property */
+ SetUriFailed = 110,
+ /** Cannot accept file */
+ AcceptFileError = 111,
+ /** File transfer cancelled */
+ FileTransferCancelled = 112,
+ /** URI Property is missing */
+ UriPropertyMissing = 113,
+ /** Non a local file */
+ NotALocalFile = 114,
+ /** Cannot provide file */
+ ProvideFileError = 115,
/** Telepathy triggered an error */
- TelepathyErrorError = 200
+ TelepathyErrorError = 200,
+ /** KTelepathy Error */
+ KTelepathyError = 300
};
class TelepathyBaseJobPrivate;
--
ktp-filetransfer-handler packaging
More information about the pkg-kde-commits
mailing list