You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
2.9 KiB
99 lines
2.9 KiB
/*
|
|
Tests for the wallet manager
|
|
|
|
Copyright (c) 2003 by Richard Smith <kde@metafoo.co.uk>
|
|
Kopete (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>
|
|
|
|
*************************************************************************
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
*************************************************************************
|
|
*/
|
|
|
|
#include <tqtextstream.h>
|
|
#include <tqtimer.h>
|
|
|
|
#include <kaboutdata.h>
|
|
#include <kapplication.h>
|
|
#include <kcmdlineargs.h>
|
|
#include <kdebug.h>
|
|
#include <kglobal.h>
|
|
#include <kstandarddirs.h>
|
|
#include <dcopclient.h>
|
|
#include <tdewallet.h>
|
|
|
|
#include "kopetewalletmanager.h"
|
|
#include "kopetewallettest_program.h"
|
|
|
|
static TQTextStream _out( stdout, IO_WriteOnly );
|
|
|
|
void closeWallet()
|
|
{
|
|
Kopete::WalletManager::self()->closeWallet();
|
|
}
|
|
|
|
void delay()
|
|
{
|
|
TQTimer::singleShot( 3000, tqApp, TQT_SLOT( quit() ) );
|
|
tqApp->exec();
|
|
}
|
|
|
|
void openWalletAsync()
|
|
{
|
|
WalletReciever *r = new WalletReciever;
|
|
_out << "[ASYNC] About to open wallet, receiver: " << r << endl;
|
|
Kopete::WalletManager::self()->openWallet( r, TQT_SLOT( gotWallet( KWallet::Wallet* ) ) );
|
|
}
|
|
|
|
void WalletReciever::gotWallet( KWallet::Wallet *w )
|
|
{
|
|
_out << "[ASYNC] Received wallet pointer: " << w << " for receiver: " << this << endl;
|
|
}
|
|
|
|
void WalletReciever::timer()
|
|
{
|
|
_out << "Timer..." << endl;
|
|
}
|
|
|
|
int main( int argc, char *argv[] )
|
|
{
|
|
TDEAboutData aboutData( "kopetewallettest", "kopetewallettest", "version" );
|
|
TDECmdLineArgs::init( argc, argv, &aboutData );
|
|
TDECmdLineOptions opts[] = { {"+action",0,0}, TDECmdLineLastOption };
|
|
TDECmdLineArgs::addCmdLineOptions( opts );
|
|
TDEApplication app( "kopetewallettest" );
|
|
|
|
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
|
|
|
|
// must register with DCOP or async callbacks will fail
|
|
_out << "DCOP registration returned " << app.dcopClient()->registerAs(app.name()) << endl;
|
|
|
|
for( int i = 0; i < args->count(); ++i )
|
|
{
|
|
TQString arg = args->arg( i );
|
|
_out << "Processing " << arg << endl;
|
|
if( arg == TQString::fromLatin1( "open" ) ) openWalletAsync();
|
|
if( arg == TQString::fromLatin1( "close" ) ) closeWallet();
|
|
if( arg == TQString::fromLatin1( "delay" ) ) delay();
|
|
_out << "Done." << endl;
|
|
}
|
|
|
|
WalletReciever *r = new WalletReciever;
|
|
|
|
TQTimer timer;
|
|
r->connect( &timer, TQT_SIGNAL( timeout() ), TQT_SLOT( timer() ) );
|
|
timer.start( 1000 );
|
|
|
|
_out << "About to start 30 second event loop" << endl;
|
|
TQTimer::singleShot( 30000, tqApp, TQT_SLOT( quit() ) );
|
|
return tqApp->exec();
|
|
}
|
|
|
|
#include "kopetewallettest_program.moc"
|
|
|
|
// vim: set noet ts=4 sts=4 sw=4:
|