android/sdremote/Makefile | 3 + android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java | 4 - android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java | 20 +++++--- android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java | 25 +++++----- android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java | 8 ++- sd/source/ui/remotecontrol/BluetoothServer.cxx | 9 +-- sd/source/ui/remotecontrol/BluetoothServer.hxx | 6 +- sd/source/ui/remotecontrol/Communicator.cxx | 8 +-- sd/source/ui/remotecontrol/Communicator.hxx | 1 sd/source/ui/remotecontrol/DiscoveryService.cxx | 10 +--- sd/source/ui/remotecontrol/DiscoveryService.hxx | 7 +- sd/source/ui/remotecontrol/ImagePreparer.cxx | 9 ++- sd/source/ui/remotecontrol/ImagePreparer.hxx | 7 +- sd/source/ui/remotecontrol/Listener.cxx | 3 - sd/source/ui/remotecontrol/Listener.hxx | 1 sd/source/ui/remotecontrol/Server.cxx | 1 sd/source/ui/remotecontrol/Transmitter.cxx | 6 -- sd/source/ui/remotecontrol/Transmitter.hxx | 7 +- 18 files changed, 73 insertions(+), 62 deletions(-)
New commits: commit 895a367d4fb7e5dedefe45937a06d4ba25641d27 Author: Thorsten Behrens <tbehr...@suse.com> Date: Fri Nov 23 17:58:15 2012 +0100 Revert ImagePreparer to plain osl::Thread, suicide in onTerminate This amends 4ab63a3aacdaa819fa98957fa017978e768931bd - since osl will still call into the object, e.g. for onTerminate. Kill ourselves there. Change-Id: I2e88f3a61ba32971e08d4cbb1590d3325d1c5364 diff --git a/sd/source/ui/remotecontrol/ImagePreparer.cxx b/sd/source/ui/remotecontrol/ImagePreparer.cxx index fa642df..28e6d6c 100644 --- a/sd/source/ui/remotecontrol/ImagePreparer.cxx +++ b/sd/source/ui/remotecontrol/ImagePreparer.cxx @@ -55,8 +55,7 @@ using namespace ::com::sun::star::uno; ImagePreparer::ImagePreparer( const uno::Reference<presentation::XSlideShowController>& rxController, Transmitter *aTransmitter ) - : Thread( "ImagePreparer Thread" ), - xController( rxController ), + : xController( rxController ), pTransmitter( aTransmitter ) { } @@ -65,7 +64,7 @@ ImagePreparer::~ImagePreparer() { } -void ImagePreparer::execute() +void SAL_CALL ImagePreparer::run() { sal_uInt32 aSlides = xController->getSlideCount(); for ( sal_uInt32 i = 0; i < aSlides; i++ ) @@ -84,6 +83,10 @@ void ImagePreparer::execute() } sendNotes( i ); } +} + +void SAL_CALL ImagePreparer::onTerminated() +{ delete this; } diff --git a/sd/source/ui/remotecontrol/ImagePreparer.hxx b/sd/source/ui/remotecontrol/ImagePreparer.hxx index 2743775..86234d5 100644 --- a/sd/source/ui/remotecontrol/ImagePreparer.hxx +++ b/sd/source/ui/remotecontrol/ImagePreparer.hxx @@ -9,7 +9,7 @@ #ifndef _SD_IMPRESSREMOTE_IMAGEPREPARER_HXX #define _SD_IMPRESSREMOTE_IMAGEPREPARER_HXX -#include <salhelper/thread.hxx> +#include <osl/thread.hxx> #include <com/sun/star/presentation/XSlideShowController.hpp> @@ -21,7 +21,7 @@ namespace sd { class ImagePreparer: - public salhelper::Thread + public osl::Thread { public: ImagePreparer( const @@ -34,7 +34,8 @@ private: Transmitter *pTransmitter; // Thread method - void execute(); + virtual void SAL_CALL run(); + virtual void SAL_CALL onTerminated(); void sendPreview( sal_uInt32 aSlideNumber ); css::uno::Sequence<sal_Int8> preparePreview( sal_uInt32 aSlideNumber, commit c50fdef7cf89e8c59db5a8539bbe51c3430d9271 Author: Thorsten Behrens <tbehr...@suse.com> Date: Fri Nov 23 17:59:41 2012 +0100 cleanup - no need for salhelper::Thread mostly Change-Id: I27461e094141efd364a2c21da75151da490da2f3 diff --git a/sd/source/ui/remotecontrol/BluetoothServer.cxx b/sd/source/ui/remotecontrol/BluetoothServer.cxx index 56fd471..41255ba 100644 --- a/sd/source/ui/remotecontrol/BluetoothServer.cxx +++ b/sd/source/ui/remotecontrol/BluetoothServer.cxx @@ -86,9 +86,8 @@ DBusGProxy* bluezGetDefaultAdapter( DBusGConnection* aConnection, } #endif // defined(LINUX) && defined(ENABLE_DBUS) -BluetoothServer::BluetoothServer( std::vector<Communicator*>* pCommunicators ): - Thread( "BluetoothServer" ), - mpCommunicators( pCommunicators ) +BluetoothServer::BluetoothServer( std::vector<Communicator*>* pCommunicators ) + : mpCommunicators( pCommunicators ) { } @@ -238,7 +237,7 @@ void BluetoothServer::setDiscoverable( bool aDiscoverable ) #endif } -void BluetoothServer::execute() +void SAL_CALL BluetoothServer::run() { SAL_INFO( "sdremote.bluetooth", "BluetoothServer::execute called" ); #if (defined(LINUX) && !defined(__FreeBSD_kernel__)) && defined(ENABLE_DBUS) @@ -435,7 +434,7 @@ void BluetoothServer::setup( std::vector<Communicator*>* pCommunicators ) return; spServer = new BluetoothServer( pCommunicators ); - spServer->launch(); + spServer->create(); } diff --git a/sd/source/ui/remotecontrol/BluetoothServer.hxx b/sd/source/ui/remotecontrol/BluetoothServer.hxx index 317a6f0..51be45f 100644 --- a/sd/source/ui/remotecontrol/BluetoothServer.hxx +++ b/sd/source/ui/remotecontrol/BluetoothServer.hxx @@ -9,7 +9,7 @@ #ifndef _SD_IMPRESSREMOTE_BLUETOOTHSERVER_HXX #define _SD_IMPRESSREMOTE_BLUETOOTHSERVER_HXX -#include <salhelper/thread.hxx> +#include <osl/thread.hxx> #include <vector> namespace sd @@ -17,7 +17,7 @@ namespace sd class Communicator; class BluetoothServer: - public salhelper::Thread + public osl::Thread { public: static void setup( std::vector<Communicator*>* pCommunicators ); @@ -29,7 +29,7 @@ namespace sd ~BluetoothServer(); static BluetoothServer *spServer; - void execute(); // salhelper::Thread + virtual void SAL_CALL run(); std::vector<Communicator*>* mpCommunicators; }; diff --git a/sd/source/ui/remotecontrol/Communicator.cxx b/sd/source/ui/remotecontrol/Communicator.cxx index 0d1beb6..f567b10 100644 --- a/sd/source/ui/remotecontrol/Communicator.cxx +++ b/sd/source/ui/remotecontrol/Communicator.cxx @@ -12,7 +12,6 @@ #include <comphelper/processfactory.hxx> #include "Communicator.hxx" -#include "ImagePreparer.hxx" #include "Listener.hxx" #include "Receiver.hxx" #include "RemoteServer.hxx" @@ -38,7 +37,7 @@ Communicator::~Communicator() void Communicator::execute() { pTransmitter = new Transmitter( mpSocket ); - pTransmitter->launch(); + pTransmitter->create(); pTransmitter->addMessage( "LO_SERVER_SERVER_PAIRED\n\n", Transmitter::PRIORITY_HIGH ); @@ -99,8 +98,9 @@ void Communicator::execute() void Communicator::informListenerDestroyed() { - pTransmitter->addMessage( "slideshow_finished\n\n", - Transmitter::PRIORITY_HIGH ); + if ( pTransmitter ) + pTransmitter->addMessage( "slideshow_finished\n\n", + Transmitter::PRIORITY_HIGH ); mListener.clear(); } diff --git a/sd/source/ui/remotecontrol/Communicator.hxx b/sd/source/ui/remotecontrol/Communicator.hxx index 81b9e67..cd3e312 100644 --- a/sd/source/ui/remotecontrol/Communicator.hxx +++ b/sd/source/ui/remotecontrol/Communicator.hxx @@ -32,7 +32,6 @@ namespace sd class Transmitter; class Listener; - class ImagePreparer; /** Class used for communication with one single client, dealing with all * tasks specific to this client. diff --git a/sd/source/ui/remotecontrol/DiscoveryService.cxx b/sd/source/ui/remotecontrol/DiscoveryService.cxx index 805ce0c..f02559c 100644 --- a/sd/source/ui/remotecontrol/DiscoveryService.cxx +++ b/sd/source/ui/remotecontrol/DiscoveryService.cxx @@ -32,10 +32,8 @@ using namespace rtl; using namespace sd; using namespace std; -DiscoveryService::DiscoveryService() - : - Thread( "sd::DiscoveryService" ) -// mSocket() +DiscoveryService::DiscoveryService() : + mSocket(0) { mSocket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); @@ -62,7 +60,7 @@ DiscoveryService::~DiscoveryService() { } -void DiscoveryService::execute() +void SAL_CALL DiscoveryService::run() { char aBuffer[BUFFER_SIZE]; while ( true ) @@ -97,7 +95,7 @@ void DiscoveryService::setup() return; spService = new DiscoveryService(); - spService->launch(); + spService->create(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/remotecontrol/DiscoveryService.hxx b/sd/source/ui/remotecontrol/DiscoveryService.hxx index 46c629b..02486ba 100644 --- a/sd/source/ui/remotecontrol/DiscoveryService.hxx +++ b/sd/source/ui/remotecontrol/DiscoveryService.hxx @@ -16,7 +16,7 @@ #include <osl/socket.hxx> #include <rtl/ref.hxx> -#include <salhelper/thread.hxx> +#include <osl/thread.hxx> namespace css = ::com::sun::star; @@ -35,7 +35,7 @@ namespace sd - class DiscoveryService : public salhelper::Thread + class DiscoveryService : public osl::Thread { public: static void setup(); @@ -45,7 +45,7 @@ namespace sd ~DiscoveryService(); static DiscoveryService *spService; - void execute(); + virtual void SAL_CALL run(); // osl::DatagramSocket mSocket; int mSocket; @@ -54,4 +54,4 @@ namespace sd } #endif // _SD_IMPRESSREMOTE_DISCOVERYSERVICE_HXX -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/remotecontrol/Listener.cxx b/sd/source/ui/remotecontrol/Listener.cxx index 344fc27..30b29a9 100644 --- a/sd/source/ui/remotecontrol/Listener.cxx +++ b/sd/source/ui/remotecontrol/Listener.cxx @@ -14,6 +14,7 @@ #include <rtl/strbuf.hxx> #include "Listener.hxx" +#include "ImagePreparer.hxx" using namespace sd; using namespace ::com::sun::star::presentation; @@ -53,7 +54,7 @@ void Listener::init( const css::uno::Reference< css::presentation::XSlideShowCon Transmitter::PRIORITY_HIGH ); ImagePreparer* pPreparer = new ImagePreparer( aController, pTransmitter ); - pPreparer->launch(); + pPreparer->create(); } else { diff --git a/sd/source/ui/remotecontrol/Listener.hxx b/sd/source/ui/remotecontrol/Listener.hxx index 49405a6..63f7dc3 100644 --- a/sd/source/ui/remotecontrol/Listener.hxx +++ b/sd/source/ui/remotecontrol/Listener.hxx @@ -20,7 +20,6 @@ #include "Communicator.hxx" #include "Transmitter.hxx" -#include "ImagePreparer.hxx" namespace css = ::com::sun::star; diff --git a/sd/source/ui/remotecontrol/Server.cxx b/sd/source/ui/remotecontrol/Server.cxx index c2bff30..b33b64e 100644 --- a/sd/source/ui/remotecontrol/Server.cxx +++ b/sd/source/ui/remotecontrol/Server.cxx @@ -24,7 +24,6 @@ #include "sddll.hxx" #include "DiscoveryService.hxx" -#include "ImagePreparer.hxx" #include "Listener.hxx" #include "Receiver.hxx" #include "RemoteServer.hxx" diff --git a/sd/source/ui/remotecontrol/Transmitter.cxx b/sd/source/ui/remotecontrol/Transmitter.cxx index 2b0eb1a..e8e3388 100644 --- a/sd/source/ui/remotecontrol/Transmitter.cxx +++ b/sd/source/ui/remotecontrol/Transmitter.cxx @@ -14,8 +14,7 @@ using namespace osl; // Sockets etc. using namespace sd; Transmitter::Transmitter( BufferedStreamSocket* aSocket ) - : Thread( "TransmitterThread" ), - pStreamSocket( aSocket ), + : pStreamSocket( aSocket ), mQueuesNotEmpty(), mFinishRequested(), mQueueMutex(), @@ -24,7 +23,7 @@ Transmitter::Transmitter( BufferedStreamSocket* aSocket ) { } -void Transmitter::execute() +void SAL_CALL Transmitter::run() { while ( true ) { @@ -85,4 +84,4 @@ void Transmitter::addMessage( const OString& aMessage, const Priority aPriority } -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/remotecontrol/Transmitter.hxx b/sd/source/ui/remotecontrol/Transmitter.hxx index e227c57..80e09b1 100644 --- a/sd/source/ui/remotecontrol/Transmitter.hxx +++ b/sd/source/ui/remotecontrol/Transmitter.hxx @@ -12,7 +12,7 @@ #include <osl/conditn.hxx> #include <osl/mutex.hxx> #include "BufferedStreamSocket.hxx" -#include <salhelper/thread.hxx> +#include <osl/thread.hxx> #include <rtl/string.hxx> #include <queue> @@ -21,7 +21,7 @@ namespace sd { class Transmitter -: public salhelper::Thread +: public osl::Thread { public: enum Priority { PRIORITY_LOW = 1, PRIORITY_HIGH }; @@ -31,7 +31,7 @@ public: void notifyFinished(); private: - void execute(); + virtual void SAL_CALL run(); ::sd::BufferedStreamSocket* pStreamSocket; @@ -46,4 +46,4 @@ private: } #endif // _SD_IMPRESSREMOTE_TRANSMITTER_HXX -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit cbc5fc321fefd2ce864276fab5e66eb2465e3e94 Author: Thorsten Behrens <tbehr...@suse.com> Date: Fri Nov 23 18:01:09 2012 +0100 Add install target for sdremote makefile Because I'm too lazy to type this all the time. Change-Id: Id415087247f89a77a9d7bff5efbcceb8d020b09f diff --git a/android/sdremote/Makefile b/android/sdremote/Makefile index 3fab559..0b5ef5f 100644 --- a/android/sdremote/Makefile +++ b/android/sdremote/Makefile @@ -8,6 +8,9 @@ include ../../config_host.mk +install: all + $(ANDROID_SDK_HOME)/platform-tools/adb install -r ./bin/ImpressRemote-debug.apk + all: properties mkdir -p ../abs-lib/libs cp $(ANDROID_SDK_HOME)/extras/android/support/v4/android-support-v4.jar ../abs-lib/libs commit 3d82022ffcd8172e64784bdad19b3f8701453bd1 Author: Thorsten Behrens <tbehr...@suse.com> Date: Sat Nov 24 15:00:15 2012 +0100 Refresh notes content of PresentationFragment when data arrives. Change-Id: Ieee87f41833eff90a1971272c8cfacaa76a3558e diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java index 3c768b2..555d3e1 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java @@ -277,7 +277,11 @@ public class PresentationFragment extends SherlockFragment { // mTopView.requestLayout(); } else if (aIntent.getAction().equals( CommunicationService.MSG_SLIDE_NOTES)) { - // TODO: update me + int aPosition = aIntent.getExtras().getInt("slide_number"); + if ( aPosition == mTopView.getSelectedItemPosition() ) { + mNotes.loadData(mCommunicationService.getSlideShow() + .getNotes(aPosition), "text/html", null); + } } } commit c2c9d8a99b7cdac0268e6bdaa042aeca7481ffb1 Author: Thorsten Behrens <tbehr...@suse.com> Date: Sat Nov 24 14:59:56 2012 +0100 Fix crashes in android remote. Several objects become invalid after ending show prematurely. Data transmission may be flawed, don't rely on valid base64 etc. Change-Id: I9bb6929b9cd6b3183948662b472f92e2fa67a7e6 diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java index bf04750..5256f98 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java +++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java @@ -95,7 +95,8 @@ public class PresentationActivity extends SherlockFragmentActivity { Intent aIntent = new Intent(this, SelectorActivity.class); aIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(aIntent); - mCommunicationService.disconnect(); + if ( mCommunicationService != null ) + mCommunicationService.disconnect(); } @Override @@ -542,4 +543,4 @@ public class PresentationActivity extends SherlockFragmentActivity { } }; } -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java index 029f1d3..3c768b2 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java @@ -119,13 +119,15 @@ public class PresentationFragment extends SherlockFragment { if (mNewCoverflowHeight != 0) { ThumbnailAdapter aAdapter = (ThumbnailAdapter) mTopView .getAdapter(); - aAdapter.setHeight(mNewCoverflowHeight); - mTopView.setImageHeight(mNewCoverflowHeight); - aAdapter.setWidth(mNewCoverflowWidth); - mTopView.setImageWidth(mNewCoverflowWidth); + if ( aAdapter != null ) { + aAdapter.setHeight(mNewCoverflowHeight); + mTopView.setImageHeight(mNewCoverflowHeight); + aAdapter.setWidth(mNewCoverflowWidth); + mTopView.setImageWidth(mNewCoverflowWidth); - // We need to update the view now - aAdapter.notifyDataSetChanged(); + // We need to update the view now + aAdapter.notifyDataSetChanged(); + } } IntentFilter aFilter = new IntentFilter( diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java b/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java index df6aded..0322b1f 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java @@ -83,16 +83,20 @@ public class Receiver { } else if (aInstruction.equals("slide_preview")) { int aSlideNumber = Integer.parseInt(aCommand.get(1)); String aImageString = aCommand.get(2); - byte[] aImage = Base64.decode(aImageString, Base64.DEFAULT); - - // Store image internally - mSlideShow.putImage(aSlideNumber, aImage); - - Intent aIntent = new Intent( - CommunicationService.MSG_SLIDE_PREVIEW); - aIntent.putExtra("slide_number", aSlideNumber); - LocalBroadcastManager.getInstance(mContext).sendBroadcast( - aIntent); + try { + byte[] aImage = Base64.decode(aImageString, Base64.DEFAULT); + + // Store image internally + mSlideShow.putImage(aSlideNumber, aImage); + + Intent aIntent = new Intent( + CommunicationService.MSG_SLIDE_PREVIEW); + aIntent.putExtra("slide_number", aSlideNumber); + LocalBroadcastManager.getInstance(mContext).sendBroadcast( + aIntent); + } catch (IllegalArgumentException e) { + // Bad data - tough luck + } } else if (aInstruction.equals("slide_notes")) { int aSlideNumber = Integer.parseInt(aCommand.get(1)); String aNotes = new String(); @@ -114,4 +118,4 @@ public class Receiver { } } -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java b/android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java index a74fb2e..0b29237 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java @@ -54,7 +54,12 @@ public class SlideShow { return BitmapFactory.decodeResource(mContext.getResources(), R.drawable.image_loading); } - return BitmapFactory.decodeByteArray(aImage, 0, aImage.length); + Bitmap aBitmap = BitmapFactory.decodeByteArray(aImage, 0, aImage.length); + if (aBitmap == null) { + return BitmapFactory.decodeResource(mContext.getResources(), + R.drawable.image_loading); + } + return aBitmap; } protected void putNotes(int aSlide, String aNotes) { @@ -178,4 +183,4 @@ public class SlideShow { } } } -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits