Added missing file
[pithos-ms-client] / trunk / Pithos.Core / IStatusNotification.cs
1 #region\r
2 /* -----------------------------------------------------------------------\r
3  * <copyright file="IStatusNotification.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.Collections.Generic;\r
43 using System.Diagnostics;\r
44 using System.IO;\r
45 using Pithos.Interfaces;\r
46 using Pithos.Network;\r
47 \r
48 namespace Pithos.Core\r
49 {\r
50     public interface IStatusNotification\r
51     {        \r
52         void NotifyChange(string status,TraceLevel level=TraceLevel.Info);\r
53         void NotifyChangedFile(string filePath);\r
54         void NotifyAccount(AccountInfo policy);\r
55         void NotifyConflicts(IEnumerable<FileSystemInfo> conflictFiles, string message);\r
56         void NotifyForFiles(IEnumerable<FileSystemInfo> files, string message,TraceLevel level);\r
57         void Notify(Notification notification);\r
58         void SetPithosStatus(PithosStatus status);\r
59         void SetPithosStatus(PithosStatus localSyncing, string format);\r
60         //Notifier GetNotifier(Notification startNotification, Notification endNotification);\r
61         Notifier GetNotifier(string startMessage, string endMessage,bool isActive=true,params object[] args);\r
62     }\r
63 \r
64     public class Notification\r
65     {\r
66         public TraceLevel Level { get; set; }\r
67         public string Title { get; set; }\r
68         public string Message { get; set; }\r
69 \r
70         public Notification()\r
71         {\r
72             Level=TraceLevel.Info;\r
73             Title = "";\r
74             Message = "";\r
75         }\r
76     }\r
77 \r
78     public class StatusNotification:Notification\r
79     {\r
80         public StatusNotification(string title)\r
81         {\r
82             Level = TraceLevel.Info;\r
83             Title = title;\r
84         }\r
85     }\r
86 \r
87     public class ProgressNotification:Notification\r
88     {\r
89         public string FileName { get; set; }\r
90         public long Block { get; set; }\r
91         public int TotalBlocks { get; set; }\r
92         public long FileSize { get; set; }\r
93         public string Action { get; set; }\r
94         public int BlockPercentage { get; set; }\r
95         \r
96         public ProgressNotification(string fileName, string action, long block, int blockPercentage,int totalBlocks, long fileSize)\r
97         {\r
98             FileName = fileName;\r
99             Block = block;\r
100             TotalBlocks = totalBlocks;\r
101             FileSize = fileSize;\r
102             Action = action;\r
103             BlockPercentage = blockPercentage;\r
104 \r
105         }\r
106     }\r
107 \r
108     public class Notification<T>:Notification\r
109     {\r
110         public T Data { get; set; }\r
111     }\r
112 \r
113     public class FilesNotification:Notification<IEnumerable<FileSystemInfo>>\r
114     {        \r
115     }\r
116 \r
117     public class PollNotification:Notification\r
118     {\r
119         public PollNotification()\r
120         {\r
121             Level=TraceLevel.Verbose;\r
122             Title = "Pithos";\r
123             Message = "Polling";\r
124         }\r
125     }\r
126 \r
127     public class CloudNotification:Notification<ObjectInfo>\r
128     {\r
129         \r
130     }\r
131     public class CloudDeleteNotification:CloudNotification\r
132     {\r
133         \r
134     }\r
135 \r
136     public class ExpirationNotification:Notification<AccountSettings>\r
137     {\r
138         public ExpirationNotification(AccountSettings account)\r
139         {\r
140             Data = account;\r
141             Level = TraceLevel.Error;\r
142             Title = "Account key expired";\r
143             Message = string.Format("Please renew the key for the account {0} from the Preferences page", account.AccountName);\r
144         }\r
145     }\r
146 }