smf/smfservermodule/smfserver/server/smfserverqt.cpp
author James Aley <jamesa@symbian.org>
Mon, 07 Jun 2010 11:43:45 +0100
changeset 13 b5d63d5fc252
parent 10 77a56c951f86
child 14 a469c0e6e7fb
permissions -rw-r--r--
Basic functionality on desktop server build. Started a test for GetServices
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
     1
/**
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
     2
 * Copyright (c) 2010 Sasken Communication Technologies Ltd.
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
     3
 * All rights reserved.
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
     5
 * under the terms of the "Eclipse Public License v1.0" 
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
     6
 * which accompanies  this distribution, and is available
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html"
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
     8
 *
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
     9
 * Initial Contributors:
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    10
 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    11
 *
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    12
 * Contributors:
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    13
 * Manasij Roy, Nalina Hariharan
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    14
 * Description:
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    15
 * SMF Server implementation for platforms other than Symbian.
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    16
 * Uses  QLocalServer-QLocalSocket classes
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    17
 *
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    18
 */
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    19
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    20
#include "smfserverqt_p.h"
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    21
#include "smfserverqtsession.h"
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    22
#include "smfserver.h"
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    23
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    24
#include <QLocalServer>
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    25
#include <QLocalSocket>
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    26
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    27
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    28
SmfServerQt::SmfServerQt(SmfServer *wrapper)
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    29
    : m_generic(wrapper)
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    30
{
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    31
    m_server = new QLocalServer(this);
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    32
    connect(m_server, SIGNAL(newConnection()), this, SLOT(newClientConnected()));
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    33
}
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    34
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    35
SmfServerQt::~SmfServerQt()
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    36
{
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    37
    m_server->close();
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    38
}
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    39
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    40
/**
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    41
  * Start the server listening for connections.
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    42
  */
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    43
bool SmfServerQt::start()
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    44
{
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    45
    const QString KServerName("SmfServerQt");
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    46
    if (m_server->listen(KServerName))
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    47
    {
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    48
        writeLog(QString(m_server->serverName() + ": listening for connections."));
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    49
        return true;
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    50
    }
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    51
    else
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    52
    {
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    53
        writeLog(QString(KServerName + ": failed to start"));
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    54
        writeLog(QString(m_server->errorString()));
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    55
        return false;
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    56
    }
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    57
}
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    58
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    59
/**
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    60
 * Return the number of open sessions
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    61
 */
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    62
int SmfServerQt::sessionListCount() const
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    63
{
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    64
    return m_sessions.count();
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    65
}
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    66
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    67
void SmfServerQt::writeLog(QString log) const
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    68
{
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    69
    qDebug() << log.toAscii().constData();
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    70
}
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    71
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    72
/**
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    73
 * Called by the SmfServer when client authorization finishes.
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    74
 * @param success success of the authorization
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    75
 */
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    76
void SmfServerQt::clientAuthorizationFinished(bool success)
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    77
{
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    78
    Q_UNUSED(success);
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    79
}
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    80
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    81
/**
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    82
  * Slot to receive incoming connections
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    83
  */
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    84
void SmfServerQt::newClientConnected()
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    85
{
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    86
    QLocalSocket *client(m_server->nextPendingConnection());
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    87
    if (!client)
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    88
    {
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    89
        writeLog("SmfServerQt::newClientConnected(): no socket - client may have dropped.");
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    90
        return;
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    91
    }
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    92
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    93
    // Create a new session for this client.
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    94
    writeLog("Client connected.");
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    95
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    96
    m_sessions.append(new SmfServerQtSession(client, this));
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    97
}
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    98
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    99
void  SmfServerQt::removeFromList()
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   100
{
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   101
}
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   102
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   103
int SmfServerQt::findAndServiceclient(int requestID,QByteArray* parsedData,SmfError error)
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   104
{
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   105
    Q_UNUSED(requestID);
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   106
    Q_UNUSED(parsedData);
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   107
    Q_UNUSED(error);
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   108
    return 0;
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   109
}
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   110