Kaydet (Commit) f82c524f authored tarafından Andrzej Hunt's avatar Andrzej Hunt

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
üst b20e6ace
......@@ -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 );
......
......@@ -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 );
......
......@@ -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();
......
......@@ -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;
};
......
......@@ -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 )
......
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