this,
SLOT(callTerminate()));
+ findGprsId();
qDebug() << "Starting...";
if(closeConnection_)
{
+ closeConnection_ = false;
ConnectionManager cm;
cm.disconnect(true);
- closeConnection_ = false;
}
}
void CallListener::incomingCall(QDBusObjectPath path, QString number)
{
- qDebug() << "Incoming: " << number;
-
ContactManager cm;
if(!cm.numberExists(number))
if(closeConnection_)
{
+ closeConnection_ = false;
ConnectionManager cm;
cm.disconnect(true);
- closeConnection_ = false;
}
searchClose();
+
+ if(gprsId_.isEmpty())
+ {
+ findGprsId();
+ }
}
void CallListener::showDelayedResult(QString const& text, int delay)
int cretries = 0;
+ bool tryGprs = (!gprsId_.isEmpty() &&
+ (configType == Settings::ANY || configType == Settings::GPRS));
+
while(cretries < CONNECTION_LOOKUP_RETRIES)
{
if(!initialized_)
break;
}
+ // ICD doesn't always find gprs connection during call, so
+ // try to use gprs anyway.
+ if(tryGprs && is3g())
+ {
+ best.id = gprsId_;
+ qDebug() << "Trying gprs";
+ break;
+ }
+
qDebug() << "No connections found, retrying...";
cretries++;
return false;
}
- sleep(WAIT_BETWEEN_RETRIES);
-
if(cm.connect(best.id))
{
break;
return false;
}
+ sleep(WAIT_BETWEEN_RETRIES);
+
qDebug() << "Unable to connect, retrying...";
retries++;
QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents);
}
}
+
+void CallListener::findGprsId()
+{
+ ConnectionManager cm;
+
+ QList<ConnectionManager::Connection> connections;
+
+ if(cm.scanConnections(connections, ConnectionManager::GPRS) &&
+ connections.size() > 0)
+ {
+ gprsId_ = connections.at(0).id;
+ }
+}
+
+bool CallListener::is3g()
+{
+ QDBusMessage msg = QDBusMessage::createMethodCall("com.nokia.phone.net",
+ "/com/nokia/phone/net",
+ "Phone.Net",
+ "get_registration_status");
+
+ QDBusMessage rep = systemBus_.call(msg);
+
+ if(rep.type() == QDBusMessage::ErrorMessage)
+ {
+ qDebug() << "Unable to get network status";
+ return false;
+ }
+
+ uint status = rep.arguments().value(6).toUInt();
+
+ if(status & 0x10) // 3.5G (HSUPA)
+ {
+ return true;
+ }
+ else if(status & 0x08) // 3G (HSDPA)
+ {
+ return true;
+ }
+
+ // Something else
+ return false;
+}