diff options
Diffstat (limited to 'protocols/Tox/src')
| -rw-r--r-- | protocols/Tox/src/tox_contacts.cpp | 10 | ||||
| -rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 12 | 
2 files changed, 14 insertions, 8 deletions
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index 26159350ae..e148a6ef9a 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -97,7 +97,7 @@ MCONTACT CToxProto::AddContact(const std::vector<uint8_t> &id, bool isTemporary)  		hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
  		CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName);
 -		db_set_blob(hContact, m_szModuleName, TOX_SETTINGS_ID, (uint8_t*)id.data(), TOX_CLIENT_ID_SIZE);
 +		db_set_blob(hContact, m_szModuleName, TOX_SETTINGS_ID, (uint8_t*)id.data(), id.size());
  		setByte(hContact, "Auth", 1);
  		DBVARIANT dbv;
 @@ -154,10 +154,10 @@ void CToxProto::LoadFriendList()  int CToxProto::OnContactDeleted(MCONTACT hContact, LPARAM lParam)
  {
 -	if (hContact)
 +	if (hContact && IsOnline())
  	{
  		DBVARIANT dbv;
 -		std::vector<uint8_t> id;
 +		std::vector<uint8_t> id(TOX_CLIENT_ID_SIZE);
  		if (!db_get(hContact, m_szModuleName, TOX_SETTINGS_ID, &dbv))
  		{
  			if (dbv.type != DBVT_BLOB)
 @@ -186,10 +186,10 @@ void CToxProto::OnFriendRequest(Tox *tox, const uint8_t *address, const uint8_t  	CToxProto *proto = (CToxProto*)arg;
  	// trim tox address to tox id
 -	std::vector<uint8_t> clientId(address, address + TOX_CLIENT_ID_SIZE);
 +	std::vector<uint8_t> clientId(address, address + TOX_FRIEND_ADDRESS_SIZE);
  	std::string id = proto->DataToHexString(clientId);
 -	MCONTACT hContact = proto->AddContact(clientId, true);
 +	MCONTACT hContact = proto->AddContact(clientId);
  	PROTORECVEVENT pre = { 0 };
  	pre.flags = PREF_UTF;
 diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 4bd9ca4efc..33f05487ed 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -83,7 +83,10 @@ MCONTACT __cdecl CToxProto::AddToList(int flags, PROTOSEARCHRESULT* psr)  	return AddContact(id, flags & PALF_TEMPORARY);
  }
 -MCONTACT __cdecl CToxProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEvent) { return 0; }
 +MCONTACT __cdecl CToxProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEvent)
 +{
 +	return 0;
 +}
  int __cdecl CToxProto::Authorize(HANDLE hDbEvent)
  {
 @@ -96,10 +99,13 @@ int __cdecl CToxProto::Authorize(HANDLE hDbEvent)  		}
  		DBVARIANT dbv;
 -		if (!db_get(NULL, m_szModuleName, TOX_SETTINGS_ID, &dbv))
 +		if (!db_get(hContact, m_szModuleName, TOX_SETTINGS_ID, &dbv))
  		{
 -			if (tox_add_friend_norequest(tox, (uint8_t*)dbv.pbVal) != TOX_ERROR)
 +			std::vector<uint8_t> id(TOX_CLIENT_ID_SIZE);
 +			memcpy(&id[0], dbv.pbVal, TOX_CLIENT_ID_SIZE);
 +			if (tox_add_friend_norequest(tox, id.data()) != TOX_ERROR)
  			{
 +				db_unset(hContact, m_szModuleName, "Auth");
  				SaveToxData();
  				db_free(&dbv);
  				return 0;
  | 
