Alexander Afanasyev | 14b0948 | 2013-10-11 18:24:45 +0200 | [diff] [blame] | 1 | /* -*- Mode: objc; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 2 | /** |
| 3 | * Copyright (c) 2013-2014, Regents of the University of California, |
Alexander Afanasyev | 6cacb97 | 2013-10-03 23:39:06 -0700 | [diff] [blame] | 4 | * |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 5 | * This file is part of NFD Control Center. See AUTHORS.md for complete list of NFD |
| 6 | * authors and contributors. |
| 7 | * |
| 8 | * NFD Control Center is free software: you can redistribute it and/or modify it under the |
| 9 | * terms of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * NFD Control Center is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 14 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with NFD |
| 17 | * Control Center, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * \author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html> |
| 20 | * \author Ilya Moiseenko <http://ilyamoiseenko.com/> |
Alexander Afanasyev | 6cacb97 | 2013-10-03 23:39:06 -0700 | [diff] [blame] | 21 | */ |
| 22 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 23 | #include "config.hpp" |
Alexander Afanasyev | 6cacb97 | 2013-10-03 23:39:06 -0700 | [diff] [blame] | 24 | #import "ndnd-status-operation.h" |
| 25 | |
| 26 | @implementation NdndStatusOperation |
| 27 | |
| 28 | -(id)initWithDelegate:(MenuDelegate*)delegate |
| 29 | { |
| 30 | if (![super init]) return nil; |
| 31 | m_delegate = delegate; |
| 32 | return self; |
| 33 | } |
| 34 | |
| 35 | -(void)main |
| 36 | { |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 37 | // NSTask *task = [[NSTask alloc] init]; |
| 38 | // [task setLaunchPath: @NDND_STATUS_COMMAND]; |
| 39 | // [task setArguments: [NSArray arrayWithObjects: @"status",@"-x",nil]]; |
Alexander Afanasyev | 6cacb97 | 2013-10-03 23:39:06 -0700 | [diff] [blame] | 40 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 41 | // NSPipe * out = [NSPipe pipe]; |
| 42 | // [task setStandardOutput:out]; |
Alexander Afanasyev | 6cacb97 | 2013-10-03 23:39:06 -0700 | [diff] [blame] | 43 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 44 | // [task launch]; |
| 45 | // [task waitUntilExit]; |
Alexander Afanasyev | 6cacb97 | 2013-10-03 23:39:06 -0700 | [diff] [blame] | 46 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 47 | // NSFileHandle * read = [out fileHandleForReading]; |
| 48 | // NSData * dataRead = [read readDataToEndOfFile]; |
| 49 | // NSString *stringRead = [[NSString alloc] initWithData:dataRead encoding:NSUTF8StringEncoding]; |
Alexander Afanasyev | 6cacb97 | 2013-10-03 23:39:06 -0700 | [diff] [blame] | 50 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 51 | // if ([stringRead isEqualToString:@""]) { |
| 52 | // [m_delegate performSelectorOnMainThread:@selector(statusUnavailable:) |
| 53 | // withObject:nil |
| 54 | // waitUntilDone:YES]; |
Alexander Afanasyev | 6cacb97 | 2013-10-03 23:39:06 -0700 | [diff] [blame] | 55 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 56 | // } else { |
| 57 | // NSError *error = nil; |
| 58 | // NSXMLDocument *document = [[NSXMLDocument alloc] |
| 59 | // initWithXMLString:stringRead |
| 60 | // options:0 |
| 61 | // error:&error]; |
| 62 | |
| 63 | // [m_delegate performSelectorOnMainThread:@selector(statusUpdated:) |
| 64 | // withObject:document |
| 65 | // waitUntilDone:YES]; |
| 66 | // } |
Alexander Afanasyev | 6cacb97 | 2013-10-03 23:39:06 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | @end |