Пример #1
0
        public static DeviceCalls getInstance()
        {
            if (instance == null)
            {
                lock (syncRoot)
                {
                    if (instance == null)
                    {
                        String iTunesMobileDeviceDllPath = RegistryUtils.getiTunesMobileDeviceDLLPath();
                        String installDirPath            = RegistryUtils.getInstallDirPath();

                        if (String.IsNullOrEmpty(iTunesMobileDeviceDllPath) || String.IsNullOrEmpty(installDirPath))
                        {
                            throw new Exception("Path to itunes dll not found, reinstall itunes");
                        }

                        add2PathEnv(installDirPath);

                        DeviceCalls dc = new DeviceCalls();
                        dc.initDll(iTunesMobileDeviceDllPath);
                        dc.initCoreFoundationDll(installDirPath + "\\CoreFoundation.dll");

                        instance = dc;
                    }
                }
            }
            return(instance);
        }
Пример #2
0
        private static int initHandle(DeviceCalls deviceCalls, Device device, short port, ref int outHandle)
        {
            short networkByteOrderPort = IPAddress.HostToNetworkOrder(port);
            int   connectionID         = deviceCalls.amDeviceGetConnectionID(device.getDevPtr());

            return(deviceCalls.usbMuxConnectByPort(connectionID, networkByteOrderPort, ref outHandle));
        }
        public DeviceConnection(Device device)
        {
            this.device  = device;
            deviceCalls  = DeviceCalls.getInstance();
            ws2Functions = Ws2Functions.getInstance();

            portConnections = new Dictionary <short, PortConnection>();
        }
Пример #4
0
        public PortConnection(short port, Device device)
        {
            this.port   = port;
            this.device = device;

            deviceCalls  = DeviceCalls.getInstance();
            ws2Functions = Ws2Functions.getInstance();

            activeSockets        = new List <Socket>();
            autoResetEventSocket = new AutoResetEvent(false);
        }
Пример #5
0
        public static bool checkPort(Ws2Functions ws2Functions, DeviceCalls deviceCalls, Device device, short port)
        {
            int outHandle = -1;
            int errorCode = initHandle(deviceCalls, device, port, ref outHandle);

            if (errorCode == 0)
            {
                ws2Functions.closeSocket(outHandle);
                return(true);
            }
            return(false);
        }
 public void startListening()
 {
     lock (syncRoot)
     {
         if (isrunning)
         {
             return;
         }
         else
         {
             deviceCalls      = DeviceCalls.getInstance();
             connectedDevices = new List <Device>();
             subscribe();
             isrunning = true;
         }
     }
 }