NSStatusItem, RunLoops and daemons (Oh My)
NSStatusItem, RunLoops and daemons (Oh My)
- Subject: NSStatusItem, RunLoops and daemons (Oh My)
- From: Michael Cashwell <email@hidden>
- Date: Wed, 12 May 2004 16:49:05 -0400
Greetings all,
I've read the archives here and at Omni and am basically more confused
than before. What I'm looking for here is "been there, done that"
guidance.
I'm working on the userland parts to go with an Ethernet-like driver
I've written. The "like" qualifier stems from it needing some
user-configurable data in the same vein as the Network Name or WEP/WPA
are pushed down to the Airport driver before it will work.
I know I'll need a daemon to push down this information (via my user
client) because it must happen during boot. This daemon will also need
to use Quinn's MoreSCF to deal with the network config (Location
changes). I know I'm going to need a system pref panel so the user can
view and set this configurable data per Location and interface. And
lastly, I could envision having an NSStatusItem in the menu bar while a
user is logged in displaying status from the daemon (akin to signal
strength in Airport).
From reading the archives it seems that a boot-context daemon should
not try to handle an NSStatusItem itself. So it sounds like I'm going
to need a user-context process for that. I'm planning to use
mach_init.d to start the daemon and mach_init_per_user.d to start the
status process. (As an aside, I don't understand the boot daemon
startup stuff in Panther. It seems to ignore dependancies that the
now-deprecated SystemStarter handled. It also does not seem to address
shutdown or restart. It seems to want to defer starting daemons until
they are "needed" but it's not clear how one expresses that need
post-boot. Confusing.)
Where I'm hung up is the language to use for the daemon (BSD C or
Obj-C) because of the need for IPC between them and the apparent
prohibition against using some system frameworks (AppKit) within a
daemon. What I have so far is:
Sys Pref Panel Obj-C / Cocoa
Status Obj-C / Cocoa
daemon ???
I have a rudimentary CLI app that I'm trying to morph into the daemon.
But I'm stuck on the IPC with the other parts. According to the best
docs I can find
(
http://developer.apple.com/documentation/UserExperience/Conceptual/
PreferencePanes/index.html) I could use distributed objects if I wrote
the daemon in Obj-C / Cocoa. But that would be a rewrite from what I
have now and I haven't been able to find any real CLI examples written
this way. One-liners that CFShow a "Hello World" message or that don't
show me how to handle argc / argv the cocoa way are of little help.
I could just stick with BSD C for the daemon but then I can't use
distributed objects. That same html page says that I could use
Distributed Notifications and goes on to show some code snippets, but
no working example. And elsewhere on that page it says that for the
notifications to work I must enter a Runloop. I also expect to need the
RunLoop in order to register for changes in the Sys Config (Location)
but I haven't really gotten that far.
The problem is, I cannot figure out how to create a run loop in a BSD
(non-Obj-C, non-carbon) app. Again, it would seem to me that template /
sample code claiming to be a daemon or tool written in Obj-C / Cocoa
might show how to deal with the run loop.
While I admit I'm green on Obj-C/Cocoa, I do see the advantages for
processes with any substantial UI. But I'm less sure about using it for
a faceless daemon given the dearth of real example code showing how to
do it right. But with the features I need I don't want to be closed
minded.
If I've missed the sample code or made wrong guesses here please
advise. Guidance welcome.
Many thanks,
Mike Cashwell
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.