smf/smfservermodule/smfserver/server/smfserverqt.cpp
author cgandhi
Thu, 05 Aug 2010 16:48:48 +0530
changeset 18 013a02bf2bb0
parent 14 a469c0e6e7fb
permissions -rw-r--r--
pushing changes for common libs and trace messages
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
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    20
#include <QLocalServer>
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    21
#include <QLocalSocket>
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    22
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    23
#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
    24
#include "smfserverqtsession.h"
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    25
#include "smfserver.h"
10
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)
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
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()));
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    33
	}
10
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()
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
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();
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    38
	}
10
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()
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
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))
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    47
    	{
14
a469c0e6e7fb changes for SmfPost, SmfCredentialMgr, PLuginManager, SmfServer. Adding Sample Plugins and Sample Client Applications.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 13
diff changeset
    48
        qDebug()<<(QString(m_server->serverName() + ": listening for connections."));
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    49
        return true;
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    50
    	}
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    51
    else
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    52
    	{
14
a469c0e6e7fb changes for SmfPost, SmfCredentialMgr, PLuginManager, SmfServer. Adding Sample Plugins and Sample Client Applications.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 13
diff changeset
    53
        qDebug()<<(QString(KServerName + ": failed to start"));
a469c0e6e7fb changes for SmfPost, SmfCredentialMgr, PLuginManager, SmfServer. Adding Sample Plugins and Sample Client Applications.
cgandhi <chandradeep.gandhi@sasken.com>
parents: 13
diff changeset
    54
        qDebug()<<(QString(m_server->errorString()));
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    55
        return false;
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    56
    	}
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    57
	}
10
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
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
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();
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    65
		}
10
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
/**
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    68
 * Called by the SmfServer when client authorization finishes.
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    69
 * @param success success of the authorization
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
void SmfServerQt::clientAuthorizationFinished(bool success)
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    72
	{
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    73
    Q_UNUSED(success);
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    74
	}
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    75
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    76
/**
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    77
  * 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
    78
  */
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    79
void SmfServerQt::newClientConnected()
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
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
    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
    82
    if (!client)
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    83
    	{
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    84
        qDebug()<<"SmfServerQt::newClientConnected(): no socket - client may have dropped.";
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    85
        return;
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    86
    	}
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    87
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    88
    // Create a new session for this client.
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    89
    qDebug()<<"Client connected.";
13
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    90
b5d63d5fc252 Basic functionality on desktop server build. Started a test for GetServices
James Aley <jamesa@symbian.org>
parents: 10
diff changeset
    91
    m_sessions.append(new SmfServerQtSession(client, this));
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    92
	}
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    93
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
    94
void  SmfServerQt::removeFromList()
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    95
	{
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    96
	}
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
int SmfServerQt::findAndServiceclient(int requestID,QByteArray* parsedData,SmfError error)
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
    99
	{
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   100
    Q_UNUSED(requestID);
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   101
    Q_UNUSED(parsedData);
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   102
    Q_UNUSED(error);
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   103
    return 0;
18
013a02bf2bb0 pushing changes for common libs and trace messages
cgandhi
parents: 14
diff changeset
   104
	}
10
77a56c951f86 Fixed build for Qt desktop
James Aley <jamesa@symbian.org>
parents:
diff changeset
   105