Kaydet (Commit) c56593f0 authored tarafından Tor Lillqvist's avatar Tor Lillqvist Kaydeden (comit) Michael Meeks

Merge in Bluetooth code for the Impress Remote for OS X

Thirteen commits from master squashed into one commit. Original commit
messages in order below, so note that claims are in many cases
overridden by later commits.

=== This is the 1st commit message:

Work in progress. It sets up the SDP service record and registers it,
and that seems to work. Does not do anything with it yet.

I wonder if the current approach to use the standard SerialPort
service class will work for Macs, as they by default have one
SerialPort service running, "Bluetooth-PDA-Sync", whatever that
is.

There is no code in the Android app to handle the case of there being
several Serial Port services on the computer it wants to connect to,
so what happens then when there are two will be interesting to see.

(I can't find in the Android API any way to enumerate services that
use the same service class. If there was, the app could choose the
correct one based on its name.)

So probably we should pretty soon switch to using a dedicated service
class UUID instead of using the standard serial port one. As we
already have the app out in the wild it will probably have to be
modified to look for both Serial Port and our own service then? Sigh.

=== This is the 2nd commit message:

Add this single-line file

=== This is the 3rd commit message:

Fix build against Mac OS X SDK 10.4

=== This is the 4th commit message:

More work on the Impress Remote Control Bluetooth code for OS X

Mostly the work of Thorsten, from December, adapted to compile against
the current remote control code, and with one or two crucial things
added. Plus lots of SAL_INFO calls added; once it works well many of
them can be dropped. Does not work properly yet, do not cherry-pick
just this to 4.0.

=== This is the 5th commit message:

Nothing in the C standard about sockets

=== This is the 6th commit message:

Fix compilation for Linux and hopefully Windows, too

=== This is the 7th commit message:

Blind fix for WaE: class does not fully implement protocol

The Xcode 3 compiler warns: class 'ChannelDelegate' does not fully
implement the 'IOBluetoothRFCOMMChannelDelegate' protocol.

=== This is the 8th commit message:

pragma GCC diagnostic is not available for 4.0.1

=== This is the 9th commit message:

std::vector::data() is C++11

=== This is the 10th commit message:

WaE: comparison is always true due to limited range of data type

=== This is the 11th commit message:

Be specific in the logging as multiple threads involved

Sure, each SAL_INFO output line includes the thread ID, but still,
good to avoid confusion from where this line is coming.

=== This is the 12th commit message:

Plug autorelease leak

=== This is the 13th commit message:

Handle gracefully the remote end closing the RFCOMM channel

Avoids a crash if one presses the "back" key on the Android remote
control.

(cherry picked from commit 100ac087)
(cherry picked from commit c30e94a9)
(cherry picked from commit bc96a843)
(cherry picked from commit f9685dc5)
(cherry picked from commit dca5d2b1)
(cherry picked from commit bd6201ee)
(cherry picked from commit 05dbe2dd)
(cherry picked from commit c21916ad)
(cherry picked from commit 730cff74)
(cherry picked from commit 21bec368)
(cherry picked from commit da3d37b9)
(cherry picked from commit b008101f)
(cherry picked from commit 6ce04df2)

Change-Id: Ic72b432b2174e2ad31225a1b5fa97c1a79330e48
Signed-off-by: 's avatarMichael Meeks <michael.meeks@suse.com>
üst 3d9911a9
......@@ -9337,7 +9337,7 @@ if test -n "$enable_sdremote" -a "$enable_sdremote" != "no"; then
# If not explicitly enabled or disabled, default
if test -z "$enable_sdremote_bluetooth"; then
case "$OS" in
LINUX|WNT)
LINUX|MACOSX|WNT)
# Default to yes for these
enable_sdremote_bluetooth=yes
;;
......
......@@ -80,6 +80,17 @@ $(eval $(call gb_CppunitTest_use_system_win32_libs,sd_uimpress,\
))
endif
ifeq ($(OS),MACOSX)
$(eval $(call gb_CppunitTest_add_libs,sd_uimpress,\
-lobjc \
))
$(eval $(call gb_CppunitTest_use_system_darwin_frameworks,sd_uimpress,\
Foundation \
IOBluetooth \
))
endif
$(eval $(call gb_CppunitTest_use_externals,sd_uimpress,\
gtk \
dbus \
......
......@@ -528,10 +528,32 @@ $(eval $(call gb_Library_add_defs,sd,\
))
ifeq ($(ENABLE_SDREMOTE_BLUETOOTH),YES)
ifeq (,$(filter IOS MACOSX,$(OS)))
$(eval $(call gb_Library_add_exception_objects,sd,\
sd/source/ui/remotecontrol/BluetoothServer \
))
else
$(eval $(call gb_Library_add_objcxxobjects,sd,\
sd/source/ui/remotecontrol/BluetoothServer \
sd/source/ui/remotecontrol/OSXBluetooth,\
-Wno-error \
))
$(eval $(call gb_Library_add_libs,sd,\
-lobjc \
))
$(eval $(call gb_Library_use_system_darwin_frameworks,sd,\
Foundation \
IOBluetooth \
))
endif
$(eval $(call gb_Library_add_defs,sd,\
-DENABLE_SDREMOTE_BLUETOOTH \
))
......
......@@ -24,6 +24,8 @@ namespace sd
static bool isDiscoverable();
static void setDiscoverable( bool aDiscoverable );
void addCommunicator( Communicator* pCommunicator );
private:
BluetoothServer( std::vector<Communicator*>* pCommunicators );
~BluetoothServer();
......
......@@ -9,7 +9,7 @@
#ifndef _SD_IMPRESSREMOTE_BUFFEREDSTREAMSOCKET_HXX
#define _SD_IMPRESSREMOTE_BUFFEREDSTREAMSOCKET_HXX
#include <boost/noncopyable.hpp>
#include "IBluetoothSocket.hxx"
#include <osl/socket.hxx>
#include <vector>
......@@ -28,8 +28,8 @@ namespace sd
* integrated into osl Sockets.
*/
class BufferedStreamSocket :
private ::osl::StreamSocket,
private ::boost::noncopyable
public IBluetoothSocket,
private ::osl::StreamSocket
{
public:
/**
......@@ -38,7 +38,7 @@ namespace sd
*/
BufferedStreamSocket( const osl::StreamSocket &aSocket );
/**
* Create a BufferedStreamSocket on top of a standard c socket.
* Create a BufferedStreamSocket on top of a POSIX or WinSock socket.
*/
BufferedStreamSocket( int aSocket );
BufferedStreamSocket( const BufferedStreamSocket &aSocket );
......@@ -47,9 +47,9 @@ namespace sd
* Returns whatever the last call of recv returned, i.e. 0 or less
* if there was a problem in communications.
*/
sal_Int32 readLine(OString& aLine);
virtual sal_Int32 readLine( OString& aLine );
sal_Int32 write( const void* pBuffer, sal_uInt32 n );
virtual sal_Int32 write( const void* pBuffer, sal_uInt32 n );
void getPeerAddr(osl::SocketAddr&);
private:
......
......@@ -21,7 +21,7 @@ using namespace std;
using namespace com::sun::star;
using namespace osl;
Communicator::Communicator( BufferedStreamSocket *pSocket ):
Communicator::Communicator( IBluetoothSocket *pSocket ):
Thread( "CommunicatorThread" ),
mpSocket( pSocket ),
pTransmitter( 0 ),
......
......@@ -9,20 +9,17 @@
#ifndef _SD_IMPRESSREMOTE_COMMUNICATOR_HXX
#define _SD_IMPRESSREMOTE_COMMUNICATOR_HXX
// SERVER
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <vector>
#include <osl/socket.hxx>
#include <rtl/ref.hxx>
#include <salhelper/thread.hxx>
#include <com/sun/star/presentation/XSlideShowController.hpp>
#include "BufferedStreamSocket.hxx"
#include "IBluetoothSocket.hxx"
#define CHARSET RTL_TEXTENCODING_UTF8
namespace sd
......@@ -39,7 +36,7 @@ namespace sd
class Communicator : public salhelper::Thread
{
public:
Communicator( BufferedStreamSocket *pSocket );
Communicator( IBluetoothSocket *pSocket );
~Communicator();
void presentationStarted( const css::uno::Reference<
......@@ -49,7 +46,7 @@ namespace sd
private:
void execute();
BufferedStreamSocket *mpSocket;
IBluetoothSocket *mpSocket;
Transmitter *pTransmitter;
rtl::Reference<Listener> mListener;
......@@ -57,4 +54,5 @@ namespace sd
}
#endif // _SD_IMPRESSREMOTE_COMMUNICATOR_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef _SD_IMPRESSREMOTE_IBLUETOOTHSOCKET_HXX
#define _SD_IMPRESSREMOTE_IBLUETOOTHSOCKET_HXX
#include <rtl/string.hxx>
#include <boost/noncopyable.hpp>
namespace sd
{
/** Interface for bluetooth data io
*/
struct IBluetoothSocket : private boost::noncopyable
{
virtual ~IBluetoothSocket() {}
/** Blocks until a line is read.
@return whatever the last call of recv returned, i.e. 0 or less
if there was a problem in communications.
*/
virtual sal_Int32 readLine(rtl::OString& aLine) = 0;
/** Write a number of bytes
@return number of bytes actually written
*/
virtual sal_Int32 write( const void* pBuffer, sal_uInt32 n ) = 0;
};
}
#endif // _SD_IMPRESSREMOTE_IBLUETOOTHSOCKET_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_OSXBLUETOOTH_H
#define INCLUDED_OSXBLUETOOTH_H
#import <IOBluetooth/objc/IOBluetoothRFCOMMChannel.h>
#include "IBluetoothSocket.hxx"
#include "Communicator.hxx"
#include "OSXBluetoothWrapper.hxx"
@interface ChannelDelegate : NSObject<IOBluetoothRFCOMMChannelDelegate>
{
sd::Communicator* pCommunicator;
sd::OSXBluetoothWrapper* pSocket;
}
- (id) initWithCommunicatorAndSocket:(sd::Communicator*)communicator socket:(sd::OSXBluetoothWrapper*)socket;
- (void) rfcommChannelData:(IOBluetoothRFCOMMChannel*)rfcommChannel data:(void *)dataPointer length:(size_t)dataLength;
- (void) rfcommChannelClosed:(IOBluetoothRFCOMMChannel*)rfcommChannel;
@end
#endif /* INCLUDED_OSXBLUETOOTH_H */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: ObjC; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <osl/conditn.hxx> // Include this early to avoid error as check() gets defined by some SDK header to empty
#include <premac.h>
#import <IOBluetooth/objc/IOBluetoothRFCOMMChannel.h>
#include <postmac.h>
#include "OSXBluetooth.h"
@implementation ChannelDelegate
- (id) initWithCommunicatorAndSocket:(sd::Communicator*)communicator socket:(sd::OSXBluetoothWrapper*)socket
{
pCommunicator = communicator;
pSocket = socket;
return self;
}
- (void) rfcommChannelData:(IOBluetoothRFCOMMChannel*)rfcommChannel data:(void *)dataPointer length:(size_t)dataLength
{
(void) rfcommChannel;
if ( pSocket )
{
pSocket->appendData(dataPointer, dataLength);
}
}
- (void) rfcommChannelClosed:(IOBluetoothRFCOMMChannel*)rfcommChannel
{
(void) rfcommChannel;
SAL_INFO( "sdremote.bluetooth", "ChannelDelegate::rfcommChannelClosed()\n");
if ( pSocket )
{
pSocket->channelClosed();
}
pCommunicator = NULL;
pSocket = NULL;
}
@end
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef _SD_IMPRESSREMOTE_OSXBLUETOOTHWRAPPER_HXX
#define _SD_IMPRESSREMOTE_OSXBLUETOOTHWRAPPER_HXX
#include <rtl/string.hxx>
#include <osl/conditn.hxx>
#include <osl/mutex.hxx>
#include <vector>
#include "IBluetoothSocket.hxx"
namespace sd
{
class OSXBluetoothWrapper : public IBluetoothSocket
{
IOBluetoothRFCOMMChannel* mpChannel;
int mnMTU;
osl::Condition mHaveBytes;
osl::Mutex mMutex;
std::vector<char> mBuffer;
public:
OSXBluetoothWrapper( IOBluetoothRFCOMMChannel* channel );
virtual sal_Int32 readLine( rtl::OString& aLine );
virtual sal_Int32 write( const void* pBuffer, sal_uInt32 len );
void appendData(void* pBuffer, size_t len );
void channelClosed();
};
}
#endif // _SD_IMPRESSREMOTE_OSXBLUETOOTHWRAPPER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -29,6 +29,7 @@
#include "RemoteServer.hxx"
#include "BluetoothServer.hxx"
#include "Communicator.hxx"
#include "BufferedStreamSocket.hxx"
using namespace std;
using namespace sd;
......
......@@ -13,7 +13,7 @@ using namespace std;
using namespace osl; // Sockets etc.
using namespace sd;
Transmitter::Transmitter( BufferedStreamSocket* aSocket )
Transmitter::Transmitter( IBluetoothSocket* aSocket )
: pStreamSocket( aSocket ),
mQueuesNotEmpty(),
mFinishRequested(),
......
......@@ -6,12 +6,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef _SD_IMPRESSREMOTE_TRANSMITTER_HXX
#define _SD_IMPRESSREMOTE_TRANSMITTER_HXX
#include <osl/conditn.hxx>
#include <osl/mutex.hxx>
#include "BufferedStreamSocket.hxx"
#include "IBluetoothSocket.hxx"
#include <osl/thread.hxx>
#include <rtl/string.hxx>
......@@ -25,7 +26,7 @@ class Transmitter
{
public:
enum Priority { PRIORITY_LOW = 1, PRIORITY_HIGH };
Transmitter( ::sd::BufferedStreamSocket* aSocket );
Transmitter( ::sd::IBluetoothSocket* aSocket );
~Transmitter();
void addMessage( const rtl::OString& aMessage, const Priority aPriority );
void notifyFinished();
......@@ -33,7 +34,7 @@ public:
private:
virtual void SAL_CALL run();
::sd::BufferedStreamSocket* pStreamSocket;
::sd::IBluetoothSocket* pStreamSocket;
::osl::Condition mQueuesNotEmpty;
::osl::Condition mFinishRequested;
......@@ -46,4 +47,5 @@ private:
}
#endif // _SD_IMPRESSREMOTE_TRANSMITTER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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