Skip to content

Commit

Permalink
Fixes: NB#273889 - [TASK] Operator name should be replaced with "Emer…
Browse files Browse the repository at this point in the history
…gency calls only" when in limited service state and there is a network available

Bug: NB#273889 - [TASK] Operator name should be replaced with "Emergency calls only" when in limited service state and there is a network available
RevBy: Ran Nyman
  • Loading branch information
Vesa Halttunen committed Jul 28, 2011
1 parent 924e89d commit 19f0b1b
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 50 deletions.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ system-ui (1.1.2~1) unstable; urgency=low

* [UNRELEASED]
* Fixes: NB#272599 - System banners should be prioritized over short event banners (a.k.a. notification previews)
* Fixes: NB#273889 - [TASK] Operator name should be replaced with "Emergency calls only" when in limited service state and there is a network available

-- Vesa Halttunen <[email protected]> Mon, 25 Jul 2011 15:03:45 +0300

Expand Down
6 changes: 3 additions & 3 deletions src/systemui/statusarea/statusareaview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ StatusAreaView::StatusAreaView(StatusArea *controller) :
QDBusConnection::sessionBus().registerService("com.meego.core.MInputMethodStatusIndicator");
QDBusConnection::sessionBus().registerObject("/inputmethodstatusindicator", landscapeInputMethodIndicator);

// Set different style names to PhoneNetworkStatusIndicator in landscape and portrait
landscapePhoneNetworkIndicator->setStyleName(QString(landscapePhoneNetworkIndicator->metaObject()->className()) + "Landscape");
portraitPhoneNetworkIndicator->setStyleName(QString(portraitPhoneNetworkIndicator->metaObject()->className()) + "Portrait");
// Set different object names to PhoneNetworkStatusIndicator in landscape and portrait
landscapePhoneNetworkIndicator->setObjectName(QString(landscapePhoneNetworkIndicator->metaObject()->className()) + "Landscape");
portraitPhoneNetworkIndicator->setObjectName(QString(portraitPhoneNetworkIndicator->metaObject()->className()) + "Portrait");

// Connect notification signals
connect(&Sysuid::instance()->notificationStatusIndicatorSink(), SIGNAL(iconIdChanged(QString)), landscapeNotificationIndicator, SLOT(setIconID(QString)));
Expand Down
37 changes: 32 additions & 5 deletions src/systemui/statusarea/statusindicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
****************************************************************************/
#include <MApplication>
#include <MLocale>
#include <MGConfItem>
#include "statusindicator.h"
#include "statusindicatormodel.h"
#include "applicationcontext.h"
Expand Down Expand Up @@ -157,13 +158,13 @@ void PhoneNetworkSignalStrengthStatusIndicator::setNetworkStatus()
QString postFix;

bool offlineMode = systemOfflineMode->value().toBool();
QString status = cellularRegistrationStatus->value().toString(); // home roam no-sim offline forbidden
QString status = cellularRegistrationStatus->value().toString(); // home roam no-sim offline forbidden no-service

if (offlineMode) {
postFix = "Offline";
} else if (status == "no-sim") {
postFix = "NoSIM";
} else if (status == "" || status == "offline" || status == "forbidden") {
} else if (status == "" || status == "offline" || status == "forbidden" || status == "no-service") {
postFix = "NoNetwork";
}

Expand Down Expand Up @@ -444,8 +445,11 @@ PhoneNetworkStatusIndicator::PhoneNetworkStatusIndicator(ApplicationContext &con

networkName = createContextItem(context, "Cellular.NetworkName");
extendedNetworkName = createContextItem(context, "Cellular.ExtendedNetworkName");
cellularServiceStatus = createContextItem(context, "Cellular.ServiceStatus");
displayLimitedServiceState = new MGConfItem("/desktop/meego/status_area/display_limited_service_state", this);
connect(networkName, SIGNAL(contentsChanged()), this, SLOT(phoneNetworkChanged()));
connect(extendedNetworkName, SIGNAL(contentsChanged()), this, SLOT(phoneNetworkChanged()));
connect(displayLimitedServiceState, SIGNAL(valueChanged()), this, SLOT(phoneNetworkChanged()));
connect(&networkChangeShowVisitorTimer, SIGNAL(timeout()), this, SLOT(showVisitorNetworkName()));
networkChangeShowVisitorTimer.setSingleShot(true);
networkChangeShowVisitorTimer.setInterval(3 * 1000);
Expand Down Expand Up @@ -504,11 +508,34 @@ void PhoneNetworkStatusIndicator::phoneNetworkChanged()
if (networkChangeShowVisitorTimer.isActive()) {
networkChangeShowVisitorTimer.stop();
}
QString home(homeNetwork());
QString visitor(visitorNetwork());

// Check whether limited service state displaying is enabled
bool limitedService = false;
bool displayLimitedServiceStateEnabled = displayLimitedServiceState->value(true).toBool();
if (displayLimitedServiceStateEnabled) {
// Limited service state should be displayed: Changes in the cellular service status are interesting
connect(cellularServiceStatus, SIGNAL(contentsChanged()), this, SLOT(phoneNetworkChanged()), Qt::UniqueConnection);

// Check if there is limited service
limitedService = cellularServiceStatus->value().toString() == "LimitedService";
} else {
// Limited service state should be displayed: Changes in the cellular service status are not interesting
disconnect(cellularServiceStatus, SIGNAL(contentsChanged()), this, SLOT(phoneNetworkChanged()));
}

QString home;
QString visitor;
if (limitedService) {
home = qtTrId("qtn_cell_emergency_calls_only");
model()->setStylePostfix("LimitedService");
} else {
home = homeNetwork();
visitor = visitorNetwork();
model()->setStylePostfix("");
}
setValue(home);

if(visitor.isEmpty() && home.isEmpty()) {
if (visitor.isEmpty() && home.isEmpty()) {
setStyleNameAndUpdate(QString(metaObject()->className()) + "Disabled");
} else {
setStyleNameAndUpdate(metaObject()->className());
Expand Down
3 changes: 3 additions & 0 deletions src/systemui/statusarea/statusindicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

class ApplicationContext;
class ContextItem;
class MGConfItem;

/*!
* StatusIndicator is a widget for displaying either image or text based status
Expand Down Expand Up @@ -367,6 +368,8 @@ private slots:

ContextItem *networkName;
ContextItem *extendedNetworkName;
ContextItem *cellularServiceStatus;
MGConfItem *displayLimitedServiceState;
QTimer networkChangeShowVisitorTimer;

#ifdef UNIT_TEST
Expand Down
16 changes: 10 additions & 6 deletions src/systemui/statusarea/statusindicatorlabelview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void StatusIndicatorLabelView::setupModel()
{
MWidgetView::setupModel();

label->setText(model()->value().toString());
updateData(QList<const char *>() << StatusIndicatorModel::Value << StatusIndicatorModel::StylePostfix);
}

void StatusIndicatorLabelView::updateData(const QList<const char *>& modifications)
Expand All @@ -58,12 +58,16 @@ void StatusIndicatorLabelView::updateData(const QList<const char *>& modificatio
foreach(member, modifications) {
if (strcmp(member, StatusIndicatorModel::Value) == 0) {
label->setText(model()->value().toString());
} else if (strcmp(member, MWidgetModel::StyleName) == 0) {
if (controller->styleName().contains("Landscape")) {
label->setStyleName("StatusIndicatorLabelLandscape");
} else if (controller->styleName().contains("Portrait")) {
label->setStyleName("StatusIndicatorLabelPortrait");
} else if (strcmp(member, StatusIndicatorModel::StylePostfix) == 0) {
QString prefix;
if (controller->objectName().contains("Landscape")) {
prefix = "StatusIndicatorLabelLandscape";
} else if (controller->objectName().contains("Portrait")) {
prefix = "StatusIndicatorLabelPortrait";
} else {
prefix = "StatusIndicatorLabel";
}
label->setStyleName(prefix + model()->stylePostfix());
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/systemui/statusarea/statusindicatorlabelview.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ protected slots:

//! A label for the text
MLabel *label;

#ifdef UNIT_TEST
friend class Ut_StatusIndicatorLabelView;
#endif
};

#endif // STATUSINDICATORLABELVIEW_H
1 change: 1 addition & 0 deletions src/systemui/statusarea/statusindicatormodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class StatusIndicatorModel : public MWidgetModel
M_MODEL(StatusIndicatorModel)
M_MODEL_PROPERTY(QVariant, value, Value, true, QVariant())
M_MODEL_PROPERTY(bool, animate, Animate, true, false)
M_MODEL_PROPERTY(QString, stylePostfix, StylePostfix, true, QString())
};

class PhoneNetworkSignalStrengthStatusIndicatorModel : public StatusIndicatorModel
Expand Down
1 change: 1 addition & 0 deletions src/systemui/sysuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ void Sysuid::loadTranslations()
locale.installTrCatalog("connectivity");
locale.installTrCatalog("volume");
locale.installTrCatalog("memory-usage");
locale.installTrCatalog("cellular-adaptation");

// and the engineering english ones
locale.installTrCatalog("systemui");
Expand Down
6 changes: 6 additions & 0 deletions tests/ut_statusareaview/ut_statusareaview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ void Ut_StatusAreaView::testSignalConnections()
QVERIFY(disconnect(&Sysuid::instance()->notificationStatusIndicatorSink(), SIGNAL(iconIdChanged(QString)), m_subject->portraitNotificationIndicator, SLOT(setIconID(QString))));
}

void Ut_StatusAreaView::testObjectNames()
{
QCOMPARE(m_subject->landscapePhoneNetworkIndicator->objectName(), QString("PhoneNetworkStatusIndicatorLandscape"));
QCOMPARE(m_subject->portraitPhoneNetworkIndicator->objectName(), QString("PhoneNetworkStatusIndicatorPortrait"));
}

void Ut_StatusAreaView::testStyleNamesFollowCallState()
{
QVERIFY(disconnect(m_subject->callContextItem, SIGNAL(contentsChanged()), m_subject, SLOT(setStyleNames())));
Expand Down
1 change: 1 addition & 0 deletions tests/ut_statusareaview/ut_statusareaview.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private slots:
void cleanup();

void testSignalConnections();
void testObjectNames();
void testStyleNamesFollowCallState();

private:
Expand Down
74 changes: 50 additions & 24 deletions tests/ut_statusindicator/ut_statusindicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <MApplication>
#include <MOnDisplayChangeEvent>
#include <MLocale>
#include <MGConfItem>
#include "ut_statusindicator.h"
#include "statusindicator.h"
#include "statusindicatoranimationview.h"
Expand Down Expand Up @@ -65,11 +66,13 @@ bool timerStarted = false;
void QTimer::start()
{
timerStarted = true;
id = 1;
}

void QTimer::stop()
{
timerStarted = false;
id = -1;
}

QString gMLocaleLanguage;
Expand All @@ -78,6 +81,17 @@ QString MLocale::language() const
return gMLocaleLanguage;
}

// MGConfItem stubs
QVariant mGConfItemValueForDisplayLimitedServiceState;
QVariant MGConfItem::value(const QVariant &def) const
{
if (key() == "/desktop/meego/status_area/display_limited_service_state") {
return QVariant(mGConfItemValueForDisplayLimitedServiceState.isNull() ? def : mGConfItemValueForDisplayLimitedServiceState);
}

return QVariant();
}

void Ut_StatusIndicator::init()
{
m_subject = NULL;
Expand All @@ -90,6 +104,7 @@ void Ut_StatusIndicator::cleanup()
{
delete m_subject;
delete testContext;
mGConfItemValueForDisplayLimitedServiceState = QVariant();
}

void Ut_StatusIndicator::initTestCase()
Expand Down Expand Up @@ -193,6 +208,7 @@ void Ut_StatusIndicator::testPhoneNetworkSignalStrenghtStyleName_data()
QTest::newRow("Empty registration status") << false << QString("") << QString("NoNetwork");
QTest::newRow("Offline registration status") << false << QString("offline") << QString("NoNetwork");
QTest::newRow("Forbidden registration status") << false << QString("forbidden") << QString("NoNetwork");
QTest::newRow("No-service registration status") << false << QString("no-service") << QString("NoNetwork");
QTest::newRow("Home registration status") << false << QString("home") << QString("");
QTest::newRow("Roam registration status") << false << QString("roam") << QString("");
}
Expand Down Expand Up @@ -534,19 +550,27 @@ void Ut_StatusIndicator::testPhoneNetwork_data() {
QTest::addColumn<QString>("visitor");
QTest::addColumn<QString>("language");
QTest::addColumn<QString>("extnetstring");

QTest::newRow("NoRoaming") << "F!o" << "F!o" << QString() << "" << "";
QTest::newRow("RoamingIdeal") << "foo (bar)" << "foo" << "bar" << "" << "";
QTest::newRow("MissingVisitor") << "F!o()" << "F!o" << QString() << "" << "";
QTest::newRow("MissingBoth") << QString() << QString() << QString() << "" << "";
QTest::newRow("HomeAndVisitorSame") << "foo (foo)" << "foo" << "foo" << "" << "";
QTest::newRow("NoStartDelimiter") << "foo bar)" << "foo bar)" << QString() << "" << "";
QTest::newRow("NoEndDelimiter") << "FoO(BaR1!" << "FoO" << QString() << "" << "";
QTest::newRow("RoamingExtraSpaces") << " f1o (bar) " << "f1o" << "bar" << "" << "";
QTest::newRow("RoamingExtraDelimiters") << "foo (()bar())" << "foo" << "()bar()" << "" << "";
QTest::newRow("ChineseLocale") << "foo" << "bar" << "" << "zh" << "bar";
QTest::newRow("ChineseLocaleNoExtNetString") << "foo" << "foo" << "" << "zh" << "";
QTest::newRow("ChineseLocaleVisitor") << "foo" << "bar" << "meh" << "zh" << "bar (meh)";
QTest::addColumn<QString>("servicestatus");
QTest::addColumn<QVariant>("displayLimitedServiceState");
QTest::addColumn<QString>("stylePostfix");

QTest::newRow("NoRoaming") << "F!o" << "F!o" << QString() << "" << "" << "FullService" << QVariant(true) << QString();
QTest::newRow("RoamingIdeal") << "foo (bar)" << "foo" << "bar" << "" << "" << "FullService" << QVariant(true) << QString();
QTest::newRow("MissingVisitor") << "F!o()" << "F!o" << QString() << "" << "" << "FullService" << QVariant(true) << QString();
QTest::newRow("MissingBoth") << QString() << QString() << QString() << "" << "" << "FullService" << QVariant(true) << QString();
QTest::newRow("HomeAndVisitorSame") << "foo (foo)" << "foo" << "foo" << "" << "" << "FullService" << QVariant(true) << QString();
QTest::newRow("NoStartDelimiter") << "foo bar)" << "foo bar)" << QString() << "" << "" << "FullService" << QVariant(true) << QString();
QTest::newRow("NoEndDelimiter") << "FoO(BaR1!" << "FoO" << QString() << "" << "" << "FullService" << QVariant(true) << QString();
QTest::newRow("RoamingExtraSpaces") << " f1o (bar) " << "f1o" << "bar" << "" << "" << "FullService" << QVariant(true) << QString();
QTest::newRow("RoamingExtraDelimiters") << "foo (()bar())" << "foo" << "()bar()" << "" << "" << "FullService" << QVariant(true) << QString();
QTest::newRow("ChineseLocale") << "foo" << "bar" << "" << "zh" << "bar" << "FullService" << QVariant(true) << QString();
QTest::newRow("ChineseLocaleNoExtNetString") << "foo" << "foo" << "" << "zh" << "" << "FullService" << QVariant(true) << QString();
QTest::newRow("ChineseLocaleVisitor") << "foo" << "bar" << "meh" << "zh" << "bar (meh)" << "FullService" << QVariant(true) << QString();
QTest::newRow("EmptyServiceStatus") << "F!o" << "F!o" << QString() << "" << "" << "" << QVariant(true) << QString();
QTest::newRow("NoCoverageServiceStatus") << "F!o" << "F!o" << QString() << "" << "" << "NoCoverage" << QVariant(true) << QString();
QTest::newRow("LimitedServiceServiceStatusLimitedServiceStateDisplayEnabled") << "foo (bar)" << qtTrId("qtn_cell_emergency_calls_only") << QString() << "" << "" << "LimitedService" << QVariant(true) << "LimitedService";
QTest::newRow("LimitedServiceServiceStatusLimitedServiceStateDisplayNotSet") << "foo (bar)" << qtTrId("qtn_cell_emergency_calls_only") << QString() << "" << "" << "LimitedService" << QVariant() << "LimitedService";
QTest::newRow("LimitedServiceServiceStatusLimitedServiceStateDisplayDisabled") << "F!o" << "F!o" << QString() << "" << "" << "LimitedService" << QVariant(false) << QString();
}

void Ut_StatusIndicator::testPhoneNetwork()
Expand All @@ -556,31 +580,33 @@ void Ut_StatusIndicator::testPhoneNetwork()
QFETCH(QString, visitor);
QFETCH(QString, language);
QFETCH(QString, extnetstring);
QFETCH(QString, servicestatus);
QFETCH(QVariant, displayLimitedServiceState);
QFETCH(QString, stylePostfix);

gMLocaleLanguage = language;
mGConfItemValueForDisplayLimitedServiceState = displayLimitedServiceState;

StatusIndicator *m_subject = new PhoneNetworkStatusIndicator(*testContext);

testContextItems["Cellular.NetworkName"]->setValue(QVariant(netstring));
testContextItems["Cellular.ExtendedNetworkName"]->setValue(QVariant(extnetstring));
testContextItems["Cellular.ServiceStatus"]->setValue(QVariant(servicestatus));
PhoneNetworkStatusIndicator* indicator = qobject_cast<PhoneNetworkStatusIndicator*>(m_subject);

// reconnect timer timeout and check that reconnection fails i.e. is already connected
bool disconnectSuccess = disconnect(&indicator->networkChangeShowVisitorTimer, SIGNAL(timeout()), indicator, SLOT(showVisitorNetworkName()));
QCOMPARE(disconnectSuccess, true);
// Check that the network change timer is connected
QCOMPARE(disconnect(&indicator->networkChangeShowVisitorTimer, SIGNAL(timeout()), indicator, SLOT(showVisitorNetworkName())), true);

// Check that registration status changes are interesting if limited service state display is enabled
QCOMPARE(disconnect(indicator->cellularServiceStatus, SIGNAL(contentsChanged()), indicator, SLOT(phoneNetworkChanged())), displayLimitedServiceState.isNull() ? true : displayLimitedServiceState.toBool());

// test methods
QCOMPARE(indicator->homeNetwork(), home);
QCOMPARE(indicator->visitorNetwork(), visitor);
// Check style postfix
QCOMPARE(m_subject->model()->stylePostfix(), stylePostfix);

// check if home network is visible at first
QCOMPARE(m_subject->model()->value(), QVariant(QString(home)));

if (home.isEmpty() && visitor.isEmpty() ) {
QVERIFY(((bool)m_subject->styleName().contains("Disabled")));
} else {
QVERIFY(!((bool)m_subject->styleName().contains("Disabled")));
}
QCOMPARE(((bool)m_subject->styleName().contains("Disabled")), home.isEmpty() && visitor.isEmpty());

if (home.isEmpty() || visitor.isEmpty() || (home == visitor)) {
// check if home or visitor empty or same, timer is not started
Expand Down
34 changes: 23 additions & 11 deletions tests/ut_statusindicatorlabelview/ut_statusindicatorlabelview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ StatusIndicatorModel *TestStatusIndicatorLabelView::getModel()
return model();
}

QString gMLabelText;
void MLabel::setText(const QString &text)
{
gMLabelText = text;
}

void Ut_StatusIndicatorLabelView::initTestCase()
{
static int argc = 1;
Expand All @@ -58,8 +52,6 @@ void Ut_StatusIndicatorLabelView::init()
controller = new StatusIndicator;
m_subject = new TestStatusIndicatorLabelView(controller);
controller->setView(m_subject);

gMLabelText.clear();
}

void Ut_StatusIndicatorLabelView::cleanup()
Expand All @@ -70,16 +62,36 @@ void Ut_StatusIndicatorLabelView::cleanup()
void Ut_StatusIndicatorLabelView::testLabelChanged()
{
m_subject->getModel()->setValue("newValue");
QCOMPARE(gMLabelText, QString("newValue"));
QCOMPARE(m_subject->label->text(), QString("newValue"));
}

void Ut_StatusIndicatorLabelView::testStylePostfixChanged()
{
controller->setObjectName("Test");
m_subject->getModel()->setStylePostfix("Postfix1");
QCOMPARE(m_subject->label->styleName(), QString("StatusIndicatorLabelPostfix1"));

controller->setObjectName("TestPortrait");
m_subject->getModel()->setStylePostfix("Postfix2");
QCOMPARE(m_subject->label->styleName(), QString("StatusIndicatorLabelPortraitPostfix2"));
}

void Ut_StatusIndicatorLabelView::testModelChanged()
{
controller->setObjectName("TestLandscape");
StatusIndicatorModel *m = new StatusIndicatorModel;
m->setValue("newValue");
m_subject->setModel(m);
QCOMPARE(gMLabelText, QString("newValue"));
}
QCOMPARE(m_subject->label->text(), QString("newValue"));
QCOMPARE(m_subject->label->styleName(), QString("StatusIndicatorLabelLandscape"));

controller->setObjectName("TestPortrait");
m = new StatusIndicatorModel;
m->setValue("anotherValue");
m->setStylePostfix("TestPostfix");
m_subject->setModel(m);
QCOMPARE(m_subject->label->text(), QString("anotherValue"));
QCOMPARE(m_subject->label->styleName(), QString("StatusIndicatorLabelPortraitTestPostfix"));
}

QTEST_APPLESS_MAIN(Ut_StatusIndicatorLabelView)
Loading

0 comments on commit 19f0b1b

Please sign in to comment.