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"
12 using namespace osl
; // Sockets etc.
15 Transmitter::Transmitter( IBluetoothSocket
* aSocket
)
16 : pStreamSocket( aSocket
),
25 void SAL_CALL
Transmitter::run()
29 mQueuesNotEmpty
.wait();
31 if ( mFinishRequested
.check() )
34 ::osl::MutexGuard
aQueueGuard( mQueueMutex
);
35 if ( !mHighPriority
.empty() )
37 OString
aMessage( mHighPriority
.front() );
39 SAL_INFO( "sdremote.bluetooth", "write high prio line '" << aMessage
<< "'" );
40 pStreamSocket
->write( aMessage
.getStr(), aMessage
.getLength() );
42 else if ( !mLowPriority
.empty() )
44 OString
aMessage( mLowPriority
.front() );
46 SAL_INFO( "sdremote.bluetooth", "write normal line '" << aMessage
<< "'" );
47 pStreamSocket
->write( aMessage
.getStr(), aMessage
.getLength() );
50 if ( mLowPriority
.empty() && mHighPriority
.empty() )
52 mQueuesNotEmpty
.reset();
57 void Transmitter::notifyFinished()
59 mFinishRequested
.set();
60 mQueuesNotEmpty
.set();
63 Transmitter::~Transmitter()
67 void Transmitter::addMessage( const OString
& aMessage
, const Priority aPriority
)
69 ::osl::MutexGuard
aQueueGuard( mQueueMutex
);
73 mLowPriority
.push( aMessage
);
76 mHighPriority
.push( aMessage
);
79 if ( !mQueuesNotEmpty
.check() )
81 mQueuesNotEmpty
.set();
86 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */