コード例 #1
0
        unsafe private bool ConnectToPhone()
        {
            if (MobileDevice.AMDeviceConnect(iDeviceHandle) == 1)
            {
                //int connid;

                throw new Exception("Phone in recovery mode, support not yet implemented");
                //connid = MobileDevice.AMDeviceGetConnectionID(ref iDeviceHandle);
                //MobileDevice.AMRestoreModeDeviceCreate(0, connid, 0);
                //return false;
            }
            if (MobileDevice.AMDeviceIsPaired(iDeviceHandle) == 0)
            {
                return(false);
            }
            int chk = MobileDevice.AMDeviceValidatePairing(iDeviceHandle);

            if (chk != 0)
            {
                return(false);
            }

            if (MobileDevice.AMDeviceStartSession(iDeviceHandle) == 1)
            {
                return(false);
            }

            if (MobileDevice.AMDeviceStartService(iDeviceHandle, new CFString("com.apple.afc2"), ref hService, null) != 0)
            {
                if (MobileDevice.AMDeviceStartService(iDeviceHandle, new CFString("com.apple.afc"), ref hService, null) != 0)
                {
                    return(false);
                }
            }
            else
            {
                wasAFC2 = true;
            }

            if (MobileDevice.AFCConnectionOpen(hService, 0, ref hAFC) != 0)
            {
                return(false);
            }

            connected = true;
            return(true);
        }