Commit 672b11fb authored by Linus Jahn's avatar Linus Jahn Committed by Jonah Brüchert

Use passive notifications when online actions fail

This will throw a Kirigami passive notification, whenever you try to add or
remove a contact or send a message when being offline. It uses the "long" preset
for the timeout.
parent 855bc84f
...@@ -190,29 +190,32 @@ quint8 Kaidan::getDisconnReason() const ...@@ -190,29 +190,32 @@ quint8 Kaidan::getDisconnReason() const
void Kaidan::sendMessage(QString jid, QString message) void Kaidan::sendMessage(QString jid, QString message)
{ {
// TODO: Add offline message cache if (client->isConnected()) {
if (client->isConnected())
emit client->sendMessageRequested(jid, message); emit client->sendMessageRequested(jid, message);
else } else {
qWarning() << "[main] Couldn't send message, because not being connected."; emit passiveNotificationRequested(tr("Could not send message, because not being connected."));
qWarning() << "[main] Could not send message, because not being connected.";
}
} }
void Kaidan::addContact(QString jid, QString nick) void Kaidan::addContact(QString jid, QString nick)
{ {
// TODO: Add an error notification/message if not connected if (client->isConnected()) {
if (client->isConnected())
emit client->addContactRequested(jid, nick); emit client->addContactRequested(jid, nick);
else } else {
qWarning() << "[main] Couldn't add contact, because not being connected."; emit passiveNotificationRequested(tr("Could not add contact, because not being connected."));
qWarning() << "[main] Could not add contact, because not being connected.";
}
} }
void Kaidan::removeContact(QString jid) void Kaidan::removeContact(QString jid)
{ {
// TODO: Add an error notification/message if not connected if (client->isConnected()) {
if (client->isConnected())
emit client->removeContactRequested(jid); emit client->removeContactRequested(jid);
else } else {
qWarning() << "[main] Couldn't remove contact, because not being connected."; emit passiveNotificationRequested(tr("Could not remove contact, because not being connected."));
qWarning() << "[main] Could not remove contact, because not being connected.";
}
} }
QString Kaidan::getResourcePath(QString name) const QString Kaidan::getResourcePath(QString name) const
...@@ -240,7 +243,7 @@ QString Kaidan::getResourcePath(QString name) const ...@@ -240,7 +243,7 @@ QString Kaidan::getResourcePath(QString name) const
return QString("file://") + directory.absoluteFilePath(name); return QString("file://") + directory.absoluteFilePath(name);
} }
} }
// on Android, we want to fetch images from the application resources // on Android, we want to fetch images from the application resources
if (QFile::exists(":/" + name)) if (QFile::exists(":/" + name))
return QString("qrc:/" + name); return QString("qrc:/" + name);
......
...@@ -303,6 +303,11 @@ signals: ...@@ -303,6 +303,11 @@ signals:
*/ */
void logInWorked(); void logInWorked();
/**
* Show passive notification
*/
void passiveNotificationRequested(QString text);
private: private:
void connectDatabases(); void connectDatabases();
......
...@@ -71,6 +71,10 @@ Kirigami.ApplicationWindow { ...@@ -71,6 +71,10 @@ Kirigami.ApplicationWindow {
Component {id: loginPage; LoginPage {}} Component {id: loginPage; LoginPage {}}
Component {id: rosterPage; RosterPage {}} Component {id: rosterPage; RosterPage {}}
function passiveNotification(text) {
showPassiveNotification(text, "long")
}
function openLogInPage() { function openLogInPage() {
// close all pages (we don't know on which page we're on, // close all pages (we don't know on which page we're on,
// thus we don't use replace) // thus we don't use replace)
...@@ -93,8 +97,9 @@ Kirigami.ApplicationWindow { ...@@ -93,8 +97,9 @@ Kirigami.ApplicationWindow {
} }
Component.onCompleted: { Component.onCompleted: {
kaidan.newCredentialsNeeded.connect(openLogInPage); kaidan.passiveNotificationRequested.connect(passiveNotification)
kaidan.logInWorked.connect(closeLogInPage); kaidan.newCredentialsNeeded.connect(openLogInPage)
kaidan.logInWorked.connect(closeLogInPage)
// push roster page (trying normal start up) // push roster page (trying normal start up)
pageStack.push(rosterPage) pageStack.push(rosterPage)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment