Kaydet (Commit) a3a8b803 authored tarafından Eike Rathke's avatar Eike Rathke Kaydeden (comit) Matúš Kukan

implementing Telepathy Tubes interface

üst e80a6eb1
......@@ -361,6 +361,7 @@ $(eval $(call gb_Helper_register_libraries,OOOLIBS, \
textfd \
tk \
tl \
tubes \
unordf \
unoxml \
updatecheckui \
......
......@@ -1086,6 +1086,34 @@ $(call gb_LinkTarget_add_libs,$(1),$(DBUSMENUGTK_LIBS))
endef
ifeq ($(ENABLE_TELEPATHY),TRUE)
define gb_LinkTarget__use_telepathy
$(call gb_LinkTarget_set_include,$(1),\
$$(INCLUDE) \
$(TELEPATHY_CFLAGS) \
)
$(call gb_LinkTarget_add_defs,$(1),\
-DENABLE_TELEPATHY \
)
$(call gb_LinkTarget_add_libs,$(1),\
$(TELEPATHY_LIBS) \
)
endef
else # !ENABLE_TELEPATHY
define gb_LinkTarget__use_telepathy
endef
endif # ENABLE_TELEPATHY
ifeq ($(SYSTEM_DB),YES)
define gb_LinkTarget__use_berkeleydb
......
......@@ -137,6 +137,7 @@ $(eval $(call gb_Module_add_moduledirs,ooo,\
$(if $(filter TRANSLATIONS,$(BUILD_TYPE)),\
translations \
) \
tubes \
twain \
ucb \
ucbhelper \
......
......@@ -145,6 +145,7 @@ export ENABLE_SCRIPTING_PYTHON=@ENABLE_SCRIPTING_PYTHON@
export ENABLE_SILENT_MSI=@ENABLE_SILENT_MSI@
export ENABLE_SYMBOLS=@ENABLE_SYMBOLS@
export ENABLE_SYSTRAY_GTK=@ENABLE_SYSTRAY_GTK@
export ENABLE_TELEPATHY=@ENABLE_TELEPATHY@
export ENABLE_XMLSEC=@ENABLE_XMLSEC@
export ENABLE_ZENITY=@ENABLE_ZENITY@
export EPM=@EPM@
......@@ -545,6 +546,8 @@ export SYSTEM_STDLIBS=@SYSTEM_STDLIBS@
export SYSTEM_VIGRA=@SYSTEM_VIGRA@
export SYSTEM_ZLIB=@SYSTEM_ZLIB@
export TARFILE_LOCATION=@TARFILE_LOCATION@
export TELEPATHY_CFLAGS=@TELEPATHY_CFLAGS@
export TELEPATHY_LIBS=@TELEPATHY_LIBS@
export THES_SYSTEM_DIR=@THES_SYSTEM_DIR@
@x_Cygwin@ export TMP=@TMP_DIRECTORY@
export TMPDIR=@TEMP_DIRECTORY@
......
......@@ -789,6 +789,11 @@ AC_ARG_ENABLE(gio,
[Determines whether to use the GIO support.]),
,enable_gio=no)
AC_ARG_ENABLE(telepathy,
AS_HELP_STRING([--enable-telepathy],
[Determines whether to enable Telepathy for collaboration.]),
,enable_telepathy=no)
AC_ARG_ENABLE(build-mozilla,
AS_HELP_STRING([--disable-build-mozilla],
[Use this option if you do not want to build the Mozilla components from
......@@ -8949,6 +8954,31 @@ AC_SUBST([ENABLE_GTK_PRINT])
AC_SUBST([GTK_PRINT_CFLAGS])
AC_SUBST([GTK_PRINT_LIBS])
dnl ===================================================================
dnl Check whether the Telepathy libraries are available.
dnl ===================================================================
ENABLE_TELEPATHY=""
TELEPATHY_CFLAGS=""
TELEPATHY_LIBS=""
AC_MSG_CHECKING([whether to enable Telepathy support])
if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_telepathy" = "yes"; then
ENABLE_TELEPATHY="TRUE"
AC_MSG_RESULT([yes])
PKG_CHECK_MODULES( TELEPATHY, telepathy-glib >= 0.16.4 )
else
AC_MSG_RESULT([no])
fi
AC_SUBST(ENABLE_TELEPATHY)
AC_SUBST(TELEPATHY_CFLAGS)
AC_SUBST(TELEPATHY_LIBS)
dnl ===================================================================
PKG_CHECK_MODULES( LIBPNG, libpng, ENABLE_QUICKSTART_LIBPNG="TRUE", ENABLE_QUICKSTART_LIBPNG="" )
AC_SUBST(LIBPNG_LIBS)
AC_SUBST(LIBPNG_CFLAGS)
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# Major Contributor(s):
# Copyright (C) 2012 Red Hat, Inc., Eike Rathke <erack@redhat.com>
#
# All Rights Reserved.
#
# For minor contributions see the git repository.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
$(eval $(call gb_CppunitTest_CppunitTest,tubes_test))
$(eval $(call gb_CppunitTest_add_exception_objects,tubes_test, \
tubes/qa/test_manager \
))
$(eval $(call gb_CppunitTest_add_linked_libs,tubes_test, \
tubes \
sal \
$(gb_STDLIBS) \
))
$(eval $(call gb_CppunitTest_set_include,tubes_test,\
-I$(realpath $(SRCDIR)/tubes/inc) \
$$(TELEPATHY_CFLAGS) \
$$(INCLUDE) \
))
# vim: set noet sw=4 ts=4:
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# Major Contributor(s):
# Copyright (C) 2012 Red Hat, Inc., Eike Rathke <erack@redhat.com>
#
# All Rights Reserved.
#
# For minor contributions see the git repository.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
$(eval $(call gb_Library_Library,tubes))
$(eval $(call gb_Library_set_include,tubes,\
-I$(realpath $(SRCDIR)/tubes/inc) \
$$(INCLUDE) \
))
$(eval $(call gb_Library_add_defs,tubes,\
-DTUBES_DLLIMPLEMENTATION \
))
$(eval $(call gb_Library_add_cxxflags,tubes,\
$$(TELEPATHY_CFLAGS) \
))
$(eval $(call gb_Library_add_libs,tubes,\
$$(TELEPATHY_LIBS) \
))
$(eval $(call gb_Library_add_linked_libs,tubes,\
$(gb_STDLIBS) \
sal \
salhelper \
))
$(eval $(call gb_Library_use_externals,tubes,\
telepathy \
))
$(eval $(call gb_Library_add_exception_objects,tubes,\
tubes/source/conference \
tubes/source/manager \
tubes/source/packet \
))
# vim:set shiftwidth=4 tabstop=4 noexpandtab: */
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
include $(module_directory)/../solenv/gbuild/partial_build.mk
# vim: set noet sw=4 ts=4:
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# Version: MPL 1.1 / GPLv3+ / LGPLv3+
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License or as specified alternatively below. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# Major Contributor(s):
# Copyright (C) 2012 Red Hat, Inc., Eike Rathke <erack@redhat.com>
#
# All Rights Reserved.
#
# For minor contributions see the git repository.
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 3 or later (the "GPLv3+"), or
# the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
# in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
# instead of those above.
$(eval $(call gb_Module_Module,tubes))
$(eval $(call gb_Module_add_targets,tubes,\
Library_tubes \
))
$(eval $(call gb_Module_add_check_targets,tubes,\
CppunitTest_tubes_test \
))
# vim:set shiftwidth=4 tabstop=4 noexpandtab: */
Interface to Telepathy Tubes.
To enable configure LibO with --enable-telepathy
Status 2012-03-16:
* no LibO code depends on this module yet, so it is not built in a regular
build, even if configured with --enable-telepathy, so cd tubes and make here
* to enable the various SAL_INFO and SAL_WARN messages emitted during
cppunittest pass SAL_LOG=... and do a debug build
* SAL_LOG="+WARN+INFO.tubes" make -rs debug=true
* the cppunittest will currently fail anyway (even if it wouldn't for other
reasons), this is on purpose to be able to see the output as otherwise it
is silenced down ... :-(
* for the cppunittest needed:
* a jabber daemon running on localhost.localdomain
* two accounts configured in Empathy
* libo1@localhost.localdomain
* libo2@localhost.localdomain
* libo1 and libo2 must be contacts/buddies of each other
* both accounts need to be online in Empathy
* very nasty GMainLoop handling for cppunittest, MAYBE we could get rid of
that in a real LibO, this might be responsible for some ugly behaviour
* contact channels seem to be successfully setup
* the client's callback TeleManager_DBusChannelHandler setup with
TeleManager::connect() does not appear to get ever called
* hence the tube offer triggered by TeleManager_ChannelReadyHandler is never
accepted
* unsure if the uniquify setup with tp_simple_handler_new_with_factory() would
work at all, hence trying to have one instance un-uniquified, but to no
avail
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2012 Red Hat, Inc., Eike Rathke <erack@redhat.com>
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#ifndef INCLUDED_TUBES_CONFERENCE_HXX
#define INCLUDED_TUBES_CONFERENCE_HXX
#include <sal/config.h>
#include "tubes/packet.hxx"
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <telepathy-glib/telepathy-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <queue>
typedef ::std::queue<TelePacket> TelePacketQueue;
class TeleManager;
/** Conference setup by TeleManager */
class TeleConference : public boost::enable_shared_from_this<TeleConference>
{
public:
TeleConference( TeleManager* pManager, TpChannel* pChannel, const rtl::OString& rSessionId );
~TeleConference();
/// Close channel and call finalize()
void close();
/// Unrefs, unregisters from manager and calls dtor if last reference!
void finalize();
TeleManager* getManager() const { return mpManager; }
/** @param rPacket
non-const on purpose, see TelePacket::getData()
*/
bool sendPacket( TelePacket& rPacket ) const;
/** Queue incoming data as TelePacket */
void queue( const char* pDBusSender, const char* pPacket, int nSize );
// --- following only to be called only by manager's callbacks ---
// TODO: make friends instead
/// "buddy@jabber.example.org" or "room@conference.example.org" or "UUID"
void setTarget( const rtl::OString& rTarget );
void setChannel( TpChannel* pChannel );
TpChannel* getChannel() const { return mpChannel; }
bool offerTube();
bool setTube( DBusConnection* pTube );
bool acceptTube( const char* pAddress );
// Only for callbacks.
void setTubeOfferedHandlerInvoked( bool b ) { mbTubeOfferedHandlerInvoked = b; }
bool isTubeOfferedHandlerInvoked() const { return mbTubeOfferedHandlerInvoked; }
private:
rtl::OString maTarget;
rtl::OString maSessionId;
TeleManager* mpManager;
TpChannel* mpChannel;
DBusConnection* mpTube;
TelePacketQueue maPacketQueue;
bool mbTubeOfferedHandlerInvoked : 1;
// hide from the public
using boost::enable_shared_from_this<TeleConference>::shared_from_this;
};
typedef boost::shared_ptr<TeleConference> TeleConferencePtr;
#endif // INCLUDED_TUBES_CONFERENCE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2012 Red Hat, Inc., Eike Rathke <erack@redhat.com>
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#ifndef INCLUDED_TUBES_MANAGER_HXX
#define INCLUDED_TUBES_MANAGER_HXX
#include <sal/config.h>
#include "tubes/tubesdllapi.h"
#include "tubes/conference.hxx"
#include "tubes/packet.hxx"
#include <rtl/ustring.hxx>
#include <salhelper/thread.hxx>
#include <rtl/ref.hxx>
#include <telepathy-glib/telepathy-glib.h>
#include <vector>
// For testing purposes, we might need more in future.
#define LIBO_TUBES_DBUS_MSG_METHOD "LibOMsg"
typedef ::std::vector<TeleConferencePtr> TeleConferenceVector;
/** Interface to Telepathy DBus Tubes.
Fragile, not working yet.
Accounts need to have been setup within Empathy already.
*/
/* FIXME: selective dllprivate methods */
class TUBES_DLLPUBLIC TeleManager
{
public:
enum AccountManagerStatus
{
AMS_UNINITIALIZED = 0,
AMS_INPREPARATION,
AMS_UNPREPARABLE,
AMS_PREPARED
};
/** Prepare tube manager with account and service to be offered/listened
to.
@param rAccount
The account (JID) to use. This must be a valid JID that has been
setup with Empathy or another Telepathy client providing
Jabber/XMPP.
@param rService
"WhatEver", is prepended with "...LibreOffice"
@param bCreateOwnGMainLoop
Whether to create and iterate an own GMainLoop. For testing
purposes when no GMainLoop is available.
*/
TeleManager( const rtl::OUString& rAccount, const rtl::OUString& rService, bool bCreateOwnGMainLoop = false );
~TeleManager();
/** Prepare the Telepathy Account Manager.
Invokes an async call that is not ready until meAccountManagerStatus is
set! Until that is AMS_PREPARED nothing else will work.
TODO: this needs some signalling mechanism
*/
void prepareAccountManager();
AccountManagerStatus getAccountManagerStatus() const
{
return meAccountManagerStatus;
}
/** Start a group session in a MUC.
@param rConferenceRoom
The MUC to be created/joined, e.g. "LibreOffice". If empty, the
conference's UUID is used.
@param rConferenceServer
Server to create the MUC on, e.g. "conference.example.org". If
empty, only the conference's UUID is used and rConferenceRoom is
ignored, hopefully resulting in a local DBus tube.
*/
bool startGroupSession( const rtl::OUString& rConferenceRoom,
const rtl::OUString& rConferenceServer );
/** Start a session with a buddy.
@param rBuddy
The buddy to be connected.
*/
bool startBuddySession( const rtl::OUString& rBuddy );
void unregisterConference( TeleConferencePtr pConference );
bool connect();
void disconnect();
void acceptTube( TpChannel* pChannel, const char* pAddress );
/** Only the callback of prepareAccountManager() is to set this. */
void setAccountManagerReady( bool bPrepared);
/** Send data to all registered conferences. */
bool sendPacket( const TelePacket& rPacket ) const;
/// "org.freedesktop.Telepathy.Client.LibreOfficeWhatEver"
rtl::OString getFullServiceName() const;
/// "/org/freedesktop/Telepathy/Client/LibreOfficeWhatEver"
rtl::OString getFullObjectPath() const;
/// Only for use with MainLoopFlusher
GMainLoop* getMainLoop() const { return mpLoop; }
GMainContext* getMainContext() const { return (mpLoop ? g_main_loop_get_context( mpLoop) : NULL); }
static rtl::OString createUuid();
// Only for callbacks.
void setChannelReadyHandlerInvoked( bool b ) { mbChannelReadyHandlerInvoked = b; }
bool isChannelReadyHandlerInvoked() const { return mbChannelReadyHandlerInvoked; }
void setAccountManagerReadyHandlerInvoked( bool b ) { mbAccountManagerReadyHandlerInvoked = b; }
bool isAccountManagerReadyHandlerInvoked() const { return mbAccountManagerReadyHandlerInvoked; }
typedef bool (TeleManager::*CallBackInvokedFunc)() const;
/** Iterate our GMainLoop, blocking, until the callback is done. */
void iterateLoop( CallBackInvokedFunc pFunc );
typedef bool (TeleConference::*ConferenceCallBackInvokedFunc)() const;
/** Iterate our GMainLoop, blocking, until the callback is done. */
void iterateLoop( const TeleConference* pConference, ConferenceCallBackInvokedFunc pFunc );
/** Iterate our GMainLoop, non-blocking, until nothing pending. */
void flushLoop() const;
private:
rtl::OString maAccountID;
rtl::OString maService; // the "WhatEver" part
TeleConferenceVector maConferences;
GMainLoop* mpLoop;
TpDBusDaemon* mpDBus;
TpAccountManager* mpAccountManager;
TpAccount* mpAccount;
TpConnection* mpConnection;
TpBaseClient* mpClient;
AccountManagerStatus meAccountManagerStatus;
bool mbChannelReadyHandlerInvoked : 1;
bool mbAccountManagerReadyHandlerInvoked : 1;
TpAccount* getMyAccount();
};
/** The most ugly workaround for not having a GMainLoop running, i.e. in
cppunittest.
*/
class MainLoopFlusher
{
public:
explicit MainLoopFlusher( const TeleManager* pManager )
:
mpManager( pManager)
{
flush();
}
~MainLoopFlusher()
{
flush();
}
void flush() const
{
mpManager->flushLoop();
}
private:
const TeleManager* mpManager;
};
#endif // INCLUDED_TUBES_MANAGER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2012 Red Hat, Inc., Eike Rathke <erack@redhat.com>
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#ifndef INCLUDED_TUBES_PACKET_HXX
#define INCLUDED_TUBES_PACKET_HXX
#include <sal/config.h>
#include <rtl/string.hxx>
#include <rtl/byteseq.hxx>
class TelePacket
{
public:
TelePacket( const char* pSender, const char* pData, int nSize )
:
maSender( pSender),
maData( reinterpret_cast<const sal_Int8*>(pData), static_cast<sal_Int32>(nSize) )
{
}
TelePacket( const TelePacket& r )
:
maSender( r.maSender),
maData( r.maData)
{
}
/** Underlying getArray() ensures reference count is exactly one, hence
this method is non-const! */
const char* getData() { return reinterpret_cast<const char*>( maData.getArray()); }
sal_Int32 getSize() const { return maData.getLength(); }
private:
rtl::OString maSender;
rtl::ByteSequence maData;
};
#endif // INCLUDED_TUBES_PACKET_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#ifndef INCLUDED_TUBESDLLAPI_H
#define INCLUDED_TUBESDLLAPI_H
#include "sal/types.h"
#if defined(TUBES_DLLIMPLEMENTATION)
#define TUBES_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
#else
#define TUBES_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
#endif
#define TUBES_DLLPRIVATE SAL_DLLPRIVATE
#endif /* INCLUDED_TUBESDLLAPI_H */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tubes tubes : solenv TELEPATHY:telepathy sal NULL
tubes tubes\prj nmake - all tubes_prj NULL
.INCLUDE : gbuildbridge.mk
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2012 Red Hat, Inc., Eike Rathke <erack@redhat.com>
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#include <sal/precppunit.hxx>
#include <tubes/manager.hxx>
#include <cppunit/TestAssert.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/plugin/TestPlugIn.h>
#include <rtl/string.hxx>
#include <rtl/ustring.hxx>
namespace {
class TestTeleTubes: public CppUnit::TestFixture
{
public:
TestTeleTubes();
~TestTeleTubes();
void testSetupManager1();
void testSetupManager2();
void testConnect1();
void testConnect2();
void testPrepareAccountManager1();
void testPrepareAccountManager2();
void testStartBuddySession1();
void testStartBuddySession2();
void testSendPacket();
void testFlushLoops();
void testDestroyManager1();
void testDestroyManager2();
void testFailAlways();
// Order is significant.
CPPUNIT_TEST_SUITE( TestTeleTubes );
CPPUNIT_TEST( testSetupManager1 );
CPPUNIT_TEST( testSetupManager2 );
CPPUNIT_TEST( testConnect1 );
CPPUNIT_TEST( testConnect2 );
CPPUNIT_TEST( testPrepareAccountManager1 );
CPPUNIT_TEST( testPrepareAccountManager2 );
CPPUNIT_TEST( testStartBuddySession1 );
CPPUNIT_TEST( testStartBuddySession2 );
CPPUNIT_TEST( testSendPacket );
CPPUNIT_TEST( testFlushLoops );
CPPUNIT_TEST( testDestroyManager1 );
CPPUNIT_TEST( testDestroyManager2 );
CPPUNIT_TEST( testFailAlways ); // need failure to display SAL_LOG, comment out for real builds
CPPUNIT_TEST_SUITE_END();
private:
void runSetupManager( TeleManager* pManager, const rtl::OUString& rBuddy );
};
// static, not members, so they actually survive cppunit test iteration
static TeleManager* mpManager1 = NULL;
static TeleManager* mpManager2 = NULL;
// XXX The accounts need to be setup in Empathy and a jabber daemon needs
// to be running on localhost.localdomain and both accounts need to be
// enabled and connected.
static rtl::OUString sAcc1( RTL_CONSTASCII_USTRINGPARAM( "libo1@localhost.localdomain"));
static rtl::OUString sAcc2( RTL_CONSTASCII_USTRINGPARAM( "libo2@localhost.localdomain"));
static rtl::OUString sService( RTL_CONSTASCII_USTRINGPARAM( "TeleTest"));
TestTeleTubes::TestTeleTubes()
{
}
TestTeleTubes::~TestTeleTubes()
{
}
void TestTeleTubes::testSetupManager1()
{
mpManager1 = new TeleManager( sAcc1, sService, true);
}
void TestTeleTubes::testSetupManager2()
{
mpManager2 = new TeleManager( sAcc2, sService);
}
void TestTeleTubes::testPrepareAccountManager1()
{
mpManager1->prepareAccountManager();
TeleManager::AccountManagerStatus eStatus = mpManager1->getAccountManagerStatus();
CPPUNIT_ASSERT( eStatus == TeleManager::AMS_PREPARED);
}
void TestTeleTubes::testPrepareAccountManager2()
{
mpManager2->prepareAccountManager();
TeleManager::AccountManagerStatus eStatus = mpManager2->getAccountManagerStatus();
CPPUNIT_ASSERT( eStatus == TeleManager::AMS_PREPARED);
}
void TestTeleTubes::testStartBuddySession1()
{
bool bStarted = mpManager1->startBuddySession( sAcc2);
CPPUNIT_ASSERT( bStarted == true);
}
void TestTeleTubes::testStartBuddySession2()
{
bool bStarted = mpManager2->startBuddySession( sAcc1);
CPPUNIT_ASSERT( bStarted == true);
}
void TestTeleTubes::testConnect1()
{
bool bConnected = mpManager1->connect();
CPPUNIT_ASSERT( bConnected == true);
}
void TestTeleTubes::testConnect2()
{
bool bConnected = mpManager2->connect();
CPPUNIT_ASSERT( bConnected == true);
}
void TestTeleTubes::testSendPacket()
{
TelePacket aPacket( "", RTL_CONSTASCII_STRINGPARAM( "from 1 to 2"));
bool bPacketSent = mpManager1->sendPacket( aPacket);
CPPUNIT_ASSERT( bPacketSent == true);
}
void TestTeleTubes::testFlushLoops()
{
mpManager1->flushLoop();
mpManager2->flushLoop();
}
void TestTeleTubes::testDestroyManager1()
{
delete mpManager1;
mpManager1 = NULL;
}
void TestTeleTubes::testDestroyManager2()
{
delete mpManager2;
mpManager2 = NULL;
}
void TestTeleTubes::testFailAlways()
{
CPPUNIT_ASSERT( false);
}
CPPUNIT_TEST_SUITE_REGISTRATION( TestTeleTubes);
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License or as specified alternatively below. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* Major Contributor(s):
* Copyright (C) 2012 Red Hat, Inc., Eike Rathke <erack@redhat.com>
*
* All Rights Reserved.
*
* For minor contributions see the git repository.
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
* instead of those above.
*/
#include <tubes/packet.hxx>
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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