Beispiel #1
0
 void Button6_Activated(object sender, EventArgs e)
 {
     try
     {
         FileChooserDialog fileChooserDialog = new FileChooserDialog("Select project file", null, FileChooserAction.Open, new object[0]);
         fileChooserDialog.AddButton(Stock.Cancel, ResponseType.Cancel);
         fileChooserDialog.AddButton(Stock.Open, ResponseType.Ok);
         fileChooserDialog.DefaultResponse = ResponseType.Ok;
         fileChooserDialog.SelectMultiple  = false;
         FileFilter fileFilter = new FileFilter();
         fileFilter.AddMimeType("application/json");
         fileFilter.AddPattern("project.json");
         fileFilter.Name = "iCode project file (project.json)";
         fileChooserDialog.AddFilter(fileFilter);
         bool flag = fileChooserDialog.Run() == -5;
         if (flag)
         {
             ProjectManager.LoadProject(fileChooserDialog.Filename);
         }
         fileChooserDialog.Dispose();
     }
     catch (Exception ex)
     {
         ExceptionWindow.Create(ex, this).ShowAll();
     }
 }
Beispiel #2
0
        public static void Add(this Notebook notebook, Widget widget, string str, bool isVolatile)
        {
            try
            {
                widget.Name = str;
                Extensions.Tabs.Add(str, widget);

                ScrolledWindow scrolledWindow = new ScrolledWindow();
                scrolledWindow.Add(widget);
                scrolledWindow.Name = str;
                if (widget is CodeTabWidget tabWidget)
                {
                    notebook.AppendPage(scrolledWindow, (tabWidget.GetLabel()));

                    tabWidget.GetLabel().ShowAll();
                    tabWidget.GetLabel().CloseClicked += delegate
                    {
                        notebook.RemovePage(notebook.PageNum(notebook.Children.First(x => x == scrolledWindow)));
                        Extensions.Tabs.Remove(str);
                    };
                }
                else
                {
                    NotebookTabLabel notebookTabLabel = new NotebookTabLabel(str, widget);

                    notebookTabLabel.CloseClicked += delegate(object obj, EventArgs eventArgs)
                    {
                        notebook.RemovePage(notebook.PageNum(notebook.Children.First(x => x == scrolledWindow)));
                        Extensions.Tabs.Remove(str);
                    };
                    notebook.AppendPage(scrolledWindow, notebookTabLabel);
                    notebookTabLabel.ShowAll();
                }

                notebook.SetTabDetachable(scrolledWindow, isVolatile);
                notebook.SetTabReorderable(scrolledWindow, isVolatile);

                widget.ShowAll();
            }
            catch (ArgumentException)
            {
                notebook.Page = notebook.PageNum(Tabs.First(x => x.Key == str).Value);
            }
            catch (Exception e)
            {
                ExceptionWindow.Create(e, notebook).ShowAll();
            }
        }
Beispiel #3
0
        public static void RunProject()
        {
            var win = DeviceSelectorWindow.Create();

            if (win.Run() == (int)ResponseType.Ok)
            {
                JObject jobj = PList.ParsePList(new PList(win.AttributesPlist));

                /* Can't get this code working.
                 * Will use temporarily the command ideviceimagemounter
                 * var iDevice = LibiMobileDevice.Instance.iDevice;
                 * var Lockdown = LibiMobileDevice.Instance.Lockdown;
                 * var ImageMounter = LibiMobileDevice.Instance.MobileImageMounter;
                 * var Plist = LibiMobileDevice.Instance.Plist;
                 *
                 * iDeviceHandle deviceHandle;
                 * iDevice.idevice_new(out deviceHandle, jobj["UniqueDeviceID"].ToString()).ThrowOnError();
                 *
                 * LockdownClientHandle lockdownHandle;
                 * Lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, "iCode").ThrowOnError();
                 *
                 * LockdownServiceDescriptorHandle lockdownServiceHandle;
                 * Lockdown.lockdownd_start_service(lockdownHandle, "com.apple.mobile.mobile_image_mounter", out lockdownServiceHandle).ThrowOnError();
                 *
                 * MobileImageMounterClientHandle mounterHandle;
                 * ImageMounter.mobile_image_mounter_new(deviceHandle, lockdownServiceHandle, out mounterHandle).ThrowOnError();
                 *
                 * string s = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tools/dmgs/" + jobj["BuildVersion"].ToString() + "/DeveloperDiskImage.dmg.signature");
                 *
                 * var b = File.Open(s, FileMode.Open, FileAccess.Read);
                 * var str = b.ReadFully();
                 * var b_length = new System.IO.FileInfo(s).Length;
                 * var file = File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tools/dmgs/" + jobj["BuildVersion"].ToString() + "/DeveloperDiskImage.dmg"));
                 * GCHandle pinnedArray = GCHandle.Alloc(file, GCHandleType.Pinned);
                 * IntPtr pointer = pinnedArray.AddrOfPinnedObject();
                 *
                 * ImageMounter.mobile_image_mounter_upload_image(mounterHandle, "Developer", (ushort) file.Length, str, (ushort) str.Length, (buffer, length, userData) => { return (int) length; }, pointer).ThrowOnError();
                 *
                 * PlistHandle plist;
                 * ImageMounter.mobile_image_mounter_mount_image(mounterHandle, "/private/var/mobile/Media/PublicStaging/staging.dimage", str, (ushort) str.Length, "Developer", out plist).ThrowOnError();
                 *
                 * uint a = 20;
                 * string xml;
                 * Plist.plist_to_xml(plist, out xml, ref a);
                 *
                 * JObject result = PList.ParsePList(new PList(xml));
                 * Console.WriteLine(result.ToString());
                 *
                 *
                 * b.Close();
                 * deviceHandle.Dispose();
                 * lockdownHandle.Dispose();
                 * lockdownServiceHandle.Dispose();
                 * mounterHandle.Dispose();
                 * pinnedArray.Free();
                 * plist.Dispose();*/
                if (BuildProject())
                {
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            var file    = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tools/dmgs/" + jobj["BuildVersion"].ToString() + "/DeveloperDiskImage.dmg");
                            var fileSig = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tools/dmgs/" + jobj["BuildVersion"].ToString() + "/DeveloperDiskImage.dmg.signature");
                            Program.WinInstance.Output.Run(Extensions.GetProcess("ideviceinstaller", "-U '" + Path.Combine(Project.Path, "build/" + Project.Name + ".ipa") + "'"), (int)ActionCategory.Sideload);
                            Thread.Sleep(500);
                            Program.WinInstance.Output.Run(Extensions.GetProcess("ideviceinstaller", "-i '" + Path.Combine(Project.Path, "build/" + Project.Name + ".ipa") + "'"), (int)ActionCategory.Sideload);
                            Thread.Sleep(500);
                            Program.WinInstance.Output.Run(Extensions.GetProcess("ideviceimagemounter", "'" + file + "' '" + fileSig + "'"), (int)ActionCategory.Launch);
                            Thread.Sleep(500);
                            Program.WinInstance.Output.Run(Extensions.GetProcess("idevicedebug", "run " + Project.BundleId), (int)ActionCategory.Launch);
                        }
                        catch (Exception e)
                        {
                            ExceptionWindow.Create(e, null).ShowAll();
                        }
                    });
                }
            }
        }
Beispiel #4
0
        public static void Main(string[] args)
        {
            System.Console.SetOut(new DatedConsole());
            Console.WriteLine("Initialized output.");
            try
            {
                if (string.IsNullOrWhiteSpace(AppImagePath))
                {
                    Console.WriteLine("iCode is running outside of an AppImage.");
                }

                Directory.CreateDirectory(ConfigPath);
                Directory.CreateDirectory(SDKPath);
                Directory.CreateDirectory(DeveloperPath);
                Directory.CreateDirectory(UserDefinedTemplatesPath);
                Directory.CreateDirectory(ConfigPath);

                Gtk.Application.Init();

                GLib.Log.SetDefaultHandler(new GLib.LogFunc((domain, level, message) =>
                {
                    if (level != GLib.LogLevelFlags.Error && level != GLib.LogLevelFlags.FlagFatal)
                    {
                        return;
                    }

                    Console.WriteLine($"Gtk error: {message} ({domain})");
                }));

                Console.WriteLine("Initialized GTK and GDL.");

                if (!File.Exists(SettingsPath))
                {
                    var startup = StartupWindow.Create();
                    if ((ResponseType)startup.Run() != ResponseType.Ok)
                    {
                        return;
                    }

                    var jobj = new JObject();
                    jobj.Add("updateConsent", startup.Accepted);
                    File.WriteAllText(SettingsPath, jobj.ToString());
                    Console.WriteLine("Initialized settings file.");
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(AppImagePath))
                    {
                        var settings = JObject.Parse(File.ReadAllText(SettingsPath));
                        if ((bool)settings["updateConsent"])
                        {
                            var outp = Extensions.LaunchProcess(
                                Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                             "Updater"), $"--check-for-update \"{AppImagePath}\"", out int ret);
                            // TODO Updater
                            if (ret == 1)
                            {
                                Console.WriteLine("Update available.");
                                UpdateAvailable = true;
                            }
                        }
                    }
                }

                NativeLibraries.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "tools/libs/"));
                Console.WriteLine("Initialized libimobiledevice.");
                Program.WinInstance = MainWindow.Create();
                Program.WinInstance.ShowAll();
                Console.WriteLine("Initialized window.");
                Gtk.Application.Run();
            }
            catch (Exception e)
            {
                ExceptionWindow.Create(e, null).ShowAll();
            }
        }