[meego-commits] 7936: Changes to Trunk/buteo-syncfw
Anas Nashif
no_reply at build.meego.com
Wed Sep 29 10:33:26 UTC 2010
Hi,
I have made the following changes to buteo-syncfw in project Trunk. Please review and accept ASAP.
Thank You,
Anas Nashif
[This message was auto-generated]
---
Request #7936:
submit: Trunk:Testing/buteo-syncfw(r3) -> Trunk/buteo-syncfw
Message:
move to Trunk
State: new 2010-09-29T03:33:25 nashif
Comment: None
changes files:
--------------
--- buteo-syncfw.changes
+++ buteo-syncfw.changes
@@ -0,0 +1,3 @@
+* Thu Sep 23 2010 Bernd Wachter <ext-bernd.wachter at nokia.com> - 0.5.1.8
+- Update version, fixing BMC#3860
+
@@ -7 +10 @@
-- Initial RPM version
\ No newline at end of file
+- Initial RPM version
old:
----
buteo-syncfw-0.5.0.21.tar.gz
new:
----
buteo-syncfw-0.5.1.8.tar.gz
spec files:
-----------
--- buteo-syncfw.spec
+++ buteo-syncfw.spec
@@ -1,5 +1,5 @@
Name: buteo-syncfw
-Version: 0.5.0.21
+Version: 0.5.1.8
Release: 1
Summary: Synchronization backend
Group: System/Libraries
@@ -22,6 +22,7 @@
%files
%defattr(-,root,root,-)
%config %{_sysconfdir}/sync/*
+%config %{_sysconfdir}/xdg/autostart/*.desktop
%{_bindir}/*
%{_libdir}/*.so.*
other changes:
--------------
++++++ buteo-syncfw-0.5.0.21.tar.gz -> buteo-syncfw-0.5.1.8.tar.gz
--- debian/changelog
+++ debian/changelog
@@ -1,3 +1,72 @@
+sync-fw (0.5.1-8) unstable; urgency=low
+
+ * Updated tag for meego.
+
+ -- Amit <amit.5.aggarwal at nokia.com> Thu, 23 Sep 2010 16:16:14 +0530
+
+sync-fw (0.5.1-7) unstable; urgency=low
+
+ * API name change for save , remove for profileMangaer.
+ * Profile change signals are emitted from ProfileManager on add/change/remove
+ * ProfileChanged Signal is removed from Accounts Helper.
+ * Added client Libraray function to be used by backendHelper of sync-ui-libs.
+
+ -- Amit <amit.5.aggarwal at nokia.com> Thu, 23 Sep 2010 14:16:14 +0530
+
+sync-fw (0.5.1-6) unstable; urgency=low
+
+ * Fixes: NB#192811 - Deleted sync destination still persists when close and open sync application
+
+ -- Duggirala Karthik <karthik.2.duggirala at nokia.com> Fri, 17 Sep 2010 14:16:14 +0530
+
+sync-fw (0.5.1-5) unstable; urgency=low
+
+ * Fixes: NB#191123 - Sync, Switch and MTP does not work
+ * Removed Aegis Manifest file.
+
+ -- Duggirala Karthik <karthik.2.duggirala at nokia.com> Fri, 10 Sep 2010 10:51:14 +0530
+
+sync-fw (0.5.1-4) unstable; urgency=low
+
+ * removed a function internal to synchronizer that is not needed anymore
+ * Fixes: NB#190114 - sync-fw Needs to have an Aegis Manifest file.
+
+ -- Srikanth <ext-srikanth.kavoori at nokia.com> Thu, 09 Sep 2010 10:51:14 +0530
+
+sync-fw (0.5.1-3) unstable; urgency=low
+
+ * Added missing headers to libsynccommon files
+
+ -- Duggirala Karthik <karthik.2.duggirala at nokia.com> Tue, 07 Sep 2010 10:08:00 +0530
+
+sync-fw (0.5.1-2) unstable; urgency=low
+
+ * Fixes: NB#188990 - Sync profile under ~/.sync
+
+ -- Santosh Puranik <santosh.puranik at nokia.com> Tue, 31 Aug 2010 19:08:00 +0530
+
+sync-fw (0.5.1-1) unstable; urgency=low
+
+ * Fixes: NB#183589 - Development packages libmeegosyncml-dev and
+ sync-fw-dev does not contain .pc files
+ * Changed the dbus interface name
+
+ -- Deepak Kodihalli <deepak.kodihalli at nokia.com> Mon, 30 Aug 2010 14:41:52 +0530
+
+sync-fw (0.5.1-0) unstable; urgency=low
+
+ * Added functions to retrieve a private thread specific dbus connection
+ * Added: libsyncommon/SyncDBusConnection.h
+ libsyncommon/SyncDBusConnection.cpp
+
+ -- Srikanth Kavoori <ext-srikanth.kavoori at nokia.com> Mon, 30 Aug 2010 11:36:34 +0530
+
+sync-fw (0.5.0-22) unstable; urgency=low
+
+ * Fixes: NB#184746
+
+ -- Deepak Kodihalli <deepak.kodihalli at nokia.com> Fri, 27 Aug 2010 15:36:34 +0530
+
sync-fw (0.5.0-21) unstable; urgency=low
* Tag for Meego.
--- debian/control
+++ debian/control
@@ -2,7 +2,7 @@
Section: utils
Priority: optional
Maintainer: Srikanth Kavoori <ext-srikanth.kavoori at nokia.com>
-Build-Depends: debhelper (>= 5), cdbs, doxygen, libqt4-dev, libdbus-1-dev , accounts-qt-dev, libcontextsubscriber-dev, libqttracker-dev , libiphb-dev ,usb-moded-dev, libsignon-qt-dev
+Build-Depends: debhelper (>= 5), cdbs, doxygen, libqt4-dev, libdbus-1-dev , accounts-qt-dev, libcontextsubscriber-dev, libqttracker-dev , libiphb-dev ,usb-moded-dev, libsignon-qt-dev, aegis-builder
Standards-Version: 3.7.2
Package: sync-fw
--- debian/rules
+++ debian/rules
@@ -7,6 +7,9 @@
CFLAGS += -Wall -Wextra -Wno-unused-parameter
CXXFLAGS += -Wall -Wextra -Wno-unused-parameter
+# architecture we're building for
+DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
+
configure: configure-stamp
configure-stamp:
dh_testdir
@@ -45,6 +48,12 @@
dh_gencontrol
dh_md5sums
dh_builddeb
-
+ifeq ($(DEB_HOST_ARCH), arm)
+ aegis-deb-add -control debian/sync-fw/DEBIAN/control .. debian/sync-fw.aegis=_aegis
+else ifeq ($(DEB_HOST_ARCH), armel)
+ aegis-deb-add -control debian/sync-fw/DEBIAN/control .. debian/sync-fw.aegis=_aegis
+endif
+
DEB_DESTDIR := $(CURDIR)/debian/tmp
DEB_DH_INSTALL_SOURCEDIR := debian/tmp
+
--- debian/sync-fw.aegis
+++ debian/sync-fw.aegis
+<aegis>
+ <request>
+ <credential name="GRP::dialout"/>
+ <for path="/usr/bin/msyncd"/>
+ </request>
+</aegis>
--- libsynccommon/SyncDBusConnection.cpp
+++ libsynccommon/SyncDBusConnection.cpp
+/*
+ * This file is part of buteo-syncfw package
+ *
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Contact: Sateesh Kavuri <sateesh.kavuri at nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include "SyncDBusConnection.h"
+#include "LogMacros.h"
+#include <QThreadStorage>
+
+namespace Buteo {
+
+ //! Private DBusConnection object that Auto Disconnects when the storage
+ // for this object is being released.
+ class AutoDBusConnection : public QDBusConnection
+ {
+ public:
+ AutoDBusConnection(const QDBusConnection& c)
+ : QDBusConnection(c)
+ {
+ FUNCTION_CALL_TRACE;
+ }
+ ~AutoDBusConnection()
+ {
+ FUNCTION_CALL_TRACE;
+ LOG_DEBUG("Disconnecting dbus connection" << name());
+ disconnectFromBus(name());
+ }
+ };
+
+ // Thread Specific Storage to store the dbus connection to session bus for this thread
+ QThreadStorage<AutoDBusConnection*> sessionBusConnection;
+
+ // Thread Specific Storage to store the dbus connection to system bus for this thread
+ QThreadStorage<AutoDBusConnection*> systemBusConnection;
+
+ // Global Variables to give different connection names in different threads.
+ QAtomicInt sessionBusCounter = 0;
+ QAtomicInt systemBusCounter = 0;
+
+
+ QDBusConnection SyncDBusConnection::sessionBus()
+ {
+ FUNCTION_CALL_TRACE;
+ // Create a separate D-Bus connection to Session Bus for each thread.
+ // Use AutoDBusConnection so that the bus gets disconnected when the
+ // thread storage is deleted.
+ if (!sessionBusConnection.hasLocalData()) {
+ QString connectionName = QString::number(sessionBusCounter.fetchAndAddRelaxed(1))
+ .prepend("sync-session-bus-");
+ sessionBusConnection.setLocalData(new AutoDBusConnection
+ (QDBusConnection::connectToBus(QDBusConnection::SessionBus,connectionName)));
+ }
+
+#ifndef QT_NO_DEBUG
+ // creating a local variable only for debugging problems with strange backtraces.
+ QDBusConnection dbus = *sessionBusConnection.localData();
+ //warning level only to be sure this is printed always
+ LOG_WARNING("DBus Connection Address:" << &dbus );
+ LOG_WARNING("DBus Connection Name:" << dbus.name() );
+ LOG_DEBUG("DBus is Connected:" << dbus.isConnected() );
+ LOG_DEBUG("DBus Connection ID:" << dbus.baseService() );
+#endif
+
+ return *sessionBusConnection.localData();
+ }
+
+ QDBusConnection SyncDBusConnection::systemBus()
+ {
+ FUNCTION_CALL_TRACE;
+ // Create a separate D-Bus connection to System Bus for each thread.
+ // Use SyncDBusConnection so that the bus gets disconnected when the
+ // thread storage is deleted.
+ if (!systemBusConnection.hasLocalData()) {
+ QString connectionName = QString::number(systemBusCounter.fetchAndAddRelaxed(1))
+ .prepend("sync-system-bus-");
+ systemBusConnection.setLocalData(new AutoDBusConnection
+ (QDBusConnection::connectToBus(QDBusConnection::SystemBus,connectionName)));
+ }
+
+#ifndef QT_NO_DEBUG
+ // creating a local variable only for debugging problems with strange backtraces.
+ QDBusConnection dbus = *systemBusConnection.localData();
+ //warning level only to be sure this is printed always
+ LOG_WARNING("DBus Connection Address:" << &dbus );
+ LOG_WARNING("DBus Connection Name:" << dbus.name() );
+ LOG_DEBUG("DBus is Connected:" << dbus.isConnected() );
+ LOG_DEBUG("DBus Connection ID:" << dbus.baseService() );
+#endif
+
+ return *systemBusConnection.localData();
+ }
+
+
+};
+
+
--- libsynccommon/SyncDBusConnection.h
+++ libsynccommon/SyncDBusConnection.h
+/*
+ * This file is part of buteo-syncfw package
+ *
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Contact: Sateesh Kavuri <sateesh.kavuri at nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef SYNCDBUSCONNECTION_H
+#define SYNCDBUSCONNECTION_H
+
+#include <QDBusConnection>
+
+namespace Buteo {
+
+// this is a workaround for QDBusConnection::SessionBus as it is not thread safe.
+// Use this class as an alternative to QDBusConnection to get a thread private
+// dbus connection
+class SyncDBusConnection {
+
+public:
+
+ //! static function to retrieve a dbus connection to sessionBus
+ static QDBusConnection sessionBus();
+
+ //! static function to retrieve a dbus connection to systemBus
+ static QDBusConnection systemBus();
+
+private:
+ //! private constructor.
+ // Cannot Create Objects of this type
+ SyncDBusConnection() { }
+
+ //! destructor
+ ~SyncDBusConnection() { }
+};
+
+}
+
+#endif
--- libsynccommon/libsynccommon.pro
+++ libsynccommon/libsynccommon.pro
@@ -1,12 +1,11 @@
TEMPLATE = lib
-
VER_MAJ = 0
VER_MIN = 4
VER_PAT = 4
-
TARGET = synccommon
DEPENDPATH += .
INCLUDEPATH += .
+QT += dbus
QT -= gui
CONFIG += dll \
debug \
@@ -14,16 +13,15 @@
create_pc \
create_prl
-QMAKE_PKGCONFIG_DESTDIR = pkgconfig
-QMAKE_PKGCONFIG_LIBDIR = $$target.path
-QMAKE_PKGCONFIG_INCDIR = $$headers.path
-pkgconfig.files = $${TARGET}.pc
-
# Input
-SOURCES += Logger.cpp
+SOURCES += SyncDBusConnection.cpp \
+ Logger.cpp
+
HEADERS += Logger.h \
LogMacros.h \
- SyncCommonDefs.h
+ SyncCommonDefs.h \
+ SyncDBusConnection.h
+
QMAKE_CXXFLAGS += -Wall \
-g \
-Wno-cast-align \
@@ -36,17 +34,25 @@
$(TARGET1) \
$(TARGET2) \
$(OBJECTS_DIR)/moc_* \
- lib$${TARGET}.prl pkgconfig/*
+ lib$${TARGET}.prl \
+ pkgconfig/*
# install
target.path = /usr/lib/
-headers.path = /usr/include/libsynccommon
+headers.path = /usr/include/libsynccommon/
headers.files = LogMacros.h \
Logger.h \
- SyncCommonDefs.h
+ SyncCommonDefs.h \
+ SyncDBusConnection.h
+
INSTALLS += target \
headers
+QMAKE_PKGCONFIG_DESTDIR = pkgconfig
+QMAKE_PKGCONFIG_LIBDIR = $$target.path
+QMAKE_PKGCONFIG_INCDIR = $$headers.path
+pkgconfig.files = $${TARGET}.pc
+
# #####################################################################
# make coverage (debug)
# #####################################################################
--- libsyncfwclient/SyncClientInterface.cpp
+++ libsyncfwclient/SyncClientInterface.cpp
@@ -92,3 +92,15 @@
{
return d_ptr->getLastSyncResult(aProfileId);
}
+
+
+QList<QString /*profileAsXml*/> SyncClientInterface::allVisibleSyncProfiles()
+{
+ return d_ptr->allVisibleSyncProfiles();
+}
+
+
+QString SyncClientInterface::syncProfile(const QString &aProfileId)
+{
+ return d_ptr->syncProfile(aProfileId);
+}
--- libsyncfwclient/SyncClientInterface.h
+++ libsyncfwclient/SyncClientInterface.h
@@ -161,6 +161,24 @@
*/
Buteo::SyncResults getLastSyncResult(const QString &aProfileId);
+ /*! \brief Gets all visible sync profiles.
+ *
+ * Returns all sync profiles that should be visible in sync ui. A profile
+ * is visible if it has not been explicitly set as hidden.
+ * \return The list of sync profiles.
+ */
+ QList<QString /*profileAsXml*/> allVisibleSyncProfiles();
+
+ /*! \brief Gets a sync profile.
+ *
+ * Loads and merges also all sub-profiles that are referenced from the
+ * main profile. Loads the log of finished synchronization sessions with
+ * this profile.
+ * \param aProfileId Name of the profile to get.
+ * \return The sync profile as Xml string.
+ */
+ QString syncProfile(const QString &aProfileId);
+
signals:
/*! \brief Notifies about Backup start.
@@ -200,10 +218,10 @@
* 0 (ADDITION): Profile was added.
* 1 (MODIFICATION): Profile was modified.
* 2 (DELETION): Profile was deleted.
- * \param aChangedProfile Updated Sync Profile Object
+ * \param aChangedProfile changed sync profie as XMl string.
*
*/
- void profileChanged(QString aProfileId,int aChangeType,Buteo::SyncProfile aChangedProfile);
+ void profileChanged(QString aProfileId,int aChangeType, QString aChangedProfile);
/*! \brief Notifies about the results of a recent sync for a profile
*
--- libsyncfwclient/SyncClientInterfacePrivate.cpp
+++ libsyncfwclient/SyncClientInterfacePrivate.cpp
@@ -23,6 +23,7 @@
#include <QString>
#include <QDomDocument>
+#include <libsyncprofile/ProfileManager.h>
#include <libsyncprofile/SyncProfile.h>
#include <libsyncprofile/SyncResults.h>
#include <libsyncprofile/SyncSchedule.h>
@@ -33,31 +34,42 @@
using namespace Buteo;
static const QString SYNC_DBUS_OBJECT = "/synchronizer";
-static const QString SYNC_DBUS_SERVICE = "com.nokia.msyncd";
+static const QString SYNC_DBUS_SERVICE = "com.meego.msyncd";
SyncClientInterfacePrivate::SyncClientInterfacePrivate(SyncClientInterface *aParent) :
- iParent(aParent) {
+ iParent(aParent)
+{
+ FUNCTION_CALL_TRACE;
iSyncDaemon = new SyncDaemonProxy(SYNC_DBUS_SERVICE, SYNC_DBUS_OBJECT,
QDBusConnection::sessionBus(), this);
if (iSyncDaemon) {
connect(iSyncDaemon,SIGNAL(signalProfileChanged(QString,int,QString)),
- this,SLOT(profileChanged(QString,int,QString)));
+ this,SLOT(slotProfileChanged(QString,int,QString)));
+
connect(iSyncDaemon, SIGNAL(resultsAvailable(QString, QString)), this,
SLOT(resultsAvailable(QString, QString)));
- connect(this,SIGNAL(profileChanged(QString,int,Buteo::SyncProfile)),
- iParent,SIGNAL(profileChanged(QString,int,Buteo::SyncProfile)));
+
+ connect(this,SIGNAL(profileChanged(QString, int, QString)),
+ iParent,SIGNAL(profileChanged(QString, int, QString)));
+
connect(this,SIGNAL(resultsAvailable(QString,Buteo::SyncResults)),
iParent,SIGNAL(resultsAvailable(QString,Buteo::SyncResults)));
+
connect (iSyncDaemon,SIGNAL(syncStatus(QString,int,QString,int)),
iParent,SIGNAL(syncStatus(QString,int,QString,int)));
+
connect(iSyncDaemon,SIGNAL(transferProgress(QString,int,int,QString,int)),
iParent,SIGNAL(transferProgress(QString,int,int,QString,int)));
+
connect(iSyncDaemon, SIGNAL(backupInProgress()),
iParent, SIGNAL(backupInProgress()));
+
connect(iSyncDaemon, SIGNAL(backupDone()),
iParent, SIGNAL(backupDone()));
+
connect(iSyncDaemon, SIGNAL(restoreInProgress()),
iParent, SIGNAL(restoreInProgress()));
+
connect(iSyncDaemon, SIGNAL(restoreDone()),
iParent, SIGNAL(restoreDone()));
}
@@ -67,12 +79,14 @@
SyncClientInterfacePrivate::~SyncClientInterfacePrivate()
{
+ FUNCTION_CALL_TRACE;
delete iSyncDaemon;
iSyncDaemon = NULL;
}
bool SyncClientInterfacePrivate::startSync(const QString &aProfileId) const
{
+ FUNCTION_CALL_TRACE;
bool syncStatus = false;
if (iSyncDaemon && !aProfileId.isEmpty()) {
@@ -84,6 +98,7 @@
void SyncClientInterfacePrivate::abortSync(const QString &aProfileId) const
{
+ FUNCTION_CALL_TRACE;
if (iSyncDaemon && !aProfileId.isEmpty()) {
iSyncDaemon->abortSync(aProfileId);
}
@@ -91,6 +106,7 @@
QStringList SyncClientInterfacePrivate::getRunningSyncList()
{
+ FUNCTION_CALL_TRACE;
QStringList runningSyncList;
if (iSyncDaemon) {
runningSyncList = iSyncDaemon->runningSyncs();
@@ -100,6 +116,7 @@
bool SyncClientInterfacePrivate::addProfile(Buteo::SyncProfile &aProfile)
{
+ FUNCTION_CALL_TRACE;
bool status = false;
if (iSyncDaemon) {
QString profileAsXmlString = aProfile.toString();
@@ -110,6 +127,7 @@
bool SyncClientInterfacePrivate::removeProfile(QString &aProfileId)
{
+ FUNCTION_CALL_TRACE;
bool status = false;
if (iSyncDaemon) {
status = iSyncDaemon->removeProfile(aProfileId);
@@ -119,6 +137,7 @@
bool SyncClientInterfacePrivate::updateProfile(Buteo::SyncProfile &aProfile)
{
+ FUNCTION_CALL_TRACE;
bool status = false;
if (iSyncDaemon) {
QString profileAsXmlString = aProfile.toString();
@@ -127,21 +146,17 @@
return status;
}
-void SyncClientInterfacePrivate::profileChanged(QString aProfileId,int aChangeType,
+void SyncClientInterfacePrivate::slotProfileChanged(QString aProfileId,int aChangeType,
QString aProfileAsXml)
{
- QDomDocument doc;
- if (doc.setContent(aProfileAsXml, true)) {
- Buteo::SyncProfile profile(doc.documentElement());
- emit profileChanged(aProfileId,aChangeType,profile);
- } else {
- LOG_DEBUG("Invalid Profile Xml Received from msyncd");
- }
+ FUNCTION_CALL_TRACE;
+ emit profileChanged(aProfileId,aChangeType,aProfileAsXml);
}
void SyncClientInterfacePrivate::resultsAvailable(QString aProfileId,
QString aLastResultsAsXml)
{
+ FUNCTION_CALL_TRACE;
QDomDocument doc;
if (doc.setContent(aLastResultsAsXml, true)) {
Buteo::SyncResults results(doc.documentElement());
@@ -154,6 +169,7 @@
bool SyncClientInterfacePrivate::setSyncSchedule(QString &aProfileId,
SyncSchedule &aSchedule)
{
+ FUNCTION_CALL_TRACE;
bool status = false;
if (iSyncDaemon) {
QString scheduleAsXmlString = aSchedule.toString();
@@ -168,6 +184,7 @@
bool SyncClientInterfacePrivate::saveSyncResults(const QString &aProfileId,
const Buteo::SyncResults &aSyncResults)
{
+ FUNCTION_CALL_TRACE;
bool status = false;
if (iSyncDaemon) {
QString resultsAsXmlString = aSyncResults.toString();
@@ -180,6 +197,7 @@
bool SyncClientInterfacePrivate::getBackUpRestoreState()
{
+ FUNCTION_CALL_TRACE;
bool status = false;
if (iSyncDaemon) {
status = iSyncDaemon->getBackUpRestoreState();
@@ -194,7 +212,10 @@
Buteo::SyncResults SyncClientInterfacePrivate::getLastSyncResult(const QString &aProfileId)
{
- Buteo::SyncResults syncResult(QDateTime::currentDateTime(),
+ FUNCTION_CALL_TRACE;
+ // Default construct with invalid values
+ // Using default constructor for QDateTime() creates "null" date.
+ Buteo::SyncResults syncResult(QDateTime(),
SyncResults::SYNC_RESULT_INVALID, Buteo::SyncResults::SYNC_RESULT_INVALID);
if (iSyncDaemon) {
@@ -211,3 +232,32 @@
}
return syncResult;
}
+
+QList<QString /*profilesAsXml*/> SyncClientInterfacePrivate::allVisibleSyncProfiles()
+{
+ FUNCTION_CALL_TRACE;
+ QList <QString> profilesAsXml;
+ if (iSyncDaemon) {
+ QStringList profilesList = iSyncDaemon->allVisibleSyncProfiles();
+ if (!profilesList.isEmpty()) {
+ foreach(QString profileAsXml, profilesList) {
+ profilesAsXml.append(profileAsXml);
+ }
+ }
+ }
+ LOG_DEBUG("allVisibleSyncProfiles "<<profilesAsXml);
+ return profilesAsXml;
+}
+
+
+QString SyncClientInterfacePrivate::syncProfile(const QString &aProfileId)
+{
+ FUNCTION_CALL_TRACE;
+ QString profileAsXml;
+ if (iSyncDaemon) {
+ profileAsXml = iSyncDaemon->syncProfile(aProfileId);
+ }
+
+ LOG_DEBUG("syncProfile "<<profileAsXml);
+ return profileAsXml;
+}
--- libsyncfwclient/SyncClientInterfacePrivate.h
+++ libsyncfwclient/SyncClientInterfacePrivate.h
@@ -125,6 +125,24 @@
*/
Buteo::SyncResults getLastSyncResult(const QString &aProfileId);
+ /*! \brief Gets all visible sync profiles.
+ *
+ * Returns all sync profiles that should be visible in sync ui. A profile
+ * is visible if it has not been explicitly set as hidden.
+ * \return The list of sync profiles.
+ */
+ QList<QString /*profileAsXml*/> allVisibleSyncProfiles();
+
+ /*! \brief Gets a sync profile.
+ *
+ * Loads and merges also all sub-profiles that are referenced from the
+ * main profile. Loads the log of finished synchronization sessions with
+ * this profile.
+ * \param aProfileId Name of the profile to get.
+ * \return The sync profile as Xml string.
+ */
+ QString syncProfile(const QString &aProfileId);
+
public slots:
/*! \brief this is the slot where we will receive the xml data for profile from msyncd.
@@ -151,7 +169,7 @@
* @param aChangedProfileAsXml - changed profile arrives as xml
*
*/
- void profileChanged(QString aProfileId , int aChangeType , QString aChangedProfileAsXml);
+ void slotProfileChanged(QString aProfileId , int aChangeType , QString aChangedProfileAsXml);
/*! \brief this is the slot where we will receive the xml data for results from msyncd
* the xml looks like this
@@ -173,9 +191,9 @@
*
* @param aProfileId - id of the profile
* @param aChangeType - change type whether addition , deletion or modification
- * @param aChangedProfile - changed sync profile object
+ * @param aChangedProfile - changed sync profie as XMl string.
*/
- void profileChanged(QString aProfileId,int aChangeType,Buteo::SyncProfile aChangedProfile);
+ void profileChanged(QString aProfileId,int aChangeType, QString aChangedProfile);
/*! \brief Signal that gets emitted on receiving resultsAvailable from msyncd
*
--- libsyncfwclient/SyncDaemonProxy.cpp
+++ libsyncfwclient/SyncDaemonProxy.cpp
@@ -23,7 +23,7 @@
/*
* This file was generated by qdbusxml2cpp version 0.7
- * Command line was: qdbusxml2cpp -p SyncDaemonProxy -N -c SyncDaemonProxy com.nokia.msyncd.xml
+ * Command line was: qdbusxml2cpp -p SyncDaemonProxy -N -c SyncDaemonProxy com.meego.msyncd.xml
*
* qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
--- libsyncfwclient/SyncDaemonProxy.h
+++ libsyncfwclient/SyncDaemonProxy.h
@@ -23,7 +23,7 @@
/*
* This file was generated by qdbusxml2cpp version 0.7
- * Command line was: qdbusxml2cpp -p SyncDaemonProxy -N -c SyncDaemonProxy com.nokia.msyncd.xml
+ * Command line was: qdbusxml2cpp -p SyncDaemonProxy -N -c SyncDaemonProxy com.meego.msyncd.xml
*
* qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
@@ -43,7 +43,7 @@
#include <QtCore/QVariant>
#include <QtDBus/QtDBus>
-/*! \brief Proxy class for interface com.nokia.msyncd
+/*! \brief Proxy class for interface com.meego.msyncd
*/
class SyncDaemonProxy: public QDBusAbstractInterface
{
@@ -51,7 +51,7 @@
public:
//! \brief returns Interface Name
static inline const char *staticInterfaceName()
- { return "com.nokia.msyncd"; }
+ { return "com.meego.msyncd"; }
public:
//! \see SyncDBusInterface::SyncDBusInterface()
@@ -78,6 +78,13 @@
return asyncCallWithArgumentList(QLatin1String("addProfile"), argumentList);
}
+ //! \see SyncDBusInterface::allVisibleSyncProfiles()
+ inline QDBusPendingReply<QStringList> allVisibleSyncProfiles()
+ {
+ QList<QVariant> argumentList;
+ return callWithArgumentList(QDBus::Block, QLatin1String("allVisibleSyncProfiles"), argumentList);
+ }
+
//! \see SyncDBusInterface::getBackUpRestoreState()
inline QDBusPendingReply<bool> getBackUpRestoreState()
{
@@ -179,6 +186,14 @@
return asyncCallWithArgumentList(QLatin1String("startSync"), argumentList);
}
+ //! \see SyncDBusInterface::syncProfile()
+ inline QDBusPendingReply<QString> syncProfile(const QString &aProfileId)
+ {
+ QList<QVariant> argumentList;
+ argumentList << qVariantFromValue(aProfileId);
+ return callWithArgumentList(QDBus::Block, QLatin1String("syncProfile"), argumentList);
+ }
+
//! \see SyncDBusInterface::updateProfile()
inline QDBusPendingReply<bool> updateProfile(const QString &aProfileAsXml)
{
--- libsyncfwclient/libsyncfwclient.pro
+++ libsyncfwclient/libsyncfwclient.pro
@@ -15,11 +15,6 @@
create_pc \
create_prl
-QMAKE_PKGCONFIG_DESTDIR = pkgconfig
-QMAKE_PKGCONFIG_LIBDIR = $$target.path
-QMAKE_PKGCONFIG_INCDIR = $$headers.path
-pkgconfig.files = $${TARGET}.pc
-
LIBS += -L../libsyncprofile/ \
-lsyncprofile
@@ -52,6 +47,11 @@
INSTALLS += target \
headers
+QMAKE_PKGCONFIG_DESTDIR = pkgconfig
+QMAKE_PKGCONFIG_LIBDIR = $$target.path
+QMAKE_PKGCONFIG_INCDIR = $$headers.path
+pkgconfig.files = $${TARGET}.pc
+
# #####################################################################
# make coverage (debug)
# #####################################################################
--- libsyncpluginmgr/libsyncpluginmgr.pro
+++ libsyncpluginmgr/libsyncpluginmgr.pro
@@ -18,11 +18,6 @@
CONFIG += dll debug silent create_pc create_prl
-QMAKE_PKGCONFIG_DESTDIR = pkgconfig
-QMAKE_PKGCONFIG_LIBDIR = $$target.path
-QMAKE_PKGCONFIG_INCDIR = $$headers.path
-pkgconfig.files = $${TARGET}.pc
-
QT+=sql
QT -= gui
@@ -74,6 +69,11 @@
DeletedItemsIdStorage.h
INSTALLS += target headers
+QMAKE_PKGCONFIG_DESTDIR = pkgconfig
+QMAKE_PKGCONFIG_LIBDIR = $$target.path
+QMAKE_PKGCONFIG_INCDIR = $$headers.path
+pkgconfig.files = $${TARGET}.pc
+
# #####################################################################
# make coverage (debug)
# #####################################################################
--- libsyncprofile/ProfileManager.cpp
+++ libsyncprofile/ProfileManager.cpp
@@ -20,860 +20,922 @@
* 02110-1301 USA
*
*/
-
-#include "ProfileManager.h"
-
-#include <QDir>
-#include <QFile>
-#include <QTextStream>
-#include <QDomDocument>
-
-#include "ProfileFactory.h"
-#include "ProfileEngineDefs.h"
-
-#include "LogMacros.h"
-#include "BtHelper.h"
-
-namespace Buteo {
-
-static const QString FORMAT_EXT = ".xml";
-static const QString BACKUP_EXT = ".bak";
-static const QString LOG_EXT = ".log";
-static const QString LOG_DIRECTORY = "logs";
-static const QString BT_PROFILE_TEMPLATE("bt_template");
-
-const QString ProfileManager::DEFAULT_PRIMARY_PROFILE_PATH =
- QDir::homePath() + "/.sync/profiles";
-const QString ProfileManager::DEFAULT_SECONDARY_PROFILE_PATH =
- "/etc/sync/profiles";
-
-// Private implementation class for ProfileManager.
-class ProfileManagerPrivate
-{
-public:
- ProfileManagerPrivate(const QString &aPrimaryPath,
- const QString &aSecondaryPath);
-
- /*! \brief Loads a profile from persistent storage.
- *
- * \param aName Name of the profile to load.
- * \param aType Type of the profile to load.
- * \return The loaded profile. 0 if the profile was not found.
- */
- Profile *load(const QString &aName, const QString &aType);
-
- /*! \brief Loads the synchronization log associated with the given profile.
- *
- * \param aProfileName Name of the sync profile whose log shall be loaded.
- * \return The loaded log. 0 if the log was not found.
- */
- SyncLog *loadLog(const QString &aProfileName);
-
- bool parseFile(const QString &aPath, QDomDocument &aDoc);
-
- void restoreBackupIfFound(const QString &aProfilePath,
- const QString &aBackupPath);
-
- QDomDocument constructProfileDocument(const Profile &aProfile);
-
- bool writeProfileFile(const QString &aProfilePath, const QDomDocument &aDoc);
-
- QString findProfileFile(const QString &aName, const QString &aType);
-
- bool createBackup(const QString &aProfilePath, const QString &aBackupPath);
-
- bool matchProfile(const Profile &aProfile,
- const ProfileManager::SearchCriteria &aCriteria);
-
- bool matchKey(const Profile &aProfile,
- const ProfileManager::SearchCriteria &aCriteria);
-
- // Primary path for profiles.
- QString iPrimaryPath;
-
- // Secondary path for profiles.
- QString iSecondaryPath;
-
-
-};
-
-}
-
-using namespace Buteo;
-
-ProfileManagerPrivate::ProfileManagerPrivate(const QString &aPrimaryPath,
- const QString &aSecondaryPath)
-: iPrimaryPath(aPrimaryPath),
- iSecondaryPath(aSecondaryPath)
-{
- if (iPrimaryPath.endsWith(QDir::separator()))
- {
- iPrimaryPath.chop(1);
- } // no else
- if (iSecondaryPath.endsWith(QDir::separator()))
- {
- iSecondaryPath.chop(1);
- } // no else
-
- LOG_DEBUG("Primary profile path set to" << iPrimaryPath);
- LOG_DEBUG("Secondary profile path set to" << iSecondaryPath);
-}
-
-Profile *ProfileManagerPrivate::load(const QString &aName, const QString &aType)
-{
- QString profilePath = findProfileFile(aName, aType);
- QString backupProfilePath = profilePath + BACKUP_EXT;
-
- QDomDocument doc;
- Profile* profile = 0;
-
- restoreBackupIfFound(profilePath, backupProfilePath);
-
- if (parseFile(profilePath, doc))
- {
- ProfileFactory pf;
- profile = pf.createProfile(doc.documentElement());
-
- if (QFile::exists(backupProfilePath))
- {
- QFile::remove(backupProfilePath);
- }
- }
- else {
- LOG_WARNING("Failed to load profile:" << aName);
- }
-
- return profile;
-}
-
-SyncLog *ProfileManagerPrivate::loadLog(const QString &aProfileName)
-{
- QString fileName = iPrimaryPath + QDir::separator() + Profile::TYPE_SYNC + QDir::separator() +
- LOG_DIRECTORY + QDir::separator() + aProfileName + LOG_EXT + FORMAT_EXT;
-
- if (!QFile::exists(fileName))
- {
- LOG_DEBUG("No sync log found for profile:" << aProfileName);
- return 0;
- } // no else
-
- QFile file(fileName);
- if (!file.open(QIODevice::ReadOnly))
- {
- LOG_WARNING("Failed to open sync log file for reading:"
- << file.fileName());
- return 0;
- } // no else
-
- QDomDocument doc;
- if (!doc.setContent(&file)) {
- file.close();
- LOG_WARNING("Failed to parse XML from sync log file:"
- << file.fileName());
- return 0;
- } // no else
- file.close();
-
- return new SyncLog(doc.documentElement());
-}
-
-bool ProfileManagerPrivate::matchProfile(const Profile &aProfile,
- const ProfileManager::SearchCriteria &aCriteria)
-{
- bool matched = false;
-
- const Profile *testProfile = &aProfile;
- if (!aCriteria.iSubProfileName.isEmpty())
- {
- // Sub-profile name was given, request a sub-profile with a
- // matching name and type.
- testProfile = aProfile.subProfile(aCriteria.iSubProfileName,
- aCriteria.iSubProfileType);
-
- if (testProfile != 0)
- {
- matched = matchKey(*testProfile, aCriteria);
- }
- else
- {
- if (aCriteria.iType == ProfileManager::SearchCriteria::NOT_EXISTS)
- {
- matched = true;
- }
- else
- {
- matched = false;
- }
- }
- }
- else if (!aCriteria.iSubProfileType.isEmpty())
- {
- // Sub-profile name was empty, but type was given. Get all
- // sub-profiles with the matching type.
- QStringList subProfileNames =
- aProfile.subProfileNames(aCriteria.iSubProfileType);
- if (!subProfileNames.isEmpty())
- {
- matched = false;
- foreach (const QString &subProfileName, subProfileNames)
- {
- testProfile = aProfile.subProfile(subProfileName,
- aCriteria.iSubProfileType);
- if (testProfile != 0 && matchKey(*testProfile, aCriteria))
- {
- matched = true;
- break;
- }
- }
- }
- else
- {
- if (aCriteria.iType == ProfileManager::SearchCriteria::NOT_EXISTS)
- {
- matched = true;
- }
- else
- {
- matched = false;
- }
- }
- }
- else
- {
- matched = matchKey(aProfile, aCriteria);
- }
-
- return matched;
-}
-
-bool ProfileManagerPrivate::matchKey(const Profile &aProfile,
- const ProfileManager::SearchCriteria &aCriteria)
-{
- bool matched = false;
-
- if (!aCriteria.iKey.isEmpty())
- {
- // Key name was given, get a key with matching name.
- QString value = aProfile.key(aCriteria.iKey);
-
- if (value.isNull())
- {
- if (aCriteria.iType == ProfileManager::SearchCriteria::NOT_EXISTS ||
- aCriteria.iType == ProfileManager::SearchCriteria::NOT_EQUAL)
- {
- matched = true;
- }
- else
- {
- matched = false;
- }
- }
- else
- {
- switch (aCriteria.iType)
- {
- case ProfileManager::SearchCriteria::EXISTS:
- matched = true;
- break;
-
- case ProfileManager::SearchCriteria::NOT_EXISTS:
- matched = false;
- break;
-
- case ProfileManager::SearchCriteria::EQUAL:
- matched = (value == aCriteria.iValue);
- break;
-
- case ProfileManager::SearchCriteria::NOT_EQUAL:
- matched = (value != aCriteria.iValue);
- break;
-
- default:
- matched = false;
- break;
- }
- }
- }
- else
- {
- if (aCriteria.iType == ProfileManager::SearchCriteria::NOT_EXISTS)
- {
- matched = false;
- }
- else
- {
- matched = true;
- }
- }
-
- return matched;
-}
-
-ProfileManager::SearchCriteria::SearchCriteria()
-: iType(ProfileManager::SearchCriteria::EQUAL)
-{
-}
-
-ProfileManager::SearchCriteria::SearchCriteria(const SearchCriteria &aSource)
-: iType(aSource.iType),
- iSubProfileName(aSource.iSubProfileName),
- iSubProfileType(aSource.iSubProfileType),
- iKey(aSource.iKey),
- iValue(aSource.iValue)
-{
-}
-
-ProfileManager::ProfileManager(const QString &aPrimaryPath,
- const QString &aSecondaryPath)
-: d_ptr(new ProfileManagerPrivate(aPrimaryPath, aSecondaryPath))
-{
-}
-
-ProfileManager::~ProfileManager()
-{
- delete d_ptr;
- d_ptr = 0;
-}
-
-Profile *ProfileManager::profile(const QString &aName, const QString &aType)
-{
- return d_ptr->load(aName, aType);
-}
-
-SyncProfile *ProfileManager::syncProfile(const QString &aName)
-{
- Profile *p = profile(aName, Profile::TYPE_SYNC);
- SyncProfile *syncProfile = 0;
- if (p != 0 && p->type() == Profile::TYPE_SYNC)
- {
- // RTTI is not allowed, use static_cast. Should be safe, because
- // type is verified.
- syncProfile = static_cast<SyncProfile*>(p);
-
- // Load and merge all sub-profiles.
- expand(*syncProfile);
-
- // Load sync log. If not found, create an empty log.
- if (syncProfile->log() == 0)
- {
- SyncLog *log = d_ptr->loadLog(aName);
- if (0 == log)
- {
- log = new SyncLog(aName);
- } // no else
- syncProfile->setLog(log);
- } // no else
+
+#include "ProfileManager.h"
+
+#include <QDir>
+#include <QFile>
+#include <QTextStream>
+#include <QDomDocument>
+
+#include "ProfileFactory.h"
+#include "ProfileEngineDefs.h"
+
+#include "LogMacros.h"
+#include "BtHelper.h"
+
+namespace Buteo {
+
+static const QString FORMAT_EXT = ".xml";
+static const QString BACKUP_EXT = ".bak";
+static const QString LOG_EXT = ".log";
+static const QString LOG_DIRECTORY = "logs";
+static const QString BT_PROFILE_TEMPLATE("bt_template");
+
+const QString ProfileManager::DEFAULT_PRIMARY_PROFILE_PATH =
+ QDir::homePath() + "/.sync/profiles";
+const QString ProfileManager::DEFAULT_SECONDARY_PROFILE_PATH =
+ "/etc/sync/profiles";
+
+// Private implementation class for ProfileManager.
+class ProfileManagerPrivate
+{
+public:
+ ProfileManagerPrivate(const QString &aPrimaryPath,
+ const QString &aSecondaryPath);
+
+ /*! \brief Loads a profile from persistent storage.
+ *
+ * \param aName Name of the profile to load.
+ * \param aType Type of the profile to load.
+ * \return The loaded profile. 0 if the profile was not found.
+ */
+ Profile *load(const QString &aName, const QString &aType);
+
+ /*! \brief Loads the synchronization log associated with the given profile.
+ *
+ * \param aProfileName Name of the sync profile whose log shall be loaded.
+ * \return The loaded log. 0 if the log was not found.
+ */
+ SyncLog *loadLog(const QString &aProfileName);
+
+ bool parseFile(const QString &aPath, QDomDocument &aDoc);
+
+ void restoreBackupIfFound(const QString &aProfilePath,
+ const QString &aBackupPath);
+
+ QDomDocument constructProfileDocument(const Profile &aProfile);
+
+ bool writeProfileFile(const QString &aProfilePath, const QDomDocument &aDoc);
+
+ QString findProfileFile(const QString &aName, const QString &aType);
+
+ bool createBackup(const QString &aProfilePath, const QString &aBackupPath);
+
+ bool matchProfile(const Profile &aProfile,
+ const ProfileManager::SearchCriteria &aCriteria);
+
+ bool matchKey(const Profile &aProfile,
+ const ProfileManager::SearchCriteria &aCriteria);
+
+ bool save(const Profile &aProfile);
+
+ bool remove(const QString &aName, const QString &aType);
+
+ bool profileExists(const QString &aProfileId ,const QString &aType);
+
+ // Primary path for profiles.
+ QString iPrimaryPath;
+
+ // Secondary path for profiles.
+ QString iSecondaryPath;
+
+
+};
+
+}
+
+using namespace Buteo;
+
+ProfileManagerPrivate::ProfileManagerPrivate(const QString &aPrimaryPath,
+ const QString &aSecondaryPath)
+: iPrimaryPath(aPrimaryPath),
+ iSecondaryPath(aSecondaryPath)
+{
+ if (iPrimaryPath.endsWith(QDir::separator()))
+ {
+ iPrimaryPath.chop(1);
+ } // no else
+ if (iSecondaryPath.endsWith(QDir::separator()))
+ {
+ iSecondaryPath.chop(1);
+ } // no else
+
+ LOG_DEBUG("Primary profile path set to" << iPrimaryPath);
+ LOG_DEBUG("Secondary profile path set to" << iSecondaryPath);
+}
+
+Profile *ProfileManagerPrivate::load(const QString &aName, const QString &aType)
+{
+ QString profilePath = findProfileFile(aName, aType);
+ QString backupProfilePath = profilePath + BACKUP_EXT;
+
+ QDomDocument doc;
+ Profile* profile = 0;
+
+ restoreBackupIfFound(profilePath, backupProfilePath);
+
+ if (parseFile(profilePath, doc))
+ {
+ ProfileFactory pf;
+ profile = pf.createProfile(doc.documentElement());
+
+ if (QFile::exists(backupProfilePath))
+ {
+ QFile::remove(backupProfilePath);
+ }
+ }
+ else {
+ LOG_WARNING("Failed to load profile:" << aName);
+ }
+
+ return profile;
+}
+
+SyncLog *ProfileManagerPrivate::loadLog(const QString &aProfileName)
+{
+ QString fileName = iPrimaryPath + QDir::separator() + Profile::TYPE_SYNC + QDir::separator() +
+ LOG_DIRECTORY + QDir::separator() + aProfileName + LOG_EXT + FORMAT_EXT;
+
+ if (!QFile::exists(fileName))
+ {
+ LOG_DEBUG("No sync log found for profile:" << aProfileName);
+ return 0;
+ } // no else
+
+ QFile file(fileName);
+ if (!file.open(QIODevice::ReadOnly))
+ {
+ LOG_WARNING("Failed to open sync log file for reading:"
+ << file.fileName());
+ return 0;
+ } // no else
+
+ QDomDocument doc;
+ if (!doc.setContent(&file)) {
+ file.close();
+ LOG_WARNING("Failed to parse XML from sync log file:"
+ << file.fileName());
+ return 0;
+ } // no else
+ file.close();
+
+ return new SyncLog(doc.documentElement());
+}
+
+bool ProfileManagerPrivate::matchProfile(const Profile &aProfile,
+ const ProfileManager::SearchCriteria &aCriteria)
+{
+ bool matched = false;
+
+ const Profile *testProfile = &aProfile;
+ if (!aCriteria.iSubProfileName.isEmpty())
+ {
+ // Sub-profile name was given, request a sub-profile with a
+ // matching name and type.
+ testProfile = aProfile.subProfile(aCriteria.iSubProfileName,
+ aCriteria.iSubProfileType);
+
+ if (testProfile != 0)
+ {
+ matched = matchKey(*testProfile, aCriteria);
+ }
+ else
+ {
+ if (aCriteria.iType == ProfileManager::SearchCriteria::NOT_EXISTS)
+ {
+ matched = true;
+ }
+ else
+ {
+ matched = false;
+ }
+ }
+ }
+ else if (!aCriteria.iSubProfileType.isEmpty())
+ {
+ // Sub-profile name was empty, but type was given. Get all
+ // sub-profiles with the matching type.
+ QStringList subProfileNames =
+ aProfile.subProfileNames(aCriteria.iSubProfileType);
+ if (!subProfileNames.isEmpty())
+ {
+ matched = false;
+ foreach (const QString &subProfileName, subProfileNames)
+ {
+ testProfile = aProfile.subProfile(subProfileName,
+ aCriteria.iSubProfileType);
+ if (testProfile != 0 && matchKey(*testProfile, aCriteria))
+ {
+ matched = true;
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (aCriteria.iType == ProfileManager::SearchCriteria::NOT_EXISTS)
+ {
+ matched = true;
+ }
+ else
+ {
+ matched = false;
+ }
+ }
+ }
+ else
+ {
+ matched = matchKey(aProfile, aCriteria);
+ }
+
+ return matched;
+}
+
+bool ProfileManagerPrivate::matchKey(const Profile &aProfile,
+ const ProfileManager::SearchCriteria &aCriteria)
+{
+ bool matched = false;
+
+ if (!aCriteria.iKey.isEmpty())
+ {
+ // Key name was given, get a key with matching name.
+ QString value = aProfile.key(aCriteria.iKey);
+
+ if (value.isNull())
+ {
+ if (aCriteria.iType == ProfileManager::SearchCriteria::NOT_EXISTS ||
+ aCriteria.iType == ProfileManager::SearchCriteria::NOT_EQUAL)
+ {
+ matched = true;
+ }
+ else
+ {
+ matched = false;
+ }
+ }
+ else
+ {
+ switch (aCriteria.iType)
+ {
+ case ProfileManager::SearchCriteria::EXISTS:
+ matched = true;
+ break;
+
+ case ProfileManager::SearchCriteria::NOT_EXISTS:
+ matched = false;
+ break;
+
+ case ProfileManager::SearchCriteria::EQUAL:
+ matched = (value == aCriteria.iValue);
+ break;
+
+ case ProfileManager::SearchCriteria::NOT_EQUAL:
+ matched = (value != aCriteria.iValue);
+ break;
+
+ default:
+ matched = false;
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (aCriteria.iType == ProfileManager::SearchCriteria::NOT_EXISTS)
+ {
+ matched = false;
+ }
+ else
+ {
+ matched = true;
+ }
+ }
+
+ return matched;
+}
+
+ProfileManager::SearchCriteria::SearchCriteria()
+: iType(ProfileManager::SearchCriteria::EQUAL)
+{
+}
+
+ProfileManager::SearchCriteria::SearchCriteria(const SearchCriteria &aSource)
+: iType(aSource.iType),
+ iSubProfileName(aSource.iSubProfileName),
+ iSubProfileType(aSource.iSubProfileType),
+ iKey(aSource.iKey),
+ iValue(aSource.iValue)
+{
+}
+
+ProfileManager::ProfileManager(const QString &aPrimaryPath,
+ const QString &aSecondaryPath)
+: d_ptr(new ProfileManagerPrivate(aPrimaryPath, aSecondaryPath))
+{
+}
+
+ProfileManager::~ProfileManager()
+{
+ delete d_ptr;
+ d_ptr = 0;
+}
+
+Profile *ProfileManager::profile(const QString &aName, const QString &aType)
+{
+ return d_ptr->load(aName, aType);
+}
+
+SyncProfile *ProfileManager::syncProfile(const QString &aName)
+{
+ Profile *p = profile(aName, Profile::TYPE_SYNC);
+ SyncProfile *syncProfile = 0;
+ if (p != 0 && p->type() == Profile::TYPE_SYNC)
+ {
+ // RTTI is not allowed, use static_cast. Should be safe, because
+ // type is verified.
+ syncProfile = static_cast<SyncProfile*>(p);
+
+ // Load and merge all sub-profiles.
+ expand(*syncProfile);
+
+ // Load sync log. If not found, create an empty log.
+ if (syncProfile->log() == 0)
+ {
+ SyncLog *log = d_ptr->loadLog(aName);
+ if (0 == log)
+ {
+ log = new SyncLog(aName);
+ } // no else
+ syncProfile->setLog(log);
+ } // no else
} else {
if (p != 0) {
delete p;
}
}
-
- return syncProfile;
-}
-
-QStringList ProfileManager::profileNames(const QString &aType)
-{
- // Search for all profile files from the primary directory
- QStringList names;
- QString nameFilter = QString("*") + FORMAT_EXT;
- {
- QDir dir(d_ptr->iPrimaryPath + QDir::separator() + aType);
- QFileInfoList fileInfoList = dir.entryInfoList(QStringList(nameFilter),
- QDir::Files | QDir::NoSymLinks);
- foreach (const QFileInfo &fileInfo, fileInfoList)
- {
- names.append(fileInfo.completeBaseName());
- }
- }
-
- // Search for all profile files from the secondary directory
- {
- QDir dir(d_ptr->iSecondaryPath + QDir::separator() + aType);
- QFileInfoList fileInfoList = dir.entryInfoList(QStringList(nameFilter),
- QDir::Files | QDir::NoSymLinks);
- foreach (const QFileInfo &fileInfo, fileInfoList)
- {
- // Add only if the list does not yet contain the name.
- QString profileName = fileInfo.completeBaseName();
- if (!names.contains(profileName))
- {
- names.append(profileName);
- }
- }
- }
-
- return names;
-}
-
-QList<SyncProfile*> ProfileManager::allSyncProfiles()
-{
- QList<SyncProfile*> profiles;
-
- QStringList names = profileNames(Profile::TYPE_SYNC);
- foreach (const QString &name, names)
- {
- SyncProfile *p = syncProfile(name);
- if (p != 0)
- {
- profiles.append(p);
- } // no else
- }
-
- return profiles;
-}
-
-QList<SyncProfile*> ProfileManager::allVisibleSyncProfiles()
-{
- QList<SyncProfile*> profiles = allSyncProfiles();
- QList<SyncProfile*> visibleProfiles;
- foreach (SyncProfile *p, profiles)
- {
- if (!p->isHidden())
- {
- visibleProfiles.append(p);
- }
- else
- {
- delete p;
- }
- }
-
- return visibleProfiles;
-}
-
-QList<SyncProfile*> ProfileManager::getSyncProfilesByData(
- const QString &aSubProfileName,
- const QString &aSubProfileType,
- const QString &aKey, const QString &aValue)
-{
- QList<SyncProfile*> allProfiles = allSyncProfiles();
- QList<SyncProfile*> matchingProfiles;
-
- foreach (SyncProfile *profile, allProfiles)
- {
- Profile *testProfile = profile;
- if (!aSubProfileName.isEmpty())
- {
- // Sub-profile name was given, request a sub-profile with a
- // matching name and type.
- testProfile = profile->subProfile(aSubProfileName, aSubProfileType);
- }
- else if (!aSubProfileType.isEmpty())
- {
- // Sub-profile name was empty, but type was given. Get the first
- // sub-profile with the matching type.
- QStringList subProfileNames =
- profile->subProfileNames(aSubProfileType);
- if (!subProfileNames.isEmpty())
- {
- testProfile = profile->subProfile(subProfileNames.first(),
- aSubProfileType);
- }
- else
- {
- testProfile = 0;
- }
- }
-
- if (0 == testProfile) // Sub-profile was not found.
- {
- delete profile;
- profile = 0;
- continue; // Not a match, continue with next profile.
- }
-
- if (!aKey.isEmpty())
- {
- // Key name was given, get a key with matching name.
- QString value = testProfile->key(aKey);
- if (value.isNull() || // Key was not found.
- (!aValue.isEmpty() && (value != aValue))) // Value didn't match
- {
- delete profile;
- profile = 0;
- continue; // Not a match, continue with next profile.
- } // no else
- } // no else
-
- // Match, add profile to the list to be returned.
- matchingProfiles.append(profile);
- }
-
- return matchingProfiles;
-}
-
-QList<SyncProfile*> ProfileManager::getSyncProfilesByData(
- const QList<SearchCriteria> &aCriteria)
-{
- QList<SyncProfile*> allProfiles = allSyncProfiles();
- QList<SyncProfile*> matchingProfiles;
-
- foreach (SyncProfile *profile, allProfiles)
- {
- bool matched = true;
- if (profile == 0)
- continue;
-
- foreach (const SearchCriteria &criteria, aCriteria)
- {
- if (!d_ptr->matchProfile(*profile, criteria))
- {
- matched = false;
- break;
- }
- }
-
- if (matched)
- {
- matchingProfiles.append(profile);
- }
- else
- {
- delete profile;
- profile = 0;
- }
- }
-
- return matchingProfiles;
-}
-
-QList<SyncProfile*> ProfileManager::getSyncProfilesByStorage(
- const QString &aStorageName, bool aStorageMustBeEnabled)
-{
- QList<SearchCriteria> criteriaList;
-
- // Require that the profile is not disabled.
- // Profile is enabled by default. Comparing with enabled = true would
- // not work, because the key may not exist at all, even if the profile
- // is enabled.
- SearchCriteria profileEnabled;
- profileEnabled.iType = SearchCriteria::NOT_EQUAL;
- profileEnabled.iKey = KEY_ENABLED;
- profileEnabled.iValue = BOOLEAN_FALSE;
- criteriaList.append(profileEnabled);
-
- // Profile must not be hidden.
- SearchCriteria profileVisible;
- profileVisible.iType = SearchCriteria::NOT_EQUAL;
- profileVisible.iKey = KEY_HIDDEN;
- profileVisible.iValue = BOOLEAN_TRUE;
- criteriaList.append(profileVisible);
-
- // Online service.
- SearchCriteria onlineService;
- onlineService.iType = SearchCriteria::EQUAL;
- onlineService.iSubProfileType = Profile::TYPE_SERVICE;
- // Service profile name is left empty. Key value is matched with all
- // found service sub-profiles, though there should be only one.
- onlineService.iKey = KEY_DESTINATION_TYPE;
- onlineService.iValue = VALUE_ONLINE;
- criteriaList.append(onlineService);
-
- // Storage must be supported.
- SearchCriteria storageSupported;
- storageSupported.iSubProfileName = aStorageName;
- storageSupported.iSubProfileType = Profile::TYPE_STORAGE;
- if (aStorageMustBeEnabled)
- {
- // Storage must be enabled also. Storages are disabled by default,
- // so we can compare with enabled = true.
- storageSupported.iType = SearchCriteria::EQUAL;
- storageSupported.iKey = KEY_ENABLED;
- storageSupported.iValue = BOOLEAN_TRUE;
- }
- else
- {
- // Existence of the storage sub-profile is sufficient.
- storageSupported.iType = SearchCriteria::EXISTS;
- }
- criteriaList.append(storageSupported);
-
- return getSyncProfilesByData(criteriaList);
-}
-
-
-bool ProfileManager::save(const Profile &aProfile)
-{
- QDomDocument doc = d_ptr->constructProfileDocument(aProfile);
- if (doc.isNull())
- {
- LOG_WARNING("No profile data to write");
- return false;
- }
-
- // Create path for the new profile file.
- QDir dir;
- dir.mkpath(d_ptr->iPrimaryPath + QDir::separator() + aProfile.type());
- QString profilePath(d_ptr->iPrimaryPath + QDir::separator() +
- aProfile.type() + QDir::separator() + aProfile.name() + FORMAT_EXT);
-
- // Create a backup of the existing profile file.
- QString oldProfilePath = d_ptr->findProfileFile(aProfile.type(), aProfile.name());
- QString backupPath = profilePath + BACKUP_EXT;
-
- if (QFile::exists(oldProfilePath) &&
- !d_ptr->createBackup(oldProfilePath, backupPath))
- {
- LOG_WARNING("Failed to create profile backup");
- }
-
- bool profileWritten = false;
- if (d_ptr->writeProfileFile(profilePath, doc))
- {
- QFile::remove(backupPath);
- profileWritten = true;
- }
- else
- {
- LOG_WARNING("Failed to save profile:" << aProfile.name());
- profileWritten = false;
- }
-
- return profileWritten;
-}
-
-SyncProfile *ProfileManager::createTempSyncProfile (const QString &destAddress, bool &saveNewProfile)
-{
- saveNewProfile = true;
- if (destAddress.contains("USB")) { //USB - PCSUite no requirement to save profile
- LOG_INFO("USB connect - pc");
- saveNewProfile = false;
- return new SyncProfile(destAddress);
- }
-
- BtHelper btHelp(destAddress);
- QMap <QString , QVariant> mapVal = btHelp.getDeviceProperties();
- uint classType = mapVal.value("Class").toInt();
- uint pcsuiteClass = 0x100; //Major Device Class - Computer!
-
- if (classType & pcsuiteClass) {
- LOG_INFO("Device major class is Computer"); // not required to save profile
- saveNewProfile = false;
- return new SyncProfile(destAddress);
- }
-
- QString profileDisplayName = mapVal.value("Name").toString();
- if (profileDisplayName.isEmpty()) {
- //Todo : What to show if name is empty !!
- //Fixes 171340
- profileDisplayName = QString ("qtn_sync_dest_name_device_default");
- }
-
- LOG_INFO("Profile Name :" << profileDisplayName);
- SyncProfile *tProfile = syncProfile(BT_PROFILE_TEMPLATE);
- Profile *service = tProfile->serviceProfile();
- if (service != 0) {
- tProfile->setKey(KEY_DISPLAY_NAME, profileDisplayName);
- QStringList keys ;
- keys << destAddress << service->name();
- tProfile->setName(keys);
- tProfile->setEnabled(true);
- tProfile->setBoolKey("hidden", false);
- service->setKey(KEY_BT_ADDRESS, destAddress);
- service->setKey(KEY_BT_NAME, profileDisplayName);
- } else {
- LOG_WARNING("No service profile, unable to update properties");
- }
-
- return tProfile;
-}
-
-
-void ProfileManager::enableStorages (Profile &aProfile,
- QMap<QString , bool> &aStorageMap)
-{
-
- QMapIterator<QString, bool> i(aStorageMap);
- LOG_INFO("ProfileManager::enableStorages");
- while (i.hasNext()) {
- i.next();
- Profile *profile = aProfile.subProfile(i.key(), Profile::TYPE_STORAGE);
- if (profile)
- profile->setEnabled(i.value());
- else
- LOG_WARNING("No storage profile by key :" << i.key());
- }
- return ;
-}
-
-bool ProfileManager::remove(const QString &aName, const QString &aType)
-{
- bool success = false;
- QString filePath = d_ptr->iPrimaryPath + QDir::separator() + aType + QDir::separator() + aName + FORMAT_EXT;
-
- // Try to load profile without expanding it. We need to check from the
- // profile data if the profile is protected before removing it.
- Profile *p = d_ptr->load(aName, aType);
- if (p)
- {
- if (!p->isProtected())
- {
- success = QFile::remove(filePath);
- if (success){
- QString logFilePath = d_ptr->iPrimaryPath + QDir::separator() + aType + QDir::separator() +
- LOG_DIRECTORY + QDir::separator() + aName + LOG_EXT + FORMAT_EXT;
- success = QFile::remove(logFilePath);
- }
- }
- else
- {
- LOG_DEBUG( "Cannot remove protected profile:" << aName );
- }
- delete p;
- p = 0;
- }
- else
- {
- LOG_DEBUG( "Profile not found from the primary path, cannot remove:" << aName );
- }
-
- return success;
-}
-
-void ProfileManager::expand(Profile &aProfile)
-{
- if (aProfile.isLoaded())
- return; // Already expanded.
-
- // Load and merge sub-profiles.
- int prevSubCount = 0;
- QList<Profile*> subProfiles = aProfile.allSubProfiles();
- int subCount = subProfiles.size();
- while (subCount > prevSubCount)
- {
- foreach (Profile *sub, subProfiles)
- {
- if (!sub->isLoaded())
- {
- Profile *loadedProfile = profile(sub->name(), sub->type());
- if (loadedProfile != 0)
- {
- aProfile.merge(*loadedProfile);
- delete loadedProfile;
- loadedProfile = 0;
- }
- else
- {
- // No separate profile file for the sub-profile.
- LOG_DEBUG( "Referenced sub-profile not found:" <<
- sub->name() );
- LOG_DEBUG( "Referenced from:" << aProfile.name() <<
- aProfile.type() );
- }
- sub->setLoaded(true);
- } // no else
- }
-
- // Load/merge may have created new sub-profile entries. Those need
- // to be loaded also. Loop if sub-profile count has changed.
- prevSubCount = subCount;
- subProfiles = aProfile.allSubProfiles();
- subCount = subProfiles.size();
- }
-
- aProfile.setLoaded(true);
-}
-
-bool ProfileManager::saveLog(const SyncLog &aLog)
-{
- QDir dir;
- QString fullPath = d_ptr->iPrimaryPath + QDir::separator() + Profile::TYPE_SYNC + QDir::separator() +
- LOG_DIRECTORY;
- dir.mkpath(fullPath);
- QFile file(fullPath + QDir::separator() + aLog.profileName() + LOG_EXT + FORMAT_EXT);
-
- if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
- {
- LOG_WARNING("Failed to open sync log file for writing:"
- << file.fileName());
- return false;
- } // no else
-
- QDomDocument doc;
- QDomProcessingInstruction xmlHeading =
- doc.createProcessingInstruction("xml",
- "version=\"1.0\" encoding=\"UTF-8\"");
- doc.appendChild(xmlHeading);
-
- QDomElement root = aLog.toXml(doc);
- if (root.isNull())
- {
- LOG_WARNING("Failed to convert sync log to XML");
- return false;
- } // no else
-
- doc.appendChild(root);
-
- QTextStream outputStream(&file);
-
- outputStream << doc.toString(PROFILE_INDENT);
-
- file.close();
-
- return true;
-}
-
-void ProfileManager::saveRemoteTargetId(Profile &aProfile,const QString& aTargetId )
-{
- LOG_DEBUG("saveRemoteTargetId :" << aTargetId);
- aProfile.setKey (KEY_REMOTE_ID, aTargetId);
- save (aProfile);
-}
-
-
-bool ProfileManager::rename(const QString &aName, const QString &aNewName)
-{
- bool ret = false;
- // Rename the sync profile
- QString source = d_ptr->iPrimaryPath + QDir::separator() + Profile::TYPE_SYNC + QDir::separator() +
- aName + FORMAT_EXT;
- QString destination = d_ptr->iPrimaryPath + QDir::separator() + Profile::TYPE_SYNC + QDir::separator() +
- aNewName + FORMAT_EXT;
- ret = QFile::rename(source, destination);
- if(true == ret)
- {
- // Rename the sync log
- QString sourceLog = d_ptr->iPrimaryPath + QDir::separator() + Profile::TYPE_SYNC + QDir::separator() +
- LOG_DIRECTORY + QDir::separator() + aName + LOG_EXT + FORMAT_EXT;
- QString destinationLog = d_ptr->iPrimaryPath + QDir::separator() + Profile::TYPE_SYNC + QDir::separator() +
- LOG_DIRECTORY + QDir::separator() + aNewName + LOG_EXT + FORMAT_EXT;
- ret = QFile::rename(sourceLog, destinationLog);
- if(false == ret)
- {
- // Roll back the earlier rename
- QFile::rename(destination, source);
- }
- }
- if(false == ret)
- {
- LOG_WARNING("Failed to rename profile" << aName);
- }
- return ret;
-}
-
-bool ProfileManager::saveSyncResults(QString aProfileName,
- const SyncResults &aResults)
-{
- FUNCTION_CALL_TRACE;
- bool success = false;
-
- SyncLog *log = d_ptr->loadLog(aProfileName);
- if (!log)
- {
- // No log yet, create new.
- log = new SyncLog(aProfileName);
- } // no else
-
- if (log)
- {
- log->addResults(aResults);
- success = saveLog(*log);
- delete log;
- log = 0;
- } // no else
-
- return success;
+
+ return syncProfile;
+}
+
+QStringList ProfileManager::profileNames(const QString &aType)
+{
+ // Search for all profile files from the primary directory
+ QStringList names;
+ QString nameFilter = QString("*") + FORMAT_EXT;
+ {
+ QDir dir(d_ptr->iPrimaryPath + QDir::separator() + aType);
+ QFileInfoList fileInfoList = dir.entryInfoList(QStringList(nameFilter),
+ QDir::Files | QDir::NoSymLinks);
+ foreach (const QFileInfo &fileInfo, fileInfoList)
+ {
+ names.append(fileInfo.completeBaseName());
+ }
+ }
+
+ // Search for all profile files from the secondary directory
+ {
+ QDir dir(d_ptr->iSecondaryPath + QDir::separator() + aType);
+ QFileInfoList fileInfoList = dir.entryInfoList(QStringList(nameFilter),
+ QDir::Files | QDir::NoSymLinks);
+ foreach (const QFileInfo &fileInfo, fileInfoList)
+ {
+ // Add only if the list does not yet contain the name.
+ QString profileName = fileInfo.completeBaseName();
+ if (!names.contains(profileName))
+ {
+ names.append(profileName);
+ }
+ }
+ }
+
+ return names;
+}
+
+QList<SyncProfile*> ProfileManager::allSyncProfiles()
+{
+ QList<SyncProfile*> profiles;
+
+ QStringList names = profileNames(Profile::TYPE_SYNC);
+ foreach (const QString &name, names)
+ {
+ SyncProfile *p = syncProfile(name);
+ if (p != 0)
+ {
+ profiles.append(p);
+ } // no else
+ }
+
+ return profiles;
+}
+
+QList<SyncProfile*> ProfileManager::allVisibleSyncProfiles()
+{
+ QList<SyncProfile*> profiles = allSyncProfiles();
+ QList<SyncProfile*> visibleProfiles;
+ foreach (SyncProfile *p, profiles)
+ {
+ if (!p->isHidden())
+ {
+ visibleProfiles.append(p);
+ }
+ else
+ {
+ delete p;
+ }
+ }
+
+ return visibleProfiles;
+}
+
+QList<SyncProfile*> ProfileManager::getSyncProfilesByData(
+ const QString &aSubProfileName,
+ const QString &aSubProfileType,
+ const QString &aKey, const QString &aValue)
+{
+ QList<SyncProfile*> allProfiles = allSyncProfiles();
+ QList<SyncProfile*> matchingProfiles;
+
+ foreach (SyncProfile *profile, allProfiles)
+ {
+ Profile *testProfile = profile;
+ if (!aSubProfileName.isEmpty())
+ {
+ // Sub-profile name was given, request a sub-profile with a
+ // matching name and type.
+ testProfile = profile->subProfile(aSubProfileName, aSubProfileType);
+ }
+ else if (!aSubProfileType.isEmpty())
+ {
+ // Sub-profile name was empty, but type was given. Get the first
+ // sub-profile with the matching type.
+ QStringList subProfileNames =
+ profile->subProfileNames(aSubProfileType);
+ if (!subProfileNames.isEmpty())
+ {
+ testProfile = profile->subProfile(subProfileNames.first(),
+ aSubProfileType);
+ }
+ else
+ {
+ testProfile = 0;
+ }
+ }
+
+ if (0 == testProfile) // Sub-profile was not found.
+ {
+ delete profile;
+ profile = 0;
+ continue; // Not a match, continue with next profile.
+ }
+
+ if (!aKey.isEmpty())
+ {
+ // Key name was given, get a key with matching name.
+ QString value = testProfile->key(aKey);
+ if (value.isNull() || // Key was not found.
+ (!aValue.isEmpty() && (value != aValue))) // Value didn't match
+ {
+ delete profile;
+ profile = 0;
+ continue; // Not a match, continue with next profile.
+ } // no else
+ } // no else
+
+ // Match, add profile to the list to be returned.
+ matchingProfiles.append(profile);
+ }
+
+ return matchingProfiles;
+}
+
+QList<SyncProfile*> ProfileManager::getSyncProfilesByData(
+ const QList<SearchCriteria> &aCriteria)
+{
+ QList<SyncProfile*> allProfiles = allSyncProfiles();
+ QList<SyncProfile*> matchingProfiles;
+
+ foreach (SyncProfile *profile, allProfiles)
+ {
+ bool matched = true;
+ if (profile == 0)
+ continue;
+
+ foreach (const SearchCriteria &criteria, aCriteria)
+ {
+ if (!d_ptr->matchProfile(*profile, criteria))
+ {
+ matched = false;
+ break;
+ }
+ }
+
+ if (matched)
+ {
+ matchingProfiles.append(profile);
+ }
+ else
+ {
+ delete profile;
+ profile = 0;
+ }
+ }
+
+ return matchingProfiles;
+}
+
+QList<SyncProfile*> ProfileManager::getSyncProfilesByStorage(
+ const QString &aStorageName, bool aStorageMustBeEnabled)
+{
+ QList<SearchCriteria> criteriaList;
+
+ // Require that the profile is not disabled.
+ // Profile is enabled by default. Comparing with enabled = true would
+ // not work, because the key may not exist at all, even if the profile
+ // is enabled.
+ SearchCriteria profileEnabled;
+ profileEnabled.iType = SearchCriteria::NOT_EQUAL;
+ profileEnabled.iKey = KEY_ENABLED;
+ profileEnabled.iValue = BOOLEAN_FALSE;
+ criteriaList.append(profileEnabled);
+
+ // Profile must not be hidden.
+ SearchCriteria profileVisible;
+ profileVisible.iType = SearchCriteria::NOT_EQUAL;
+ profileVisible.iKey = KEY_HIDDEN;
+ profileVisible.iValue = BOOLEAN_TRUE;
+ criteriaList.append(profileVisible);
+
+ // Online service.
+ SearchCriteria onlineService;
+ onlineService.iType = SearchCriteria::EQUAL;
+ onlineService.iSubProfileType = Profile::TYPE_SERVICE;
+ // Service profile name is left empty. Key value is matched with all
+ // found service sub-profiles, though there should be only one.
+ onlineService.iKey = KEY_DESTINATION_TYPE;
+ onlineService.iValue = VALUE_ONLINE;
+ criteriaList.append(onlineService);
+
+ // Storage must be supported.
+ SearchCriteria storageSupported;
+ storageSupported.iSubProfileName = aStorageName;
+ storageSupported.iSubProfileType = Profile::TYPE_STORAGE;
+ if (aStorageMustBeEnabled)
+ {
+ // Storage must be enabled also. Storages are disabled by default,
+ // so we can compare with enabled = true.
+ storageSupported.iType = SearchCriteria::EQUAL;
+ storageSupported.iKey = KEY_ENABLED;
+ storageSupported.iValue = BOOLEAN_TRUE;
+ }
+ else
+ {
+ // Existence of the storage sub-profile is sufficient.
+ storageSupported.iType = SearchCriteria::EXISTS;
+ }
+ criteriaList.append(storageSupported);
+
+ return getSyncProfilesByData(criteriaList);
+}
+
+
+bool ProfileManagerPrivate::save(const Profile &aProfile)
+{
+ QDomDocument doc = constructProfileDocument(aProfile);
+ if (doc.isNull())
+ {
+ LOG_WARNING("No profile data to write");
+ return false;
+ }
+
+ // Create path for the new profile file.
+ QDir dir;
+ dir.mkpath(iPrimaryPath + QDir::separator() + aProfile.type());
+ QString profilePath(iPrimaryPath + QDir::separator() +
+ aProfile.type() + QDir::separator() + aProfile.name() + FORMAT_EXT);
+
+ // Create a backup of the existing profile file.
+ QString oldProfilePath = findProfileFile(aProfile.type(), aProfile.name());
+ QString backupPath = profilePath + BACKUP_EXT;
+
+ if (QFile::exists(oldProfilePath) &&
+ !createBackup(oldProfilePath, backupPath))
+ {
+ LOG_WARNING("Failed to create profile backup");
+ }
+
+ bool profileWritten = false;
+ if (writeProfileFile(profilePath, doc))
+ {
+ QFile::remove(backupPath);
+ profileWritten = true;
+ }
+ else
+ {
+ LOG_WARNING("Failed to save profile:" << aProfile.name());
+ profileWritten = false;
+ }
+
+ return profileWritten;
+}
+
+Profile* ProfileManager::profileFromXml(const QString &aProfileAsXml)
+{
+ Profile *profile = NULL;
+ if(!aProfileAsXml.isEmpty()) {
+ QDomDocument doc;
+ if(doc.setContent(aProfileAsXml,true)) {
+ ProfileFactory pf;
+ profile = pf.createProfile(doc.documentElement());
+ }
+ }
+ return profile;
+}
+
+QString ProfileManager::addProfile(Profile &aProfile)
+{
+ QString profileId("");
+ // just check to see if the profile exists. then send an update
+ /// signal instead of added signal .
+ if(d_ptr->profileExists(aProfile.name(),aProfile.type())){
+ LOG_DEBUG("Profile Exists ... Overwriting it ... ");
+ profileId = updateProfile(aProfile);
+ } else {
+ if(d_ptr->save(aProfile)) {
+ profileId=aProfile.name();
+ }
+ emit signalProfileChanged(aProfile.name(),ProfileManager::PROFILE_ADDED,aProfile.toString());
+ }
+ return profileId;
+}
+
+QString ProfileManager::updateProfile(const Profile &aProfile)
+{
+ QString profileId("");
+ if(d_ptr->save(aProfile)) {
+ profileId=aProfile.name();
+ }
+ emit signalProfileChanged(aProfile.name(),ProfileManager::PROFILE_MODIFIED,aProfile.toString());
+ return profileId;
+}
+
+SyncProfile *ProfileManager::createTempSyncProfile (const QString &destAddress, bool &saveNewProfile)
+{
+ saveNewProfile = true;
+ if (destAddress.contains("USB")) { //USB - PCSUite no requirement to save profile
+ LOG_INFO("USB connect - pc");
+ saveNewProfile = false;
+ return new SyncProfile(destAddress);
+ }
+
+ BtHelper btHelp(destAddress);
+ QMap <QString , QVariant> mapVal = btHelp.getDeviceProperties();
+ uint classType = mapVal.value("Class").toInt();
+ uint pcsuiteClass = 0x100; //Major Device Class - Computer!
+
+ if (classType & pcsuiteClass) {
+ LOG_INFO("Device major class is Computer"); // not required to save profile
+ saveNewProfile = false;
+ return new SyncProfile(destAddress);
+ }
+
+ QString profileDisplayName = mapVal.value("Name").toString();
+ if (profileDisplayName.isEmpty()) {
+ //Todo : What to show if name is empty !!
+ //Fixes 171340
+ profileDisplayName = QString ("qtn_sync_dest_name_device_default");
+ }
+
+ LOG_INFO("Profile Name :" << profileDisplayName);
+ SyncProfile *tProfile = syncProfile(BT_PROFILE_TEMPLATE);
+ Profile *service = tProfile->serviceProfile();
+ if (service != 0) {
+ tProfile->setKey(KEY_DISPLAY_NAME, profileDisplayName);
+ QStringList keys ;
+ keys << destAddress << service->name();
+ tProfile->setName(keys);
+ tProfile->setEnabled(true);
+ tProfile->setBoolKey("hidden", false);
+ service->setKey(KEY_BT_ADDRESS, destAddress);
+ service->setKey(KEY_BT_NAME, profileDisplayName);
+ } else {
+ LOG_WARNING("No service profile, unable to update properties");
+ }
+
+ return tProfile;
+}
+
+
+void ProfileManager::enableStorages (Profile &aProfile,
+ QMap<QString , bool> &aStorageMap)
+{
+
+ QMapIterator<QString, bool> i(aStorageMap);
+ LOG_INFO("ProfileManager::enableStorages");
+ while (i.hasNext()) {
+ i.next();
+ Profile *profile = aProfile.subProfile(i.key(), Profile::TYPE_STORAGE);
+ if (profile)
+ profile->setEnabled(i.value());
+ else
+ LOG_WARNING("No storage profile by key :" << i.key());
+ }
+ return ;
+}
+
+bool ProfileManager::removeProfile(const QString &aProfileId)
+{
+ bool success = false;
+
+ SyncProfile *profile = syncProfile(aProfileId);
+ if(profile){
+ success = d_ptr->remove(aProfileId,profile->type());
+ if(success) {
+ emit signalProfileChanged(aProfileId,ProfileManager::PROFILE_REMOVED, QString(""));
+ }
+ delete profile;
+ profile = NULL;
+ }
+ return success;
+}
+
+bool ProfileManagerPrivate::remove(const QString &aName, const QString &aType)
+{
+ bool success = false;
+ QString filePath = iPrimaryPath + QDir::separator() + aType + QDir::separator() + aName + FORMAT_EXT;
+
+ // Try to load profile without expanding it. We need to check from the
+ // profile data if the profile is protected before removing it.
+ Profile *p = load(aName, aType);
+ if (p)
+ {
+ if (!p->isProtected())
+ {
+ success = QFile::remove(filePath);
+ if (success){
+ QString logFilePath = iPrimaryPath + QDir::separator() + aType + QDir::separator() +
+ LOG_DIRECTORY + QDir::separator() + aName + LOG_EXT + FORMAT_EXT;
+ success = QFile::remove(logFilePath);
+ }
+ }
+ else
+ {
+ LOG_DEBUG( "Cannot remove protected profile:" << aName );
+ }
+ delete p;
+ p = 0;
+ }
+ else
+ {
+ LOG_DEBUG( "Profile not found from the primary path, cannot remove:" << aName );
+ }
+
+ return success;
+}
+
+void ProfileManager::expand(Profile &aProfile)
+{
+ if (aProfile.isLoaded())
+ return; // Already expanded.
+
+ // Load and merge sub-profiles.
+ int prevSubCount = 0;
+ QList<Profile*> subProfiles = aProfile.allSubProfiles();
+ int subCount = subProfiles.size();
+ while (subCount > prevSubCount)
+ {
+ foreach (Profile *sub, subProfiles)
+ {
+ if (!sub->isLoaded())
+ {
+ Profile *loadedProfile = profile(sub->name(), sub->type());
+ if (loadedProfile != 0)
+ {
+ aProfile.merge(*loadedProfile);
+ delete loadedProfile;
+ loadedProfile = 0;
+ }
+ else
+ {
+ // No separate profile file for the sub-profile.
+ LOG_DEBUG( "Referenced sub-profile not found:" <<
+ sub->name() );
+ LOG_DEBUG( "Referenced from:" << aProfile.name() <<
+ aProfile.type() );
+ }
+ sub->setLoaded(true);
+ } // no else
+ }
+
+ // Load/merge may have created new sub-profile entries. Those need
+ // to be loaded also. Loop if sub-profile count has changed.
+ prevSubCount = subCount;
+ subProfiles = aProfile.allSubProfiles();
+ subCount = subProfiles.size();
+ }
+
+ aProfile.setLoaded(true);
+}
+
+bool ProfileManager::saveLog(const SyncLog &aLog)
+{
+ QDir dir;
+ QString fullPath = d_ptr->iPrimaryPath + QDir::separator() + Profile::TYPE_SYNC + QDir::separator() +
+ LOG_DIRECTORY;
+ dir.mkpath(fullPath);
+ QFile file(fullPath + QDir::separator() + aLog.profileName() + LOG_EXT + FORMAT_EXT);
+
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
+ {
+ LOG_WARNING("Failed to open sync log file for writing:"
+ << file.fileName());
+ return false;
+ } // no else
+
+ QDomDocument doc;
+ QDomProcessingInstruction xmlHeading =
+ doc.createProcessingInstruction("xml",
+ "version=\"1.0\" encoding=\"UTF-8\"");
+ doc.appendChild(xmlHeading);
+
+ QDomElement root = aLog.toXml(doc);
+ if (root.isNull())
+ {
+ LOG_WARNING("Failed to convert sync log to XML");
+ return false;
+ } // no else
+
+ doc.appendChild(root);
+
+ QTextStream outputStream(&file);
+
+ outputStream << doc.toString(PROFILE_INDENT);
+
+ file.close();
+
+ return true;
+}
+
+void ProfileManager::saveRemoteTargetId(Profile &aProfile,const QString& aTargetId )
+{
+ LOG_DEBUG("saveRemoteTargetId :" << aTargetId);
+ aProfile.setKey (KEY_REMOTE_ID, aTargetId);
+ addProfile(aProfile);
+}
+
+
+bool ProfileManager::rename(const QString &aName, const QString &aNewName)
+{
+ bool ret = false;
+ // Rename the sync profile
+ QString source = d_ptr->iPrimaryPath + QDir::separator() + Profile::TYPE_SYNC + QDir::separator() +
+ aName + FORMAT_EXT;
+ QString destination = d_ptr->iPrimaryPath + QDir::separator() + Profile::TYPE_SYNC + QDir::separator() +
+ aNewName + FORMAT_EXT;
+ ret = QFile::rename(source, destination);
+ if(true == ret)
+ {
+ // Rename the sync log
+ QString sourceLog = d_ptr->iPrimaryPath + QDir::separator() + Profile::TYPE_SYNC + QDir::separator() +
+ LOG_DIRECTORY + QDir::separator() + aName + LOG_EXT + FORMAT_EXT;
+ QString destinationLog = d_ptr->iPrimaryPath + QDir::separator() + Profile::TYPE_SYNC + QDir::separator() +
+ LOG_DIRECTORY + QDir::separator() + aNewName + LOG_EXT + FORMAT_EXT;
+ ret = QFile::rename(sourceLog, destinationLog);
+ if(false == ret)
+ {
+ // Roll back the earlier rename
+ QFile::rename(destination, source);
+ }
+ }
+ if(false == ret)
+ {
+ LOG_WARNING("Failed to rename profile" << aName);
+ }
+ return ret;
+}
+
+bool ProfileManager::saveSyncResults(QString aProfileName,
+ const SyncResults &aResults)
+{
+ FUNCTION_CALL_TRACE;
+ bool success = false;
+
+ SyncLog *log = d_ptr->loadLog(aProfileName);
+ if (!log)
+ {
+ // No log yet, create new.
+ log = new SyncLog(aProfileName);
+ } // no else
+
+ if (log)
+ {
+ log->addResults(aResults);
+ success = saveLog(*log);
+ delete log;
+ log = 0;
+ } // no else
+
+ return success;
}
bool ProfileManager::setSyncSchedule(QString aProfileId , QString aScheduleAsXml)
@@ -888,7 +950,7 @@
if(doc.setContent(aScheduleAsXml,true)) {
SyncSchedule schedule(doc.documentElement());
profile->setSyncSchedule(schedule);
- save(*profile);
+ addProfile(*profile);
status = true;
}
delete profile;
@@ -899,145 +961,139 @@
return status;
}
+bool ProfileManagerPrivate::parseFile(const QString &aPath, QDomDocument &aDoc)
+{
+ bool parsingOk = false;
+
+ if (QFile::exists(aPath))
+ {
+ QFile file(aPath);
+
+ if (file.open(QIODevice::ReadOnly))
+ {
+ parsingOk = aDoc.setContent(&file);
+ file.close();
+
+ if (!parsingOk)
+ {
+ LOG_WARNING("Failed to parse profile XML: " << aPath);
+ }
+ }
+ else {
+ LOG_WARNING("Failed to open profile file for reading:" << aPath);
+ }
+ }
+ else
+ {
+ LOG_WARNING("Profile file not found:" << aPath);
+ }
+
+
+
+ return parsingOk;
+}
-QString ProfileManager::addProfile(QString &aProfileAsXml)
+QDomDocument ProfileManagerPrivate::constructProfileDocument(const Profile &aProfile)
{
- QString profileId;
- if(!aProfileAsXml.isEmpty()) {
+ QDomDocument doc;
+ QDomElement root = aProfile.toXml(doc);
+
+ if (root.isNull())
+ {
+ LOG_WARNING("Failed to convert profile to XML");
+ }
+ else
+ {
+ QDomProcessingInstruction xmlHeading =
+ doc.createProcessingInstruction("xml",
+ "version=\"1.0\" encoding=\"UTF-8\"");
+
+ doc.appendChild(xmlHeading);
+ doc.appendChild(root);
+ }
+
+ return doc;
+}
+
+bool ProfileManagerPrivate::writeProfileFile(const QString &aProfilePath,
+ const QDomDocument &aDoc)
+{
+ QFile file(aProfilePath);
+ bool profileWritten = false;
+
+ if (file.open(QIODevice::WriteOnly | QIODevice::Truncate))
+ {
+ QTextStream outputStream(&file);
+ outputStream << aDoc.toString(PROFILE_INDENT);
+ file.close();
+ profileWritten = true;
+ }
+ else
+ {
+ LOG_WARNING("Failed to open profile file for writing:" << aProfilePath);
+ profileWritten = false;
+ }
+
+ return profileWritten;
+}
+
+void ProfileManagerPrivate::restoreBackupIfFound(const QString &aProfilePath,
+ const QString &aBackupPath)
+{
+ if (QFile::exists(aBackupPath))
+ {
+ LOG_WARNING("Profile backup file found. The actual profile may be corrupted.");
+
QDomDocument doc;
- if(doc.setContent(aProfileAsXml,true)) {
- SyncProfile profile(doc.documentElement());
- save(profile);
- profileId = profile.name();
- }
- }
- return profileId;
-}
-
-bool ProfileManagerPrivate::parseFile(const QString &aPath, QDomDocument &aDoc)
-{
- bool parsingOk = false;
-
- if (QFile::exists(aPath))
- {
- QFile file(aPath);
-
- if (file.open(QIODevice::ReadOnly))
- {
- parsingOk = aDoc.setContent(&file);
- file.close();
-
- if (!parsingOk)
- {
- LOG_WARNING("Failed to parse profile XML: " << aPath);
- }
- }
- else {
- LOG_WARNING("Failed to open profile file for reading:" << aPath);
- }
- }
- else
- {
- LOG_WARNING("Profile file not found:" << aPath);
- }
-
-
-
- return parsingOk;
-}
-
-QDomDocument ProfileManagerPrivate::constructProfileDocument(const Profile &aProfile)
-{
- QDomDocument doc;
- QDomElement root = aProfile.toXml(doc);
-
- if (root.isNull())
- {
- LOG_WARNING("Failed to convert profile to XML");
- }
- else
- {
- QDomProcessingInstruction xmlHeading =
- doc.createProcessingInstruction("xml",
- "version=\"1.0\" encoding=\"UTF-8\"");
-
- doc.appendChild(xmlHeading);
- doc.appendChild(root);
- }
-
- return doc;
-}
-
-bool ProfileManagerPrivate::writeProfileFile(const QString &aProfilePath,
- const QDomDocument &aDoc)
-{
- QFile file(aProfilePath);
- bool profileWritten = false;
-
- if (file.open(QIODevice::WriteOnly | QIODevice::Truncate))
- {
- QTextStream outputStream(&file);
- outputStream << aDoc.toString(PROFILE_INDENT);
- file.close();
- profileWritten = true;
- }
- else
- {
- LOG_WARNING("Failed to open profile file for writing:" << aProfilePath);
- profileWritten = false;
- }
-
- return profileWritten;
-}
-
-void ProfileManagerPrivate::restoreBackupIfFound(const QString &aProfilePath,
- const QString &aBackupPath)
-{
- if (QFile::exists(aBackupPath))
- {
- LOG_WARNING("Profile backup file found. The actual profile may be corrupted.");
-
- QDomDocument doc;
- if (parseFile(aBackupPath, doc))
- {
- LOG_DEBUG("Restoring profile from backup");
- QFile::remove(aProfilePath);
- QFile::copy(aBackupPath, aProfilePath);
- }
- else
- {
- LOG_WARNING("Failed to parse backup file");
- LOG_DEBUG("Removing backup file");
- QFile::remove(aBackupPath);
- }
- }
-}
-
-bool ProfileManagerPrivate::createBackup(const QString &aProfilePath,
- const QString &aBackupPath)
-{
- return QFile::copy(aProfilePath, aBackupPath);
-}
-
-QString ProfileManagerPrivate::findProfileFile(const QString &aName, const QString &aType)
-{
- QString fileName = aType + QDir::separator() + aName + FORMAT_EXT;
- QString primaryPath = iPrimaryPath + QDir::separator() + fileName;
- QString secondaryPath = iSecondaryPath + QDir::separator() + fileName;
-
- if (QFile::exists(primaryPath))
- {
- return primaryPath;
- }
- else if (!QFile::exists(secondaryPath))
- {
- return primaryPath;
- }
- else
- {
- return secondaryPath;
- }
-}
+ if (parseFile(aBackupPath, doc))
+ {
+ LOG_DEBUG("Restoring profile from backup");
+ QFile::remove(aProfilePath);
+ QFile::copy(aBackupPath, aProfilePath);
+ }
+ else
+ {
+ LOG_WARNING("Failed to parse backup file");
+ LOG_DEBUG("Removing backup file");
+ QFile::remove(aBackupPath);
+ }
+ }
+}
+
+bool ProfileManagerPrivate::createBackup(const QString &aProfilePath,
+ const QString &aBackupPath)
+{
+ return QFile::copy(aProfilePath, aBackupPath);
+}
+
+QString ProfileManagerPrivate::findProfileFile(const QString &aName, const QString &aType)
+{
+ QString fileName = aType + QDir::separator() + aName + FORMAT_EXT;
+ QString primaryPath = iPrimaryPath + QDir::separator() + fileName;
+ QString secondaryPath = iSecondaryPath + QDir::separator() + fileName;
+
+ if (QFile::exists(primaryPath))
+ {
+ return primaryPath;
+ }
+ else if (!QFile::exists(secondaryPath))
+ {
+ return primaryPath;
+ }
+ else
+ {
+ return secondaryPath;
+ }
+}
+
+// this function checks to see if its a new profile or an
+// existing profile being modified under $HOME/.sync/profiles directory.
+bool ProfileManagerPrivate::profileExists(const QString &aProfileId ,const QString &aType)
+{
+ QString profileFile = iPrimaryPath + QDir::separator() + aType + QDir::separator() + aProfileId + FORMAT_EXT;
+ LOG_DEBUG("profileFile:" << profileFile);
+ return QFile::exists(profileFile);
+}
+
-
--- libsyncprofile/ProfileManager.h
+++ libsyncprofile/ProfileManager.h
@@ -20,270 +20,298 @@
* 02110-1301 USA
*
*/
-
-#ifndef PROFILEMANAGER_H
-#define PROFILEMANAGER_H
-
-#include "SyncProfile.h"
-#include "Profile.h"
-#include <QList>
-
-namespace Buteo {
-
-class ProfileManagerPrivate;
-
-/*! \brief
- * ProfileManager is responsible for storing and retrieving the profiles.
- *
- * It also constructs top level profiles by loading and merging all referenced
- * sub-profiles. The ProfileManager hides the actual storage from the user, so
- * that it makes no difference if the profiles are stored to simple XML-files
- * or to a database. Profiles can be queried by name and type.
- */
-class ProfileManager
-{
+
+#ifndef PROFILEMANAGER_H
+#define PROFILEMANAGER_H
+
+#include "SyncProfile.h"
+#include "Profile.h"
+#include <QList>
+
+namespace Buteo {
+
+class ProfileManagerPrivate;
+
+/*! \brief
+ * ProfileManager is responsible for storing and retrieving the profiles.
+ *
+ * It also constructs top level profiles by loading and merging all referenced
+ * sub-profiles. The ProfileManager hides the actual storage from the user, so
+ * that it makes no difference if the profiles are stored to simple XML-files
+ * or to a database. Profiles can be queried by name and type.
+ */
+class ProfileManager: public QObject
+{
+ Q_OBJECT
public:
- //! Primary profile path where profiles will be searched.
+ //! Primary profile path where profiles will be searched.
static const QString DEFAULT_PRIMARY_PROFILE_PATH;
- //! Secondary profile path where profiles will be searched.
- static const QString DEFAULT_SECONDARY_PROFILE_PATH;
-
- //! Search criteria for finding profiles.
- struct SearchCriteria
+ //! Secondary profile path where profiles will be searched.
+ static const QString DEFAULT_SECONDARY_PROFILE_PATH;
+
+ //! Search criteria for finding profiles.
+ struct SearchCriteria
+ {
+ //! Enum to identify if a member type exists or not
+ enum Type
+ {
+ //! Sub-profile (and key) exists.
+ EXISTS,
+
+ //! Sub-profile (or key) does not exist.
+ NOT_EXISTS,
+
+ //! Key value is equal.
+ EQUAL,
+
+ //! Key value is not equal.
+ NOT_EQUAL
+ };
+
+ //! \brief Constructor.
+ SearchCriteria();
+
+ //! \brief Copy constructor.
+ SearchCriteria(const SearchCriteria &aSource);
+
+ //! Search criteria type.
+ Type iType;
+
+ //! Sub-profile name. If this is empty but profile type is given,
+ //! matching is tried with each sub-profile of correct type. If both
+ //! profile name and type are empty, mathing is done with keys of the
+ //! main profile.
+ QString iSubProfileName;
+
+ //! Sub-profile type. If this is empty but profile name is given,
+ //! matching is done with the first sub-profile having the correct name
+ //! regardless of the type.
+ QString iSubProfileType;
+
+ //! Key name. If this is empty, key comparison is not made.
+ QString iKey;
+
+ //! Key value. This must be given if criteria type is EQUAL or NOT_EQUAL.
+ QString iValue;
+ };
+
+ //! \brief Enum to indicate the change type of the Profile Operation
+ enum ProfileChangeType
{
- //! Enum to identify if a member type exists or not
- enum Type
- {
- //! Sub-profile (and key) exists.
- EXISTS,
-
- //! Sub-profile (or key) does not exist.
- NOT_EXISTS,
-
- //! Key value is equal.
- EQUAL,
-
- //! Key value is not equal.
- NOT_EQUAL
- };
-
- //! \brief Constructor.
- SearchCriteria();
-
- //! \brief Copy constructor.
- SearchCriteria(const SearchCriteria &aSource);
-
- //! Search criteria type.
- Type iType;
-
- //! Sub-profile name. If this is empty but profile type is given,
- //! matching is tried with each sub-profile of correct type. If both
- //! profile name and type are empty, mathing is done with keys of the
- //! main profile.
- QString iSubProfileName;
-
- //! Sub-profile type. If this is empty but profile name is given,
- //! matching is done with the first sub-profile having the correct name
- //! regardless of the type.
- QString iSubProfileType;
-
- //! Key name. If this is empty, key comparison is not made.
- QString iKey;
-
- //! Key value. This must be given if criteria type is EQUAL or NOT_EQUAL.
- QString iValue;
- };
-
- /*! \brief Constructor.
- *
- * \param aPrimaryPath Path where profiles are searched first. Save
- * operations will write to this location.
- * \param aSecondaryPath Path where a profile is searched for if it is
- * not found from the primary path. Useful for having default read-only
- * profiles.
- */
- ProfileManager(const QString &aPrimaryPath = DEFAULT_PRIMARY_PROFILE_PATH,
- const QString &aSecondaryPath = DEFAULT_SECONDARY_PROFILE_PATH);
-
- /*! \brief Destructor.
- */
- ~ProfileManager();
-
- /*! \brief Gets the names of all available profiles with the given type.
- *
- * \param aType Type of the profiles to get.
- * \return The list of profile names.
- */
- QStringList profileNames(const QString &aType);
-
- /*! \brief Gets a sync profile.
- *
- * Loads and merges also all sub-profiles that are referenced from the
- * main profile. Loads the log of finished synchronization sessions with
- * this profile.
- * \param aName Name of the profile to get.
- * \return The sync profile. NULL if the profile is not found. Caller becomes
- * the owner of the returned object and is responsible of deleting it after
- * use. Changes made to the profile are not saved to the persistent profile
- * storage, unless save function of this class is called.
- */
- SyncProfile *syncProfile(const QString &aName);
-
- /*! \brief Gets all sync profiles.
- *
- * \return The list of sync profiles. Caller is responsible for deleting
- * the returned profile objects.
- */
- QList<SyncProfile*> allSyncProfiles();
-
- /*! \brief Gets all visible sync profiles.
- *
- * Returns all sync profiles that should be visible in sync ui. A profile
- * is visible if it has not been explicitly set as hidden.
- * \return The list of sync profiles. Caller is responsible for deleting
- * the returned profile objects.
- */
- QList<SyncProfile*> allVisibleSyncProfiles();
-
- /*! \brief Gets profiles with matching data.
- *
- * \param aSubProfileName Name of a required sub-profile. If this is given,
- * the sub-profile must exist and key comparison is made with the keys
- * of the sub-profile.
- * \param aSubProfileType Type of a required sub-profile. If this is given but
- * sub-profile name is empty, the first sub-profile with matching type is
- * used in comparison.
- * \param aKey Name of a required key. If this is empty, key comparison is
- * not made and existance of the sub-profile is enough.
- * \param aValue Value of the required key. If this is empty, any value
- * is accepted as long as the key itself exists.
- * \return List of matching profiles. Caller is responsible for deleting
- * the returned profile objects.
- */
- QList<SyncProfile*> getSyncProfilesByData(const QString &aSubProfileName,
- const QString &aSubProfileType,
- const QString &aKey = "", const QString &aValue = "");
-
- /*! \brief Gets profiles with matching data.
- *
- * \param aCriteria List of criteria to use in the search. Each criterion
- * in the list has to match for a profile to be returned as a result.
- * \return List of matching profiles. Caller is responsible for deleting
- * the returned profile objects.
- */
- QList<SyncProfile*> getSyncProfilesByData(
- const QList<SearchCriteria> &aCriteria);
-
- /*! \brief Gets profiles based on supported storages.
- *
- * Returns all enabled and visible sync profiles of online destinations
- * that support the given storage. Device-to-device sync profiles are not
- * returned.
- * \param aStorageName Name of the storage that must be supported.
- * \param aStorageMustBeEnabled True if the supported storage must be
- * also enabled. Only enabled storages are included in sync session.
- * \return List of matching profiles. Caller is responsible for deleting
- * the returned profile objects.
- */
- QList<SyncProfile*> getSyncProfilesByStorage(
+ //! a New Profile has been added
+ PROFILE_ADDED = 0,
+ //! a Existing Profile has been modified
+ PROFILE_MODIFIED,
+ //! Profile has been Removed
+ PROFILE_REMOVED
+ };
+
+ /*! \brief Constructor.
+ *
+ * \param aPrimaryPath Path where profiles are searched first. Save
+ * operations will write to this location.
+ * \param aSecondaryPath Path where a profile is searched for if it is
+ * not found from the primary path. Useful for having default read-only
+ * profiles.
+ */
+ ProfileManager(const QString &aPrimaryPath = DEFAULT_PRIMARY_PROFILE_PATH,
+ const QString &aSecondaryPath = DEFAULT_SECONDARY_PROFILE_PATH);
+
+ /*! \brief Destructor.
+ */
+ ~ProfileManager();
+
+ /*! \brief Gets the names of all available profiles with the given type.
+ *
+ * \param aType Type of the profiles to get.
+ * \return The list of profile names.
+ */
+ QStringList profileNames(const QString &aType);
+
+ /*! \brief Gets a sync profile.
+ *
+ * Loads and merges also all sub-profiles that are referenced from the
+ * main profile. Loads the log of finished synchronization sessions with
+ * this profile.
+ * \param aName Name of the profile to get.
+ * \return The sync profile. NULL if the profile is not found. Caller becomes
+ * the owner of the returned object and is responsible of deleting it after
+ * use. Changes made to the profile are not saved to the persistent profile
+ * storage, unless save function of this class is called.
+ */
+ SyncProfile *syncProfile(const QString &aName);
+
+ /*! \brief Gets all sync profiles.
+ *
+ * \return The list of sync profiles. Caller is responsible for deleting
+ * the returned profile objects.
+ */
+ QList<SyncProfile*> allSyncProfiles();
+
+ /*! \brief Gets all visible sync profiles.
+ *
+ * Returns all sync profiles that should be visible in sync ui. A profile
+ * is visible if it has not been explicitly set as hidden.
+ * \return The list of sync profiles. Caller is responsible for deleting
+ * the returned profile objects.
+ */
+ QList<SyncProfile*> allVisibleSyncProfiles();
+
+ /*! \brief Gets profiles with matching data.
+ *
+ * \param aSubProfileName Name of a required sub-profile. If this is given,
+ * the sub-profile must exist and key comparison is made with the keys
+ * of the sub-profile.
+ * \param aSubProfileType Type of a required sub-profile. If this is given but
+ * sub-profile name is empty, the first sub-profile with matching type is
+ * used in comparison.
+ * \param aKey Name of a required key. If this is empty, key comparison is
+ * not made and existance of the sub-profile is enough.
+ * \param aValue Value of the required key. If this is empty, any value
+ * is accepted as long as the key itself exists.
+ * \return List of matching profiles. Caller is responsible for deleting
+ * the returned profile objects.
+ */
+ QList<SyncProfile*> getSyncProfilesByData(const QString &aSubProfileName,
+ const QString &aSubProfileType,
+ const QString &aKey = "", const QString &aValue = "");
+
+ /*! \brief Gets profiles with matching data.
+ *
+ * \param aCriteria List of criteria to use in the search. Each criterion
+ * in the list has to match for a profile to be returned as a result.
+ * \return List of matching profiles. Caller is responsible for deleting
+ * the returned profile objects.
+ */
+ QList<SyncProfile*> getSyncProfilesByData(
+ const QList<SearchCriteria> &aCriteria);
+
+ /*! \brief Gets profiles based on supported storages.
+ *
+ * Returns all enabled and visible sync profiles of online destinations
+ * that support the given storage. Device-to-device sync profiles are not
+ * returned.
+ * \param aStorageName Name of the storage that must be supported.
+ * \param aStorageMustBeEnabled True if the supported storage must be
+ * also enabled. Only enabled storages are included in sync session.
+ * \return List of matching profiles. Caller is responsible for deleting
+ * the returned profile objects.
+ */
+ QList<SyncProfile*> getSyncProfilesByStorage(
const QString &aStorageName, bool aStorageMustBeEnabled = false);
- /*! \brief Saves a profile to a persistent storage.
+ /*! \brief Expands the given profile.
+ *
+ * Loads and merges all sub-profiles that are referenced from the main
+ * profile.
+ * \param aProfile Name of the profile to expand.
+ */
+ void expand(Profile &aProfile);
+
+ /*! \brief Saves the given synchronization log.
*
- * \param aProfile Profile to save.
+ * \param aLog Log to save.
* \return True if saving was successful.
*/
- bool save(const Profile &aProfile);
-
- /*! \brief Expands the given profile.
- *
- * Loads and merges all sub-profiles that are referenced from the main
- * profile.
- * \param aProfile Name of the profile to expand.
- */
- void expand(Profile &aProfile);
-
- /*! \brief Saves the given synchronization log.
- *
- * \param aLog Log to save.
- * \return True if saving was successful.
- */
- bool saveLog(const SyncLog &aLog);
-
- /*! \brief Saves the results of a sync session to the log.
- *
- * This is a convenience function that loads the log associated with the
- * given profile, appends the given results to the log and then saves the
- * log.
- * \param aProfileName Name of the profile used in the sync session.
- * \param aResults Results.
- * \return True if saving was successful.
- */
- bool saveSyncResults(QString aProfileName, const SyncResults &aResults);
-
- /*! \brief Gets a profile.
- *
- * \param aName Name of the profile to get.
- * \param aType Type of the profile to get.
- * \return Pointer to the profile. If the profile is not found, NULL is
- * returned. Caller is responsible for deleting the returned object.
- * Changes made to the profile are not saved to profile storage, unless
- * save function of this class is called
- */
- Profile *profile(const QString &aName, const QString &aType);
-
- /*! \brief Gets a temporary profile (saved if sync is sucessfull).
- *
- * \param btAddress Address of the remote device bt address/usb .
- * \param saveNewProfile If to save the profile or not (e.g pc suite profile)
- * \return Pointer to the profile.
- * Changes made to the profile are not saved to profile storage, unless
- * save function of this class is called
- */
+ bool saveLog(const SyncLog &aLog);
+
+ /*! \brief Saves the results of a sync session to the log.
+ *
+ * This is a convenience function that loads the log associated with the
+ * given profile, appends the given results to the log and then saves the
+ * log.
+ * \param aProfileName Name of the profile used in the sync session.
+ * \param aResults Results.
+ * \return True if saving was successful.
+ */
+ bool saveSyncResults(QString aProfileName, const SyncResults &aResults);
+
+ /*! \brief Gets a profile.
+ *
+ * \param aName Name of the profile to get.
+ * \param aType Type of the profile to get.
+ * \return Pointer to the profile. If the profile is not found, NULL is
+ * returned. Caller is responsible for deleting the returned object.
+ * Changes made to the profile are not saved to profile storage, unless
+ * updateProfile function of this class is called
+ */
+ Profile *profile(const QString &aName, const QString &aType);
+
+ /*! \brief Gets a profile object from an xml document.
+ *
+ * \param aProfileAsXml Name of the profile to get.
+ * \return Pointer to the profile. If the xml is not valid, NULL is
+ * returned. Caller is responsible for deleting the returned object.
+ * Changes made to the profile are not saved to profile storage, unless
+ * updateProfile function of this class is called
+ */
+ Profile *profileFromXml(const QString &aProfileAsXml);
+
+ /*! \brief Gets a temporary profile (saved if sync is sucessfull).
+ *
+ * \param btAddress Address of the remote device bt address/usb .
+ * \param saveNewProfile If to save the profile or not (e.g pc suite profile)
+ * \return Pointer to the profile.
+ * Changes made to the profile are not saved to profile storage, unless
+ * save function of this class is called
+ */
SyncProfile *createTempSyncProfile (const QString &btAddress, bool &saveNewProfile);
/*! \brief used to create a profile and save it to persistent storage.
* if a profile with the same name and type exists , this API
* overwrites it.
+ * if a profile with the same name and type exists , this API calls updateProfile
+ * NOTE: only Sync Profiles can be added using ProfileManger
*
* \param aProfileAsXml - sync profile object passed as xml
* \return profileId
*/
- QString addProfile(QString &aProfileAsXml);
+ QString addProfile(Profile &aProfile);
+
+ /*! \brief Updates the existing profile with the profile
+ * given as parameter and emits profileChanged Signal
+ * NOTE: only Sync Profiles can be updated using ProfileManger
+ *
+ * \param aProfile - Profile Object
+ * \return profileId - this will be empty if the update Failed.
+ */
+ QString updateProfile(const Profile &aProfile);
/*! \brief Deletes a profile from the persistent storage.
*
- * \param aName Name of the profile to remove.
- * \param aType Type of the profile to remove.
+ * This will emit a signalProfileChanged with ChangeType
+ * as Removed if Removal is successful
+ * NOTE: only Sync Profiles can be updated using ProfileManger
+ * \param aProfileId Profile to be remove.
* \return Success indicator.
*/
- bool remove(const QString &aName, const QString &aType);
-
- /*! \brief Renames a profile, and the associated log too
- *
- * \param aName The old name of the profile
- * \param aNewName The new name for the profile
- * \return Returns true if the rename was successful
- */
- bool rename(const QString &aName, const QString &aNewName);
-
- /*! \brief Enables sync'd storages in profile
- *
- * \param aProfile Profile of the remote device
- * \param aStorageMap Map of storage names(hcalendar, hcontacts) and if sync
- * enabled value true/false
- *
- */
- void enableStorages (Profile &aProfile, QMap<QString , bool> &aStorageMap);
-
- /*! \brief Sets remote target in profile
- *
- * \param aProfile Profile of the remote device
- * \param aId remote device id
- *
- */
+ bool removeProfile(const QString &aProfileId);
+
+ /*! \brief Renames a profile, and the associated log too
+ *
+ * \param aName The old name of the profile
+ * \param aNewName The new name for the profile
+ * \return Returns true if the rename was successful
+ */
+ bool rename(const QString &aName, const QString &aNewName);
+
+ /*! \brief Enables sync'd storages in profile
+ *
+ * \param aProfile Profile of the remote device
+ * \param aStorageMap Map of storage names(hcalendar, hcontacts) and if sync
+ * enabled value true/false
+ *
+ */
+ void enableStorages (Profile &aProfile, QMap<QString , bool> &aStorageMap);
+
+ /*! \brief Sets remote target in profile
+ *
+ * \param aProfile Profile of the remote device
+ * \param aId remote device id
+ *
+ */
void saveRemoteTargetId (Profile &aProfile,const QString& aId);
/*! \brief Sets/Overwrites the schedule to a profile
@@ -292,20 +320,32 @@
* \param aScheduleAsXml SyncSchedule Object as an xml string
*
*/
- bool setSyncSchedule(QString aProfileId , QString aScheduleAsXml);
+ bool setSyncSchedule(QString aProfileId , QString aScheduleAsXml);
#ifdef SYNCFW_UNIT_TESTS
friend class ProfileManagerTest;
#endif
-
+
+signals:
+
+ /*! \brief Notifies about a change in profile.
+ *
+ * This signal is sent when the profile data is modified or when a profile
+ * is added or deleted in msyncd.
+ * \param aProfileName Name of the changed profile.
+ * \param aChangeType \see ProfileManager::ProfileChangeType
+ * \param aProfileAsXml Updated Profile Object is sent as xml
+ *
+ */
+ void signalProfileChanged(QString aProfileName, int aChangeType , QString aProfileAsXml);
+
private:
-
- ProfileManager& operator=(const ProfileManager &aRhs);
-
- ProfileManagerPrivate *d_ptr;
-};
-
-}
-
-#endif // PROFILEMANAGER_H
+ ProfileManager& operator=(const ProfileManager &aRhs);
+
+ ProfileManagerPrivate *d_ptr;
+};
+
+}
+
+#endif // PROFILEMANAGER_H
--- libsyncprofile/libsyncprofile.pro
+++ libsyncprofile/libsyncprofile.pro
@@ -17,11 +17,6 @@
create_pc \
create_prl
-QMAKE_PKGCONFIG_DESTDIR = pkgconfig
-QMAKE_PKGCONFIG_LIBDIR = $$target.path
-QMAKE_PKGCONFIG_INCDIR = $$headers.path
-pkgconfig.files = $${TARGET}.pc
-
# Input
HEADERS += Profile.h \
ProfileFactory.h \
@@ -39,13 +34,13 @@
BtHelper.h
SOURCES += Profile.cpp \
+ ProfileManager.cpp \
ProfileFactory.cpp \
ProfileField.cpp \
TargetResults.cpp \
SyncResults.cpp \
SyncProfile.cpp \
SyncLog.cpp \
- ProfileManager.cpp \
StorageProfile.cpp \
SyncSchedule.cpp \
BtHelper.cpp
@@ -86,6 +81,11 @@
headers \
utility
+QMAKE_PKGCONFIG_DESTDIR = pkgconfig
+QMAKE_PKGCONFIG_LIBDIR = $$target.path
+QMAKE_PKGCONFIG_INCDIR = $$headers.path
+pkgconfig.files = $${TARGET}.pc
+
# #####################################################################
# make coverage (debug)
# #####################################################################
--- msyncd/AccountsHelper.cpp
+++ msyncd/AccountsHelper.cpp
@@ -88,9 +88,8 @@
{
LOG_DEBUG("Removing profile" << profile->name());
// Delete the profile
- iProfileManager.remove(profile->name(), Profile::TYPE_SYNC);
- // Emit signal over D-Bus to signal profile removal
- emit profileChanged(profile->name(), 2);
+ iProfileManager.removeProfile(profile->name());
+
delete profile;
}
}
@@ -111,8 +110,7 @@
foreach(SyncProfile *profile, profiles)
{
profile->setKey(KEY_HIDDEN, BOOLEAN_TRUE);
- iProfileManager.save(*profile);
- emit profileChanged(profile->name(), 1);
+ iProfileManager.updateProfile(*profile);
delete profile;
}
}
@@ -142,12 +140,12 @@
}
}
}
+
// Now disable all remaining profiles
foreach(SyncProfile *profile, profiles)
{
profile->setKey(KEY_ACTIVE, BOOLEAN_FALSE);
- iProfileManager.save(*profile);
- emit profileChanged(profile->name(), 1);
+ iProfileManager.updateProfile(*profile);
delete profile;
}
}
@@ -199,12 +197,11 @@
LOG_DEBUG ("!!!! Service not supported !!!!");
return;
}
- QString remote_database = serviceProfile->key(KEY_REMOTE_DATABASE);
QString profileName ;
- if (!remote_database.isEmpty() && !service->name().isEmpty()) {
+ if (!service->name().isEmpty()) {
QStringList keys;
- keys << remote_database << service->name();
+ keys << QString::number(account->id()) << service->name();
serviceProfile->setName(keys);
profileName = serviceProfile->name();
}
@@ -224,8 +221,7 @@
newProfile->setKey(KEY_HIDDEN, BOOLEAN_FALSE);
newProfile->setKey(KEY_ACTIVE, BOOLEAN_TRUE);
// Save the newly created profile
- iProfileManager.save(*newProfile);
- emit profileChanged(newProfile->name(), 0);
+ iProfileManager.addProfile(*newProfile);
delete newProfile;
}
else if(true == profile->boolKey(KEY_USE_ACCOUNTS, false))
@@ -233,8 +229,7 @@
// Set profile as enabled
profile->setKey(KEY_ACTIVE, BOOLEAN_FALSE);
profile->setKey(KEY_HIDDEN, BOOLEAN_FALSE);
- iProfileManager.save(*profile);
- emit profileChanged(profile->name(), 1);
+ iProfileManager.addProfile(*profile);
delete profile;
}
}
--- msyncd/AccountsHelper.h
+++ msyncd/AccountsHelper.h
@@ -82,17 +82,6 @@
*/
void slotAccountNameChanged(const QString &newName);
-Q_SIGNALS:
- /*! \brief The signal is emitted when a profile gets added, removed, or modified
- *
- * \param profileName The name of the profile that changed
- * \param changeType
- * 0 -- Profile added
- * 1 -- Profile modified
- * 2 -- Profile deleted
- */
- void profileChanged(QString profileName, int changeType);
-
private:
QList<SyncProfile*> getProfilesByAccountId(Accounts::AccountId);
--- msyncd/ServerPluginRunner.cpp
+++ msyncd/ServerPluginRunner.cpp
@@ -30,9 +30,6 @@
using namespace Buteo;
-// Maximum time in milliseconds to wait for a thread to stop
-static const unsigned long long MAX_THREAD_STOP_WAIT_TIME = 5000;
-
ServerPluginRunner::ServerPluginRunner(const QString &aPluginName,
Profile *aProfile, PluginManager *aPluginMgr, PluginCbInterface *aPluginCbIf,
ServerActivator *aServerActivator, QObject *aParent)
@@ -149,7 +146,7 @@
if (iThread != 0)
{
iThread->stopThread();
- iThread->wait(MAX_THREAD_STOP_WAIT_TIME);
+ iThread->wait();
}
}
--- msyncd/SyncBackup.cpp
+++ msyncd/SyncBackup.cpp
@@ -24,6 +24,7 @@
#include "SyncBackup.h"
#include "SyncBackupAdaptor.h"
#include "LogMacros.h"
+#include "SyncDBusConnection.h"
#include <QtDBus/QtDBus>
#include <QtDBus/QDBusServiceWatcher>
@@ -47,7 +48,7 @@
Q_ASSERT(false);
}
- QDBusConnection dbus = QDBusConnection::sessionBus();
+ QDBusConnection dbus = SyncDBusConnection::sessionBus();
if (dbus.registerObject(DBUS_BACKUP_OBJECT, this)) {
LOG_DEBUG("Registered sync backup to D-Bus");
@@ -71,7 +72,7 @@
FUNCTION_CALL_TRACE;
iBackupRestore = false;
//Unregister from D-Bus.
- QDBusConnection dbus = QDBusConnection::sessionBus();
+ QDBusConnection dbus = SyncDBusConnection::sessionBus();
dbus.unregisterObject(DBUS_BACKUP_OBJECT);
delete iWatchService;
iWatchService = 0;
@@ -116,7 +117,7 @@
QVariant vt = QVariant::fromValue((uchar)aResult);
arguments.append(vt);
iReply->setArguments(arguments);
- QDBusConnection::sessionBus().send(*iReply);
+ SyncDBusConnection::sessionBus().send(*iReply);
delete iReply;
iReply = 0;
}
--- msyncd/SyncDBusAdaptor.cpp
+++ msyncd/SyncDBusAdaptor.cpp
@@ -23,7 +23,7 @@
/*
* This file was generated by qdbusxml2cpp version 0.7
- * Command line was: qdbusxml2cpp -a SyncDBusAdaptor -c SyncDBusAdaptor com.nokia.msyncd.xml
+ * Command line was: qdbusxml2cpp -a SyncDBusAdaptor -c SyncDBusAdaptor com.meego.msyncd.xml
*
* qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
@@ -58,21 +58,29 @@
void SyncDBusAdaptor::abortSync(const QString &aProfileId)
{
- // handle method call com.nokia.msyncd.abortSync
+ // handle method call com.meego.msyncd.abortSync
QMetaObject::invokeMethod(parent(), "abortSync", Q_ARG(QString, aProfileId));
}
bool SyncDBusAdaptor::addProfile(const QString &aProfileAsXml)
{
- // handle method call com.nokia.msyncd.addProfile
+ // handle method call com.meego.msyncd.addProfile
bool out0;
QMetaObject::invokeMethod(parent(), "addProfile", Q_RETURN_ARG(bool, out0), Q_ARG(QString, aProfileAsXml));
return out0;
}
+QStringList SyncDBusAdaptor::allVisibleSyncProfiles()
+{
+ // handle method call com.meego.msyncd.allVisibleSyncProfiles
+ QStringList aProfilesAsXml;
+ QMetaObject::invokeMethod(parent(), "allVisibleSyncProfiles", Q_RETURN_ARG(QStringList, aProfilesAsXml));
+ return aProfilesAsXml;
+}
+
bool SyncDBusAdaptor::getBackUpRestoreState()
{
- // handle method call com.nokia.msyncd.getBackUpRestoreState
+ // handle method call com.meego.msyncd.getBackUpRestoreState
bool out0;
QMetaObject::invokeMethod(parent(), "getBackUpRestoreState", Q_RETURN_ARG(bool, out0));
return out0;
@@ -80,7 +88,7 @@
QString SyncDBusAdaptor::getLastSyncResult(const QString &aProfileId)
{
- // handle method call com.nokia.msyncd.getLastSyncResult
+ // handle method call com.meego.msyncd.getLastSyncResult
QString aSyncResultAsString;
QMetaObject::invokeMethod(parent(), "getLastSyncResult", Q_RETURN_ARG(QString, aSyncResultAsString), Q_ARG(QString, aProfileId));
return aSyncResultAsString;
@@ -88,7 +96,7 @@
bool SyncDBusAdaptor::isLastSyncScheduled(const QString &aProfileId)
{
- // handle method call com.nokia.msyncd.isLastSyncScheduled
+ // handle method call com.meego.msyncd.isLastSyncScheduled
bool out0;
QMetaObject::invokeMethod(parent(), "isLastSyncScheduled", Q_RETURN_ARG(bool, out0), Q_ARG(QString, aProfileId));
return out0;
@@ -96,7 +104,7 @@
int SyncDBusAdaptor::lastSyncMajorCode(const QString &aProfileId)
{
- // handle method call com.nokia.msyncd.lastSyncMajorCode
+ // handle method call com.meego.msyncd.lastSyncMajorCode
int aMajorCode;
QMetaObject::invokeMethod(parent(), "lastSyncMajorCode", Q_RETURN_ARG(int, aMajorCode), Q_ARG(QString, aProfileId));
return aMajorCode;
@@ -104,7 +112,7 @@
int SyncDBusAdaptor::lastSyncMinorCode(const QString &aProfileId)
{
- // handle method call com.nokia.msyncd.lastSyncMinorCode
+ // handle method call com.meego.msyncd.lastSyncMinorCode
int aMinorCode;
QMetaObject::invokeMethod(parent(), "lastSyncMinorCode", Q_RETURN_ARG(int, aMinorCode), Q_ARG(QString, aProfileId));
return aMinorCode;
@@ -112,7 +120,7 @@
QString SyncDBusAdaptor::lastSyncTime(const QString &aProfileId)
{
- // handle method call com.nokia.msyncd.lastSyncTime
+ // handle method call com.meego.msyncd.lastSyncTime
QString aTimeAsString;
QMetaObject::invokeMethod(parent(), "lastSyncTime", Q_RETURN_ARG(QString, aTimeAsString), Q_ARG(QString, aProfileId));
return aTimeAsString;
@@ -120,13 +128,13 @@
void SyncDBusAdaptor::releaseStorages(const QStringList &aStorageNames)
{
- // handle method call com.nokia.msyncd.releaseStorages
+ // handle method call com.meego.msyncd.releaseStorages
QMetaObject::invokeMethod(parent(), "releaseStorages", Q_ARG(QStringList, aStorageNames));
}
bool SyncDBusAdaptor::removeProfile(const QString &aProfileId)
{
- // handle method call com.nokia.msyncd.removeProfile
+ // handle method call com.meego.msyncd.removeProfile
bool out0;
QMetaObject::invokeMethod(parent(), "removeProfile", Q_RETURN_ARG(bool, out0), Q_ARG(QString, aProfileId));
return out0;
@@ -134,7 +142,7 @@
bool SyncDBusAdaptor::requestStorages(const QStringList &aStorageNames)
{
- // handle method call com.nokia.msyncd.requestStorages
+ // handle method call com.meego.msyncd.requestStorages
bool out0;
QMetaObject::invokeMethod(parent(), "requestStorages", Q_RETURN_ARG(bool, out0), Q_ARG(QStringList, aStorageNames));
return out0;
@@ -142,7 +150,7 @@
QStringList SyncDBusAdaptor::runningSyncs()
{
- // handle method call com.nokia.msyncd.runningSyncs
+ // handle method call com.meego.msyncd.runningSyncs
QStringList out0;
QMetaObject::invokeMethod(parent(), "runningSyncs", Q_RETURN_ARG(QStringList, out0));
return out0;
@@ -150,7 +158,7 @@
bool SyncDBusAdaptor::saveSyncResults(const QString &aProfileId, const QString &aSyncResults)
{
- // handle method call com.nokia.msyncd.saveSyncResults
+ // handle method call com.meego.msyncd.saveSyncResults
bool out0;
QMetaObject::invokeMethod(parent(), "saveSyncResults", Q_RETURN_ARG(bool, out0), Q_ARG(QString, aProfileId), Q_ARG(QString, aSyncResults));
return out0;
@@ -158,7 +166,7 @@
bool SyncDBusAdaptor::setSyncSchedule(const QString &aProfileId, const QString &aScheduleAsXml)
{
- // handle method call com.nokia.msyncd.setSyncSchedule
+ // handle method call com.meego.msyncd.setSyncSchedule
bool out0;
QMetaObject::invokeMethod(parent(), "setSyncSchedule", Q_RETURN_ARG(bool, out0), Q_ARG(QString, aProfileId), Q_ARG(QString, aScheduleAsXml));
return out0;
@@ -166,15 +174,23 @@
bool SyncDBusAdaptor::startSync(const QString &aProfileId)
{
- // handle method call com.nokia.msyncd.startSync
+ // handle method call com.meego.msyncd.startSync
bool out0;
QMetaObject::invokeMethod(parent(), "startSync", Q_RETURN_ARG(bool, out0), Q_ARG(QString, aProfileId));
return out0;
}
+QString SyncDBusAdaptor::syncProfile(const QString &aProfileId)
+{
+ // handle method call com.meego.msyncd.syncProfile
+ QString aProfileAsXml;
+ QMetaObject::invokeMethod(parent(), "syncProfile", Q_RETURN_ARG(QString, aProfileAsXml), Q_ARG(QString, aProfileId));
+ return aProfileAsXml;
+}
+
bool SyncDBusAdaptor::updateProfile(const QString &aProfileAsXml)
{
- // handle method call com.nokia.msyncd.updateProfile
+ // handle method call com.meego.msyncd.updateProfile
bool out0;
QMetaObject::invokeMethod(parent(), "updateProfile", Q_RETURN_ARG(bool, out0), Q_ARG(QString, aProfileAsXml));
return out0;
--- msyncd/SyncDBusAdaptor.h
+++ msyncd/SyncDBusAdaptor.h
@@ -23,7 +23,7 @@
/*
* This file was generated by qdbusxml2cpp version 0.7
- * Command line was: qdbusxml2cpp -a SyncDBusAdaptor -c SyncDBusAdaptor com.nokia.msyncd.xml
+ * Command line was: qdbusxml2cpp -a SyncDBusAdaptor -c SyncDBusAdaptor com.meego.msyncd.xml
*
* qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
@@ -45,14 +45,14 @@
class QVariant;
/*!
- * \brief Adaptor class for interface com.nokia.msyncd
+ * \brief Adaptor class for interface com.meego.msyncd
*/
class SyncDBusAdaptor: public QDBusAbstractAdaptor
{
Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "com.nokia.msyncd")
+ Q_CLASSINFO("D-Bus Interface", "com.meego.msyncd")
Q_CLASSINFO("D-Bus Introspection", ""
-" <interface name=\"com.nokia.msyncd\">\n"
+" <interface name=\"com.meego.msyncd\">\n"
" <signal name=\"syncStatus\">\n"
" <arg direction=\"out\" type=\"s\" name=\"aProfileName\"/>\n"
" <arg direction=\"out\" type=\"i\" name=\"aStatus\"/>\n"
@@ -142,6 +142,13 @@
" <arg direction=\"out\" type=\"s\" name=\"aSyncResultAsString\"/>\n"
" <arg direction=\"in\" type=\"s\" name=\"aProfileId\"/>\n"
" </method>\n"
+" <method name=\"syncProfile\">\n"
+" <arg direction=\"out\" type=\"s\" name=\"aProfileAsXml\"/>\n"
+" <arg direction=\"in\" type=\"s\" name=\"aProfileId\"/>\n"
+" </method>\n"
+" <method name=\"allVisibleSyncProfiles\">\n"
+" <arg direction=\"out\" type=\"as\" name=\"aProfilesAsXml\"/>\n"
+" </method>\n"
" </interface>\n"
"");
public:
@@ -160,6 +167,9 @@
//! \see SyncDBusInterface::addProfile()
bool addProfile(const QString &aProfileAsXml);
+ //! \see SyncDBusInterface::allVisibleSyncProfiles()
+ QStringList allVisibleSyncProfiles();
+
//! \see SyncDBusInterface::getBackUpRestoreState()
bool getBackUpRestoreState();
@@ -199,6 +209,9 @@
//! \see SyncDBusInterface::startSync()
bool startSync(const QString &aProfileId);
+ //! \see SyncDBusInterface::syncProfile()
+ QString syncProfile(const QString &aProfileId);
+
//! \see SyncDBusInterface::updateProfile()
bool updateProfile(const QString &aProfileAsXml);
Q_SIGNALS: // SIGNALS
--- msyncd/SyncDBusInterface.h
+++ msyncd/SyncDBusInterface.h
@@ -39,7 +39,7 @@
class SyncDBusInterface : public QObject
{
Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "com.nokia.msyncd")
+ Q_CLASSINFO("D-Bus Interface", "com.meego.msyncd")
public:
@@ -263,6 +263,24 @@
* \return QString of syncResult.
*/
virtual QString getLastSyncResult(const QString &aProfileId) = 0;
+
+ /*! \brief Gets all visible sync profiles.
+ *
+ * Returns all sync profiles that should be visible in sync ui. A profile
+ * is visible if it has not been explicitly set as hidden.
+ * \return The list of sync profiles.
+ */
+ virtual QStringList allVisibleSyncProfiles() = 0;
+
+ /*! \brief Gets a sync profile.
+ *
+ * Loads and merges also all sub-profiles that are referenced from the
+ * main profile. Loads the log of finished synchronization sessions with
+ * this profile.
+ * \param aProfileId Name of the profile to get.
+ * \return The sync profile as Xml string.
+ */
+ virtual QString syncProfile(const QString &aProfileId) = 0;
};
}
--- msyncd/SyncSchedulerDBusAdaptor.cpp
+++ msyncd/SyncSchedulerDBusAdaptor.cpp
-/*
- * This file is part of buteo-syncfw package
- *
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- *
- * Contact: Sateesh Kavuri <sateesh.kavuri at nokia.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-
-#include "SyncSchedulerDBusAdaptor.h"
-#include "LogMacros.h"
-
-using namespace Buteo;
-
-SyncSchedulerDBusAdaptor::SyncSchedulerDBusAdaptor(QObject* aParent) :
- QDBusAbstractAdaptor(aParent)
-
-{
- FUNCTION_CALL_TRACE;
-}
-
-
-SyncSchedulerDBusAdaptor::~SyncSchedulerDBusAdaptor()
-{
- FUNCTION_CALL_TRACE;
-}
-
-
-/*!
- \fn SyncSchedulerDBusAdaptor::triggerAlarm(cookie_t aAlarmID)
- */
-void SyncSchedulerDBusAdaptor::triggerAlarm(int aAlarmID)
-{
- FUNCTION_CALL_TRACE;
- QMetaObject::invokeMethod(parent(), "doAlarmActions", Q_ARG(long, aAlarmID));
-}
-
-
--- msyncd/SyncSchedulerDBusAdaptor.h
+++ msyncd/SyncSchedulerDBusAdaptor.h
-/*
- * This file is part of buteo-syncfw package
- *
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- *
- * Contact: Sateesh Kavuri <sateesh.kavuri at nokia.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-
-#ifndef QDBUSABSTRACTADAPTORSYNCSCHEDULERDBUSADAPTOR_H
-#define QDBUSABSTRACTADAPTORSYNCSCHEDULERDBUSADAPTOR_H
-
-#include <QtDBus/QtDBus>
-
-namespace Buteo {
-
-class SyncSchedulerDBusAdaptor: public QDBusAbstractAdaptor{
-
- Q_OBJECT
- Q_CLASSINFO("D-Bus Interface", "com.nokia.msyncd.scheduler")
- Q_CLASSINFO("D-Bus Introspection", ""
-" <interface name=\"com.nokia.msyncd.scheduler\" >\n"
-" <method name=\"triggerAlarm\" >\n"
-" <arg direction=\"in\" type=\"i\" name=\"aAlarmID\" />\n"
-" <annotation value=\"true\" name=\"org.freedesktop.DBus.Method.NoReply\" />\n"
-" </method>\n"
-" </interface>\n"
- "")
-
-public:
- /**
- * \brief Constructor
- * @param aParent A pointer to parent object
- */
- SyncSchedulerDBusAdaptor(QObject* aParent);
-
- /**
- * \brief Destructor
- */
- virtual ~SyncSchedulerDBusAdaptor();
-
-public Q_SLOTS:
-
- /**
- * \brief Called when an alarm event is triggered by the alarm daemon
- * @param aAlarmID
- */
- Q_NOREPLY void triggerAlarm(int aAlarmID);
-};
-
-}
-#endif
--- msyncd/USBModedProxy.cpp
+++ msyncd/USBModedProxy.cpp
@@ -34,6 +34,7 @@
#include <usb-moded/usb_moded-dbus.h>
#include "USBModedProxy.h"
#include "LogMacros.h"
+#include "SyncDBusConnection.h"
using namespace Buteo;
@@ -42,7 +43,7 @@
*/
USBModedProxy::USBModedProxy(QObject *parent)
- : QDBusAbstractInterface(USB_MODE_SERVICE, USB_MODE_OBJECT, staticInterfaceName(), QDBusConnection::systemBus(), parent)
+ : QDBusAbstractInterface(USB_MODE_SERVICE, USB_MODE_OBJECT, staticInterfaceName(), SyncDBusConnection::systemBus(), parent)
{
FUNCTION_CALL_TRACE;
if(false == QObject::connect(this, SIGNAL(sig_usb_state_ind(const QString&)), this, SLOT(slotModeChanged(const QString&))))
--- msyncd/bin/msyncd.desktop
+++ msyncd/bin/msyncd.desktop
+[Desktop Entry]
+Exec=/usr/bin/msyncd
+Name=Synchronization daemon
+Type=Application
--- msyncd/com.meego.msyncd.xml
+++ msyncd/com.meego.msyncd.xml
+<!--
+/*
+ * This file is part of buteo-syncfw package
+ *
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Contact: Sateesh Kavuri <sateesh.kavuri at nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+-->
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="com.meego.msyncd">
+ <signal name="syncStatus">
+ <arg name="aProfileName" type="s" direction="out"/>
+ <arg name="aStatus" type="i" direction="out"/>
+ <arg name="aMessage" type="s" direction="out"/>
+ <arg name="aErrorCode" type="i" direction="out"/>
+ </signal>
+ <signal name="transferProgress">
+ <arg name="aProfileName" type="s" direction="out"/>
+ <arg name="aTransferDatabase" type="i" direction="out"/>
+ <arg name="aTransferType" type="i" direction="out"/>
+ <arg name="aMimeType" type="s" direction="out"/>
+ <arg name="aCommittedItems" type="i" direction="out"/>
+ </signal>
+ <signal name="signalProfileChanged">
+ <arg name="aProfileName" type="s" direction="out"/>
+ <arg name="aChangeType" type="i" direction="out"/>
+ <arg name="aProfileAsXml" type="s" direction="out"/>
+ </signal>
+ <signal name="backupInProgress">
+ </signal>
+ <signal name="backupDone">
+ </signal>
+ <signal name="restoreInProgress">
+ </signal>
+ <signal name="restoreDone">
+ </signal>
+ <signal name="resultsAvailable">
+ <arg name="aProfileName" type="s" direction="out"/>
+ <arg name="aResultsAsXml" type="s" direction="out"/>
+ </signal>
+ <method name="startSync">
+ <arg type="b" direction="out"/>
+ <arg name="aProfileId" type="s" direction="in"/>
+ </method>
+ <method name="abortSync">
+ <arg name="aProfileId" type="s" direction="in"/>
+ <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
+ </method>
+ <method name="addProfile">
+ <arg type="b" direction="out"/>
+ <arg name="aProfileAsXml" type="s" direction="in"/>
+ </method>
+ <method name="removeProfile">
+ <arg type="b" direction="out"/>
+ <arg name="aProfileId" type="s" direction="in"/>
+ </method>
+ <method name="updateProfile">
+ <arg type="b" direction="out"/>
+ <arg name="aProfileAsXml" type="s" direction="in"/>
+ </method>
+ <method name="saveSyncResults">
+ <arg type="b" direction="out"/>
+ <arg name="aProfileId" type="s" direction="in"/>
+ <arg name="aSyncResults" type="s" direction="in"/>
+ </method>
+ <method name="requestStorages">
+ <arg type="b" direction="out"/>
+ <arg name="aStorageNames" type="as" direction="in"/>
+ </method>
+ <method name="releaseStorages">
+ <arg name="aStorageNames" type="as" direction="in"/>
+ <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
+ </method>
+ <method name="runningSyncs">
+ <arg type="as" direction="out"/>
+ </method>
+ <method name="getBackUpRestoreState">
+ <arg type="b" direction="out"/>
+ </method>
+ <method name="setSyncSchedule">
+ <arg type="b" direction="out"/>
+ <arg name="aProfileId" type="s" direction="in"/>
+ <arg name="aScheduleAsXml" type="s" direction="in"/>
+ </method>
+ <method name="isLastSyncScheduled">
+ <arg type="b" direction="out"/>
+ <arg name="aProfileId" type="s" direction="in"/>
+ </method>
+ <method name="lastSyncMinorCode">
+ <arg name="aMinorCode" type="i" direction="out"/>
+ <arg name="aProfileId" type="s" direction="in"/>
+ </method>
+ <method name="lastSyncMajorCode">
+ <arg name="aMajorCode" type="i" direction="out"/>
+ <arg name="aProfileId" type="s" direction="in"/>
+ </method>
+ <method name="lastSyncTime">
+ <arg name="aTimeAsString" type="s" direction="out"/>
+ <arg name="aProfileId" type="s" direction="in"/>
+ </method>
+ <method name="getLastSyncResult">
+ <arg name="aSyncResultAsString" type="s" direction="out"/>
+ <arg name="aProfileId" type="s" direction="in"/>
+ </method>
+ <method name="syncProfile">
+ <arg name="aProfileAsXml" type="s" direction="out"/>
+ <arg name="aProfileId" type="s" direction="in"/>
+ </method>
+ <method name="allVisibleSyncProfiles">
+ <arg name="aProfilesAsXml" type="as" direction="out"/>
+ </method>
+ </interface>
+</node>
--- msyncd/com.nokia.msyncd.xml
+++ msyncd/com.nokia.msyncd.xml
-<!--
-/*
- * This file is part of buteo-syncfw package
- *
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- *
- * Contact: Sateesh Kavuri <sateesh.kavuri at nokia.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
--->
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node>
- <interface name="com.nokia.msyncd">
- <signal name="syncStatus">
- <arg name="aProfileName" type="s" direction="out"/>
- <arg name="aStatus" type="i" direction="out"/>
- <arg name="aMessage" type="s" direction="out"/>
- <arg name="aErrorCode" type="i" direction="out"/>
- </signal>
- <signal name="transferProgress">
- <arg name="aProfileName" type="s" direction="out"/>
- <arg name="aTransferDatabase" type="i" direction="out"/>
- <arg name="aTransferType" type="i" direction="out"/>
- <arg name="aMimeType" type="s" direction="out"/>
- <arg name="aCommittedItems" type="i" direction="out"/>
- </signal>
- <signal name="signalProfileChanged">
- <arg name="aProfileName" type="s" direction="out"/>
- <arg name="aChangeType" type="i" direction="out"/>
- <arg name="aProfileAsXml" type="s" direction="out"/>
- </signal>
- <signal name="backupInProgress">
- </signal>
- <signal name="backupDone">
- </signal>
- <signal name="restoreInProgress">
- </signal>
- <signal name="restoreDone">
- </signal>
- <signal name="resultsAvailable">
- <arg name="aProfileName" type="s" direction="out"/>
- <arg name="aResultsAsXml" type="s" direction="out"/>
- </signal>
- <method name="startSync">
- <arg type="b" direction="out"/>
- <arg name="aProfileId" type="s" direction="in"/>
- </method>
- <method name="abortSync">
- <arg name="aProfileId" type="s" direction="in"/>
- <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
- </method>
- <method name="addProfile">
- <arg type="b" direction="out"/>
- <arg name="aProfileAsXml" type="s" direction="in"/>
- </method>
- <method name="removeProfile">
- <arg type="b" direction="out"/>
- <arg name="aProfileId" type="s" direction="in"/>
- </method>
- <method name="updateProfile">
- <arg type="b" direction="out"/>
- <arg name="aProfileAsXml" type="s" direction="in"/>
- </method>
- <method name="saveSyncResults">
- <arg type="b" direction="out"/>
- <arg name="aProfileId" type="s" direction="in"/>
- <arg name="aSyncResults" type="s" direction="in"/>
- </method>
- <method name="requestStorages">
- <arg type="b" direction="out"/>
- <arg name="aStorageNames" type="as" direction="in"/>
- </method>
- <method name="releaseStorages">
- <arg name="aStorageNames" type="as" direction="in"/>
- <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
- </method>
- <method name="runningSyncs">
- <arg type="as" direction="out"/>
- </method>
- <method name="getBackUpRestoreState">
- <arg type="b" direction="out"/>
- </method>
- <method name="setSyncSchedule">
- <arg type="b" direction="out"/>
- <arg name="aProfileId" type="s" direction="in"/>
- <arg name="aScheduleAsXml" type="s" direction="in"/>
- </method>
- <method name="isLastSyncScheduled">
- <arg type="b" direction="out"/>
- <arg name="aProfileId" type="s" direction="in"/>
- </method>
- <method name="lastSyncMinorCode">
- <arg name="aMinorCode" type="i" direction="out"/>
- <arg name="aProfileId" type="s" direction="in"/>
- </method>
- <method name="lastSyncMajorCode">
- <arg name="aMajorCode" type="i" direction="out"/>
- <arg name="aProfileId" type="s" direction="in"/>
- </method>
- <method name="lastSyncTime">
- <arg name="aTimeAsString" type="s" direction="out"/>
- <arg name="aProfileId" type="s" direction="in"/>
- </method>
- <method name="getLastSyncResult">
- <arg name="aSyncResultAsString" type="s" direction="out"/>
- <arg name="aProfileId" type="s" direction="in"/>
- </method>
- </interface>
-</node>
--- msyncd/generate_dbus_adaptor.sh
+++ msyncd/generate_dbus_adaptor.sh
@@ -22,5 +22,5 @@
# */
#
-qdbuscpp2xml -M -S SyncDBusInterface.h -o com.nokia.msyncd.xml
-qdbusxml2cpp -a SyncDBusAdaptor -c SyncDBusAdaptor com.nokia.msyncd.xml
+qdbuscpp2xml -M -S SyncDBusInterface.h -o com.meego.msyncd.xml
+qdbusxml2cpp -a SyncDBusAdaptor -c SyncDBusAdaptor com.meego.msyncd.xml
--- msyncd/generate_dbus_proxy.sh
+++ msyncd/generate_dbus_proxy.sh
@@ -22,4 +22,4 @@
# */
#
-qdbusxml2cpp -p SyncDaemonProxy -N -c SyncDaemonProxy com.nokia.msyncd.xml
+qdbusxml2cpp -p SyncDaemonProxy -N -c SyncDaemonProxy com.meego.msyncd.xml
--- msyncd/main.cpp
+++ msyncd/main.cpp
@@ -33,7 +33,7 @@
#include "synchronizer.h"
const QString LOGGER_CONFIG_FILE( "/etc/sync/set_sync_log_level" );
-const QString SYNC_LOG_FILE_PATH( "/home/user/.sync/synchronizer.log" );
+const QString SYNC_LOG_FILE_PATH( QDir::homePath () + QDir::separator() + ".sync" + QDir::separator() + "synchronizer.log");
// Linux signal handler. This application is shutdown by sending a
// SIGTERM to it
--- msyncd/msyncd.pro
+++ msyncd/msyncd.pro
@@ -99,6 +99,8 @@
target.path = /usr/bin/
loglevel.files = bin/set_sync_log_level
loglevel.path = /etc/sync/
+meego.files = bin/msyncd.desktop
+meego.path = /etc/xdg/autostart/
INSTALLS += target \
loglevel
@@ -139,10 +141,11 @@
# for compiling on meego
linux-g++-maemo {
- message("Compiling with USBModed support")
+ message("Maemo specific install")
DEFINES += __USBMODED__
HEADERS += USBModedProxy.h
SOURCES += USBModedProxy.cpp
} else {
- message("Compiling without USBModed")
+ message("Meego specific install")
+ INSTALLS += meego
}
--- msyncd/synchronizer.cpp
+++ msyncd/synchronizer.cpp
@@ -37,6 +37,7 @@
#include "ProfileFactory.h"
#include "ProfileEngineDefs.h"
#include "LogMacros.h"
+#include "SyncDBusConnection.h"
#include <contextsubscriber/contextproperty.h>
#include <QtDebug>
@@ -46,7 +47,7 @@
using namespace Buteo;
static const QString SYNC_DBUS_OBJECT = "/synchronizer";
-static const QString SYNC_DBUS_SERVICE = "com.nokia.msyncd";
+static const QString SYNC_DBUS_SERVICE = "com.meego.msyncd";
// Maximum time in milliseconds to wait for a thread to stop
static const unsigned long long MAX_THREAD_STOP_WAIT_TIME = 5000;
@@ -86,7 +87,7 @@
new SyncDBusAdaptor(this);
// Register our object on the session bus and expose interface to others.
- QDBusConnection dbus = QDBusConnection::sessionBus();
+ QDBusConnection dbus = SyncDBusConnection::sessionBus();
if (!dbus.registerObject(SYNC_DBUS_OBJECT, this) ||
!dbus.registerService(SYNC_DBUS_SERVICE))
{
@@ -98,6 +99,8 @@
LOG_DEBUG("Registered to D-Bus");
} // else ok
+ connect(&iProfileManager,SIGNAL(signalProfileChanged(QString,int,QString)),
+ this ,SIGNAL(signalProfileChanged(QString,int,QString)));
iTransportTracker = new TransportTracker(this);
@@ -110,9 +113,6 @@
// Initialize account manager.
iAccounts = new AccountsHelper(iProfileManager, this); // Deleted with parent.
- QObject::connect(iAccounts, SIGNAL(profileChanged(QString,int)),
- this, SLOT(handleAccountsProfileChange(QString,int)));
-
// Context property for low battery situation.
iLowPower = new ContextProperty("Battery.LowBattery", this);
@@ -164,7 +164,7 @@
// Unregister from D-Bus.
- QDBusConnection dbus = QDBusConnection::sessionBus();
+ QDBusConnection dbus = SyncDBusConnection::sessionBus();
dbus.unregisterObject(SYNC_DBUS_OBJECT);
if (!dbus.unregisterService(SYNC_DBUS_SERVICE))
{
@@ -282,13 +282,6 @@
session->setFailureResult(SyncResults::SYNC_RESULT_FAILED, Buteo::SyncResults::LOW_BATTERY_POWER);
emit syncStatus(aProfileName, Sync::SYNC_ERROR, "Low battery", Buteo::SyncResults::LOW_BATTERY_POWER);
}
- else if (!isTransportAvailable(session))
- {
- LOG_DEBUG( "Required transport not available" );
- session->setFailureResult(SyncResults::SYNC_RESULT_FAILED, Buteo::SyncResults::CONNECTION_ERROR);
- emit syncStatus(aProfileName, Sync::SYNC_ERROR, "Connection Error", Buteo::SyncResults::CONNECTION_ERROR);
-
- }
else if (!session->reserveStorages(&iStorageBooker))
{
LOG_DEBUG( "Needed storage(s) already in use, queuing sync request" );
@@ -383,7 +376,7 @@
if (iSyncUIInterface == NULL) {
LOG_DEBUG( "iSyncUIInterface is Null" );
iSyncUIInterface = new QDBusInterface("com.nokia.syncui", "/org/maemo/m",
- "com.nokia.MApplicationIf", QDBusConnection::sessionBus() );
+ "com.nokia.MApplicationIf", SyncDBusConnection::sessionBus() );
Q_ASSERT(iSyncUIInterface);
}
else if(!iSyncUIInterface->isValid()) {
@@ -391,7 +384,7 @@
delete iSyncUIInterface;
iSyncUIInterface = NULL;
iSyncUIInterface = new QDBusInterface("com.nokia.syncui", "/org/maemo/m",
- "com.nokia.MApplicationIf", QDBusConnection::sessionBus() );
+ "com.nokia.MApplicationIf", SyncDBusConnection::sessionBus() );
Q_ASSERT(iSyncUIInterface);
}
//calling launch with argument list
@@ -429,28 +422,28 @@
switch(aStatus)
{
case Sync::SYNC_DONE:
- {
- if (session->isProfileCreated()) {
- QMap<QString,bool> storageMap = session->getStorageMap();
- //session->setFailureResult(SyncResults::SYNC_RESULT_SUCCESS, Buteo::SyncResults::NO_ERROR);
- iProfileManager.enableStorages (*session->profile(),storageMap);
- iProfileManager.save(*session->profile());
- }
- break;
+ {
+ if (session->isProfileCreated()) {
+ QMap<QString,bool> storageMap = session->getStorageMap();
+ //session->setFailureResult(SyncResults::SYNC_RESULT_SUCCESS, Buteo::SyncResults::NO_ERROR);
+ iProfileManager.enableStorages (*session->profile(),storageMap);
+ iProfileManager.updateProfile(*session->profile());
}
+ break;
+ }
case Sync::SYNC_ABORTED:
case Sync::SYNC_CANCELLED:
- {
- session->setFailureResult(SyncResults::SYNC_RESULT_CANCELLED, Buteo::SyncResults::ABORTED);
- break;
- }
+ {
+ session->setFailureResult(SyncResults::SYNC_RESULT_CANCELLED, Buteo::SyncResults::ABORTED);
+ break;
+ }
case Sync::SYNC_ERROR:
- {
- session->setFailureResult(SyncResults::SYNC_RESULT_FAILED, aErrorCode);
- break;
- }
+ {
+ session->setFailureResult(SyncResults::SYNC_RESULT_FAILED, aErrorCode);
+ break;
+ }
default:
LOG_WARNING("Unhandled Status in onSessionFinished" << aStatus);
@@ -527,15 +520,6 @@
emit syncStatus(profileName, Sync::SYNC_ERROR, "Low Battery", Buteo::SyncResults::LOW_BATTERY_POWER);
tryNext = true;
}
- else if (!isTransportAvailable(session))
- {
- LOG_DEBUG( "Required transport not available, aborting sync request" );
- iSyncQueue.dequeue();
- session->setFailureResult(SyncResults::SYNC_RESULT_FAILED, Buteo::SyncResults::CONNECTION_ERROR);
- cleanupSession(session);
- emit syncStatus(profileName, Sync::SYNC_ERROR, "", Buteo::SyncResults::CONNECTION_ERROR);
- tryNext = true;
- }
else if (!session->reserveStorages(&iStorageBooker))
{
LOG_DEBUG( "Needed storage(s) already in use" );
@@ -581,6 +565,7 @@
if (aSession->isScheduled())
{
reschedule(profileName);
+ emit signalProfileChanged(profileName, 1 ,QString());
} // no else
} // no else
aSession->setProfileCreated(false);
@@ -613,9 +598,14 @@
FUNCTION_CALL_TRACE
bool status = false;
if(!aProfileAsXml.isEmpty()) {
- QString profileId = iProfileManager.addProfile(aProfileAsXml);
- if(!profileId.isEmpty()) {
- status = true;
+ // save the changes to persistent storage
+ Profile *profile = iProfileManager.profileFromXml(aProfileAsXml);
+ if(profile) {
+ QString profileId = iProfileManager.addProfile(*profile);
+ if(!profileId.isEmpty()) {
+ status = true;
+ }
+ delete profile;
}
}
return status;
@@ -625,6 +615,7 @@
{
FUNCTION_CALL_TRACE
bool status = false;
+ // We assume this call is made on a Sync Profile
SyncProfile *profile = iProfileManager.syncProfile (aProfileId);
if(!aProfileId.isEmpty() && profile) {
@@ -644,7 +635,7 @@
iSyncScheduler->removeProfile(aProfileId);
}
- PluginRunner *pluginRunner ;
+ PluginRunner *pluginRunner;
if (client) {
pluginRunner = new ClientPluginRunner(subProfile->name(), profile, &iPluginManager, this, this);
} else {
@@ -659,12 +650,12 @@
return status;
}
- const SyncResults * syncResults = profile->lastResults();
- if (!pluginRunner->cleanUp() && !syncResults){
+ const SyncResults * syncResults = profile->lastResults();
+ if (!pluginRunner->cleanUp() && syncResults){
LOG_CRITICAL ("Error in removing anchors, sync session ");
} else {
LOG_DEBUG("Removing the profile");
- iProfileManager.remove (aProfileId, profile->type());
+ iProfileManager.removeProfile(aProfileId);
status = true;
}
delete profile;
@@ -679,12 +670,17 @@
bool status = false;
if(!aProfileAsXml.isEmpty()) {
// save the changes to persistent storage
- QString profileId = iProfileManager.addProfile(aProfileAsXml);
+ Profile *profile = iProfileManager.profileFromXml(aProfileAsXml);
+ if(profile) {
+ QString profileId = iProfileManager.updateProfile(*profile);
- // if the profile changes are for schedule sync we need to reschedule
- if(!profileId.isEmpty()) {
- reschedule(profileId);
- status = true;
+ // if the profile changes are for schedule sync we need to reschedule
+ if(!profileId.isEmpty()) {
+ reschedule(profileId);
+ status = true;
+ }
+
+ delete profile;
}
}
return status;
@@ -724,8 +720,8 @@
}
void Synchronizer::onTransferProgress( const QString &aProfileName,
- Sync::TransferDatabase aDatabase, Sync::TransferType aType,
- const QString &aMimeType, int aCommittedItems )
+ Sync::TransferDatabase aDatabase, Sync::TransferType aType,
+ const QString &aMimeType, int aCommittedItems )
{
FUNCTION_CALL_TRACE;
@@ -845,31 +841,31 @@
if (iServerActivator != 0)
{
+ if( false == resume )
+ {
+ connect(iServerActivator, SIGNAL(serverEnabled(const QString &)),
+ this, SLOT(startServer(const QString &)), Qt::QueuedConnection);
+
+ connect(iServerActivator, SIGNAL(serverDisabled(const QString &)),
+ this, SLOT(stopServer(const QString &)), Qt::QueuedConnection);
+ }
+
+ QStringList enabledServers = iServerActivator->enabledServers();
+ foreach (QString server, enabledServers)
+ {
if( false == resume )
{
- connect(iServerActivator, SIGNAL(serverEnabled(const QString &)),
- this, SLOT(startServer(const QString &)), Qt::QueuedConnection);
-
- connect(iServerActivator, SIGNAL(serverDisabled(const QString &)),
- this, SLOT(stopServer(const QString &)), Qt::QueuedConnection);
+ startServer(server);
}
-
- QStringList enabledServers = iServerActivator->enabledServers();
- foreach (QString server, enabledServers)
+ else
{
- if( false == resume )
- {
- startServer(server);
- }
- else
+ ServerPluginRunner *pluginRunner = iServers[server];
+ if( pluginRunner )
{
- ServerPluginRunner *pluginRunner = iServers[server];
- if( pluginRunner )
- {
- pluginRunner->resume();
- }
+ pluginRunner->resume();
}
}
+ }
}
else
{
@@ -891,18 +887,18 @@
QStringList activeServers = iServers.keys();
foreach (QString server, activeServers)
{
- if( false == suspend )
- {
- stopServer(server);
- }
- else
+ if( false == suspend )
+ {
+ stopServer(server);
+ }
+ else
+ {
+ ServerPluginRunner *pluginRunner = iServers[server];
+ if( pluginRunner )
{
- ServerPluginRunner *pluginRunner = iServers[server];
- if( pluginRunner )
- {
- pluginRunner->suspend();
- }
+ pluginRunner->suspend();
}
+ }
}
}
@@ -1080,7 +1076,7 @@
if (iSyncUIInterface == NULL) {
LOG_DEBUG( "iSyncUIInterface is NULL" );
iSyncUIInterface = new QDBusInterface("com.nokia.syncui", "/org/maemo/m",
- "com.nokia.MApplicationIf", QDBusConnection::sessionBus() );
+ "com.nokia.MApplicationIf", SyncDBusConnection::sessionBus() );
Q_ASSERT(iSyncUIInterface);
}
else if(!iSyncUIInterface->isValid()) {
@@ -1088,7 +1084,7 @@
delete iSyncUIInterface;
iSyncUIInterface = NULL;
iSyncUIInterface = new QDBusInterface("com.nokia.syncui", "/org/maemo/m",
- "com.nokia.MApplicationIf", QDBusConnection::sessionBus() );
+ "com.nokia.MApplicationIf", SyncDBusConnection::sessionBus() );
Q_ASSERT(iSyncUIInterface);
}
@@ -1165,33 +1161,6 @@
}
}
-bool Synchronizer::isTransportAvailable(const SyncSession *aSession)
-{
- bool available = false;
- if (aSession != 0 && iTransportTracker != 0 && aSession->profile() != 0)
- {
- switch (aSession->profile()->destinationType())
- {
- case SyncProfile::DESTINATION_TYPE_DEVICE:
- available = iTransportTracker->isConnectivityAvailable(
- Sync::CONNECTIVITY_BT);
- break;
-
- case SyncProfile::DESTINATION_TYPE_ONLINE:
- // For online destinations, transport availability depends on the
- // existence of a network session, thus always return true here and
- // wait for a response from openSession
- available = true;
- default:
- LOG_DEBUG("Destination type not defined, assuming transport available");
- available = true;
- break;
- }
- }
-
- return available;
-}
-
bool Synchronizer::isBackupRestoreInProgress ()
{
FUNCTION_CALL_TRACE;
@@ -1276,16 +1245,6 @@
return iSyncBackup->getBackUpRestoreState();
}
-void Synchronizer::handleAccountsProfileChange(QString profile ,int aChangeType)
-{
- FUNCTION_CALL_TRACE;
- SyncProfile *syncProfile = iProfileManager.syncProfile(profile);
- if(syncProfile) {
- QString profileAsString = syncProfile->toString();
- emit signalProfileChanged(profile,aChangeType,profileAsString);
- }
-}
-
QString Synchronizer::getLastSyncResult(const QString &aProfileId)
{
FUNCTION_CALL_TRACE;
@@ -1302,10 +1261,54 @@
else {
LOG_DEBUG("SyncResults not Found!!!");
}
+ delete profile;
}
else {
+
LOG_DEBUG("No profile found with aProfileId"<<aProfileId);
}
}
return lastSyncResult;
}
+
+QStringList Synchronizer::allVisibleSyncProfiles()
+{
+ FUNCTION_CALL_TRACE;
+ QStringList profilesAsXml;
+
+ QList<Buteo::SyncProfile *> profiles = iProfileManager.allVisibleSyncProfiles();
+
+ if(!profiles.isEmpty()) {
+ foreach(Buteo::SyncProfile *profile , profiles) {
+ if(profile) {
+ profilesAsXml.append(profile->toString());
+ delete profile;
+ profile = NULL;
+ }
+ }
+ }
+ LOG_DEBUG("allVisibleSyncProfiles profilesAsXml"<<profilesAsXml);
+ return profilesAsXml;
+}
+
+
+QString Synchronizer::syncProfile(const QString &aProfileId)
+{
+ FUNCTION_CALL_TRACE;
+ QString profileAsXml;
+
+ if(!aProfileId.isEmpty()) {
+ SyncProfile *profile = iProfileManager.syncProfile (aProfileId);
+ if(profile) {
+ profileAsXml.append(profile->toString());
+ delete profile;
+ profile = NULL;
+ }
+ else {
+
+ LOG_DEBUG("No profile found with aProfileId"<<aProfileId);
+ }
+ }
+ LOG_DEBUG("syncProfile profileAsXml"<<profileAsXml<<"aProfileId"<<aProfileId);
+ return profileAsXml;
+}
--- msyncd/synchronizer.h
+++ msyncd/synchronizer.h
@@ -137,6 +137,24 @@
* \return QString of syncResult.
*/
virtual QString getLastSyncResult(const QString &aProfileId);
+
+ /*! \brief Gets all visible sync profiles.
+ *
+ * Returns all sync profiles that should be visible in sync ui. A profile
+ * is visible if it has not been explicitly set as hidden.
+ * \return The list of sync profiles.
+ */
+ virtual QStringList allVisibleSyncProfiles();
+
+ /*! \brief Gets a sync profile.
+ *
+ * Loads and merges also all sub-profiles that are referenced from the
+ * main profile. Loads the log of finished synchronization sessions with
+ * this profile.
+ * \param aProfileId Name of the profile to get.
+ * \return The sync profile as Xml string.
+ */
+ virtual QString syncProfile(const QString &aProfileId);
// --------------------------------------------------------------------------
//! Called starts a schedule sync.
@@ -157,9 +175,6 @@
//! Called to get the current backup/restore state
virtual bool getBackUpRestoreState();
- //! handles any changes in the accounts profile
- virtual void handleAccountsProfileChange(QString,int);
-
signals:
//! emitted by releaseStorages call
@@ -254,7 +269,6 @@
*
*/
void initializeScheduler();
- bool isTransportAvailable(const SyncSession *aSession);
bool isBackupRestoreInProgress ();
--- unittests/tests/msyncdtests/ServerActivatorTest.cpp
+++ unittests/tests/msyncdtests/ServerActivatorTest.cpp
@@ -42,10 +42,10 @@
// add server profiles through Profile class
Profile myProfile("sampleServerProfile", Profile::TYPE_SERVER);
- QVERIFY(iProfileManager->save(myProfile));
+ QVERIFY(!iProfileManager->updateProfile(myProfile).isEmpty());
Profile myProfile2("sampleServerProfile2", Profile::TYPE_SERVER);
- iProfileManager->save(myProfile2);
+ iProfileManager->updateProfile(myProfile2);
iServerActivator = new ServerActivator(*iProfileManager, *iTransportTracker, this);
@@ -123,7 +123,7 @@
sampleServerProfile.setName("sampleProfile");
const QString PROFILE_PATH("syncprofiletests/testprofiles/user");
ProfileManager myProfileManager(PROFILE_PATH, PROFILE_PATH);
- myProfileManager.save(sampleServerProfile);
+ myProfileManager.updateProfile(sampleServerProfile);
TransportTracker myTrasportTracker(this);
ServerActivator sampleServerActivator(myProfileManager, myTrasportTracker, this);
@@ -143,7 +143,7 @@
sampleServerActivator.onConnectivityStateChanged(Sync::CONNECTIVITY_USB, false);
QCOMPARE(disabledSpy.count(), 1);
- QVERIFY(myProfileManager.remove("sampleProfile", Profile::TYPE_SERVER));
+ QVERIFY(myProfileManager.removeProfile("sampleProfile"));
}
void ServerActivatorTest :: testTransportsFromProfile()
--- unittests/tests/msyncdtests/ServerPluginRunnerTest.cpp
+++ unittests/tests/msyncdtests/ServerPluginRunnerTest.cpp
@@ -34,7 +34,7 @@
iTransportTracker = new TransportTracker(this);
iProfileManager = new ProfileManager("profile1", "profile2");
iProfile = new Profile("dummyprofile", Profile::TYPE_SERVER);
- iProfileManager->save(*iProfile);
+ iProfileManager->updateProfile(*iProfile);
iServerActivator = new ServerActivator(*iProfileManager, *iTransportTracker);
--- unittests/tests/msyncdtests/SyncSchedulerDBusAdaptorTest.cpp
+++ unittests/tests/msyncdtests/SyncSchedulerDBusAdaptorTest.cpp
-/*
- * This file is part of buteo-syncfw package
- *
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- *
- * Contact: Sateesh Kavuri <sateesh.kavuri at nokia.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-#include "SyncSchedulerDBusAdaptorTest.h"
-#include "SyncSchedulerDBusAdaptor.h"
-#include "SyncFwTestLoader.h"
-
-using namespace Buteo;
-
-void SyncSchedulerDBusAdaptorTest::doAlarmActions(long /*aAlarmEventID*/)
-{
- iMethodInvoked = true;
-}
-
-
-
-void SyncSchedulerDBusAdaptorTest::testTriggerAlarm()
-{
- iMethodInvoked = false;
- SyncSchedulerDBusAdaptor dbusAdaptor(this);
- long alarmID = 1;
- dbusAdaptor.triggerAlarm(alarmID);
- QVERIFY(iMethodInvoked);
-}
-
-TESTLOADER_ADD_TEST(SyncSchedulerDBusAdaptorTest);
--- unittests/tests/msyncdtests/SyncSchedulerDBusAdaptorTest.h
+++ unittests/tests/msyncdtests/SyncSchedulerDBusAdaptorTest.h
-/*
- * This file is part of buteo-syncfw package
- *
- * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
- *
- * Contact: Sateesh Kavuri <sateesh.kavuri at nokia.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-#ifndef SYNCSCHEDULERDBUSADAPTORTEST_H_
-#define SYNCSCHEDULERDBUSADAPTORTEST_H_
-
-#include <QtTest/QtTest>
-
-namespace Buteo {
-
-class SyncSchedulerDBusAdaptorTest: public QObject
-{
- Q_OBJECT
-
- public slots:
- void doAlarmActions(long aAlarmEventID);
-
- private slots:
-
- void testTriggerAlarm();
-
- private:
- bool iMethodInvoked;
-};
-
-}
-
-#endif // SYNCSCHEDULERDBUSADAPTORTEST_H_
--- unittests/tests/msyncdtests/SynchronizerTest.cpp
+++ unittests/tests/msyncdtests/SynchronizerTest.cpp
@@ -160,7 +160,6 @@
QVERIFY(iSync->iTransportTracker != 0);
iSync->iTransportTracker->updateState(Sync::CONNECTIVITY_USB, true);
- QCOMPARE(iSync->isConnectivityAvailable(Sync::CONNECTIVITY_USB), true);
//test startServers()
QVERIFY(iSync->iServerActivator != 0);
@@ -206,7 +205,6 @@
QVERIFY(iSyncSession != 0);
QVERIFY(iSync->iTransportTracker != 0);
QVERIFY(iSyncSession->profile() != 0);
- QCOMPARE(iSync->isTransportAvailable(iSyncSession), true);
}
void SynchronizerTest::testSignals()
{
--- unittests/tests/syncprofiletests/ProfileManagerTest.cpp
+++ unittests/tests/syncprofiletests/ProfileManagerTest.cpp
@@ -598,7 +598,7 @@
QVERIFY(p != 0);
QCOMPARE(p->isEnabled(), true);
p->setEnabled(false);
- pm.save(*p);
+ pm.addProfile(*p);
}
{
@@ -615,7 +615,7 @@
}
p->setEnabled(true);
- pm.save(*p);
+ pm.updateProfile(*p);
}
}
@@ -633,7 +633,7 @@
QScopedPointer<SyncProfile> p(pm.syncProfile(OVI_CALENDAR));
QVERIFY(p != 0);
p->setBoolKey(KEY_HIDDEN, true);
- pm.save(*p);
+ pm.addProfile(*p);
// Verify that number of visible profiles is reduced.
profiles = pm.allVisibleSyncProfiles();
@@ -643,7 +643,7 @@
// Make profile visible again.
p->removeKey(KEY_HIDDEN);
- pm.save(*p);
+ pm.updateProfile(*p);
}
void ProfileManagerTest::testRemovingProfiles()
@@ -655,20 +655,17 @@
QScopedPointer<SyncProfile> p(pm.syncProfile(OVI_CALENDAR));
QVERIFY(p != 0);
p->setName(TEMP_NAME);
- pm.save(*p);
-
- // Try removing with wrong type.
- QCOMPARE(pm.remove(TEMP_NAME, Profile::TYPE_STORAGE), false);
+ pm.addProfile(*p);
// Try removing protected profile.
p->setBoolKey(KEY_PROTECTED, true);
- pm.save(*p);
- QCOMPARE(pm.remove(TEMP_NAME, Profile::TYPE_SYNC), false);
+ pm.updateProfile(*p);
+ QCOMPARE(pm.removeProfile(TEMP_NAME), false);
// Disable protectiong and remove profile.
p->removeKey(KEY_PROTECTED);
- pm.save(*p);
- QCOMPARE(pm.remove(TEMP_NAME, Profile::TYPE_SYNC), true);
+ pm.updateProfile(*p);
+ QCOMPARE(pm.removeProfile(TEMP_NAME), true);
}
void ProfileManagerTest::testOverrideKey()
More information about the MeeGo-commits
mailing list