/* -*- 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
  changeEvent(QEvent *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::shared_ptr<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
  resetIcon();

  void
  reply(const ndn::Interest& interest,
        const ndn::shared_ptr<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::shared_ptr<const ndn::Data>& data);
  
  void
  introCertTimeout(const ndn::Interest& interest,
                   int retry, const QString& msg);

  void
  waitForContactList();

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

  void
  onClose();

private slots:
  void
  onReturnPressed();

  void 
  onTreeButtonPressed();

  void 
  onProcessData(const ndn::shared_ptr<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::shared_ptr<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::shared_ptr<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
