summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-23 08:26:01 (UTC)
committer zautrix <zautrix>2004-09-23 08:26:01 (UTC)
commita9e235027e0c92fb53462e968dee2b43228d7984 (patch) (side-by-side diff)
tree91565646ef5eeccd0f51a679add40499586abf8e
parente395b9a15f5047582c17665de85d28dad64b8a8e (diff)
downloadkdepimpi-a9e235027e0c92fb53462e968dee2b43228d7984.zip
kdepimpi-a9e235027e0c92fb53462e968dee2b43228d7984.tar.gz
kdepimpi-a9e235027e0c92fb53462e968dee2b43228d7984.tar.bz2
sync fixes
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp46
-rw-r--r--korganizer/mainwindow.h2
2 files changed, 34 insertions, 14 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 460bbdc..f4ac0d6 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -2031,14 +2031,14 @@ void MainWindow::getFile(QSocket* socket)
}
}
#endif
#endif
}
setCaption( i18n("File received - reloading calendar...") );
- file.close();
socket->close();
+ file.close();
mView->watchSavedFile();
mView->openCalendar( defaultFileName() );
setCaption( i18n("Easy-Pi-Sync successful!") );
delete mSyncActionDialog;
mSyncActionDialog = 0;
@@ -2120,13 +2120,13 @@ QString fileName;
#else
fileName = "/tmp/kopitempfile.ics";
#endif
QFile file( fileName );
if (!file.open( IO_WriteOnly ) ) {
setCaption( i18n("Error: Cannot open temp file for write.") );
- qDebug("Error open calender file for writing: %s",fileName.latin1() );
+ qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
return ;
}
//QTextStream os2( mCommandSocket );
//os2.setEncoding( QTextStream::UnicodeUTF8 );
@@ -2147,12 +2147,13 @@ QString fileName;
mCommandSocket->waitForMore ( 100 );
}
//mCommandSocket->waitForMore ( 5000 );
}
file.close();
mCommandSocket->close();
+ // pending: deleting after signal SIGNAL(delayedCloseFinished())
//delete mCommandSocket;
setCaption( i18n("Remote file saved to temp file.") );
//mCommandSocket = 0;
mCurrentSyncProfile = 2 ; // last file
mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
@@ -2178,12 +2179,13 @@ QString fileName;
if ( !mCommandSocketFinish ) {
mCommandSocketFinish = new QSocket( this );
}
mCommandSocketFinish->connectToHost( KOPrefs::instance()->mActiveSyncIP, KOPrefs::instance()->mActiveSyncPort.toUInt() );
+ // pending connect signals connected () and error to new slots
QString host = KOPrefs::instance()->mActiveSyncIP;
QFile file2( fileName );
if (!file2.open( IO_ReadOnly ) ) {
setCaption( i18n("Error: Cannot open temp file for read.") );
qDebug("error open cal file ");
return ;
@@ -2202,12 +2204,13 @@ QString fileName;
}
} else {
os2 << "STOP\r\n";
}
mCommandSocketFinish->close();
file.close();
+ // pending: deleting after signal SIGNAL(delayedCloseFinished())
//delete ( mCommandSocket);
//mCommandSocket = 0;
qDebug("Syncing succesful! ");
setCaption( i18n("Easy-Pi-Sync succesful!") );
@@ -2488,42 +2491,57 @@ void MainWindow::printCal()
{
mView->print();//mCp->showDialog();
}
-KServerSocket:: KServerSocket ( Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ){;};
+KServerSocket:: KServerSocket ( Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
+{
+
+ mSocket = 0;
+};
void KServerSocket::newConnection ( int socket )
{
qDebug("KServerSocket:New connection %d ", socket);
- QSocket* s = new QSocket( this );
- connect( s, SIGNAL(readyRead()), this, SLOT(readClient()) );
- connect( s, SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
- s->setSocket( socket );
+ if ( mSocket ) {
+ qDebug("KServerSocket::newConnection Socket deleted! ");
+ delete mSocket;
+ mSocket = 0;
+ }
+ mSocket = new QSocket( this );
+ connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
+ connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
+ mSocket->setSocket( socket );
}
void KServerSocket::discardClient()
{
qDebug(" KServerSocket::discardClient()");
- QSocket* socket = (QSocket*)sender();
- delete socket;
+ if ( mSocket ) {
+ qDebug("delete ");
+ delete mSocket;
+ mSocket = 0;
+ }
//emit endConnect();
}
void KServerSocket::readClient()
{
+ if ( mSocket == 0 ) {
+ qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
+ return;
+ }
qDebug("KServerSocket readClient()");
- QSocket* socket = (QSocket*)sender();
- if ( socket->canReadLine() ) {
- QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() );
+ if ( mSocket->canReadLine() ) {
+ QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() );
qDebug("KServerSocket socket->canReadLine()");
if ( tokens[0] == "GET" ) {
- emit sendFile( socket );
+ emit sendFile( mSocket );
}
if ( tokens[0] == "PUT" ) {
- emit getFile( socket );
+ emit getFile( mSocket );
}
if ( tokens[0] == "STOP" ) {
emit endConnect();
}
}
}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 7b4fd27..cc656a3 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -35,12 +35,14 @@ signals:
void sendFile(QSocket*);
void getFile(QSocket*);
void endConnect();
private slots:
void discardClient();
void readClient();
+ private :
+ QSocket* mSocket;
};
namespace KCal {
class CalendarLocal;
}