コード例 #1
0
ファイル: kionetrctest.cpp プロジェクト: vasi/kdelibs
int main(int argc, char **argv)
{
    const char *version = "0.5";
    KLocalizedString description = ki18n("Unit test for .netrc and kionetrc parser.");
    KCmdLineOptions options;
    options.add("+command", ki18n("[url1,url2 ,...]"));

    KCmdLineArgs::init( argc, argv, "kionetrctest", 0, ki18n("KIO-netrc-test"), version, description );
    KCmdLineArgs::addCmdLineOptions( options );
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    int count = args->count();
    KApplication app;

    if ( !count )
        args->usage();
    else
    {
        KUrl u;
        for( int i=0 ; i < count; i++ )
        {
            u = args->arg(i);
            if ( !u.isValid() )
            {
                kDebug() << u.url() << " is invalid! Ignoring...";
                continue;
            }
            output( u );
        }
    }
    args->clear();
    return 0;
}
コード例 #2
0
int main(int argc, char **argv)
{
    KAboutData about("khotnewstuff", 0, ki18n("KHotNewStuff"), "0.4");
    about.setProgramIconName("get-hot-new-stuff");
    KCmdLineArgs *args;

    KCmdLineArgs::init(argc, argv, &about);

    KCmdLineOptions op;
    op.add("+filename", ki18n("Name of .knsrc file to use"));
    op.add("+filename", ki18n("Name of file to upload"));
    KCmdLineArgs::addCmdLineOptions(op);
    args = KCmdLineArgs::parsedArgs();

    KApplication i;
    
    if (args->count() > 0) {
        KNS3::UploadDialog dialog(args->arg(0));
        if (args->count() > 1) {
            dialog.setUploadFile(KUrl(args->arg(1)));
        }
        dialog.exec();
    }
    else
    {
        args->usage();
        return -1;
    }
    return 0;
}
コード例 #3
0
ファイル: krootimage.cpp プロジェクト: aarontc/kde-workspace
int
main(int argc, char *argv[])
{
    KCmdLineArgs::init(argc, argv, "krootimage", "kdmgreet",
                       ki18n("KRootImage"), QByteArray(),
                       ki18n("Fancy desktop background for kdm"));

    KCmdLineOptions options;
    options.add("+config", ki18n("Name of the configuration file"));
    KCmdLineArgs::addCmdLineOptions(options);

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    if (!args->count())
        args->usage();
    KComponentData inst(KCmdLineArgs::aboutData());
    MyApplication app(args->arg(0).toLocal8Bit(),
                      KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv());
    args->clear();

    app.exec();
    app.flush();

    // Keep color resources after termination
    XSetCloseDownMode(QX11Info::display(), RetainTemporary);

    return 0;
}
コード例 #4
0
ファイル: main.cpp プロジェクト: Munrek/ktechlab
int main(int argc, char **argv)
{
    KAboutData about(QByteArray("microbe"), QByteArray("languages"), ki18n("Microbe"),
                     QByteArray(version), ki18n(description),
                     KAboutData::License_GPL, ki18n("(C) 2004-2005, The KTechLab developers"),
                     KLocalizedString(), QByteArray("http://ktechlab.org"),
                     QByteArray("*****@*****.**") );
    about.addAuthor( ki18n("Daniel Clarke"), KLocalizedString(),
                     QByteArray("*****@*****.**") );
    about.addAuthor( ki18n("David Saxton"), KLocalizedString(),
                     QByteArray("*****@*****.**") );
    about.addAuthor( ki18n("Modified to add pic 16f877,16f627 and 16f628 by George John"),
                     KLocalizedString(), QByteArray("*****@*****.**") );
    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineOptions o;
    o.add( QByteArray("show-source"),
           ki18n( "Show source code lines in assembly output") );
    o.add( QByteArray("nooptimize"),
           ki18n( "Do not attempt optimization of generated instructions.") );
    o.add( QByteArray("+[Input URL]"),
           ki18n( "Input filename" ) );
    o.add( QByteArray("+[Output URL]"),
           ki18n( "Output filename" ) );

    KCmdLineArgs::addCmdLineOptions(o);

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    if (args->count() == 2 )
    {
        Microbe mb;
//      QString s = mb.compile( args->arg(0), args->isSet("show-source"), args->isSet("optimize"));

        QString s = mb.compile( args->arg(0), args->isSet("optimize"));

        QString errorReport = mb.errorReport();

        if ( !errorReport.isEmpty() )
        {
            kError() << errorReport;
            return 1; // If there was an error, don't write the output to file.
        }

        else
        {
            QFile outFile(args->arg(1));
            outFile.open(QIODevice::WriteOnly);
            QDataStream out(&outFile);
            out << s;
            return 0;
        }
    }
    else args->usage();
}
コード例 #5
0
ファイル: testvcalexport.cpp プロジェクト: pvuorela/kcalcore
int main( int argc, char **argv )
{
  KAboutData aboutData( "testvcalexport", 0,
                        ki18n( "Part of LibKCal's test suite. Checks if export "
                               "to vCalendar still works correctly." ), "0.1" );
  KCmdLineArgs::init( argc, argv, &aboutData );

  KCmdLineOptions options;
  options.add( "verbose", ki18n( "Verbose output" ) );
  options.add( "+input", ki18n( "Name of input file" ) );
  options.add( "+output", ki18n( "Name of output file" ) );
  KCmdLineArgs::addCmdLineOptions( options );

  KComponentData componentData( &aboutData );
  //QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );

  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

  if ( args->count() != 2 ) {
    args->usage( "Wrong number of arguments." );
  }

  QString input = args->arg( 0 );
  QString output = args->arg( 1 );

  QFileInfo outputFileInfo( output );
  output = outputFileInfo.absoluteFilePath();

  kDebug() << "Input file:" << input;
  kDebug() << "Output file:" << output;

  MemoryCalendar::Ptr cal( new MemoryCalendar( KDateTime::UTC ) );
  FileStorage instore( cal, input );

  if ( !instore.load() ) {
    return 1;
  }
  QString tz = cal->nonKDECustomProperty( "X-LibKCal-Testsuite-OutTZ" );
  if ( !tz.isEmpty() ) {
    cal->setViewTimeZoneId( tz );
  }

  FileStorage outstore( cal, output, new VCalFormat );
  if ( !outstore.save() ) {
    return 1;
  }

  return 0;
}
コード例 #6
0
ファイル: kwebdesktop.cpp プロジェクト: serghei/kde3-kdebase
int main(int argc, char **argv)
{
    KAboutData data("kwebdesktop", I18N_NOOP("KDE Web Desktop"), VERSION, I18N_NOOP("Displays an HTML page as the background of the desktop"),
                    KAboutData::License_GPL, "(c) 2000, David Faure <*****@*****.**>");
    data.addAuthor("David Faure", I18N_NOOP("developer and maintainer"), "*****@*****.**");

    KCmdLineArgs::init(argc, argv, &data);

    KCmdLineArgs::addCmdLineOptions(options); // Add our own options.

    KApplication app;

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    if(args->count() != 3 && args->count() != 4)
    {
        args->usage();
        return 1;
    }
    const int width = QCString(args->arg(0)).toInt();
    const int height = QCString(args->arg(1)).toInt();
    QCString imageFile = args->arg(2);
    QString url;
    if(args->count() == 4)
        url = QString::fromLocal8Bit(args->arg(3));

    KWebDesktop *webDesktop = new KWebDesktop(0, imageFile, width, height);

    if(url.isEmpty())
        url = KWebDesktopSettings::uRL();
    // Apply uri filter
    KURIFilterData uridata = url;
    KURIFilter::self()->filterURI(uridata);
    KURL u = uridata.uri();

    // Now start getting, to ensure mimetype and possible connection
    KWebDesktopRun *run = new KWebDesktopRun(webDesktop, u);

    int ret = app.exec();

    KIO::SimpleJob::removeOnHold(); // Kill any slave that was put on hold.
    delete webDesktop;
    delete run;
    // khtml::Cache::clear();

    return ret;
}
コード例 #7
0
int main(int argc, char **argv)
{
    new KInstance("makekdewidgets");

    KAboutData about("makekdewidgets", I18N_NOOP("makekdewidgets"), version, description, KAboutData::License_GPL,
                     "(C) 2004-2005 ian reinhart geiser", 0, 0, "*****@*****.**");
    about.addAuthor("ian reinhart geiser", 0, "*****@*****.**");
    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions(options);
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    if(args->count() < 1)
    {
        args->usage();
        return (1);
    }

    QFileInfo fi(args->arg(args->count() - 1));

    QString outputFile = args->getOption("o");
    QString pluginName = args->getOption("n");
    QString group = args->getOption("g");
    QString iconPath = "";
    if(args->isSet("p"))
        iconPath = args->getOption("p");
    QString fileName = fi.absFilePath();

    if(args->isSet("o"))
    {
        QFile output(outputFile);
        if(output.open(IO_WriteOnly))
        {
            QTextStream ts(&output);
            buildFile(ts, group, fileName, pluginName, iconPath);
        }
        output.close();
    }
    else
    {
        QTextStream ts(stdout, IO_WriteOnly);
        buildFile(ts, group, fileName, pluginName, iconPath);
    }
}
コード例 #8
0
int main( int argc, char **argv )
{
  KAboutData aboutData( "readandwrite", "Read and Write Calendar", "0.1" );
  KCmdLineArgs::init( argc, argv, &aboutData );
  KCmdLineArgs::addCmdLineOptions( options );

  KApplication app( false, false );

  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

  if ( args->count() != 2 ) {
    args->usage( "Wrong number of arguments." );
  }

  // use zoneinfo data from source dir
  set_zone_directory( KDETOPSRCDIR "/libkcal/libical/zoneinfo" );

  QString input = QFile::decodeName( args->arg( 0 ) );
  QString output = QFile::decodeName( args->arg( 1 ) );

  QFileInfo outputFileInfo( output );
  output = outputFileInfo.absFilePath();

  kdDebug(5800) << "Input file: " << input << endl;
  kdDebug(5800) << "Output file: " << output << endl;


  CalendarLocal cal( QString::fromLatin1("UTC") );

  if ( !cal.load( input ) ) return 1;
  QString tz = cal.nonKDECustomProperty( "X-LibKCal-Testsuite-OutTZ" );
  if ( !tz.isEmpty() ) {
    cal.setTimeZoneIdViewOnly( tz );
  }
  if ( !cal.save( output ) ) return 1;

  return 0;
}
コード例 #9
0
int
main( int argc, char *argv[] )
{
	KApplication::disableAutoDcopRegistration();

	KLocale::setMainCatalogue( "kdesktop" );
	KCmdLineArgs::init( argc, argv, "krootimage", I18N_NOOP( "KRootImage" ), description, version );
	KCmdLineArgs::addCmdLineOptions( options );

	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
	if (!args->count())
		args->usage();
	MyApplication app( args->arg( 0 ) );
	args->clear();

	app.exec();

	app.flushX();

	// Keep color resources after termination
	XSetCloseDownMode( qt_xdisplay(), RetainTemporary );

	return 0;
}
コード例 #10
0
int main(int argc, char** argv)
{
  KAboutData about ("kdvi", I18N_NOOP("KDVI"), "1.4",
                    description, KAboutData::License_GPL,
                    "Markku Hinhala, Stephan Kebekus",
                    I18N_NOOP("This program displays Device Independent (DVI) files which are produced by the TeX typesetting system.\n"
                    "This KDVI version is based on original code from KDVI version 0.43 and xdvik."));

  about.addAuthor ("Stefan Kebekus",
                   I18N_NOOP("Current Maintainer."),
                   "*****@*****.**",
                   "http://www.mi.uni-koeln.de/~kebekus");

  about.addAuthor ("Markku Hinhala", I18N_NOOP("Author of kdvi 0.4.3"));
  about.addAuthor ("Nicolai Langfeldt", I18N_NOOP("Maintainer of xdvik"));
  about.addAuthor ("Paul Vojta", I18N_NOOP("Author of xdvi"));
  about.addCredit ("Philipp Lehmann", I18N_NOOP("Testing and bug reporting."));
  about.addCredit ("Wilfried Huss", I18N_NOOP("Re-organisation of source code."));

  KCmdLineArgs::init(argc, argv, &about);
  KCmdLineArgs::addCmdLineOptions(options);
  KApplication app;

  // see if we are starting with session management
  if (app.isRestored())
  {
    RESTORE(KViewShell);
  }
  else
  {
    KCmdLineArgs* args = KCmdLineArgs::parsedArgs();

    if (args->isSet("unique"))
    {
      // With --unique, we need 2 arguments.
      if (args->count() < 1) 
      {
        args->usage();
        exit(-1);
      }

      // Find the fully qualified file name of the file we are
      // loading. Complain, if we are given a URL which does not point
      // to a local file.
      KURL url(args->url(0));

      if (!url.isValid()) 
      {
        kdError(4300) << QString(I18N_NOOP("The URL %1 is not well-formed.")).arg(args->arg(0)) << endl;
        return -1;
      }

      if (!url.isLocalFile()) 
      {
        kdError(4300) << QString(I18N_NOOP("The URL %1 does not point to a local file. You can only specify local "
             "files if you are using the '--unique' option.")).arg(args->arg(0)) << endl;
        return -1;
      }

      QString qualPath = QFileInfo(url.path()).absFilePath();

      app.dcopClient()->attach();
      // We need to register as "kviewshell" to stay compatible with existing DCOP-skripts.
      QCString id = app.dcopClient()->registerAs("unique-kviewshell");
      if (id.isNull())
        kdError(4300) << "There was an error using dcopClient()->registerAs()." << endl;
      QCStringList apps = app.dcopClient()->registeredApplications();
      for ( QCStringList::Iterator it = apps.begin(); it != apps.end(); ++it ) 
      {
        if ((*it).find("kviewshell") == 0) 
        {
          QByteArray data, replyData;
          QCString replyType;
          QDataStream arg(data, IO_WriteOnly);
          bool result;
          arg << qualPath.stripWhiteSpace();
          if (!app.dcopClient()->call( *it, "kmultipage", "is_file_loaded(QString)", data, replyType, replyData))
            kdError(4300) << "There was an error using DCOP." << endl;
          else 
          {
            QDataStream reply(replyData, IO_ReadOnly);
            if (replyType == "bool") 
            {
              reply >> result;
              if (result == true) 
              {
                if (app.dcopClient()->send( *it, "kmultipage", "jumpToReference(QString)", url.ref()) == true)
                {
                  app.dcopClient()->detach();
                  return 0;
                }
              }
            }
            else
              kdError(4300) << "The DCOP function 'doIt' returned an unexpected type of reply!";
          }
        }
      }
コード例 #11
0
int main(int argc, char** argv)
{
    KAboutData aboutData("CCSGraph",
                         0,
                         ki18n("CCSGraph"),
                         "1.0",
                         ki18n("Output the graph of color conversion of pigment's Color Conversion"),
                         KAboutData::License_LGPL,
                         ki18n("(c) 2007 Cyrille Berger"),
                         KLocalizedString(),
                         "www.koffice.org",
                         "*****@*****.**");
    KCmdLineArgs::init( argc, argv, &aboutData );
    // Initialize the list of options
    KCmdLineOptions options;
    options.add("graphs", ki18n("return the list of available graphs"));
    options.add("graph <type>", ki18n("specify the type of graph (see --graphs to get the full list, the default is full)"), "full");
    options.add("src-key <key>", ki18n("specify the key of the source color space"), "");
    options.add("dst-key <key>", ki18n("specify the key of the destination color space"), "");
    options.add("output <type>", ki18n("specify the output (can be ps or dot, the default is ps)"), "ps");
    options.add("+outputfile", ki18n("name of the output file"));
    KCmdLineArgs::addCmdLineOptions( options );
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    if( args->isSet("graphs"))
    {
        // Don't change those lines to use qDebug derivatives, they need to be outputed
        // to stdout not stderr.
        std::cout << "full : show all the connection on the graph" << std::endl;
        std::cout << "bestpath : show the best path for a given transformation" << std::endl;
        exit(EXIT_SUCCESS);
    }
    QString graphType = args->getOption("graph");
    QString outputType = args->getOption("output");
    if( args->count() != 1 )
    {
        kError() << "No output file name specified";
        args->usage();
        exit(EXIT_FAILURE);
    }
    QString outputFileName = args->arg(0);
    // Generate the graph
    KApplication app;
    QString dot;
    if(graphType == "full")
    {
        dot = KoColorSpaceRegistry::instance()->colorConversionSystem()->toDot();
    } else if(graphType == "bestpath") {
        QString srcKey = args->getOption("src-key");
        QString dstKey = args->getOption("dst-key");
        if (srcKey == "" or dstKey == "") {
            kError() << "src-key and dst-key must be specified for the graph bestpath";
            exit(EXIT_FAILURE);
        }
        else {
            dot = KoColorSpaceRegistry::instance()->colorConversionSystem()->bestPathToDot(srcKey, dstKey );
        }
    } else {
        kError() << "Unknow graph type : " << graphType.toLatin1();
        exit(EXIT_FAILURE);
    }

    if (outputType == "dot") {
        QFile file(outputFileName);
        if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
            exit(EXIT_FAILURE);
        QTextStream out(&file);
        out << dot;
    }
    else if (outputType == "ps" or outputType == "svg" ) {
        QTemporaryFile file;
        if (!file.open()) {
            exit(EXIT_FAILURE);
        }
        QTextStream out(&file);
        out << dot;
        QString cmd = QString("dot -T%1 %2 -o %3").arg(outputType).arg(file.fileName()).arg(outputFileName);
        file.close();

        if (QProcess::execute(cmd) != 0)
        {
            kError() << "An error has occurred when executing : '" << cmd << "' the most likely cause is that 'dot' command is missing, and that you should install graphviz (from http://www.graphiz.org)";
        }
    }
    else {
        kError() << "Unknow output type : " << outputType;
        exit(EXIT_FAILURE);
    }
}
コード例 #12
0
int main( int argc, char **argv )
{
  KAboutData aboutData(
    "testrecurson", 0,
    ki18n( "Tests all dates from 2002 to 2010 to test if the event recurs on each individual date. "
           "This is meant to test the Recurrence::recursOn method for errors." ), "0.1" );
  KCmdLineArgs::init( argc, argv, &aboutData );

  KCmdLineOptions options;
  options.add( "verbose", ki18n( "Verbose output" ) );
  options.add( "+input", ki18n( "Name of input file" ) );
  options.add( "[+output]", ki18n( "optional name of output file for the recurrence dates" ) );
  KCmdLineArgs::addCmdLineOptions( options );

  KComponentData componentData( &aboutData );
  //QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );

  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

  if ( args->count() < 1 ) {
    args->usage( "Wrong number of arguments." );
  }

  QString input = args->arg( 0 );
//   kDebug() << "Input file:" << input;

  QTextStream *outstream;
  outstream = 0;
  QString fn( "" );
  if ( args->count() > 1 ) {
    fn = args->arg( 1 );
//     kDebug() << "We have a file name given:" << fn;
  }
  QFile outfile( fn );
  if ( !fn.isEmpty() && outfile.open( QIODevice::WriteOnly ) ) {
//     kDebug() << "Opened output file!!!";
    outstream = new QTextStream( &outfile );
  }

  MemoryCalendar::Ptr cal( new MemoryCalendar( KDateTime::UTC ) );

  FileStorage store( cal, input );
  if ( !store.load() ) return 1;
  QString tz = cal->nonKDECustomProperty( "X-LibKCal-Testsuite-OutTZ" );
  if ( !tz.isEmpty() ) {
    cal->setViewTimeZoneId( tz );
  }

  Incidence::List inc = cal->incidences();

  for ( Incidence::List::Iterator it = inc.begin(); it != inc.end(); ++it ) {
    Incidence::Ptr incidence = *it;

//     kDebug() << " ->" << incidence->summary() << "<-";

//     incidence->recurrence()->dump();

    QDate dt( 1996, 7, 1 );
    if ( outstream ) {
      // Output to file for testing purposes
      int nr = 0;
      while ( dt.year() <= 2020 && nr<=500 ) {
        if ( incidence->recursOn( dt, cal->viewTimeSpec() ) ) {
          (*outstream) << dt.toString( Qt::ISODate ) << endl;
          nr++;
        }
        dt = dt.addDays( 1 );
      }
    } else {
      dt = QDate( 2005, 1, 1 );
      while ( dt.year() < 2007 ) {
        if ( incidence->recursOn( dt, cal->viewTimeSpec() ) ) {
          kDebug() << dt.toString( Qt::ISODate );
        }
        dt = dt.addDays( 1 );
      }
    }
  }

  delete outstream;
  outfile.close();
  return 0;
}
コード例 #13
0
ファイル: kmdcodectest.cpp プロジェクト: KDE/kdelibs4support
int main(int argc, char *argv[])
{
    KCmdLineOptions options;
    options.add("c <digest>", ki18n("compare <digest> with the calculated digest for a string or file."));
    options.add("d", ki18n("decode the given string or file using base64"));
    options.add("e", ki18n("encode the given string or file using base64"));
    options.add("f", ki18n("the filename to be used as input"), "default");
    options.add("p", ki18n("encode the given string or file using quoted-printable"));
    options.add("q", ki18n("decode the given string or file using quoted-printable"));
    options.add("r", ki18n("calculate the raw md5 for the given string or file"));
    options.add("s", ki18n("the string to be used as input"));
    options.add("t", ki18n("perform a timed message-digest test"));
    options.add("u", ki18n("uuencode the given string or file"));
    options.add("x", ki18n("uudecode the given string or file"));
    options.add("z", ki18n("run a preset message-digest test"));
    options.add("+command", ki18n("[input1, input2,...]"));

    KCmdLineArgs::init(argc, argv, "kmdcodectest", 0,
                       ki18n("KMDCodecTest"), "1.0",
                       ki18n("Unit test for md5, base64 encode/decode "
                             "and uuencode/decode facilities"));
    KCmdLineArgs::addCmdLineOptions(options);
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    int count = args->count();

    //QCoreApplication app;

    if (!count) {
        if (args->isSet("t")) {
            MD5_timeTrial();
        } else if (args->isSet("z")) {
            MD5_testSuite();
        } else {
            args->usage();
        }
    } else {
        bool isVerify = args->isSet("c");
        bool isString = args->isSet("s");
        bool isFile = args->isSet("f");
        Codec type = Unspecified;
        if (args->isSet("d")) {
            type = Base64Decode;
        } else if (args->isSet("e")) {
            type = Base64Encode;
        } else if (args->isSet("u")) {
            type = UUEncode;
        } else if (args->isSet("x")) {
            type = UUDecode;
        } else if (args->isSet("p")) {
            type = QPEncode;
        } else if (args->isSet("q")) {
            type = QPDecode;
        }
        if (isVerify) {
            const char *opt = args->getOption("c").toLocal8Bit().data();
            for (int i = 0; i < count; i++) {
                MD5_verify(args->arg(i).toLocal8Bit().constData(), opt, (isString || !isFile));
            }
        } else {
            for (int i = 0; i < count; i++) {
                if (type != Unspecified) {
                    testCodec(args->arg(i).toLocal8Bit().constData(), type, isFile);
                } else {
                    if (isString) {
                        MD5_string(args->arg(i).toLocal8Bit().constData(), 0, args->isSet("r"));
                    } else {
                        MD5_file(args->arg(i).toLocal8Bit().constData(), args->isSet("r"));
                    }
                }
            }
        }
    }
    args->clear();
    return (0);
}
コード例 #14
0
int main( int argc, char **argv )
{
  KAboutData aboutData(
    "testrecurrencenew", 0,
    ki18n( "Load recurrence rules with the new class and print out debug messages" ), "0.1" );
  KCmdLineArgs::init( argc, argv, &aboutData );

  KCmdLineOptions options;
  options.add( "verbose", ki18n( "Verbose output" ) );
  options.add( "+input", ki18n( "Name of input file" ) );
  options.add( "[+output]", ki18n( "optional name of output file for the recurrence dates" ) );
  KCmdLineArgs::addCmdLineOptions( options );

  KComponentData componentData( &aboutData );
  //QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );

  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

  if ( args->count() < 1 ) {
    args->usage( "Wrong number of arguments." );
  }

  QString input = args->arg( 0 );
  kDebug() << "Input file:" << input;

  QTextStream *outstream;
  outstream = 0;
  QString fn( "" );
  if ( args->count() > 1 ) {
    fn = args->arg( 1 );
    kDebug() << "We have a file name given:" << fn;
  }
  QFile outfile( fn );
  if ( !fn.isEmpty() && outfile.open( QIODevice::WriteOnly ) ) {
    kDebug() << "Opened output file!!!";
    outstream = new QTextStream( &outfile );
  }

  MemoryCalendar::Ptr cal( new MemoryCalendar( KDateTime::UTC ) );

  KDateTime::Spec viewSpec;
  FileStorage store( cal, input );
  if ( !store.load() ) return 1;
  QString tz = cal->nonKDECustomProperty( "X-LibKCal-Testsuite-OutTZ" );
  if ( !tz.isEmpty() ) {
    viewSpec = KDateTime::Spec( KSystemTimeZones::zone( tz ) );
  }

  Incidence::List inc = cal->incidences();

  for ( Incidence::List::Iterator it = inc.begin(); it != inc.end(); ++it ) {
    Incidence::Ptr incidence = *it;
    kDebug() << "*+*+*+*+*+*+*+*+*+*";
    kDebug() << " ->" << incidence->summary() << "<-";

    incidence->recurrence()->dump();

    KDateTime dt( incidence->recurrence()->endDateTime() );
    int i = 0;
    if ( outstream ) {
      if ( !dt.isValid() ) {
        if ( viewSpec.isValid() ) {
          dt = KDateTime( QDate( 2011, 1, 1 ), QTime( 0, 0, 1 ), viewSpec );
        } else {
          dt = KDateTime( QDate( 2011, 1, 1 ), QTime( 0, 0, 1 ) );
        }
      } else {
        dt = dt.addYears( 2 );
      }
      kDebug() << "-------------------------------------------";
      kDebug() << " *~*~*~*~ Starting with date:" << dumpTime( dt, viewSpec );
      // Output to file for testing purposes
      while ( dt.isValid() && i < 500 ) {
        ++i;
        dt = incidence->recurrence()->getPreviousDateTime( dt );
        if ( dt.isValid() ) {
          (*outstream) << dumpTime( dt, viewSpec ) << endl;
        }
      }
    } else {
      if ( !dt.isValid() ) {
        dt = KDateTime( QDate( 2005, 7, 31 ), QTime( 23, 59, 59 ), KDateTime::Spec::UTC() );
      } else {
        dt = dt.addYears( 2 );
      }
      incidence->recurrence()->dump();
      kDebug() << "-------------------------------------------";
      kDebug() << " *~*~*~*~ Starting with date:" << dumpTime( dt, viewSpec );
      // Output to konsole
      while ( dt.isValid() && i < 50 ) {
        ++i;
        kDebug() << "-------------------------------------------";
        dt = incidence->recurrence()->getPreviousDateTime( dt );
        if ( dt.isValid() ) {
          kDebug() << " *~*~*~*~ Previous date is:" << dumpTime( dt, viewSpec );
        }
      }
    }
  }

  delete outstream;
  outfile.close();
  return 0;
}
コード例 #15
0
int main (int argc, char *argv[])
{
    const char *version = "1.0";
    const char *description = "Unit test for md5, base64 encode/decode and uuencode/decode facilities";
    KCmdLineOptions options[] =
    {
        { "c <digest>", "compare <digest> with the calculated digest for a string or file.", 0 },
        { "d", "decode the given string or file using base64", 0 },
        { "e", "encode the given string or file using base64", 0 },
        { "f", "the filename to be used as input", "default" },
        { "p", "encode the given string or file using quoted-printable", 0},
        { "q", "decode the given string or file using quoted-printable", 0},
        { "r", "calculate the raw md5 for the given string or file", 0 },
        { "s", "the string to be used as input", 0 },
        { "t", "perform a timed message-digest test", 0 },
        { "u", "uuencode the given string or file", 0 },
        { "x", "uudecode the given string or file", 0 },
        { "z", "run a preset message-digest test", 0 },
        { "+command", "[input1, input2,...]", 0 },
        KCmdLineLastOption
    };

    KCmdLineArgs::init( argc, argv, "kmdcodectest", description, version );
    KCmdLineArgs::addCmdLineOptions( options );
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    int count = args->count();

    KApplication app;

    if (!count)
    {
        if ( args->isSet("t") )
            MD5_timeTrial ();
        else if ( args->isSet("z") )
            MD5_testSuite ();
        else
            args->usage();
    }
    else
    {
       bool isVerify = args->isSet("c");
       bool isString = args->isSet("s");
       bool isFile = args->isSet( "f" );
       Codec type = Unspecified;
       if ( args->isSet("d") )
          type = Base64Decode;
       else if ( args->isSet("e") )
          type = Base64Encode;
       else if ( args->isSet("u") )
          type = UUEncode;
       else if ( args->isSet("x") )
          type = UUDecode;
       else if ( args->isSet("p") )
          type = QPEncode;
       else if ( args->isSet("q") )
          type = QPDecode;
       if ( isVerify )
       {
          const char* opt = args->getOption( "c" ).data();
          for ( int i=0 ; i < count; i++ )
            MD5_verify ( QCString(args->arg(i)), opt, (isString || !isFile) );
       }
       else
       {
          for ( int i=0 ; i < count; i++ )
          {
            if ( type != Unspecified )
              testCodec( args->arg(i), type, isFile );
            else
            {
              if ( isString )
                MD5_string( args->arg( i ), 0, args->isSet("r") );
              else
                MD5_file( args->arg( i ), args->isSet("r") );
            }
          }
       }
    }
    args->clear();
    return (0);
}
コード例 #16
0
int main(int argc, char **argv)
{
    KAboutData aboutData("testrecurrencenew", "Load recurrence rules with the new class and print out debug messages", "0.1");
    KCmdLineArgs::init(argc, argv, &aboutData);
    KCmdLineArgs::addCmdLineOptions(options);

    KApplication app(false, false);

    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    if(args->count() < 1)
    {
        args->usage("Wrong number of arguments.");
    }

    // use zoneinfo data from source dir
    set_zone_directory(KDETOPSRCDIR "/libkcal/libical/zoneinfo");

    QString input = QFile::decodeName(args->arg(0));
    kdDebug(5800) << "Input file: " << input << endl;

    QTextStream *outstream;
    outstream = 0;
    QString fn("");
    if(args->count() > 1)
    {
        fn = args->arg(1);
        kdDebug() << "We have a file name given: " << fn << endl;
    }
    QFile outfile(fn);
    if(!fn.isEmpty() && outfile.open(IO_WriteOnly))
    {
        kdDebug() << "Opened output file!!!" << endl;
        outstream = new QTextStream(&outfile);
    }

    CalendarLocal cal(QString::fromLatin1("UTC"));

    if(!cal.load(input)) return 1;
    QString tz = cal.nonKDECustomProperty("X-LibKCal-Testsuite-OutTZ");
    if(!tz.isEmpty())
    {
        cal.setTimeZoneIdViewOnly(tz);
    }

    Incidence::List inc = cal.incidences();

    for(Incidence::List::Iterator it = inc.begin(); it != inc.end(); ++it)
    {
        Incidence *incidence = *it;
        kdDebug(5800) << "*+*+*+*+*+*+*+*+*+*" << endl;
        kdDebug(5800) << " -> " << incidence->summary() << " <- " << endl;

        incidence->recurrence()->dump();

        QDateTime dt(incidence->recurrence()->endDateTime());
        int i = 0;
        if(outstream)
        {
            if(!dt.isValid()) dt = QDateTime(QDate(2011, 1, 1), QTime(0, 0, 1));
            else dt = dt.addYears(2);
            kdDebug(5800) << "-------------------------------------------" << endl;
            kdDebug(5800) << " *~*~*~*~ Starting with date: " << dt << endl;
            // Output to file for testing purposes
            while(dt.isValid() && i < 500)
            {
                dt = dt.addSecs(-1);
                ++i;
                dt = incidence->recurrence()->getPreviousDateTime(dt);
                (*outstream) << dt.toString(Qt::ISODate) << endl;
            }
        }
        else
        {
            if(!dt.isValid()) dt = QDateTime(QDate(2005, 7, 31), QTime(23, 59, 59));
            else dt = dt.addYears(2);
            incidence->recurrence()->dump();
            kdDebug(5800) << "-------------------------------------------" << endl;
            kdDebug(5800) << " *~*~*~*~ Starting with date: " << dt << endl;
            // Output to konsole
            while(dt.isValid() && i < 50)
            {
                dt = dt.addSecs(-1);
                ++i;
                kdDebug(5800) << "-------------------------------------------" << endl;
                dt = incidence->recurrence()->getPreviousDateTime(dt);
                kdDebug(5800) << " *~*~*~*~ Previous date is: " << dt << endl;
            }
        }
    }

    delete outstream;
    outfile.close();
    return 0;
}