Added missing file
[pithos-ms-client] / trunk / Pithos.Network / AccountInfo.cs
1 #region\r
2 /* -----------------------------------------------------------------------\r
3  * <copyright file="AccountInfo.cs" company="GRNet">\r
4  * \r
5  * Copyright 2011-2012 GRNET S.A. All rights reserved.\r
6  *\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
10  *\r
11  *   1. Redistributions of source code must retain the above\r
12  *      copyright notice, this list of conditions and the following\r
13  *      disclaimer.\r
14  *\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
19  *\r
20  *\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
33  *\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
38  * </copyright>\r
39  * -----------------------------------------------------------------------\r
40  */\r
41 #endregion\r
42 using System;\r
43 using System.Collections.Generic;\r
44 using Pithos.Interfaces;\r
45 \r
46 namespace Pithos.Network\r
47 {\r
48     public class AccountInfo\r
49     {\r
50         public string UserName { get; set; }\r
51         public string Token { get; set; }\r
52         public Uri StorageUri { get; set; }\r
53 \r
54         public Uri AccountKey\r
55         {\r
56             get{return new Uri(StorageUri,"../" + UserName);}\r
57         }\r
58         \r
59         private string _accountPath;\r
60         public string AccountPath\r
61         {\r
62             get { return _accountPath; }\r
63             set { _accountPath = value.ToLower(); }\r
64         }\r
65 \r
66         public int BlockSize { get; set; }\r
67 \r
68         public string BlockHash { get; set; }\r
69 \r
70         public long Quota { get; set; }\r
71 \r
72         public long BytesUsed { get; set; }\r
73 \r
74         public string Usage\r
75         {\r
76             get\r
77             {\r
78                 var gigabytes = Quota / 1073741824;\r
79                 var percentage = BytesUsed / (double)Quota;\r
80                 return String.Format("{0:P0} of {1} GB", percentage, gigabytes);\r
81             }\r
82 \r
83         }\r
84 \r
85         private string _siteUri;\r
86         public string SiteUri\r
87         {\r
88             get { return _siteUri; }\r
89             set\r
90             {\r
91                 _siteUri = value;\r
92             }\r
93         }\r
94 \r
95         public List<Group> Groups { get; set; }\r
96 \r
97     }\r
98 \r
99     public class Group\r
100     {\r
101         public string Name { get; set; }\r
102 \r
103         public List<string> Users { get; set; }\r
104 \r
105         public Group()\r
106         {\r
107             \r
108         }\r
109 \r
110         public Group(string name,string users)\r
111         {\r
112             Name = name;\r
113 \r
114             if (String.IsNullOrWhiteSpace(users))\r
115                 return;\r
116             Users=new List<string>(users.Split(','));\r
117         }\r
118     }\r
119 }\r