smf/smfservermodule/smfserver/server/smfserverqt.cpp
changeset 13 b5d63d5fc252
parent 10 77a56c951f86
child 14 a469c0e6e7fb
equal deleted inserted replaced
12:5bed45b14781 13:b5d63d5fc252
     9  * Initial Contributors:
     9  * Initial Contributors:
    10  * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
    10  * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
    11  *
    11  *
    12  * Contributors:
    12  * Contributors:
    13  * Manasij Roy, Nalina Hariharan
    13  * Manasij Roy, Nalina Hariharan
    14 * Description:
    14  * Description:
    15 * SMF Server implementation for platforms other than Symbian.
    15  * SMF Server implementation for platforms other than Symbian.
    16 * Uses  QLocalServer-QLocalSocket classes
    16  * Uses  QLocalServer-QLocalSocket classes
    17 *
    17  *
    18 */
    18  */
    19 
    19 
    20 #include "smfserverqt_p.h"
    20 #include "smfserverqt_p.h"
       
    21 #include "smfserverqtsession.h"
       
    22 #include "smfserver.h"
    21 
    23 
    22 #include <QLocalServer>
    24 #include <QLocalServer>
    23 #include <QLocalSocket>
    25 #include <QLocalSocket>
    24 
    26 
    25 //
       
    26 // SmfServerQt
       
    27 //
       
    28 
    27 
    29 SmfServerQt::SmfServerQt()
    28 SmfServerQt::SmfServerQt(SmfServer *wrapper)
       
    29     : m_generic(wrapper)
    30 {
    30 {
       
    31     m_server = new QLocalServer(this);
       
    32     connect(m_server, SIGNAL(newConnection()), this, SLOT(newClientConnected()));
    31 }
    33 }
    32 
    34 
    33 SmfServerQt::~SmfServerQt()
    35 SmfServerQt::~SmfServerQt()
    34 {
    36 {
       
    37     m_server->close();
    35 }
    38 }
    36 
    39 
       
    40 /**
       
    41   * Start the server listening for connections.
       
    42   */
    37 bool SmfServerQt::start()
    43 bool SmfServerQt::start()
    38 {
    44 {
    39     return false;
    45     const QString KServerName("SmfServerQt");
       
    46     if (m_server->listen(KServerName))
       
    47     {
       
    48         writeLog(QString(m_server->serverName() + ": listening for connections."));
       
    49         return true;
       
    50     }
       
    51     else
       
    52     {
       
    53         writeLog(QString(KServerName + ": failed to start"));
       
    54         writeLog(QString(m_server->errorString()));
       
    55         return false;
       
    56     }
    40 }
    57 }
    41 
    58 
       
    59 /**
       
    60  * Return the number of open sessions
       
    61  */
    42 int SmfServerQt::sessionListCount() const
    62 int SmfServerQt::sessionListCount() const
    43 {
    63 {
    44     return 0;
    64     return m_sessions.count();
    45 }
    65 }
    46 
    66 
    47 void SmfServerQt::writeLog(QString log) const
    67 void SmfServerQt::writeLog(QString log) const
    48 {
    68 {
    49     Q_UNUSED(log);
    69     qDebug() << log.toAscii().constData();
    50 }
    70 }
    51 
    71 
    52 /**
    72 /**
    53  * Called by the SmfServer when client authorization finishes.
    73  * Called by the SmfServer when client authorization finishes.
    54  * @param success success of the authorization
    74  * @param success success of the authorization
    56 void SmfServerQt::clientAuthorizationFinished(bool success)
    76 void SmfServerQt::clientAuthorizationFinished(bool success)
    57 {
    77 {
    58     Q_UNUSED(success);
    78     Q_UNUSED(success);
    59 }
    79 }
    60 
    80 
       
    81 /**
       
    82   * Slot to receive incoming connections
       
    83   */
    61 void SmfServerQt::newClientConnected()
    84 void SmfServerQt::newClientConnected()
    62 {
    85 {
       
    86     QLocalSocket *client(m_server->nextPendingConnection());
       
    87     if (!client)
       
    88     {
       
    89         writeLog("SmfServerQt::newClientConnected(): no socket - client may have dropped.");
       
    90         return;
       
    91     }
       
    92 
       
    93     // Create a new session for this client.
       
    94     writeLog("Client connected.");
       
    95 
       
    96     m_sessions.append(new SmfServerQtSession(client, this));
    63 }
    97 }
    64 
    98 
    65 void  SmfServerQt::removeFromList()
    99 void  SmfServerQt::removeFromList()
    66 {
   100 {
    67 }
   101 }
    72     Q_UNUSED(parsedData);
   106     Q_UNUSED(parsedData);
    73     Q_UNUSED(error);
   107     Q_UNUSED(error);
    74     return 0;
   108     return 0;
    75 }
   109 }
    76 
   110 
    77 //
       
    78 // SmfServerQtSession
       
    79 //
       
    80 
       
    81 SmfServerQtSession::SmfServerQtSession(QLocalSocket *clientConnection, SmfServerQt *server)
       
    82 {
       
    83     Q_UNUSED(server);
       
    84     Q_UNUSED(clientConnection);
       
    85 }
       
    86 
       
    87 SmfServerQtSession::~SmfServerQtSession()
       
    88 {
       
    89 }
       
    90 
       
    91 void SmfServerQtSession::readDataFromClient()
       
    92 {
       
    93 }
       
    94 
       
    95 void SmfServerQtSession::clientAuthorizationFinished(bool success)
       
    96 {
       
    97     Q_UNUSED(success);
       
    98 }