summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@gmail.com>2012-07-20 21:31:30 +0200
committerMatúš Kukan <matus.kukan@gmail.com>2012-07-24 13:51:10 +0200
commitb12954531953fb8ad585847fe42677d714991ef1 (patch)
tree27a93059da4a0e36fb19af6545f46d0fd083be60 /sc
parent22d551b3f636c15468e9411b93872f7ab3aecdea (diff)
tubes: init TeleManager in desktop
- register clients when we run --invisible - create ScDocFuncSend only if we are going to use it Change-Id: I7e33cd5a2e42e34a055146dc6c2bdac3657d6529
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/collab/contacts.cxx89
1 files changed, 39 insertions, 50 deletions
diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx
index 84f73e160530..5ade483c016f 100644
--- a/sc/source/ui/collab/contacts.cxx
+++ b/sc/source/ui/collab/contacts.cxx
@@ -55,7 +55,6 @@ class TubeContacts : public ModelessDialog
SvxSimpleTableContainer maListContainer;
SvxSimpleTable maList;
TeleManager* mpManager;
- ScDocFuncSend* mpSender;
DECL_LINK( BtnConnectHdl, void * );
DECL_LINK( BtnGroupHdl, void * );
@@ -71,35 +70,53 @@ class TubeContacts : public ModelessDialog
};
boost::ptr_vector<AccountContact> maACs;
+ ScDocFuncSend* GetScDocFuncSendInCurrentSfxObjectShell()
+ {
+ ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current());
+ ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL;
+ return dynamic_cast<ScDocFuncSend*> (pDocFunc);
+ }
+
+ ScDocFuncSend* EnsureScDocFuncSendInCurrentSfxObjectShell()
+ {
+ ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current());
+ ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL;
+ ScDocFuncSend *pSender = dynamic_cast<ScDocFuncSend*> (pDocFunc);
+ if (!pSender)
+ {
+ // This means pDocFunc has to be ScDocFuncDirect* and we are not collaborating yet.
+ ScDocFuncDirect *pDirect = dynamic_cast<ScDocFuncDirect*> (pDocFunc);
+ ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect );
+ pSender = new ScDocFuncSend( *pScDocShell, pReceiver );
+ pScDocShell->SetDocFunc( pSender );
+ }
+ return pSender;
+ }
+
void Invite()
{
AccountContact *pAC = NULL;
if (maList.FirstSelected())
pAC = static_cast<AccountContact*> (maList.FirstSelected()->GetUserData());
- if (pAC && mpSender->GetConference())
+ if (pAC)
{
- TpContact* pContact = pAC->mpContact;
- fprintf( stderr, "inviting %s\n", tp_contact_get_identifier( pContact ) );
- mpSender->GetConference()->invite( pContact );
+ ScDocFuncSend *pSender = GetScDocFuncSendInCurrentSfxObjectShell();
+ if (pSender && pSender->GetConference())
+ {
+ TpContact* pContact = pAC->mpContact;
+ pSender->GetConference()->invite( pContact );
+ }
}
}
void Listen()
{
- if (!mpManager)
- return ;
-
if (!mpManager->registerClients())
- {
- fprintf( stderr, "Could not register client handlers.\n" );
- }
+ SAL_INFO( "sc.tubes", "Could not register client handlers." );
}
void StartBuddySession()
{
- if (!mpManager)
- return ;
-
AccountContact *pAC = NULL;
if (maList.FirstSelected())
pAC = static_cast<AccountContact*> (maList.FirstSelected()->GetUserData());
@@ -114,8 +131,9 @@ class TubeContacts : public ModelessDialog
tp_contact_get_identifier( pContact ) );
else
{
- mpSender->SetCollaboration( pConference );
- mpSender->SendFile( OStringToOUString(
+ ScDocFuncSend* pSender = EnsureScDocFuncSendInCurrentSfxObjectShell();
+ pSender->SetCollaboration( pConference );
+ pSender->SendFile( OStringToOUString(
pConference->getUuid(), RTL_TEXTENCODING_UTF8 ) );
}
}
@@ -123,9 +141,6 @@ class TubeContacts : public ModelessDialog
void StartGroupSession()
{
- if (!mpManager)
- return ;
-
AccountContact *pAC = NULL;
if (maList.FirstSelected())
pAC = static_cast<AccountContact*> (maList.FirstSelected()->GetUserData());
@@ -138,7 +153,10 @@ class TubeContacts : public ModelessDialog
if (!pConference)
fprintf( stderr, "could not start group session\n" );
else
- mpSender->SetCollaboration( pConference );
+ {
+ ScDocFuncSend* pSender = EnsureScDocFuncSendInCurrentSfxObjectShell();
+ pSender->SetCollaboration( pConference );
+ }
}
}
@@ -155,32 +173,6 @@ public:
mpManager( TeleManager::get() )
{
Hide();
- ScDocShell *pScDocShell = dynamic_cast<ScDocShell*> (SfxObjectShell::Current());
- ScDocFunc *pDocFunc = pScDocShell ? &pScDocShell->GetDocFunc() : NULL;
- mpSender = dynamic_cast<ScDocFuncSend*> (pDocFunc);
- if (!mpSender)
- {
- // This means pDocFunc has to be ScDocFuncDirect* and we are not collaborating yet.
- ScDocFuncDirect *pDirect = dynamic_cast<ScDocFuncDirect*> (pDocFunc);
- ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect );
- mpSender = new ScDocFuncSend( *pScDocShell, pReceiver );
- pScDocShell->SetDocFunc( mpSender );
-
- // FIXME: Who should really own TeleManager and where it can be destroyed ?
- // Take reference, so TeleManager does not get destroyed after closing dialog:
- mpManager = TeleManager::get();
-
- if (mpManager->createAccountManager())
- {
- mpManager->prepareAccountManager();
- }
- else
- {
- fprintf( stderr, "Could not create AccountManager.\n" );
- mpManager->unref();
- mpManager = NULL;
- }
- }
maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) );
maBtnGroup.SetClickHdl( LINK( this, TubeContacts, BtnGroupHdl ) );
maBtnInvite.SetClickHdl( LINK( this, TubeContacts, BtnInviteHdl ) );
@@ -201,8 +193,7 @@ public:
}
virtual ~TubeContacts()
{
- if (mpManager)
- mpManager->unref();
+ mpManager->unref();
}
static rtl::OUString fromUTF8( const char *pStr )
@@ -213,8 +204,6 @@ public:
void Populate()
{
- if (!mpManager)
- return ;
ContactList *pContacts = mpManager->getContactList();
if ( pContacts )
{