summaryrefslogtreecommitdiffstats
path: root/tdeabc/tests
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-02-15 21:57:54 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-02-15 21:57:54 -0600
commited99a30644c19b0a3cf0d2147243532df4daa16b (patch)
tree7f3f2850e59824fdf100a642367a82b1e7f0204f /tdeabc/tests
parente5f2d46e9caf6942f365f1b454087dda71a340f7 (diff)
downloadtdelibs-ed99a30644c19b0a3cf0d2147243532df4daa16b.tar.gz
tdelibs-ed99a30644c19b0a3cf0d2147243532df4daa16b.zip
Rename additional header files to avoid conflicts with KDE4
Diffstat (limited to 'tdeabc/tests')
-rw-r--r--tdeabc/tests/Makefile.am55
-rw-r--r--tdeabc/tests/bigread.cpp65
-rw-r--r--tdeabc/tests/bigwrite.cpp70
-rw-r--r--tdeabc/tests/kabcargl.cpp70
-rw-r--r--tdeabc/tests/testaddressee.cpp57
-rw-r--r--tdeabc/tests/testaddresseelist.cpp196
-rw-r--r--tdeabc/tests/testaddressfmt.cpp63
-rw-r--r--tdeabc/tests/testaddresslineedit.cpp29
-rw-r--r--tdeabc/tests/testdb.cpp33
-rw-r--r--tdeabc/tests/testdistlist.cpp59
-rw-r--r--tdeabc/tests/testkabc.cpp62
-rw-r--r--tdeabc/tests/testkabcdlg.cpp45
-rw-r--r--tdeabc/tests/testldapclient.cpp161
-rw-r--r--tdeabc/tests/testldapclient.h51
-rw-r--r--tdeabc/tests/testlock.cpp206
-rw-r--r--tdeabc/tests/testlock.h51
16 files changed, 1273 insertions, 0 deletions
diff --git a/tdeabc/tests/Makefile.am b/tdeabc/tests/Makefile.am
new file mode 100644
index 000000000..201cf746a
--- /dev/null
+++ b/tdeabc/tests/Makefile.am
@@ -0,0 +1,55 @@
+# Make sure $(all_includes) remains last!
+INCLUDES = -I$(top_builddir)/kabc -I$(top_srcdir)/kabc -I$(top_srcdir)/kab \
+ -I$(srcdir)/../vcardparser/ -I$(srcdir)/../vcard/include \
+ -I$(srcdir)/../vcard/include/generated \
+ -I$(srcdir)/../vcardparser $(all_includes)
+LDADD = ../libkabc.la
+
+METASOURCES = AUTO
+
+check_PROGRAMS = testlock testldapclient
+
+testlock_LDFLAGS = $(all_libraries)
+testlock_SOURCES = testlock.cpp
+
+testldapclient_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+testldapclient_SOURCES = testldapclient.cpp
+
+EXTRA_PROGRAMS = testkabc testkabcdlg testdistlist bigread bigwrite testdb \
+ testaddressee testaddresseelist testaddressfmt kabcargl testaddresslineedit
+
+testkabc_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+testkabc_SOURCES = testkabc.cpp
+
+testaddressee_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+testaddressee_SOURCES = testaddressee.cpp
+
+testaddresseelist_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+testaddresseelist_SOURCES = testaddresseelist.cpp
+
+testaddressfmt_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+testaddressfmt_SOURCES = testaddressfmt.cpp
+
+testkabcdlg_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+testkabcdlg_SOURCES = testkabcdlg.cpp
+
+testdistlist_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+testdistlist_SOURCES = testdistlist.cpp
+
+testaddresslineedit_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+testaddresslineedit_SOURCES = testaddresslineedit.cpp
+
+bigread_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+bigread_LDADD = ../libkabc.la $(top_builddir)/tdeabc/plugins/file/libkabc_file.la
+bigread_SOURCES = bigread.cpp
+
+bigwrite_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+bigwrite_LDADD = ../libkabc.la $(top_builddir)/tdeabc/plugins/file/libkabc_file.la
+bigwrite_SOURCES = bigwrite.cpp
+
+testdb_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+testdb_SOURCES = testdb.cpp
+
+kabcargl_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor
+kabcargl_SOURCES = kabcargl.cpp
+
diff --git a/tdeabc/tests/bigread.cpp b/tdeabc/tests/bigread.cpp
new file mode 100644
index 000000000..a5022367c
--- /dev/null
+++ b/tdeabc/tests/bigread.cpp
@@ -0,0 +1,65 @@
+#include <sys/times.h>
+
+#include <tdeaboutdata.h>
+#include <tdeapplication.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+
+#include "addressbook.h"
+#include "vcardformat.h"
+#include "plugins/file/resourcefile.h"
+#if 0
+#include "resourcesql.h"
+#endif
+
+using namespace KABC;
+
+int main(int argc,char **argv)
+{
+ TDEAboutData aboutData("bigread","BigReadKabc","0.1");
+ TDECmdLineArgs::init(argc,argv,&aboutData);
+
+ TDEApplication app( false, false );
+
+ AddressBook ab;
+
+ ResourceFile r( "my.kabc", "vcard2" );
+ ab.addResource( &r );
+
+#if 0
+ ResourceSql rsql( &ab, "root", "kde4ever", "localhost" );
+ ab.addResource( &rsql );
+#endif
+
+ struct tms start;
+
+ times( &start );
+
+#if 0
+ kdDebug() << "utime : " << int( start.tms_utime ) << endl;
+ kdDebug() << "stime : " << int( start.tms_stime ) << endl;
+ kdDebug() << "cutime: " << int( start.tms_cutime ) << endl;
+ kdDebug() << "cstime: " << int( start.tms_cstime ) << endl;
+#endif
+
+ kdDebug() << "Start load" << endl;
+ ab.load();
+ kdDebug() << "Finished load" << endl;
+
+ struct tms end;
+
+ times( &end );
+
+#if 0
+ kdDebug() << "utime : " << int( end.tms_utime ) << endl;
+ kdDebug() << "stime : " << int( end.tms_stime ) << endl;
+ kdDebug() << "cutime: " << int( end.tms_cutime ) << endl;
+ kdDebug() << "cstime: " << int( end.tms_cstime ) << endl;
+#endif
+
+ kdDebug() << "UTime: " << int( end.tms_utime ) - int( start.tms_utime ) << endl;
+ kdDebug() << "STime: " << int( end.tms_stime ) - int( start.tms_stime ) << endl;
+
+// ab.dump();
+}
diff --git a/tdeabc/tests/bigwrite.cpp b/tdeabc/tests/bigwrite.cpp
new file mode 100644
index 000000000..4b9fa7bc3
--- /dev/null
+++ b/tdeabc/tests/bigwrite.cpp
@@ -0,0 +1,70 @@
+#include <sys/times.h>
+
+#include <tdeaboutdata.h>
+#include <tdeapplication.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+
+#include "addressbook.h"
+#include "vcardformat.h"
+#include "plugins/file/resourcefile.h"
+
+using namespace KABC;
+
+int main(int argc,char **argv)
+{
+ TDEAboutData aboutData("bigwrite","BigWriteKabc","0.1");
+ TDECmdLineArgs::init(argc,argv,&aboutData);
+
+ TDEApplication app( false, false );
+
+ AddressBook ab;
+ ResourceFile r( "my.kabc", "vcard" );
+ ab.addResource( &r );
+
+ for( int i = 0; i < 5000; ++i ) {
+ Addressee a;
+ a.setGivenName( "number" + TQString::number( i ) );
+ a.setFamilyName( "Name" );
+ a.insertEmail( TQString::number( i ) + "@domain" );
+
+ ab.insertAddressee( a );
+ }
+ printf( "\n" );
+
+ Ticket *t = ab.requestSaveTicket( &r );
+ if ( t ) {
+ struct tms start;
+
+ times( &start );
+
+#if 0
+ kdDebug() << "utime : " << int( start.tms_utime ) << endl;
+ kdDebug() << "stime : " << int( start.tms_stime ) << endl;
+ kdDebug() << "cutime: " << int( start.tms_cutime ) << endl;
+ kdDebug() << "cstime: " << int( start.tms_cstime ) << endl;
+#endif
+
+ if ( !ab.save( t ) ) {
+ kdDebug() << "Can't save." << endl;
+ }
+
+ struct tms end;
+
+ times( &end );
+
+#if 0
+ kdDebug() << "utime : " << int( end.tms_utime ) << endl;
+ kdDebug() << "stime : " << int( end.tms_stime ) << endl;
+ kdDebug() << "cutime: " << int( end.tms_cutime ) << endl;
+ kdDebug() << "cstime: " << int( end.tms_cstime ) << endl;
+#endif
+
+ kdDebug() << "UTime: " << int( end.tms_utime ) - int( start.tms_utime ) << endl;
+ kdDebug() << "STime: " << int( end.tms_stime ) - int( start.tms_stime ) << endl;
+
+ } else {
+ kdDebug() << "No ticket for save." << endl;
+ }
+}
diff --git a/tdeabc/tests/kabcargl.cpp b/tdeabc/tests/kabcargl.cpp
new file mode 100644
index 000000000..e38a8a22e
--- /dev/null
+++ b/tdeabc/tests/kabcargl.cpp
@@ -0,0 +1,70 @@
+/*
+ This file is part of libkabc.
+ Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <tqfile.h>
+#include <tqtextstream.h>
+#include <tqregexp.h>
+
+#include <tdeaboutdata.h>
+#include <tdeapplication.h>
+#include <kdebug.h>
+#include <tdecmdlineargs.h>
+#include <tdeglobal.h>
+#include <kstandarddirs.h>
+
+#include "stdaddressbook.h"
+
+using namespace KABC;
+
+int main(int argc,char **argv)
+{
+ TDEAboutData aboutData("kabcargl","Fix broken pre3.0rc3 format","0.1");
+ aboutData.addAuthor("Cornelius Schumacher", 0, "schumacher@kde.org");
+
+ TDECmdLineArgs::init(argc,argv,&aboutData);
+
+ TDEApplication app;
+
+ TQString filename = StdAddressBook::fileName();
+
+ TQFile f( filename );
+ if ( !f.open( IO_ReadOnly ) ) {
+ kdDebug() << "Error opening file '" << filename << "' for reading." << endl;
+ return 1;
+ }
+
+ TQTextStream t( &f );
+ t.setEncoding(TQTextStream::UnicodeUTF8);
+ TQString text = t.read();
+ f.close();
+
+ text = TQString::fromUtf8( text.local8Bit() );
+ text.replace( "\n", "\r\n" );
+
+ if ( !f.open( IO_WriteOnly ) ) {
+ kdDebug() << "Error opening file '" << filename << "' for writing." << endl;
+ return 1;
+ }
+
+ TQTextStream t2( &f );
+ t2.setEncoding(TQTextStream::UnicodeUTF8);
+ t2 << text;
+ f.close();
+}
diff --git a/tdeabc/tests/testaddressee.cpp b/tdeabc/tests/testaddressee.cpp
new file mode 100644
index 000000000..ef55ae403
--- /dev/null
+++ b/tdeabc/tests/testaddressee.cpp
@@ -0,0 +1,57 @@
+#include <tdeaboutdata.h>
+#include <tdeapplication.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+#include <kstandarddirs.h>
+
+#include "addressbook.h"
+#include "plugins/file/resourcefile.h"
+#include "formats/binaryformat.h"
+#include "vcardformat.h"
+#include "phonenumber.h"
+
+using namespace KABC;
+
+static const TDECmdLineOptions options[] =
+{
+ { "save", "", 0 },
+ { "number", "", 0 },
+ TDECmdLineLastOption
+};
+
+int main(int argc,char **argv)
+{
+ TDEAboutData aboutData("testaddressee","TestAddressee","0.1");
+ TDECmdLineArgs::init(argc, argv, &aboutData);
+ TDECmdLineArgs::addCmdLineOptions(options);
+
+ TDEApplication app;
+ TDECmdLineArgs* args = TDECmdLineArgs::parsedArgs();
+
+ kdDebug() << "Creating a" << endl;
+ Addressee a;
+
+ kdDebug() << "tick1" << endl;
+ a.setGivenName("Hans");
+ kdDebug() << "tick2" << endl;
+ a.setPrefix("Dr.");
+
+ kdDebug() << "Creating b" << endl;
+ Addressee b( a );
+
+ kdDebug() << "tack1" << endl;
+ a.setFamilyName("Wurst");
+ kdDebug() << "tack2" << endl;
+ a.setNickName("hansi");
+
+ kdDebug() << "Creating c" << endl;
+ Addressee c = a;
+
+ kdDebug() << "tock1" << endl;
+ c.setGivenName("Eberhard");
+
+ a.dump();
+ b.dump();
+ c.dump();
+}
diff --git a/tdeabc/tests/testaddresseelist.cpp b/tdeabc/tests/testaddresseelist.cpp
new file mode 100644
index 000000000..f247f1744
--- /dev/null
+++ b/tdeabc/tests/testaddresseelist.cpp
@@ -0,0 +1,196 @@
+#include <tdeaboutdata.h>
+#include <tdeapplication.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+#include <kstandarddirs.h>
+
+#include "addressbook.h"
+#include "addresseelist.h"
+
+using namespace KABC;
+
+static const TDECmdLineOptions options[] =
+{
+ { "save", "", 0 },
+ { "number", "", 0 },
+ TDECmdLineLastOption
+};
+
+int main(int /*argc*/,char /* **argv*/)
+{
+/* TDEAboutData aboutData("testaddresseelist","TestAddresseeList","0.1");
+ TDECmdLineArgs::init(argc, argv, &aboutData);
+ TDECmdLineArgs::addCmdLineOptions(options);
+
+ TDEApplication app;
+ TDECmdLineArgs* args = TDECmdLineArgs::parsedArgs(); */
+
+ kdDebug() << "Creating addressees" << endl;
+ Addressee a, b, c, d, e, f;
+ a.setGivenName ("Peter");
+ a.setFamilyName("Pan");
+ a.setFormattedName("Pan, Peter");
+ a.setUid("Asdf");
+ b.setGivenName ("Phileas");
+ b.setFamilyName("Fogg");
+ b.setFormattedName("Fogg, Phileas");
+ b.setUid("Rsdf");
+ c.setGivenName ("Jim");
+ c.setFamilyName("Hawkins");
+ c.setFormattedName("Hawkins, Jim");
+ c.setUid("Fhwn");
+ d.setGivenName ("John");
+ d.setFamilyName("Silver");
+ d.setPrefix ("Long");
+ d.setFormattedName("Long John Silver");
+ d.setUid("Z2hk");
+ e.setGivenName ("Alice");
+ e.setFamilyName("Liddel");
+ e.setFormattedName("Liddel, Alice");
+ e.setUid("kk45");
+ f.setGivenName ("Edmond");
+ f.setFamilyName("Dantes");
+ f.setFormattedName("Dantes, Edmond");
+ f.setUid("78ze");
+
+ kdDebug() << "Adding to list" << endl;
+ AddresseeList list;
+ list.append(a);
+ list.append(b);
+ list.append(c);
+ list.append(d);
+ list.append(e);
+ list.append(f);
+
+ list.sortBy(FamilyName);
+ if ( !( (*list.at(0)).uid()=="78ze"
+ && (*list.at(1)).uid()=="Rsdf"
+ && (*list.at(2)).uid()=="Fhwn"
+ && (*list.at(3)).uid()=="kk45"
+ && (*list.at(4)).uid()=="Asdf"
+ && (*list.at(5)).uid()=="Z2hk"
+ ) ) {
+ kdError() << "SORTING BY FAMILY NAME NOT CORRECT!" << endl;
+ kdDebug() << "list sorted by family name:" << endl;
+ list.dump();
+ } else {
+ kdDebug() << "Sorting by family name correct." << endl;
+ }
+ list.setReverseSorting(true);
+ list.sort();
+ if ( !( (*list.at(5)).uid()=="78ze"
+ && (*list.at(4)).uid()=="Rsdf"
+ && (*list.at(3)).uid()=="Fhwn"
+ && (*list.at(2)).uid()=="kk45"
+ && (*list.at(1)).uid()=="Asdf"
+ && (*list.at(0)).uid()=="Z2hk"
+ ) ) {
+ kdError() << "REVERSE SORTING BY FAMILY NAME NOT CORRECT!" << endl;
+ kdDebug() << "list reverse sorted by family name:" << endl;
+ list.dump();
+ } else {
+ kdDebug() << "Reverse sorting by family name correct." << endl;
+ }
+
+ list.setReverseSorting(false);
+ list.sortBy(FormattedName);
+ if ( !( (*list.at(0)).uid()=="78ze"
+ && (*list.at(1)).uid()=="Rsdf"
+ && (*list.at(2)).uid()=="Fhwn"
+ && (*list.at(3)).uid()=="kk45"
+ && (*list.at(4)).uid()=="Z2hk"
+ && (*list.at(5)).uid()=="Asdf"
+ ) ) {
+ kdError() << "SORTING BY FORMATTED NAME NOT CORRECT!" << endl;
+ kdDebug() << "list sorted by formatted name:" << endl;
+ list.dump();
+ } else {
+ kdDebug() << "Sorting by formatted name correct." << endl;
+ }
+ list.setReverseSorting(true);
+ list.sort();
+ if ( !( (*list.at(5)).uid()=="78ze"
+ && (*list.at(4)).uid()=="Rsdf"
+ && (*list.at(3)).uid()=="Fhwn"
+ && (*list.at(2)).uid()=="kk45"
+ && (*list.at(1)).uid()=="Z2hk"
+ && (*list.at(0)).uid()=="Asdf"
+ ) ) {
+ kdError() << "REVERSE SORTING BY FORMATTED NAME NOT CORRECT!" << endl;
+ kdDebug() << "list reverse sorted by formatted name:" << endl;
+ list.dump();
+ } else {
+ kdDebug() << "Reverse sorting by formatted name correct." << endl;
+ }
+
+
+ list.setReverseSorting(false);
+ list.sortBy(Uid);
+ if ( !( (*list.at(0)).uid()=="78ze"
+ && (*list.at(1)).uid()=="Asdf"
+ && (*list.at(2)).uid()=="Fhwn"
+ && (*list.at(3)).uid()=="Rsdf"
+ && (*list.at(4)).uid()=="Z2hk"
+ && (*list.at(5)).uid()=="kk45"
+ ) ) {
+ kdError() << "SORTING BY UID NOT CORRECT!" << endl;
+ kdDebug() << "list sorted by Uid:" << endl;
+ list.dump();
+ } else {
+ kdDebug() << "Sorting by Uid correct." << endl;
+ }
+ list.setReverseSorting(true);
+ list.sortBy(Uid);
+ if ( !( (*list.at(5)).uid()=="78ze"
+ && (*list.at(4)).uid()=="Asdf"
+ && (*list.at(3)).uid()=="Fhwn"
+ && (*list.at(2)).uid()=="Rsdf"
+ && (*list.at(1)).uid()=="Z2hk"
+ && (*list.at(0)).uid()=="kk45"
+ ) ) {
+ kdError() << "REVERSE SORTING BY UID NOT CORRECT!" << endl;
+ kdDebug() << "list sorted by Uid:" << endl;
+ list.dump();
+ } else {
+ kdDebug() << "Reverse sorting by Uid correct." << endl;
+ }
+
+ // zero, one or two entries might give errors in a poor sorting
+ // implementation
+ kdDebug() << "sorting empty list" << endl;
+ AddresseeList list2;
+ list2.sort();
+
+ kdDebug() << "sorting one entry list" << endl;
+ list2.append(a);
+ list2.sort();
+
+ kdDebug() << "sorting two entry list" << endl;
+ list2.append(f);
+ list2.setReverseSorting(false);
+ list2.sort();
+ if ( !( (*list2.at(0)).uid()=="78ze"
+ && (*list2.at(1)).uid()=="Asdf"
+ ) ) {
+ kdError() << "SORTING BY FORMATTED NAME IN A TWO ENTRY LIST NOT CORRECT!" << endl;
+ kdDebug() << "list sorted by formatted name, two entries:" << endl;
+ list2.dump();
+ } else {
+ kdDebug() << "Sorting by FormattedName in a two entry list correct." << endl;
+ }
+ list2.setReverseSorting(true);
+ list2.sort();
+ if ( !( (*list2.at(1)).uid()=="78ze"
+ && (*list2.at(0)).uid()=="Asdf"
+ ) ) {
+ kdError() << "REVERSE SORTING BY FORMATTED NAME IN A TWO ENTRY LIST NOT CORRECT!" << endl;
+ kdDebug() << "list reverse sorted by formatted name, two entries:" << endl;
+ list2.dump();
+ } else {
+ kdDebug() << "Reverse sorting by FormattedName in a two entry list correct." << endl;
+ }
+
+}
+
+
diff --git a/tdeabc/tests/testaddressfmt.cpp b/tdeabc/tests/testaddressfmt.cpp
new file mode 100644
index 000000000..2eb438335
--- /dev/null
+++ b/tdeabc/tests/testaddressfmt.cpp
@@ -0,0 +1,63 @@
+#include <tdeaboutdata.h>
+#include <tdeapplication.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+#include <kstandarddirs.h>
+
+#include "addressbook.h"
+#include "address.h"
+
+using namespace KABC;
+
+static const TDECmdLineOptions options[] =
+{
+ { "save", "", 0 },
+ { "number", "", 0 },
+ TDECmdLineLastOption
+};
+
+int main(int argc,char **argv)
+{
+ TDEAboutData aboutData("testaddressfmt","TestAddressFormat","0.1");
+ TDECmdLineArgs::init(argc, argv, &aboutData);
+ TDECmdLineArgs::addCmdLineOptions(options);
+
+ TDEApplication app;
+
+ Address a;
+ a.setStreet("Lummerlandstr. 1");
+ a.setPostalCode("12345");
+ a.setLocality("Lummerstadt");
+ a.setCountry ("Germany");
+
+ Address b;
+ b.setStreet("457 Foobar Ave");
+ b.setPostalCode("1A2B3C");
+ b.setLocality("Nervousbreaktown");
+ b.setRegion("DC");
+ b.setCountry("United States of America");
+
+ Address c;
+ c.setStreet("Lummerlandstr. 1");
+ c.setPostalCode("12345");
+ c.setLocality("Lummerstadt");
+ c.setCountry ("Deutschland");
+
+ Address d;
+ d.setStreet("Lummerlandstr. 1");
+ d.setPostalCode("12345");
+ d.setLocality("Lummerstadt");
+ d.setCountry ("");
+
+ tqDebug( "-------------------------------------\nShould have german address formatting, local country formatting\n" );
+ tqDebug( a.formattedAddress("Jim Knopf").latin1() );
+ tqDebug( "-------------------------------------\nShould have US address formatting, local country formatting\n" );
+ tqDebug( b.formattedAddress("Huck Finn").latin1() );
+ tqDebug( "-------------------------------------\nShould have german address formatting, local country formatting\n" );
+ tqDebug( c.formattedAddress("Jim Knopf").latin1() );
+ tqDebug( "-------------------------------------\nShould have local address formatting, local country formatting\n" );
+ tqDebug( d.formattedAddress("Jim Knopf").latin1() );
+}
+
+
diff --git a/tdeabc/tests/testaddresslineedit.cpp b/tdeabc/tests/testaddresslineedit.cpp
new file mode 100644
index 000000000..74446f482
--- /dev/null
+++ b/tdeabc/tests/testaddresslineedit.cpp
@@ -0,0 +1,29 @@
+#include <tdeaboutdata.h>
+#include <tdeapplication.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+
+#include "addresslineedit.h"
+
+using namespace KABC;
+
+int main( int argc,char **argv )
+{
+ TDEAboutData aboutData( "testaddresslineedit",
+ I18N_NOOP( "Test Address LineEdit" ), "0.1" );
+ TDECmdLineArgs::init( argc, argv, &aboutData );
+
+ TDEApplication app;
+
+ AddressLineEdit *lineEdit = new AddressLineEdit( 0 );
+
+ lineEdit->show();
+ app.setMainWidget( lineEdit );
+
+ TQObject::connect( &app, TQT_SIGNAL( lastWindowClosed() ), &app, TQT_SLOT( quit() ) );
+
+ app.exec();
+
+ delete lineEdit;
+}
diff --git a/tdeabc/tests/testdb.cpp b/tdeabc/tests/testdb.cpp
new file mode 100644
index 000000000..f7ec1d17c
--- /dev/null
+++ b/tdeabc/tests/testdb.cpp
@@ -0,0 +1,33 @@
+#include <tdeaboutdata.h>
+#include <tdeapplication.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+
+#include "addressbook.h"
+#include "vcardformat.h"
+#include "resourcesql.h"
+
+using namespace KABC;
+
+int main(int argc,char **argv)
+{
+ TDEAboutData aboutData("testdb","TestKabcDB","0.1");
+ TDECmdLineArgs::init(argc,argv,&aboutData);
+
+// TDEApplication app( false, false );
+ TDEApplication app;
+
+ AddressBook ab;
+
+ ResourceSql r( &ab, "root", "kde4ever", "localhost" );
+ if ( ! r.open() ) {
+ kdDebug() << "Failed to open resource." << endl;
+ }
+
+ r.load( &ab );
+
+ r.close();
+
+ ab.dump();
+}
diff --git a/tdeabc/tests/testdistlist.cpp b/tdeabc/tests/testdistlist.cpp
new file mode 100644
index 000000000..69a309ff9
--- /dev/null
+++ b/tdeabc/tests/testdistlist.cpp
@@ -0,0 +1,59 @@
+#include <tqwidget.h>
+
+#include <tdeaboutdata.h>
+#include <tdeapplication.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+
+#include "stdaddressbook.h"
+
+#include "distributionlisteditor.h"
+#include "distributionlist.h"
+
+using namespace KABC;
+
+static const TDECmdLineOptions options[] =
+{
+ {"list <listname>", I18N_NOOP("Show distribution list with name <listname>"), 0},
+ TDECmdLineLastOption
+};
+
+
+int main(int argc,char **argv)
+{
+ TDEAboutData aboutData("testdistlist",I18N_NOOP("Test Distribution Lists"),"0.1");
+ TDECmdLineArgs::init(argc,argv,&aboutData);
+ TDECmdLineArgs::addCmdLineOptions( options );
+
+ TDEApplication app;
+
+ TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
+ if (args->isSet("list")) {
+ TQString name = args->getOption("list");
+
+ DistributionListManager *manager =
+ new DistributionListManager( StdAddressBook::self() );
+ manager->load();
+ DistributionList *list = manager->list( name );
+ if ( !list ) {
+ kdDebug() << "No list with name '" << name << "'" << endl;
+ return 1;
+ } else {
+ kdDebug() << "RESULT: " << list->emails().join(", ") << endl;
+ return 0;
+ }
+ }
+
+ DistributionListEditor *editor =
+ new DistributionListEditor( StdAddressBook::self(), 0 );
+
+ editor->show();
+ app.setMainWidget(editor);
+
+ TQObject::connect( &app, TQT_SIGNAL( lastWindowClosed() ), &app, TQT_SLOT( quit() ) );
+
+ app.exec();
+
+ delete editor;
+}
diff --git a/tdeabc/tests/testkabc.cpp b/tdeabc/tests/testkabc.cpp
new file mode 100644
index 000000000..427262cab
--- /dev/null
+++ b/tdeabc/tests/testkabc.cpp
@@ -0,0 +1,62 @@
+#include <tdeaboutdata.h>
+#include <tdeapplication.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+#include <kstandarddirs.h>
+
+#include <tqfile.h>
+#include <tqimage.h>
+
+#include "geo.h"
+#include "secrecy.h"
+#include "stdaddressbook.h"
+#include "timezone.h"
+#include "key.h"
+#include "agent.h"
+#include "vcardconverter.h"
+
+using namespace KABC;
+
+int main(int argc,char **argv)
+{
+ TDEAboutData aboutData("testkabc",I18N_NOOP("TestKabc"),"0.1");
+ TDECmdLineArgs::init(argc, argv, &aboutData);
+
+ TDEApplication app( false, false );
+ AddressBook *ab = StdAddressBook::self();
+
+#define READ
+
+#ifdef READ
+ AddressBook::Iterator it;
+ for ( it = ab->begin(); it != ab->end(); ++it ) {
+ TQString vcard;
+ VCardConverter converter;
+ converter.addresseeToVCard( *it, vcard );
+ kdDebug() << "card=" << vcard << endl;
+ }
+#else
+ Addressee addr;
+
+ addr.setGivenName("Tobias");
+ addr.setFamilyName("Koenig");
+
+
+ Picture pic;
+ TQImage img;
+ img.load("/home/tobias/test.png");
+/*
+ pic.setData(img);
+ pic.setType(TQImage::imageFormat("/home/tobias/test.png"));
+*/
+ pic.setUrl("http://www.mypict.de");
+ addr.setLogo( pic );
+
+ ab->insertAddressee( addr );
+
+ StdAddressBook::save();
+#endif
+
+ return 0;
+}
diff --git a/tdeabc/tests/testkabcdlg.cpp b/tdeabc/tests/testkabcdlg.cpp
new file mode 100644
index 000000000..aef203d28
--- /dev/null
+++ b/tdeabc/tests/testkabcdlg.cpp
@@ -0,0 +1,45 @@
+#include <tqwidget.h>
+
+#include <tdeaboutdata.h>
+#include <tdeapplication.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+
+#include "addresseedialog.h"
+
+using namespace KABC;
+
+static const TDECmdLineOptions options[] =
+{
+ {"multiple", I18N_NOOP("Allow selection of multiple addressees"), 0},
+ TDECmdLineLastOption
+};
+
+int main(int argc,char **argv)
+{
+ TDEAboutData aboutData("testkabcdlg",I18N_NOOP("TestKabc"),"0.1");
+ TDECmdLineArgs::init(argc,argv,&aboutData);
+ TDECmdLineArgs::addCmdLineOptions( options );
+
+ TDEApplication app;
+
+ TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
+ if (args->isSet("multiple")) {
+ Addressee::List al = AddresseeDialog::getAddressees( 0 );
+ Addressee::List::ConstIterator it;
+ kdDebug() << "Selected Addressees:" << endl;
+ for( it = al.begin(); it != al.end(); ++it ) {
+ kdDebug() << " " << (*it).fullEmail() << endl;
+ }
+ } else {
+ Addressee a = AddresseeDialog::getAddressee( 0 );
+
+ if ( !a.isEmpty() ) {
+ kdDebug() << "Selected Addressee:" << endl;
+ a.dump();
+ } else {
+ kdDebug() << "No Addressee selected." << endl;
+ }
+ }
+}
diff --git a/tdeabc/tests/testldapclient.cpp b/tdeabc/tests/testldapclient.cpp
new file mode 100644
index 000000000..df9fd6226
--- /dev/null
+++ b/tdeabc/tests/testldapclient.cpp
@@ -0,0 +1,161 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 David Faure <faure@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "testldapclient.h"
+
+#include <tdeapplication.h>
+#include <kdebug.h>
+#include <tdecmdlineargs.h>
+
+#include <tqeventloop.h>
+
+#include <assert.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+ TDEApplication::disableAutoDcopRegistration();
+ TDECmdLineArgs::init(argc,argv,"testldapclient", 0, 0, 0, 0);
+ TDEApplication app;
+
+ TestLDAPClient test;
+ test.setup();
+ test.runAll();
+ test.cleanup();
+ kdDebug() << "All tests OK." << endl;
+ return 0;
+}
+
+void TestLDAPClient::setup()
+{
+}
+
+void TestLDAPClient::runAll()
+{
+ testIntevation();
+}
+
+bool TestLDAPClient::check(const TQString& txt, TQString a, TQString b)
+{
+ if (a.isEmpty())
+ a = TQString::null;
+ if (b.isEmpty())
+ b = TQString::null;
+ if (a == b) {
+ kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl;
+ }
+ else {
+ kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl;
+ cleanup();
+ exit(1);
+ }
+ return true;
+}
+
+void TestLDAPClient::cleanup()
+{
+ mClient = 0;
+}
+
+void TestLDAPClient::testIntevation()
+{
+ kdDebug() << k_funcinfo << endl;
+ mClient = new LdapClient( this );
+
+ mClient->setHost( "ca.intevation.de" );
+ mClient->setPort( "389" );
+ mClient->setBase( "o=Intevation GmbH,c=de" );
+
+ // Same list as in kaddressbook's ldapsearchdialog
+ TQStringList attrs;
+ attrs << "l" << "Company" << "co" << "department" << "description" << "mail" << "facsimileTelephoneNumber" << "cn" << "homePhone" << "mobile" << "o" << "pager" << "postalAddress" << "st" << "street" << "title" << "uid" << "telephoneNumber" << "postalCode" << "objectClass";
+ // the list from ldapclient.cpp
+ //attrs << "cn" << "mail" << "givenname" << "sn" << "objectClass";
+ mClient->setAttrs( attrs );
+
+ // Taken from LdapSearch
+ //TQString mSearchText = TQString::fromUtf8( "Till" );
+ //TQString filter = TQString( "&(|(objectclass=person)(objectclass=groupOfNames)(mail=*))(|(cn=%1*)(mail=%2*)(givenName=%3*)(sn=%4*))" )
+ // .arg( mSearchText ).arg( mSearchText ).arg( mSearchText ).arg( mSearchText );
+
+ // For some reason a fromUtf8 broke the search for me (no results).
+ // But this certainly looks fishy, it might break on non-utf8 systems.
+ TQString filter = "&(|(objectclass=person)(objectclass=groupofnames)(mail=*))(|(cn=*Ägypten MDK*)(sn=*Ägypten MDK*))";
+
+ connect( mClient, TQT_SIGNAL( result( const KABC::LdapObject& ) ),
+ this, TQT_SLOT( slotLDAPResult( const KABC::LdapObject& ) ) );
+ connect( mClient, TQT_SIGNAL( done() ),
+ this, TQT_SLOT( slotLDAPDone() ) );
+ connect( mClient, TQT_SIGNAL( error( const TQString& ) ),
+ this, TQT_SLOT( slotLDAPError( const TQString& ) ) );
+ mClient->startQuery( filter );
+ kapp->eventLoop()->enterLoop();
+ delete mClient; mClient = 0;
+}
+
+// from kaddressbook... ugly though...
+static TQString asUtf8( const TQByteArray &val )
+{
+ if ( val.isEmpty() )
+ return TQString::null;
+
+ const char *data = val.data();
+
+ //TQString::fromUtf8() bug workaround
+ if ( data[ val.size() - 1 ] == '\0' )
+ return TQString::fromUtf8( data, val.size() - 1 );
+ else
+ return TQString::fromUtf8( data, val.size() );
+}
+
+static TQString join( const KABC::LdapAttrValue& lst, const TQString& sep )
+{
+ TQString res;
+ bool already = false;
+ for ( KABC::LdapAttrValue::ConstIterator it = lst.begin(); it != lst.end(); ++it ) {
+ if ( already )
+ res += sep;
+ already = TRUE;
+ res += asUtf8( *it );
+ }
+ return res;
+}
+
+void TestLDAPClient::slotLDAPResult( const KABC::LdapObject& obj )
+{
+ TQString cn = join( obj.attrs[ "cn" ], ", " );
+ kdDebug() << " cn:" << cn << endl;
+ assert( !obj.attrs[ "mail" ].isEmpty() );
+ TQString mail = join( obj.attrs[ "mail" ], ", " );
+ kdDebug() << " mail:" << mail << endl;
+ assert( mail.contains( '@' ) );
+}
+
+void TestLDAPClient::slotLDAPError( const TQString& err )
+{
+ kdDebug() << k_funcinfo << err << endl;
+ ::exit( 1 );
+}
+
+void TestLDAPClient::slotLDAPDone()
+{
+ kdDebug() << k_funcinfo << endl;
+ kapp->eventLoop()->exitLoop();
+}
+
+#include "testldapclient.moc"
diff --git a/tdeabc/tests/testldapclient.h b/tdeabc/tests/testldapclient.h
new file mode 100644
index 000000000..1995914c3
--- /dev/null
+++ b/tdeabc/tests/testldapclient.h
@@ -0,0 +1,51 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 David Faure <faure@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef TESTLDAPCLIENT_H
+#define TESTLDAPCLIENT_H
+
+#include <tqobject.h>
+
+#include "../ldapclient.h"
+typedef KABC::LdapClient LdapClient;
+
+class TestLDAPClient : public TQObject
+{
+ Q_OBJECT
+
+public:
+ TestLDAPClient() {}
+ void setup();
+ void runAll();
+ void cleanup();
+
+ // tests
+ void testIntevation();
+
+private slots:
+ void slotLDAPResult( const KABC::LdapObject& );
+ void slotLDAPError( const TQString& );
+ void slotLDAPDone();
+
+private:
+ bool check(const TQString& txt, TQString a, TQString b);
+
+ LdapClient* mClient;
+};
+
+#endif
diff --git a/tdeabc/tests/testlock.cpp b/tdeabc/tests/testlock.cpp
new file mode 100644
index 000000000..3ebd724bb
--- /dev/null
+++ b/tdeabc/tests/testlock.cpp
@@ -0,0 +1,206 @@
+/*
+ This file is part of libkabc.
+
+ Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "testlock.h"
+
+#include "stdaddressbook.h"
+
+#include <tdeaboutdata.h>
+#include <tdeapplication.h>
+#include <kdebug.h>
+#include <tdelocale.h>
+#include <tdecmdlineargs.h>
+#include <kdirwatch.h>
+
+#include <tdemessagebox.h>
+#include <kdialog.h>
+
+#include <tqwidget.h>
+#include <tqlabel.h>
+#include <tqlayout.h>
+#include <tqpushbutton.h>
+#include <tqlistview.h>
+#include <tqdir.h>
+
+#include <iostream>
+
+#include <sys/types.h>
+#include <unistd.h>
+
+using namespace KABC;
+
+LockWidget::LockWidget( const TQString &identifier )
+{
+ TQVBoxLayout *topLayout = new TQVBoxLayout( this );
+ topLayout->setMargin( KDialog::marginHint() );
+ topLayout->setSpacing( KDialog::spacingHint() );
+
+ if ( identifier.isEmpty() ) {
+ mLock = 0;
+ } else {
+ mLock = new Lock( identifier );
+
+ int pid = getpid();
+
+ TQLabel *pidLabel = new TQLabel( "Process ID: " + TQString::number( pid ),
+ this );
+ topLayout->addWidget( pidLabel );
+
+ TQHBoxLayout *identifierLayout = new TQHBoxLayout( topLayout );
+
+ TQLabel *resourceLabel = new TQLabel( "Identifier:", this );
+ identifierLayout->addWidget( resourceLabel );
+
+ TQLabel *resourceIdentifier = new TQLabel( identifier, this );
+ identifierLayout->addWidget( resourceIdentifier );
+
+ mStatus = new TQLabel( "Status: Unlocked", this );
+ topLayout->addWidget( mStatus );
+
+ TQPushButton *button = new TQPushButton( "Lock", this );
+ topLayout->addWidget( button );
+ connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( lock() ) );
+
+ button = new TQPushButton( "Unlock", this );
+ topLayout->addWidget( button );
+ connect( button, TQT_SIGNAL( clicked() ), TQT_SLOT( unlock() ) );
+ }
+
+ mLockView = new TQListView( this );
+ topLayout->addWidget( mLockView );
+ mLockView->addColumn( "Lock File" );
+ mLockView->addColumn( "PID" );
+ mLockView->addColumn( "Locking App" );
+
+ updateLockView();
+
+ TQPushButton *quitButton = new TQPushButton( "Quit", this );
+ topLayout->addWidget( quitButton );
+ connect( quitButton, TQT_SIGNAL( clicked() ), TQT_SLOT( close() ) );
+
+ KDirWatch *watch = KDirWatch::self();
+ connect( watch, TQT_SIGNAL( dirty( const TQString & ) ),
+ TQT_SLOT( updateLockView() ) );
+ connect( watch, TQT_SIGNAL( created( const TQString & ) ),
+ TQT_SLOT( updateLockView() ) );
+ connect( watch, TQT_SIGNAL( deleted( const TQString & ) ),
+ TQT_SLOT( updateLockView() ) );
+ watch->addDir( Lock::locksDir() );
+ watch->startScan();
+}
+
+LockWidget::~LockWidget()
+{
+ delete mLock;
+}
+
+void LockWidget::updateLockView()
+{
+ mLockView->clear();
+
+ TQDir dir( Lock::locksDir() );
+
+ TQStringList files = dir.entryList( "*.lock" );
+
+ TQStringList::ConstIterator it;
+ for( it = files.begin(); it != files.end(); ++it ) {
+ if ( *it == "." || *it == ".." ) continue;
+
+ TQString app;
+ int pid;
+ if ( !Lock::readLockFile( dir.filePath( *it ), pid, app ) ) {
+ kdWarning() << "Unable to open lock file '" << *it << "'" << endl;
+ } else {
+ new TQListViewItem( mLockView, *it, TQString::number( pid ), app );
+ }
+ }
+}
+
+void LockWidget::lock()
+{
+ if ( !mLock->lock() ) {
+ KMessageBox::sorry( this, mLock->error() );
+ } else {
+ mStatus->setText( "Status: Locked" );
+ }
+}
+
+void LockWidget::unlock()
+{
+ if ( !mLock->unlock() ) {
+ KMessageBox::sorry( this, mLock->error() );
+ } else {
+ mStatus->setText( "Status: Unlocked" );
+ }
+}
+
+
+static const TDECmdLineOptions options[] =
+{
+ { "a", 0, 0 },
+ { "addressbook", "Standard address book", 0 },
+ { "d", 0, 0 },
+ { "diraddressbook", "Standard address book directory resource", 0 },
+ { "+identifier", "Identifier of resource to be locked, e.g. filename", 0 },
+ TDECmdLineLastOption
+};
+
+int main(int argc,char **argv)
+{
+ TDEAboutData aboutData("testlock",I18N_NOOP("Test libkabc Lock"),"0.1");
+ TDECmdLineArgs::init(argc,argv,&aboutData);
+ TDECmdLineArgs::addCmdLineOptions( options );
+
+ TDEApplication app;
+
+ TQString identifier;
+
+ TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
+ if ( args->count() == 1 ) {
+ identifier = args->arg( 0 );
+ } else if ( args->count() != 0 ) {
+ std::cerr << "Usage: testlock <identifier>" << std::endl;
+ return 1;
+ }
+
+ if ( args->isSet( "addressbook" ) ) {
+ if ( args->count() == 1 ) {
+ std::cerr << "Ignoring resource identifier" << std::endl;
+ }
+ identifier = StdAddressBook::fileName();
+ }
+
+ if ( args->isSet( "diraddressbook" ) ) {
+ if ( args->count() == 1 ) {
+ std::cerr << "Ignoring resource identifier" << std::endl;
+ }
+ identifier = StdAddressBook::directoryName();
+ }
+
+ LockWidget mainWidget( identifier );
+
+ kapp->setMainWidget( &mainWidget );
+ mainWidget.show();
+
+ return app.exec();
+}
+
+#include "testlock.moc"
diff --git a/tdeabc/tests/testlock.h b/tdeabc/tests/testlock.h
new file mode 100644
index 000000000..a94d4e8c6
--- /dev/null
+++ b/tdeabc/tests/testlock.h
@@ -0,0 +1,51 @@
+/*
+ This file is part of libkabc.
+
+ Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef KABC_TESTLOCK_H
+#define KABC_TESTLOCK_H
+
+#include "lock.h"
+
+#include <tqwidget.h>
+
+class TQLabel;
+class TQListView;
+
+class KABC_EXPORT LockWidget : public TQWidget
+{
+ Q_OBJECT
+ public:
+ LockWidget( const TQString &identifier );
+ ~LockWidget();
+
+ protected slots:
+ void lock();
+ void unlock();
+
+ void updateLockView();
+
+ private:
+ KABC::Lock *mLock;
+
+ TQLabel *mStatus;
+ TQListView *mLockView;
+};
+
+#endif