2004-05-05 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / System.Messaging / System.Messaging / MessageQueue.cs
1 //\r
2 // System.Messaging\r
3 //\r
4 // Authors:\r
5 //      Peter Van Isacker (sclytrack@planetinternet.be)\r
6 //      Rafael Teixeira   (rafaelteixeirabr@hotmail.com)\r
7 //\r
8 // (C) 2003 Peter Van Isacker\r
9 //\r
10 using System;\r
11 using System.Collections;\r
12 using System.ComponentModel;\r
13 \r
14 namespace System.Messaging \r
15 {\r
16         public class MessageQueue: Component, IEnumerable \r
17         {\r
18                 \r
19                 #region Fields\r
20                 \r
21                 public static readonly long InfiniteQueueSize;\r
22                 public static readonly TimeSpan InfiniteTimeout;\r
23                 \r
24                 private bool isPrivate = false;\r
25                 private string queueName;       \r
26                 private string machineName;\r
27                 \r
28                 \r
29                 #endregion //Fields\r
30 \r
31                 \r
32                 #region Constructor\r
33                 \r
34                 [MonoTODO]\r
35                 public MessageQueue() \r
36                 {\r
37                         throw new NotImplementedException();\r
38                 }\r
39                 \r
40                 [MonoTODO]\r
41                 public MessageQueue(string path)\r
42                 {\r
43                         this.Path = path;\r
44                         this.isPrivate= false;\r
45                 }\r
46                 \r
47                 [MonoTODO]\r
48                 private MessageQueue(string queueName, string machineName, bool isPrivate)\r
49                 {\r
50                         this.queueName = queueName;\r
51                         this.machineName = machineName;\r
52                         this.isPrivate= isPrivate;\r
53                 }\r
54                 \r
55                 [MonoTODO]\r
56                 public MessageQueue(string path, bool sharedModeDenyReceive)\r
57                 {\r
58                         throw new NotImplementedException();\r
59                 }\r
60                 \r
61                 #endregion //Constructor\r
62                 \r
63                 #region Properties\r
64                 \r
65                 public bool Authenticate {\r
66                         [MonoTODO]\r
67                         get {throw new NotImplementedException();}\r
68                         [MonoTODO]\r
69                         set {throw new NotImplementedException();}\r
70                 }\r
71                 public short BasePriority {\r
72                         [MonoTODO]\r
73                         get {throw new NotImplementedException();}\r
74                         [MonoTODO]\r
75                         set {throw new NotImplementedException();}\r
76                 }\r
77                 public bool CanRead {\r
78                         [MonoTODO]\r
79                         get {throw new NotImplementedException();}\r
80                 }\r
81                 public bool CanWrite {\r
82                         [MonoTODO]\r
83                         get {throw new NotImplementedException();}\r
84                 }\r
85                 public Guid Category {\r
86                         [MonoTODO]\r
87                         get {throw new NotImplementedException();}\r
88                         [MonoTODO]\r
89                         set {throw new NotImplementedException();}\r
90                 }\r
91                 public DateTime CreateTime {\r
92                         [MonoTODO]\r
93                         get {throw new NotImplementedException();}\r
94                 }\r
95                 public DefaultPropertiesToSend DefaultPropertiesToSend {\r
96                         [MonoTODO]\r
97                         get {throw new NotImplementedException();}\r
98                         [MonoTODO]\r
99                         set {throw new NotImplementedException();}\r
100                 }\r
101                 public bool DenySharedReceive {\r
102                         [MonoTODO]\r
103                         get {throw new NotImplementedException();}\r
104                         [MonoTODO]\r
105                         set {throw new NotImplementedException();}\r
106                 }\r
107                 public static bool EnableConnectionCache {\r
108                         [MonoTODO]\r
109                         get {throw new NotImplementedException();}\r
110                         [MonoTODO]\r
111                         set {throw new NotImplementedException();}\r
112                 }\r
113                 public EncryptionRequired EncryptionRequired {\r
114                         [MonoTODO]\r
115                         get {throw new NotImplementedException();}\r
116                         [MonoTODO]\r
117                         set {throw new NotImplementedException();}\r
118                 }\r
119                 public string FormatName {\r
120                         [MonoTODO]\r
121                         get {throw new NotImplementedException();}\r
122                 }\r
123                 public IMessageFormatter Formatter {\r
124                         [MonoTODO]\r
125                         get {throw new NotImplementedException();}\r
126                         [MonoTODO]\r
127                         set {throw new NotImplementedException();}\r
128                 }\r
129                 public Guid Id {\r
130                         [MonoTODO]\r
131                         get {throw new NotImplementedException();}\r
132                 }\r
133                 public string Label {\r
134                         [MonoTODO]\r
135                         get {throw new NotImplementedException();}\r
136                         [MonoTODO]\r
137                         set {throw new NotImplementedException();}\r
138                 }\r
139                 public DateTime LastModifyTime {\r
140                         [MonoTODO]\r
141                         get {throw new NotImplementedException();}\r
142                 }\r
143                 public string MachineName {\r
144                         get { return machineName; }\r
145                         set { machineName = value; }\r
146                 }\r
147                 public long MaximumJournalSize {\r
148                         [MonoTODO]\r
149                         get {throw new NotImplementedException();}\r
150                         [MonoTODO]\r
151                         set {throw new NotImplementedException();}\r
152                 }\r
153                 public long MaximumQueueSize {\r
154                         [MonoTODO]\r
155                         get {throw new NotImplementedException();}\r
156                         [MonoTODO]\r
157                         set {throw new NotImplementedException();}\r
158                 }\r
159                 public MessagePropertyFilter MessageReadPropertyFilter {\r
160                         [MonoTODO]\r
161                         get {throw new NotImplementedException();}\r
162                         [MonoTODO]\r
163                         set {throw new NotImplementedException();}\r
164                 }\r
165                 public string Path {\r
166                         get { return machineName + ":" + queueName; }\r
167                         [MonoTODO("split input")]\r
168                         set {throw new NotImplementedException();}\r
169                 }\r
170                 public string QueueName {\r
171                         get { return queueName; }\r
172                         set { queueName = value; }\r
173                 }\r
174                 public IntPtr ReadHandle {\r
175                         [MonoTODO]\r
176                         get {throw new NotImplementedException();}\r
177                 }\r
178                 public ISynchronizeInvoke SynchronizingObject {\r
179                         [MonoTODO]\r
180                         get {throw new NotImplementedException();}\r
181                         [MonoTODO]\r
182                         set {throw new NotImplementedException();}\r
183                 }\r
184                 public bool Transactional {\r
185                         [MonoTODO]\r
186                         get {throw new NotImplementedException();}\r
187                 }\r
188                 public bool UseJournalQueue {\r
189                         [MonoTODO]\r
190                         get {throw new NotImplementedException();}\r
191                         [MonoTODO]\r
192                         set {throw new NotImplementedException();}\r
193                 }\r
194                 \r
195                 #endregion //Properties\r
196                 \r
197                 #region Methods\r
198                 \r
199                 public IntPtr WriteHandle {\r
200                         [MonoTODO]\r
201                         get {throw new NotImplementedException();}\r
202                 }\r
203                 [MonoTODO]\r
204                 public IAsyncResult BeginPeek()\r
205                 {\r
206                         throw new NotImplementedException();\r
207                 }\r
208                 [MonoTODO]\r
209                 public IAsyncResult BeginPeek(TimeSpan timeout)\r
210                 {\r
211                         throw new NotImplementedException();\r
212                 }\r
213                 [MonoTODO]\r
214                 public IAsyncResult BeginPeek(TimeSpan timeout, object stateObject)\r
215                 {\r
216                         throw new NotImplementedException();\r
217                 }\r
218                 [MonoTODO]\r
219                 public IAsyncResult BeginPeek(TimeSpan timeout,\r
220                                                                           object stateObject,\r
221                                                                           AsyncCallback callback)\r
222                 {\r
223                         throw new NotImplementedException();\r
224                 }\r
225                 [MonoTODO]\r
226                 public IAsyncResult BeginReceive()\r
227                 {\r
228                         throw new NotImplementedException();\r
229                 }\r
230                 [MonoTODO]\r
231                 public IAsyncResult BeginReceive(TimeSpan timeout)\r
232                 {\r
233                         throw new NotImplementedException();\r
234                 }\r
235                 [MonoTODO]\r
236                 public IAsyncResult BeginReceive(TimeSpan timeout, object stateObject)\r
237                 {\r
238                         throw new NotImplementedException();\r
239                 }\r
240                 [MonoTODO]\r
241                 public IAsyncResult BeginReceive(TimeSpan timeout, object stateObject, AsyncCallback callback)\r
242                 {\r
243                         throw new NotImplementedException();\r
244                 }\r
245                 [MonoTODO]\r
246                 public static void ClearConnectionCache()\r
247                 {\r
248                         throw new NotImplementedException();\r
249                 }\r
250                 [MonoTODO]\r
251                 public void Close()\r
252                 {\r
253                         throw new NotImplementedException();\r
254                 }\r
255                 [MonoTODO]\r
256                 public static MessageQueue Create(string path)\r
257                 {\r
258                         throw new NotImplementedException();\r
259                 }\r
260                 [MonoTODO]\r
261                 public static MessageQueue Create(string path, bool transactional)\r
262                 {\r
263                         throw new NotImplementedException();\r
264                 }\r
265                 [MonoTODO]\r
266                 public static void Delete(string path)\r
267                 {\r
268                         throw new NotImplementedException();\r
269                 }\r
270                 [MonoTODO]\r
271                 public Message EndPeek(IAsyncResult asyncResult)\r
272                 {\r
273                         throw new NotImplementedException();\r
274                 }\r
275                 [MonoTODO]\r
276                 public Message EndReceive(IAsyncResult asyncResult)\r
277                 {\r
278                         throw new NotImplementedException();\r
279                 }\r
280                 [MonoTODO]\r
281                 public static bool Exists(string path)\r
282                 {\r
283                         throw new NotImplementedException();\r
284                 }\r
285                 [MonoTODO]\r
286                 public Message[] GetAllMessages()\r
287                 {\r
288                         throw new NotImplementedException();\r
289                 }\r
290                 [MonoTODO]\r
291                 public IEnumerator GetEnumerator()\r
292                 {\r
293                         throw new NotImplementedException();\r
294                 }\r
295                 [MonoTODO]\r
296                 public static Guid GetMachiIdneId(string machineName)\r
297                 {\r
298                         throw new NotImplementedException();\r
299                 }\r
300                 [MonoTODO]\r
301                 public MessageEnumerator GetMessageEnumerator()\r
302                 {\r
303                         throw new NotImplementedException();\r
304                 }\r
305                 \r
306                 private static ArrayList currentQueueList;\r
307                 \r
308                 static MessageQueue()\r
309                 {\r
310                         currentQueueList = new ArrayList();\r
311                         // for testing purposes\r
312                         currentQueueList.Add(new MessageQueue(@"localhost:\public\TestQueue"));\r
313                         currentQueueList.Add(new MessageQueue(@"\private\AnotherTestQueue", "localhost", true));\r
314                 }\r
315                 \r
316                 public static MessageQueueEnumerator GetMessageQueueEnumerator()\r
317                 {\r
318                         return new MessageQueueEnumerator(currentQueueList);\r
319                 }\r
320 \r
321                 private static ArrayList filteredQueueList(MessageQueueCriteria criteria)\r
322                 {\r
323                         ArrayList list = new ArrayList();\r
324                         foreach(MessageQueue queue in currentQueueList)\r
325                                 if (criteria.Match(queue.Id, queue.CreateTime, queue.Label, queue.MachineName, queue.LastModifyTime))\r
326                                         list.Add(queue);\r
327                         return list;\r
328                 }\r
329                 \r
330                 public static MessageQueueEnumerator GetMessageQueueEnumerator(MessageQueueCriteria criteria)\r
331                 {\r
332                         return new MessageQueueEnumerator(filteredQueueList(criteria));\r
333                 }\r
334                 \r
335                 public static MessageQueue[] GetPrivateQueuesByMachine(string machineName)\r
336                 {\r
337                         if (machineName == null || machineName.Length == 0)\r
338                                 throw new ArgumentException();\r
339                         ArrayList list = new ArrayList();\r
340                         foreach(MessageQueue queue in currentQueueList)\r
341                                 if (queue.machineName == machineName && queue.isPrivate)\r
342                                         list.Add(queue);\r
343                         return (MessageQueue[])list.ToArray(typeof(MessageQueue));\r
344                 }\r
345                 \r
346                 [MonoTODO]\r
347                 public static MessageQueue[] GetPublicQueues()\r
348                 {\r
349                         throw new NotImplementedException();\r
350                 }\r
351                 [MonoTODO]\r
352                 public static MessageQueue[] GetPublicQueues(MessageQueueCriteria criteria)\r
353                 {\r
354                         throw new NotImplementedException();\r
355                 }\r
356                 [MonoTODO]\r
357                 public static MessageQueue[] GetPublicQueuesByCategory(Guid category)\r
358                 {\r
359                         throw new NotImplementedException();\r
360                 }\r
361                 [MonoTODO]\r
362                 public static MessageQueue[] GetPublicQueuesByLabel(string label)\r
363                 {\r
364                         throw new NotImplementedException();\r
365                 }\r
366                 [MonoTODO]\r
367                 public static MessageQueue[] GetPublicQueuesByMachine(string machineName)\r
368                 {\r
369                         throw new NotImplementedException();\r
370                 }\r
371                 [MonoTODO]\r
372                 public Message Peek()\r
373                 {\r
374                         throw new NotImplementedException();\r
375                 }\r
376                 [MonoTODO]\r
377                 public Message Peek(TimeSpan timeout)\r
378                 {\r
379                         throw new NotImplementedException();\r
380                 }\r
381                 [MonoTODO]\r
382                 public Message PeekByCorrelationId(string correlationId)\r
383                 {\r
384                         throw new NotImplementedException();\r
385                 }\r
386                 [MonoTODO]\r
387                 public Message PeekByCorrelationId(string correlationId, TimeSpan timeout)\r
388                 {\r
389                         throw new NotImplementedException();\r
390                 }\r
391                 [MonoTODO]\r
392                 public Message PeekById(string id)\r
393                 {\r
394                         throw new NotImplementedException();\r
395                 }\r
396                 [MonoTODO]\r
397                 public Message PeekById(string id, TimeSpan timeout)\r
398                 {\r
399                         throw new NotImplementedException();\r
400                 }\r
401                 [MonoTODO]\r
402                 public void Purge()\r
403                 {\r
404                         throw new NotImplementedException();\r
405                 }\r
406                 [MonoTODO]\r
407                 public Message Receive()\r
408                 {\r
409                         throw new NotImplementedException();\r
410                 }\r
411                 [MonoTODO]\r
412                 public Message Receive(MessageQueueTransaction transaction)\r
413                 {\r
414                         throw new NotImplementedException();\r
415                 }\r
416                 [MonoTODO]\r
417                 public Message Receive(MessageQueueTransactionType transactionType)\r
418                 {\r
419                         throw new NotImplementedException();\r
420                 }\r
421                 [MonoTODO]\r
422                 public Message Receive(TimeSpan timeout)\r
423                 {\r
424                         throw new NotImplementedException();\r
425                 }\r
426                 [MonoTODO]\r
427                 public Message Receive(TimeSpan timeout, MessageQueueTransaction transaction)\r
428                 {\r
429                         throw new NotImplementedException();\r
430                 }\r
431                 [MonoTODO]\r
432                 public Message Receive(TimeSpan timeout, MessageQueueTransactionType transactionType)\r
433                 {\r
434                         throw new NotImplementedException();\r
435                 }\r
436                 [MonoTODO]\r
437                 public Message ReceiveByCorrelationId(string correlationId)\r
438                 {\r
439                         throw new NotImplementedException();\r
440                 }\r
441                 [MonoTODO]\r
442                 public Message ReceiveByCorrelationId(string correlationId, MessageQueueTransaction transaction)\r
443                 {\r
444                         throw new NotImplementedException();\r
445                 }\r
446                 [MonoTODO]\r
447                 public Message ReceiveByCorrelationId(string correlationId, MessageQueueTransactionType transactionType)\r
448                 {\r
449                         throw new NotImplementedException();\r
450                 }\r
451                 [MonoTODO]\r
452                 public Message ReceiveByCorrelationId(string correlationId, TimeSpan timeout)\r
453                 {\r
454                         throw new NotImplementedException();\r
455                 }\r
456                 [MonoTODO]\r
457                 public Message ReceiveByCorrelationId(string correlationId, TimeSpan timeout, MessageQueueTransaction transaction)\r
458                 {\r
459                         throw new NotImplementedException();\r
460                 }\r
461                 [MonoTODO]\r
462                 public Message ReceiveByCorrelationId(string correlationId, TimeSpan timeout, MessageQueueTransactionType transactionType)\r
463                 {\r
464                         throw new NotImplementedException();\r
465                 }\r
466                 [MonoTODO]\r
467                 public Message ReceiveById(string id)\r
468                 {\r
469                         throw new NotImplementedException();\r
470                 }\r
471                 [MonoTODO]\r
472                 public Message ReceiveById(string id,MessageQueueTransaction transaction)\r
473                 {\r
474                         throw new NotImplementedException();\r
475                 }\r
476                 [MonoTODO]\r
477                 public Message ReceiveById(string id,MessageQueueTransactionType transactionType)\r
478                 {\r
479                         throw new NotImplementedException();\r
480                 }\r
481                 [MonoTODO]\r
482                 public Message ReceiveById(string id,TimeSpan timeout)\r
483                 {\r
484                         throw new NotImplementedException();\r
485                 }\r
486                 [MonoTODO]\r
487                 public void Refresh()\r
488                 {\r
489                         throw new NotImplementedException();\r
490                 }\r
491                 [MonoTODO]\r
492                 public void ResetPermissions()\r
493                 {\r
494                         throw new NotImplementedException();\r
495                 }\r
496                 \r
497                 #endregion //Methods\r
498                 \r
499                 //TODO: Use these events.\r
500                 \r
501                 public event PeekCompletedEventHandler PeekCompleted;\r
502                 \r
503                 public event ReceiveCompletedEventHandler ReceiveCompleted;\r
504                 \r
505                 [MonoTODO]\r
506                 protected override void Dispose(bool disposing)\r
507                 {\r
508                 }\r
509                 ~MessageQueue()\r
510                 {\r
511                 }\r
512         }\r
513 }\r