blob: 9803a6a95eaed30a0d30106594145f8b72849fbc [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"
#ifndef Q_MOC_RUN
#include "contact-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,
const ndn::Name& interestName,
int inviterIndex);
std::string
getRandomString();
void
popChatInvitation(const ndn::Name& interestName,
int inviterIndex,
const ndn::Name& inviterNameSpace,
ndn::Ptr<ndn::security::IdentityCertificate> certificate);
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
refreshContactList();
void
showContextMenu(const QPoint& pos);
void
startChatroom(const QString& chatroom, const QString& invitee, bool isIntroducer);
void
startChatroom2(const QString& chatroom, const QString& inviter);
void
acceptInvitation(const ndn::Name& interestName,
const ndn::security::IdentityCertificate& identityCertificate,
QString inviter,
QString chatroom);
void
rejectInvitation(const ndn::Name& interestName);
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;
QAction* m_menuInvite;
QAction* m_menuAlias;
std::vector<ndn::Ptr<ContactItem> > m_contactList;
ndn::Ptr<ndn::security::Keychain> m_keychain;
ndn::Ptr<ndn::Wrapper> m_handler;
ndn::Name m_defaultIdentity;
ndn::Name m_localPrefix;
std::string m_currentSelectedContactAlias;
std::string m_currentSelectedContactNamespace;
};
#endif // CONTACTPANEL_H