From 311f8d8c00ac52bcb59c1f3aa8523f905584f1bf Mon Sep 17 00:00:00 2001 From: eshe Date: Thu, 22 Jul 2010 16:49:00 +0100 Subject: [PATCH] Added call log and German translation. --- src/common/cache.cpp | 136 ++++++++++- src/common/cache.h | 14 ++ src/common/db.cpp | 34 ++- src/common/db.h | 2 +- src/common/settings.cpp | 4 +- src/common/translations.grc | 7 - src/common/translations.qrc | 8 + src/common/translations/de_DE.qm | Bin 0 -> 8751 bytes src/common/translations/de_DE.ts | 459 ++++++++++++++++++++++++++++++++++++++ src/common/translations/fi_FI.qm | Bin 8773 -> 9190 bytes src/common/translations/fi_FI.ts | 126 +++++++---- src/daemon/calllistener.cpp | 48 +++- src/daemon/calllistener.h | 11 +- src/daemon/daemon.pro | 3 +- src/daemon/main.cpp | 7 + src/gui/gui.pro | 10 +- src/gui/icons.grc | 7 - src/gui/icons.qrc | 7 + src/gui/listwidget.cpp | 75 +++++++ src/gui/listwidget.h | 51 +++++ src/gui/logwindow.cpp | 174 +++++++++++++++ src/gui/logwindow.h | 52 +++++ src/gui/main.cpp | 3 + src/gui/mainwindow.cpp | 32 ++- src/gui/mainwindow.h | 5 + src/gui/resultwindow.cpp | 17 +- src/gui/searchdialog.cpp | 12 +- src/gui/searchdialog.h | 3 +- 28 files changed, 1198 insertions(+), 109 deletions(-) mode change 100755 => 100644 src/common/dasoertliche.cpp mode change 100755 => 100644 src/common/dasoertliche.h mode change 100755 => 100644 src/common/dastelefonbuch.cpp mode change 100755 => 100644 src/common/dastelefonbuch.h delete mode 100644 src/common/translations.grc create mode 100644 src/common/translations.qrc create mode 100644 src/common/translations/de_DE.qm create mode 100644 src/common/translations/de_DE.ts delete mode 100644 src/gui/icons.grc create mode 100644 src/gui/icons.qrc create mode 100644 src/gui/listwidget.cpp create mode 100644 src/gui/listwidget.h create mode 100644 src/gui/logwindow.cpp create mode 100644 src/gui/logwindow.h diff --git a/src/common/cache.cpp b/src/common/cache.cpp index fcbbcb5..b339d43 100644 --- a/src/common/cache.cpp +++ b/src/common/cache.cpp @@ -54,6 +54,7 @@ int Cache::clear() return ret; } + bool Cache::findItem(QString const& number, Source::Result& result) { bool connected = DB::connected(); @@ -63,13 +64,14 @@ bool Cache::findItem(QString const& number, Source::Result& result) DB::connect(); } - QSqlQuery query; - query.prepare("SELECT name, street, city FROM cache WHERE number = :number"); - query.bindValue(":number", number); + QSqlQuery query("SELECT name, street, city FROM cache WHERE number LIKE '%" + number.right(7) + "'"); + + //query.prepare("SELECT name, street, city FROM cache WHERE number = :number"); + //query.bindValue(":number", number); bool ret = false; - if(query.exec() && query.next()) + if(query.next()) { result.number = number; result.name = query.value(0).toString(); @@ -155,6 +157,132 @@ bool Cache::addItem(Source::Result const& result) } +bool Cache::logItem(Source::Result const& result, bool missed, unsigned int time) +{ + bool connected = DB::connected(); + + if(!connected) + { + DB::connect(); + } + + bool ret = true; + + QSqlQuery query; + + query.prepare("INSERT INTO log(number, name, street, city, time, missed) VALUES(:number, :name, :street, :city, :time, :missed)"); + query.bindValue(":number", result.number); + query.bindValue(":name", result.name); + query.bindValue(":street", result.street); + query.bindValue(":city", result.city); + query.bindValue(":time", time); + int misVal = missed ? 1 : 0; + + query.bindValue(":missed", misVal); + + if(!query.exec()) + { + ret = false; + } + + query.clear(); + + // Delete old entries from cache + if(LOG_MAX_SIZE > 0) + { + if(query.exec("SELECT COUNT(*) FROM log") && query.next()) + { + int itemsToDelete = query.value(0).toInt() - LOG_MAX_SIZE; + + for(int i = 0; i < itemsToDelete; i++) + { + query.clear(); + + if(!query.exec("DELETE FROM cache WHERE id = (SELECT MIN(id) FROM cache)")) + { + QSqlError error = query.lastError(); + qDebug() << "Unable to delete old cache entries: " << error.text(); + ret = false; + } + } + } + else + { + QSqlError error = query.lastError(); + qDebug() << "Unable to get count for cache entries: " << error.text(); + ret = false; + } + + } + + if(!connected) + { + DB::disconnect(); + } + + return ret; + +} + +void Cache::getLogItems(QList& items, int limit) +{ + bool connected = DB::connected(); + + if(!connected) + { + DB::connect(); + } + + QSqlQuery query("SELECT number, name, street, city, time, missed FROM log ORDER BY time DESC LIMIT " + QString::number(limit)); + + while(query.next()) + { + LogDetails details; + details.result.number = query.value(0).toString(); + details.result.name = query.value(1).toString(); + details.result.street = query.value(2).toString(); + details.result.city = query.value(3).toString(); + details.time = query.value(4).toInt(); + + int missed = query.value(5).toInt(); + + details.missed = missed ? true : false; + + items.push_back(details); + } + + if(!connected) + { + DB::disconnect(); + } + +} + +int Cache::clearLog() +{ + bool connected = DB::connected(); + + if(!connected) + { + DB::connect(); + } + + QSqlQuery query; + int ret = -1; + + if(query.exec("DELETE FROM log")) + { + ret = query.numRowsAffected(); + } + + if(!connected) + { + DB::disconnect(); + } + + return ret; +} + Cache& Cache::instance() { if(!instance_) diff --git a/src/common/cache.h b/src/common/cache.h index f08b9d9..977159d 100644 --- a/src/common/cache.h +++ b/src/common/cache.h @@ -19,16 +19,30 @@ #ifndef CACHE_H #define CACHE_H +#include +#include #include "source.h" class Cache { public: + struct LogDetails + { + Source::Result result; + int time; + bool missed; + }; + + static int const LOG_MAX_SIZE = 80; + static Cache& instance(); int clear(); bool findItem(QString const& number, Source::Result& result); bool addItem(Source::Result const& result); + bool logItem(Source::Result const& result, bool missed, unsigned int time); + void getLogItems(QList& items, int limit); + int clearLog(); private: Cache(); diff --git a/src/common/dasoertliche.cpp b/src/common/dasoertliche.cpp old mode 100755 new mode 100644 diff --git a/src/common/dasoertliche.h b/src/common/dasoertliche.h old mode 100755 new mode 100644 diff --git a/src/common/dastelefonbuch.cpp b/src/common/dastelefonbuch.cpp old mode 100755 new mode 100644 diff --git a/src/common/dastelefonbuch.h b/src/common/dastelefonbuch.h old mode 100755 new mode 100644 diff --git a/src/common/db.cpp b/src/common/db.cpp index ce0cf97..4028a74 100644 --- a/src/common/db.cpp +++ b/src/common/db.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include "db.h" @@ -26,6 +27,7 @@ namespace { const QString SQL_DRIVER = "QSQLITE"; const QString SQL_DATABASE = ".jenirok.db"; + const int DB_VERSION = 2; } bool DB::initialized_ = false; @@ -50,11 +52,20 @@ bool DB::connect() if(ret && !initialized_) { - QSqlQuery query("SELECT value FROM settings WHERE name = 'initialized'"); + QSqlQuery query("SELECT value FROM settings WHERE name = 'db_version'"); - if(!query.next()) + if(query.next()) { - ret = createTables(); + int currentVersion = query.value(0).toString().toInt(); + + if(currentVersion < DB_VERSION) + { + ret = createTables(true); + } + } + else + { + ret = createTables(false); } } @@ -94,15 +105,24 @@ QSqlDatabase& DB::instance() return db_; } -bool DB::createTables() +bool DB::createTables(bool update) { QSqlQuery query; bool ret = true; - ret = ret && query.exec("CREATE TABLE cache (id INTEGER PRIMARY KEY, number VARCHAR(32) NOT NULL UNIQUE, name VARCHAR(255) NOT NULL, street VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL)"); - ret = ret && query.exec("CREATE TABLE settings (name VARCHAR(255) NOT NULL PRIMARY KEY, value VARCHAR(255) NOT NULL)"); - ret = ret && query.exec("INSERT INTO settings(name, value) VALUES('initialized', '1')"); + ret = ret && query.exec("CREATE TABLE IF NOT EXISTS cache (id INTEGER PRIMARY KEY, number VARCHAR(32) NOT NULL UNIQUE, name VARCHAR(255) NOT NULL, street VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL)"); + ret = ret && query.exec("CREATE TABLE IF NOT EXISTS settings (name VARCHAR(255) NOT NULL PRIMARY KEY, value VARCHAR(255) NOT NULL)"); + ret = ret && query.exec("CREATE TABLE IF NOT EXISTS log (id INTEGER PRIMARY KEY, number VARCHAR(32) NOT NULL, name VARCHAR(255), street VARCHAR(255), city VARCHAR(255), time INTEGER NOT NULL, missed INTEGER NOT NULL)"); + + if(update) + { + ret = ret && query.exec("UPDATE settings SET value = '" + QString::number(DB_VERSION) + "' WHERE name = 'db_version'"); + } + else + { + ret = ret && query.exec("INSERT INTO settings(name, value) VALUES('db_version', '" + QString::number(DB_VERSION) + "')"); + } return ret; } diff --git a/src/common/db.h b/src/common/db.h index 0aa2490..6c1b989 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -34,7 +34,7 @@ public: private: DB(); - static bool createTables(); + static bool createTables(bool update); static QSqlDatabase db_; static bool initialized_; }; diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 182f0ab..21962d9 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -27,10 +27,11 @@ namespace { - static int const LANGUAGE_COUNT = 4; + static int const LANGUAGE_COUNT = 5; static QString const LANGUAGE_NAMES[LANGUAGE_COUNT] = { "English", + "Deutsch", "Norsk", "Suomi", "Svenska" @@ -38,6 +39,7 @@ namespace static QString const LANGUAGE_IDS[LANGUAGE_COUNT] = { "en_US", + "de_DE", "nb_NO", "fi_FI", "sv_SE" diff --git a/src/common/translations.grc b/src/common/translations.grc deleted file mode 100644 index 974784d..0000000 --- a/src/common/translations.grc +++ /dev/null @@ -1,7 +0,0 @@ - - - translations/fi_FI.qm - translations/nb_NO.qm - translations/sv_SE.qm - - diff --git a/src/common/translations.qrc b/src/common/translations.qrc new file mode 100644 index 0000000..6bb133a --- /dev/null +++ b/src/common/translations.qrc @@ -0,0 +1,8 @@ + + + translations/fi_FI.qm + translations/nb_NO.qm + translations/sv_SE.qm + translations/de_DE.qm + + diff --git a/src/common/translations/de_DE.qm b/src/common/translations/de_DE.qm new file mode 100644 index 0000000000000000000000000000000000000000..f9f21130259643183527d2bf88a9a20bb4a16656 GIT binary patch literal 8751 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 + + + + AboutDialog + + + About + Über + + + + CallListener + + Searching... + Suche... + + + Request timed out + Server antwortet nicht + + + Searching failed: + Suche misslungen: + + + Phone number was not found + Telefonnummer nicht gefunden + + + Automatic connecting is not allowed by settings. + Einstellungen verbieten automatische Verbindung. + + + Connecting... + Verbinde... + + + No available 3G or WLAN networks found. + Keine 3G oder WLAN Verbindungen gefunden. + + + Selected access point doesn't exist. + Der gewählte Access-Point existiert nicht. + + + Unable to connect to network. + Netzwerkverbindung nicht möglich. + + + + ConnectionSelector + + + Use global setting + Globale Einstellung verwenden + + + + WLAN connection + WLAN-Verbindung + + + + GPRS connection + GPRS-Verbindung + + + + Any connection + Irgendeine Verbindung + + + + DetailWindow + + + + Add to contacts + Zu Kontakten hinzufügen + + + + Copy number to clipboard + Nummer kopieren + + + + Call + Anruf + + + + Send SMS + SMS senden + + + + + Name + Name + + + + Street + Straße + + + + City + Stadt + + + + Phone number + Telefonnummer + + + + Unable make call + Anruf nicht möglich + + + + Add + Hinzufügen + + + + Contact was successfully added to contacts. + Kontakt erfolgreich hinzugefügt. + + + + Unable to open SMS application + Kann SMS Anwendung nicht öffnen + + + + + + Error + Fehler + + + + Unable to add contact. + Kann Kontakt nicht hinzufügen. + + + + Number was successfully copied to clipboard. + Telefonnummer kopiert. + + + + EmptyGuiConfig + + + Selected phonebook has no settings to configure. + Kein Einstellungen für das gewählte Telefonbuch. + + + + EniroGuiConfig + + + Eniro username + Eniro Benutzername + + + + Eniro password + Eniro Passwort + + + + Eniro site + Eniro Seite + + + + Finnish + Finnisch + + + + Swedish + Schwedisch + + + + Danish + Dänisch + + + + MainWindow + + + Jenirok + Jenirok + + + + + Stop daemon + Hintergrunddienst stoppen + + + + + Start daemon + Hintergrunddienst starten + + + + Search + Suchen + + + + Settings + Einstellungen + + + + About + Über + + + + Daemon was successfully stopped. + Hintergrunddienst erfolgreich angehalten. + + + + Unable to stop daemon. + Kann Hintergrunddienst nicht anhalten. + + + + Unable to start daemon + Kann Hintergrunddienst nicht starten + + + + Daemon cannot be started because it's not allowed to connect to the Internet. You have to either allow automatic Internet connection in Jenirok settings or in global Maemo settings. + Der Hintergrunddienst kann nicht gestartet werden, da er keinen Internetzugriff erhält. Lösung: Entweder automatische Internetverbindung in Jenirok oder in den globalen Maemo Einstellungen erlauben. + + + + Open settings + Einstellungen öffnen + + + + Close + Schliessen + + + + Daemon was successfully started. + Hintergrunddienst erfolgreich gestartet. + + + + Unable to start daemon. + Konnte Hintergrunddienst nicht starten. + + + + Error + Fehler + + + + Info + Info + + + + You need to set login details or other options in settings before using this feature. + Für diese Funktion müssen zuerst Anmeldedetails oder andere Einstellungen ausgefüllt sein. + + + + ResultWindow + + + Search results + Suchergebnisse + + + + Connection to server failed + Konnte nicht mit Server verbinden + + + + Invalid login details + Ungültige Anmeldedaten + + + + Request timed out + Server antwortet nicht + + + + Searching failed: + Suche fehlgeschlagen: + + + + Error + Fehler + + + + No results found + Keine Ergebnisse + + + + SearchDialog + + + + Search + Suche + + + + Name/number + Name/Nummer + + + + Location + Ort + + + + Type + Typ + + + + Persons + Personen + + + + Companies + Firmen + + + + Settings + + + fi + fi + + + + SettingsDialog + + + Settings + Einstellungen + + + + Cache size (numbers) + Programmspeicherplatz (Nummern) + + + + Clear + Leeren + + + + Language + Sprache + + + + Automatic + Automatisch + + + + Phonebook + Telefonbuch + + + + Autostart + Autostart + + + + Enabled + Aktiviert + + + + Disabled + Deaktiviert + + + + Connect automatically on + Automatisch verbinden bei + + + + Save + Speichern + + + + General + Allgemein + + + + Daemon + Hintergrunddienst + + + + + Phonebook settings + Telefonbuch + + + + Restarting daemon... + Hintergrunddienst wird neu gestartet... + + + + You need to restart Jenirok for language change to take effect. + Jenirok muss neu gestartet werden, damit die Spracheinstellungen aktiv werden. + + + + %n number(s) were deleted from cache + + %n Telefonnummer aus Programmspeicher gelöscht + %n Telefonnummern aus Programmspeicher gelöscht + + + + diff --git a/src/common/translations/fi_FI.qm b/src/common/translations/fi_FI.qm index 8c9f0c6079d81950ca0b458189ac0af69fc847fa..644013640d24b3d7804f5c84d985c301d091bfe4 100644 GIT binary patch delta 1061 zcmZ`%Z%k8H96fE{E3JL69kvvx3eNxuM1$i4Tec8CfC>U(C?Lv~#R|{1(zQ!VM=++( z7!pj3n-Rs15jW=FNOTI(NHE4IMA-+_4@Tn$VjP(X5(Z(q7y^2riHTF+&CBoJ-@WJj z&hOkiwC?ZXLk{f@U>pWq=YisrfOre2ss)z*1tGSYdu0%Q>u1~zQMk)|E5wp~AmJ&* z*btE32JwbU{2pYsi~@$ODDD`B|b?G zp{*whB$nVgvuuq+qAc*SLVYuN$AG zfb?1YwI8g^H|wWr*-To${?$&NcbqrKWorR@zoD?83P>3;Ol*ikgYc)Ya@7n0(?b3? zy@2Ve;1y2*soRC_W2sbLA)FcfmV)Ypvz0Nxa#@&p#R5rd#3Yv;Nd8@n^#pjnON?Ec zr{D^)^X?fy9ua@p&-3=0cyxUw_8g!y<^pl}aVMa^wGcG|CF3Upg^Ul3Wn(>595mJr zj?l_y#^KWjTAOT~b4E$@(l~dUSCmj>a%^KqOD0WgIw;JMYpUpdLEM+7>Xij7&}cdm z<=S=6Y*$YK(&y&zCgPJWm=D~z&Wp)2ca>)FDiW7GG>Dwo<@PyUnzrnmW!IBxVA+%< zv~wdH$g^lU$EhRP()vX+*9WByRedz*wN!lgUm7wZ4d}vz?~TXw>(b2{J`E`d!eWGm1Mi%m*ARB7?_SEGXa!d;k(8%AJ zm8WC}f=XC*hw8mbNDW8)P2rpbZkfx2o?2g^A=s>=%W$C@E%0I&R0KH2Na#lpjqtr? zGZ*>EqxgfK4-hy|i3kZ)jkw5r*u;&2`rvoIfJdo!`~4r`$i;g2SeQi-q7*lpI3kNP z1>eW{7wLV>yWa}SsP?KMRdMsLk7R{HYM{yAqOfmD^{5StCByG(?i;sx1*Zw+|Lf5} OTiP$#9etY}Gx8gR delta 692 zcmX9+ZAepL6n^f#@4frDA9I`A+_Hrzff$A4>W_q2IZ+Wq#lDEjCYWG9gsh-l5TQcI zNYiCuN>;*t6b^+@!gQkcqkfr@5+%~WWEJa!AzG()|2*$|&Ux;6&U4<+{+UC!()9sA zng`qkfPV-Or@=zIC{_+O@SN}pMD_--`XHA20K*Ez&I?!@4F9N-vcOfoe- zjo9yIV0#y*Xg2|Nfjd6DNJ5=lV-xYx+PJk165ws)CoXCfZ{@$$O;ddlpKPFddx4;q z9{_AcLUCa=;HnVTONhr_v8=oVx;&g!cg5IXuN&|zuqV+|B>EE@t_lJ2C`%;ipY}1) z;jshGTrm`G1~Rh6(8LyLtQ7BEr#kC$3Nzk{;SMsvR4C5B?*sVh6uP>kwDDr%os`N~ z!!+YBsV@4OOp8hLj|J$+=$AH~B+7PG+MJ~=7!DfKkCAwD+_Ih)`qxf(CpoX=|IM+e~3@P*;R;Fs{87M*J z%T%14x}=I#@8~|OK3vEl$JW%LzIJlzff}77p_wap s{%(2}otDy7Pd6n3bRcxbEnDs_5@2ZrcC<%Uc%K?+u-3Ck!jVw_0`^+A ConnectionSelector - + Use global setting Käytä järj. asetusta - + WLAN connection WLAN-yhteys - + GPRS connection GPRS-yhteys - + Any connection Mikä tahansa yhteys @@ -164,122 +164,150 @@ EniroGuiConfig - + Eniro username Eniro-tunnus - + Eniro password Eniro-salasana - + Eniro site Eniro-sivusto - + Finnish Suomi - + Swedish Ruotsi - + Danish Tanska + LogWindow + + + Incoming call log + Puheluloki + + + + Clear log + Tyhjennä loki + + + + There are currently no logged calls + Ei kirjattuja puheluita + + + + %1 (no search results) + %1 (ei hakutuloksia) + + + MainWindow - + Jenirok Jenirok - - + + Stop daemon Pysäytä - - + + Start daemon Käynnistä - + Search Hae - + + Log + Loki + + + Settings Asetukset - + About Tietoa - + Daemon was successfully stopped. Palvelu pysäytettiin onnistuneesti. - + Unable to stop daemon. Palvelun pysäyttäminen ei onnistunut. - + Unable to start daemon Palvelun käynnistäminen ei onnistunut - + Daemon cannot be started because it's not allowed to connect to the Internet. You have to either allow automatic Internet connection in Jenirok settings or in global Maemo settings. Palvelua ei voida käynnistää, koska sillä ei ole oikeutta yhdistää Internetiin. Sinun täytyy sallia automaattinen yhteyden muodostaminen joko Jenirokin asetuksista tai Maemon omista Internet-asetuksista. - + Open settings Avaa asetukset - + Close Sulje - + Daemon was successfully started. Palvelu käynnistettiin onnistuneesti. - + Unable to start daemon. Palvelun käynnistäminen ei onnistunut. - + Error Virhe - + Info Info - + You need to set login details or other options in settings before using this feature. Sinun täytyy asettaa kirjautumistiedot tai muita asetuksia ennen kuin voit käyttää tätä ominaisuutta. @@ -292,32 +320,32 @@ Hakutulokset - + Connection to server failed Palvelimelle yhdistäminen epäonnistui - + Invalid login details Virheellinen tunnus tai salasana - + Request timed out Pyyntö aikakatkaistiin - + Searching failed: Haku epäonnistui: - + Error Virhe - + No results found Ei hakutuloksia @@ -325,33 +353,33 @@ SearchDialog - + Search Hae - + Name/number Numero/nimi - + Location Sijainti - + Type Tyyppi - + Persons Henkilöt - + Companies Yritykset @@ -359,7 +387,7 @@ Settings - + fi fi @@ -417,28 +445,28 @@ Yhdistä automaattisesti - + Save Tallenna - + General Yleiset - + Daemon Taustaprosessi - - + + Phonebook settings Puhelinluettelo - + Restarting daemon... Käynnistetään palvelu uudelleen... @@ -448,7 +476,7 @@ Jenirok täytyy käynnistää uudelleen, jotta uudet kieliasetukset tulevat voimaan. - + %n number(s) were deleted from cache Poistettiin %n numero välimuistista diff --git a/src/daemon/calllistener.cpp b/src/daemon/calllistener.cpp index 78d5737..b4d80d4 100644 --- a/src/daemon/calllistener.cpp +++ b/src/daemon/calllistener.cpp @@ -18,6 +18,7 @@ #include #include +#include #include "calllistener.h" #include "settings.h" #include "cache.h" @@ -35,13 +36,14 @@ namespace const QString CALL_SIGNAL_INCOMING = "Coming"; const QString CALL_SIGNAL_RELEASE = "Release"; const QString CALL_SIGNAL_TERMINATED = "Terminated"; + const QString CALL_SIGNAL_ANSWERED = "AudioConnect"; } QDBusConnection CallListener::systemBus_ = QDBusConnection::systemBus(); CallListener::CallListener(): source_(0), closeConnection_(false), initialized_(false), box_(0), label_(0), -retries_(-1), timer_(0) +retries_(-1), timer_(0), currentCall_(0) { } @@ -111,6 +113,16 @@ void CallListener::search(Source::SearchDetails const& details) { qDebug() << "Search called"; + if(currentCall_) + { + delete currentCall_; + } + + currentCall_ = new CallDetails; + currentCall_->number = details.query; + currentCall_->time = QDateTime::currentDateTime().toTime_t(); + currentCall_->answered = false; + searchInit(); Source::Result result; @@ -123,11 +135,12 @@ void CallListener::search(Source::SearchDetails const& details) showDelayedResult(createResult(result.name, result.street, result.city), BANNER_DELAY); + + currentCall_->result = result; } else { retries_ = 0; - currentSearch_ = details.query; if(!handleConnection()) { @@ -156,7 +169,7 @@ void CallListener::requestFinished(QVector const& results, } // If box is not visible, the call must have been terminated already - if(!initialized_ || !box_->isVisible()) + if(!initialized_ || !box_->isVisible() || !currentCall_) { return; } @@ -170,7 +183,7 @@ void CallListener::requestFinished(QVector const& results, if(retries_ < SEARCH_RETRIES && retries_ >= 0) { retries_++; - source_->search(Source::SearchDetails(currentSearch_, "", Source::BOTH)); + source_->search(Source::SearchDetails(currentCall_->number, "", Source::BOTH)); return; } else @@ -209,11 +222,11 @@ void CallListener::requestFinished(QVector const& results, Source::Result result = results.at(0); result.number = details.query; Cache::instance().addItem(result); + currentCall_->result = results.at(0); } } retries_ = -1; - currentSearch_ = ""; } QString CallListener::createResult(QString const& name, QString const& street, QString const& city) @@ -273,6 +286,13 @@ void CallListener::incomingCall(QDBusObjectPath path, QString number) this, SLOT(callTerminate())); + systemBus_.connect(CALL_SERVICE_NAME, + path.path(), + CALL_SERVICE_INSTANCE_NAME, + CALL_SIGNAL_ANSWERED, + this, + SLOT(handleAnswer())); + search(Source::SearchDetails(number, "", Source::BOTH)); } else @@ -288,9 +308,27 @@ void CallListener::callTerminate() box_->hide(); } + if(currentCall_) + { + currentCall_->result.number = currentCall_->number; + Cache::instance().logItem(currentCall_->result, !currentCall_->answered, currentCall_->time); + delete currentCall_; + currentCall_ = 0; + } + searchClose(); } +void CallListener::handleAnswer() +{ + qDebug() << "Answered"; + + if(currentCall_) + { + currentCall_->answered = true; + } +} + void CallListener::showDelayedResult(QString const& text, int delay) { timedMessage_ = text; diff --git a/src/daemon/calllistener.h b/src/daemon/calllistener.h index 682ea1b..5e1d18b 100644 --- a/src/daemon/calllistener.h +++ b/src/daemon/calllistener.h @@ -54,10 +54,19 @@ private slots: void incomingCall(QDBusObjectPath path, QString numbe); void callTerminate(); void showTimedMessage(); + void handleAnswer(); private: Q_DISABLE_COPY(CallListener); + struct CallDetails + { + QString number; + Source::Result result; + bool answered; + unsigned int time; + }; + void search(Source::SearchDetails const& details); void showResult(QString const& text); void showDelayedResult(QString const& text, int delay); @@ -79,8 +88,8 @@ private: QLabel* label_; static QDBusConnection systemBus_; int retries_; - QString currentSearch_; int timer_; + CallDetails* currentCall_; }; #endif // CALLLISTENER_H diff --git a/src/daemon/daemon.pro b/src/daemon/daemon.pro index d9e3ccd..0987c0e 100644 --- a/src/daemon/daemon.pro +++ b/src/daemon/daemon.pro @@ -31,8 +31,7 @@ HEADERS += calllistener.h \ ../common/connectionmanager.h \ ../common/cache.h \ ../common/dastelefonbuch.h -TRANSLATIONS = ../common/translations/fi_FI.ts -RESOURCES = ../common/translations.grc +RESOURCES = ../common/translations.qrc INCLUDEPATH += ../common CONFIG += link_pkgconfig PKGCONFIG += libebook-1.2 gconf-2.0 diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp index 69964f3..d3b73a4 100644 --- a/src/daemon/main.cpp +++ b/src/daemon/main.cpp @@ -21,6 +21,13 @@ #include "calllistener.h" #include "settings.h" +#include "source.h" +#include "cache.h" +#include +#include +#include +#include + int main(int argc, char *argv[]) { diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 3492c0a..ce51464 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -25,7 +25,9 @@ SOURCES += main.cpp \ ../common/settings.cpp \ ../common/connectionmanager.cpp \ ../common/cache.cpp \ - ../common/dastelefonbuch.cpp + ../common/dastelefonbuch.cpp \ + logwindow.cpp \ + listwidget.cpp HEADERS += mainwindow.h \ searchdialog.h \ resultwindow.h \ @@ -49,9 +51,11 @@ HEADERS += mainwindow.h \ ../common/settings.h \ ../common/connectionmanager.h \ ../common/cache.h \ - ../common/dastelefonbuch.h + ../common/dastelefonbuch.h \ + logwindow.h \ + listwidget.h +RESOURCES = icons.qrc ../common/translations.qrc TRANSLATIONS = ../common/translations/fi_FI.ts -RESOURCES = icons.grc ../common/translations.grc INCLUDEPATH += ../common CONFIG += link_pkgconfig PKGCONFIG += libebook-1.2 gconf-2.0 diff --git a/src/gui/icons.grc b/src/gui/icons.grc deleted file mode 100644 index 68f3e89..0000000 --- a/src/gui/icons.grc +++ /dev/null @@ -1,7 +0,0 @@ - - - icons/start.png - icons/stop.png - icons/icon.png - - diff --git a/src/gui/icons.qrc b/src/gui/icons.qrc new file mode 100644 index 0000000..68f3e89 --- /dev/null +++ b/src/gui/icons.qrc @@ -0,0 +1,7 @@ + + + icons/start.png + icons/stop.png + icons/icon.png + + diff --git a/src/gui/listwidget.cpp b/src/gui/listwidget.cpp new file mode 100644 index 0000000..39a6519 --- /dev/null +++ b/src/gui/listwidget.cpp @@ -0,0 +1,75 @@ +/* + * This file is part of Jenirok. + * + * Jenirok is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jenirok is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jenirok. If not, see . + * + */ + +#include +#include +#include "listwidget.h" + +ListWidget::ListWidget(QWidget* parent): QTableWidget(parent) +{ + connect(this, SIGNAL(cellClicked(int, int)), this, SLOT(handleClick(int))); + setColumnCount(1); + verticalHeader()->hide(); + horizontalHeader()->hide(); + setColumnWidth(0, 800); + setSelectionMode(QAbstractItemView::SingleSelection); +} + +void ListWidget::addWidget(QWidget* widget, QVariant const& data) +{ + int row = rowCount(); + setRowCount(row + 1); + setCellWidget(row, 0, widget); + data_[row] = data; + widgets_[row] = widget; + resizeRowToContents (row); +} + +QVariant ListWidget::getData(int index) const +{ + if(data_.find(index) != data_.end()) + { + return data_[index]; + } + + return QVariant(); +} + +QWidget* ListWidget::getWidget(int index) const +{ + if(widgets_.find(index) != widgets_.end()) + { + return widgets_[index]; + } + + return 0; +} + +void ListWidget::clear() +{ + QTableWidget::clear(); + data_.clear(); + widgets_.clear(); + setRowCount(0); +} + +void ListWidget::handleClick(int index) +{ + clearSelection(); + emit itemClicked(index); +} diff --git a/src/gui/listwidget.h b/src/gui/listwidget.h new file mode 100644 index 0000000..04db528 --- /dev/null +++ b/src/gui/listwidget.h @@ -0,0 +1,51 @@ +/* + * This file is part of Jenirok. + * + * Jenirok is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jenirok is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jenirok. If not, see . + * + */ + +#ifndef LISTWIDGET_H +#define LISTWIDGET_H + +#include +#include +#include + +class ListWidget : public QTableWidget +{ + Q_OBJECT + +public: + ListWidget(QWidget* parent = 0); + void addWidget(QWidget* widget, QVariant const& data); + QVariant getData(int index) const; + QWidget* getWidget(int index) const; + +signals: + void itemClicked(int index); + +public slots: + void clear(); + +private slots: + void handleClick(int index); + +private: + QTableWidget* widget_; + QMap data_; + QMap widgets_; +}; + +#endif diff --git a/src/gui/logwindow.cpp b/src/gui/logwindow.cpp new file mode 100644 index 0000000..1fb8484 --- /dev/null +++ b/src/gui/logwindow.cpp @@ -0,0 +1,174 @@ +/* + * This file is part of Jenirok. + * + * Jenirok is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jenirok is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jenirok. If not, see . + * + */ + +#include +#include +#include +#include +#include +#include +#include "logwindow.h" + +LogWindow::LogWindow(QWidget* parent): QMainWindow(parent), list_(0) +{ + setAttribute(Qt::WA_Maemo5StackedWindow); + setWindowTitle(tr("Incoming call log")); + menuBar()->addAction(tr("Clear log"), this, SLOT(clearLog())); +} + +void LogWindow::setVisible(bool visible) +{ + if(visible) + { + loadLogItems(); + } + + QMainWindow::setVisible(visible); +} + +void LogWindow::loadLogItems() +{ + if(!list_) + { + list_ = new ListWidget(this); + setCentralWidget(list_); + connect(list_, SIGNAL(itemClicked(int)), this, + SLOT(itemClicked(int))); + } + else + { + list_->clear(); + } + + QList logList; + + Cache::instance().getLogItems(logList, LOG_MAX_ITEMS); + + if(logList.size() == 0) + { + QLabel* info = new QLabel(tr("There are currently no logged calls")); + info->setAlignment(Qt::AlignCenter); + setCentralWidget(info); + list_ = 0; + } + else + { + for(int i = 0; i < logList.size(); i++) + { + QMap data; + data["name"] = QVariant(logList.at(i).result.name); + data["street"] = QVariant(logList.at(i).result.street); + data["city"] = QVariant(logList.at(i).result.city); + data["number"] = QVariant(logList.at(i).result.number); + + list_->addWidget(createWidget(logList.at(i)), data); + } + } +} + +void LogWindow::itemClicked(int index) +{ + if(!list_) + { + return; + } + + QMap data = list_->getData(index).toMap(); + Source::Result details; + details.name = data["name"].toString(); + + if(details.name.isEmpty()) + { + return; + } + + details.street = data["street"].toString(); + details.city = data["city"].toString(); + details.number = data["number"].toString(); + + emit logItemSelected(details); +} + +QWidget* LogWindow::createWidget(Cache::LogDetails const& details) +{ + QWidget* widget = new QWidget; + QHBoxLayout* layout = new QHBoxLayout; + + QIcon icon; + + if(details.missed) + { + icon = QIcon::fromTheme("general_missed"); + } + else + { + icon = QIcon::fromTheme("general_received"); + } + + QLabel* label = new QLabel; + label->setPixmap(icon.pixmap(48, 48)); + + layout->addWidget(label); + + QVBoxLayout* content = new QVBoxLayout; + + QString text; + + if(details.result.name.isEmpty()) + { + text = tr("%1 (no search results)").arg(details.result.number); + } + else + { + text = details.result.name; + + if(!details.result.street.isEmpty()) + { + text += ", " + details.result.street; + } + + if(!details.result.city.isEmpty()) + { + text += ", " + details.result.city; + } + } + + QLabel* nameLabel = new QLabel(text); + + QDateTime date = QDateTime::fromTime_t(details.time); + QLabel* dateLabel = new QLabel(date.toString(Qt::SystemLocaleShortDate)); + QFont font; + font.setPointSize(11); + dateLabel->setFont(font); + + content->addWidget(nameLabel); + content->addWidget(dateLabel); + + layout->addLayout(content, Qt::AlignLeft); + + widget->setLayout(layout); + + return widget; +} + +void LogWindow::clearLog() +{ + Cache::instance().clearLog(); + + loadLogItems(); +} diff --git a/src/gui/logwindow.h b/src/gui/logwindow.h new file mode 100644 index 0000000..2afe7e7 --- /dev/null +++ b/src/gui/logwindow.h @@ -0,0 +1,52 @@ +/* + * This file is part of Jenirok. + * + * Jenirok is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Jenirok is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jenirok. If not, see . + * + */ + +#ifndef LOGWINDOW_H +#define LOGWINDOW_H + +#include +#include +#include "source.h" +#include "listwidget.h" +#include "cache.h" + +class LogWindow : public QMainWindow +{ + Q_OBJECT + +public: + static int const LOG_MAX_ITEMS = 50; + LogWindow(QWidget* parent = 0); + +signals: + void logItemSelected(Source::Result const& result); + +protected: + void setVisible(bool visible); + +private slots: + void itemClicked(int index); + void clearLog(); + +private: + QWidget* createWidget(Cache::LogDetails const& details); + void loadLogItems(); + ListWidget* list_; +}; + +#endif diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 215c254..e642575 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -43,5 +43,8 @@ int main(int argc, char *argv[]) QObject::connect(&results, SIGNAL(itemSelected(Source::Result const&)), &details, SLOT(loadData(Source::Result const&))); + QObject::connect(&window, SIGNAL(logItemSelected(Source::Result const&)), + &details, SLOT(loadData(Source::Result const&))); + return app.exec(); } diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 2d4800d..3e62491 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -43,7 +43,8 @@ namespace MainWindow::MainWindow(QWidget* parent): QMainWindow(parent), searchResults_(0), settingsDialog_(0), running_(false), -toggleButton_(0), searchDialog_(0), aboutDialog_(0), warning_(0) +toggleButton_(0), searchDialog_(0), aboutDialog_(0), warning_(0), +logWindow_(0) { setWindowTitle(tr("Jenirok")); setAttribute(Qt::WA_Maemo5StackedWindow); @@ -62,21 +63,35 @@ toggleButton_(0), searchDialog_(0), aboutDialog_(0), warning_(0) running_ = false; } + QSizePolicy policy; + + policy.setHorizontalPolicy(QSizePolicy::Preferred); + + toggleButton_->setSizePolicy(policy); + QToolButton* searchButton = createButton(tr("Search")); searchButton->setIcon(QIcon::fromTheme("general_search")); + searchButton->setSizePolicy(policy); + + QToolButton* logButton = createButton(tr("Log")); + logButton->setIcon(QIcon::fromTheme("general_call")); + logButton->setSizePolicy(policy); QSize size(64, 64); searchButton->setIconSize(size); toggleButton_->setIconSize(size); + logButton->setIconSize(size); QHBoxLayout *buttonLayout = new QHBoxLayout; - buttonLayout->addWidget(toggleButton_, Qt::AlignLeft); - buttonLayout->addWidget(searchButton, Qt::AlignRight); + buttonLayout->addWidget(toggleButton_, Qt::AlignHCenter); + buttonLayout->addWidget(searchButton, Qt::AlignHCenter); + buttonLayout->addWidget(logButton, Qt::AlignHCenter); mainWidget->setLayout(buttonLayout); connect(toggleButton_, SIGNAL(pressed()), this, SLOT(toggleDaemon())); connect(searchButton, SIGNAL(pressed()), this, SLOT(openSearch())); + connect(logButton, SIGNAL(pressed()), this, SLOT(openLog())); setCentralWidget(mainWidget); menuBar()->addAction(tr("Settings"), this, SLOT(showSettings())); @@ -202,6 +217,17 @@ void MainWindow::openSearch() searchDialog_->show(); } +void MainWindow::openLog() +{ + if(!logWindow_) + { + logWindow_ = new LogWindow(this); + connect(logWindow_, SIGNAL(logItemSelected(Source::Result const&)), this, SIGNAL(logItemSelected(Source::Result const&))); + } + + logWindow_->show(); +} + QToolButton* MainWindow::createButton(QString const& text) { QToolButton* button = new QToolButton(); diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index b8e88aa..98ff0c6 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -26,6 +26,8 @@ #include "searchdialog.h" #include "settingsdialog.h" #include "aboutdialog.h" +#include "source.h" +#include "logwindow.h" class MainWindow : public QMainWindow { @@ -37,12 +39,14 @@ public: signals: void search(SearchDialog::SearchDetails& details); + void logItemSelected(Source::Result const& result); public slots: void showSettings(); void showAbout(); void toggleDaemon(); void openSearch(); + void openLog(); void handleSearch(SearchDialog::SearchDetails& details); private: @@ -54,6 +58,7 @@ private: SearchDialog* searchDialog_; AboutDialog* aboutDialog_; QDialog* warning_; + LogWindow* logWindow_; }; diff --git a/src/gui/resultwindow.cpp b/src/gui/resultwindow.cpp index 5d04f03..adbd404 100644 --- a/src/gui/resultwindow.cpp +++ b/src/gui/resultwindow.cpp @@ -90,21 +90,6 @@ void ResultWindow::search(SearchDialog::SearchDetails& details) config->apply(source_); delete config; - Source::SearchType type; - - switch(details.type) - { - case 0: - type = Source::PERSONS; - break; - case 1: - type = Source::YELLOW_PAGES; - break; - default: - qDebug() << "Unknown search type: " << details.type; - return; - } - show(); setAttribute(Qt::WA_Maemo5ShowProgressIndicator, true); @@ -116,7 +101,7 @@ void ResultWindow::search(SearchDialog::SearchDetails& details) connectionManager_->connect(); source_->abort(); - source_->search(Source::SearchDetails(details.name, details.location, type)); + source_->search(Source::SearchDetails(details.name, details.location, details.type)); } diff --git a/src/gui/searchdialog.cpp b/src/gui/searchdialog.cpp index 5ee806c..a6224cb 100644 --- a/src/gui/searchdialog.cpp +++ b/src/gui/searchdialog.cpp @@ -23,7 +23,6 @@ #include #include #include "searchdialog.h" -#include "source.h" #include "settings.h" SearchDialog::SearchDialog(QWidget* parent): QDialog(parent), @@ -76,7 +75,16 @@ void SearchDialog::searchPressed() } details.location = locationInput_->text(); - details.type = selector_->value().toInt(); + + int type = 0; + + if(selector_->isVisible()) + { + type = selector_->value().toInt(); + } + + details.type = static_cast(type); + emit search(details); hide(); } diff --git a/src/gui/searchdialog.h b/src/gui/searchdialog.h index 05c54c5..2f57a9b 100644 --- a/src/gui/searchdialog.h +++ b/src/gui/searchdialog.h @@ -25,6 +25,7 @@ #include #include #include "buttonselector.h" +#include "source.h" class SearchDialog : public QDialog { @@ -36,7 +37,7 @@ public: { QString name; QString location; - int type; + Source::SearchType type; }; SearchDialog(QWidget* parent = 0); -- 1.7.9.5