blob: d6c07874fce06fd6d3890e6fc89eab6d6d487f7c [file] [log] [blame]
/* -*- 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>
*/
#ifndef CONTACTPANEL_H
#define CONTACTPANEL_H
#include <QDialog>
#include <QStringListModel>
#include <QtSql/QSqlDatabase>
#include <QMenu>
#include "profileeditor.h"
#include "addcontactpanel.h"
#include "setaliasdialog.h"
#include "startchatdialog.h"
#include "invitationdialog.h"
#include "settingdialog.h"
#include "chatdialog.h"
#ifndef Q_MOC_RUN
#include "contact-manager.h"
#include "chronos-invitation.h"
#include "panel-policy-manager.h"
#endif
namespace Ui {
class ContactPanel;
}
class ContactPanel : public QDialog
{
Q_OBJECT
public:
explicit ContactPanel(ndn::Ptr<ContactManager> contactManager, QWidget *parent = 0);
~ContactPanel();
private:
void
openDB();
void
setKeychain();
void
setLocalPrefix();
void
onLocalPrefixVerified(ndn::Ptr<ndn::Data> data);
void
onLocalPrefixTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest);
void
onUnverified(ndn::Ptr<ndn::Data> data);
void
onTimeout(ndn::Ptr<ndn::Closure> closure, ndn::Ptr<ndn::Interest> interest);
void
setInvitationListener();
void
onInvitation(ndn::Ptr<ndn::Interest> interest);
void
onInvitationCertVerified(ndn::Ptr<ndn::Data> data,
ndn::Ptr<ChronosInvitation> invitation);
std::string
getRandomString();
void
popChatInvitation(ndn::Ptr<ChronosInvitation> invitation,
const ndn::Name& inviterNameSpace,
ndn::Ptr<ndn::security::IdentityCertificate> certificate);
signals:
void
newInvitationReady();
private slots:
void
updateSelection(const QItemSelection &selected,
const QItemSelection &deselected);
void
updateDefaultIdentity(const QString& identity);
void
openProfileEditor();
void
openAddContactPanel();
void
openSetAliasDialog();
void
openStartChatDialog();
void
openSettingDialog();
void
openInvitationDialog();
void
refreshContactList();
void
showContextMenu(const QPoint& pos);
void
startChatroom(const QString& chatroom, const QString& invitee, bool isIntroducer);
void
startChatroom2(const ChronosInvitation& invitation,
const ndn::security::IdentityCertificate& identityCertificate);
void
acceptInvitation(const ChronosInvitation& invitation,
const ndn::security::IdentityCertificate& identityCertificate);
void
rejectInvitation(const ChronosInvitation& invitation);
private:
Ui::ContactPanel *ui;
ndn::Ptr<ContactManager> m_contactManager;
QStringListModel* m_contactListModel;
ProfileEditor* m_profileEditor;
AddContactPanel* m_addContactPanel;
SetAliasDialog* m_setAliasDialog;
StartChatDialog* m_startChatDialog;
InvitationDialog* m_invitationDialog;
SettingDialog* m_settingDialog;
std::map<ndn::Name, ChatDialog*> m_chatDialogs;
QAction* m_menuInvite;
QAction* m_menuAlias;
std::vector<ndn::Ptr<ContactItem> > m_contactList;
ndn::Ptr<PanelPolicyManager> m_panelPolicyManager;
ndn::Ptr<ndn::security::Keychain> m_keychain;
ndn::Ptr<ndn::Wrapper> m_handler;
ndn::Name m_defaultIdentity;
ndn::Name m_localPrefix;
ndn::Name m_inviteListenPrefix;
std::string m_currentSelectedContactAlias;
std::string m_currentSelectedContactNamespace;
};
#endif // CONTACTPANEL_H