diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-18 18:26:28 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-04-23 22:20:31 +0200 |
commit | b9337e22ce1dbf2eba0e8c8db294ae99f4111f91 (patch) | |
tree | 53ee1bd3dfd213815a21579151983cb997922b05 /include/tubes | |
parent | f4e1642a1761d5eab6ccdd89928869c2b2f1528a (diff) |
execute move of global headers
see https://gerrit.libreoffice.org/#/c/3367/
and Change-Id: I00c96fa77d04b33a6f8c8cd3490dfcd9bdc9e84a for details
Change-Id: I199a75bc4042af20817265d5ef85b1134a96ff5a
Diffstat (limited to 'include/tubes')
-rw-r--r-- | include/tubes/collaboration.hxx | 50 | ||||
-rw-r--r-- | include/tubes/conference.hxx | 83 | ||||
-rw-r--r-- | include/tubes/constants.h | 54 | ||||
-rw-r--r-- | include/tubes/file-transfer-helper.h | 125 | ||||
-rw-r--r-- | include/tubes/manager.hxx | 155 | ||||
-rw-r--r-- | include/tubes/tubesdllapi.h | 16 |
6 files changed, 483 insertions, 0 deletions
diff --git a/include/tubes/collaboration.hxx b/include/tubes/collaboration.hxx new file mode 100644 index 000000000000..3f32d4188dbe --- /dev/null +++ b/include/tubes/collaboration.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * 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/. + */ + +#ifndef INCLUDED_TUBES_COLLABORATION_HXX +#define INCLUDED_TUBES_COLLABORATION_HXX + +#include <sal/config.h> + +#include <rtl/ustring.hxx> +#include <tubes/tubesdllapi.h> + +class TeleConference; +typedef struct _TpContact TpContact; + +class TUBES_DLLPUBLIC Collaboration +{ + TeleConference* mpConference; + // This is in fact of type TubeContacts* from anonymous namespace + void* mpContacts; +public: + Collaboration(); + virtual ~Collaboration(); + + /** Returns to normal editing mode */ + virtual void EndCollaboration() const = 0; + virtual void PacketReceived( const OString& rPacket ) const = 0; + /** Saves current document and then calls SendFile() with the file URL */ + virtual void SaveAndSendFile( TpContact* pContact ) const = 0; + /** Prepares document for collaboration and should call SetConference() */ + virtual void StartCollaboration( TeleConference* pConference ) = 0; + + TUBES_DLLPRIVATE sal_uInt64 GetId() const; + TUBES_DLLPRIVATE void Invite( TpContact* pContact ) const; + + /** Application calls this to display contacts dialog from where can the collaboration start */ + void DisplayContacts(); + void SendFile( TpContact* pContact, const OUString& rURL ) const; + void SendPacket( const OString& rPacket ) const; + void SetConference( TeleConference* pConference ); +}; + +#endif // INCLUDED_TUBES_COLLABORATION_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/tubes/conference.hxx b/include/tubes/conference.hxx new file mode 100644 index 000000000000..7dfd744d959a --- /dev/null +++ b/include/tubes/conference.hxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * 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/. + */ + +#ifndef INCLUDED_TUBES_CONFERENCE_HXX +#define INCLUDED_TUBES_CONFERENCE_HXX + +#include <sal/config.h> +#include <rtl/ustring.hxx> + +class Collaboration; +class TeleConferenceImpl; +typedef struct _TpAccount TpAccount; +typedef struct _TpContact TpContact; +typedef struct _TpDBusTubeChannel TpDBusTubeChannel; +typedef struct _GDBusConnection GDBusConnection; + +/** Conference setup by TeleManager */ +class TeleConference +{ +public: + + TeleConference( TpAccount* pAccount, + TpDBusTubeChannel* pChannel, + const OString sUuid = OString(), + bool bMaster = false ); + ~TeleConference(); + + /// Close channel and call finalize() + void close(); + + /// Unrefs, unregisters from manager and calls dtor if last reference! + void finalize(); + + bool sendPacket( const OString& rPacket ); + + void invite( TpContact *pContact ); + + typedef void (*FileSentCallback)( bool aSuccess, void* pUserData); + void sendFile( TpContact* pContact, const OUString& rURL, FileSentCallback pCallback, void* pUserData); + const OString& getUuid() const { return msUuid; } + + Collaboration* getCollaboration() const; + void setCollaboration( Collaboration* pCollaboration ); + + // --- following only to be called only by manager's callbacks --- + // TODO: make friends instead + void setChannel( TpAccount* pAccount, TpDBusTubeChannel* pChannel ); + bool offerTube(); + bool acceptTube(); + + // Only for callbacks. + bool setTube( GDBusConnection* pTube ); + void setTubeOfferedHandlerInvoked( bool b ); + bool isTubeOfferedHandlerInvoked() const; + bool isMaster() const; + void setUuid( const OString& rUuid ) { msUuid = rUuid; } + +private: + friend class TeleManager; + // Used only by TeleManager: + /// got tube accepted on other end as well? + bool isReady() const; + + // Private: + bool spinUntilTubeEstablished(); + + Collaboration* mpCollaboration; + TpAccount* mpAccount; + TpDBusTubeChannel* mpChannel; + OString msUuid; + bool mbMaster; + TeleConferenceImpl* pImpl; +}; + +#endif // INCLUDED_TUBES_CONFERENCE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/tubes/constants.h b/include/tubes/constants.h new file mode 100644 index 000000000000..5c34534c8e37 --- /dev/null +++ b/include/tubes/constants.h @@ -0,0 +1,54 @@ +/* -*- 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 Collabora Ltd. + * + * 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_CONSTANTS_H +#define INCLUDED_TUBES_CONSTANTS_H + +/* DBusTube.ServiceName. + * + * FIXME: Should be something like + * + * org.libreoffice.calc + * org.libreoffice.writer + * + * etc. This does not need to include the org.freedesktop.Telepathy.Client + * stuff. + */ +#define LIBO_DTUBE_SERVICE "org.libreoffice.calc" + +/* Client name suffix, for passing as 'name' to + * tp_simple_handler_new_with_am(). */ +#define LIBO_CLIENT_SUFFIX "LibreOffice" + +/* Key value storing UUID for TeleConference + */ +#define LIBO_TUBES_UUID "LIBO_TUBES_UUID" + +#endif // INCLUDED_TUBES_CONSTANTS_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/tubes/file-transfer-helper.h b/include/tubes/file-transfer-helper.h new file mode 100644 index 000000000000..016aed8fdec7 --- /dev/null +++ b/include/tubes/file-transfer-helper.h @@ -0,0 +1,125 @@ +/* + * empathy-ft-handler.h - Header for EmpathyFTHandler + * Copyright (C) 2009 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk> + */ + +/* empathy-ft-handler.h */ + +#ifndef __EMPATHY_FT_HANDLER_H__ +#define __EMPATHY_FT_HANDLER_H__ + +#include <glib-object.h> +#include <gio/gio.h> + +#include <telepathy-glib/contact.h> +#include <telepathy-glib/file-transfer-channel.h> + +G_BEGIN_DECLS + +#define EMPATHY_TYPE_FT_HANDLER empathy_ft_handler_get_type() +#define EMPATHY_FT_HANDLER(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ + EMPATHY_TYPE_FT_HANDLER, EmpathyFTHandler)) +#define EMPATHY_FT_HANDLER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST ((klass), \ + EMPATHY_TYPE_FT_HANDLER, EmpathyFTHandlerClass)) +#define EMPATHY_IS_FT_HANDLER(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_FT_HANDLER)) +#define EMPATHY_IS_FT_HANDLER_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_FT_HANDLER)) +#define EMPATHY_FT_HANDLER_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + EMPATHY_TYPE_FT_HANDLER, EmpathyFTHandlerClass)) + +typedef struct _EmpathyFTHandlerPriv EmpathyFTHandlerPriv; + +typedef struct { + GObject parent; + EmpathyFTHandlerPriv *priv; +} EmpathyFTHandler; + +typedef struct { + GObjectClass parent_class; +} EmpathyFTHandlerClass; + +#define EMPATHY_FT_ERROR_QUARK g_quark_from_static_string ("EmpathyFTError") + +typedef enum { + EMPATHY_FT_ERROR_FAILED, + EMPATHY_FT_ERROR_HASH_MISMATCH, + EMPATHY_FT_ERROR_TP_ERROR, + EMPATHY_FT_ERROR_SOCKET, + EMPATHY_FT_ERROR_NOT_SUPPORTED, + EMPATHY_FT_ERROR_INVALID_SOURCE_FILE, + EMPATHY_FT_ERROR_EMPTY_SOURCE_FILE +} EmpathyFTErrorEnum; + +/** + * EmpathyFTHandlerReadyCallback: + * @handler: the handler which is now ready + * @error: a #GError if the operation failed, or %NULL + * @user_data: user data passed to the callback + */ +typedef void (* EmpathyFTHandlerReadyCallback) (EmpathyFTHandler *handler, + GError *error, + gpointer user_data); + +GType empathy_ft_handler_get_type (void); + +/* public methods */ +void empathy_ft_handler_new_outgoing ( + TpAccount *account, + TpContact *contact, + GFile *source, + gint64 action_time, + EmpathyFTHandlerReadyCallback callback, + gpointer user_data); +void empathy_ft_handler_set_service_name ( + EmpathyFTHandler *self, + const gchar *service_name); +void empathy_ft_handler_set_description ( + EmpathyFTHandler *self, + const gchar *description); + + +void empathy_ft_handler_new_incoming (TpFileTransferChannel *channel, + EmpathyFTHandlerReadyCallback callback, + gpointer user_data); +void empathy_ft_handler_incoming_set_destination (EmpathyFTHandler *handler, + GFile *destination); + +void empathy_ft_handler_start_transfer (EmpathyFTHandler *handler); +void empathy_ft_handler_cancel_transfer (EmpathyFTHandler *handler); + +/* properties of the transfer */ +const char * empathy_ft_handler_get_filename (EmpathyFTHandler *handler); +const char * empathy_ft_handler_get_content_type (EmpathyFTHandler *handler); +TpContact * empathy_ft_handler_get_contact (EmpathyFTHandler *handler); +GFile * empathy_ft_handler_get_gfile (EmpathyFTHandler *handler); +const char *empathy_ft_handler_get_description(EmpathyFTHandler*); +gboolean empathy_ft_handler_get_use_hash (EmpathyFTHandler *handler); +gboolean empathy_ft_handler_is_incoming (EmpathyFTHandler *handler); +guint64 empathy_ft_handler_get_transferred_bytes (EmpathyFTHandler *handler); +guint64 empathy_ft_handler_get_total_bytes (EmpathyFTHandler *handler); +gboolean empathy_ft_handler_is_completed (EmpathyFTHandler *handler); +gboolean empathy_ft_handler_is_cancelled (EmpathyFTHandler *handler); + +G_END_DECLS + +#endif /* __EMPATHY_FT_HANDLER_H__ */ diff --git a/include/tubes/manager.hxx b/include/tubes/manager.hxx new file mode 100644 index 000000000000..e906e9fd7dd0 --- /dev/null +++ b/include/tubes/manager.hxx @@ -0,0 +1,155 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * 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/. + */ + +#ifndef INCLUDED_TUBES_MANAGER_HXX +#define INCLUDED_TUBES_MANAGER_HXX + +#include <sal/config.h> +#include <tubes/tubesdllapi.h> +#include <rtl/ustring.hxx> + +#include <utility> +#include <vector> + +// For testing purposes, we might need more in future. +#define LIBO_TUBES_DBUS_INTERFACE "org.libreoffice.calc" +#define LIBO_TUBES_DBUS_MSG_METHOD "LibOMsg" +#define LIBO_TUBES_DBUS_PATH "/org/libreoffice/calc" + +namespace osl { class Mutex; } +class Collaboration; +class TeleConference; +class TeleManagerImpl; +typedef struct _TpAccount TpAccount; +typedef struct _TpContact TpContact; + +typedef ::std::pair< TpAccount *, TpContact * > AccountContactPair; +typedef ::std::vector< AccountContactPair > AccountContactPairV; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +/** Interface to Telepathy DBus Tubes. + + Fragile, not working yet. + + Accounts need to have been setup within Empathy already. + */ + +class TeleManager +{ +public: + /** Prepare tube manager with account and service to be offered/listened + to. + */ + TUBES_DLLPUBLIC static bool init( bool bListen ); + + 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(); + + /** Connect to DBus, create and prepare the Telepathy Account Manager. */ + static bool createAccountManager(); + + /** Setup client handlers. */ + static bool registerClients(); + + /** Fetches the contact list. + Is non-functional until createAccountManager(). + */ + // exported for unit test + TUBES_DLLPUBLIC static AccountContactPairV getContacts(); + + /** Start a demo session where all local documents are shared to each other */ + static TeleConference* startDemoSession(); + + /** Start a group session in a MUC. + + @param pAccount + The account to use. This must be a valid Jabber account. + + @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. + */ + static TeleConference* startGroupSession( TpAccount *pAccount, + const OUString& rConferenceRoom, + const OUString& rConferenceServer ); + + /** Start a session with a buddy. + + @param pAccount + The account to use. This must be a valid Jabber account. + + @param pBuddy + The buddy to be connected. Must be a contact of pAccount. + */ + // exported for unit test + TUBES_DLLPUBLIC static TeleConference* startBuddySession( TpAccount *pAccount, TpContact *pBuddy ); + + static void registerCollaboration( Collaboration* pCollaboration ); + static void unregisterCollaboration( Collaboration* pCollaboration ); + /** Used to determine whether we are closing the channel by ourselves. + * @return true if the Collaboration is still registered */ + static bool existsCollaboration( Collaboration* pCollaboration ); + /** Display contact list dialog for all documents. */ + static void displayAllContacts(); + + static void registerDemoConference( TeleConference* pConference ); + static void unregisterDemoConference( TeleConference* pConference ); + /** Broadcast packet to all conferences. Used for demo mode. */ + static void broadcastPacket( const OString& rPacket ); + + + // Only for callbacks. + static void addConference( TeleConference* pConference ); + static OString createUuid(); + /** @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 ); + + /// "LibreOfficeWhatEver" + static OString getFullClientName(); + + /// "org.libreoffice.calcWhatEver" + static OString getFullServiceName(); + + /// "/org/libreoffice/calcWhatEver" + static OString getFullObjectPath(); + + /** 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 + used it must be called before the first TeleManager is instanciated and + connects. + */ + // exported for unit test + TUBES_DLLPUBLIC static void addSuffixToNames( const char* pName ); + +private: + static TeleManagerImpl* pImpl; + + static ::osl::Mutex& GetMutex(); +}; + +#endif // INCLUDED_TUBES_MANAGER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/tubes/tubesdllapi.h b/include/tubes/tubesdllapi.h new file mode 100644 index 000000000000..ea1b70770277 --- /dev/null +++ b/include/tubes/tubesdllapi.h @@ -0,0 +1,16 @@ +/* -*- 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: */ |