示例#1
0
bool CWizDatabase::setUserGroupInfo(const CWizGroupDataArray& arrayGroup)
{
    if (!deleteMetasByName(g_strGroupSection))
        return false;

    int nTotal = arrayGroup.size();
    if (!nTotal) {
        return false;
    }

    if (!SetMeta(g_strGroupSection, "Count", QString::number(nTotal))) {
        return false;
    }

    int nErrors = 0;
    for (int i = 0; i < nTotal; i++) {
        WIZGROUPDATA group(arrayGroup[i]);
        if (!SetMeta(g_strGroupSection, QString::number(i), group.strGroupGUID)) {
            nErrors++;
        }

        if (!SetMeta(g_strGroupSection, group.strGroupGUID, group.strGroupName)) {
            nErrors++;
        }
    }

    if (nErrors > 0) {
        return false;
    }

    return true;
}
示例#2
0
bool CWizDatabase::SetUserCert(const QString& strN, const QString& stre, const QString& strd, const QString& strHint)
{
    return SetMeta(g_strCertSection, "N", strN) \
           && SetMeta(g_strCertSection, "E", stre) \
           && SetMeta(g_strCertSection, "D", strd) \
           && SetMeta(g_strCertSection, "Hint", strHint);
}
示例#3
0
 int Ardb::Incrby(const DBID& db, const Slice& key, int64_t increment, int64_t& value)
 {
     CommonMetaValue* meta = GetMeta(db, key, false);
     StringMetaValue* smeta = NULL;
     if (NULL != meta)
     {
         if (meta->header.type != STRING_META)
         {
             DELETE(meta);
             return ERR_INVALID_TYPE;
         }
         smeta = (StringMetaValue*) meta;
         smeta->value.ToNumber();
         if (smeta->value.type == BYTES_VALUE)
         {
             DELETE(smeta);
             return ERR_INVALID_TYPE;
         }
         smeta->value.Incrby(increment);
         value = smeta->value.integer_value;
         SetMeta(db, key, *smeta);
         DELETE(smeta);
     }
     else
     {
         StringMetaValue nsmeta;
         nsmeta.value.SetIntValue(increment);
         KeyObject k(key, KEY_META, db);
         SetMeta(k, nsmeta);
         value = increment;
     }
     return 0;
 }
示例#4
0
bool CWizDatabase::setDatabaseInfo(const QString& strKbGUID, const QString& strDatabaseServer,
                                   const QString& strName, int nPermission)
{
    Q_ASSERT(!strKbGUID.isEmpty() && !strName.isEmpty());

    m_strKbGUID = strKbGUID;
    m_strDatabaseServer = strDatabaseServer;

    if (m_strName != strName) {
        m_strName = strName;
        Q_EMIT databaseRename(strKbGUID);
    }

    if (m_nPermission != nPermission) {
        m_nPermission = nPermission;
        Q_EMIT databasePermissionChanged(strKbGUID);
    }

    int nErrors = 0;

    if (!SetMeta(g_strDatabaseInfoSection, "Name", strName))
        nErrors++;

    if (!SetMeta(g_strDatabaseInfoSection, "KbGUID", strKbGUID))
        nErrors++;

    if (!SetMeta(g_strDatabaseInfoSection, "Permission", QString::number(nPermission)))
        nErrors++;

    if (!SetMeta(g_strDatabaseInfoSection, "Version", WIZ_DATABASE_VERSION))
        nErrors++;

    if (nErrors > 0)
        return false;

    return true;
}
示例#5
0
bool CWizDatabase::setUserInfo(const WIZUSERINFO& userInfo)
{
    int errors = 0;

    if (!SetMeta(g_strAccountSection, "DisplayName", userInfo.strDisplayName))
        errors++;

    if (!SetMeta(g_strAccountSection, "UserType", userInfo.strUserType))
        errors++;

    if (!SetMeta(g_strAccountSection, "UserLevelName", userInfo.strUserLevelName))
        errors++;

    if (!SetMeta(g_strAccountSection, "UserLevel", QString::number(userInfo.nUserLevel)))
        errors++;

    if (!SetMeta(g_strAccountSection, "UserPoints", QString::number(userInfo.nUserPoints)))
        errors++;

    if (errors > 0)
        return false;

    return true;
}
示例#6
0
bool CWizDatabase::SetUserName(const QString& strUserName)
{
    CString strOld;
    GetUserName(strOld);
    if (!strOld.IsEmpty()) {
        TOLOG("Can not set user name: user name exists!");
        return false;
    }

    if (!SetMeta(g_strAccountSection, _T("UserName"), strUserName)) {
        TOLOG("Failed to set user name while SetUserName");
        return false;
    }

    return true;
}
示例#7
0
bool CWizDatabase::setUserGroupInfo(const CWizGroupDataArray& arrayGroup)
{
    if (!deleteMetasByName(g_strGroupSection)\
            && !deleteMetasByName(g_strBizGroupSection))
        return false;

    int nTotal = arrayGroup.size();
    if (!nTotal) {
        return false;
    }

    // collect biz group info
    QMap<QString, QString> bizInfo;
    for (int i = 0; i < nTotal; i++) {
        const WIZGROUPDATA& data = arrayGroup[i];
        if (!data.bizGUID.isEmpty())
            bizInfo[data.bizGUID] = data.bizName;
    }

    // set biz info
    SetMeta(g_strBizGroupSection, "Count", QString::number(bizInfo.size()));

    int idx = 0;
    QMap<QString, QString>::const_iterator it;
    for (it = bizInfo.begin(); it != bizInfo.end(); it++) {
        SetMeta(g_strBizGroupSection, QString::number(idx), it.key());
        SetMeta(g_strBizGroupSection, it.key(), it.value());
        idx++;
    }

    // set group info
    SetMeta(g_strGroupSection, "Count", QString::number(nTotal));

    for (int i = 0; i < nTotal; i++) {
        const WIZGROUPDATA& data = arrayGroup[i];
        SetMeta(g_strGroupSection, QString::number(i), data.strGroupGUID);
        SetMeta(g_strGroupSection, data.strGroupGUID, data.strGroupName);

        // also biz link
        if (!data.bizGUID.isEmpty()) {
            SetMeta(g_strBizGroupSection, data.strGroupGUID, data.bizGUID);
        }
    }

    return true;
}
示例#8
0
bool CWizDatabase::SetPassword(const QString& strOldPassword, const QString& strPassword)
{
    CString strOld;
    if (!GetPassword(strOld)) {
        TOLOG("Failed to get old password while changing password");
        return false;
    }

    if (strOld != strOldPassword) {
        TOLOG("Invalid password while changing password");
        return false;
    }

    if (!SetMeta(g_strAccountSection, "Password", WizEncryptPassword(strPassword))) {
        TOLOG("Failed to set new password while changing password");
        return false;
    }

    return true;
}
示例#9
0
bool CWizDatabase::setDatabaseInfo(const WIZDATABASEINFO& dbInfo)
{
    Q_ASSERT(!dbInfo.kbGUID.isEmpty() && !dbInfo.name.isEmpty());
    //Q_ASSERT(dbInfo.kbGUID == m_info.kbGUID);

    m_info.bizName = dbInfo.bizName;
    m_info.bizGUID = dbInfo.bizGUID;

    m_info.kbGUID = dbInfo.kbGUID;
    m_info.serverUrl = dbInfo.serverUrl;

    if (m_info.name != dbInfo.name) {
        m_info.name = dbInfo.name;
        Q_EMIT databaseRename(dbInfo.kbGUID);
    }

    if (m_info.nPermission != dbInfo.nPermission) {
        m_info.nPermission = dbInfo.nPermission;
        Q_EMIT databasePermissionChanged(dbInfo.kbGUID);
    }

    int nErrors = 0;

    if (!SetMeta(g_strDatabaseInfoSection, "Name", dbInfo.name))
        nErrors++;

    if (!SetMeta(g_strDatabaseInfoSection, "KbGUID", dbInfo.kbGUID))
        nErrors++;

    if (!SetMeta(g_strDatabaseInfoSection, "Permission", QString::number(dbInfo.nPermission)))
        nErrors++;

    if (!SetMeta(g_strDatabaseInfoSection, "Version", WIZ_DATABASE_VERSION))
        nErrors++;

    // set biz group info
    if (!dbInfo.bizGUID.isEmpty() && !dbInfo.bizName.isEmpty()) {
        if (!SetMeta(g_strDatabaseInfoSection, "BizName", dbInfo.bizName))
            nErrors++;

        if (!SetMeta(g_strDatabaseInfoSection, "BizGUID", dbInfo.bizGUID))
            nErrors++;
    }

    if (nErrors)
        return false;

    return true;
}
示例#10
0
bool CWizDatabase::SetPasswordFalgs(UINT nFlags)
{
    return SetMeta(g_strAccountSection, "PasswordFlags", WizIntToStr(int(nFlags)));
}