major change: Add security support & Adjust GUI

Change-Id: I7abef37169dec1ef4b68e760dee5214c147c1915
diff --git a/src/add-contact-panel.cpp b/src/add-contact-panel.cpp
new file mode 100644
index 0000000..5ce575c
--- /dev/null
+++ b/src/add-contact-panel.cpp
@@ -0,0 +1,97 @@
+/* -*- 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>
+ */
+
+#include "add-contact-panel.h"
+#include "ui_add-contact-panel.h"
+
+#ifndef Q_MOC_RUN
+#endif
+
+AddContactPanel::AddContactPanel(QWidget *parent)
+  : QDialog(parent)
+  , ui(new Ui::AddContactPanel)
+{
+  ui->setupUi(this);
+
+  connect(ui->cancelButton, SIGNAL(clicked()),
+          this, SLOT(onCancelClicked()));
+  connect(ui->searchButton, SIGNAL(clicked()),
+          this, SLOT(onSearchClicked()));
+  connect(ui->addButton, SIGNAL(clicked()),
+          this, SLOT(onAddClicked()));
+
+  ui->infoView->setColumnCount(3);
+
+  m_typeHeader = new QTableWidgetItem(QString("Type"));
+  ui->infoView->setHorizontalHeaderItem(0, m_typeHeader);
+  m_valueHeader = new QTableWidgetItem(QString("Value"));
+  ui->infoView->setHorizontalHeaderItem(1, m_valueHeader);
+  m_endorseHeader = new QTableWidgetItem(QString("Endorse"));
+  ui->infoView->setHorizontalHeaderItem(2, m_endorseHeader);
+
+}
+
+AddContactPanel::~AddContactPanel()
+{
+  delete m_typeHeader;
+  delete m_valueHeader;
+  delete m_endorseHeader;
+
+  delete ui;
+}
+
+void
+AddContactPanel::onCancelClicked()
+{
+  this->close(); 
+}
+
+void
+AddContactPanel::onSearchClicked()
+{
+  // ui->infoView->clear();
+  for(int i = ui->infoView->rowCount() - 1; i >= 0 ; i--)
+    ui->infoView->removeRow(i);
+
+  m_searchIdentity = ui->contactInput->text();
+  emit fetchInfo(m_searchIdentity);
+}
+
+void
+AddContactPanel::onAddClicked()
+{
+  emit addContact(m_searchIdentity);
+  this->close();
+}
+
+void
+AddContactPanel::onContactEndorseInfoReady(const chronos::EndorseInfo& endorseInfo)
+{
+  int entrySize = endorseInfo.endorsement_size();
+
+  for(int rowCount = 0; rowCount < entrySize; rowCount++)
+    {
+      ui->infoView->insertRow(rowCount);  
+      QTableWidgetItem* type = new QTableWidgetItem(QString::fromStdString(endorseInfo.endorsement(rowCount).type()));
+      ui->infoView->setItem(rowCount, 0, type);
+    
+      QTableWidgetItem* value = new QTableWidgetItem(QString::fromStdString(endorseInfo.endorsement(rowCount).value()));
+      ui->infoView->setItem(rowCount, 1, value);
+
+      QTableWidgetItem* endorse = new QTableWidgetItem(QString::fromStdString(endorseInfo.endorsement(rowCount).endorse()));
+      ui->infoView->setItem(rowCount, 2, endorse);
+    }
+}
+
+
+#if WAF
+#include "add-contact-panel.moc"
+#include "add-contact-panel.cpp.moc"
+#endif