xref: /AOO41X/main/vcl/unx/generic/dtrans/config.cxx (revision c82f28778d59b20a7e6c0f9982d1bc73807a432a)
1*c82f2877SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c82f2877SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c82f2877SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c82f2877SAndrew Rist  * distributed with this work for additional information
6*c82f2877SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c82f2877SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c82f2877SAndrew Rist  * "License"); you may not use this file except in compliance
9*c82f2877SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*c82f2877SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*c82f2877SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c82f2877SAndrew Rist  * software distributed under the License is distributed on an
15*c82f2877SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c82f2877SAndrew Rist  * KIND, either express or implied.  See the License for the
17*c82f2877SAndrew Rist  * specific language governing permissions and limitations
18*c82f2877SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*c82f2877SAndrew Rist  *************************************************************/
21*c82f2877SAndrew Rist 
22*c82f2877SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <cstdio>
28cdf0e10cSrcweir #include <unotools/configitem.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "X11_selection.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #define SETTINGS_CONFIGNODE "VCL/Settings/Transfer"
33cdf0e10cSrcweir #define SELECTION_PROPERTY "SelectionTimeout"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace x11
36cdf0e10cSrcweir {
37cdf0e10cSrcweir 
38cdf0e10cSrcweir class DtransX11ConfigItem : public ::utl::ConfigItem
39cdf0e10cSrcweir {
40cdf0e10cSrcweir     sal_Int32           m_nSelectionTimeout;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir     virtual void Notify( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rPropertyNames );
43cdf0e10cSrcweir     virtual void Commit();
44cdf0e10cSrcweir public:
45cdf0e10cSrcweir     DtransX11ConfigItem();
46cdf0e10cSrcweir     virtual ~DtransX11ConfigItem();
47cdf0e10cSrcweir 
getSelectionTimeout() const48cdf0e10cSrcweir     sal_Int32 getSelectionTimeout() const { return m_nSelectionTimeout; }
49cdf0e10cSrcweir };
50cdf0e10cSrcweir 
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
53cdf0e10cSrcweir using namespace com::sun::star::lang;
54cdf0e10cSrcweir using namespace com::sun::star::uno;
55cdf0e10cSrcweir using namespace rtl;
56cdf0e10cSrcweir using namespace x11;
57cdf0e10cSrcweir 
getSelectionTimeout()58cdf0e10cSrcweir sal_Int32 SelectionManager::getSelectionTimeout()
59cdf0e10cSrcweir {
60cdf0e10cSrcweir     if( m_nSelectionTimeout < 1 )
61cdf0e10cSrcweir     {
62cdf0e10cSrcweir         DtransX11ConfigItem aCfg;
63cdf0e10cSrcweir         m_nSelectionTimeout = aCfg.getSelectionTimeout();
64cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
65cdf0e10cSrcweir         fprintf( stderr, "initialized selection timeout to %ld seconds\n", m_nSelectionTimeout );
66cdf0e10cSrcweir #endif
67cdf0e10cSrcweir     }
68cdf0e10cSrcweir     return m_nSelectionTimeout;
69cdf0e10cSrcweir }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir /*
72cdf0e10cSrcweir  *  DtransX11ConfigItem constructor
73cdf0e10cSrcweir  */
74cdf0e10cSrcweir 
DtransX11ConfigItem()75cdf0e10cSrcweir DtransX11ConfigItem::DtransX11ConfigItem() :
76cdf0e10cSrcweir     ConfigItem( OUString( RTL_CONSTASCII_USTRINGPARAM( SETTINGS_CONFIGNODE ) ),
77cdf0e10cSrcweir                 CONFIG_MODE_DELAYED_UPDATE ),
78cdf0e10cSrcweir     m_nSelectionTimeout( 3 )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     if( IsValidConfigMgr() )
81cdf0e10cSrcweir     {
82cdf0e10cSrcweir         Sequence< OUString > aKeys( 1 );
83cdf0e10cSrcweir         aKeys.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SELECTION_PROPERTY ) );
84cdf0e10cSrcweir         Sequence< Any > aValues = GetProperties( aKeys );
85cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
86cdf0e10cSrcweir         fprintf( stderr, "found %ld properties for %s\n", aValues.getLength(), SELECTION_PROPERTY );
87cdf0e10cSrcweir #endif
88cdf0e10cSrcweir         Any* pValue = aValues.getArray();
89cdf0e10cSrcweir         for( int i = 0; i < aValues.getLength(); i++, pValue++ )
90cdf0e10cSrcweir         {
91cdf0e10cSrcweir             if( pValue->getValueTypeClass() == TypeClass_STRING )
92cdf0e10cSrcweir             {
93cdf0e10cSrcweir                 const OUString* pLine = (const OUString*)pValue->getValue();
94cdf0e10cSrcweir                 if( pLine->getLength() )
95cdf0e10cSrcweir                 {
96cdf0e10cSrcweir                     m_nSelectionTimeout = pLine->toInt32();
97cdf0e10cSrcweir                     if( m_nSelectionTimeout < 1 )
98cdf0e10cSrcweir                         m_nSelectionTimeout = 1;
99cdf0e10cSrcweir                 }
100cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
101cdf0e10cSrcweir                 fprintf( stderr, "found SelectionTimeout \"%s\"\n",
102cdf0e10cSrcweir                 OUStringToOString( *pLine, osl_getThreadTextEncoding() ).getStr() );
103cdf0e10cSrcweir #endif
104cdf0e10cSrcweir             }
105cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
106cdf0e10cSrcweir             else
107cdf0e10cSrcweir                 fprintf( stderr, "found SelectionTimeout of type \"%s\"\n",
108cdf0e10cSrcweir                 OUStringToOString( pValue->getValueType().getTypeName(), osl_getThreadTextEncoding() ).getStr() );
109cdf0e10cSrcweir #endif
110cdf0e10cSrcweir         }
111cdf0e10cSrcweir     }
112cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
113cdf0e10cSrcweir     else
114cdf0e10cSrcweir         fprintf( stderr, "no valid configmanager, could not read timeout setting\n" );
115cdf0e10cSrcweir #endif
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir /*
119cdf0e10cSrcweir  *  DtransX11ConfigItem destructor
120cdf0e10cSrcweir  */
121cdf0e10cSrcweir 
~DtransX11ConfigItem()122cdf0e10cSrcweir DtransX11ConfigItem::~DtransX11ConfigItem()
123cdf0e10cSrcweir {
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
126cdf0e10cSrcweir /*
127cdf0e10cSrcweir  *  DtransX11ConfigItem::Commit
128cdf0e10cSrcweir  */
129cdf0e10cSrcweir 
Commit()130cdf0e10cSrcweir void DtransX11ConfigItem::Commit()
131cdf0e10cSrcweir {
132cdf0e10cSrcweir     // for the clipboard service this is readonly, so
133cdf0e10cSrcweir     // there is nothing to commit
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir /*
137cdf0e10cSrcweir  *  DtransX11ConfigItem::Notify
138cdf0e10cSrcweir  */
139cdf0e10cSrcweir 
Notify(const Sequence<OUString> &)140cdf0e10cSrcweir void DtransX11ConfigItem::Notify( const Sequence< OUString >& /*rPropertyNames*/ )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 
145