tdepim: various changes

Submitted by deloptes via private email.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
This commit is contained in:
deloptes 2020-12-06 11:21:54 +01:00 committed by Patrick Ohly
parent a6b490ef83
commit 57d357afee
14 changed files with 117 additions and 482 deletions

View file

@ -1,69 +0,0 @@
<!DOCTYPE DCOP-IDL><DCOP-IDL>
<SOURCE>/opt/software_x64/KDE/TDE/tdepim/knotes/KNotesIface.h</SOURCE>
<INCLUDE>tqstring.h</INCLUDE>
<INCLUDE>tqdatetime.h</INCLUDE>
<INCLUDE>tqmap.h</INCLUDE>
<INCLUDE>dcopobject.h</INCLUDE>
<CLASS>
<NAME>KNotesIface</NAME>
<SUPER>DCOPObject</SUPER>
<FUNC>
<TYPE>TQString</TYPE>
<NAME>newNote</NAME>
<ARG><TYPE qleft="const" qright="&amp;">TQString</TYPE><NAME>name</NAME></ARG>
<ARG><TYPE qleft="const" qright="&amp;">TQString</TYPE><NAME>text</NAME></ARG>
</FUNC>
<FUNC>
<TYPE>TQString</TYPE>
<NAME>newNoteFromClipboard</NAME>
<ARG><TYPE qleft="const" qright="&amp;">TQString</TYPE><NAME>name</NAME></ARG>
</FUNC>
<FUNC>
<TYPE>ASYNC</TYPE>
<NAME>killNote</NAME>
<ARG><TYPE qleft="const" qright="&amp;">TQString</TYPE><NAME>noteId</NAME></ARG>
</FUNC>
<FUNC>
<TYPE>ASYNC</TYPE>
<NAME>killNote</NAME>
<ARG><TYPE qleft="const" qright="&amp;">TQString</TYPE><NAME>noteId</NAME></ARG>
<ARG><TYPE>bool</TYPE><NAME>force</NAME></ARG>
</FUNC>
<FUNC qual="const">
<TYPE>TQMap&lt;TQString,TQString&gt;</TYPE>
<NAME>notes</NAME>
</FUNC>
<FUNC>
<TYPE>ASYNC</TYPE>
<NAME>setName</NAME>
<ARG><TYPE qleft="const" qright="&amp;">TQString</TYPE><NAME>noteId</NAME></ARG>
<ARG><TYPE qleft="const" qright="&amp;">TQString</TYPE><NAME>newName</NAME></ARG>
</FUNC>
<FUNC>
<TYPE>ASYNC</TYPE>
<NAME>setText</NAME>
<ARG><TYPE qleft="const" qright="&amp;">TQString</TYPE><NAME>noteId</NAME></ARG>
<ARG><TYPE qleft="const" qright="&amp;">TQString</TYPE><NAME>newText</NAME></ARG>
</FUNC>
<FUNC qual="const">
<TYPE>TQString</TYPE>
<NAME>name</NAME>
<ARG><TYPE qleft="const" qright="&amp;">TQString</TYPE><NAME>noteId</NAME></ARG>
</FUNC>
<FUNC qual="const">
<TYPE>TQString</TYPE>
<NAME>text</NAME>
<ARG><TYPE qleft="const" qright="&amp;">TQString</TYPE><NAME>noteId</NAME></ARG>
</FUNC>
<FUNC qual="const">
<TYPE>int</TYPE>
<NAME>getRevision</NAME>
<ARG><TYPE qleft="const" qright="&amp;">TQString</TYPE><NAME>noteId</NAME></ARG>
</FUNC>
<FUNC qual="const">
<TYPE>TQDateTime</TYPE>
<NAME>getLastModified</NAME>
<ARG><TYPE qleft="const" qright="&amp;">TQString</TYPE><NAME>noteId</NAME></ARG>
</FUNC>
</CLASS>
</DCOP-IDL>

View file

@ -1,259 +0,0 @@
/****************************************************************************
**
** DCOP Stub Implementation created by dcopidl2cpp from KNotesIface.kidl
**
** WARNING! All changes made in this file will be lost!
**
*****************************************************************************/
#include "KNotesIface_stub.h"
#include <dcopclient.h>
#include <kdatastream.h>
KNotesIface_stub::KNotesIface_stub( const TQCString& app, const TQCString& obj )
: DCOPStub( app, obj )
{
}
KNotesIface_stub::KNotesIface_stub( DCOPClient* client, const TQCString& app, const TQCString& obj )
: DCOPStub( client, app, obj )
{
}
KNotesIface_stub::KNotesIface_stub( const DCOPRef& ref )
: DCOPStub( ref )
{
}
TQString KNotesIface_stub::newNote( const TQString& arg0, const TQString& arg1 )
{
TQString result;
if ( !dcopClient() ) {
setStatus( CallFailed );
return result;
}
TQByteArray data, replyData;
TQCString replyType;
TQDataStream arg( data, IO_WriteOnly );
arg << arg0;
arg << arg1;
if ( dcopClient()->call( app(), obj(), "newNote(TQString,TQString)", data, replyType, replyData ) ) {
if ( replyType == "TQString" ) {
TQDataStream _reply_stream( replyData, IO_ReadOnly );
_reply_stream >> result;
setStatus( CallSucceeded );
} else {
callFailed();
}
} else {
callFailed();
}
return result;
}
TQString KNotesIface_stub::newNoteFromClipboard( const TQString& arg0 )
{
TQString result;
if ( !dcopClient() ) {
setStatus( CallFailed );
return result;
}
TQByteArray data, replyData;
TQCString replyType;
TQDataStream arg( data, IO_WriteOnly );
arg << arg0;
if ( dcopClient()->call( app(), obj(), "newNoteFromClipboard(TQString)", data, replyType, replyData ) ) {
if ( replyType == "TQString" ) {
TQDataStream _reply_stream( replyData, IO_ReadOnly );
_reply_stream >> result;
setStatus( CallSucceeded );
} else {
callFailed();
}
} else {
callFailed();
}
return result;
}
void KNotesIface_stub::killNote( const TQString& arg0 )
{
if ( !dcopClient() ) {
setStatus( CallFailed );
return;
}
TQByteArray data;
TQDataStream arg( data, IO_WriteOnly );
arg << arg0;
dcopClient()->send( app(), obj(), "killNote(TQString)", data );
setStatus( CallSucceeded );
}
void KNotesIface_stub::killNote( const TQString& arg0, bool arg1 )
{
if ( !dcopClient() ) {
setStatus( CallFailed );
return;
}
TQByteArray data;
TQDataStream arg( data, IO_WriteOnly );
arg << arg0;
arg << arg1;
dcopClient()->send( app(), obj(), "killNote(TQString,bool)", data );
setStatus( CallSucceeded );
}
TQMap<TQString,TQString> KNotesIface_stub::notes()
{
TQMap<TQString,TQString> result;
if ( !dcopClient() ) {
setStatus( CallFailed );
return result;
}
TQByteArray data, replyData;
TQCString replyType;
if ( dcopClient()->call( app(), obj(), "notes()", data, replyType, replyData ) ) {
if ( replyType == "TQMap<TQString,TQString>" ) {
TQDataStream _reply_stream( replyData, IO_ReadOnly );
_reply_stream >> result;
setStatus( CallSucceeded );
} else {
callFailed();
}
} else {
callFailed();
}
return result;
}
void KNotesIface_stub::setName( const TQString& arg0, const TQString& arg1 )
{
if ( !dcopClient() ) {
setStatus( CallFailed );
return;
}
TQByteArray data;
TQDataStream arg( data, IO_WriteOnly );
arg << arg0;
arg << arg1;
dcopClient()->send( app(), obj(), "setName(TQString,TQString)", data );
setStatus( CallSucceeded );
}
void KNotesIface_stub::setText( const TQString& arg0, const TQString& arg1 )
{
if ( !dcopClient() ) {
setStatus( CallFailed );
return;
}
TQByteArray data;
TQDataStream arg( data, IO_WriteOnly );
arg << arg0;
arg << arg1;
dcopClient()->send( app(), obj(), "setText(TQString,TQString)", data );
setStatus( CallSucceeded );
}
TQString KNotesIface_stub::name( const TQString& arg0 )
{
TQString result;
if ( !dcopClient() ) {
setStatus( CallFailed );
return result;
}
TQByteArray data, replyData;
TQCString replyType;
TQDataStream arg( data, IO_WriteOnly );
arg << arg0;
if ( dcopClient()->call( app(), obj(), "name(TQString)", data, replyType, replyData ) ) {
if ( replyType == "TQString" ) {
TQDataStream _reply_stream( replyData, IO_ReadOnly );
_reply_stream >> result;
setStatus( CallSucceeded );
} else {
callFailed();
}
} else {
callFailed();
}
return result;
}
TQString KNotesIface_stub::text( const TQString& arg0 )
{
TQString result;
if ( !dcopClient() ) {
setStatus( CallFailed );
return result;
}
TQByteArray data, replyData;
TQCString replyType;
TQDataStream arg( data, IO_WriteOnly );
arg << arg0;
if ( dcopClient()->call( app(), obj(), "text(TQString)", data, replyType, replyData ) ) {
if ( replyType == "TQString" ) {
TQDataStream _reply_stream( replyData, IO_ReadOnly );
_reply_stream >> result;
setStatus( CallSucceeded );
} else {
callFailed();
}
} else {
callFailed();
}
return result;
}
int KNotesIface_stub::getRevision( const TQString& arg0 )
{
int result = 0;
if ( !dcopClient() ) {
setStatus( CallFailed );
return result;
}
TQByteArray data, replyData;
TQCString replyType;
TQDataStream arg( data, IO_WriteOnly );
arg << arg0;
if ( dcopClient()->call( app(), obj(), "getRevision(TQString)", data, replyType, replyData ) ) {
if ( replyType == "int" ) {
TQDataStream _reply_stream( replyData, IO_ReadOnly );
_reply_stream >> result;
setStatus( CallSucceeded );
} else {
callFailed();
}
} else {
callFailed();
}
return result;
}
TQDateTime KNotesIface_stub::getLastModified( const TQString& arg0 )
{
TQDateTime result;
if ( !dcopClient() ) {
setStatus( CallFailed );
return result;
}
TQByteArray data, replyData;
TQCString replyType;
TQDataStream arg( data, IO_WriteOnly );
arg << arg0;
if ( dcopClient()->call( app(), obj(), "getLastModified(TQString)", data, replyType, replyData ) ) {
if ( replyType == "TQDateTime" ) {
TQDataStream _reply_stream( replyData, IO_ReadOnly );
_reply_stream >> result;
setStatus( CallSucceeded );
} else {
callFailed();
}
} else {
callFailed();
}
return result;
}

View file

@ -1,41 +0,0 @@
/****************************************************************************
**
** DCOP Stub Definition created by dcopidl2cpp from KNotesIface.kidl
**
** WARNING! All changes made in this file will be lost!
**
*****************************************************************************/
#ifndef __KNOTESIFACE_STUB__
#define __KNOTESIFACE_STUB__
#include <dcopstub.h>
#include <dcopobject.h>
#include <tqmap.h>
#include <tqdatetime.h>
#include <tqstring.h>
class KNotesIface_stub : virtual public DCOPStub
{
public:
KNotesIface_stub( const TQCString& app, const TQCString& id );
KNotesIface_stub( DCOPClient* client, const TQCString& app, const TQCString& id );
explicit KNotesIface_stub( const DCOPRef& ref );
virtual TQString newNote( const TQString& name, const TQString& text );
virtual TQString newNoteFromClipboard( const TQString& name );
virtual ASYNC killNote( const TQString& noteId );
virtual ASYNC killNote( const TQString& noteId, bool force );
virtual TQMap<TQString,TQString> notes();
virtual ASYNC setName( const TQString& noteId, const TQString& newName );
virtual ASYNC setText( const TQString& noteId, const TQString& newText );
virtual TQString name( const TQString& noteId );
virtual TQString text( const TQString& noteId );
virtual int getRevision( const TQString& noteId );
virtual TQDateTime getLastModified( const TQString& noteId );
protected:
KNotesIface_stub() : DCOPStub( never_use ) {}
};
#endif

View file

@ -85,7 +85,7 @@ TDEPIMAddressBookSource::~TDEPIMAddressBookSource()
delete app;
}
TQString TDEPIMAddressBookSource::lastModifiedNormalized(TDEABC::Addressee &e)
TQString TDEPIMAddressBookSource::lastModified(TDEABC::Addressee &e)
{
//Get the revision date of the KDE addressbook entry.
TQDateTime d = e.revision();
@ -97,7 +97,7 @@ TQString TDEPIMAddressBookSource::lastModifiedNormalized(TDEABC::Addressee &e)
e.setRevision(d);
}
// We pass UTC, because we open the calendar in UTC
// We pass UTC, because we open the source in UTC
// return d.toString(TQt::ISODate);
return d.toString("yyyyMMddThhmmssZ");
}
@ -126,18 +126,18 @@ TDEPIMAddressBookSource::Databases TDEPIMAddressBookSource::getDatabases()
++it;
SE_LOG_DEBUG(getDisplayName(), "SUB Name : %s , ID: %s",
static_cast<const char*>(res->resourceName().utf8()),
static_cast<const char*>(res->identifier().utf8()) );
res->resourceName().utf8().data(),
res->identifier().utf8().data() );
/*
* we pull only active resources thus user has freedom to decide what wants to be visible for sync
*/
if ( res->isActive() ) {
result.push_back (
Database (
static_cast<const char*>(res->resourceName().utf8()), // the name of the resource
static_cast<const char*>(res->identifier().utf8()), // the path - (we use the resource uid)
first, // default or not
res->readOnly() // read only or not
res->resourceName().utf8().data(), // the name of the resource
res->identifier().utf8().data(), // the path - (we use the resource uid)
first, // default or not
res->readOnly() // read only or not
)
);
first = false;
@ -156,11 +156,11 @@ void TDEPIMAddressBookSource::open()
TDEABC::Resource *res;
while ( (res = it.current()) != 0 ) {
++it;
if ( id.compare(static_cast<const char*>(res->identifier().utf8())) == 0 ) {
if ( id.compare(res->identifier().utf8().data()) == 0 ) {
if ( ! res->isActive() )
Exception::throwError(SE_HERE, "internal error, configured resource is not active");
ticketPtr = res->requestSaveTicket();
SE_LOG_DEBUG(getDisplayName(), "TDE address book id: %s ", static_cast<const char*>(res->identifier().utf8()) );
SE_LOG_DEBUG(getDisplayName(), "TDE address book id: %s ", res->identifier().utf8().data() );
break;
}
}
@ -197,13 +197,12 @@ void TDEPIMAddressBookSource::listAllItems(RevisionMap_t &revisions)
for (TDEABC::Resource::Iterator it=workbookPtr->begin(); it!=workbookPtr->end(); it++) {
TDEABC::Addressee ab = (*it);
TQString lm = lastModifiedNormalized(ab);
revisions[static_cast<const char*>(ab.uid().utf8())] = static_cast<const char*>(lm.utf8());
TQString lm = lastModified(ab);
revisions[ab.uid().utf8().data()] = lm.utf8().data();
// m_categories.append(a.categories()); // Set filter categories
SE_LOG_DEBUG(getDisplayName(), "Addressee UID: %s last changed(%s)",
static_cast<const char*>(ab.uid().utf8()),
static_cast<const char*>(lm.utf8())
);
SE_LOG_DEBUG(getDisplayName(), "Addressee UID: %s modified(%s)",
ab.uid().utf8().data(),
lm.utf8().data());
}
}
@ -260,12 +259,12 @@ TrackingSyncSource::InsertItemResult TDEPIMAddressBookSource::insertItem(const s
// read out the new addressee to get the new revision
TDEABC::Addressee addresseeNew = workbookPtr->findByUid(uidOld);
TQString revision = lastModifiedNormalized(addresseeNew);
TQString revision = lastModified(addresseeNew);
SE_LOG_DEBUG(getDisplayName(), "TDE addressbook UID= %s ADD/UPDATE (REV=%s) OK",
static_cast<const char*>(uidOld.utf8()),
static_cast<const char*>(revision.utf8()) );
return InsertItemResult(static_cast<const char*>(uidOld.utf8()), static_cast<const char*>(revision.utf8()), state);
uidOld.utf8().data(),
revision.utf8().data() );
return InsertItemResult(uidOld.utf8().data(), revision.utf8().data(), state);
}
void TDEPIMAddressBookSource::readItem(const std::string &luid, std::string &item, bool raw)
@ -289,10 +288,10 @@ void TDEPIMAddressBookSource::readItem(const std::string &luid, std::string &ite
else
data = converter.createVCard(addressee, TDEABC::VCardConverter::v3_0);
item.assign(static_cast<const char*>(data.utf8()));
item.assign(data.utf8().data());
/* DEBUG
SE_LOG_DEBUG(getDisplayName(), "Item id ( %s )", luid.c_str() );
SE_LOG_DEBUG(getDisplayName(), "data %s", static_cast<const char*>(data.utf8()));
SE_LOG_DEBUG(getDisplayName(), "data %s", data.utf8().data();
*/
}
@ -341,8 +340,8 @@ std::string TDEPIMAddressBookSource::getDescription(const string &luid)
}
desc.append("\n");
SE_LOG_DEBUG(getDisplayName(), "User summary %s", static_cast<const char*>(desc.utf8()));
return static_cast<const char*>(desc.utf8());
SE_LOG_DEBUG(getDisplayName(), "User summary %s", desc.utf8().data());
return desc.utf8().data();
}
void TDEPIMAddressBookSource::getSynthesisInfo(SynthesisInfo &info,

View file

@ -108,7 +108,7 @@ private:
* the specific entry.
* If no revision is available, always return the same 0-time stamp
*/
TQString lastModifiedNormalized(TDEABC::Addressee &e);
TQString lastModified(TDEABC::Addressee &e);
// /** TODO if it makes sense to sync up only specific categories
// * return true if at least one item in the given list is included in the categories member

View file

@ -30,6 +30,7 @@
#include <syncevo/Exception.h>
#include <syncevo/Logging.h>
#include <kstandarddirs.h>
#include <libkcal/icalformat.h>
//#include <libkcal/vcalformat.h>
#include <libkcal/calendarlocal.h>
@ -60,12 +61,17 @@ TDEPIMCalendarSource::TDEPIMCalendarSource( TDEPIMCalendarSourceType type, const
Exception::throwError(SE_HERE, "internal init error, invalid calendar type");
break;
}
//NOTE not really used
//NOTE not really used
m_contentMimeType = "text/calendar";
app = new TDEPIMSyncSource("syncevo-tdepim-cal");
calendarResPtr = new KCal::CalendarResources( "UTC" );
TDEConfig config( locate( "config", "korganizerrc" ) );
config.setGroup( "Time & Date" );
TQString tz = config.readEntry( "TimeZoneId", "UTC" );
calendarResPtr = new KCal::CalendarResources( tz );
if (!calendarResPtr) {
Exception::throwError(SE_HERE, "internal error, can not open the default calendar");
}
@ -82,7 +88,7 @@ TDEPIMCalendarSource::~TDEPIMCalendarSource() {
delete app;
}
TQString TDEPIMCalendarSource::lastModifiedNormalized(const KCal::Incidence *e)
TQString TDEPIMCalendarSource::lastModified(const KCal::Incidence *e)
{
TQDateTime d = e->lastModified();
// if no modification date is available, always return the same 0-time stamp
@ -92,7 +98,7 @@ TQString TDEPIMCalendarSource::lastModifiedNormalized(const KCal::Incidence *e)
d.setTime_t(0);
// We pass UTC, because we open the calendar in UTC
// return d.toString(TQt::ISODate);
// return d.toString(TQt::ISODate);
return d.toString("yyyyMMddThhmmssZ");
}
@ -115,8 +121,8 @@ TDEPIMCalendarSource::Databases TDEPIMCalendarSource::getDatabases()
result.push_back (
Database (
static_cast<const char*>(( *i )->resourceName().utf8()), // the name of the resource
static_cast<const char*>(( *i )->identifier().utf8()), // the path - (we use the resource uid)
( *i )->resourceName().utf8().data(), // the name of the resource
( *i )->identifier().utf8().data(), // the path - (we use the resource uid)
first, // default or not
( *i )->readOnly() // read only or not
)
@ -138,7 +144,7 @@ void TDEPIMCalendarSource::open()
* what will be visible for sync
*/
for (KRES::Manager<KCal::ResourceCalendar>::ActiveIterator i = mgr->activeBegin(); i != mgr->activeEnd(); i++) {
if ( static_cast<const char*>(( *i )->identifier().utf8()) == id ) {
if ( ( *i )->identifier().utf8().data() == id ) {
// SE_LOG_DEBUG(getDisplayName(), "Resource id: %s found", path_str.c_str() );
calendarPtr = ( *i ) ;
break;
@ -194,31 +200,31 @@ void TDEPIMCalendarSource::listAllItems(SyncSourceRevisions::RevisionMap_t &revi
case TDEPIM_TASKS:
e = calendarPtr->rawEvents( KCal::EventSortUnsorted , KCal::SortDirectionAscending );
for (KCal::Event::List::ConstIterator i = e.begin(); i != e.end(); i++) {
lm = lastModifiedNormalized((*i));
revisions[static_cast<const char*>((*i)->uid().utf8())] = static_cast<const char*>(lm.utf8());
SE_LOG_DEBUG(getDisplayName(), "Event UID: %s last changed( %s )",
static_cast<const char*>((*i)->uid().utf8()),
static_cast<const char*>(lm.utf8()));
lm = lastModified((*i));
revisions[(*i)->uid().utf8().data()] = lm.utf8().data();
SE_LOG_DEBUG(getDisplayName(), "Event UID: %s modified( %s )",
(*i)->uid().utf8().data(),
lm.utf8().data());
}
break;
case TDEPIM_TODO:
t = calendarPtr->rawTodos( KCal::TodoSortUnsorted , KCal::SortDirectionAscending );
for (KCal::Todo::List::ConstIterator i = t.begin(); i != t.end(); i++) {
lm = lastModifiedNormalized((*i));
revisions[static_cast<const char*>((*i)->uid().utf8())] = static_cast<const char*>(lm.utf8());
SE_LOG_DEBUG(getDisplayName(), "Todos UID: %s last changed( %s )",
static_cast<const char*>((*i)->uid().utf8()),
static_cast<const char*>(lm.utf8()));
lm = lastModified((*i));
revisions[(*i)->uid().utf8().data()] = lm.utf8().data();
SE_LOG_DEBUG(getDisplayName(), "Todos UID: %s modified( %s )",
(*i)->uid().utf8().data(),
lm.utf8().data());
}
break;
case TDEPIM_JOURNAL:
j = calendarPtr->rawJournals( KCal::JournalSortUnsorted , KCal::SortDirectionAscending );
for (KCal::Journal::List::ConstIterator i = j.begin(); i != j.end(); i++) {
lm = lastModifiedNormalized((*i));
revisions[static_cast<const char*>((*i)->uid().utf8())] = static_cast<const char*>(lm.utf8());
SE_LOG_DEBUG(getDisplayName(), "Journal UID: %s last changed( %s )",
static_cast<const char*>((*i)->uid().utf8()),
static_cast<const char*>(lm.utf8()));
lm = lastModified((*i));
revisions[(*i)->uid().utf8().data()] = lm.utf8().data();
SE_LOG_DEBUG(getDisplayName(), "Journal UID: %s modified( %s )",
(*i)->uid().utf8().data(),
lm.utf8().data());
}
break;
default:
@ -238,6 +244,8 @@ TrackingSyncSource::InsertItemResult TDEPIMCalendarSource::insertItem(const std:
TQString uid = TQString::fromUtf8(luid.data(), luid.size());
TQString data = TQString::fromUtf8(item.data(), item.size());
SE_LOG_DEBUG(getDisplayName(), "Item to save: ( %s )", data.latin1() );
/*
* Check if item already exists. If yes notify the engine and do nothing here
*/
@ -250,46 +258,42 @@ TrackingSyncSource::InsertItemResult TDEPIMCalendarSource::insertItem(const std:
// Exception::throwError(SE_HERE, "internal error, unable to save calendar");
SE_LOG_DEBUG(getDisplayName(), "Item deleted for merge: ( %s )", uid.latin1() );
replaced = true;
// FIXME ufortunately the ITEM_NEEDS_MERGE does not work well with updated items
// FIXME unfortunately the ITEM_NEEDS_MERGE does not work well with updated items
// std::string ret_uid(uid.utf8(), uid.utf8().length());
// return InsertItemResult(ret_uid, "", ITEM_NEEDS_MERGE);
}
/*
* Add to local calendar, so that we may set the uid
* Create incidence and set the uid to the old one if replaced
*/
KCal::CalendarLocal cal(TQString::fromLatin1( "UTC" ));
if (! format.fromString(&cal,data) )
Exception::throwError(SE_HERE, "internal error, unable to convert calendar data");
KCal::Incidence *e = format.fromString(data);
if (e==0)
Exception::throwError(SE_HERE, "internal error, unable to convert calendar data");
if ( replaced )
e->setUid( uid );
else
uid = e->uid();
if ( ! calendarPtr->addIncidence(e))
Exception::throwError(SE_HERE, "internal error, unable to add item to calendar");
if ( ! calendarPtr->save(e) )
Exception::throwError(SE_HERE, "internal error, unable to save item to calendar");
SE_LOG_DEBUG(getDisplayName(), "Item saved: ( %s )", uid.latin1() );
/*
* Add the events from the temporary calendar
* We iterate over the list, but it should have only one event.
*/
KCal::Incidence::List itemList = cal.incidences();
for (KCal::Incidence::List::ConstIterator i = itemList.begin(); i != itemList.end(); i++) {
KCal::Incidence *e = (*i)->clone();
if ( replaced )
e->setUid( uid );
else
uid = e->uid();
if ( ! calendarPtr->addIncidence(e))
Exception::throwError(SE_HERE, "internal error, unable to add item to calendar");
if ( ! calendarPtr->save(e) )
Exception::throwError(SE_HERE, "internal error, unable to save item to calendar");
SE_LOG_DEBUG(getDisplayName(), "Item saved: ( %s )", uid.latin1() );
}
calendarResPtr->setModified(true);
KCal::Incidence *newinc = calendarPtr->incidence(uid);
if ( ! newinc )
Exception::throwError(SE_HERE, "internal error, unable to get item from calendar");
TQString lm=lastModifiedNormalized(newinc);
TQString lm=lastModified(newinc);
SE_LOG_DEBUG(getDisplayName(), "Item ( %s : %s ) done.",
static_cast<const char*>(newinc->uid().utf8()),
static_cast<const char*>(lm.utf8() ));
return InsertItemResult(static_cast<const char*>(newinc->uid().utf8()), static_cast<const char*>(lm.utf8()), state);
newinc->uid().utf8().data(),
lm.utf8().data());
return InsertItemResult(newinc->uid().utf8().data(), lm.utf8().data(), state);
}
void TDEPIMCalendarSource::readItem(const std::string &luid, std::string &item, bool raw)
@ -297,13 +301,11 @@ void TDEPIMCalendarSource::readItem(const std::string &luid, std::string &item,
KCal::ICalFormat iCalFmt;
// NOTE: The libkcal vCal (v.1.0) does not work pretty well - the support is disabled for now
// KCal::VCalFormat vCalFmt;
// TQString data = "";
TQString uid = TQString::fromUtf8(luid.data(),luid.size());
/* Build a local calendar for the incidence data */
KCal::CalendarLocal cal(TQString::fromLatin1( "UTC" ) /*calendarResPtr->timeZoneId()*/);
KCal::CalendarLocal cal( calendarResPtr->timeZoneId() );
switch (m_type) {
case TDEPIM_TASKS:
cal.addIncidence(calendarPtr->event(uid)->clone());
@ -319,12 +321,11 @@ void TDEPIMCalendarSource::readItem(const std::string &luid, std::string &item,
break;
}
// Convert the data to icalendar
// Convert the data to string
TQString data = iCalFmt.toString( &cal );
item.assign(static_cast<const char*>(data.utf8()));
item.assign(data.utf8().data());
SE_LOG_DEBUG(getDisplayName(), "Item id ( %s )", luid.c_str() );
// SE_LOG_DEBUG(getDisplayName(), "TDE calendar Data: %s\n", data_str.c_str() );
// SE_LOG_DEBUG(getDisplayName(), "TDE calendar Data: %s\n", data.utf8().data() );
}
@ -348,7 +349,7 @@ std::string TDEPIMCalendarSource::getDescription(const std::string &luid)
{
KCal::Incidence *inc = calendarPtr->incidence(TQString::fromUtf8(luid.data(),luid.size()));
if ( inc )
return static_cast<const char*>(inc->summary().utf8());
return inc->summary().utf8().data();
SE_LOG_DEBUG(getDisplayName(), "Resource id(%s) not found", luid.c_str() );
return "";
}

View file

@ -92,7 +92,7 @@ private:
* This functions is used internally to normalize the revision field
* If no revision is available, always return the same 0-time stamp
*/
TQString lastModifiedNormalized(const KCal::Incidence *e);
TQString lastModified(const KCal::Incidence *e);
/* All calendar storages must suppport UID/RECURRENCE-ID,
* it's part of the API. Therefore we can rely on it.

View file

@ -39,7 +39,6 @@ static std::unique_ptr<SyncSource> createSource ( const SyncSourceParams &params
* NOTE: The libkcal vCal (v.1.0) does not work pretty well I had to leave
* support only for iCal
*/
SourceType sourceType = SyncSource::getSourceType(params.m_nodes);
// SE_LOG_DEBUG("createSource() c1", "Requested Source format %s", sourceType.m_format.c_str());
@ -134,14 +133,10 @@ class TDECalendarTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(TDECalendarTest);
CPPUNIT_TEST(testInstantiate);
// There is no default database in Akonadi:
// CPPUNIT_TEST(testOpenDefaultCalendar);
// CPPUNIT_TEST(testOpenDefaultTodo);
// CPPUNIT_TEST(testOpenDefaultMemo);
// Besides, don't enable tests which depend on running Akonadi,
// because that would cause "client-test SyncEvolution" unless
// Akonadi was started first:
// CPPUNIT_TEST(testTimezones);
CPPUNIT_TEST_SUITE_END();

View file

@ -83,7 +83,7 @@ TDEPIMNotesSource::~TDEPIMNotesSource() {
}
TQString TDEPIMNotesSource::lastModifiedNormalized(TQDateTime &d) const
TQString TDEPIMNotesSource::lastModified(TQDateTime &d) const
{
// if no modification date is available, always return the same 0-time stamp
// to avoid that 2 calls deliver different times which would be treated as changed entry
@ -91,7 +91,7 @@ TQString TDEPIMNotesSource::lastModifiedNormalized(TQDateTime &d) const
if (!d.isValid())
d.setTime_t(0);
// We pass UTC, because we open the calendar in UTC
// We pass UTC, because we open the source in UTC
// return d.toString(TQt::ISODate);
return d.toString("yyyyMMddThhmmssZ");
}
@ -181,12 +181,12 @@ void TDEPIMNotesSource::listAllItems(SyncSourceRevisions::RevisionMap_t &revisio
TQDateTime dt = kn_iface->getLastModified(TQString(i.key().utf8()));
if (kn_iface->status() != DCOPStub::CallSucceeded)
Exception::throwError(SE_HERE, "internal error, DCOP call failed");
revisions[static_cast<const char*>(i.key().utf8())] = static_cast<const char*>(lastModifiedNormalized(dt).utf8());
revisions[i.key().utf8().data()] = lastModified(dt).utf8().data();
/* DEBUG
SE_LOG_DEBUG(getDisplayName(), "KNotes UID: %s", static_cast<const char*>(i.key().utf8()) );
SE_LOG_DEBUG(getDisplayName(), "KNotes REV: %s", static_cast<const char*>(lastModifiedNormalized(dt).utf8()) );
SE_LOG_DEBUG(getDisplayName(), "KNotes DATA: %s", static_cast<const char*>(data.utf8()));
SE_LOG_DEBUG(getDisplayName(), "KNotes UID: %s", i.key().utf8().data() );
SE_LOG_DEBUG(getDisplayName(), "KNotes REV: %s", lastModified(dt).utf8().data() );
SE_LOG_DEBUG(getDisplayName(), "KNotes DATA: %s", data.utf8().data());
*/
}
}
@ -203,8 +203,8 @@ TrackingSyncSource::InsertItemResult TDEPIMNotesSource::insertItem(const std::st
TQString summary = data.section('\n', 0, 0); // first line is our title == summary
TQString body = data.section('\n', 1); // rest
/* DEBUG
SE_LOG_DEBUG(getDisplayName(), "KNotes SUM : %s", static_cast<const char*>(summary.utf8()) );
SE_LOG_DEBUG(getDisplayName(), "KNotes BODY: %s", static_cast<const char*>(body.utf8()) );
SE_LOG_DEBUG(getDisplayName(), "KNotes SUM : %s", summary.utf8().data() );
SE_LOG_DEBUG(getDisplayName(), "KNotes BODY: %s", body.utf8().data() );
*/
TQString newuid;
@ -225,7 +225,7 @@ TrackingSyncSource::InsertItemResult TDEPIMNotesSource::insertItem(const std::st
TQDateTime dt = kn_iface->getLastModified(newuid);
if (kn_iface->status() != DCOPStub::CallSucceeded)
Exception::throwError(SE_HERE, "internal error, DCOP call failed");
return InsertItemResult(static_cast<const char*>(newuid.utf8()), static_cast<const char*>(lastModifiedNormalized(dt).utf8()), state);
return InsertItemResult(newuid.utf8().data(), lastModified(dt).utf8().data(), state);
}
@ -234,7 +234,7 @@ void TDEPIMNotesSource::readItem(const std::string &luid, std::string &item, boo
TQString uid = TQString::fromUtf8(luid.data(),luid.size());
TQString data = kn_iface->name( uid ) + '\n' + stripHtml(kn_iface->text( uid ));
item.assign( static_cast<const char*>(data.utf8()) );
item.assign( data.utf8().data() );
}
void TDEPIMNotesSource::removeItem(const std::string &luid)
@ -255,7 +255,7 @@ std::string TDEPIMNotesSource::getDescription(const std::string &luid)
TQString uid = TQString::fromUtf8(luid.data(),luid.size());
TQString data = kn_iface->name( uid );
if ( data.length() > 0 )
return static_cast<const char*>(data.utf8());
return data.utf8().data();
SE_LOG_DEBUG(getDisplayName(), "Resource id(%s) not found", luid.c_str() );
return "";

View file

@ -75,7 +75,7 @@ private:
*/
static TQString stripHtml(TQString input);
TQString lastModifiedNormalized(TQDateTime &d) const;
TQString lastModified(TQDateTime &d) const;
/**
* Implement some brief information extraction from the note

View file

@ -89,16 +89,10 @@ class TDENotesTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(TDENotesTest);
CPPUNIT_TEST(testInstantiate);
// There is no default database in Akonadi:
// CPPUNIT_TEST(testOpenDefaultCalendar);
// CPPUNIT_TEST(testOpenDefaultTodo);
// CPPUNIT_TEST(testOpenDefaultMemo);
// Besides, don't enable tests which depend on running Akonadi,
// because that would cause "client-test SyncEvolution" unless
// Akonadi was started first:
// CPPUNIT_TEST(testTimezones);
CPPUNIT_TEST_SUITE_END();
protected:

View file

@ -65,12 +65,6 @@ TDEPIMSyncSource::TDEPIMSyncSource(TQString name) :
TDEPIMSyncSource::~TDEPIMSyncSource()
{
if ( newApp ) {
delete tdeappPtr;
tdeappPtr = 0;
}
// SE_LOG_DEBUG(NULL, "TDE base destroyed OK");
}
SE_END_CXX

View file

@ -7,7 +7,12 @@ TDEPIMABCFOUND=no
TDEPIMDCOPFOUND=no
TDEPIMNOTESFOUND=no
AC_CHECK_PROGS([TQMAKE], [tqmake tqmake])
AC_CHECK_PROGS([TQMAKE], [tqmake])
# dcopidl is required to generate the stubs
AC_CHECK_PROGS([DCOPIDL], [dcopidl], [/opt/trinity/bin/dcopidl])
AC_CHECK_PROGS([DCOPIDL2CPP], [dcopidl2cpp], [/opt/trinity/bin/dcopidl2cpp])
#AC_CHECK_FILE([KNotesIface.h], [action-if-found], [action-if-not-found], [includes])
PKG_CHECK_MODULES(TQT, tqt, TQTFOUND=yes, [TQTFOUND=no])
# Check for TDEPIM. There is no .pc file for it,
@ -83,6 +88,7 @@ if test $enable_tdepimcal = yes ; then
test $TDEPIMCALFOUND = yes || AC_MSG_ERROR([--enable-tdepimcal requires packages libtdepim1-trinity-dev,
tdelibs14-trinity-dev, but they were not found])
AC_DEFINE(ENABLE_TDEPIMCAL, 1, [TDE PIM Calendar available])
AC_DEFINE(ENABLE_TDEPIM, 1, [TDE PIM enabled])
else
# avoid unneeded dependencies on TDEPIM
TDEPIMCAL_CFLAGS=
@ -93,6 +99,7 @@ if test $enable_tdepimabc = yes ; then
test $TDEPIMABCFOUND = yes || AC_MSG_ERROR([--enable-tdepimabc requires packages libtdepim1-trinity-dev,
tdelibs14-trinity-dev, but they were not found])
AC_DEFINE(ENABLE_TDEPIMABC, 1, [TDE PIM Address Book available])
AC_DEFINE(ENABLE_TDEPIM, 1, [TDE PIM enabled])
else
# avoid unneeded dependencies on TDEPIM
TDEPIMABC_CFLAGS=
@ -103,6 +110,7 @@ if test $enable_tdepimnotes = yes ; then
test $TDEPIMNOTESFOUND = yes || AC_MSG_ERROR([--enable-tdepimnotes requires packages tdelibs14-trinity-dev,
tdepim-trinity-dev, but they were not found])
AC_DEFINE(ENABLE_TDEPIMNOTES, 1, [TDE PIM Address Book available])
AC_DEFINE(ENABLE_TDEPIM, 1, [TDE PIM enabled])
else
# avoid unneeded dependencies on TDEPIM
TDEPIMNOTES_CFLAGS=

View file

@ -50,7 +50,20 @@ src_backends_tdepim_cppflags = \
$(BACKEND_CPPFLAGS) \
-I$(top_srcdir)/src/backends/tdepim
#src_backends_tdepim_src = $(src_backends_tdepim_synctdepimcal_src) $(src_backends_tdepim_synctdepimabc_src)
src/backends/tdepim/KNotesIface.kidl:
cp /opt/trinity/include/KNotesIface.h src/backends/tdepim/KNotesIface.h
cd src/backends/tdepim/ && $(DCOPIDL) KNotesIface.h > KNotesIface.kidl
src/backends/tdepim/KNotesIface_stub.h: src/backends/tdepim/KNotesIface.kidl
cd src/backends/tdepim/ && $(DCOPIDL2CPP) KNotesIface.kidl
src/backends/tdepim/KNotesIface_stub.cpp: src/backends/tdepim/KNotesIface_stub.h
CLEANFILES += src/backends/tdepim/KNotesIface_stub.h \
src/backends/tdepim/KNotesIface_stub.cpp \
src/backends/tdepim/KNotesIface.kidl \
src/backends/tdepim/KNotesIface_skel.cpp \
src/backends/tdepim/KNotesIface.h
src_backends_tdepim_synctdepimcal_la_SOURCES = $(src_backends_tdepim_synctdepimcal_src)
src_backends_tdepim_synctdepimcal_la_LIBADD = $(TDEPIMCAL_LIBS) $(SYNCEVOLUTION_LIBS)