~ubuntu-branches/ubuntu/wily/gnome-do/wily

« back to all changes in this revision

Viewing changes to Do.Platform/src/Do.Platform/Services.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2011-02-15 21:50:02 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110215215002-1j8ylb69o15asb06
Tags: 0.8.4-0ubuntu1
* The Race Against FF upload.  Merge from unreleased Debian git.
  Remaining Ubuntu changes:
  + debian/patches/05_disable_resize_grips.patch.diff:
    Disable resize handles for the Do windows.
  + debian/control:
    Bump gtk# build dep for HasResizeGrip API.
* New Debian changes:
* The long fortold release
  + Fixes a threadsafety issue resulting in 100% CPU usage (Closes: 565591,
    LP: #450852).
  + Proxies all keyring calls to the GTK main thread, as required by the new
    gnome-keyring (Closes: 603876, LP: #553643)
* debian/patches/00_bundledlibs.dpatch:
* debian/rules:
  + Upstream has dropped bundled gmcs binary; now 100% DFSG-free, so we don't
    have to repack the tarball or patch the buildsystem.
* debian/patches/03_disable_docky.dpatch:
  + Drop.  Docky is now gone in the upstream tarball.
* debian/rules:
* debian/control:
* debian/patches/*:
  + Switch to quilt to harmonise with other pkg-cli-* packages.
* debian/control:
  + Drop recommends on gnome-do-docklets.  Docky is now a separate package,
    so the docklets are useless for Do.
  + Bump Breaks on gnome-do-plugins to 0.8.3.  Do no longer provides the Wink
    library, which has been imported into the 0.8.3 do-plugins sources.
  + Bump standards-version; no changes needed.
  + Migrate to git and update VCS fields appropriately

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
using System;
21
21
using System.Linq;
 
22
using System.Reflection;
22
23
using System.Collections.Generic;
23
24
 
24
25
using Mono.Addins;
32
33
 
33
34
        public class Services
34
35
        {
35
 
 
36
36
                static ICoreService core;
37
37
                static PathsService paths;
 
38
                static INetworkService network;
38
39
                static IWindowingService windowing;
39
40
                static AbstractSystemService system;
 
41
                static IKeyBindingService keybinder;
40
42
                static IEnumerable<ILogService> logs;
41
43
                static PreferencesFactory preferences;
42
 
                static AbstractApplicationService application;
43
44
                static IEnvironmentService environment;
44
45
                static INotificationsService notifications;
 
46
                static IPluginManagerService plugin_manager;
 
47
                static AbstractApplicationService application;
45
48
                static IUniverseFactoryService universe_factory;
46
 
                static INetworkService network;
 
49
                static AbstractPackageManagerService package_manager;
47
50
 
48
51
                /// <summary>
49
52
                /// Initializes the class. Must be called after Mono.Addins is initialized; if this is
59
62
                                // TODO find a better exception to throw.
60
63
                                throw new Exception ("AddinManager was initialized before Services.");
61
64
                        }
 
65
                        
62
66
                        AddinManager.AddExtensionNodeHandler ("/Do/Service", OnServiceChanged);
 
67
                        InitializeStrictServices ();
63
68
                }
64
 
 
 
69
                
65
70
                /// <summary>
66
71
                /// When a service is changed, we "dirty the cache".
67
72
                /// </summary>
68
73
                static void OnServiceChanged (object sender, ExtensionNodeEventArgs e)
69
 
                {
 
74
                {                       
70
75
                        IService service = e.ExtensionObject as IService;
71
76
 
72
77
                        switch (e.Change) {
79
84
                        }
80
85
 
81
86
                        // Dirty the appropriate cache.
 
87
                        if (service is ILogService)
 
88
                                logs = null;
82
89
                        if (service is ICoreService)
83
90
                                core = null;
84
 
                        if (service is IEnvironmentService)
85
 
                                environment = null;
 
91
                        if (service is PathsService)
 
92
                                paths = null;
 
93
                        if (service is INetworkService)
 
94
                                network = null;
 
95
                        if (service is IWindowingService)
 
96
                                windowing = null;
86
97
                        // Although it is not obvious, this also takes care of the ISecurePreferences service.
87
98
                        if (service is IPreferencesService)
88
99
                                preferences = null;
89
 
                        if (service is ILogService)
90
 
                                logs = null;
91
 
                        if (service is IUniverseFactoryService)
92
 
                                universe_factory = null;
 
100
                        if (service is IEnvironmentService)
 
101
                                environment = null;
 
102
                        if (service is AbstractSystemService)
 
103
                                system = null;
93
104
                        if (service is INotificationsService)
94
105
                                notifications = null;
95
 
                        if (service is IWindowingService)
96
 
                                windowing = null;
97
 
                        if (service is PathsService)
98
 
                                paths = null;
 
106
                        if (service is IUniverseFactoryService)
 
107
                                universe_factory = null;                        
99
108
                        if (service is AbstractApplicationService)
100
109
                                application = null;
101
 
                        if (service is AbstractSystemService)
102
 
                                system = null;
103
 
                        if (service is INetworkService)
104
 
                                network = null;
105
110
                }
106
111
 
107
112
                /// <summary>
185
190
                                        network = LocateService<INetworkService, Default.NetworkService> ();
186
191
                                return network;
187
192
                        }
188
 
                }       
189
 
                        
 
193
                }
 
194
                
 
195
                public static AbstractPackageManagerService PackageManager {
 
196
                        get {
 
197
                                if (package_manager == null)
 
198
                                        package_manager = LocateService<AbstractPackageManagerService, Default.DefaultPackageManagerService> ();
 
199
                                return package_manager;
 
200
                        }
 
201
                }
 
202
                
 
203
                public static IPluginManagerService PluginManager {
 
204
                        get {
 
205
                                if (plugin_manager == null)
 
206
                                        plugin_manager = LocateService<IPluginManagerService, Default.PluginManagerService> ();
 
207
                                return plugin_manager;
 
208
                        }
 
209
                }
 
210
                
 
211
                public static IKeyBindingService Keybinder {
 
212
                        get {
 
213
                                if (keybinder == null)
 
214
                                        keybinder = LocateService<IKeyBindingService, Default.KeyBindingService> ();
 
215
                                return keybinder;
 
216
                        }
 
217
                }
 
218
 
190
219
                public static PreferencesFactory Preferences {
191
220
                        get {
192
221
                                if (preferences == null) {
229
258
                                return Enumerable.Empty<TService> ();
230
259
                        }
231
260
                }
 
261
                
 
262
                /// <summary>
 
263
                /// loops through the Property members of this class, and if it's a strict service gets it's value.
 
264
                /// This will in turn cause a LocateService call, and the appropriate service will be loaded.
 
265
                /// </summary>
 
266
                static void InitializeStrictServices ()
 
267
                {
 
268
                        foreach (PropertyInfo property in typeof (Services).GetProperties ()) {
 
269
                                Type returnType = property.PropertyType;
 
270
                                if (returnType.GetInterface ("Do.Platform.IStrictService") != null) {
 
271
                                        // this looks stupid, but this is how you call the method on static classes.
 
272
                                        property.GetValue (null, null);
 
273
                                }
 
274
                        }
 
275
                }
232
276
        }
233
277
}