summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp2
-rw-r--r--libkcal/calendar.h1
-rw-r--r--libkcal/calendarlocal.cpp25
-rw-r--r--libkcal/calendarlocal.h1
-rw-r--r--libkdepim/ksyncmanager.cpp5
5 files changed, 29 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 307027a..e45240a 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1611,97 +1611,97 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
//QPtrList<Event> el = local->rawEvents();
Event* eventR;
QString uid;
int take;
Event* eventRSync;
Event* eventLSync;
clearAllViews();
QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
bool fullDateRange = false;
local->resetTempSyncStat();
mLastCalendarSync = QDateTime::currentDateTime();
if ( mSyncManager->syncWithDesktop() ) {
remote->resetPilotStat(1);
if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
} else {
qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
}
}
QDateTime modifiedCalendar = mLastCalendarSync;
eventLSync = getLastSyncEvent();
eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
if ( eventR ) {
qDebug("last-syncEvent on remote found ");
eventRSync = (Event*) eventR->clone();
remote->deleteEvent(eventR );
} else {
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
eventRSync = (Event*)eventLSync->clone();
} else {
fullDateRange = true;
eventRSync = new Event();
eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
eventRSync->setDtStart( mLastCalendarSync );
eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
eventRSync->setCategories( i18n("SyncEvent") );
}
}
if ( eventLSync->dtStart() == mLastCalendarSync )
fullDateRange = true;
if ( ! fullDateRange ) {
if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
- qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
+ qDebug("KO: Sync: Set fulldate to true! Local: %s --- Remote: %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
//qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
fullDateRange = true;
}
}
if ( mSyncManager->syncWithDesktop() ) {
fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
}
if ( fullDateRange )
mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
else
mLastCalendarSync = eventLSync->dtStart();
// for resyncing if own file has changed
if ( mCurrentSyncDevice == "deleteaftersync" ) {
mLastCalendarSync = loadedFileVersion;
//qDebug("setting mLastCalendarSync ");
}
//qDebug("*************************** ");
qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
QPtrList<Incidence> er = remote->rawIncidences();
Incidence* inR = er.first();
Incidence* inL;
QProgressBar bar( er.count(),0 );
bar.setCaption (i18n("Syncing - close to abort!") );
// ************** setting up filter *************
CalFilter *filterIN = 0;
CalFilter *filterOUT = 0;
CalFilter *filter = mFilters.first();
while(filter) {
if ( filter->name() == mSyncManager->mFilterInCal )
filterIN = filter;
if ( filter->name() == mSyncManager->mFilterOutCal )
filterOUT = filter;
filter = mFilters.next();
}
int w = 300;
if ( QApplication::desktop()->width() < 320 )
w = 220;
int h = bar.sizeHint().height() ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
bar.show();
int modulo = (er.count()/10)+1;
int incCounter = 0;
while ( inR ) {
if ( ! bar.isVisible() )
return false;
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 0a94914..66836a1 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -271,96 +271,97 @@ public:
Remove all relations to an incidence
*/
virtual void removeRelations( Incidence * );
/**
Set calendar filter, which filters events for the events() functions.
The Filter object is owned by the caller.
*/
void setFilter( CalFilter * );
/**
Return calendar filter.
*/
CalFilter *filter();
virtual QDateTime nextAlarm( int daysTo ) = 0;
virtual QString nextSummary( ) const = 0;
virtual void reInitAlarmSettings() = 0;
virtual QDateTime nextAlarmEventDateTime() const = 0;
virtual void checkAlarmForIncidence( Incidence *, bool ) = 0;
/**
Return all alarms, which ocur in the given time interval.
*/
virtual Alarm::List alarms( const QDateTime &from,
const QDateTime &to ) = 0;
class Observer {
public:
virtual void calendarModified( bool, Calendar * ) = 0;
};
void registerObserver( Observer * );
void setModified( bool );
/**
Set product id returned by loadedProductId(). This function is only
useful for the calendar loading code.
*/
void setLoadedProductId( const QString & );
/**
Return product id taken from file that has been loaded. Returns
QString::null, if no calendar has been loaded.
*/
QString loadedProductId();
int defaultCalendar();
void setDontDeleteIncidencesOnClose ();
public slots:
void setDefaultCalendar( int );
virtual void setCalendarEnabled( int id, bool enable ) = 0;
+ virtual void setAllCalendarEnabled( bool enable ) = 0;
virtual void setAlarmEnabled( int id, bool enable ) = 0;
virtual void setReadOnly( int id, bool enable ) = 0;
virtual void setDefaultCalendarEnabledOnly() = 0;
virtual void setCalendarRemove( int id ) = 0;
virtual void getIncidenceCount( int calId, int& events, int & todos, int & journals) = 0;
signals:
void calendarChanged();
void calendarSaved();
void calendarLoaded();
void addAlarm(const QDateTime &qdt, const QString &noti );
void removeAlarm(const QDateTime &qdt, const QString &noti );
protected:
/**
Get unfiltered events, which occur on the given date.
*/
virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0;
/**
Get unfiltered events, which occur on the given date.
*/
virtual QPtrList<Event> rawEventsForDate( const QDate &date,
bool sorted = false ) = 0;
/**
Get events in a range of dates. If inclusive is set to true, only events
are returned, which are completely included in the range.
*/
virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
bool inclusive = false ) = 0;
Incidence *mNextAlarmIncidence;
Incidence *mUndoIncidence;
int mDefaultCalendar;
bool mDeleteIncidencesOnClose;
private:
void init();
QString mOwner; // who the calendar belongs to
QString mOwnerEmail; // email address of the owner
int mTimeZone; // timezone OFFSET from GMT (MINUTES)
bool mLocalTime; // use local time, not UTC or a time zone
CalFilter *mFilter;
CalFilter *mDefaultFilter;
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 45e3128..2a57724 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -145,113 +145,123 @@ bool CalendarLocal::mergeCalendar( Calendar* remote )
while ( inR ) {
inL = incidenceForUid( inR->uid(),false );
if ( inL ) {
if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) {
int calID = inL->calID();
deleteIncidence( inL );
inL = inR->clone();
inL->setCalID( calID );
addIncidence( inL );
}
} else {
inL = inR->clone();
inL->setCalID( 0 );// add to default cal
addIncidence( inL );
}
inR = er.next();
}
return true;
}
bool CalendarLocal::addCalendarFile( QString name, int id )
{
CalendarLocal calendar( timeZoneId() );
calendar.setDefaultCalendar( id );
if ( calendar.load( name ) ) {
addCalendar( &calendar );
return true;
}
return false;
}
void CalendarLocal::setSyncEventsEnabled()
{
Event * ev;
ev = mEventList.first();
while ( ev ) {
if ( ev->uid().left(15) == QString("last-syncEvent-") )
ev->setCalEnabled( true );
ev = mEventList.next();
}
}
void CalendarLocal::setSyncEventsReadOnly()
{
Event * ev;
ev = mEventList.first();
while ( ev ) {
if ( ev->uid().left(15) == QString("last-syncEvent-") ) {
ev->setReadOnly( true );
- ev->setCalID( 1 );
}
ev = mEventList.next();
}
}
+
void CalendarLocal::addCalendar( Calendar* cal )
{
cal->setDontDeleteIncidencesOnClose();
+ setSyncEventsEnabled();
{
QPtrList<Event> EventList = cal->rawEvents();
+ QPtrList<Event> el;
Event * ev = EventList.first();
while ( ev ) {
+ if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) {
+ Event * se = event( ev->uid() );
+ if ( se )
+ el.append( se );
+ }
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mEventList.append( ev );
ev = EventList.next();
}
+ for ( ev = el.first(); ev; ev = el.next() ) {
+ deleteIncidence ( ev );
+ }
}
{
QPtrList<Todo> TodoList = cal->rawTodos();
Todo * ev = TodoList.first();
while ( ev ) {
QString rel = ev->relatedToUid();
if ( !rel.isEmpty() ){
ev->setRelatedTo ( 0 );
ev->setRelatedToUid( rel );
}
ev = TodoList.next();
}
//TodoList = cal->rawTodos();
ev = TodoList.first();
while ( ev ) {
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mTodoList.append( ev );
setupRelations( ev );
ev = TodoList.next();
}
}
{
QPtrList<Journal> JournalList = cal->journals();
Journal * ev = JournalList.first();
while ( ev ) {
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mJournalList.append( ev );
ev = JournalList.next();
}
}
setModified( true );
}
bool CalendarLocal::load( const QString &fileName )
{
FileStorage storage( this, fileName );
return storage.load();
}
bool CalendarLocal::save( const QString &fileName, CalFormat *format )
{
FileStorage storage( this, fileName, format );
return storage.save();
}
void CalendarLocal::stopAllTodos()
@@ -958,96 +968,109 @@ Journal *CalendarLocal::journal( const QString &uid )
}
}
return retVal;
}
QPtrList<Journal> CalendarLocal::journals()
{
QPtrList<Journal> el;
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
if ( it->calEnabled() ) el.append( it );
return el;
}
void CalendarLocal::setCalendarRemove( int id )
{
{
QPtrList<Event> EventList = mEventList;
Event * ev = EventList.first();
while ( ev ) {
if ( ev->calID() == id )
deleteEvent( ev );
ev = EventList.next();
}
}
{
QPtrList<Todo> TodoList = mTodoList;
Todo * ev = TodoList.first();
while ( ev ) {
if ( ev->calID() == id )
deleteTodo( ev );
ev = TodoList.next();
}
}
{
QPtrList<Journal> JournalList = mJournalList;
Journal * ev = JournalList.first();
while ( ev ) {
if ( ev->calID() == id )
deleteJournal( ev );
ev = JournalList.next();
}
}
clearUndo(0);
}
+void CalendarLocal::setAllCalendarEnabled( bool enable )
+{
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ it->setCalEnabled( enable );
+
+ for ( Event *it = mEventList.first(); it; it = mEventList.next() )
+ it->setCalEnabled( enable );
+
+ for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
+ it->setCalEnabled( enable );
+
+
+}
void CalendarLocal::setCalendarEnabled( int id, bool enable )
{
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
if ( it->calID() == id ) it->setCalEnabled( enable );
for ( Event *it = mEventList.first(); it; it = mEventList.next() )
if ( it->calID() == id ) it->setCalEnabled( enable );
for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
if ( it->calID() == id ) it->setCalEnabled( enable );
}
void CalendarLocal::setReadOnly( int id, bool enable )
{
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
if ( it->calID() == id ) it->setReadOnly( enable );
for ( Event *it = mEventList.first(); it; it = mEventList.next() )
if ( it->calID() == id ) it->setReadOnly( enable );
for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
if ( it->calID() == id ) it->setReadOnly( enable );
}
void CalendarLocal::setAlarmEnabled( int id, bool enable )
{
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
if ( it->calID() == id ) it->setAlarmEnabled( enable );
for ( Event *it = mEventList.first(); it; it = mEventList.next() )
if ( it->calID() == id ) it->setAlarmEnabled( enable );
for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
if ( it->calID() == id ) it->setAlarmEnabled( enable );
reInitAlarmSettings();
}
void CalendarLocal::setDefaultCalendarEnabledOnly()
{
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
it->setCalEnabled( it->calID() == mDefaultCalendar );
for ( Event *it = mEventList.first(); it; it = mEventList.next() )
it->setCalEnabled( it->calID() == mDefaultCalendar);
for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index eb7bf34..b70f0c9 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -149,84 +149,85 @@ class CalendarLocal : public Calendar
Return all alarms, which ocur in the given time interval.
*/
Alarm::List alarms( const QDateTime &from, const QDateTime &to );
/**
Return all alarms, which ocur before given date.
*/
Alarm::List alarmsTo( const QDateTime &to );
QDateTime nextAlarm( int daysTo ) ;
QDateTime nextAlarmEventDateTime() const;
void checkAlarmForIncidence( Incidence *, bool deleted ) ;
void registerAlarm();
void deRegisterAlarm();
QString getAlarmNotification();
QString nextSummary() const ;
/**
This method should be called whenever a Event is modified directly
via it's pointer. It makes sure that the calendar is internally
consistent.
*/
void update( IncidenceBase *incidence );
/**
Builds and then returns a list of all events that match for the
date specified. useful for dayView, etc. etc.
*/
QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false );
/**
Get unfiltered events for date \a qdt.
*/
QPtrList<Event> rawEventsForDate( const QDateTime &qdt );
/**
Get unfiltered events in a range of dates. If inclusive is set to true,
only events are returned, which are completely included in the range.
*/
QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
bool inclusive = false );
Todo *todo( QString, QString );
Event *event( QString, QString );
void getIncidenceCount( int calId, int& events, int & todos, int & journals);
public slots:
void setCalendarEnabled( int id, bool enable );
void setAlarmEnabled( int id, bool enable );
void setReadOnly( int id, bool enable );
void setDefaultCalendarEnabledOnly();
void setCalendarRemove( int id );
+ void setAllCalendarEnabled( bool enable );
protected:
// Event* mNextAlarmEvent;
QString mNextSummary;
QString mNextAlarmEventDateTimeString;
QString mLastAlarmNotificationString;
QDateTime mNextAlarmEventDateTime;
QDateTime mNextAlarmDateTime;
void reInitAlarmSettings();
/** Notification function of IncidenceBase::Observer. */
void incidenceUpdated( IncidenceBase *i ) { update( i ); }
/** inserts an event into its "proper place" in the calendar. */
void insertEvent( Event *event );
/** Append alarms of incidence in interval to list of alarms. */
void appendAlarms( Alarm::List &alarms, Incidence *incidence,
const QDateTime &from, const QDateTime &to );
/** Append alarms of recurring events in interval to list of alarms. */
void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence,
const QDateTime &from, const QDateTime &to );
private:
void init();
QPtrList<Event> mEventList;
QPtrList<Todo> mTodoList;
QPtrList<Journal> mJournalList;
};
}
#endif
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 795cd30..d2cb71b 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1095,115 +1095,114 @@ bool KSyncManager::isProgressBarCanceled()
return !bar->isVisible();
}
QString KSyncManager::syncFileName()
{
QString fn = "tempfile";
switch(mTargetApp)
{
case (KAPI):
fn = "tempsyncab.vcf";
break;
case (KOPI):
fn = "tempsynccal.ics";
break;
case (PWMPI):
fn = "tempsyncpw.pwm";
break;
default:
break;
}
#ifdef DESKTOP_VERSION
return locateLocal( "tmp", fn );
#else
return (QString( "/tmp/" )+ fn );
#endif
}
void KSyncManager::syncPi()
{
mIsKapiFile = true;
mPisyncFinished = false;
qApp->processEvents();
if ( mAskForPreferences )
if ( !edit_pisync_options()) {
mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
mPisyncFinished = true;
return;
}
bool ok;
Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
if ( ! ok ) {
mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
mPisyncFinished = true;
return;
}
mCurrentResourceLocal = "";
mCurrentResourceRemote = "";
- qDebug ( "KSM: sync pi %d",mSpecificResources.count() );
if ( mSpecificResources.count() ) {
int lastSyncRes = mSpecificResources.count()/2;
int ccc = mSpecificResources.count()-1;
while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) {
--ccc;
--lastSyncRes;
- qDebug ( "KSM: sync pi %d",ccc );
+ //qDebug ( "KSM: sync pi %d",ccc );
}
int startLocal = 0;
int startRemote = mSpecificResources.count()/2;
emit multiResourceSyncStart( true );
while ( startLocal < mSpecificResources.count()/2 ) {
if ( startLocal+1 >= lastSyncRes )
emit multiResourceSyncStart( false );
mPisyncFinished = false;
mCurrentResourceLocal = mSpecificResources[ startLocal ];
mCurrentResourceRemote = mSpecificResources[ startRemote ];
- qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
+ //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
if ( !mCurrentResourceRemote.isEmpty() ) {
qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
commandSocket->readFile( syncFileName() );
while ( !mPisyncFinished ) {
//qDebug("waiting ");
qApp->processEvents();
}
}
++startRemote;
++startLocal;
}
mPisyncFinished = true;
} else {
KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
commandSocket->readFile( syncFileName() );
}
}
void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
{
//enum { success, errorW, errorR, quiet };
if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) {
if ( state == KCommandSocket::errorPW )
mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
else if ( state == KCommandSocket::errorCA )
mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
else if ( state == KCommandSocket::errorFI )
mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
else if ( state == KCommandSocket::errorED )
mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") );
else if ( state == KCommandSocket::errorUN )
mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
delete s;
if ( state == KCommandSocket::errorR ) {
KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
commandSocket->sendStop();
}
mPisyncFinished = true;