summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koprefs.cpp2
-rw-r--r--korganizer/koprefs.h3
-rw-r--r--korganizer/mainwindow.cpp321
-rw-r--r--korganizer/mainwindow.h70
4 files changed, 2 insertions, 394 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 84e3d00..1210094 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -131,130 +131,128 @@ KOPrefs::KOPrefs() :
addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
addItemBool("Confirm Deletes",&mConfirm,true);
addItemString("Archive File",&mArchiveFile);
addItemString("Html Export File",&mHtmlExportFile,
QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
addItemBool("Html With Save",&mHtmlWithSave,false);
KPrefs::setCurrentGroup("Personal Settings");
addItemInt("Mail Client",&mMailClient,MailClientKMail);
addItemBool("Use Control Center Email",&mEmailControlCenter,false);
addItemBool("Bcc",&mBcc,false);
KPrefs::setCurrentGroup("Time & Date");
// addItemString("Time Zone",&mTimeZone,"+0100");
addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") );
// addItemInt("TimeZoneOffset",&mTimeZoneOffset,60);
addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
addItemInt("Default Start Time",&mStartTime,10);
addItemInt("Default Duration",&mDefaultDuration,2);
addItemInt("Default Alarm Time",&mAlarmTime,3);
addItemInt("Daylight Savings",&mDaylightSavings,0);
KPrefs::setCurrentGroup("AlarmSettings");
addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
KPrefs::setCurrentGroup("Calendar");
addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
KPrefs::setCurrentGroup("Fonts");
// qDebug(" KPrefs::setCurrentGroup(Fonts); ");
addItemFont("TimeBar Font",&mTimeBarFont);
addItemFont("MonthView Font",&mMonthViewFont);
addItemFont("AgendaView Font",&mAgendaViewFont);
addItemFont("MarcusBains Font",&mMarcusBainsFont);
addItemFont("TimeLabels Font",&mTimeLabelsFont);
addItemFont("TodoView Font",&mTodoViewFont);
addItemFont("ListView Font",&mListViewFont);
addItemFont("DateNavigator Font",&mDateNavigatorFont);
addItemFont("EditBox Font",&mEditBoxFont);
addItemFont("JournalView Font",&mJornalViewFont);
addItemFont("WhatsNextView Font",&mWhatsNextFont);
addItemFont("EventView Font",&mEventViewFont);
// KPrefs::setCurrentGroup("SyncProfiles");
// addItemString("LocalMachineName",&mLocalMachineName, "undefined");
// addItemStringList("SyncProfileNames",&mSyncProfileNames);
// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames);
KPrefs::setCurrentGroup("RemoteSyncing");
// addItemBool("UsePasswd",&mUsePassWd,false);
// addItemBool("WriteBackFile",&mWriteBackFile,true);
// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
// addItemBool("AskForPreferences",&mAskForPreferences,true);
// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
- addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
- addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" );
addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
addItemInt("LastSyncTime",&mLastSyncTime,0);
addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3);
addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
#ifdef _WIN32_
QString hdp= locateLocal("data","korganizer")+"\\\\";
#else
QString hdp= locateLocal("data","korganizer")+"/";
#endif
// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65");
// addItemString("RemoteUser",&mRemoteUser, "zaurus");
// addItemString("RemotePassWd",&mRemotePassWd, "");
// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics");
// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" );
KPrefs::setCurrentGroup("LoadSaveFileNames");
addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
KPrefs::setCurrentGroup("Locale");
addItemInt("PreferredLanguage",&mPreferredLanguage,0);
addItemInt("PreferredTime",&mPreferredTime,0);
addItemInt("PreferredDate",&mPreferredDate,0);
addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
KPrefs::setCurrentGroup("Colors");
addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
addItemBool("UseAppColors",&mUseAppColors,false);
KPrefs::setCurrentGroup("Views");
addItemInt("Hour Size",&mHourSize,8);
addItemBool("Show Daily Recurrences",&mDailyRecur,true);
addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index d9ac851..ff09e19 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -217,97 +217,96 @@ class KOPrefs : public KPimPrefs
QStringList mSyncProfileNames;
QStringList mExternSyncProfiles;
QString mLocalMachineName;
void setCategoryColor(QString cat,const QColor & color);
QColor *categoryColor(QString cat);
QString mArchiveFile;
QString mHtmlExportFile;
bool mHtmlWithSave;
QStringList mSelectedPlugins;
QString mLastImportFile;
QString mLastVcalFile;
QString mLastSaveFile;
QString mLastLoadFile;
QString mLastSyncedLocalFile;
QString mDefaultAlarmFile;
int mIMIPScheduler;
int mIMIPSend;
QStringList mAdditionalMails;
int mIMIPAutoRefresh;
int mIMIPAutoInsertReply;
int mIMIPAutoInsertRequest;
int mIMIPAutoFreeBusy;
int mIMIPAutoFreeBusyReply;
QStringList mTodoTemplates;
QStringList mEventTemplates;
int mDestination;
bool mEditOnDoubleClick;
bool mViewChangeHoldFullscreen;
bool mViewChangeHoldNonFullscreen;
bool mCenterOnCurrentTime;
bool mSetTimeToDayStartAt;
bool mHighlightCurrentDay;
bool mUseHighlightLightColor;
bool mListViewMonthTimespan;
bool mWNViewShowsParents;
bool mWNViewShowLocation;
bool mTodoViewShowsPercentage;
bool mTodoViewUsesCatColors;
bool mTodoViewUsesSmallFont;
bool mTodoViewUsesForegroundColor;
bool mMonthViewUsesForegroundColor;
bool mHightlightDateTimeEdit;
bool mShortDateInViewer;
QStringList mLocationDefaults;
QStringList mEventSummaryUser;
QStringList mTodoSummaryUser;
bool mUseInternalAlarmNotification;
int mAlarmPlayBeeps;
int mAlarmSuspendTime;
int mAlarmSuspendCount;
int mAlarmBeepInterval;
- QString mPassiveSyncPort;
- QString mPassiveSyncPw;
+
QString mActiveSyncPort;
QString mActiveSyncIP;
//US I copied the following settings into KPimGlobalPrefs
// that allows us later to easily remove the settings from here.
int mPreferredDate;
QString mUserDateFormatLong;
QString mUserDateFormatShort;
int mPreferredLanguage;
int mPreferredTime;
bool mWeekStartsOnSunday;
QString mTimeZoneId;
bool mUseDaylightsaving;
int mDaylightsavingStart;
int mDaylightsavingEnd;
private:
QDict<QColor> mCategoryColors;
QColor mDefaultCategoryColor;
QFont mDefaultTimeBarFont;
QFont mDefaultViewFont;
QFont mDefaultMonthViewFont;
QString mName;
QString mEmail;
};
#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 9104347..e3324ee 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -69,129 +69,128 @@ using namespace KCal;
#include "koimportoldialog.h"
#endif
#include "mainwindow.h"
class KOex2phonePrefs : public QDialog
{
public:
KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
QDialog( parent, name, true )
{
setCaption( i18n("Export to phone options") );
QVBoxLayout* lay = new QVBoxLayout( this );
lay->setSpacing( 3 );
lay->setMargin( 3 );
QLabel *lab;
lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
lab->setAlignment (AlignHCenter );
QHBox* temphb;
temphb = new QHBox( this );
new QLabel( i18n("I/O device: "), temphb );
mPhoneDevice = new QLineEdit( temphb);
lay->addWidget( temphb );
temphb = new QHBox( this );
new QLabel( i18n("Connection: "), temphb );
mPhoneConnection = new QLineEdit( temphb);
lay->addWidget( temphb );
temphb = new QHBox( this );
new QLabel( i18n("Model(opt.): "), temphb );
mPhoneModel = new QLineEdit( temphb);
lay->addWidget( temphb );
mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
mWriteBackFuture->setChecked( true );
lay->addWidget( mWriteBackFuture );
temphb = new QHBox( this );
new QLabel( i18n("Max. weeks in future: ") , temphb );
mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
mWriteBackFutureWeeks->setValue( 8 );
lay->addWidget( temphb );
lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
lab->setAlignment (AlignHCenter );
QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
lay->addWidget( ok );
QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
lay->addWidget( cancel );
connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
resize( 220, 240 );
}
public:
QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
QCheckBox* mWriteBackFuture;
QSpinBox* mWriteBackFutureWeeks;
};
int globalFlagBlockStartup;
MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
QMainWindow( parent, name )
{
mPassWordPiSync = "abc";
#ifdef DESKTOP_VERSION
setFont( QFont("Arial"), 14 );
#endif
- mSyncActionDialog = 0;
mServerSocket = 0;
mClosed = false;
//QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
QString confFile = locateLocal("config","korganizerrc");
QFileInfo finf ( confFile );
bool showWarning = !finf.exists();
setIcon(SmallIcon( "ko24" ) );
mBlockAtStartup = true;
mFlagKeyPressed = false;
setCaption("KOrganizer/Pi");
KOPrefs *p = KOPrefs::instance();
KPimGlobalPrefs::instance()->setGlobalConfig();
// if ( QApplication::desktop()->height() > 480 ) {
// if ( p->mHourSize == 4 )
// p->mHourSize = 6;
// }
if ( p->mHourSize > 18 )
p->mHourSize = 18;
QMainWindow::ToolBarDock tbd;
if ( p->mToolBarHor ) {
if ( p->mToolBarUp )
tbd = Bottom;
else
tbd = Top;
}
else {
if ( p->mToolBarUp )
tbd = Right;
else
tbd = Left;
}
if ( KOPrefs::instance()->mUseAppColors )
QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
globalFlagBlockStartup = 1;
iconToolBar = new QPEToolBar( this );
addToolBar (iconToolBar , tbd );
mBlockSaveFlag = false;
mCalendarModifiedFlag = false;
QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
splash->setAlignment ( AlignCenter );
setCentralWidget( splash );
#ifndef DESKTOP_VERSION
showMaximized();
#endif
//qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
setDefaultPreferences();
mCalendar = new CalendarLocal();
mView = new CalendarView( mCalendar, this,"mCalendar " );
mView->hide();
//mView->resize(splash->size() );
initActions();
#ifndef DESKTOP_VERSION
iconToolBar->show();
qApp->processEvents();
#endif
//qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
int vh = height() ;
int vw = width();
//qDebug("Toolbar hei %d ",iconToolBar->height() );
if ( iconToolBar->orientation () == Qt:: Horizontal ) {
vh -= iconToolBar->height();
} else {
vw -= iconToolBar->height();
@@ -2286,384 +2285,64 @@ void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
}
question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
question,
i18n("Okay!")) ;
setCaption ("KO/Pi");
return;
}
setCaption ( i18n( "Copying succeed." ) );
//qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
// Event* e = mView->getLastSyncEvent();
// e->setReadOnly( false );
// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
// e->setReadOnly( true );
if ( KOPrefs::instance()->mWriteBackFile ) {
command = prof->getPostSyncCommand();
int fi;
if ( (fi = command.find("$PWD$")) > 0 ) {
QString pwd = getPassword();
command = command.left( fi )+ pwd + command.mid( fi+5 );
}
setCaption ( i18n( "Writing back file ..." ) );
result = system ( command );
qDebug("KO: Writing back file result: %d ", result);
if ( result != 0 ) {
setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
return;
} else {
setCaption ( i18n( "Syncronization sucessfully completed" ) );
}
}
}
return;
}
void MainWindow::syncSharp()
{
if ( mCalendarModifiedFlag )
save();
mView->syncSharp();
slotModifiedChanged( true );
}
void MainWindow::syncPhone()
{
if ( mCalendarModifiedFlag )
save();
mView->syncPhone();
slotModifiedChanged( true );
}
void MainWindow::printSel( )
{
mView->viewManager()->agendaView()->agenda()->printSelection();
}
void MainWindow::printCal()
{
mView->print();//mCp->showDialog();
}
-
-
-KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
-{
- mPassWord = pw;
- mSocket = 0;
- mSyncActionDialog = 0;
- blockRC = false;
-};
-
-void KServerSocket::newConnection ( int socket )
-{
- // qDebug("KServerSocket:New connection %d ", 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()");
- if ( mSocket ) {
- delete mSocket;
- mSocket = 0;
- }
- //emit endConnect();
-}
-void KServerSocket::readClient()
-{
- if ( blockRC )
- return;
- if ( mSocket == 0 ) {
- qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
- return;
- }
- qDebug("KServerSocket readClient()");
- if ( mSocket->canReadLine() ) {
- QString line = mSocket->readLine();
- qDebug("KServerSocket readline: %s ", line.latin1());
- QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
- if ( tokens[0] == "GET" ) {
- if ( tokens[1] == mPassWord )
- //emit sendFile( mSocket );
- send_file();
- else {
- KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password"));
- qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
- }
- }
- if ( tokens[0] == "PUT" ) {
- if ( tokens[1] == mPassWord ) {
- //emit getFile( mSocket );
- blockRC = true;
- get_file();
- }
- else {
- KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
- qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
- }
- }
- if ( tokens[0] == "STOP" ) {
- //emit endConnect();
- end_connect();
- }
- }
-}
-void KServerSocket::end_connect()
-{
- delete mSyncActionDialog;
- mSyncActionDialog = 0;
-}
-void KServerSocket::send_file()
-{
- //qDebug("MainWindow::sendFile(QSocket* s) ");
- if ( mSyncActionDialog )
- delete mSyncActionDialog;
- mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
- mSyncActionDialog->setCaption(i18n("Received sync request"));
- QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
- QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
- lay->addWidget( label);
- lay->setMargin(7);
- lay->setSpacing(7);
- mSyncActionDialog->setFixedSize( 230, 120);
- mSyncActionDialog->show();
- qDebug("KSS::saving ... ");
- emit saveFile();
- qApp->processEvents();
- QString fileName = mFileName;
- QFile file( fileName );
- if (!file.open( IO_ReadOnly ) ) {
- delete mSyncActionDialog;
- mSyncActionDialog = 0;
- qDebug("KSS::error open file ");
- mSocket->close();
- if ( mSocket->state() == QSocket::Idle )
- QTimer::singleShot( 10, this , SLOT ( discardClient()));
- return ;
-
- }
- mSyncActionDialog->setCaption( i18n("Sending file...") );
- QTextStream ts( &file );
- ts.setCodec( QTextCodec::codecForName("utf8") );
- QTextStream os( mSocket );
- os.setCodec( QTextCodec::codecForName("utf8") );
- //os.setEncoding( QTextStream::UnicodeUTF8 );
- while ( ! ts.atEnd() ) {
- os << ts.readLine() << "\n";
- }
- //os << ts.read();
- file.close();
- mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
- mSocket->close();
- if ( mSocket->state() == QSocket::Idle )
- QTimer::singleShot( 10, this , SLOT ( discardClient()));
-}
-void KServerSocket::get_file()
-{
- mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
-
- piTime.start();
- piFileString = "";
- QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
-}
-
-
-void KServerSocket::readBackFileFromSocket()
-{
- //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
- while ( mSocket->canReadLine () ) {
- piTime.restart();
- QString line = mSocket->readLine ();
- piFileString += line;
- //qDebug("readline: %s ", line.latin1());
- mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
-
- }
- if ( piTime.elapsed () < 3000 ) {
- // wait for more
- //qDebug("waitformore ");
- QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
- return;
- }
- QString fileName = mFileName;
- QFile file ( fileName );
- if (!file.open( IO_WriteOnly ) ) {
- delete mSyncActionDialog;
- mSyncActionDialog = 0;
- qDebug("error open cal file ");
- piFileString = "";
- emit file_received( false );
- blockRC = false;
- return ;
-
- }
-
- // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
- QTextStream ts ( &file );
- ts.setCodec( QTextCodec::codecForName("utf8") );
- mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
- ts << piFileString;
- mSocket->close();
- if ( mSocket->state() == QSocket::Idle )
- QTimer::singleShot( 10, this , SLOT ( discardClient()));
- file.close();
- delete mSyncActionDialog;
- mSyncActionDialog = 0;
- piFileString = "";
- blockRC = false;
- emit file_received( true );
-
-}
-
-KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
-{
- mPassWord = password;
- mSocket = 0;
- mPort = port;
- mHost = host;
-
- mRetVal = quiet;
- mTimerSocket = new QTimer ( this );
- connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
-}
-void KCommandSocket::readFile( QString fn )
-{
- if ( !mSocket ) {
- mSocket = new QSocket( this );
- connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
- connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
- }
- mFileString = "";
- mFileName = fn;
- mFirst = true;
- mSocket->connectToHost( mHost, mPort );
- QTextStream os( mSocket );
- os.setEncoding( QTextStream::UnicodeUTF8 );
- os << "GET " << mPassWord << "\r\n";
- mTimerSocket->start( 10000 );
-}
-
-void KCommandSocket::writeFile( QString fileName )
-{
- if ( !mSocket ) {
- mSocket = new QSocket( this );
- connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
- connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
- }
- mFileName = fileName ;
- mSocket->connectToHost( mHost, mPort );
-}
-void KCommandSocket::writeFileToSocket()
-{
- QFile file2( mFileName );
- if (!file2.open( IO_ReadOnly ) ) {
- mRetVal= errorW;
- mSocket->close();
- if ( mSocket->state() == QSocket::Idle )
- QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
- return ;
- }
- QTextStream ts2( &file2 );
- ts2.setCodec( QTextCodec::codecForName("utf8") );
- QTextStream os2( mSocket );
- os2.setCodec( QTextCodec::codecForName("utf8") );
- os2 << "PUT " << mPassWord << "\r\n";;
- while ( ! ts2.atEnd() ) {
- os2 << ts2.readLine() << "\n";
- }
- mRetVal= successW;
- file2.close();
- mSocket->close();
- if ( mSocket->state() == QSocket::Idle )
- QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
-}
-void KCommandSocket::sendStop()
-{
- if ( !mSocket ) {
- mSocket = new QSocket( this );
- connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
- }
- mSocket->connectToHost( mHost, mPort );
- QTextStream os2( mSocket );
- os2.setCodec( QTextCodec::codecForName("utf8") );
- os2 << "STOP\r\n";
- mSocket->close();
- if ( mSocket->state() == QSocket::Idle )
- QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
-}
-
-void KCommandSocket::startReadFileFromSocket()
-{
- if ( ! mFirst )
- return;
- mFirst = false;
- mTimerSocket->stop();
- mFileString = "";
- mTime.start();
- QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
-
-}
-void KCommandSocket::readFileFromSocket()
-{
- //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
- while ( mSocket->canReadLine () ) {
- mTime.restart();
- QString line = mSocket->readLine ();
- mFileString += line;
- //qDebug("readline: %s ", line.latin1());
- }
- if ( mTime.elapsed () < 3000 ) {
- // wait for more
- //qDebug("waitformore ");
- QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
- return;
- }
- QString fileName = mFileName;
- QFile file ( fileName );
- if (!file.open( IO_WriteOnly ) ) {
- mFileString = "";
- mRetVal = errorR;
- qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
- deleteSocket();
- return ;
-
- }
- // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
- QTextStream ts ( &file );
- ts.setCodec( QTextCodec::codecForName("utf8") );
- ts << mFileString;
- file.close();
- mFileString = "";
- mRetVal = successR;
- mSocket->close();
- // if state is not idle, deleteSocket(); is called via
- // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
- if ( mSocket->state() == QSocket::Idle )
- deleteSocket();
-}
-
-void KCommandSocket::deleteSocket()
-{
- if ( mTimerSocket->isActive () ) {
- mTimerSocket->stop();
- KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
- mRetVal = errorR;
- }
- //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
- if ( mSocket)
- delete mSocket;
- mSocket = 0;
- emit commandFinished( this, mRetVal );
-}
-
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 4f89e03..0da0be0 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,216 +1,148 @@
#ifndef KORGE_MAINWINDOW_H
#define KORGE_MAINWINDOW_H
#include <qmainwindow.h>
#include <qtimer.h>
#include <qdict.h>
#include <qfile.h>
-#include <qsocket.h>
#include <qtextstream.h>
#include <qregexp.h>
#include <libkcal/incidence.h>
#include "simplealarmclient.h"
+#include <ksyncmanager.h>
class QAction;
class CalendarView;
class KSyncProfile;
#ifdef DESKTOP_VERSION
#define QPEToolBar QToolBar
#define QPEMenuBar QMenuBar
#endif
class QPEToolBar;
-#include <qserversocket.h>
-#include <qsocket.h>
-#include <qnetworkprotocol.h>
-class KServerSocket : public QServerSocket
-{
- Q_OBJECT
-
-public:
- KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
-
- void newConnection ( int socket ) ;
- void setFileName( QString fn ) {mFileName = fn;};
-
-signals:
- //void sendFile(QSocket*);
- //void getFile(QSocket*);
- void file_received( bool );
- //void file_sent();
- void saveFile();
- void endConnect();
-private slots:
- void discardClient();
- void readClient();
- void readBackFileFromSocket();
- private :
- bool blockRC;
- void send_file();
- void get_file();
- void end_connect();
- QDialog* mSyncActionDialog;
- QSocket* mSocket;
- QString mPassWord;
- QString mFileName;
- QTime piTime;
- QString piFileString;
-};
-
-class KCommandSocket : public QObject
-{
- Q_OBJECT
-public:
- enum state { successR, errorR, successW, errorW, quiet };
- KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
- void readFile( QString );
- void writeFile( QString );
- void sendStop();
-
-
-signals:
- void commandFinished( KCommandSocket*, int );
-private slots:
- void startReadFileFromSocket();
- void readFileFromSocket();
- void deleteSocket();
- void writeFileToSocket();
- private :
- QSocket* mSocket;
- QString mPassWord;
- Q_UINT16 mPort;
- QString mHost;
- QString mFileName;
- QTimer* mTimerSocket;
- int mRetVal;
- QTime mTime;
- QString mFileString;
- bool mFirst;
-};
namespace KCal {
class CalendarLocal;
}
using namespace KCal;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
~MainWindow();
public slots:
virtual void showMaximized ();
void configureAgenda( int );
void recieve( const QCString& msg, const QByteArray& data );
static QString defaultFileName();
static QString syncFileName();
static QString resourcePath();
protected slots:
void setCaptionToDates();
int ringSync();
void multiSync( bool askforPrefs = false );
void about();
void licence();
void faq();
void usertrans();
void features();
void synchowto();
void whatsNew();
void keyBindings();
void aboutAutoSaving();;
void aboutKnownBugs();
void processIncidenceSelection( Incidence * );
void importQtopia();
void importBday();
void importOL();
void importIcal();
void importFile( QString, bool );
void quickImportIcal();
void slotModifiedChanged( bool );
void save();
void configureToolBar( int );
void printSel();
void printCal();
void saveCalendar();
void loadCalendar();
void exportVCalendar();
void fillFilterMenu();
void selectFilter( int );
void exportToPhone( int );
void slotSyncMenu( int );
void confSync();
void syncSharp();
void syncPhone();
void syncPi();
void syncLocalFile();
bool syncWithFile( QString, bool );
void quickSyncLocalFile();
protected:
void displayText( QString, QString);
void displayFile( QString, QString);
void enableIncidenceActions( bool );
private slots:
QSocket* piSocket;
QString piFileString;
QTime piTime;
void deleteCommandSocket(KCommandSocket* s, int state );
void fillSyncMenu();
void getFile( bool );
void readFileFromSocket();
private:
//QTimer* mTimerCommandSocket;
QString mPassWordPiSync;
KServerSocket * mServerSocket;
bool mClosed;
void saveOnClose();
int mCurrentSyncProfile;
void enableQuick();
void syncRemote( KSyncProfile* , bool ask = true);
bool mFlagKeyPressed;
bool mBlockAtStartup;
QPEToolBar *iconToolBar;
void initActions();
void setDefaultPreferences();
void keyPressEvent ( QKeyEvent * ) ;
void keyReleaseEvent ( QKeyEvent * ) ;
QPopupMenu *configureToolBarMenu;
QPopupMenu *selectFilterMenu;
QPopupMenu *configureAgendaMenu, *syncMenu;
CalendarLocal *mCalendar;
CalendarView *mView;
QString getPassword();
QAction *mNewSubTodoAction;
QAction *mShowAction;
QAction *mEditAction;
QAction *mDeleteAction;
QAction *mCloneAction;
QAction *mMoveAction;
QAction *mBeamAction;
QAction *mCancelAction;
void closeEvent( QCloseEvent* ce );
SimpleAlarmClient mAlarmClient;
QTimer mSaveTimer;
bool mBlockSaveFlag;
bool mCalendarModifiedFlag;
QPixmap loadPixmap( QString );
- QDialog * mSyncActionDialog;
};
#endif