From: Drew Fisher <drew.m.fisher@gmail.com>
Date: Thu, 7 Oct 2010 20:28:00 +0000 (-0700)
Subject: Make client speak the redefined protocol to the server correctly.
X-Git-Url: http://git.zarvox.org/%7Bwebsite%7D?a=commitdiff_plain;h=a4156d365e75e3b691a468a9e81d272303dd9367;p=shareboard.git

Make client speak the redefined protocol to the server correctly.

Also, force enum to remain consistent.
---

diff --git a/action.h b/action.h
index 9e25722..25ba717 100644
--- a/action.h
+++ b/action.h
@@ -12,13 +12,13 @@
 class Action {
 public:
 	enum Type {
-		INVALID,
-		UserJoin,
-		UserPart,
-		MouseMove,
-		DrawLine,
-		AddImage,
-		UserChat
+		INVALID=0,
+		UserJoin=1,
+		UserPart=2,
+		MouseMove=3,
+		DrawLine=4,
+		AddImage=5,
+		UserChat=6
 	};
 
 	Action();
diff --git a/connectionmanager.cpp b/connectionmanager.cpp
index db02dfe..0e4d498 100644
--- a/connectionmanager.cpp
+++ b/connectionmanager.cpp
@@ -40,9 +40,14 @@ void ConnectionManager::haveData() {
 		quint16 t = 0; // Type
 		QString timestring;
 		textstream >> mesgID >> userID >> timestring >> t;
+		qDebug() << "Read line:";
+		qDebug() << "\tmesgID: "<< mesgID;
+		qDebug() << "\tuserID: "<< userID;
+		qDebug() << "\ttime  : "<< timestring;
+		qDebug() << "\ttype  : "<< t;
 
 		// Validate input
-		QDateTime timestamp = QDateTime::fromString(timestring, "yyyy-MM-ddTHH-mm-ss.zzz");
+		QDateTime timestamp = QDateTime::fromString(timestring, "yyyy-MM-ddTHH:mm:ss.zzz");
 		if(mesgID == -1 || userID == -1 || !timestamp.isValid() ) {
 			qWarning() << "Received invalid message from server; discarding.";
 			continue;
@@ -69,6 +74,7 @@ void ConnectionManager::haveData() {
 				action->mesgID = mesgID;
 				action->userID = userID;
 				action->timestamp = timestamp;
+				qDebug() << "Update: got UserJoin:" << username << "joined";
 				break;
 				}
 			case Action::UserPart:
@@ -96,9 +102,8 @@ void ConnectionManager::haveData() {
 				}
 			case Action::DrawLine:
 				{
-				/*
 				act = new DrawLineAction();
-				action = static_cast<DrawLineAction*>(act);
+				DrawLineAction* action = static_cast<DrawLineAction*>(act);
 				int red = 0;
 				int green = 0;
 				int blue = 0;
@@ -110,6 +115,10 @@ void ConnectionManager::haveData() {
 					continue;
 				}
 				do {
+					qreal x = 0;
+					qreal y = 0;
+					textstream >> x >> y;
+					action->points.append(QPointF(x,y));
 					// some stuff with the points
 				} while(textstream.status() == QTextStream::Ok);
 				action->color = QColor::fromRgb(red, green, blue);
@@ -117,20 +126,26 @@ void ConnectionManager::haveData() {
 				action->mesgID = mesgID;
 				action->userID = userID;
 				action->timestamp = timestamp;
-				*/
 				break;
 				}
 			case Action::AddImage:
 				{
-				/*
 				act = new AddImageAction();
 				AddImageAction* action = static_cast<AddImageAction*>(act);
-				// do somethin with the top-left point
+				qreal x = 0;
+				qreal y = 0;
+				textstream >> x >> y;
+				action->topLeft = QPointF(x,y);
 				// handle reading image data as base64-encoded binary, bleah
+				QString im;
+				textstream >> im;
+				// im is a base64-encoded binary string.
+				
+
+
 				action->mesgID = mesgID;
 				action->userID = userID;
 				action->timestamp = timestamp;
-				*/
 				break;
 				}
 			case Action::UserChat:
@@ -165,7 +180,7 @@ void ConnectionManager::haveData() {
 void ConnectionManager::onConnect() {
 	qDebug() << "connection established";
 	emit connected();
-	(*textStream) << "0 0 0 2 " << username << endl;
+	(*textStream) << "0 0 0 1 " << username << endl;
 	qDebug() << "sent JoinAction";
 }