Preventing Services from activating your application
posted by Tim on 11.29.07 @ 1:59 am
I failed to find any way to do this via the internets; but gdb, and some kindly soul inside Apple, met the challenge:
(gdb) b -[NSUserDefaults objectForKey:] Breakpoint 17 at 0x94172fa4 (gdb) c Continuing. ... invoke service, hit breakpoint ... (gdb) po *(id *)($fp + 16) NSShouldActivateForServiceRequest (gdb)
Is there a better way to do this? Google and mdls don’t seem to know about NSShouldActivateForServiceRequest at all, so I’m guessing not.
Lest I state the obvious, have you tried setting NSShouldActivateForServiceRequest to NO? Or are you looking for a better way than that?
(Or have I misread your gdb session?)
By Peter Jaros on 11.29.07 5:53 am
That’s exactly what I’m doing now — the problem is that this default isn’t documented anywhere that I can find. Nor is any other way of doing this documented (also, the normal behavior is bad — if I wanted my app to activate when the service was invoked, I’d tell it to!)
By Tim on 11.29.07 12:10 pm
Hmm. Have you tried breaking on respondsToSelector:? Perhaps there’s a delegate method that controls this. Although you’re right, it *is* a weird default.
By Peter Jaros on 11.30.07 5:12 am
I vaguely think I remember someone telling me about this.. I think Cocoa uses a heuristic to guess whether activating is appropriate.
If you didn’t file a bug for API, please do.
By ken on 12.23.07 11:51 pm