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.
81 lines
2.8 KiB
81 lines
2.8 KiB
15 years ago
|
/*
|
||
|
KAbc2Mutt
|
||
|
|
||
|
Copyright (c) 2003 - 2004 Tobias Koenig <tokoe@kde.org>
|
||
|
|
||
|
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.
|
||
|
*/
|
||
|
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
|
#include <tdecmdlineargs.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
|
#include <iostream>
|
||
|
|
||
11 years ago
|
#include "tdeabc2mutt.h"
|
||
15 years ago
|
|
||
|
static const char version[] = "0.2";
|
||
11 years ago
|
static const char appName[] = "tdeabc2mutt";
|
||
|
static const char programName[] = I18N_NOOP( "tdeabc2mutt" );
|
||
|
static const char description[] = I18N_NOOP( "tdeabc - mutt converter" );
|
||
15 years ago
|
|
||
12 years ago
|
static TDECmdLineOptions k2moptions[] =
|
||
15 years ago
|
{
|
||
|
{ "query <substring>", I18N_NOOP( "Only show contacts where name or address matches <substring>" ), 0 },
|
||
|
{ "format <format>", I18N_NOOP( "Default format is 'alias'. 'query' returns email<tab>name<tab>, 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},
|
||
12 years ago
|
TDECmdLineLastOption
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
|
int main( int argc, char **argv )
|
||
|
{
|
||
12 years ago
|
TDEApplication::disableAutoDcopRegistration();
|
||
12 years ago
|
TDECmdLineArgs::init( argc, argv, appName, programName, description, version );
|
||
|
TDECmdLineArgs::addCmdLineOptions( k2moptions );
|
||
15 years ago
|
|
||
12 years ago
|
TDEApplication app( false, false );
|
||
15 years ago
|
|
||
12 years ago
|
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
|
||
15 years ago
|
|
||
|
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
|
||
15 years ago
|
const TQString subString = TQString::fromLocal8Bit( args->getOption( "query" ) );
|
||
15 years ago
|
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();
|
||
|
}
|