Index: c6.cpp
===================================================================
RCS file: /cvsroot/openc6/OpenC6_branch_1/c6/c6.cpp,v
retrieving revision 1.57
diff -u -r1.57 c6.cpp
--- c6.cpp 20 Apr 2004 09:55:55 -0000 1.57
+++ c6.cpp 23 Apr 2004 14:46:33 -0000
@@ -26,7 +26,7 @@
C6Config.defaultSoundPath = commonPath + DEFAULTSOUNDPATH;
C6Config.commonPath = commonPath;
- if(signal(SIGCHLD,(void*)&sig_chld) == SIG_ERR)
+ if(signal(SIGCHLD,sig_chld) == SIG_ERR)
qDebug("Signal Error");
#ifdef USE_KDE
Index: c6.h
===================================================================
RCS file: /cvsroot/openc6/OpenC6_branch_1/c6/c6.h,v
retrieving revision 1.40
diff -u -r1.40 c6.h
--- c6.h 31 Mar 2004 16:36:23 -0000 1.40
+++ c6.h 23 Apr 2004 14:46:33 -0000
@@ -181,7 +181,7 @@
void flashTrayIcon(bool state);
/** No descriptions */
QString getCurrentTimeStr();
- void sig_chld(int signum);
+ static void sig_chld(int signum);
/** No descriptions */
void trayIconFlashStop();
/** No descriptions */
Index: c6proto.cpp
===================================================================
RCS file: /cvsroot/openc6/OpenC6_branch_1/c6/c6proto.cpp,v
retrieving revision 1.35
diff -u -r1.35 c6proto.cpp
--- c6proto.cpp 13 Apr 2004 14:35:31 -0000 1.35
+++ c6proto.cpp 23 Apr 2004 14:46:33 -0000
@@ -975,6 +975,8 @@
OutCount = 1;
setSocket(socket);
C6Config = config;
+ chunck_no = 1;
+ avg_len = 0;
connect(this,SIGNAL(readyRead()),SLOT(socket_ReadyRead()));
connect(this,SIGNAL(connectionClosed()),SLOT(socket_Closed()));
connect(this,SIGNAL(error(int)),SLOT(socket_Error(int)));
@@ -1267,12 +1269,11 @@
*/
void C6XferProto::getNextChunk(BYTE *data)
{
- int len,chunk_no;
- static int avg_len = 0;
+ int len;
QFile *fs = new QFile(C6Config->fileReceivePath+file);
- WORD_READ(data,chunk_no); data+=4;
+ data+=4;
WORD_READ(data,len); data+=2;
if (avg_len)
@@ -1287,7 +1288,9 @@
fs->close();
if (fsize)
- emit receiveProgress((int)((chunk_no-1)*avg_len*100/fsize));
+ emit receiveProgress((int)(chunck_no*avg_len*100/fsize));
+
+ chunck_no++;
}
delete fs;
@@ -1321,7 +1324,7 @@
*/
void C6XferProto::endOfReceive()
{
- emit receiveProgress(101);
+ emit receiveProgress(255);
}
@@ -1366,7 +1369,6 @@
*/
void C6XferServer::xferAborted()
{
-
emit receiveAborted();
}
Index: c6proto.h
===================================================================
RCS file: /cvsroot/openc6/OpenC6_branch_1/c6/c6proto.h,v
retrieving revision 1.27
diff -u -r1.27 c6proto.h
--- c6proto.h 8 Apr 2004 09:28:03 -0000 1.27
+++ c6proto.h 23 Apr 2004 14:46:33 -0000
@@ -44,6 +44,7 @@
QString file,nick;
int OutCount;
int chunck_no;
+ int avg_len;
long int fsize;
QCString DataIn,inComing;
public:
Index: chat.ui
===================================================================
RCS file: /cvsroot/openc6/OpenC6_branch_1/c6/chat.ui,v
retrieving revision 1.11
diff -u -r1.11 chat.ui
--- chat.ui 17 Apr 2004 12:17:50 -0000 1.11
+++ chat.ui 23 Apr 2004 14:46:35 -0000
@@ -1512,25 +1512,6 @@
Aggiungi utente
-
-
- transmitBar
-
-
- true
-
-
-
- 35
- 358
- 145
- 16
-
-
-
- AncestorOrigin
-
-
textLabel1_2
@@ -1697,22 +1678,6 @@
Interrompe la ricezione di un file
-
-
- receiveBar
-
-
- true
-
-
-
- 274
- 358
- 145
- 16
-
-
-
receiveSwitch
@@ -1897,6 +1862,44 @@
Anywhere
+
+
+ transmitBar
+
+
+ true
+
+
+
+ 35
+ 358
+ 145
+ 16
+
+
+
+ AncestorOrigin
+
+
+
+
+ receiveBar
+
+
+ true
+
+
+
+ 274
+ 358
+ 145
+ 16
+
+
+
+ AncestorOrigin
+
+
Index: chatview.cpp
===================================================================
RCS file: /cvsroot/openc6/OpenC6_branch_1/c6/chatview.cpp,v
retrieving revision 1.35
diff -u -r1.35 chatview.cpp
--- chatview.cpp 17 Apr 2004 12:17:50 -0000 1.35
+++ chatview.cpp 23 Apr 2004 14:46:35 -0000
@@ -253,7 +253,7 @@
if (s != "")
{
transmitBar->setProgress(0);
- localProgress = 0;
+ transmitLocalProgress = 0;
emit sendFile(s,otherNick);
}
}
@@ -293,7 +293,7 @@
connect(xferSocket,SIGNAL(connectionClosed()),this,SLOT(xferSocket_connectionClosed()));
connect(xferSocket,SIGNAL(xferAborted()),this,SLOT(xferAborted()));
connect(xferSocket,SIGNAL(xferProgress(int)),this,SLOT(xferProgress(int)));
- localProgress = 0;
+ transmitLocalProgress = 0;
transmitFileName = filename;
xferSocket->fire();
}
@@ -309,7 +309,7 @@
void ChatView::xferSocket_connectionClosed()
{
QString a = getOtherNick();
- if (localProgress < 100)
+ if (transmitLocalProgress < 100)
{
xferSocket->close();
emit transferError(a,transmitFileName,XFERABORT);
@@ -326,14 +326,14 @@
/** No descriptions */
void ChatView::xferProgress(int progress)
{
- localProgress = progress;
+ transmitLocalProgress = progress;
if (progress == 255)
progress = 100;
transmitBar->setProgress(progress);
- if (localProgress == 255)
+ if (transmitLocalProgress == 255)
UpdateText(END_OF_TRANSFER_MSG(transmitFileName),C6Config->ForeMessageColor);
}
@@ -348,6 +348,7 @@
xferSocket->disconnect();
xferSocket->close();
delete xferSocket;
+ xferSocket = NULL;
}
}
@@ -357,7 +358,7 @@
*/
void ChatView::stopTransmitButton_clicked()
{
- if ((xferSocket != NULL) && (xferSocket->state() == QSocket::Connected))
+ if ((xferSocket != NULL) && (xferSocket->state() == QSocket::Connected) && (transmitLocalProgress != 255))
{
xferSocket->close();
UpdateText(ABORT_TRANSFER_MSG(transmitFileName),C6Config->ForeMessageColor);
@@ -379,10 +380,13 @@
*/
void ChatView::activateFileServer()
{
- xferServer = new C6XferServer(C6Config,serverPort,this);
- connect(xferServer,SIGNAL(receiveProgress(int)),this,SLOT(receiveProgress(int)));
- connect(xferServer,SIGNAL(signalFileSpec(QString&,long int)),this,SLOT(receiveFileSpec(QString&, long int )));
- connect(xferServer,SIGNAL(receiveAborted()),this,SLOT(receiveAborted()));
+ if (!xferServer)
+ {
+ xferServer = new C6XferServer(C6Config,serverPort,this);
+ connect(xferServer,SIGNAL(receiveProgress(int)),this,SLOT(receiveProgress(int)));
+ connect(xferServer,SIGNAL(signalFileSpec(QString&,long int)),this,SLOT(receiveFileSpec(QString&, long int )));
+ connect(xferServer,SIGNAL(receiveAborted()),this,SLOT(receiveAborted()));
+ }
}
@@ -391,16 +395,14 @@
*/
void ChatView::receiveProgress(int progress)
{
- int localProgress;
+ receiveLocalProgress = progress;
- localProgress = progress;
-
- if (progress == 101)
- progress--;
+ if (progress == 255)
+ progress = 100;
receiveBar->setProgress(progress);
- if (localProgress == 101)
+ if (receiveLocalProgress == 255)
UpdateText(END_OF_RECEIVE_MSG(receiveFileName,receiveFileSize),C6Config->ForeMessageColor);
}
@@ -452,5 +454,12 @@
*/
void ChatView::stopReceiveButton_clicked()
{
- xferServer->stopReceive();
+ if (xferServer && receiveLocalProgress != 255 && receiveLocalProgress)
+ {
+ QString a = getOtherNick();
+
+ xferServer->stopReceive();
+ UpdateText(RECEIVE_ABORT_TRANSFER_MSG(receiveFileName,a),C6Config->ForeMessageColor);
+ receiveLocalProgress = 0;
+ }
}
Index: chatview.h
===================================================================
RCS file: /cvsroot/openc6/OpenC6_branch_1/c6/chatview.h,v
retrieving revision 1.21
diff -u -r1.21 chatview.h
--- chatview.h 31 Mar 2004 16:36:23 -0000 1.21
+++ chatview.h 23 Apr 2004 14:46:35 -0000
@@ -98,7 +98,7 @@
QString defaultIconPath,defaultButtonPath;
QString otherNick,myNick,transmitFileName,receiveFileName;
C6XferProto *xferSocket;
- int localProgress,serverPort;
+ int transmitLocalProgress,serverPort,receiveLocalProgress;
long int receiveFileSize;
bool xferOnSwitch;
C6XferServer *xferServer;
Index: macroetc.h
===================================================================
RCS file: /cvsroot/openc6/OpenC6_branch_1/c6/macroetc.h,v
retrieving revision 1.32
diff -u -r1.32 macroetc.h
--- macroetc.h 8 Apr 2004 09:28:03 -0000 1.32
+++ macroetc.h 23 Apr 2004 14:46:35 -0000
@@ -158,6 +158,7 @@
#define SEARCHWAITSTR QString("Ricerca in corso.......")
#define END_OF_TRANSFER_MSG(filename) QString("Invio del file ")+filename+" completato con successo!"
#define ABORT_TRANSFER_MSG(filename) QString("Invio del file ")+filename+" interrotto!"
+#define RECEIVE_ABORT_TRANSFER_MSG(filename,nick) QString("Ricezione del file ")+filename+" da "+nick+" interrotta!"
#define END_OF_RECEIVE_MSG(filename,filesize) QString("Ricezione del file ")+filename+" ("+QString::number(filesize)+" bytes) "+"completato con successo!"
#define NO_USER_FOUND_MSG QString("Nessun utente trovato")
#define ENTER_CHAT_MSG(nick) QString("Il netfriend ")+nick+QString::fromUtf8(" รจ appena entrato in chat")