Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / vcl / unx / kde / UnxCommandThread.hxx
blobb893eb3559d73f36496767990d9c5171f1ed870b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_VCL_UNX_KDE_UNXCOMMANDTHREAD_HXX
21 #define INCLUDED_VCL_UNX_KDE_UNXCOMMANDTHREAD_HXX
23 #include <com/sun/star/uno/Any.hxx>
24 #include <com/sun/star/uno/Sequence.hxx>
26 #include <osl/conditn.hxx>
27 #include <osl/mutex.hxx>
28 #include <osl/thread.hxx>
29 #include <rtl/ustring.hxx>
31 #include <vcl/svapp.hxx>
33 #include <list>
35 class UnxFilePickerNotifyThread;
37 /** Synchronization for the 'thread-less' version of the fpicker.
39 Something like osl::Condition, but calls Application::Yield() while in
40 wait().
42 class YieldingCondition
44 ::osl::Mutex m_aMutex;
45 bool m_bValue;
47 bool get()
49 ::osl::MutexGuard aGuard( m_aMutex );
50 return m_bValue;
53 public:
54 YieldingCondition() { reset(); }
56 void reset()
58 ::osl::MutexGuard aGuard( m_aMutex );
59 m_bValue = false;
62 void set()
64 ::osl::MutexGuard aGuard( m_aMutex );
65 m_bValue = true;
68 void wait()
70 while ( !get() )
71 Application::Yield();
75 class UnxFilePickerCommandThread : public ::osl::Thread
77 protected:
78 UnxFilePickerNotifyThread *m_pNotifyThread;
79 int m_nReadFD;
81 ::osl::Mutex m_aMutex;
83 YieldingCondition m_aExecCondition;
84 sal_Bool m_aResult;
86 ::osl::Condition m_aGetCurrentFilterCondition;
87 OUString m_aGetCurrentFilter;
89 ::osl::Condition m_aGetDirectoryCondition;
90 OUString m_aGetDirectory;
92 ::osl::Condition m_aGetFilesCondition;
93 ::std::list< OUString > m_aGetFiles;
95 ::osl::Condition m_aGetValueCondition;
96 ::com::sun::star::uno::Any m_aGetValue;
98 public:
99 UnxFilePickerCommandThread( UnxFilePickerNotifyThread *pNotifyThread, int nReadFD );
100 ~UnxFilePickerCommandThread();
102 YieldingCondition& SAL_CALL execCondition() { return m_aExecCondition; }
103 sal_Bool SAL_CALL result();
105 ::osl::Condition& SAL_CALL getCurrentFilterCondition() { return m_aGetCurrentFilterCondition; }
106 OUString SAL_CALL getCurrentFilter();
108 ::osl::Condition& SAL_CALL getDirectoryCondition() { return m_aGetDirectoryCondition; }
109 OUString SAL_CALL getDirectory();
111 ::osl::Condition& SAL_CALL getFilesCondition() { return m_aGetFilesCondition; }
112 ::com::sun::star::uno::Sequence< OUString > SAL_CALL getFiles();
114 ::osl::Condition& SAL_CALL getValueCondition() { return m_aGetValueCondition; }
115 ::com::sun::star::uno::Any SAL_CALL getValue();
117 protected:
118 virtual void SAL_CALL run();
120 virtual void SAL_CALL handleCommand( const OUString &rCommand/*, sal_Bool &rQuit*/ );
121 ::std::list< OUString > SAL_CALL tokenize( const OUString &rCommand );
124 #endif // INCLUDED_VCL_UNX_KDE_UNXCOMMANDTHREAD_HXX
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */