summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp105
-rw-r--r--korganizer/mainwindow.h38
2 files changed, 101 insertions, 42 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 2e6b5c8..460bbdc 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,38 +1,40 @@
#include <stdlib.h>
#include <qaction.h>
#include <qpopupmenu.h>
#include <qpainter.h>
#include <qwhatsthis.h>
+#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qlineedit.h>
#include <qtextcodec.h>
#include <qfile.h>
#include <qdir.h>
#include <qapp.h>
#include <qfileinfo.h>
#include <qlabel.h>
#include <qmap.h>
#include <qwmatrix.h>
#include <qtextbrowser.h>
#include <qtextstream.h>
#ifndef DESKTOP_VERSION
#include <qpe/global.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qtopia/alarmserver.h>
#include <qtopia/qcopenvelope_qws.h>
+#include <unistd.h> // for sleep
#else
#include <qmenubar.h>
#include <qtoolbar.h>
#include <qapplication.h>
//#include <resource.h>
#endif
#include <libkcal/calendarlocal.h>
#include <libkcal/todo.h>
#include <libkdepim/ksyncprofile.h>
#include <libkcal/kincidenceformatter.h>
#include <libkdepim/kpimglobalprefs.h>
@@ -1137,30 +1139,25 @@ void MainWindow::displayFile( QString fn, QString cap )
}
void MainWindow::features()
{
displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
}
void MainWindow::usertrans()
{
displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
}
-#if 0
-#include <libkcal/vcalformat.h>
-#include <libkcal/event.h>
-#include <libkcal/todo.h>
-#include <libkcal/incidence.h>
-#endif
+
void MainWindow::synchowto()
{
#if 0
QPtrList<Incidence> er = mCalendar->rawIncidences();
Incidence* inR = er.first();
VCalFormat vf;
QString strout;
while ( inR ) {
if ( inR->type() == "Todo" )
strout = vf.todoToString( (Todo *) inR );
if ( inR->type() == "Event" )
strout = vf.eventToString( (Event *) inR );
@@ -1419,25 +1416,24 @@ void MainWindow::slotModifiedChanged( bool changed )
return;
int msec;
// we store the changes after 1 minute,
// and for safety reasons after 10 minutes again
if ( !mBlockSaveFlag )
msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
else
msec = 1000 * 600;
mSaveTimer.start( msec, true ); // 1 minute
qDebug("KO: Saving File in %d secs!", msec/1000);
mCalendarModifiedFlag = true;
}
-#include <qfileinfo.h>
void MainWindow::save()
{
if ( mBlockSaveFlag )
return;
bool store = mBlockSaveFlag;
mBlockSaveFlag = true;
if ( mView->checkFileVersion( defaultFileName()) ) {
QTime neededSaveTime = QDateTime::currentDateTime().time();
setCaption(i18n("KO/Pi:Saving Data to File ..." ));
qDebug("KO: Start saving data to file!");
mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
@@ -1857,25 +1853,24 @@ void MainWindow::exportVCalendar()
if ( createbup ) {
if ( mView->exportVCalendar( fn ) ) {
KOPrefs::instance()->mLastVcalFile = fn;
if ( fn.length() > 20 )
mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
else
mes = i18n("KO/Pi:Exported to %1").arg(fn );
setCaption(mes);
}
}
}
-#include <qpushbutton.h>
QString MainWindow::getPassword( )
{
QString retfile = "";
QDialog dia ( this, "input-dialog", true );
QLineEdit lab ( &dia );
lab.setEchoMode( QLineEdit::Password );
QVBoxLayout lay( &dia );
lay.setMargin(7);
lay.setSpacing(7);
lay.addWidget( &lab);
dia.setFixedSize( 230,50 );
dia.setCaption( i18n("Enter password") );
@@ -1992,27 +1987,60 @@ void MainWindow::getFile(QSocket* socket)
qDebug("error open cal file ");
return ;
}
mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
QTextStream ts( &file );
ts.setCodec( QTextCodec::codecForName("utf8") );
bool first = true;
while ( socket->canReadLine () || first ) {
first = false;
while ( socket->canReadLine () ) {
+ qDebug("avail %d ", socket->bytesAvailable () );
ts << socket->readLine ();
}
+ QTime ti;
+ ti.start();
+ while ( ti.elapsed () < 5000 && !socket->canReadLine () ) {
+ qDebug("waiting1a %d %d ",ti.elapsed (), socket->bytesAvailable () );
+ //qApp->processEvents();
+ qDebug("waiting1b %d ",ti.elapsed () );
+ if ( !socket->canReadLine () ) {
+ qDebug("waiting1c %d ",ti.elapsed () );
+ usleep( 100000);
+ }
+ //socket->waitForMore ( 100 );
+ }
+ ts << socket->readLine ();
+#if 0
+#ifdef DESKTOP_VERSION
socket->waitForMore ( 5000 );
+#else
+ // socket->waitForMore ( 5000 );
+ // seems to be broken in qt2
+ bool stop = false;
+ QTime ti;
+ ti.start();
+ while ( ti.elapsed < 5000 && !stop ) {
+ qApp->processEvents();
+ if ( socket->canReadLine () )
+ stop = true ;
+ else {
+ usleep( 100000 );
+
+ }
+ }
+#endif
+#endif
}
setCaption( i18n("File received - reloading calendar...") );
file.close();
socket->close();
mView->watchSavedFile();
mView->openCalendar( defaultFileName() );
setCaption( i18n("Easy-Pi-Sync successful!") );
delete mSyncActionDialog;
mSyncActionDialog = 0;
}
@@ -2100,26 +2128,34 @@ QString fileName;
}
//QTextStream os2( mCommandSocket );
//os2.setEncoding( QTextStream::UnicodeUTF8 );
QTextStream ts( &file );
ts.setCodec( QTextCodec::codecForName("utf8") );
bool first = true;
while ( mCommandSocket->canReadLine () || first) {
first = false;
while ( mCommandSocket->canReadLine () ) {
ts << mCommandSocket->readLine ();
+ }
+ QTime ti;
+ ti.start();
+ while ( ti.elapsed () < 5000 && !mCommandSocket->canReadLine () ) {
+ qApp->processEvents();
+ qDebug("waiting2 %d ",ti.elapsed () );
+ if ( !mCommandSocket->canReadLine () )
+ mCommandSocket->waitForMore ( 100 );
}
- mCommandSocket->waitForMore ( 5000 );
+ //mCommandSocket->waitForMore ( 5000 );
}
file.close();
mCommandSocket->close();
//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 );
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
KSyncProfile* temp = new KSyncProfile ();
temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
@@ -2443,12 +2479,63 @@ void MainWindow::syncPhone()
}
void MainWindow::printSel( )
{
mView->viewManager()->agendaView()->agenda()->printSelection();
}
void MainWindow::printCal()
{
mView->print();//mCp->showDialog();
}
+
+
+
+KServerSocket:: KServerSocket ( Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ){;};
+
+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 );
+}
+
+void KServerSocket::discardClient()
+{
+ qDebug(" KServerSocket::discardClient()");
+ QSocket* socket = (QSocket*)sender();
+ delete socket;
+ //emit endConnect();
+}
+void KServerSocket::readClient()
+{
+ qDebug("KServerSocket readClient()");
+ QSocket* socket = (QSocket*)sender();
+ if ( socket->canReadLine() ) {
+ QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() );
+ qDebug("KServerSocket socket->canReadLine()");
+ if ( tokens[0] == "GET" ) {
+ emit sendFile( socket );
+ }
+ if ( tokens[0] == "PUT" ) {
+ emit getFile( socket );
+ }
+ if ( tokens[0] == "STOP" ) {
+ emit endConnect();
+ }
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 5985d56..7b4fd27 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -18,63 +18,35 @@ class KSyncProfile;
#define QPEMenuBar QMenuBar
#endif
class QPEToolBar;
#include <qserversocket.h>
#include <qsocket.h>
#include <qnetworkprotocol.h>
class KServerSocket : public QServerSocket
{
Q_OBJECT
public:
- KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ) :
- QServerSocket( port, backlog, parent, name ){;};
- void 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 );
- }
+ KServerSocket ( Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
+
+ void newConnection ( int socket ) ;
signals:
void sendFile(QSocket*);
void getFile(QSocket*);
void endConnect();
private slots:
- void discardClient()
- {
- QSocket* socket = (QSocket*)sender();
- delete socket;
- //emit endConnect();
- }
- void readClient()
- {
- qDebug("readClient() ");
- QSocket* socket = (QSocket*)sender();
- if ( socket->canReadLine() ) {
- QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), socket->readLine() );
- if ( tokens[0] == "GET" ) {
- emit sendFile( socket );
- }
- if ( tokens[0] == "PUT" ) {
- emit getFile( socket );
- }
- if ( tokens[0] == "STOP" ) {
- emit endConnect();
- }
- }
- }
+ void discardClient();
+ void readClient();
};
namespace KCal {
class CalendarLocal;
}
using namespace KCal;
class MainWindow : public QMainWindow
{
Q_OBJECT