00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 #include <qregexp.h>
00033 
00034 #include <klocale.h>
00035 #include <kglobal.h>
00036 #include <kapplication.h>
00037 #include <kaboutdata.h>
00038 #include <kmessagebox.h>
00039 #include <kcmdlineargs.h>
00040 
00041 
00042 static KCmdLineOptions options[] = 
00043   {
00044       { "e", 0,0 },
00045       { "error", I18N_NOOP("Display error message (default)"), 0 },
00046       { "w", 0, 0},
00047       { "warning", I18N_NOOP("Display warning message"), 0 },
00048       { "i", 0, 0 },
00049       { "info", I18N_NOOP("Display informational message"), 0 },
00050       { "+message", I18N_NOOP("Message string to be displayed"), 0 },
00051       KCmdLineLastOption 
00052   };
00053 
00054 KAboutData aboutData("artsmessage", I18N_NOOP("artsmessage"), "0.1",
00055                      I18N_NOOP("Utility to display aRts error messages."),
00056                      KAboutData::License_GPL, "(c) 2001, Jeff Tranter", 0, 0, "tranter@kde.org");
00057 
00058 int main(int argc, char **argv) {
00059     aboutData.addAuthor("Jeff Tranter", 0, "tranter@kde.org");
00060     KGlobal::locale()->setMainCatalogue("kdelibs");
00061     KCmdLineArgs::init(argc, argv, &aboutData);
00062     KCmdLineArgs::addCmdLineOptions(options);
00063     KApplication app;
00064     
00065     KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00066     QString msg;
00067 
00068     
00069     if (args->count() == 0) {
00070         args->usage();
00071     }
00072 
00073     
00074     for (int i = 0; i < args->count(); i++) {
00075         if (i == 0)
00076             msg = args->arg(i);
00077         else
00078             msg += QString(" ") + args->arg(i);
00079     }
00080 
00081     const int notifyOptions = 0; 
00082     if (args->isSet("w")) {
00083         KMessageBox::sorry(0, msg, i18n("Warning"), notifyOptions);
00084     } else if (args->isSet("i")) {
00085         QString id = msg;
00086         id.replace(QRegExp("[\\[\\]\\s=]"), "_");
00087         KMessageBox::information(0, msg, i18n("Informational"), id, notifyOptions);
00088     } else {
00089         KMessageBox::error(0, msg, i18n("Error"), notifyOptions);
00090     }
00091     
00092     return 0;
00093 }