root / trunk / Pithos.Client.WPF / Preferences / ProxyAccountViewModel.cs @ f2d88248
History | View | Annotate | Download (4.6 kB)
1 | 255f5f86 | Panagiotis Kanavos | #region |
---|---|---|---|
2 | 255f5f86 | Panagiotis Kanavos | /* ----------------------------------------------------------------------- |
3 | 255f5f86 | Panagiotis Kanavos | * <copyright file="ProxyAccountViewModel.cs" company="GRNet"> |
4 | 255f5f86 | Panagiotis Kanavos | * |
5 | 255f5f86 | Panagiotis Kanavos | * Copyright 2011-2012 GRNET S.A. All rights reserved. |
6 | 255f5f86 | Panagiotis Kanavos | * |
7 | 255f5f86 | Panagiotis Kanavos | * Redistribution and use in source and binary forms, with or |
8 | 255f5f86 | Panagiotis Kanavos | * without modification, are permitted provided that the following |
9 | 255f5f86 | Panagiotis Kanavos | * conditions are met: |
10 | 255f5f86 | Panagiotis Kanavos | * |
11 | 255f5f86 | Panagiotis Kanavos | * 1. Redistributions of source code must retain the above |
12 | 255f5f86 | Panagiotis Kanavos | * copyright notice, this list of conditions and the following |
13 | 255f5f86 | Panagiotis Kanavos | * disclaimer. |
14 | 255f5f86 | Panagiotis Kanavos | * |
15 | 255f5f86 | Panagiotis Kanavos | * 2. Redistributions in binary form must reproduce the above |
16 | 255f5f86 | Panagiotis Kanavos | * copyright notice, this list of conditions and the following |
17 | 255f5f86 | Panagiotis Kanavos | * disclaimer in the documentation and/or other materials |
18 | 255f5f86 | Panagiotis Kanavos | * provided with the distribution. |
19 | 255f5f86 | Panagiotis Kanavos | * |
20 | 255f5f86 | Panagiotis Kanavos | * |
21 | 255f5f86 | Panagiotis Kanavos | * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS |
22 | 255f5f86 | Panagiotis Kanavos | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
23 | 255f5f86 | Panagiotis Kanavos | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
24 | 255f5f86 | Panagiotis Kanavos | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR |
25 | 255f5f86 | Panagiotis Kanavos | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
26 | 255f5f86 | Panagiotis Kanavos | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
27 | 255f5f86 | Panagiotis Kanavos | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
28 | 255f5f86 | Panagiotis Kanavos | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
29 | 255f5f86 | Panagiotis Kanavos | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | 255f5f86 | Panagiotis Kanavos | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
31 | 255f5f86 | Panagiotis Kanavos | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
32 | 255f5f86 | Panagiotis Kanavos | * POSSIBILITY OF SUCH DAMAGE. |
33 | 255f5f86 | Panagiotis Kanavos | * |
34 | 255f5f86 | Panagiotis Kanavos | * The views and conclusions contained in the software and |
35 | 255f5f86 | Panagiotis Kanavos | * documentation are those of the authors and should not be |
36 | 255f5f86 | Panagiotis Kanavos | * interpreted as representing official policies, either expressed |
37 | 255f5f86 | Panagiotis Kanavos | * or implied, of GRNET S.A. |
38 | 255f5f86 | Panagiotis Kanavos | * </copyright> |
39 | 255f5f86 | Panagiotis Kanavos | * ----------------------------------------------------------------------- |
40 | 255f5f86 | Panagiotis Kanavos | */ |
41 | 255f5f86 | Panagiotis Kanavos | #endregion |
42 | 65282d58 | Panagiotis Kanavos | using System.ComponentModel.Composition; |
43 | 65282d58 | Panagiotis Kanavos | using System.Diagnostics.Contracts; |
44 | 65282d58 | Panagiotis Kanavos | using System.Net; |
45 | 65282d58 | Panagiotis Kanavos | using Caliburn.Micro; |
46 | 65282d58 | Panagiotis Kanavos | using Pithos.Client.WPF.Configuration; |
47 | 65282d58 | Panagiotis Kanavos | |
48 | 65282d58 | Panagiotis Kanavos | namespace Pithos.Client.WPF.Preferences |
49 | 65282d58 | Panagiotis Kanavos | { |
50 | 65282d58 | Panagiotis Kanavos | using System; |
51 | 65282d58 | Panagiotis Kanavos | using System.Collections.Generic; |
52 | 65282d58 | Panagiotis Kanavos | using System.Linq; |
53 | 65282d58 | Panagiotis Kanavos | using System.Text; |
54 | 65282d58 | Panagiotis Kanavos | |
55 | 65282d58 | Panagiotis Kanavos | [Export(typeof(ProxyAccountViewModel))] |
56 | 65282d58 | Panagiotis Kanavos | public class ProxyAccountViewModel:Screen |
57 | 65282d58 | Panagiotis Kanavos | { |
58 | 65282d58 | Panagiotis Kanavos | public override string DisplayName |
59 | 65282d58 | Panagiotis Kanavos | { |
60 | 65282d58 | Panagiotis Kanavos | get { return "Proxy Settings"; } |
61 | 65282d58 | Panagiotis Kanavos | set |
62 | 65282d58 | Panagiotis Kanavos | { |
63 | 65282d58 | Panagiotis Kanavos | base.DisplayName = value; |
64 | 65282d58 | Panagiotis Kanavos | } |
65 | 65282d58 | Panagiotis Kanavos | } |
66 | 65282d58 | Panagiotis Kanavos | private string _userName; |
67 | 65282d58 | Panagiotis Kanavos | public string UserName |
68 | 65282d58 | Panagiotis Kanavos | { |
69 | 65282d58 | Panagiotis Kanavos | get { return _userName; } |
70 | 65282d58 | Panagiotis Kanavos | set |
71 | 65282d58 | Panagiotis Kanavos | { |
72 | 65282d58 | Panagiotis Kanavos | if (String.IsNullOrWhiteSpace(value)) |
73 | 65282d58 | Panagiotis Kanavos | throw new ArgumentNullException(); |
74 | 65282d58 | Panagiotis Kanavos | _userName = value; |
75 | 65282d58 | Panagiotis Kanavos | NotifyOfPropertyChange(()=>UserName); |
76 | 65282d58 | Panagiotis Kanavos | } |
77 | 65282d58 | Panagiotis Kanavos | } |
78 | 65282d58 | Panagiotis Kanavos | |
79 | 65282d58 | Panagiotis Kanavos | private string _password; |
80 | 65282d58 | Panagiotis Kanavos | public string Password |
81 | 65282d58 | Panagiotis Kanavos | { |
82 | 65282d58 | Panagiotis Kanavos | get { return _password; } |
83 | 65282d58 | Panagiotis Kanavos | set |
84 | 65282d58 | Panagiotis Kanavos | { |
85 | 65282d58 | Panagiotis Kanavos | if (String.IsNullOrWhiteSpace(value)) |
86 | 65282d58 | Panagiotis Kanavos | throw new ArgumentNullException(); |
87 | 65282d58 | Panagiotis Kanavos | _password = value; |
88 | 65282d58 | Panagiotis Kanavos | NotifyOfPropertyChange(()=>Password); |
89 | 65282d58 | Panagiotis Kanavos | } |
90 | 65282d58 | Panagiotis Kanavos | } |
91 | 65282d58 | Panagiotis Kanavos | |
92 | 65282d58 | Panagiotis Kanavos | private string _domain; |
93 | 65282d58 | Panagiotis Kanavos | public string Domain |
94 | 65282d58 | Panagiotis Kanavos | { |
95 | 65282d58 | Panagiotis Kanavos | get { return _domain; } |
96 | 65282d58 | Panagiotis Kanavos | set |
97 | 65282d58 | Panagiotis Kanavos | { |
98 | 65282d58 | Panagiotis Kanavos | _domain = value; |
99 | 65282d58 | Panagiotis Kanavos | NotifyOfPropertyChange(()=>Domain); |
100 | 65282d58 | Panagiotis Kanavos | } |
101 | 65282d58 | Panagiotis Kanavos | } |
102 | 65282d58 | Panagiotis Kanavos | |
103 | 65282d58 | Panagiotis Kanavos | public PithosSettings Settings |
104 | 65282d58 | Panagiotis Kanavos | { |
105 | 65282d58 | Panagiotis Kanavos | get { return _settings; } |
106 | 65282d58 | Panagiotis Kanavos | set |
107 | 65282d58 | Panagiotis Kanavos | { |
108 | 65282d58 | Panagiotis Kanavos | _settings = value; |
109 | 34bdb91d | Panagiotis Kanavos | UserName = _settings.ProxyUsername; |
110 | 34bdb91d | Panagiotis Kanavos | Password = _settings.ProxyPassword; |
111 | 34bdb91d | Panagiotis Kanavos | Domain = _settings.ProxyDomain; |
112 | 34bdb91d | Panagiotis Kanavos | NotifyOfPropertyChange(() => Settings); |
113 | 65282d58 | Panagiotis Kanavos | } |
114 | 65282d58 | Panagiotis Kanavos | } |
115 | 65282d58 | Panagiotis Kanavos | |
116 | 65282d58 | Panagiotis Kanavos | private PithosSettings _settings; |
117 | 65282d58 | Panagiotis Kanavos | |
118 | 65282d58 | Panagiotis Kanavos | |
119 | 34bdb91d | Panagiotis Kanavos | public ProxyAccountViewModel() |
120 | 34bdb91d | Panagiotis Kanavos | { |
121 | 34bdb91d | Panagiotis Kanavos | |
122 | 65282d58 | Panagiotis Kanavos | } |
123 | 65282d58 | Panagiotis Kanavos | |
124 | 65282d58 | Panagiotis Kanavos | public void SaveChanges() |
125 | 65282d58 | Panagiotis Kanavos | { |
126 | 65282d58 | Panagiotis Kanavos | /* |
127 | 65282d58 | Panagiotis Kanavos | Settings.ProxyUsername = UserName; |
128 | 65282d58 | Panagiotis Kanavos | Settings.ProxyPassword = Password; |
129 | 65282d58 | Panagiotis Kanavos | Settings.ProxyDomain = Domain; |
130 | 65282d58 | Panagiotis Kanavos | Settings.UseManualProxy = true; |
131 | 65282d58 | Panagiotis Kanavos | Settings.UseDefaultProxy = false; |
132 | 65282d58 | Panagiotis Kanavos | Settings.UseNoProxy = false; |
133 | 65282d58 | Panagiotis Kanavos | Settings.ProxyAuthentication = true; |
134 | 65282d58 | Panagiotis Kanavos | */ |
135 | 34bdb91d | Panagiotis Kanavos | Proxy.SetCredentials(Settings.ProxyUsername, Settings.ProxyPassword, Settings.ProxyDomain); |
136 | 65282d58 | Panagiotis Kanavos | this.TryClose(true); |
137 | 65282d58 | Panagiotis Kanavos | } |
138 | 65282d58 | Panagiotis Kanavos | |
139 | 65282d58 | Panagiotis Kanavos | public void RejectChanges() |
140 | 65282d58 | Panagiotis Kanavos | { |
141 | 65282d58 | Panagiotis Kanavos | this.TryClose(); |
142 | 65282d58 | Panagiotis Kanavos | } |
143 | 65282d58 | Panagiotis Kanavos | } |
144 | 65282d58 | Panagiotis Kanavos | } |