Merge commit 'syncevolution-1-2-2'
Conflicts: Makefile.am configure-post.in configure.ac src/Makefile-gen.am src/dbus/qt/Makefile.am src/syncevo-dbus-server.cpp test/test-dbus.py Conflicts caused by renaming of files on master. Manually applied the relevant changes to the renamed files.
This commit is contained in:
commit
f1bffbc1a4
21
Makefile.am
21
Makefile.am
|
@ -238,19 +238,30 @@ toplevel_so_check:
|
|||
done
|
||||
endif
|
||||
|
||||
# Be strict about running 'syncevolution' only when not doing
|
||||
# cross-compilation: in that case, if running 'syncevolution' fails,
|
||||
# abort the build process. Otherwise proceed with the fallback below,
|
||||
# which is to keep the "see --sync/source-property ?" placeholders in
|
||||
# the README.
|
||||
if COND_CROSS_COMPILING
|
||||
RUN_SYNCEVOLUTION_CHECK=if ($$?) { return ""; } else { return $$buffer; }
|
||||
else
|
||||
RUN_SYNCEVOLUTION_CHECK=die if $$?; return $$buffer;
|
||||
endif
|
||||
|
||||
# patch README.rst properties on-the-fly
|
||||
README.patched.rst: README.rst src/syncevolution
|
||||
$(AM_V_GEN)perl -e '$$syncfound=0; $$sourcefound=0; $$res=0;' \
|
||||
-e 'sub run { $$cmd = shift; $$buffer = `$$cmd`; die if $$?; return $$buffer; }' \
|
||||
-e 'sub run { $$cmd = shift; $$buffer = `env LD_LIBRARY_PATH=src/syncevo/.libs:src/gdbus/.libs:src/gdbusxx/.libs:src/build-synthesis/src/.libs:$$ENV{LD_LIBRARY_PATH} $$cmd`; $(RUN_SYNCEVOLUTION_CHECK) }' \
|
||||
-e 'while (<>) {' \
|
||||
-e 's/^:Version: .*/:Version: $(VERSION)/;' \
|
||||
-e 's/:Date: .*/":Date: " . `date +%Y-%m-%d`/e;' \
|
||||
-e 'if (s;<<insert sync-property>>\n;run("src/syncevolution --daemon=no --sync-property ?");e) { $$syncfound=1; }' \
|
||||
-e 'if (s;<<insert source-property>>\n;run("src/syncevolution --daemon=no --source-property ?");e) { $$sourcefound=1; }' \
|
||||
-e 'if (s;(<< see "syncevolution --sync-property ." >>\n);run("src/syncevolution --daemon=no --sync-property ?") || $$1;e) { $$syncfound=1; }' \
|
||||
-e 'if (s;(<< see "syncevolution --source-property ." >>\n);run("src/syncevolution --daemon=no --source-property ?") || $$1;e) { $$sourcefound=1; }' \
|
||||
-e 'print;' \
|
||||
-e '}' \
|
||||
-e 'die "<<insert sync-property>> not in README.rst?!" unless $$syncfound;' \
|
||||
-e 'die "<<insert source-property>> not in README.rst?!" unless $$sourcefound;' \
|
||||
-e 'die "<<sync-property>> tag not in README.rst?!" unless $$syncfound;' \
|
||||
-e 'die "<<source-property>> tag not in README.rst?!" unless $$sourcefound;' \
|
||||
-e 'exit $$res;' \
|
||||
$< >$@
|
||||
CLEANFILES += README.patched.rst
|
||||
|
|
48
NEWS
48
NEWS
|
@ -1,3 +1,51 @@
|
|||
SyncEvolution 1.2.1 -> 1.2.2, 13.01.2012
|
||||
========================================
|
||||
|
||||
Maintenance release with various bug fixes.
|
||||
|
||||
* syncevo-dbus-server + ConnMan: fixed "online" detection (BMC #21541, BMC #24587)
|
||||
|
||||
SyncEvolution did not recognize any cellular connectivity as
|
||||
suitable for syncing. The strict check for certain "connected
|
||||
technology" is unnecessary, anything which makes the computer
|
||||
"online" should be good enough. So now it just uses the ConnMan
|
||||
"State" property.
|
||||
|
||||
Additional benefit: will continue to work with ConnMan 1.0, which
|
||||
won't have the "ConnectedTechnologies" property anymore.
|
||||
|
||||
The Bluetooth available check was also (incorrectly) using the
|
||||
ConnMan API. Now asssume that OBEX/Bluetooth is always available.
|
||||
|
||||
* automatic backups: added INFO messages and fixed dumpData/printChanges (BMC #24619)
|
||||
|
||||
Point out that backups are created (user might be unaware otherwise
|
||||
and wonder about the delay), explain why (so that users know how to
|
||||
turn it off).
|
||||
|
||||
Turning these backups off with dumpData=0 printChanges=0 had to be
|
||||
fixed, backups were always written previously.
|
||||
|
||||
* EDS compatibility: bumped version check for EDS 3.2
|
||||
|
||||
SyncEvolution is known to work with EDS 3.2. Therefore use the
|
||||
libebook/ecal/edataserver libs from 3.2 if available, without
|
||||
warnings in the --version output. Also happens with inconsistent
|
||||
distro setups where the old libs are available and would have been
|
||||
prefered by SyncEvolution 1.2.1 even though the old libs no longer
|
||||
work with EDS 3.2.
|
||||
|
||||
* GTK-UI: do not accept service config without a username (BMC#23106)
|
||||
|
||||
Instead of creating such a config, an error dialog is shown.
|
||||
|
||||
* GTK-UI: updated translations
|
||||
|
||||
* fixed various compile issues, primarily on Fedora Core 17
|
||||
(unistd.h/ssize_t, invoking syncevolution during compilation,
|
||||
missing src/dbus/qt/configure-sub.in)
|
||||
|
||||
|
||||
SyncEvolution 1.2 -> 1.2.1, 25.11.2011
|
||||
======================================
|
||||
|
||||
|
|
|
@ -686,11 +686,11 @@ defined, which is marked with the word `required`.
|
|||
|
||||
Sync properties
|
||||
---------------
|
||||
<<insert sync-property>>
|
||||
<< see "syncevolution --sync-property ?" >>
|
||||
|
||||
Source properties
|
||||
-----------------
|
||||
<<insert source-property>>
|
||||
<< see "syncevolution --source-property ?" >>
|
||||
|
||||
|
||||
EXAMPLES
|
||||
|
|
|
@ -8,7 +8,7 @@ dnl Invoke autogen.sh to produce a configure script.
|
|||
#
|
||||
# Starting with the 1.1 release cycle, the rpm-style
|
||||
# .99 pseudo-version number is used to mark a pre-release.
|
||||
AC_INIT([syncevolution], [m4_esyscmd([build/gen-git-version.sh 1.2.1])])
|
||||
AC_INIT([syncevolution], [m4_esyscmd([build/gen-git-version.sh 1.2.2])])
|
||||
# STABLE_VERSION=1.0.1+
|
||||
AC_SUBST(STABLE_VERSION)
|
||||
|
||||
|
@ -1070,6 +1070,9 @@ SYNCEVOLUTION_LIBS=`pwd`/src/syncevo/libsyncevolution.la
|
|||
AC_SUBST(SYNCEVOLUTION_CFLAGS)
|
||||
AC_SUBST(SYNCEVOLUTION_LIBS)
|
||||
|
||||
# invoking syncevolution binary is allowed to fail when cross-compiling
|
||||
AM_CONDITIONAL([COND_CROSS_COMPILING], [test "$cross_compiling" = "yes"])
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
src/syncevo/syncevolution.pc
|
||||
|
|
|
@ -34,7 +34,7 @@ ConnmanClient::ConnmanClient(Server &server):
|
|||
m_propertyChanged(*this, "PropertyChanged")
|
||||
{
|
||||
if (getConnection()) {
|
||||
typedef std::map <std::string, boost::variant <std::vector <std::string> > > PropDict;
|
||||
typedef std::map <std::string, boost::variant<std::string> > PropDict;
|
||||
GDBusCXX::DBusClientCall1<PropDict> getProp(*this,"GetProperties");
|
||||
getProp (boost::bind(&ConnmanClient::getPropCb, this, _1, _2));
|
||||
m_propertyChanged.activate(boost::bind(&ConnmanClient::propertyChanged, this, _1, _2));
|
||||
|
@ -44,12 +44,12 @@ ConnmanClient::ConnmanClient(Server &server):
|
|||
}
|
||||
|
||||
void ConnmanClient::getPropCb (const std::map <std::string,
|
||||
boost::variant <std::vector <std::string> > >& props, const string &error){
|
||||
boost::variant<std::string> >& props, const string &error){
|
||||
if (!error.empty()) {
|
||||
if (error == "org.freedesktop.DBus.Error.ServiceUnknown") {
|
||||
// ensure there is still first set of singal set in case of no
|
||||
// connman available
|
||||
m_server.getPresenceStatus().updatePresenceStatus (true, true);
|
||||
m_server.getPresenceStatus().updatePresenceStatus (true, PresenceStatus::HTTP_TRANSPORT);
|
||||
SE_LOG_DEBUG (NULL, NULL, "No connman service available %s", error.c_str());
|
||||
return;
|
||||
}
|
||||
|
@ -57,65 +57,28 @@ void ConnmanClient::getPropCb (const std::map <std::string,
|
|||
return;
|
||||
}
|
||||
|
||||
typedef std::pair <std::string, boost::variant <std::vector <std::string> > > element;
|
||||
bool httpPresence = false, btPresence = false;
|
||||
typedef std::pair <std::string, boost::variant<std::string> > element;
|
||||
bool httpPresence = false;
|
||||
BOOST_FOREACH (element entry, props) {
|
||||
//match connected for HTTP based peers (wifi/wimax/ethernet)
|
||||
if (entry.first == "ConnectedTechnologies") {
|
||||
std::vector <std::string> connected = boost::get <std::vector <std::string> > (entry.second);
|
||||
BOOST_FOREACH (std::string tech, connected) {
|
||||
if (boost::iequals (tech, "wifi") || boost::iequals (tech, "ethernet")
|
||||
|| boost::iequals (tech, "wimax")) {
|
||||
httpPresence = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (entry.first == "AvailableTechnologies") {
|
||||
std::vector <std::string> enabled = boost::get <std::vector <std::string> > (entry.second);
|
||||
BOOST_FOREACH (std::string tech, enabled){
|
||||
if (boost::iequals (tech, "bluetooth")) {
|
||||
btPresence = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
// just check online state, we don't care how about the underlying technology
|
||||
if (entry.first == "State") {
|
||||
std::string state = boost::get<std::string>(entry.second);
|
||||
httpPresence = state == "online";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//now delivering the signals
|
||||
m_server.getPresenceStatus().updatePresenceStatus (httpPresence, btPresence);
|
||||
m_server.getPresenceStatus().updatePresenceStatus (httpPresence, PresenceStatus::HTTP_TRANSPORT);
|
||||
}
|
||||
|
||||
void ConnmanClient::propertyChanged(const std::string &name,
|
||||
const boost::variant<std::vector<std::string>, std::string> &prop)
|
||||
{
|
||||
bool httpPresence=false, btPresence=false;
|
||||
bool httpChanged=false, btChanged=false;
|
||||
if (boost::iequals(name, "ConnectedTechnologies")) {
|
||||
httpChanged=true;
|
||||
std::vector<std::string> connected = boost::get<vector<std::string> >(prop);
|
||||
BOOST_FOREACH (std::string tech, connected) {
|
||||
if (boost::iequals (tech, "wifi") || boost::iequals (tech, "ethernet")
|
||||
|| boost::iequals (tech, "wimax")) {
|
||||
httpPresence=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (boost::iequals (name, "AvailableTechnologies")){
|
||||
btChanged=true;
|
||||
std::vector<std::string> enabled = boost::get<std::vector<std::string> >(prop);
|
||||
BOOST_FOREACH (std::string tech, enabled){
|
||||
if (boost::iequals (tech, "bluetooth")) {
|
||||
btPresence = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(httpChanged) {
|
||||
m_server.getPresenceStatus().updatePresenceStatus (httpPresence, PresenceStatus::HTTP_TRANSPORT);
|
||||
} else if (btChanged) {
|
||||
m_server.getPresenceStatus().updatePresenceStatus (btPresence, PresenceStatus::BT_TRANSPORT);
|
||||
} else {
|
||||
if (name == "State") {
|
||||
std::string state = boost::get<std::string>(prop);
|
||||
m_server.getPresenceStatus().updatePresenceStatus(state == "online",
|
||||
PresenceStatus::HTTP_TRANSPORT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
void propertyChanged(const std::string &name,
|
||||
const boost::variant<std::vector<std::string>, std::string> &prop);
|
||||
|
||||
void getPropCb(const std::map <std::string, boost::variant <std::vector <std::string> > >& props, const std::string &error);
|
||||
void getPropCb(const std::map <std::string, boost::variant<std::string> >& props, const std::string &error);
|
||||
|
||||
/** TRUE if watching ConnMan status */
|
||||
bool isAvailable() { return getConnection() != NULL; }
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
private:
|
||||
Server &m_server;
|
||||
|
||||
GDBusCXX::SignalWatch2 <std::string, boost::variant<std::vector<std::string>, std::string> > m_propertyChanged;
|
||||
GDBusCXX::SignalWatch2 <std::string, boost::variant<std::string> > m_propertyChanged;
|
||||
};
|
||||
|
||||
SE_END_CXX
|
||||
|
|
|
@ -89,13 +89,15 @@ class PresenceStatus {
|
|||
|
||||
void updateConfigPeers (const std::string &peer, const ReadOperations::Config_t &config);
|
||||
|
||||
void updatePresenceStatus (bool httpPresence, bool btPresence);
|
||||
void updatePresenceStatus (bool newStatus, TransportType type);
|
||||
|
||||
bool getHttpPresence() { return m_httpPresence; }
|
||||
bool getBtPresence() { return m_btPresence; }
|
||||
Timer& getHttpTimer() { return m_httpTimer; }
|
||||
Timer& getBtTimer() { return m_btTimer; }
|
||||
|
||||
private:
|
||||
void updatePresenceStatus (bool httpPresence, bool btPresence);
|
||||
};
|
||||
|
||||
SE_END_CXX
|
||||
|
|
|
@ -269,10 +269,15 @@ Server::Server(GMainLoop *loop,
|
|||
LoggerBase::pushLogger(this);
|
||||
setLevel(LoggerBase::DEBUG);
|
||||
|
||||
// Assume that Bluetooth is available. Neither ConnMan nor Network
|
||||
// manager can tell us about that. The "Bluetooth" ConnMan technology
|
||||
// is about IP connection via Bluetooth - not what we need.
|
||||
getPresenceStatus().updatePresenceStatus(true, PresenceStatus::BT_TRANSPORT);
|
||||
|
||||
if (!m_connman.isAvailable() &&
|
||||
!m_networkManager.isAvailable()) {
|
||||
// assume that we are online if no network manager was found at all
|
||||
getPresenceStatus().updatePresenceStatus(true, true);
|
||||
getPresenceStatus().updatePresenceStatus(true, PresenceStatus::HTTP_TRANSPORT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ src_dist_hook:
|
|||
mkdir -p $(distdir)/src/synthesis && \
|
||||
if test -d '$(SYNTHESIS_SRC)/.git'; \
|
||||
then \
|
||||
( ( cd '$(SYNTHESIS_SRC)' && git archive HEAD ) | ( cd '$(distdir)/src/synthesis' && tar xf - && $$SHELL autogen.sh && rm -rf autom4te.cache ) ) && \
|
||||
( ( cd '$(SYNTHESIS_SRC)' && git archive HEAD ) | ( cd '$(distdir)/src/synthesis' && tar xf - && $$SHELL autogen.sh && rm -rf autom4te.cache && find . -name .gitignore -delete ) ) && \
|
||||
( printf '%s' 'Creating ChangeLog...' && \
|
||||
( ( cd '$(SYNTHESIS_SRC)' && \
|
||||
echo '# Generated by configure. Do not edit.' && \
|
||||
|
@ -156,7 +156,7 @@ src_dist_hook:
|
|||
then \
|
||||
cp -a '$(SYNTHESIS_SRC)/'* '$(distdir)/src/synthesis' && \
|
||||
for i in _build autom4te.cache; do [ ! -d "$(SYNTHESIS_SRC)/$$i" ] || chmod -R u+rwx "$(SYNTHESIS_SRC)/$$i"; done && \
|
||||
find '$(distdir)/src/synthesis' -name '.libs' -o -name '*~' -o -name '.*' -o -name '*.o' -o -name '*.lo' -o -name 'CVS' -o -name '.svn' -o -name '.git' -o -name 'autom4te.cache' -print0 | xargs -0 rm -rf; \
|
||||
find '$(distdir)/src/synthesis' -name '.libs' -o -name '*~' -o -name '.*' -o -name '*.o' -o -name '*.lo' -o -name 'CVS' -o -name '.svn' -o -name '.git' -o -name .gitignore -o -name 'autom4te.cache' -print0 | xargs -0 rm -rf; \
|
||||
fi
|
||||
|
||||
clean-local: testclean
|
||||
|
|
|
@ -1289,10 +1289,16 @@ public:
|
|||
// @param excludeSource when non-empty, limit preparation to that source
|
||||
void syncPrepare(const string &excludeSource = "") {
|
||||
if (m_logdir.getLogfile().size() &&
|
||||
(m_client.getDumpData() || m_doLogging)) {
|
||||
m_doLogging &&
|
||||
(m_client.getDumpData() || m_client.getPrintChanges())) {
|
||||
// dump initial databases
|
||||
SE_LOG_INFO(NULL, NULL, "creating complete data backup before sync (%s)",
|
||||
(m_client.getDumpData() && m_client.getPrintChanges()) ? "enabled with dumpData and needed for printChanges" :
|
||||
m_client.getDumpData() ? "because it was enabled with dumpData" :
|
||||
m_client.getPrintChanges() ? "needed for printChanges" :
|
||||
"???");
|
||||
dumpDatabases("before", &SyncSourceReport::m_backupBefore, excludeSource);
|
||||
if (m_doLogging) {
|
||||
if (m_client.getPrintChanges()) {
|
||||
// compare against the old "after" database dump
|
||||
dumpLocalChanges("", "after", "before", excludeSource,
|
||||
StringPrintf("%s data changes to be applied during synchronization:\n",
|
||||
|
@ -1313,9 +1319,15 @@ public:
|
|||
// dump database after sync if explicitly enabled or
|
||||
// needed for comparison;
|
||||
// in the latter case only if dumping it at the beginning completed
|
||||
if (m_client.getDumpData() ||
|
||||
(m_doLogging && m_reportTodo && !m_prepared.empty())) {
|
||||
if (m_doLogging &&
|
||||
(m_client.getDumpData() ||
|
||||
(m_client.getPrintChanges() && m_reportTodo && !m_prepared.empty()))) {
|
||||
try {
|
||||
SE_LOG_INFO(NULL, NULL, "creating complete data backup after sync (%s)",
|
||||
(m_client.getDumpData() && m_client.getPrintChanges()) ? "enabled with dumpData and needed for printChanges" :
|
||||
m_client.getDumpData() ? "because it was enabled with dumpData" :
|
||||
m_client.getPrintChanges() ? "needed for printChanges" :
|
||||
"???");
|
||||
dumpDatabases("after", &SyncSourceReport::m_backupAfter);
|
||||
} catch (...) {
|
||||
Exception::handle();
|
||||
|
@ -1366,11 +1378,15 @@ public:
|
|||
}
|
||||
|
||||
// compare databases?
|
||||
dumpLocalChanges(m_logdir.getLogdir(),
|
||||
"before", "after", "",
|
||||
StringPrintf("\nData modified %s during synchronization:\n",
|
||||
m_client.isLocalSync() ? m_client.getContextName().c_str() : "locally"),
|
||||
"CLIENT_TEST_LEFT_NAME='before sync' CLIENT_TEST_RIGHT_NAME='after sync' CLIENT_TEST_REMOVED='removed during sync' CLIENT_TEST_ADDED='added during sync'");
|
||||
if (m_client.getPrintChanges()) {
|
||||
dumpLocalChanges(m_logdir.getLogdir(),
|
||||
"before", "after", "",
|
||||
StringPrintf("\nData modified %s during synchronization:\n",
|
||||
m_client.isLocalSync() ? m_client.getContextName().c_str() : "locally"),
|
||||
"CLIENT_TEST_LEFT_NAME='before sync' CLIENT_TEST_RIGHT_NAME='after sync' CLIENT_TEST_REMOVED='removed during sync' CLIENT_TEST_ADDED='added during sync'");
|
||||
}
|
||||
|
||||
// now remove some old logdirs
|
||||
m_logdir.expire();
|
||||
}
|
||||
}
|
||||
|
@ -3828,14 +3844,14 @@ void SyncContext::status()
|
|||
bool found = access(prevLogdir.c_str(), R_OK|X_OK) == 0;
|
||||
|
||||
if (found) {
|
||||
try {
|
||||
sourceList.setPath(prevLogdir);
|
||||
if (getPrintChanges() || getDumpData()) {
|
||||
if (!m_quiet && getPrintChanges()) {
|
||||
try {
|
||||
sourceList.setPath(prevLogdir);
|
||||
sourceList.dumpDatabases("current", NULL);
|
||||
sourceList.dumpLocalChanges("", "after", "current", "");
|
||||
} catch(...) {
|
||||
Exception::handle();
|
||||
}
|
||||
} catch(...) {
|
||||
Exception::handle();
|
||||
}
|
||||
} else {
|
||||
ostream &out = getOutput();
|
||||
|
@ -3960,10 +3976,8 @@ void SyncContext::restore(const string &dirname, RestoreDatabase database)
|
|||
source->open();
|
||||
}
|
||||
|
||||
if (!m_quiet || getDumpData()) {
|
||||
if (!m_quiet && getPrintChanges()) {
|
||||
sourceList.dumpDatabases("current", NULL);
|
||||
}
|
||||
if (!m_quiet) {
|
||||
sourceList.dumpLocalChanges(dirname, "current", datadump, "",
|
||||
"Data changes to be applied locally during restore:\n",
|
||||
"CLIENT_TEST_LEFT_NAME='current data' "
|
||||
|
|
|
@ -198,7 +198,7 @@ extern "C" void EDSAbiWrapperInit()
|
|||
|
||||
# ifdef ENABLE_EBOOK
|
||||
ebookhandle =
|
||||
findSymbols("libebook-1.2.so", 5, 10,
|
||||
findSymbols("libebook-1.2.so", 5, 12,
|
||||
FIND_SYMBOLS_NEED_ALL|FIND_SYMBOLS_LENIENT_MAX_VERSION, NULL,
|
||||
&EDSAbiWrapperSingleton.e_book_add_contact, "e_book_add_contact",
|
||||
&EDSAbiWrapperSingleton.e_book_authenticate_user, "e_book_authenticate_user",
|
||||
|
@ -232,7 +232,7 @@ extern "C" void EDSAbiWrapperInit()
|
|||
|
||||
# ifdef ENABLE_ECAL
|
||||
static const int libecalMinVersion = 3,
|
||||
libecalMaxVersion = 8;
|
||||
libecalMaxVersion = 10;
|
||||
ecalhandle =
|
||||
findSymbols("libecal-1.2.so", libecalMinVersion, libecalMaxVersion,
|
||||
FIND_SYMBOLS_NEED_ALL|FIND_SYMBOLS_LENIENT_MAX_VERSION, NULL,
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#include <list>
|
||||
#include <ostream>
|
||||
|
||||
// for size_t and ssize_t
|
||||
#include <unistd.h>
|
||||
|
||||
#include <syncevo/declarations.h>
|
||||
SE_BEGIN_CXX
|
||||
namespace LCS {
|
||||
|
|
|
@ -1056,167 +1056,158 @@ class TestNamedConfig(unittest.TestCase, DBusUtil):
|
|||
|
||||
|
||||
class Connman (dbus.service.Object):
|
||||
count = 0
|
||||
state = "online"
|
||||
getPropertiesCalled = False
|
||||
waitingForGetProperties = False
|
||||
|
||||
@dbus.service.method(dbus_interface='net.connman.Manager', in_signature='', out_signature='a{sv}')
|
||||
def GetProperties(self):
|
||||
self.count = self.count+1
|
||||
if (self.count == 1):
|
||||
# notify TestDBusServerPresence.setUp()?
|
||||
if self.waitingForGetProperties:
|
||||
loop.quit()
|
||||
return {"ConnectedTechnologies":["ethernet", "some other stuff"],
|
||||
"AvailableTechnologies": ["bluetooth"]}
|
||||
elif (self.count == 2):
|
||||
""" unplug the ethernet cable """
|
||||
loop.quit()
|
||||
return {"ConnectedTechnologies":["some other stuff"],
|
||||
"AvailableTechnologies": ["bluetooth"]}
|
||||
elif (self.count == 3):
|
||||
""" replug the ethernet cable """
|
||||
loop.quit()
|
||||
return {"ConnectedTechnologies":["ethernet", "some other stuff"],
|
||||
"AvailableTechnologies": ["bluetooth"]}
|
||||
elif (self.count == 4):
|
||||
""" nothing presence """
|
||||
loop.quit()
|
||||
return {"ConnectedTechnologies":[""],
|
||||
"AvailableTechnologies": [""]}
|
||||
elif (self.count == 5):
|
||||
""" come back the same time """
|
||||
loop.quit()
|
||||
return {"ConnectedTechnologies":["ethernet", "some other stuff"],
|
||||
"AvailableTechnologies": ["bluetooth"]}
|
||||
else:
|
||||
return {}
|
||||
self.getPropertiesCalled = True
|
||||
return { "State" : self.state }
|
||||
|
||||
@dbus.service.signal(dbus_interface='net.connman.Manager', signature='sv')
|
||||
def PropertyChanged(self, key, value):
|
||||
pass
|
||||
|
||||
def emitSignal(self):
|
||||
self.count = self.count+1
|
||||
if (self.count == 2):
|
||||
""" unplug the ethernet cable """
|
||||
self.PropertyChanged("ConnectedTechnologies",["some other stuff"])
|
||||
return
|
||||
elif (self.count == 3):
|
||||
""" replug the ethernet cable """
|
||||
self.PropertyChanged("ConnectedTechnologies", ["ethernet", "some other stuff"])
|
||||
return
|
||||
elif (self.count == 4):
|
||||
""" nothing presence """
|
||||
self.PropertyChanged("ConnectedTechnologies", [""])
|
||||
self.PropertyChanged("AvailableTechnologies", [""])
|
||||
return
|
||||
elif (self.count == 5):
|
||||
""" come back the same time """
|
||||
self.PropertyChanged("ConnectedTechnologies", ["ethernet", "some other stuff"])
|
||||
self.PropertyChanged("AvailableTechnologies", ["bluetooth"])
|
||||
return
|
||||
def setState(self, state):
|
||||
if self.state != state:
|
||||
self.state = state
|
||||
self.PropertyChanged("State", state)
|
||||
# race condition: it happened that method calls
|
||||
# reached syncevo-dbus-server before the state change,
|
||||
# thus breaking the test
|
||||
time.sleep(1)
|
||||
|
||||
def reset(self):
|
||||
self.count = 0
|
||||
self.state = "online"
|
||||
self.getPropertiesCalled = False
|
||||
self.waitingForGetProperties = False
|
||||
|
||||
class TestDBusServerPresence(unittest.TestCase, DBusUtil):
|
||||
"""Tests Presence signal and checkPresence API"""
|
||||
|
||||
# Our fake ConnMan implementation must be present on the
|
||||
# bus also outside of tests, because syncevo-dbus-server
|
||||
# will try to call it before setUp(). The implementation's
|
||||
# initialization and tearDown() below ensures that the state
|
||||
# is "online" outside of tests.
|
||||
name = dbus.service.BusName ("net.connman", bus);
|
||||
conn = Connman (bus, "/")
|
||||
|
||||
def setUp(self):
|
||||
self.conn = Connman (bus, "/")
|
||||
self.setUpServer()
|
||||
self.cbFailure = None
|
||||
# we don't know if the GetProperties() call was already
|
||||
# processed; if not, wait for it here
|
||||
if not self.conn.getPropertiesCalled:
|
||||
self.conn.waitingForGetProperties = True
|
||||
loop.run()
|
||||
|
||||
def tearDown(self):
|
||||
self.conn.remove_from_connection()
|
||||
self.conn.reset()
|
||||
self.conf = None
|
||||
|
||||
def presenceCB(self,
|
||||
server, status, transport,
|
||||
expected):
|
||||
try:
|
||||
state = expected.pop(server, None)
|
||||
if not state:
|
||||
self.fail("unexpected presence signal for config " + server)
|
||||
self.failUnlessEqual(status, state[0])
|
||||
if not status:
|
||||
self.failUnlessEqual(transport, state[1])
|
||||
except Exception, ex:
|
||||
# tell test method about the problem
|
||||
loop.quit()
|
||||
self.cbFailure = ex
|
||||
# log exception
|
||||
raise ex
|
||||
|
||||
if not expected:
|
||||
# got all expected signals
|
||||
loop.quit()
|
||||
|
||||
def expect(self, expected):
|
||||
'''expected: hash from server config name to state+transport'''
|
||||
match = bus.add_signal_receiver(lambda x,y,z:
|
||||
self.presenceCB(x,y,z, expected), \
|
||||
'Presence',
|
||||
'org.syncevolution.Server',
|
||||
self.server.bus_name,
|
||||
None,
|
||||
byte_arrays=True,
|
||||
utf8_strings=True)
|
||||
return match
|
||||
|
||||
@property("ENV", "DBUS_TEST_CONNMAN=session")
|
||||
@timeout(100)
|
||||
def testPresenceSignal(self):
|
||||
"""TestDBusServerPresence.testPresenceSignal - check Server.Presence signal"""
|
||||
self.conn.reset()
|
||||
self.setUpSession("foo")
|
||||
self.session.SetConfig(False, False, {"" : {"syncURL":
|
||||
"http://http-only-1"}})
|
||||
self.session.Detach()
|
||||
def cb_http_presence(server, status, transport):
|
||||
try:
|
||||
self.assertEqual (status, "")
|
||||
self.assertEqual (server, "foo")
|
||||
self.assertEqual (transport, "http://http-only-1")
|
||||
finally:
|
||||
loop.quit()
|
||||
|
||||
match = bus.add_signal_receiver(cb_http_presence,
|
||||
'Presence',
|
||||
'org.syncevolution.Server',
|
||||
self.server.bus_name,
|
||||
None,
|
||||
byte_arrays=True,
|
||||
utf8_strings=True)
|
||||
# this loop is quit by connman GetProperties
|
||||
# creating a config does not trigger a Presence signal
|
||||
self.setUpSession("foo")
|
||||
self.session.SetConfig(False, False, {"" : {"syncURL": "http://http-only-1"}})
|
||||
self.session.Detach()
|
||||
|
||||
# go offline
|
||||
match = self.expect({"foo" : ("no transport", "")})
|
||||
self.conn.setState("idle")
|
||||
loop.run()
|
||||
# this loop is quit by cb_http_presence
|
||||
loop.run()
|
||||
time.sleep(1)
|
||||
self.failIf(self.cbFailure)
|
||||
match.remove()
|
||||
|
||||
# Changing the properties temporarily does change
|
||||
# the presence of the config although strictly speaking,
|
||||
# the presence of the config on disk hasn't changed.
|
||||
# Not sure whether we really want that behavior.
|
||||
match = self.expect({"foo" : ("", "obex-bt://temp-bluetooth-peer-changed-from-http")})
|
||||
self.setUpSession("foo")
|
||||
self.session.SetConfig(True, False, {"" : {"syncURL":
|
||||
"obex-bt://temp-bluetooth-peer-changed-from-http"}})
|
||||
def cb_bt_presence(server, status, transport):
|
||||
self.assertEqual (status, "")
|
||||
self.assertEqual (server, "foo")
|
||||
self.assertEqual (transport,
|
||||
"obex-bt://temp-bluetooth-peer-changed-from-http")
|
||||
loop.quit()
|
||||
match.remove()
|
||||
match = bus.add_signal_receiver(cb_bt_presence,
|
||||
'Presence',
|
||||
'org.syncevolution.Server',
|
||||
self.server.bus_name,
|
||||
None,
|
||||
byte_arrays=True,
|
||||
utf8_strings=True)
|
||||
self.conn.emitSignal()
|
||||
# A ConnMan state change is needed to trigger the presence signal.
|
||||
# Definitely not the behavior that we want :-/
|
||||
self.conn.setState("failure")
|
||||
loop.run()
|
||||
time.sleep(1)
|
||||
self.failIf(self.cbFailure)
|
||||
match.remove()
|
||||
# remove temporary config change, back to using HTTP
|
||||
# BUG BMC #24648 in syncevo-dbus-server: after discarding the temporary
|
||||
# config change it keeps using the obex-bt syncURL.
|
||||
# Work around that bug in thus test here temporarily
|
||||
# by explicitly restoring the previous URL.
|
||||
self.session.SetConfig(True, False, {"" : {"syncURL": "http://http-only-1"}})
|
||||
self.session.Detach()
|
||||
|
||||
# create second session
|
||||
self.setUpSession("bar")
|
||||
self.session.SetConfig(False, False, {"" : {"syncURL":
|
||||
"http://http-client-2"}})
|
||||
self.session.Detach()
|
||||
self.foo = "random string"
|
||||
self.bar = "random string"
|
||||
match.remove()
|
||||
self.conn.emitSignal()
|
||||
self.conn.emitSignal()
|
||||
def cb_bt_http_presence(server, status, transport):
|
||||
if (server == "foo"):
|
||||
self.foo = status
|
||||
elif (server == "bar"):
|
||||
self.bar = status
|
||||
else:
|
||||
self.fail("wrong server config")
|
||||
loop.quit()
|
||||
|
||||
match = bus.add_signal_receiver(cb_bt_http_presence,
|
||||
'Presence',
|
||||
'org.syncevolution.Server',
|
||||
self.server.bus_name,
|
||||
None,
|
||||
byte_arrays=True,
|
||||
utf8_strings=True)
|
||||
#count=5, 2 signals recevied
|
||||
self.conn.emitSignal()
|
||||
# go back to online mode
|
||||
match = self.expect({"foo" : ("", "http://http-only-1"),
|
||||
"bar" : ("", "http://http-client-2")})
|
||||
self.conn.setState("online")
|
||||
loop.run()
|
||||
self.failIf(self.cbFailure)
|
||||
match.remove()
|
||||
|
||||
# and offline
|
||||
match = self.expect({"foo" : ("no transport", ""),
|
||||
"bar" : ("no transport", "")})
|
||||
self.conn.setState("idle")
|
||||
loop.run()
|
||||
time.sleep(1)
|
||||
self.assertEqual (self.foo, "")
|
||||
self.assertEqual (self.bar, "")
|
||||
self.failIf(self.cbFailure)
|
||||
match.remove()
|
||||
|
||||
@property("ENV", "DBUS_TEST_CONNMAN=session")
|
||||
@timeout(100)
|
||||
def testServerCheckPresence(self):
|
||||
"""TestDBusServerPresence.testServerCheckPresence - check Server.CheckPresence()"""
|
||||
self.conn.reset()
|
||||
self.setUpSession("foo")
|
||||
self.session.SetConfig(False, False, {"" : {"syncURL":
|
||||
"http://http-client"}})
|
||||
|
@ -1230,9 +1221,7 @@ class TestDBusServerPresence(unittest.TestCase, DBusUtil):
|
|||
"obex-bt://bt-client-mixed http://http-client-mixed"}})
|
||||
self.session.Detach()
|
||||
|
||||
#let dbus server get the first presence
|
||||
loop.run()
|
||||
time.sleep(1)
|
||||
# online initially
|
||||
(status, transports) = self.server.CheckPresence ("foo")
|
||||
self.assertEqual (status, "")
|
||||
self.assertEqual (transports, ["http://http-client"])
|
||||
|
@ -1244,9 +1233,17 @@ class TestDBusServerPresence(unittest.TestCase, DBusUtil):
|
|||
self.assertEqual (transports, ["obex-bt://bt-client-mixed",
|
||||
"http://http-client-mixed"])
|
||||
|
||||
#count = 2
|
||||
self.conn.emitSignal()
|
||||
time.sleep(1)
|
||||
# go offline; Bluetooth remains on
|
||||
self.conn.setState("idle")
|
||||
# wait until server has seen the state change
|
||||
match = bus.add_signal_receiver(lambda x,y,z: loop.quit(),
|
||||
'Presence',
|
||||
'org.syncevolution.Server',
|
||||
self.server.bus_name,
|
||||
None,
|
||||
byte_arrays=True,
|
||||
utf8_strings=True)
|
||||
match.remove()
|
||||
(status, transports) = self.server.CheckPresence ("foo")
|
||||
self.assertEqual (status, "no transport")
|
||||
(status, transports) = self.server.CheckPresence ("bar")
|
||||
|
@ -1260,22 +1257,67 @@ class TestDBusServerPresence(unittest.TestCase, DBusUtil):
|
|||
@timeout(100)
|
||||
def testSessionCheckPresence(self):
|
||||
"""TestDBusServerPresence.testSessionCheckPresence - check Session.CheckPresence()"""
|
||||
self.conn.reset()
|
||||
self.setUpSession("foobar")
|
||||
self.session.SetConfig(False, False, {"" : {"syncURL":
|
||||
"obex-bt://bt-client-mixed http://http-client-mixed"}})
|
||||
loop.run()
|
||||
time.sleep(1)
|
||||
status = self.session.checkPresence()
|
||||
self.assertEqual (status, "")
|
||||
self.conn.emitSignal()
|
||||
self.conn.emitSignal()
|
||||
self.conn.emitSignal()
|
||||
#count = 4
|
||||
time.sleep(1)
|
||||
self.failUnlessEqual (status, "")
|
||||
|
||||
# go offline; Bluetooth remains on
|
||||
self.conn.setState("idle")
|
||||
# wait until server has seen the state change
|
||||
match = bus.add_signal_receiver(lambda x,y,z: loop.quit(),
|
||||
'Presence',
|
||||
'org.syncevolution.Server',
|
||||
self.server.bus_name,
|
||||
None,
|
||||
byte_arrays=True,
|
||||
utf8_strings=True)
|
||||
match.remove()
|
||||
|
||||
# config uses Bluetooth, so syncing still possible
|
||||
status = self.session.checkPresence()
|
||||
self.failUnlessEqual (status, "")
|
||||
|
||||
# now the same without Bluetooth, while offline
|
||||
self.session.Detach()
|
||||
self.setUpSession("foo")
|
||||
self.session.SetConfig(False, False, {"" : {"syncURL": "http://http-only"}})
|
||||
status = self.session.checkPresence()
|
||||
self.assertEqual (status, "no transport")
|
||||
|
||||
# go online
|
||||
self.conn.setState("online")
|
||||
# wait until server has seen the state change
|
||||
match = bus.add_signal_receiver(lambda x,y,z: loop.quit(),
|
||||
'Presence',
|
||||
'org.syncevolution.Server',
|
||||
self.server.bus_name,
|
||||
None,
|
||||
byte_arrays=True,
|
||||
utf8_strings=True)
|
||||
match.remove()
|
||||
status = self.session.checkPresence()
|
||||
self.failUnlessEqual (status, "")
|
||||
|
||||
# temporary config change shall always affect the
|
||||
# Session.CheckPresence() result: go offline,
|
||||
# then switch to Bluetooth (still present)
|
||||
self.conn.setState("idle")
|
||||
match = bus.add_signal_receiver(lambda x,y,z: loop.quit(),
|
||||
'Presence',
|
||||
'org.syncevolution.Server',
|
||||
self.server.bus_name,
|
||||
None,
|
||||
byte_arrays=True,
|
||||
utf8_strings=True)
|
||||
match.remove()
|
||||
status = self.session.checkPresence()
|
||||
self.failUnlessEqual (status, "no transport")
|
||||
self.session.SetConfig(True, False, {"" : {"syncURL": "obex-bt://bt-client-mixed"}})
|
||||
status = self.session.checkPresence()
|
||||
self.failUnlessEqual (status, "")
|
||||
|
||||
def run(self, result):
|
||||
self.runTest(result, True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue