Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include "interact.hxx"
22 :
23 : #include "com/sun/star/java/JavaDisabledException.hpp"
24 : #include "com/sun/star/java/JavaVMCreationFailureException.hpp"
25 : #include "com/sun/star/task/XInteractionAbort.hpp"
26 : #include "com/sun/star/task/XInteractionRetry.hpp"
27 : #include "com/sun/star/task/XInteractionContinuation.hpp"
28 : #include "cppuhelper/implbase1.hxx"
29 : #include "osl/mutex.hxx"
30 :
31 : using stoc_javavm::InteractionRequest;
32 :
33 : namespace {
34 :
35 : class AbortContinuation:
36 : public cppu::WeakImplHelper1< css::task::XInteractionAbort >
37 : {
38 : public:
39 0 : inline AbortContinuation() {}
40 :
41 0 : virtual inline void SAL_CALL select() throw (css::uno::RuntimeException) {}
42 :
43 : private:
44 : AbortContinuation(AbortContinuation &); // not implemented
45 : void operator =(AbortContinuation); // not implemented
46 :
47 0 : virtual inline ~AbortContinuation() {}
48 : };
49 :
50 : }
51 :
52 : class InteractionRequest::RetryContinuation:
53 : public cppu::WeakImplHelper1< css::task::XInteractionRetry >
54 : {
55 : public:
56 0 : inline RetryContinuation(): m_bSelected(false) {}
57 :
58 : virtual void SAL_CALL select() throw (css::uno::RuntimeException);
59 :
60 : bool isSelected() const;
61 :
62 : private:
63 : RetryContinuation(RetryContinuation &); // not implemented
64 : void operator =(RetryContinuation); // not implemented
65 :
66 0 : virtual inline ~RetryContinuation() {}
67 :
68 : mutable osl::Mutex m_aMutex;
69 : bool m_bSelected;
70 : };
71 :
72 0 : void SAL_CALL InteractionRequest::RetryContinuation::select()
73 : throw (css::uno::RuntimeException)
74 : {
75 0 : osl::MutexGuard aGuard(m_aMutex);
76 0 : m_bSelected = true;
77 0 : }
78 :
79 0 : bool InteractionRequest::RetryContinuation::isSelected() const
80 : {
81 0 : osl::MutexGuard aGuard(m_aMutex);
82 0 : return m_bSelected;
83 : }
84 :
85 0 : InteractionRequest::InteractionRequest(css::uno::Any const & rRequest):
86 0 : m_aRequest(rRequest)
87 : {
88 0 : m_aContinuations.realloc(2);
89 0 : m_xRetryContinuation = new RetryContinuation;
90 0 : m_aContinuations[0] = new AbortContinuation;
91 0 : m_aContinuations[1] = m_xRetryContinuation.get();
92 0 : }
93 :
94 0 : css::uno::Any SAL_CALL InteractionRequest::getRequest()
95 : throw (css::uno::RuntimeException)
96 : {
97 0 : return m_aRequest;
98 : }
99 :
100 : css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >
101 0 : SAL_CALL InteractionRequest::getContinuations()
102 : throw (css::uno::RuntimeException)
103 : {
104 0 : return m_aContinuations;
105 : }
106 :
107 0 : bool InteractionRequest::retry() const
108 : {
109 0 : return m_xRetryContinuation.is() && m_xRetryContinuation->isSelected();
110 : }
111 :
112 0 : InteractionRequest::~InteractionRequest()
113 0 : {}
114 :
115 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|