1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 #include "Transmitter.hxx"
10 #include "IBluetoothSocket.hxx"
11 #include <sal/log.hxx>
14 using namespace osl
; // Sockets etc.
17 Transmitter::Transmitter( IBluetoothSocket
* aSocket
)
18 : pStreamSocket( aSocket
),
27 void SAL_CALL
Transmitter::run()
29 osl_setThreadName("bluetooth Transmitter");
33 mQueuesNotEmpty
.wait();
35 if ( mFinishRequested
.check() )
38 ::osl::MutexGuard
aQueueGuard( mQueueMutex
);
39 if ( !mHighPriority
.empty() )
41 OString
aMessage( mHighPriority
.front() );
43 SAL_INFO( "sdremote.bluetooth", "write high prio line '" << aMessage
<< "'" );
44 pStreamSocket
->write( aMessage
.getStr(), aMessage
.getLength() );
46 else if ( !mLowPriority
.empty() )
48 OString
aMessage( mLowPriority
.front() );
50 SAL_INFO( "sdremote.bluetooth", "write normal line '" << aMessage
<< "'" );
51 pStreamSocket
->write( aMessage
.getStr(), aMessage
.getLength() );
54 if ( mLowPriority
.empty() && mHighPriority
.empty() )
56 mQueuesNotEmpty
.reset();
61 void Transmitter::notifyFinished()
63 mFinishRequested
.set();
64 mQueuesNotEmpty
.set();
67 Transmitter::~Transmitter()
71 void Transmitter::addMessage( const OString
& aMessage
, const Priority aPriority
)
73 ::osl::MutexGuard
aQueueGuard( mQueueMutex
);
77 mLowPriority
.push( aMessage
);
80 mHighPriority
.push( aMessage
);
83 if ( !mQueuesNotEmpty
.check() )
85 mQueuesNotEmpty
.set();
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */