public void Start(string name, string oldValue, string newValue) { if (name != SERVICE_NAME || newValue == "") { return; } // find our remote iface = new QDBusInterface(SERVICE_NAME, "/", "com.trolltech.QtDBus.ComplexPong.Pong", QDBusConnection.SessionBus(), this); if (!iface.IsValid()) { Console.Error.WriteLine(QDBusConnection.SessionBus().LastError().Message()); QCoreApplication.Quit(); } Connect(iface, SIGNAL("aboutToQuit()"), QCoreApplication.Instance(), SLOT("quit()")); while (true) { Console.Write("Ask your question: "); string line = Console.ReadLine().Trim(); if (line == "") { iface.Call("quit"); return; } else if (line == "value") { QVariant reply = iface.Property("value"); if (!reply.IsNull()) { Console.WriteLine("value = {0}",reply.ToString()); } } else if (line.StartsWith("value=")) { iface.SetProperty("value",new QVariant(line.Substring(6))); } else { QDBusReply <string> reply = new QDBusReply <string>(iface.Call("query",new QVariant(line))); if (reply.IsValid()) { Console.WriteLine("Reply was: {0}",reply.Value()); } } if (iface.LastError().IsValid()) { Console.Error.WriteLine("Call failed: {0}",iface.LastError().Message()); } } }
public string ping(string arg) { QMetaObject.InvokeMethod(QCoreApplication.Instance(), "quit"); return("ping(\"" + arg + "\") got called"); }
public void quit() { QTimer.singleShot(0, QCoreApplication.Instance(), SLOT("quit()")); }