2 testbedfakeserver.cpp - Kopete Testbed Protocol
4 Copyright (c) 2003 by Will Stephenson <will@stevello.free-online.co.uk>
5 Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
7 *************************************************************************
9 * This library is free software; you can redistribute it and/or *
10 * modify it under the terms of the GNU General Public *
11 * License as published by the Free Software Foundation; either *
12 * version 2 of the License, or (at your option) any later version. *
14 *************************************************************************
17 #include "testbedfakeserver.h"
20 #include "testbedincomingmessage.h"
23 TestbedFakeServer::TestbedFakeServer()
27 TestbedFakeServer::~TestbedFakeServer()
29 qDeleteAll( m_incomingMessages
);
32 void TestbedFakeServer::sendMessage( const QString
&contactId
, const QString
&message
)
34 // see what contact the message is for
35 // if it's for Echo, respond immediately
36 kDebug( 14210 ) << "Message for: " << contactId
<< ", is: " << message
;
37 kDebug( 14210 ) << "recipient is echo, coming back at you.";
38 // put the message in a map and start a timer to tell it to deliver itself.
39 //emit messageReceived( QString::fromLatin1( "echo: " ) + message );
40 QString messageId
= contactId
+ QString::fromLatin1(": ");
41 TestbedIncomingMessage
* msg
= new TestbedIncomingMessage( this, messageId
+ message
);
42 m_incomingMessages
.append( msg
);
43 QTimer::singleShot( 1000, msg
, SLOT( deliver() ) );
45 // This removes any delivered messages
49 void TestbedFakeServer::incomingMessage( QString message
)
51 emit
messageReceived( message
);
54 void TestbedFakeServer::purgeMessages()
56 for ( int i
= m_incomingMessages
.count() - 1; i
>= 0; --i
)
58 if ( m_incomingMessages
[i
]->delivered() )
59 m_incomingMessages
.removeAt(i
);
63 #include "testbedfakeserver.moc"