Exemplo n.º 1
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.º 2
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.º 3
0
QStringList Wallet::walletList()
{
    DCOPReply r = DCOPRef("kded", "kwalletd").call("wallets");
    QStringList rc;
    if(r.isValid())
    {
        r.get(rc);
    }
    return rc;
}
Exemplo n.º 4
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.º 5
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.º 6
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.º 7
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.º 8
0
bool Wallet::isEnabled()
{
    DCOPReply r = DCOPRef("kded", "kwalletd").call("isEnabled");
    bool rc = false;
    if(r.isValid())
    {
        r.get(rc);
    }
    return rc;
}
Exemplo n.º 9
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.º 10
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.º 11
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.º 12
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.º 13
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.º 14
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.º 15
0
int Wallet::lockWallet()
{
    if(_handle == -1)
    {
        return -1;
    }

    DCOPReply r = _dcopRef->call("close", _handle, true);
    _handle = -1;
    _folder = QString::null;
    _name = QString::null;
    if(r.isValid())
    {
        int drc = -1;
        r.get(drc);
        return drc;
    }
    return -1;
}
Exemplo n.º 16
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;
        }
Exemplo n.º 17
0
bool Wallet::createFolder(const QString &f)
{
    bool rc = true;

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

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

    return rc;
}
Exemplo n.º 18
0
bool Wallet::removeFolder(const QString &f)
{
    bool rc = false;

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

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

    if(_folder == f)
    {
        setFolder(QString::null);
    }

    return rc;
}
Exemplo n.º 19
0
Wallet *Wallet::openWallet(const QString &name, WId w, OpenType ot)
{
    if(ot == Asynchronous)
    {
        Wallet *wallet = new Wallet(-1, name);
        DCOPRef("kded", "kwalletd").send("openAsynchronous", name, wallet->objId(), uint(w));
        return wallet;
    }

    // avoid deadlock if the app has some popup open (#65978/#71048)
    while(QWidget *widget = qApp->activePopupWidget())
        widget->close();

    bool isPath = ot == Path;
    DCOPReply r;

    if(isPath)
    {
        r = DCOPRef("kded", "kwalletd").call("openPath", name, uint(w));
    }
    else
    {
        r = DCOPRef("kded", "kwalletd").call("open", name, uint(w));
    }

    if(r.isValid())
    {
        int drc = -1;
        r.get(drc);
        if(drc != -1)
        {
            return new Wallet(drc, name);
        }
    }

    return 0;
}
Exemplo n.º 20
0
int run(DCOPRef& ref) {
  DCOPClient *client = KApplication::dcopClient();

  // Disable completion for now.  We might want to add completion of JS
  // keywords and Kst objects at some point.
  rl_bind_key('\t', rl_insert);

  kstName = ref.app();

#ifndef SOLARIS
  signal(SIGALRM, &ping);
  itimerval tv = { { 1, 0 }, { 1, 0 } };
  itimerval old;
  setitimer(ITIMER_REAL, &tv, &old);
#endif

  for (;;) {
    if (!client->registeredApplications().contains(kstName)) {
      printf("%s", _T("Kst application process has terminated.\n"));
      return ERR_KST_TERMINATED;
    }

    char *l = 0L;
    const char *prompt = "kst> ";
    QString line;
    do {
      if (!line.isEmpty()) {
        // replace \ with \n
        line[line.length() - 1] = '\n';
      }

      l = readline(prompt);

      prompt = "";

      if (!l) {
        return 0;
      }
      line += QString(l);
      free(l);
      l = 0L;
    } while (line.endsWith("\\"));

    QString clean = line.stripWhiteSpace();

    if (clean == "exit") {
      return ERR_NONE;
    }

    if (clean == "session") {
      printf("%s\n", ref.app().data());
      continue;
    }

    if (clean == "help") {
      printf("%s", _T("Help:\n"));
      printf("%s", _T("session\t\t\t\tDisplay the name of the session in use\n"));
      printf("%s", _T("help\t\t\t\tDisplay help\n"));
      printf("%s", _T("exit\t\t\t\tExit the command-line interpreter\n"));
      continue;
    }

    if (clean.isEmpty()) {
      continue;
    }

    add_history(line.latin1());

    DCOPReply r = ref.call("evaluate", clean);
    if (r.isValid()) {
      QString res;
      r.get(res);
      if (!res.isEmpty()) {
        printf("%s\n", res.latin1());
      }
    }
  }
}