本文整理汇总了C++中UserPtr::isOnline方法的典型用法代码示例。如果您正苦于以下问题:C++ UserPtr::isOnline方法的具体用法?C++ UserPtr::isOnline怎么用?C++ UserPtr::isOnline使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserPtr
的用法示例。
在下文中一共展示了UserPtr::isOnline方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkUser
void AntiSpam::checkUser(const QString &cid, const QString &msg, const QString &hubUrl){
UserPtr user = ClientManager::getInstance()->findUser(CID(_tq(cid)));
if (!user->isOnline()){
if (sandbox.contains(cid))
sandbox.remove(cid);
return;
}
if (sandbox.contains(cid)){
int counter = sandbox[cid];
++counter;
QList<QString> keys = getKeys();
foreach (QString key, keys){
if (key.toUpper() == msg.toUpper()){
(*this) << eIN_GRAY << WulforUtil::getInstance()->getNicks(cid);
return;
}
}
if (counter > try_count){
(*this) << eIN_BLACK << WulforUtil::getInstance()->getNicks(cid);
return;
}
ClientManager::getInstance()->privateMessage(user, _tq("Try again."), false, hubUrl.toStdString());
sandbox[cid] = counter;
}
示例2: updateUser
void UsersFrame::updateUser(const UserPtr& aUser) {
for(int i = 0; i < ctrlUsers.GetItemCount(); ++i) {
UserInfo *ui = ctrlUsers.getItemData(i);
if(ui->user == aUser) {
ui->columns[COLUMN_SEEN] = aUser->isOnline() ? TSTRING(ONLINE) : Text::toT(Util::formatTime("%Y-%m-%d %H:%M", FavoriteManager::getInstance()->getLastSeen(aUser)));
if(aUser->isOnline()) {
// TODO: if(aUser->isSet(User::AWAY))
// ctrlUsers.SetItem(i,0,LVIF_IMAGE, NULL, 1, 0, 0, NULL);
//else
ctrlUsers.SetItem(i,0,LVIF_IMAGE, NULL, 0, 0, 0, NULL);
} else
ctrlUsers.SetItem(i,0,LVIF_IMAGE, NULL, 2, 0, 0, NULL);
ctrlUsers.updateItem(i);
}
}
}
示例3: getUserFlags
StringSet Serializer::getUserFlags(const UserPtr& aUser) noexcept {
StringSet ret;
if (aUser->isSet(User::BOT)) {
ret.insert("bot");
}
if (aUser->isSet(User::FAVORITE)) {
ret.insert("favorite");
}
if (aUser->isSet(User::IGNORED)) {
ret.insert("ignored");
}
if (aUser == ClientManager::getInstance()->getMe()) {
ret.insert("me");
}
if (aUser->isSet(User::NMDC)) {
ret.insert("nmdc");
}
if (aUser->isSet(User::ASCH)) {
ret.insert("asch");
}
if (!aUser->isOnline()) {
ret.insert("offline");
}
return ret;
}
示例4: sendMessage
void PMWindow::sendMessage(QString msg, bool thirdPerson, bool stripNewLines){
UserPtr user = ClientManager::getInstance()->findUser(CID(cid.toStdString()));
if (user && user->isOnline()){
if (stripNewLines)
msg.replace("\n", "");
if (msg.isEmpty() || msg == "\n")
return;
ClientManager::getInstance()->privateMessage(HintedUser(user, _tq(hubUrl)), _tq(msg), thirdPerson);
}
else {
addStatusMessage(tr("User went offline"));
}
if (out_messages_unsent){
out_messages.removeLast();
out_messages_unsent = false;
}
out_messages << msg;
if (out_messages.size() > WIGET(WI_OUT_IN_HIST))
out_messages.removeFirst();
out_messages_index = out_messages.size()-1;
}
示例5: updateUser
void UsersFrame::updateUser(const UserPtr& aUser) {
for(size_t i = 0; i < users->size(); ++i) {
UserInfo *ui = users->getData(i);
if(ui->user == aUser) {
ui->columns[COLUMN_SEEN] = aUser->isOnline() ? T_("Online") : Text::toT(Util::formatTime("%Y-%m-%d %H:%M", FavoriteManager::getInstance()->getLastSeen(aUser)));
users->update(i);
}
}
}
示例6: checkUser
void AntiSpam::checkUser(const QString &cid, const QString &msg, const QString &hubUrl){
UserPtr user = ClientManager::getInstance()->findUser(CID(_tq(cid)));
if (!user->isOnline()){
if (sandbox.contains(cid))
sandbox.remove(cid);
return;
}
log(tr("Checking user %1 (message: %2, cid: %3)...").arg(WulforUtil::getInstance()->getNicks(cid)).arg(msg).arg(cid));
if (sandbox.contains(cid)){
int counter = sandbox[cid];
++counter;
QList<QString> keys = getKeys();
for (auto key : keys){
if (key.toUpper() == msg.toUpper()){
(*this) << eIN_GRAY << WulforUtil::getInstance()->getNicks(cid);
log(tr("%1: Moving user to GRAY.").arg(cid));
sandbox.remove(cid);
return;
}
}
if (counter > try_count){
(*this) << eIN_BLACK << WulforUtil::getInstance()->getNicks(cid);
log(tr("%1: Moving user to BLACK.").arg(cid));
sandbox.remove(cid);
return;
}
ClientManager::getInstance()->privateMessage(HintedUser(user, _tq(hubUrl)), _tq("Try again."), false);
log(tr("%1: Sending \"Try again\" message.").arg(cid));
sandbox[cid] = counter;
}
else {
sandbox[cid] = 0;
QString question = tr("Hi, this is AntiSpam bot. So question is \"%1\"").arg(phrase);
ClientManager::getInstance()->privateMessage(HintedUser(user, _tq(hubUrl)), _tq(question), false);
}
}
示例7: show
bool UsersFrame::show(const UserPtr &u, bool any) const {
if(any && (u->isOnline() || isFav(u) || isWaiting(u) || hasDownload(u))) {
return true;
}
if(SETTING(USERS_FILTER_ONLINE) && !u->isOnline()) {
return false;
}
if(SETTING(USERS_FILTER_FAVORITE) && !isFav(u)) {
return false;
}
if(SETTING(USERS_FILTER_WAITING) && !isWaiting(u)) {
return false;
}
if(SETTING(USERS_FILTER_QUEUE) && !hasDownload(u)) {
return false;
}
return true;
}
示例8:
void UsersFrame::UserInfo::update(const UserPtr& u, bool visible) {
auto fu = FavoriteManager::getInstance()->getFavoriteUser(u);
if(fu) {
isFavorite = true;
grantSlot = fu->isSet(FavoriteUser::FLAG_GRANTSLOT);
columns[COLUMN_NICK] = Text::toT(fu->getNick());
if(!visible) {
return;
}
columns[COLUMN_DESCRIPTION] = Text::toT(fu->getDescription());
if(u->isOnline()) {
columns[COLUMN_SEEN] = T_("Online");
columns[COLUMN_HUB] = WinUtil::getHubNames(u->getCID()).first;
} else {
columns[COLUMN_SEEN] = fu->getLastSeen() > 0 ? Text::toT(Util::formatTime("%Y-%m-%d %H:%M", fu->getLastSeen())) : T_("Offline");
columns[COLUMN_HUB] = Text::toT(fu->getUrl());
}
} else {
isFavorite = false;
grantSlot = false;
columns[COLUMN_NICK] = WinUtil::getNicks(u->getCID());
if(!visible) {
return;
}
if(u->isOnline()) {
columns[COLUMN_SEEN] = T_("Online");
columns[COLUMN_HUB] = WinUtil::getHubNames(u->getCID()).first;
} else {
columns[COLUMN_SEEN] = T_("Offline");
}
}
columns[COLUMN_CID] = Text::toT(u->getCID().toBase32());
}
示例9: sendMessage
void PMWindow::sendMessage(QString msg, bool stripNewLines){
UserPtr user = ClientManager::getInstance()->findUser(CID(cid.toStdString()));
if (user && user->isOnline()){
if (stripNewLines)
msg.replace("\n", "");
if (msg.isEmpty() || msg == "\n")
return;
ClientManager::getInstance()->privateMessage(user, msg.toStdString(), false, hubUrl.toStdString());
}
else {
addStatusMessage(tr("User went offline"));
}
}
示例10: createNode
/*
* Creates new (or update existing) node which is NOT added to our routing table
*/
Node::Ptr KBucket::createNode(const UserPtr& u, const string& ip, uint16_t port, bool update, bool isUdpKeyValid)
{
if(u->isSet(User::DHT)) // is this user already known in DHT?
{
Node::Ptr node = NULL;
// no online node found, try get from routing table
for(NodeList::iterator it = nodes.begin(); it != nodes.end(); ++it)
{
if(u->getCID() == (*it)->getUser()->getCID())
{
node = *it;
// put node at the end of the list
nodes.erase(it);
nodes.push_back(node);
break;
}
}
if(node == NULL && u->isOnline())
{
// try to get node from ClientManager (user can be online but not in our routing table)
// this fixes the bug with DHT node online twice
node = (Node*)ClientManager::getInstance()->findDHTNode(u->getCID());
node = node.get();
}
if(node != NULL)
{
// fine, node found, update it and return it
if(update)
{
string oldIp = node->getIdentity().getIp();
string oldPort = node->getIdentity().getUdpPort();
if(ip != oldIp || static_cast<uint16_t>(Util::toInt(oldPort)) != port)
{
node->setIpVerified(false);
// TODO: don't allow update when new IP already exists for different node
// erase old IP and remember new one
ipMap.erase(oldIp + ":" + oldPort);
ipMap.insert(ip + ":" + Util::toString(port));
}
if(!node->isIpVerified())
node->setIpVerified(isUdpKeyValid);
node->setAlive();
node->getIdentity().setIp(ip);
node->getIdentity().setUdpPort(Util::toString(port));
DHT::getInstance()->setDirty();
}
return node;
}
}
u->setFlag(User::DHT);
Node::Ptr node(new Node(u));
node->getIdentity().setIp(ip);
node->getIdentity().setUdpPort(Util::toString(port));
node->setIpVerified(isUdpKeyValid);
return node;
}