[Libreoffice-commits] core.git: 9 commits - sd/inc sd/source
Andrzej Hunt
andrzej.hunt at collabora.com
Sun Jun 29 22:45:33 PDT 2014
sd/inc/glob.hrc | 2
sd/source/core/glob.src | 5
sd/source/ui/dlg/RemoteDialog.cxx | 14 -
sd/source/ui/dlg/RemoteDialogClientBox.cxx | 196 ++++++++++-------
sd/source/ui/dlg/RemoteDialogClientBox.hxx | 16 -
sd/source/ui/inc/RemoteServer.hxx | 20 +
sd/source/ui/remotecontrol/Server.cxx | 77 +++++-
sd/source/ui/slidesorter/controller/SlsSlotManager.cxx | 13 +
sd/source/ui/view/outlnvs2.cxx | 11
9 files changed, 240 insertions(+), 114 deletions(-)
New commits:
commit a4decedeb6dc15e2bbd26217ed9f49903847fa3c
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Mon Jun 30 07:42:21 2014 +0200
Impress Remote Dialog: avoid flickering when device selected.
Changing visibility of items (i.e. the pin box / deauthorise button)
whilst painting the ClientBox can cause extra Paint request to be fired,
essentially resulting in an infinite loop (although slightly slowed
down by going through a VCL timer). These repeated paints (and repeated
hide/showing) of items resulted in a rather ugly flickering, which
is now gone.
Change-Id: Ib6b22dd1b08f3be5d1f543cfbb27a1ed782b5720
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.cxx b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
index f651457..f59347b 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.cxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
@@ -84,7 +84,6 @@ ClientBox::ClientBox( Window* pParent, WinBits nStyle ) :
m_aDeauthoriseButton.SetText( SD_RESSTR(STR_DEAUTHORISE_CLIENT) );
m_aDeauthoriseButton.SetClickHdl( LINK( this, ClientBox, DeauthoriseHdl ) );
- SetPaintTransparent( true );
SetPosPixel( Point( RSC_SP_DLG_INNERBORDER_LEFT, RSC_SP_DLG_INNERBORDER_TOP ) );
long nIconHeight = 2*TOP_OFFSET + SMALL_ICON_SIZE;
long nTitleHeight = 2*TOP_OFFSET + GetTextHeight();
@@ -245,15 +244,30 @@ void ClientBox::selectEntry( const long nPos )
}
}
+ // We empty the pin box now too, just in case the user previously
+ // entered a pin, but then changed their selected device.
+ m_aPinBox.SetText( "" );
+ if ( m_bHasActive )
+ {
+ bool bAlreadyAuthorised =
+ m_vEntries[ m_nActive ]->m_pClientInfo->mbIsAlreadyAuthorised;
+
+ if ( bAlreadyAuthorised )
+ {
+ m_aDeauthoriseButton.GetFocus();
+ }
+ else
+ {
+ m_aPinBox.GetFocus();
+ }
+ }
+
if ( IsReallyVisible() )
{
m_bNeedsRecalc = true;
Invalidate();
}
- // We empty the pin box now too, just in case the user previously
- // entered a pin, but then changed their selected device.
- m_aPinBox.SetText( "" );
guard.clear();
}
@@ -317,43 +331,9 @@ void ClientBox::DrawRow( const Rectangle& rRect, const TClientBoxEntry pEntry )
aPos.Y() += aTextHeight;
if ( pEntry->m_bActive )
{
- Size aSize = LogicToPixel( Size( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ),
- MapMode( MAP_APPFONT ) );
- m_aPinBox.SetSizePixel( aSize );
- m_aDeauthoriseButton.SetSizePixel( m_aDeauthoriseButton.GetOptimalSize() );
- const Rectangle aRect( GetEntryRect( m_nActive ) );
- Size aBtnSize( m_aPinBox.GetSizePixel() );
- Point aBtnPos( aRect.Left(),
- aRect.Bottom() - TOP_OFFSET - aBtnSize.Height() );
-
- bool bAlreadyAuthorised = pEntry->m_pClientInfo->mbIsAlreadyAuthorised;
-
- if ( !bAlreadyAuthorised )
- {
- OUString sPinText(SD_RESSTR(STR_ENTER_PIN));
- DrawText( Rectangle( aBtnPos.X(), aBtnPos.Y(), rRect.Right(), rRect.Bottom() - TOP_OFFSET),
- sPinText, 0 );
-
- aBtnPos = Point( aRect.Left() + GetTextWidth( sPinText ),
- aRect.Bottom() - TOP_OFFSET - aBtnSize.Height() );
- }
- m_aPinBox.SetPosPixel( aBtnPos );
- m_aPinBox.Show( !bAlreadyAuthorised );
-
- aBtnPos.Move( 20, 0 );
- m_aDeauthoriseButton.SetPosPixel( aBtnPos );
- m_aDeauthoriseButton.Show( bAlreadyAuthorised );
- if ( bAlreadyAuthorised )
- {
- m_aDeauthoriseButton.GetFocus();
- }
- else
- {
- m_aPinBox.GetFocus();
- }
- }
- else
- {
+ OUString sPinText(SD_RESSTR(STR_ENTER_PIN));
+ DrawText( m_sPinTextRect,
+ sPinText, 0 );
}
SetLineColor( Color( COL_LIGHTGRAY ) );
@@ -367,10 +347,48 @@ void ClientBox::RecalcAll()
SetupScrollBar();
- if ( m_bHasActive )
+ Size aPBSize = LogicToPixel(
+ Size( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ),
+ MapMode( MAP_APPFONT ) );
+ m_aPinBox.SetSizePixel( aPBSize );
+ m_aDeauthoriseButton.SetSizePixel( m_aDeauthoriseButton.GetOptimalSize() );
+
+ if ( !m_bHasActive )
+ {
+ m_aPinBox.Show( false );
+ m_aDeauthoriseButton.Show( false );
+ }
+ else
{
Rectangle aEntryRect = GetEntryRect( m_nActive );
+ Size aPinBoxSize( m_aPinBox.GetSizePixel() );
+ Point aPos( aEntryRect.Left(),
+ aEntryRect.Bottom() - TOP_OFFSET - aPinBoxSize.Height() );
+
+ bool bAlreadyAuthorised = m_vEntries[ m_nActive ]->m_pClientInfo->mbIsAlreadyAuthorised;
+
+ if ( !bAlreadyAuthorised )
+ {
+ m_sPinTextRect = Rectangle( aPos.X(), aPos.Y(),
+ aEntryRect.Right(),
+ aEntryRect.Bottom() - TOP_OFFSET);
+
+ OUString sPinText(SD_RESSTR(STR_ENTER_PIN));
+
+ aPos = Point( aEntryRect.Left() + GetTextWidth( sPinText ),
+ aEntryRect.Bottom() - TOP_OFFSET - aPinBoxSize.Height() );
+ m_aPinBox.SetPosPixel( aPos );
+ }
+ else
+ {
+ aPos += Point( 20, 0 );
+ m_aDeauthoriseButton.SetPosPixel( aPos );
+ }
+
+ m_aPinBox.Show( !bAlreadyAuthorised );
+ m_aDeauthoriseButton.Show( bAlreadyAuthorised );
+
if ( m_bAdjustActive )
{
m_bAdjustActive = false;
@@ -475,15 +493,6 @@ void ClientBox::Paint( const Rectangle &/*rPaintRect*/ )
const ::osl::MutexGuard aGuard( m_entriesMutex );
- // It's easiest to disbale these and only reenable as appropriate in DrawRow
- // -- both are shown in only certain situations, and e.g. if we've removed
- // the last entry then the visibility of the deauthorise button won't be
- // changed in the loop below, or when we select 0 entries then we
- // won't run through the appropriate conditions which would otherwise
- // set the visibility of the pin-box.
- m_aDeauthoriseButton.Show( false );
- m_aPinBox.Show( false );
-
typedef std::vector< TClientBoxEntry >::iterator ITER;
for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex )
{
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.hxx b/sd/source/ui/dlg/RemoteDialogClientBox.hxx
index 1d07cbd..bcbf621 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.hxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.hxx
@@ -103,6 +103,7 @@ class ClientBox:
NumericBox m_aPinBox;
PushButton m_aDeauthoriseButton;
+ Rectangle m_sPinTextRect;
ScrollBar m_aScrollBar;
commit 580b1890d8985d4248b1d5d783ad379d64e82259
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Sat Jun 28 14:45:09 2014 +0200
Allow removal of remotes even if Server not running.
This is purely config manipulation so shouldn't rely on having
the Server actually running (e.g. if disabled, and/or if network
setup failed).
Change-Id: Ifc6e5639ba6842a18eb0be99387a5f8dd871da06
diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx
index 8133537..d80b846 100644
--- a/sd/source/ui/remotecontrol/Server.cxx
+++ b/sd/source/ui/remotecontrol/Server.cxx
@@ -239,16 +239,16 @@ std::vector< ::boost::shared_ptr< ClientInfo > > RemoteServer::getClients()
{
SAL_INFO( "sdremote", "RemoteServer::getClients() called" );
std::vector< ::boost::shared_ptr< ClientInfo > > aClients;
- if ( !spServer )
+ if ( spServer )
{
- SAL_INFO( "sdremote", "No remote server instance => no clients" );
- return aClients;
+ MutexGuard aGuard( sDataMutex );
+ aClients.assign( spServer->mAvailableClients.begin(),
+ spServer->mAvailableClients.end() );
+ }
+ else
+ {
+ SAL_INFO( "sdremote", "No remote server instance => no remote clients" );
}
-
- MutexGuard aGuard( sDataMutex );
- aClients.assign( spServer->mAvailableClients.begin(),
- spServer->mAvailableClients.end() );
-
// We also need to provide authorised clients (no matter whether or not
// they are actually available), so that they can be de-authorised if
// necessary. We specifically want these to be at the end of the list
@@ -342,8 +342,6 @@ void RemoteServer::deauthoriseClient( ::boost::shared_ptr< ClientInfo > pClient
// the UI.
SAL_INFO( "sdremote", "RemoteServer::deauthoriseClient called" );
- if ( !spServer )
- return;
if ( !pClient->mbIsAlreadyAuthorised )
// We can't remove unauthorised clients from the authorised list...
commit d61468314bbfd2a79929b48e62d7e5ed354ab79b
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 27 18:20:14 2014 +0200
fdo#63378 Enable Impress Remote Dialog menu item for all view shells.
Change-Id: I47f040c1463b4be648d411c2f7f0070b8aed3e9c
diff --git a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
index 5194360..9bf97ee 100644
--- a/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
+++ b/sd/source/ui/slidesorter/controller/SlsSlotManager.cxx
@@ -276,6 +276,19 @@ void SlotManager::FuTemporary (SfxRequest& rRequest)
}
break;
+ case SID_REMOTE_DLG:
+ {
+#ifdef ENABLE_SDREMOTE
+ SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
+ VclAbstractDialog* pDlg = pFact ?
+ pFact->CreateRemoteDialog( mrSlideSorter.GetContentWindow().get() ) :
+ 0;
+ if (pDlg)
+ pDlg->Execute();
+#endif
+ }
+ break;
+
default:
break;
}
diff --git a/sd/source/ui/view/outlnvs2.cxx b/sd/source/ui/view/outlnvs2.cxx
index f916b8f..7ad626c 100644
--- a/sd/source/ui/view/outlnvs2.cxx
+++ b/sd/source/ui/view/outlnvs2.cxx
@@ -285,6 +285,17 @@ void OutlineViewShell::FuTemporary(SfxRequest &rReq)
}
break;
+ case SID_REMOTE_DLG:
+ {
+#ifdef ENABLE_SDREMOTE
+ SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
+ VclAbstractDialog* pDlg = pFact ? pFact->CreateRemoteDialog(GetActiveWindow()) : 0;
+ if (pDlg)
+ pDlg->Execute();
+#endif
+ }
+ break;
+
case SID_CUSTOMSHOW_DLG:
{
SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
commit eba630ca1689d65d6f58c0e6bd7658cc6eac8dcc
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 27 17:53:07 2014 +0200
Remote Dialog: give focus to pin entry when item selected.
Change-Id: I5718a5b881a32ecf4cebdbd6a682097119c26837
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.cxx b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
index 69c0b0c..f651457 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.cxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
@@ -343,6 +343,14 @@ void ClientBox::DrawRow( const Rectangle& rRect, const TClientBoxEntry pEntry )
aBtnPos.Move( 20, 0 );
m_aDeauthoriseButton.SetPosPixel( aBtnPos );
m_aDeauthoriseButton.Show( bAlreadyAuthorised );
+ if ( bAlreadyAuthorised )
+ {
+ m_aDeauthoriseButton.GetFocus();
+ }
+ else
+ {
+ m_aPinBox.GetFocus();
+ }
}
else
{
commit a17737ef45af66b1f86759c02005c28d5585d534
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 27 17:53:02 2014 +0200
Remote Dialog: make sure pin box is empty.
The only way to do this seems to be setting an empty string --
using clear, or setting 0, results in a 0 being shown, which is
rather ugly and unintuitive.
Change-Id: Ic641c4fcecd634b7fff397989ee0b079239ea44c
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.cxx b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
index 47769d2..69c0b0c 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.cxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
@@ -251,6 +251,9 @@ void ClientBox::selectEntry( const long nPos )
Invalidate();
}
+ // We empty the pin box now too, just in case the user previously
+ // entered a pin, but then changed their selected device.
+ m_aPinBox.SetText( "" );
guard.clear();
}
@@ -333,7 +336,6 @@ void ClientBox::DrawRow( const Rectangle& rRect, const TClientBoxEntry pEntry )
aBtnPos = Point( aRect.Left() + GetTextWidth( sPinText ),
aRect.Bottom() - TOP_OFFSET - aBtnSize.Height() );
-
}
m_aPinBox.SetPosPixel( aBtnPos );
m_aPinBox.Show( !bAlreadyAuthorised );
commit 3c5223b232992b7c49c4827d69bc54366c7a3f48
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 27 17:46:41 2014 +0200
Make sure pin box and deauth button hidden when no items selected.
Change-Id: I650191b9b092a3562c7bfcdfe40ac4968d18ae36
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.cxx b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
index c8e0f99..47769d2 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.cxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
@@ -465,14 +465,14 @@ void ClientBox::Paint( const Rectangle &/*rPaintRect*/ )
const ::osl::MutexGuard aGuard( m_entriesMutex );
- // If we have just removed the last entry (via deauthorise)
- // then we need to make sure we hide the button (usually
- // this would all be dealt with in in DrawRow, but that
- // won't be called for 0 items).
- if ( m_vEntries.size() == 0 )
- {
- m_aDeauthoriseButton.Show( false );
- }
+ // It's easiest to disbale these and only reenable as appropriate in DrawRow
+ // -- both are shown in only certain situations, and e.g. if we've removed
+ // the last entry then the visibility of the deauthorise button won't be
+ // changed in the loop below, or when we select 0 entries then we
+ // won't run through the appropriate conditions which would otherwise
+ // set the visibility of the pin-box.
+ m_aDeauthoriseButton.Show( false );
+ m_aPinBox.Show( false );
typedef std::vector< TClientBoxEntry >::iterator ITER;
for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex )
commit a4620e23cec01169995ec7bc056c51295a4f9907
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 27 15:32:57 2014 +0200
Kill some unused/commented code.
These are various remainders of the extension dialog that this
dialog was originall based on.
Change-Id: I564dd371b7d58322cc3ef03c7401151f3098f333
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.cxx b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
index 43ee394..c8e0f99 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.cxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
@@ -49,8 +49,6 @@ ClientBoxEntry::ClientBoxEntry( ::boost::shared_ptr<ClientInfo> pClientInfo ) :
ClientBoxEntry::~ClientBoxEntry()
{}
-// ClientRemovedListener
-
void ClientRemovedListener::disposing( lang::EventObject const & rEvt )
throw ( uno::RuntimeException, std::exception )
{
@@ -96,10 +94,6 @@ ClientBox::ClientBox( Window* pParent, WinBits nStyle ) :
m_nStdHeight = nIconHeight;
m_nStdHeight += GetTextHeight() + TOP_OFFSET;
-// nIconHeight = ICON_HEIGHT + 2*TOP_OFFSET + 1;
-// if ( m_nStdHeight < nIconHeight )
-// m_nStdHeight = nIconHeight;
-
m_nActiveHeight = m_nStdHeight;
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
@@ -136,13 +130,6 @@ ClientBox::~ClientBox()
m_bInDelete = true;
- typedef std::vector< TClientBoxEntry >::iterator ITER;
-
- for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex )
- {
-// (*iIndex)->m_xPackage->removeEventListener( uno::Reference< lang::XEventListener > ( m_xRemoveListener, uno::UNO_QUERY ) );
- }
-
m_vEntries.clear();
m_xRemoveListener.clear();
@@ -295,17 +282,6 @@ void ClientBox::DrawRow( const Rectangle& rRect, const TClientBoxEntry pEntry )
// FIXME: draw bluetooth or wifi icon
Point aPos( rRect.TopLeft() );
-// aPos += Point( TOP_OFFSET, TOP_OFFSET );
-// Image aImage;
-// if ( ! pEntry->m_aIcon )
-// aImage = m_aDefaultImage;
-// else
-// aImage = pEntry->m_aIcon;
-// Size aImageSize = aImage.GetSizePixel();
-// if ( ( aImageSize.Width() <= ICON_WIDTH ) && ( aImageSize.Height() <= ICON_HEIGHT ) )
-// DrawImage( Point( aPos.X()+((ICON_WIDTH-aImageSize.Width())/2), aPos.Y()+((ICON_HEIGHT-aImageSize.Height())/2) ), aImage );
-// else
-// DrawImage( aPos, Size( ICON_WIDTH, ICON_HEIGHT ), aImage );
// Setup fonts
Font aStdFont( GetFont() );
@@ -365,14 +341,6 @@ void ClientBox::DrawRow( const Rectangle& rRect, const TClientBoxEntry pEntry )
aBtnPos.Move( 20, 0 );
m_aDeauthoriseButton.SetPosPixel( aBtnPos );
m_aDeauthoriseButton.Show( bAlreadyAuthorised );
-
-// long nExtraHeight = 0;
-
-// if ( pEntry->m_bHasButtons )
-// nExtraHeight = m_nExtraHeight;
-
-// DrawText( Rectangle( aPos.X(), aPos.Y(), rRect.Right(), rRect.Bottom() - nExtraHeight ),
-// sDescription, TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
}
else
{
@@ -644,8 +612,6 @@ bool ClientBox::Notify( NotifyEvent& rNEvt )
long ClientBox::addEntry( ::boost::shared_ptr<ClientInfo> pClientInfo )
{
long nPos = 0;
-// PackageState eState = m_pManager->getPackageState( xPackage );
-// bool bLocked = m_pManager->isReadOnly( xPackage );
TClientBoxEntry pEntry( new ClientBoxEntry( pClientInfo ) );
@@ -670,23 +636,6 @@ long ClientBox::addEntry( ::boost::shared_ptr<ClientInfo> pClientInfo )
// }
}
- //Related: rhbz#702833 Only add a Listener if we're adding a new entry, to
- //keep in sync with removeEventListener logic
- if (bNewEntryInserted)
- {
-
- // pEntry->m_xPackage->addEventListener(uno::Reference< lang::XEventListener > ( m_xRemoveListener, uno::UNO_QUERY ) );
- }
-
-// pEntry->m_bHasOptions = m_pManager->supportsOptions( xPackage );
-// pEntry->m_bUser = xPackage->getRepositoryName().equals( USER_PACKAGE_MANAGER );
-// pEntry->m_bShared = xPackage->getRepositoryName().equals( SHARED_PACKAGE_MANAGER );
-// pEntry->m_bNew = m_bInCheckMode;
-// pEntry->m_bMissingLic = bLicenseMissing;
-
-// if ( bLicenseMissing )
-// pEntry->m_sErrorText = DialogHelper::getResourceString( RID_STR_ERROR_MISSING_LICENSE );
-
//access to m_nActive must be guarded
if ( !m_bInCheckMode && m_bHasActive && ( m_nActive >= nPos ) )
m_nActive += 1;
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.hxx b/sd/source/ui/dlg/RemoteDialogClientBox.hxx
index 0be1606..1d07cbd 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.hxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.hxx
@@ -159,8 +159,6 @@ public:
void selectEntry( const long nPos );
long addEntry( ::boost::shared_ptr<ClientInfo> pClientInfo );
- void updateEntry( const ::boost::shared_ptr<ClientInfo> pPackageInfo );
- void removeEntry( const ::boost::shared_ptr<ClientInfo> pPackageInfo );
void clearEntries();
void prepareChecking();
commit 6216eee4b94cace7984eb12dbad26fa91a5de94f
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 27 15:25:31 2014 +0200
Impress Remote: allow removal of authorised remotes.
Previously authorising a device meant that it would have access
forever -- we now list previously authorised remotes in the remote
dialog, along with controls to allow removal of such remotes.
Change-Id: I4179739f3a2ba0a8fe19c2a0cd0cbbece9cb4352
diff --git a/sd/inc/glob.hrc b/sd/inc/glob.hrc
index 3e2d4a4..f9fc89e 100644
--- a/sd/inc/glob.hrc
+++ b/sd/inc/glob.hrc
@@ -148,7 +148,7 @@
#define STR_SLIDE_TRANSITION_PANE RID_GLOB_START+228
#define RID_SLIDESORTER_ICONS RID_GLOB_START+227
-
+#define STR_DEAUTHORISE_CLIENT RID_GLOB_START+229
#endif // _SDGLOB_HRC
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/core/glob.src b/sd/source/core/glob.src
index bebd5d6..8bdd59e 100644
--- a/sd/source/core/glob.src
+++ b/sd/source/core/glob.src
@@ -453,4 +453,9 @@ String STR_ENTER_PIN
Text [ en-US ] = "Enter PIN:";
};
+String STR_DEAUTHORISE_CLIENT
+{
+ Text [ en-US ] = "Remove client authorisation";
+};
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/dlg/RemoteDialog.cxx b/sd/source/ui/dlg/RemoteDialog.cxx
index 4265bac..63edf44 100644
--- a/sd/source/ui/dlg/RemoteDialog.cxx
+++ b/sd/source/ui/dlg/RemoteDialog.cxx
@@ -25,20 +25,6 @@ RemoteDialog::RemoteDialog( Window *pWindow )
get(m_pButtonClose, "close");
get(m_pClientBox, "tree");
-#ifdef ENABLE_SDREMOTE
- RemoteServer::ensureDiscoverable();
-
- vector<::boost::shared_ptr<ClientInfo>> aClients( RemoteServer::getClients() );
-
- const vector<::boost::shared_ptr<ClientInfo>>::const_iterator aEnd( aClients.end() );
-
- for ( vector<::boost::shared_ptr<ClientInfo>>::const_iterator aIt( aClients.begin() );
- aIt != aEnd; ++aIt )
- {
- m_pClientBox->addEntry( *aIt );
- }
-#endif
-
m_pButtonConnect->SetClickHdl( LINK( this, RemoteDialog, HandleConnectButton ) );
SetCloseHdl( LINK( this, RemoteDialog, CloseHdl ) );
m_pButtonClose->SetClickHdl( LINK( this, RemoteDialog, CloseHdl ) );
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.cxx b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
index 22affdb..43ee394 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.cxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
@@ -17,6 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <vector>
+
#include "svtools/controldims.hrc"
#include "RemoteDialogClientBox.hxx"
@@ -30,6 +32,8 @@
#include "glob.hrc"
+using namespace std;
+
using namespace ::com::sun::star;
namespace sd {
@@ -72,12 +76,15 @@ ClientBox::ClientBox( Window* pParent, WinBits nStyle ) :
m_nActiveHeight( 0 ),
m_nExtraHeight( 2 ),
m_aPinBox( this, 0 ),
+ m_aDeauthoriseButton( this ),
m_aScrollBar( this, WB_VERT )
{
m_aScrollBar.SetScrollHdl( LINK( this, ClientBox, ScrollHdl ) );
m_aScrollBar.EnableDrag();
m_aPinBox.SetUseThousandSep(false);
+ m_aDeauthoriseButton.SetText( SD_RESSTR(STR_DEAUTHORISE_CLIENT) );
+ m_aDeauthoriseButton.SetClickHdl( LINK( this, ClientBox, DeauthoriseHdl ) );
SetPaintTransparent( true );
SetPosPixel( Point( RSC_SP_DLG_INNERBORDER_LEFT, RSC_SP_DLG_INNERBORDER_TOP ) );
@@ -103,6 +110,8 @@ ClientBox::ClientBox( Window* pParent, WinBits nStyle ) :
m_xRemoveListener = new ClientRemovedListener( this );
+ populateEntries();
+
Show();
}
@@ -332,18 +341,30 @@ void ClientBox::DrawRow( const Rectangle& rRect, const TClientBoxEntry pEntry )
Size aSize = LogicToPixel( Size( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ),
MapMode( MAP_APPFONT ) );
m_aPinBox.SetSizePixel( aSize );
+ m_aDeauthoriseButton.SetSizePixel( m_aDeauthoriseButton.GetOptimalSize() );
const Rectangle aRect( GetEntryRect( m_nActive ) );
Size aBtnSize( m_aPinBox.GetSizePixel() );
Point aBtnPos( aRect.Left(),
aRect.Bottom() - TOP_OFFSET - aBtnSize.Height() );
- OUString sPinText(SD_RESSTR(STR_ENTER_PIN));
- DrawText( Rectangle( aBtnPos.X(), aBtnPos.Y(), rRect.Right(), rRect.Bottom() - TOP_OFFSET),
- sPinText, 0 );
- aBtnPos = Point( aRect.Left() + GetTextWidth( sPinText ),
- aRect.Bottom() - TOP_OFFSET - aBtnSize.Height() );
+ bool bAlreadyAuthorised = pEntry->m_pClientInfo->mbIsAlreadyAuthorised;
+
+ if ( !bAlreadyAuthorised )
+ {
+ OUString sPinText(SD_RESSTR(STR_ENTER_PIN));
+ DrawText( Rectangle( aBtnPos.X(), aBtnPos.Y(), rRect.Right(), rRect.Bottom() - TOP_OFFSET),
+ sPinText, 0 );
+ aBtnPos = Point( aRect.Left() + GetTextWidth( sPinText ),
+ aRect.Bottom() - TOP_OFFSET - aBtnSize.Height() );
+
+ }
m_aPinBox.SetPosPixel( aBtnPos );
+ m_aPinBox.Show( !bAlreadyAuthorised );
+
+ aBtnPos.Move( 20, 0 );
+ m_aDeauthoriseButton.SetPosPixel( aBtnPos );
+ m_aDeauthoriseButton.Show( bAlreadyAuthorised );
// long nExtraHeight = 0;
@@ -476,6 +497,15 @@ void ClientBox::Paint( const Rectangle &/*rPaintRect*/ )
const ::osl::MutexGuard aGuard( m_entriesMutex );
+ // If we have just removed the last entry (via deauthorise)
+ // then we need to make sure we hide the button (usually
+ // this would all be dealt with in in DrawRow, but that
+ // won't be called for 0 items).
+ if ( m_vEntries.size() == 0 )
+ {
+ m_aDeauthoriseButton.Show( false );
+ }
+
typedef std::vector< TClientBoxEntry >::iterator ITER;
for ( ITER iIndex = m_vEntries.begin(); iIndex < m_vEntries.end(); ++iIndex )
{
@@ -671,6 +701,44 @@ long ClientBox::addEntry( ::boost::shared_ptr<ClientInfo> pClientInfo )
return nPos;
}
+void ClientBox::clearEntries()
+{
+ selectEntry( -1 );
+ m_bHasActive = false;
+
+ const ::osl::MutexGuard aGuard( m_entriesMutex );
+
+ m_vEntries.clear();
+ if ( IsReallyVisible() )
+ Invalidate();
+ m_bNeedsRecalc = true;
+}
+
+void ClientBox::populateEntries()
+{
+ const ::osl::MutexGuard aGuard( m_entriesMutex );
+
+ clearEntries();
+
+#ifdef ENABLE_SDREMOTE
+ RemoteServer::ensureDiscoverable();
+
+ vector<::boost::shared_ptr<ClientInfo>> aClients( RemoteServer::getClients() );
+
+ const vector<::boost::shared_ptr<ClientInfo>>::const_iterator aEnd( aClients.end() );
+
+ for ( vector<::boost::shared_ptr<ClientInfo>>::const_iterator aIt( aClients.begin() );
+ aIt != aEnd; ++aIt )
+ {
+ addEntry( *aIt );
+ }
+#endif
+
+ if ( IsReallyVisible() )
+ Invalidate();
+ m_bNeedsRecalc = true;
+}
+
void ClientBox::DoScroll( long nDelta )
{
m_nTopIndex += nDelta;
@@ -690,6 +758,20 @@ IMPL_LINK( ClientBox, ScrollHdl, ScrollBar*, pScrBar )
return 1;
}
+IMPL_LINK_NOARG( ClientBox, DeauthoriseHdl )
+{
+ long aSelected = GetActiveEntryIndex();
+ if ( aSelected < 0 )
+ return 1;
+ TClientBoxEntry aEntry = GetEntryData(aSelected);
+
+#ifdef ENABLE_SDREMOTE
+ RemoteServer::deauthoriseClient( aEntry->m_pClientInfo );
+#endif
+ populateEntries();
+ return 1;
+}
+
} //namespace dp_gui
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.hxx b/sd/source/ui/dlg/RemoteDialogClientBox.hxx
index 83295f2..0be1606 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.hxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.hxx
@@ -23,6 +23,7 @@
#include "rtl/ustring.hxx"
#include "vcl/scrbar.hxx"
#include "vcl/fixed.hxx"
+#include "vcl/button.hxx"
#include "vcl/dialog.hxx"
#include "vcl/field.hxx"
@@ -98,8 +99,10 @@ class ClientBox:
long m_nExtraHeight;
Size m_aOutputSize;
Link m_aClickHdl;
+ Link m_aDeauthoriseHdl;
NumericBox m_aPinBox;
+ PushButton m_aDeauthoriseButton;
ScrollBar m_aScrollBar;
@@ -125,7 +128,7 @@ class ClientBox:
void DeleteRemoved();
DECL_DLLPRIVATE_LINK( ScrollHdl, ScrollBar* );
-
+ DECL_DLLPRIVATE_LINK( DeauthoriseHdl, void * );
//Index starts with 1.
//Throws an com::sun::star::lang::IllegalArgumentException, when the index is invalid.
void checkIndex(sal_Int32 pos) const;
@@ -158,11 +161,13 @@ public:
long addEntry( ::boost::shared_ptr<ClientInfo> pClientInfo );
void updateEntry( const ::boost::shared_ptr<ClientInfo> pPackageInfo );
void removeEntry( const ::boost::shared_ptr<ClientInfo> pPackageInfo );
+ void clearEntries();
void prepareChecking();
void checkEntries();
OUString getPin();
+ void populateEntries();
};
}
diff --git a/sd/source/ui/inc/RemoteServer.hxx b/sd/source/ui/inc/RemoteServer.hxx
index a17e984..91718f9 100644
--- a/sd/source/ui/inc/RemoteServer.hxx
+++ b/sd/source/ui/inc/RemoteServer.hxx
@@ -46,10 +46,15 @@ namespace sd
OUString mName;
OUString mAddress;
+ bool mbIsAlreadyAuthorised;
+
enum PROTOCOL { NETWORK = 1, BLUETOOTH };
- ClientInfo( const OUString& rName, const OUString& rAddress ) :
+ ClientInfo( const OUString& rName,
+ const OUString& rAddress,
+ const bool bIsAlreadyAuthorised ) :
mName( rName ),
- mAddress( rAddress ) {}
+ mAddress( rAddress ),
+ mbIsAlreadyAuthorised( bIsAlreadyAuthorised ) {}
virtual ~ClientInfo() {};
};
@@ -71,6 +76,7 @@ namespace sd
SD_DLLPUBLIC static std::vector< ::boost::shared_ptr< ClientInfo > > getClients();
SD_DLLPUBLIC static bool connectClient( ::boost::shared_ptr< ClientInfo > pClient,
const OUString& aPin );
+ SD_DLLPUBLIC static void deauthoriseClient( ::boost::shared_ptr< ClientInfo > pClient );
/// ensure that discoverability (eg. for Bluetooth) is enabled
SD_DLLPUBLIC static void ensureDiscoverable();
diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx
index 038fac6..8133537 100644
--- a/sd/source/ui/remotecontrol/Server.cxx
+++ b/sd/source/ui/remotecontrol/Server.cxx
@@ -54,9 +54,10 @@ namespace sd {
ClientInfoInternal( const OUString& rName,
const OUString& rAddress,
+ const bool bIsAlreadyAuthorised,
BufferedStreamSocket *pSocket,
const OUString& rPin ):
- ClientInfo( rName, rAddress ),
+ ClientInfo( rName, rAddress, bIsAlreadyAuthorised ),
mpStreamSocket( pSocket ),
mPin( rPin ) {}
};
@@ -127,8 +128,8 @@ void RemoteServer::execute()
::boost::shared_ptr< ClientInfoInternal > pClient(
new ClientInfoInternal(
OStringToOUString( aName, RTL_TEXTENCODING_UTF8 ),
- aAddress, pSocket, OStringToOUString( aPin,
- RTL_TEXTENCODING_UTF8 ) );
+ aAddress, false, pSocket, OStringToOUString( aPin,
+ RTL_TEXTENCODING_UTF8 ) ) );
mAvailableClients.push_back( pClient );
// Read off any additional non-empty lines
@@ -247,6 +248,23 @@ std::vector< ::boost::shared_ptr< ClientInfo > > RemoteServer::getClients()
MutexGuard aGuard( sDataMutex );
aClients.assign( spServer->mAvailableClients.begin(),
spServer->mAvailableClients.end() );
+
+ // We also need to provide authorised clients (no matter whether or not
+ // they are actually available), so that they can be de-authorised if
+ // necessary. We specifically want these to be at the end of the list
+ // since the user is more likely to be trying to connect a new remote
+ // than removing an existing remote.
+ // We can also be sure that pre-authorised clients will not be on the
+ // available clients list, as they get automatially connected if seen.
+ // TODO: we should probably add some sort of extra labelling to mark
+ // authorised AND connected client.
+ Reference< XNameAccess > const xConfig = officecfg::Office::Impress::Misc::AuthorisedRemotes::get();
+ Sequence< OUString > aNames = xConfig->getElementNames();
+ for ( int i = 0; i < aNames.getLength(); i++ )
+ {
+ aClients.push_back( ::boost::shared_ptr< ClientInfo > ( new ClientInfo( aNames[i], "", true ) ) );
+ }
+
return aClients;
}
@@ -257,7 +275,12 @@ bool RemoteServer::connectClient( ::boost::shared_ptr< ClientInfo > pClient, con
return false;
ClientInfoInternal* apClient = dynamic_cast< ClientInfoInternal* >( pClient.get() );
- ClientInfoInternal *apClient = (ClientInfoInternal*) pClient;
+ if ( !apClient )
+ // could happen if we try to "connect" an already authorised client
+ {
+ return false;
+ }
+
if ( apClient->mPin.equals( aPin ) )
{
// Save in settings first
@@ -312,6 +335,30 @@ bool RemoteServer::connectClient( ::boost::shared_ptr< ClientInfo > pClient, con
}
}
+void RemoteServer::deauthoriseClient( ::boost::shared_ptr< ClientInfo > pClient )
+{
+ // TODO: we probably want to forcefully disconnect at this point too?
+ // But possibly via a separate function to allow just disconnecting from
+ // the UI.
+
+ SAL_INFO( "sdremote", "RemoteServer::deauthoriseClient called" );
+ if ( !spServer )
+ return;
+
+ if ( !pClient->mbIsAlreadyAuthorised )
+ // We can't remove unauthorised clients from the authorised list...
+ {
+ return;
+ }
+
+ boost::shared_ptr< ConfigurationChanges > aChanges = ConfigurationChanges::create();
+ Reference< XNameContainer > const xConfig =
+ officecfg::Office::Impress::Misc::AuthorisedRemotes::get( aChanges );
+
+ xConfig->removeByName( pClient->mName );
+ aChanges->commit();
+}
+
void SdDLL::RegisterRemotes()
{
SAL_INFO( "sdremote", "SdDLL::RegisterRemotes called" );
commit f82c524f7615abc13adadca12ef27237ff3df4b7
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jun 27 12:09:01 2014 +0200
Move ClientInfo to shared_ptrs.
I don't think these ever get deleted anywhere? This changes will also
help in the management of existing clients (separate commit).
Change-Id: I339916439f6b798524fac33e91688f81c03a3ca5
diff --git a/sd/source/ui/dlg/RemoteDialog.cxx b/sd/source/ui/dlg/RemoteDialog.cxx
index fd2fe81..4265bac 100644
--- a/sd/source/ui/dlg/RemoteDialog.cxx
+++ b/sd/source/ui/dlg/RemoteDialog.cxx
@@ -28,11 +28,11 @@ RemoteDialog::RemoteDialog( Window *pWindow )
#ifdef ENABLE_SDREMOTE
RemoteServer::ensureDiscoverable();
- vector<ClientInfo*> aClients( RemoteServer::getClients() );
+ vector<::boost::shared_ptr<ClientInfo>> aClients( RemoteServer::getClients() );
- const vector<ClientInfo*>::const_iterator aEnd( aClients.end() );
+ const vector<::boost::shared_ptr<ClientInfo>>::const_iterator aEnd( aClients.end() );
- for ( vector<ClientInfo*>::const_iterator aIt( aClients.begin() );
+ for ( vector<::boost::shared_ptr<ClientInfo>>::const_iterator aIt( aClients.begin() );
aIt != aEnd; ++aIt )
{
m_pClientBox->addEntry( *aIt );
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.cxx b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
index 4d356bc..22affdb 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.cxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.cxx
@@ -36,7 +36,7 @@ namespace sd {
// struct ClientBoxEntry
-ClientBoxEntry::ClientBoxEntry( ClientInfo* pClientInfo ) :
+ClientBoxEntry::ClientBoxEntry( ::boost::shared_ptr<ClientInfo> pClientInfo ) :
m_bActive( false ),
m_pClientInfo( pClientInfo )
{
@@ -611,7 +611,7 @@ bool ClientBox::Notify( NotifyEvent& rNEvt )
return true;
}
-long ClientBox::addEntry( ClientInfo* pClientInfo )
+long ClientBox::addEntry( ::boost::shared_ptr<ClientInfo> pClientInfo )
{
long nPos = 0;
// PackageState eState = m_pManager->getPackageState( xPackage );
diff --git a/sd/source/ui/dlg/RemoteDialogClientBox.hxx b/sd/source/ui/dlg/RemoteDialogClientBox.hxx
index 5b63438..83295f2 100644
--- a/sd/source/ui/dlg/RemoteDialogClientBox.hxx
+++ b/sd/source/ui/dlg/RemoteDialogClientBox.hxx
@@ -56,9 +56,9 @@ typedef ::boost::shared_ptr< ClientBoxEntry > TClientBoxEntry;
struct ClientBoxEntry
{
bool m_bActive :1;
- ClientInfo* m_pClientInfo;
+ ::boost::shared_ptr<ClientInfo> m_pClientInfo;
- ClientBoxEntry( ClientInfo* pClientInfo );
+ ClientBoxEntry( ::boost::shared_ptr<ClientInfo> pClientInfo );
~ClientBoxEntry();
};
@@ -155,9 +155,9 @@ public:
void RemoveUnlocked();
void selectEntry( const long nPos );
- long addEntry( ClientInfo* pClientInfo );
- void updateEntry( const ClientInfo* rPackageInfo );
- void removeEntry( const ClientInfo* rPackageInfo );
+ long addEntry( ::boost::shared_ptr<ClientInfo> pClientInfo );
+ void updateEntry( const ::boost::shared_ptr<ClientInfo> pPackageInfo );
+ void removeEntry( const ::boost::shared_ptr<ClientInfo> pPackageInfo );
void prepareChecking();
void checkEntries();
diff --git a/sd/source/ui/inc/RemoteServer.hxx b/sd/source/ui/inc/RemoteServer.hxx
index 4773083..a17e984 100644
--- a/sd/source/ui/inc/RemoteServer.hxx
+++ b/sd/source/ui/inc/RemoteServer.hxx
@@ -18,6 +18,8 @@
#include <sys/types.h>
#include <vector>
+#include <boost/shared_ptr.hpp>
+
#include <osl/mutex.hxx>
#include <osl/socket.hxx>
#include <rtl/ref.hxx>
@@ -48,6 +50,8 @@ namespace sd
ClientInfo( const OUString& rName, const OUString& rAddress ) :
mName( rName ),
mAddress( rAddress ) {}
+
+ virtual ~ClientInfo() {};
};
struct ClientInfoInternal;
@@ -64,8 +68,8 @@ namespace sd
static void presentationStopped();
// For the control dialog
- SD_DLLPUBLIC static std::vector<ClientInfo*> getClients();
- SD_DLLPUBLIC static bool connectClient( ClientInfo *pClient,
+ SD_DLLPUBLIC static std::vector< ::boost::shared_ptr< ClientInfo > > getClients();
+ SD_DLLPUBLIC static bool connectClient( ::boost::shared_ptr< ClientInfo > pClient,
const OUString& aPin );
/// ensure that discoverability (eg. for Bluetooth) is enabled
@@ -83,7 +87,7 @@ namespace sd
static ::std::vector<Communicator*> sCommunicators;
osl::AcceptorSocket mSocket;
- ::std::vector<ClientInfoInternal*> mAvailableClients;
+ ::std::vector< ::boost::shared_ptr< ClientInfoInternal > > mAvailableClients;
void execute() SAL_OVERRIDE;
};
diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx
index ff42804..038fac6 100644
--- a/sd/source/ui/remotecontrol/Server.cxx
+++ b/sd/source/ui/remotecontrol/Server.cxx
@@ -124,7 +124,8 @@ void RemoteServer::execute()
OUString aAddress = aClientAddr.getHostname();
MutexGuard aGuard( sDataMutex );
- ClientInfoInternal* pClient = new ClientInfoInternal(
+ ::boost::shared_ptr< ClientInfoInternal > pClient(
+ new ClientInfoInternal(
OStringToOUString( aName, RTL_TEXTENCODING_UTF8 ),
aAddress, pSocket, OStringToOUString( aPin,
RTL_TEXTENCODING_UTF8 ) );
@@ -233,10 +234,10 @@ void RemoteServer::removeCommunicator( Communicator* mCommunicator )
}
}
-std::vector<ClientInfo*> RemoteServer::getClients()
+std::vector< ::boost::shared_ptr< ClientInfo > > RemoteServer::getClients()
{
SAL_INFO( "sdremote", "RemoteServer::getClients() called" );
- std::vector<ClientInfo*> aClients;
+ std::vector< ::boost::shared_ptr< ClientInfo > > aClients;
if ( !spServer )
{
SAL_INFO( "sdremote", "No remote server instance => no clients" );
@@ -249,12 +250,13 @@ std::vector<ClientInfo*> RemoteServer::getClients()
return aClients;
}
-bool RemoteServer::connectClient( ClientInfo* pClient, const OUString& aPin )
+bool RemoteServer::connectClient( ::boost::shared_ptr< ClientInfo > pClient, const OUString& aPin )
{
SAL_INFO( "sdremote", "RemoteServer::connectClient called" );
if ( !spServer )
return false;
+ ClientInfoInternal* apClient = dynamic_cast< ClientInfoInternal* >( pClient.get() );
ClientInfoInternal *apClient = (ClientInfoInternal*) pClient;
if ( apClient->mPin.equals( aPin ) )
{
@@ -292,7 +294,7 @@ bool RemoteServer::connectClient( ClientInfo* pClient, const OUString& aPin )
sCommunicators.push_back( pCommunicator );
- for ( vector<ClientInfoInternal*>::iterator aIt = spServer->mAvailableClients.begin();
+ for ( vector<::boost::shared_ptr<ClientInfoInternal>>::iterator aIt = spServer->mAvailableClients.begin();
aIt != spServer->mAvailableClients.end(); ++aIt )
{
if ( pClient == *aIt )
More information about the Libreoffice-commits
mailing list