Ejemplo n.º 1
0
QString Logger::path()
{
    QDir dir;
    QString path = KStandardDirs::locateLocal("data", "lancelot", true);
    if (!path.endsWith('/')) {
        path += '/';
    }
    path += "log/";

    if (!dir.exists(path)) {
        if (!dir.mkpath(path)) {
            return QString();
        }

        KNotification * notify = new KNotification("UsageLoggingOn");
        notify->setText(i18n("Usage logging is activated."));
        notify->setPixmap(KIcon("view-history").pixmap(KIconLoader::SizeMedium, KIconLoader::SizeMedium));
        notify->setActions(QStringList(i18n("Configure")));

        QObject::connect(notify, SIGNAL(activated(uint)), Logger::self(), SLOT(configureMenu()));

        notify->sendEvent();
    }

    QDate date = QDate::currentDate();
    path += "log-" + QString::number(date.year())
            + '-' + QString::number(date.month());

    return path;
}
Ejemplo n.º 2
0
void DistroUpgrade::distroUpgrade(PackageKit::Transaction::DistroUpgrade type, const QString &name, const QString &description)
{
    // TODO make use of the type
    switch (m_configs[CFG_DISTRO_UPGRADE].toInt()) {
    case Enum::DistroNever:
        return;
    case Enum::DistroStable:
        if (type != Transaction::DistroUpgradeStable) {
            // The user only wants to know about stable releases
            return;
        }
    default:
        break;
    }

    kDebug() << "Distro upgrade found!" << name << description;
    if (m_shownDistroUpgrades.contains(name)) {
        // ignore distro upgrade if the user already saw it
        return;
    }

    KNotification *notify = new KNotification("DistroUpgradeAvailable", 0, KNotification::Persistent);
    notify->setComponentName("apperd");
    notify->setTitle(i18n("Distribution upgrade available"));
    notify->setText(description);

    QStringList actions;
    actions << i18n("Start upgrade now");
    notify->setActions(actions);
    connect(notify, SIGNAL(activated(uint)),
            this, SLOT(handleDistroUpgradeAction(uint)));
    notify->sendEvent();
    m_shownDistroUpgrades << name;
}
Ejemplo n.º 3
0
void OpenCalaisTextMatchPlugin::doGetPossibleMatches( const QString& text )
{
    kDebug();
    // cancel previous jobs
    delete m_lookupJob;
    m_lookupJob = 0;

    if ( OpenCalais::Config::licenseKey().isEmpty() ) {
        kDebug() << "no key";
        if ( OpenCalais::Config::showKeyWarning() ) {
            KNotification* n = KNotification::event( KNotification::Warning,
                               i18n( "No OpenCalais API key configured." ) );
            n->setActions( QStringList() << i18n( "Configure..." ) );
            connect( n, SIGNAL( action1Activated() ), this, SLOT( slotConfigure() ) );
            OpenCalais::Config::self()->findItem( "ShowKeyWarning" )->setProperty( false );
            OpenCalais::Config::self()->writeConfig();
        }
        emitFinished();
    }
    else {
        // do the lookup
        m_lookupJob = new OpenCalais::LookupJob( this );
        connect( m_lookupJob, SIGNAL( result( KJob* ) ),
                 this, SLOT( slotResult( KJob* ) ) );
        m_lookupJob->setContent( text );
        m_lookupJob->start();
    }
}
Ejemplo n.º 4
0
void KNotificationBackend::notify(const Notification &n)
{
    QString type;
    switch (n.type) {
    case Highlight:
        type = "Highlight"; break;
    case HighlightFocused:
        type = "HighlightFocused"; break;
    case PrivMsg:
        type = "PrivMsg"; break;
    case PrivMsgFocused:
        type = "PrivMsgFocused"; break;
    }

#if QT_VERSION < 0x050000
    QString message = QString("<b>&lt;%1&gt;</b> %2").arg(n.sender, Qt::escape(n.message));
#else
    QString message = QString("<b>&lt;%1&gt;</b> %2").arg(n.sender, n.message.toHtmlEscaped());
#endif
    KNotification *notification = KNotification::event(type, message, QIcon::fromTheme("dialog-information").pixmap(48), QtUi::mainWindow(),
        KNotification::RaiseWidgetOnActivation
        |KNotification::CloseWhenWidgetActivated
        |KNotification::CloseOnTimeout);
    connect(notification, SIGNAL(activated(uint)), SLOT(notificationActivated()));
    notification->setActions(QStringList("View"));
    notification->setProperty("notificationId", n.notificationId);

    _notifications.append(qMakePair(n.notificationId, QPointer<KNotification>(notification)));

    updateToolTip();
    QtUi::mainWindow()->systemTray()->setAlert(true);
}
Ejemplo n.º 5
0
void notifier_t::notify_reboot() {
  KNotification* note = new KNotification("requestreboot",0L, KNotification::Persistent);
  note->setTitle(i18n("Please reboot your system."));
  note->setText(i18n("In order to complete this upgrade, you need to reboot your system."));
  note->setPixmap(KIcon("system-reboot").pixmap(QSize(32,32)));
  note->setComponentData(m_component_data);
  note->setActions(QStringList()
    << i18nc("Do the proposed action (upgrade, reboot, etc) later", "Later")
    << i18nc("Reboot the system", "Reboot"));
  connect(note,SIGNAL(closed()),m_reboot_nagger,SLOT(start()));
  connect(note,SIGNAL(action1Activated()),m_reboot_nagger,SLOT(start()));
  connect(note,SIGNAL(action2Activated()),SLOT(reboot()));
  note->sendEvent();
}
Ejemplo n.º 6
0
void EmoticonSetInstaller::showResult()
{
    kDebug();

    KNotification *notification = new KNotification(QLatin1String("emoticonsSuccess"), NULL, KNotification::Persistent);
    notification->setText( i18n("Installed Emoticonset %1 successfully.", this->bundleName()) );

    notification->setActions( QStringList() << i18n("OK") );
    QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close()));
    QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close()));

    notification->sendEvent();

    Q_EMIT showedResult();
}
Ejemplo n.º 7
0
void KMixToolBox::notification(const char *notificationName, const QString &text,
                                const QStringList &actions, QObject *receiver,
                                const char *actionSlot)
{
    KNotification *notification = new KNotification(notificationName);
    //notification->setComponentData(componentData());
    notification->setText(text);
    //notification->setPixmap(...);
    notification->addContext(QLatin1String("Application"), KGlobal::mainComponent().componentName());
    if (!actions.isEmpty() && receiver && actionSlot) {
        notification->setActions(actions);
        QObject::connect(notification, SIGNAL(activated(uint)), receiver, actionSlot);
    }
    notification->sendEvent();
}
Ejemplo n.º 8
0
void notifier_t::show_update_notification(const QString& title, const QString& message, const QString& iconname) {
  if(m_upgrade_notification) {
    m_upgrade_notification.data()->close();
  }
  KNotification* note = new KNotification("updatesavailable",0L, KNotification::Persistent);
  note->setTitle(title);
  note->setText(message);
  note->setPixmap(KIcon(iconname).pixmap(QSize(32,32)));
  note->setComponentData(m_component_data);
  note->setActions(QStringList()
    << i18nc("Do the proposed action (upgrade, reboot, etc) later", "Later"));
  note->sendEvent();
  m_upgrade_notification=note;
  return;
}
Ejemplo n.º 9
0
void EmoticonSetInstaller::showRequest()
{
    kDebug();

    KNotification *notification = new KNotification(QLatin1String("emoticonsRequest"), NULL, KNotification::Persistent);
    notification->setText( i18n("Install Emoticonset %1", this->bundleName()) );
    notification->setActions( QStringList() << i18n("Install") << i18n("Cancel") );

    QObject::connect(notification, SIGNAL(action1Activated()), this, SLOT(install()));
    QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close()));

    QObject::connect(notification, SIGNAL(ignored()), this, SLOT(ignoreRequest()));
    QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close()));

    QObject::connect(notification, SIGNAL(action2Activated()), this, SLOT(ignoreRequest()));
    QObject::connect(notification, SIGNAL(action2Activated()), notification, SLOT(close()));

    notification->sendEvent();
}
Ejemplo n.º 10
0
void KNotificationBackend::notify(const Notification& n)
{
    QString type;
    switch (n.type) {
    case Highlight:
        type = "Highlight";
        break;
    case HighlightFocused:
        type = "HighlightFocused";
        break;
    case PrivMsg:
        type = "PrivMsg";
        break;
    case PrivMsgFocused:
        type = "PrivMsgFocused";
        break;
    }

    QString message = QString("<b>&lt;%1&gt;</b> %2").arg(n.sender, n.message.toHtmlEscaped());
    KNotification* notification = KNotification::event(type,
                                                       message,
                                                       icon::get("dialog-information").pixmap(48),
                                                       QtUi::mainWindow(),
                                                       KNotification::RaiseWidgetOnActivation | KNotification::CloseWhenWidgetActivated
                                                           | KNotification::CloseOnTimeout);
    connect(notification,
            selectOverload<uint>(&KNotification::activated),
            this,
            selectOverload<>(&KNotificationBackend::notificationActivated));
    notification->setActions(QStringList("View"));
    notification->setProperty("notificationId", n.notificationId);

    _notifications.append(qMakePair(n.notificationId, QPointer<KNotification>(notification)));

    updateToolTip();
}
Ejemplo n.º 11
0
void AdiumxtraProtocolHandler::install()
{
    if (m_url.isEmpty()) {
        Q_EMIT finished();
        return; // BundleInstaller:: xxxxx
    }

    QUrl url = QUrl::fromUserInput(m_url);
    if(url.scheme() == QLatin1String("adiumxtra")) {
        url.setScheme(QStringLiteral("http"));
    }

    QTemporaryFile *tmpFile = new QTemporaryFile();
    if (tmpFile->open()) {
        KIO::Job* getJob = KIO::file_copy(url, QUrl::fromLocalFile(tmpFile->fileName()), -1,
                                          KIO::Overwrite | KIO::HideProgressInfo);
        if (getJob->exec()) {
            qWarning() << "Download failed";
            Q_EMIT finished();
            return; // BundleInstaller::BundleCannotOpen;
        }
        getJob->deleteLater();
    }

    KArchive *archive = 0L;

    QMimeDatabase db;

    QString currentBundleMimeType =  db.mimeTypeForFile(tmpFile->fileName()).name();
    if (currentBundleMimeType == QLatin1String("application/zip")) {
        archive = new KZip(tmpFile->fileName());
    } else if (currentBundleMimeType == QLatin1String("application/x-compressed-tar") ||
               currentBundleMimeType == QLatin1String("application/x-bzip-compressed-tar") ||
               currentBundleMimeType == QLatin1String("application/x-gzip") ||
               currentBundleMimeType == QLatin1String("application/x-bzip")) {
        archive = new KTar(tmpFile->fileName());
    } else {
        KNotification *notification = new KNotification(QLatin1String("packagenotrecognized"), NULL, KNotification::Persistent);
        notification->setText( i18n("Package type not recognized or not supported") );
        notification->setActions( QStringList() << i18n("OK") );
        QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close()));
        QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close()));
        notification->setComponentName(ktelepathyComponentName());
        notification->sendEvent();
        qWarning() << "Unsupported file type" << currentBundleMimeType;
        Q_EMIT finished();
        return;// BundleInstaller::BundleNotValid;
    }

    if (!archive->open(QIODevice::ReadOnly)) {
        delete archive;
        qWarning() << "Cannot open theme file";
        Q_EMIT finished();
        return;// BundleInstaller::BundleCannotOpen;
    }

    ChatStyleInstaller *chatStyleInstaller = new ChatStyleInstaller(archive, tmpFile);
    if (chatStyleInstaller->validate() == BundleInstaller::BundleValid) {
        chatStyleInstaller->showRequest();

        QObject::connect(chatStyleInstaller, SIGNAL(finished(BundleInstaller::BundleStatus)),
                         chatStyleInstaller, SLOT(showResult()));
        QObject::connect(chatStyleInstaller, SIGNAL(showedResult()), this, SIGNAL(finished()));
        QObject::connect(chatStyleInstaller, SIGNAL(showedResult()),
                         chatStyleInstaller, SLOT(deleteLater()));
        QObject::connect(chatStyleInstaller, SIGNAL(ignoredRequest()), this, SIGNAL(finished()));
        QObject::connect(chatStyleInstaller, SIGNAL(ignoredRequest()),
                         chatStyleInstaller, SLOT(deleteLater()));

        return;// BundleInstaller::BundleValid;
    }
    delete chatStyleInstaller;

    EmoticonSetInstaller *emoticonSetInstaller = new EmoticonSetInstaller(archive, tmpFile);
    if(emoticonSetInstaller->validate() == BundleInstaller::BundleValid) {
        emoticonSetInstaller->showRequest();

        QObject::connect(emoticonSetInstaller, SIGNAL(finished(BundleInstaller::BundleStatus)),
                         emoticonSetInstaller, SLOT(showResult()));
        QObject::connect(emoticonSetInstaller, SIGNAL(showedResult()), this, SIGNAL(finished()));
        QObject::connect(emoticonSetInstaller, SIGNAL(showedResult()),
                         emoticonSetInstaller, SLOT(deleteLater()));
        QObject::connect(emoticonSetInstaller, SIGNAL(ignoredRequest()), this, SIGNAL(finished()));
        QObject::connect(emoticonSetInstaller, SIGNAL(ignoredRequest()),
                         emoticonSetInstaller, SLOT(deleteLater()));

        return;// BundleInstaller::BundleValid;
    }
    delete emoticonSetInstaller;

    KNotification *notification = new KNotification(QLatin1String("packagenotrecognized"),
                                                    NULL,
                                                    KNotification::Persistent);
    notification->setText( i18n("Package type not recognized or not supported") );
    QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close()));
    QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close()));
    notification->setActions( QStringList() << i18n("OK") );
    notification->setComponentName(ktelepathyComponentName());
    notification->sendEvent();

    Q_EMIT finished();
    return;// BundleInstaller::BundleUnknownError;
}