From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kabc/kabc2mutt/main.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 kabc/kabc2mutt/main.cpp (limited to 'kabc/kabc2mutt/main.cpp') diff --git a/kabc/kabc2mutt/main.cpp b/kabc/kabc2mutt/main.cpp new file mode 100644 index 000000000..8da8f5491 --- /dev/null +++ b/kabc/kabc2mutt/main.cpp @@ -0,0 +1,80 @@ +/* + KAbc2Mutt + + Copyright (c) 2003 - 2004 Tobias Koenig + + This program is free software; you can redistribute it and/or + modify it under the terms of version 2 of the GNU General Public + License as published by the Free Software Foundation. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include +#include +#include + +#include + +#include "kabc2mutt.h" + +static const char version[] = "0.2"; +static const char appName[] = "kabc2mutt"; +static const char programName[] = I18N_NOOP( "kabc2mutt" ); +static const char description[] = I18N_NOOP( "kabc - mutt converter" ); + +static KCmdLineOptions k2moptions[] = +{ + { "query ", I18N_NOOP( "Only show contacts where name or address matches " ), 0 }, + { "format ", I18N_NOOP( "Default format is 'alias'. 'query' returns emailname, as needed by mutt's query_command" ), "alias" }, + { "alternate-key-format", I18N_NOOP( "Default key format is 'JohDoe', this option turns it into 'jdoe'" ), 0 }, + { "ignore-case", I18N_NOOP( "Make queries case insensitive" ), 0 }, + { "all-addresses", I18N_NOOP( "Return all mail addresses, not just the preferred one" ), 0}, + KCmdLineLastOption +}; + + +int main( int argc, char **argv ) +{ + KApplication::disableAutoDcopRegistration(); + KCmdLineArgs::init( argc, argv, appName, programName, description, version ); + KCmdLineArgs::addCmdLineOptions( k2moptions ); + + KApplication app( false, false ); + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + KABC2Mutt *object = new KABC2Mutt( 0 ); + + // Handle --format option + object->setFormat( (args->getOption("format") == "query") ? KABC2Mutt::Query : KABC2Mutt::Aliases ); + + // Handle --alternate-key-format option + object->setAlternateKeyFormat( args->isSet( "alternate-key-format" ) ); + + // Handle --all-addresses option + object->setAllAddresses( args->isSet( "all-addresses" ) ); + + // Handle --query option + const QString subString = QString::fromLocal8Bit( args->getOption( "query" ) ); + if ( !subString.isEmpty() ) { + // Mutt wants a first line with some status message on it + // See http://mutt.org/doc/manual/manual-4.html#ss4.5 + std::cout << i18n( "Searching KDE addressbook" ).latin1() << std::endl; + } + object->setQuery( subString ); + + // Handle --ignore-case option + object->setIgnoreCase( !args->isSet( "ignore-case" ) ); + + object->run(); + + return app.exec(); +} -- cgit v1.2.1