MCPcopy Create free account
hub / github.com/Martchus/syncthingtray / exec

Method exec

cli/application.cpp:109–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109int Application::exec(int argc, const char *const *argv)
110{
111 try {
112 // parse arguments
113 m_args.parser.readArgs(argc, argv);
114
115 // check whether application needs to be terminated due to --bash-completion argument
116 if (terminated) {
117 return statusCode;
118 }
119
120 m_args.parser.ensureDefaultOperation();
121 m_args.parser.checkConstraints();
122 m_argsRead = true;
123
124 } catch (const ParseError &failure) {
125 cerr << failure;
126 return 1;
127 }
128
129 // handle help argument
130 if (m_args.parser.helpArg().isPresent()) {
131 m_args.parser.printHelp(cout);
132 return 0;
133 }
134
135 // load configuration
136 if (const int res = loadConfig()) {
137 return res;
138 }
139
140 // finally do the request or establish connection
141 m_connection.setPollingFlags(SyncthingConnection::PollingFlags::MainEvents);
142 if (m_args.status.isPresent() || m_args.statusPwd.isPresent() || m_args.waitForIdle.isPresent()) {
143 // those arguments require establishing a connection first, the actual handler is called by handleStatusChanged() when
144 // the connection has been established
145 if (m_args.status.isPresent()) {
146 connect(&m_connection, &SyncthingConnection::newConfigApplied, [this] { findRelevantDirsAndDevs(OperationType::Status); });
147 }
148 m_connection.reconnect(m_settings);
149 cerr << Phrases::Info << "Connecting to " << m_settings.syncthingUrl.toLocal8Bit().data() << " ..." << TextAttribute::Reset << flush;
150 } else {
151 // call handler for any other arguments directly
152 applySettings();
153 m_args.parser.invokeCallbacks();
154 }
155
156 // enter main event loop
157 if (!m_requiresMainEventLoop) {
158 return 0;
159 }
160 return QCoreApplication::exec();
161}
162
163void Application::invalidateDirsAndDevs()
164{

Callers 15

initTestCaseMethod · 0.80
testFileModelMethod · 0.80
main.cppFile · 0.80
showViewMenuFunction · 0.80
mainFunction · 0.80
replaceProcessFunction · 0.80
tryToConnectMethod · 0.80
openBrowserInAppModeFunction · 0.80
browseRemoteFilesDialogFunction · 0.80
errorNotificationsDialogFunction · 0.80

Calls 4

readArgsMethod · 0.80
setPollingFlagsMethod · 0.80
reconnectMethod · 0.80
dataMethod · 0.45

Tested by 5

initTestCaseMethod · 0.64
testFileModelMethod · 0.64
mainFunction · 0.64