/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2013, Regents of the University of California
 *                     Yingdi Yu
 *
 * BSD license, See the LICENSE file for more information
 *
 * Author: Yingdi Yu <yingdi@cs.ucla.edu>
 */

#include "invitation-dialog.hpp"
#include "ui_invitation-dialog.h"

namespace chronos {

InvitationDialog::InvitationDialog(QWidget* parent)
  : QDialog(parent)
  , ui(new Ui::InvitationDialog)
{
    ui->setupUi(this);

    connect(ui->okButton, SIGNAL(clicked()),
            this, SLOT(onOkClicked()));
    connect(ui->cancelButton, SIGNAL(clicked()),
            this, SLOT(onCancelClicked()));
}

InvitationDialog::~InvitationDialog()
{
    delete ui;
}

void
InvitationDialog::setInvitation(const std::string& alias,
                                const std::string& chatroom,
                                const Name& interestName)
{
  std::string msg = alias;
  m_invitationInterest = interestName;
  msg.append(" invites you to: ").append(chatroom);
  ui->msgLabel->setText(QString::fromStdString(msg));
}

void
InvitationDialog::onOkClicked()
{
  emit invitationResponded(m_invitationInterest, true);
  this->close();

  ui->msgLabel->clear();
  m_invitationInterest.clear();
}

void
InvitationDialog::onCancelClicked()
{
  emit invitationResponded(m_invitationInterest, false);
  this->close();

  ui->msgLabel->clear();
  m_invitationInterest.clear();
}

} // namespace chronos

#if WAF
#include "invitation-dialog.moc"
#include "invitation-dialog.cpp.moc"
#endif
