summaryrefslogtreecommitdiff
path: root/protocols/Skype/src/skypekit/contact.cpp
blob: c7a1a3247ddd8b6269413b0db7c8a4519100e126 (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
62
63
64
65
#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 == Contact::SKYPEOUT || availability == Contact::BLOCKED_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
	{
		SEString sid;
		this->GetIdentity(sid);

		this->GetPropDisplayname(result);
		if (this->proto && this->proto->login)
		{
			if (sid.equals(result))
				this->GetPropFullname(result);
		}

		if (result.size() == 0)
			result = sid;
	}
	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);
}