/* -*- 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.h"
#include "ui_invitation-dialog.h"

using namespace std;
using namespace ndn;

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 string& alias,
                                const string& chatroom,
                                const Name& interestName)
{
  string msg = alias;
  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();
}

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