summaryrefslogtreecommitdiff
path: root/protocols/Skype/src/skype_subclassing.cpp
blob: bb943a708e0b3065ac376005c1f2e07a11421ac3 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "skype_subclassing.h"

CAccount* CSkype::newAccount(int oid) 
{ 
	return new CAccount(oid, this); 
}

CContactGroup* CSkype::newContactGroup(int oid)
{ 
	return new CContactGroup(oid, this); 
}

CContact* CSkype::newContact(int oid) 
{ 
	return new CContact(oid, this); 
}

CAccount::CAccount(unsigned int oid, SERootObject* root) : Account(oid, root) 
{
	this->isLoggedOut = true;
}

void CAccount::OnChange(int prop)
{
  if (prop == CAccount::P_STATUS)
  {
	  CAccount::STATUS loginStatus;
	  this->GetPropStatus(loginStatus);
	  if (loginStatus == CAccount::LOGGED_IN)  
		  this->isLoggedOut = false;
		
		if (loginStatus == CAccount::LOGGED_OUT) 
		{ 
			this->isLoggedOut = true; 
			CAccount::LOGOUTREASON whyLogout;
			this->GetPropLogoutreason(whyLogout);
			if (whyLogout != Account::LOGOUT_CALLED)
			{
				printf("%s\n", (const char*)tostring(whyLogout));
			}
		}
	}

}

void CAccount::BlockWhileLoggingIn()
{
  while (this->isLoggedOut) 
	  Sleep(1); 
}

void CAccount::BlockWhileLoggingOut()
{
  while ( !this->isLoggedOut) 
	  Sleep(1);
}

CContactGroup::CContactGroup(unsigned int oid, SERootObject* root) : ContactGroup(oid, root) 
{
}

void CContactGroup::OnChange(const ContactRef& contact)
{
}


CContact::CContact(unsigned int oid, SERootObject* root) : Contact(oid, root) 
{
	this->proto = NULL;
	this->callback == NULL;
}

void CContact::SetOnContactChangeCallback(OnContactChangeFunc callback, CSkypeProto* proto)
{
	this->proto = proto;
	this->callback = callback;
}

void CContact::OnChange(int prop)
{
	if (this->callback && this->proto)
		(proto->*callback)(this, prop);
}