| 1 |
/* Copyright (C) 2016 - 2017 Dan Chapman <[email protected]> |
| 2 |
|
| 3 |
This file is part of Dekko email client for Ubuntu devices |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU General Public License as |
| 7 |
published by the Free Software Foundation; either version 2 of |
| 8 |
the License or (at your option) version 3 |
| 9 |
|
| 10 |
This program is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License |
| 16 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
import QtQuick 2.4 |
| 19 |
import QuickFlux 1.0 |
| 20 |
import Dekko.Mail 1.0 |
| 21 |
import Dekko.Mail.API 1.0 |
| 22 |
|
| 23 |
// Error manager is responsible for listening for and ordering display of error messages |
| 24 |
// from the Client and other dispatched error actions. |
| 25 |
Item { |
| 26 |
|
| 27 |
Connections { |
| 28 |
target: Client |
| 29 |
onClientError: { |
| 30 |
Log.logError("ErrorManager::clientError", "Houston we have a problem!!") |
| 31 |
switch(error) { |
| 32 |
case Client.NoError: |
| 33 |
Log.logError("ErrorManager::NoError", "Few! false alarm. Displaying a toast if there is an error string") |
| 34 |
if (errorString != "") { |
| 35 |
ViewActions.orderSimpleToast(ViewKeys.toastMainWindow, errorString) |
| 36 |
} |
| 37 |
break |
| 38 |
case Client.FrameworkFault: |
| 39 |
Log.logError("ErrorManager::FrameworkFault", "We have a framework fault: " + errorString) |
| 40 |
// shout loudly |
| 41 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 42 |
break |
| 43 |
case Client.SystemError: |
| 44 |
Log.logError("ErrorManager::SystemError", "We have a system fault: " + errorString) |
| 45 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 46 |
break |
| 47 |
case Client.InternalServerError: |
| 48 |
Log.logError("ErrorManager::InternalServerError", "Error in the remote server: " + errorString) |
| 49 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 50 |
break |
| 51 |
case Client.UnexpectedResponse: |
| 52 |
Log.logError("ErrorManager::UnexpectedResponse", "Unexpected response received: " + errorString) |
| 53 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 54 |
break |
| 55 |
case Client.LoginFailed: |
| 56 |
Log.logError("ErrorManager::LoginFailed", "Login failed, maybe check credentials??: " + errorString) |
| 57 |
// TODO: show a special login failed dialog with some advice to check credentials. |
| 58 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 59 |
break |
| 60 |
case Client.CancelError: |
| 61 |
Log.logError("ErrorManager::CancelError", "Cancelation error " + errorString) |
| 62 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 63 |
break |
| 64 |
case Client.FileSystemFull: |
| 65 |
Log.logError("ErrorManager::FileSystemFull", "File system is full, time to free up some space me thinks: " + errorString) |
| 66 |
// TODO: once we have the cache pruner should we offer to prune old messages to free up some space? |
| 67 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 68 |
break |
| 69 |
case Client.MessageNotExist: |
| 70 |
Log.logError("ErrorManager::MessageNotExist", "Message doesn't exist, maybe it got removed/moved on the server and we didn't find out: " + errorString) |
| 71 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 72 |
break |
| 73 |
case Client.EnqueueFailed: |
| 74 |
Log.logError("ErrorManager::EnqueueFailed", "Failed to enqueue: " + errorString) |
| 75 |
break |
| 76 |
case Client.NoConnection: |
| 77 |
Log.logError("ErrorManager::NoConnection", errorString) |
| 78 |
ViewActions.orderSimpleToast(ViewKeys.toastMainWindow, qsTr("No connection")) |
| 79 |
break |
| 80 |
case Client.ConnectionInUse: |
| 81 |
Log.logError("ErrorManager::ConnectionInUse", errorString) |
| 82 |
ViewActions.orderSimpleToast(ViewKeys.toastMainWindow, qsTr("No connection")) |
| 83 |
break |
| 84 |
case Client.ConnectionNotReady: |
| 85 |
Log.logError("ErrorManager::ConnectionNotReady", errorString) |
| 86 |
ViewActions.orderSimpleToast(ViewKeys.toastMainWindow, qsTr("Connection unavailable")) |
| 87 |
break |
| 88 |
case Client.ConfigurationError: |
| 89 |
Log.logError("ErrorManager::ConfigurationError", errorString) |
| 90 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 91 |
break |
| 92 |
case Client.InvalidAddress: |
| 93 |
Log.logError("ErrorManager::InvalidAddress", errorString) |
| 94 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 95 |
break |
| 96 |
case Client.InvalidData: |
| 97 |
Log.logError("ErrorManager::invalidData", errorString) |
| 98 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 99 |
break |
| 100 |
case Client.TimeoutError: |
| 101 |
Log.logError("ErrorManager::TimoutError", errorString); |
| 102 |
ViewActions.orderSimpleToast(ViewKeys.toastMainWindow, qsTr("Action timed out")) |
| 103 |
break |
| 104 |
case Client.InternalStateReset: |
| 105 |
Log.logError("ErrorManager::InternalStateReset", errorString) |
| 106 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 107 |
break |
| 108 |
case Client.SslNotSupported: |
| 109 |
Log.logError("ErrorManager::SslNotSupported", errorString) |
| 110 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 111 |
break |
| 112 |
case Client.UntrustedCertificate: |
| 113 |
Log.logError("ErrorManager::UntrustedCertificate", errorString) |
| 114 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 115 |
break |
| 116 |
case Client.UnknownError: |
| 117 |
Log.logError("ErrorManager::UnknownError", errorString) |
| 118 |
PopupActions.showError(PopupKeys.popupMainWindow, errorString) |
| 119 |
break |
| 120 |
} |
| 121 |
} |
| 122 |
} |
| 123 |
} |