Add OSX souces, courtesy of RokuMike

This commit is contained in:
Ron Pedde 2006-07-26 07:48:06 +00:00
parent 63d6df105f
commit 4665559105
45 changed files with 5860 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,18 @@
{
IBClasses = (
{
ACTIONS = {prefsMenuChosen = id; startStopMenuChosen = id; };
CLASS = FireflyHelper;
LANGUAGE = ObjC;
OUTLETS = {statusMenu = NSMenu; };
SUPERCLASS = NSObject;
},
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
CLASS = MyASKNibObjectInfoManager;
LANGUAGE = ObjC;
SUPERCLASS = ASKNibObjectInfoManager;
}
);
IBVersion = 1;
}

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>155 322 356 240 0 0 1440 878 </string>
<key>IBEditorPositions</key>
<dict>
<key>209</key>
<string>283 632 160 106 0 0 1440 878 </string>
<key>29</key>
<string>521 639 125 44 0 0 1440 878 </string>
</dict>
<key>IBFramework Version</key>
<string>446.1</string>
<key>IBOpenObjects</key>
<array>
<integer>209</integer>
</array>
<key>IBSystem Version</key>
<string>8J135</string>
</dict>
</plist>

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,18 @@
{
IBClasses = (
{
ACTIONS = {prefsMenuChosen = id; startStopMenuChosen = id; };
CLASS = FireflyHelper;
LANGUAGE = ObjC;
OUTLETS = {statusMenu = NSMenu; };
SUPERCLASS = NSObject;
},
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
CLASS = MyASKNibObjectInfoManager;
LANGUAGE = ObjC;
SUPERCLASS = ASKNibObjectInfoManager;
}
);
IBVersion = 1;
}

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>155 322 356 240 0 0 1440 878 </string>
<key>IBEditorPositions</key>
<dict>
<key>209</key>
<string>283 632 160 106 0 0 1440 878 </string>
<key>29</key>
<string>521 639 125 44 0 0 1440 878 </string>
</dict>
<key>IBFramework Version</key>
<string>446.1</string>
<key>IBOpenObjects</key>
<array>
<integer>209</integer>
</array>
<key>IBSystem Version</key>
<string>8J135</string>
</dict>
</plist>

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,348 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 42;
objects = {
/* Begin PBXBuildFile section */
10AE11000A39121A00525B7B /* FireflyHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 10AE10FE0A39121A00525B7B /* FireflyHelper.m */; };
10AE11DD0A3929D700525B7B /* FireflyHelper.icns in Resources */ = {isa = PBXBuildFile; fileRef = 10AE11DC0A3929D700525B7B /* FireflyHelper.icns */; };
10C790F80A65BCD500732D76 /* ff_logo_status_menu.tif in Resources */ = {isa = PBXBuildFile; fileRef = 10C790F70A65BCD400732D76 /* ff_logo_status_menu.tif */; };
10C791120A65C54000732D76 /* FireflyServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 10C791110A65C54000732D76 /* FireflyServer.m */; };
10C792820A65EF1800732D76 /* Server in Resources */ = {isa = PBXBuildFile; fileRef = 10C792440A65EF1800732D76 /* Server */; };
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
/* End PBXBuildFile section */
/* Begin PBXBuildStyle section */
E423408A0A771CDF00669C87 /* Development */ = {
isa = PBXBuildStyle;
buildSettings = {
COPY_PHASE_STRIP = NO;
};
name = Development;
};
E423408B0A771CDF00669C87 /* Deployment */ = {
isa = PBXBuildStyle;
buildSettings = {
COPY_PHASE_STRIP = YES;
};
name = Deployment;
};
/* End PBXBuildStyle section */
/* Begin PBXFileReference section */
089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
10AE10FE0A39121A00525B7B /* FireflyHelper.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FireflyHelper.m; sourceTree = "<group>"; };
10AE10FF0A39121A00525B7B /* FireflyHelper.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FireflyHelper.h; sourceTree = "<group>"; };
10AE11DC0A3929D700525B7B /* FireflyHelper.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = FireflyHelper.icns; sourceTree = "<group>"; };
10C78FB60A637C5300732D76 /* FireflyPrefsProtocol.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = FireflyPrefsProtocol.h; path = ../FireflyPrefsProtocol.h; sourceTree = "<group>"; };
10C790F70A65BCD400732D76 /* ff_logo_status_menu.tif */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = ff_logo_status_menu.tif; sourceTree = "<group>"; };
10C791100A65C54000732D76 /* FireflyServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FireflyServer.h; sourceTree = "<group>"; };
10C791110A65C54000732D76 /* FireflyServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FireflyServer.m; sourceTree = "<group>"; };
10C792440A65EF1800732D76 /* Server */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Server; sourceTree = "<group>"; };
10C7931F0A661A2F00732D76 /* FireflyCommon.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = FireflyCommon.h; path = ../FireflyCommon.h; sourceTree = "<group>"; };
13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = "<group>"; };
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
32CA4F630368D1EE00C91783 /* Firefly Minder_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Firefly Minder_Prefix.pch"; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* Firefly Helper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Firefly Helper.app"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
8D11072E0486CEB800E47090 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
080E96DDFE201D6D7F000001 /* Classes */ = {
isa = PBXGroup;
children = (
10C78FB60A637C5300732D76 /* FireflyPrefsProtocol.h */,
10AE10FE0A39121A00525B7B /* FireflyHelper.m */,
10C791100A65C54000732D76 /* FireflyServer.h */,
10C791110A65C54000732D76 /* FireflyServer.m */,
10AE10FF0A39121A00525B7B /* FireflyHelper.h */,
);
name = Classes;
sourceTree = "<group>";
};
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
);
name = "Linked Frameworks";
sourceTree = "<group>";
};
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
isa = PBXGroup;
children = (
29B97324FDCFA39411CA2CEA /* AppKit.framework */,
13E42FB307B3F0F600E4EEF1 /* CoreData.framework */,
29B97325FDCFA39411CA2CEA /* Foundation.framework */,
);
name = "Other Frameworks";
sourceTree = "<group>";
};
19C28FACFE9D520D11CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
8D1107320486CEB800E47090 /* Firefly Helper.app */,
);
name = Products;
sourceTree = "<group>";
};
29B97314FDCFA39411CA2CEA /* Firefly Minder */ = {
isa = PBXGroup;
children = (
080E96DDFE201D6D7F000001 /* Classes */,
10C7931F0A661A2F00732D76 /* FireflyCommon.h */,
29B97315FDCFA39411CA2CEA /* Other Sources */,
29B97317FDCFA39411CA2CEA /* Resources */,
29B97323FDCFA39411CA2CEA /* Frameworks */,
19C28FACFE9D520D11CA2CBB /* Products */,
);
name = "Firefly Minder";
sourceTree = "<group>";
};
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
isa = PBXGroup;
children = (
32CA4F630368D1EE00C91783 /* Firefly Minder_Prefix.pch */,
29B97316FDCFA39411CA2CEA /* main.m */,
);
name = "Other Sources";
sourceTree = "<group>";
};
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
10C792440A65EF1800732D76 /* Server */,
8D1107310486CEB800E47090 /* Info.plist */,
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
29B97318FDCFA39411CA2CEA /* MainMenu.nib */,
10AE11DC0A3929D700525B7B /* FireflyHelper.icns */,
10C790F70A65BCD400732D76 /* ff_logo_status_menu.tif */,
);
name = Resources;
sourceTree = "<group>";
};
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */,
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
8D1107260486CEB800E47090 /* Firefly Helper */ = {
isa = PBXNativeTarget;
buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "Firefly Helper" */;
buildPhases = (
8D1107290486CEB800E47090 /* Resources */,
8D11072C0486CEB800E47090 /* Sources */,
8D11072E0486CEB800E47090 /* Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = "Firefly Helper";
productInstallPath = "$(HOME)/Applications";
productName = "Firefly Minder";
productReference = 8D1107320486CEB800E47090 /* Firefly Helper.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Firefly Helper" */;
buildSettings = {
};
buildStyles = (
E423408A0A771CDF00669C87 /* Development */,
E423408B0A771CDF00669C87 /* Deployment */,
);
hasScannedForEncodings = 1;
mainGroup = 29B97314FDCFA39411CA2CEA /* Firefly Minder */;
projectDirPath = "";
targets = (
8D1107260486CEB800E47090 /* Firefly Helper */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
8D1107290486CEB800E47090 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */,
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
10AE11DD0A3929D700525B7B /* FireflyHelper.icns in Resources */,
10C790F80A65BCD500732D76 /* ff_logo_status_menu.tif in Resources */,
10C792820A65EF1800732D76 /* Server in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
8D11072C0486CEB800E47090 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8D11072D0486CEB800E47090 /* main.m in Sources */,
10AE11000A39121A00525B7B /* FireflyHelper.m in Sources */,
10C791120A65C54000732D76 /* FireflyServer.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
089C165DFE840E0CC02AAC07 /* English */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
29B97318FDCFA39411CA2CEA /* MainMenu.nib */ = {
isa = PBXVariantGroup;
children = (
29B97319FDCFA39411CA2CEA /* English */,
);
name = MainMenu.nib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
C01FCF4B08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(LIBRARY_SEARCH_PATHS_QUOTED_1)",
);
LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/Server/plugins\"";
PRODUCT_NAME = "Firefly Helper";
WRAPPER_EXTENSION = app;
ZERO_LINK = NO;
};
name = Debug;
};
C01FCF4C08A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = (
ppc,
i386,
);
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_MODEL_TUNING = G5;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(LIBRARY_SEARCH_PATHS_QUOTED_1)",
);
LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/Server/plugins\"";
PRODUCT_NAME = "Firefly Helper";
WRAPPER_EXTENSION = app;
};
name = Release;
};
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_VERSION_i386 = 4.0;
GCC_VERSION_ppc = 3.3;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = "";
MACOSX_DEPLOYMENT_TARGET_i386 = 10.4;
MACOSX_DEPLOYMENT_TARGET_ppc = 10.3;
PREBINDING = NO;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
SDKROOT_i386 = /Developer/SDKs/MacOSX10.4u.sdk;
SDKROOT_ppc = /Developer/SDKs/MacOSX10.3.9.sdk;
ZERO_LINK = NO;
};
name = Debug;
};
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_VERSION_i386 = 4.0;
GCC_VERSION_ppc = 3.3;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = "";
MACOSX_DEPLOYMENT_TARGET_i386 = 10.4;
MACOSX_DEPLOYMENT_TARGET_ppc = 10.3;
PREBINDING = NO;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
SDKROOT_i386 = /Developer/SDKs/MacOSX10.4u.sdk;
SDKROOT_ppc = /Developer/SDKs/MacOSX10.3.9.sdk;
ZERO_LINK = NO;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "Firefly Helper" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C01FCF4B08A954540054247B /* Debug */,
C01FCF4C08A954540054247B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Firefly Helper" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C01FCF4F08A954540054247B /* Debug */,
C01FCF5008A954540054247B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 29B97313FDCFA39411CA2CEA /* Project object */;
}

View File

@ -0,0 +1,7 @@
//
// Prefix header for all source files of the 'Firefly Minder' target in the 'Firefly Minder' project
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif

View File

@ -0,0 +1,57 @@
//
// FireflyHelper.h
//
// The "controller" part of our Model-View-Controller trio, plus what
// little "view" there is for this mostly-faceless program.
//
// The Firefly Helper manages setup and startup of the server, as well
// as communication withe the Prefs pane via Distributed Objects. It
// also optionally handles the Status Item (the menu by the clock in
// the menu bar).
//
// Created by Mike Kobb on 7/12/06.
// Copyright 2006 Roku, LLC. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "../FireflyPrefsProtocol.h"
#import "FireflyServer.h"
@interface FireflyHelper : NSObject < FireflyPrefsServerProtocol >
{
IBOutlet NSMenu *statusMenu;
NSStatusItem *statusItem;
NSProtocolChecker *protocolChecker;
NSConnection *prefsConnection;
FireflyServer *fireflyServer;
// Our client
id client;
int clientIdent;
}
- (IBAction)startStopMenuChosen:(id)sender;
- (IBAction)prefsMenuChosen:(id)sender;
// NSApplication delegate methods
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
- (void)applicationWillTerminate:(NSNotification *)aNotification;
// private utilities
- (void)serverNotification:(NSNotification *)theNotification;
- (BOOL)checkClient;
// wrappers to client calls; trap exceptions
- (void)tellClientStatusChanged:(FireflyServerStatus)newStatus;
- (void)tellClientVersionChanged:(NSString *)newVersion;
- (void)tellClientURLChanged:(NSString *)newURL;
// Methods for status item
- (void)displayStatusItem;
- (void)hideStatusItem;
- (int)numberOfItemsInMenu:(NSMenu *)menu;
- (void)menuNeedsUpdate:(NSMenu *)menu;
@end

Binary file not shown.

View File

@ -0,0 +1,622 @@
//
// FireflyHelper.m
//
// The "controller" part of our Model-View-Controller trio, plus what
// little "view" there is for this mostly-faceless program.
//
// The Firefly Helper manages setup and startup of the server, as well
// as communication withe the Prefs pane via Distributed Objects. It
// also optionally handles the Status Item (the menu by the clock in
// the menu bar).
//
// Created by Mike Kobb on 7/12/06.
// Copyright 2006 Roku, LLC. All rights reserved.
//
#import "FireflyHelper.h"
#import "FireflyServer.h"
#include "../FireflyCommon.h"
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/sysctl.h>
@implementation FireflyHelper
// ---------------------------------------------------------------------------
// init
//
// Note that we create this path in this way primarily because we cribbed
// the code from the prefs pane, and we eventually will probably
// change both, so for now it's best to be consistent.
// ---------------------------------------------------------------------------
- (id)init
{
protocolChecker = nil;
prefsConnection = nil;
fireflyServer = nil;
statusItem = nil;
client = nil;
clientIdent = 0;
return self;
}
// ---------------------------------------------------------------------------
// dealloc
// ---------------------------------------------------------------------------
- (void)dealloc
{
[protocolChecker release];
[prefsConnection release];
[statusItem release];
[FireflyServer release];
[super dealloc];
}
// ---------------------------------------------------------------------------
// applicationDidFinishLaunching
//
// We implement this delegate method so that we will be called when the
// Firefly Helper app is launched. We check to see if the prefs say
// we should launch the server when we launch, and if they do, we launch.
// ---------------------------------------------------------------------------
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Perform any checking of the installation here. Probably just look for
// the config file and put up a dialog if not found.
bool bSuccess = false;
NSString *errorString = @"";
do // while(false)
{
// Create and initialize our fireflyServer object
NSString *serverPath =
[[NSBundle bundleForClass:[self class]] pathForResource:@"firefly"
ofType:nil
inDirectory:@"Server"];
fireflyServer =
[[[FireflyServer alloc] initWithServerPath:serverPath] retain];
if( nil == fireflyServer )
{
errorString =
NSLocalizedString( @"Failed to initialize Firefly server",
@"explanatory text for failure to launch Firefly helper" );
break;
}
// Register for notifications from our server. Go ahead and do this before we
// start it.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(serverNotification:)
name:@STATUS_CHANGE
object:fireflyServer ];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(serverNotification:)
name:@VERSION_CHANGE
object:fireflyServer ];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(serverNotification:)
name:@URL_CHANGE
object:fireflyServer ];
// Must call this or Bonjour stuff won't work
[fireflyServer setup];
CFBooleanRef shouldLaunch = CFPreferencesCopyAppValue( CFSTR(FF_PREFS_LAUNCH_AT_LOGIN),
CFSTR(FF_PREFS_DOMAIN) );
if( NULL != shouldLaunch )
{
if( CFBooleanGetValue( shouldLaunch ) )
[fireflyServer start];
CFRelease( shouldLaunch );
}
// Okay, we're open for business. Let's vend our interface for
// the prefs pane to use
CFStringRef userName = CSCopyUserName( false );
NSString *serviceName = [@"FireflyHelper" stringByAppendingString:(NSString*)userName];
CFRelease(userName);
protocolChecker = [NSProtocolChecker
protocolCheckerWithTarget:self
protocol:@protocol(FireflyPrefsServerProtocol)];
prefsConnection = [NSConnection defaultConnection];
[prefsConnection setRootObject:protocolChecker];
if( ![prefsConnection registerName:serviceName] )
{
errorString =
NSLocalizedString( @"Unable to open communication channel for Preference pane",
@"explanatory text for failure to luanch Firefly helper" );
break;
}
// Made it through!
bSuccess = true;
// If we're supposed to put up a Menu Extra (NSStatusItem), do so
CFBooleanRef showMenu = CFPreferencesCopyAppValue( CFSTR(FF_PREFS_SHOW_MENU_EXTRA),
CFSTR(FF_PREFS_DOMAIN) );
if( NULL != showMenu )
{
if( CFBooleanGetValue( showMenu ) )
[self displayStatusItem];
CFRelease( showMenu );
}
} while( false );
// If we encountered a critical failure, we need to display an alert and
// then quit.
if( !bSuccess )
{
NSString *alertString = NSLocalizedString( @"Firefly cannot start",
@"Alert message when firefly helper can't start" );
NSString *quitString = NSLocalizedString( @"Quit",
@"Label for quit button in failure alert" );
NSAlert *alert = [NSAlert alertWithMessageText:alertString
defaultButton:quitString
alternateButton:nil
otherButton:nil
informativeTextWithFormat:errorString];
[alert setAlertStyle:NSCriticalAlertStyle];
[NSApp activateIgnoringOtherApps:YES];
[alert runModal];
[NSApp terminate:self];
}
}
// ---------------------------------------------------------------------------
// applicationWillTerminate
//
// We implement this delegate method so that we will be called when the
// Firefly Helper app is quitting. When the user logs out, we quit their
// Firefly server process.
// ---------------------------------------------------------------------------
- (void)applicationWillTerminate:(NSNotification *)aNotification
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
// Notify the prefs pane we're bailing?
[fireflyServer shutdown]; // also stops the server
[prefsConnection invalidate];
}
// ---------------------------------------------------------------------------
// serverNotification
//
// Our handler for notifications from the server
// ---------------------------------------------------------------------------
- (void)serverNotification:(NSNotification *)theNotification
{
if( [[theNotification name] isEqualToString:@STATUS_CHANGE] )
{
[self tellClientStatusChanged:[fireflyServer status]];
}
else if( [[theNotification name] isEqualToString:@VERSION_CHANGE] )
{
[self tellClientVersionChanged:[fireflyServer version]];
}
else if( [[theNotification name] isEqualToString:@URL_CHANGE] )
{
[self tellClientURLChanged:[fireflyServer configURL]];
}
}
// ---------------------------------------------------------------------------
// checkClient
//
// Call this function to see if a client is really connected. If our client
// ivar is nil, returns NO, but if it's not nil, we try to "ping" the client.
// If that ping fails, the client ivar is released and set to nil, and we
// also return NO.
// ---------------------------------------------------------------------------
- (BOOL)checkClient
{
BOOL bRetVal = NO;
@try
{
bRetVal = [client stillThere];
}
@catch( NSException *exception )
{
[client autorelease];
client = nil;
NSLog( @"Client disappeared; setting to nil" );
}
return bRetVal;
}
// ---------------------------------------------------------------------------
// tellClientStatusChanged
//
// A wrapper for the call to statusChanged, that tests client for nil and
// traps any IPC-related exception. If an exception fires, this function
// will call our checkClient function to see if the client is still valid.
// ---------------------------------------------------------------------------
- (void)tellClientStatusChanged:(FireflyServerStatus)newStatus
{
if( nil != client )
{
@try
{
[client statusChanged:newStatus];
}
@catch( NSException *exception )
{
[self checkClient];
}
}
}
// ---------------------------------------------------------------------------
// tellClientVersionChanged
//
// A wrapper for the call to versionChanged. See tellClientStatusChanged
// for details.
// ---------------------------------------------------------------------------
- (void)tellClientVersionChanged:(NSString *)newVersion
{
if( nil != client )
{
@try
{
[client versionChanged:newVersion];
}
@catch( NSException *exception )
{
[self checkClient];
}
}
}
// ---------------------------------------------------------------------------
// tellClientURLChanged
//
// A wrapper for the call to configUrlChanged. See tellClientStatusChanged
// for details.
// ---------------------------------------------------------------------------
- (void)tellClientURLChanged:(NSString *)newURL
{
if( nil != client )
{
@try
{
[client configUrlChanged:newURL];
}
@catch( NSException * )
{
[self checkClient];
}
}
}
// ===========================================================================
// Items pertaining to the Status Item (our little menu bar item)
// ===========================================================================
// ---------------------------------------------------------------------------
// displayStatusItem
//
// Adds our Firefly menu to the menu bar
// ---------------------------------------------------------------------------
- (void)displayStatusItem
{
if( nil == statusItem )
{
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:
NSSquareStatusItemLength] retain];
if( nil != statusItem )
{
[statusMenu setDelegate:self];
[statusItem setMenu:statusMenu];
NSImage *statusImage =
[[NSImage alloc] initWithContentsOfFile:
[[NSBundle mainBundle] pathForResource:@"ff_logo_status_menu"
ofType:@"tif"]];
[statusItem setImage:statusImage];
[statusItem setHighlightMode:YES];
}
}
}
// ---------------------------------------------------------------------------
// hideStatusItem
//
// Takes our Firefly menu out of the menu bar
// ---------------------------------------------------------------------------
- (void)hideStatusItem
{
if( nil != statusItem )
{
[[statusItem statusBar] removeStatusItem:statusItem];
[statusItem autorelease];
statusItem = nil;
}
}
// ---------------------------------------------------------------------------
// startStopMenuChosen
//
// Somebody chose "Start Firefly" or "Stop Firefly" from the menu
// ---------------------------------------------------------------------------
- (IBAction)startStopMenuChosen:(id)sender
{
if( nil != fireflyServer )
{
if( [fireflyServer isRunning] )
[fireflyServer stop];
else
[fireflyServer start];
}
}
// ---------------------------------------------------------------------------
// prefsMenuChosen
//
// Somebody chose "Firefly PreferencesÉ"
// ---------------------------------------------------------------------------
- (IBAction)prefsMenuChosen:(id)sender
{
NSDictionary *errorDict = nil;
NSString *scriptSource = @"tell application \"System Preferences\"\n"
"activate\n"
"set current pane to pane \"org.fireflymediaserver.prefpanel\"\n"
"end tell\n";
NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource:scriptSource];
if( nil != myScript )
{
[myScript executeAndReturnError:&errorDict];
[myScript release];
}
}
// ---------------------------------------------------------------------------
// numberOfItemsInMenu
//
// NSMenu delegate method. We always return -1 because we don't change the
// number of items in the menu.
// ---------------------------------------------------------------------------
- (int)numberOfItemsInMenu:(NSMenu *)menu
{
return -1;
}
// ---------------------------------------------------------------------------
// menuNeedsUpdate
//
// NSMenu delegate method. If our status has changed, we update the menu
// item text.
// ---------------------------------------------------------------------------
- (void)menuNeedsUpdate:(NSMenu *)menu
{
if( menu == statusMenu && 3 == [menu numberOfItems] )
{
// Just need to update the status of the server and the start/stop
// menu
id item = [menu itemAtIndex:0];
[item setTitle:StringForFireflyStatus( [self fireflyStatus] )];
item = [menu itemAtIndex:1];
if( [self fireflyIsRunning] )
{
[item setTitle:NSLocalizedString( @"Stop Firefly",
@"Text for status menu" )];
}
else
{
[item setTitle:NSLocalizedString( @"Start Firefly",
@"Text for status menu" )];
}
}
}
// ===========================================================================
// Implementation of FireflyPrefsProtocol
// ===========================================================================
// ---------------------------------------------------------------------------
// registerClient
//
// When the Prefs pane starts up and connects to us, it will register itself
// with us so that we may notify it of changes in the server status while
// it's open. This registration process also gives us the ability to detect
// when a
// ---------------------------------------------------------------------------
- (BOOL)registerClient:(id) newClient withIdentifier:(int) ident
{
BOOL bRetVal = NO;
if( nil != client )
{
// Hm. We already have a client connected. Let's see if it's really
// still there. This will set client to nil if the client has died.
if( [self checkClient] )
NSLog(@"registerClient called, but valid client already connected!\n");
}
if( nil == client )
{
client = [newClient retain];
clientIdent = ident;
bRetVal = YES;
}
return bRetVal;
}
// ---------------------------------------------------------------------------
// unregisterClientId
//
// When the Prefs pane is closing, it unregisters, so we know not to try to
// send it more udpates
// ---------------------------------------------------------------------------
- (void)unregisterClientId:(int) ident
{
if( ident == clientIdent )
{
clientIdent = 0;
[client autorelease];
client = nil;
}
}
// ---------------------------------------------------------------------------
// startFirefly
//
// Starts the server. Return value indicates that the server process was
// started. If a client has registered for status updates, it will see the
// status kFireflyStatusStarting. The server could possibly quit before
// coming online, so clients really should register for status updates.
// ---------------------------------------------------------------------------
- (FireflyStartResult)startFirefly
{
FireflyStartResult retVal = kFireflyStartFail;
if( nil != fireflyServer && [fireflyServer start] )
retVal = kFireflyStartSuccess;
return retVal;
}
// ---------------------------------------------------------------------------
// stopFirefly
//
// Signals the server to stop. A successful return value indicates that the
// server was not running, or has been successfully signaled to stop.
// Clients should register for status updates and look for the actual change
// to kFireflyStatusStopped to confirm shutdown.
// ---------------------------------------------------------------------------
- (FireflyStopResult)stopFirefly
{
FireflyStopResult retVal = kFireflyStopFail;
if( nil != fireflyServer && [fireflyServer stop] )
retVal = kFireflyStopSuccess;
return retVal;
}
// ---------------------------------------------------------------------------
// rescanLibrary
//
// Tells the server to re-scan the library. Returns a failure result if
// the server is not running.
// ---------------------------------------------------------------------------
- (FireflyRescanResult)rescanLibrary
{
FireflyRescanResult retVal = kFireflyRescanInvalid;
if( nil != fireflyServer )
retVal = [fireflyServer status];
return retVal;
}
// ---------------------------------------------------------------------------
// fireflyStatus
//
// Replies with the state of the server
// ---------------------------------------------------------------------------
- (FireflyServerStatus)fireflyStatus
{
FireflyServerStatus retVal = kFireflyStatusInvalid;
if( nil != fireflyServer )
retVal = [fireflyServer status];
return retVal;
}
// ---------------------------------------------------------------------------
// stopFirefly
//
// Signals the server to restart. A successful return value indicates that
// the server has been successfully signaled to restart.
// Clients should register for status updates and look for the actual changes
// in server status to verify that the signal is handled.
// ---------------------------------------------------------------------------
- (FireflyRestartResult)restartFirefly
{
FireflyRestartResult retVal = kFireflyRestartFail;
if( nil != fireflyServer && [fireflyServer restart] )
retVal = kFireflyRestartSuccess;
return retVal;
}
// ---------------------------------------------------------------------------
// fireflyVersion
//
// Replies with the version of the server. Returns nil if the
// server is not running or we are unable to ascertain the version. Note
// that a method invocation on nil returns nil, so we don't need to check
// fireflyServer for nil.
// ---------------------------------------------------------------------------
- (NSString *)fireflyVersion
{
return [fireflyServer version];
}
// ---------------------------------------------------------------------------
// fireflyConfigURL
//
// Replies with the URL to the advanced configuration page for the server.
// Returns nil if the server is not running or we are unable to
// ascertain the URL. See note about nil above.
// ---------------------------------------------------------------------------
- (NSString *)fireflyConfigURL
{
return [fireflyServer configURL];
}
// ---------------------------------------------------------------------------
// showHelperMenu
//
// Allows the prefs pane to specify whether to show the item. This setting
// is persistent
// ---------------------------------------------------------------------------
- (void)showHelperMenu:(BOOL)bShowMenu
{
if( bShowMenu )
[self displayStatusItem];
else
[self hideStatusItem];
}
// ---------------------------------------------------------------------------
// fireflyVersion
//
// Returns YES if the server is running, NO if not
// ---------------------------------------------------------------------------
- (BOOL)fireflyIsRunning
{
BOOL retVal = NO;
if( nil != fireflyServer )
retVal = [fireflyServer isRunning];
return retVal;
}
// ===========================================================================
// Implementation of NSMenuValidation
// ===========================================================================
// ---------------------------------------------------------------------------
// validateMenuItem
//
// Our first item is always disabled. Our last is always enabled. The
// one in the middle depends upon our status
// ---------------------------------------------------------------------------
- (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem
{
BOOL bRetVal = NO;
if( nil != statusMenu && 3 == [statusMenu numberOfItems] )
{
if( menuItem == [statusMenu itemAtIndex:2] )
bRetVal = YES;
else if( menuItem == [statusMenu itemAtIndex:1] )
{
FireflyServerStatus status = [self fireflyStatus];
if( status != kFireflyStatusStopping && status != kFireflyStatusInvalid )
bRetVal = YES;
}
}
return bRetVal;
}
@end

View File

@ -0,0 +1,91 @@
//
// FireflyServer.h
//
// The "model" part of our Model-View-Controller trio. Represents the
// firefly server itself, and encapsulates launching, quitting, status,
// etc.
//
// Created by Mike Kobb on 7/12/06.
// Copyright 2006 Roku, LLC. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#include "../FireflyCommon.h"
#define STATUS_CHANGE "org.fireflymediaserver.status-change"
#define VERSION_CHANGE "org.fireflymediaserver.version-change"
#define URL_CHANGE "org.fireflymediaserver.url-change"
@interface FireflyServer : NSObject
{
NSString *fireflyServerPath;
NSTask *serverTask;
NSString *serverVersion;
NSString *serverURL;
unsigned short serverPort;
id delegate;
FireflyServerStatus status;
// We use Bonjour to find our server port and help notice if the server
// stops
NSNetServiceBrowser *netBrowser;
BOOL bScanIsActive;
NSMutableArray *pendingNetServices;
NSNetService *fireflyService;
char ffid[9];
}
// public methods for managing the lifecycle of the server object
- (void)setup;
- (void)shutdown;
// public methods for controlling the server process
- (id)initWithServerPath:(NSString *) serverPath;
- (BOOL)start;
- (BOOL)stop;
- (BOOL)restart;
- (void)setDelegate:(id) delegate;
// public methods for querying server status & properties
- (BOOL)isRunning;
- (FireflyServerStatus)status;
- (NSString *)version;
- (NSString *)configURL;
// private utilities
- (void)setStatus:(FireflyServerStatus)newStatus;
- (void)setURL:(NSString *)newURL;
- (void)setVersion:(NSString *)newVersion;
- (void)taskEnded:(NSNotification *)notification;
- (NSString*)fireflyConfigFilePath;
- (BOOL)startAndUpdateStatus:(BOOL)bUpdate;
- (void)killRunningFireflies;
// Bonjour delegate methods (NSNetServiceBrowser)
- (void)netServiceBrowserWillSearch:(NSNetServiceBrowser *)netServiceBrowser;
- (void)netServiceBrowserDidStopSearch:(NSNetServiceBrowser *)netServiceBrowser;
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser
didRemoveService:(NSNetService *)netService
moreComing:(BOOL)moreServicesComing;
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser
didRemoveDomain:(NSString *)domainName
moreComing:(BOOL)moreDomainsComing;
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser
didNotSearch:(NSDictionary *)errorInfo;
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser
didFindService:(NSNetService *)netService
moreComing:(BOOL)moreServicesComing;
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser
didFindDomain:(NSString *)domainName
moreComing:(BOOL)moreDomainsComing;
// Bonjour delegate methods (NSNetService)
- (void)netServiceDidResolveAddress:(NSNetService *)service;
- (void)netService:(NSNetService *)service didNotResolve:(NSDictionary *)errorInfo;
- (void)netServiceWillResolve:(NSNetService *)service;
@end

View File

@ -0,0 +1,659 @@
//
// FireflyServer.m
//
// The "model" part of our Model-View-Controller trio. Represents the
// firefly server itself, and encapsulates launching, quitting, status,
// etc.
//
// Created by Mike Kobb on 7/12/06.
// Copyright 2006 Roku, LLC. All rights reserved.
//
#import <CoreFoundation/CoreFoundation.h>
#import <netinet/in.h> // for sockaddr_in
#include <arpa/inet.h> // for inet_ntoa and so forth
#include <sys/socket.h> // AF_INET6
#import "FireflyServer.h"
@implementation FireflyServer
// ---------------------------------------------------------------------------
// initWithServerPath
//
// Initialize the server object to manage the server at the given path.
// ---------------------------------------------------------------------------
- (id)initWithServerPath:(NSString *) path
{
if( ( self = [super init] ) != nil )
{
fireflyServerPath = [[NSString stringWithString:path] retain];
serverTask = nil;
delegate = nil;
serverVersion = nil;
serverURL = nil;
status = kFireflyStatusStopped;
// Bonjour stuff below
netBrowser = [[NSNetServiceBrowser alloc] init];
pendingNetServices = [[NSMutableArray arrayWithCapacity:5] retain];
fireflyService = nil;
// Pick a random ffid that we'll be able to use to identify our
// server easily
srand((unsigned int)time(NULL));
sprintf( ffid, "%08x", rand() );
// Register for task ending notifications, so we can find out
// if our server process quits.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(taskEnded:)
name:NSTaskDidTerminateNotification
object:nil];
}
return self;
}
// ---------------------------------------------------------------------------
// dealloc
//
//
// ---------------------------------------------------------------------------
- (void)dealloc
{
// First, kill the server!
[fireflyServerPath release];
[serverTask release];
[serverVersion release];
[serverURL release];
[netBrowser release];
[pendingNetServices release];
[fireflyService release];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
// ---------------------------------------------------------------------------
// setup
//
// Not to be confused with 'start', this function is to be called before
// starting to use the object. It handles starting our Bonjour stuff and
// so on.
// ---------------------------------------------------------------------------
- (void)setup
{
// It's time to start our scan, limiting to the local host.
[netBrowser setDelegate:self];
[netBrowser searchForServicesOfType:@"_http._tcp." inDomain:@"local."];
}
// ---------------------------------------------------------------------------
// shutdown
//
// Not to be confused with 'stop', this function is to be called when
// preparing to dispose the object. It handles shutting down our Bonjour
// stuff and so on. But, it does also stop the server if it's running.
// ---------------------------------------------------------------------------
- (void)shutdown
{
// shut down the firefly server
[self setStatus:kFireflyStatusStopping];
[self stop];
// Now shut down the Bonjour scan.
[netBrowser stop];
// FIXME: Is it safe to do this right after calling stop, or should we
// put these in didStop?
NSEnumerator *enumerator = [pendingNetServices objectEnumerator];
NSNetService *service;
while( service = [enumerator nextObject] )
[service stop];
[pendingNetServices removeAllObjects];
}
// ---------------------------------------------------------------------------
// setDelegate
//
// We will message our delegate when important things happen, like the server
// starting or stopping, etc.
// ---------------------------------------------------------------------------
- (void)setDelegate:(id) delegateToSet
{
delegate = delegateToSet;
}
// ---------------------------------------------------------------------------
// isRunning
//
// Is the server running?
// ---------------------------------------------------------------------------
- (BOOL)isRunning
{
BOOL retVal = NO;
if( nil != serverTask )
retVal = [serverTask isRunning];
return retVal;
}
// ---------------------------------------------------------------------------
// start
//
// Starts the server. Note that this function may fail if the server is
// already running.
// ---------------------------------------------------------------------------
- (BOOL)start
{
BOOL retVal = NO;
FireflyServerStatus curStatus = [self status];
if( curStatus == kFireflyStatusStopped ||
curStatus == kFireflyStatusStartFailed ||
curStatus == kFireflyStatusCrashed )
{
retVal = [self startAndUpdateStatus:YES];
}
return retVal;
}
// ---------------------------------------------------------------------------
// stop
//
// Signals the server to stop. Returns YES if the signal was sent successfully
// ---------------------------------------------------------------------------
- (BOOL)stop
{
BOOL retVal = NO;
if( nil != serverTask )
{
[self setStatus:kFireflyStatusStopping];
[serverTask terminate];
retVal = YES;
}
return retVal;
}
// ---------------------------------------------------------------------------
// restart
//
// restarts the server. Tells the server to shut down after setting our
// status to "restarting". When the server shuts down, the taskEnded
// method will see that status, and restart the server.
// ---------------------------------------------------------------------------
- (BOOL)restart
{
BOOL retVal = NO;
if( nil != serverTask )
{
[self setStatus:kFireflyStatusRestarting];
[serverTask terminate];
retVal = YES;
}
return retVal;
}
// ---------------------------------------------------------------------------
// status
//
// Returns the current server status
// ---------------------------------------------------------------------------
- (FireflyServerStatus)status
{
return status;
}
// ---------------------------------------------------------------------------
// version
//
// Returns the current server version, or nil if it's not yet known
// ---------------------------------------------------------------------------
- (NSString *)version
{
return serverVersion;
}
// ---------------------------------------------------------------------------
// configURL
//
// Returns the server's advanced user configuration URL, or nil if it's not
// yet known
// ---------------------------------------------------------------------------
- (NSString *)configURL
{
return serverURL;
}
// ===========================================================================
// Private utilities.
// ===========================================================================
// ---------------------------------------------------------------------------
// setStatus
//
// Sets the status and notifies interested parties of the change.
// ---------------------------------------------------------------------------
- (void)setStatus:(FireflyServerStatus) newStatus
{
status = newStatus;
[[NSNotificationCenter defaultCenter] postNotificationName:@STATUS_CHANGE
object:self];
}
// ---------------------------------------------------------------------------
// setURL
//
// Sets the server config URL and notifies interested parties of the change.
// ---------------------------------------------------------------------------
- (void)setURL:(NSString *) newUrl
{
[serverURL autorelease];
serverURL = [[NSString stringWithString:newUrl] retain];
[[NSNotificationCenter defaultCenter] postNotificationName:@URL_CHANGE
object:self];
}
// ---------------------------------------------------------------------------
// setVersion
//
// Sets the server version and notifies interested parties of the change.
// ---------------------------------------------------------------------------
- (void)setVersion:(NSString *)newVersion
{
[serverVersion autorelease];
serverVersion = [[NSString stringWithString:newVersion] retain];
[[NSNotificationCenter defaultCenter] postNotificationName:@VERSION_CHANGE
object:self];
}
// ---------------------------------------------------------------------------
// taskEnded
//
// We register this function to be called when tasks end. If the task is
// our server task, then we dispose the (now useless) object and notify
// interested parties of the change. We check for normal versus abnormal
// termination and set status accordingly.
// ---------------------------------------------------------------------------
- (void)taskEnded:(NSNotification *)notification
{
if( serverTask == [notification object] )
{
int termStatus = [[notification object] terminationStatus];
[serverTask autorelease];
serverTask = nil;
if( kFireflyStatusRestarting == status )
{
// Don't post the message saying that the server stopped;
// just start up and let the success or failure of that startup
// handle the status update.
[self startAndUpdateStatus:NO];
}
else
{
if( 0 == termStatus )
[self setStatus:kFireflyStatusStopped];
else if( kFireflyStatusStarting == status )
[self setStatus:kFireflyStatusStartFailed];
else
[self setStatus:kFireflyStatusCrashed];
NSLog(@"Server Task ended with status %d\n", termStatus);
}
}
}
// ---------------------------------------------------------------------------
// fireflyConfigFilePath
//
// Build the path to the config file, test that it's valid and return it. If
// we can't find a file at the expected location, we return nil
// ---------------------------------------------------------------------------
- (NSString*)fireflyConfigFilePath
{
NSString *retVal = nil;
NSArray * appSupportDirArray =
NSSearchPathForDirectoriesInDomains( NSLibraryDirectory,
NSUserDomainMask,
YES );
if( [appSupportDirArray count] > 0 )
{
BOOL bIsDir = NO;
NSFileManager *mgr = [NSFileManager defaultManager];
NSString *configFilePath =
[[appSupportDirArray objectAtIndex:0]
stringByAppendingPathComponent:@"Application Support/Firefly/"
FIREFLY_CONF_NAME];
if( [mgr fileExistsAtPath:configFilePath isDirectory:&bIsDir] && !bIsDir )
retVal = configFilePath;
}
return retVal;
}
// ---------------------------------------------------------------------------
// startAndUpdateStatus
//
// Private utility that actually starts the server. If the bUpdate flag is
// NO, then this utility will leave the current status in place, even though
// the server is starting. This is intended for use by the restart function,
// so that the status will remain in "restarting" until the server actually
// comes online (or fails)
// ---------------------------------------------------------------------------
- (BOOL)startAndUpdateStatus:(BOOL)bUpdate
{
BOOL retVal = NO;
[self killRunningFireflies];
NSString *configFilePath = [self fireflyConfigFilePath];
if( nil != configFilePath )
{
NSArray *array = [NSArray arrayWithObjects:
@"-y", @"-f", @"-c",
configFilePath,
@"-b",
[NSString stringWithUTF8String:ffid], // best 10.4<->10.3 compromise method...
nil];
@try
{
serverTask = [[[NSTask alloc] init] retain];
[serverTask setLaunchPath:fireflyServerPath];
[serverTask setCurrentDirectoryPath:[fireflyServerPath stringByDeletingLastPathComponent]];
[serverTask setArguments:array];
if( bUpdate )
[self setStatus:kFireflyStatusStarting];
[serverTask launch];
retVal = YES;
}
@catch( NSException *exception )
{
if( [[exception name] isEqual:NSInvalidArgumentException] )
;
NSLog(@"FireflyServer: Caught %@: %@", [exception name], [exception reason]);
[self setStatus:kFireflyStatusStartFailed];
}
}
else
{
NSLog(@"couldn't find config file at %@\n", configFilePath);
}
return retVal;
}
// ---------------------------------------------------------------------------
// killRunningFireflies
//
// This may seem like paranoia, but things really go badly if there is more
// than one copy of Firefly running (e.g. started from the command line, or
// failing to quit when signaled). So, we enforce some preconditions here.
// ---------------------------------------------------------------------------
- (void)killRunningFireflies
{
kinfo_proc *result;
size_t length;
GetProcesses( &result, &length );
// Okay, now we have our list of processes. Let's find OUR copy of
// firefly. Note that Firefly runs as multiple processes, so we look
// through all processes, not stopping when we find one. We *are*
// careful to only kill processes owned by the current user!
if( NULL != result )
{
int procCount = length / sizeof(kinfo_proc);
int i = 0;
uid_t ourUID = getuid();
for( ; i < procCount; i++ )
{
if( ourUID == result[i].kp_eproc.e_pcred.p_ruid &&
0 == strcasecmp( result[i].kp_proc.p_comm, FIREFLY_SERVER_NAME ) )
{
NSLog(@"Killing rogue firefly, pid %d\n", result[i].kp_proc.p_pid);
kill( result[i].kp_proc.p_pid, SIGKILL );
}
}
free( result );
}
}
// ===========================================================================
// Below are the delegate methods for Bonjour discovery of the server.
// ===========================================================================
// ---------------------------------------------------------------------------
// netServiceBrowserWillSearch:
//
// Lets us know that the Bonjour search has started
// ---------------------------------------------------------------------------
- (void)netServiceBrowserWillSearch:(NSNetServiceBrowser *)netServiceBrowser
{
#ifdef FIREFLY_DEBUG
NSLog(@"NSNetServiceBrowser started\n");
#endif
bScanIsActive = YES;
}
// ---------------------------------------------------------------------------
// netServiceBrowserDidStopSearch:
//
// Should only stop if we ask it to, as when we're quitting the app
// ---------------------------------------------------------------------------
- (void)netServiceBrowserDidStopSearch:(NSNetServiceBrowser *)netServiceBrowser
{
#ifdef FIREFLY_DEBUG
NSLog(@"NSNetServiceBrowser stopped\n");
#endif
bScanIsActive = NO;
}
// ---------------------------------------------------------------------------
// netServiceBrowser:didRemoveService:moreComing:
//
// Called when a Bonjour service goes away.
// ---------------------------------------------------------------------------
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser
didRemoveService:(NSNetService *)netService
moreComing:(BOOL)moreServicesComing
{
// Is it our service? If so, we need to switch the status text and change
// the start/stop button, and also update the web page button and text.
if( [netService isEqual:fireflyService] )
{
[fireflyService autorelease];
fireflyService = nil;
// FIXME: AND? Theoretically, we should be notified that our NSTask
// went away, so this notification isn't needed to detect that the
// server stopped. But, what if due to some error, the Bonjour
// service croaked but left the server itself running?
}
}
// ---------------------------------------------------------------------------
// netServiceBrowser:didRemoveDomain:moreComing:
//
// unless our local host goes away, we really don't care.
// ---------------------------------------------------------------------------
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser
didRemoveDomain:(NSString *)domainName
moreComing:(BOOL)moreDomainsComing
{
}
// ---------------------------------------------------------------------------
// netServiceBrowser:didNotSearch:
//
// Called if the search failed to start. We need to alert the user.
// ---------------------------------------------------------------------------
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser
didNotSearch:(NSDictionary *)errorInfo
{
// FIXME: display error info? Try again? Quit?
}
// ---------------------------------------------------------------------------
// netServiceBrowser:didFindService:moreComing:
//
// A Bonjour service has been discovered. It might be our server. We need
// to ask the service to resolve, so we can see if it is.
// ---------------------------------------------------------------------------
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser
didFindService:(NSNetService *)netService
moreComing:(BOOL)moreServicesComing
{
// We need to ask this object to resolve itself so we can figure out if it's the server
// we want. In case the user closes the panel, we need to have a list of all the ones
// pending so we can stop them.
[pendingNetServices addObject:netService];
[netService setDelegate:self];
[netService resolve];
if( !moreServicesComing )
bScanIsActive = NO;
}
// ---------------------------------------------------------------------------
// netServiceBrowser:didFindDomain:moreComing:
//
// Don't think we care about this one, but I'm pretty sure we're supposed to
// implement it (why?)
// ---------------------------------------------------------------------------
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser
didFindDomain:(NSString *)domainName
moreComing:(BOOL)moreDomainsComing
{
}
// ---------------------------------------------------------------------------
// netServiceDidResolveAddress:
//
// We asked a service to resolve, and it has. Time to check to see if it's
// our server.
// ---------------------------------------------------------------------------
- (void)netServiceDidResolveAddress:(NSNetService *)service
{
// Is it a firefly service, and if so, is it ours?
// NOTE: EXTREMELY IMPORTANT!
// protocolSpecificInformation is a deprecated API, and the Tiger-on approved way is TXTRecordData.
// protocolSpecificInformation, though, is available back to 10.2. These return the data in
// DIFFERENT FORMATS. TXTRecordData returns the data in the mDNS-standard format of a packed
// array of Pascal strings, while protocolSpecificInformation returns the strings separated by 0x01
// characters. The TXTRecordContainsKey function and related utilities assume (at least on Tiger)
// the packed-Pascal format, so we have to use strstr instead. Happily, all we really care
// about here is that the ffid tag exists, so we don't need to do much parsing.
const char *version = NULL;
const char* txtRecordBytes = NULL;
NSData *data = nil;
NSString *txtRecord = [service protocolSpecificInformation];
if( nil != txtRecord )
data = [txtRecord dataUsingEncoding:NSUTF8StringEncoding];
txtRecordBytes = (const char*)[data bytes];
if( NULL != txtRecordBytes &&
NULL != ( version = strnstr( txtRecordBytes, "\001mtd-version=", [data length] ) ) )
{
// Okay, this is a firefly server. Let's see if it's *our* server
int i = 0;
char buf[256]; // max allowed size, but we'll still be careful not to overrun.
strncpy( buf, txtRecordBytes, 255 );
buf[255] = '\0';
#ifdef FIREFLY_DEBUG
NSLog( @"Text record is: %s\n", buf );
#endif
const char *ffidptr = strnstr( txtRecordBytes, "\001ffid=", [data length] );
if( NULL != ffidptr )
{
// This is a bit of a pain due to the stuff described in the big
// comment above.
// advance over the key
ffidptr += 6;
while( '\0' != ffidptr[i] &&
'\001' != ffidptr[i] &&
((ffidptr-txtRecordBytes)+i) < [data length] )
{
#ifdef FIREFLY_DEBUG
NSLog(@"Adding %c (%d)to ffidptr\n", ffidptr[i], ffidptr[i]);
#endif
buf[i] = ffidptr[i++];
}
buf[i] = '\0';
NSLog(@"Comparing buf %s against our ffid %s\n", buf, ffid);
if( 0 == strcmp( buf, ffid ) )
{
// WOOT! This is us. Get the version and port
i = 0;
version += 13;
while( '\0' != version[i] &&
'\001' != version[i] &&
((version-txtRecordBytes)+i) < [data length] )
buf[i] = version[i++];
buf[i] = '\0';
[self setVersion:[NSString stringWithUTF8String:buf]];
// Time to get the port.
NSArray *svcAddresses = [service addresses];
if( 0 != [svcAddresses count] )
{
NSData *addrData = [svcAddresses objectAtIndex:0];
struct sockaddr_in *addrPtr = (struct sockaddr_in*)[addrData bytes];
if( NULL != addrPtr )
{
serverPort = ntohs(addrPtr->sin_port);
[self setURL:[NSString stringWithFormat:@"http://localhost:%u", serverPort]];
}
}
// Okay, it's the one we want, so let's remember it and update
// our status
[fireflyService autorelease];
fireflyService = [service retain];
[self setStatus:kFireflyStatusActive];
#ifdef FIREFLY_DEBUG
NSBeep();
sleep(1);
NSBeep();
sleep(1);
NSBeep();
#endif
}
}
}
// It's no longer pending, so remove from array. If it was ours, we've
// retained it.
[pendingNetServices removeObject:service];
// If we're no longer scanning and we've exhausted all the
// services that we found without identifying the correct server,
// we need to ...?
if( !bScanIsActive && 0 == [pendingNetServices count] && nil == fireflyService )
; //FIXME
}
// ---------------------------------------------------------------------------
// netService:didNotResolve:
//
// We tried to resolve a service, and failed. It's probably not really
// running. We could always try again, but it doesn't seem to be necessary
// ---------------------------------------------------------------------------
- (void)netService:(NSNetService *)service didNotResolve:(NSDictionary *)errorInfo
{
[pendingNetServices removeObject:service];
#ifdef FIREFLY_DEBUG
if( nil == fireflyService )
NSLog(@"Failed to resolve service: %@\n", [errorInfo valueForKey:NSNetServicesErrorCode] );
#endif
}
// ---------------------------------------------------------------------------
// netServiceWillResolve:
//
// Just lets us know resolution has started.
// ---------------------------------------------------------------------------
- (void)netServiceWillResolve:(NSNetService *)service
{
}
@end

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>FireflyHelper</string>
<key>CFBundleIdentifier</key>
<string>org.fireflymediaserver.fireflyhelper</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>102</string>
<key>CFBundleShortVersionString</key>
<string>1.0b2</string>
<key>NSHumanReadableCopyright</key>
<string>© 2006 Roku LLC</string>
<key>LSUIElement</key>
<string>1</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

Binary file not shown.

View File

@ -0,0 +1,4 @@
{
IBClasses = ({CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; });
IBVersion = 1;
}

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>94 103 356 240 0 0 1280 1002 </string>
<key>IBEditorPositions</key>
<dict>
<key>29</key>
<string>93 343 318 44 0 0 1280 1002 </string>
</dict>
<key>IBFramework Version</key>
<string>403.0</string>
<key>IBSystem Version</key>
<string>8A278</string>
</dict>
</plist>

Binary file not shown.

Binary file not shown.

14
osx/Firefly Helper/main.m Normal file
View File

@ -0,0 +1,14 @@
//
// main.m
// Firefly Minder
//
// Created by Mike Kobb on 6/8/06.
// Copyright __MyCompanyName__ 2006. All rights reserved.
//
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **) argv);
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildVersion</key>
<string>1</string>
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<key>CFBundleVersion</key>
<string>0.1</string>
<key>ProjectName</key>
<string>NibPBTemplates</string>
<key>SourceVersion</key>
<string>1160200</string>
</dict>
</plist>

229
osx/FireflyCommon.h Normal file
View File

@ -0,0 +1,229 @@
/*
* FireflyCommonConstants.h
*
* Created by Mike Kobb on 7/12/06.
* Copyright 2006 Roku LLC. All rights reserved.
*
* This file contains common constants and types needed by both the
* prefs pane and helper apps.
*/
#ifndef __ORG_FIREFLYMEDIASERVER_FIREFLY_COMMON_H
#define __ORG_FIREFLYMEDIASERVER_FIREFLY_COMMON_H
#include <sys/sysctl.h> // used by GetProcesses
#define FIREFLY_SERVER_NAME "firefly"
#define FIREFLY_DIR_NAME "Firefly"
#define FIREFLY_CONF_NAME "firefly.conf"
#define FF_PREFS_DOMAIN "org.fireflymediaserver.firefly"
#define FF_PREFS_LAUNCH_AT_LOGIN "org.fireflymediaserver.launchAtLogin"
#define FF_PREFS_SHOW_MENU_EXTRA "org.fireflymediaserver.showMenuExtra"
// Define this to enable certain debug output
//#define FIREFLY_DEBUG
typedef enum
{
kFireflyStartInvalid = 0,
kFireflyStartSuccess = 1,
kFireflyStartFail = 2
} FireflyStartResult;
typedef enum
{
kFireflyStopInvalid = 0,
kFireflyStopSuccess = 1,
kFireflyStopFail = 2
} FireflyStopResult;
typedef enum
{
kFireflyRestartInvalid = 0,
kFireflyRestartSuccess = 1,
kFireflyRestartFail = 2
} FireflyRestartResult;
typedef enum
{
kFireflyRescanInvalid = 0,
kFireflyRescanSuccess = 1,
kFireflyRescanFail = 2
} FireflyRescanResult;
typedef enum
{
kFireflyStatusInvalid,
kFireflyStatusStopped,
kFireflyStatusStarting,
kFireflyStatusActive,
kFireflyStatusScanning,
kFireflyStatusStopping,
kFireflyStatusRestarting,
kFireflyStatusStartFailed,
kFireflyStatusCrashed
} FireflyServerStatus;
static NSString*
StringForFireflyStatus( FireflyServerStatus inStatus )
{
NSString *retVal = nil;
switch( inStatus )
{
case kFireflyStatusStopped:
retVal = NSLocalizedString( @"Firefly is not running",
@"Status message for Firefly" );
break;
case kFireflyStatusStarting:
retVal = NSLocalizedString( @"Firefly is starting",
@"Status message for Firefly" );
break;
case kFireflyStatusActive:
retVal = NSLocalizedString( @"Firefly is running",
@"Status message for Firefly" );
break;
case kFireflyStatusScanning:
retVal = NSLocalizedString( @"Firefly is scanning the library",
@"Status message for Firefly" );
break;
case kFireflyStatusStopping:
retVal = NSLocalizedString( @"Firefly is stopping",
@"Status message for Firefly" );
break;
case kFireflyStatusRestarting:
retVal = NSLocalizedString( @"Firefly is restarting",
@"Status message for Firefly" );
break;
case kFireflyStatusStartFailed:
retVal = NSLocalizedString( @"Firefly failed to start",
@"Status message for Firefly" );
break;
case kFireflyStatusCrashed:
retVal = NSLocalizedString( @"Firefly stopped unexpectedly",
@"Status message for Firefly" );
break;
case kFireflyStatusInvalid:
default:
retVal = NSLocalizedString( @"Firefly status is unknown",
@"Status message for Firefly" );
break;
}
return retVal;
}
// ===========================================================================
// Process management the Unix way -- Finding if the server is already
// running, or finding a specific process
// ===========================================================================
// This just makes syntax more convenient (don't have to say 'struct' everyplace)
typedef struct kinfo_proc kinfo_proc;
// ------------------------------------------------------------------------
// GetProcesses
//
// Static utility function allocates and returns an array of kinfo_proc
// structures representing the currently-running processes on the machine.
// The calling function is responsible for disposing the returned pointer
// with free()
//
// Because Firefly runs as a BSD daemon, the Process Manager is not useful
// in finding it. Instead, we have to talk to the BSD layer. This code
// was provided by Apple in a tech note.
// ------------------------------------------------------------------------
static void
GetProcesses( kinfo_proc **outResult, size_t *outLength)
{
int err;
kinfo_proc * result;
BOOL done;
static const int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
// Declaring name as const requires us to cast it when passing it to
// sysctl because the prototype doesn't include the const modifier.
// (That's the Apple comment, but they don't say *why* they made it const...)
size_t length;
// We call sysctl with result == NULL and length == 0.
// That will succeed, and set length to the appropriate length.
// We then allocate a buffer of that size and call sysctl again
// with that buffer. If that succeeds, we're done. If that fails
// with ENOMEM, we have to throw away our buffer and loop. Note
// that the loop causes use to call sysctl with NULL again; this
// is necessary because the ENOMEM failure case sets length to
// the amount of data returned, not the amount of data that
// could have been returned.
result = NULL;
done = NO;
do
{
// Call sysctl with a NULL buffer.
length = 0;
err = sysctl( (int *) name, (sizeof(name) / sizeof(*name)) - 1,
NULL, &length,
NULL, 0);
if (err == -1)
err = errno;
// Allocate an appropriately sized buffer based on the results
// from the previous call.
if (err == 0)
{
result = malloc(length);
if (result == NULL)
err = ENOMEM;
}
// Call sysctl again with the new buffer. If we get an ENOMEM
// error, toss away our buffer and start again.
if (err == 0)
{
err = sysctl( (int *) name, (sizeof(name) / sizeof(*name)) - 1,
result, &length,
NULL, 0);
if (err == -1)
err = errno;
if (err == 0)
done = YES;
else if (err == ENOMEM)
{
free(result);
result = NULL;
err = 0;
}
}
} while (err == 0 && !done);
// Clean up and establish post conditions.
if( err != 0 )
{
if( result != NULL)
free(result);
*outResult = NULL;
*outLength = 0;
}
if( err == 0 )
{
*outResult = result;
*outLength = length;
}
}
// __ORG_FIREFLYMEDIASERVER_FIREFLY_COMMON_H
#endif

View File

@ -0,0 +1,61 @@
{
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
CLASS = NSPreferencePane;
LANGUAGE = ObjC;
OUTLETS = {
"_firstKeyView" = id;
"_initialKeyView" = id;
"_lastKeyView" = id;
"_window" = id;
};
SUPERCLASS = NSObject;
},
{
ACTIONS = {
applyNowButtonClicked = id;
browseButtonClicked = id;
helperMenuCheckboxClicked = id;
logoButtonClicked = id;
myAction = id;
passwordChanged = id;
portChanged = id;
portPopupChanged = id;
pwCheckBoxChanged = id;
serverStartOptionChanged = id;
shareNameChanged = id;
startStopButtonClicked = id;
webPageButtonClicked = id;
};
CLASS = OrgFireflyMediaServerPrefs;
LANGUAGE = ObjC;
OUTLETS = {
applyNowButton = NSButton;
browseButton = NSButton;
helperMenuCheckbox = NSButton;
libraryField = NSTextField;
libraryIcon = NSImageView;
logTextView = NSTextView;
mainTabView = NSTabView;
myOutlet = id;
nameField = NSTextField;
panelVersionText = NSTextField;
passwordCheckbox = NSButton;
passwordField = NSTextField;
portField = NSTextField;
portPopup = NSPopUpButton;
progressSpinner = NSProgressIndicator;
serverStartOptions = NSPopUpButton;
serverVersionText = NSTextField;
startStopButton = NSButton;
statusText = NSTextField;
webPageButton = NSButton;
webPageInfoText = NSTextField;
};
SUPERCLASS = NSPreferencePane;
},
{CLASS = TextFormatter; LANGUAGE = ObjC; SUPERCLASS = NSFormatter; }
);
IBVersion = 1;
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>41 85 481 349 0 0 1440 878 </string>
<key>IBFramework Version</key>
<string>446.1</string>
<key>IBLockedTabItems</key>
<array>
<integer>99</integer>
</array>
<key>IBOpenObjects</key>
<array>
<integer>12</integer>
</array>
<key>IBSystem Version</key>
<string>8J135</string>
</dict>
</plist>

Binary file not shown.

View File

@ -0,0 +1,61 @@
{
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
CLASS = NSPreferencePane;
LANGUAGE = ObjC;
OUTLETS = {
"_firstKeyView" = id;
"_initialKeyView" = id;
"_lastKeyView" = id;
"_window" = id;
};
SUPERCLASS = NSObject;
},
{
ACTIONS = {
applyNowButtonClicked = id;
browseButtonClicked = id;
helperMenuCheckboxClicked = id;
logoButtonClicked = id;
myAction = id;
passwordChanged = id;
portChanged = id;
portPopupChanged = id;
pwCheckBoxChanged = id;
serverStartOptionChanged = id;
shareNameChanged = id;
startStopButtonClicked = id;
webPageButtonClicked = id;
};
CLASS = OrgFireflyMediaServerPrefs;
LANGUAGE = ObjC;
OUTLETS = {
applyNowButton = NSButton;
browseButton = NSButton;
helperMenuCheckbox = NSButton;
libraryField = NSTextField;
libraryIcon = NSImageView;
logTextView = NSTextView;
mainTabView = NSTabView;
myOutlet = id;
nameField = NSTextField;
panelVersionText = NSTextField;
passwordCheckbox = NSButton;
passwordField = NSTextField;
portField = NSTextField;
portPopup = NSPopUpButton;
progressSpinner = NSProgressIndicator;
serverStartOptions = NSPopUpButton;
serverVersionText = NSTextField;
startStopButton = NSButton;
statusText = NSTextField;
webPageButton = NSButton;
webPageInfoText = NSTextField;
};
SUPERCLASS = NSPreferencePane;
},
{CLASS = TextFormatter; LANGUAGE = ObjC; SUPERCLASS = NSFormatter; }
);
IBVersion = 1;
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>41 85 481 349 0 0 1440 878 </string>
<key>IBFramework Version</key>
<string>446.1</string>
<key>IBLockedTabItems</key>
<array>
<integer>99</integer>
</array>
<key>IBOpenObjects</key>
<array>
<integer>12</integer>
</array>
<key>IBSystem Version</key>
<string>8J135</string>
</dict>
</plist>

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,229 @@
/*
* FireflyCommonConstants.h
*
* Created by Mike Kobb on 7/12/06.
* Copyright 2006 Roku LLC. All rights reserved.
*
* This file contains common constants and types needed by both the
* prefs pane and helper apps.
*/
#ifndef __ORG_FIREFLYMEDIASERVER_FIREFLY_COMMON_H
#define __ORG_FIREFLYMEDIASERVER_FIREFLY_COMMON_H
#include <sys/sysctl.h> // used by GetProcesses
#define FIREFLY_SERVER_NAME "firefly"
#define FIREFLY_DIR_NAME "Firefly"
#define FIREFLY_CONF_NAME "firefly.conf"
#define FF_PREFS_DOMAIN "org.fireflymediaserver.firefly"
#define FF_PREFS_LAUNCH_AT_LOGIN "org.fireflymediaserver.launchAtLogin"
#define FF_PREFS_SHOW_MENU_EXTRA "org.fireflymediaserver.showMenuExtra"
// Define this to enable certain debug output
//#define FIREFLY_DEBUG
typedef enum
{
kFireflyStartInvalid = 0,
kFireflyStartSuccess = 1,
kFireflyStartFail = 2
} FireflyStartResult;
typedef enum
{
kFireflyStopInvalid = 0,
kFireflyStopSuccess = 1,
kFireflyStopFail = 2
} FireflyStopResult;
typedef enum
{
kFireflyRestartInvalid = 0,
kFireflyRestartSuccess = 1,
kFireflyRestartFail = 2
} FireflyRestartResult;
typedef enum
{
kFireflyRescanInvalid = 0,
kFireflyRescanSuccess = 1,
kFireflyRescanFail = 2
} FireflyRescanResult;
typedef enum
{
kFireflyStatusInvalid,
kFireflyStatusStopped,
kFireflyStatusStarting,
kFireflyStatusActive,
kFireflyStatusScanning,
kFireflyStatusStopping,
kFireflyStatusRestarting,
kFireflyStatusStartFailed,
kFireflyStatusCrashed
} FireflyServerStatus;
static NSString*
StringForFireflyStatus( FireflyServerStatus inStatus )
{
NSString *retVal = nil;
switch( inStatus )
{
case kFireflyStatusStopped:
retVal = NSLocalizedString( @"Firefly is not running",
@"Status message for Firefly" );
break;
case kFireflyStatusStarting:
retVal = NSLocalizedString( @"Firefly is starting",
@"Status message for Firefly" );
break;
case kFireflyStatusActive:
retVal = NSLocalizedString( @"Firefly is running",
@"Status message for Firefly" );
break;
case kFireflyStatusScanning:
retVal = NSLocalizedString( @"Firefly is scanning the library",
@"Status message for Firefly" );
break;
case kFireflyStatusStopping:
retVal = NSLocalizedString( @"Firefly is stopping",
@"Status message for Firefly" );
break;
case kFireflyStatusRestarting:
retVal = NSLocalizedString( @"Firefly is restarting",
@"Status message for Firefly" );
break;
case kFireflyStatusStartFailed:
retVal = NSLocalizedString( @"Firefly failed to start",
@"Status message for Firefly" );
break;
case kFireflyStatusCrashed:
retVal = NSLocalizedString( @"Firefly stopped unexpectedly",
@"Status message for Firefly" );
break;
case kFireflyStatusInvalid:
default:
retVal = NSLocalizedString( @"Firefly status is unknown",
@"Status message for Firefly" );
break;
}
return retVal;
}
// ===========================================================================
// Process management the Unix way -- Finding if the server is already
// running, or finding a specific process
// ===========================================================================
// This just makes syntax more convenient (don't have to say 'struct' everyplace)
typedef struct kinfo_proc kinfo_proc;
// ------------------------------------------------------------------------
// GetProcesses
//
// Static utility function allocates and returns an array of kinfo_proc
// structures representing the currently-running processes on the machine.
// The calling function is responsible for disposing the returned pointer
// with free()
//
// Because Firefly runs as a BSD daemon, the Process Manager is not useful
// in finding it. Instead, we have to talk to the BSD layer. This code
// was provided by Apple in a tech note.
// ------------------------------------------------------------------------
static void
GetProcesses( kinfo_proc **outResult, size_t *outLength)
{
int err;
kinfo_proc * result;
BOOL done;
static const int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0 };
// Declaring name as const requires us to cast it when passing it to
// sysctl because the prototype doesn't include the const modifier.
// (That's the Apple comment, but they don't say *why* they made it const...)
size_t length;
// We call sysctl with result == NULL and length == 0.
// That will succeed, and set length to the appropriate length.
// We then allocate a buffer of that size and call sysctl again
// with that buffer. If that succeeds, we're done. If that fails
// with ENOMEM, we have to throw away our buffer and loop. Note
// that the loop causes use to call sysctl with NULL again; this
// is necessary because the ENOMEM failure case sets length to
// the amount of data returned, not the amount of data that
// could have been returned.
result = NULL;
done = NO;
do
{
// Call sysctl with a NULL buffer.
length = 0;
err = sysctl( (int *) name, (sizeof(name) / sizeof(*name)) - 1,
NULL, &length,
NULL, 0);
if (err == -1)
err = errno;
// Allocate an appropriately sized buffer based on the results
// from the previous call.
if (err == 0)
{
result = malloc(length);
if (result == NULL)
err = ENOMEM;
}
// Call sysctl again with the new buffer. If we get an ENOMEM
// error, toss away our buffer and start again.
if (err == 0)
{
err = sysctl( (int *) name, (sizeof(name) / sizeof(*name)) - 1,
result, &length,
NULL, 0);
if (err == -1)
err = errno;
if (err == 0)
done = YES;
else if (err == ENOMEM)
{
free(result);
result = NULL;
err = 0;
}
}
} while (err == 0 && !done);
// Clean up and establish post conditions.
if( err != 0 )
{
if( result != NULL)
free(result);
*outResult = NULL;
*outLength = 0;
}
if( err == 0 )
{
*outResult = result;
*outLength = length;
}
}
// __ORG_FIREFLYMEDIASERVER_FIREFLY_COMMON_H
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,346 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 42;
objects = {
/* Begin PBXBuildFile section */
1061CA7B0A23A648002E88E0 /* OrgFireflyMediaServerPrefs.h in Headers */ = {isa = PBXBuildFile; fileRef = 1061CA790A23A648002E88E0 /* OrgFireflyMediaServerPrefs.h */; };
1061CB530A266BAE002E88E0 /* FireflyLogo.png in Resources */ = {isa = PBXBuildFile; fileRef = 1061CB520A266BAE002E88E0 /* FireflyLogo.png */; };
1062C6FB0A7554840003FC27 /* FireflyCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 1062C6FA0A7554840003FC27 /* FireflyCommon.h */; };
1098819D0A704B3200F53ED9 /* firefly.conf in Resources */ = {isa = PBXBuildFile; fileRef = 1098819C0A704B3200F53ED9 /* firefly.conf */; };
10B4B4030A34E3A9008238B7 /* OrgFireflyMediaServerPrefs.m in Sources */ = {isa = PBXBuildFile; fileRef = 10B4B4020A34E3A9008238B7 /* OrgFireflyMediaServerPrefs.m */; };
10C78FE00A637CA900732D76 /* FireflyPrefsProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 10C78FDF0A637CA900732D76 /* FireflyPrefsProtocol.h */; };
10C7930B0A660CCA00732D76 /* Firefly Helper.app in Resources */ = {isa = PBXBuildFile; fileRef = 10C792B50A660CC900732D76 /* Firefly Helper.app */; };
8D202CEA0486D31800D8A456 /* FireflyPrefs_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 32DBCFA20370C41700C91783 /* FireflyPrefs_Prefix.pch */; };
8D202CED0486D31800D8A456 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; };
8D202CEE0486D31800D8A456 /* FireflyPrefsPref.tiff in Resources */ = {isa = PBXBuildFile; fileRef = F506C040013D9D8001CA16C8 /* FireflyPrefsPref.tiff */; };
8D202CEF0486D31800D8A456 /* FireflyPrefsPref.nib in Resources */ = {isa = PBXBuildFile; fileRef = F506C042013D9D8C01CA16C8 /* FireflyPrefsPref.nib */; };
8D202CF30486D31800D8A456 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
8D202CF40486D31800D8A456 /* PreferencePanes.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F506C035013D953901CA16C8 /* PreferencePanes.framework */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
1061CA790A23A648002E88E0 /* OrgFireflyMediaServerPrefs.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = OrgFireflyMediaServerPrefs.h; sourceTree = "<group>"; };
1061CB520A266BAE002E88E0 /* FireflyLogo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = FireflyLogo.png; sourceTree = "<group>"; };
1062C6FA0A7554840003FC27 /* FireflyCommon.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FireflyCommon.h; sourceTree = "<group>"; };
1098819C0A704B3200F53ED9 /* firefly.conf */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = firefly.conf; sourceTree = "<group>"; };
10B4B4020A34E3A9008238B7 /* OrgFireflyMediaServerPrefs.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = OrgFireflyMediaServerPrefs.m; sourceTree = "<group>"; };
10C78FDF0A637CA900732D76 /* FireflyPrefsProtocol.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = FireflyPrefsProtocol.h; path = ../FireflyPrefsProtocol.h; sourceTree = "<group>"; };
10C792B50A660CC900732D76 /* Firefly Helper.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; path = "Firefly Helper.app"; sourceTree = "<group>"; };
32DBCFA20370C41700C91783 /* FireflyPrefs_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FireflyPrefs_Prefix.pch; sourceTree = "<group>"; };
8D202CF70486D31800D8A456 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8D202CF80486D31800D8A456 /* Firefly.prefPane */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Firefly.prefPane; sourceTree = BUILT_PRODUCTS_DIR; };
F506C035013D953901CA16C8 /* PreferencePanes.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PreferencePanes.framework; path = /System/Library/Frameworks/PreferencePanes.framework; sourceTree = "<absolute>"; };
F506C040013D9D8001CA16C8 /* FireflyPrefsPref.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = FireflyPrefsPref.tiff; sourceTree = "<group>"; };
F506C043013D9D8C01CA16C8 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/FireflyPrefsPref.nib; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
8D202CF20486D31800D8A456 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8D202CF30486D31800D8A456 /* Cocoa.framework in Frameworks */,
8D202CF40486D31800D8A456 /* PreferencePanes.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
089C166AFE841209C02AAC07 /* FireflyPrefs */ = {
isa = PBXGroup;
children = (
08FB77AFFE84173DC02AAC07 /* Classes */,
32DBCFA10370C40200C91783 /* Other Sources */,
089C167CFE841241C02AAC07 /* Resources */,
089C1671FE841209C02AAC07 /* Frameworks and Libraries */,
19C28FB8FE9D52D311CA2CBB /* Products */,
);
name = FireflyPrefs;
sourceTree = "<group>";
};
089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = {
isa = PBXGroup;
children = (
1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */,
1058C7AEFEA557BF11CA2CBB /* Other Frameworks */,
);
name = "Frameworks and Libraries";
sourceTree = "<group>";
};
089C167CFE841241C02AAC07 /* Resources */ = {
isa = PBXGroup;
children = (
10C792B50A660CC900732D76 /* Firefly Helper.app */,
1098819C0A704B3200F53ED9 /* firefly.conf */,
8D202CF70486D31800D8A456 /* Info.plist */,
089C167DFE841241C02AAC07 /* InfoPlist.strings */,
F506C040013D9D8001CA16C8 /* FireflyPrefsPref.tiff */,
F506C042013D9D8C01CA16C8 /* FireflyPrefsPref.nib */,
1061CB520A266BAE002E88E0 /* FireflyLogo.png */,
);
name = Resources;
sourceTree = "<group>";
};
08FB77AFFE84173DC02AAC07 /* Classes */ = {
isa = PBXGroup;
children = (
1062C6FA0A7554840003FC27 /* FireflyCommon.h */,
10C78FDF0A637CA900732D76 /* FireflyPrefsProtocol.h */,
10B4B4020A34E3A9008238B7 /* OrgFireflyMediaServerPrefs.m */,
1061CA790A23A648002E88E0 /* OrgFireflyMediaServerPrefs.h */,
);
name = Classes;
sourceTree = "<group>";
};
1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */,
F506C035013D953901CA16C8 /* PreferencePanes.framework */,
);
name = "Linked Frameworks";
sourceTree = "<group>";
};
1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = {
isa = PBXGroup;
children = (
089C1672FE841209C02AAC07 /* Foundation.framework */,
089C167FFE841241C02AAC07 /* AppKit.framework */,
);
name = "Other Frameworks";
sourceTree = "<group>";
};
19C28FB8FE9D52D311CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
8D202CF80486D31800D8A456 /* Firefly.prefPane */,
);
name = Products;
sourceTree = "<group>";
};
32DBCFA10370C40200C91783 /* Other Sources */ = {
isa = PBXGroup;
children = (
32DBCFA20370C41700C91783 /* FireflyPrefs_Prefix.pch */,
);
name = "Other Sources";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
8D202CE90486D31800D8A456 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
8D202CEA0486D31800D8A456 /* FireflyPrefs_Prefix.pch in Headers */,
1061CA7B0A23A648002E88E0 /* OrgFireflyMediaServerPrefs.h in Headers */,
10C78FE00A637CA900732D76 /* FireflyPrefsProtocol.h in Headers */,
1062C6FB0A7554840003FC27 /* FireflyCommon.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
8D202CE80486D31800D8A456 /* Firefly */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1DBD214808BA80EA00186707 /* Build configuration list for PBXNativeTarget "Firefly" */;
buildPhases = (
8D202CE90486D31800D8A456 /* Headers */,
8D202CEC0486D31800D8A456 /* Resources */,
8D202CF00486D31800D8A456 /* Sources */,
8D202CF20486D31800D8A456 /* Frameworks */,
8D202CF50486D31800D8A456 /* Rez */,
);
buildRules = (
);
dependencies = (
);
name = Firefly;
productInstallPath = "$(HOME)/Library/PreferencePanes";
productName = FireflyPrefs;
productReference = 8D202CF80486D31800D8A456 /* Firefly.prefPane */;
productType = "com.apple.product-type.bundle";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
089C1669FE841209C02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DBD214C08BA80EA00186707 /* Build configuration list for PBXProject "FireflyPrefs" */;
hasScannedForEncodings = 1;
mainGroup = 089C166AFE841209C02AAC07 /* FireflyPrefs */;
projectDirPath = "";
targets = (
8D202CE80486D31800D8A456 /* Firefly */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
8D202CEC0486D31800D8A456 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8D202CED0486D31800D8A456 /* InfoPlist.strings in Resources */,
8D202CEE0486D31800D8A456 /* FireflyPrefsPref.tiff in Resources */,
8D202CEF0486D31800D8A456 /* FireflyPrefsPref.nib in Resources */,
1061CB530A266BAE002E88E0 /* FireflyLogo.png in Resources */,
10C7930B0A660CCA00732D76 /* Firefly Helper.app in Resources */,
1098819D0A704B3200F53ED9 /* firefly.conf in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXRezBuildPhase section */
8D202CF50486D31800D8A456 /* Rez */ = {
isa = PBXRezBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXRezBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
8D202CF00486D31800D8A456 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
10B4B4030A34E3A9008238B7 /* OrgFireflyMediaServerPrefs.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
089C167DFE841241C02AAC07 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
089C167EFE841241C02AAC07 /* English */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
F506C042013D9D8C01CA16C8 /* FireflyPrefsPref.nib */ = {
isa = PBXVariantGroup;
children = (
F506C043013D9D8C01CA16C8 /* English */,
);
name = FireflyPrefsPref.nib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
1DBD214908BA80EA00186707 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = FireflyPrefs_Prefix.pch;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Library/PreferencePanes";
MACOSX_DEPLOYMENT_TARGET_ppc = 10.3;
PRODUCT_NAME = Firefly;
WRAPPER_EXTENSION = prefPane;
ZERO_LINK = YES;
};
name = Debug;
};
1DBD214A08BA80EA00186707 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = (
ppc,
i386,
);
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = FireflyPrefs_Prefix.pch;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Library/PreferencePanes";
MACOSX_DEPLOYMENT_TARGET_ppc = 10.3;
PRODUCT_NAME = Firefly;
SDKROOT_ppc = /Developer/SDKs/MacOSX10.3.9.sdk;
WRAPPER_EXTENSION = prefPane;
};
name = Release;
};
1DBD214D08BA80EA00186707 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_VERSION_i386 = 4.0;
GCC_VERSION_ppc = 3.3;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_PKGINFO_FILE = YES;
MACOSX_DEPLOYMENT_TARGET_i386 = 10.4;
MACOSX_DEPLOYMENT_TARGET_ppc = 10.2;
PREBINDING = NO;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
SDKROOT_i386 = /Developer/SDKs/MacOSX10.4u.sdk;
SDKROOT_ppc = /Developer/SDKs/MacOSX10.3.9.sdk;
};
name = Debug;
};
1DBD214E08BA80EA00186707 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_VERSION_i386 = 4.0;
GCC_VERSION_ppc = 3.3;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_PKGINFO_FILE = YES;
MACOSX_DEPLOYMENT_TARGET_i386 = 10.4;
MACOSX_DEPLOYMENT_TARGET_ppc = 10.2;
PREBINDING = NO;
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
SDKROOT_i386 = /Developer/SDKs/MacOSX10.4u.sdk;
SDKROOT_ppc = /Developer/SDKs/MacOSX10.2.8.sdk;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
1DBD214808BA80EA00186707 /* Build configuration list for PBXNativeTarget "Firefly" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DBD214908BA80EA00186707 /* Debug */,
1DBD214A08BA80EA00186707 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
1DBD214C08BA80EA00186707 /* Build configuration list for PBXProject "FireflyPrefs" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1DBD214D08BA80EA00186707 /* Debug */,
1DBD214E08BA80EA00186707 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 089C1669FE841209C02AAC07 /* Project object */;
}

Binary file not shown.

View File

@ -0,0 +1,8 @@
//
// Prefix header for all source files of the 'FireflyPrefs' target in the 'FireflyPrefs' project.
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#endif

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>org.fireflymediaserver.prefpanel</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>102</string>
<key>CFBundleShortVersionString</key>
<string>1.0b3</string>
<key>NSHumanReadableCopyright</key>
<string>© 2006 Roku LLC</string>
<key>NSMainNibFile</key>
<string>FireflyPrefsPref</string>
<key>NSPrefPaneIconFile</key>
<string>FireflyPrefsPref.tiff</string>
<key>NSPrefPaneIconLabel</key>
<string>Firefly</string>
<key>NSPrincipalClass</key>
<string>OrgFireflyMediaServerPrefs</string>
</dict>
</plist>

View File

@ -0,0 +1,158 @@
/* OrgFireflyMediaServerPrefs */
#import <Cocoa/Cocoa.h>
#import <PreferencePanes/NSPreferencePane.h>
#import <CoreFoundation/CoreFoundation.h>
#import "../FireflyPrefsProtocol.h"
@interface OrgFireflyMediaServerPrefs : NSPreferencePane < FireflyPrefsClientProtocol >
{
IBOutlet NSButton *browseButton;
IBOutlet NSTextField *libraryField;
IBOutlet NSImageView *libraryIcon;
IBOutlet NSTextField *nameField;
IBOutlet NSButton *passwordCheckbox;
IBOutlet NSButton *helperMenuCheckbox;
IBOutlet NSTextField *passwordField;
IBOutlet NSTextField *portField;
IBOutlet NSPopUpButton *portPopup;
IBOutlet NSPopUpButton *serverStartOptions;
IBOutlet NSTextField *panelVersionText;
IBOutlet NSTextField *serverVersionText;
IBOutlet NSButton *startStopButton;
IBOutlet NSTextField *statusText;
IBOutlet NSButton *webPageButton;
IBOutlet NSTextField *webPageInfoText;
IBOutlet NSTabView *mainTabView;
IBOutlet NSButton *applyNowButton;
IBOutlet NSProgressIndicator *progressSpinner;
IBOutlet NSTextView *logTextView;
IBOutlet NSScrollView *logTextScroller;
CFStringRef appID;
NSMutableString *ourHostName;
NSMutableString *fireflyFolderPath;
NSMutableString *fireflyHelperPath;
NSMutableString *serverURL;
NSMutableString *logFilePath;
NSMutableString *playlistPath;
NSString *userName;
// Handling of the config file
NSMutableString *configFilePath;
BOOL configAppearsValid;
NSMutableString *configError;
NSMutableArray *configFileStrings;
unsigned long idxOfServerName;
unsigned long idxOfPassword;
unsigned long idxOfPort;
unsigned long idxOfLibraryPath;
unsigned long idxOfNextSection;
unsigned long idxOfDbPath;
unsigned long idxOfLogPath;
unsigned long idxOfPlaylistPath;
// Track whether we need to save
BOOL bConfigNeedsSaving;
// The actual preferences we manage with this GUI
NSMutableString *serverName;
NSMutableString *serverPassword;
NSMutableString *libraryPath;
unsigned short serverPort; // 0 means automatic
BOOL bStartServerOnLogin;
BOOL bShowHelperMenu;
// Timer mechanism for setting up IPC
int ipcTries;
NSTimer *ipcTimer;
// Interprocess communication with Firefly Helper
id serverProxy;
NSProtocolChecker *protocolChecker;
int clientIdent;
// Log view updating
NSTimer *logTimer;
NSDate *logDate;
}
- (IBAction)browseButtonClicked:(id)sender;
- (IBAction)passwordChanged:(id)sender;
- (IBAction)shareNameChanged:(id)sender;
- (IBAction)portPopupChanged:(id)sender;
- (IBAction)portChanged:(id)sender;
- (IBAction)pwCheckBoxChanged:(id)sender;
- (IBAction)serverStartOptionChanged:(id)sender;
- (IBAction)startStopButtonClicked:(id)sender;
- (IBAction)webPageButtonClicked:(id)sender;
- (IBAction)applyNowButtonClicked:(id)sender;
- (IBAction)helperMenuCheckboxClicked:(id)sender;
// Overrides of NSPreferencePane methods
- (void)willSelect;
- (void)didSelect;
- (NSPreferencePaneUnselectReply)shouldUnselect;
- (void)willUnselect;
// Checking the validity of the Firefly installation.
- (BOOL)validateInstall;
// Tracking the need to save the config
- (void)setConfigNeedsSaving:(BOOL)needsSaving;
// UI utility functions
- (void)disableAllControls;
- (void)updateServerStatus:(FireflyServerStatus) status;
- (void)setIconForPath;
// Functions for loading and saving our configuration, as well as
// reading and writing the config file.
- (BOOL)loadSettings;
- (BOOL)saveSettings;
- (BOOL)updateLoginItem;
- (void)readSettingsForHelper:(BOOL*)outHelper andServer:(BOOL*)outServer;
- (BOOL)readConfigFromPath:(NSString*)path;
- (BOOL)writeConfigToPath:(NSString*)path;
- (BOOL)createDefaultConfigFile;
- (NSString *)readValueFromBuf:(char*)buf startingAt:(int)idx unescapeCommas:(BOOL) bUnescapeCommas;
- (void)setDefaultValues;
// Finding or launching the helper
- (BOOL)helperIsRunning;
- (void)launchHelperIfNeeded;
// Validation of user entries
- (BOOL)control:(NSControl *)control isValidObject:(id) obj;
- (BOOL)currentTabIsValid;
- (void)alertForControl:(NSControl *)control;
// Alert delegate method(s)
- (void)alertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo;
- (void)applySheetDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo;
// Tab view delegate method(s)
- (BOOL)tabView:(NSTabView *)tabView shouldSelectTabViewItem:(NSTabViewItem *)tabViewItem;
// Browse panel delegate method(s)
- (void)browsePanelEnded:(NSOpenPanel *)panel returnCode:(int)panelResult contextInfo:(void *)contextInfo;
// Methods for dealing with the IPC proxy
- (BOOL)makeProxyConnection;
- (BOOL)checkProxyConnection;
- (void)proxyTimerFired:(NSTimer *) timer;
- (FireflyStartResult)startFirefly;
- (FireflyStopResult)stopFirefly;
- (FireflyRestartResult)restartFirefly;
- (FireflyRescanResult)rescanLibrary;
- (FireflyServerStatus)fireflyStatus;
- (BOOL)fireflyIsRunning;
- (NSString*)fireflyVersion;
- (NSString*)fireflyConfigURL;
- (void)showHelperMenu:(BOOL)bShowMenu;
// Log view stuff
- (void)updateLogTextView;
- (void)logTimerFired:(NSTimer *) timer;
@end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,351 @@
# $Id: mt-daapd.conf.templ 1000 2006-05-01 08:07:56Z rpedde $
#
# This is the mt-daapd config file.
#
# If you have problems or questions with the format of this file,
# direct your questions to rpedde@users.sourceforge.net.
#
# You can also check the website at http://mt-daapd.sourceforge.net,
# as there is a growing documentation library there, peer-supported
# forums and possibly more.
#
[general]
#
# web_root (required)
#
# Location of the admin web pages.
#
# If you installed from .RPM, .deb, or tarball with --prefix=/usr, then
# this is correct.
#
# If you installed from tarball without --prefix=/usr, then the correct
# path is probably /usr/local/share/mt-daapd/admin-root.
#
# In the default Mac install, this is a relative path, compared to the server
web_root = admin-root
#
# port (required)
#
# What port to listen on. Leave blank to auto-assign. If the port is
# specified, and that port is already taken, the server will not start.
#
port =
#
# admin_pw (required)
#
# This is the password to the administrative pages. If blank, access
# will only be possible from the local host.
#
# In the default Mac install, this is left blank so that only local
# host control is allowed
admin_pw =
#
# db_type (required)
#
# This is what kind of backend database to store the song
# info in. Valid choices are "sqlite" and "sqlite3".
#
db_type = sqlite
#
# db_parms
#
# This is any extra information the db needs to connect.
# in the case of sqlite and sqlite3, this is the name
# of the directory to store the database in
#
# If you installed from RPM or .deb, this path likely already
# exists. If not, then you must create it. The directory itself
# must be writable by the "runas" user.
#
# On the Mac, this lives in the Application Support folder, in our
# Firefly folder.
#
db_parms =
#
# mp3_dir (required)
#
# Location of the mp3 files to share. Note that because the
# files are stored in the database by inode, these must be
# in the same physical filesystem.
#
mp3_dir =
#
# servername (required)
#
# This is both the name of the server as advertised
# via rendezvous, and the name of the database
# exported via DAAP. Also know as "What shows up in iTunes".
#
servername =
#
# runas (required)
#
# This is the user to drop privs to if running as
# root. If mt-daapd is not started as root, this
# configuration option is ignored. Notice that this
# must be specified whether the server is running
# as root or not.
#
# This is also ignored on Windows.
#
runas = nobody
#
# playlist (optional)
#
# This is the location of a playlist file.
# This is for Apple-style "Smart Playlists"
# See the mt-daapd.playlist file in the
# contrib directory for syntax and examples
#
# This doesn't control static playlists... these
# are controlled with the "process_m3u" directive
# below.
#
#
# On the Mac, this lives in our Firefly folder in Application Support
playlist =
#
# password (optional)
#
# This is the password required to listen to MP3 files
# i.e. the password that iTunes prompts for
#
password =
#
# extensions (optional)
#
# These are the file extensions that the daap server will
# try to index and serve. By default, it only indexes and
# serves .mp3 files. It can also server .m4a and .m4p files,
# and just about any other files, really. Unfortunately, while
# it can *attempt* to serve other files (.ogg?), iTunes won't
# play them. Perhaps this would be useful on Linux with
# Rhythmbox, once it understands daap. (hurry up!)
#
# Failing that, one can use server-side conversion to transcode
# non-standard (.ogg, .flac) music to wav on the server side.
# See the ssc_* options below.
#
# To be able to index .ogg files, you'll need to have configured
# with --enable-oggvorbis. For .flac, --enable-flac, for .mpc,
# --enable-musepack.
#
extensions = .mp3,.m4a,.m4p,.aiff
#
# ssc_codectypes (optional)
#
# List of codectypes for files that the daap server should
# perform internal format conversion and present to clients
# as WAV files. The file extensions that these codectypes correspond
# to must also be present in 'extensions'
# configuration value, or files are not probed in the first
# place.
#
# Valid codectypes:
#
# mp4a - for AAC (.aac, .mp4, .m4a, .m4p)
# mpeg - for mp3
# wav - for wav
# wma - for wma
# ogg - for ogg
# flac - for flac (.flac, .fla)
# mpc for musepack (.mpc, .mpp, .mp+)
# alac for alac (.m4a)
#
# NOTE: 1.0b3 of the Mac server does not have support for transcoding
# Ogg and FLAC. Stay tuned
ssc_codectypes = alac
#
# ssc_prog (optional)
#
# Program that is used in server side format conversion.
# Program must accept following command line syntax:
# ssc_prog filename offset length ...
# Parameter filename is the real name of the file that is
# to be converted and streamed, offset is number of bytes
# that are skipped from the beginning of the _output_ file
# before streaming is started, length is length of the song
# in seconds (or zero). All other possible arguments must
# be ignored. The resulting wav file (or the rest of
# the file after initial seek) is written to the standard
# output by the ssc_prog program. This is typically
# a script that is a front end for different conversion tools
# handling different formats.
#
# On the Mac, this is a relative path by default
ssc_prog = ./mt-daapd-ssc.sh
#
# logfile (optional)
#
# This is the file to log to. If this is not configured,
# then it will log to the syslog.
#
# Not that the -d <level> switch will control the log verbosity.
# By default, it runs at log level 1. Log level 9 will churn
# out scads of useless debugging information. Values in between
# will vary the amount of logging you get.
#
# On the Mac, this lives in our Firefly folder in Application Support
logfile =
#
# truncate (optional)
#
# If logging is configured and this flag is enabled, the
# server will truncate the log file each time it starts.
# This is a good idea for both disk space and readability.
#
truncate = 1
#
# art_filename (optional)
#
# There is experimental support thanks to Hiren Joshi
# (hirenj@mooh.org) for dynamically adding art to the id3v2
# header as it is streamed (!!). If you were using a music system
# like zina or andromeda, for example, with cover art called
# "_folderOpenImage.jpg", you could use the parameter
# art_file _folderOpenImage.jpg and if the file _folderOpenImage.jpg
# was located in the same folder as the .mp3 file, it would appear
# in iTunes. Cool, eh?
#
#art_filename = _folderOpenImage.jpg
#
# rescan_interval
#
# How often to check the file system to see if any mp3 files
# have been added or removed.
#
# if not specified, the default is 0, which disables background scanning.
#
# If background rescanning is disabled, a scan can still be forced from the
# "status" page of the administrative web interface
#
# Setting a rescan_interval lower than the time it takes to rescan
# won't hurt anything, it will just waste CPU, and make connect times
# to the daap server longer.
#
#
rescan_interval = 300
# always_scan
#
# The default behavior is not not do background rescans of the
# filesystem unless there are clients connected. The thought is to
# allow the drives to spin down unless they are in use. This might be
# of more importance in IDE drives that aren't designed to be run
# 24x7. Forcing a scan through the web interface will always work
# though, even if no users are connected.
# always_scan = 0
#
# process_m3u
#
# By default m3u processing is turned off, since most m3u files
# sitting around in peoples mp3 directories have bad paths, and
# I hear about it. :)
#
# If you are sure your m3u files have good paths (i.e. unixly pathed,
# with relative paths relative to the directory the m3u is in), then
# you can turn on m3u processing by setting this directive to 1.
#
# I'm not sure "unixly" is a word, but you get the idea.
#
# On the Mac, process_m3u needs to be on in order to scan the iTunes
# database for playlists, so this is on in the default Mac install.
process_m3u = 1
#
# scan_type
#
#
# This sets how aggressively mp3 files should be scanned to determine
# file length. There are three values:
#
# 0 (Normal)
# Just scan the first mp3 frame to try and calculate size. This will
# be accurate for most files, but VBR files without an Xing tag will
# probably have wildly inaccurate file times. This is the default.
#
# 1 (Aggressive)
# This checks the bitrates of 10 frames in the middle of the song.
# This will still be inaccurate for VBR files without an Xing tag,
# but they probably won't be quite as inaccurate as 0. This takes
# more time, obviously, although the time hit will only happen the
# first time you scan a particular file.
#
# 2 (Painfully aggressive)
# This walks through the entire song, counting the number of frames.
# This should result in accurate song times, but will take the most
# time. Again, this will only have to be incurred the first time
# the file is indexed.
#
scan_type = 2
#
# compress
#
# Whether to use gzip content-encoding when transferring playlists etc.
# This was contributed as a patch by Ciamac Moallemi just prior to the 0.2.1
# release, and as such, hasn't gotten as much testing as other features.
#
# This feature should substantially speed up transfers of large databases
# and playlists.
#
# It will eventually default to 1, but currently it defaults to 0.
#
#compress = 0
[scan]
#
# correct_order
#
# When set to 1, ensures that items in a playlist are returned in the
# order in which they are set in the playlist. On platforms with
# limited memory, this may impose an unacceptable performance penalty,
# but on a PC or Mac, it's fine.
#
correct_order = 1
[plugins]
plugin_dir = plugins
plugins = ssc-script.so,rsp.so

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildVersion</key>
<string>54</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>ProjectName</key>
<string>PreferencePaneTemplate</string>
<key>SourceVersion</key>
<string>120000</string>
</dict>
</plist>

View File

@ -0,0 +1,43 @@
/*
* FireflyPrefsProtocol.h
* Firefly Helper
*
* Created by Mike Kobb on 7/10/06.
* Copyright 2006 Roku LLC. All rights reserved.
*
* This file houses the declaration of the FireflyPrefsServerProtocol
* and FireflyPrefsClientProtocol, which are used on the Macintosh
* for communication between the Firefly prefs pane and the Firefly
* Helper background app.
*
*/
#include "FireflyCommon.h"
// The protocol for functions exported by the server (the Firefly Helper)
@protocol FireflyPrefsServerProtocol
- (BOOL)registerClient:(byref id)client withIdentifier:(int)ident;
- (oneway void)unregisterClientId:(int)ident;
- (FireflyStartResult)startFirefly;
- (FireflyStopResult)stopFirefly;
- (FireflyRestartResult)restartFirefly;
- (FireflyRescanResult)rescanLibrary;
- (FireflyServerStatus)fireflyStatus;
- (BOOL)fireflyIsRunning;
- (bycopy NSString*)fireflyVersion;
- (bycopy NSString*)fireflyConfigURL;
- (oneway void)showHelperMenu:(BOOL)bShowMenu;
@end
// The protocol for functions exported by the client (the prefs pane)
@protocol FireflyPrefsClientProtocol
- (BOOL)stillThere;
- (oneway void)statusChanged:(FireflyServerStatus)newStatus;
- (oneway void)versionChanged:(bycopy NSString*)newVersion;
- (oneway void)configUrlChanged:(bycopy NSString*)newUrl;
@end

BIN
osx/Uninstall Firefly.app Executable file

Binary file not shown.

63
osx/makedist.sh.templ Executable file
View File

@ -0,0 +1,63 @@
#!/bin/sh
if [ $# -eq 1 ]; then
# any argument leaves the server folder as-is
AR="Firefly Helper/Server/admin-root"
mkdir "Firefly Helper/Server/plugins"
mkdir "${AR}"
mkdir "${AR}/lib-js"
mkdir "${AR}/lib-js/script.aculo.us"
cp ../.build/ppc/mt-daapd FireflyHelper/Server/firefly
cp ../.build/ppc/*so FireflyHelper/Server/Plugins
cp ../.build/wavstreamer FireflyHelper/Server
cp ../.build/alac FireflyHelper/Server
cp ../admin-root/*\(html|xml|txt|jar|gif|js|png|jpg\) "${AR}"
cp ../admin-root/CREDITS "${AR}"
cp ../admin-root/lib-js/*js "${AR}/lib-js"
cp ../admin-root/lib-js/script.aculo.us/*js "${AR}/li-js/script.aculo.us"
fi
pushd "Firefly Helper"
xcodebuild
if [ "$?" -ne "0" ]; then
echo "Could not build Firefly Helper Project"
exit 1
fi
popd
rm -rf "FireflyPrefs/Firefly Helper.app"
mv "Firefly Helper/build/Release/Firefly Helper.app" FireflyPrefs
pushd "FireflyPrefs"
xcodebuild
if [ "$?" -ne "0" ]; then
echo "Could not build FireflyPrefs panel"
exit 2
fi
# Now, build the image
mkdir staging
cp Install/root_DS_Store staging/.DS_Store
mkdir staging/.background
cp Install/background.png staging/.background/background.png
cp Install/_background_DS_Store staging/.background/.DS_Store
if [ ! -x FireflyPrefs/build/Release/Firefly.prefPane ]; then
echo "Wait... I can't find the pref pane"
exit 1
fi
mv FireflyPrefs/build/Release/Firefly.prefPane staging
cp "Uninstall Firefly.app" staging
cp -r "Install/Read Me First!.rtfd" staging
hdiutil makehybrid -hfs -hfs-volume-name "Install Firefly" -hfs-openfolder staging staging -o tmp.dmg
hdiutil convert -format UDZO tmp.dmg -o Firefly.dmg
rm -rf staging
rm tmp.dmg