Esempio n. 1
0
bool MAPIContact::SetNotes(const String &szNotes, bool bRTF) {
#ifdef _WIN32_WCE
	return SetPropertyString(PR_BODY, szNotes);
#else
	if(!Contact() || IsNull(szNotes)) 
		return false;
	ULONG nLen = (ULONG)szNotes.GetLength();

	HRESULT hr = E_FAIL;
	LPSTREAM pStream = NULL;
	if(bRTF) {
		if(Contact()->OpenProperty(PR_RTF_COMPRESSED, &IID_IStream, STGM_CREATE | STGM_WRITE, 
								MAPI_MODIFY | MAPI_CREATE, (LPUNKNOWN*)&pStream) == S_OK) {
			IStream *pUncompressed;
			if(WrapCompressedRTFStream(pStream,MAPI_MODIFY, &pUncompressed) == S_OK) {
				hr = pUncompressed->Write(szNotes, nLen*sizeof(TCHAR), NULL);
				if(pUncompressed->Commit(STGC_DEFAULT)==S_OK) 
					pStream->Commit(STGC_DEFAULT);
				RELEASE(pUncompressed);
			}
		}
	} else {
		if(Contact()->OpenProperty(PR_BODY, &IID_IStream, 0, MAPI_MODIFY | MAPI_CREATE, 
																(LPUNKNOWN*)&pStream) == S_OK) 
			hr = pStream->Write(szNotes, (nLen+1)*sizeof(TCHAR), NULL);
	}
	RELEASE(pStream);
	return (hr == S_OK);
#endif
}
Esempio n. 2
0
bool AddresseeEdit::parse(std::vector<Contact>& contacts) const
{
  typedef boost::tokenizer<boost::escaped_list_separator<wchar_t>,
                           std::wstring::const_iterator, std::wstring>
    CsvTokenizer;

  std::wstring t = text();
  CsvTokenizer tok(t);
  
  for (CsvTokenizer::iterator i = tok.begin(); i != tok.end(); ++i) {
    std::wstring addressee = *i;

    boost::trim(addressee);
    std::wstring::size_type pos = addressee.find_last_of(' ');
    if (pos != std::string::npos) {
      std::wstring email = addressee.substr(pos + 1);
      std::wstring name = addressee.substr(0, pos);

      boost::trim(email);
      boost::trim(name);
      if (email[0] == '<')
	email = email.substr(1);
      if (email[email.length() - 1] == '>')
	email = email.substr(0, email.length() - 1);

      if (!email.empty())
	contacts.push_back(Contact(name, email));
    } else
      if (!addressee.empty())
	contacts.push_back(Contact(L"", addressee));
  }
  return true;
}
Esempio n. 3
0
Contact
World::find_entity_by_ray(const Ray ray) const
{
  assert(m_impl && m_impl->world_instance_id);
  auto world = Core_detail::world_index_get_world_data(m_impl->world_instance_id);

  Data::Physics::Physics_data *phys = world->physics;
  
  uint32_t contacts = 0;
  Data::Physics::Contact contact;
  
  Data::Physics::world_find_with_ray(
    phys,
    ray.get_origin(),
    math::vec3_scale(
      ray.get_direction(),
      ray.get_distance()
    ),
    &contact,
    1,
    &contacts
  );
  
  if(contacts)
  {
    return to_core_contact(&contact);
  }
  
  return Contact();
}
Esempio n. 4
0
void C4Object::TargetBounds(C4Real &ctco, int32_t limit_low, int32_t limit_hi, int32_t cnat_low, int32_t cnat_hi)
{
	switch (ForceLimits(ctco,limit_low,limit_hi))
	{
	case -1:
		// stop
		if (cnat_low==CNAT_Left) xdir=0; else ydir=0;
		// do calls
		Contact(cnat_low);
		break;
	case +1:
		// stop
		if (cnat_hi==CNAT_Right) xdir=0; else ydir=0;
		// do calls
		Contact(cnat_hi);
		break;
	}
}
void ContactManager::AddPair(Fixture *A, Fixture *B) {	
	Vector2 pt, norml;
	float sep;
	if ( FindOverlap(A->GetShape(), A->GetBody()->position, B->GetShape(), B->GetBody()->position, norml, pt, sep) ) {
		assert( A->GetBody() !=  B->GetBody() );
		contacts[numContacts] = Contact(A, B, norml, pt, sep);
		numContacts++;
		assert(numContacts < MaxNumContacts);
	}
}
boost::optional<Contact>
NarrowPhaseCollisionDetector::object_vs_world(NormalPhysicsObject& object) const
{
	const Vector3d& previousPos = object.previous_position() ? *object.previous_position() : object.position();
	const Vector3d& pos = object.position();

	int mapIndex = m_boundsManager->lookup_bounds_index(object.bounds_group(), object.posture());
	OnionUtil::Transition transition = OnionUtil::find_first_transition(mapIndex, previousPos, pos, m_tree);

	switch(transition.classifier)
	{
		case OnionUtil::RAY_EMPTY:
		{
			// The object's movement lies entirely in empty space, so there's no collision.
			return boost::none;
		}
		case OnionUtil::RAY_SOLID:
		{
			Vector3d dir = pos - previousPos;
			if(dir.length_squared() >= EPSILON*EPSILON)
			{
				dir.normalize();
				transition = OnionUtil::find_first_transition(mapIndex, previousPos - dir * 0.1, pos, m_tree);

				// If we still haven't found a transition, there's probably no collision to handle.
				// If we have, fall through to the next case.
				if(transition.classifier != OnionUtil::RAY_TRANSITION_ES) return boost::none;
			}
			else return boost::none;
		}
		case OnionUtil::RAY_TRANSITION_ES:
		{
			const Vector3d& contactPoint = *transition.location;
			const Vector3d& contactNormal = transition.plane->normal();

			// Calculate the intersection time (as a number in [0,1]).
			double contactDistSquared = (contactPoint - previousPos).length_squared();
			double moveDistSquared = (pos - previousPos).length_squared();
			assert(moveDistSquared > 0);
			double time = sqrt(contactDistSquared / moveDistSquared);

			return Contact(Vector3d(0,0,0), contactPoint, contactNormal, time, object, mapIndex);
		}
		case OnionUtil::RAY_TRANSITION_SE:
		{
			// This should never happen (since objects can't move into walls), but better let the object back into
			// the world if it does happen.
			return boost::none;
		}
		default:
		{
			throw Exception("This will never happen as the case statement is exhaustive");
		}
	}
}
std::list<Contact> GetSpecContacts( Circle * pCirc, OBB * pOBB )
{
	vec2 b_pos = pOBB->WorldSpaceClamp( pCirc->v2Center );
	vec2 n = glm::normalize( b_pos - pCirc->v2Center );
	vec2 a_pos = pCirc->v2Center + n * pCirc->circData.fRadius;
	
	float fDist = glm::dot( b_pos - a_pos, n );
	
	// Construct and return
	return{ Contact( pCirc, pOBB, a_pos, b_pos, n, fDist ) };
}
Esempio n. 8
0
SICONOS_EXPORT void h0(unsigned int sizeOfq, const double* q, unsigned int sizeOfY, double* y, unsigned int sizeZ, double* z)
{
  unsigned int i;
  double CC[69];

  Contact(CC, q);

  for (i = 0; i < sizeOfY; i++)
    y[i] = CC[sizeOfY + i];

}
boost::optional<Contact>
NarrowPhaseCollisionDetector::convert_to_world_contact(const boost::optional<Contact>& relativeContact) const
{
	if(!relativeContact) return boost::none;
	const Contact& rc = *relativeContact;

	// This makes the relative point on B relative to the centre of B rather than to the centre of A.
	return Contact(rc.relative_pointA(),
				   rc.relative_pointB() + rc.objectA().position() - rc.objectB()->position(),
				   rc.normal(), rc.time(), rc.objectA(), rc.map_indexA(), rc.objectB(), rc.map_indexB());
}
Esempio n. 10
0
Contact getContact(){
	string name, number;
	cout << "Please enter the 'Name' of the contact you'd like to enter(case sensitive):";
	cin >> name;
	cout << endl;
	
	cout << "Please enter the 'Number' of the contact you'd like to enter:";
	cin >> number;
	cout << endl;
	return Contact(name,number);
}
Esempio n. 11
0
bool MAPIContact::SetAnniversary(const Time &tm) {
	SYSTEMTIME st;
	MAPIEx::SetSystemTime(st, tm);
	
#ifdef _WIN32_WCE
	return m_pPOOM ? m_pPOOM->SetDate(m_pContact, PR_WEDDING_ANNIVERSARY,tmAnniversary) : false;
#else
	SPropValue prop;
	prop.ulPropTag = PR_WEDDING_ANNIVERSARY;
	SystemTimeToFileTime(&st, &prop.Value.ft);
	return (Contact()->SetProps(1, &prop, NULL) == S_OK);
#endif
}
Esempio n. 12
0
Contact Contact::Builder::build() {
	return Contact(firstname,
                   lastname,
                   nickname,
                   login,
                   postaladdr,
                   emailaddr,
                   phonenbr,
                   birthdaydate,
                   favoritemeal,
                   underwearcol,
                   darkestsecret);
}
Esempio n. 13
0
bool MAPIContact::SetBirthday(const Time &tm) {
	SYSTEMTIME st;
	MAPIEx::SetSystemTime(st, tm);
	
#ifdef _WIN32_WCE
	return m_pPOOM ? m_pPOOM->SetDate(m_pContact, PR_BIRTHDAY, st) : false;
#else
	SPropValue prop;
	prop.ulPropTag = PR_BIRTHDAY;
	SystemTimeToFileTime(&st, &prop.Value.ft);
	return (Contact()->SetProps(1, &prop, NULL) == S_OK);
#endif
}
Esempio n. 14
0
void MergeSort::merge(Data *data, int first, int middle, int last, int (*compar)(Contact&, Contact&)) {
    int n1 = middle - first + 1; //length of left array
    int n2 = last - middle; //length of right array
    vector<Contact> L (n1 + 1, Contact("", "", 0)); //initialize vector of dummy Contacts
    vector<Contact> R (n2 + 1, Contact("", "", 0)); //initialize vector of dummy Contacts
    for (int i = 0; i < n1; i++) { //copy left Contacts into left vector
      L[i] = data->array[first+i];
    }
    for (int j = 0; j < n2; j++) { //copy right Contacts into right vector
      R[j] = data->array[middle+1+j];
    }

    L[n1] = Contact("zzzz", "address", 99999); //last value equal to high value to be sentinel value
    R[n2] = Contact("zzzz", "address", 99999);

    vector<Contact> A ((last - first) + 1, Contact("", "", 0)); //initialize vector to hold sorted array
    int i = 0;
    int j = 0;

    for (int k = 0; k < (last - first) + 1; k++) { //merge them back      
      if (compar( L[i], R[j]) <= 0) { //if L[i] is smaller or equal       
        A[k] = L[i];        
        i++;       
      }
      else {
        A[k] = R[j];
        j++;        
      }
    }

    int m = 0;

    for (int n = first; n < last + 1; n++) {//copy back to array
      data->array[n] = A[m];
      m++;
    }
    return;
}
Esempio n. 15
0
AddressBookModel::AddressBookModel( QObject* parent, bts::addressbook::addressbook_ptr abook )
    :QAbstractTableModel(parent),my( new Detail::AddressBookModelImpl() )
{
    my->_abook = abook;
    my->_default_icon.addFile(QStringLiteral(":/images/user.png"), QSize(), QIcon::Normal, QIcon::Off);

    const std::unordered_map<uint32_t,bts::addressbook::wallet_contact>& loaded_contacts = abook->get_contacts();
    my->_contacts.reserve( loaded_contacts.size() );
    for( auto itr = loaded_contacts.begin(); itr != loaded_contacts.end(); ++itr )
    {
        ilog( "loading contacts..." );
        my->_contacts.push_back( Contact(itr->second) );
    }
}
Esempio n. 16
0
Contact MySqlStorage::getContact(QString jid, QString contactJid)
{
    QSqlQuery query;
    query.prepare("SELECT version, approved, ask, jid, name, subscription, groups FROM qjabberd_contact WHERE user_id = :user_id AND jid = :jid");
    query.bindValue(":user_id", getUserId(jid));
    query.bindValue(":jid", contactJid);
    query.exec();

    if (query.first())
    {
        return Contact(query.value(0).toString(),
                       query.value(1).toBool(),
                       query.value(2).toString(),
                       query.value(3).toString(),
                       query.value(4).toString(),
                       query.value(5).toString(),
                       QJsonDocument::fromJson(query.value(6).toByteArray()).object().value("groups").toVariant().toStringList().toSet());
    }
    else
    {
        return Contact();
    }
}
Esempio n. 17
0
// Categories are stored under the multi-value named property CATEGORIES_PROPERTY
// Pass in a string of semicolon separated category names
bool MAPIContact::SetCategories(const String &szCategories) {
#ifdef _WIN32_WCE
	return SetPropertyString(OUTLOOK_CATEGORIES, szCategories);
#else
	String strCategories = szCategories;
	int nCount = 0;
	if (!strCategories.IsEmpty())
		nCount++;
	int nIndex = 0;
	String strCategory = Tokenize2(strCategories, ";", nIndex);
	while(strCategory.IsEmpty() && !IsNull(nIndex)) {
		nCount++;
		strCategory = Tokenize2(strCategories, ";", nIndex);
	}

	HRESULT hr = E_FAIL;
	if(!nCount) {
		if(DeleteNamedProperty(CATEGORIES_PROPERTY)) 
			return true;
	} else {
		LPTSTR* arCategories = new LPTSTR[nCount];

		nCount = 0;
		nIndex = 0;
		int nLen = 0;
		strCategory = Tokenize2(strCategories, ";", nIndex);		
		do {
			nLen = strCategory.GetLength();
			if(nLen > 0) {
				arCategories[nCount] = new TCHAR[nLen+1];
				memcpy(arCategories[nCount], (LPCTSTR)strCategory, nLen*sizeof(TCHAR));
				arCategories[nCount++][nLen] = (TCHAR)0;
				strCategory = Tokenize2(strCategories, ";", nIndex);		
			}
		} while(nLen && !IsNull(nIndex));

		LPSPropValue pProp;
		if(SetNamedMVProperty(CATEGORIES_PROPERTY, (LPCTSTR*)arCategories, nCount, pProp)) {
			hr=Contact()->SetProps(1, pProp, NULL);
			MAPIFreeBuffer(pProp);
		}

		for(nIndex=0; nIndex < nCount; nIndex++) 
			delete [] arCategories[nIndex];
		delete [] arCategories;
	}
	return (hr == S_OK);
#endif
}
Esempio n. 18
0
void AddressBookModel::reloadContacts()
{
  const std::unordered_map<uint32_t, bts::addressbook::wallet_contact>& loaded_contacts =
    my->_address_book->get_contacts();
  my->_contacts.clear();
  my->_contacts.reserve(loaded_contacts.size() );

  for (auto itr = loaded_contacts.begin(); itr != loaded_contacts.end(); ++itr)
  {
    auto contact = itr->second;
    ilog("loading contacts...");
    my->_contacts.push_back(Contact(contact) );
  }
  std::sort( my->_contacts.begin(), my->_contacts.end());
}
Esempio n. 19
0
QList<Contact> Contacts::getContactsFromPhone(){
   QPointer<QContactManager> contactManager = new QContactManager();
   // QStringList QContactManager::supportedContactTypes ()
   QList<QContact> contactsPhone = contactManager->contacts();
   QList<Contact> contacts;
   foreach (const QContact& contact, contactsPhone) {
       QContactPhoneNumber phoneNumber = contact.detail<QContactPhoneNumber>();
       //  QList<QContactPhoneNumber> phoneNumbers = contact.details<QContactPhoneNumber>();
       if(!phoneNumber.isEmpty()){
           QContactName name = contact.detail<QContactName>();
           QString number = phoneNumber.number();
           number = number.replace("+","");
           QString nameFinal = name.firstName()+" "+name.lastName();
           contacts.append(Contact(nameFinal.trimmed(),number));
       }
   }
Esempio n. 20
0
QList<Contact> MySqlStorage::getContactsList(QString jid)
{
    QList<Contact> contactList;
    QSqlQuery query;
    query.prepare("SELECT version, approved, ask, jid, name, subscription, groups"
                  " FROM qjabberd_contact WHERE user_id = :user_id");
    query.bindValue(":user_id", getUserId(jid));
    query.exec();
    while (query.next())
    {
        contactList << Contact(query.value(0).toString(), query.value(1).toBool(), query.value(2).toString(),
                               query.value(3).toString(), query.value(4).toString(), query.value(5).toString(),
                               QJsonDocument::fromJson(query.value(6).toByteArray()).object().value("groups").toVariant().toStringList().toSet());
    }
    return contactList;
}
Esempio n. 21
0
    size_t collide(CircleShape &circle, BoxShape &box, float dt, Contact *pxContacts, size_t numMaxContacts)
    {
        dt, pxContacts, numMaxContacts;
        const Point2f &p1 = circle.body.getPosition();
        const Point2f &p2 = box.body.getPosition();

        // work in the box's coordinate system
        const Point2f kDiff = p1 - p2;

        // compute squared distance and closest point on box
        float fSqrDistance = 0.0f, fDelta;
        Point2f kClosest(kDiff * box.GetDir(0), kDiff * box.GetDir(1));
        const Point2f &extents = box.GetExtents();
        if (kClosest.x < -extents.x)
        {
            fDelta = kClosest.x + extents.x;
            fSqrDistance += fDelta*fDelta;
            kClosest.x = -extents.x;
        }
        else if (kClosest.x > extents.x)
        {
            fDelta = kClosest.x - extents.x;
            fSqrDistance += fDelta*fDelta;
            kClosest.x = extents.x;
        }
        if (kClosest.y < -extents.y)
        {
            fDelta = kClosest.y + extents.y;
            fSqrDistance += fDelta*fDelta;
            kClosest.y = -extents.y;
        }
        else if (kClosest.y > extents.y)
        {
            fDelta = kClosest.y - extents.y;
            fSqrDistance += fDelta*fDelta;
            kClosest.y = extents.y;
        }
        if (fSqrDistance > circle.GetRadius() * circle.GetRadius())
        {
            return 0;
        }
        Point2f d = p2 + kClosest - p1;
        d.Normalize();

        pxContacts[0] = Contact(p1 + d * circle.GetRadius(), p2 + kClosest, &circle.body, &box.body);
        return 1;
    }
Contact NarrowPhaseCollisionDetector::make_contact(const Vector3d& v0, const SupportMapping_CPtr& mappingA,
												   const SupportMapping_CPtr& mappingB, const Vector3d& relativeMovement,
												   PhysicsObject& objectA, PhysicsObject& objectB) const
{
	Vector3d contactNormal = (-v0).normalize();
	Vector3d contactPointA = (*mappingA)(-contactNormal);
	Vector3d contactPointB = (*mappingB)(contactNormal);
	double penetrationDepth = (contactPointB - contactPointA).dot(contactNormal);
	assert(penetrationDepth > 0);
	double contactDistanceMoved = relativeMovement.dot(contactNormal);
	double time = contactDistanceMoved > 0 ? 1 - penetrationDepth/contactDistanceMoved : 0;
	NormalPhysicsObject *nobjectA = dynamic_cast<NormalPhysicsObject*>(&objectA);
	NormalPhysicsObject *nobjectB = dynamic_cast<NormalPhysicsObject*>(&objectB);
	int mapIndexA = nobjectA ? m_boundsManager->lookup_bounds_index(nobjectA->bounds_group(), nobjectA->posture()) : -1;
	int mapIndexB = nobjectB ? m_boundsManager->lookup_bounds_index(nobjectB->bounds_group(), nobjectB->posture()) : -1;
	return Contact(contactPointA, contactPointB, contactNormal, time, objectA, mapIndexA, objectB, mapIndexB);
}
void KeyhoteeMainWindow::addContact()
{
  if (checkSaving())
  {
      connect(ui->new_contact, &ContactView::savedNewContact, this, &KeyhoteeMainWindow::onSavedNewContact);
      connect(ui->new_contact, &ContactView::savedNewContact, ui->contacts_page, &ContactsTable::onSavedNewContact);
      connect(ui->new_contact, &ContactView::canceledNewContact, this, &KeyhoteeMainWindow::onCanceledNewContact);
      connect(ui->new_contact, &ContactView::canceledNewContact, ui->contacts_page, &ContactsTable::onCanceledNewContact);

      enableMenu(false);
      ui->new_contact->setAddingNewContact(true);
      ui->new_contact->setContact(Contact());    
      ui->contacts_page->addNewContact(*ui->new_contact);
      ui->widget_stack->setCurrentWidget(ui->contacts_page);
      //ui->widget_stack->setCurrentWidget( ui->new_contact);
  }
}
Esempio n. 24
0
int32_t C4Object::ContactCheck(int32_t iAtX, int32_t iAtY, uint32_t *border_hack_contacts, bool collide_halfvehic)
{
	// Check shape contact at given position
	Shape.ContactCheck(iAtX,iAtY,border_hack_contacts,collide_halfvehic);

	// Store shape contact values in object t_contact
	t_contact=Shape.ContactCNAT;

	// Contact script call for the first contacted cnat
	if (Shape.ContactCNAT)
		for (int32_t ccnat=0; ccnat<4; ccnat++) // Left, right, top bottom
			if (Shape.ContactCNAT & (1<<ccnat))
				if (Contact(1<<ccnat))
					break; // Will stop on first positive return contact call!

	// Return shape contact count
	return Shape.ContactCount;
}
Esempio n. 25
0
    size_t collide(CircleShape &circle1, CircleShape &circle2, float dt, Contact *pxContacts, size_t numMaxContacts)
    {
        dt, numMaxContacts;

        float rR = circle1.GetRadius() + circle2.GetRadius();
        const Point2f &p1 = circle1.body.getPosition();
        const Point2f &p2 = circle2.body.getPosition();
        Point2f d = p2 - p1;
        float len = d.Length();
        if (len > rR)
        {
            return 0;
        }
        d.Normalize();
        
        pxContacts[0] = Contact(p1 + d * circle1.GetRadius(), p1 + d * (len - circle1.GetRadius()), &circle1.body, &circle2.body);
        return 1;
    }
Esempio n. 26
0
void KeyhoteeMainWindow::addContact()
{
   /*
   EditContactDialog* editcon = new EditContactDialog(this);
   editcon->show();
   connect( editcon, &QDialog::finished, [=]( int result ){
        if( result == QDialog::Accepted )
        {
           auto app    = bts::application::instance();
           auto profile    = app->get_profile();
           auto abook  = profile->get_addressbook();
           abook->store_contact( editcon->getContact() );
        }
        editcon->deleteLater();
     });
   */
  ui->new_contact->setContact( Contact(), ContactView::edit );
  ui->widget_stack->setCurrentWidget( ui->new_contact );
}
Esempio n. 27
0
std::list<Contact> GetSpecContacts( Circle * pA, Circle * pB )
{
	// find and normalize distance
	vec2 d = pB->v2Center - pA->v2Center;
	vec2 n = glm::normalize( d );

	// contact points along circumference
	vec2 a_pos = pA->v2Center + n * pA->Radius();
	vec2 b_pos = pB->v2Center - n * pB->Radius();

	// distance between circumferences
	float dist = glm::length( a_pos - b_pos );

	if ( IsOverlapping( pA, pB ) )
	{
		dist = -dist;
		// std::cout << "Negating circle dist" << std::endl;
	}

	// Construct and return
	return{ Contact( pA, pB, a_pos, b_pos, n, dist ) };
}
Esempio n. 28
0
int DumpContactCommand::Execute() {
  Networks networks(*config()->config());
  if (!networks.IsInitialized()) {
    LOG(ERROR) << "Unable to load networks.";
    return 1;
  }

  map<const string, Contact> contacts;
  for (const auto net : networks.networks()) {
    string lower_case_network_name(net.name);
    StringLowerCase(&lower_case_network_name);
    contacts.emplace(lower_case_network_name, Contact(net.dir, false));
  }

  for (const auto& c : contacts) {
    cout << "CONTACT.NET information: : " << c.first << endl;
    cout << "===========================================================" << endl;
    cout << c.second.ToString() << endl;
  }

  return 0;
}
Esempio n. 29
0
void C4Object::StopAndContact(C4Real & ctco, C4Real limit, C4Real & speed, int32_t cnat)
{
	ctco = limit;
	speed = 0;
	Contact(cnat);
}
Esempio n. 30
0
ContactView::ContactView(QWidget* parent)
  : QWidget(parent),
  ui(new Ui::ContactView() ),
  _validForm(false)
{
  _address_book = nullptr;  
  ui->setupUi(this);
  _addingNewContact = false;
  _editing = false;
  _modified = false;

   message_tools = new QToolBar( ui->toolbar_container );
  QGridLayout* grid_layout = new QGridLayout(ui->toolbar_container);
  grid_layout->setContentsMargins(0, 0, 0, 0);
  grid_layout->setSpacing(0);
  ui->toolbar_container->setLayout(grid_layout);
  grid_layout->addWidget(message_tools, 0, 0);
  ui->email->setVisible (false);              //unsupported
  ui->phone->setVisible (false);
  ui->phone_label->setVisible (false);
  ui->email_label->setVisible (false);
  ui->privacy_comboBox->setVisible (false);
  ui->privacy_level_label->setVisible (false);//unsupported
  //default contact view: info page
  ui->contact_pages->setCurrentIndex(info);
  
  /// add identity observer
  IdentityObservable::getInstance().addObserver( ui->widget_Identity );

  send_mail = new QAction( QIcon( ":/images/128x128/contact_info_send_mail.png"), tr("Mail"), this);
  chat_contact = new QAction( QIcon( ":/images/chat.png"), tr("Chat"), this);  
  edit_contact = new QAction( QIcon(":/images/128x128/contact_info_edit.png"), tr("Edit"), this);
  share_contact = new QAction(QIcon(":/images/128x128/contact_share.png"), tr("Share contact"), this);
  request_contact = new QAction( QIcon(":/images/128x128/contact_info_request_authorisation.png"), tr("Request authorisation"), this);
  save_contact = new QAction( QIcon(":/images/128x128/contact_info_save.png"), tr( "Save"), this );
  cancel_edit_contact = new QAction( QIcon(":/images/128x128/contact_info_cancel_edit.png"), tr("Discard changes"), this);
  connect(ui->icon_view, &QToolButton::clicked, this, &ContactView::onIconSearch);

  message_tools->addAction(send_mail);  
  message_tools->addAction(chat_contact);
  message_tools->addAction(share_contact);
  message_tools->addAction(request_contact);
  separatorToolBar = message_tools->addSeparator ();
  message_tools->addAction(edit_contact);
  message_tools->addAction(save_contact);  
  message_tools->addAction(cancel_edit_contact);

  QLabel *label = new QLabel((tr("     Create new contact")));
  label_createContact = message_tools->addWidget (label);
  QFont font;  
  font.setBold(true);
  font.setPointSize (16);
  label->setFont (font);

  ui->khid_pubkey->setMode(KeyhoteeIDPubKeyWidget::ModeWidget::ShowContact);

  connect(save_contact, &QAction::triggered, this, &ContactView::onSave);
  connect(cancel_edit_contact, &QAction::triggered, this, &ContactView::onCancel);
  connect(edit_contact, &QAction::triggered, this, &ContactView::onEdit);
  connect(send_mail, &QAction::triggered, this, &ContactView::onMail);
  connect(chat_contact, &QAction::triggered, this, &ContactView::onChat);
  connect(share_contact, &QAction::triggered, this, &ContactView::onShareContact);
  connect(request_contact, &QAction::triggered, this, &ContactView::onRequestContact);

  connect(ui->firstname, &QLineEdit::textChanged, this, &ContactView::firstNameChanged);
  connect(ui->lastname, &QLineEdit::textChanged, this, &ContactView::lastNameChanged);
  connect( ui->privacy_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(privacyLevelChanged(int)));
  connect(ui->email, &QLineEdit::textChanged, this, &ContactView::emailChanged);
  connect(ui->phone, &QLineEdit::textChanged, this, &ContactView::phoneChanged);
  connect(ui->notes, &QPlainTextEdit::textChanged, this, &ContactView::notesChanged);
  connect(ui->sendButton, &QPushButton::clicked, this, &ContactView::onSend);
  connect(ui->chat_input, &QPlainTextEdit::textChanged, this, &ContactView::onTextChanged);

  connect(ui->contact_pages, &QTabWidget::currentChanged, this, &ContactView::currentTabChanged);

  connect(ui->mining_effort_slider, &QSlider::valueChanged, this, &ContactView::onMiningEffortSliderChanged);
  connect(ui->khid_pubkey, &KeyhoteeIDPubKeyWidget::currentState, this, &ContactView::onStateWidget);

  contactEditable(false);
  ui->chat_input->installEventFilter(this);

  checkSendMailButton();
  setContact(Contact() );
}