1998-12-01 20:54:23 +00:00
|
|
|
/*
|
2007-12-07 11:57:41 +00:00
|
|
|
set_show_service.m
|
1998-12-01 20:54:23 +00:00
|
|
|
|
|
|
|
GNUstep utility to enable or disable a service for the current user.
|
|
|
|
|
|
|
|
Copyright (C) 1998 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
Date: November 1998
|
|
|
|
|
1999-02-04 13:06:58 +00:00
|
|
|
This file is part of the GNUstep Project
|
1998-12-01 20:54:23 +00:00
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
This program is free software; you can redistribute it and/or
|
1999-02-04 13:06:58 +00:00
|
|
|
modify it under the terms of the GNU General Public License
|
2007-10-29 21:16:17 +00:00
|
|
|
as published by the Free Software Foundation; either version 3
|
1999-02-04 13:06:58 +00:00
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
1999-02-04 13:06:58 +00:00
|
|
|
You should have received a copy of the GNU General Public
|
2007-10-29 21:16:17 +00:00
|
|
|
License along with this library; see the file COPYING.
|
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
1999-02-04 13:06:58 +00:00
|
|
|
|
1998-12-01 20:54:23 +00:00
|
|
|
*/
|
|
|
|
|
2010-02-20 10:40:44 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#import <Foundation/NSAutoreleasePool.h>
|
|
|
|
#import <Foundation/NSArray.h>
|
|
|
|
#import <Foundation/NSProcessInfo.h>
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
#import "AppKit/NSApplication.h"
|
1998-12-01 20:54:23 +00:00
|
|
|
|
|
|
|
int
|
2000-06-29 14:25:07 +00:00
|
|
|
main(int argc, char** argv, char **env)
|
1998-12-01 20:54:23 +00:00
|
|
|
{
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
NSProcessInfo *proc;
|
|
|
|
NSArray *args;
|
|
|
|
unsigned index;
|
|
|
|
|
|
|
|
// [NSObject enableDoubleReleaseCheck: YES];
|
2000-06-29 14:25:07 +00:00
|
|
|
#ifdef GS_PASS_ARGUMENTS
|
|
|
|
[NSProcessInfo initializeWithArguments:argv count:argc environment:env];
|
|
|
|
#endif
|
1998-12-01 20:54:23 +00:00
|
|
|
|
|
|
|
pool = [NSAutoreleasePool new];
|
|
|
|
|
|
|
|
proc = [NSProcessInfo processInfo];
|
|
|
|
if (proc == nil)
|
|
|
|
{
|
|
|
|
NSLog(@"unable to get process information!\n");
|
2003-05-12 19:58:20 +00:00
|
|
|
exit(EXIT_SUCCESS);
|
1998-12-01 20:54:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
args = [proc arguments];
|
|
|
|
|
1999-02-17 09:36:25 +00:00
|
|
|
for (index = 1; index < [args count]; index++)
|
1998-12-01 20:54:23 +00:00
|
|
|
{
|
|
|
|
if ([[args objectAtIndex: index] isEqual: @"--help"])
|
|
|
|
{
|
|
|
|
printf(
|
|
|
|
"set_show_service enables or disables the display of a specified service\n"
|
2007-12-07 11:57:41 +00:00
|
|
|
"item. It's should be in the form 'set_show_service --enable name' or \n"
|
1998-12-01 20:54:23 +00:00
|
|
|
"'set_show_service --disable name' where 'name' is a service name.\n");
|
2003-05-12 19:58:20 +00:00
|
|
|
exit(EXIT_SUCCESS);
|
1998-12-01 20:54:23 +00:00
|
|
|
}
|
|
|
|
if ([[args objectAtIndex: index] isEqual: @"--enable"])
|
|
|
|
{
|
|
|
|
if (index >= [args count] - 1)
|
|
|
|
{
|
|
|
|
NSLog(@"No name specified for enable.\n");
|
2003-05-12 19:58:20 +00:00
|
|
|
exit(EXIT_FAILURE);
|
1998-12-01 20:54:23 +00:00
|
|
|
}
|
|
|
|
NSSetShowsServicesMenuItem([args objectAtIndex: ++index], YES);
|
2003-05-12 19:58:20 +00:00
|
|
|
exit(EXIT_SUCCESS);
|
1998-12-01 20:54:23 +00:00
|
|
|
}
|
|
|
|
if ([[args objectAtIndex: index] isEqual: @"--disable"])
|
|
|
|
{
|
|
|
|
if (index >= [args count] - 1)
|
|
|
|
{
|
|
|
|
NSLog(@"No name specified for disable.\n");
|
2003-05-12 19:58:20 +00:00
|
|
|
exit(EXIT_FAILURE);
|
1998-12-01 20:54:23 +00:00
|
|
|
}
|
|
|
|
NSSetShowsServicesMenuItem([args objectAtIndex: ++index], NO);
|
2003-05-12 19:58:20 +00:00
|
|
|
exit(EXIT_SUCCESS);
|
1998-12-01 20:54:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NSLog(@"Nothing to do.\n");
|
2011-05-27 12:42:37 +00:00
|
|
|
[pool drain];
|
1998-12-01 20:54:23 +00:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|