public bool BackupDocumentsDirectory(string BundleIdentifier, string DestinationDocumentsDirectory)
        {
            return(PerformActionOnAllDevices(StandardEnumerationDelayMS, delegate(MobileDeviceInstance Device)
            {
                bool bResult = true;
                string DeviceType = Device.ProductType;
                if (String.IsNullOrEmpty(DeviceId) || Device.DeviceId == DeviceId ||
                    (DeviceId.Contains("All_tvOS_On") && DeviceType.Contains("TV")) ||
                    (DeviceId.Contains("All_iOS_On") && !DeviceType.Contains("TV")))
                {
                    string SafeDeviceName = MobileDeviceInstance.SanitizePathNoFilename(Device.DeviceName);

                    // Destination folder
                    string TargetFolder = Path.Combine(DestinationDocumentsDirectory, SafeDeviceName);

                    // Source folder
                    string SourceFolder = "/Documents/";

                    bResult = Device.TryBackup(BundleIdentifier, SourceFolder, TargetFolder + SourceFolder);
                    SourceFolder = "/Library/Caches/";
                    bResult = Device.TryBackup(BundleIdentifier, SourceFolder, TargetFolder + SourceFolder);

                    ReportIF.Log("");
                }
                return bResult;
            }));
        }
        public MobileDeviceInstance StartTCPTunnel(string inDeviceID, ref IntPtr TCPService, short Port = 8888)
        {
            MobileDeviceInstance targetDevice = null;

            PerformActionOnAllDevices(2 * StandardEnumerationDelayMS, delegate(MobileDeviceInstance Device)
            {
                if (inDeviceID == Device.DeviceId)
                {
                    targetDevice = Device;
                }
                return(true);
            });
            if (targetDevice != null)
            {
                if (targetDevice.StartTCPRelayService(ref TCPService))
                {
                    return(targetDevice);
                }
                ReportIF.Error("Could not start TCP relay to " + inDeviceID);
            }
            else
            {
                ReportIF.Error("Could not find device " + inDeviceID);
            }
            return(null);
        }
        public void TunnelToDevice(string inDeviceID, String Command)
        {
            MobileDeviceInstance TargetDevice = null;

            PerformActionOnAllDevices(2 * StandardEnumerationDelayMS, delegate(MobileDeviceInstance Device)
            {
                if (inDeviceID == Device.DeviceId)
                {
                    TargetDevice = Device;
                }
                return(true);
            });
            IntPtr TCPService = new IntPtr();

            if (TargetDevice != null)
            {
                TargetDevice.StartTCPRelayService(ref TCPService);

                int SentDat = TargetDevice.TunnelData(Command, TCPService);

                TargetDevice.StopSyslogService();
            }
            else
            {
                ReportIF.Error("Could not find device " + inDeviceID);
            }
        }
        public void ListenToDevice(string inDeviceID, TextWriter Writer)
        {
            MobileDeviceInstance targetDevice = null;

            PerformActionOnAllDevices(2 * StandardEnumerationDelayMS, delegate(MobileDeviceInstance Device)
            {
                if (inDeviceID == Device.DeviceId)
                {
                    targetDevice = Device;
                }
                return(true);
            });

            if (targetDevice != null)
            {
                targetDevice.StartSyslogService();

                // This never returns, the process must be killed to stop logging
                while (true)
                {
                    string curLog = targetDevice.GetSyslogData();
                    if (curLog.Trim().Length > 0)
                    {
                        Writer.Write(curLog);
                    }
                    System.Threading.Thread.Sleep(50);
                }
            }
            else
            {
                ReportIF.Error("Could not find device " + inDeviceID);
            }
        }
        void MobileDeviceConnected(object sender, Manzana.ConnectEventArgs args)
        {
            string DeviceName         = "(unknown name)";
            MobileDeviceInstance Inst = MobileDeviceInstanceManager.ConnectedDevices[args.Device];

            if (Inst != null)
            {
                DeviceName = Inst.DeviceName;
            }

            ReportIF.Log(String.Format("Mobile Device '{0}' connected", DeviceName));
            Inst.OnGenericProgress = MobileDeviceProgressCallback;

            Inst.TransferProgressDivisor = ReportIF.GetTransferProgressDivider();
        }
Ejemplo n.º 6
0
        public bool BackupDocumentsDirectory(string BundleIdentifier, string DestinationDocumentsDirectory)
        {
            return(PerformActionOnAllDevices(StandardEnumerationDelayMS, delegate(MobileDeviceInstance Device)
            {
                string SafeDeviceName = MobileDeviceInstance.SanitizePathNoFilename(Device.DeviceName);

                // Destination folder
                string TargetFolder = Path.Combine(DestinationDocumentsDirectory, SafeDeviceName);

                // Source folder
                string SourceFolder = "/Documents/";

                bool bResult = Device.TryBackup(BundleIdentifier, SourceFolder, TargetFolder);

                ReportIF.Log("");

                return bResult;
            }));
        }