~ubuntu-branches/ubuntu/trusty/gnome-do/trusty

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Christopher James Halse Rogers
  • Date: 2012-03-26 11:12:21 UTC
  • mfrom: (0.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20120326111221-1jk143fy37zxi3e4
Tags: 0.9-1
* New upstream version no longer uses deprecated internal glib headers.
  (Closes: #665537)
* [59fa37b9] Fix watch file
* [63486516] Imported Upstream version 0.9
* [8c636d84] Disable testsuite for now; requires running dbus and gconf daemons
* [e46de4b9] Remove inaccurate README.Source
* [4591d677] Add git-buildpackage configuration to default to pristine-tar

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
                static IWindowingService windowing;
40
40
                static AbstractSystemService system;
41
41
                static IKeyBindingService keybinder;
42
 
                static IEnumerable<ILogService> logs;
43
42
                static PreferencesFactory preferences;
44
43
                static IEnvironmentService environment;
45
44
                static INotificationsService notifications;
48
47
                static IUniverseFactoryService universe_factory;
49
48
                static AbstractPackageManagerService package_manager;
50
49
 
 
50
                // Logs are special; ensure we always have at least a default log service
 
51
                static IEnumerable<ILogService> logs = new ILogService[] { new Default.LogService () };
 
52
 
51
53
                /// <summary>
52
54
                /// Initializes the class. Must be called after Mono.Addins is initialized; if this is
53
55
                /// called and Mono.Addins is not initialized, an exception will be thrown.
62
64
                                // TODO find a better exception to throw.
63
65
                                throw new Exception ("AddinManager was initialized before Services.");
64
66
                        }
65
 
                        
 
67
 
 
68
                        LoadLogServices ();
 
69
 
66
70
                        AddinManager.AddExtensionNodeHandler ("/Do/Service", OnServiceChanged);
67
71
                        InitializeStrictServices ();
68
72
                }
75
79
                        IService service = e.ExtensionObject as IService;
76
80
 
77
81
                        switch (e.Change) {
78
 
                        case ExtensionChange.Add:
79
 
                                if (service is IInitializedService)
80
 
                                        (service as IInitializedService).Initialize ();
81
 
                                break;
82
 
                        case ExtensionChange.Remove:
83
 
                                break;
 
82
                                case ExtensionChange.Add:
 
83
                                        if (service is IInitializedService)
 
84
                                                (service as IInitializedService).Initialize ();
 
85
                                        break;
 
86
                                case ExtensionChange.Remove:
 
87
                                        break;
84
88
                        }
85
89
 
 
90
                        // Loggers must be handled specially.
 
91
                        if (service is ILogService)
 
92
                                LoadLogServices ();
 
93
 
86
94
                        // Dirty the appropriate cache.
87
 
                        if (service is ILogService)
88
 
                                logs = null;
89
95
                        if (service is ICoreService)
90
96
                                core = null;
91
97
                        if (service is PathsService)
109
115
                                application = null;
110
116
                }
111
117
 
 
118
                // Log services need to be treated specially.  They're not lazy-initialised,
 
119
                // and cannot log while being initialised.
 
120
 
 
121
                static void LoadLogServices ()
 
122
                {
 
123
                        IEnumerable<ILogService> tmp = null;
 
124
                        if (AddinManager.IsInitialized) {
 
125
                                tmp = AddinManager.GetExtensionObjects ("/Do/Service", true).OfType<ILogService> ();
 
126
                                if (!tmp.Any ()) {
 
127
                                        tmp = null;
 
128
                                }
 
129
                        }
 
130
                        logs = tmp ?? new ILogService [] { new Default.LogService () };
 
131
                }
 
132
 
112
133
                /// <summary>
113
134
                /// All available log services. Used primarily by the static Log class.
114
135
                /// </summary>
115
136
                public static IEnumerable<ILogService> Logs {
116
137
                        get {
117
 
                                if (logs == null)
118
 
                                        logs = LocateServices<ILogService, Default.LogService> ().ToArray ();
119
138
                                return logs;
120
139
                        }
121
140
                }