summaryrefslogtreecommitdiff
path: root/src/login/LoginModel.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-01-24 20:19:19 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-01-24 20:19:19 (GMT)
commit97b35bc47059315d4138c8e0827842d2c03de152 (patch)
treefeaf7a8c018982ba9d7ca1b8e6e15294abfdfc84 /src/login/LoginModel.cpp
parent04488081d3fa0cd3dfb2939e5d902bc894df150d (diff)
downloadpowder-97b35bc47059315d4138c8e0827842d2c03de152.zip
powder-97b35bc47059315d4138c8e0827842d2c03de152.tar.gz
Various
Diffstat (limited to 'src/login/LoginModel.cpp')
-rw-r--r--src/login/LoginModel.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/login/LoginModel.cpp b/src/login/LoginModel.cpp
new file mode 100644
index 0000000..7940cf0
--- /dev/null
+++ b/src/login/LoginModel.cpp
@@ -0,0 +1,69 @@
+/*
+ * LoginModel.cpp
+ *
+ * Created on: Jan 24, 2012
+ * Author: Simon
+ */
+
+#include "LoginModel.h"
+
+LoginModel::LoginModel() {
+ // TODO Auto-generated constructor stub
+
+}
+
+void LoginModel::Login(string username, string password)
+{
+ statusText = "Logging in...";
+ loginStatus = false;
+ notifyStatusChanged();
+ LoginStatus status = Client::Ref().Login(username, password);
+ switch(status)
+ {
+ case LoginOkay:
+ statusText = "Logged in";
+ loginStatus = true;
+ break;
+ case LoginPasswordInvalid:
+ statusText = "Username or Password incorrect";
+ break;
+ case LoginUsernameInvalid:
+ statusText = "Username incorrect";
+ break;
+ case LoginBanned:
+ statusText = "Banned: " + Client::Ref().GetLastError();
+ break;
+ default:
+ statusText = "Error";
+ break;
+ }
+ notifyStatusChanged();
+}
+
+void LoginModel::AddObserver(LoginView * observer)
+{
+ observers.push_back(observer);
+}
+
+string LoginModel::GetStatusText()
+{
+ return statusText;
+}
+
+bool LoginModel::GetStatus()
+{
+ return loginStatus;
+}
+
+void LoginModel::notifyStatusChanged()
+{
+ for(int i = 0; i < observers.size(); i++)
+ {
+ observers[i]->NotifyStatusChanged(this);
+ }
+}
+
+LoginModel::~LoginModel() {
+ // TODO Auto-generated destructor stub
+}
+