kalarm

main.cpp
1/*
2 * main.cpp
3 * Program: kalarm
4 * Copyright © 2001-2007 by David Jarvie <software@astrojar.org.uk>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21#include "kalarm.h"
22
23#include <stdlib.h>
24
25#include <tdecmdlineargs.h>
26#include <tdeaboutdata.h>
27#include <tdelocale.h>
28#include <kdebug.h>
29
30#include "kalarmapp.h"
31
32#define PROGRAM_NAME "kalarm"
33
34static TDECmdLineOptions options[] =
35{
36 { "a", 0, 0 },
37 { "ack-confirm", I18N_NOOP("Prompt for confirmation when alarm is acknowledged"), 0 },
38 { "A", 0, 0 },
39 { "attach <url>", I18N_NOOP("Attach file to email (repeat as needed)"), 0 },
40 { "auto-close", I18N_NOOP("Auto-close alarm window after --late-cancel period"), 0 },
41 { "bcc", I18N_NOOP("Blind copy email to self"), 0 },
42 { "b", 0, 0 },
43 { "beep", I18N_NOOP("Beep when message is displayed"), 0 },
44 { "colour", 0, 0 },
45 { "c", 0, 0 },
46 { "color <color>", I18N_NOOP("Message background color (name or hex 0xRRGGBB)"), 0 },
47 { "colourfg", 0, 0 },
48 { "C", 0, 0 },
49 { "colorfg <color>", I18N_NOOP("Message foreground color (name or hex 0xRRGGBB)"), 0 },
50 { "calendarURL <url>", I18N_NOOP("URL of calendar file"), 0 },
51 { "cancelEvent <eventID>", I18N_NOOP("Cancel alarm with the specified event ID"), 0 },
52 { "d", 0, 0 },
53 { "disable", I18N_NOOP("Disable the alarm"), 0 },
54 { "e", 0, 0 },
55 { "!exec <commandline>", I18N_NOOP("Execute a shell command line"), 0 },
56 { "edit <eventID>", I18N_NOOP("Display the alarm edit dialog to edit the specified alarm"), 0 },
57 { "n", 0, 0 },
58 { "edit-new", I18N_NOOP("Display the alarm edit dialog to edit a new alarm"), 0 },
59 { "edit-new-preset <templateName>", I18N_NOOP("Display the alarm edit dialog, preset with a template"), 0 },
60 { "f", 0, 0 },
61 { "file <url>", I18N_NOOP("File to display"), 0 },
62 { "F", 0, 0 },
63 { "from-id <ID>", I18N_NOOP("KMail identity to use as sender of email"), 0 },
64 { "handleEvent <eventID>", I18N_NOOP("Trigger or cancel alarm with the specified event ID"), 0 },
65 { "i", 0, 0 },
66 { "interval <period>", I18N_NOOP("Interval between alarm repetitions"), 0 },
67 { "k", 0, 0 },
68 { "korganizer", I18N_NOOP("Show alarm as an event in KOrganizer"), 0 },
69 { "l", 0, 0 },
70 { "late-cancel <period>", I18N_NOOP("Cancel alarm if more than 'period' late when triggered"), "1" },
71 { "L", 0, 0 },
72 { "login", I18N_NOOP("Repeat alarm at every login"), 0 },
73 { "m", 0, 0 },
74 { "mail <address>", I18N_NOOP("Send an email to the given address (repeat as needed)"), 0 },
75 { "p", 0, 0 },
76 { "play <url>", I18N_NOOP("Audio file to play once"), 0 },
77#ifndef WITHOUT_ARTS
78 { "P", 0, 0 },
79 { "play-repeat <url>", I18N_NOOP("Audio file to play repeatedly"), 0 },
80#endif
81 { "recurrence <spec>", I18N_NOOP("Specify alarm recurrence using iCalendar syntax"), 0 },
82 { "R", 0, 0 },
83 { "reminder <period>", I18N_NOOP("Display reminder in advance of alarm"), 0 },
84 { "reminder-once <period>", I18N_NOOP("Display reminder once, before first alarm recurrence"), 0 },
85 { "r", 0, 0 },
86 { "repeat <count>", I18N_NOOP("Number of times to repeat alarm (including initial occasion)"), 0 },
87 { "reset", I18N_NOOP("Reset the alarm scheduling daemon"), 0 },
88 { "s", 0, 0 },
89 { "speak", I18N_NOOP("Speak the message when it is displayed"), 0 },
90 { "stop", I18N_NOOP("Stop the alarm scheduling daemon"), 0 },
91 { "S", 0, 0 },
92 { "subject", I18N_NOOP("Email subject line"), 0 },
93 { "t", 0, 0 },
94 { "time <time>", I18N_NOOP("Trigger alarm at time [[[yyyy-]mm-]dd-]hh:mm, or date yyyy-mm-dd"), 0 },
95 { "tray", I18N_NOOP("Display system tray icon"), 0 },
96 { "triggerEvent <eventID>", I18N_NOOP("Trigger alarm with the specified event ID"), 0 },
97 { "u", 0, 0 },
98 { "until <time>", I18N_NOOP("Repeat until time [[[yyyy-]mm-]dd-]hh:mm, or date yyyy-mm-dd"), 0 },
99#ifndef WITHOUT_ARTS
100 { "V", 0, 0 },
101 { "volume <percent>", I18N_NOOP("Volume to play audio file"), 0 },
102#endif
103 { "+[message]", I18N_NOOP("Message text to display"), 0 },
104 TDECmdLineLastOption
105};
106
107
108int main(int argc, char *argv[])
109{
110 TDEAboutData aboutData(PROGRAM_NAME, I18N_NOOP("KAlarm"), KALARM_VERSION,
111 I18N_NOOP("Personal alarm message, command and email scheduler for TDE"),
112 TDEAboutData::License_GPL,
113 "Copyright 2001-2007, David Jarvie", 0, "http://www.astrojar.org.uk/kalarm");
114 aboutData.addAuthor("David Jarvie", 0, "software@astrojar.org.uk");
115
116 TDECmdLineArgs::init(argc, argv, &aboutData);
117 TDECmdLineArgs::addCmdLineOptions(options);
118 TDEUniqueApplication::addCmdLineOptions();
119
120 if (!KAlarmApp::start())
121 {
122 // An instance of the application is already running
123 exit(0);
124 }
125
126 // This is the first time through
127 //kdDebug(5950) << "[KAlarm] Initializing.\n";
128 KAlarmApp* app = KAlarmApp::getInstance();
129 app->restoreSession();
130 return app->exec();
131}
the KAlarm application object