2
// This program is free software; you can redistribute it and/or modify
3
// it under the terms of the GNU General Public License as published by
4
// the Free Software Foundation; either version 3 of the License, or
5
// (at your option) any later version.
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License for more details.
12
// You should have received a copy of the GNU General Public License
13
// along with this program; if not, write to the Free Software
14
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
public interface IConfluenceConfiguration
45
/// To be valid, all required fields must be filled out
51
/// Configuration that uses gconf to do the magic
53
public class ConfluenceConfiguration : IConfluenceConfiguration
56
/// The gnome conf key that contains the base url for our Confluence installation.
57
/// ie. http://opensource.atlassian.com/confluence/spring
59
private const string _sGCONF_KEY= "/apps/gnome-do/plugins/Confluence";
61
private GConf.Client _gconf;
63
public ConfluenceConfiguration()
65
_gconf= new GConf.Client();
68
MaxSearchResults = DefaultMaxSearchResults;
71
private void SetConfValue( string key, string val )
73
_gconf.Set( _sGCONF_KEY + "/" + key, val );
76
private string GetConfValue( string key, string fallback )
80
return _gconf.Get( _sGCONF_KEY + "/" + key ) as String;
82
catch( GConf.NoSuchKeyException )
90
get { return GetConfValue( "baseUrl", "" ); }
94
if (value.EndsWith("/"))
96
char[] trimChars = { '/' };
97
value = value.TrimEnd(trimChars);
100
SetConfValue( "baseUrl", value );
104
public string Username
106
get { return GetConfValue( "username", "" ); }
107
set { SetConfValue( "username", value ); }
110
public string Password
112
get { return GetConfValue( "password", "" ); }
113
set { SetConfValue( "password", value ); }
116
public int MaxSearchResults
122
return Convert.ToInt32(GetConfValue( "maxSearchResults", "" ));
124
catch (FormatException)
126
return DefaultMaxSearchResults;
130
set { SetConfValue( "maxSearchResults", Convert.ToString( value )); }
133
public int DefaultMaxSearchResults
142
/// To be valid, all required fields must be filled out
144
public bool IsValid()
146
return BaseUrl.Length>0;