summaryrefslogtreecommitdiff
path: root/protocols/Skype/src/skypekit/contact.cpp
blob: 622023a040615e11088a63914fe545f20efbb8e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "..\skype.h"
#include "contact.h"

CContact::CContact(unsigned int oid, CSkypeProto* _ppro) :
	Contact(oid, _ppro),
	proto(_ppro)
{
}

SEString CContact::GetSid()
{
	SEString result;
	CContact::AVAILABILITY availability;
	this->GetPropAvailability(availability);
	if (availability == CContact::SKYPEOUT)
		this->GetPropPstnnumber(result);
	else
		this->GetPropSkypename(result);
	return result;
}

SEString CContact::GetNick()
{
	SEString result;
	CContact::AVAILABILITY availability;
	this->GetPropAvailability(availability);
	if (availability == CContact::SKYPEOUT)
		this->GetPropPstnnumber(result);
	else
	{
		this->GetPropDisplayname(result);
		if (this->proto && this->proto->login)
		{
			SEString sid;
			this->GetIdentity(sid);
			if (sid.equals(result))
				this->GetPropFullname(result);
		}
	}
	return result;
}

bool CContact::GetFullname(SEString &firstName, SEString &lastName)
{
	SEString fullname;
	this->GetPropFullname(fullname);
	int pos = fullname.find(" ");
	if (pos != -1)
	{
		firstName = fullname.substr(0, pos - 1);
		lastName = fullname.right((int)fullname.size() - pos - 1);
	} else
		firstName = fullname;
	
	return true;
}

void CContact::OnChange(int prop)
{
	proto->OnContactChanged(this->ref(), prop);
}