summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
Unidiff
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 5d48884..ea543dd 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -246,65 +246,66 @@ void KSyncManager::enableQuick()
246 lepw.setText( mPrefs->mPassiveSyncPw ); 246 lepw.setText( mPrefs->mPassiveSyncPw );
247 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 247 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
248 lay.addWidget( &label2); 248 lay.addWidget( &label2);
249 lay.addWidget( &lepw); 249 lay.addWidget( &lepw);
250 dia.setFixedSize( 230,80 ); 250 dia.setFixedSize( 230,80 );
251 dia.setCaption( i18n("Enter port for Pi-Sync") ); 251 dia.setCaption( i18n("Enter port for Pi-Sync") );
252 QPushButton pb ( "OK", &dia); 252 QPushButton pb ( "OK", &dia);
253 lay.addWidget( &pb ); 253 lay.addWidget( &pb );
254 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 254 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
255 dia.show(); 255 dia.show();
256 if ( ! dia.exec() ) 256 if ( ! dia.exec() )
257 return; 257 return;
258 dia.hide(); 258 dia.hide();
259 qApp->processEvents(); 259 qApp->processEvents();
260 mPrefs->mPassiveSyncPw = lepw.text(); 260 mPrefs->mPassiveSyncPw = lepw.text();
261 mPrefs->mPassiveSyncPort = lab.text(); 261 mPrefs->mPassiveSyncPort = lab.text();
262 bool ok; 262 bool ok;
263 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 263 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
264 if ( ! ok ) { 264 if ( ! ok ) {
265 KMessageBox::information( 0, i18n("No valid port")); 265 KMessageBox::information( 0, i18n("No valid port"));
266 return; 266 return;
267 } 267 }
268 //qDebug("port %d ", port); 268 //qDebug("port %d ", port);
269 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 269 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
270 mServerSocket->setFileName( defaultFileName() ); 270 mServerSocket->setFileName( defaultFileName() );
271 //qDebug("connected "); 271 //qDebug("connected ");
272 if ( !mServerSocket->ok() ) { 272 if ( !mServerSocket->ok() ) {
273 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 273 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
274 delete mServerSocket; 274 delete mServerSocket;
275 mServerSocket = 0; 275 mServerSocket = 0;
276 return; 276 return;
277 } 277 }
278 connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) ); 278 //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) );
279 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
279 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 280 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
280} 281}
281 282
282void KSyncManager::syncLocalFile() 283void KSyncManager::syncLocalFile()
283{ 284{
284 285
285 QString fn =mLastSyncedLocalFile; 286 QString fn =mLastSyncedLocalFile;
286 QString ext; 287 QString ext;
287 288
288 switch(mTargetApp) 289 switch(mTargetApp)
289 { 290 {
290 case (KAPI): 291 case (KAPI):
291 ext = "(*.vcf)"; 292 ext = "(*.vcf)";
292 break; 293 break;
293 case (KOPI): 294 case (KOPI):
294 ext = "(*.ics/*.vcs)"; 295 ext = "(*.ics/*.vcs)";
295 break; 296 break;
296 case (PWMPI): 297 case (PWMPI):
297 ext = "(*.pwm)"; 298 ext = "(*.pwm)";
298 break; 299 break;
299 default: 300 default:
300 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 301 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
301 break; 302 break;
302 303
303 } 304 }
304 305
305 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 306 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
306 if ( fn == "" ) 307 if ( fn == "" )
307 return; 308 return;
308 if ( syncWithFile( fn, false ) ) { 309 if ( syncWithFile( fn, false ) ) {
309 qDebug("syncLocalFile() successful "); 310 qDebug("syncLocalFile() successful ");
310 } 311 }
@@ -899,65 +900,65 @@ void KServerSocket::readClient()
899 } 900 }
900 else { 901 else {
901 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); 902 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
902 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 903 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
903 } 904 }
904 } 905 }
905 if ( tokens[0] == "STOP" ) { 906 if ( tokens[0] == "STOP" ) {
906 //emit endConnect(); 907 //emit endConnect();
907 end_connect(); 908 end_connect();
908 } 909 }
909 } 910 }
910} 911}
911void KServerSocket::end_connect() 912void KServerSocket::end_connect()
912{ 913{
913 delete mSyncActionDialog; 914 delete mSyncActionDialog;
914 mSyncActionDialog = 0; 915 mSyncActionDialog = 0;
915} 916}
916void KServerSocket::send_file() 917void KServerSocket::send_file()
917{ 918{
918 //qDebug("MainWindow::sendFile(QSocket* s) "); 919 //qDebug("MainWindow::sendFile(QSocket* s) ");
919 if ( mSyncActionDialog ) 920 if ( mSyncActionDialog )
920 delete mSyncActionDialog; 921 delete mSyncActionDialog;
921 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 922 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
922 mSyncActionDialog->setCaption(i18n("Received sync request")); 923 mSyncActionDialog->setCaption(i18n("Received sync request"));
923 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 924 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
924 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 925 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
925 lay->addWidget( label); 926 lay->addWidget( label);
926 lay->setMargin(7); 927 lay->setMargin(7);
927 lay->setSpacing(7); 928 lay->setSpacing(7);
928 mSyncActionDialog->setFixedSize( 230, 120); 929 mSyncActionDialog->setFixedSize( 230, 120);
929 mSyncActionDialog->show(); 930 mSyncActionDialog->show();
930 qDebug("KSS::saving ... "); 931 qDebug("KSS::saving ... ");
931 emit saveFile(); 932 emit request_file();
932 qApp->processEvents(); 933 qApp->processEvents();
933 QString fileName = mFileName; 934 QString fileName = mFileName;
934 QFile file( fileName ); 935 QFile file( fileName );
935 if (!file.open( IO_ReadOnly ) ) { 936 if (!file.open( IO_ReadOnly ) ) {
936 delete mSyncActionDialog; 937 delete mSyncActionDialog;
937 mSyncActionDialog = 0; 938 mSyncActionDialog = 0;
938 qDebug("KSS::error open file "); 939 qDebug("KSS::error open file ");
939 mSocket->close(); 940 mSocket->close();
940 if ( mSocket->state() == QSocket::Idle ) 941 if ( mSocket->state() == QSocket::Idle )
941 QTimer::singleShot( 10, this , SLOT ( discardClient())); 942 QTimer::singleShot( 10, this , SLOT ( discardClient()));
942 return ; 943 return ;
943 944
944 } 945 }
945 mSyncActionDialog->setCaption( i18n("Sending file...") ); 946 mSyncActionDialog->setCaption( i18n("Sending file...") );
946 QTextStream ts( &file ); 947 QTextStream ts( &file );
947 ts.setCodec( QTextCodec::codecForName("utf8") ); 948 ts.setCodec( QTextCodec::codecForName("utf8") );
948 QTextStream os( mSocket ); 949 QTextStream os( mSocket );
949 os.setCodec( QTextCodec::codecForName("utf8") ); 950 os.setCodec( QTextCodec::codecForName("utf8") );
950 //os.setEncoding( QTextStream::UnicodeUTF8 ); 951 //os.setEncoding( QTextStream::UnicodeUTF8 );
951 while ( ! ts.atEnd() ) { 952 while ( ! ts.atEnd() ) {
952 os << ts.readLine() << "\n"; 953 os << ts.readLine() << "\n";
953 } 954 }
954 //os << ts.read(); 955 //os << ts.read();
955 file.close(); 956 file.close();
956 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 957 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
957 mSocket->close(); 958 mSocket->close();
958 if ( mSocket->state() == QSocket::Idle ) 959 if ( mSocket->state() == QSocket::Idle )
959 QTimer::singleShot( 10, this , SLOT ( discardClient())); 960 QTimer::singleShot( 10, this , SLOT ( discardClient()));
960} 961}
961void KServerSocket::get_file() 962void KServerSocket::get_file()
962{ 963{
963 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 964 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );