Exemple #1
0
void PeerData::updateNameDelayed(
		const QString &newName,
		const QString &newNameOrPhone,
		const QString &newUsername) {
	if (name == newName) {
		if (isUser()) {
			if (asUser()->nameOrPhone == newNameOrPhone
				&& asUser()->username == newUsername) {
				return;
			}
		} else if (isChannel()) {
			if (asChannel()->username == newUsername) {
				return;
			}
		} else if (isChat()) {
			return;
		}
	}

	++nameVersion;
	name = newName;
	nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
	refreshEmptyUserpic();

	Notify::PeerUpdate update(this);
	update.flags |= UpdateFlag::NameChanged;
	update.oldNameFirstChars = nameFirstChars();

	if (isUser()) {
		if (asUser()->username != newUsername) {
			asUser()->username = newUsername;
			update.flags |= UpdateFlag::UsernameChanged;
		}
		asUser()->setNameOrPhone(newNameOrPhone);
	} else if (isChannel()) {
		if (asChannel()->username != newUsername) {
			asChannel()->username = newUsername;
			if (newUsername.isEmpty()) {
				asChannel()->removeFlags(
					MTPDchannel::Flag::f_username);
			} else {
				asChannel()->addFlags(MTPDchannel::Flag::f_username);
			}
			update.flags |= UpdateFlag::UsernameChanged;
		}
	}
	fillNames();
	Notify::PeerUpdated().notify(update, true);
}
Exemple #2
0
int
getObjType( rsComm_t *rsComm, char *objName, char * objType ) {
    if ( isData( rsComm, objName, NULL ) >= 0 ) {
        strcpy( objType, "-d" );
    }
    else if ( isColl( rsComm, objName, NULL ) >= 0 ) {
        strcpy( objType, "-c" );
    }
    else if ( isResc( rsComm, objName ) == 0 ) {
        strcpy( objType, "-r" );
    }
    else if ( isUser( rsComm, objName ) == 0 ) {
        strcpy( objType, "-u" );
    }
    else if ( isMeta( rsComm, objName ) == 0 ) {
        strcpy( objType, "-m" );
    }
    else if ( isToken( rsComm, objName ) == 0 ) {
        strcpy( objType, "-t" );
    }
    else {
        return INVALID_OBJECT_TYPE;
    }
    return 0;
}
Exemple #3
0
QString DAuth::userPasswordHash(const QString& inName)
{
    QString name = inName.trimmed().toLower();
    if (!isUser(name)) // if user not exist then no hash
        return QByteArray();
    return MIA_NAMESPACE->config( name, "Password" );
}
Exemple #4
0
User&
Value::toUser()
{
    if (not isUser()) {
        throw utils::CastError(_("Value is not a user value"));
    }
    return static_cast<User&>(*this);
}
//Get Client information
ClientInfo* ClientManager::getClientInfo(int clientId)
{
	ClientInfo* client = NULL;
	if (isUser(clientId))
	{
		client = clients[clientId];
	}
	return client;
}
Exemple #6
0
bool HistoryItem::canDeleteForEveryone(TimeId now) const {
	const auto peer = history()->peer;
	const auto messageToMyself = peer->isSelf();
	const auto messageTooOld = messageToMyself
		? false
		: peer->isUser()
		? (now - date() >= Global::RevokePrivateTimeLimit())
		: (now - date() >= Global::RevokeTimeLimit());
	if (id < 0 || messageToMyself || messageTooOld || isPost()) {
		return false;
	}
	if (peer->isChannel()) {
		return false;
	} else if (const auto user = peer->asUser()) {
		// Bots receive all messages and there is no sense in revoking them.
		// See https://github.com/telegramdesktop/tdesktop/issues/3818
		if (user->botInfo) {
			return false;
		}
	}
	if (!toHistoryMessage()) {
		return false;
	} else if (const auto media = this->media()) {
		if (!media->allowsRevoke()) {
			return false;
		}
	}
	if (!out()) {
		if (const auto chat = peer->asChat()) {
			if (!chat->amCreator()
				&& !(chat->adminRights()
					& ChatAdminRight::f_delete_messages)) {
				return false;
			}
		} else if (peer->isUser()) {
			return Global::RevokePrivateInbox();
		} else {
			return false;
		}
	}
	return true;
}
Exemple #7
0
// ----------------------------------------------------------------------------
// method: getUserDetails
//
// Create the CmpSeabaseDDLuser class containing user details for the
// request userID
//
// Input:
//    userID - the database authorization ID to search for
//
//  Output:
//    A returned parameter:
//       0 - authorization details are available
//       < 0 - an error was returned trying to get details
//       100 - authorization details were not found
//       > 0 - (not 100) warning was returned
// ----------------------------------------------------------------------------
Int32 CmpSeabaseDDLuser::getUserDetails(Int32 userID)
{
  Int32 retcode = getAuthDetails(userID);
  if (retcode == 0)
  {
    if (!isUser())
      *CmpCommon::diags() << DgSqlCode (-CAT_IS_NOT_A_USER)
                          << DgString0 (getAuthDbName());
    return -CAT_IS_NOT_A_USER;
  }
  return retcode;
}
Exemple #8
0
void regsiter(){
    memmove(&comingbuf[0], &comingbuf[1], 1);
    char *User = strtok(comingbuf,"%");
    char *Pass = strtok(NULL,"%");
    if (isUser(User) == 1)
    {
        write(sockfd,error,1);
    }else{
        regsiterSQL(User,Pass);
        write(sockfd,succ,1);
    }
    bzero(comingbuf,LENG);
}
Exemple #9
0
// ----------------------------------------------------------------------------
// method: getUserDetails
//
// Create the CmpSeabaseDDLuser class containing user details for the
// requested username
//
// Input:
//    userName - the database username to retrieve details for
//    isExternal -
//       true - the username is the external name (auth_ext_name)
//       false - the username is the database name (auth_db_name)
//
//  Output:
//    A returned parameter:
//       0 - authorization details are available
//       < 0 - an error was returned trying to get details
//       100 - authorization details were not found
//       > 0 - (not 100) warning was returned
// ----------------------------------------------------------------------------
Int32 CmpSeabaseDDLuser::getUserDetails(const char *pUserName,
                                        bool isExternal)
{
  Int32 retcode = getAuthDetails(pUserName, isExternal);
  if (retcode == 0)
  {
    if (!isUser())
    {
      *CmpCommon::diags() << DgSqlCode (-CAT_IS_NOT_A_USER)
                          << DgString0 (pUserName);
      return -CAT_IS_NOT_A_USER;
    }
  }
  return retcode;
}
Exemple #10
0
int
getObjType(rsComm_t *rsComm, char *objName, char * objType)
{
    if (isData(rsComm, objName, NULL) >= 0)
      strcpy(objType,"-d");
    else if (isColl(rsComm, objName, NULL) >= 0)
      strcpy(objType,"-c");
    else if (isResc(rsComm, objName) == 0)
      strcpy(objType,"-r");
    else if (isRescGroup(rsComm, objName) == 0)
      strcpy(objType,"-g");
    else if (isUser(rsComm, objName) == 0)
      strcpy(objType,"-u");
    else if (isMeta(rsComm, objName) == 0)
      strcpy(objType,"-m");
    else if (isToken(rsComm, objName) == 0)
      strcpy(objType,"-t");
    else
      return(INVALID_OBJECT_TYPE);
    return (0);
}
Exemple #11
0
void Settings::SingleObjectPropertiesReadWrite(const Settings::Action action,
                                               QObject *qobject_p, const QStringList &properties)
{
const QPointer<QObject> qo_qp(qobject_p);
    if (qo_qp) {
        // Static object properties
        const auto qmetaobject_p = qo_qp->metaObject();
        for (auto i = 0; i < (qmetaobject_p->propertyCount() - 1); ++i) {
            const QString property_name(qmetaobject_p->property(i).name());
            if (TRUE != property_name.isEmpty()) {
                const auto property = qmetaobject_p->property(i);
                if (property.isWritable() && (property.isUser() || properties.contains(property_name))) {
                    if (READ == action) {
                        property.write(qo_qp.data(), value(property_name));
                    } else if (WRITE == action) {
                        const QVariant property_value(property.read(qobject_p));
                        if (property_value.isValid()) {
                            setValue(property_name, property_value);
                        }
                    } else { D_ASSERT(FALSE); }
                }
            }
        }
        // Dynamic object properties
        foreach (const auto &property_name, qo_qp->dynamicPropertyNames()) {
            //if (properties.contains(property_name.constData())) {
                if (READ == action) {
                    qo_qp->setProperty(property_name.constData(), value(QString(property_name)));
                } else if (WRITE == action) {
                    const QVariant property_value(qo_qp->property(property_name.constData()));
                    if (property_value.isValid()) {
                        setValue(property_name, property_value);
                    }
                } else { D_ASSERT(FALSE); }
            //}
        }
    }
}