2 * Copyright (c) 2020 Collabora Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <json-c/json.h>
23 Launcher::setup_pws_connection(void)
25 pws = pws_data_source_init(afm_sock_name.toStdString().c_str());
29 connection_set = true;
34 Launcher::connection_is_set(void)
36 return connection_set;
40 Launcher::start(const QString &app)
47 rid = pws_start_process(pws, app.toStdString().c_str());
49 applications.insert(app, rid);
55 Launcher::terminate(const QString &app)
60 if (pws_stop_process(pws, app.toStdString().c_str()))
67 Launcher::is_running(const QString &app)
74 rid = pws_check_process_is_running(pws, app.toStdString().c_str());
75 /* remove it from QHash if it was there and current no longer shows up */
79 if (applications.contains(app))
80 applications.remove(app);
87 Launcher::get_list_runnables(QString *qstr)
90 struct json_object *json;
95 items = pws_get_list_runnables(pws, &json);
97 *qstr = QString(json_object_to_json_string(json));
101 /* necessary as pws_get_list_runnables won't free() the json reply on
103 pws_data_source_reply_destroy(pws);