summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-05 08:07:41 (UTC)
committer zautrix <zautrix>2004-10-05 08:07:41 (UTC)
commitad859d26b813101adab963f50e694961702561d9 (patch) (side-by-side diff)
tree36eb7f12ee6ee80f50cdd13bbfaba74e9a1b37d1
parentfc2c103f45a6d4e4105259436266538c645f2c87 (diff)
downloadkdepimpi-ad859d26b813101adab963f50e694961702561d9.zip
kdepimpi-ad859d26b813101adab963f50e694961702561d9.tar.gz
kdepimpi-ad859d26b813101adab963f50e694961702561d9.tar.bz2
cleanup
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp20
-rw-r--r--korganizer/koprefs.cpp1
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--korganizer/mainwindow.cpp115
-rw-r--r--korganizer/mainwindow.h2
-rw-r--r--libkcal/calstorage.h2
-rw-r--r--libkcal/filestorage.cpp4
-rw-r--r--libkcal/filestorage.h2
-rw-r--r--libkcal/icalformat.cpp24
-rw-r--r--libkcal/icalformat.h3
10 files changed, 20 insertions, 154 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index eaea040..fecc7e2 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1176,104 +1176,104 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
}
inR = er.next();
}
}
bar.hide();
mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
eventLSync->setReadOnly( false );
eventLSync->setDtStart( mLastCalendarSync );
eventRSync->setDtStart( mLastCalendarSync );
eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
eventLSync->setReadOnly( true );
if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
remote->addEvent( eventRSync );
QString mes;
mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
QString delmess;
if ( delFut ) {
delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture );
mes += delmess;
}
if ( KOPrefs::instance()->mShowSyncSummary ) {
KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
}
qDebug( mes );
mCalendar->checkAlarmForIncidence( 0, true );
return syncOK;
}
void CalendarView::setSyncDevice( QString s )
{
mCurrentSyncDevice= s;
}
void CalendarView::setSyncName( QString s )
{
mCurrentSyncName= s;
}
bool CalendarView::syncCalendar(QString filename, int mode)
{
mGlobalSyncMode = SYNC_MODE_NORMAL;
CalendarLocal* calendar = new CalendarLocal();
calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
FileStorage* storage = new FileStorage( calendar );
bool syncOK = false;
storage->setFileName( filename );
// qDebug("loading ... ");
- if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
+ if ( storage->load() ) {
getEventViewerDialog()->setSyncMode( true );
syncOK = synchronizeCalendar( mCalendar, calendar, mode );
getEventViewerDialog()->setSyncMode( false );
if ( syncOK ) {
if ( KOPrefs::instance()->mWriteBackFile )
{
- storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
+ storage->setSaveFormat( new ICalFormat() );
storage->save();
}
}
setModified( true );
}
delete storage;
delete calendar;
if ( syncOK )
updateView();
return syncOK;
}
void CalendarView::syncPhone()
{
syncExternal( 1 );
}
void CalendarView::syncExternal( int mode )
{
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
//mCurrentSyncDevice = "sharp-DTM";
if ( KOPrefs::instance()->mAskForPreferences )
edit_sync_options();
qApp->processEvents();
CalendarLocal* calendar = new CalendarLocal();
calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
bool syncOK = false;
bool loadSuccess = false;
PhoneFormat* phoneFormat = 0;
#ifndef DESKTOP_VERSION
SharpFormat* sharpFormat = 0;
if ( mode == 0 ) { // sharp
sharpFormat = new SharpFormat () ;
loadSuccess = sharpFormat->load( calendar, mCalendar );
} else
#endif
if ( mode == 1 ) { // phone
phoneFormat = new PhoneFormat (mCurrentSyncDevice,
KOPrefs::instance()->mPhoneDevice,
KOPrefs::instance()->mPhoneConnection,
KOPrefs::instance()->mPhoneModel);
loadSuccess = phoneFormat->load( calendar,mCalendar);
} else
return;
if ( loadSuccess ) {
getEventViewerDialog()->setSyncMode( true );
syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
getEventViewerDialog()->setSyncMode( false );
@@ -1454,198 +1454,200 @@ bool CalendarView::importQtopia( const QString &categories,
{
// write back XML file
}
setModified( true );
}
} else {
QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
question, i18n("Ok")) ;
}
delete calendar;
updateView();
return syncOK;
#endif
}
void CalendarView::setSyncEventsReadOnly()
{
Event * ev;
QPtrList<Event> eL = mCalendar->rawEvents();
ev = eL.first();
while ( ev ) {
if ( ev->uid().left(15) == QString("last-syncEvent-") )
ev->setReadOnly( true );
ev = eL.next();
}
}
bool CalendarView::openCalendar(QString filename, bool merge)
{
if (filename.isEmpty()) {
return false;
}
if (!QFile::exists(filename)) {
KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
return false;
}
globalFlagBlockAgenda = 1;
if (!merge) mCalendar->close();
mStorage->setFileName( filename );
- if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
+ if ( mStorage->load() ) {
if ( merge ) ;//setModified( true );
else {
//setModified( true );
mViewManager->setDocumentId( filename );
mDialogManager->setDocumentId( filename );
mTodoList->setDocumentId( filename );
}
globalFlagBlockAgenda = 2;
// if ( getLastSyncEvent() )
// getLastSyncEvent()->setReadOnly( true );
mCalendar->reInitAlarmSettings();
setSyncEventsReadOnly();
updateUnmanagedViews();
updateView();
- if ( filename != MainWindow::defaultFileName() )
- saveCalendar( MainWindow::defaultFileName() );
loadedFileVersion = QDateTime::currentDateTime();
+ if ( filename != MainWindow::defaultFileName() ) {
+ saveCalendar( MainWindow::defaultFileName() );
+ watchSavedFile();
+ }
return true;
} else {
// while failing to load, the calendar object could
// have become partially populated. Clear it out.
if ( !merge ) mCalendar->close();
KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
globalFlagBlockAgenda = 2;
updateView();
}
return false;
}
void CalendarView::setLoadedFileVersion(QDateTime dt)
{
loadedFileVersion = dt;
}
bool CalendarView::checkFileChanged(QString fn)
{
QFileInfo finf ( fn );
if ( !finf.exists() )
return true;
QDateTime dt = finf.lastModified ();
if ( dt <= loadedFileVersion )
return false;
return true;
}
void CalendarView::watchSavedFile()
{
QFileInfo finf ( MainWindow::defaultFileName());
if ( !finf.exists() )
return;
QDateTime dt = finf.lastModified ();
if ( dt < loadedFileVersion ) {
QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
return;
}
loadedFileVersion = dt;
}
bool CalendarView::checkFileVersion(QString fn)
{
QFileInfo finf ( fn );
if ( !finf.exists() )
return true;
QDateTime dt = finf.lastModified ();
//qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
//qDebug("file on disk version %s",dt.toString().latin1());
if ( dt <= loadedFileVersion )
return true;
int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
i18n("KO/Pi Warning"),i18n("Overwrite"),
i18n("Sync+save"));
if ( km == KMessageBox::Cancel )
return false;
if ( km == KMessageBox::Yes )
return true;
setSyncDevice("deleteaftersync" );
KOPrefs::instance()->mAskForPreferences = true;
KOPrefs::instance()->mSyncAlgoPrefs = 3;
KOPrefs::instance()->mWriteBackFile = false;
KOPrefs::instance()->mWriteBackExistingOnly = false;
KOPrefs::instance()->mShowSyncSummary = false;
syncCalendar( fn, 3 );
Event * e = getLastSyncEvent();
mCalendar->deleteEvent ( e );
updateView();
return true;
}
bool CalendarView::saveCalendar( QString filename )
{
// Store back all unsaved data into calendar object
// qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
if ( mViewManager->currentView() )
mViewManager->currentView()->flushView();
//mStorage->setFileName( filename );
- mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
+ mStorage->setSaveFormat( new ICalFormat() );
mStorage->setFileName( filename );
bool success;
success = mStorage->save();
if ( !success ) {
return false;
}
return true;
}
void CalendarView::closeCalendar()
{
// child windows no longer valid
emit closingDown();
mCalendar->close();
setModified(false);
updateView();
}
void CalendarView::archiveCalendar()
{
mDialogManager->showArchiveDialog();
}
void CalendarView::readSettings()
{
// mViewManager->showAgendaView();
QString str;
//qDebug("CalendarView::readSettings() ");
// read settings from the KConfig, supplying reasonable
// defaults where none are to be found
KConfig *config = KOGlobals::config();
#ifndef KORG_NOSPLITTER
config->setGroup("KOrganizer Geometry");
QValueList<int> sizes = config->readIntListEntry("Separator1");
if (sizes.count() != 2) {
sizes << mDateNavigator->minimumSizeHint().width();
sizes << 300;
}
mPanner->setSizes(sizes);
sizes = config->readIntListEntry("Separator2");
@@ -2256,97 +2258,97 @@ void CalendarView::beamIncidence(Incidence * Inc)
}
void CalendarView::beamCalendar()
{
QPtrList<Incidence> delSel = mCalendar->rawIncidences();
//qDebug("beamCalendar() ");
beamIncidenceList( delSel );
}
void CalendarView::beamFilteredCalendar()
{
QPtrList<Incidence> delSel = mCalendar->incidences();
//qDebug("beamFilteredCalendar() ");
beamIncidenceList( delSel );
}
void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
{
if ( beamDialog->exec () == QDialog::Rejected )
return;
QString fn = "/tmp/kopibeamfile";
QString mes;
bool createbup = true;
if ( createbup ) {
QString description = "\n";
CalendarLocal* cal = new CalendarLocal();
if ( beamDialog->beamLocal() )
cal->setLocalTime();
else
cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
Incidence *incidence = delSel.first();
bool addText = false;
if ( delSel.count() < 10 )
addText = true;
else {
description.sprintf(i18n(" %d items?"),delSel.count() );
}
while ( incidence ) {
Incidence *in = incidence->clone();
if ( addText )
description += in->summary() + "\n";
cal->addIncidence( in );
incidence = delSel.next();
}
if ( beamDialog->beamVcal() ) {
fn += ".vcs";
FileStorage storage( cal, fn, new VCalFormat );
storage.save();
} else {
fn += ".ics";
- FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
+ FileStorage storage( cal, fn, new ICalFormat( ) );
storage.save();
}
delete cal;
mes = i18n("KO/Pi: Ready for beaming");
setCaption(mes);
#ifndef DESKTOP_VERSION
Ir *ir = new Ir( this );
connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
ir->send( fn, description, "text/x-vCalendar" );
#endif
}
}
void CalendarView::beamDone( Ir *ir )
{
#ifndef DESKTOP_VERSION
delete ir;
#endif
}
void CalendarView::moveIncidence(Incidence * inc )
{
if ( !inc ) return;
// qDebug("showDatePickerForIncidence( ) ");
if ( mDateFrame->isVisible() )
mDateFrame->hide();
else {
int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
mDateFrame->show();
}
mDatePickerMode = 2;
mMoveIncidence = inc ;
QDate da;
if ( mMoveIncidence->type() == "Todo" ) {
Todo * to = (Todo *) mMoveIncidence;
if ( to->hasDueDate() )
da = to->dtDue().date();
else
da = QDate::currentDate();
} else {
da = mMoveIncidence->dtStart().date();
}
mDatePicker->setDate( da );
}
@@ -2811,97 +2813,97 @@ void CalendarView::deleteEvent(Event *anEvent)
if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
schedule(Scheduler::Cancel,anEvent);
checkExternalId( anEvent);
mCalendar->deleteEvent(anEvent);
changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
}
} // if-else
emit updateSearchDialog();
}
bool CalendarView::deleteEvent(const QString &uid)
{
Event *ev = mCalendar->event(uid);
if (ev) {
deleteEvent(ev);
return true;
} else {
return false;
}
}
/*****************************************************************************/
void CalendarView::action_mail()
{
#ifndef KORG_NOMAIL
KOMailClient mailClient;
Incidence *incidence = currentSelection();
if (!incidence) {
KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
return;
}
if(incidence->attendeeCount() == 0 ) {
KMessageBox::sorry(this,
i18n("Can't generate mail:\nNo attendees defined.\n"));
return;
}
CalendarLocal cal_tmp;
Event *event = 0;
Event *ev = 0;
if ( incidence && incidence->type() == "Event" ) {
event = static_cast<Event *>(incidence);
ev = new Event(*event);
cal_tmp.addEvent(ev);
}
- ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
+ ICalFormat mForm();
QString attachment = mForm.toString( &cal_tmp );
if (ev) delete(ev);
mailClient.mailAttendees(currentSelection(), attachment);
#endif
#if 0
Event *anEvent = 0;
if (mViewManager->currentView()->isEventView()) {
anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
}
if (!anEvent) {
KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
return;
}
if(anEvent->attendeeCount() == 0 ) {
KMessageBox::sorry(this,
i18n("Can't generate mail:\nNo attendees defined.\n"));
return;
}
mailobject.emailEvent(anEvent);
#endif
}
void CalendarView::schedule_publish(Incidence *incidence)
{
Event *event = 0;
Todo *todo = 0;
if (incidence == 0) {
incidence = mViewManager->currentView()->selectedIncidences().first();
if (incidence == 0) {
incidence = mTodoList->selectedIncidences().first();
}
}
if ( incidence && incidence->type() == "Event" ) {
event = static_cast<Event *>(incidence);
} else {
if ( incidence && incidence->type() == "Todo" ) {
todo = static_cast<Todo *>(incidence);
}
}
if (!event && !todo) {
@@ -3096,97 +3098,97 @@ void CalendarView::setReadOnly(bool readOnly)
}
bool CalendarView::isModified()
{
return mModified;
}
void CalendarView::printSetup()
{
#ifndef KORG_NOPRINTER
createPrinter();
mCalPrinter->setupPrinter();
#endif
}
void CalendarView::print()
{
#ifndef KORG_NOPRINTER
createPrinter();
DateList tmpDateList = mNavigator->selectedDates();
mCalPrinter->print(CalPrinter::Month,
tmpDateList.first(), tmpDateList.last());
#endif
}
void CalendarView::printPreview()
{
#ifndef KORG_NOPRINTER
kdDebug() << "CalendarView::printPreview()" << endl;
createPrinter();
DateList tmpDateList = mNavigator->selectedDates();
mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
tmpDateList.last());
#endif
}
void CalendarView::exportICalendar()
{
QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
// Force correct extension
if (filename.right(4) != ".ics") filename += ".ics";
- FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
+ FileStorage storage( mCalendar, filename, new ICalFormat() );
storage.save();
}
bool CalendarView::exportVCalendar( QString filename )
{
if (mCalendar->journals().count() > 0) {
int result = KMessageBox::warningContinueCancel(this,
i18n("The journal entries can not be\nexported to a vCalendar file."),
i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
true);
if (result != KMessageBox::Continue) return false;
}
//QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
// Force correct extension
if (filename.right(4) != ".vcs") filename += ".vcs";
FileStorage storage( mCalendar, filename, new VCalFormat );
return storage.save();
}
void CalendarView::eventUpdated(Incidence *)
{
setModified();
// Don't call updateView here. The code, which has caused the update of the
// event is responsible for updating the view.
// updateView();
}
void CalendarView::adaptNavigationUnits()
{
if (mViewManager->currentView()->isEventView()) {
int days = mViewManager->currentView()->currentDateCount();
if (days == 1) {
emit changeNavStringPrev(i18n("&Previous Day"));
emit changeNavStringNext(i18n("&Next Day"));
} else {
emit changeNavStringPrev(i18n("&Previous Week"));
emit changeNavStringNext(i18n("&Next Week"));
}
}
}
void CalendarView::processMainViewSelection( Incidence *incidence )
{
if ( incidence ) mTodoList->clearSelection();
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 0034715..e0623d5 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -179,97 +179,96 @@ KOPrefs::KOPrefs() :
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("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("QuickSavingWOUnicode",&mUseQuicksave,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);
addItemBool("ShowShortMonthName",&mMonthShowShort,false);
addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
addItemBool("Enable ToolTips",&mEnableToolTips,false);
addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false);
addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);
addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 696433e..7abd741 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -221,93 +221,92 @@ class KOPrefs : public KPimPrefs
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 mUseQuicksave;
bool mShortDateInViewer;
QStringList mLocationDefaults;
QStringList mEventSummaryUser;
QStringList mTodoSummaryUser;
bool mUseInternalAlarmNotification;
int mAlarmPlayBeeps;
int mAlarmSuspendTime;
int mAlarmSuspendCount;
int mAlarmBeepInterval;
QString mPassiveSyncPort;
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 5aa75f5..43ee2d7 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1907,123 +1907,118 @@ void MainWindow::enableQuick()
lay.addWidget( &lab);
QLineEdit lepw ( &dia );
lepw.setText( "abc" );
QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
lay.addWidget( &label2);
lay.addWidget( &lepw);
dia.setFixedSize( 230,80 );
dia.setCaption( i18n("Enter port for Pi-Sync") );
QPushButton pb ( "OK", &dia);
lay.addWidget( &pb );
connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
dia.show();
int res = dia.exec();
if ( res )
retfile = lab.text();
else
return;
dia.hide();
passWordPiSync = lepw.text();
qApp->processEvents();
KOPrefs::instance()->mPassiveSyncPort = retfile;
bool ok;
Q_UINT16 port = retfile.toUInt(&ok);
if ( ! ok ) {
KMessageBox::information( this, i18n("No valid port"));
return;
}
//qDebug("port %d ", port);
mServerSocket = new KServerSocket ( passWordPiSync, port ,1 );
mServerSocket->setFileName( defaultFileName() );
//qDebug("connected ");
if ( !mServerSocket->ok() ) {
qWarning("Failed to bind to port %d", port);
delete mServerSocket;
mServerSocket = 0;
return;
}
connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) );
connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) );
}
void MainWindow::getFile( bool success )
{
if ( ! success ) {
setCaption( i18n("Error receiving file. Nothing changed!") );
return;
}
- // pending adjust time for watchSavedFile()
- //mView->watchSavedFile();
+ mView->watchSavedFile();
mView->openCalendar( defaultFileName() );
setCaption( i18n("Pi-Sync successful!") );
}
void MainWindow::syncPi()
{
qApp->processEvents();
- performQuickQuick();
-}
-
-void MainWindow::performQuickQuick()
-{
bool ok;
Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
if ( ! ok ) {
setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
return;
}
KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
setCaption( i18n("Sending request for remote file ...") );
commandSocket->readFile( syncFileName() );
}
+
void MainWindow::deleteCommandSocket(KCommandSocket*s, int state)
{
qDebug("MainWindow::deleteCommandSocket %d", state);
//enum { success, errorW, errorR, quiet };
if ( state == KCommandSocket::errorR ) {
setCaption( i18n("ERROR: Receiving remote file failed.") );
delete s;
KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
commandSocket->sendStop();
return;
} else if ( state == KCommandSocket::errorW ) {
setCaption( i18n("ERROR:Writing back file failed.") );
} else if ( state == KCommandSocket::successR ) {
QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
} else if ( state == KCommandSocket::successW ) {
setCaption( i18n("Pi-Sync succesful!") );
}
delete s;
}
void MainWindow::readFileFromSocket()
{
QString fileName = syncFileName();
setCaption( i18n("Remote file saved to temp file.") );
if ( ! syncWithFile( fileName , true ) ) {
setCaption( i18n("Syncing failed.") );
qDebug("Syncing failed ");
return;
}
KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
if ( KOPrefs::instance()->mWriteBackFile )
commandSocket->writeFile( fileName );
else {
commandSocket->sendStop();
setCaption( i18n("Pi-Sync succesful!") );
}
}
void MainWindow::syncLocalFile()
{
@@ -2121,202 +2116,96 @@ void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
setCaption ( i18n( "Copy remote file to local machine..." ) );
int fileSize = 0;
int result = system ( command );
// 0 : okay
// 256: no such file or dir
//
qDebug("KO: Remote copy result(0 = okay): %d ",result );
if ( result != 0 ) {
int len = maxlen;
while ( len < command.length() ) {
command.insert( len , "\n" );
len += maxlen +2;
}
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::syncSSH()
-{
- // not used anymore
- QTime timer;
- timer.start();
- //qDebug("MainWindow::syncssh() ");
- KOPrefs *p = KOPrefs::instance();
- QString localFile = p->mLocalTempFile;
- QString remoteIP = p->mRemoteIP;
- QString remoteUser = p->mRemoteUser;
- QString remoteFile = p->mRemoteFile;
- if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
- remoteUser += ":" + p->mRemotePassWd;
-
- QString question = i18n("Do you really want\nto remote sync?\n \n") +
- i18n("IP: " ) +remoteIP +"\n" +
- i18n("User: " ) + remoteUser +"\n" ;
- int maxlen = 30;
- if ( QApplication::desktop()->width() > 320 )
- maxlen += 25;
- if ( remoteFile.length() > maxlen )
- question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
- else
- question += i18n("Remote file:\n " ) + remoteFile +"\n";
- if ( localFile.length() > maxlen )
- question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
- else
- question += i18n("Local temp file:\n " ) + localFile +"\n";
-
- if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
- question,
- i18n("Yes"), i18n("No"),
- 0, 0 ) != 0 )
- return;
- // if ( !p->mUsePassWd ) {
- // QString pass = getPassword();
- // if ( pass.length() > 0 )
- // remoteUser += ":" + pass;
- // }
- QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
- setCaption ( i18n( "Copy remote file to local machine..." ) );
- int fileSize = 0;
- int result = system ( command );
- // 0 : okay
- // 256: no such file or dir
- //
- qDebug("KO: Remote copy result(0 = okay): %d ",result );
- if ( result != 0 ) {
- int len = maxlen;
- while ( len < command.length() ) {
- command.insert( len , "\n" );
- len += maxlen +2;
- }
- 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." ) );
- //mView->setSyncDevice("ssh-scp" );
- if ( syncWithFile(localFile , true ) ) {
-// Event* e = mView->getLastSyncEvent();
-// e->setReadOnly( false );
-// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
-// e->setReadOnly( true );
- if ( KOPrefs::instance()->mWriteBackFile ) {
- command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
- setCaption ( i18n( "Writing back file ..." ) );
- result = system ( command );
- if ( result != 0 ) {
- int len = maxlen;
- while ( len < command.length() ) {
- command.insert( len , "\n" );
- len += maxlen +2;
- }
- question = i18n("Sorry, the copy back 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;
- } else {
- setCaption ( i18n( "Syncronization sucessfully completed" ) );
- }
- }
- }
- return;
-#if 0
- system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
- while ( timer.elapsed() < 5000 )
- qApp->processEvents();
-
- qDebug("MainWindow::merging) ");
- mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
- while ( mBlockSaveFlag )
- qApp->processEvents();
- save();
- system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
-#endif
-
-}
-
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;
};
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()) );
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 4da371e..ba627b9 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -100,111 +100,109 @@ 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 slotSyncMenu( int );
- void syncSSH();
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 performQuickQuick();
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;
void closeEvent( QCloseEvent* ce );
SimpleAlarmClient mAlarmClient;
QTimer mSaveTimer;
bool mBlockSaveFlag;
bool mCalendarModifiedFlag;
QPixmap loadPixmap( QString );
QDialog * mSyncActionDialog;
};
#endif
diff --git a/libkcal/calstorage.h b/libkcal/calstorage.h
index 72972ea..82c8682 100644
--- a/libkcal/calstorage.h
+++ b/libkcal/calstorage.h
@@ -1,52 +1,52 @@
/*
This file is part of libkcal.
Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KCAL_CALSTORAGE_H
#define KCAL_CALSTORAGE_H
namespace KCal {
class Calendar;
/**
This class provides the interface to the storage of a calendar.
*/
class CalStorage
{
public:
CalStorage( Calendar *calendar )
{
mCalendar = calendar;
}
virtual ~CalStorage() {}
Calendar *calendar() const { return mCalendar; }
virtual bool open() = 0;
- virtual bool load(bool = false ) = 0;
+ virtual bool load( ) = 0;
virtual bool save() = 0;
virtual bool close() = 0;
private:
Calendar *mCalendar;
};
}
#endif
diff --git a/libkcal/filestorage.cpp b/libkcal/filestorage.cpp
index 00c15d9..a139124 100644
--- a/libkcal/filestorage.cpp
+++ b/libkcal/filestorage.cpp
@@ -31,107 +31,107 @@
#include "vcalformat.h"
#include "icalformat.h"
#include "filestorage.h"
using namespace KCal;
FileStorage::FileStorage( Calendar *cal, const QString &fileName,
CalFormat *format )
: CalStorage( cal ),
mFileName( fileName ),
mSaveFormat( format )
{
}
FileStorage::~FileStorage()
{
delete mSaveFormat;
}
void FileStorage::setFileName( const QString &fileName )
{
mFileName = fileName;
}
QString FileStorage::fileName()const
{
return mFileName;
}
void FileStorage::setSaveFormat( CalFormat *format )
{
delete mSaveFormat;
mSaveFormat = format;
}
CalFormat *FileStorage::saveFormat()const
{
return mSaveFormat;
}
bool FileStorage::open()
{
return true;
}
-bool FileStorage::load( bool quick )
+bool FileStorage::load( )
{
kdDebug(5800) << "FileStorage::load(): '" << mFileName << "'" << endl;
// do we want to silently accept this, or make some noise? Dunno...
// it is a semantical thing vs. a practical thing.
if (mFileName.isEmpty()) return false;
// Always try to load with iCalendar. It will detect, if it is actually a
// vCalendar file.
- ICalFormat iCal (quick );
+ ICalFormat iCal;
bool success = iCal.load( calendar(), mFileName);
if ( !success ) {
if ( iCal.exception() ) {
// kdDebug(5800) << "---Error: " << mFormat->exception()->errorCode() << endl;
if ( iCal.exception()->errorCode() == ErrorFormat::CalVersion1 ) {
// Expected non vCalendar file, but detected vCalendar
kdDebug(5800) << "FileStorage::load() Fallback to VCalFormat" << endl;
VCalFormat vCal;
success = vCal.load( calendar(), mFileName );
calendar()->setLoadedProductId( vCal.productId() );
} else {
return false;
}
} else {
kdDebug(5800) << "Warning! There should be set an exception." << endl;
return false;
}
} else {
// kdDebug(5800) << "---Success" << endl;
calendar()->setLoadedProductId( iCal.loadedProductId() );
}
calendar()->setModified( false );
return true;
}
bool FileStorage::save()
{
if ( mFileName.isEmpty() ) return false;
bool success;
if ( mSaveFormat ) {
success = mSaveFormat->save( calendar(), mFileName);
} else {
ICalFormat iCal;
success = iCal.save( calendar(), mFileName);
}
if ( success ) calendar()->setModified( false );
return success;
}
bool FileStorage::close()
diff --git a/libkcal/filestorage.h b/libkcal/filestorage.h
index e9dc15e..17010ac 100644
--- a/libkcal/filestorage.h
+++ b/libkcal/filestorage.h
@@ -1,58 +1,58 @@
/*
This file is part of libkcal.
Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KCAL_FILESTORAGE_H
#define KCAL_FILESTORAGE_H
#include "calstorage.h"
namespace KCal {
/**
This class provides a calendar storage as a local file.
*/
class FileStorage : public CalStorage
{
public:
FileStorage( Calendar *, const QString &fileName = QString::null,
CalFormat *format = 0 );
virtual ~FileStorage();
void setFileName( const QString &mFileName );
QString fileName()const;
/**
FileStorage takes ownership of format object.
*/
void setSaveFormat( CalFormat * );
CalFormat *saveFormat()const;
bool open();
- bool load(bool quick = false );
+ bool load( );
bool save();
bool close();
private:
QString mFileName;
CalFormat *mSaveFormat;
};
}
#endif
diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp
index f2e7dfc..3a2aac6 100644
--- a/libkcal/icalformat.cpp
+++ b/libkcal/icalformat.cpp
@@ -5,170 +5,150 @@
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qdatetime.h>
#include <qstring.h>
#include <qptrlist.h>
#include <qregexp.h>
#include <qclipboard.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qtextcodec.h>
#include <stdlib.h>
#include <kdebug.h>
#include <kglobal.h>
#include <klocale.h>
extern "C" {
#include <ical.h>
#include <icalss.h>
#include <icalparser.h>
#include <icalrestriction.h>
}
#include "calendar.h"
#include "calendarlocal.h"
#include "journal.h"
#include "icalformat.h"
#include "icalformatimpl.h"
#define _ICAL_VERSION "2.0"
using namespace KCal;
-ICalFormat::ICalFormat(bool quick )
+ICalFormat::ICalFormat( )
{
- mQuicksave = false; //quick;
mImpl = new ICalFormatImpl( this );
tzOffsetMin = 0;
//qDebug("new ICalFormat() ");
}
ICalFormat::~ICalFormat()
{
delete mImpl;
//qDebug("delete ICalFormat ");
}
bool ICalFormat::load( Calendar *calendar, const QString &fileName)
{
clearException();
QFile file( fileName );
if (!file.open( IO_ReadOnly ) ) {
setException(new ErrorFormat(ErrorFormat::LoadError));
return false;
}
QTextStream ts( &file );
QString text;
-#if 0
- if ( !mQuicksave ) {
- qDebug("KO: No quickload!");
- ts.setEncoding( QTextStream::Latin1 );
- text = ts.read();
- } else {
- ts.setCodec( QTextCodec::codecForName("utf8") );
- text = ts.read();
- }
-#endif
+
ts.setEncoding( QTextStream::Latin1 );
text = ts.read();
file.close();
return fromString( calendar, text );
}
//#include <qdatetime.h>
bool ICalFormat::save( Calendar *calendar, const QString &fileName )
{
//kdDebug(5800) << "ICalFormat::save(): " << fileName << endl;
//qDebug("ICalFormat::save ");
clearException();
QString text = toString( calendar );
//return false;
// qDebug("to string takes ms: %d ",is.elapsed() );
if ( text.isNull() ) return false;
// TODO: write backup file
//is.restart();
QFile file( fileName );
if (!file.open( IO_WriteOnly ) ) {
setException(new ErrorFormat(ErrorFormat::SaveError,
i18n("Could not open file '%1'").arg(fileName)));
return false;
}
QTextStream ts( &file );
-// #ifdef DESKTOP_VERSION
-// mQuicksave = false;
-// #endif
-// if ( mQuicksave ) {
-// ts << text.utf8();
-// } else {
-// ts.setEncoding( QTextStream::Latin1 );
-// ts << text;
-// //ts << text.latin1();
-// }
ts.setEncoding( QTextStream::Latin1 );
ts << text;
file.close();
//qDebug("saving file takes ms: %d ", is.elapsed() );
return true;
}
bool ICalFormat::fromString( Calendar *cal, const QString &text )
{
setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
// qDebug("ICalFormat::fromString tz: %s ", cal->timeZoneId().latin1());
// Get first VCALENDAR component.
// TODO: Handle more than one VCALENDAR or non-VCALENDAR top components
icalcomponent *calendar;
//calendar = icalcomponent_new_from_string( text.local8Bit().data());
// good calendar = icalcomponent_new_from_string( text.utf8().data());
calendar = icalcomponent_new_from_string( (char*)text.latin1());
if (!calendar) {
setException(new ErrorFormat(ErrorFormat::ParseErrorIcal));
return false;
}
bool success = true;
if (icalcomponent_isa(calendar) != ICAL_VCALENDAR_COMPONENT) {
setException(new ErrorFormat(ErrorFormat::NoCalendar));
success = false;
} else {
// put all objects into their proper places
if ( !mImpl->populate( cal, calendar ) ) {
if ( !exception() ) {
setException(new ErrorFormat(ErrorFormat::ParseErrorKcal));
}
success = false;
} else
mLoadedProductId = mImpl->loadedProductId();
}
icalcomponent_free( calendar );
return success;
}
Incidence *ICalFormat::fromString( const QString &text )
{
CalendarLocal cal( mTimeZoneId );
fromString(&cal, text);
diff --git a/libkcal/icalformat.h b/libkcal/icalformat.h
index 236efbf..485ab6e 100644
--- a/libkcal/icalformat.h
+++ b/libkcal/icalformat.h
@@ -1,116 +1,115 @@
/*
This file is part of libkcal.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ICALFORMAT_H
#define ICALFORMAT_H
#include <qstring.h>
#include "scheduler.h"
#include "calformat.h"
namespace KCal {
class ICalFormatImpl;
/**
This class implements the iCalendar format. It provides methods for
loading/saving/converting iCalendar format data into the internal KOrganizer
representation as Calendar and Events.
@short iCalendar format implementation
*/
class ICalFormat : public CalFormat {
public:
/** Create new iCalendar format. */
- ICalFormat( bool quick = false );
+ ICalFormat( );
virtual ~ICalFormat();
/**
Loads a calendar on disk in iCalendar format into calendar.
Returns true if successful, else returns false. Provides more error
information by exception().
@param calendar Calendar object to be filled.
@param fileName The name of the calendar file on disk.
*/
bool load( Calendar *, const QString &fileName );
/**
Writes out the calendar to disk in iCalendar format. Returns true if
successful and false on error.
@param calendar The Calendar object to be written.
@param fileName The name of the calendar file on disk.
*/
bool save( Calendar *, const QString &fileName );
/**
Parse string and populate calendar with that information.
*/
bool fromString( Calendar *, const QString & );
/**
Parse string and return first ical component.
*/
Incidence *fromString( const QString & );
/**
Return calendar information as string.
*/
QString toString( Calendar * );
/**
Return incidence as full iCalendar formatted text.
*/
QString toICalString( Incidence * );
/**
Return incidence as iCalendar formatted text.
*/
QString toString( Incidence * );
/**
Return recurrence as iCalendar formatted text.
*/
QString toString( Recurrence * );
/**
Parse string and fill recurrence object with
that information
*/
//bool fromString ( Recurrence *, const QString& );
/** Create a scheduling message for event \a e using method \m */
QString createScheduleMessage(IncidenceBase *e,Scheduler::Method m);
/** Parse scheduling message provided as string \s */
ScheduleMessage *parseScheduleMessage( Calendar *, const QString &s);
/** Set id of used time zone and whether this time zone is UTC or not. */
void setTimeZone( const QString &id, bool utc );
QString timeZoneId() const;
int timeOffset();
const char * tzString();
bool utc() const;
private:
ICalFormatImpl *mImpl;
- bool mQuicksave;
QString mTimeZoneId;
QCString mTzString;
int tzOffsetMin;
bool mUtc;
};
}
#endif