summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-06-27 12:09:01 +0200
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-06-30 07:45:16 +0200
commitf82c524f7615abc13adadca12ef27237ff3df4b7 (patch)
tree74e047a8bda9dff9cc0f48e42b3266648a34be55 /sd
parentb20e6acea2cb2013f450bb4b97b51142dbb4f161 (diff)
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
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/dlg/RemoteDialog.cxx6
-rw-r--r--sd/source/ui/dlg/RemoteDialogClientBox.cxx4
-rw-r--r--sd/source/ui/dlg/RemoteDialogClientBox.hxx10
-rw-r--r--sd/source/ui/inc/RemoteServer.hxx10
-rw-r--r--sd/source/ui/remotecontrol/Server.cxx12
5 files changed, 24 insertions, 18 deletions
diff --git a/sd/source/ui/dlg/RemoteDialog.cxx b/sd/source/ui/dlg/RemoteDialog.cxx
index fd2fe8136987..4265bacab957 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 4d356bcfc971..22affdb3748a 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 5b634384a39d..83295f2ed1d9 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 4773083f4964..a17e98426342 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 ff42804d77a7..038fac63f002 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 )