KCal::Journal* ResourceKolab::addNote( const QString& data, const QString& subresource, quint32 sernum, const QString &mimetype ) { KCal::Journal* journal = 0; // FIXME: This does not take into account the time zone! KCal::ICalFormat formatter; if ( mimetype == attachmentMimeType ) journal = Note::xmlToJournal( data ); else journal = static_cast<KCal::Journal*>( formatter.fromString( data ) ); Q_ASSERT( journal ); if( journal && !mUidMap.contains( journal->uid() ) ) { if ( addNote( journal, subresource, sernum ) ) return journal; else delete journal; } else if ( journal && mUidMap.contains( journal->uid() ) ) { //For debugging kDebug( 5500 ) << "mUidMap already contains" << journal->uid(); } return 0; }
QString KNotesApp::newNote( const QString& name, const QString& text ) { // create the new note KCal::Journal *journal = new KCal::Journal(); // new notes have the current date/time as title if none was given if ( !name.isEmpty() ) journal->setSummary( name ); else journal->setSummary( KGlobal::locale()->formatDateTime( QDateTime::currentDateTime() ) ); // the body of the note journal->setDescription( text ); m_manager->addNewNote( journal ); showNote( journal->uid() ); return journal->uid(); }
void ResourceKolab::incidenceUpdated( KCal::IncidenceBase* i ) { QString subResource; quint32 sernum; if ( mUidMap.contains( i->uid() ) ) { subResource = mUidMap[ i->uid() ].resource(); sernum = mUidMap[ i->uid() ].serialNumber(); } else { // can this happen? subResource = findWritableResource( mSubResources ); if ( subResource.isEmpty() ) // canceled return; sernum = 0; } KCal::Journal* journal = static_cast<KCal::Journal*>( i ); QString xml = Note::journalToXML( journal ); if( !xml.isEmpty() && kmailUpdate( subResource, sernum, xml, attachmentMimeType, journal->uid() ) ) mUidMap[ i->uid() ] = StorageReference( subResource, sernum ); }