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 ) ...@@ -28,11 +28,11 @@ RemoteDialog::RemoteDialog( Window *pWindow )
#ifdef ENABLE_SDREMOTE #ifdef ENABLE_SDREMOTE
RemoteServer::ensureDiscoverable(); 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 ) aIt != aEnd; ++aIt )
{ {
m_pClientBox->addEntry( *aIt ); m_pClientBox->addEntry( *aIt );
......
...@@ -36,7 +36,7 @@ namespace sd { ...@@ -36,7 +36,7 @@ namespace sd {
// struct ClientBoxEntry // struct ClientBoxEntry
ClientBoxEntry::ClientBoxEntry( ClientInfo* pClientInfo ) : ClientBoxEntry::ClientBoxEntry( ::boost::shared_ptr<ClientInfo> pClientInfo ) :
m_bActive( false ), m_bActive( false ),
m_pClientInfo( pClientInfo ) m_pClientInfo( pClientInfo )
{ {
...@@ -611,7 +611,7 @@ bool ClientBox::Notify( NotifyEvent& rNEvt ) ...@@ -611,7 +611,7 @@ bool ClientBox::Notify( NotifyEvent& rNEvt )
return true; return true;
} }
long ClientBox::addEntry( ClientInfo* pClientInfo ) long ClientBox::addEntry( ::boost::shared_ptr<ClientInfo> pClientInfo )
{ {
long nPos = 0; long nPos = 0;
// PackageState eState = m_pManager->getPackageState( xPackage ); // PackageState eState = m_pManager->getPackageState( xPackage );
......
...@@ -56,9 +56,9 @@ typedef ::boost::shared_ptr< ClientBoxEntry > TClientBoxEntry; ...@@ -56,9 +56,9 @@ typedef ::boost::shared_ptr< ClientBoxEntry > TClientBoxEntry;
struct ClientBoxEntry struct ClientBoxEntry
{ {
bool m_bActive :1; bool m_bActive :1;
ClientInfo* m_pClientInfo; ::boost::shared_ptr<ClientInfo> m_pClientInfo;
ClientBoxEntry( ClientInfo* pClientInfo ); ClientBoxEntry( ::boost::shared_ptr<ClientInfo> pClientInfo );
~ClientBoxEntry(); ~ClientBoxEntry();
}; };
...@@ -155,9 +155,9 @@ public: ...@@ -155,9 +155,9 @@ public:
void RemoveUnlocked(); void RemoveUnlocked();
void selectEntry( const long nPos ); void selectEntry( const long nPos );
long addEntry( ClientInfo* pClientInfo ); long addEntry( ::boost::shared_ptr<ClientInfo> pClientInfo );
void updateEntry( const ClientInfo* rPackageInfo ); void updateEntry( const ::boost::shared_ptr<ClientInfo> pPackageInfo );
void removeEntry( const ClientInfo* rPackageInfo ); void removeEntry( const ::boost::shared_ptr<ClientInfo> pPackageInfo );
void prepareChecking(); void prepareChecking();
void checkEntries(); void checkEntries();
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include <sys/types.h> #include <sys/types.h>
#include <vector> #include <vector>
#include <boost/shared_ptr.hpp>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <osl/socket.hxx> #include <osl/socket.hxx>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
...@@ -48,6 +50,8 @@ namespace sd ...@@ -48,6 +50,8 @@ namespace sd
ClientInfo( const OUString& rName, const OUString& rAddress ) : ClientInfo( const OUString& rName, const OUString& rAddress ) :
mName( rName ), mName( rName ),
mAddress( rAddress ) {} mAddress( rAddress ) {}
virtual ~ClientInfo() {};
}; };
struct ClientInfoInternal; struct ClientInfoInternal;
...@@ -64,8 +68,8 @@ namespace sd ...@@ -64,8 +68,8 @@ namespace sd
static void presentationStopped(); static void presentationStopped();
// For the control dialog // For the control dialog
SD_DLLPUBLIC static std::vector<ClientInfo*> getClients(); SD_DLLPUBLIC static std::vector< ::boost::shared_ptr< ClientInfo > > getClients();
SD_DLLPUBLIC static bool connectClient( ClientInfo *pClient, SD_DLLPUBLIC static bool connectClient( ::boost::shared_ptr< ClientInfo > pClient,
const OUString& aPin ); const OUString& aPin );
/// ensure that discoverability (eg. for Bluetooth) is enabled /// ensure that discoverability (eg. for Bluetooth) is enabled
...@@ -83,7 +87,7 @@ namespace sd ...@@ -83,7 +87,7 @@ namespace sd
static ::std::vector<Communicator*> sCommunicators; static ::std::vector<Communicator*> sCommunicators;
osl::AcceptorSocket mSocket; osl::AcceptorSocket mSocket;
::std::vector<ClientInfoInternal*> mAvailableClients; ::std::vector< ::boost::shared_ptr< ClientInfoInternal > > mAvailableClients;
void execute() SAL_OVERRIDE; void execute() SAL_OVERRIDE;
}; };
......
...@@ -124,7 +124,8 @@ void RemoteServer::execute() ...@@ -124,7 +124,8 @@ void RemoteServer::execute()
OUString aAddress = aClientAddr.getHostname(); OUString aAddress = aClientAddr.getHostname();
MutexGuard aGuard( sDataMutex ); MutexGuard aGuard( sDataMutex );
ClientInfoInternal* pClient = new ClientInfoInternal( ::boost::shared_ptr< ClientInfoInternal > pClient(
new ClientInfoInternal(
OStringToOUString( aName, RTL_TEXTENCODING_UTF8 ), OStringToOUString( aName, RTL_TEXTENCODING_UTF8 ),
aAddress, pSocket, OStringToOUString( aPin, aAddress, pSocket, OStringToOUString( aPin,
RTL_TEXTENCODING_UTF8 ) ); RTL_TEXTENCODING_UTF8 ) );
...@@ -233,10 +234,10 @@ void RemoteServer::removeCommunicator( Communicator* mCommunicator ) ...@@ -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" ); SAL_INFO( "sdremote", "RemoteServer::getClients() called" );
std::vector<ClientInfo*> aClients; std::vector< ::boost::shared_ptr< ClientInfo > > aClients;
if ( !spServer ) if ( !spServer )
{ {
SAL_INFO( "sdremote", "No remote server instance => no clients" ); SAL_INFO( "sdremote", "No remote server instance => no clients" );
...@@ -249,12 +250,13 @@ std::vector<ClientInfo*> RemoteServer::getClients() ...@@ -249,12 +250,13 @@ std::vector<ClientInfo*> RemoteServer::getClients()
return aClients; 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" ); SAL_INFO( "sdremote", "RemoteServer::connectClient called" );
if ( !spServer ) if ( !spServer )
return false; return false;
ClientInfoInternal* apClient = dynamic_cast< ClientInfoInternal* >( pClient.get() );
ClientInfoInternal *apClient = (ClientInfoInternal*) pClient; ClientInfoInternal *apClient = (ClientInfoInternal*) pClient;
if ( apClient->mPin.equals( aPin ) ) if ( apClient->mPin.equals( aPin ) )
{ {
...@@ -292,7 +294,7 @@ bool RemoteServer::connectClient( ClientInfo* pClient, const OUString& aPin ) ...@@ -292,7 +294,7 @@ bool RemoteServer::connectClient( ClientInfo* pClient, const OUString& aPin )
sCommunicators.push_back( pCommunicator ); 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 ) aIt != spServer->mAvailableClients.end(); ++aIt )
{ {
if ( pClient == *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