Ejemplo n.º 1
0
        public unsafe void GetiPhonesAsync()
        {
            void *voidPtr;

            _deviceNotificationCallback = DeviceNotifyCallback;
            int num = MobileDevice.AMDeviceNotificationSubscribe(_deviceNotificationCallback, 0, 0, 0, out voidPtr);

            if (num != 0)
            {
                throw new Exception("AMDeviceNotificationSubscribe failed with error " + num);
            }
        }
 /// <summary>
 /// 开始监听链接
 /// </summary>
 /// <param name="errorCallBack">链接出错回调</param>
 public void StartListen()
 {
     if (!iSStartListen)
     {
         iSStartListen = true;
         try
         {
             deviceNotificationCallback                     = NotificationCallback;
             deviceDFUConnectedNotificationCallback         = DfuConnectCallback;
             deviceRecoveryConnectedNotificationCallback    = RecoveryConnectCallback;
             deviceDFUDisConnectedNotificationCallback      = DfuDisconnectCallback;
             deviceRecoveryDisConnectedNotificationCallback = RecoveryDisconnectCallback;
             IntPtr    zero  = IntPtr.Zero;
             kAMDError error = (kAMDError)MobileDevice.AMDeviceNotificationSubscribe(this.deviceNotificationCallback, 0, 1, 0, ref zero);
             if (error != kAMDError.kAMDSuccess)
             {
                 if (ListenErrorEvent != null)
                 {
                     ListenErrorEvent(this, new ListenErrorEventHandlerEventArgs("AMDeviceNotificationSubscribe failed with error : " + error.ToString(), ListenErrorEventType.StartListen));
                 }
             }
             IntPtr userInfo = IntPtr.Zero;
             error = (kAMDError)MobileDevice.AMRestoreRegisterForDeviceNotifications(this.deviceDFUConnectedNotificationCallback, this.deviceRecoveryConnectedNotificationCallback, this.deviceDFUDisConnectedNotificationCallback, this.deviceRecoveryDisConnectedNotificationCallback, 0, ref userInfo);
             if (error != kAMDError.kAMDSuccess)
             {
                 if (ListenErrorEvent != null)
                 {
                     ListenErrorEvent(this, new ListenErrorEventHandlerEventArgs("AMRestoreRegisterForDeviceNotifications failed with error : " + error.ToString(), ListenErrorEventType.StartListen));
                 }
             }
         }
         catch (Exception ex)
         {
             if (ListenErrorEvent != null)
             {
                 ListenErrorEvent(this, new ListenErrorEventHandlerEventArgs(ex.Message, ListenErrorEventType.StartListen));
             }
         }
     }
 }
Ejemplo n.º 3
0
        private unsafe void doConstruction()
        {
            void *voidPtr;

            this.dnc  = new DeviceNotificationCallback(this.NotifyCallback);
            this.drn1 = new DeviceRestoreNotificationCallback(this.DfuConnectCallback);
            this.drn2 = new DeviceRestoreNotificationCallback(this.RecoveryConnectCallback);
            this.drn3 = new DeviceRestoreNotificationCallback(this.DfuDisconnectCallback);
            this.drn4 = new DeviceRestoreNotificationCallback(this.RecoveryDisconnectCallback);
            int num = MobileDevice.AMDeviceNotificationSubscribe(this.dnc, 0, 0, 0, out voidPtr);

            if (num != 0)
            {
                throw new Exception("AMDeviceNotificationSubscribe failed with error " + num);
            }
            num = MobileDevice.AMRestoreRegisterForDeviceNotifications(this.drn1, this.drn2, this.drn3, this.drn4, 0, null);
            if (num != 0)
            {
                throw new Exception("AMRestoreRegisterForDeviceNotifications failed with error " + num);
            }
            this.current_directory = "/";
        }