main.cpp
00001 /* 00002 * main.cpp 00003 * Program: kalarm 00004 * Copyright © 2001-2007 by David Jarvie <software@astrojar.org.uk> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include "kalarm.h" 00022 00023 #include <stdlib.h> 00024 00025 #include <kcmdlineargs.h> 00026 #include <kaboutdata.h> 00027 #include <klocale.h> 00028 #include <kdebug.h> 00029 00030 #include "kalarmapp.h" 00031 00032 #define PROGRAM_NAME "kalarm" 00033 00034 static KCmdLineOptions options[] = 00035 { 00036 { "a", 0, 0 }, 00037 { "ack-confirm", I18N_NOOP("Prompt for confirmation when alarm is acknowledged"), 0 }, 00038 { "A", 0, 0 }, 00039 { "attach <url>", I18N_NOOP("Attach file to email (repeat as needed)"), 0 }, 00040 { "auto-close", I18N_NOOP("Auto-close alarm window after --late-cancel period"), 0 }, 00041 { "bcc", I18N_NOOP("Blind copy email to self"), 0 }, 00042 { "b", 0, 0 }, 00043 { "beep", I18N_NOOP("Beep when message is displayed"), 0 }, 00044 { "colour", 0, 0 }, 00045 { "c", 0, 0 }, 00046 { "color <color>", I18N_NOOP("Message background color (name or hex 0xRRGGBB)"), 0 }, 00047 { "colourfg", 0, 0 }, 00048 { "C", 0, 0 }, 00049 { "colorfg <color>", I18N_NOOP("Message foreground color (name or hex 0xRRGGBB)"), 0 }, 00050 { "calendarURL <url>", I18N_NOOP("URL of calendar file"), 0 }, 00051 { "cancelEvent <eventID>", I18N_NOOP("Cancel alarm with the specified event ID"), 0 }, 00052 { "d", 0, 0 }, 00053 { "disable", I18N_NOOP("Disable the alarm"), 0 }, 00054 { "e", 0, 0 }, 00055 { "!exec <commandline>", I18N_NOOP("Execute a shell command line"), 0 }, 00056 { "edit <eventID>", I18N_NOOP("Display the alarm edit dialog to edit the specified alarm"), 0 }, 00057 { "n", 0, 0 }, 00058 { "edit-new", I18N_NOOP("Display the alarm edit dialog to edit a new alarm"), 0 }, 00059 { "edit-new-preset <templateName>", I18N_NOOP("Display the alarm edit dialog, preset with a template"), 0 }, 00060 { "f", 0, 0 }, 00061 { "file <url>", I18N_NOOP("File to display"), 0 }, 00062 { "F", 0, 0 }, 00063 { "from-id <ID>", I18N_NOOP("KMail identity to use as sender of email"), 0 }, 00064 { "handleEvent <eventID>", I18N_NOOP("Trigger or cancel alarm with the specified event ID"), 0 }, 00065 { "i", 0, 0 }, 00066 { "interval <period>", I18N_NOOP("Interval between alarm repetitions"), 0 }, 00067 { "k", 0, 0 }, 00068 { "korganizer", I18N_NOOP("Show alarm as an event in KOrganizer"), 0 }, 00069 { "l", 0, 0 }, 00070 { "late-cancel <period>", I18N_NOOP("Cancel alarm if more than 'period' late when triggered"), "1" }, 00071 { "L", 0, 0 }, 00072 { "login", I18N_NOOP("Repeat alarm at every login"), 0 }, 00073 { "m", 0, 0 }, 00074 { "mail <address>", I18N_NOOP("Send an email to the given address (repeat as needed)"), 0 }, 00075 { "p", 0, 0 }, 00076 { "play <url>", I18N_NOOP("Audio file to play once"), 0 }, 00077 #ifndef WITHOUT_ARTS 00078 { "P", 0, 0 }, 00079 { "play-repeat <url>", I18N_NOOP("Audio file to play repeatedly"), 0 }, 00080 #endif 00081 { "recurrence <spec>", I18N_NOOP("Specify alarm recurrence using iCalendar syntax"), 0 }, 00082 { "R", 0, 0 }, 00083 { "reminder <period>", I18N_NOOP("Display reminder in advance of alarm"), 0 }, 00084 { "reminder-once <period>", I18N_NOOP("Display reminder once, before first alarm recurrence"), 0 }, 00085 { "r", 0, 0 }, 00086 { "repeat <count>", I18N_NOOP("Number of times to repeat alarm (including initial occasion)"), 0 }, 00087 { "reset", I18N_NOOP("Reset the alarm scheduling daemon"), 0 }, 00088 { "s", 0, 0 }, 00089 { "speak", I18N_NOOP("Speak the message when it is displayed"), 0 }, 00090 { "stop", I18N_NOOP("Stop the alarm scheduling daemon"), 0 }, 00091 { "S", 0, 0 }, 00092 { "subject", I18N_NOOP("Email subject line"), 0 }, 00093 { "t", 0, 0 }, 00094 { "time <time>", I18N_NOOP("Trigger alarm at time [[[yyyy-]mm-]dd-]hh:mm, or date yyyy-mm-dd"), 0 }, 00095 { "tray", I18N_NOOP("Display system tray icon"), 0 }, 00096 { "triggerEvent <eventID>", I18N_NOOP("Trigger alarm with the specified event ID"), 0 }, 00097 { "u", 0, 0 }, 00098 { "until <time>", I18N_NOOP("Repeat until time [[[yyyy-]mm-]dd-]hh:mm, or date yyyy-mm-dd"), 0 }, 00099 #ifndef WITHOUT_ARTS 00100 { "V", 0, 0 }, 00101 { "volume <percent>", I18N_NOOP("Volume to play audio file"), 0 }, 00102 #endif 00103 { "+[message]", I18N_NOOP("Message text to display"), 0 }, 00104 KCmdLineLastOption 00105 }; 00106 00107 00108 int main(int argc, char *argv[]) 00109 { 00110 KAboutData aboutData(PROGRAM_NAME, I18N_NOOP("KAlarm"), KALARM_VERSION, 00111 I18N_NOOP("Personal alarm message, command and email scheduler for KDE"), 00112 KAboutData::License_GPL, 00113 "Copyright 2001-2007, David Jarvie", 0, "http://www.astrojar.org.uk/kalarm"); 00114 aboutData.addAuthor("David Jarvie", 0, "software@astrojar.org.uk"); 00115 00116 KCmdLineArgs::init(argc, argv, &aboutData); 00117 KCmdLineArgs::addCmdLineOptions(options); 00118 KUniqueApplication::addCmdLineOptions(); 00119 00120 if (!KAlarmApp::start()) 00121 { 00122 // An instance of the application is already running 00123 exit(0); 00124 } 00125 00126 // This is the first time through 00127 kdDebug(5950) << "main(): initialising\n"; 00128 KAlarmApp* app = KAlarmApp::getInstance(); 00129 app->restoreSession(); 00130 return app->exec(); 00131 }