smf/smfservermodule/smfserver/server/smfserverqtsession.cpp
changeset 18 013a02bf2bb0
parent 13 b5d63d5fc252
--- a/smf/smfservermodule/smfserver/server/smfserverqtsession.cpp	Thu Aug 05 16:46:37 2010 +0530
+++ b/smf/smfservermodule/smfserver/server/smfserverqtsession.cpp	Thu Aug 05 16:48:48 2010 +0530
@@ -12,77 +12,78 @@
  * Contributors:
  * Manasij Roy, Nalina Hariharan
  *
- *
  * Description: Session implementation for Qt desktop builds
  *
  */
 
+#include <qdebug.h>
+
 #include "smfserverqtsession.h"
 #include "smfserverqt_p.h"
 #include "smfserver.h"
 
 SmfServerQtSession::SmfServerQtSession(QLocalSocket *clientConnection, SmfServerQt *server)
     : m_opCode(-1), m_clientConnection(clientConnection), m_server(server)
-{
+	{
     connect(m_clientConnection, SIGNAL(readyRead()), this, SLOT(readDataFromClient()));
     connect(m_clientConnection, SIGNAL(error(QLocalSocket::LocalSocketError)),
             this, SLOT(socketError(QLocalSocket::LocalSocketError)));
-}
+	}
 
 SmfServerQtSession::~SmfServerQtSession()
-{
+	{
     // The socket has the QLocalServer as a parent, but it should be deleted to
     // save unnecessary accumulation of these objects in memory. It won't be double deleted.
     delete m_clientConnection;
-}
+	}
 
 void SmfServerQtSession::readDataFromClient()
-{
+	{
     // TODO: This needs to be much safer.
     if(m_clientConnection->bytesAvailable() < sizeof(typeof(SmfRequestTypeID)))
-    {
+    	{
         // Don't read yet, haven't received opcode
         return;
-    }
+    	}
 
     if (m_opCode == -1)
-    {
+    	{
         QDataStream in(m_clientConnection);
         in >> m_opCode;
-    }
+    	}
 
     // m_opCode set, so handle request
     handleRequest();
-}
+	}
 
 /**
  * Call the appropriate handler function
  */
 void SmfServerQtSession::handleRequest()
-{
+	{
     switch (m_opCode)
-    {
-    case SmfGetService:
-        handleGetService();
-        break;
-    default:
-        m_server->writeLog(QString("Bad Request received: ") + m_opCode);
-    }
-}
+		{
+		case SmfGetService:
+			handleGetService();
+			break;
+		default:
+			qDebug()<<"Bad Request received =  "<<m_opCode);
+		}
+	}
 
 /**
  * Find available services for specified interface and return list to client.
  */
 void SmfServerQtSession::handleGetService()
-{
-    m_server->writeLog("SmfServerQtSession::handleGetService()");
+	{
+    qDebug()<<"SmfServerQtSession::handleGetService()";
 
     QDataStream in(m_clientConnection);
 
     // Get interface type requested
     SmfInterfaceID ifName;
     in >> ifName;
-    m_server->writeLog("Requested: " + ifName);
+    qDebug()<<"Requested = "<<ifName;
 
     // Get the available services for this interface
     QMap<SmfPluginID, SmfProvider> services;
@@ -91,26 +92,25 @@
     // write back the results
     QDataStream out(m_clientConnection);
     out << services;
-}
+	}
 
 void SmfServerQtSession::clientAuthorizationFinished(bool success)
-{
+	{
     Q_UNUSED(success);
-}
+	}
 
 void SmfServerQtSession::socketError(QLocalSocket::LocalSocketError error)
-{
+	{
     switch (error)
-    {
-    case QLocalSocket::PeerClosedError:
-        m_server->writeLog("Peer closed connection.");
-        break;
-    case QLocalSocket::SocketTimeoutError:
-        m_server->writeLog("error: connection timed out.");
-        break;
-    default:
-        m_server->writeLog("error: unkown socket error: " + error);
-        break;
-    }
-}
-
+		{
+		case QLocalSocket::PeerClosedError:
+			qDebug()<<"Peer closed connection.";
+			break;
+		case QLocalSocket::SocketTimeoutError:
+			qDebug()<<"error: connection timed out.";
+			break;
+		default:
+			qDebug()<<"error: unkown socket error: "<<error;
+			break;
+		}
+	}