2 /* -----------------------------------------------------------------------
\r
3 * <copyright file="ProxyAccountViewModel.cs" company="GRNet">
\r
5 * Copyright 2011-2012 GRNET S.A. All rights reserved.
\r
7 * Redistribution and use in source and binary forms, with or
\r
8 * without modification, are permitted provided that the following
\r
9 * conditions are met:
\r
11 * 1. Redistributions of source code must retain the above
\r
12 * copyright notice, this list of conditions and the following
\r
15 * 2. Redistributions in binary form must reproduce the above
\r
16 * copyright notice, this list of conditions and the following
\r
17 * disclaimer in the documentation and/or other materials
\r
18 * provided with the distribution.
\r
21 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
\r
22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
\r
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
\r
24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
\r
25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
\r
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
\r
28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
\r
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
\r
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
\r
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
32 * POSSIBILITY OF SUCH DAMAGE.
\r
34 * The views and conclusions contained in the software and
\r
35 * documentation are those of the authors and should not be
\r
36 * interpreted as representing official policies, either expressed
\r
37 * or implied, of GRNET S.A.
\r
39 * -----------------------------------------------------------------------
\r
42 using System.ComponentModel.Composition;
\r
43 using System.Diagnostics.Contracts;
\r
45 using Caliburn.Micro;
\r
46 using Pithos.Client.WPF.Configuration;
\r
48 namespace Pithos.Client.WPF.Preferences
\r
51 using System.Collections.Generic;
\r
55 [Export(typeof(ProxyAccountViewModel))]
\r
56 public class ProxyAccountViewModel:Screen
\r
58 public override string DisplayName
\r
60 get { return "Proxy Settings"; }
\r
63 base.DisplayName = value;
\r
66 private string _userName;
\r
67 public string UserName
\r
69 get { return _userName; }
\r
72 if (String.IsNullOrWhiteSpace(value))
\r
73 throw new ArgumentNullException();
\r
75 NotifyOfPropertyChange(()=>UserName);
\r
79 private string _password;
\r
80 public string Password
\r
82 get { return _password; }
\r
85 if (String.IsNullOrWhiteSpace(value))
\r
86 throw new ArgumentNullException();
\r
88 NotifyOfPropertyChange(()=>Password);
\r
92 private string _domain;
\r
93 public string Domain
\r
95 get { return _domain; }
\r
99 NotifyOfPropertyChange(()=>Domain);
\r
103 public PithosSettings Settings
\r
105 get { return _settings; }
\r
109 UserName = _settings.ProxyUsername;
\r
110 Password = _settings.ProxyPassword;
\r
111 Domain = _settings.ProxyDomain;
\r
112 NotifyOfPropertyChange(() => Settings);
\r
116 private PithosSettings _settings;
\r
119 public ProxyAccountViewModel()
\r
124 public void SaveChanges()
\r
127 Settings.ProxyUsername = UserName;
\r
128 Settings.ProxyPassword = Password;
\r
129 Settings.ProxyDomain = Domain;
\r
130 Settings.UseManualProxy = true;
\r
131 Settings.UseDefaultProxy = false;
\r
132 Settings.UseNoProxy = false;
\r
133 Settings.ProxyAuthentication = true;
\r
135 Proxy.SetCredentials(Settings.ProxyUsername, Settings.ProxyPassword, Settings.ProxyDomain);
\r
136 this.TryClose(true);
\r
139 public void RejectChanges()
\r