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-- |
10 | 1 |
/** |
2 |
* Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of the "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html" |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution |
|
11 |
* |
|
12 |
* Contributors: |
|
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 | 19 |
|
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 | 23 |
|
24 |
#include <QLocalServer> |
|
25 |
#include <QLocalSocket> |
|
26 |
||
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 | 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 | 33 |
} |
34 |
||
35 |
SmfServerQt::~SmfServerQt() |
|
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 | 38 |
} |
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 | 43 |
bool SmfServerQt::start() |
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 | 57 |
} |
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 | 62 |
int SmfServerQt::sessionListCount() const |
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 | 65 |
} |
66 |
||
67 |
void SmfServerQt::writeLog(QString log) const |
|
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 | 70 |
} |
71 |
||
72 |
/** |
|
73 |
* Called by the SmfServer when client authorization finishes. |
|
74 |
* @param success success of the authorization |
|
75 |
*/ |
|
76 |
void SmfServerQt::clientAuthorizationFinished(bool success) |
|
77 |
{ |
|
78 |
Q_UNUSED(success); |
|
79 |
} |
|
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 | 84 |
void SmfServerQt::newClientConnected() |
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 | 97 |
} |
98 |
||
99 |
void SmfServerQt::removeFromList() |
|
100 |
{ |
|
101 |
} |
|
102 |
||
103 |
int SmfServerQt::findAndServiceclient(int requestID,QByteArray* parsedData,SmfError error) |
|
104 |
{ |
|
105 |
Q_UNUSED(requestID); |
|
106 |
Q_UNUSED(parsedData); |
|
107 |
Q_UNUSED(error); |
|
108 |
return 0; |
|
109 |
} |
|
110 |