summaryrefslogtreecommitdiffstats
path: root/knotes/resourcemanager.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-01 00:37:02 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-01 00:37:02 +0000
commitcc29364f06178f8f6b457384f2ec37a042bd9d43 (patch)
tree7c77a3184c698bbf9d98cef09fb1ba8124daceba /knotes/resourcemanager.cpp
parent4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff)
downloadtdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz
tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip
* Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch
* Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed * Added journal read support to the CalDAV resource * Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'knotes/resourcemanager.cpp')
-rw-r--r--knotes/resourcemanager.cpp48
1 files changed, 33 insertions, 15 deletions
diff --git a/knotes/resourcemanager.cpp b/knotes/resourcemanager.cpp
index 112ec03f8..226d90005 100644
--- a/knotes/resourcemanager.cpp
+++ b/knotes/resourcemanager.cpp
@@ -64,6 +64,11 @@ void KNotesResourceManager::load()
KRES::Manager<ResourceNotes>::ActiveIterator it;
for ( it = m_manager->activeBegin(); it != m_manager->activeEnd(); ++it )
{
+ if ( (*it)->isOpen() ) {
+ kdDebug(5500) << (*it)->resourceName() << " is already open" << endl;
+ continue;
+ }
+
kdDebug(5500) << "Opening resource " + (*it)->resourceName() << endl;
(*it)->setManager( this );
if ( (*it)->open() )
@@ -80,17 +85,19 @@ void KNotesResourceManager::save()
// when adding a new note, make sure a config file exists!!
-void KNotesResourceManager::addNewNote( KCal::Journal *journal )
+bool KNotesResourceManager::addNewNote( KCal::Journal *journal )
{
// TODO: Make this configurable
ResourceNotes *resource = m_manager->standardResource();
- if ( resource )
- {
- resource->addNote( journal );
- registerNote( resource, journal );
- }
- else
+ if ( resource ) {
+ if ( resource->addNote( journal ) ) {
+ registerNote( resource, journal );
+ return true;
+ }
+ } else {
kdWarning(5500) << k_funcinfo << "no resource!" << endl;
+ }
+ return false;
}
void KNotesResourceManager::registerNote( ResourceNotes *resource,
@@ -103,15 +110,21 @@ void KNotesResourceManager::registerNote( ResourceNotes *resource,
void KNotesResourceManager::deleteNote( KCal::Journal *journal )
{
+ if ( !journal )
+ return;
+
TQString uid = journal->uid();
// Remove the journal from the resource it came from
- m_resourceMap[ uid ]->deleteNote( journal );
- m_resourceMap.remove( uid );
-
- // libkcal does not delete the journal immediately, therefore it is ok to
- // emit the journal here
- emit sigDeregisteredNote( journal );
+ ResourceNotes *res = m_resourceMap[ uid ];
+ if ( res ) {
+ res->deleteNote( journal );
+ m_resourceMap.remove( uid );
+
+ // libkcal does not delete the journal immediately, therefore it is ok to
+ // emit the journal here
+ emit sigDeregisteredNote( journal );
+ }
}
KCal::Alarm::List KNotesResourceManager::alarms( const TQDateTime& from, const TQDateTime& to )
@@ -122,8 +135,8 @@ KCal::Alarm::List KNotesResourceManager::alarms( const TQDateTime& from, const T
for ( it = m_manager->activeBegin(); it != m_manager->activeEnd(); ++it )
{
KCal::Alarm::List list = (*it)->alarms( from, to );
- KCal::Alarm::List::Iterator it;
- for ( it = list.begin(); it != list.end(); ++it )
+ KCal::Alarm::List::ConstIterator it;
+ for ( it = list.constBegin(); it != list.constEnd(); ++it )
result.append( *it );
}
@@ -137,6 +150,11 @@ void KNotesResourceManager::resourceAdded( ResourceNotes *resource )
if ( !resource->isActive() )
return;
+ if ( resource->isOpen() ) {
+ kdDebug(5500) << resource->resourceName() << " is already open" << endl;
+ return;
+ }
+
resource->setManager( this );
if ( resource->open() )
resource->load();