void ConferenceAuthOp::onPasswordProvided(QDBusPendingCallWatcher *watcher)
{
    QDBusPendingReply<bool> reply = *watcher;
    if (!reply.isValid() || reply.count() < 1) {
        return;
    }

    if (reply.argumentAt<0>()) {
        m_walletInterface->setEntry(m_account,m_channel->targetId(), m_password);
        setFinished();
    } else {
        qDebug() << "Password was incorrect, enter again";
        passwordDialog();
    }
}
Exemple #2
0
void PanelMenu::showMenu(int x, int y)
{
    if (m_menuManager && m_menuManager->isValid()){
        QDBusPendingReply<QDBusObjectPath> pr = m_menuManager->RegisterMenu();
        if (pr.count() == 1)
        {
            QDBusObjectPath op = pr.argumentAt(0).value<QDBusObjectPath>();
            m_menuInterfacePath = op.path();
            DBusMenu *m_menu = new DBusMenu(m_menuInterfacePath,this);
            connect(m_menu,&DBusMenu::MenuUnregistered,m_menu,&DBusMenu::deleteLater);
            connect(m_menu,&DBusMenu::ItemInvoked,this,&PanelMenu::onItemInvoked);

            QJsonObject targetObj;
            targetObj.insert("x",QJsonValue(x));
            targetObj.insert("y",QJsonValue(y));
            targetObj.insert("isDockMenu",QJsonValue(false));

            QJsonArray contentArry;
            contentArry.append(createRadioItemObj(tr("Fashion mode"),ToFashionMode,DockModeGroup,m_dockModeData->getDockMode() == Dock::FashionMode));
            contentArry.append(createRadioItemObj(tr("Efficient mode"),ToEfficientMode,DockModeGroup,m_dockModeData->getDockMode() == Dock::EfficientMode));
            contentArry.append(createRadioItemObj(tr("Classic mode"),ToClassicMode,DockModeGroup,m_dockModeData->getDockMode() == Dock::ClassicMode));
            contentArry.append(createItemObj("",OperationType(-1)));
            contentArry.append(createRadioItemObj(tr("Keep showing"),ToKeepShowing,HideModeGroup,m_dockModeData->getHideMode() == Dock::KeepShowing));
            contentArry.append(createRadioItemObj(tr("Keep hidden"),ToKeepHidden,HideModeGroup,m_dockModeData->getHideMode() == Dock::KeepHidden));
            contentArry.append(createRadioItemObj(tr("Smart hide"),ToSmartHide,HideModeGroup,m_dockModeData->getHideMode() == Dock::SmartHide));
            contentArry.append(createItemObj("",OperationType(-1)));
            contentArry.append(createItemObj(tr("Notification area settings"),ToPluginSetting));

            QJsonObject contentObj;
            contentObj.insert("items",contentArry);
            targetObj.insert("menuJsonContent",QString(QJsonDocument(contentObj).toJson()));

            m_menu->ShowMenu(QString(QJsonDocument(targetObj).toJson()));
        }
    }
}
    void SignonIdentity::verifyUiSlot(QDBusPendingCallWatcher *call)
    {
        TRACE();
        setAutoDestruct(true);

        QDBusMessage errReply;
        QDBusPendingReply<QVariantMap> reply;
        if (call != NULL) {
            reply = *call;
            call->deleteLater();
        }
        QVariantMap resultParameters;
        if (!reply.isError() && reply.count()) {
            resultParameters = reply.argumentAt<0>();
        } else {
            errReply = m_message.createErrorReply(SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_NAME,
                    SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_STR);
            SIGNOND_BUS.send(errReply);
            return;
        }

        if (!resultParameters.contains(SSOUI_KEY_ERROR)) {
            //no reply code
            errReply = m_message.createErrorReply(SIGNOND_INTERNAL_SERVER_ERR_NAME,
                    SIGNOND_INTERNAL_SERVER_ERR_STR);
            SIGNOND_BUS.send(errReply);
            return;
        }

        int errorCode = resultParameters.value(SSOUI_KEY_ERROR).toInt();
        TRACE() << "error: " << errorCode;
        if (errorCode != QUERY_ERROR_NONE) {
            if (errorCode == QUERY_ERROR_CANCELED)
                errReply = m_message.createErrorReply(SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_NAME,
                        SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_STR);
            else if (errorCode == QUERY_ERROR_FORGOT_PASSWORD)
                errReply = m_message.createErrorReply(SIGNOND_FORGOT_PASSWORD_ERR_NAME,
                        SIGNOND_FORGOT_PASSWORD_ERR_STR);
            else
                errReply = m_message.createErrorReply(SIGNOND_INTERNAL_SERVER_ERR_NAME,
                        QString(QLatin1String("signon-ui call returned error %1")).arg(errorCode));

            SIGNOND_BUS.send(errReply);
            return;
        }

        if (resultParameters.contains(SSOUI_KEY_PASSWORD)) {
            CredentialsDB *db = CredentialsAccessManager::instance()->credentialsDB();
            if (db == NULL) {
                BLAME() << "NULL database handler object.";
                errReply = m_message.createErrorReply(SIGNOND_STORE_FAILED_ERR_NAME,
                        SIGNOND_STORE_FAILED_ERR_STR);
                SIGNOND_BUS.send(errReply);
                return;
            }

            //compare passwords
            if (m_pInfo) {
                bool ret = m_pInfo->password() == resultParameters[SSOUI_KEY_PASSWORD].toString();

                if (!ret && resultParameters.contains(SSOUI_KEY_CONFIRMCOUNT)) {
                    int count = resultParameters[SSOUI_KEY_CONFIRMCOUNT].toInt();
                    TRACE() << "retry count:" << count;
                    if (count > 0) { //retry
                        resultParameters[SSOUI_KEY_CONFIRMCOUNT] = (count-1);
                        resultParameters[SSOUI_KEY_MESSAGEID] = QUERY_MESSAGE_NOT_AUTHORIZED;
                        queryUserPassword(resultParameters);
                        return;
                    } else {
                        //TODO show error note here if needed
                    }
                }
                delete m_pInfo;
                m_pInfo = NULL;
                QDBusMessage dbusreply = m_message.createReply();
                dbusreply << ret;
                SIGNOND_BUS.send(dbusreply);
                return;
            }
        }
        //this should not happen, return error
        errReply = m_message.createErrorReply(SIGNOND_INTERNAL_SERVER_ERR_NAME,
                SIGNOND_INTERNAL_SERVER_ERR_STR);
        SIGNOND_BUS.send(errReply);
        return;
    }
    void SignonIdentity::queryUiSlot(QDBusPendingCallWatcher *call)
    {
        TRACE();
        setAutoDestruct(true);

        QDBusMessage errReply;
        QDBusPendingReply<QVariantMap> reply;
        if (call != NULL) {
            reply = *call;
            call->deleteLater();
        }
        QVariantMap resultParameters;
        if (!reply.isError() && reply.count()) {
            resultParameters = reply.argumentAt<0>();
        } else {
            errReply = m_message.createErrorReply(SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_NAME,
                    SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_STR);
            SIGNOND_BUS.send(errReply);
            return;
        }

        if (!resultParameters.contains(SSOUI_KEY_ERROR)) {
            //no reply code
            errReply = m_message.createErrorReply(SIGNOND_INTERNAL_SERVER_ERR_NAME,
                    SIGNOND_INTERNAL_SERVER_ERR_STR);
            SIGNOND_BUS.send(errReply);
            return;
        }

        int errorCode = resultParameters.value(SSOUI_KEY_ERROR).toInt();
        TRACE() << "error: " << errorCode;
        if (errorCode != QUERY_ERROR_NONE) {
            if (errorCode == QUERY_ERROR_CANCELED)
                errReply = m_message.createErrorReply(SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_NAME,
                        SIGNOND_IDENTITY_OPERATION_CANCELED_ERR_STR);
            else
                errReply = m_message.createErrorReply(SIGNOND_INTERNAL_SERVER_ERR_NAME,
                        QString(QLatin1String("signon-ui call returned error %1")).arg(errorCode));

            SIGNOND_BUS.send(errReply);
            return;
        }

        if (resultParameters.contains(SSOUI_KEY_PASSWORD)) {
            CredentialsDB *db = CredentialsAccessManager::instance()->credentialsDB();
            if (db == NULL) {
                BLAME() << "NULL database handler object.";
                errReply = m_message.createErrorReply(SIGNOND_STORE_FAILED_ERR_NAME,
                        SIGNOND_STORE_FAILED_ERR_STR);
                SIGNOND_BUS.send(errReply);
                return;
            }

            //store new password
            if (m_pInfo) {
                m_pInfo->setPassword(resultParameters[SSOUI_KEY_PASSWORD].toString());

                quint32 ret = db->updateCredentials(*m_pInfo, true);
                delete m_pInfo;
                m_pInfo = NULL;
                if (ret != SIGNOND_NEW_IDENTITY) {
                    QDBusMessage dbusreply = m_message.createReply();
                    dbusreply << quint32(m_id);
                    SIGNOND_BUS.send(dbusreply);
                    return;
                } else{
                    BLAME() << "Error during update";
                }
            }
        }

        //this should not happen, return error
        errReply = m_message.createErrorReply(SIGNOND_INTERNAL_SERVER_ERR_NAME,
                SIGNOND_INTERNAL_SERVER_ERR_STR);
        SIGNOND_BUS.send(errReply);
        return;
    }