~ifolder-dev/simias/trunk-packaging

« back to all changes in this revision

Viewing changes to src/core/SimiasClient/.svn/text-base/NodeEventArgs.cs.svn-base

  • Committer: Jorge O. Castro
  • Date: 2007-12-03 06:56:46 UTC
  • Revision ID: jorge@ubuntu.com-20071203065646-mupcnjcwgm5mnhyt
* Remove a bunch of .svn directories we no longer need.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
 |
3
 
 | Copyright (c) 2007 Novell, Inc.
4
 
 | All Rights Reserved.
5
 
 |
6
 
 | This program is free software; you can redistribute it and/or
7
 
 | modify it under the terms of version 2 of the GNU General Public License as
8
 
 | published by the Free Software Foundation.
9
 
 |
10
 
 | This program is distributed in the hope that it will be useful,
11
 
 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 | GNU General Public License for more details.
14
 
 |
15
 
 | You should have received a copy of the GNU General Public License
16
 
 | along with this program; if not, contact Novell, Inc.
17
 
 |
18
 
 | To contact Novell about this file by physical or electronic mail,
19
 
 | you may find current contact information at www.novell.com 
20
 
 |
21
 
 | Author: Russ Young
22
 
 |***************************************************************************/
23
 
 
24
 
using System;
25
 
using System.Text;
26
 
 
27
 
namespace Simias.Client.Event
28
 
{
29
 
        /// <summary>
30
 
        /// The Event types supported.
31
 
        /// </summary>
32
 
        [Flags]
33
 
        public enum EventType : short
34
 
        {
35
 
                /// <summary>
36
 
                /// The event is for a node create.
37
 
                /// </summary>
38
 
                NodeCreated = 1,
39
 
                /// <summary>
40
 
                /// The event is for a node delete.
41
 
                /// </summary>
42
 
                NodeDeleted = 2,
43
 
                /// <summary>
44
 
                /// The event is for a node change.
45
 
                /// </summary>
46
 
                NodeChanged = 4,
47
 
                /// <summary>
48
 
                /// The event is for no access.
49
 
                /// </summary>
50
 
                NoAccess = 8
51
 
        };
52
 
 
53
 
        /// <summary>
54
 
        /// The event arguments for a Collection event.
55
 
        /// </summary>
56
 
        [Serializable]
57
 
        public class NodeEventArgs : SimiasEventArgs
58
 
        {
59
 
                #region Fields
60
 
 
61
 
                string                                  source;
62
 
                string                                  id;
63
 
                string                                  collection;
64
 
                string                                  modifier;
65
 
                string                                  type;
66
 
                int                                             eventId;
67
 
                ulong                                   masterRev;
68
 
                ulong                                   slaveRev;
69
 
                long                                    fileSize;
70
 
 
71
 
                /// <summary>
72
 
                /// Flags for the node event.
73
 
                /// </summary>
74
 
                [Flags]
75
 
                public enum EventFlags : ushort
76
 
                {
77
 
                        /// <summary>
78
 
                        /// The event was caused by local only properties.
79
 
                        /// </summary>
80
 
                        LocalOnly = 1,
81
 
                }
82
 
 
83
 
                EventFlags                              flags;
84
 
                
85
 
                #endregion
86
 
 
87
 
                #region Constructor
88
 
 
89
 
                /// <summary>
90
 
                /// Constructs a SimiasEventArgs that will be used by CollectionHandler delegates.
91
 
                /// Describes the node affected by the event.
92
 
                /// </summary>
93
 
                /// <param name="source">The source of the event.</param>
94
 
                /// <param name="node">The object of the event.</param>
95
 
                /// <param name="collection">The Collection that the node belongs to.</param>\
96
 
                /// <param name="type">The Type of the Node.</param>
97
 
                /// <param name="changeType">The type of change that occured.</param>
98
 
                /// <param name="eventId">A user defined event ID. Only has meaning to a publisher.</param>
99
 
                /// <param name="time">The time of the event.</param>
100
 
                /// <param name="masterRev">The master revision for the node.</param>
101
 
                /// <param name="slaveRev">The local revision for the node.</param>
102
 
                /// <param name="fileSize">The length of the file if the node is a BaseFileNode. Otherwise
103
 
                /// the value of this parameter will be zero.</param>
104
 
                public NodeEventArgs(string source, string node, string collection, string type, EventType changeType, int eventId, DateTime time, ulong masterRev, ulong slaveRev, long fileSize) :
105
 
                        this(source, node, collection, string.Empty, type, changeType, eventId, time, masterRev, slaveRev, fileSize)
106
 
                {
107
 
                }
108
 
 
109
 
                /// <summary>
110
 
                /// Constructs a SimiasEventArgs that will be used by CollectionHandler delegates.
111
 
                /// Describes the node affected by the event.
112
 
                /// </summary>
113
 
                /// <param name="source">The source of the event.</param>
114
 
                /// <param name="node">The object of the event.</param>
115
 
                /// <param name="collection">The Collection that the node belongs to.</param>
116
 
                /// <param name="modifier">The user that modified the node.</param>
117
 
                /// <param name="type">The Type of the Node.</param>
118
 
                /// <param name="changeType">The type of change that occured.</param>
119
 
                /// <param name="eventId">A user defined event ID. Only has meaning to a publisher.</param>
120
 
                /// <param name="time">The time of the event.</param>
121
 
                /// <param name="masterRev">The master revision for the node.</param>
122
 
                /// <param name="slaveRev">The local revision for the node.</param>
123
 
                /// <param name="fileSize">The length of the file if the node is a BaseFileNode. Otherwise
124
 
                /// the value of this parameter will be zero.</param>
125
 
                public NodeEventArgs(string source, string node, string collection, string modifier, string type, EventType changeType, int eventId, DateTime time, ulong masterRev, ulong slaveRev, long fileSize) :
126
 
                        base(changeType.ToString(), time)
127
 
                {
128
 
                        this.source = source;
129
 
                        this.id = node;
130
 
                        this.collection = collection;
131
 
                        this.modifier = modifier;
132
 
                        this.type = type;
133
 
                        this.eventId = eventId;
134
 
                        this.masterRev = masterRev;
135
 
                        this.slaveRev = slaveRev;
136
 
                        this.fileSize = fileSize;
137
 
                }
138
 
 
139
 
                #endregion
140
 
                
141
 
                #region Properties
142
 
 
143
 
                /// <summary>
144
 
                /// Gets the string that represents the source of the event.
145
 
                /// </summary>
146
 
                public string Source
147
 
                {
148
 
                        get {return source;}
149
 
                }
150
 
 
151
 
                /// <summary>
152
 
                /// Gets the ID of the affected Node/Collection.
153
 
                /// </summary>
154
 
                public string ID
155
 
                {
156
 
                        get {return id;}
157
 
                }
158
 
                
159
 
                /// <summary>
160
 
                /// Gets the containing collection ID.
161
 
                /// </summary>
162
 
                public string Collection
163
 
                {
164
 
                        get {return collection;}
165
 
                }
166
 
 
167
 
                /// <summary>
168
 
                /// Gets the ID of the user that modified the node.
169
 
                /// </summary>
170
 
                public string Modifier
171
 
                {
172
 
                        get {return modifier;}
173
 
                }
174
 
 
175
 
                /// <summary>
176
 
                /// Gets the Type of the affected Node.
177
 
                /// </summary>
178
 
                public string Type
179
 
                {
180
 
                        get {return type;}
181
 
                }
182
 
 
183
 
                /// <summary>
184
 
                /// Gets a Sets an event ID.  Usually 0. 
185
 
                /// Used by a publisher. Can be used to detect circular events.
186
 
                /// </summary>
187
 
                public int EventId
188
 
                {
189
 
                        get {return eventId;}
190
 
                }
191
 
 
192
 
                /// <summary>
193
 
                /// Gets the Node ID.
194
 
                /// </summary>
195
 
                public string Node
196
 
                {
197
 
                        get {return ID;}
198
 
                }
199
 
 
200
 
                /// <summary>
201
 
                /// Gets or sets the flags.
202
 
                /// </summary>
203
 
                public ushort Flags
204
 
                {
205
 
                        get {return (ushort)flags;}
206
 
                        set {flags = (EventFlags)value; }
207
 
                }
208
 
 
209
 
                /// <summary>
210
 
                /// Gets or sets if the event refers to local only changes.
211
 
                /// </summary>
212
 
                public bool LocalOnly
213
 
                {
214
 
                        get
215
 
                        {
216
 
                                return ((flags & EventFlags.LocalOnly) > 0);
217
 
                        }
218
 
                        set
219
 
                        {
220
 
                                if (value)
221
 
                                        flags |= EventFlags.LocalOnly;
222
 
                                else
223
 
                                        flags &= ~EventFlags.LocalOnly;
224
 
                        }
225
 
                }
226
 
 
227
 
                /// <summary>
228
 
                /// Gets the master revision for the node.
229
 
                /// </summary>
230
 
                public ulong MasterRev
231
 
                {
232
 
                        get { return masterRev; }
233
 
                }
234
 
 
235
 
                /// <summary>
236
 
                /// Gets the slave revision for the node.
237
 
                /// </summary>
238
 
                public ulong SlaveRev
239
 
                {
240
 
                        get { return slaveRev; }
241
 
                }
242
 
 
243
 
                /// <summary>
244
 
                /// Gets the file size for the node. If the node is 
245
 
                /// not a file type, zero is returned.
246
 
                /// </summary>
247
 
                public long FileSize
248
 
                {
249
 
                        get { return fileSize; }
250
 
                }
251
 
 
252
 
 
253
 
                /// <summary>
254
 
                /// Gets the type of event that occurred
255
 
                /// </summary>
256
 
                public EventType EventType
257
 
                {
258
 
                        get
259
 
                        {
260
 
                                return (EventType)Enum.Parse(typeof(EventType), EventData);
261
 
                        }
262
 
                }
263
 
 
264
 
                #endregion
265
 
        }
266
 
}