Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[buteo-sync-plugins-social] Add knowncontacts plugin. Fixes JB#48443
This is new plugin that can sync contacts written to ini files. It
ensures that the contacts are not synced to any cloud services.
  • Loading branch information
Tomin1 committed Jan 14, 2020
1 parent ad6470b commit 4653c07
Show file tree
Hide file tree
Showing 11 changed files with 791 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -6,3 +6,7 @@ Makefile
*.qm
*.moc
*.obj
/RPMS/
*.list
*-client
tests/tst_*/tst_*
65 changes: 44 additions & 21 deletions rpm/sociald.spec
Expand Up @@ -16,6 +16,7 @@ BuildRequires: pkgconfig(libsignon-qt5)
BuildRequires: pkgconfig(accounts-qt5) >= 1.13
BuildRequires: pkgconfig(socialcache) >= 0.0.48
BuildRequires: pkgconfig(libsailfishkeyprovider)
BuildRequires: pkgconfig(qtcontacts-sqlite-qt5-extensions)
BuildRequires: qt5-qttools-linguist
BuildRequires: ssu-devel
Requires: buteo-syncfw-qt5-msyncd
Expand Down Expand Up @@ -44,7 +45,7 @@ BuildRequires: pkgconfig(libkcalcoren-qt5)
Requires: %{name} = %{version}-%{release}

%description facebook-calendars
Provides calendar synchronisation with Facebook
%{summary}.

%files facebook-calendars
#out-of-process-plugin form:
Expand Down Expand Up @@ -74,7 +75,7 @@ BuildRequires: pkgconfig(qtcontacts-sqlite-qt5-extensions)
Requires: %{name} = %{version}-%{release}

%description facebook-contacts
Provides contact synchronisation with Facebook
%{summary}

%files facebook-contacts
#out-of-process-plugin form:
Expand All @@ -101,7 +102,7 @@ Summary: Provides image synchronisation with Facebook
Requires: %{name} = %{version}-%{release}

%description facebook-images
Provides image synchronisation with Facebook
%{summary}.

%files facebook-images
#out-of-process-plugin form:
Expand Down Expand Up @@ -129,7 +130,7 @@ BuildRequires: qt5-qttools-linguist
Requires: %{name} = %{version}-%{release}

%description facebook-signon
Provides signon credentials refreshing with Facebook
%{summary}.

%files facebook-signon
#out-of-process-plugin form:
Expand Down Expand Up @@ -159,7 +160,7 @@ BuildRequires: pkgconfig(libkcalcoren-qt5)
Requires: %{name} = %{version}-%{release}

%description google-calendars
Provides calendar synchronisation with Google
%{summary}.

%files google-calendars
#out-of-process-plugin form:
Expand Down Expand Up @@ -189,7 +190,7 @@ BuildRequires: pkgconfig(qtcontacts-sqlite-qt5-extensions) >= 0.1.58
Requires: %{name} = %{version}-%{release}

%description google-contacts
Provides contact synchronisation with Google
%{summary}.

%files google-contacts
#out-of-process-plugin form:
Expand Down Expand Up @@ -217,7 +218,7 @@ BuildRequires: qt5-qttools-linguist
Requires: %{name} = %{version}-%{release}

%description google-signon
Provides signon credentials refreshing with Google
%{summary}.

%files google-signon
#out-of-process-plugin form:
Expand Down Expand Up @@ -249,7 +250,7 @@ BuildRequires: qt5-qttools-linguist
Requires: %{name} = %{version}-%{release}

%description twitter-notifications
Provides notification synchronisation with Twitter
%{summary}.

%files twitter-notifications
#out-of-process-plugin form:
Expand Down Expand Up @@ -283,7 +284,7 @@ BuildRequires: qt5-qttools-linguist
Requires: %{name} = %{version}-%{release}

%description twitter-posts
Provides post synchronisation with Twitter
%{summary}.

%files twitter-posts
#out-of-process-plugin form:
Expand Down Expand Up @@ -312,7 +313,7 @@ BuildRequires: qt5-qttools-linguist
Requires: %{name} = %{version}-%{release}

%description onedrive-signon
Provides signon credentials refreshing with OneDrive
%{summary}.

%files onedrive-signon
#out-of-process-plugin form:
Expand Down Expand Up @@ -342,7 +343,7 @@ BuildRequires: qt5-qttools-linguist
Requires: %{name} = %{version}-%{release}

%description vk-posts
Provides post synchronisation with VK
%{summary}.

%files vk-posts
%{_datadir}/lipstick/notificationcategories/x-nemo.social.vk.statuspost.conf
Expand Down Expand Up @@ -370,7 +371,7 @@ Summary: Provides image synchronisation with Dropbox
Requires: %{name} = %{version}-%{release}

%description dropbox-images
Provides image synchronisation with Dropbox
%{summary}.

%files dropbox-images
#out-of-process-plugin form:
Expand All @@ -396,7 +397,7 @@ Summary: Provides image synchronisation with OneDrive
Requires: %{name} = %{version}-%{release}

%description onedrive-images
Provides image synchronisation with OneDrive
%{summary}.

%files onedrive-images
#out-of-process-plugin form:
Expand Down Expand Up @@ -425,7 +426,7 @@ BuildRequires: qt5-qttools-linguist
Requires: %{name} = %{version}-%{release}

%description onedrive-backup
Provides backup-blob synchronization for OneDrive
%{summary}.

%files onedrive-backup
#out-of-process-plugin form:
Expand Down Expand Up @@ -454,7 +455,7 @@ BuildRequires: qt5-qttools-linguist
Requires: %{name} = %{version}-%{release}

%description dropbox-backup
Provides backup-blob synchronization for Dropbox
%{summary}.

%files dropbox-backup
#out-of-process-plugin form:
Expand Down Expand Up @@ -484,7 +485,7 @@ BuildRequires: qt5-qttools-linguist
Requires: %{name} = %{version}-%{release}

%description vk-notifications
Provides notification synchronisation with VK
%{summary}.

%files vk-notifications
#out-of-process-plugin form:
Expand Down Expand Up @@ -514,7 +515,7 @@ BuildRequires: pkgconfig(libkcalcoren-qt5)
Requires: %{name} = %{version}-%{release}

%description vk-calendars
Provides calendar synchronisation with VK
%{summary}.

%files vk-calendars
#out-of-proces-plugin form:
Expand Down Expand Up @@ -544,7 +545,7 @@ BuildRequires: pkgconfig(qtcontacts-sqlite-qt5-extensions)
Requires: %{name} = %{version}-%{release}

%description vk-contacts
Provides contact synchronisation with VK
%{summary}.

%files vk-contacts
#out-of-process-plugin form:
Expand All @@ -571,7 +572,7 @@ Summary: Provides image synchronisation with VK
Requires: %{name} = %{version}-%{release}

%description vk-images
Provides image synchronisation with VK
%{summary}.

%files vk-images
#out-of-process-plugin form:
Expand All @@ -593,12 +594,34 @@ done
systemctl-user restart msyncd.service || :



%package knowncontacts
Summary: Store locally created contacts

%description knowncontacts
Buteo sync plugin that stores locally created contacts, such as email
recipients.

%post knowncontacts
systemctl-user try-restart msyncd.service || :

%files knowncontacts
%defattr(-,root,root,-)
#out-of-process-plugin form:
%{_libdir}/buteo-plugins-qt5/oopp/knowncontacts-client
#in-process-plugin form:
#/usr/lib/buteo-plugins-qt5/knowncontacts-client.so
%{_sysconfdir}/buteo/profiles/client/knowncontacts.xml
%{_sysconfdir}/buteo/profiles/sync/knowncontacts.Contacts.xml



%package ts-devel
Summary: Translation source for sociald
Group: System/Applications

%description ts-devel
Translation source for sociald
%{summary}.

%files ts-devel
%defattr(-,root,root,-)
Expand All @@ -612,7 +635,7 @@ Requires: qt5-qtdeclarative-devel-tools
Requires: qt5-qtdeclarative-import-qttest

%description tests
Automatable tests for sociald
%{summary}.

%files tests
%defattr(-,root,root,-)
Expand Down
30 changes: 30 additions & 0 deletions src/knowncontacts/README.md
@@ -0,0 +1,30 @@
Knowncontacts Sync Plugin
=========================
This is a sync plugin for Buteo framework. It stores locally created contacts,
such as email recipients that are not to be synced elsewhere and only ever
syncs to the device side.

In this case the "server" means QSettings files containing contacts. On sync
this plugin reads the files and creates local contacts from the information.

Contact file format
-------------------
A contact in QSettings file must have an id as group name and contact
information as key value pairs. There are no requirements for the id but it
must be consistent between syncs to avoid duplicating contact information. All
keys are optional. A file may have as many contacts as needed. The file must
end with file extension `ini` and they are stored in
`~/.local/share/system/privileged/Contacts/knowncontacts`.

```ini
[john.doe.example]
FirstName=John
LastName=Doe
EmailAddress=john@example.com
```

Supported keys:
- FirstName, LastName
- EmailAddress
- Phone, HomePhone, MobilePhone
- Company, Title, Office
15 changes: 15 additions & 0 deletions src/knowncontacts/knowncontacts.Contacts.xml
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<profile name="knowncontacts.Contacts" type="sync" >
<key name="destinationtype" value="online"/>
<key name="displayname" value="KnownContacts"/>
<key name="enabled" value="true" />
<key name="hidden" value="true" />
<key name="use_accounts" value="true" />

<profile name="knowncontacts" type="client" >
<key name="Sync Transport" value="HTTP" />
<key name="Sync Direction" value="two-way" />
<key name="conflictpolicy" value="server-wins" />
</profile>
</profile>
49 changes: 49 additions & 0 deletions src/knowncontacts/knowncontacts.pro
@@ -0,0 +1,49 @@
TARGET = knowncontacts-client

DEFINES += "CLASSNAME=KnownContactsPlugin"
DEFINES += CLASSNAME_H=\\\"knowncontactsplugin.h\\\"
knowncontacts_sync_profile.path = /etc/buteo/profiles/sync
knowncontacts_sync_profile.files = knowncontacts.Contacts.xml
knowncontacts_client_plugin_xml.path = /etc/buteo/profiles/client
knowncontacts_client_plugin_xml.files = knowncontacts.xml

HEADERS += \
knowncontactsplugin.h \
knowncontactssyncer.h

SOURCES += \
knowncontactsplugin.cpp \
knowncontactssyncer.cpp

OTHER_FILES = \
knowncontacts.Contacts.xml
knowncontacts.xml

QT -= gui
QT += dbus

CONFIG += link_pkgconfig c++14
PKGCONFIG += buteosyncfw5 Qt5Contacts qtcontacts-sqlite-qt5-extensions

QMAKE_CXXFLAGS = -Wall \
-g \
-Wno-cast-align \
-O2 -finline-functions

TEMPLATE = app
target.path = /usr/lib/buteo-plugins-qt5/oopp
DEFINES += CLIENT_PLUGIN
INCLUDE_DIR = $$system(pkg-config --cflags buteosyncfw5|cut -f2 -d'I')

HEADERS += $$INCLUDE_DIR/ButeoPluginIfaceAdaptor.h \
$$INCLUDE_DIR/PluginCbImpl.h \
$$INCLUDE_DIR/PluginServiceObj.h

SOURCES += $$INCLUDE_DIR/ButeoPluginIfaceAdaptor.cpp \
$$INCLUDE_DIR/PluginCbImpl.cpp \
$$INCLUDE_DIR/PluginServiceObj.cpp \
$$INCLUDE_DIR/plugin_main.cpp

INSTALLS += target \
knowncontacts_sync_profile \
knowncontacts_client_plugin_xml
7 changes: 7 additions & 0 deletions src/knowncontacts/knowncontacts.xml
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<profile name="knowncontacts" type="client" >
<key name="Sync Transport" value="HTTP" />
<key name="Sync Direction" value="two-way" />
<key name="conflictpolicy" value="server-wins" />
</profile>

0 comments on commit 4653c07

Please sign in to comment.