Exemplo n.º 1
0
static void continueInWindow(QString _wname)
{
    QCString wname = _wname.latin1();
    int id = -1;

    KStringList apps = kapp->dcopClient()->registeredApplications();
    for(KStringList::Iterator it = apps.begin(); it != apps.end(); ++it)
    {
        QCString &clientId = *it;

        if(qstrncmp(clientId, wname, wname.length()) != 0)
            continue;

        DCOPRef client(clientId.data(), wname + "-mainwindow#1");
        DCOPReply result = client.call("getWinID()");

        if(result.isValid())
        {
            id = (int)result;
            break;
        }
    }

    KWin::activateWindow(id);
}
Exemplo n.º 2
0
bool MediaImpl::statMedium(const QString &name, KIO::UDSEntry &entry)
{
    kdDebug(1219) << "MediaImpl::statMedium: " << name << endl;

    DCOPRef mediamanager("kded", "mediamanager");
    DCOPReply reply = mediamanager.call("properties", name);

    if(!reply.isValid())
    {
        m_lastErrorCode = KIO::ERR_SLAVE_DEFINED;
        m_lastErrorMessage = i18n("The KDE mediamanager is not running.");
        return false;
    }

    Medium m = Medium::create(reply);

    if(m.id().isEmpty())
    {
        entry.clear();
        return false;
    }

    createMediumEntry(entry, m);

    return true;
}
Exemplo n.º 3
0
bool GenericMonitor::retrieveKmixDevices()
{
	if(m_volumeDeviceIdx != -1 && m_muteDeviceIdx != -1)
		return true; // both indexes already set

	DCOPReply reply = kmixClient->call("masterDeviceIndex");
	if (!reply.isValid())
	{ // maybe the error occurred because kmix wasn't running
		_interface->displayText(i18n("Starting KMix..."));
		if (kapp->startServiceByDesktopName("kmix")==0) // trying to start kmix
		{
			reply = kmixClient->call("masterDeviceIndex");
			if (reply.isValid())
				kmixWindow->send("hide");
		}
	}
		
	if (!reply.isValid())
	{
		kdDebug() << "KMilo: GenericMonitor could not access kmix/Mixer0 via dcop" 
							<< endl;
		_interface->displayText(i18n("It seems that KMix is not running."));
		
		return false;
	} else {
		if (m_volumeDeviceIdx == -1)
			m_volumeDeviceIdx = reply;
		if (m_muteDeviceIdx == -1)
			m_muteDeviceIdx = m_volumeDeviceIdx; // this is the behaviour documented in README
		return true;
	}
}
Exemplo n.º 4
0
void KCookiesManagement::getDomains()
{
    DCOPReply reply = DCOPRef("kded", "kcookiejar").call("findDomains");

    if(!reply.isValid())
    {
        QString caption = i18n("Information Lookup Failure");
        QString message = i18n(
            "Unable to retrieve information about the "
            "cookies stored on your computer.");
        KMessageBox::sorry(this, message, caption);
        return;
    }

    QStringList domains = reply;

    if(dlg->lvCookies->childCount())
    {
        reset();
        dlg->lvCookies->setCurrentItem(0L);
    }

    CookieListViewItem *dom;
    for(QStringList::Iterator dIt = domains.begin(); dIt != domains.end(); dIt++)
    {
        dom = new CookieListViewItem(dlg->lvCookies, *dIt);
        dom->setExpandable(true);
    }

    // are ther any cookies?
    dlg->pbDeleteAll->setEnabled(dlg->lvCookies->childCount());
}
Exemplo n.º 5
0
Wallet::Wallet(int handle, const QString &name) : QObject(0L), DCOPObject(), d(0L), _name(name), _handle(handle)
{

    _dcopRef = new DCOPRef("kded", "kwalletd");

    _dcopRef->dcopClient()->setNotifications(true);
    connect(_dcopRef->dcopClient(), SIGNAL(applicationRemoved(const QCString &)), this, SLOT(slotAppUnregistered(const QCString &)));

    connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "walletClosed(int)", "slotWalletClosed(int)", false);
    connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "folderListUpdated(QString)", "slotFolderListUpdated(QString)", false);
    connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "folderUpdated(QString, QString)", "slotFolderUpdated(QString, QString)", false);
    connectDCOPSignal(_dcopRef->app(), _dcopRef->obj(), "applicationDisconnected(QString, QCString)",
                      "slotApplicationDisconnected(QString, QCString)", false);

    // Verify that the wallet is still open
    if(_handle != -1)
    {
        DCOPReply r = _dcopRef->call("isOpen", _handle);
        if(r.isValid())
        {
            bool rc = false;
            r.get(rc);
            if(!rc)
            {
                _handle = -1;
                _name = QString::null;
            }
        }
    }
}
Exemplo n.º 6
0
bool MediaImpl::listMedia(QValueList< KIO::UDSEntry > &list)
{
    kdDebug(1219) << "MediaImpl::listMedia" << endl;

    DCOPRef mediamanager("kded", "mediamanager");
    DCOPReply reply = mediamanager.call("fullList");

    if(!reply.isValid())
    {
        m_lastErrorCode = KIO::ERR_SLAVE_DEFINED;
        m_lastErrorMessage = i18n("The KDE mediamanager is not running.");
        return false;
    }

    Medium::List media = Medium::createList(reply);

    KIO::UDSEntry entry;

    Medium::List::iterator it = media.begin();
    Medium::List::iterator end = media.end();

    for(; it != end; ++it)
    {
        entry.clear();

        createMediumEntry(entry, *it);

        list.append(entry);
    }

    return true;
}
Exemplo n.º 7
0
void KCookiesManagement::getCookies(QListViewItem *cookieDom)
{
    CookieListViewItem *ckd = static_cast< CookieListViewItem * >(cookieDom);
    if(ckd->cookiesLoaded())
        return;

    QValueList< int > fields;
    fields << 0 << 1 << 2 << 3;

    DCOPReply reply = DCOPRef("kded", "kcookiejar")
                          .call("findCookies", DCOPArg(fields, "QValueList<int>"), ckd->domain(), QString::null, QString::null, QString::null);
    if(reply.isValid())
    {
        QStringList fieldVal = reply;
        QStringList::Iterator fIt = fieldVal.begin();

        while(fIt != fieldVal.end())
        {
            CookieProp *details = new CookieProp;
            details->domain = *fIt++;
            details->path = *fIt++;
            details->name = *fIt++;
            details->host = *fIt++;
            details->allLoaded = false;
            new CookieListViewItem(cookieDom, details);
        }

        static_cast< CookieListViewItem * >(cookieDom)->setCookiesLoaded();
    }
}
Exemplo n.º 8
0
Attr_list::Attr_list( QDomElement const& el, QWidget *w, QTag *dtdTag )
  : Attr(el, w, dtdTag)
{
   combo = (QComboBox *)w;

   QString source = el.attribute("source");
   if (source == "dcop") //fill the list with a result of a DCOP call
   {
     QString method = el.attribute("method");
     QString interface = el.attribute("interface", "QuantaIf");
     QString arguments = el.attribute("arguments");
     arguments.replace("%tagname%", m_dtdTag->name());
     DCOPReply reply = QuantaCommon::callDCOPMethod(interface, method, arguments);
     if (reply.isValid())
     {
        QStringList list = reply;
        combo->insertStringList(list);
     }
   }

   for ( QDomElement n = el.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {
      if ( n.tagName() == "items" ) {
         QDomElement item = n.firstChild().toElement();
         while ( !item.isNull() ) {
             combo->insertItem( item.text() );
             item = item.nextSibling().toElement();
         }
      }
   }

   setValue("");
}
Exemplo n.º 9
0
void KMail::KorgHelper::ensureRunning()
{
    QString error;
    QCString dcopService;
    int result = KDCOPServiceStarter::self()->findServiceFor( "DCOP/Organizer", QString::null, QString::null, &error, &dcopService );
    if ( result == 0 ) {
        // OK, so korganizer (or kontact) is running. Now ensure the object we want is available
        // [that's not the case when kontact was already running, but korganizer not loaded into it...]
        static const char* const dcopObjectId = "KOrganizerIface";
        QCString dummy;
        if ( !kapp->dcopClient()->findObject( dcopService, dcopObjectId, "", QByteArray(), dummy, dummy ) ) {
            DCOPRef ref( dcopService, dcopService ); // talk to the KUniqueApplication or its kontact wrapper
            DCOPReply reply = ref.call( "load()" );
            if ( reply.isValid() && (bool)reply ) {
                kdDebug() << "Loaded " << dcopService << " successfully" << endl;
                Q_ASSERT( kapp->dcopClient()->findObject( dcopService, dcopObjectId, "", QByteArray(), dummy, dummy ) );
            } else
                kdWarning() << "Error loading " << dcopService << endl;
        }

        // We don't do anything with it, we just need it to be running so that it handles
        // the incoming directory.
    }
    else
        kdWarning() << "Couldn't start DCOP/Organizer: " << dcopService << " " << error << endl;
}
Exemplo n.º 10
0
bool KCookiesManagement::cookieDetails(CookieProp *cookie)
{
    QValueList< int > fields;
    fields << 4 << 5 << 7;

    DCOPReply reply = DCOPRef("kded", "kcookiejar")
                          .call("findCookies", DCOPArg(fields, "QValueList<int>"), cookie->domain, cookie->host, cookie->path, cookie->name);
    if(!reply.isValid())
        return false;

    QStringList fieldVal = reply;

    QStringList::Iterator c = fieldVal.begin();
    cookie->value = *c++;
    unsigned tmp = (*c++).toUInt();

    if(tmp == 0)
        cookie->expireDate = i18n("End of session");
    else
    {
        QDateTime expDate;
        expDate.setTime_t(tmp);
        cookie->expireDate = KGlobal::locale()->formatDateTime(expDate);
    }

    tmp = (*c).toUInt();
    cookie->secure = i18n(tmp ? "Yes" : "No");
    cookie->allLoaded = true;
    return true;
}
Exemplo n.º 11
0
bool Wallet::isEnabled()
{
    DCOPReply r = DCOPRef("kded", "kwalletd").call("isEnabled");
    bool rc = false;
    if(r.isValid())
    {
        r.get(rc);
    }
    return rc;
}
Exemplo n.º 12
0
int Wallet::deleteWallet(const QString &name)
{
    DCOPReply r = DCOPRef("kded", "kwalletd").call("deleteWallet", name);
    int rc = -1;
    if(r.isValid())
    {
        r.get(rc);
    }
    return rc;
}
Exemplo n.º 13
0
bool Wallet::disconnectApplication(const QString &wallet, const QCString &app)
{
    DCOPReply r = DCOPRef("kded", "kwalletd").call("disconnectApplication", wallet, app);
    bool rc = false;
    if(r.isValid())
    {
        r.get(rc);
    }
    return rc;
}
Exemplo n.º 14
0
bool Wallet::isOpen(const QString &name)
{
    DCOPReply r = DCOPRef("kded", "kwalletd").call("isOpen", name);
    bool rc = false;
    if(r.isValid())
    {
        r.get(rc);
    }
    return rc;
}
Exemplo n.º 15
0
int Wallet::closeWallet(const QString &name, bool force)
{
    DCOPReply r = DCOPRef("kded", "kwalletd").call("close", name, force);
    int rc = -1;
    if(r.isValid())
    {
        r.get(rc);
    }
    return rc;
}
Exemplo n.º 16
0
QStringList Wallet::walletList()
{
    DCOPReply r = DCOPRef("kded", "kwalletd").call("wallets");
    QStringList rc;
    if(r.isValid())
    {
        r.get(rc);
    }
    return rc;
}
Exemplo n.º 17
0
QStringList Wallet::users(const QString &name)
{
    DCOPReply r = DCOPRef("kded", "kwalletd").call("users", name);
    QStringList drc;
    if(r.isValid())
    {
        r.get(drc);
    }
    return drc;
}
Exemplo n.º 18
0
bool PropertiesPage::save()
{
  TQStringList result;

  if (options.contains("ro"))
    result << TQString("ro=%1").arg(option_ro->isChecked() ? "true" : "false");

  if (options.contains("quiet"))
    result << TQString("quiet=%1").arg(option_quiet->isChecked() ? "true" : "false");

  if (options.contains("sync"))
    result << TQString("sync=%1").arg(option_sync->isChecked() ? "true" : "false");

  if (options.contains("atime"))
    result << TQString("atime=%1").arg(option_atime->isChecked() ? "true" : "false");

  if (options.contains("flush"))
    result << TQString("flush=%1").arg(option_flush->isChecked() ? "true" : "false");

  if (options.contains("utf8"))
    result << TQString("utf8=%1").arg(option_utf8->isChecked() ? "true" : "false");

  if (options.contains("uid"))
    result << TQString("uid=%1").arg(option_uid->isChecked() ? "true" : "false");

  if (options.contains("shortname"))
    result << TQString("shortname=%1").arg(short_names[option_shortname->currentItem()]);

  if (options.contains("journaling"))
    result << TQString("journaling=%1").arg(journales[option_journaling->currentItem()]);

  TQString mp = option_mountpoint->text();
  if (!mp.startsWith("/media/"))
    {
      KMessageBox::sorry(this, i18n("Mountpoint has to be below /media"));
      return false;
    }
  result << TQString("mountpoint=%1").arg(mp);
  result << TQString("automount=%1").arg(option_automount->isChecked() ? "true" : "false");
  result << TQString("use_defaults=%1").arg(option_defaults->isChecked() ? "true" : "false");

  kdDebug() << result << endl;

  DCOPRef mediamanager("kded", "mediamanager");
  DCOPReply reply = mediamanager.call( "setMountoptions", id, result);

  if (reply.isValid())
    return (bool)reply;
  else {
    KMessageBox::sorry(this,
		       i18n("Saving the changes failed"));

    return false;
  }
}
Exemplo n.º 19
0
const Medium KFileMediaPlugin::askMedium(KFileMetaInfo &info)
{
	DCOPRef mediamanager("kded", "mediamanager");
	kdDebug() << "properties " << info.url() << endl;
	DCOPReply reply = mediamanager.call( "properties", info.url().url() );

	if ( !reply.isValid() )
	{
		return Medium(QString::null, QString::null);
	}

	return Medium::create(reply);
}
Exemplo n.º 20
0
bool MediaImpl::ensureMediumMounted(Medium &medium)
{
    if(medium.id().isEmpty())
    {
        m_lastErrorCode = KIO::ERR_COULD_NOT_MOUNT;
        m_lastErrorMessage = i18n("No such medium.");
        return false;
    }

    if(medium.needMounting())
    {
        m_lastErrorCode = 0;

        mp_mounting = &medium;


        /*
        KIO::Job* job = KIO::mount(false, 0,
                                   medium.deviceNode(),
                                   medium.mountPoint());
        job->setAutoWarningHandlingEnabled(false);
        connect( job, SIGNAL( result( KIO::Job * ) ),
                 this, SLOT( slotMountResult( KIO::Job * ) ) );
        connect( job, SIGNAL( warning( KIO::Job *, const QString & ) ),
                 this, SLOT( slotWarning( KIO::Job *, const QString & ) ) );
        */
        kapp->dcopClient()->connectDCOPSignal("kded", "mediamanager", "mediumChanged(QString, bool)", "mediaimpl", "slotMediumChanged(QString)",
                                              false);

        DCOPRef mediamanager("kded", "mediamanager");
        DCOPReply reply = mediamanager.call("mount", medium.id());
        if(reply.isValid())
            reply.get(m_lastErrorMessage);
        else
            m_lastErrorMessage = i18n("Internal Error");
        if(!m_lastErrorMessage.isEmpty())
            m_lastErrorCode = KIO::ERR_SLAVE_DEFINED;
        else
        {
            qApp->eventLoop()->enterLoop();
        }

        mp_mounting = 0L;

        kapp->dcopClient()->disconnectDCOPSignal("kded", "mediamanager", "mediumChanged(QString, bool)", "mediaimpl", "slotMediumChanged(QString)");

        return m_lastErrorCode == 0;
    }

    return true;
}
Exemplo n.º 21
0
void NetworkStatus::onlineStatusChanged()
{
  DCOPRef dcopCall( "kded", "networkstatus" );
  DCOPReply reply = dcopCall.call( "onlineStatus()", true );
  if ( reply.isValid() ) {
    int status = reply;
    if ( status == 3 )
      setStatus( Online );
    else {
      if ( mStatus != Offline )
        setStatus( Offline );
    }
  }
}
Exemplo n.º 22
0
int Wallet::renameEntry(const QString &oldName, const QString &newName)
{
    int rc = -1;

    if(_handle == -1)
    {
        return rc;
    }

    DCOPReply r = _dcopRef->call("renameEntry", _handle, _folder, oldName, newName);
    if(r.isValid())
    {
        r.get(rc);
    }

    return rc;
}
Exemplo n.º 23
0
bool KonqSidebarTree::tabSupport()
{
    // see if the newTab() dcop function is available (i.e. the sidebar is embedded into konqueror)
   DCOPRef ref(kapp->dcopClient()->appId(), topLevelWidget()->name());
    DCOPReply reply = ref.call("functions()");
    if (reply.isValid()) {
        QCStringList funcs;
        reply.get(funcs, "QCStringList");
        for (QCStringList::ConstIterator it = funcs.begin(); it != funcs.end(); ++it) {
            if ((*it) == "void newTab(QString url)") {
                return true;
                break;
            }
        }
    }
    return false;
}
Exemplo n.º 24
0
bool Wallet::hasFolder(const QString &f)
{
    bool rc = false;

    if(_handle == -1)
    {
        return rc;
    }

    DCOPReply r = _dcopRef->call("hasFolder", _handle, f);
    if(r.isValid())
    {
        r.get(rc);
    }

    return rc;
}
Exemplo n.º 25
0
QStringList Wallet::entryList()
{
    QStringList rc;

    if(_handle == -1)
    {
        return rc;
    }

    DCOPReply r = _dcopRef->call("entryList", _handle, _folder);
    if(r.isValid())
    {
        r.get(rc);
    }

    return rc;
}
Exemplo n.º 26
0
bool GenericMonitor::retrieveMute() 
{
	bool kmix_error = false;

	if(!retrieveKmixDevices())
		return false;

	DCOPReply reply = kmixClient->call("mute", m_muteDeviceIdx);
	if (reply.isValid())
		m_mute = reply;
	else
		kmix_error = true;

	if (kmix_error)
	{
		// maybe the error occurred because kmix wasn't running
		_interface->displayText(i18n("Starting KMix..."));
		if (kapp->startServiceByDesktopName("kmix")==0) // trying to start kmix
		{
			// trying again
			reply = kmixClient->call("mute", m_muteDeviceIdx);
			if (reply.isValid()) 
			{
				m_mute = reply;
				kmix_error = false;
				kmixWindow->send("hide");
			}
		}	else 
		{
			kmixWindow->send("hide");
			kmix_error = true;
		}
	}

	if (kmix_error)
	{
		kdDebug() << "KMilo: GenericMonitor could not access kmix/Mixer0 via dcop" 
							<< endl;
		_interface->displayText(i18n("It seems that KMix is not running."));
		
		return false;
	} else {
		return true;
	}
}
Exemplo n.º 27
0
const Medium MediaImpl::findMediumByName(const QString &name, bool &ok)
{
    DCOPRef mediamanager("kded", "mediamanager");
    DCOPReply reply = mediamanager.call("properties", name);

    if(reply.isValid())
    {
        ok = true;
    }
    else
    {
        m_lastErrorCode = KIO::ERR_SLAVE_DEFINED;
        m_lastErrorMessage = i18n("The KDE mediamanager is not running.");
        ok = false;
    }

    return Medium::create(reply);
}
Exemplo n.º 28
0
int Wallet::readEntryList(const QString &key, QMap< QString, QByteArray > &value)
{
    int rc = -1;

    if(_handle == -1)
    {
        return rc;
    }

    DCOPReply r = _dcopRef->call("readEntryList", _handle, _folder, key);
    if(r.isValid())
    {
        r.get(value);
        rc = 0;
    }

    return rc;
}
Exemplo n.º 29
0
void Kopete::Away::slotTimerTimeout()
{
    // Time to check whether we're active or autoaway.  We basically have two
    // bits of info to go on - KDE's screensaver status
    // (KScreenSaverIface::isBlanked()) and the X11 activity detection.
    //
    // Note that isBlanked() is a slight of a misnomer.  It returns true if we're:
    //  - using a non-locking screensaver, which is running, or
    //  - using a locking screensaver which is still locked, regardless of
    //    whether the user is trying to unlock it right now
    // Either way, it's only worth checking for activity if the screensaver
    // isn't blanked/locked, because activity while blanked is impossible and
    // activity while locked never matters (if there is any, it's probably just
    // the cleaner wiping the keyboard :).


    /* we should be able to respond to KDesktop queries to avoid a deadlock, so we allow the event loop to be called */
    static bool rentrency_protection=false;
    if(rentrency_protection)
        return;
    rentrency_protection=true;
    DCOPRef screenSaver("kdesktop", "KScreensaverIface");
    DCOPReply isBlanked = screenSaver.callExt("isBlanked" ,  DCOPRef::UseEventLoop, 10);
    rentrency_protection=false;
    if(!instance) //this may have been deleted in the event loop
        return;
    if (!(isBlanked.isValid() && isBlanked.type == "bool" && ((bool)isBlanked)))
    {
        // DCOP failed, or returned something odd, or the screensaver is
        // inactive, so check for activity the X11 way.  It's only worth
        // checking for autoaway if there's no activity, and because
        // Screensaver blanking/locking implies autoAway activation (see
        // KopeteIface::KopeteIface()), only worth checking autoAway when the
        // screensaver isn't running.
        if (isActivity())
        {
            setActive();
        }
        else if (!d->autoaway && d->useAutoAway && idleTime() > d->awayTimeout)
        {
            setAutoAway();
        }
    }
}
Exemplo n.º 30
0
int Wallet::readMap(const QString &key, QMap< QString, QString > &value)
{
    int rc = -1;

    if(_handle == -1)
    {
        return rc;
    }

    DCOPReply r = _dcopRef->call("readMap", _handle, _folder, key);
    if(r.isValid())
    {
        QByteArray v;
        r.get(v);
        if(!v.isEmpty())
        {
            QDataStream ds(v, IO_ReadOnly);
            ds >> value;
        }