Пример #1
0
void ContactListEdit::insertCompletion( const QModelIndex& completionIndex )
  {
  if( !completionIndex.isValid())
    return;
  QString completion = completionIndex.data().toString();
  int row = completionIndex.data(Qt::UserRole).toInt();
  row = row / 2;
  //DLNFIX consider telling ContactListEdit about addressbookmodel some other way eventually
  QModelIndex index = getKeyhoteeWindow()->getAddressBookModel()->index(row,0);
  auto contact = getKeyhoteeWindow()->getAddressBookModel()->getContact(index);
  insertCompletion(completion, contact);
  }
Пример #2
0
void ContactView::onShareContact()
{
  QList<const Contact*> contacts;
  contacts.push_back(&_current_contact);

  getKeyhoteeWindow()->shareContact(contacts);
}
Пример #3
0
void ContactView::onChat()
{
  ui->contact_pages->setCurrentIndex(chat);
  //clear unread message count on display of chat window
  //DLNFIX maybe getMainWindow can be removed via some connect magic or similar observer notification?
  ContactGui* contact_gui = getKeyhoteeWindow()->getContactGui(_current_contact.wallet_index);
  if (contact_gui)
    contact_gui->setUnreadMsgCount(0);
  ui->chat_input->setFocus();
}
Пример #4
0
void ContactView::onRequestContact()
{
  RequestAuthorization *request = new RequestAuthorization(this, *getKeyhoteeWindow()->getConnectionProcessor());
  if(!ui->khid_pubkey->getKeyhoteeID().isEmpty() && gMiningIsPossible)
    request->setKeyhoteeID(_current_contact.dac_id_string.c_str());
  else
  {
    std::string public_key_string = public_key_address(_current_contact.public_key.serialize());
    request->setPublicKey(public_key_string.c_str());
  }
  request->enableAddContact(false);
  request->setAddressBook(_address_book);
  request->show();
}
Пример #5
0
void TFileAttachmentWidget::onAddContactTriggered()
{
  TSelection selection;
  RetrieveSelection(&selection);

  assert(selection.size() == 1 &&
    "Bad code in command update ui (onAttachementTableSelectionChanged)");

  const AAttachmentItem* item = selection.front();

  QByteArray contactData;
  item->getContactData(contactData);
  assert (contactData.size() > 0);  

  std::list<Contact> contacts;
  Contact contact;
  ContactvCard vCard(contactData);
  // Public key can be invalid, but user can correct key in the "Add contact" dialog
  vCard.convert(&contact);
  contacts.push_back(contact);

  getKeyhoteeWindow()->addToContacts(false, contacts);
  getKeyhoteeWindow()->activateMainWindow();
}
Пример #6
0
void ContactsTable::onSelectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
  {
  QItemSelectionModel* selection_model = ui->contact_table->selectionModel();
  QModelIndexList      indexes = selection_model->selectedRows();
  bool                 oneRow = (indexes.size() == 1);

  if (oneRow)
    {
    QModelIndex mapped_index = _sorted_addressbook_model->mapToSource(indexes[0]);
    auto        contact_id = _addressbook_model->getContact(mapped_index).wallet_index;
    Q_EMIT      contactOpened(contact_id);      
    }
  else
    {
    _currentWidgetView = ui->page_message;
    ui->contact_details_view->setCurrentWidget(ui->page_message);
    }

  getKeyhoteeWindow()->refreshMenuOptions();
  }
Пример #7
0
void ContactView::onMail()
{
  getKeyhoteeWindow()->newMailMessageTo(_current_contact);
}
Пример #8
0
bool ContactGui::isChatVisible()
{
  return getKeyhoteeWindow()->isSelectedContactGui(this) && _view->isChatSelected();
}
Пример #9
0
void TFileAttachmentWidget::onFindContactTriggered()
{
  getKeyhoteeWindow()->openContactGui(_clickedContact.wallet_index);
  getKeyhoteeWindow()->activateMainWindow();  
}
Пример #10
0
void TFileAttachmentWidget::onImportContactTriggered()
{
  TSelection selection;
  RetrieveSelection(&selection);

  QStringList         contactsDuplicated;
  QStringList         contactsPublicKeyInvalid;
  QByteArray          contactData;
  std::list<Contact>  contacts;
  Contact             contact;
  QString             fileName;  
  fc::ecc::public_key parsedKey;
  for (AAttachmentItem* item : selection)
  {    
    item->getContactData(contactData);
    fileName = item->GetDisplayedFileName();
    //check validation file name
    if (TFileAttachmentWidget::isValidContactvCard(fileName, *item, &contactData))
    {
      ContactvCard vCard(contactData);
      assert (contactData.size() > 0);
      std::string publicKeyString = vCard.getPublicKey().toStdString();
    
      //check validation public key
      if (public_key_address::convert(publicKeyString, &parsedKey))
      {
        if(Utils::matchContact(parsedKey, &_clickedContact))
        {
          contactsDuplicated.push_back(fileName);
        }
        else
        {
          // Must be success because validation is checked in the above
          assert (vCard.convert(&contact) == ContactvCard::ConvertStatus::SUCCESS);
          contacts.push_back(contact);
        }
      }
      else
        contactsPublicKeyInvalid.push_back(fileName);
    }
  }

  QWidget *parentWidget;
  if (contacts.size())
  {
    getKeyhoteeWindow()->addToContacts(true/*silent*/, contacts);
    getKeyhoteeWindow()->activateMainWindow();
    parentWidget = getKeyhoteeWindow();
  }
  else
    parentWidget = this;

  QString msg = "";
  if (contactsDuplicated.size())
  {
    /// Report a message about contacts duplicated
    msg += (tr("Following contacts were not imported because they already exist in your contact list:<br/>"));
    for(auto name : contactsDuplicated)
    {
      msg += name + tr("<br/>");
    }
  }
  if (contactsPublicKeyInvalid.size())
  {
    //set empty line if contactsDuplicated exist
    if (contactsDuplicated.size())
      msg += tr("<br/>");
    /// Report a message about contacts with invalid public key
    msg += (tr("Following contacts were not imported because they have invalid public key:<br/>"));
    for(auto name : contactsPublicKeyInvalid)
    {
      msg += name + tr("<br/>");
    }
  }

  if (contactsDuplicated.size() || contactsPublicKeyInvalid.size())
  {    
    QMessageBox::information(parentWidget, tr("Import contact(s)"), msg);
  }
}
Пример #11
0
void ContactListEdit::onActiveFindContact()
{
  getKeyhoteeWindow()->openContactGui(_clicked_contact->wallet_index);
  getKeyhoteeWindow()->activateMainWindow();
}
Пример #12
0
void ContactListEdit::onActiveAddContact()
{
  getKeyhoteeWindow()->addToContacts(_clicked_contact);
  getKeyhoteeWindow()->activateMainWindow();
}