+jenirok (0.2-1) unstable; urgency=low
+
+ * Architecture changed to allow easier addition of new phonebook sources.
+ * Added Norwegian phonebook (1881.no)
+ * Connection handling improved especially in cases where no 3g or wlan network is available.
+
+ -- Jesse Hakanen <jessehakanen@gmail.com> Tue, 15 Jun 2010 13:14:57 +0100
+
jenirok (0.1-7) unstable; urgency=low
* Decreased daemon's memory usage.
#include <icd/dbus_api.h>
#include "connectionmanager.h"
+bool ConnectionManager::connected_ = false;
ConnectionManager::ConnectionManager(QObject* parent): QObject(parent),
blocking_(true), stateReady_(false), connectionReady_(false), scanReady_(false),
-connected_(false), timeout_(false), numberOfConnections_(0),
+timeout_(false), numberOfConnections_(0),
scannedConnections_(0), timer_(0), error_(NO_ERROR), connections_(0)
{
QDBusConnection systemBus = QDBusConnection::systemBus();
error_ = UNKNOWN_ERROR;
}
+ connected_ = false;
+
return false;
}
+ connected_ = true;
+
return true;
}
if(!scanConnections(connections))
{
+ qDebug() << "Unable to scan connections";
return false;
}
bool ConnectionManager::disconnect(bool force)
{
- // Forced disconnect is not allowed if connection
- // was not initialized by this class
- if(!connected_ && force)
+ if(force)
{
- return false;
+ // Do not allow forced disconnection if connection was not started
+ // by this class.
+ if(!connected_)
+ {
+ return false;
+ }
+
+ QDBusMessage msg = QDBusMessage::createSignal("/com/nokia/icd_ui",
+ "com.nokia.icd_ui",
+ "disconnect");
+
+ QList<QVariant> arguments;
+ bool val = true;
+ arguments.append(QVariant(val));
+ msg.setArguments(arguments);
+
+ bool ret = QDBusConnection::systemBus().send(msg);
+
+ if(ret)
+ {
+ connected_ = false;
+ }
+
+ return ret;
}
connectionReady_ = false;
unsigned int flags;
- if(force)
- {
- flags = static_cast<unsigned int>(ICD_CONNECTION_FLAG_UI_EVENT);
- }
- else
- {
- flags = static_cast<unsigned int>(ICD_CONNECTION_FLAG_USER_EVENT);
- }
+ flags = static_cast<unsigned int>(ICD_CONNECTION_FLAG_USER_EVENT);
icd2interface_->call(ICD_DBUS_API_DISCONNECT_REQ, QVariant(flags));
connected_ = false;
bool stateReady_;
bool connectionReady_;
bool scanReady_;
- bool connected_;
+ static bool connected_;
bool timeout_;
int numberOfConnections_;
int scannedConnections_;
namespace
{
const int COUNTRY_CODES[] = {358, 45, 46, 47, 354};
- const int NUM_OF_CODES = 4;
+ const int NUM_OF_CODES = 5;
}
ContactManager::ContactManager(): book_(0)
if (g_contacts == 0)
{
- qDebug() << "no contacts";
return false;
}
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;
+}
bool handleConnection();
void showError(QString const& msg, int delay = 0);
void sleep(int ms);
+ void findGprsId();
+ bool is3g();
QString createResult(QString const& name, QString const& street, QString const& city);
QString timedMessage_;
Source* source_;
int retries_;
QString currentSearch_;
int timer_;
+ QString gprsId_;
};
#endif // CALLLISTENER_H
#include <QtGui/QApplication>
#include "calllistener.h"
#include "settings.h"
+#include "connectionmanager.h"
+#include <QtCore/QDebug>
int main(int argc, char *argv[])
{
*/
#include <QtGui/QStandardItem>
+#include <QtCore/QDebug>
#include "buttonselector.h"
ButtonSelector::ButtonSelector(QString const& text, QWidget* parent):
{
selector_->setCurrentIndex(0);
}
+
}
void ButtonSelector::clear()
}
selectByValue(currentValue);
+
loaded_ = true;
}
connectionSelector_ = new ConnectionSelector(tr("Connect automatically on"), this);
QString selectedConnection = Settings::instance()->get("connection");
- connectionSelector_->selectByValue(selectedConnection);
+
+ if(connectionSelector_->selectByValue(selectedConnection) &&
+ selectedConnection == "gprs")
+ {
+ connectionSelector_->updateConnections();
+ }
QPushButton* submitButton = new QPushButton(tr("Save"), this);
connect(submitButton, SIGNAL(pressed()), this, SLOT(saveSettings()));