Many updates

- Exit warning dialog is now based on standard NSAlert
- All command-line tools are executed asynchronously using
  NSOperationQueue
- Status is processed using XSLT and visualized in basic HTML format

Also, all constants for command-line tools are moved to wscipt/config.h.  If
new commands needed, they should be added into wscript, which will
eventually create proper config.h file.

Change-Id: I2e7c248f8f3b92085a50c49761bd81702fe8685b
diff --git a/osx/ndnd-status-operation.mm b/osx/ndnd-status-operation.mm
new file mode 100644
index 0000000..ab0f303
--- /dev/null
+++ b/osx/ndnd-status-operation.mm
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * @copyright See LICENCE for copyright and license information.
+ *
+ * @author Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ * @author Ilya Moiseenko <iliamo@ucla.edu>
+ */
+
+#include "config.h"
+#import "ndnd-status-operation.h"
+
+@implementation NdndStatusOperation
+
+-(id)initWithDelegate:(MenuDelegate*)delegate
+{
+  if (![super init]) return nil;
+  m_delegate = delegate;
+  return self;
+}
+
+-(void)main
+{
+  NSTask *task = [[NSTask alloc] init];
+  [task setLaunchPath: @NDND_STATUS_COMMAND];
+  [task setArguments: [NSArray arrayWithObjects: @"status",@"-x",nil]];
+
+  NSPipe * out = [NSPipe pipe];
+  [task setStandardOutput:out];
+
+  [task launch];
+  [task waitUntilExit];
+
+  NSFileHandle * read = [out fileHandleForReading];
+  NSData * dataRead = [read readDataToEndOfFile];
+  NSString *stringRead = [[NSString alloc] initWithData:dataRead encoding:NSUTF8StringEncoding];
+
+  if ([stringRead isEqualToString:@""]) {
+    [m_delegate performSelectorOnMainThread:@selector(statusUnavailable:)
+                                 withObject:nil
+                                 waitUntilDone:YES];
+    
+  } else {
+    NSError *error = nil;
+    NSXMLDocument *document = [[NSXMLDocument alloc]
+                                initWithXMLString:stringRead
+                                          options:0
+                                          error:&error];
+
+    [m_delegate performSelectorOnMainThread:@selector(statusUpdated:)
+                                 withObject:document
+                                 waitUntilDone:YES];
+  }
+  
+  // [daemonStatusText setStringValue:stringRead];
+}
+
+@end