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
84
85
86
87
88
|
#include "skype.h"
LIST<CSkypeProto> CSkypeProto::instanceList(1, CSkypeProto::CompareProtos);
int CSkypeProto::CompareProtos(const CSkypeProto *p1, const CSkypeProto *p2)
{
return wcscmp(p1->m_tszUserName, p2->m_tszUserName);
}
CSkypeProto* CSkypeProto::InitSkypeProto(const char* protoName, const wchar_t* userName)
{
if (CSkypeProto::instanceList.getCount() > 0)
{
CSkypeProto::ShowNotification(
::TranslateT("SkypeKit will only permit you to login to one account at a time.\nAdding multiple instances of SkypeKit is prohibited in the licence agreement and standard distribution terms."),
MB_ICONERROR);
return NULL;
}
CSkypeProto *ppro = new CSkypeProto(protoName, userName);
VARST profilename( _T("%miranda_profilename%"));
if ( !ppro->StartSkypeRuntime((TCHAR *)profilename))
{
CSkypeProto::ShowNotification(::TranslateT("Did not unpack SkypeKit.exe."), MB_ICONERROR);
return NULL;
}
char *keyPair = ppro->LoadKeyPair();
if (keyPair == NULL)
{
CSkypeProto::ShowNotification(::TranslateT("Initialization key corrupted or not valid."), MB_ICONERROR);
return NULL;
}
TransportInterface::Status status = ppro->init(keyPair, "127.0.0.1", ppro->skypeKitPort, 0, 1);
if (status != TransportInterface::OK)
{
wchar_t message[256];
::mir_sntprintf(message, SIZEOF(message), ::TranslateT("SkypeKit did not initialize (%d)."), status);
CSkypeProto::ShowNotification(message, MB_ICONERROR);
return NULL;
}
if ( !ppro->start())
{
CSkypeProto::ShowNotification(TranslateT("SkypeKit did not start."), MB_ICONERROR);
return NULL;
}
::mir_free(keyPair);
CSkypeProto::instanceList.insert(ppro);
return ppro;
}
int CSkypeProto::UninitSkypeProto(CSkypeProto* ppro)
{
ppro->stop();
ppro->StopSkypeRuntime();
CSkypeProto::instanceList.remove(ppro);
delete ppro;
return 0;
}
void CSkypeProto::UninitInstances()
{
instanceList.destroy();
}
CSkypeProto* CSkypeProto::GetContactInstance(HANDLE hContact)
{
char *proto = (char *)::CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
if (proto == NULL)
return NULL;
for (int i = 0; i < CSkypeProto::instanceList.getCount(); i++)
if ( !::strcmp(proto, CSkypeProto::instanceList[i]->m_szModuleName))
return CSkypeProto::instanceList[i];
return NULL;
}
|