Exemple #1
0
void RawFeedsCmd::request(const QByteArray &dest, const ClientCmd &cmd)
{
  ClientCmd body(cmd.body());
  if (body.command().isEmpty())
    return;

  QVariantMap json = JSON::parse(body.body().toUtf8()).toMap();
  ClientFeeds::request(ChatClient::channels()->get(dest), cmd.command(), body.command(), json);
}
bool SendFileMessages::command(const QByteArray &dest, const ClientCmd &cmd)
{
  if (SimpleID::typeOf(dest) != SimpleID::UserId)
    return false;

  QString command = cmd.command().toLower();
  if (command == LS("send")) {
    if (cmd.body().isEmpty())
      m_plugin->sendFile(dest);
    else
      m_plugin->sendFile(dest, cmd.body());

    return true;
  }

  return false;
}
Exemple #3
0
bool ConsoleCmd::command(const QByteArray &dest, const ClientCmd &cmd)
{
  Q_UNUSED(dest)

  const QString command = cmd.command().toLower();
  if (command == LS("console")) {
    m_plugin->show();
  }
  else if (command == LS("cookie")) {
    if (isTalk(dest, command) && isOnline())
      getCookie(dest);
  }
  else
    return false;

  return true;
}
Exemple #4
0
bool RawFeedsCmd::command(const QByteArray &dest, const ClientCmd &cmd)
{
  QString command = cmd.command().toLower();
  if (command == LS("feeds")) {
    m_plugin->setEnabled(true);

    ClientCmd body(cmd.body());
    if (!body.isValid() && Channel::isCompatibleId(dest)) {
      QVariantMap json;
      json[FEED_KEY_COMPACT] = false;
      ClientFeeds::request(dest, FEED_METHOD_GET, FEED_WILDCARD_ASTERISK, json);
    }
    else if (body.command() == LS("local"))
      localFeeds(dest);
    else if (body.command() == LS("off"))
      m_plugin->setEnabled(false);

    return true;
  }

  if (command == LS("feed")) {
    m_plugin->setEnabled(true);

    ClientCmd body(cmd.body());
    if (!body.isValid())
      return true;

    request(dest, body);
    return true;
  }

  if (command == LS("headers")) {
    m_headers = JSON::parse(cmd.body().toUtf8()).toMap();
    return true;
  }

  if (command == "req") {
    ClientCmd body(cmd.body());
    request(body.command().toUpper(), dest, body.body());
    return true;
  }

  if (command == LS("auth") || command == LS("del") || command == LS("get") || command == LS("post") || command == LS("pub") || command == LS("put") || command == LS("sub") || command == LS("unsub")) {
    request(command.toUpper(), dest, cmd.body());
    return true;
  }

  return false;
}