Public feed #600746

Stuff

public text v1 · immutable
Raw Edit
·published 2007-07-03 02:02 UTC
rendered paste body
#include <stdio.h>
#include <CoreFoundation/CoreFoundation.h>
#include <MobileDevice/MobileDevice.h>

void device_notification_callback(struct am_device_notification_callback_info *
    info)
{
    int i;
    mach_error_t err;
    struct am_device *dev = info->dev;

    fprintf(stderr, "device notification callback: got info with msg %d\n",
        info->msg);

    err = AMDeviceConnect(dev); 
    fprintf(stderr, "AMDeviceConnect: %08x\n", err);
    if (!err)
        break;

    err = AMDeviceIsPaired(dev); 
    fprintf(stderr, "AMDeviceIsPaired: %08x\n", err);
    err = AMDeviceValidatePairing(dev); 
    fprintf(stderr, "AMDeviceValidatePairing: %08x\n", err);
}

int main()
{
    mach_error_t err;
    struct am_device_notification *notif;

    err = AMDeviceNotificationSubscribe(device_notification_callback, 0, 0, 0,
        &notif);
    fprintf(stderr, "AMDeviceNotificationSubscribe: %08x\n", err);

    fprintf(stderr, "Running...\n");

    CFRunLoopRun();

    return 0;
}