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

#ifndef CHRONOS_CHAT_DIALOG_HPP
#define CHRONOS_CHAT_DIALOG_HPP

#include <QDialog>
#include <QTextTable>
#include <QStringListModel>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QTimer>

#ifndef Q_MOC_RUN
#include "common.hpp"
#include "contact-manager.hpp"
#include "invitation.hpp"
#include "contact.hpp"
#include "chatbuf.pb.h"
#include "intro-cert-list.pb.h"
#include "digest-tree-scene.hpp"
#include "trust-tree-scene.hpp"
#include "trust-tree-node.hpp"
#include "validator-invitation.hpp"
#include <sync-socket.h>
#include <sync-seq-no.h>
#include <ndn-cxx/security/key-chain.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/thread.hpp>
#endif

#include "invite-list-dialog.hpp"


#define MAX_HISTORY_ENTRY   20

namespace Ui {
class ChatDialog;
}

namespace chronos {

class ChatDialog : public QDialog
{
  Q_OBJECT

public:
  explicit
  ChatDialog(ContactManager* contactManager,
             shared_ptr<ndn::Face> face,
             const ndn::IdentityCertificate& myCertificate,
             const Name& chatroomPrefix,
             const Name& localPrefix,
             const std::string& nick,
             bool witSecurity,
             QWidget* parent = 0);

  ~ChatDialog();

  void
  addSyncAnchor(const Invitation& invitation);

  void
  processTreeUpdateWrapper(const std::vector<Sync::MissingDataInfo>&, Sync::SyncSocket *);

  void
  processDataWrapper(const shared_ptr<const Data>& data);

  void
  processDataNoShowWrapper(const shared_ptr<const Data>& data);

  void
  processRemoveWrapper(const std::string& prefix);

protected:
  void
  closeEvent(QCloseEvent* e);

  void
  changeEvent(QEvent* e);

  void
  resizeEvent(QResizeEvent* e);

  void
  showEvent(QShowEvent* e);

private:
  void
  updatePrefix();

  void
  updateLabels();

  void
  initializeSync();

  void
  sendInvitation(shared_ptr<Contact> contact, bool isIntroducer);

  void
  replyWrapper(const Interest& interest, Data& data,
               size_t routablePrefixOffset, bool isIntroducer);

  void
  replyTimeoutWrapper(const Interest& interest,
                      size_t routablePrefixOffset);

  void
  onReplyValidated(const shared_ptr<const Data>& data,
                   size_t inviteeRoutablePrefixOffset,
                   bool isIntroduce);

  void
  onReplyValidationFailed(const shared_ptr<const Data>& data,
                          const std::string& failureInfo);

  void
  invitationRejected(const Name& identity);

  void
  invitationAccepted(const ndn::IdentityCertificate& inviteeCert,
                     const Name& inviteePrefix, bool isIntroducer);

  void
  fetchIntroCert(const Name& identity, const Name& prefix);

  void
  onIntroCertList(const Interest& interest, const Data& data);

  void
  onIntroCertListTimeout(const Interest& interest, int retry, const std::string& msg);

  void
  introCertWrapper(const Interest& interest, Data& data);

  void
  introCertTimeoutWrapper(const Interest& interest, int retry, const QString& msg);

  void
  onCertListInterest(const Name& prefix, const Interest& interest);

  void
  onCertListRegisterFailed(const Name& prefix, const std::string& msg);

  void
  onCertSingleInterest(const Name& prefix, const Interest& interest);

  void
  onCertSingleRegisterFailed(const Name& prefix, const std::string& msg);


  void
  sendMsg(SyncDemo::ChatMessage& msg);

  void
  disableSyncTreeDisplay();

  void
  appendMessage(const SyncDemo::ChatMessage msg, bool isHistory = false);

  void
  processRemove(QString prefix);

  ndn::Name
  getInviteeRoutablePrefix(const Name& invitee);

  void
  formChatMessage(const QString& text, SyncDemo::ChatMessage& msg);

  void
  formControlMessage(SyncDemo::ChatMessage &msg, SyncDemo::ChatMessage::ChatMessageType type);

  QString
  formatTime(time_t timestamp);

  void
  printTimeInCell(QTextTable* table, time_t timestamp);

  std::string
  getRandomString();

  void
  showMessage(const QString&, const QString&);

  void
  fitView();

  void
  summonReaper();

  void
  getTree(TrustTreeNodeList& nodeList);

  void
  plotTrustTree();

signals:
  void
  processData(const shared_ptr<const Data>& data, bool show, bool isHistory);

  void
  processTreeUpdate(const std::vector<Sync::MissingDataInfo>);

  void
  closeChatDialog(const QString& chatroomName);

  void
  inivationRejection(const QString& msg);

  void
  showChatMessage(const QString& chatroomName, const QString& from, const QString& data);

  void
  resetIcon();

  void
  reply(const Interest& interest, const shared_ptr<const Data>& data,
        size_t routablePrefixOffset, bool isIntroducer);

  void
  replyTimeout(const Interest& interest, size_t routablePrefixOffset);

  void
  introCert(const Interest& interest, const shared_ptr<const Data>& data);

  void
  introCertTimeout(const Interest& interest, int retry, const QString& msg);

  void
  waitForContactList();

public slots:
  void
  onLocalPrefixUpdated(const QString& localPrefix);

  void
  onClose();

private slots:
  void
  onReturnPressed();

  void
  onSyncTreeButtonPressed();

  void
  onTrustTreeButtonPressed();

  void
  onProcessData(const shared_ptr<const Data>& data, bool show, bool isHistory);

  void
  onProcessTreeUpdate(const std::vector<Sync::MissingDataInfo>&);

  void
  onReplot();

  void
  onRosterChanged(QStringList staleUserList);

  void
  onInviteListDialogRequested();

  void
  sendJoin();

  void
  sendHello();

  void
  sendLeave();

  void
  enableSyncTreeDisplay();

  void
  reap();

  void
  onSendInvitation(QString invitee);

  void
  onReply(const Interest& interest, const shared_ptr<const Data>& data,
          size_t routablePrefixOffset, bool isIntroducer);

  void
  onReplyTimeout(const Interest& interest, size_t routablePrefixOffset);

  void
  onIntroCert(const Interest& interest, const shared_ptr<const Data>& data);

  void
  onIntroCertTimeout(const Interest& interest, int retry, const QString& msg);

private:
  Ui::ChatDialog *ui;
  ndn::KeyChain m_keyChain;

  ContactManager* m_contactManager;
  shared_ptr<ndn::Face> m_face;

  ndn::IdentityCertificate m_myCertificate;
  Name m_identity;

  Name m_certListPrefix;
  const ndn::RegisteredPrefixId* m_certListPrefixId;
  Name m_certSinglePrefix;
  const ndn::RegisteredPrefixId* m_certSinglePrefixId;

  std::string m_chatroomName;
  Name m_chatroomPrefix;
  Name m_localPrefix;
  bool m_useRoutablePrefix;
  Name m_chatPrefix;
  Name m_localChatPrefix;
  std::string m_nick;
  DigestTreeScene *m_scene;
  TrustTreeScene *m_trustScene;
  QStringListModel *m_rosterModel;
  QTimer* m_timer;


  int64_t m_lastMsgTime;
  int m_randomizedInterval;
  bool m_joined;

  Sync::SyncSocket *m_sock;
  uint64_t m_session;
  shared_ptr<ndn::SecRuleRelative> m_dataRule;

  InviteListDialog* m_inviteListDialog;
  shared_ptr<ValidatorInvitation> m_invitationValidator;

  boost::recursive_mutex m_msgMutex;
  boost::recursive_mutex m_sceneMutex;
  QList<QString> m_zombieList;
  int m_zombieIndex;
};

} // namespace chronos

#endif // CHRONOS_CHAT_DIALOG_HPP
