Ejemplo n.º 1
0
/*!
 * Отправка обновлённой информации о себе.
 */
ChannelPacket ChannelNotice::update(ClientChannel channel)
{
  ChannelPacket packet(new ChannelNotice(channel->id(), channel->id(), CHANNELS_UPDATE_CMD, DateTime::utc()));
  packet->setText(channel->name());
  packet->gender        = channel->gender().raw();
  packet->channelStatus = channel->status().value();
  return packet;
}
Ejemplo n.º 2
0
ChannelPacket ChannelNotice::info(ClientChannel channel, qint64 date)
{
  ChannelPacket packet(new ChannelNotice(channel->id(), channel->id(), CHANNELS_INFO_CMD, date ? date : DateTime::utc()));
  packet->setDirection(Server2Client);
  packet->setText(channel->name());
  packet->gender        = channel->gender().raw();
  packet->channelStatus = channel->status().value();
  return packet;
}
Ejemplo n.º 3
0
/*!
 * Формирование пакета для отправки клиенту заголовка канала.
 *
 * \param channel Канал.
 * \param dest    Идентификатор получателя.
 * \param command Команда.
 */
ChannelPacket ChannelNotice::channel(ClientChannel channel, const QByteArray &dest, const QString &command)
{
  ChannelPacket packet(new ChannelNotice(channel->id(), dest, command, DateTime::utc()));
  packet->setDirection(Server2Client);
  packet->setText(channel->name());
  packet->gender        = channel->gender().raw();
  packet->channelStatus = channel->status().value();
//  packet.setData(channel->feeds().headers(0));

  if (channel->type() == SimpleID::ChannelId)
    packet->channels = channel->channels().all();

  return packet;
}
Ejemplo n.º 4
0
/*!
 * Получение идентификатора пользователя из менеджера сетей
 * и установка базовых данных из настроек.
 */
QByteArray Networks::id() const
{
  ClientChannel channel = ChatClient::channel();
  channel->setName(ChatCore::settings()->value("Profile/Nick").toString());
  channel->gender().setRaw(ChatCore::settings()->value("Profile/Gender").toInt());
  channel->status().set(ChatCore::settings()->value("Profile/Status").toInt());

  Network item = ChatCore::networks()->item(ChatCore::networks()->selected());
  if (!item->isValid())
    return QByteArray();

  channel->setId(item->userId());

  return channel->id();
}
Ejemplo n.º 5
0
/*!
 * Иконка канала.
 */
QIcon ChatIcons::icon(ClientChannel channel, int options)
{
  QString file = LS(":/images/channel.png");

  if (channel->type() == ChatId::UserId || channel->id().isEmpty()) {
    file = LS(":/images/user");
    int gender = channel->gender().value();
    int color  = channel->gender().color();

    if (gender == Gender::Unknown) {
      file += LS("-unknown");
    }
    else if (gender == Gender::Ghost) {
      file += LS("-ghost");
    }
    else if (gender == Gender::Bot) {
      file += LS("-bot");
    }
    else if (color != Gender::Default) {
      file += LS("-") + Gender::colorToString(color);
    }

    if (gender == Gender::Female)
      file += LS("-female");

    file += LS(".png");
  }
  else if (channel->type() == ChatId::ChannelId && channel->gender().color() == Gender::Green) {
    file = LS(":/images/secure.png");
  }

  const Status& status = channel->status();
  if (options & OfflineStatus && status.value() == Status::Offline && !(options & Statuses))
    options |= Statuses;

  if (options & Statuses) {
    if (options & OfflineStatus && (status.value() == Status::Offline || !channel->isSynced()))
      return QIcon(QIcon(file).pixmap(16, 16, QIcon::Disabled));

    return ChatIcons::icon(file, overlay(status.value()));
  }

  return QIcon(file);
}