SVN_SILENT made messages (.desktop file) - always resolve ours
[kdepim.git] / kalarm / commandoptions.h
blob13605d0c5e54003208b1c9578859ba8a404ac162
1 /*
2 * commandoptions.h - extract command line options
3 * Program: kalarm
4 * Copyright © 2001-2016 by David Jarvie <djarvie@kde.org>
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.
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.
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.
21 #ifndef COMMANDOPTIONS_H
22 #define COMMANDOPTIONS_H
24 #include "editdlg.h"
25 #include "eventid.h"
27 #include <kalarmcal/kaevent.h>
28 #include <kalarmcal/karecurrence.h>
30 #include <kdatetime.h>
31 #include <QByteArray>
32 #include <QColor>
33 #include <QStringList>
34 class QCommandLineParser;
35 class QCommandLineOption;
37 using namespace KAlarmCal;
39 class CommandOptions
41 public:
42 enum Command
44 CMD_ERROR, // error in command line options
45 NONE, // no command
46 TRAY, // --tray
47 TRIGGER_EVENT, // --triggerEvent
48 CANCEL_EVENT, // --cancelEvent
49 EDIT, // --edit
50 EDIT_NEW_PRESET, // --edit-new-preset
51 EDIT_NEW, // --edit-new-display, --edit-new-command, --edit-new-email
52 NEW, // --file, --exec-display, --exec, --mail, message
53 LIST // --list
55 static QStringList setOptions(QCommandLineParser*, const QStringList& args);
56 static void process();
57 static CommandOptions* instance() { return mInstance; }
58 Command command() const { return mCommand; }
59 QString commandName() const { return optionName(mCommandOpt); }
60 EventId eventId() const { return mEventId; }
61 QString templateName() const { return mTemplateName; }
62 EditAlarmDlg::Type editType() const { return mEditType; }
63 KAEvent::SubAction editAction() const { return mEditAction; }
64 QString text() const { return mText; }
65 KDateTime alarmTime() const { return mAlarmTime; }
66 KARecurrence* recurrence() const { return mRecurrence; }
67 int subRepeatCount() const { return mRepeatCount; }
68 KCalCore::Duration subRepeatInterval() const { return mRepeatInterval; }
69 int lateCancel() const { return mLateCancel; }
70 QColor bgColour() const { return mBgColour; }
71 QColor fgColour() const { return mFgColour; }
72 int reminderMinutes() const { return mReminderMinutes; }
73 QString audioFile() const { return mAudioFile; }
74 float audioVolume() const { return mAudioVolume; }
75 KCalCore::Person::List addressees() const { return mAddressees; }
76 QStringList attachments() const { return mAttachments; }
77 QString subject() const { return mSubject; }
78 uint fromID() const { return mFromID; }
79 KAEvent::Flags flags() const { return mFlags; }
80 bool disableAll() const { return mDisableAll; }
81 #ifndef NDEBUG
82 KDateTime simulationTime() const { return mSimulationTime; }
83 #endif
84 static void printError(const QString& errmsg);
86 private:
87 enum Option
89 ACK_CONFIRM,
90 ATTACH,
91 AUTO_CLOSE,
92 BCC,
93 BEEP,
94 COLOUR,
95 COLOURFG,
96 OptCANCEL_EVENT,
97 DISABLE,
98 DISABLE_ALL,
99 EXEC,
100 EXEC_DISPLAY,
101 OptEDIT,
102 EDIT_NEW_DISPLAY,
103 EDIT_NEW_COMMAND,
104 EDIT_NEW_EMAIL,
105 EDIT_NEW_AUDIO,
106 OptEDIT_NEW_PRESET,
107 FILE,
108 FROM_ID,
109 INTERVAL,
110 KORGANIZER,
111 LATE_CANCEL,
112 OptLIST,
113 LOGIN,
114 MAIL,
115 PLAY,
116 PLAY_REPEAT,
117 RECURRENCE,
118 REMINDER,
119 REMINDER_ONCE,
120 REPEAT,
121 SPEAK,
122 SUBJECT,
123 #ifndef NDEBUG
124 TEST_SET_TIME,
125 #endif
126 TIME,
127 OptTRAY,
128 OptTRIGGER_EVENT,
129 UNTIL,
130 VOLUME,
131 Num_Options, // number of Option values
132 Opt_Message // special value representing "message"
135 explicit CommandOptions();
136 bool checkCommand(Option, Command, EditAlarmDlg::Type = EditAlarmDlg::NO_TYPE);
137 inline void setError(const QString& error);
138 void setErrorRequires(Option opt, Option opt2, Option opt3 = Num_Options);
139 void setErrorParameter(Option);
140 void setErrorIncompatible(Option opt1, Option opt2);
141 void checkEditType(EditAlarmDlg::Type type, Option opt)
142 { checkEditType(type, EditAlarmDlg::NO_TYPE, opt); }
143 void checkEditType(EditAlarmDlg::Type, EditAlarmDlg::Type, Option);
144 static QString arg(int n);
145 static QString optionName(Option, bool shortName = false);
147 static CommandOptions* mInstance; // the unique instance
148 static QCommandLineParser* mParser;
149 static QVector<QCommandLineOption*> mOptions; // all possible command line options
150 static QStringList mExecArguments; // arguments for --exec or --exec-display
151 QString mError; // error message
152 Command mCommand; // the selected command
153 Option mCommandOpt; // option for the selected command
154 EventId mEventId; // TRIGGER_EVENT, CANCEL_EVENT, EDIT: event ID
155 QString mTemplateName; // EDIT_NEW_PRESET: template name
156 EditAlarmDlg::Type mEditType; // NEW, EDIT_NEW_*: alarm edit type
157 KAEvent::SubAction mEditAction; // NEW: alarm edit sub-type
158 bool mEditActionSet; // NEW: mEditAction is valid
159 QString mText; // NEW: alarm text
160 KDateTime mAlarmTime; // NEW: alarm time
161 KARecurrence* mRecurrence; // NEW: recurrence
162 int mRepeatCount; // NEW: sub-repetition count
163 KCalCore::Duration mRepeatInterval; // NEW: sub-repetition interval
164 int mLateCancel; // NEW: late-cancellation interval
165 QColor mBgColour; // NEW: background colour
166 QColor mFgColour; // NEW: foreground colour
167 int mReminderMinutes;// NEW: reminder period
168 QString mAudioFile; // NEW: audio file path
169 float mAudioVolume; // NEW: audio file volume
170 KCalCore::Person::List mAddressees; // NEW: email addressees
171 QStringList mAttachments; // NEW: email attachment file names
172 QString mSubject; // NEW: email subject
173 uint mFromID; // NEW: email sender ID
174 KAEvent::Flags mFlags; // NEW: event flags
175 bool mDisableAll; // disable all alarm monitoring
176 #ifndef NDEBUG
177 KDateTime mSimulationTime; // system time to be simulated, or invalid if none
178 #endif
181 #endif // COMMANDOPTIONS_H
183 // vim: et sw=4: