2 This file is part of kdepim.
4 Copyright (c) 2005 Will Stephenson <lists@stevello.free-online.co.uk>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
23 #include <dcopclient.h>
24 #include <kapplication.h>
25 #include "provideriface.h"
27 #include "testservice.h"
28 #include "serviceiface_stub.h"
30 TestService::TestService() : QObject(), DCOPObject("ProviderIface")
32 kapp
->dcopClient()->registerAs("testservice" );
33 m_service
= new ServiceIface_stub( "kded", "networkstatus" );
34 m_status
= NetworkStatus::Offline
;
35 NetworkStatus::Properties nsp
;
37 nsp
.name
= "test_net";
38 nsp
.onDemandPolicy
= NetworkStatus::All
;
39 nsp
.service
= kapp
->dcopClient()->appId();
40 nsp
.status
= m_status
;
41 m_service
->registerNetwork( "test_net", nsp
);
44 TestService::~TestService()
49 int TestService::status( const QString
& network
)
55 int TestService::establish( const QString
& network
)
58 m_status
= NetworkStatus::Establishing
;
59 m_service
->setNetworkStatus( "test_net", (int)m_status
);
60 m_nextStatus
= NetworkStatus::Online
;
61 QTimer::singleShot( 5000, this, SLOT( slotStatusChange() ) );
62 return (int)NetworkStatus::RequestAccepted
;
65 int TestService::shutdown( const QString
& network
)
68 m_status
= NetworkStatus::ShuttingDown
;
69 m_service
->setNetworkStatus( "test_net", (int)m_status
);
70 m_nextStatus
= NetworkStatus::Offline
;
71 QTimer::singleShot( 5000, this, SLOT( slotStatusChange() ) );
72 return (int)NetworkStatus::RequestAccepted
;
75 void TestService::simulateFailure()
77 m_status
= NetworkStatus::OfflineFailed
;
78 m_service
->setNetworkStatus( "test_net", (int)m_status
);
81 void TestService::simulateDisconnect()
83 m_status
= NetworkStatus::OfflineDisconnected
;
84 m_service
->setNetworkStatus( "test_net", (int)m_status
);
87 void TestService::slotStatusChange()
89 m_status
= m_nextStatus
;
90 m_service
->setNetworkStatus( "test_net", (int)m_status
);
93 int main( int argc
, char** argv
)
95 KApplication
app(argc
, argv
, "testdcop");
96 TestService
* test
= new TestService
;
101 #include "testservice.moc"