public ManageSitesDialog (SetupService service, Builder builder, IntPtr handle): base (handle)
		{
			builder.Autoconnect (this);
//			TransientFor = parent;
//			Services.PlaceDialog (this, parent);
			this.service = service;
			treeStore = new Gtk.ListStore (typeof (string), typeof (string), typeof(bool));
			repoTree.Model = treeStore;
			repoTree.HeadersVisible = false;
			var crt = new Gtk.CellRendererToggle ();
			crt.Toggled += HandleRepoToggled;
			repoTree.AppendColumn ("", crt, "active", 2);
			repoTree.AppendColumn ("", new Gtk.CellRendererText (), "markup", 1);
			repoTree.Selection.Changed += new EventHandler(OnSelect);
			
			AddinRepository[] reps = service.Repositories.GetRepositories ();
			foreach (AddinRepository rep in reps)
				AppendRepository (rep);

			btnRemove.Sensitive = false;

			//Wire buttons
			btnRemove.Clicked += OnRemove;
			btnAdd.Clicked += OnAdd;

			ShowAll ();
		}
		public override bool Execute ()
		{
			if (!InitializeAddinRegistry ())
				return false;

			string[] result;
			try {
				var service = new SetupService (Registry);
				result = service.BuildPackage (
					new LogProgressStatus (Log, 0),
					OutputDir,
					AddinFile
				);
			} catch (Exception ex) {
				Log.LogError ("Internal error: {0}", ex);
				return false;
			}

			if (Log.HasLoggedErrors)
				return false;

			if (result.Length != 1) {
				Log.LogError ("Unexpected number of packaging results: {0}", result.Length);
				return false;
			}

			PackageFile = result [0];

			Log.LogMessage (MessageImportance.Normal, "Created package: {0}", PackageFile);

			return true;
		}
		public AddinInstallDialog (SetupService service)
		{
			Build ();
			this.service = service;
			wizardNotebook.ShowTabs = false;
			ActionArea.Hide ();
			
			tree = new InstallAddinTreeWidget (addinTree);
			tree.AllowSelection = true;
			tree.SelectionChanged += new EventHandler (OnAddinSelectionChanged);
			
			repoStore = new ListStore (typeof(string), typeof(string));
			repoCombo.Model = repoStore;
			CellRendererText crt = new CellRendererText ();
			repoCombo.PackStart (crt, true);
			repoCombo.AddAttribute (crt, "text", 0);
			filterComboBox.Active = 1;
			
			imageInstall.Stock = "md-software-update";
			imageInstall.IconSize = (int)IconSize.Dialog;
			
			FillRepos ();
			repoCombo.Active = 0;
			LoadAddins ();
			FillAddinInfo ();
			OnPageChanged ();
		}
 public InstallDialog(Gtk.Window parent, SetupService service)
 {
     this.Build ();
     this.service = service;
     TransientFor = parent;
     WindowPosition = Gtk.WindowPosition.CenterOnParent;
     boxProgress.Visible = false;
     Resizable = false;
 }
		public AddinInstallerDialog (AddinRegistry reg, string message, string[] addinIds)
		{
			this.Build();
			
			this.addinIds = addinIds;
			setup = new SetupService (reg);

			if (!CheckAddins (true))
				UpdateRepos ();
		}
		public AddinInstallerDialog (AddinRegistry reg, string message, string[] addinIds,
		                             Builder builder, IntPtr handle): base (handle)
		{
			builder.Autoconnect (this);
			
			this.addinIds = addinIds;
			setup = new SetupService (reg);

			if (!CheckAddins (true))
				UpdateRepos ();
		}
		void IAddinInstaller.InstallAddins (AddinRegistry reg, string message, string[] addinIds)
		{
			if (logLevel > 0) {
				if (message != null && message.Length > 0) {
					Console.WriteLine (message);
				} else {
					Console.WriteLine ("Additional extensions are required to perform this operation.");
				}
			}
			ArrayList entries = new ArrayList ();
			SetupService setup = new SetupService (reg);
			string idNotFound;
			do {
				idNotFound = null;
				foreach (string id in addinIds) {
					string name = Addin.GetIdName (id);
					string version = Addin.GetIdVersion (id);
					AddinRepositoryEntry[] ares = setup.Repositories.GetAvailableAddin (name, version);
					if (ares.Length == 0) {
						idNotFound = id;
						entries.Clear ();
						break;
					} else
						entries.Add (ares[0]);
				}
				if (idNotFound != null) {
					if (repoUpdated)
						throw new InstallException ("Extension '" + idNotFound + "' not found in the registered extension repositories");
					if (prompt) {
						Console.WriteLine ("The extension '" + idNotFound + "' could not be found in the registered repositories.");
						Console.WriteLine ("The repository indices may be outdated.");
						if (!Confirm ("Do you wan't to update them now?"))
							throw new InstallException ("Extension '" + idNotFound + "' not found in the registered extension repositories");
					}
					setup.Repositories.UpdateAllRepositories (new ConsoleProgressStatus (logLevel));
					repoUpdated = true;
				}
			}
			while (idNotFound != null);
			
			if (logLevel > 0) {
				Console.WriteLine ("The following extensions will be installed:");
				foreach (AddinRepositoryEntry addin in entries)
					Console.WriteLine (" - " + addin.Addin.Name + " v" + addin.Addin.Version);
				
				if (prompt) {
					if (!Confirm ("Do you want to continue with the installation?"))
						throw new InstallException ("Installation cancelled");
				}
			}
			setup.Install (new ConsoleProgressStatus (logLevel), (AddinRepositoryEntry[]) entries.ToArray (typeof(AddinRepositoryEntry)));
		}
		public static void Initialize (bool updateAddinRegistry)
		{
			if (initialized)
				return;
			Counters.RuntimeInitialization.BeginTiming ();
			SetupInstrumentation ();
			
			AddinManager.AddinLoadError += OnLoadError;
			AddinManager.AddinLoaded += OnLoad;
			AddinManager.AddinUnloaded += OnUnload;
			
			try {
				Counters.RuntimeInitialization.Trace ("Initializing Addin Manager");
				AddinManager.Initialize (MonoDevelop.Core.PropertyService.ConfigPath);
				AddinManager.InitializeDefaultLocalizer (new DefaultAddinLocalizer ());
				
				if (updateAddinRegistry)
					AddinManager.Registry.Update (null);
				setupService = new SetupService (AddinManager.Registry);
				Counters.RuntimeInitialization.Trace ("Initialized Addin Manager");
				
				string prefix = string.Empty;
				if (PropertyService.IsWindows)
					prefix = "win-";
	
				string mainRep = "http://monodevelop.com/files/addins/" + prefix + AddinManager.CurrentAddin.Version + "/main.mrep";
				
				AddinRepository[] repos = setupService.Repositories.GetRepositories ();
				foreach (AddinRepository rep in repos) {
					if (rep.Url.StartsWith ("http://go-mono.com/md/") || (rep.Url.StartsWith ("http://monodevelop.com/files/addins/") && rep.Url != mainRep))
						setupService.Repositories.RemoveRepository (rep.Url);
				}
				setupService.Repositories.RegisterRepository (null, mainRep, false);
	
				Counters.RuntimeInitialization.Trace ("Initializing Assembly Service");
				systemAssemblyService = new SystemAssemblyService ();
				systemAssemblyService.Initialize ();
				
				initialized = true;
				
			} catch (Exception ex) {
				Console.WriteLine (ex);
				AddinManager.AddinLoadError -= OnLoadError;
				AddinManager.AddinLoaded -= OnLoad;
				AddinManager.AddinUnloaded -= OnUnload;
			} finally {
				Counters.RuntimeInitialization.EndTiming ();
			}
		}
		public InstallDialog (SetupService service, Builder builder, IntPtr handle): base (handle)
		{
			builder.Autoconnect (this);
			this.service = service;
//			TransientFor = parent;
			WindowPosition = Gtk.WindowPosition.CenterOnParent;
//			Services.PlaceDialog (this, parent);
			boxProgress.Visible = false;
			Resizable = false;

			//Wire Buttons
			buttonOk.Clicked += OnButtonOkClicked;
			buttonCancel.Clicked += OnButtonCancelClicked;

			ShowAll ();
		}
		public ManageSitesDialog (SetupService service)
		{
			Build ();
			this.service = service;
			treeStore = new Gtk.ListStore (typeof (string), typeof (string));
			repoTree.Model = treeStore;
			repoTree.HeadersVisible = true;
			repoTree.AppendColumn (Catalog.GetString ("Name"), new Gtk.CellRendererText (), "text", 1);
			repoTree.AppendColumn (Catalog.GetString ("Url"), new Gtk.CellRendererText (), "text", 0);
			repoTree.Selection.Changed += new EventHandler(OnSelect);
			
			AddinRepository[] reps = service.Repositories.GetRepositories ();
			foreach (AddinRepository rep in reps) {
				treeStore.AppendValues (rep.Url, rep.Title);
			}

			btnRemove.Sensitive = false;
		}
Exemple #11
0
		public static void Initialize (bool updateAddinRegistry)
		{
			if (initialized)
				return;
			Counters.RuntimeInitialization.BeginTiming ();
			SetupInstrumentation ();
			
			// Set a default sync context
			if (SynchronizationContext.Current == null)
				SynchronizationContext.SetSynchronizationContext (new SynchronizationContext ());
			
			AddinManager.AddinLoadError += OnLoadError;
			AddinManager.AddinLoaded += OnLoad;
			AddinManager.AddinUnloaded += OnUnload;
			
			try {
				Counters.RuntimeInitialization.Trace ("Initializing Addin Manager");
				AddinManager.Initialize (MonoDevelop.Core.PropertyService.ConfigPath);
				AddinManager.InitializeDefaultLocalizer (new DefaultAddinLocalizer ());
				
				if (updateAddinRegistry)
					AddinManager.Registry.Update (null);
				setupService = new SetupService (AddinManager.Registry);
				Counters.RuntimeInitialization.Trace ("Initialized Addin Manager");
				
				RegisterAddinRepositories ();
				
				Counters.RuntimeInitialization.Trace ("Initializing Assembly Service");
				systemAssemblyService = new SystemAssemblyService ();
				systemAssemblyService.Initialize ();
				
				initialized = true;
				
			} catch (Exception ex) {
				Console.WriteLine (ex);
				AddinManager.AddinLoadError -= OnLoadError;
				AddinManager.AddinLoaded -= OnLoad;
				AddinManager.AddinUnloaded -= OnUnload;
			} finally {
				Counters.RuntimeInitialization.EndTiming ();
			}
		}
		public ManageSitesDialog (Gtk.Window parent, SetupService service)
		{
			Build ();
			TransientFor = parent;
			Services.PlaceDialog (this, parent);
			this.service = service;
			treeStore = new Gtk.ListStore (typeof (string), typeof (string), typeof(bool));
			repoTree.Model = treeStore;
			repoTree.HeadersVisible = false;
			var crt = new Gtk.CellRendererToggle ();
			crt.Toggled += HandleRepoToggled;
			repoTree.AppendColumn ("", crt, "active", 2);
			repoTree.AppendColumn ("", new Gtk.CellRendererText (), "markup", 1);
			repoTree.Selection.Changed += new EventHandler(OnSelect);
			
			AddinRepository[] reps = service.Repositories.GetRepositories ();
			foreach (AddinRepository rep in reps)
				AppendRepository (rep);

			btnRemove.Sensitive = false;
		}
        public void TestSetup()
        {
            setup = new SetupService ();
            baseDir = Path.GetDirectoryName (new Uri (typeof(TestBase).Assembly.CodeBase).LocalPath);
            addinsDir = new DirectoryInfo (baseDir).Parent.Parent.Parent.FullName;
            addinsDir = Path.Combine (addinsDir, "lib");

            repoDir = Path.Combine (TempDir, "repo");
            repoExtrasDir = Path.Combine (repoDir,"extras");
            monitor = new ConsoleProgressStatus (true);

            repoBaseUrl = new Uri (repoDir).ToString ();
            repoUrl = new Uri (Path.Combine (repoDir, "main.mrep")).ToString ();
        }
 public void Init(SetupService service)
 {
     this.service = service;
 }
Exemple #15
0
 public AddinStore(SetupService service)
 {
     this.service = service;
 }
 public SetupTool(AddinRegistry registry)
 {
     this.registry = registry;
     service       = new SetupService(registry);
     CreateCommands();
 }
Exemple #17
0
 /// <summary>
 /// Creates a new instance
 /// </summary>
 /// <param name="registry">
 /// Add-in registry to manage.
 /// </param>
 public SetupTool(AddinRegistry registry)
 {
     this.registry = registry;
     service = new SetupService (registry);
     CreateCommands ();
 }
Exemple #18
0
 public AddinStore(SetupService service)
 {
     this.service = service;
 }
Exemple #19
0
        static void UpdateRepos(int appId, bool updateAll)
        {
            using (UserModel m = UserModel.GetAdmin (appId)) {
                string basePath = AddinsPath;

                SetupService setupService = new SetupService ();
                LocalStatusMonitor monitor = new LocalStatusMonitor ();

                HashSet<string> fileList = new HashSet<string> ();
                FindFiles (fileList, basePath);
                HashSet<string> reposToBuild = new HashSet<string> ();

                List<Release> releases = new List<Release> ();

                foreach (Release rel in m.GetReleases ()) {
                    if (rel.Status == ReleaseStatus.Deleted)
                        continue;
                    foreach (string plat in rel.PlatformsList) {
                        string repoPath = Path.Combine (basePath, rel.DevStatus.ToString ());
                        repoPath = Path.Combine (repoPath, plat);
                        repoPath = Path.Combine (repoPath, rel.TargetAppVersion);
                        string path = Path.GetFullPath (Path.Combine (repoPath, rel.AddinId + "-" + rel.Version + ".mpack"));
                        fileList.Remove (path);
                        if (rel.Status == ReleaseStatus.PendingPublish || updateAll) {
                            if (!Directory.Exists (repoPath))
                                Directory.CreateDirectory (repoPath);
                            if (!File.Exists (rel.GetFilePath (plat))) {
                                Log (LogSeverity.Error, "Could not publish release " + rel.Version + " of add-in " + rel.AddinId + ". File " + rel.GetFilePath (plat) + " not found");
                                continue;
                            }
                            File.Copy (rel.GetFilePath (plat), path, true);
                            GenerateInstallerFile (m, path, rel, plat);
                            reposToBuild.Add (repoPath);
                            if (!releases.Contains (rel) && rel.Status == ReleaseStatus.PendingPublish)
                                releases.Add (rel);
                        }
                    }
                }
                foreach (AppRelease arel in m.GetAppReleases ()) {
                    foreach (object status in Enum.GetValues (typeof(DevStatus))) {
                        foreach (string plat in m.CurrentApplication.PlatformsList) {
                            string repoPath = Path.Combine (basePath, status.ToString ());
                            repoPath = Path.Combine (repoPath, plat);
                            repoPath = Path.Combine (repoPath, arel.AppVersion);
                            if (!Directory.Exists (repoPath)) {
                                Directory.CreateDirectory (repoPath);
                                reposToBuild.Add (repoPath);
                            }
                            else if (!File.Exists (Path.Combine (repoPath, "main.mrep")) || updateAll)
                                reposToBuild.Add (repoPath);
                        }
                    }
                }

                // Remove old add-ins

                foreach (string f in fileList) {
                    try {
                        reposToBuild.Add (Path.GetFullPath (Path.GetDirectoryName (f)));
                        File.Delete (f);
                        string f2 = Path.ChangeExtension (f, m.CurrentApplication.AddinPackageExtension);
                        if (File.Exists (f2))
                            File.Delete (f2);
                    }
                    catch (Exception ex) {
                        Log (ex);
                    }
                }

                // Update the repos

                foreach (string r in reposToBuild) {
                    string mainFile = Path.Combine (r, "main.mrep");
                    if (File.Exists (mainFile))
                        File.Delete (mainFile);
                    setupService.BuildRepository (monitor, r);
                    AppendCompatibleRepo (m, mainFile);
                    string ds = r.Substring (basePath.Length + 1);
                    int i = ds.IndexOf (Path.DirectorySeparatorChar);
                    ds = ds.Substring (0, i);
                    string title = m.CurrentApplication.Name + " Add-in Repository";
                    if (ds != DevStatus.Stable.ToString())
                        title += " (" + ds + " channel)";
                    AppendName (mainFile, title);
                    AppendName (Path.Combine (r, "root.mrep"), title);
                }

                foreach (Release rel in releases)
                    m.SetPublished (rel);
            }
        }
Exemple #20
0
        static Mistelix()
        {
            string debug;

            base_dir = System.IO.Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), Defines.APPNAME_LOWER);

            // Mono addins
            AddinManager.Initialize (base_dir);
            AddinManager.Registry.Update (null);
            SetupService setupService = new SetupService (AddinManager.Registry);

            preferences = new Preferences ();
            recent_files = new RecentFilesStorage ();

            debug = Environment.GetEnvironmentVariable ("MISTELIX_DEBUG");

            if (String.Compare (debug, "true", false) == 0 || String.Compare (debug, "1", false) == 0) {
                debugging = true;
                Logger.LogLevel = Level.DEBUG;
                Logger.LogDevice = new FileLogger ();
            }
        }
	static int Main (string [] args)
	{
		bool empty = false;
		Program program = null;
		ICore control = null;
		List<string> uris = new List<string> ();
		Unix.SetProcessName (Defines.PACKAGE);

		// Options and Option parsing
		bool shutdown = false;
		bool view = false;
		bool slideshow = false;
		string import_uri = null;
		
		program = new Program (Defines.PACKAGE, 
				       Defines.VERSION, 
				       Modules.UI, args);		
		
		FSpot.Global.PhotoDirectory = Preferences.Get<string> (Preferences.STORAGE_PATH);

		for (int i = 0; i < args.Length && !shutdown; i++) {
			switch (args [i]) {
			case "-h": case "-?": case "-help": case "--help": case "-usage":
				Help ();
				return 0;
			
			case "-shutdown": case "--shutdown":
				Log.Information ("Shutting down existing F-Spot server...");
				shutdown = true;
				break;

			case "-b": case "-basedir": case "--basedir":
				if (i+1 == args.Length || args[i+1].StartsWith ("-")) {
					Log.Error ("f-spot: -basedir option takes one argument");
					return 1;
				}
				FSpot.Global.BaseDirectory = args [++i];
				Log.InformationFormat ("BaseDirectory is now {0}", FSpot.Global.BaseDirectory);
				break;

			case "-p": case "-photodir": case "--photodir":
				if (i+1 == args.Length || args[i+1].StartsWith ("-")) {
					Log.Error ("f-spot: -photodir option takes one argument");
					return 1;
				}
				FSpot.Global.PhotoDirectory = System.IO.Path.GetFullPath (args [++i]);
				Log.InformationFormat ("PhotoDirectory is now {0}", FSpot.Global.PhotoDirectory);
				break;

			case "-i": case "-import": case "--import":
				if (i+1 == args.Length) {
					Log.Error ("f-spot: -import option takes one argument");
					return 1;
				}
				import_uri = args [++i];
				break;
			
			case "-slideshow": case "--slideshow":
				slideshow = true;
				break;

			case "-v": case "-view": case "--view":
				if (i+1 == args.Length || args[i+1].StartsWith ("-")) {
					Log.Error ("f-spot: -view option takes (at least) one argument");
					return 1;
				}
				view = true;
				while (!(i+1 == args.Length) && !args[i+1].StartsWith ("-"))
					uris.Add (args [++i]);
//				if (!System.IO.Directory.Exists (args[i+1]) && !System.IO.File.Exists (args[i+1])) {
//					Log.Error ("f-spot: -view argument must be an existing file or directory");
//					return 1;
//				}
				break;

			case "-versions": case "--versions":
				Versions ();
				return 0;
			
			case "-V": case "-version": case "--version":
				Version ();
				return 0;
			
			case "--debug":
				Log.Debugging = true;
				// Debug GdkPixbuf critical warnings
				GLib.LogFunc logFunc = new GLib.LogFunc (GLib.Log.PrintTraceLogFunction);
				GLib.Log.SetLogHandler ("GdkPixbuf", GLib.LogLevelFlags.Critical, logFunc);
		
				// Debug Gtk critical warnings
				GLib.Log.SetLogHandler ("Gtk", GLib.LogLevelFlags.Critical, logFunc);

				break;
			case "--uninstalled": case "--gdb":
				break;
			default:
				if (args [i].StartsWith ("--profile"))
					break;
				if (args [i].StartsWith ("--trace"))
					break;
				Log.DebugFormat ("Unparsed argument >>{0}<<", args [i]);
				Help ();
				return 1;
			}
		}

		// Validate command line options
		if ( (import_uri != null && (view || shutdown || slideshow)) || 
		     (view && (shutdown || slideshow)) ||
		     (shutdown && slideshow) ) {
			Log.Error ("Can't mix -import, -view, -shutdown or -slideshow");
			return 1;
		}

		if (slideshow == true) {
			Catalog.Init ("f-spot", Defines.LOCALE_DIR);
				
			Core core = new Core ();
			core.ShowSlides (null);
			program.Run ();
			Log.Debug ("done");
			return 0;
		}
		
		try {

			uint timer = Log.InformationTimerStart ("Initializing DBus");
			try {
				NDesk.DBus.BusG.Init();
			} catch (Exception e) {
				throw new ApplicationException ("F-Spot cannot find the Dbus session bus.  Make sure dbus is configured properly or start a new session for f-spot using \"dbus-launch f-spot\"", e);
			}
			Log.DebugTimerPrint (timer, "DBusInitialization took {0}");
			uint ma_timer = Log.InformationTimerStart ("Initializing Mono.Addins");
			AddinManager.Initialize (FSpot.Global.BaseDirectory);
			AddinManager.Registry.Update (null);
			SetupService setupService = new SetupService (AddinManager.Registry);
			string maj_version = String.Join (".", Defines.VERSION.Split ('.'), 0, 3);
			foreach (AddinRepository repo in setupService.Repositories.GetRepositories ())
				if (repo.Url.StartsWith ("http://addins.f-spot.org/") && !repo.Url.StartsWith ("http://addins.f-spot.org/" + maj_version)) {
					Log.InformationFormat ("Unregistering {0}", repo.Url);
					setupService.Repositories.RemoveRepository (repo.Url);
				}
			setupService.Repositories.RegisterRepository (null, "http://addins.f-spot.org/" + maj_version, false);
			Log.DebugTimerPrint (ma_timer, "Mono.Addins Initialization took {0}");
			
		

			bool create = true;
			int retry_count = 0;
			while (control == null) {
				try {
					control = Core.FindInstance ();
					Log.InformationFormat ("Found active FSpot server: {0}", control);
					program = null;
				} catch (System.Exception) { 
					if (!shutdown)
						Log.Information ("Starting new FSpot server");
				}
				
				Core core = null;
				try {
					if (control == null && create) {
						create = false;
						Gnome.Vfs.Vfs.Initialize ();

						if (File.Exists (Preferences.Get<string> (Preferences.GTK_RC))) {
#if GTK_2_12_2
							if (!File.Exists (Path.Combine (Global.BaseDirectory, "gtkrc")))
								(File.Create (Path.Combine (Global.BaseDirectory, "gtkrc"))).Dispose ();
							Gtk.Rc.AddDefaultFile (Path.Combine (Global.BaseDirectory, "gtkrc"));
							Global.DefaultRcFiles = Gtk.Rc.DefaultFiles;
#endif
							Gtk.Rc.AddDefaultFile (Preferences.Get<string> (Preferences.GTK_RC));
						}
						
						Catalog.Init ("f-spot", Defines.LOCALE_DIR);
						try {
							Gtk.Window.DefaultIconList = new Gdk.Pixbuf [] {
								GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 16, (Gtk.IconLookupFlags)0),
								GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 22, (Gtk.IconLookupFlags)0),
								GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 32, (Gtk.IconLookupFlags)0),
								GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 48, (Gtk.IconLookupFlags)0)
							};
						} catch {}

						core = new Core (view);
						core.RegisterServer ();

						empty = view || Core.Database.Empty;
						control = core;
					}
				} catch (System.Exception e) {
					System.Console.WriteLine ("XXXXX{1}{0}{1}XXXXX", e, Environment.NewLine);
					control = null;

					if (core != null)
						core.UnregisterServer ();

					// if there is a problem with the DB, so is no way we can survive
					if (e is DbException) {
						throw;
					}
				}
				if (control == null) {
					Log.Warning ("Can't get a connection to the dbus. Trying again...");
					if (++ retry_count > 5) {
						Log.Error ("Sorry, couldn't start F-Spot");
						return 1;
					}
				}
			}
			
			
			UriList list = new UriList ();

			if (shutdown) {
				try {
					control.Shutdown ();
				} catch (System.Exception) {
					// trap errors
				}
				System.Environment.Exit (0);
			}

			if (import_uri != null) {
				control.Import (import_uri);
			}

			if (view) {
				foreach (string s in uris)
					list.AddUnknown (s);
				if (list.Count == 0) {
					Help ();
					return 1;
				}
				control.View (list.ToString ());
			}
			
			if (empty && import_uri == null && !view)
				control.Import (null);
			
			if (import_uri != null || !view) {
				control.Organize ();
				Gdk.Global.NotifyStartupComplete ();
				foreach (ServiceNode service in AddinManager.GetExtensionNodes ("/FSpot/Services")) {
					service.Initialize ();
					service.Start ();
				}
			}			

#if GSD_2_24
			Log.Information ("Hack for gnome-settings-daemon engaged");
			int max_age, max_size;
			if (Preferences.TryGet<int> (Preferences.GSD_THUMBS_MAX_AGE, out max_age)) {
				if (max_age < 0)
					Log.Debug ("maximum_age check already disabled, good");
				else if (max_age == 0)
					Log.Warning ("maximum_age is 0 (tin-hat mode), not overriding");
				else if (max_age < 180) {
					Log.Debug ("Setting maximum_age to a saner value");
					Preferences.Set (Preferences.GSD_THUMBS_MAX_AGE, 180);
				}
			}

			if (Preferences.TryGet<int> (Preferences.GSD_THUMBS_MAX_SIZE, out max_size)) {
				int count = Core.Database.Photos.Count ("photos");
				// average thumbs are taking 70K, so this will push the threshold
				//if f-spot takes more than 70% of the thumbs space
				int size = count / 10;
				if (max_size < 0)
					Log.Debug ("maximum_size check already disabled, good");
				else if (max_size == 0)
					Log.Warning ("maximum_size is 0 (tin-hat mode), not overriding");
				else if (max_size < size) {
					Log.DebugFormat ("Setting maximum_size to a saner value ({0}MB), according to your db size", size);
					Preferences.Set (Preferences.GSD_THUMBS_MAX_SIZE, size);
				}
			}

#endif
			if (program != null)
				program.Run ();
			
			Log.Information ("exiting");
		} catch (System.Exception e) {
			Log.Exception (e);
			ExceptionDialog dlg = new ExceptionDialog(e);
			dlg.Run();
			dlg.Destroy();
			System.Environment.Exit(1);
		}
		return 0;
	}
		internal RepositoryRegistry (SetupService service)
		{
			this.service = service;
		}
Exemple #23
0
		public static bool InApplicationNamespace (SetupService service, string id)
		{
			return service.ApplicationNamespace == null || id.StartsWith (service.ApplicationNamespace + ".");
		}
Exemple #24
0
 internal RepositoryRegistry(SetupService service)
 {
     this.service = service;
 }
Exemple #25
0
 static void InitializeAddins()
 {
     uint timer = Log.InformationTimerStart ("Initializing Mono.Addins");
     try {
         UpdatePlugins ();
     } catch (Exception) {
         Log.Debug ("Failed to initialize plugins, will remove addin-db and try again.");
         ResetPluginDb ();
     }
     SetupService setupService = new SetupService (AddinManager.Registry);
     foreach (AddinRepository repo in setupService.Repositories.GetRepositories ()) {
         if (repo.Url.StartsWith ("http://addins.f-spot.org/")) {
             Log.InformationFormat ("Unregistering {0}", repo.Url);
             setupService.Repositories.RemoveRepository (repo.Url);
         }
     }
     Log.DebugTimerPrint (timer, "Mono.Addins Initialization took {0}");
 }
Exemple #26
0
        AddinData BuildProjectAddin(BuildContext ctx, SourceTagInfo stag, string logFile, string sourcePath, AppReleaseInfo rel, AddinProjectAddin addin)
        {
            SetupService ss = new SetupService ();
            bool generatedXplatPackage = false;
            HashSet<string> foundPlatforms = new HashSet<string> ();
            AddinData ainfo = new AddinData ();

            foreach (AddinProjectSource psource in addin.Sources) {
                if (string.IsNullOrEmpty (psource.AddinFile))
                    throw new Exception ("AddinFile element not found in addin-project.xml");

                string platforms = psource.Platforms;
                if (string.IsNullOrEmpty (platforms))
                    platforms = ctx.Application.Platforms;

                string[] platformList = platforms.Split (new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string plat in platformList)
                    if (!foundPlatforms.Add (plat))
                        throw new Exception ("Platform " + plat + " specificed in more than open Project element");

                string outFile = NormalizePath (psource.AddinFile);

                if (!string.IsNullOrEmpty (psource.BuildFile)) {

                    // Build the project

                    string solFile = Path.Combine (sourcePath, NormalizePath (psource.BuildFile));

                    string ops = " \"/p:ReferencePath=" + rel.GetAssembliesPath (ctx) + "\"";

                    if (!string.IsNullOrEmpty (psource.BuildConfiguration))
                        ops += " \"/property:Configuration=" + psource.BuildConfiguration + "\"";

                    ops = ops + " \"" + solFile + "\"";

                    StringBuilder output = new StringBuilder ();
                    try {
                        // Clean the project
                        RunCommand (ctx.LocalSettings.MSBuildCommand, "/t:Clean " + ops, output, output, Timeout.Infinite);

                        // Build
                        RunCommand (ctx.LocalSettings.MSBuildCommand, ops, output, output, Timeout.Infinite);
                    }
                    finally {
                        File.AppendAllText (logFile, "<pre>" + HttpUtility.HtmlEncode (output.ToString ()) + "</pre>");
                    }
                }

                // Generate the package

                string tmpPath = Path.Combine (sourcePath, "tmp");

                File.AppendAllText (logFile, "<p><b>Building Package</b></p>");
                LocalStatusMonitor monitor = new LocalStatusMonitor ();
                try {
                    if (Directory.Exists (tmpPath))
                        Directory.Delete (tmpPath, true);
                    Directory.CreateDirectory (tmpPath);
                    ss.BuildPackage (monitor, tmpPath, Path.Combine (sourcePath, outFile));
                    string file = Directory.GetFiles (tmpPath, "*.mpack").FirstOrDefault ();
                    if (file == null)
                        throw new Exception ("Add-in generation failed");

                    AddinInfo ai = ReadAddinInfo (file);
                    ainfo.AddinVersion = ai.Version;
                    ainfo.AddinId = Mono.Addins.Addin.GetIdName (ai.Id);

                    if (!generatedXplatPackage && platformList.Length > 0) {
                        File.Copy (file, Path.Combine (stag.GetPackagePath (ctx), "All.mpack"), true);
                        generatedXplatPackage = true;
                    }
                    else {
                        foreach (string plat in platformList) {
                            File.Copy (file, Path.Combine (stag.GetPackagePath (ctx), plat + ".mpack"), true);
                        }
                    }
                }
                finally {
                    try {
                        Directory.Delete (tmpPath, true);
                    }
                    catch { }
                    File.AppendAllText (logFile, "<pre>" + HttpUtility.HtmlEncode (monitor.ToString ()) + "</pre>");
                }
            }
            ainfo.Platforms = string.Join (" ", foundPlatforms.ToArray ());
            ainfo.AppVersion = rel.AppVersion;
            return ainfo;
        }
Exemple #27
0
        static int Main(string [] args)
        {
            bool empty = false;
            List<string> uris = new List<string> ();
            Unix.SetProcessName (Defines.PACKAGE);

            // Options and Option parsing
            bool shutdown = false;
            bool view = false;
            bool slideshow = false;
            string import_uri = null;

            GLib.GType.Init ();
            Catalog.Init ("f-spot", Defines.LOCALE_DIR);

            FSpot.Global.PhotoDirectory = Preferences.Get<string> (Preferences.STORAGE_PATH);
            for (int i = 0; i < args.Length && !shutdown; i++) {
                switch (args [i]) {
                case "-h": case "-?": case "-help": case "--help": case "-usage":
                    Help ();
                    return 0;

                case "-shutdown": case "--shutdown":
                    Log.Information ("Shutting down existing F-Spot server...");
                    shutdown = true;
                    break;

                case "-b": case "-basedir": case "--basedir":
                    if (i+1 == args.Length || args[i+1].StartsWith ("-")) {
                        Log.Error ("f-spot: -basedir option takes one argument");
                        return 1;
                    }
                    FSpot.Global.BaseDirectory = args [++i];
                    Log.Information ("BaseDirectory is now {0}", FSpot.Global.BaseDirectory);
                    break;

                case "-p": case "-photodir": case "--photodir":
                    if (i+1 == args.Length || args[i+1].StartsWith ("-")) {
                        Log.Error ("f-spot: -photodir option takes one argument");
                        return 1;
                    }
                    FSpot.Global.PhotoDirectory = System.IO.Path.GetFullPath (args [++i]);
                    Log.Information ("PhotoDirectory is now {0}", FSpot.Global.PhotoDirectory);
                    break;

                case "-i": case "-import": case "--import":
                    if (i+1 == args.Length) {
                        Log.Error ("f-spot: -import option takes one argument");
                        return 1;
                    }
                    import_uri = args [++i];
                    break;

                case "-slideshow": case "--slideshow":
                    slideshow = true;
                    break;

                case "-v": case "-view": case "--view":
                    if (i+1 == args.Length || args[i+1].StartsWith ("-")) {
                        Log.Error ("f-spot: -view option takes (at least) one argument");
                        return 1;
                    }
                    view = true;
                    while (!(i+1 == args.Length) && !args[i+1].StartsWith ("-"))
                        uris.Add (args [++i]);
            //				if (!System.IO.Directory.Exists (args[i+1]) && !System.IO.File.Exists (args[i+1])) {
            //					Log.Error ("f-spot: -view argument must be an existing file or directory");
            //					return 1;
            //				}
                    break;

                case "-versions": case "--versions":
                    Versions ();
                    return 0;

                case "-V": case "-version": case "--version":
                    Version ();
                    return 0;

                case "--strace":
                    Log.Tracing = true;
                    break;

                case "--debug":
                    Log.Debugging = true;
                    // Debug GdkPixbuf critical warnings
                    GLib.LogFunc logFunc = new GLib.LogFunc (GLib.Log.PrintTraceLogFunction);
                    GLib.Log.SetLogHandler ("GdkPixbuf", GLib.LogLevelFlags.Critical, logFunc);

                    // Debug Gtk critical warnings
                    GLib.Log.SetLogHandler ("Gtk", GLib.LogLevelFlags.Critical, logFunc);

                    // Debug GLib critical warnings
                    GLib.Log.SetLogHandler ("GLib", GLib.LogLevelFlags.Critical, logFunc);

                    //Debug GLib-GObject critical warnings
                    GLib.Log.SetLogHandler ("GLib-GObject", GLib.LogLevelFlags.Critical, logFunc);

                    break;
                case "--uninstalled": case "--gdb": case "--valgrind": case "--sync":
                    break;
                default:
                    if (args [i].StartsWith ("--profile"))
                        break;
                    if (args [i].StartsWith ("--trace"))
                        break;
                    Log.Debug ("Unparsed argument >>{0}<<", args [i]);
                    break;
                }
            }

            // Validate command line options
            if ( (import_uri != null && (view || shutdown || slideshow)) ||
                 (view && (shutdown || slideshow)) ||
                 (shutdown && slideshow) ) {
                Log.Error ("Can't mix -import, -view, -shutdown or -slideshow");
                return 1;
            }

            //Initialize Mono.Addins
            uint timer = Log.InformationTimerStart ("Initializing Mono.Addins");
            AddinManager.Initialize (FSpot.Global.BaseDirectory);
            AddinManager.Registry.Update (null);
            SetupService setupService = new SetupService (AddinManager.Registry);
            string maj_version = String.Join (".", Defines.VERSION.Split ('.'), 0, 3);
            foreach (AddinRepository repo in setupService.Repositories.GetRepositories ())
                if (repo.Url.StartsWith ("http://addins.f-spot.org/") && !repo.Url.StartsWith ("http://addins.f-spot.org/" + maj_version)) {
                    Log.Information ("Unregistering {0}", repo.Url);
                    setupService.Repositories.RemoveRepository (repo.Url);
                }
            setupService.Repositories.RegisterRepository (null, "http://addins.f-spot.org/" + maj_version, false);
            Log.DebugTimerPrint (timer, "Mono.Addins Initialization took {0}");

            //Gtk initialization
            Gtk.Application.Init (Defines.PACKAGE, ref args);
            Gnome.Vfs.Vfs.Initialize ();

            // init web proxy globally
            Platform.WebProxy.Init ();

            if (File.Exists (Preferences.Get<string> (Preferences.GTK_RC))) {
                if (File.Exists (Path.Combine (Global.BaseDirectory, "gtkrc")))
                    Gtk.Rc.AddDefaultFile (Path.Combine (Global.BaseDirectory, "gtkrc"));

                Global.DefaultRcFiles = Gtk.Rc.DefaultFiles;
                Gtk.Rc.AddDefaultFile (Preferences.Get<string> (Preferences.GTK_RC));
                Gtk.Rc.ReparseAllForSettings (Gtk.Settings.Default, true);
            }

            try {
                Gtk.Window.DefaultIconList = new Gdk.Pixbuf [] {
                    GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 16, (Gtk.IconLookupFlags)0),
                    GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 22, (Gtk.IconLookupFlags)0),
                    GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 32, (Gtk.IconLookupFlags)0),
                    GtkUtil.TryLoadIcon (FSpot.Global.IconTheme, "f-spot", 48, (Gtk.IconLookupFlags)0)
                };
            } catch {}

            try {
                if (slideshow == true) {
                    App.Instance.Slideshow (null);
                } else if (shutdown) {
                    try {
                        App.Instance.Shutdown ();
                    } catch (System.Exception) { // trap errors
                    }
                    System.Environment.Exit (0);
                } else if (view) {
                    UriList list = new UriList ();
                    foreach (string s in uris)
                        list.AddUnknown (s);
                    if (list.Count == 0) {
                        Help ();
                        return 1;
                    }
                    App.Instance.View (list);
                } else if (import_uri != null) {
                    App.Instance.Import (import_uri);
                } else {
                    App.Instance.Organize ();
                }

                if (App.Instance.IsRunning)
                    return 0;
                Gtk.Application.Run ();
            } catch (System.Exception e) {
                Log.Exception (e);
                ExceptionDialog dlg = new ExceptionDialog(e);
                dlg.Run();
                dlg.Destroy();
                System.Environment.Exit(1);
            }
            return 0;
        }
        void IAddinInstaller.InstallAddins(AddinRegistry reg, string message, string[] addinIds)
        {
            if (logLevel > 0)
            {
                if (message != null && message.Length > 0)
                {
                    Console.WriteLine(message);
                }
                else
                {
                    Console.WriteLine("Additional extensions are required to perform this operation.");
                }
            }
            ArrayList    entries = new ArrayList();
            SetupService setup   = new SetupService(reg);
            string       idNotFound;

            do
            {
                idNotFound = null;
                foreach (string id in addinIds)
                {
                    string name    = Addin.GetIdName(id);
                    string version = Addin.GetIdVersion(id);
                    AddinRepositoryEntry[] ares = setup.Repositories.GetAvailableAddin(name, version);
                    if (ares.Length == 0)
                    {
                        idNotFound = id;
                        entries.Clear();
                        break;
                    }
                    else
                    {
                        entries.Add(ares[0]);
                    }
                }
                if (idNotFound != null)
                {
                    if (repoUpdated)
                    {
                        throw new InstallException("Add-in '" + idNotFound + "' not found in the registered add-in repositories");
                    }
                    if (prompt)
                    {
                        Console.WriteLine("The add-in '" + idNotFound + "' could not be found in the registered repositories.");
                        Console.WriteLine("The repository indices may be outdated.");
                        if (!Confirm("Do you wan't to update them now?"))
                        {
                            throw new InstallException("Add-in '" + idNotFound + "' not found in the registered add-in repositories");
                        }
                    }
                    setup.Repositories.UpdateAllRepositories(new ConsoleProgressStatus(logLevel));
                    repoUpdated = true;
                }
            }while (idNotFound != null);

            if (logLevel > 0)
            {
                Console.WriteLine("The following add-ins will be installed:");
                foreach (AddinRepositoryEntry addin in entries)
                {
                    Console.WriteLine(" - " + addin.Addin.Name + " v" + addin.Addin.Version);
                }

                if (prompt)
                {
                    if (!Confirm("Do you want to continue with the installation?"))
                    {
                        throw new InstallException("Installation cancelled");
                    }
                }
            }
            setup.Install(new ConsoleProgressStatus(logLevel), (AddinRepositoryEntry[])entries.ToArray(typeof(AddinRepositoryEntry)));
        }
Exemple #29
0
 public MonoAddinsRepositoryProvider(SetupService service)
 {
     this.service = service;
 }