1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_SVTOOLS_SYSCREDS_HXX
25 #define INCLUDED_SVTOOLS_SYSCREDS_HXX
26 
27 #include <set>
28 #include <memory>
29 #include "osl/mutex.hxx"
30 #include "rtl/ustring.hxx"
31 #include "com/sun/star/uno/Sequence.hxx"
32 #include "unotools/configitem.hxx"
33 
34 class SysCredentialsConfig;
35 
36 class SysCredentialsConfigItem : public utl::ConfigItem
37 {
38 	public:
39         SysCredentialsConfigItem( SysCredentialsConfig * pOwner );
40 		//virtual ~SysCredentialsConfigItem();
41 
42     	virtual void Notify(
43             const com::sun::star::uno::Sequence< rtl::OUString > &
44                 seqPropertyNames );
45     	virtual void Commit();
46 
47 		com::sun::star::uno::Sequence< rtl::OUString >
48         getSystemCredentialsURLs();
49 
50         void setSystemCredentialsURLs(
51             const com::sun::star::uno::Sequence< rtl::OUString > &
52                 seqURLList );
53 
54 		//bool isSystemCredentialsURL( const rtl::OUString & rURL ) const;
55 
56 private:
57         ::osl::Mutex m_aMutex;
58         bool m_bInited;
59         com::sun::star::uno::Sequence< rtl::OUString > m_seqURLs;
60         SysCredentialsConfig * m_pOwner;
61 };
62 
63 typedef std::set< rtl::OUString > StringSet;
64 
65 class SysCredentialsConfig
66 {
67 	public:
68         SysCredentialsConfig();
69 
70         rtl::OUString find( rtl::OUString const & rURL );
71         void add( rtl::OUString const & rURL, bool bPersistent );
72         void remove( rtl::OUString const & rURL );
73         com::sun::star::uno::Sequence< rtl::OUString > list( bool bOnlyPersistent );
74 
75         void persistentConfigChanged();
76 
77     private:
78         void initCfg();
79         void writeCfg();
80 
81         ::osl::Mutex m_aMutex;
82         StringSet    m_aMemContainer;
83         StringSet    m_aCfgContainer;
84         SysCredentialsConfigItem m_aConfigItem;
85         bool         m_bCfgInited;
86 };
87 
88 #endif // INCLUDED_SVTOOLS_SYSCREDS_HXX
89