bool AppX11::shutdown() { _Debug("Try KDE session manger to shutdown."); QDBusInterface kde("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface", QDBusConnection::sessionBus()); auto response = kde.call("logout", 0, 2, 2); if (response.type() != QDBusMessage::ErrorMessage) return true; _Debug("KDE session manager does not work: [%%] %%", response.errorName(), response.errorMessage()); _Debug("Fallback to Gnome session manager."); QDBusInterface gnome("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager", QDBusConnection::sessionBus()); response = gnome.call("RequestShutdown"); if (response.type() != QDBusMessage::ErrorMessage) return true; _Debug("Gnome session manager does not work: [%%] %%", response.errorName(), response.errorMessage()); _Debug("Fallback to gnome-power-cmd.sh."); if (QProcess::startDetached("gnome-power-cmd.sh shutdown") || QProcess::startDetached("gnome-power-cmd shutdown")) return true; _Debug("gnome-power-cmd.sh does not work."); _Debug("Fallback to HAL."); QDBusInterface hal("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", QDBusConnection::systemBus()); response = hal.call("Shutdown"); if (response.type() != QDBusMessage::ErrorMessage) return true; _Debug("HAL does not work: [%%] %%", response.errorName(), response.errorMessage()); _Debug("Fallback to ConsoleKit."); QDBusInterface consoleKit("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", QDBusConnection::systemBus()); response = consoleKit.call("Stop"); if (response.type() != QDBusMessage::ErrorMessage) return true; _Debug("ConsoleKit does not work: [%%] %%", response.errorName(), response.errorMessage()); _Debug("Sorry, there's no way to shutdown."); return false; }
int main( int argc, char** argv ) { XML_IN; int length=0; double *data=NULL; const char * full_fname = "../../../matlab/data.txt"; file_read_into_array_doubles(full_fname, &data, &length); if (verbose==1 || verbose==-1) { print_vec(data,"data",0,length); } double maximum, minimum; double bw=-1; double* density=NULL; double* x=NULL; find_max_min_array_doubles(data,length,&maximum,&minimum); //kde(data,length,pow(2,14),minimum-5,maximum+5); kde(data,length,128,minimum-5,maximum+5, &density, &x, &bw); if(!density) free(density); free(data); XML_OUT; return 0; }
void Log::postNotification(MsgType mt, const QString &console, const QString &plain) { // Message notification with balloon tooltips QString qsIcon; switch (mt) { case DebugInfo: case CriticalError: qsIcon=QLatin1String("gtk-dialog-error"); break; case Warning: qsIcon=QLatin1String("gtk-dialog-warning"); break; case TextMessage: qsIcon=QLatin1String("gtk-edit"); break; default: qsIcon=QLatin1String("gtk-dialog-info"); break; } #ifdef USE_DBUS QDBusMessage response; QVariantMap hints; hints.insert(QLatin1String("desktop-entry"), QLatin1String("mumble")); { QDBusInterface kde(QLatin1String("org.kde.VisualNotifications"), QLatin1String("/VisualNotifications"), QLatin1String("org.kde.VisualNotifications")); if (kde.isValid()) { QList<QVariant> args; args.append(QLatin1String("mumble")); args.append(uiLastId); args.append(QString()); args.append(QLatin1String("mumble")); args.append(msgName(mt)); args.append(console); args.append(QStringList()); args.append(hints); args.append(5000); response = kde.callWithArgumentList(QDBus::AutoDetect, QLatin1String("Notify"), args); } } if (response.type()!=QDBusMessage::ReplyMessage || response.arguments().at(0).toUInt()==0) { QDBusInterface gnome(QLatin1String("org.freedesktop.Notifications"), QLatin1String("/org/freedesktop/Notifications"), QLatin1String("org.freedesktop.Notifications")); if (gnome.isValid()) response = gnome.call(QLatin1String("Notify"), QLatin1String("Mumble"), uiLastId, qsIcon, msgName(mt), console, QStringList(), hints, -1); } if (response.type()==QDBusMessage::ReplyMessage && response.arguments().count() == 1) { uiLastId = response.arguments().at(0).toUInt(); } else { #else Q_UNUSED(console); if (true) { #endif postQtNotification(mt, plain); } }
static bool DBusReboot(void) { #if CONFIG_QTDBUS QDBusInterface kde("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface"); QDBusInterface gnome("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager"); QDBusInterface consolekit("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", QDBusConnection::systemBus()); QDBusInterface hal("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", QDBusConnection::systemBus()); QDBusReply<void> void_reply = kde.call("logout", 0, 1, 2); QDBusReply<bool> bool_reply; QDBusReply<int> int_reply; if (!void_reply.isValid()) { bool_reply = gnome.call("CanShutdown"); if (bool_reply.isValid() && bool_reply.value() == 1) void_reply=gnome.call("RequestReboot"); } if (!void_reply.isValid()) { bool_reply = consolekit.call("CanRestart"); if (bool_reply.isValid() && bool_reply.value() == 1) void_reply = consolekit.call("Restart"); } if (!void_reply.isValid()) int_reply = hal.call("Reboot"); return void_reply.isValid() || int_reply.isValid(); #endif return false; }
void bones_get_threshold(double* data, int length, double* ths) { XML_IN; int verbose=1; double maximum, minimum; double bw=-1; double *density=NULL; double *x=NULL; int n=128; kde(data,length,n,-1,-1, &density, &x, &bw); //compute maxima double delta=1e-3; int l_min,l_max; double* min_x; double* max_x; peakdet( n, x, density, delta, &l_min,&min_x,&l_max,&max_x); if (verbose==1 || verbose==-1) { print_vec(x,"x",0,n); print_vec(density,"density",0,n); print_vec(data,"data",0,length); print_vec(min_x,"min_x",0,l_min); print_vec(max_x,"max_x",0,l_max); } ths[0]=0; ths[1]=min_x[1]; printf("lo: %g hi: %g\n",ths[0],ths[1]); if(!density) free(density); if(!x) free(x); XML_OUT; }