/* -*- 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: Zhenkai Zhu <zhenkai@cs.ucla.edu>
 *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
 *         Yingdi Yu <yingdi@cs.ucla.edu>
 */

#ifndef CHAT_DIALOG_H
#define CHAT_DIALOG_H

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

#include "invite-list-dialog.h"

#ifndef Q_MOC_RUN
#include "contact-manager.h"
#include "invitation.h"
#include "contact.h"
#include "chatbuf.pb.h"
#include "intro-cert-list.pb.h"
#include "digesttreescene.h"
#include <sync-socket.h>
#include <sync-seq-no.h>
#include <ndn-cpp-dev/security/key-chain.hpp>
#include "validator-invitation.h"

#include <boost/thread/locks.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/thread.hpp>
#endif

#define MAX_HISTORY_ENTRY   20

namespace Ui {
class ChatDialog;
}

class ChatDialog : public QDialog
{
  Q_OBJECT

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

  ~ChatDialog();
  
  void 
  addSyncAnchor(const chronos::Invitation& invitation);

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

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

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

  void 
  processRemoveWrapper(std::string);

protected:
  void 
  closeEvent(QCloseEvent *e);

  void 
  resizeEvent(QResizeEvent *);
  
  void 
  showEvent(QShowEvent *);

private:
  void
  updatePrefix();
  
  void 
  updateLabels();

  void
  initializeSync();

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

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

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

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

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

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

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

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

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

  void
  introCertWrapper(const ndn::Interest& interest, ndn::Data& data);
  
  void
  introCertTimeoutWrapper(const ndn::Interest& interest, int retry, const QString& msg);

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

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

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

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


  void 
  sendMsg(SyncDemo::ChatMessage &msg);

  void 
  disableTreeDisplay();

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

  void 
  processRemove(QString prefix);

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

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

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

  QString 
  formatTime(time_t);

  void 
  printTimeInCell(QTextTable *, time_t);

  std::string 
  getRandomString();

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

  void 
  fitView();

  void 
  summonReaper();

signals:  
  void
  processData(const ndn::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
  reply(const ndn::Interest& interest, const ndn::Data& data, size_t routablePrefixOffset, bool isIntroducer);

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

  void
  introCert(const ndn::Interest& interest, const ndn::Data& data);
  
  void
  introCertTimeout(const ndn::Interest& interest, int retry, const QString& msg);


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

  void
  onClose();

private slots:
  void
  onReturnPressed();

  void 
  onTreeButtonPressed();

  void 
  onProcessData(const ndn::Data& data, bool show, bool isHistory);

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

  void 
  onReplot();

  void 
  onRosterChanged(QStringList);

  void
  onInviteListDialogRequested();

  void 
  sendJoin();

  void
  sendHello();

  void
  sendLeave();

  void 
  enableTreeDisplay();

  void
  reap();

  void
  onSendInvitation(QString);

  void
  onReply(const ndn::Interest& interest, const ndn::Data& data, size_t routablePrefixOffset, bool isIntroducer);

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

  void
  onIntroCert(const ndn::Interest& interest, const ndn::Data& data);

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

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

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

  ndn::IdentityCertificate m_myCertificate;
  ndn::Name m_identity;

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

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


  int64_t m_lastMsgTime;
  int m_randomizedInterval;
  bool m_joined;

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

  InviteListDialog* m_inviteListDialog;
  ndn::shared_ptr<chronos::ValidatorInvitation> m_invitationValidator;

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

#endif // CHAT_DIALOG_H
