Skip to content

Commit

Permalink
[sociald] Support syncing Google contacts. Contributes to JB#4698
Browse files Browse the repository at this point in the history
This commit ports the buteo-sync-plugin-google-simple plugin into
the sociald infrastructure in order to support multiple accounts
and to properly cleanup data on account removal.

Contributes to JB#4698 and JB#8747 and JB#10453
  • Loading branch information
Chris Adams committed Oct 8, 2013
1 parent 70e21fd commit a49eb8a
Show file tree
Hide file tree
Showing 13 changed files with 1,577 additions and 2 deletions.
5 changes: 4 additions & 1 deletion rpm/sociald.spec
@@ -1,6 +1,6 @@
Name: sociald
Summary: Syncs device data from social services
Version: 0.0.33
Version: 0.0.37
Release: 1
Group: System/Applications
License: TBD
Expand Down Expand Up @@ -31,6 +31,8 @@ Requires: nemo-qml-plugin-notifications-qt5
Requires: nemo-qml-plugin-social-qt5 >= 0.0.11
Requires: buteo-syncfw-qt5-msyncd
Requires: mkcal-qt5
Obsoletes: buteo-sync-plugins-google-simple <= 0.0.2
Provides: buteo-sync-plugins-google-simple

%description
A daemon process which provides data synchronization with various social services.
Expand All @@ -46,6 +48,7 @@ A daemon process which provides data synchronization with various social service
%config %{_sysconfdir}/buteo/profiles/sync/facebook.Posts.xml
%config %{_sysconfdir}/buteo/profiles/sync/twitter.Notifications.xml
%config %{_sysconfdir}/buteo/profiles/sync/twitter.Posts.xml
%config %{_sysconfdir}/buteo/profiles/sync/google.Contacts.xml
%{_datadir}/lipstick/notificationcategories/x-nemo.social.facebook.notification.conf
%{_datadir}/lipstick/notificationcategories/x-nemo.social.twitter.mention.conf
%{_datadir}/translations/sociald_eng_en.qm
Expand Down
24 changes: 24 additions & 0 deletions src/google/google.pri
@@ -0,0 +1,24 @@
INCLUDEPATH += . ..

PKGCONFIG += qtcontacts-sqlite-qt5-extensions

SOURCES += \
$$PWD/googledatatypesyncadaptor.cpp \
$$PWD/googlecontactsyncadaptor.cpp \
$$PWD/googlecontactstream.cpp \
$$PWD/googlecontactatom.cpp

HEADERS += \
$$PWD/googledatatypesyncadaptor.h \
$$PWD/googlecontactsyncadaptor.h \
$$PWD/googlecontactstream.h \
$$PWD/googlecontactatom.h \
$$PWD/googlecontactatom_global.h

OTHER_FILES += google_sync_profiles.files

# google buteo sync profiles
google_sync_profiles.path = /etc/buteo/profiles/sync
google_sync_profiles.files = $$PWD/../xml/sync/google.Contacts.xml

INSTALLS += google_sync_profiles
151 changes: 151 additions & 0 deletions src/google/googlecontactatom.cpp
@@ -0,0 +1,151 @@
/****************************************************************************
**
** Copyright (C) 2013 Jolla Ltd. and/or its subsidiary(-ies).
** Contact: Chris Adams <chris.adams@jollamobile.com>
**
** Contributors: Sateesh Kavuri <sateesh.kavuri@gmail.com>
** Mani Chandrasekar <maninc@gmail.com>
** Chris Adams <chris.adams@jollamobile.com>
**
****************************************************************************/

#include "googlecontactatom.h"
#include <LogMacros.h>

GoogleContactAtom::GoogleContactAtom()
{
}

void GoogleContactAtom::setAuthorEmail(const QString &authorEmail)
{
mAuthorEmail = authorEmail;
}

QString GoogleContactAtom::authorEmail() const
{
return mAuthorEmail;
}

void GoogleContactAtom::setAuthorName(const QString &authorName)
{
mAuthorName = authorName;
}

QString GoogleContactAtom::authorName() const
{
return mAuthorName;
}

void GoogleContactAtom::setId(const QString &id)
{
mId = id;
}

QString GoogleContactAtom::id() const
{
return mId;
}

void GoogleContactAtom::setUpdated(const QString &updated)
{
mUpdated = updated;
}

QString GoogleContactAtom::updated() const
{
return mUpdated;
}

void GoogleContactAtom::setCategory (const QString &schema, const QString &term)
{
Q_UNUSED(schema)
Q_UNUSED(term)
}

void GoogleContactAtom::setTitle(const QString &title)
{
mTitle = title;
}

QString GoogleContactAtom::title() const
{
return mTitle;
}

void GoogleContactAtom::setGenerator(const QString &name, const QString &version, const QString &uri)
{
mGeneratorName = name;
mGeneratorVersion = version;
mGeneratorUri = uri;
}

void GoogleContactAtom::setContent (const QString &note, const QString &type)
{
Q_UNUSED(note)
Q_UNUSED(type)
}

QString GoogleContactAtom::generatorName() const
{
return mGeneratorName;
}

QString GoogleContactAtom::generatorVersion() const
{
return mGeneratorVersion;
}

QString GoogleContactAtom::generatorUri() const
{
return mGeneratorUri;
}

void GoogleContactAtom::setTotalResults(int totalResults)
{
mTotalResults = totalResults;
}

int GoogleContactAtom::totalResults() const
{
return mTotalResults;
}

void GoogleContactAtom::setStartIndex(int startIndex)
{
mStartIndex = startIndex;
}

int GoogleContactAtom::startIndex() const
{
return mStartIndex;
}

void GoogleContactAtom::setItemsPerPage(int itemsPerPage)
{
mItemsPerPage = itemsPerPage;
}

int GoogleContactAtom::itemsPerPage() const
{
return mItemsPerPage;
}

void GoogleContactAtom::addEntryContact(const QContact &entryContact)
{
mContactList.append(entryContact);
}

QList<QContact> GoogleContactAtom::entryContacts() const
{
return mContactList;
}

void GoogleContactAtom::setNextEntriesUrl(const QString &nextUrl)
{
mNextEntriesUrl = nextUrl;
}

QString GoogleContactAtom::nextEntriesUrl() const
{
return mNextEntriesUrl;
}
103 changes: 103 additions & 0 deletions src/google/googlecontactatom.h
@@ -0,0 +1,103 @@
/****************************************************************************
**
** Copyright (C) 2013 Jolla Ltd. and/or its subsidiary(-ies).
** Contact: Chris Adams <chris.adams@jollamobile.com>
**
** Contributors: Sateesh Kavuri <sateesh.kavuri@gmail.com>
** Chris Adams <chris.adams@jollamobile.com>
**
****************************************************************************/

#ifndef GOOGLECONTACTATOM_H
#define GOOGLECONTACTATOM_H

#include <QMetaEnum>
#include <QMap>
#include <QList>
#include <QXmlStreamWriter>

#include <QContact>

USE_CONTACTS_NAMESPACE

class GoogleContactAtom {
public:
GoogleContactAtom ();

typedef enum
{
text,
html,
xhtml
} TYPE;

void setAuthorName(const QString &authorName);
QString authorName() const;

void setAuthorEmail(const QString &authorEmail);
QString authorEmail() const;

void setId(const QString &id);
QString id() const;

void setUpdated(const QString &updated);
QString updated() const;

void setCategory (const QString &schema = QLatin1String("http://schemas.google.com/g/2005#kind"),
const QString &term = QLatin1String("http://schemas.google.com/contact/2008#contact"));

void setTitle(const QString &title);
QString title() const;

void setContent (const QString &note, const QString &type = QLatin1String("text"));

void setGenerator(const QString &name = QLatin1String("Contacts"),
const QString &version = QLatin1String("1.0"),
const QString &uri = QLatin1String("http://sailfish.org"));
QString generatorName() const;
QString generatorVersion() const;
QString generatorUri() const;

void setTotalResults(int totalResults);
int totalResults() const;

void setStartIndex(int startIndex);
int startIndex() const;

void setItemsPerPage(int itemsPerPage);
int itemsPerPage() const;

void addEntryContact(const QContact &contact);
QList<QContact> entryContacts() const;

void setNextEntriesUrl (const QString &nextUrl);
QString nextEntriesUrl() const;

private:
QString mAuthorEmail;
QString mAuthorName;
QString mCategory;
QString mCategoryTerm;
QString mSchema;
QString mContributor;
QString mGeneratorName;
QString mGeneratorVersion;
QString mGeneratorUri;
QString mIcon;
QString mId;
QString mLink;
QString mLogo;
QString mRights;
QString mSubtitle;
QString mTitle;
QString mUpdated;

int mTotalResults;
int mStartIndex;
int mItemsPerPage;

QList<QContact> mContactList;
QString mNextEntriesUrl;
};

#endif // GOOGLECONTACTATOM_H

0 comments on commit a49eb8a

Please sign in to comment.