Remoto - VFS: main.cpp Source File
Remoto - VFS
main.cpp
Go to the documentation of this file.
1 
2 #include <signal.h>
3 
4 #include <QCoreApplication>
5 #include <QCommandLineParser>
6 #include <QNetworkAccessManager>
7 #include <QVariantMap>
8 #include <QJSValue>
9 #include <QQmlEngine>
10 
11 #include "VFS.h"
12 
13 #include "defines.h"
14 
15 int main(int argc, char *argv[])
16 {
17  QCoreApplication app(argc, argv);
18 
19  QCoreApplication::setOrganizationName(ORGANIZATION_NAME);
20  QCoreApplication::setOrganizationDomain(ORGANIZATION_DOMAIN);
21  QCoreApplication::setApplicationName(APPLICATION_NAME);
22  QCoreApplication::setApplicationVersion(APPLICATION_VERSION);
23 
24  //register required meta types
25  qRegisterMetaType<postID>("postID");
26  qRegisterMetaType<VFS_request*>("VFS_request*");
27  qRegisterMetaType<VFS_request::requestType>("VFS_request::requestType");
28 
29  //initialize some objects which will remove warning messages
30  // - https://bugreports.qt.io/browse/QTBUG-50928
31  // - http://www.qtcentre.org/threads/60776-Qt-warning-of-type-conversion-already-registered
32 
33  //creating this object alone covers many cases
34  QNetworkAccessManager m;
35 
36  //covers QJSValue -> QVariantMap
37  QQmlEngine engine;
38  QVariantMap vm;
39  QJSValue value = engine.toScriptValue<QVariantMap>(vm);
40 
41  //this has not proven to be fully effective
42 // signal(SIGPIPE, SIG_IGN); //ignore SIGPIPE signals
43  //signal(SIGTTOU,SIG_IGN); //these are for subprocesses that may send signals we don't like
44  //signal(SIGTTIN,SIG_IGN);
46 
47  QCommandLineParser parser;
48  QCommandLineOption helpOption = parser.addHelpOption();
49  QCommandLineOption versionOption = parser.addVersionOption();
50 
51  //config
52  QCommandLineOption configOption(
53  {"c","config"},
54  "The path to an xml config file.",
55  "config"
56  );
57  parser.addOption(configOption);
58  parser.addPositionalArgument("config", "The path to an xml config file.","[config]");
59 
60  //plugins
61  QCommandLineOption pluginsOption(
62  {"p","plugins"},
63  "A plugin directory path. This option can appear multiple times.",
64  "plugins"
65  );
66  parser.addOption(pluginsOption);
67 
68  //describe
69  QCommandLineOption describeOption(
70  {"d","describe"},
71  "Load all plugins found and print a description for the nodes within them."
72  );
73  parser.addOption(describeOption);
74 
75  parser.process(app);
76 
77  const QStringList args = parser.positionalArguments();
78 
79  printf(RMO_CREDIT);
80 
81  bool help = parser.isSet(helpOption);
82  bool version = parser.isSet(versionOption);
83  QString config = args.length() ? args.at(0) : parser.value(configOption);
84  QStringList plugins = parser.values(pluginsOption);
85  bool describe = parser.isSet(describeOption);
86  bool printconfig = false; //if ever needed we can toggle it here
87 
88  if (help || version)
89  return 0;
90 
91  VFS v(config,plugins,describe,printconfig);
92 
93  if (describe || config.isEmpty())
94  return 0;
95 
96  return app.exec();
97 }
VFS is the root node for a Virtual Filesystem.
Definition: VFS.h:15
setter value
a setter DOCME
getter help
A getter that will return a pane object's help message, or a default message indicating that no help ...
setter config
a setter DOCME
#define APPLICATION_VERSION
Definition: defines.h:7
#define ORGANIZATION_NAME
Definition: defines.h:4
#define ORGANIZATION_DOMAIN
Definition: defines.h:5
#define RMO_CREDIT
Definition: defines.h:9
#define APPLICATION_NAME
Definition: defines.h:6
int main(int argc, char *argv[])
Definition: main.cpp:15