2012-03-16 22:14:54 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
2013-04-19 21:10:42 +01:00
|
|
|
* This file is part of the LibreOffice project.
|
2012-03-16 22:14:54 +01:00
|
|
|
*
|
2013-04-19 21:10:42 +01:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2012-03-16 22:14:54 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_TUBES_MANAGER_HXX
|
|
|
|
#define INCLUDED_TUBES_MANAGER_HXX
|
|
|
|
|
|
|
|
#include <sal/config.h>
|
2012-07-26 12:56:19 +02:00
|
|
|
#include <tubes/tubesdllapi.h>
|
2012-03-16 22:14:54 +01:00
|
|
|
#include <rtl/ustring.hxx>
|
|
|
|
|
2012-08-20 14:08:02 +02:00
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
2012-03-16 22:14:54 +01:00
|
|
|
// For testing purposes, we might need more in future.
|
2012-03-30 18:50:27 +01:00
|
|
|
#define LIBO_TUBES_DBUS_INTERFACE "org.libreoffice.calc"
|
2012-03-16 22:14:54 +01:00
|
|
|
#define LIBO_TUBES_DBUS_MSG_METHOD "LibOMsg"
|
2012-03-30 18:50:27 +01:00
|
|
|
#define LIBO_TUBES_DBUS_PATH "/org/libreoffice/calc"
|
2012-03-16 22:14:54 +01:00
|
|
|
|
2012-03-21 16:10:16 +01:00
|
|
|
namespace osl { class Mutex; }
|
2012-08-07 10:59:58 +02:00
|
|
|
class Collaboration;
|
2012-07-26 12:56:19 +02:00
|
|
|
class TeleConference;
|
2012-03-21 16:10:16 +01:00
|
|
|
class TeleManagerImpl;
|
2012-07-23 20:48:47 +02:00
|
|
|
typedef struct _TpAccount TpAccount;
|
|
|
|
typedef struct _TpContact TpContact;
|
2012-03-16 22:14:54 +01:00
|
|
|
|
2012-08-20 14:08:02 +02:00
|
|
|
typedef ::std::pair< TpAccount *, TpContact * > AccountContactPair;
|
|
|
|
typedef ::std::vector< AccountContactPair > AccountContactPairV;
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
2012-03-16 22:14:54 +01:00
|
|
|
/** Interface to Telepathy DBus Tubes.
|
|
|
|
|
|
|
|
Fragile, not working yet.
|
|
|
|
|
|
|
|
Accounts need to have been setup within Empathy already.
|
|
|
|
*/
|
|
|
|
|
2012-07-14 00:06:01 +02:00
|
|
|
class TeleManager
|
2012-03-16 22:14:54 +01:00
|
|
|
{
|
2012-08-15 14:10:22 +02:00
|
|
|
public:
|
2012-03-16 22:14:54 +01:00
|
|
|
/** Prepare tube manager with account and service to be offered/listened
|
|
|
|
to.
|
|
|
|
*/
|
2012-08-07 15:35:20 +02:00
|
|
|
TUBES_DLLPUBLIC static bool init( bool bListen );
|
2012-03-16 22:14:54 +01:00
|
|
|
|
2012-08-07 15:35:20 +02:00
|
|
|
TUBES_DLLPUBLIC static void finalize();
|
|
|
|
|
|
|
|
/** True if there has been tube channel received and is still not used. */
|
|
|
|
TUBES_DLLPUBLIC static bool hasWaitingConference();
|
|
|
|
|
|
|
|
/** Get a conference with current UUID to set a session. */
|
|
|
|
TUBES_DLLPUBLIC static TeleConference* getConference();
|
2012-03-23 16:39:43 +00:00
|
|
|
|
2012-08-15 14:10:22 +02:00
|
|
|
/** Connect to DBus, create and prepare the Telepathy Account Manager. */
|
2012-08-07 15:35:20 +02:00
|
|
|
static bool createAccountManager();
|
2012-07-13 19:06:34 +02:00
|
|
|
|
|
|
|
/** Setup client handlers. */
|
2012-08-07 15:35:20 +02:00
|
|
|
static bool registerClients();
|
2012-07-13 19:06:34 +02:00
|
|
|
|
2012-08-20 14:08:02 +02:00
|
|
|
/** Fetches the contact list.
|
|
|
|
Is non-functional until createAccountManager().
|
2012-03-23 10:18:25 +00:00
|
|
|
*/
|
2012-08-16 00:47:02 +02:00
|
|
|
// exported for unit test
|
2012-08-20 14:08:02 +02:00
|
|
|
TUBES_DLLPUBLIC static AccountContactPairV getContacts();
|
2012-03-23 10:18:25 +00:00
|
|
|
|
2012-08-04 16:30:55 +02:00
|
|
|
/** Start a demo session where all local documents are shared to each other */
|
2012-08-07 15:35:20 +02:00
|
|
|
static TeleConference* startDemoSession();
|
2012-08-04 16:30:55 +02:00
|
|
|
|
2012-03-16 22:14:54 +01:00
|
|
|
/** Start a group session in a MUC.
|
|
|
|
|
2012-06-30 12:52:57 +02:00
|
|
|
@param pAccount
|
|
|
|
The account to use. This must be a valid Jabber account.
|
|
|
|
|
2012-03-16 22:14:54 +01:00
|
|
|
@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.
|
|
|
|
*/
|
2012-08-07 15:35:20 +02:00
|
|
|
static TeleConference* startGroupSession( TpAccount *pAccount,
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString& rConferenceRoom,
|
|
|
|
const OUString& rConferenceServer );
|
2012-03-16 22:14:54 +01:00
|
|
|
|
|
|
|
/** Start a session with a buddy.
|
|
|
|
|
2012-03-22 12:59:15 +00:00
|
|
|
@param pAccount
|
|
|
|
The account to use. This must be a valid Jabber account.
|
2012-03-21 16:10:16 +01:00
|
|
|
|
2012-03-22 12:59:15 +00:00
|
|
|
@param pBuddy
|
2012-03-23 10:55:09 +01:00
|
|
|
The buddy to be connected. Must be a contact of pAccount.
|
2012-03-16 22:14:54 +01:00
|
|
|
*/
|
2012-08-16 00:47:02 +02:00
|
|
|
// exported for unit test
|
|
|
|
TUBES_DLLPUBLIC static TeleConference* startBuddySession( TpAccount *pAccount, TpContact *pBuddy );
|
2012-07-20 00:12:19 +02:00
|
|
|
|
2012-08-07 15:35:20 +02:00
|
|
|
static void registerCollaboration( Collaboration* pCollaboration );
|
|
|
|
static void unregisterCollaboration( Collaboration* pCollaboration );
|
2012-08-20 12:05:50 +02:00
|
|
|
/** Used to determine whether we are closing the channel by ourselves.
|
|
|
|
* @return true if the Collaboration is still registered */
|
2012-08-09 23:37:32 +02:00
|
|
|
static bool existsCollaboration( Collaboration* pCollaboration );
|
2012-08-07 10:59:58 +02:00
|
|
|
/** Display contact list dialog for all documents. */
|
2012-08-07 15:35:20 +02:00
|
|
|
static void displayAllContacts();
|
2012-08-07 10:59:58 +02:00
|
|
|
|
2012-08-07 15:35:20 +02:00
|
|
|
static void registerDemoConference( TeleConference* pConference );
|
|
|
|
static void unregisterDemoConference( TeleConference* pConference );
|
2012-08-04 16:30:55 +02:00
|
|
|
/** Broadcast packet to all conferences. Used for demo mode. */
|
2012-08-07 15:35:20 +02:00
|
|
|
static void broadcastPacket( const OString& rPacket );
|
2012-03-20 20:24:33 +01:00
|
|
|
|
2012-03-16 22:14:54 +01:00
|
|
|
|
|
|
|
// Only for callbacks.
|
2012-08-04 16:30:55 +02:00
|
|
|
static void addConference( TeleConference* pConference );
|
2013-04-07 12:06:47 +02:00
|
|
|
static OString createUuid();
|
2012-08-20 12:05:50 +02:00
|
|
|
/** @param rUuid
|
|
|
|
is stored so that accepted conference with this UUID could be
|
|
|
|
then retrieved by getConference() when loading new document
|
|
|
|
*/
|
|
|
|
static void setCurrentUuid( const OString& rUuid );
|
2012-03-16 22:14:54 +01:00
|
|
|
|
2012-03-21 19:31:50 +01:00
|
|
|
/// "LibreOfficeWhatEver"
|
2013-04-07 12:06:47 +02:00
|
|
|
static OString getFullClientName();
|
2012-03-21 19:31:50 +01:00
|
|
|
|
|
|
|
/// "org.libreoffice.calcWhatEver"
|
2013-04-07 12:06:47 +02:00
|
|
|
static OString getFullServiceName();
|
2012-03-21 19:31:50 +01:00
|
|
|
|
|
|
|
/// "/org/libreoffice/calcWhatEver"
|
2013-04-07 12:06:47 +02:00
|
|
|
static OString getFullObjectPath();
|
2012-03-21 19:31:50 +01:00
|
|
|
|
|
|
|
/** Add a suffix to the client name and DBus tube names, e.g. "WhatEver"
|
|
|
|
|
|
|
|
Normally the client name is LibreOffice and the DBus tube service name
|
|
|
|
is something like org.libreoffice.calc, this modifies the names to
|
|
|
|
"LibreOffice"+pName and "org.libreoffice.calc"+pName to make tests not
|
|
|
|
interfere with the real world. This is not to be used otherwise. If
|
2014-10-08 11:02:03 +02:00
|
|
|
used it must be called before the first TeleManager is instantiated and
|
2012-03-21 19:31:50 +01:00
|
|
|
connects.
|
|
|
|
*/
|
2012-08-16 00:47:02 +02:00
|
|
|
// exported for unit test
|
|
|
|
TUBES_DLLPUBLIC static void addSuffixToNames( const char* pName );
|
2012-03-21 19:31:50 +01:00
|
|
|
|
2012-03-16 22:14:54 +01:00
|
|
|
private:
|
2012-03-21 16:10:16 +01:00
|
|
|
static TeleManagerImpl* pImpl;
|
|
|
|
|
2012-07-14 00:06:01 +02:00
|
|
|
static ::osl::Mutex& GetMutex();
|
2012-03-16 22:14:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDED_TUBES_MANAGER_HXX
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|