示例#1
0
bool ProfileField::isMatch(const Notify &notify)
{
  int type = notify.type();
  if (type != Notify::FeedReply && type != Notify::FeedData)
    return false;

  const FeedNotify &n = static_cast<const FeedNotify &>(notify);
  return n.match(ChatClient::id(), FEED_NAME_PROFILE);
}
示例#2
0
void NetworkManager::notify(const Notify &notify)
{
  if (notify.type() == Notify::ServerRenamed) {
    Network item = this->item(ChatClient::serverId());
    if (!item)
      return;

    item->setName(ChatClient::serverName());
    item->write();
  }
}
示例#3
0
void ProfileField::notify(const Notify &notify)
{
  if (!isMatch(notify))
    return;

  if (notify.type() == Notify::FeedReply) {
    const FeedNotify &n = static_cast<const FeedNotify &>(notify);
    if (!n.json().contains(m_field))
      return;
  }

  reload();
}
示例#4
0
void HistoryChatView::notify(const Notify &notify)
{
  if (notify.type() == Notify::FeedReply) {
    const FeedNotify &n = static_cast<const FeedNotify &>(notify);
    if (n.feed() == FEED_NAME_MESSAGES && n.path() == MESSAGES_FEED_LAST_KEY) {
      if (n.status() == Notice::NotModified) {
        const QList<QByteArray> messages = HistoryDB::last(n.channel());
        HistoryImpl::get(n.channel(), messages);
        emulateLast(n.channel(), messages);
      }
      else if (n.status() == Notice::OK && !n.json().contains(MESSAGES_FEED_BEFORE_KEY) && !n.json().contains(MESSAGES_FEED_EMULATED_KEY))
        HistoryDB::add(n.channel(), n.json().value(MESSAGES_FEED_MESSAGES_KEY).toStringList());
    }
  }
}
示例#5
0
void ConsoleCmd::notify(const Notify &notify)
{
  if (notify.type() == Notify::FeedReply) {
    const FeedNotify &n = static_cast<const FeedNotify &>(notify);
    if (n.channel() == ChatClient::serverId() && n.name() == CONSOLE_FEED_COOKIE_REQ && !m_cookie.isEmpty()) {
      if (n.status() == Notice::OK) {
        const QByteArray id = SimpleID::decode(n.json().value(LS("user")).toString());
        if (m_cookie == id)
          AlertMessage::show(LS("<b>Cookie:</b> ") + n.json().value(CONSOLE_FEED_COOKIE_KEY).toString(), ALERT_MESSAGE_INFO);
      }

      m_cookie.clear();
    }

  }
}
示例#6
0
void ChannelsView::notify(const Notify &notify)
{
  int type = notify.type();
  if (type == Notify::FeedData || type == Notify::FeedReply) {
    const FeedNotify &n = static_cast<const FeedNotify &>(notify);
    if (n.channel() != ChatClient::serverId())
      return;

    QVariantMap json = WebBridge::feed(n);
    if (json.isEmpty())
      return;

    emit feed(json);
  }
  else if (type == Notify::ServerRenamed) {
    emit serverRenamed(ChatClient::serverName());
  }
}
示例#7
0
void ChatView::notify(const Notify &notify)
{
  const int type = notify.type();

  if (type == Notify::ClearChat) {
    if (m_id == notify.data().toByteArray())
      clearPage();
  }
  else if (type == Notify::FeedData || type == Notify::FeedReply) {
    const FeedNotify &n = static_cast<const FeedNotify &>(notify);
    if (n.channel() == id() || n.channel() == ChatClient::id() || (n.channel() == ChatClient::serverId() && n.feed() == FEED_NAME_ACL)) {
      const QVariantMap json = WebBridge::feed(n);
      if (json.isEmpty())
        return;

      if (!m_loaded)
        m_pendingFeeds.enqueue(json);
      else
        emit feed(json);
    }
  }
}
示例#8
0
void StatusBar::notify(const Notify &notify)
{
  if (notify.type() == Notify::ServerRenamed)
    setServerName();
}