Exemple #1
0
        /// <summary>
        /// Creates a new iPhone object. If an iPhone is connected to the computer, a connection will automatically be opened.
        /// </summary>
        public iPhone()
        {
            AMDeviceNotification notification;
            int ret = 0;

            dnc  = new DeviceNotificationCallback(NotifyCallback);
            drn1 = new DeviceRestoreNotificationCallback(DfuConnectCallback);
            drn2 = new DeviceRestoreNotificationCallback(RecoveryConnectCallback);
            drn3 = new DeviceRestoreNotificationCallback(DfuDisconnectCallback);
            drn4 = new DeviceRestoreNotificationCallback(RecoveryDisconnectCallback);

            notification = new AMDeviceNotification();
            ret          = MobileDevice.AMDeviceNotificationSubscribe(dnc, 0, 0, 0, ref notification);
            if (ret != 0)
            {
                throw new Exception("AMDeviceNotificationSubscribe failed with error " + ret);
            }

            ret = MobileDevice.AMRestoreRegisterForDeviceNotifications(drn1, drn2, drn3, drn4, 0, IntPtr.Zero);
            if (ret != 0)
            {
                throw new Exception("AMRestoreRegisterForDeviceNotifications failed with error " + ret);
            }
            current_directory = "/";
        }
 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);
     }
 }
        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);
            }
        }
Exemple #4
0
        public static int AMDeviceNotificationSubscribe(DeviceNotificationCallback callback, uint unused1, uint unused2, uint unused3, ref AMDeviceNotification notification)
        {
            IntPtr ptr;
            int    ret;

            ptr = IntPtr.Zero;
            ret = AMDeviceNotificationSubscribe(callback, unused1, unused2, unused3, ref ptr);
            if ((ret == 0) && (ptr != IntPtr.Zero))
            {
                notification = (AMDeviceNotification)Marshal.PtrToStructure(ptr, notification.GetType());
            }
            return(ret);
        }
        /// <summary>
        /// Initialize the mobile device manager, which handles discovery of connected Apple mobile devices
        /// </summary>
        /// <param name="myConnectHandler"></param>
        /// <param name="myDisconnectHandler"></param>
        public static void Initialize(ConnectEventHandler myConnectHandler, ConnectEventHandler myDisconnectHandler)
        {
            ConnectEH    += myConnectHandler;
            DisconnectEH += myDisconnectHandler;

            DeviceCallbackHandle = new DeviceNotificationCallback(NotifyCallback);

            int ret = MobileDevice.AMDeviceMethods.NotificationSubscribe(DeviceCallbackHandle);

            if (ret != 0)
            {
                throw new Exception("AMDeviceNotificationSubscribe failed with error " + ret);
            }
        }
Exemple #6
0
        static DeviceMonitor()
        {
            IntPtr ptr;

            var dnc = new DeviceNotificationCallback(DeviceMonitor.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 = iTunesMobileDevice.AMDeviceNotificationSubscribe(dnc, 0, 0, 0, out ptr);

            if (num != 0)
            {
                throw new Exception("AMDeviceNotificationSubscribe failed with error " + num);
            }
        }
Exemple #7
0
		/// <summary>
		/// Initializes a new iDevice object.
		/// </summary>
		unsafe private void doConstruction() {
			dnc = new DeviceNotificationCallback(NotifyCallback);
			drn1 = new DeviceRestoreNotificationCallback(DfuConnectCallback);
			drn2 = new DeviceRestoreNotificationCallback(RecoveryConnectCallback);
			drn3 = new DeviceRestoreNotificationCallback(DfuDisconnectCallback);
			drn4 = new DeviceRestoreNotificationCallback(RecoveryDisconnectCallback);

			void* notification;
			int ret = MobileDevice.AMDeviceNotificationSubscribe(dnc, 0, 0, 0, out notification);
			if (ret != 0) {
				throw new Exception("AMDeviceNotificationSubscribe failed with error " + ret);
			}

			ret = MobileDevice.AMRestoreRegisterForDeviceNotifications(drn1, drn2, drn3, drn4, 0, null);
			if (ret != 0) {
				throw new Exception("AMRestoreRegisterForDeviceNotifications failed with error " + ret);
			}
			current_directory = "/";
		}
 /// <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));
             }
         }
     }
 }
Exemple #9
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 = "/";
        }
        /// <summary>
        /// 开始监听链接
        /// 需要使用线程方式调用
        /// </summary>
        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(deviceNotificationCallback, 0, 1, 0, ref zero);
                    if (error != kAMDError.kAMDSuccess)
                    {
                        //Check "Apple Mobile Device Service" status
                        ListenErrorEvent?.Invoke(this, new ListenErrorEventHandlerEventArgs("AMDeviceNotificationSubscribe failed with error : " + error, ListenErrorEventType.StartListen));
                    }

                    IntPtr userInfo = IntPtr.Zero;
                    error = (kAMDError)MobileDevice.AMRestoreRegisterForDeviceNotifications(deviceDFUConnectedNotificationCallback, deviceRecoveryConnectedNotificationCallback, deviceDFUDisConnectedNotificationCallback, deviceRecoveryDisConnectedNotificationCallback, 0,
                                                                                            ref userInfo);
                    if (error != kAMDError.kAMDSuccess)
                    {
                        ListenErrorEvent?.Invoke(this, new ListenErrorEventHandlerEventArgs("AMRestoreRegisterForDeviceNotifications failed with error : " + error, ListenErrorEventType.StartListen));
                    }
                    //LoopRun
                    CoreFoundation.CFRunLoopRun();
                }
                catch (Exception ex)
                {
                    if (ListenErrorEvent != null)
                    {
                        ListenErrorEvent(this, new ListenErrorEventHandlerEventArgs(ex.Message, ListenErrorEventType.StartListen));
                    }
                }
            }
        }
        /// <summary>
        ///     配置链接,注册通知回调
        /// </summary>
        private void doConstruction()
        {
            IntPtr voidPtr = IntPtr.Zero;

            dnc  = NotifyCallback;
            drn1 = DfuConnectCallback;
            drn2 = RecoveryConnectCallback;
            drn3 = DfuDisconnectCallback;
            drn4 = RecoveryDisconnectCallback;
            int num = MobileDevice.AMDeviceNotificationSubscribe(dnc, 0, 0, 0, ref voidPtr);

            if (num != 0)
            {
                throw new Exception("AMDeviceNotificationSubscribe failed with error " + num);
            }
            num = MobileDevice.AMRestoreRegisterForDeviceNotifications(drn1, drn2, drn3, drn4, 0, IntPtr.Zero);
            if (num != 0)
            {
                throw new Exception("AMRestoreRegisterForDeviceNotifications failed with error " + num);
            }
            current_directory = "/";
        }
Exemple #12
0
        /// <summary>
        /// Initializes a new iDevice object.
        /// </summary>
        unsafe private void doConstruction()
        {
            dnc  = new DeviceNotificationCallback(NotifyCallback);
            drn1 = new DeviceRestoreNotificationCallback(DfuConnectCallback);
            drn2 = new DeviceRestoreNotificationCallback(RecoveryConnectCallback);
            drn3 = new DeviceRestoreNotificationCallback(DfuDisconnectCallback);
            drn4 = new DeviceRestoreNotificationCallback(RecoveryDisconnectCallback);

            void *notification;
            int   ret = MobileDevice.AMDeviceNotificationSubscribe(dnc, 0, 0, 0, out notification);

            if (ret != 0)
            {
                throw new Exception("AMDeviceNotificationSubscribe failed with error " + ret);
            }

            ret = MobileDevice.AMRestoreRegisterForDeviceNotifications(drn1, drn2, drn3, drn4, 0, null);
            if (ret != 0)
            {
                throw new Exception("AMRestoreRegisterForDeviceNotifications failed with error " + ret);
            }
            current_directory = "/";
        }
Exemple #13
0
        /// <summary>
        /// Creates a new iPhone object. If an iPhone is connected to the computer, a connection will automatically be opened.
        /// </summary>
        public iPhone()
        {
            AMDeviceNotification notification;
            int ret = 0;

            dnc = new DeviceNotificationCallback(NotifyCallback);
            drn1 = new DeviceRestoreNotificationCallback(DfuConnectCallback);
            drn2 = new DeviceRestoreNotificationCallback(RecoveryConnectCallback);
            drn3 = new DeviceRestoreNotificationCallback(DfuDisconnectCallback);
            drn4 = new DeviceRestoreNotificationCallback(RecoveryDisconnectCallback);

            notification = new AMDeviceNotification();
            ret = MobileDevice.AMDeviceNotificationSubscribe(dnc, 0, 0, 0, ref notification);
            if (ret != 0) {
                throw new Exception("AMDeviceNotificationSubscribe failed with error " + ret);
            }

            ret = MobileDevice.AMRestoreRegisterForDeviceNotifications(drn1, drn2, drn3, drn4, 0, IntPtr.Zero);
            if (ret != 0) {
                throw new Exception("AMRestoreRegisterForDeviceNotifications failed with error " + ret);
            }
            current_directory = "/";
        }
 private extern static int AMDeviceNotificationSubscribe(DeviceNotificationCallback callback, uint unused1, uint unused2, uint unused3, out IntPtr am_device_notification_ptr);
            public static int NotificationSubscribe(DeviceNotificationCallback DeviceCallbackHandle)
            {
                IntPtr notification;

                return(AMDeviceNotificationSubscribe(DeviceCallbackHandle, 0, 0, 0, out notification));
            }
 extern static int AMDeviceNotificationSubscribe(DeviceNotificationCallback callback, uint unused1, uint unused2, uint unused3, out IntPtr am_device_notification_ptr);
 public static extern int AMDeviceNotificationSubscribe(DeviceNotificationCallback callback, uint unused1,
                                                        uint unused2, uint unused3, ref IntPtr am_device_notification_ptr);
 public static extern int AMDeviceNotificationSubscribe(DeviceNotificationCallback callback, uint unused1,
     uint unused2, uint unused3, ref IntPtr am_device_notification_ptr);
Exemple #19
0
 public static extern unsafe int AMDeviceNotificationSubscribe(DeviceNotificationCallback callback, uint unused1, uint unused2, uint unused3, out void *am_device_notification_ptr);
			public static int NotificationSubscribe(DeviceNotificationCallback DeviceCallbackHandle)
			{
				IntPtr notification;
				return AMDeviceNotificationSubscribe(DeviceCallbackHandle, 0, 0, 0, out notification);
			}
		public int NotificationSubscribe(DeviceNotificationCallback DeviceCallbackHandle)
		{
			return AMDeviceMethods.NotificationSubscribe(DeviceCallbackHandle);
		}
Exemple #22
0
        /// <summary>
        /// Initializes a new iPhone object.
        /// </summary>
        private unsafe void doConstruction()
        {
            dnc = new DeviceNotificationCallback(NotifyCallback);

            void* notification;

            int ret = MobileDevice.AMDeviceNotificationSubscribe(dnc, 0, 0, 0, out notification);
            if (ret != 0) {
                throw new Exception("AMDeviceNotificationSubscribe failed with error " + ret);
            }
        }
 /// <summary>
 ///     配置链接,注册通知回调
 /// </summary>
 private void doConstruction()
 {
     IntPtr voidPtr=IntPtr.Zero;
     dnc = NotifyCallback;
     drn1 = DfuConnectCallback;
     drn2 = RecoveryConnectCallback;
     drn3 = DfuDisconnectCallback;
     drn4 = RecoveryDisconnectCallback;
     int num = MobileDevice.AMDeviceNotificationSubscribe(dnc, 0, 0, 0, ref voidPtr);
     if (num != 0)
     {
         throw new Exception("AMDeviceNotificationSubscribe failed with error " + num);
     }
     num = MobileDevice.AMRestoreRegisterForDeviceNotifications(drn1, drn2, drn3, drn4, 0, IntPtr.Zero);
     if (num != 0)
     {
         throw new Exception("AMRestoreRegisterForDeviceNotifications failed with error " + num);
     }
     current_directory = "/";
 }
 /// <summary>
 /// Initialize the mobile device manager, which handles discovery of connected Apple mobile devices
 /// </summary>
 /// <param name="myConnectHandler"></param>
 /// <param name="myDisconnectHandler"></param>
 public static void Initialize(ConnectEventHandler myConnectHandler, ConnectEventHandler myDisconnectHandler)
 {
     ConnectEH += myConnectHandler;
     DisconnectEH += myDisconnectHandler;
 
     DeviceCallbackHandle = new DeviceNotificationCallback(NotifyCallback);
     
     int ret = MobileDevice.DeviceImpl.NotificationSubscribe(DeviceCallbackHandle);
     if (ret != 0)
     {
         throw new Exception("AMDeviceNotificationSubscribe failed with error " + ret);
     }
 }
 static extern int AMDeviceNotificationSubscribe(DeviceNotificationCallback callback, uint unused0, uint unused1, uint cookie, out IntPtr am_device_notification_ptr);
 public static unsafe extern int AMDeviceNotificationSubscribe(DeviceNotificationCallback callback, uint unused1, uint unused2, uint unused3, out void* am_device_notification_ptr);
Exemple #27
0
        public static int AMDeviceNotificationSubscribe(DeviceNotificationCallback callback, uint unused1, uint unused2, uint unused3, ref AMDeviceNotification notification)
        {
            IntPtr	ptr;
            int		ret;

            ptr = IntPtr.Zero;
            ret = AMDeviceNotificationSubscribe(callback, unused1, unused2, unused3, ref ptr);
            if ((ret == 0) && (ptr != IntPtr.Zero)) {
                notification = (AMDeviceNotification)Marshal.PtrToStructure(ptr, notification.GetType());
            }
            return ret;
        }
Exemple #28
0
 /// <summary>
 /// 配置链接,注册通知回调
 /// </summary>
 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 = "/";
 }
 extern static int AMDeviceNotificationSubscribe(DeviceNotificationCallback callback, uint unused0, uint unused1, uint cookie, out IntPtr am_device_notification_ptr);