Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Network location question



Kicker.bundle may or may not be what you're looking for. I've done an "ugly" hack to have scripts run whenever I change network locations... it has its flaws, but it works for me. It's probably not the right way to do these things...

http://tcollier.oc9.org/index.php/Nixes/NetworkLocationScripts

Some of the info on that site may not be completely accurate, but I have referenced other pages which may be helpful.

--
Toby Collier
http://www.indifferent.com

"We all pay for life with death, so everything in between should be free." -- Bill Hicks


On Aug 3, 2005, at 10:47 AM, Mike Laster wrote:

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;
}

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/macnetworkprog/tcollier% 40indifferent.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/macnetworkprog/email@hidden

This email sent to email@hidden
References: 
 >Network location question (From: Mike Laster <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.