1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #ifndef INCLUDED_TUBES_MANAGER_HXX
11 #define INCLUDED_TUBES_MANAGER_HXX
13 #include <sal/config.h>
14 #include <tubes/tubesdllapi.h>
15 #include <rtl/ustring.hxx>
20 // For testing purposes, we might need more in future.
21 #define LIBO_TUBES_DBUS_INTERFACE "org.libreoffice.calc"
22 #define LIBO_TUBES_DBUS_MSG_METHOD "LibOMsg"
23 #define LIBO_TUBES_DBUS_PATH "/org/libreoffice/calc"
25 namespace osl
{ class Mutex
; }
28 class TeleManagerImpl
;
29 typedef struct _TpAccount TpAccount
;
30 typedef struct _TpContact TpContact
;
32 typedef ::std::pair
< TpAccount
*, TpContact
* > AccountContactPair
;
33 typedef ::std::vector
< AccountContactPair
> AccountContactPairV
;
35 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
36 /** Interface to Telepathy DBus Tubes.
38 Fragile, not working yet.
40 Accounts need to have been setup within Empathy already.
46 /** Prepare tube manager with account and service to be offered/listened
49 TUBES_DLLPUBLIC
static bool init( bool bListen
);
51 TUBES_DLLPUBLIC
static void finalize();
53 /** True if there has been tube channel received and is still not used. */
54 TUBES_DLLPUBLIC
static bool hasWaitingConference();
56 /** Get a conference with current UUID to set a session. */
57 TUBES_DLLPUBLIC
static TeleConference
* getConference();
59 /** Connect to DBus, create and prepare the Telepathy Account Manager. */
60 static bool createAccountManager();
62 /** Setup client handlers. */
63 static bool registerClients();
65 /** Fetches the contact list.
66 Is non-functional until createAccountManager().
68 // exported for unit test
69 TUBES_DLLPUBLIC
static AccountContactPairV
getContacts();
71 /** Start a demo session where all local documents are shared to each other */
72 static TeleConference
* startDemoSession();
74 /** Start a group session in a MUC.
77 The account to use. This must be a valid Jabber account.
79 @param rConferenceRoom
80 The MUC to be created/joined, e.g. "LibreOffice". If empty, the
81 conference's UUID is used.
83 @param rConferenceServer
84 Server to create the MUC on, e.g. "conference.example.org". If
85 empty, only the conference's UUID is used and rConferenceRoom is
86 ignored, hopefully resulting in a local DBus tube.
88 static TeleConference
* startGroupSession( TpAccount
*pAccount
,
89 const OUString
& rConferenceRoom
,
90 const OUString
& rConferenceServer
);
92 /** Start a session with a buddy.
95 The account to use. This must be a valid Jabber account.
98 The buddy to be connected. Must be a contact of pAccount.
100 // exported for unit test
101 TUBES_DLLPUBLIC
static TeleConference
* startBuddySession( TpAccount
*pAccount
, TpContact
*pBuddy
);
103 static void registerCollaboration( Collaboration
* pCollaboration
);
104 static void unregisterCollaboration( Collaboration
* pCollaboration
);
105 /** Used to determine whether we are closing the channel by ourselves.
106 * @return true if the Collaboration is still registered */
107 static bool existsCollaboration( Collaboration
* pCollaboration
);
108 /** Display contact list dialog for all documents. */
109 static void displayAllContacts();
111 static void registerDemoConference( TeleConference
* pConference
);
112 static void unregisterDemoConference( TeleConference
* pConference
);
113 /** Broadcast packet to all conferences. Used for demo mode. */
114 static void broadcastPacket( const OString
& rPacket
);
117 // Only for callbacks.
118 static void addConference( TeleConference
* pConference
);
119 static OString
createUuid();
121 is stored so that accepted conference with this UUID could be
122 then retrieved by getConference() when loading new document
124 static void setCurrentUuid( const OString
& rUuid
);
126 /// "LibreOfficeWhatEver"
127 static OString
getFullClientName();
129 /// "org.libreoffice.calcWhatEver"
130 static OString
getFullServiceName();
132 /// "/org/libreoffice/calcWhatEver"
133 static OString
getFullObjectPath();
135 /** Add a suffix to the client name and DBus tube names, e.g. "WhatEver"
137 Normally the client name is LibreOffice and the DBus tube service name
138 is something like org.libreoffice.calc, this modifies the names to
139 "LibreOffice"+pName and "org.libreoffice.calc"+pName to make tests not
140 interfere with the real world. This is not to be used otherwise. If
141 used it must be called before the first TeleManager is instantiated and
144 // exported for unit test
145 TUBES_DLLPUBLIC
static void addSuffixToNames( const char* pName
);
148 static TeleManagerImpl
* pImpl
;
150 static ::osl::Mutex
& GetMutex();
153 #endif // INCLUDED_TUBES_MANAGER_HXX
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */