2020-10-31 Fred Gleason <fredg@paravelsystems.com>

* Added an 'RDApplication::ExitCode'.
	* Implemented 'RDApplication::ExitCode' in rdimport(1).
	* Implemented 'RDApplication::ExitCode' in rdlogmanager(1).
	* Implemented 'RDApplication::ExitCode' in rdservice(8).

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2020-10-31 16:47:41 -04:00
parent b7702a9c79
commit 2aa5aea4f9
22 changed files with 814 additions and 148 deletions

View File

@ -20520,3 +20520,8 @@
* Added a 'put' section to the WebGet interface.
2020-10-31 Fred Gleason <fredg@paravelsystems.com>
* Added an '--output-pattern' switch to rdimport(1).
2020-10-31 Fred Gleason <fredg@paravelsystems.com>
* Added an 'RDApplication::ExitCode'.
* Implemented 'RDApplication::ExitCode' in rdimport(1).
* Implemented 'RDApplication::ExitCode' in rdlogmanager(1).
* Implemented 'RDApplication::ExitCode' in rdservice(8).

View File

@ -65,7 +65,8 @@ man_MANS = rdairplay.1\
rdservice.8\
rdsoftkeys.1
EXTRA_DIST = rdairplay.1\
EXTRA_DIST = exitcodes.xml\
rdairplay.1\
rdairplay.xml\
rdalsaconfig.1\
rdalsaconfig.xml\

View File

@ -0,0 +1,32 @@
<!--
This is the full set of defined exit codes in Rivendell
A subset of these should go in each man page.
-->
<refsect1 id='exit_values'><title>Exit Values</title>
<para>
<segmentedlist>
<?dbhtml list-presentation="tabular"?>
<?dbfo list-presentation="tabular"?>
<segtitle></segtitle>
<segtitle></segtitle>
<seglistitem><seg>0</seg><seg>Normal exit</seg></seglistitem>
<seglistitem><seg>1</seg><seg>Prior instance already running</seg></seglistitem>
<seglistitem><seg>2</seg><seg>Unable to open database</seg></seglistitem>
<seglistitem><seg>3</seg><seg>Unable to start a service component</seg></seglistitem>
<seglistitem><seg>4</seg><seg>Unknown/invalid command line option</seg></seglistitem>
<seglistitem><seg>5</seg><seg>Unable to overwrite output [-P given]</seg></seglistitem>
<seglistitem><seg>6</seg><seg>No such service</seg></seglistitem>
<seglistitem><seg>7</seg><seg>No such log</seg></seglistitem>
<seglistitem><seg>8</seg><seg>No such report</seg></seglistitem>
<seglistitem><seg>9</seg><seg>Log generation failed</seg></seglistitem>
<seglistitem><seg>10</seg><seg>Schedule import failed</seg></seglistitem>
<seglistitem><seg>11</seg><seg>Insufficient permissions</seg></seglistitem>
<seglistitem><seg>12</seg><seg>Report generation failed</seg></seglistitem>
<seglistitem><seg>13</seg><seg>One or more audio imports failed</seg></seglistitem>
<seglistitem><seg>14</seg><seg>Unknown dropbox ID</seg></seglistitem>
<seglistitem><seg>15</seg><seg>No such group</seg></seglistitem>
<seglistitem><seg>16</seg><seg>Invalid cart number</seg></seglistitem>
<seglistitem><seg>17</seg><seg>No such scheduler code</seg></seglistitem>
</segmentedlist>
</para>
</refsect1>

View File

@ -947,6 +947,25 @@
</variablelist>
</refsect1>
<refsect1 id='exit_values'><title>Exit Values</title>
<para>
<segmentedlist>
<?dbhtml list-presentation="tabular"?>
<?dbfo list-presentation="tabular"?>
<segtitle></segtitle>
<segtitle></segtitle>
<seglistitem><seg>0</seg><seg>Normal exit</seg></seglistitem>
<seglistitem><seg>2</seg><seg>Unable to open database</seg></seglistitem>
<seglistitem><seg>4</seg><seg>Unknown/invalid command line option</seg></seglistitem>
<seglistitem><seg>13</seg><seg>One or more audio imports failed</seg></seglistitem>
<seglistitem><seg>14</seg><seg>Unknown dropbox ID</seg></seglistitem>
<seglistitem><seg>15</seg><seg>No such group</seg></seglistitem>
<seglistitem><seg>16</seg><seg>Invalid cart number</seg></seglistitem>
<seglistitem><seg>17</seg><seg>No such scheduler code</seg></seglistitem>
</segmentedlist>
</para>
</refsect1>
<refsect1>
<title>NOTES</title>
<para>

View File

@ -186,29 +186,27 @@
</variablelist>
</refsect1>
<refsect1 id='exit_values'><title>Exit Values</title>
<para>
<segmentedlist>
<?dbhtml list-presentation="tabular"?>
<?dbfo list-presentation="tabular"?>
<segtitle></segtitle>
<segtitle></segtitle>
<seglistitem><seg>0</seg><seg>Normal exit</seg></seglistitem>
<seglistitem><seg>1</seg><seg>Prior instance found</seg></seglistitem>
<seglistitem><seg>2</seg><seg>Unable to open database</seg></seglistitem>
<seglistitem><seg>3</seg><seg>Unable to start a service component</seg></seglistitem>
<seglistitem><seg>4</seg><seg>Unrecognized/invalid command line option</seg></seglistitem>
<seglistitem><seg>5</seg><seg>Output overwrite protected</seg></seglistitem>
<seglistitem><seg>6</seg><seg>No such service</seg></seglistitem>
<seglistitem><seg>7</seg><seg>No such log</seg></seglistitem>
<seglistitem><seg>8</seg><seg>No such report</seg></seglistitem>
<seglistitem><seg>9</seg><seg>Log generation failed</seg></seglistitem>
<seglistitem><seg>10</seg><seg>Schedule file import failed</seg></seglistitem>
<seglistitem><seg>11</seg><seg>Insufficient permissions</seg></seglistitem>
<seglistitem><seg>11</seg><seg>Report generation failed</seg></seglistitem>
</segmentedlist>
</para>
</refsect1>
<refsect1 id='exit_values'><title>Exit Values</title>
<para>
<segmentedlist>
<?dbhtml list-presentation="tabular"?>
<?dbfo list-presentation="tabular"?>
<segtitle></segtitle>
<segtitle></segtitle>
<seglistitem><seg>0</seg><seg>Normal exit</seg></seglistitem>
<seglistitem><seg>2</seg><seg>Unable to open database</seg></seglistitem>
<seglistitem><seg>4</seg><seg>Unknown/invalid command line option</seg></seglistitem>
<seglistitem><seg>5</seg><seg>Unable to overwrite output [-P given]</seg></seglistitem>
<seglistitem><seg>6</seg><seg>No such service</seg></seglistitem>
<seglistitem><seg>7</seg><seg>No such log</seg></seglistitem>
<seglistitem><seg>8</seg><seg>No such report</seg></seglistitem>
<seglistitem><seg>9</seg><seg>Log generation failed</seg></seglistitem>
<seglistitem><seg>10</seg><seg>Schedule import failed</seg></seglistitem>
<seglistitem><seg>11</seg><seg>Insufficient permissions</seg></seglistitem>
<seglistitem><seg>12</seg><seg>Report generation failed</seg></seglistitem>
</segmentedlist>
</para>
</refsect1>
<refsect1>
<title>BUGS</title>

View File

@ -92,29 +92,21 @@
</variablelist>
</refsect1>
<refsect1 id='exit_values'><title>Exit Values</title>
<para>
<segmentedlist>
<?dbhtml list-presentation="tabular"?>
<?dbfo list-presentation="tabular"?>
<segtitle></segtitle>
<segtitle></segtitle>
<seglistitem><seg>0</seg><seg>Normal exit</seg></seglistitem>
<seglistitem><seg>1</seg><seg>Prior instance found</seg></seglistitem>
<seglistitem><seg>2</seg><seg>Unable to open database</seg></seglistitem>
<seglistitem><seg>3</seg><seg>Unable to start a service component</seg></seglistitem>
<seglistitem><seg>4</seg><seg>Unrecognized/invalid command line option</seg></seglistitem>
<seglistitem><seg>5</seg><seg>Output overwrite protected</seg></seglistitem>
<seglistitem><seg>6</seg><seg>No such service</seg></seglistitem>
<seglistitem><seg>7</seg><seg>No such log</seg></seglistitem>
<seglistitem><seg>8</seg><seg>No such report</seg></seglistitem>
<seglistitem><seg>9</seg><seg>Log generation failed</seg></seglistitem>
<seglistitem><seg>10</seg><seg>Schedule file import failed</seg></seglistitem>
<seglistitem><seg>11</seg><seg>Insufficient permissions</seg></seglistitem>
<seglistitem><seg>11</seg><seg>Report generation failed</seg></seglistitem>
</segmentedlist>
</para>
</refsect1>
<refsect1 id='exit_values'><title>Exit Values</title>
<para>
<segmentedlist>
<?dbhtml list-presentation="tabular"?>
<?dbfo list-presentation="tabular"?>
<segtitle></segtitle>
<segtitle></segtitle>
<seglistitem><seg>0</seg><seg>Normal exit</seg></seglistitem>
<seglistitem><seg>1</seg><seg>Prior instance already running</seg></seglistitem>
<seglistitem><seg>2</seg><seg>Unable to open database</seg></seglistitem>
<seglistitem><seg>3</seg><seg>Unable to start a service component</seg></seglistitem>
<seglistitem><seg>4</seg><seg>Unknown/invalid command line option</seg></seglistitem>
</segmentedlist>
</para>
</refsect1>
<refsect1 id='see_also'><title>See Also</title>
<para>

View File

@ -990,6 +990,82 @@
<source>Rivendell service is not active.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ok</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>prior instance already running</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to open database</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to start a service component</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown/invalid command option</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to overwrite output [-P given]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such service</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>log generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>schedule import failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>insufficient permissions</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>report generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>one or more audio imports failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown dropbox id</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>invalid cart number</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such scheduler code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAudioSettingsDialog</name>

View File

@ -986,6 +986,82 @@
<source>Rivendell service is not active.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ok</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>prior instance already running</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to open database</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to start a service component</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown/invalid command option</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to overwrite output [-P given]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such service</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>log generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>schedule import failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>insufficient permissions</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>report generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>one or more audio imports failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown dropbox id</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>invalid cart number</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such scheduler code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAudioSettingsDialog</name>

View File

@ -986,6 +986,82 @@
<source>OK</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ok</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>prior instance already running</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to open database</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to start a service component</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown/invalid command option</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to overwrite output [-P given]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such service</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>log generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>schedule import failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>insufficient permissions</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>report generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>one or more audio imports failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown dropbox id</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>invalid cart number</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such scheduler code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAudioSettingsDialog</name>

View File

@ -952,6 +952,82 @@
<source>OK</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ok</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>prior instance already running</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to open database</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to start a service component</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown/invalid command option</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to overwrite output [-P given]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such service</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>log generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>schedule import failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>insufficient permissions</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>report generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>one or more audio imports failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown dropbox id</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>invalid cart number</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such scheduler code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAudioSettingsDialog</name>

View File

@ -986,6 +986,82 @@
<source>Rivendell service is not active.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ok</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>prior instance already running</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to open database</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to start a service component</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown/invalid command option</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to overwrite output [-P given]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such service</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>log generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>schedule import failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>insufficient permissions</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>report generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>one or more audio imports failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown dropbox id</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>invalid cart number</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such scheduler code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAudioSettingsDialog</name>

View File

@ -986,6 +986,82 @@
<source>Rivendell service is not active.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ok</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>prior instance already running</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to open database</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to start a service component</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown/invalid command option</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to overwrite output [-P given]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such service</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>log generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>schedule import failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>insufficient permissions</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>report generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>one or more audio imports failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown dropbox id</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>invalid cart number</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such scheduler code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAudioSettingsDialog</name>

View File

@ -986,6 +986,82 @@
<source>Rivendell service is not active.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>ok</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>prior instance already running</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to open database</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to start a service component</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown/invalid command option</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unable to overwrite output [-P given]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such service</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such log</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such report</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>log generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>schedule import failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>insufficient permissions</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>report generation failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>one or more audio imports failed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>unknown dropbox id</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such group</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>invalid cart number</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>no such scheduler code</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAudioSettingsDialog</name>

View File

@ -615,23 +615,6 @@
*/
#define RD_RSS_XML_FILE_EXTENSION "rss"
/*
* Exit Codes
*/
#define RD_EXIT_OK 0 // Normal exit
#define RD_EXIT_PRIOR_INSTANCE 1 // Prior instance found
#define RD_EXIT_NO_DB 2 // Unable to open database
#define RD_EXIT_SVC_FAILED 3 // Unable to start a service component
#define RD_EXIT_UNKNOWN_OPTION 4 // Unrecognized command line option
#define RD_EXIT_OUTPUT_PROTECTED 5 // Couldn't overwrite output (-P)
#define RD_EXIT_NO_SERVICE 6 // No such service
#define RD_EXIT_NO_LOG 7 // No such log
#define RD_EXIT_NO_REPORT 8 // No such report
#define RD_EXIT_LOG_GEN_FAILED 9 // Log generation failed
#define RD_EXIT_LOG_LINK_FAILED 10 // Schedule import failed
#define RD_EXIT_NO_PERMS 11 // Insufficient permissions
#define RD_EXIT_REPORT_FAILED 12 // Report generation failed
/*
* Shelf life for GPIO event records
*/

View File

@ -353,6 +353,91 @@ void RDApplication::syslog(RDConfig *config,int priority,const char *fmt,...)
}
QString RDApplication::exitCodeText(RDApplication::ExitCode code)
{
QString ret=tr("unknown")+QString().sprintf(" [%u]",code);
switch(code) {
case RDApplication::ExitOk:
ret=tr("ok");
break;
case RDApplication::ExitPriorInstance:
ret=tr("prior instance already running");
break;
case RDApplication::ExitNoDb:
ret=tr("unable to open database");
break;
case RDApplication::ExitSvcFailed:
ret=tr("unable to start a service component");
break;
case RDApplication::ExitInvalidOption:
ret=tr("unknown/invalid command option");
break;
case RDApplication::ExitOutputProtected:
ret=tr("unable to overwrite output [-P given]");
break;
case RDApplication::ExitNoSvc:
ret=tr("no such service");
break;
case RDApplication::ExitNoLog:
ret=tr("no such log");
break;
case RDApplication::ExitNoReport:
ret=tr("no such report");
break;
case RDApplication::ExitLogGenFailed:
ret=tr("log generation failed");
break;
case RDApplication::ExitLogLinkFailed:
ret=tr("schedule import failed");
break;
case RDApplication::ExitNoPerms:
ret=tr("insufficient permissions");
break;
case RDApplication::ExitReportFailed:
ret=tr("report generation failed");
break;
case RDApplication::ExitImportFailed:
ret=tr("one or more audio imports failed");
break;
case RDApplication::ExitNoDropbox:
ret=tr("unknown dropbox id");
break;
case RDApplication::ExitNoGroup:
ret=tr("no such group");
break;
case RDApplication::ExitInvalidCart:
ret=tr("invalid cart number");
break;
case RDApplication::ExitNoSchedCode:
ret=tr("no such scheduler code");
break;
case RDApplication::ExitLast:
break;
}
return ret;
}
void RDApplication::userChangedData()
{
app_user->setName(app_ripc->user());

View File

@ -47,6 +47,12 @@ class RDApplication : public QObject
public:
enum ErrorType {ErrorOk=0,ErrorDbVersionSkew=1,ErrorNoHostEntry=2,
ErrorNoService=3};
enum ExitCode {ExitOk=0,ExitPriorInstance=1,ExitNoDb=2,ExitSvcFailed=3,
ExitInvalidOption=4,ExitOutputProtected=5,ExitNoSvc=6,
ExitNoLog=7,ExitNoReport=8,ExitLogGenFailed=9,
ExitLogLinkFailed=10,ExitNoPerms=11,ExitReportFailed=12,
ExitImportFailed=13,ExitNoDropbox=14,ExitNoGroup=15,
ExitInvalidCart=16,ExitNoSchedCode=17,ExitLast=18};
RDApplication(const QString &module_name,const QString &cmdname,
const QString &usage,QObject *parent=0);
~RDApplication();
@ -69,6 +75,7 @@ class RDApplication : public QObject
void logAuthenticationFailure(const QHostAddress &orig_addr,
const QString &login_name=QString());
static void syslog(RDConfig *config,int priority,const char *fmt,...);
static QString exitCodeText(ExitCode code);
private slots:
void userChangedData();

View File

@ -51,7 +51,7 @@ int RunReportOperation(int argc,char *argv[],const QString &rptname,
rda=new RDApplication("RDLogManager","rdlogmanager",RDLOGMANAGER_USAGE);
if(!rda->open(&err_msg)) {
fprintf(stderr,"rdlogmanager: %s\n",err_msg.toUtf8().constData());
exit(RD_EXIT_NO_DB);
exit(RDApplication::ExitNoDb);
}
//
@ -60,7 +60,7 @@ int RunReportOperation(int argc,char *argv[],const QString &rptname,
RDReport *report=new RDReport(rptname,rda->station(),rda->config());
if(!report->exists()) {
fprintf(stderr,"rdlogmanager: no such report\n");
return RD_EXIT_NO_REPORT;
return RDApplication::ExitNoReport;
}
//
@ -71,14 +71,14 @@ int RunReportOperation(int argc,char *argv[],const QString &rptname,
fprintf(stderr,"report \"%s\" for %s already exists\n",
(const char *)rptname.utf8(),
(const char *)yesterday.addDays(start_offset).toString());
exit(RD_EXIT_OUTPUT_PROTECTED);
exit(RDApplication::ExitOutputProtected);
}
if(!report->generateReport(yesterday.addDays(start_offset),
yesterday.addDays(end_offset),rda->station(),
&out_path)) {
fprintf(stderr,"rdlogmanager: report generation failed [%s]\n",
(const char *)RDReport::errorText(report->errorCode()));
return RD_EXIT_REPORT_FAILED;
return RDApplication::ExitReportFailed;
}
return RD_EXIT_OK;
return RDApplication::ExitOk;
}

View File

@ -49,7 +49,7 @@ LogObject::LogObject(const QString &svcname,int start_offset,
rda=new RDApplication("RDLogManager","rdlogmanager","");
if(!rda->open(&err_msg)) {
fprintf(stderr,"rdlogmanager: %s\n",err_msg.toUtf8().constData());
exit(RD_EXIT_NO_DB);
exit(RDApplication::ExitNoDb);
}
connect(rda,SIGNAL(userChanged()),this,SLOT(userData()));
@ -73,7 +73,7 @@ void LogObject::userData()
RDSvc *svc=new RDSvc(log_service_name,rda->station(),rda->config());
if(!svc->exists()) {
fprintf(stderr,"rdlogmanager: no such service\n");
exit(RD_EXIT_NO_SERVICE);
exit(RDApplication::ExitNoSvc);
}
QDate start_date=QDate::currentDate().addDays(1+log_start_offset);
QString logname=
@ -88,7 +88,7 @@ void LogObject::userData()
if(log_protect_existing&&log->exists()) {
fprintf(stderr,"log \"%s\" already exists\n",
log->name().utf8().constData());
exit(RD_EXIT_OUTPUT_PROTECTED);
exit(RDApplication::ExitOutputProtected);
}
SendNotification(RDNotification::DeleteAction,log->name());
log->removeTracks(rda->station(),rda->user(),rda->config());
@ -101,7 +101,7 @@ void LogObject::userData()
&unused_report,rda->user(),&err_msg)) {
fprintf(stderr,"rdlogmanager: log generation failed\n");
printf("%s\n",err_msg.toUtf8().constData());
exit(RD_EXIT_LOG_GEN_FAILED);
exit(RDApplication::ExitLogGenFailed);
}
log->updateTracks();
SendNotification(RDNotification::AddAction,log->name());
@ -124,33 +124,33 @@ void LogObject::userData()
if(log_merge_music) {
if(!log->exists()) {
fprintf(stderr,"rdlogmanager: log does not exist\n");
exit(RD_EXIT_NO_LOG);
exit(RDApplication::ExitNoLog);
}
if(log_protect_existing&&
(log->linkState(RDLog::SourceMusic)==RDLog::LinkDone)) {
fprintf(stderr,
"rdlogmanager: music for log \"%s\" is already imported\n",
log->name().utf8().constData());
exit(RD_EXIT_LOG_LINK_FAILED);
exit(RDApplication::ExitLogLinkFailed);
}
if((!log->includeImportMarkers())&&
(log->linkState(RDLog::SourceMusic)!=RDLog::LinkMissing)) {
fprintf(stderr,
"rdlogmanager: music for log \"%s\" cannot be reimported\n",
log->name().utf8().constData());
exit(RD_EXIT_LOG_LINK_FAILED);
exit(RDApplication::ExitLogLinkFailed);
}
report="";
log->removeTracks(rda->station(),rda->user(),rda->config());
if(!svc->clearLogLinks(RDSvc::Traffic,logname,rda->user(),&err_msg)) {
fprintf(stderr,"rdlogmanager: music import failed\n");
printf("%s\n",err_msg.toUtf8().constData());
exit(RD_EXIT_LOG_LINK_FAILED);
exit(RDApplication::ExitLogLinkFailed);
}
if(!svc->clearLogLinks(RDSvc::Music,logname,rda->user(),&err_msg)) {
fprintf(stderr,"rdlogmanager: music import failed\n");
printf("%s\n",err_msg.toUtf8().constData());
exit(RD_EXIT_LOG_LINK_FAILED);
exit(RDApplication::ExitLogLinkFailed);
}
if(svc->linkLog(RDSvc::Music,start_date,logname,&report,rda->user(),
&err_msg)) {
@ -159,7 +159,7 @@ void LogObject::userData()
else {
fprintf(stderr,"rdlogmanager: music import failed\n");
printf("%s\n",err_msg.toUtf8().constData());
exit(RD_EXIT_LOG_LINK_FAILED);
exit(RDApplication::ExitLogLinkFailed);
}
SendNotification(RDNotification::ModifyAction,log->name());
}
@ -170,27 +170,27 @@ void LogObject::userData()
if(log_merge_traffic) {
if(!log->exists()) {
fprintf(stderr,"rdlogmanager: log does not exist\n");
exit(RD_EXIT_NO_LOG);
exit(RDApplication::ExitNoLog);
}
if(log_protect_existing&&
(log->linkState(RDLog::SourceTraffic)==RDLog::LinkDone)) {
fprintf(stderr,
"rdlogmanager: traffic for log \"%s\" is already imported\n",
(const char *)log->name().utf8());
exit(RD_EXIT_LOG_LINK_FAILED);
exit(RDApplication::ExitLogLinkFailed);
}
if((!log->includeImportMarkers())&&
(log->linkState(RDLog::SourceTraffic)!=RDLog::LinkMissing)) {
fprintf(stderr,
"rdlogmanager: traffic for log \"%s\" cannot be reimported\n",
log->name().utf8().constData());
exit(RD_EXIT_LOG_LINK_FAILED);
exit(RDApplication::ExitLogLinkFailed);
}
report="";
if(!svc->clearLogLinks(RDSvc::Traffic,logname,rda->user(),&err_msg)) {
fprintf(stderr,"rdlogmanager: traffic schedule import failed\n");
printf("%s\n",err_msg.toUtf8().constData());
exit(RD_EXIT_LOG_LINK_FAILED);
exit(RDApplication::ExitLogLinkFailed);
}
if(svc->linkLog(RDSvc::Traffic,start_date,logname,&report,rda->user(),
&err_msg)) {
@ -201,7 +201,7 @@ void LogObject::userData()
printf("%s\n",err_msg.toUtf8().constData());
delete log;
delete svc;
exit(RD_EXIT_LOG_LINK_FAILED);
exit(RDApplication::ExitLogLinkFailed);
}
SendNotification(RDNotification::ModifyAction,log->name());
}
@ -211,10 +211,10 @@ void LogObject::userData()
//
delete log;
delete svc;
exit(RD_EXIT_OK);
exit(RDApplication::ExitOk);
}
fprintf(stderr,"rdlogmanager: insufficient permissions\n");
exit(RD_EXIT_NO_PERMS);
exit(RDApplication::ExitNoPerms);
}

View File

@ -2,7 +2,7 @@
//
// The Log Generator Utility for Rivendell.
//
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2020 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -60,7 +60,7 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
rda=new RDApplication("RDLogManager","rdlogmanager",RDLOGMANAGER_USAGE,this);
if(!rda->open(&err_msg)) {
QMessageBox::critical(this,"RDLogManager - "+tr("Error"),err_msg);
exit(RD_EXIT_NO_DB);
exit(RDApplication::ExitNoDb);
}
setWindowTitle(tr("RDLogManager"));
@ -228,7 +228,7 @@ void MainWidget::reportsData()
void MainWidget::quitMainWidget()
{
exit(RD_EXIT_OK);
exit(RDApplication::ExitOk);
}
@ -319,7 +319,7 @@ int main(int argc,char *argv[])
}
else {
fprintf(stderr,"rdlogmanager: missing argument to \"-s\"\n");
exit(RD_EXIT_UNKNOWN_OPTION);
exit(RDApplication::ExitInvalidOption);
}
cmd->setProcessed(i,true);
}
@ -330,7 +330,7 @@ int main(int argc,char *argv[])
}
else {
fprintf(stderr,"rdlogmanager: missing argument to \"-r\"\n");
exit(RD_EXIT_UNKNOWN_OPTION);
exit(RDApplication::ExitInvalidOption);
}
cmd->setProcessed(i,true);
}
@ -341,7 +341,7 @@ int main(int argc,char *argv[])
}
else {
fprintf(stderr,"rdlogmanager: missing argument to \"-d\"\n");
exit(RD_EXIT_UNKNOWN_OPTION);
exit(RDApplication::ExitInvalidOption);
}
cmd->setProcessed(i,true);
}
@ -352,14 +352,14 @@ int main(int argc,char *argv[])
}
else {
fprintf(stderr,"rdlogmanager: missing argument to \"-e\"\n");
exit(RD_EXIT_UNKNOWN_OPTION);
exit(RDApplication::ExitInvalidOption);
}
cmd->setProcessed(i,true);
}
if(!cmd->processed(i)) {
fprintf(stderr,"rdlogmanager: unknown command option \"%s\"\n",
(const char *)cmd->key(i));
exit(RD_EXIT_UNKNOWN_OPTION);
exit(RDApplication::ExitInvalidOption);
}
}
delete cmd;
@ -367,7 +367,7 @@ int main(int argc,char *argv[])
(cmd_generate||cmd_merge_traffic||cmd_merge_music)) {
fprintf(stderr,
"rdlogmanager: log and report operations are mutually exclusive\n");
exit(RD_EXIT_UNKNOWN_OPTION);
exit(RDApplication::ExitInvalidOption);
}
if(cmd_generate||cmd_merge_traffic||cmd_merge_music) {

View File

@ -65,7 +65,7 @@ MainObject::MainObject(QObject *parent)
//
if(RDGetPids("rdservice").size()>1) {
rda->syslog(LOG_ERR,"prior instance found");
exit(RD_EXIT_PRIOR_INSTANCE);
exit(RDApplication::ExitPriorInstance);
}
//
@ -75,7 +75,7 @@ MainObject::MainObject(QObject *parent)
if(!rda->open(&err_msg,&err_type,false)) {
rda->syslog(LOG_ERR,"unable to open database [%s]",
(const char *)err_msg.utf8());
exit(RD_EXIT_NO_DB);
exit(RDApplication::ExitNoDb);
}
//
@ -91,7 +91,7 @@ MainObject::MainObject(QObject *parent)
}
if(!rda->cmdSwitch()->processed(i)) {
fprintf(stderr,"rdservice: unknown command-line option\n");
exit(RD_EXIT_UNKNOWN_OPTION);
exit(RDApplication::ExitInvalidOption);
}
}
@ -109,7 +109,7 @@ MainObject::MainObject(QObject *parent)
Shutdown();
rda->syslog(LOG_ERR,"unable to start service component [%s]",
(const char *)err_msg.toUtf8());
exit(RD_EXIT_SVC_FAILED);
exit(RDApplication::ExitSvcFailed);
}
//
@ -149,7 +149,7 @@ void MainObject::exitData()
Shutdown();
RDDeletePid(RD_PID_DIR,"rdservice.pid");
rda->syslog(LOG_DEBUG,"shutting down normally");
exit(RD_EXIT_OK);
exit(RDApplication::ExitOk);
}
if(global_reload_dropboxes) {

View File

@ -98,6 +98,7 @@ MainObject::MainObject(QObject *parent)
import_clear_dayparts=false;
import_xml=false;
import_to_mono=false;
import_failed_imports=0;
//
// Open the Database
@ -105,7 +106,7 @@ MainObject::MainObject(QObject *parent)
rda=new RDApplication("rdimport","rdimport",RDIMPORT_USAGE,this);
if(!rda->open(&err_msg)) {
fprintf(stderr,"rdimport: %s\n",(const char *)err_msg);
exit(1);
exit(RDApplication::ExitNoDb);
}
//
@ -113,7 +114,7 @@ MainObject::MainObject(QObject *parent)
//
if(rda->cmdSwitch()->keys()<2) {
Log(LOG_ERR,QString().sprintf("\n%s\n",RDIMPORT_USAGE));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
for(unsigned i=0;i<rda->cmdSwitch()->keys()-2;i++) {
if(rda->cmdSwitch()->key(i)=="--verbose") {
@ -132,11 +133,11 @@ MainObject::MainObject(QObject *parent)
import_cart_number=rda->cmdSwitch()->value(i).toUInt(&ok);
if((!ok)||(import_cart_number<1)||(import_cart_number>999999)) {
Log(LOG_ERR,QString("rdimport: invalid cart number\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
if(import_use_cartchunk_cutid) {
Log(LOG_ERR,QString("rdimport: '--to-cart' and '--use-cartchunk-cutid' are mutually exclusive\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
import_single_cart=true;
rda->cmdSwitch()->setProcessed(i,true);
@ -144,7 +145,7 @@ MainObject::MainObject(QObject *parent)
if(rda->cmdSwitch()->key(i)=="--use-cartchunk-cutid") {
if(import_cart_number!=0) {
Log(LOG_ERR,QString("rdimport: '--to-cart' and '--use-cartchunk-cutid' are mutually exclusive\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
import_use_cartchunk_cutid=true;
rda->cmdSwitch()->setProcessed(i,true);
@ -153,7 +154,7 @@ MainObject::MainObject(QObject *parent)
import_cart_number_offset=rda->cmdSwitch()->value(i).toInt(&ok);
if(!ok) {
Log(LOG_ERR,QString("rdimport: invalid --cart-number-offset\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
rda->cmdSwitch()->setProcessed(i,true);
}
@ -173,7 +174,7 @@ MainObject::MainObject(QObject *parent)
import_startdate_offset=rda->cmdSwitch()->value(i).toInt(&ok);
if(!ok) {
Log(LOG_ERR,QString("rdimport: invalid startdate-offset\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
rda->cmdSwitch()->setProcessed(i,true);
}
@ -181,7 +182,7 @@ MainObject::MainObject(QObject *parent)
import_enddate_offset=rda->cmdSwitch()->value(i).toInt(&ok);
if(!ok) {
Log(LOG_ERR,QString("rdimport: invalid enddate-offset\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
rda->cmdSwitch()->setProcessed(i,true);
}
@ -193,42 +194,42 @@ MainObject::MainObject(QObject *parent)
QStringList f0=rda->cmdSwitch()->value(i).split(",");
if(f0.size()!=2) {
Log(LOG_ERR,QString("rdimport: invalid argument to --set-datetimes\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
for(unsigned j=0;j<2;j++) {
if((f0[j].length()!=15)||(f0[j].mid(8,1)!="-")) {
Log(LOG_ERR,QString("rdimport: invalid argument to --set-datetimes\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
unsigned year=f0[j].left(4).toUInt(&ok);
if(!ok) {
Log(LOG_ERR,QString("rdimport: invalid year argument to --set-datetimes\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
unsigned month=f0[j].mid(4,2).toUInt(&ok);
if((!ok)||(month>12)) {
Log(LOG_ERR,QString("rdimport: invalid month argument to --set-datetimes\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
unsigned day=f0[j].mid(6,2).toUInt(&ok);
if((!ok)||(day>31)) {
Log(LOG_ERR,QString("rdimport: invalid day argument to --set-datetimes\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
unsigned hour=f0[j].mid(9,2).toUInt(&ok);
if((!ok)||(hour>23)) {
Log(LOG_ERR,QString("rdimport: invalid hour argument to --set-datetimes\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
unsigned min=f0[j].mid(11,2).toUInt(&ok);
if((!ok)||(min>59)) {
Log(LOG_ERR,QString("rdimport: invalid minute argument to --set-datetimes\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
unsigned sec=f0[j].right(2).toUInt(&ok);
if((!ok)||(sec>59)) {
Log(LOG_ERR,QString("rdimport: invalid seconds argument to --set-datetimes\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
import_datetimes[j]=QDateTime(QDate(year,month,day),
QTime(hour,min,sec));
@ -238,7 +239,7 @@ MainObject::MainObject(QObject *parent)
}
if(import_datetimes[0]>=import_datetimes[1]) {
Log(LOG_ERR,QString("rdimport: datetime cannot end before it begins\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
rda->cmdSwitch()->setProcessed(i,true);
}
@ -246,33 +247,33 @@ MainObject::MainObject(QObject *parent)
QStringList f0=rda->cmdSwitch()->value(i).split(",");
if(f0.size()!=2) {
Log(LOG_ERR,QString("rdimport: invalid argument to --set-daypart-times\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
for(unsigned j=0;j<2;j++) {
if(f0[j].length()!=6) {
Log(LOG_ERR,QString("rdimport: invalid argument to --set-daypart-times\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
unsigned hour=f0[j].left(2).toUInt(&ok);
if((!ok)||(hour>23)) {
Log(LOG_ERR,QString("rdimport: invalid hour argument to --set-daypart-times\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
unsigned min=f0[j].mid(2,2).toUInt(&ok);
if((!ok)||(min>59)) {
Log(LOG_ERR,QString("rdimport: invalid minute argument to --set-daypart-times\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
unsigned sec=f0[j].right(2).toUInt(&ok);
if((!ok)||(sec>59)) {
Log(LOG_ERR,QString("rdimport: invalid seconds argument to --set-daypart-times\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
import_dayparts[j].setHMS(hour,min,sec);
}
if(import_dayparts[0]>=import_dayparts[1]) {
Log(LOG_ERR,QString("rdimport: daypart cannot end before it begins\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
rda->cmdSwitch()->setProcessed(i,true);
}
@ -303,7 +304,7 @@ MainObject::MainObject(QObject *parent)
import_metadata_pattern=rda->cmdSwitch()->value(i);
if(!VerifyPattern(import_metadata_pattern)) {
Log(LOG_ERR,QString("rdimport: invalid --metadata-pattern\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
rda->cmdSwitch()->setProcessed(i,true);
}
@ -311,7 +312,7 @@ MainObject::MainObject(QObject *parent)
import_output_pattern=rda->cmdSwitch()->value(i);
if(!VerifyPattern(import_output_pattern)) {
Log(LOG_ERR,QString("rdimport: invalid --output-pattern\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
rda->cmdSwitch()->setProcessed(i,true);
}
@ -323,7 +324,7 @@ MainObject::MainObject(QObject *parent)
import_persistent_dropbox_id=rda->cmdSwitch()->value(i).toInt(&ok);
if(!ok) {
Log(LOG_ERR,QString("rdimport: invalid persistent dropbox id\n"));
exit(2);
exit(RDApplication::ExitNoDropbox);
}
rda->cmdSwitch()->setProcessed(i,true);
}
@ -331,7 +332,7 @@ MainObject::MainObject(QObject *parent)
import_create_startdate_offset=rda->cmdSwitch()->value(i).toInt(&ok);
if(!ok) {
Log(LOG_ERR,QString("rdimport: invalid create-startddate-offset\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
import_create_dates=true;
rda->cmdSwitch()->setProcessed(i,true);
@ -341,7 +342,7 @@ MainObject::MainObject(QObject *parent)
if((!ok) ||
(import_create_startdate_offset > import_create_enddate_offset )) {
Log(LOG_ERR,QString("rdimport: invalid create-enddate-offset\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
import_create_dates=true;
rda->cmdSwitch()->setProcessed(i,true);
@ -362,7 +363,7 @@ MainObject::MainObject(QObject *parent)
import_string_bpm=rda->cmdSwitch()->value(i).toInt(&ok);
if(!ok) {
Log(LOG_ERR,QString("rdimport: invalid value for --set-string-bpm\n"));
exit(255);
exit(RDApplication::ExitInvalidOption);
}
rda->cmdSwitch()->setProcessed(i,true);
}
@ -401,7 +402,7 @@ MainObject::MainObject(QObject *parent)
}
else {
Log(LOG_ERR,"invalid ISRC \""+rda->cmdSwitch()->value(i)+"\"\n");
exit(1);
exit(RDApplication::ExitInvalidOption);
}
}
if(rda->cmdSwitch()->key(i)=="--set-string-recording-mbid") {
@ -423,7 +424,7 @@ MainObject::MainObject(QObject *parent)
if(rda->cmdSwitch()->key(i)=="--set-string-title") {
if(rda->cmdSwitch()->value(i).isEmpty()) {
Log(LOG_ERR,QString("rdimport: title field cannot be empty\n"));
exit(255);
exit(RDApplication::ExitInvalidOption);
}
import_string_title=rda->cmdSwitch()->value(i);
rda->cmdSwitch()->setProcessed(i,true);
@ -436,7 +437,7 @@ MainObject::MainObject(QObject *parent)
import_string_year=rda->cmdSwitch()->value(i).toInt(&ok);
if(!ok) {
Log(LOG_ERR,QString("rdimport: invalid value for --set-string-year\n"));
exit(255);
exit(RDApplication::ExitInvalidOption);
}
rda->cmdSwitch()->setProcessed(i,true);
}
@ -451,19 +452,19 @@ MainObject::MainObject(QObject *parent)
//
if(import_datetimes[0].isValid()&&import_clear_datetimes) {
Log(LOG_ERR,QString("rdimport: --set-datetimes and --clear-datetimes are mutually exclusive\n"));
exit(255);
exit(RDApplication::ExitInvalidOption);
}
if((!import_dayparts[1].isNull())&&import_clear_dayparts) {
Log(LOG_ERR,QString("rdimport: --set-daypart-times and --clear-daypart-times are mutually exclusive\n"));
exit(255);
exit(RDApplication::ExitInvalidOption);
}
if((!import_metadata_pattern.isEmpty())&&import_xml) {
Log(LOG_ERR,QString().sprintf("rdimport: --metadata-pattern and --xml are mutually exclusive\n"));
exit(255);
exit(RDApplication::ExitInvalidOption);
}
if((!import_log_filename.isEmpty())&&import_log_syslog) {
Log(LOG_ERR,QString().sprintf("rdimport: --log-filename and --log-syslog are mutually exclusive\n"));
exit(255);
exit(RDApplication::ExitInvalidOption);
}
import_cut_markers=new MarkerSet();
@ -495,7 +496,7 @@ MainObject::MainObject(QObject *parent)
if(!import_group->exists()) {
Log(LOG_ERR,QString().sprintf("rdimport: invalid group specified\n"));
delete import_group;
exit(2);
exit(RDApplication::ExitNoGroup);
}
import_file_key=i+1;
i=rda->cmdSwitch()->keys();
@ -509,7 +510,7 @@ MainObject::MainObject(QObject *parent)
if(!import_group->cartNumberValid(import_cart_number)) {
Log(LOG_ERR,QString().sprintf("rdimport: invalid cart number for group\n"));
delete import_group;
exit(2);
exit(RDApplication::ExitInvalidCart);
}
}
@ -520,7 +521,7 @@ MainObject::MainObject(QObject *parent)
if(!SchedulerCodeExists(import_add_scheduler_codes[i])) {
Log(LOG_ERR,QString().sprintf("rdimport: scheduler code \"%s\" does not exist\n",
(const char *)import_add_scheduler_codes[i].toUtf8()));
exit(2);
exit(RDApplication::ExitNoSchedCode);
}
}
@ -545,7 +546,7 @@ MainObject::MainObject(QObject *parent)
}
else {
Log(LOG_ERR,QString("rdimport: invalid normalization level\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
rda->cmdSwitch()->setProcessed(i,true);
}
@ -556,7 +557,7 @@ MainObject::MainObject(QObject *parent)
}
else {
Log(LOG_ERR,QString("rdimport: invalid autotrim level\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
rda->cmdSwitch()->setProcessed(i,true);
}
@ -567,7 +568,7 @@ MainObject::MainObject(QObject *parent)
}
else {
Log(LOG_ERR,QString("rdimport: invalid segue level\n"));
exit(2);
exit(RDApplication::ExitInvalidOption);
}
rda->cmdSwitch()->setProcessed(i,true);
}
@ -852,7 +853,7 @@ void MainObject::userData()
Log(LOG_INFO,QString("rdimport finished\n"));
exit(0);
NormalExit();
}
@ -971,7 +972,7 @@ MainObject::Result MainObject::ImportFile(const QString &filename,
delete wavedata;
delete effective_group;
if(!import_run) {
exit(0);
NormalExit();
}
if(!import_temp_fix_filename.isEmpty()) {
// printf("Fixed Name: %s\n",(const char *)import_temp_fix_filename);
@ -991,7 +992,7 @@ MainObject::Result MainObject::ImportFile(const QString &filename,
delete wavedata;
delete effective_group;
if(!import_run) {
exit(0);
NormalExit();
}
if(!import_temp_fix_filename.isEmpty()) {
QFile::remove(import_temp_fix_filename);
@ -1056,7 +1057,7 @@ MainObject::Result MainObject::ImportFile(const QString &filename,
delete effective_group;
if(import_drop_box) {
if(!import_run) {
exit(0);
NormalExit();
}
if(!import_temp_fix_filename.isEmpty()) {
QFile::remove(import_temp_fix_filename);
@ -1146,7 +1147,7 @@ MainObject::Result MainObject::ImportFile(const QString &filename,
delete wavedata;
delete effective_group;
if(!import_run) {
exit(0);
NormalExit();
}
if(!import_temp_fix_filename.isEmpty()) {
QFile::remove(import_temp_fix_filename);
@ -1357,7 +1358,7 @@ MainObject::Result MainObject::ImportFile(const QString &filename,
Log(LOG_INFO,QString().sprintf(" Deleted file \"%s\"\n",(const char *)RDGetBasePart(filename).toUtf8()));
}
if(!import_run) {
exit(0);
NormalExit();
}
if(!import_temp_fix_filename.isEmpty()) {
QFile::remove(import_temp_fix_filename);
@ -2166,6 +2167,15 @@ void MainObject::Log(int prio,const QString &msg) const
}
void MainObject::NormalExit() const
{
if(import_failed_imports>0) {
exit(RDApplication::ExitImportFailed);
}
exit(RDApplication::ExitOk);
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv,false);

View File

@ -74,6 +74,7 @@ class MainObject : public QObject
void ReadXmlFile(const QString &basename,RDWaveData *wavedata) const;
void Log(int prio,const QString &msg) const;
void SendNotification(RDNotification::Action action,unsigned cartnum);
void NormalExit() const;
unsigned import_file_key;
RDGroup *import_group;
bool import_verbose;
@ -134,6 +135,7 @@ class MainObject : public QObject
QString import_string_title;
QString import_string_user_defined;
int import_string_year;
int import_failed_imports;
struct DropboxList {
QString filename;
unsigned size;