[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [akonadi-sugarcrm] /: Added support for SugarCRM tasks
From: Kevin Krammer <kevin.krammer () gmx ! at>
Date: 2012-01-25 19:34:37
Message-ID: 20120125193437.DC85AA60A6 () git ! kde ! org
[Download RAW message or body]
Git commit a9037e01196740e0811cad22de70fd309e375a6a by Kevin Krammer, on behalf of \
Eric Newberry. Committed on 11/01/2012 at 01:29.
Pushed by krake into branch 'master'.
Added support for SugarCRM tasks
M +3 -0 CMakeLists.txt
M +6 -8 sugarcrmresource.cpp
A +31 -0 taskaccessorpair.cpp [License: GPL (v3)]
A +43 -0 taskaccessorpair.h [License: GPL (v3)]
A +507 -0 taskshandler.cpp [License: GPL (v3)]
A +60 -0 taskshandler.h [License: GPL (v3)]
http://commits.kde.org/akonadi-sugarcrm/a9037e01196740e0811cad22de70fd309e375a6a
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a147d7c..62798a5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,6 +94,8 @@ set( sugarcrmresource_SRCS
sugarcrmresource.cpp
sugarjob.cpp
sugarsession.cpp
+ taskaccessorpair.cpp
+ taskshandler.cpp
updateentryjob.cpp
# work with local implementations until available from kdepimlibs
@@ -122,6 +124,7 @@ target_link_libraries(akonadi_sugarcrm_resource
${KDE4_AKONADI_KABC_LIBS}
${KDE4_AKONADI_LIBS}
${KDEPIMLIBS_KABC_LIBS}
+ ${KDEPIMLIBS_KCALCORE_LIBS}
${KDE4_KDECORE_LIBS}
${QT_QTDBUS_LIBRARY}
${QT_QTCORE_LIBRARY})
diff --git a/sugarcrmresource.cpp b/sugarcrmresource.cpp
index f3e4a34..8dc9cd3 100644
--- a/sugarcrmresource.cpp
+++ b/sugarcrmresource.cpp
@@ -22,6 +22,7 @@
#include "conflicthandler.h"
#include "contactshandler.h"
#include "leadshandler.h"
+#include "taskshandler.h"
#include "createentryjob.h"
#include "deleteentryjob.h"
#include "fetchentryjob.h"
@@ -407,14 +408,11 @@ void SugarCRMResource::listModulesResult( KJob *job )
ModuleHandler* handler = 0;
if ( module == QLatin1String( "Contacts" ) ) {
handler = new ContactsHandler( mSession );
- }
-
- else if(module == QLatin1String("Leads"))
- {
- handler = new LeadsHandler(mSession);
- }
-
- else {
+ } else if(module == QLatin1String("Leads")) {
+ handler = new LeadsHandler(mSession);
+ } else if(module == QLatin1String("Tasks")) {
+ handler = new TasksHandler(mSession);
+ } else {
//kDebug() << "No module handler for" << module;
continue;
}
diff --git a/taskaccessorpair.cpp b/taskaccessorpair.cpp
new file mode 100644
index 0000000..bf3c714
--- /dev/null
+++ b/taskaccessorpair.cpp
@@ -0,0 +1,31 @@
+/****************************************************************************
+** Copyright (C) 2010, 2011 Klaralvdalens Datakonsult AB. All rights reserved.
+** Copyright (C) 2012 Eric Newberry <ericnewberry@mirametrics.com>. All Rights \
Reserved. +**
+** This file is part of the Akonadi Resource for SugarCRM.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.GPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "taskaccessorpair.h"
+
+TaskAccessorPair::TaskAccessorPair( taskValueGetter get, taskValueSetter set, const \
QString &name ) + : getter( get ), diffName( name )
+{
+ setter.vSetter = set;
+}
+
+/*TaskAccessorPair::TaskAccessorPair( taskValueGetter get, taskDateTimeSetter set, \
const QString &name ) + : getter( get ), diffName( name )
+{
+ setter.dSetter = set;
+}*/
\ No newline at end of file
diff --git a/taskaccessorpair.h b/taskaccessorpair.h
new file mode 100644
index 0000000..2dfb37b
--- /dev/null
+++ b/taskaccessorpair.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+** Copyright (C) 2010, 2011 Klaralvdalens Datakonsult AB. All rights reserved.
+** Copyright (C) 2012 Eric Newberry <ericnewberry@mirametrics.com>. All Rights \
Reserved. +**
+** This file is part of the Akonadi Resource for SugarCRM.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.GPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#pragma once
+
+#include <kcalcore/todo.h>
+
+#include <QHash>
+
+typedef QString (*taskValueGetter)( const KCalCore::Todo& );
+typedef void (*taskValueSetter)( const QString&, KCalCore::Todo&);
+//typedef void (*taskDateTimeSetter)( const KDateTime&, KCalCore::Todo&);
+
+class TaskAccessorPair
+{
+public:
+ TaskAccessorPair( taskValueGetter get, taskValueSetter set, const QString &name \
); +
+ //TaskAccessorPair( taskValueGetter get, taskDateTimeSetter set, const QString \
&name ); +
+public:
+ taskValueGetter getter;
+ union tsetter {
+ taskValueSetter vSetter;
+ //taskDateTimeSetter dSetter;
+ } setter;
+ const QString diffName;
+};
\ No newline at end of file
diff --git a/taskshandler.cpp b/taskshandler.cpp
new file mode 100644
index 0000000..bbecca8
--- /dev/null
+++ b/taskshandler.cpp
@@ -0,0 +1,507 @@
+/****************************************************************************
+** Copyright (C) 2010, 2011 Klaralvdalens Datakonsult AB. All rights reserved.
+** Copyright (C) 2011-2012 Eric Newberry <ericnewberry@mirametrics.com>. All Rights \
Reserved. +**
+** This file is part of the Akonadi Resource for SugarCRM.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.GPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#include "taskshandler.h"
+
+#include "sugarsession.h"
+#include "sugarsoap.h"
+
+#include <kcalcore/todo.h>
+
+#include <akonadi/collection.h>
+#include <akonadi/abstractdifferencesreporter.h>
+#include <akonadi/kabc/contactparts.h>
+
+#include <kdatetime.h>
+
+#include <KLocale>
+
+#include <QHash>
+
+using namespace KCalCore;
+
+static QString getId( const KCalCore::Todo &todo )
+{
+ return todo.customProperty( "SugarCRM", "X-Id" );
+}
+
+static void setId( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setCustomProperty( "SugarCRM", "X-Id", value );
+}
+
+static QString getName( const KCalCore::Todo &todo )
+{
+ return todo.customProperty( "SugarCRM", "X-Name" );
+}
+
+static void setName( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setCustomProperty( "SugarCRM", "X-Name", value );
+}
+
+static QString getDateEntered( const KCalCore::Todo &todo )
+{
+ return todo.created().toString();
+}
+
+static void setDateEntered( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setCreated( KDateTime::fromString(value, "%Y-%m-%d %H:%M:%S") );
+}
+
+static QString getDateModified( const KCalCore::Todo &todo )
+{
+ return todo.customProperty( "SugarCRM", "X-DateModified" );
+}
+
+static void setDateModified( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setCustomProperty( "SugarCRM", "X-DateModified", value );
+}
+
+static QString getModifiedUserId( const KCalCore::Todo &todo )
+{
+ return todo.customProperty( "SugarCRM", "X-ModifiedUserId" );
+}
+
+static void setModifiedUserId( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setCustomProperty( "SugarCRM", "X-ModifiedUserId", value );
+}
+
+static QString getCreatedBy( const KCalCore::Todo &todo )
+{
+ return todo.customProperty( "SugarCRM", "X-CreatedBy" );
+}
+
+static void setCreatedBy( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setCustomProperty( "SugarCRM", "X-CreatedBy", value );
+}
+
+static QString getDescription( const KCalCore::Todo &todo )
+{
+ return todo.description();
+}
+
+static void setDescription( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setDescription( value );
+}
+
+static QString getDeleted( const KCalCore::Todo &todo )
+{
+ return todo.customProperty( "SugarCRM", "X-Deleted" );
+}
+
+static void setDeleted( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setCustomProperty( "SugarCRM", "X-Deleted", value );
+}
+
+static QString getAssignedUserId( const KCalCore::Todo &todo )
+{
+ return todo.customProperty( "SugarCRM", "X-AssignedUserId" );
+}
+
+static void setAssignedUserId( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setCustomProperty( "SugarCRM", "X-AssignedUserId", value );
+}
+
+static QString getStatus( const KCalCore::Todo &todo )
+{
+ if(todo.status() == KCalCore::Todo::StatusConfirmed) {
+ return "Not Started";
+ } else if(todo.status() == KCalCore::Todo::StatusInProcess) {
+ return "In Progress";
+ } else if(todo.status() == KCalCore::Todo::StatusCompleted) {
+ return "Completed";
+ } else if(todo.status() == KCalCore::Todo::StatusNeedsAction) {
+ return "Pending Input";
+ } else if(todo.customStatus() == "StatusDeferred") {
+ return "Deferred";
+ } else {
+ return "None";
+ }
+}
+
+static void setStatus( const QString &value, KCalCore::Todo &todo )
+{
+ if(value == "Not Started") {
+ todo.setStatus(KCalCore::Todo::StatusConfirmed);
+ } else if(value == "In Progress") {
+ todo.setStatus(KCalCore::Todo::StatusInProcess);
+ } else if(value == "Completed") {
+ todo.setStatus(KCalCore::Todo::StatusCompleted);
+ } else if(value == "Pending Input") {
+ todo.setStatus(KCalCore::Todo::StatusNeedsAction);
+ } else if(value == "Deferred") {
+ todo.setCustomStatus("StatusDeferred");
+ } else {
+ todo.setStatus(KCalCore::Todo::StatusNone);
+ }
+}
+
+static QString getDateDueFlag( const KCalCore::Todo &todo )
+{
+ return todo.customProperty( "SugarCRM", "X-DateDueFlag" );
+}
+
+static void setDateDueFlag( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setCustomProperty( "SugarCRM", "X-DateDueFlag", value );
+}
+
+static QString getDateDue( const KCalCore::Todo &todo )
+{
+ KDateTime dateDue = todo.dtDue();
+ return dateDue.toString("%Y-%m-%d %H:%M:%S");
+}
+
+static void setDateDue( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setDtDue( KDateTime::fromString(value, "%Y-%m-%d %H:%M:%S", new KTimeZones, \
true) ); +}
+
+static QString getDateStartFlag( const KCalCore::Todo &todo )
+{
+ return todo.customProperty( "SugarCRM", "X-DateStartFlag" );
+}
+
+static void setDateStartFlag( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setCustomProperty( "SugarCRM", "X-DateStartFlag", value );
+}
+
+static QString getDateStart( const KCalCore::Todo &todo )
+{
+ KDateTime dateStart = todo.dtStart();
+ return dateStart.toString("%Y-%m-%d %H:%M:%S");
+}
+
+static void setDateStart( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setDtStart( KDateTime::fromString(value, "%Y-%m-%d %H:%M:%S", new \
KTimeZones, true) ); +}
+
+static QString getParentType( const KCalCore::Todo &todo )
+{
+ return todo.customProperty( "SugarCRM", "X-ParentType" );
+}
+
+static void setParentType( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setCustomProperty( "SugarCRM", "X-ParentType", value );
+}
+
+static QString getParentId( const KCalCore::Todo &todo )
+{
+ return todo.customProperty( "SugarCRM", "X-ParentId" );
+}
+
+static void setParentId( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setCustomProperty( "SugarCRM", "X-ParentId", value );
+}
+
+static QString getContactId( const KCalCore::Todo &todo )
+{
+ return todo.customProperty( "SugarCRM", "X-ContactId" );
+}
+
+static void setContactId( const QString &value, KCalCore::Todo &todo )
+{
+ todo.setCustomProperty( "SugarCRM", "X-ContactId", value );
+}
+
+static QString getPriority( const KCalCore::Todo &todo )
+{
+ if(todo.priority() == 1) {
+ return "High";
+ } else if(todo.priority() == 5) {
+ return "Medium";
+ } else if(todo.priority() == 9) {
+ return "Low";
+ } else {
+ return "None";
+ }
+}
+
+static void setPriority( const QString &value, KCalCore::Todo &todo )
+{
+ if(value == "High") {
+ todo.setPriority(1);
+ } else if(value == "Medium") {
+ todo.setPriority(5);
+ } else if(value == "Low") {
+ todo.setPriority(9);
+ } else {
+ todo.setPriority(0);
+ }
+}
+
+TasksHandler::TasksHandler( SugarSession *session )
+ : ModuleHandler( QLatin1String( "Tasks" ), session ),
+ mAccessors( new AccessorHash )
+{
+ mAccessors->insert( QLatin1String( "id" ),
+ new TaskAccessorPair( getId, setId, QString() ) );
+ mAccessors->insert( QLatin1String( "name" ),
+ new TaskAccessorPair( getName, setName, QString() ) );
+ mAccessors->insert( QLatin1String( "date_entered" ),
+ new TaskAccessorPair( getDateEntered, setDateEntered, \
QString() ) ); + mAccessors->insert( QLatin1String( "date_modififed" ),
+ new TaskAccessorPair( getDateModified, setDateModified, \
QString() ) ); + mAccessors->insert( QLatin1String( "modified_user_id" ),
+ new TaskAccessorPair( getModifiedUserId, setModifiedUserId, \
QString() ) ); + mAccessors->insert( QLatin1String( "created_by" ),
+ new TaskAccessorPair( getCreatedBy, setCreatedBy, QString() \
) ); + mAccessors->insert( QLatin1String( "description" ),
+ new TaskAccessorPair( getDescription, setDescription, \
QString() ) ); + mAccessors->insert( QLatin1String( "deleted" ),
+ new TaskAccessorPair( getDeleted, setDeleted, QString() ) );
+ mAccessors->insert( QLatin1String( "assigned_user_id" ),
+ new TaskAccessorPair( getAssignedUserId, setAssignedUserId, \
QString() ) ); + mAccessors->insert( QLatin1String( "status" ),
+ new TaskAccessorPair( getStatus, setStatus, QString() ) );
+ mAccessors->insert( QLatin1String( "date_due_flag" ),
+ new TaskAccessorPair( getDateDueFlag, setDateDueFlag, \
QString() ) ); + mAccessors->insert( QLatin1String( "date_due" ),
+ new TaskAccessorPair( getDateDue, setDateDue, QString() ) );
+ mAccessors->insert( QLatin1String( "date_start_flag" ),
+ new TaskAccessorPair( getDateStartFlag, setDateStartFlag, \
QString() ) ); + mAccessors->insert( QLatin1String( "date_start" ),
+ new TaskAccessorPair( getDateStart, setDateStart, QString() \
) ); + mAccessors->insert( QLatin1String( "parent_type" ),
+ new TaskAccessorPair( getParentType, setParentType, \
QString() ) ); + mAccessors->insert( QLatin1String( "parent_id" ),
+ new TaskAccessorPair( getParentId, setParentId, QString() ) \
); + mAccessors->insert( QLatin1String( "contact_id" ),
+ new TaskAccessorPair( getContactId, setContactId, QString() \
) ); + mAccessors->insert( QLatin1String( "priority" ),
+ new TaskAccessorPair( getPriority, setPriority, QString() ) \
); +}
+
+TasksHandler::~TasksHandler()
+{
+ qDeleteAll( *mAccessors );
+ delete mAccessors;
+}
+
+QStringList TasksHandler::supportedFields() const
+{
+ return mAccessors->keys();
+}
+
+Akonadi::Collection TasksHandler::collection() const
+{
+ Akonadi::Collection taskCollection;
+ taskCollection.setRemoteId( moduleName() );
+ taskCollection.setContentMimeTypes( QStringList() << \
KCalCore::Todo::todoMimeType() ); + taskCollection.setName( i18nc( "@item folder \
name", "Tasks" ) ); + taskCollection.setRights( Akonadi::Collection::CanChangeItem \
| + Akonadi::Collection::CanCreateItem |
+ Akonadi::Collection::CanDeleteItem );
+
+ return taskCollection;
+}
+
+void TasksHandler::listEntries( const ListEntriesScope &scope )
+{
+ const QString query = scope.query( QLatin1String( "tasks" ) );
+ const QString orderBy = QLatin1String( "tasks.id" );
+ const int offset = scope.offset();
+ const int maxResults = 100;
+ const int fetchDeleted = scope.deleted();
+
+ TNS__Select_fields selectedFields;
+ selectedFields.setItems( mAccessors->keys() );
+
+ soap()->asyncGet_entry_list( sessionId(), moduleName(), query, orderBy, offset, \
selectedFields, maxResults, fetchDeleted ); +}
+
+bool TasksHandler::setEntry( const Akonadi::Item &item )
+{
+ if ( !item.hasPayload<KCalCore::Todo::Ptr>() ) {
+ kError() << "item (id=" << item.id() << ", remoteId=" << item.remoteId()
+ << ", mime=" << item.mimeType() << ") is missing Todo payload";
+ return false;
+ }
+
+ QList<TNS__Name_value> itemList;
+
+ // if there is an id add it, otherwise skip this field
+ // no id will result in the contact being added
+ if ( !item.remoteId().isEmpty() ) {
+ TNS__Name_value field;
+ field.setName( QLatin1String( "id" ) );
+ field.setValue( item.remoteId() );
+
+ itemList << field;
+ }
+
+ const KCalCore::Todo::Ptr todo = item.payload<KCalCore::Todo::Ptr>();
+ AccessorHash::const_iterator it = mAccessors->constBegin();
+ AccessorHash::const_iterator endIt = mAccessors->constEnd();
+ for ( ; it != endIt; ++it ) {
+ // check if this is a read-only field
+ if ( (*it)->getter == 0 ) {
+ continue;
+ }
+ TNS__Name_value field;
+ field.setName( it.key() );
+ field.setValue( (*it)->getter( *todo ) );
+
+ itemList << field;
+ }
+
+ TNS__Name_value_list valueList;
+ valueList.setItems( itemList );
+ soap()->asyncSet_entry( sessionId(), moduleName(), valueList );
+
+ return true;
+}
+
+Akonadi::Item TasksHandler::itemFromEntry( const TNS__Entry_value &entry, const \
Akonadi::Collection &parentCollection ) +{
+ Akonadi::Item item;
+
+ const QList<TNS__Name_value> valueList = entry.name_value_list().items();
+ if ( valueList.isEmpty() ) {
+ kWarning() << "Tasks entry for id=" << entry.id() << "has no values";
+ return item;
+ }
+
+ item.setRemoteId( entry.id() );
+ item.setParentCollection( parentCollection );
+ item.setMimeType( KCalCore::Todo::todoMimeType() );
+
+ KCalCore::Todo::Ptr todo( new KCalCore::Todo );
+ todo->setUid( entry.id() );
+
+ item.setPayload<KCalCore::Todo::Ptr>( todo );
+ item.setRemoteRevision( getDateModified( *todo ) );
+
+ return item;
+}
+
+bool TasksHandler::needBackendChange( const Akonadi::Item &item, const \
QSet<QByteArray> &modifiedParts ) const +{
+ if ( ModuleHandler::needBackendChange( item, modifiedParts ) ) {
+ return true;
+ }
+
+ return modifiedParts.contains( partIdFromPayloadPart( \
Akonadi::ContactPart::Lookup ) ) || + modifiedParts.contains( \
partIdFromPayloadPart( Akonadi::ContactPart::Standard ) ); +}
+
+void TasksHandler::compare( Akonadi::AbstractDifferencesReporter *reporter,
+ const Akonadi::Item &leftItem, const Akonadi::Item \
&rightItem ) +{
+ Q_ASSERT( leftItem.hasPayload<KCalCore::Todo::Ptr>() );
+ Q_ASSERT( rightItem.hasPayload<KCalCore::Todo::Ptr>() );
+
+ const KCalCore::Todo::Ptr leftTask = leftItem.payload<KCalCore::Todo::Ptr>();
+ const KCalCore::Todo::Ptr rightTask = rightItem.payload<KCalCore::Todo::Ptr>();
+
+ const QString modifiedBy = mSession->userName();
+ const QString modifiedOn = formatDate( getDateModified( *rightTask ) );
+
+ reporter->setLeftPropertyValueTitle( i18nc( "@title:column", "Local Task" ) );
+ reporter->setRightPropertyValueTitle(
+ i18nc( "@title:column", "Serverside Task: modified by %1 on %2",
+ modifiedBy, modifiedOn ) );
+
+ /*bool seenPrimaryAddress = false;
+ bool seenOtherAddress = false;
+ AccessorHash::const_iterator it = mAccessors->constBegin();
+ AccessorHash::const_iterator endIt = mAccessors->constEnd();
+ for ( ; it != endIt; ++it ) {
+ // check if this is a read-only field
+ if ( (*it)->getter == 0 ) {
+ continue;
+ }
+
+ QString leftValue = (*it)->getter( leftContact );
+ QString rightValue = (*it)->getter( rightContact );
+
+ QString diffName = (*it)->diffName;
+ if ( diffName.isEmpty() ) {
+ // check for special fields
+ if ( isAddressValue( it.key() ) ) {
+ if ( isPrimaryAddressValue( it.key() ) ) {
+ if ( !seenPrimaryAddress ) {
+ diffName = i18nc( "item:intable", "Primary Address" );
+ seenPrimaryAddress = true;
+ const KABC::Address leftAddress =
+ leftContact.address( KABC::Address::Work | \
KABC::Address::Pref ); + const KABC::Address rightAddress =
+ rightContact.address( KABC::Address::Work | \
KABC::Address::Pref ); +
+ leftValue = leftAddress.formattedAddress();
+ rightValue = rightAddress.formattedAddress();
+ } else {
+ // already printed, skip
+ continue;
+ }
+ } else {
+ if ( !seenOtherAddress ) {
+ seenOtherAddress = true;
+ diffName = i18nc( "item:intable", "Other Address" );
+ const KABC::Address leftAddress =
+ leftContact.address( KABC::Address::Home );
+ const KABC::Address rightAddress =
+ rightContact.address( KABC::Address::Home );
+
+ leftValue = leftAddress.formattedAddress();
+ rightValue = rightAddress.formattedAddress();
+ } else {
+ // already printed, skip
+ continue;
+ }
+ }
+ } else if ( it.key() == "do_not_call" ) {
+ diffName = i18nc( "@item:intable", "Do Not Call" );
+ leftValue = getDoNotCall( leftContact ) == QLatin1String( "1" )
+ ? QLatin1String( "Yes" ) : QLatin1String( "No" );
+ rightValue = getDoNotCall( rightContact ) == QLatin1String( "1" )
+ ? QLatin1String( "Yes" ) : QLatin1String( "No" );
+ } else {
+ // internal field, skip
+ continue;
+ }
+ }
+
+ if ( leftValue.isEmpty() && rightValue.isEmpty() ) {
+ continue;
+ }
+
+ if ( leftValue.isEmpty() ) {
+ reporter->addProperty( \
Akonadi::AbstractDifferencesReporter::AdditionalRightMode, + \
diffName, leftValue, rightValue ); + } else if ( rightValue.isEmpty() ) {
+ reporter->addProperty( \
Akonadi::AbstractDifferencesReporter::AdditionalLeftMode, + \
diffName, leftValue, rightValue ); + } else if ( leftValue != rightValue ) {
+ reporter->addProperty( \
Akonadi::AbstractDifferencesReporter::ConflictMode, + \
diffName, leftValue, rightValue ); + }
+ }*/
+}
diff --git a/taskshandler.h b/taskshandler.h
new file mode 100644
index 0000000..c74464b
--- /dev/null
+++ b/taskshandler.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+** Copyright (C) 2010, 2011 Klaralvdalens Datakonsult AB. All rights reserved.
+** Copyright (C) 2011-2012 Eric Newberry <ericnewberry@mirametrics.com>. All Rights \
Reserved. +**
+** This file is part of the Akonadi Resource for SugarCRM.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.GPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#pragma once
+
+#include "modulehandler.h"
+#include "taskaccessorpair.h"
+
+template <typename U, typename V> class QHash;
+
+class TasksHandler : public ModuleHandler
+{
+public:
+ TasksHandler( SugarSession *session );
+
+ ~TasksHandler();
+
+ QStringList supportedFields() const;
+
+ Akonadi::Collection collection() const;
+
+ void listEntries( const ListEntriesScope &scope );
+
+ bool setEntry( const Akonadi::Item &item );
+
+ Akonadi::Item itemFromEntry( const TNS__Entry_value &entry, const \
Akonadi::Collection &parentCollection ); +
+ bool needBackendChange( const Akonadi::Item &item, const QSet<QByteArray> \
&modifiedParts ) const; +
+ void compare( Akonadi::AbstractDifferencesReporter *reporter,
+ const Akonadi::Item &leftItem, const Akonadi::Item &rightItem );
+
+private:
+ /*inline bool isAddressValue( const QString& value ) const
+ { return ( isAltAddressValue( value ) || isPrimaryAddressValue( value ) );}
+ inline bool isAltAddressValue( const QString& value ) const
+ { return value.startsWith( QString( "alt_address_" ) );}
+ inline bool isPrimaryAddressValue( const QString& value ) const
+ { return value.startsWith( QString( "primary_address_" ) );}*/
+
+ QString adjustedTime( const QString datetime ) const;
+
+ typedef QHash<QString, TaskAccessorPair*> AccessorHash;
+ AccessorHash *mAccessors;
+};
\ No newline at end of file
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic