summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2014-06-29 17:56:19 +0000
committerme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2014-06-29 17:56:19 +0000
commitaf3c479447078c889b1bbb7a5e405c6f61620e82 (patch)
tree172d4c5d152b40d27399e4d6f2f3fe882ead2fd7
parent2ca40dbee2a3d7bb320d03395e51297af5d481fb (diff)
downloadpica-pica-af3c479447078c889b1bbb7a5e405c6f61620e82.tar.gz
pica-pica-af3c479447078c889b1bbb7a5e405c6f61620e82.zip
fixed pause/resume bugs, moved callbacks.file_progress() call for outgoing transfer inside send_file_fragment to make it always be called before finished_callback
git-svn-id: svn://localhost/project_picapica/trunk@314 fb96df88-216d-11de-830c-f3023f12d8ac
-rwxr-xr-xPICA_client.c16
-rw-r--r--pica-client/dialogs/filetransferdialog.cpp4
-rw-r--r--pica-client/filetransfercontroller.cpp6
-rw-r--r--pica-client/skynet.cpp2
4 files changed, 21 insertions, 7 deletions
diff --git a/PICA_client.c b/PICA_client.c
index 25e92f7..6d428e4 100755
--- a/PICA_client.c
+++ b/PICA_client.c
@@ -773,8 +773,11 @@ static unsigned int procmsg_FILEFRAGMENT(unsigned char* buf, unsigned int nb, vo
{
struct PICA_chaninfo *chan = (struct PICA_chaninfo *)p;
-
-if (chan->recvfilestate != PICA_CHANRECVFILESTATE_RECEIVING)
+/*
+ *Allow incoming FILEFRAGMENTs while paused
+ */
+if (chan->recvfilestate != PICA_CHANRECVFILESTATE_RECEIVING
+ && chan->recvfilestate != PICA_CHANRECVFILESTATE_PAUSED)
return 0;
if (nb - 4 != *(uint16_t*)(buf + 2))
@@ -874,7 +877,7 @@ switch(receiver_cmd)
case PICA_PROTO_FILECONTROL_RESUME:
if (chan->sendfilestate == PICA_CHANSENDFILESTATE_PAUSED)
- chan->recvfilestate = PICA_CHANSENDFILESTATE_SENDING;
+ chan->sendfilestate = PICA_CHANSENDFILESTATE_SENDING;
else
return 0;
break;
@@ -1404,9 +1407,10 @@ while(ipt)
}
else if (ipt->sendfilestate == PICA_CHANSENDFILESTATE_SENDING)
{
- if (PICA_OK == PICA_send_file_fragment(ipt))
+ if (PICA_OK != (ret = PICA_send_file_fragment(ipt)))
{
- callbacks.file_progress(ipt->peer_id, ipt->sendfile_pos, 0);
+ callbacks.channel_closed_cb(ipt->peer_id, ret);
+ kill_ptr = ipt;
}
}
ipt = ipt->next;
@@ -1875,6 +1879,8 @@ else
chn->sendfile_pos += fragment_size;
+callbacks.file_progress(chn->peer_id, chn->sendfile_pos, 0);
+
if (chn->sendfile_pos >= chn->sendfile_size)
{
chn->sendfilestate = PICA_CHANSENDFILESTATE_IDLE;
diff --git a/pica-client/dialogs/filetransferdialog.cpp b/pica-client/dialogs/filetransferdialog.cpp
index c87ed89..bd442c8 100644
--- a/pica-client/dialogs/filetransferdialog.cpp
+++ b/pica-client/dialogs/filetransferdialog.cpp
@@ -243,9 +243,9 @@ QString FileTransferDialog::timeLeft(quint64 seconds)
return QString(tr("%1 days")).arg(days, 6, 'f', 1);
if (hours > 0)
- return QString("%1:%2").arg(hours).arg(minutes % 60);
+ return QString("%1h:%2m").arg(hours).arg(minutes % 60);
- return QString("%1:%2").arg(minutes).arg(seconds % 60);
+ return QString("%1:%2").arg(minutes).arg((double)(seconds % 60), 2, 'f', 0, '0');
}
void FileTransferDialog::timeout()
diff --git a/pica-client/filetransfercontroller.cpp b/pica-client/filetransfercontroller.cpp
index a293827..ca1fa44 100644
--- a/pica-client/filetransfercontroller.cpp
+++ b/pica-client/filetransfercontroller.cpp
@@ -23,13 +23,17 @@ FileTransferController::FileTransferController(QObject *parent) :
void FileTransferController::file_finished_incoming(QByteArray peer_id)
{
if (ftdialogs_in.contains(peer_id))
+
ftdialogs_in.remove(peer_id);
}
void FileTransferController::file_finished_outgoing(QByteArray peer_id)
{
if (ftdialogs_out.contains(peer_id))
+ {
ftdialogs_out.remove(peer_id);
+ qDebug() << "outgoing file transfer finished, removing dialog pointer\n";
+ }
}
void FileTransferController::file_progress(QByteArray peer_id, quint64 bytes_sent, quint64 bytes_received)
@@ -69,6 +73,7 @@ void FileTransferController::file_accepted_by_peer(QByteArray peer_id)
connect(skynet, SIGNAL(OutgoingFileResumed(QByteArray)), this, SLOT(file_resumed_outgoing(QByteArray)));
connect(skynet, SIGNAL(OutgoingFileCancelled(QByteArray)), this, SLOT(file_cancelled_outgoing(QByteArray)));
connect(skynet, SIGNAL(OutgoingFileIoError(QByteArray)), this, SLOT(file_ioerror_outgoing(QByteArray)));
+ connect(skynet, SIGNAL(OutgoingFileFinished(QByteArray)), this, SLOT(file_finished_outgoing(QByteArray)));
ftdialogs_out[peer_id]->setTransferStatus(FileTransferDialog::SENDINGFILE);
}
@@ -133,6 +138,7 @@ void FileTransferController::file_accepted_by_me(QByteArray peer_id)
connect(skynet, SIGNAL(IncomingFileResumed(QByteArray)), this, SLOT(file_resumed_incoming(QByteArray)));
connect(skynet, SIGNAL(IncomingFileCancelled(QByteArray)), this, SLOT(file_cancelled_incoming(QByteArray)));
connect(skynet, SIGNAL(IncomingFileIoError(QByteArray)), this, SLOT(file_ioerror_incoming(QByteArray)));
+ connect(skynet,SIGNAL(IncomingFileFinished(QByteArray)), this, SLOT(file_finished_incoming(QByteArray)));
ftdialogs_in[peer_id]->setTransferStatus(FileTransferDialog::RECEIVINGFILE);
}
diff --git a/pica-client/skynet.cpp b/pica-client/skynet.cpp
index 6426538..aba41d7 100644
--- a/pica-client/skynet.cpp
+++ b/pica-client/skynet.cpp
@@ -727,6 +727,8 @@ void SkyNet::file_control(const unsigned char *peer_id, unsigned int sender_cmd,
void SkyNet::file_finished(const unsigned char *peer_id, int sending)
{
+ qDebug()<< "file_finished callback\n";
+
if (sending)
skynet->emit_OutgoingFileFinished(QByteArray((const char *)peer_id, PICA_ID_SIZE));
else