Message::Message(char *n, struct netField *netf, bool srv) : message(netf), isServer(srv), hasSub(false) { std::string msgName(n); struct netField *nf = message; while( nf->type != MP_END && hasSub == false) { switch(nf->type) { case MP_MSGID: msgid= nf->param; break; case MP_ARRAYFIXED: case MP_ARRAY_VAR_SMALL: case MP_ARRAY_VAR_LARGE: case MP_OPTIONAL: hasSub= true; break; default: break; } nf++; } size_t pos= msgName.rfind(".cpp"); if (pos != std::string::npos) msgName.erase(pos); name= msgName; }
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); } }