2 * This file is part of the libCEC(R) library.
4 * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited. All rights reserved.
5 * libCEC(R) is an original work, containing original code.
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
9 * This program is dual-licensed; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
27 * For more information contact:
28 * Pulse-Eight Licensing <license@pulse-eight.com>
29 * http://www.pulse-eight.com/
30 * http://www.pulse-eight.net/
33 using System.Collections.Generic;
35 using LibCECTray.controller.applications.@internal;
36 using LibCECTray.settings;
38 namespace LibCECTray.controller.applications
40 class Applications : CECSettingString
42 private Applications() :
43 base("global_applications", "Applications", string.Empty, null)
47 public static ApplicationController Get(string key)
49 return (_instance != null && _instance.Value.ContainsKey(key))
50 ? _instance.Value[key]
54 public static List<ApplicationController> GetAll()
56 List<ApplicationController> retVal = new List<ApplicationController>();
57 if (_instance != null)
59 foreach (var app in _instance.Value.Values)
65 public new Dictionary<string, ApplicationController> Value
69 if (_controllers == null)
71 _controllers = DefaultValue;
72 var split = base.Value.Split('~');
73 foreach (var item in split)
77 var app = ApplicationController.FromString(_controller, _controller.Settings, item);
79 _controllers.Add(app.ProcessName, app);
89 StringBuilder sb = new StringBuilder();
90 foreach (var app in value.Values)
92 sb.AppendFormat("{0}~", app.AsString());
94 base.Value = sb.ToString();
98 public new Dictionary<string, ApplicationController> DefaultValue
102 var defaultValues = new Dictionary<string, ApplicationController>();
103 WMCController wmcController = new WMCController(_controller);
104 defaultValues.Add(wmcController.ProcessName, wmcController);
105 XBMCController xbmcController = new XBMCController(_controller);
106 defaultValues.Add(xbmcController.ProcessName, xbmcController);
108 return defaultValues;
113 StringBuilder sb = new StringBuilder();
114 foreach (var app in value.Values)
116 sb.AppendFormat("{0}~", app.AsString());
118 base.DefaultValue = sb.ToString();
122 public static void Initialise(CECController controller)
124 _controller = controller;
125 if (_instance == null)
126 _instance = new Applications();
127 controller.Settings["global_applications"] = _instance;
128 controller.Settings.Load(_instance);
130 foreach (var app in _instance.Value)
131 _controller.RegisterApplication(app.Value);
134 private static Applications _instance;
135 private static CECController _controller;
136 private Dictionary<string, ApplicationController> _controllers;