Commit e702826d authored by mvogt's avatar mvogt

[libcontacts] Initial commit

Extract SeasideCache from nemo-qml-plugin-contacts and export from
this library.
parents
include(package.pri)
include(contacts-namespace.pri)
CONFIG += qt link_pkgconfig
QT -= gui
equals(QT_MAJOR_VERSION, 4) {
CONFIG += mobility
MOBILITY += contacts versit
PKGCONFIG += qtcontacts-sqlite-extensions
}
equals(QT_MAJOR_VERSION, 5) {
PKGCONFIG += Qt5Contacts Qt5Versit qtcontacts-sqlite-qt5-extensions
# Needed for qt4 moc, which can't handle numeric tests
DEFINES *= QT_VERSION_5
}
# We need different macros depending on which Contacts we're using
equals(QT_MAJOR_VERSION, 4) {
DEFINES *= BEGIN_CONTACTS_NAMESPACE=QTM_BEGIN_NAMESPACE
DEFINES *= END_CONTACTS_NAMESPACE=QTM_END_NAMESPACE
DEFINES *= USE_CONTACTS_NAMESPACE=QTM_USE_NAMESPACE
DEFINES *= BEGIN_VERSIT_NAMESPACE=
DEFINES *= END_VERSIT_NAMESPACE=
DEFINES *= USE_VERSIT_NAMESPACE=
}
equals(QT_MAJOR_VERSION, 5) {
DEFINES *= USING_QTPIM
DEFINES *= BEGIN_CONTACTS_NAMESPACE=QT_BEGIN_NAMESPACE_CONTACTS
DEFINES *= END_CONTACTS_NAMESPACE=QT_END_NAMESPACE_CONTACTS
DEFINES *= USE_CONTACTS_NAMESPACE=QTCONTACTS_USE_NAMESPACE
DEFINES *= BEGIN_VERSIT_NAMESPACE=QT_BEGIN_NAMESPACE_VERSIT
DEFINES *= END_VERSIT_NAMESPACE=QT_END_NAMESPACE_VERSIT
DEFINES *= USE_VERSIT_NAMESPACE=QTVERSIT_USE_NAMESPACE
}
TEMPLATE = subdirs
SUBDIRS = src tests
tests.depends = src
equals(QT_MAJOR_VERSION, 4): PACKAGENAME=contactcache
equals(QT_MAJOR_VERSION, 5): PACKAGENAME=contactcache-qt5
Name: libcontacts-qt5
Summary: Nemo contact cache library
Version: 0.0.0
Release: 1
Group: System/Libraries
License: BSD
URL: https://github.com/nemomobile/libcontacts
Source0: %{name}-%{version}.tar.bz2
Requires: qtcontacts-sqlite-qt5
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Test)
BuildRequires: pkgconfig(Qt5Contacts)
BuildRequires: pkgconfig(Qt5Versit)
BuildRequires: pkgconfig(mlite5)
BuildRequires: pkgconfig(qtcontacts-sqlite-qt5-extensions)
%description
%{summary}.
%package tests
Summary: Nemo contact cache library tests
Group: System/Libraries
Requires: %{name} = %{version}-%{release}
%description tests
%{summary}.
%package devel
Summary: Nemo contact cache library headers
Group: System/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
%{summary}.
%prep
%setup -q -n %{name}-%{version}
%build
%qmake5
make %{?jobs:-j%jobs}
%install
rm -rf %{buildroot}
%qmake_install
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root,-)
%{_libdir}/libcontactcache-qt5.so*
%files tests
%defattr(-,root,root,-)
/opt/tests/contactcache-qt5/*
%files devel
%defattr(-,root,root,-)
%{_includedir}/contactcache-qt5/*
%{_libdir}/pkgconfig/contactcache-qt5.pc
Name: libcontacts
Summary: Nemo contact cache library
Version: 0.0.0
Release: 1
Group: System/Libraries
License: BSD
URL: https://github.com/nemomobile/libcontacts
Source0: %{name}-%{version}.tar.bz2
Requires: qtcontacts-sqlite
BuildRequires: pkgconfig(QtCore)
BuildRequires: pkgconfig(QtContacts)
BuildRequires: pkgconfig(QtVersit)
BuildRequires: pkgconfig(mlite)
BuildRequires: pkgconfig(qtcontacts-sqlite-extensions)
%description
%{summary}.
%package tests
Summary: Nemo contact cache library tests
Group: System/Libraries
Requires: %{name} = %{version}-%{release}
%description tests
%{summary}.
%package devel
Summary: Nemo contact cache library headers
Group: System/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
%{summary}.
%prep
%setup -q -n %{name}-%{version}
%build
%qmake
make %{?jobs:-j%jobs}
%install
rm -rf %{buildroot}
%qmake_install
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root,-)
%{_libdir}/libcontactcache.so*
%files tests
%defattr(-,root,root,-)
/opt/tests/contactcache/*
%files devel
%defattr(-,root,root,-)
%{_includedir}/contactcache/*
%{_libdir}/pkgconfig/contactcache.pc
/*
* Copyright (C) 2013 Jolla Mobile <matthew.vogt@jollamobile.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#ifndef CONTACTCACHEEXPORT_H
#define CONTACTCACHEEXPORT_H
#include <QtGlobal>
#ifdef CONTACTCACHE_BUILD
#define CONTACTCACHE_EXPORT Q_DECL_EXPORT
#else
#define CONTACTCACHE_EXPORT Q_DECL_IMPORT
#endif
#endif
/*
* libseaside - Library that provides an interface to the Contacts application
* Copyright (c) 2013, Matt Vogt
*
* This program is licensed under the terms and conditions of the
* Apache License, version 2.0. The full text of the Apache License is at
* http://www.apache.org/licenses/LICENSE-2.0
*
*/
#include "normalization_p.h"
namespace Normalization {
QString normalizePhoneNumber(const QString &input)
{
// Use the same algorithm as maemo localNumber
// Not actually the 'visual-separators' from RFC3966...
// This logic is derived from qtcontacts-tracker
static const QString separators(QString::fromLatin1(" .-()[]"));
static const QString dtmfChars(QString::fromLatin1("pPwWxX"));
// TODO: possibly make this tunable?
static const int maxCharacters = 7;
QString subset;
subset.reserve(input.length());
QString::const_iterator it = input.constBegin(), end = input.constEnd();
for ( ; it != end; ++it) {
if ((*it).isDigit()) {
// Convert to ASCII, capturing unicode digit values
subset.append(QChar::fromLatin1('0' + (*it).digitValue()));
} else if (!separators.contains(*it) &&
(*it).category() != QChar::Other_Format) {
// If this is a DTMF character, stop processing here
if (dtmfChars.contains(*it)) {
break;
} else {
subset.append(*it);
}
}
}
return subset.right(maxCharacters);
}
}
/*
* libseaside - Library that provides an interface to the Contacts application
* Copyright (c) 2013, Matt Vogt
*
* This program is licensed under the terms and conditions of the
* Apache License, version 2.0. The full text of the Apache License is at
* http://www.apache.org/licenses/LICENSE-2.0
*
*/
#ifndef __NORMALIZATION_P_H__
#define __NORMALIZATION_P_H__
#include <QString>
namespace Normalization {
QString normalizePhoneNumber(const QString &input);
}
#endif
This diff is collapsed.
This diff is collapsed.
include(../config.pri)
TEMPLATE = lib
CONFIG += qt hide_symbols
CONFIG += create_pc create_prl no_install_prl
# 'contacts' is too generic for the target name - use 'contactcache'
TARGET = $${PACKAGENAME}
target.path = $$PREFIX/lib
INSTALLS += target
QMAKE_PKGCONFIG_INCDIR = $$PREFIX/include/$${PACKAGENAME}
QMAKE_PKGCONFIG_LIBDIR = $$PREFIX/lib
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
CONFIG += link_pkgconfig
equals(QT_MAJOR_VERSION, 4) {
packagesExist(mlite) {
PKGCONFIG += mlite
DEFINES += HAS_MLITE
} else {
warning("mlite not available. Some functionality may not work as expected.")
}
}
equals(QT_MAJOR_VERSION, 5) {
packagesExist(mlite5) {
PKGCONFIG += mlite5
DEFINES += HAS_MLITE
} else {
warning("mlite not available. Some functionality may not work as expected.")
}
}
DEFINES += CONTACTCACHE_BUILD
SOURCES += \
$$PWD/normalization.cpp \
$$PWD/seasidecache.cpp
HEADERS += \
$$PWD/normalization_p.h \
$$PWD/contactcacheexport.h \
$$PWD/seasidecache.h \
$$PWD/synchronizelists.h
headers.files = \
$$PWD/contactcacheexport.h \
$$PWD/seasidecache.h \
$$PWD/synchronizelists.h
headers.path = $$PREFIX/include/$$TARGET
INSTALLS += headers
This diff is collapsed.
include(../package.pri)
SRCDIR = ../../src/
INCLUDEPATH += $$SRCDIR
DEPENDPATH = $$INCLUDEPATH
QT -= gui
QT += testlib
TEMPLATE = app
CONFIG -= app_bundle
target.path = /opt/tests/$${PACKAGENAME}
INSTALLS += target
include(../package.pri)
TEMPLATE = subdirs
SUBDIRS = tst_synchronizelists
tests_xml.target = tests.xml
tests_xml.depends = $$PWD/tests.xml.in
tests_xml.commands = sed -e "s:@PACKAGENAME@:$${PACKAGENAME}:g" $< > $@
tests_xml.CONFIG += no_check_exist
QMAKE_EXTRA_TARGETS = tests_xml
QMAKE_CLEAN += $$tests_xml.target
PRE_TARGETDEPS += $$tests_xml.target
tests_install.path = /opt/tests/$${PACKAGENAME}
tests_install.files = $$tests_xml.target
tests_install.depends = tests_xml
tests_install.CONFIG += no_check_exist
INSTALLS += tests_install
<?xml version="1.0" encoding="UTF-8"?>
<testdefinition version="1.0">
<suite name="contactcache-tests" domain="mw">
<description>Contact cache automatic tests</description>
<set name="contactcache-test0" feature="Contacts">
<description>Contact cache automatic tests</description>
<case manual="false" name="synchronizelists">
<step>/opt/tests/@PACKAGENAME@/tst_synchronizelists</step>
</case>
</set>
</suite>
</testdefinition>
This diff is collapsed.
include(../common.pri)
TARGET = tst_synchronizelists
SOURCES += tst_synchronizelists.cpp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment