void GaduProtocol::sendStatusToServer() { if (!isConnected() && !isDisconnecting()) return; if (!GaduSession) return; // some services have per-status configuration configureServices(); Status newStatus = status(); int friends = account().privateStatus() ? GG_STATUS_FRIENDS_MASK : 0; int type = GaduProtocolHelper::gaduStatusFromStatus(newStatus); bool hasDescription = !newStatus.description().isEmpty(); setStatusFlags(); m_lastSentStatus = newStatus; auto writableSessionToken = Connection->writableSessionToken(); if (hasDescription) gg_change_status_descr( writableSessionToken.rawSession(), type | friends, newStatus.description().toUtf8().constData()); else gg_change_status(writableSessionToken.rawSession(), type | friends); account().accountContact().setCurrentStatus(status()); }
QXmppPresence JabberPresenceService::statusToPresence(const Status &status) { auto result = QXmppPresence{}; result.setType(QXmppPresence::Available); result.setStatusText(status.description()); switch (status.type()) { case StatusType::FreeForChat: result.setAvailableStatusType(QXmppPresence::Chat); break; case StatusType::Online: result.setAvailableStatusType(QXmppPresence::Online); break; case StatusType::Away: result.setAvailableStatusType(QXmppPresence::Away); break; case StatusType::NotAvailable: result.setAvailableStatusType(QXmppPresence::XA); break; case StatusType::DoNotDisturb: result.setAvailableStatusType(QXmppPresence::DND); break; case StatusType::Invisible: result.setAvailableStatusType(QXmppPresence::DND); break; case StatusType::Offline: default: result.setType(QXmppPresence::Unavailable); break; } return result; }
bool statusesEqual(Status status1, Status status2) { if (status1.description() != status2.description()) return false; if (status1.type() == status2.type()) return true; if (status1.type() == "Invisible" && status2.type() == "DoNotDisturb") return true; if (status1.type() == "DoNotDisturb" && status2.type() == "Invisible") return true; return false; }
void BaseStatusContainer::storeStatus(Status status) { if (!MyStorableObject->isValidStorage()) return; MyStorableObject->storeValue("LastStatusDescription", status.description()); MyStorableObject->storeValue("LastStatusName", status.type()); }
KaduIcon StatusTypeManager::statusIcon(const QString &protocol, const Status &status) { const StatusTypeData & statusTypeData = this->statusTypeData(status.type()); QString iconName = QString("protocols/%1/%2%3") .arg(protocol) .arg(statusTypeData.iconName()) .arg(status.description().isEmpty() ? QString() : QLatin1String("_d")); return KaduIcon(iconName, "16x16"); }
bool OnlineAndDescriptionBuddyFilter::acceptBuddy(const Buddy &buddy) { if (!Enabled) return true; Contact preferredContact = BuddyPreferredManager::instance()->preferredContact(buddy, false); if (preferredContact.isNull()) return false; Status status = preferredContact.currentStatus(); return !status.isDisconnected() || !status.description().isEmpty(); }
void HistorySqlStorage::appendStatus(const Contact &contact, const Status &status, const QDateTime &time) { kdebugf(); DatabaseMutex.lock(); AppendStatusQuery.bindValue(":contact", contact.uuid().toString()); AppendStatusQuery.bindValue(":status", status.type()); AppendStatusQuery.bindValue(":set_time", time); AppendStatusQuery.bindValue(":description", status.description()); executeQuery(AppendStatusQuery); DatabaseMutex.unlock(); kdebugf2(); }
unsigned int GaduProtocolHelper::gaduStatusFromStatus(const Status &status) { bool hasDescription = !status.description().isEmpty(); StatusType type = status.type(); if (StatusTypeFreeForChat == type) return hasDescription ? GG_STATUS_FFC_DESCR : GG_STATUS_FFC; if (StatusTypeOnline == type) return hasDescription ? GG_STATUS_AVAIL_DESCR : GG_STATUS_AVAIL; if (StatusTypeAway == type || StatusTypeNotAvailable == type) return hasDescription ? GG_STATUS_BUSY_DESCR : GG_STATUS_BUSY; if (StatusTypeDoNotDisturb == type) return hasDescription ? GG_STATUS_DND_DESCR : GG_STATUS_DND; if (StatusTypeInvisible == type) return hasDescription ? GG_STATUS_INVISIBLE_DESCR : GG_STATUS_INVISIBLE; return hasDescription ? GG_STATUS_NOT_AVAIL_DESCR : GG_STATUS_NOT_AVAIL; }
XMPP::Status toIrisStatus(Status status) { XMPP::Status s = XMPP::Status(); const QString &type = status.type(); if ("Online" == type) s.setType(XMPP::Status::Online); else if ("FreeForChat" == type) s.setType(XMPP::Status::FFC); else if ("DoNotDisturb" == type) s.setType(XMPP::Status::DND); else if ("NotAvailable" == type) s.setType(XMPP::Status::XA); else if ("Away" == type) s.setType(XMPP::Status::Away); else if ("Invisible" == type) s.setType(XMPP::Status::DND); else s.setType(XMPP::Status::Offline); s.setStatus(status.description()); return s; }
static QString getStatusIconPath(BuddyOrContact buddyOrContact) { Buddy buddy = buddyOrContact.buddy(); Contact contact = buddyOrContact.contact(); if (buddy.isBlocked()) return webKitPath(IconsManager::instance()->iconPath("kadu_icons", "16x16", "blocked")); if (contact.isBlocking()) return webKitPath(IconsManager::instance()->iconPath("kadu_icons", "16x16", "blocking")); if (contact.contactAccount()) { Protocol *protocol = contact.contactAccount().protocolHandler(); if (protocol) { StatusTypeManager* statustypemanager = StatusTypeManager::instance(); if (statustypemanager) { Status status = contact.currentStatus(); QString iconpath = statustypemanager->statusIconFullPath(protocol->statusPixmapPath(), status.type(), !status.description().isEmpty(), false); if (!iconpath.isEmpty()) return webKitPath(iconpath); } } } return QString(); }