You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bluesky-commits@incubator.apache.org by ma...@apache.org on 2010/12/14 01:35:56 UTC

svn commit: r1048897 - /incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/

Author: mabowen
Date: Tue Dec 14 01:35:55 2010
New Revision: 1048897

URL: http://svn.apache.org/viewvc?rev=1048897&view=rev
Log:
current student source code, gradually add protocol now.

Added:
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/CommClient.pro
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/CommClient.pro.user
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/Message.cpp
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/Message.h
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/clientsocket.cpp
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/clientsocket.h
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/commevent.cpp
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/commevent.h
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/main.cpp
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.cpp
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.h
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.ui
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/msgagent.cpp
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/msgagent.h
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/protocol.h
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/qthreadex.h
    incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/ui_mainwindow.h

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/CommClient.pro
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/CommClient.pro?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/CommClient.pro (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/CommClient.pro Tue Dec 14 01:35:55 2010
@@ -0,0 +1,28 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-11-30T20:24:50
+#
+#-------------------------------------------------
+
+QT       += core gui network xml
+
+TARGET = CommClient
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+        mainwindow.cpp \
+    msgagent.cpp \
+    commevent.cpp \
+    clientsocket.cpp \
+    Message.cpp
+
+HEADERS  += mainwindow.h \
+    protocol.h \
+    msgagent.h \
+    commevent.h \
+    clientsocket.h \
+    qthreadex.h \
+    Message.h
+
+FORMS    += mainwindow.ui

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/CommClient.pro.user
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/CommClient.pro.user?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/CommClient.pro.user (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/CommClient.pro.user Tue Dec 14 01:35:55 2010
@@ -0,0 +1,113 @@
+<!DOCTYPE QtCreatorProject>
+<qtcreator>
+ <data>
+  <variable>ProjectExplorer.Project.ActiveTarget</variable>
+  <value type="int">0</value>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.EditorSettings</variable>
+  <valuemap type="QVariantMap">
+   <value key="EditorConfiguration.Codec" type="QByteArray">System</value>
+  </valuemap>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.Target.0</variable>
+  <valuemap type="QVariantMap">
+   <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Desktop</value>
+   <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.DesktopTarget</value>
+   <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">0</value>
+   <value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
+   <valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
+    <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
+     <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
+     <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
+     <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
+    </valuemap>
+    <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
+     <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+     <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+     <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
+     <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
+     <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+    </valuemap>
+    <value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
+    <valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
+     <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+     <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+     <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
+     <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+      <value type="QString">clean</value>
+     </valuelist>
+     <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+    </valuemap>
+    <value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
+    <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
+    <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+    <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Debug</value>
+    <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">E:/Qt/2010.04/qt/examples/CommClientUi/CommClient-build-desktop</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">2</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">2</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
+   </valuemap>
+   <valuemap key="ProjectExplorer.Target.BuildConfiguration.1" type="QVariantMap">
+    <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
+     <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
+     <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
+     <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
+    </valuemap>
+    <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
+     <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+     <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+     <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
+     <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
+     <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+    </valuemap>
+    <value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
+    <valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
+     <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+     <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+     <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
+     <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+      <value type="QString">clean</value>
+     </valuelist>
+     <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+    </valuemap>
+    <value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
+    <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
+    <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+    <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Release</value>
+    <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">E:/Qt/2010.04/qt/examples/CommClientUi/CommClient-build-desktop</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">2</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">2</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
+   </valuemap>
+   <value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">2</value>
+   <valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
+    <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">CommClient</value>
+    <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
+    <value key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase" type="int">2</value>
+    <valuelist key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments" type="QVariantList"/>
+    <value key="Qt4ProjectManager.Qt4RunConfiguration.ProFile" type="QString">CommClient.pro</value>
+    <value key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix" type="bool">false</value>
+    <value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">false</value>
+    <valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+    <value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetName" type="bool">false</value>
+    <value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetWorkingDirectory" type="bool">false</value>
+    <value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString"></value>
+   </valuemap>
+   <value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
+  </valuemap>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.TargetCount</variable>
+  <value type="int">1</value>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
+  <value type="int">4</value>
+ </data>
+</qtcreator>

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/Message.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/Message.cpp?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/Message.cpp (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/Message.cpp Tue Dec 14 01:35:55 2010
@@ -0,0 +1,382 @@
+//////////////////////////////////////////////////////////////////////
+// 文件名:Message.cpp
+//
+// 功 能:XML格式的文本通信消息的封装和解析(源文件)
+//
+// 版 本:1.0
+//
+// 作 者:林杰
+//
+// 最近修改日期:2007-09-18
+//////////////////////////////////////////////////////////////////////
+
+#include "Message.h"
+
+#ifdef _DEBUG
+#undef THIS_FILE
+static char THIS_FILE[]=__FILE__;
+#define new DEBUG_NEW
+#endif
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+// 构造函数
+// 初始化各个成员变量
+QMessage::QMessage()
+{
+	//消息的版本和字符集信息
+	strText = "<?xml version=\"1.0\" encoding=\"GB2312\" ?>";
+	strCmd = "NULL";
+	strID = "NULL";
+	strName = "NULL";
+	strType = "NULL";
+	bIsCrypt = false;
+	bIsCompress = false;
+	strCreateDate = "NULL";	
+	bHasBody = false;
+}
+
+// 析构函数
+// 释放存储包体所占的Map树的空间
+QMessage::~QMessage()
+{
+}
+
+//设置消息号
+void QMessage::SetCmd(LPCTSTR pa)
+{	
+	strCmd = pa;
+}
+
+//亩发送者ID
+void QMessage::SetID(LPCTSTR pa)
+{	
+	strID = pa;
+}
+
+//设置发送者用户名
+void QMessage::SetName(LPCTSTR pa)
+{	
+	strName = pa;
+}
+
+//设置发送者类型
+void QMessage::SetType(LPCTSTR pa)
+{	
+	strType = pa;
+}
+
+//设置是否加密码
+void QMessage::SetCrypt(bool pa)
+{	
+	bIsCrypt = pa;
+}
+
+//设置是否压缩
+void QMessage::SetCompress(bool pa)
+{	
+	bIsCompress = pa;
+}
+
+//设置日期
+void QMessage::SetCreateDate(LPCTSTR pa)
+{	
+	strCreateDate = pa;
+}
+
+//设置是否有包体
+void QMessage::SetHasBody(bool pa)
+{	
+	if(pa)
+		bHasBody = true;
+	else bHasBody = false;
+}
+
+//设置包体指针所指向的 Map树的树根
+void QMessage::SetBody(QMap<QString,QVariant> pa)
+{	
+	if(!pa.isEmpty())
+    {
+		bHasBody = true;
+		pBodyMap = pa;
+	}
+}
+
+//判断是否是str开头的简单字符串节点
+bool QMessage::IsStringNode(QString strNodeName)
+{
+	if (strNodeName.toLower().left(3)=="str")
+		return true;
+	else return false;
+}
+
+//判断是否是lst开头的复杂节点
+bool QMessage::IsListNode(QString strNodeName)
+{
+	//strNodeName.MakeLower();
+	if (strNodeName.toLower().left(3)=="lst")
+		return true;
+	else return false;
+}
+
+//把Map对象及其以下的树转换成Markup中的一系列节点 (递归函数)
+void QMessage::MapToMarkup(QMap<QString,QVariant> &ChildMap){
+	QMap<QString,QVariant>::iterator iter;
+	QMap<QString,QVariant> list1;
+	QString key;
+	QString temp;
+    QDomElement root = nowroot;
+    for(iter = ChildMap.begin(); iter != ChildMap.end(); iter++)
+    {
+    	key=iter.key();
+    	cout<<key.toStdString()<<":";
+    	//如果 该节点是复杂的列表节点, 递归调用该函数来释放对象空间
+    	if( IsListNode(key) )
+    	{
+    		list1=iter.value().toMap();
+    		QDomElement element= doc.createElement(key);
+    		nowroot.appendChild(element);
+    		nowroot=element;
+   			MapToMarkup(list1);
+    		nowroot=root;
+    	}
+    	//如果是简单的文本节点,则读取名称和文本内容
+    	else if(IsStringNode(key))
+    	{
+    		temp =iter.value().toString();
+    		cout<<temp.toStdString()<<endl;
+    		QDomElement element= doc.createElement(key);
+    		QDomText text = doc.createTextNode(temp);
+    		element.appendChild(text);
+    		nowroot.appendChild(element);
+    	}
+    }
+}
+
+//把markup中当前的复杂结点加入childmap
+//这是一个递归函数,递归搜索CMarkup中的各个树结点
+void QMessage::MarkupToMap(QMap<QString,QVariant> &ChildMap)
+{
+    QMap<QString,QVariant> mapNode;
+    QString qsNode;
+	if(nowroot.isNull()){
+		nowroot=doc.documentElement();
+	}
+    QDomNode n = nowroot.firstChild();
+    while(!n.isNull()) {
+        QDomElement e = n.toElement(); // try to convert the node to an element.
+        if(!e.isNull()) {
+        	if(e.firstChild().isText())
+			{//简单节点
+				qsNode=e.text();
+				ChildMap.insert(e.tagName(),qsNode);
+				cout<<e.tagName().toStdString()<<":"<<e.text().toStdString()<<endl;
+			}
+        	else
+			{
+				mapNode=QMap<QString,QVariant>();
+				ChildMap.insert(e.tagName(),mapNode);
+				cout<<e.tagName().toStdString()<<endl;
+				nowroot=e;
+	        	MarkupToMap(ChildMap);
+			}
+        }
+        n = n.nextSibling();
+    }
+}
+
+
+//封装一个消息到字符串。
+//如果Url为空,则只返回封装后消息字符串;
+//如果Url指定确定值,则还要把消息内容存到该Url指定的文本文件。
+QString& QMessage::CreateMsg(LPCTSTR Url)
+{
+	QString strTemp;
+	QDomElement head;
+	QDomElement temp;
+	//TODO 需要重构
+	nowroot=doc.createElement("Message");
+	doc.appendChild(nowroot);
+	head=doc.createElement("Head");
+	nowroot.appendChild(head);
+	temp=doc.createElement("Cmd");
+	head.appendChild(temp);
+	temp.appendChild(doc.createTextNode(strCmd));
+	temp=doc.createElement("ID");
+	head.appendChild(temp);
+	temp.appendChild(doc.createTextNode(strID));
+	temp=doc.createElement("Name");
+	head.appendChild(temp);
+	temp.appendChild(doc.createTextNode(strName));
+	temp=doc.createElement("Type");
+	head.appendChild(temp);
+	temp.appendChild(doc.createTextNode(strType));
+	temp=doc.createElement("IsCrypt");
+	head.appendChild(temp);
+	temp.appendChild(doc.createTextNode(bIsCrypt ? "true":"false"));
+	temp=doc.createElement("IsCompress");
+	head.appendChild(temp);
+	temp.appendChild(doc.createTextNode(bIsCompress ? "true":"false"));
+	temp=doc.createElement("CreateDate");
+	head.appendChild(temp);
+	temp.appendChild(doc.createTextNode(strCreateDate));
+	temp=doc.createElement("HasBody");
+	head.appendChild(temp);
+	temp.appendChild(doc.createTextNode(bHasBody ? "true":"false"));
+	
+	//如果标志指示有包体内容,且包体内容指针不为空,则读取其内容
+	if(bHasBody && !pBodyMap.isEmpty())
+	{
+		QDomElement body=doc.createElement("Body");
+		doc.appendChild(body);
+		nowroot=body;
+		MapToMarkup(pBodyMap);
+	}
+	strText=doc.toString();
+#ifdef _DEBUG
+	//如果有Url参数,则把消息内容保存到其指定的位置
+//	if(Url)	doc->Save(Url);
+
+	strText += doc->GetDoc();
+#endif
+	return strText;
+}
+
+//获取消息号
+QString QMessage::GetCmd()
+{
+	return strCmd;
+}
+
+//亩发送者ID
+QString QMessage::GetID()
+{
+	return strID;
+}
+
+//获取发送者用户名
+QString QMessage::GetName()
+{
+	return strName;
+}
+
+//获取发送者类型
+QString QMessage::GetType()
+{
+	return strType;
+}
+
+//获取是否加密码
+bool QMessage::IsCrypt()
+{
+	return bIsCrypt;
+}
+
+//获取是否压缩
+bool QMessage::IsCompress()
+{
+	return bIsCompress;
+}
+
+//获取日期
+QString QMessage::GetCreateDate()
+{
+	return strCreateDate;
+}
+
+//获取是否有包体
+bool QMessage::HasBody()
+{
+	return bHasBody;
+}
+
+//获取包体指针所指向的 Map树的树根
+QMap<QString,QVariant>  QMessage::GetBody()
+{
+	return pBodyMap;
+}
+
+//解析文本消息,把各个消息内容存入相对的变量
+bool QMessage::ParseMsg(LPCTSTR msg, int file)//
+{
+	strText = QString(msg);
+	//如果调用函数时有file参数,从文件载入XML消息。
+	if(file){
+		QFile file(msg);
+		if (!file.open(QFile::ReadOnly | QFile::Text)) {
+			return false;
+		}
+		QString errorStr;
+		int errorLine;
+		int errorColumn;
+
+		if (!doc.setContent(&file, false, &errorStr, &errorLine, &errorColumn)) {
+			return false;
+		}
+		file.close();
+	}
+	else doc.setContent(QString(msg));
+	//如果调用函数时没有file参数,从字符串载入XML消息。
+	nowroot=doc.documentElement();
+	if(!doc.elementsByTagName("Message").isEmpty())
+	{
+		//解析消息包头部分,把消息头的各个子内容放入相应变量
+		if(!doc.elementsByTagName("Head").isEmpty())
+		{
+			//TODO 需要重构
+			//进入包头
+			if(!doc.elementsByTagName("Cmd").isEmpty())
+			{
+				strCmd = doc.elementsByTagName("Cmd").at(0).toElement().text();
+			}
+			if(!doc.elementsByTagName("ID").isEmpty())
+			{
+				strID = doc.elementsByTagName("ID").at(0).toElement().text();
+			}
+			if(!doc.elementsByTagName("Name").isEmpty())
+			{
+				strName = doc.elementsByTagName("Name").at(0).toElement().text();
+			}
+			if(!doc.elementsByTagName("Type").isEmpty())
+			{
+				strType = doc.elementsByTagName("Type").at(0).toElement().text();
+			}
+			if(!doc.elementsByTagName("IsCrypt").isEmpty())
+			{
+				if(doc.elementsByTagName("IsCrypt").at(0).toElement().text() == "true")
+					bIsCrypt = true;
+				else bIsCrypt = false;
+			}
+			if(!doc.elementsByTagName("IsCompress").isEmpty())
+			{
+				if(doc.elementsByTagName("IsCompress").at(0).toElement().text() == "true")
+					bIsCompress = true;
+				else bIsCompress = false;
+			}
+			if(!doc.elementsByTagName("CreateDate").isEmpty())
+			{
+				strCreateDate = doc.elementsByTagName("CreateDate").at(0).toElement().text();
+			}
+			if(!doc.elementsByTagName("HasBody").isEmpty())
+			{
+				QString temp;
+				temp = doc.elementsByTagName("HasBody").at(0).toElement().text();
+				if(temp == "true")
+					bHasBody = true;
+				else bHasBody = false;
+			}
+			//退出包头
+		}
+		//如果有包体,则根据包体的树结构创建一棵由QMap<QString,QVariant>对象构成的包体树,并把根指针赋给BodyMap
+		if(bHasBody)//HasBody
+		{
+			nowroot=doc.elementsByTagName("Body").at(0).toElement();
+			pBodyMap = QMap<QString,QVariant>();
+			MarkupToMap(pBodyMap);
+		}
+	}
+	return true;
+
+}

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/Message.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/Message.h?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/Message.h (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/Message.h Tue Dec 14 01:35:55 2010
@@ -0,0 +1,120 @@
+//////////////////////////////////////////////////////////////////////
+// 文件名:Message.h
+//
+// 功 能:XML格式的文本通信消息的封装和解析(头文件)
+//
+// 版 本:1.0
+//
+// 作 者:林杰
+//
+// QT版本:0.2
+//
+// 作 者:魏广程
+//
+// 最近修改日期:2010-11-17
+//////////////////////////////////////////////////////////////////////
+
+#if !defined(AFX_MESSAGE_H__0AB58702_913F_4B17_9788_C79DE8DDDD5C__INCLUDED_)
+#define AFX_MESSAGE_H__0AB58702_913F_4B17_9788_C79DE8DDDD5C__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+#ifdef _UNICODE
+	typedef const wchar_t * LPCTSTR;
+#else
+	typedef const char * LPCTSTR;
+#endif
+
+#include <QMap>
+#include <QVariant>
+#include <QString>
+#include <QFile>
+#include <QDomDocument>
+#include <iostream>
+	using namespace std;
+//#include "Markup.h"
+
+//模块通信消息类
+class QMessage
+{
+public:
+	QMessage();
+	~QMessage();
+
+public:	
+
+	//封装XML协议消息的方法
+	//设置消息号
+	void SetCmd(LPCTSTR pa);
+	//设置发送方ID
+	void SetID(LPCTSTR pa);
+	//设置发送方用户名
+	void SetName(LPCTSTR pa);
+	//设置发送方类型
+	void SetType(LPCTSTR pa);
+	//设置是否加密
+	void SetCrypt(bool pa);
+	//设置是否压缩
+	void SetCompress(bool pa);	
+	//设置创建日期
+	void SetCreateDate(LPCTSTR pa);	
+	//设置是否有包体标志
+	void SetHasBody(bool pa);
+	//设置包体指针
+	void SetBody(QMap<QString,QVariant> pa);
+	//封装一个消息到字符串。
+	//如果Url为空,则只返回封装后消息字符串;
+	//如果Url指定确定值,则还要把消息内容存到该Url指定的文本文件。
+	QString& CreateMsg(LPCTSTR Url = NULL);
+
+
+	//解析XML协议消息的方法
+	//如果调用此函数时只带一个字符串参数,则解析该字符串;
+	//如果想解析一个文本文件,则第一个参数为文件路径,第二个为1
+	bool ParseMsg(LPCTSTR msg, int file=0);//
+	//获取消息号
+	QString GetCmd();
+	//获取消息发送方ID
+	QString GetID();
+	//获取消息发送方用户名
+	QString GetName();
+	//获取发送方类型
+	QString GetType();
+	//获取是否加密
+	bool IsCrypt();
+	//获取是否压缩
+	bool IsCompress();	
+	//获取创建日期
+	QString GetCreateDate();
+	//获取是否有包体标志
+	bool HasBody();
+	//获取消息包体指针
+	QMap<QString,QVariant> GetBody();
+
+
+
+
+private:
+	QDomDocument doc;		//XML解析转换类Markup对象指针
+	QDomElement nowroot;
+	QString strCmd;			//map<QString,void *>消息编号
+	QString strID;			//发送方ID
+	QString strName;		//发送方用户名
+	QString strType;		//发送方类型
+	QString strText;		//消息文本
+	bool bIsCrypt;			//是否加密
+	bool bIsCompress;		//是否压缩
+	QString strCreateDate;	//创建日期
+	bool bHasBody;			//是否有包体信息标志
+	QMap<QString,QVariant> pBodyMap;	//包体内容指针
+        void MapToMarkup(QMap<QString,QVariant> &ChildMap);
+        void MarkupToMap(QMap<QString,QVariant> &ChildMap);
+
+
+	bool IsStringNode(QString strNodeName);
+	bool IsListNode(QString strNodeName);
+
+};
+
+#endif // !defined(AFX_MESSAGE_H__0AB58702_913F_4B17_9788_C79DE8DDDD5C__INCLUDED_)

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/clientsocket.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/clientsocket.cpp?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/clientsocket.cpp (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/clientsocket.cpp Tue Dec 14 01:35:55 2010
@@ -0,0 +1,130 @@
+
+#include <QCoreApplication>
+#include "clientsocket.h"
+#include "commevent.h"
+#include <iostream>
+
+
+
+ClientSocket::ClientSocket(QObject* pmsgagent,QObject * parent)
+    :QTcpSocket(parent),
+    nextMessageSize(0),
+    m_pmsgagent(pmsgagent)
+{
+    connect(this, SIGNAL(readyRead()), this, SLOT(readClient()));
+    connect(this, SIGNAL(disconnected()), this, SLOT(clientDisconnect()));
+    connect(this, SIGNAL(error(QAbstractSocket::SocketError)),
+            this, SLOT(gotError()));
+
+    //connect(this,SIGNAL(onReceived(char*)),m_pmsgserver,SLOT(onReceived(char*)));
+}
+
+ClientSocket::~ClientSocket()
+{
+    delete m_pmsgagent;
+}
+
+void ClientSocket::readClient()
+{
+    //get the total length of the msg
+    char head[8];
+    memset(head, 0, 8);
+    if(read(head, 8) == -1)
+    {
+        return;
+    }
+    int totallength = atoi(head);
+
+    char recvbuffer[10000];
+    memset(recvbuffer, 0, 10000);
+    //where to write
+    int index = 0;
+    //each time how many chars reved
+    int recvlength = 0;
+    //
+    int torecvlength = totallength - 8;
+
+    do
+    {
+        recvlength = read(recvbuffer+index, torecvlength);
+        if(recvlength == -1)
+        {
+            return;
+        }
+        index += recvlength;
+        torecvlength -= recvlength;
+    }
+    while(torecvlength != 0);
+
+    CommEvent* ce = new CommEvent(SkyClass::GotMessage,
+                                  new QString(recvbuffer));
+    QCoreApplication::postEvent(m_pmsgagent,ce);
+}
+
+
+void ClientSocket::clientDisconnect()
+{
+//    CommEvent* ce = new CommEvent(SkyClass::ClientDisconnect,
+//                                  0);
+   CommEvent* ce = new CommEvent(SkyClass::ClientDisconnect,
+                                  new QString("client log out!"));
+    QCoreApplication::postEvent(m_pmsgagent,ce);
+}
+
+void ClientSocket::gotError()
+{
+    this->error();
+    if(this->error() != QTcpSocket::RemoteHostClosedError)
+    {
+        clientDisconnect();
+    }
+}
+
+void ClientSocket::Connect(QString* pip,int port)
+{
+    this->connectToHost(*pip, port);
+}
+void ClientSocket::Send(QString* msg)
+{
+    char strmsg[10000];
+    memset(strmsg, 0, 10000);
+    sprintf(strmsg,"%08d%s",msg->length()+8,msg->toLatin1().data());
+    this->write(strmsg);
+}
+void ClientSocket::DisConnect()
+{
+    this->disconnectFromHost();
+}
+
+bool ClientSocket::event(QEvent * event)
+{
+    if(event->type() == QEvent::User)
+    {
+        CommEvent * ue = static_cast<CommEvent *>(event);
+        switch(ue->commType)
+        {
+        case SkyClass::DoConnect:
+            Connect(ue->m_pMsg,ue->m_n);
+            delete ue->m_pMsg;
+            break;
+        case SkyClass::SendMessage:
+            Send(ue->m_pMsg);
+            delete ue->m_pMsg;
+            break;
+            //add by kevin
+        case SkyClass::DoDisconnect:
+            Send(ue->m_pMsg);
+            this->DisConnect();
+            delete ue->m_pMsg;
+            std::cout << "client disconnect!" << std::endl;
+            break;
+        default:
+            return false;
+        }
+    }
+    else
+    {
+        return QObject::event(event);
+    }
+    return true;
+}

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/clientsocket.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/clientsocket.h?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/clientsocket.h (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/clientsocket.h Tue Dec 14 01:35:55 2010
@@ -0,0 +1,43 @@
+#ifndef CLIENTSOCKET_H
+#define CLIENTSOCKET_H
+
+
+#include <QTcpSocket>
+#include <QPointer>
+#include "protocol.h"
+
+
+class ClientSocket : public QTcpSocket
+{
+    Q_OBJECT
+public:
+    ClientSocket(QObject* pmsgagent,QObject *parent = 0);
+    ~ClientSocket();
+
+private slots:
+    void readClient();
+    void clientDisconnect();
+    void gotError();
+
+
+    bool event(QEvent * event);
+
+public slots:
+    void Connect(QString* pip,int port);
+    void Send(QString* msg);
+    void DisConnect();
+
+
+signals:
+    void onReceived(char* msg);
+    void onConnectionClosed();
+
+
+private:
+    quint32 nextMessageSize;
+    QObject* m_pmsgagent;
+};
+
+typedef QPointer<ClientSocket> pClientSocket;
+
+#endif // CLIENTSOCKET_H

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/commevent.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/commevent.cpp?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/commevent.cpp (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/commevent.cpp Tue Dec 14 01:35:55 2010
@@ -0,0 +1,6 @@
+#include "commevent.h"
+
+CommEvent::CommEvent(SkyClass::EventType ut,QString* pmsg)
+    :QEvent(QEvent::User),commType(ut),m_pMsg(pmsg)
+{
+}

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/commevent.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/commevent.h?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/commevent.h (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/commevent.h Tue Dec 14 01:35:55 2010
@@ -0,0 +1,24 @@
+#ifndef COMMEVENT_H
+#define COMMEVENT_H
+
+#include <QEvent>
+#include <QString>
+
+#include "protocol.h"
+#include "clientsocket.h"
+
+
+class CommEvent : public QEvent
+{
+public:
+    CommEvent(SkyClass::EventType commType,QString* pmsg);
+    SkyClass::EventType commType;
+
+    //dest ip or msg
+    QString* m_pMsg;
+
+    //dest port
+    int m_n;
+};
+
+#endif // COMMEVENT_H

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/main.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/main.cpp?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/main.cpp (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/main.cpp Tue Dec 14 01:35:55 2010
@@ -0,0 +1,28 @@
+#include <QtGui/QApplication>
+#include "mainwindow.h"
+#include "msgagent.h"
+#include "qthreadex.h"
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+
+    MsgAgent agent;
+    MainWindow w(&agent);
+    ClientSocket socket(&agent);
+
+    agent.m_peventui = &w;
+    agent.m_peventsocket = &socket;
+
+    QThreadEx agentthread;
+    QThreadEx socketthread;
+
+    agent.moveToThread(&agentthread);
+    socket.moveToThread(&socketthread);
+
+    agentthread.start();
+    socketthread.start();
+    w.show();
+
+    return a.exec();
+}

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.cpp?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.cpp (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.cpp Tue Dec 14 01:35:55 2010
@@ -0,0 +1,76 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+#include "commevent.h"
+#include <QMutexLocker>
+#include <QDateTime>
+#include <QWidget>
+#include <iostream>
+MainWindow::MainWindow(QObject* msgagent,QWidget *parent) :
+    m_peventmsgagent(msgagent),
+    QMainWindow(parent),
+    ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+    //Ó³ÉäÍ˳ö¶¯×÷
+//    connect(ui->logoutButton, SIGNAL(clicked()), this, SLOT(on_logoutButton_clicked()));
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+
+void MainWindow::on_connectButton_clicked()
+{
+    CommEvent* ce = new CommEvent(SkyClass::DoConnect,
+                                  new QString("127.0.0.1"));
+    ce->m_n = 7000;
+    QCoreApplication::postEvent(m_peventmsgagent,ce);
+}
+
+void MainWindow::on_loginButton_clicked()
+{
+    //get some info from ui
+    //to do
+    //create a xml message
+    CommEvent* ce = new CommEvent(SkyClass::SendMessage,
+                                  new QString("this is from test client!"));
+    QCoreApplication::postEvent(m_peventmsgagent,ce);
+}
+
+void MainWindow::on_logoutButton_clicked()
+{
+    CommEvent* ce = new CommEvent(SkyClass::ClientDisconnect,
+                                  new QString("client log out"));
+    QCoreApplication::postEvent(m_peventmsgagent,ce);
+
+}
+/*
+bool MainWindow::event(QEvent * event)
+{
+    if(event->type() == QEvent::User)
+    {
+        //ue will be deleted automaticly
+        //a new event
+        CommEvent * ue = static_cast<CommEvent *>(event);
+        QListWidgetItem *lst;
+        switch(ue->commType)
+        {
+        case SkyClass::LogEvent:
+             lst = new QListWidgetItem(QDateTime::currentDateTime().toString(Qt::ISODate)+": " + *(ue->m_pMsg));//, listWidget);
+
+            ui->listWidget->insertItem(1,lst);
+
+            delete ue->m_pMsg;
+            break;
+        default:
+            return false;
+        }
+    }
+    else
+    {
+        return QObject::event(event);
+    }
+    return true;
+}
+*/

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.h?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.h (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.h Tue Dec 14 01:35:55 2010
@@ -0,0 +1,33 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QMutex>
+
+namespace Ui {
+    class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    explicit MainWindow(QObject* msgagent,QWidget *parent = 0);
+    ~MainWindow();
+
+private:
+    Ui::MainWindow *ui;
+    QObject* m_peventmsgagent;
+
+    //bool event(QEvent * event);
+    QMutex m_logmutex;
+
+ public slots:
+    void on_loginButton_clicked();
+    void on_connectButton_clicked();
+    //add by kevin
+    void on_logoutButton_clicked();
+};
+
+#endif // MAINWINDOW_H

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.ui
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.ui?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.ui (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/mainwindow.ui Tue Dec 14 01:35:55 2010
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>ClientWindow</string>
+  </property>
+  <widget class="QWidget" name="centralWidget">
+   <widget class="QPushButton" name="connectButton">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>20</y>
+      <width>75</width>
+      <height>23</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Connect</string>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="loginButton">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>60</y>
+      <width>75</width>
+      <height>23</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Login</string>
+    </property>
+   </widget>
+   <widget class="QListWidget" name="listWidget">
+    <property name="geometry">
+     <rect>
+      <x>145</x>
+      <y>20</y>
+      <width>231</width>
+      <height>231</height>
+     </rect>
+    </property>
+   </widget>
+   <widget class="QPushButton" name="logoutButton">
+    <property name="geometry">
+     <rect>
+      <x>30</x>
+      <y>170</y>
+      <width>75</width>
+      <height>23</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Logout</string>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>400</width>
+     <height>20</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QToolBar" name="mainToolBar">
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+  <widget class="QStatusBar" name="statusBar"/>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/msgagent.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/msgagent.cpp?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/msgagent.cpp (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/msgagent.cpp Tue Dec 14 01:35:55 2010
@@ -0,0 +1,82 @@
+#include <QCoreApplication>
+#include <QMutexLocker>
+#include "msgagent.h"
+#include "commevent.h"
+#include "clientsocket.h"
+#include <QtGlobal>
+
+MsgAgent::MsgAgent(QObject *parent) :
+    QObject(parent)
+{
+}
+
+
+bool MsgAgent::event(QEvent * event)
+{
+    if(event->type() == QEvent::User)
+    {
+        //ue will be deleted automaticly
+        //a new event
+        CommEvent * ue = static_cast<CommEvent *>(event);
+        CommEvent* ce;
+        switch(ue->commType)
+        {
+        case SkyClass::DoConnect:
+            ce = new CommEvent(SkyClass::DoConnect, ue->m_pMsg);
+            ce->m_n = ue->m_n;
+            QCoreApplication::postEvent(m_peventsocket, ce);
+            break;
+        case SkyClass::SendMessage:
+            ce = new CommEvent(SkyClass::SendMessage, ue->m_pMsg);
+            QCoreApplication::postEvent(m_peventsocket, ce);
+            break;
+        case SkyClass::GotMessage:
+            parserequst(ue->m_pMsg);
+            delete ue->m_pMsg;
+            break;
+        case SkyClass::ClientDisconnect:
+            onConnectionClosed(ue->m_pMsg);
+            qDebug("dissconnect message send!");
+            break;
+        default:
+            return false;
+        }
+    }
+    else
+    {
+        return QObject::event(event);
+    }
+    return true;
+}
+
+bool MsgAgent::onConnectionClosed(QString *pMsg)
+{
+    CommEvent* ce = new CommEvent(SkyClass::DoDisconnect,
+                                  new QString(*pMsg));
+    QCoreApplication::postEvent(m_peventui,ce);
+
+    return true;
+}
+
+bool MsgAgent::parserequst(QString* pmsg)
+{
+    //to do
+
+
+    //show this message
+    CommEvent* ce = new CommEvent(SkyClass::LogEvent,
+                                  new QString(*pmsg));
+    QCoreApplication::postEvent(m_peventui,ce);
+
+
+
+
+
+    //SendMyMsg(*pmsg,psocket);
+
+
+
+    return true;
+}
+
+

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/msgagent.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/msgagent.h?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/msgagent.h (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/msgagent.h Tue Dec 14 01:35:55 2010
@@ -0,0 +1,30 @@
+#ifndef MSGAGENT_H
+#define MSGAGENT_H
+
+#include <QObject>
+#include <QList>
+#include <QMutex>
+
+#include "commevent.h"
+
+class MsgAgent : public QObject
+{
+    Q_OBJECT
+public:
+    MsgAgent(QObject *parent = 0);
+
+    QObject* m_peventui;
+    QObject* m_peventsocket;
+
+private:
+    bool event(QEvent * event);
+    bool onConnectionClosed(QString *pMsg);
+
+    bool parserequst(QString* pmsg);
+
+private:
+
+
+};
+
+#endif // MSGAGENT_H

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/protocol.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/protocol.h?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/protocol.h (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/protocol.h Tue Dec 14 01:35:55 2010
@@ -0,0 +1,49 @@
+#ifndef PROTOCOL_H
+#define PROTOCOL_H
+
+#include <QObject>
+
+namespace SkyClass
+{
+    const quint32 ServerId = 0;
+    const quint32 CenterId = 1;
+    const quint32 SystemId = 2;
+
+    const quint8 UserInfoUpdateAction = 0;
+    const quint8 UserInfoNewAction = 1;
+    const quint8 UserInfoLeaveAction = 2;
+
+    enum ClientType {ClientTypeBegin = 7000,
+                    UnKnown,
+                    Teacher,
+                    Student,
+                    DTU};
+
+    enum EventType {EventTypeBegin = 8000,
+                    LogEvent,
+                    ErrorEvent,
+                    ClientConnected,
+                    ClientReg,
+                    ClientDisconnect,
+                    ServerConnected,
+                    ServerDisconnect,
+                    DoConnect,
+                    DoDisconnect,
+                    GotMessage,
+                    SendMessage,
+                    GotUserInfo,
+                    SendUserInfo,
+                    GotClientInfo,
+                    SendClientInfo,
+                    EventTypeEnd};
+    namespace MsgType{
+        enum MsgType{
+            MsgTypeBegin,
+            ClientInfo,
+            UserInfo,
+            Message,
+            MsgTypeEnd};
+    }
+}
+
+#endif // PROTOCOL_H

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/qthreadex.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/qthreadex.h?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/qthreadex.h (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/qthreadex.h Tue Dec 14 01:35:55 2010
@@ -0,0 +1,12 @@
+#ifndef QTHREADEX_H
+#define QTHREADEX_H
+
+#include <QThread>
+
+class QThreadEx : public QThread
+{
+protected:
+    void run(){exec();}
+};
+
+#endif // QTHREADEX_H

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/ui_mainwindow.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/ui_mainwindow.h?rev=1048897&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/ui_mainwindow.h (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/StudentQT-0.2.0/ui_mainwindow.h Tue Dec 14 01:35:55 2010
@@ -0,0 +1,92 @@
+/********************************************************************************
+** Form generated from reading UI file 'mainwindow.ui'
+**
+** Created: Mon Dec 13 20:12:14 2010
+**      by: Qt User Interface Compiler version 4.6.3
+**
+** WARNING! All changes made in this file will be lost when recompiling UI file!
+********************************************************************************/
+
+#ifndef UI_MAINWINDOW_H
+#define UI_MAINWINDOW_H
+
+#include <QtCore/QVariant>
+#include <QtGui/QAction>
+#include <QtGui/QApplication>
+#include <QtGui/QButtonGroup>
+#include <QtGui/QHeaderView>
+#include <QtGui/QListWidget>
+#include <QtGui/QMainWindow>
+#include <QtGui/QMenuBar>
+#include <QtGui/QPushButton>
+#include <QtGui/QStatusBar>
+#include <QtGui/QToolBar>
+#include <QtGui/QWidget>
+
+QT_BEGIN_NAMESPACE
+
+class Ui_MainWindow
+{
+public:
+    QWidget *centralWidget;
+    QPushButton *connectButton;
+    QPushButton *loginButton;
+    QListWidget *listWidget;
+    QPushButton *logoutButton;
+    QMenuBar *menuBar;
+    QToolBar *mainToolBar;
+    QStatusBar *statusBar;
+
+    void setupUi(QMainWindow *MainWindow)
+    {
+        if (MainWindow->objectName().isEmpty())
+            MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
+        MainWindow->resize(400, 300);
+        centralWidget = new QWidget(MainWindow);
+        centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
+        connectButton = new QPushButton(centralWidget);
+        connectButton->setObjectName(QString::fromUtf8("connectButton"));
+        connectButton->setGeometry(QRect(30, 20, 75, 23));
+        loginButton = new QPushButton(centralWidget);
+        loginButton->setObjectName(QString::fromUtf8("loginButton"));
+        loginButton->setGeometry(QRect(30, 60, 75, 23));
+        listWidget = new QListWidget(centralWidget);
+        listWidget->setObjectName(QString::fromUtf8("listWidget"));
+        listWidget->setGeometry(QRect(145, 20, 231, 231));
+        logoutButton = new QPushButton(centralWidget);
+        logoutButton->setObjectName(QString::fromUtf8("logoutButton"));
+        logoutButton->setGeometry(QRect(30, 170, 75, 23));
+        MainWindow->setCentralWidget(centralWidget);
+        menuBar = new QMenuBar(MainWindow);
+        menuBar->setObjectName(QString::fromUtf8("menuBar"));
+        menuBar->setGeometry(QRect(0, 0, 400, 20));
+        MainWindow->setMenuBar(menuBar);
+        mainToolBar = new QToolBar(MainWindow);
+        mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
+        MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar);
+        statusBar = new QStatusBar(MainWindow);
+        statusBar->setObjectName(QString::fromUtf8("statusBar"));
+        MainWindow->setStatusBar(statusBar);
+
+        retranslateUi(MainWindow);
+
+        QMetaObject::connectSlotsByName(MainWindow);
+    } // setupUi
+
+    void retranslateUi(QMainWindow *MainWindow)
+    {
+        MainWindow->setWindowTitle(QApplication::translate("MainWindow", "ClientWindow", 0, QApplication::UnicodeUTF8));
+        connectButton->setText(QApplication::translate("MainWindow", "Connect", 0, QApplication::UnicodeUTF8));
+        loginButton->setText(QApplication::translate("MainWindow", "Login", 0, QApplication::UnicodeUTF8));
+        logoutButton->setText(QApplication::translate("MainWindow", "Logout", 0, QApplication::UnicodeUTF8));
+    } // retranslateUi
+
+};
+
+namespace Ui {
+    class MainWindow: public Ui_MainWindow {};
+} // namespace Ui
+
+QT_END_NAMESPACE
+
+#endif // UI_MAINWINDOW_H