Kaydet (Commit) b870f142 authored tarafından Matúš Kukan's avatar Matúš Kukan

tubes: make contacts dialog a member of Collaboration class

Change-Id: Ib50b550f9486bc1abfeefd5d1aac57c0d712ec04
üst 34c6421b
...@@ -32,11 +32,8 @@ ...@@ -32,11 +32,8 @@
#include "docsh.hxx" #include "docsh.hxx"
#include "docfunc.hxx" #include "docfunc.hxx"
#include "sccollaboration.hxx" #include "sccollaboration.hxx"
#include <tubes/contacts.hxx>
#include <tubes/manager.hxx> #include <tubes/manager.hxx>
#include <vector>
void ScDocFuncSend::RecvMessage( const rtl::OString &rString ) void ScDocFuncSend::RecvMessage( const rtl::OString &rString )
{ {
try { try {
...@@ -127,7 +124,7 @@ sal_Bool ScDocFuncSend::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& r ...@@ -127,7 +124,7 @@ sal_Bool ScDocFuncSend::SetNormalString( bool& o_rbNumFmtSet, const ScAddress& r
mpCollaboration->SaveAndSendFile( NULL, rText ); mpCollaboration->SaveAndSendFile( NULL, rText );
if ( rtl::OUString( rText ) == "contacts" ) if ( rtl::OUString( rText ) == "contacts" )
tubes::createContacts( rDocShell.GetCollaboration() ); mpCollaboration->DisplayContacts();
return true; // needs some code auditing action return true; // needs some code auditing action
} }
......
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
#ifdef ENABLE_TELEPATHY #ifdef ENABLE_TELEPATHY
#include "sccollaboration.hxx" #include "sccollaboration.hxx"
#include <tubes/contacts.hxx>
#endif #endif
#define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() ) #define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() )
...@@ -118,7 +117,7 @@ void ScCellShell::Execute( SfxRequest& rReq ) ...@@ -118,7 +117,7 @@ void ScCellShell::Execute( SfxRequest& rReq )
case SID_COLLABORATION: case SID_COLLABORATION:
#ifdef ENABLE_TELEPATHY #ifdef ENABLE_TELEPATHY
tubes::createContacts( GetViewData()->GetDocShell()->GetCollaboration() ); GetViewData()->GetDocShell()->GetCollaboration()->DisplayContacts();
#endif #endif
break; break;
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
$(eval $(call gb_Package_Package,tubes_inc,$(SRCDIR)/tubes/inc)) $(eval $(call gb_Package_Package,tubes_inc,$(SRCDIR)/tubes/inc))
$(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/collaboration.hxx,tubes/collaboration.hxx)) $(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/collaboration.hxx,tubes/collaboration.hxx))
$(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/contacts.hxx,tubes/contacts.hxx))
$(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/manager.hxx,tubes/manager.hxx)) $(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/manager.hxx,tubes/manager.hxx))
$(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/tubesdllapi.h,tubes/tubesdllapi.h)) $(eval $(call gb_Package_add_file,tubes_inc,inc/tubes/tubesdllapi.h,tubes/tubesdllapi.h))
......
...@@ -21,6 +21,8 @@ typedef struct _TpContact TpContact; ...@@ -21,6 +21,8 @@ typedef struct _TpContact TpContact;
class TUBES_DLLPUBLIC Collaboration class TUBES_DLLPUBLIC Collaboration
{ {
TeleConference* mpConference; TeleConference* mpConference;
// This is in fact of type TubeContacts* from anonymous namespace
void* mpContacts;
public: public:
Collaboration(); Collaboration();
virtual ~Collaboration(); virtual ~Collaboration();
...@@ -33,6 +35,7 @@ public: ...@@ -33,6 +35,7 @@ public:
TUBES_DLLPRIVATE TeleConference* GetConference() const; TUBES_DLLPRIVATE TeleConference* GetConference() const;
TUBES_DLLPRIVATE sal_uInt64 GetId() const; TUBES_DLLPRIVATE sal_uInt64 GetId() const;
void DisplayContacts();
void SendFile( TpContact* pContact, const OUString& rURL ) const; void SendFile( TpContact* pContact, const OUString& rURL ) const;
void SendPacket( const OString& rPacket ) const; void SendPacket( const OString& rPacket ) const;
void SetConference( TeleConference* pConference ); void SetConference( TeleConference* pConference );
......
/* -*- 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 Michael Meeks <michael.meeks@suse.com> (initial developer)
*
* 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/config.h"
#include <tubes/tubesdllapi.h>
class Collaboration;
namespace tubes {
void TUBES_DLLPUBLIC createContacts( Collaboration* pCollaboration );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#define LIBO_TUBES_DBUS_PATH "/org/libreoffice/calc" #define LIBO_TUBES_DBUS_PATH "/org/libreoffice/calc"
namespace osl { class Mutex; } namespace osl { class Mutex; }
class Collaboration;
class ContactList; class ContactList;
class TeleConference; class TeleConference;
class TeleManagerImpl; class TeleManagerImpl;
...@@ -128,6 +129,11 @@ public: ...@@ -128,6 +129,11 @@ public:
/** Get a conference with current UUID to set a session. */ /** Get a conference with current UUID to set a session. */
TUBES_DLLPUBLIC static TeleConference* getConference(); TUBES_DLLPUBLIC static TeleConference* getConference();
static void registerCollaboration( Collaboration* pCollaboration );
static void unregisterCollaboration( Collaboration* pCollaboration );
/** Display contact list dialog for all documents. */
static void displayAllContacts();
static void registerDemoConference( TeleConference* pConference ); static void registerDemoConference( TeleConference* pConference );
static void unregisterDemoConference( TeleConference* pConference ); static void unregisterDemoConference( TeleConference* pConference );
/** Broadcast packet to all conferences. Used for demo mode. */ /** Broadcast packet to all conferences. Used for demo mode. */
......
...@@ -10,13 +10,18 @@ ...@@ -10,13 +10,18 @@
#include <tubes/collaboration.hxx> #include <tubes/collaboration.hxx>
#include <tubes/conference.hxx> #include <tubes/conference.hxx>
#include <tubes/manager.hxx>
Collaboration::Collaboration() Collaboration::Collaboration() :
mpConference( NULL ),
mpContacts( NULL )
{ {
TeleManager::registerCollaboration( this );
} }
Collaboration::~Collaboration() Collaboration::~Collaboration()
{ {
TeleManager::unregisterCollaboration( this );
if (mpConference) if (mpConference)
mpConference->close(); mpConference->close();
} }
......
...@@ -101,16 +101,13 @@ bool tb_contact_is_online( TpContact *contact ) ...@@ -101,16 +101,13 @@ bool tb_contact_is_online( TpContact *contact )
return tb_presence_is_online (tp_contact_get_presence_type (contact)); return tb_presence_is_online (tp_contact_get_presence_type (contact));
} }
namespace tubes {
void reDrawAllContacts();
}
static void presence_changed_cb( TpContact* /* contact */, static void presence_changed_cb( TpContact* /* contact */,
guint /* type */, guint /* type */,
gchar* /* status */, gchar* /* status */,
gchar* /* message */, gchar* /* message */,
gpointer /* pContactList*/ ) gpointer /* pContactList*/ )
{ {
tubes::reDrawAllContacts(); TeleManager::displayAllContacts();
} }
AccountContactPairV ContactList::getContacts() AccountContactPairV ContactList::getContacts()
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <tubes/conference.hxx> #include <tubes/conference.hxx>
#include <tubes/collaboration.hxx> #include <tubes/collaboration.hxx>
#include <tubes/contact-list.hxx> #include <tubes/contact-list.hxx>
#include <tubes/contacts.hxx>
#include <tubes/manager.hxx> #include <tubes/manager.hxx>
#include <unotools/confignode.hxx> #include <unotools/confignode.hxx>
#include <vcl/fixed.hxx> #include <vcl/fixed.hxx>
...@@ -282,34 +281,13 @@ IMPL_LINK_NOARG( TubeContacts, BtnListenHdl ) ...@@ -282,34 +281,13 @@ IMPL_LINK_NOARG( TubeContacts, BtnListenHdl )
return 0; return 0;
} }
// Mapping contacts dialog instance for each document
typedef std::map< sal_uInt64, TubeContacts* > DialogsMap;
static DialogsMap aDialogsMap;
TubeContacts* ContactsFactory( Collaboration* pCollaboration )
{
sal_uInt64 Id = pCollaboration->GetId();
if (aDialogsMap.find( Id ) == aDialogsMap.end())
aDialogsMap[ Id ] = new TubeContacts( pCollaboration );
return aDialogsMap[ Id ];
}
} // anonymous namespace } // anonymous namespace
namespace tubes { void Collaboration::DisplayContacts()
void createContacts( Collaboration* pCollaboration )
{ {
TubeContacts* pContacts = ContactsFactory( pCollaboration ); if (!mpContacts)
pContacts->Populate(); mpContacts = new TubeContacts( this );
} reinterpret_cast<TubeContacts*> (mpContacts)->Populate();
void reDrawAllContacts()
{
for (DialogsMap::const_iterator it = aDialogsMap.begin();
it != aDialogsMap.end(); ++it)
it->second->Populate();
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -103,6 +103,8 @@ public: ...@@ -103,6 +103,8 @@ public:
MapStringConference maAcceptedConferences; MapStringConference maAcceptedConferences;
typedef std::set< TeleConference* > DemoConferences; typedef std::set< TeleConference* > DemoConferences;
DemoConferences maDemoConferences; DemoConferences maDemoConferences;
typedef std::set< Collaboration* > Collaborations;
Collaborations maCollaborations;
TeleManagerImpl(); TeleManagerImpl();
~TeleManagerImpl(); ~TeleManagerImpl();
...@@ -225,6 +227,23 @@ TeleConference* TeleManager::getConference() ...@@ -225,6 +227,23 @@ TeleConference* TeleManager::getConference()
return pConference; return pConference;
} }
void TeleManager::registerCollaboration( Collaboration* pCollaboration )
{
pImpl->maCollaborations.insert( pCollaboration );
}
void TeleManager::unregisterCollaboration( Collaboration* pCollaboration )
{
pImpl->maCollaborations.erase( pCollaboration );
}
void TeleManager::displayAllContacts()
{
for (TeleManagerImpl::Collaborations::iterator it = pImpl->maCollaborations.begin();
it != pImpl->maCollaborations.end(); ++it)
(*it)->DisplayContacts();
}
void TeleManager::registerDemoConference( TeleConference* pConference ) void TeleManager::registerDemoConference( TeleConference* pConference )
{ {
pImpl->maDemoConferences.insert( pConference ); pImpl->maDemoConferences.insert( pConference );
......
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