forked from cromer/pamac-classic
fix this annoying #54
This commit is contained in:
parent
e8c2ab079c
commit
a0f1bf3a88
@ -1099,21 +1099,17 @@ namespace Pamac {
|
|||||||
|
|
||||||
[DBus (no_reply = true)]
|
[DBus (no_reply = true)]
|
||||||
public void quit () {
|
public void quit () {
|
||||||
try {
|
|
||||||
new Thread<int>.try ("quit thread", () => {
|
|
||||||
databases_lock_mutex.lock ();
|
|
||||||
// be sure to not quit with locked databases
|
// be sure to not quit with locked databases
|
||||||
alpm_config.handle.trans_release ();
|
alpm_config.handle.trans_release ();
|
||||||
if (lockfile.query_exists () == false) {
|
if (lockfile.query_exists () == true) {
|
||||||
loop.quit ();
|
try {
|
||||||
}
|
lockfile.delete ();
|
||||||
databases_lock_mutex.unlock ();
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
} catch (GLib.Error e) {
|
} catch (GLib.Error e) {
|
||||||
stderr.printf ("%s\n", e.message);
|
GLib.stderr.printf("%s\n", e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
loop.quit ();
|
||||||
|
}
|
||||||
// End of Daemon Object
|
// End of Daemon Object
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Pamac {
|
namespace Pamac {
|
||||||
|
public struct ErrorInfos {
|
||||||
|
public string message;
|
||||||
|
public string[] details;
|
||||||
|
}
|
||||||
[DBus (name = "org.manjaro.pamac")]
|
[DBus (name = "org.manjaro.pamac")]
|
||||||
public interface Daemon : Object {
|
public interface Daemon : Object {
|
||||||
public abstract void start_refresh (int force) throws IOError;
|
public abstract void start_refresh (int force) throws IOError;
|
||||||
|
[DBus (no_reply = true)]
|
||||||
|
public abstract void quit () throws IOError;
|
||||||
|
public signal void refresh_finished (ErrorInfos error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pamac.Daemon pamac_daemon;
|
||||||
|
MainLoop loop;
|
||||||
|
|
||||||
bool check_pamac_running () {
|
bool check_pamac_running () {
|
||||||
Application app;
|
Application app;
|
||||||
bool run = false;
|
bool run = false;
|
||||||
@ -57,16 +67,27 @@ bool check_pamac_running () {
|
|||||||
return run;
|
return run;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (string[] args) {
|
void on_refresh_finished () {
|
||||||
Pamac.Daemon daemon;
|
try {
|
||||||
|
pamac_daemon.quit ();
|
||||||
|
} catch (IOError e) {
|
||||||
|
stderr.printf ("IOError: %s\n", e.message);
|
||||||
|
}
|
||||||
|
loop.quit ();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main () {
|
||||||
if (check_pamac_running () == false) {
|
if (check_pamac_running () == false) {
|
||||||
try {
|
try {
|
||||||
daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac",
|
pamac_daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac",
|
||||||
"/org/manjaro/pamac");
|
"/org/manjaro/pamac");
|
||||||
daemon.start_refresh (0);
|
pamac_daemon.refresh_finished.connect (on_refresh_finished);
|
||||||
|
pamac_daemon.start_refresh (0);
|
||||||
} catch (IOError e) {
|
} catch (IOError e) {
|
||||||
stderr.printf ("IOError: %s\n", e.message);
|
stderr.printf ("IOError: %s\n", e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
loop = new MainLoop ();
|
||||||
|
loop.run ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,8 @@ namespace Pamac {
|
|||||||
public interface Daemon : Object {
|
public interface Daemon : Object {
|
||||||
public abstract void start_refresh (int force) throws IOError;
|
public abstract void start_refresh (int force) throws IOError;
|
||||||
public abstract async Updates get_updates (bool enable_aur) throws IOError;
|
public abstract async Updates get_updates (bool enable_aur) throws IOError;
|
||||||
public abstract async void quit () throws IOError;
|
[DBus (no_reply = true)]
|
||||||
|
public abstract void quit () throws IOError;
|
||||||
public signal void refresh_finished (ErrorInfos error);
|
public signal void refresh_finished (ErrorInfos error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,16 +53,21 @@ namespace Pamac {
|
|||||||
try {
|
try {
|
||||||
daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac",
|
daemon = Bus.get_proxy_sync (BusType.SYSTEM, "org.manjaro.pamac",
|
||||||
"/org/manjaro/pamac");
|
"/org/manjaro/pamac");
|
||||||
|
// Connecting to signal
|
||||||
|
daemon.refresh_finished.connect (on_refresh_finished);
|
||||||
} catch (IOError e) {
|
} catch (IOError e) {
|
||||||
stderr.printf ("IOError: %s\n", e.message);
|
stderr.printf ("IOError: %s\n", e.message);
|
||||||
}
|
}
|
||||||
// Connecting to signal
|
|
||||||
daemon.refresh_finished.connect (on_refresh_finished);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void stop_daemon () {
|
void stop_daemon () {
|
||||||
if (check_pamac_running () == false && lockfile.query_exists () == false) {
|
if (check_pamac_running () == false) {
|
||||||
daemon.quit.begin ();
|
daemon.refresh_finished.disconnect (on_refresh_finished);
|
||||||
|
try {
|
||||||
|
daemon.quit ();
|
||||||
|
} catch (IOError e) {
|
||||||
|
stderr.printf ("IOError: %s\n", e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user