diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2013-09-03 20:02:55 +0200 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2013-09-03 21:02:00 +0200 |
commit | 533bad2a1503973aaf8186691422c2eda91d02d4 (patch) | |
tree | f7e52f62416048859aa9bde8425e20aac0e7c669 /tdeabc/tdeabcdistlistupdater/tdeabcdistlistupdater.cpp | |
parent | 8144d5434bbd1c4448a37695aed6ad3d348043d8 (diff) | |
download | tdepim-533bad2a1503973aaf8186691422c2eda91d02d4.tar.gz tdepim-533bad2a1503973aaf8186691422c2eda91d02d4.zip |
Additional k => tde renaming and fixes
Diffstat (limited to 'tdeabc/tdeabcdistlistupdater/tdeabcdistlistupdater.cpp')
-rw-r--r-- | tdeabc/tdeabcdistlistupdater/tdeabcdistlistupdater.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/tdeabc/tdeabcdistlistupdater/tdeabcdistlistupdater.cpp b/tdeabc/tdeabcdistlistupdater/tdeabcdistlistupdater.cpp new file mode 100644 index 000000000..9228e1f47 --- /dev/null +++ b/tdeabc/tdeabcdistlistupdater/tdeabcdistlistupdater.cpp @@ -0,0 +1,95 @@ +/* + This file is part of libtdeabc. + Copyright (c) 2008 Tobias Koenig <tokoe@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 <tdeaboutdata.h> +#include <tdeapplication.h> +#include <tdecmdlineargs.h> +#include <ksimpleconfig.h> +#include <kdebug.h> +#include <tdeglobal.h> +#include <tdelocale.h> +#include <kstandarddirs.h> + +#include <tdeabc/stdaddressbook.h> +#include <libtdepim/distributionlist.h> + +static const TDECmdLineOptions options[] = +{ + { "disable-autostart", "Disable automatic startup on login", 0 }, + TDECmdLineLastOption +}; + +void convertDistributionLists() +{ + KSimpleConfig cfg( locateLocal( "data", "tdeabc/distlists" ) ); + const TQMap<TQString, TQString> entryMap = cfg.entryMap( "DistributionLists" ); + + if ( entryMap.isEmpty() ) // nothing to convert + return; + + TQMapConstIterator<TQString, TQString> it; + for ( it = entryMap.begin(); it != entryMap.end(); ++it ) { + const TQString listName = it.key(); + const TQStringList entries = TQStringList::split( ',', it.data(), true ); + + KPIM::DistributionList distList; + distList.setUid( TDEApplication::randomString( 10 ) ); + distList.setName( listName ); + + if ( entries.count() > 1 ) { + for ( uint i = 0; i < entries.count(); i += 2 ) { + const TQString uid = entries[ i ]; + const TQString preferredEMail = entries[ i + 1 ]; + + distList.insertEntry( uid, preferredEMail ); + } + } + + TDEABC::StdAddressBook::self()->insertAddressee( distList ); + } + + TDEABC::StdAddressBook::self()->save(); +} + +int main( int argc, char **argv ) +{ + TDEApplication::disableAutoDcopRegistration(); + + TDEAboutData aboutData( "tdeabcdistlistupdater", "Converter tool for distribution lists", "0.1" ); + aboutData.addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); + + TDECmdLineArgs::init( argc, argv, &aboutData ); + TDECmdLineArgs::addCmdLineOptions( options ); + + TDEApplication app( false, false ); + + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + + if ( args->isSet( "disable-autostart" ) ) { + kdDebug() << "Disable autostart." << endl; + + TDEConfig *config = app.config(); + config->setGroup( "Startup" ); + config->writeEntry( "EnableAutostart", false ); + } + + convertDistributionLists(); +} + |