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 <QLocalServer> |
|
21 #include <QLocalSocket> |
|
22 |
20 #include "smfserverqt_p.h" |
23 #include "smfserverqt_p.h" |
21 #include "smfserverqtsession.h" |
24 #include "smfserverqtsession.h" |
22 #include "smfserver.h" |
25 #include "smfserver.h" |
23 |
26 |
24 #include <QLocalServer> |
|
25 #include <QLocalSocket> |
|
26 |
|
27 |
27 |
28 SmfServerQt::SmfServerQt(SmfServer *wrapper) |
28 SmfServerQt::SmfServerQt(SmfServer *wrapper) |
29 : m_generic(wrapper) |
29 : m_generic(wrapper) |
30 { |
30 { |
31 m_server = new QLocalServer(this); |
31 m_server = new QLocalServer(this); |
32 connect(m_server, SIGNAL(newConnection()), this, SLOT(newClientConnected())); |
32 connect(m_server, SIGNAL(newConnection()), this, SLOT(newClientConnected())); |
33 } |
33 } |
34 |
34 |
35 SmfServerQt::~SmfServerQt() |
35 SmfServerQt::~SmfServerQt() |
36 { |
36 { |
37 m_server->close(); |
37 m_server->close(); |
38 } |
38 } |
39 |
39 |
40 /** |
40 /** |
41 * Start the server listening for connections. |
41 * Start the server listening for connections. |
42 */ |
42 */ |
43 bool SmfServerQt::start() |
43 bool SmfServerQt::start() |
44 { |
44 { |
45 const QString KServerName("SmfServerQt"); |
45 const QString KServerName("SmfServerQt"); |
46 if (m_server->listen(KServerName)) |
46 if (m_server->listen(KServerName)) |
47 { |
47 { |
48 qDebug()<<(QString(m_server->serverName() + ": listening for connections.")); |
48 qDebug()<<(QString(m_server->serverName() + ": listening for connections.")); |
49 return true; |
49 return true; |
50 } |
50 } |
51 else |
51 else |
52 { |
52 { |
53 qDebug()<<(QString(KServerName + ": failed to start")); |
53 qDebug()<<(QString(KServerName + ": failed to start")); |
54 qDebug()<<(QString(m_server->errorString())); |
54 qDebug()<<(QString(m_server->errorString())); |
55 return false; |
55 return false; |
56 } |
56 } |
57 } |
57 } |
58 |
58 |
59 /** |
59 /** |
60 * Return the number of open sessions |
60 * Return the number of open sessions |
61 */ |
61 */ |
62 int SmfServerQt::sessionListCount() const |
62 int SmfServerQt::sessionListCount() const |
63 { |
63 { |
64 return m_sessions.count(); |
64 return m_sessions.count(); |
65 } |
65 } |
66 |
|
67 /*void SmfServerQt::writeLog(QString log) const |
|
68 { |
|
69 qDebug() << log.toAscii().constData(); |
|
70 }*/ |
|
71 |
66 |
72 /** |
67 /** |
73 * Called by the SmfServer when client authorization finishes. |
68 * Called by the SmfServer when client authorization finishes. |
74 * @param success success of the authorization |
69 * @param success success of the authorization |
75 */ |
70 */ |
76 void SmfServerQt::clientAuthorizationFinished(bool success) |
71 void SmfServerQt::clientAuthorizationFinished(bool success) |
77 { |
72 { |
78 Q_UNUSED(success); |
73 Q_UNUSED(success); |
79 } |
74 } |
80 |
75 |
81 /** |
76 /** |
82 * Slot to receive incoming connections |
77 * Slot to receive incoming connections |
83 */ |
78 */ |
84 void SmfServerQt::newClientConnected() |
79 void SmfServerQt::newClientConnected() |
85 { |
80 { |
86 QLocalSocket *client(m_server->nextPendingConnection()); |
81 QLocalSocket *client(m_server->nextPendingConnection()); |
87 if (!client) |
82 if (!client) |
88 { |
83 { |
89 qDebug()<<("SmfServerQt::newClientConnected(): no socket - client may have dropped."); |
84 qDebug()<<"SmfServerQt::newClientConnected(): no socket - client may have dropped."; |
90 return; |
85 return; |
91 } |
86 } |
92 |
87 |
93 // Create a new session for this client. |
88 // Create a new session for this client. |
94 qDebug()<<("Client connected."); |
89 qDebug()<<"Client connected."; |
95 |
90 |
96 m_sessions.append(new SmfServerQtSession(client, this)); |
91 m_sessions.append(new SmfServerQtSession(client, this)); |
97 } |
92 } |
98 |
93 |
99 void SmfServerQt::removeFromList() |
94 void SmfServerQt::removeFromList() |
100 { |
95 { |
101 } |
96 } |
102 |
97 |
103 int SmfServerQt::findAndServiceclient(int requestID,QByteArray* parsedData,SmfError error) |
98 int SmfServerQt::findAndServiceclient(int requestID,QByteArray* parsedData,SmfError error) |
104 { |
99 { |
105 Q_UNUSED(requestID); |
100 Q_UNUSED(requestID); |
106 Q_UNUSED(parsedData); |
101 Q_UNUSED(parsedData); |
107 Q_UNUSED(error); |
102 Q_UNUSED(error); |
108 return 0; |
103 return 0; |
109 } |
104 } |
110 |
105 |