Network location question
Network location question
- Subject: Network location question
- From: Mike Laster <email@hidden>
- Date: Wed, 3 Aug 2005 11:47:00 -0400
How can I detect when the network location has been changed? I
figure it is something to do with the System Configuration framework,
but I can't find much documentation on it.
What I want to do is write a program to be able detect network
location changes and then run a script when this occurs.
This is the direction I'm going now (which doesn't work):
#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
void sc_callback(SCPreferencesRef prefs,
SCPreferencesNotification notificationType,
void *info)
{
NSLog(@"callback called!");
}
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
SCPreferencesRef scpref = NULL;
SCPreferencesContext prefcontext;
CFRunLoopRef rlref = NULL;
bzero(&prefcontext,sizeof(SCPreferencesContext));
scpref = SCPreferencesCreate(NULL,CFSTR("TEST"),CFSTR("Setup:/
Network/Global/IPv4"));
SCPreferencesSetCallback(scpref,sc_callback,&prefcontext);
rlref = [[NSRunLoop currentRunLoop] getCFRunLoop];
SCPreferencesScheduleWithRunLoop
(scpref,rlref,kCFRunLoopDefaultMode);
[[NSRunLoop currentRunLoop] run];
if (scpref != NULL)
{
CFRelease(scpref);
scpref = NULL;
}
[pool release];
return 0;
}
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden