2 * Copyright (C) 2005-2010 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 #include "ApplicationOperations.h"
23 #include "Application.h"
24 #include "ApplicationMessenger.h"
27 #include "utils/log.h"
28 #include "GUIInfoManager.h"
31 using namespace JSONRPC;
33 JSON_STATUS CApplicationOperations::GetProperties(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
35 CVariant properties = CVariant(CVariant::VariantTypeObject);
36 for (unsigned int index = 0; index < parameterObject["properties"].size(); index++)
38 CStdString propertyName = parameterObject["properties"][index].asString();
41 if ((ret = GetPropertyValue(propertyName, property)) != OK)
44 properties[propertyName] = property;
52 JSON_STATUS CApplicationOperations::SetVolume(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
54 int oldVolume = g_application.GetVolume();
55 int volume = (int)parameterObject["value"].asInteger();
57 g_application.SetVolume(volume);
59 g_application.getApplicationMessenger().ShowVolumeBar(oldVolume < volume);
61 return GetPropertyValue("volume", result);
64 JSON_STATUS CApplicationOperations::ToggleMute(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
66 g_application.getApplicationMessenger().SendAction(CAction(ACTION_MUTE));
67 return GetPropertyValue("volume", result);
70 JSON_STATUS CApplicationOperations::Quit(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
72 g_application.getApplicationMessenger().Quit();
76 JSON_STATUS CApplicationOperations::GetPropertyValue(const CStdString &property, CVariant &result)
78 if (property.Equals("volume"))
79 result = g_application.GetVolume();
80 else if (property.Equals("muted"))
81 result = g_application.IsMuted();
82 else if (property.Equals("name"))
84 else if (property.Equals("version"))
86 result = CVariant(CVariant::VariantTypeObject);
87 result["major"] = VERSION_MAJOR;
88 result["minor"] = VERSION_MINOR;
90 result["revision"] = GIT_REV;
92 CStdString tag(VERSION_TAG);
93 if (tag.Equals("PRE-"))
94 result["tag"] = "alpha";
95 else if (tag.Equals("BETA-"))
96 result["tag"] = "beta";
97 else if (tag.Left(2).Equals("RC"))
98 result["tag"] = "releasecandidate";
100 result["tag"] = "stable";
102 result["tag"] = "prealpha";
105 return InvalidParams;