Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
64d1fcb1
Kaydet (Commit)
64d1fcb1
authored
Eyl 18, 2012
tarafından
Andrzej J.R. Hunt
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Switch bluetooth discoverability on when remote dialog shown (Linux).
Change-Id: Ie0e4f7a353d77f5312deea06f0a316d8e1b1ed47
üst
6c1b61b0
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
202 additions
and
33 deletions
+202
-33
RemoteDialog.cxx
sd/source/ui/dlg/RemoteDialog.cxx
+20
-3
RemoteDialog.hxx
sd/source/ui/dlg/RemoteDialog.hxx
+3
-0
RemoteServer.hxx
sd/source/ui/inc/RemoteServer.hxx
+3
-0
BluetoothServer.cxx
sd/source/ui/remotecontrol/BluetoothServer.cxx
+160
-25
BluetoothServer.hxx
sd/source/ui/remotecontrol/BluetoothServer.hxx
+2
-1
Server.cxx
sd/source/ui/remotecontrol/Server.cxx
+14
-4
No files found.
sd/source/ui/dlg/RemoteDialog.cxx
Dosyayı görüntüle @
64d1fcb1
...
@@ -22,10 +22,15 @@ RemoteDialog::RemoteDialog( Window *pWindow ) :
...
@@ -22,10 +22,15 @@ RemoteDialog::RemoteDialog( Window *pWindow ) :
ModalDialog
(
pWindow
,
SdResId
(
DLG_PAIR_REMOTE
)
),
ModalDialog
(
pWindow
,
SdResId
(
DLG_PAIR_REMOTE
)
),
mButtonConnect
(
this
,
SdResId
(
BTN_CONNECT
)
),
mButtonConnect
(
this
,
SdResId
(
BTN_CONNECT
)
),
mButtonCancel
(
this
,
SdResId
(
BTN_CANCEL
)
),
mButtonCancel
(
this
,
SdResId
(
BTN_CANCEL
)
),
mClientBox
(
this
,
NULL
,
SdResId
(
LB_SERVERS
)
)
mClientBox
(
this
,
NULL
,
SdResId
(
LB_SERVERS
)
),
mPreviouslyDiscoverable
()
{
{
FreeResource
();
FreeResource
();
mPreviouslyDiscoverable
=
RemoteServer
::
isBluetoothDiscoverable
();
if
(
!
mPreviouslyDiscoverable
)
RemoteServer
::
setBluetoothDiscoverable
(
true
);
vector
<
ClientInfo
*>
aClients
(
RemoteServer
::
getClients
()
);
vector
<
ClientInfo
*>
aClients
(
RemoteServer
::
getClients
()
);
for
(
vector
<
ClientInfo
*>::
const_iterator
aIt
(
aClients
.
begin
()
);
for
(
vector
<
ClientInfo
*>::
const_iterator
aIt
(
aClients
.
begin
()
);
...
@@ -35,6 +40,8 @@ RemoteDialog::RemoteDialog( Window *pWindow ) :
...
@@ -35,6 +40,8 @@ RemoteDialog::RemoteDialog( Window *pWindow ) :
}
}
mButtonConnect
.
SetClickHdl
(
LINK
(
this
,
RemoteDialog
,
HandleConnectButton
)
);
mButtonConnect
.
SetClickHdl
(
LINK
(
this
,
RemoteDialog
,
HandleConnectButton
)
);
SetCloseHdl
(
LINK
(
this
,
RemoteDialog
,
CloseHdl
)
);
mButtonCancel
.
SetClickHdl
(
LINK
(
this
,
RemoteDialog
,
CloseHdl
)
);
}
}
RemoteDialog
::~
RemoteDialog
()
RemoteDialog
::~
RemoteDialog
()
...
@@ -53,11 +60,20 @@ IMPL_LINK_NOARG(RemoteDialog, HandleConnectButton)
...
@@ -53,11 +60,20 @@ IMPL_LINK_NOARG(RemoteDialog, HandleConnectButton)
OUString
aPin
(
mClientBox
.
getPin
()
);
OUString
aPin
(
mClientBox
.
getPin
()
);
if
(
RemoteServer
::
connectClient
(
aEntry
->
m_pClientInfo
,
aPin
)
)
if
(
RemoteServer
::
connectClient
(
aEntry
->
m_pClientInfo
,
aPin
)
)
{
{
Close
();
return
CloseHdl
(
0
);
return
0
;
}
}
else
else
return
1
;
return
1
;
}
}
IMPL_LINK_NOARG
(
RemoteDialog
,
CloseHdl
)
{
if
(
!
mPreviouslyDiscoverable
)
{
RemoteServer
::
setBluetoothDiscoverable
(
false
);
}
Close
();
return
0
;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
sd/source/ui/dlg/RemoteDialog.hxx
Dosyayı görüntüle @
64d1fcb1
...
@@ -27,8 +27,11 @@ private:
...
@@ -27,8 +27,11 @@ private:
OKButton
mButtonConnect
;
OKButton
mButtonConnect
;
CancelButton
mButtonCancel
;
CancelButton
mButtonCancel
;
ClientBox
mClientBox
;
ClientBox
mClientBox
;
// Whether discoverability was enabled befor the dialog started.
bool
mPreviouslyDiscoverable
;
DECL_DLLPRIVATE_LINK
(
HandleConnectButton
,
void
*
);
DECL_DLLPRIVATE_LINK
(
HandleConnectButton
,
void
*
);
DECL_LINK
(
CloseHdl
,
void
*
);
public
:
public
:
RemoteDialog
(
Window
*
pWindow
);
RemoteDialog
(
Window
*
pWindow
);
~
RemoteDialog
();
~
RemoteDialog
();
...
...
sd/source/ui/inc/RemoteServer.hxx
Dosyayı görüntüle @
64d1fcb1
...
@@ -69,6 +69,9 @@ namespace sd
...
@@ -69,6 +69,9 @@ namespace sd
SD_DLLPUBLIC
static
sal_Bool
connectClient
(
ClientInfo
*
pClient
,
SD_DLLPUBLIC
static
sal_Bool
connectClient
(
ClientInfo
*
pClient
,
rtl
::
OUString
aPin
);
rtl
::
OUString
aPin
);
SD_DLLPUBLIC
static
bool
isBluetoothDiscoverable
();
SD_DLLPUBLIC
static
void
setBluetoothDiscoverable
(
bool
aDiscoverable
);
// For the communicator
// For the communicator
static
void
removeCommunicator
(
Communicator
*
pCommunicator
);
static
void
removeCommunicator
(
Communicator
*
pCommunicator
);
private
:
private
:
...
...
sd/source/ui/remotecontrol/BluetoothServer.cxx
Dosyayı görüntüle @
64d1fcb1
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include <sys/socket.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
#include <bluetooth/rfcomm.h>
#define DBUS_TYPE_G_STRING_ANY_HASHTABLE (dbus_g_type_get_map( "GHashTable", G_TYPE_STRING, G_TYPE_VALUE ))
#endif
#endif
#ifdef WIN32
#ifdef WIN32
...
@@ -34,6 +35,48 @@
...
@@ -34,6 +35,48 @@
using
namespace
sd
;
using
namespace
sd
;
#if (defined(LINUX) && !defined(__FreeBSD_kernel__)) && defined(ENABLE_DBUS)
DBusGProxy
*
bluezGetDefaultAdapter
(
DBusGConnection
*
aConnection
,
const
gchar
*
aInterfaceType
=
"org.bluez.Adapter"
)
{
GError
*
aError
=
NULL
;
DBusGProxy
*
aManager
=
NULL
;
aManager
=
dbus_g_proxy_new_for_name
(
aConnection
,
"org.bluez"
,
"/"
,
"org.bluez.Manager"
);
if
(
aManager
==
NULL
)
{
dbus_g_connection_unref
(
aConnection
);
return
NULL
;
}
gboolean
aResult
;
// The following should be a DBusGObjectPath, however the necessary
// typedef is missing in older version of dbus-glib.
char
*
aAdapterPath
=
NULL
;
aResult
=
dbus_g_proxy_call
(
aManager
,
"DefaultAdapter"
,
&
aError
,
G_TYPE_INVALID
,
DBUS_TYPE_G_OBJECT_PATH
,
&
aAdapterPath
,
G_TYPE_INVALID
);
g_object_unref
(
G_OBJECT
(
aManager
));
if
(
!
aResult
||
aError
)
{
if
(
aError
)
g_error_free
(
aError
);
return
NULL
;
}
DBusGProxy
*
aAdapter
=
NULL
;
aAdapter
=
dbus_g_proxy_new_for_name
(
aConnection
,
"org.bluez"
,
aAdapterPath
,
aInterfaceType
);
g_free
(
aAdapterPath
);
return
aAdapter
;
}
#endif // defined(LINUX) && defined(ENABLE_DBUS)
BluetoothServer
::
BluetoothServer
(
std
::
vector
<
Communicator
*>*
pCommunicators
)
:
BluetoothServer
::
BluetoothServer
(
std
::
vector
<
Communicator
*>*
pCommunicators
)
:
Thread
(
"BluetoothServer"
),
Thread
(
"BluetoothServer"
),
mpCommunicators
(
pCommunicators
)
mpCommunicators
(
pCommunicators
)
...
@@ -46,56 +89,148 @@ BluetoothServer::~BluetoothServer()
...
@@ -46,56 +89,148 @@ BluetoothServer::~BluetoothServer()
bool
BluetoothServer
::
isDiscoverable
()
bool
BluetoothServer
::
isDiscoverable
()
{
{
return
true
;
#if (defined(LINUX) && !defined(__FreeBSD_kernel__)) && defined(ENABLE_DBUS)
g_type_init
();
gboolean
aResult
;
GError
*
aError
=
NULL
;
DBusGConnection
*
aConnection
=
NULL
;
aConnection
=
dbus_g_bus_get
(
DBUS_BUS_SYSTEM
,
&
aError
);
if
(
aError
!=
NULL
)
{
g_error_free
(
aError
);
return
false
;
}
DBusGProxy
*
aAdapter
=
bluezGetDefaultAdapter
(
aConnection
);
if
(
aAdapter
==
NULL
)
{
dbus_g_connection_unref
(
aConnection
);
return
false
;
}
GHashTable
*
aProperties
;
aResult
=
dbus_g_proxy_call
(
aAdapter
,
"GetProperties"
,
&
aError
,
G_TYPE_INVALID
,
DBUS_TYPE_G_STRING_ANY_HASHTABLE
,
&
aProperties
,
G_TYPE_INVALID
);
g_object_unref
(
G_OBJECT
(
aAdapter
));
dbus_g_connection_unref
(
aConnection
);
if
(
!
aResult
||
aError
)
{
if
(
aError
)
g_error_free
(
aError
);
return
false
;
}
GVariant
*
aVariant
=
dbus_g_value_build_g_variant
(
(
GValue
*
)
g_hash_table_lookup
(
aProperties
,
"Discoverable"
)
);
gboolean
aIsDiscoverable
=
g_variant_get_boolean
(
aVariant
);
g_free
(
aVariant
);
g_free
(
aProperties
);
return
aIsDiscoverable
;
#else // defined(LINUX) && defined(ENABLE_DBUS)
return
false
;
#endif
}
}
void
BluetoothServer
::
execute
(
)
void
BluetoothServer
::
setDiscoverable
(
bool
aDiscoverable
)
{
{
#if (defined(LINUX) && !defined(__FreeBSD_kernel__)) && defined(ENABLE_DBUS)
#if (defined(LINUX) && !defined(__FreeBSD_kernel__)) && defined(ENABLE_DBUS)
g_type_init
();
g_type_init
();
gboolean
aResult
;
GError
*
aError
=
NULL
;
GError
*
aError
=
NULL
;
DBusGConnection
*
aConnection
=
NULL
;
DBusGConnection
*
aConnection
=
NULL
;
aConnection
=
dbus_g_bus_get
(
DBUS_BUS_SYSTEM
,
&
aError
);
aConnection
=
dbus_g_bus_get
(
DBUS_BUS_SYSTEM
,
&
aError
);
if
(
aError
!=
NULL
)
{
if
(
aError
!=
NULL
)
{
g_error_free
(
aError
);
g_error_free
(
aError
);
return
;
return
;
}
}
DBusGProxy
*
aAdapter
=
bluezGetDefaultAdapter
(
aConnection
);
if
(
aAdapter
==
NULL
)
{
dbus_g_connection_unref
(
aConnection
);
return
;
}
DBusGProxy
*
aManager
=
NULL
;
GHashTable
*
aProperties
;
aManager
=
dbus_g_proxy_new_for_name
(
aConnection
,
"org.bluez"
,
"/"
,
aResult
=
dbus_g_proxy_call
(
aAdapter
,
"GetProperties"
,
&
aError
,
"org.bluez.Manager"
);
G_TYPE_INVALID
,
DBUS_TYPE_G_STRING_ANY_HASHTABLE
,
&
aProperties
,
G_TYPE_INVALID
);
if
(
aManager
==
NULL
)
if
(
!
aResult
||
aError
)
{
{
dbus_g_connection_unref
(
aConnection
);
if
(
aError
)
g_error_free
(
aError
);
return
;
}
GVariant
*
aVariant
=
dbus_g_value_build_g_variant
(
(
GValue
*
)
g_hash_table_lookup
(
aProperties
,
"Powered"
)
);
gboolean
aPowered
=
g_variant_get_boolean
(
aVariant
);
g_free
(
aVariant
);
g_free
(
aProperties
);
if
(
!
aPowered
)
{
g_object_unref
(
G_OBJECT
(
aAdapter
));
return
;
return
;
}
}
gboolean
aResult
;
GValue
aTimeout
=
G_VALUE_INIT
;
// The following should be a DBusGObjectPath, however the necessary
g_value_init
(
&
aTimeout
,
G_TYPE_UINT
);
// typedef is missing in older version of dbus-glib.
g_value_set_uint
(
&
aTimeout
,
0
);
char
*
aAdapterPath
=
NULL
;
aResult
=
dbus_g_proxy_call
(
aAdapter
,
"SetProperty"
,
&
aError
,
aResult
=
dbus_g_proxy_call
(
aManager
,
"DefaultAdapter"
,
&
aError
,
G_TYPE_STRING
,
"DiscoverableTimeout"
,
G_TYPE_INVALID
,
G_TYPE_VALUE
,
&
aTimeout
,
G_TYPE_INVALID
,
G_TYPE_INVALID
);
DBUS_TYPE_G_OBJECT_PATH
,
&
aAdapterPath
,
if
(
!
aResult
||
aError
)
G_TYPE_INVALID
);
{
if
(
aError
)
g_error_free
(
aError
);
return
;
}
g_object_unref
(
G_OBJECT
(
aManager
));
GValue
aDiscoverableGValue
=
G_VALUE_INIT
;
if
(
!
aResult
)
g_value_init
(
&
aDiscoverableGValue
,
G_TYPE_BOOLEAN
);
g_value_set_boolean
(
&
aDiscoverableGValue
,
aDiscoverable
);
aResult
=
dbus_g_proxy_call
(
aAdapter
,
"SetProperty"
,
&
aError
,
G_TYPE_STRING
,
"Discoverable"
,
G_TYPE_VALUE
,
&
aDiscoverableGValue
,
G_TYPE_INVALID
,
G_TYPE_INVALID
);
if
(
!
aResult
||
aError
)
{
{
dbus_g_connection_unref
(
aConnection
);
if
(
aError
)
g_error_free
(
aError
);
return
;
return
;
}
}
DBusGProxy
*
aAdapter
=
NULL
;
g_object_unref
(
G_OBJECT
(
aAdapter
));
aAdapter
=
dbus_g_proxy_new_for_name
(
aConnection
,
"org.bluez"
,
dbus_g_connection_unref
(
aConnection
);
aAdapterPath
,
"org.bluez.Service"
);
#else // defined(LINUX) && defined(ENABLE_DBUS)
g_free
(
aAdapterPath
);
return
;
#endif
}
void
BluetoothServer
::
execute
()
{
#if (defined(LINUX) && !defined(__FreeBSD_kernel__)) && defined(ENABLE_DBUS)
g_type_init
();
GError
*
aError
=
NULL
;
DBusGConnection
*
aConnection
=
NULL
;
aConnection
=
dbus_g_bus_get
(
DBUS_BUS_SYSTEM
,
&
aError
);
if
(
aError
!=
NULL
)
{
g_error_free
(
aError
);
return
;
}
DBusGProxy
*
aAdapter
=
bluezGetDefaultAdapter
(
aConnection
,
"org.bluez.Service"
);
if
(
aAdapter
==
NULL
)
if
(
aAdapter
==
NULL
)
{
{
dbus_g_connection_unref
(
aConnection
);
dbus_g_connection_unref
(
aConnection
);
...
@@ -105,7 +240,7 @@ void BluetoothServer::execute()
...
@@ -105,7 +240,7 @@ void BluetoothServer::execute()
// Add the record -- the handle can be used to release it again, but we
// Add the record -- the handle can be used to release it again, but we
// don't bother as the record is automatically released when LO exits.
// don't bother as the record is automatically released when LO exits.
guint
aHandle
;
guint
aHandle
;
aResult
=
dbus_g_proxy_call
(
aAdapter
,
"AddRecord"
,
&
aError
,
gboolean
aResult
=
dbus_g_proxy_call
(
aAdapter
,
"AddRecord"
,
&
aError
,
G_TYPE_STRING
,
BLUETOOTH_SERVICE_RECORD
,
G_TYPE_STRING
,
BLUETOOTH_SERVICE_RECORD
,
G_TYPE_INVALID
,
G_TYPE_INVALID
,
G_TYPE_UINT
,
&
aHandle
,
G_TYPE_UINT
,
&
aHandle
,
...
...
sd/source/ui/remotecontrol/BluetoothServer.hxx
Dosyayı görüntüle @
64d1fcb1
...
@@ -22,7 +22,8 @@ namespace sd
...
@@ -22,7 +22,8 @@ namespace sd
public
:
public
:
static
void
setup
(
std
::
vector
<
Communicator
*>*
pCommunicators
);
static
void
setup
(
std
::
vector
<
Communicator
*>*
pCommunicators
);
bool
isDiscoverable
();
static
bool
isDiscoverable
();
static
void
setDiscoverable
(
bool
aDiscoverable
);
private
:
private
:
BluetoothServer
(
std
::
vector
<
Communicator
*>*
pCommunicators
);
BluetoothServer
(
std
::
vector
<
Communicator
*>*
pCommunicators
);
~
BluetoothServer
();
~
BluetoothServer
();
...
...
sd/source/ui/remotecontrol/Server.cxx
Dosyayı görüntüle @
64d1fcb1
...
@@ -177,7 +177,7 @@ void RemoteServer::presentationStarted( const css::uno::Reference<
...
@@ -177,7 +177,7 @@ void RemoteServer::presentationStarted( const css::uno::Reference<
return
;
return
;
MutexGuard
aGuard
(
spServer
->
mDataMutex
);
MutexGuard
aGuard
(
spServer
->
mDataMutex
);
for
(
vector
<
Communicator
*>::
const_iterator
aIt
=
spServer
->
mCommunicators
.
begin
();
for
(
vector
<
Communicator
*>::
const_iterator
aIt
=
spServer
->
mCommunicators
.
begin
();
aIt
!=
spServer
->
mCommunicators
.
end
();
++
aIt
)
aIt
<
spServer
->
mCommunicators
.
end
();
aIt
++
)
{
{
(
*
aIt
)
->
presentationStarted
(
rController
);
(
*
aIt
)
->
presentationStarted
(
rController
);
}
}
...
@@ -188,7 +188,7 @@ void RemoteServer::presentationStopped()
...
@@ -188,7 +188,7 @@ void RemoteServer::presentationStopped()
return
;
return
;
MutexGuard
aGuard
(
spServer
->
mDataMutex
);
MutexGuard
aGuard
(
spServer
->
mDataMutex
);
for
(
vector
<
Communicator
*>::
const_iterator
aIt
=
spServer
->
mCommunicators
.
begin
();
for
(
vector
<
Communicator
*>::
const_iterator
aIt
=
spServer
->
mCommunicators
.
begin
();
aIt
!=
spServer
->
mCommunicators
.
end
();
++
aIt
)
aIt
<
spServer
->
mCommunicators
.
end
();
aIt
++
)
{
{
(
*
aIt
)
->
disposeListener
();
(
*
aIt
)
->
disposeListener
();
}
}
...
@@ -200,7 +200,7 @@ void RemoteServer::removeCommunicator( Communicator* mCommunicator )
...
@@ -200,7 +200,7 @@ void RemoteServer::removeCommunicator( Communicator* mCommunicator )
return
;
return
;
MutexGuard
aGuard
(
spServer
->
mDataMutex
);
MutexGuard
aGuard
(
spServer
->
mDataMutex
);
for
(
vector
<
Communicator
*>::
iterator
aIt
=
spServer
->
mCommunicators
.
begin
();
for
(
vector
<
Communicator
*>::
iterator
aIt
=
spServer
->
mCommunicators
.
begin
();
aIt
!=
spServer
->
mCommunicators
.
end
();
++
aIt
)
aIt
<
spServer
->
mCommunicators
.
end
();
aIt
++
)
{
{
if
(
mCommunicator
==
*
aIt
)
if
(
mCommunicator
==
*
aIt
)
{
{
...
@@ -265,7 +265,7 @@ sal_Bool RemoteServer::connectClient( ClientInfo* pClient, rtl::OUString aPin )
...
@@ -265,7 +265,7 @@ sal_Bool RemoteServer::connectClient( ClientInfo* pClient, rtl::OUString aPin )
spServer
->
mCommunicators
.
push_back
(
pCommunicator
);
spServer
->
mCommunicators
.
push_back
(
pCommunicator
);
for
(
vector
<
ClientInfoInternal
*>::
iterator
aIt
=
spServer
->
mAvailableClients
.
begin
();
for
(
vector
<
ClientInfoInternal
*>::
iterator
aIt
=
spServer
->
mAvailableClients
.
begin
();
aIt
!=
spServer
->
mAvailableClients
.
end
();
++
aIt
)
aIt
<
spServer
->
mAvailableClients
.
end
();
aIt
++
)
{
{
if
(
pClient
==
*
aIt
)
if
(
pClient
==
*
aIt
)
{
{
...
@@ -293,4 +293,14 @@ void SdDLL::RegisterRemotes()
...
@@ -293,4 +293,14 @@ void SdDLL::RegisterRemotes()
sd
::
DiscoveryService
::
setup
();
sd
::
DiscoveryService
::
setup
();
}
}
bool
RemoteServer
::
isBluetoothDiscoverable
()
{
return
BluetoothServer
::
isDiscoverable
();
}
void
RemoteServer
::
setBluetoothDiscoverable
(
bool
aDiscoverable
)
{
BluetoothServer
::
setDiscoverable
(
aDiscoverable
);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment