2 * Copyright (C) 2011, Jamie Thompson
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this program; If not, see
16 * <http://www.gnu.org/licenses/>.
19 #include "CellularRadio.h"
27 const char * NOKIA_SERVICE_PHONE_SCC("com.nokia.phone.SSC");
28 const char * NOKIA_PATH_PHONE_SCC("/com/nokia/phone/SSC");
29 const char * NOKIA_IFACE_PHONE_SCC("com.nokia.phone.SSC");
31 bool CellularRadio::CurrentState()
33 QDBusInterface nokiaPhone(NOKIA_SERVICE_PHONE_SCC, NOKIA_PATH_PHONE_SCC, NOKIA_IFACE_PHONE_SCC, QDBusConnection::systemBus());
34 if (nokiaPhone.isValid())
36 QDBusReply<QString> isEnabledReply = nokiaPhone.call("get_modem_state");
37 if(isEnabledReply.isValid())
39 bool isEnabled(isEnabledReply.value() == "online" || isEnabledReply.value() == "actvation_pending");
40 qDebug() << (isEnabled ? "Enabled:\t\t" : "Not enabled:\t") << "Cellular";
44 qDebug() << isEnabledReply.error();
47 qDebug() << nokiaPhone.lastError();
49 throw std::runtime_error("Unable to query cellular modem state");
52 void CellularRadio::SetState(bool shouldRadioBeEnabled)
54 QDBusInterface nokiaPhone(NOKIA_SERVICE_PHONE_SCC, NOKIA_PATH_PHONE_SCC, NOKIA_IFACE_PHONE_SCC, QDBusConnection::systemBus());
55 if (nokiaPhone.isValid())
57 QDBusReply<void> disableModemReply = nokiaPhone.call("set_radio", shouldRadioBeEnabled);
59 if(!disableModemReply.isValid())
60 qDebug() << disableModemReply.error().message();
63 qDebug() << nokiaPhone.lastError().message();