Exemplo n.º 1
0
bool KMCupsJobManager::listJobs(const QString& prname, KMJobManager::JobType type, int limit)
{
	IppRequest	req;
	QStringList	keys;
	CupsInfos	*infos = CupsInfos::self();

	// wanted attributes
	keys.append("job-id");
	keys.append("job-uri");
	keys.append("job-name");
	keys.append("job-state");
	keys.append("job-printer-uri");
	keys.append("job-k-octets");
	keys.append("job-originating-user-name");
	keys.append("job-k-octets-completed");
	keys.append("job-media-sheets");
	keys.append("job-media-sheets-completed");
	keys.append("job-priority");
	keys.append("job-billing");

	req.setOperation(IPP_GET_JOBS);

	// add printer-uri
	KMPrinter *mp = KMManager::self()->findPrinter(prname);
	if (!mp)
		return false;

	if (!mp->uri().isEmpty())
	{
		req.addURI(IPP_TAG_OPERATION, "printer-uri", mp->uri().prettyURL());
		/*
		req.setHost(mp->uri().host());
		req.setPort(mp->uri().port());
		*/
	}
	else
		req.addURI(IPP_TAG_OPERATION, "printer-uri", QString("ipp://%1/%2/%3").arg(infos->hostaddr(),
                            (mp&&mp->isClass())?"classes":"printers", prname));

	// other attributes
	req.addKeyword(IPP_TAG_OPERATION, "requested-attributes", keys);
	if (type == KMJobManager::CompletedJobs)
		req.addKeyword(IPP_TAG_OPERATION,"which-jobs",QString::fromLatin1("completed"));
	if (limit > 0)
		req.addInteger(IPP_TAG_OPERATION,"limit",limit);

	// send request
	if (req.doRequest("/"))
		parseListAnswer(req, mp);
	else
		return false;

	return true;
}
Exemplo n.º 2
0
void KMMainView::slotPrinterSelected(const QString &prname)
{
    KMPrinter *p = KMManager::self()->findPrinter(prname);
    m_current = p;
    if(p && !p->isSpecial())
        KMFactory::self()->manager()->completePrinter(p);
    m_printerpages->setPrinter(p);

    // update actions state (only if toolbar enabled, workaround for toolbar
    // problem).
    // if (m_toolbar->isEnabled())
    //{
    int mask = (m_manager->hasManagement() ? m_manager->printerOperationMask() : 0);
    bool sp = !(p && p->isSpecial());
    m_actions->action("printer_remove")->setEnabled(!sp || ((mask & KMManager::PrinterRemoval) && p && p->isLocal() && !p->isImplicit()));
    m_actions->action("printer_configure")->setEnabled(!sp || ((mask & KMManager::PrinterConfigure) && p && !p->isClass(true) /*&& p->isLocal()*/));
    m_actions->action("printer_hard_default")
        ->setEnabled((sp && (mask & KMManager::PrinterDefault) && p && !p->isClass(true) && !p->isHardDefault() && p->isLocal()));
    m_actions->action("printer_soft_default")->setEnabled((p && !p->isSoftDefault()));
    m_actions->action("printer_test")->setEnabled((sp && (mask & KMManager::PrinterTesting) && p && !p->isClass(true)));
    bool stmask = (sp && (mask & KMManager::PrinterEnabling) && p);
    m_actions->action("printer_state_change")->setEnabled(stmask && p->isLocal());
    m_actions->action("printer_spool_change")->setEnabled(stmask);
    m_actions->action("printer_start")->setEnabled((stmask && p->state() == KMPrinter::Stopped));
    m_actions->action("printer_stop")->setEnabled((stmask && p->state() != KMPrinter::Stopped));
    m_actions->action("printer_enable")->setEnabled((stmask && !p->acceptJobs()));
    m_actions->action("printer_disable")->setEnabled((stmask && p->acceptJobs()));

    m_actions->action("printer_add")->setEnabled((mask & KMManager::PrinterCreation));
    mask = m_manager->serverOperationMask();
    m_actions->action("server_restart")->setEnabled((mask & KMManager::ServerRestarting));
    m_actions->action("server_configure")->setEnabled((mask & KMManager::ServerConfigure));

    KMFactory::self()->manager()->validatePluginActions(m_actions, p);
    //}
    m_actions->action("printer_tool")->setEnabled(p && !p->isClass(true) && !p->isRemote() && !p->isSpecial());
}
Exemplo n.º 3
0
void KMMainView::slotRightButtonClicked(const QString &prname, const QPoint &p)
{
    KMPrinter *printer = KMManager::self()->findPrinter(prname);
    // construct popup menu
    m_pop->clear();
    if(printer)
    {
        m_current = printer;
        if(!printer->isSpecial())
        {
            if(printer->isLocal())
                m_actions->action((printer->state() == KMPrinter::Stopped ? "printer_start" : "printer_stop"))->plug(m_pop);
            m_actions->action((printer->acceptJobs() ? "printer_disable" : "printer_enable"))->plug(m_pop);
            m_pop->insertSeparator();
        }
        if(!printer->isSoftDefault())
            m_actions->action("printer_soft_default")->plug(m_pop);
        if(printer->isLocal() && !printer->isImplicit())
        {
            if(!printer->isHardDefault())
                m_actions->action("printer_hard_default")->plug(m_pop);
            m_actions->action("printer_remove")->plug(m_pop);
            m_pop->insertSeparator();
            if(!printer->isClass(true))
            {
                m_actions->action("printer_configure")->plug(m_pop);
                m_actions->action("printer_test")->plug(m_pop);
                m_actions->action("printer_tool")->plug(m_pop);
                m_pop->insertSeparator();
            }
        }
        else
        {
            if(!printer->isClass(true))
            {
                m_actions->action("printer_configure")->plug(m_pop);
                m_actions->action("printer_test")->plug(m_pop);
            }
            m_pop->insertSeparator();
        }
        if(!printer->isSpecial())
        {
            QValueList< KAction * > pactions = m_actions->actions("plugin");
            for(QValueList< KAction * >::Iterator it = pactions.begin(); it != pactions.end(); ++it)
                (*it)->plug(m_pop);
            if(pactions.count() > 0)
                m_pop->insertSeparator();
        }
    }
    else
    {
        m_actions->action("printer_add")->plug(m_pop);
        m_actions->action("printer_add_special")->plug(m_pop);
        m_pop->insertSeparator();
        m_actions->action("server_restart")->plug(m_pop);
        m_actions->action("server_configure")->plug(m_pop);
        m_pop->insertSeparator();
        m_actions->action("manager_configure")->plug(m_pop);
        m_actions->action("view_refresh")->plug(m_pop);
        m_pop->insertSeparator();
    }
    m_actions->action("view_printerinfos")->plug(m_pop);
    m_actions->action("view_change")->plug(m_pop);
    m_actions->action("orientation_change")->plug(m_pop);
    m_actions->action("view_toolbar")->plug(m_pop);
    m_actions->action("view_menubar")->plug(m_pop);
    m_pop->insertSeparator();
    m_actions->action("view_pfilter")->plug(m_pop);

    // pop the menu
    m_pop->popup(p);
}