Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sociald] Add VK contacts sync adaptor. Contributes to JB#19272
This commit adds (one-way) contacts sync adaptor for VKontakte. Contributes to JB#19272
- Loading branch information
Chris Adams
authored and
Antti Seppälä
committed
Oct 12, 2015
1 parent
87b907f
commit 83cd9f2
Showing
13 changed files
with
1,351 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CONFIG += link_pkgconfig | ||
PKGCONFIG += Qt5Contacts qtcontacts-sqlite-qt5-extensions | ||
QT += contacts-private | ||
SOURCES += $$PWD/vkcontactsyncadaptor.cpp $$PWD/vkcontactimagedownloader.cpp | ||
HEADERS += $$PWD/vkcontactsyncadaptor.h $$PWD/vkcontactimagedownloader.h | ||
INCLUDEPATH += $$PWD | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
TARGET = vk-contacts-client | ||
VERSION = 0.0.1 | ||
|
||
DEFINES += "CLASSNAME=VKContactsPlugin" | ||
DEFINES += CLASSNAME_H=\\\"vkcontactsplugin.h\\\" | ||
DEFINES += SOCIALD_USE_QTPIM | ||
include($$PWD/../../common.pri) | ||
include($$PWD/../vk-common.pri) | ||
include($$PWD/vk-contacts.pri) | ||
|
||
vk_contacts_sync_profile.path = /etc/buteo/profiles/sync | ||
vk_contacts_sync_profile.files = $$PWD/vk.Contacts.xml | ||
vk_contacts_client_plugin_xml.path = /etc/buteo/profiles/client | ||
vk_contacts_client_plugin_xml.files = $$PWD/vk-contacts.xml | ||
|
||
HEADERS += vkcontactsplugin.h | ||
SOURCES += vkcontactsplugin.cpp | ||
|
||
OTHER_FILES += \ | ||
vk.Contacts.xml \ | ||
vk-contacts.xml | ||
|
||
INSTALLS += \ | ||
target \ | ||
vk_contacts_sync_profile \ | ||
vk_contacts_client_plugin_xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<profile name="vk-contacts" type="client" > | ||
<field name="Sync Direction" /> | ||
</profile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<profile name="vk.Contacts" type="sync" > | ||
<key name="category" value="vk.Contacts" /> | ||
<key name="enabled" value="false" /> | ||
<key name="use_accounts" value="false" /> | ||
<key name="destinationtype" value="online" /> | ||
<key name="hidden" value="true" /> | ||
<key name="displayname" value="VK Contacts"/> | ||
|
||
<schedule enabled="false" interval="" days="1,2,3,4,5,6,7" syncconfiguredtime="" time="05:00:00" /> | ||
|
||
<profile name="vk-contacts" type="client" > | ||
<key name="Sync Direction" value="from-remote" /> | ||
</profile> | ||
</profile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2014 Jolla Ltd. | ||
** Contact: Chris Adams <chris.adams@jollamobile.com> | ||
** | ||
****************************************************************************/ | ||
|
||
#include "vkcontactimagedownloader.h" | ||
|
||
#include <QUrl> | ||
#include <QUrlQuery> | ||
#include <QNetworkRequest> | ||
#include <QNetworkReply> | ||
#include <QNetworkAccessManager> | ||
|
||
static const char *IMAGE_DOWNLOADER_TOKEN_KEY = "token"; | ||
static const char *IMAGE_DOWNLOADER_IDENTIFIER_KEY = "identifier"; | ||
|
||
VKContactImageDownloader::VKContactImageDownloader() | ||
: AbstractImageDownloader() | ||
{ | ||
} | ||
|
||
QString VKContactImageDownloader::staticOutputFile(const QString &identifier, const QUrl &url) | ||
{ | ||
return makeOutputFile(SocialSyncInterface::VK, SocialSyncInterface::Contacts, identifier, url.toString()); | ||
} | ||
|
||
QNetworkReply * VKContactImageDownloader::createReply(const QString &url, | ||
const QVariantMap &metadata) | ||
{ | ||
Q_D(AbstractImageDownloader); | ||
|
||
// XXX TODO: this might not be needed. | ||
QString accessToken = metadata.value(IMAGE_DOWNLOADER_TOKEN_KEY).toString(); | ||
QUrl requestUrl(url); | ||
QUrlQuery urlQuery; | ||
urlQuery.addQueryItem("access_token", accessToken); | ||
requestUrl.setQuery(urlQuery); | ||
|
||
QNetworkRequest request(requestUrl); | ||
return d->networkAccessManager->get(request); | ||
} | ||
|
||
QString VKContactImageDownloader::outputFile(const QString &url, const QVariantMap &data) const | ||
{ | ||
return staticOutputFile(data.value(IMAGE_DOWNLOADER_IDENTIFIER_KEY).toString(), url); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2014 Jolla Ltd. | ||
** Contact: Chris Adams <chris.adams@jollamobile.com> | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef VKCONTACTIMAGEDOWNLOADER_H | ||
#define VKCONTACTIMAGEDOWNLOADER_H | ||
|
||
#include <socialcache/abstractimagedownloader.h> | ||
#include <socialcache/abstractimagedownloader_p.h> | ||
|
||
#include <QObject> | ||
#include <QString> | ||
#include <QVariantMap> | ||
#include <QUrl> | ||
|
||
class QNetworkReply; | ||
class VKContactImageDownloader: public AbstractImageDownloader | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit VKContactImageDownloader(); | ||
static QString staticOutputFile(const QString &identifier, const QUrl &url); | ||
protected: | ||
QNetworkReply * createReply(const QString &url, const QVariantMap &metadata); | ||
// This is a reimplemented method, used by AbstractImageDownloader | ||
QString outputFile(const QString &url, const QVariantMap &data) const; | ||
private: | ||
Q_DECLARE_PRIVATE(AbstractImageDownloader) | ||
}; | ||
|
||
#endif // VKCONTACTIMAGEDOWNLOADER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2014 Jolla Ltd. | ||
** Contact: Chris Adams <chris.adams@jolla.com> | ||
** | ||
****************************************************************************/ | ||
|
||
#include "constants_p.h" | ||
#include <qtcontacts-extensions_impl.h> | ||
#include <qcontactoriginmetadata_impl.h> | ||
|
||
#include "vkcontactsplugin.h" | ||
#include "vkcontactsyncadaptor.h" | ||
#include "socialnetworksyncadaptor.h" | ||
|
||
extern "C" VKContactsPlugin* createPlugin(const QString& pluginName, | ||
const Buteo::SyncProfile& profile, | ||
Buteo::PluginCbInterface *callbackInterface) | ||
{ | ||
return new VKContactsPlugin(pluginName, profile, callbackInterface); | ||
} | ||
|
||
extern "C" void destroyPlugin(VKContactsPlugin* plugin) | ||
{ | ||
delete plugin; | ||
} | ||
|
||
VKContactsPlugin::VKContactsPlugin(const QString& pluginName, | ||
const Buteo::SyncProfile& profile, | ||
Buteo::PluginCbInterface *callbackInterface) | ||
: SocialdButeoPlugin(pluginName, profile, callbackInterface, | ||
QStringLiteral("vk"), | ||
SocialNetworkSyncAdaptor::dataTypeName(SocialNetworkSyncAdaptor::Contacts)) | ||
{ | ||
} | ||
|
||
VKContactsPlugin::~VKContactsPlugin() | ||
{ | ||
} | ||
|
||
SocialNetworkSyncAdaptor *VKContactsPlugin::createSocialNetworkSyncAdaptor() | ||
{ | ||
return new VKContactSyncAdaptor(this); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/**************************************************************************** | ||
** | ||
** Copyright (C) 2014 Jolla Ltd. | ||
** Contact: Chris Adams <chris.adams@jolla.com> | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef VKCONTACTSPLUGIN_H | ||
#define VKCONTACTSPLUGIN_H | ||
|
||
#include "socialdbuteoplugin.h" | ||
|
||
class VKContactsPlugin : public SocialdButeoPlugin | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
VKContactsPlugin(const QString& pluginName, | ||
const Buteo::SyncProfile& profile, | ||
Buteo::PluginCbInterface *cbInterface); | ||
~VKContactsPlugin(); | ||
|
||
protected: | ||
SocialNetworkSyncAdaptor *createSocialNetworkSyncAdaptor(); | ||
}; | ||
|
||
extern "C" VKContactsPlugin* createPlugin(const QString& pluginName, | ||
const Buteo::SyncProfile& profile, | ||
Buteo::PluginCbInterface *cbInterface); | ||
|
||
extern "C" void destroyPlugin(VKContactsPlugin* client); | ||
|
||
#endif // VKCONTACTSPLUGIN_H |
Oops, something went wrong.