kwalletd: indent and format

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-03-28 21:36:06 +03:00
parent 5a94dc6959
commit 0af77fcbde
11 changed files with 1027 additions and 1027 deletions

File diff suppressed because it is too large Load diff

View file

@ -20,50 +20,50 @@ static QTextStream _out( stdout, QIODevice::WriteOnly );
void openWallet()
{
_out << "About to ask for wallet async" << endl;
_out << "About to ask for wallet async" << endl;
// we have no wallet: ask for one.
KWallet::Wallet *wallet = KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Asynchronous );
// we have no wallet: ask for one.
KWallet::Wallet *wallet = KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Asynchronous );
WalletReceiver r;
r.connect( wallet, SIGNAL( walletOpened(bool) ), SLOT( walletOpened(bool) ) );
WalletReceiver r;
r.connect( wallet, SIGNAL( walletOpened(bool) ), SLOT( walletOpened(bool) ) );
_out << "About to start 30 second event loop" << endl;
_out << "About to start 30 second event loop" << endl;
QTimer::singleShot( 30000, qApp, SLOT( quit() ) );
int ret = qApp->exec();
QTimer::singleShot( 30000, qApp, SLOT( quit() ) );
int ret = qApp->exec();
if ( ret == 0 )
_out << "Timed out!" << endl;
else
_out << "Success!" << endl;
if ( ret == 0 ) {
_out << "Timed out!" << endl;
} else {
_out << "Success!" << endl;
}
}
void WalletReceiver::walletOpened( bool got )
{
_out << "Got async wallet: " << got << endl;
qApp->exit( 1 );
_out << "Got async wallet: " << got << endl;
qApp->exit( 1 );
}
int main( int argc, char *argv[] )
{
KAboutData aboutData("kwalletasync", 0, ki18n("kwalletasync"), "version");
KComponentData componentData(&aboutData);
QApplication app( argc, argv );
KAboutData aboutData("kwalletasync", 0, ki18n("kwalletasync"), "version");
KComponentData componentData(&aboutData);
QApplication app( argc, argv );
// force name with D-BUS
QDBusReply<QDBusConnectionInterface::RegisterServiceReply> reply
= QDBusConnection::sessionBus().interface()->registerService( "org.kde.kwalletasync",
QDBusConnectionInterface::ReplaceExistingService );
// force name with D-BUS
QDBusReply<QDBusConnectionInterface::RegisterServiceReply> reply
= QDBusConnection::sessionBus().interface()->registerService( "org.kde.kwalletasync",
QDBusConnectionInterface::ReplaceExistingService );
if ( !reply.isValid() )
{
_out << "D-BUS name request returned " << reply.error().name() << endl;
}
if ( !reply.isValid() ) {
_out << "D-BUS name request returned " << reply.error().name() << endl;
}
openWallet();
openWallet();
return 0;
return 0;
}
// vim: set noet ts=4 sts=4 sw=4:

View file

@ -41,23 +41,23 @@ KWalletAutoClose::KWalletAutoClose() : QObject()
void KWalletAutoClose::openWallet()
{
_out << "Opening wallet synchronously" << endl;
Wallet *wallet = Wallet::openWallet(Wallet::NetworkWallet(), 0, Wallet::Synchronous);
_out << "Exiting without closing. The wallet should autoclose." << endl;
Q_UNUSED(wallet);
kapp->exit(0);
_out << "Opening wallet synchronously" << endl;
Wallet *wallet = Wallet::openWallet(Wallet::NetworkWallet(), 0, Wallet::Synchronous);
_out << "Exiting without closing. The wallet should autoclose." << endl;
Q_UNUSED(wallet);
kapp->exit(0);
}
int main(int argc, char *argv[])
{
KAboutData aboutData("kwalletmany", 0, ki18n("kwalletmany"), "version");
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
KWalletAutoClose m;
QTimer::singleShot(0, &m, SLOT(openWallet()));
return app.exec();
KAboutData aboutData("kwalletmany", 0, ki18n("kwalletmany"), "version");
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
KWalletAutoClose m;
QTimer::singleShot(0, &m, SLOT(openWallet()));
return app.exec();
}
#include "moc_kwalletautoclose.cpp"

View file

@ -28,13 +28,13 @@
class KWalletAutoClose : public QObject
{
Q_OBJECT
Q_OBJECT
public:
KWalletAutoClose();
KWalletAutoClose();
public Q_SLOTS:
void openWallet();
void openWallet();
};
#endif // KWALLETAUTOCLOSE_H

View file

@ -21,72 +21,71 @@ static QTextStream _out( stdout, QIODevice::WriteOnly );
void openWallet()
{
_out << "About to ask for wallet async" << endl;
_out << "About to ask for wallet async" << endl;
// we have no wallet: ask for one.
KWallet::Wallet *wallet = KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Asynchronous );
// we have no wallet: ask for one.
KWallet::Wallet *wallet = KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Asynchronous );
WalletReceiver r;
r.connect( wallet, SIGNAL( walletOpened(bool) ), SLOT( walletOpened(bool) ) );
WalletReceiver r;
r.connect( wallet, SIGNAL( walletOpened(bool) ), SLOT( walletOpened(bool) ) );
_out << "About to ask for wallet sync" << endl;
_out << "About to ask for wallet sync" << endl;
wallet = KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Synchronous );
wallet = KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Synchronous );
_out << "Got sync wallet: " << (wallet != 0) << endl;
_out << "About to start 30 second event loop" << endl;
_out << "Got sync wallet: " << (wallet != 0) << endl;
_out << "About to start 30 second event loop" << endl;
QTimer::singleShot( 30000, qApp, SLOT( quit() ) );
int ret = qApp->exec();
QTimer::singleShot( 30000, qApp, SLOT( quit() ) );
int ret = qApp->exec();
if ( ret == 0 ) {
_out << "Timed out!" << endl;
} else {
_out << "Success!" << endl;
}
if ( ret == 0 )
_out << "Timed out!" << endl;
else
_out << "Success!" << endl;
QMap<QString,QString> p;
ret = wallet->readPasswordList("*", p);
_out << "readPasswordList returned: " << ret << endl;
_out << "readPasswordList returned " << p.keys().count() << " entries" << endl;
QMap<QString, QMap<QString, QString> > q;
ret = wallet->readMapList("*", q);
_out << "readMapList returned: " << ret << endl;
_out << "readMapList returned " << q.keys().count() << " entries" << endl;
QMap<QString,QString> p;
ret = wallet->readPasswordList("*", p);
_out << "readPasswordList returned: " << ret << endl;
_out << "readPasswordList returned " << p.keys().count() << " entries" << endl;
QMap<QString, QMap<QString, QString> > q;
ret = wallet->readMapList("*", q);
_out << "readMapList returned: " << ret << endl;
_out << "readMapList returned " << q.keys().count() << " entries" << endl;
QMap<QString, QByteArray> s;
ret = wallet->readEntryList("*", s);
_out << "readEntryList returned: " << ret << endl;
_out << "readEntryList returned " << s.keys().count() << " entries" << endl;
QMap<QString, QByteArray> s;
ret = wallet->readEntryList("*", s);
_out << "readEntryList returned: " << ret << endl;
_out << "readEntryList returned " << s.keys().count() << " entries" << endl;
delete wallet;
delete wallet;
}
void WalletReceiver::walletOpened( bool got )
{
_out << "Got async wallet: " << got << endl;
qApp->exit( 1 );
_out << "Got async wallet: " << got << endl;
qApp->exit( 1 );
}
int main( int argc, char *argv[] )
{
KAboutData aboutData("kwalletboth", 0, ki18n("kwalletboth"), "version");
KComponentData componentData(&aboutData);
QApplication app( argc, argv );
KAboutData aboutData("kwalletboth", 0, ki18n("kwalletboth"), "version");
KComponentData componentData(&aboutData);
QApplication app( argc, argv );
// force name with D-BUS
QDBusReply<QDBusConnectionInterface::RegisterServiceReply> reply
= QDBusConnection::sessionBus().interface()->registerService( "org.kde.kwalletboth",
QDBusConnectionInterface::ReplaceExistingService );
// force name with D-BUS
QDBusReply<QDBusConnectionInterface::RegisterServiceReply> reply
= QDBusConnection::sessionBus().interface()->registerService( "org.kde.kwalletboth",
QDBusConnectionInterface::ReplaceExistingService );
if ( !reply.isValid() )
{
_out << "D-BUS name request returned " << reply.error().name() << endl;
}
if ( !reply.isValid() ) {
_out << "D-BUS name request returned " << reply.error().name() << endl;
}
openWallet();
openWallet();
return 0;
return 0;
}
// vim: set noet ts=4 sts=4 sw=4:

View file

@ -48,57 +48,57 @@ KWalletMany::~KWalletMany()
void KWalletMany::walletOpened(bool open)
{
_out << "Got async wallet: " << (open) << endl;
--_pending;
if (_pending == 0) {
quit();
}
_out << "Got async wallet: " << (open) << endl;
--_pending;
if (_pending == 0) {
quit();
}
}
void KWalletMany::quit()
{
if (_pending == 0) {
_out << "Success!" << endl;
} else {
_out << "Failed: " << _pending << " requests were not handled!" << endl;
}
_loop.quit();
if (_pending == 0) {
_out << "Success!" << endl;
} else {
_out << "Failed: " << _pending << " requests were not handled!" << endl;
}
_loop.quit();
}
void KWalletMany::openWallet()
{
QEventLoop waitLoop;
// open plenty of wallets in synchronous and asynchronous mode
for (int i = 0; i < NUMWALLETS; ++i) {
// request asynchronous wallet
_out << "About to ask for wallet async" << endl;
Wallet *wallet;
wallet = Wallet::openWallet(Wallet::NetworkWallet(), 0, Wallet::Asynchronous);
connect(wallet, SIGNAL(walletOpened(bool)), SLOT(walletOpened(bool)));
_wallets.append(wallet);
QTimer::singleShot(500, &waitLoop, SLOT(quit()));
waitLoop.exec();
}
_loop.exec();
while (!_wallets.isEmpty()) {
delete _wallets.takeFirst();
}
QEventLoop waitLoop;
// open plenty of wallets in synchronous and asynchronous mode
for (int i = 0; i < NUMWALLETS; ++i) {
// request asynchronous wallet
_out << "About to ask for wallet async" << endl;
Wallet *wallet;
wallet = Wallet::openWallet(Wallet::NetworkWallet(), 0, Wallet::Asynchronous);
connect(wallet, SIGNAL(walletOpened(bool)), SLOT(walletOpened(bool)));
_wallets.append(wallet);
QTimer::singleShot(500, &waitLoop, SLOT(quit()));
waitLoop.exec();
}
_loop.exec();
while (!_wallets.isEmpty()) {
delete _wallets.takeFirst();
}
}
int main(int argc, char *argv[])
{
KAboutData aboutData("kwalletmany", 0, ki18n("kwalletmany"), "version");
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
KWalletMany m;
QTimer::singleShot(0, &m, SLOT(openWallet()));
QTimer::singleShot(30000, &m, SLOT(quit()));
return app.exec();
KAboutData aboutData("kwalletmany", 0, ki18n("kwalletmany"), "version");
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
KWalletMany m;
QTimer::singleShot(0, &m, SLOT(openWallet()));
QTimer::singleShot(30000, &m, SLOT(quit()));
return app.exec();
}
#include "moc_kwalletmany.cpp"

View file

@ -33,21 +33,21 @@ namespace KWallet { class Wallet; }
class KWalletMany : public QObject
{
Q_OBJECT
Q_OBJECT
public:
KWalletMany();
~KWalletMany();
KWalletMany();
~KWalletMany();
public slots:
void openWallet();
void quit();
void walletOpened(bool open);
void openWallet();
void quit();
void walletOpened(bool open);
private:
QList<KWallet::Wallet*> _wallets;
int _pending;
QEventLoop _loop;
QList<KWallet::Wallet*> _wallets;
int _pending;
QEventLoop _loop;
};
#endif // KWALLETMANY_H

View file

@ -34,74 +34,74 @@ static QString _kdewallet;
int openAndClose()
{
QDBusInterface service("org.kde.kwalletd", "/modules/kwalletd");
if (!service.isValid()) {
_out << "Constructed service is invalid!" << endl;
return 1;
}
QDBusReply<int> h = service.call(QDBus::Block, "open", _kdewallet, (qlonglong)0, "kwalletnoautoclose");
if (!h.isValid() || h.value() < 0) {
_out << "Opening the wallet failed!" << endl;
_out << "Error: " << h.error().message() << endl;
return 1;
} else {
_out << "Wallet opened." << endl;
}
QDBusInterface service("org.kde.kwalletd", "/modules/kwalletd");
if (!service.isValid()) {
_out << "Constructed service is invalid!" << endl;
return 1;
}
QDBusReply<int> h = service.call(QDBus::Block, "open", _kdewallet, (qlonglong)0, "kwalletnoautoclose");
if (!h.isValid() || h.value() < 0) {
_out << "Opening the wallet failed!" << endl;
_out << "Error: " << h.error().message() << endl;
return 1;
} else {
_out << "Wallet opened." << endl;
}
_out << "closing the wallet" << endl;
QDBusReply<int> r = service.call(QDBus::Block, "close", h.value(), false, "kwalletnoautoclose");
return r;
_out << "closing the wallet" << endl;
QDBusReply<int> r = service.call(QDBus::Block, "close", h.value(), false, "kwalletnoautoclose");
return r;
}
int main(int argc, char *argv[])
{
KAboutData aboutData("kwalletnoautoclose", 0, ki18n("kwalletnoautoclose"), "version");
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
KAboutData aboutData("kwalletnoautoclose", 0, ki18n("kwalletnoautoclose"), "version");
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
QDBusInterface service("org.kde.kwalletd", "/modules/kwalletd");
if (!service.isValid()) {
_out << "Constructed service is invalid!" << endl;
return 1;
}
QDBusReply<bool> r = service.call(QDBus::Block, "isEnabled");
if (!r.isValid() || !r) {
_out << "kwalletd is disabled or not running!" << endl;
return 1;
}
QDBusReply<QString> kdewallet = service.call(QDBus::Block, "localWallet");
_kdewallet = kdewallet;
_out << "local wallet is " << _kdewallet << endl;
QDBusReply<bool> open = service.call(QDBus::Block, "isOpen", _kdewallet);
if (open) {
_out << "wallet is already open. Please close to run this test." << endl;
return 1;
}
int rc;
_out << "Opening and closing the wallet properly." << endl;
rc = openAndClose();
if (rc != 0) {
_out << "FAILED!" << endl;
return rc;
}
_out << "Opening and exiting." << endl;
QDBusReply<int> h = service.call(QDBus::Block, "open", _kdewallet, (qlonglong)0, "kwalletnoautoclose");
if (h < 0) {
_out << "Opening the wallet failed!" << endl;
return 1;
} else {
_out << "Wallet opened." << endl;
}
_out << "Exiting. Wallet should stay open." << endl;
return 0;
QDBusInterface service("org.kde.kwalletd", "/modules/kwalletd");
if (!service.isValid()) {
_out << "Constructed service is invalid!" << endl;
return 1;
}
QDBusReply<bool> r = service.call(QDBus::Block, "isEnabled");
if (!r.isValid() || !r) {
_out << "kwalletd is disabled or not running!" << endl;
return 1;
}
QDBusReply<QString> kdewallet = service.call(QDBus::Block, "localWallet");
_kdewallet = kdewallet;
_out << "local wallet is " << _kdewallet << endl;
QDBusReply<bool> open = service.call(QDBus::Block, "isOpen", _kdewallet);
if (open) {
_out << "wallet is already open. Please close to run this test." << endl;
return 1;
}
int rc;
_out << "Opening and closing the wallet properly." << endl;
rc = openAndClose();
if (rc != 0) {
_out << "FAILED!" << endl;
return rc;
}
_out << "Opening and exiting." << endl;
QDBusReply<int> h = service.call(QDBus::Block, "open", _kdewallet, (qlonglong)0, "kwalletnoautoclose");
if (h < 0) {
_out << "Opening the wallet failed!" << endl;
return 1;
} else {
_out << "Wallet opened." << endl;
}
_out << "Exiting. Wallet should stay open." << endl;
return 0;
}

View file

@ -17,27 +17,27 @@ static QTextStream _out(stdout, QIODevice::WriteOnly);
void openWallet()
{
_out << "About to ask for wallet /tmp/test.kwl sync" << endl;
_out << "About to ask for wallet /tmp/test.kwl sync" << endl;
KWallet::Wallet *wallet = KWallet::Wallet::openWallet("/tmp/test.kwl", 0, KWallet::Wallet::Path);
KWallet::Wallet *wallet = KWallet::Wallet::openWallet("/tmp/test.kwl", 0, KWallet::Wallet::Path);
_out << "Got path wallet: " << (wallet != 0) << endl;
if (wallet) {
_out << "Closing wallet" << endl;
delete wallet;
}
kapp->exit(0);
_out << "Got path wallet: " << (wallet != 0) << endl;
if (wallet) {
_out << "Closing wallet" << endl;
delete wallet;
}
kapp->exit(0);
}
int main(int argc, char *argv[])
{
KAboutData aboutData("kwalletpath", 0, ki18n("kwalletpath"), "version");
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
KAboutData aboutData("kwalletpath", 0, ki18n("kwalletpath"), "version");
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
openWallet();
openWallet();
exit(0);
exit(0);
}

View file

@ -18,32 +18,31 @@ static QTextStream _out( stdout, QIODevice::WriteOnly );
void openWallet()
{
_out << "About to ask for wallet sync" << endl;
_out << "About to ask for wallet sync" << endl;
KWallet::Wallet *w = KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Synchronous );
KWallet::Wallet *w = KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(), 0, KWallet::Wallet::Synchronous );
_out << "Got sync wallet: " << (w != 0) << endl;
_out << "Got sync wallet: " << (w != 0) << endl;
}
int main( int argc, char *argv[] )
{
KAboutData aboutData("kwalletsync", 0, ki18n("kwalletsync"), "version");
KComponentData componentData(&aboutData);
QApplication app( argc, argv );
KAboutData aboutData("kwalletsync", 0, ki18n("kwalletsync"), "version");
KComponentData componentData(&aboutData);
QApplication app( argc, argv );
// force name with D-BUS
QDBusReply<QDBusConnectionInterface::RegisterServiceReply> reply
= QDBusConnection::sessionBus().interface()->registerService( "org.kde.kwalletsync",
QDBusConnectionInterface::ReplaceExistingService );
// force name with D-BUS
QDBusReply<QDBusConnectionInterface::RegisterServiceReply> reply
= QDBusConnection::sessionBus().interface()->registerService( "org.kde.kwalletsync",
QDBusConnectionInterface::ReplaceExistingService );
if ( !reply.isValid() )
{
_out << "D-BUS name request returned " << reply.error().name() << endl;
}
if ( !reply.isValid() ) {
_out << "D-BUS name request returned " << reply.error().name() << endl;
}
openWallet();
openWallet();
return 0;
return 0;
}
// vim: set noet ts=4 sts=4 sw=4:

View file

@ -30,7 +30,6 @@ int main(int argc, char **argv)
int ret = app.exec();
return ret;
}