summaryrefslogtreecommitdiff
path: root/protocols/Skype
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Skype')
-rw-r--r--protocols/Skype/Skype.vcxproj1
-rw-r--r--protocols/Skype/Skype.vcxproj.filters3
-rw-r--r--protocols/Skype/src/skype.cpp8
-rw-r--r--protocols/Skype/src/skype.h31
-rw-r--r--protocols/Skype/src/skype_contacts.cpp20
-rw-r--r--protocols/Skype/src/skype_netlib.cpp34
-rw-r--r--protocols/Skype/src/skype_proto.cpp23
-rw-r--r--protocols/Skype/src/skype_proto.h24
-rw-r--r--protocols/Skype/src/skype_subclassing.cpp8
-rw-r--r--protocols/Skype/src/skype_subclassing.h20
-rw-r--r--protocols/Skype/src/skype_utils.cpp33
11 files changed, 119 insertions, 86 deletions
diff --git a/protocols/Skype/Skype.vcxproj b/protocols/Skype/Skype.vcxproj
index 26b28ff7d7..35cc7da653 100644
--- a/protocols/Skype/Skype.vcxproj
+++ b/protocols/Skype/Skype.vcxproj
@@ -109,6 +109,7 @@
<ClCompile Include="src\skype_dialogs.cpp" />
<ClCompile Include="src\skype_events.cpp" />
<ClCompile Include="src\skype_icons.cpp" />
+ <ClCompile Include="src\skype_netlib.cpp" />
<ClCompile Include="src\skype_proto.cpp" />
<ClCompile Include="src\skype_settings.cpp" />
<ClCompile Include="src\skype_subclassing.cpp" />
diff --git a/protocols/Skype/Skype.vcxproj.filters b/protocols/Skype/Skype.vcxproj.filters
index 8ad618391e..f4224aaf7b 100644
--- a/protocols/Skype/Skype.vcxproj.filters
+++ b/protocols/Skype/Skype.vcxproj.filters
@@ -39,6 +39,9 @@
<ClCompile Include="src\skype_contacts.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\skype_netlib.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\resource.h">
diff --git a/protocols/Skype/src/skype.cpp b/protocols/Skype/src/skype.cpp
index 5254eaebf0..db983a1b68 100644
--- a/protocols/Skype/src/skype.cpp
+++ b/protocols/Skype/src/skype.cpp
@@ -122,9 +122,7 @@ void StartSkypeRuntime()
if ( FindWindow(NULL, runtimePath))
- {
- port += rand() % 100;
- }
+ port += rand() % 100;
mir_sntprintf(param, SIZEOF(param), L"-p -p %d", port);
@@ -143,11 +141,11 @@ void StartSkypeRuntime()
extern "C" int __declspec(dllexport) Load(void)
{
- StartSkypeRuntime();
LoadKeyPair();
+ StartSkypeRuntime();
g_skype = new CSkype();
- g_skype->init(keyBuf, "127.0.0.1", port, "streamlog.txt");
+ g_skype->init(keyBuf, "127.0.0.1", port);
g_skype->start();
PROTOCOLDESCRIPTOR pd = { sizeof(pd) };
diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h
index c3e944cbbe..7a46bafec9 100644
--- a/protocols/Skype/src/skype.h
+++ b/protocols/Skype/src/skype.h
@@ -42,34 +42,17 @@
#include "resource.h"
#include "version.h"
-#define MODULE "Skype"
-
extern HINSTANCE g_hInstance;
-// skype
-
-//#define SSL_LIB_CYASSL
-//#define NO_FILESYSTEM
-
-// Enable desktop video
-//#define SKYPEKIT_SURFACE_RENDERING
-
-// Additional flags for desktop video for non-Windows targets
-//#define VIDEO_TRANSPORT_SYSV
-//#define VIDEO_TRANSPORT_POSIX
-
-#undef OCSP_REQUEST
-#undef OCSP_RESPONSE
-
-#include "skype_subclassing.h"
-
void IconsLoad();
-static const char* g_keyFileName = "..\\..\\..\\SkypeKit\\keypair.crt";
-
-extern CSkype* g_skype;
-
+#define MODULE "Skype"
#define SKYPE_SETTINGS_NAME "Name"
#define SKYPE_SETTINGS_STATUS "Status"
#define SKYPE_SETTINGS_LOGIN "SkypeLogin"
-#define SKYPE_SETTINGS_PASSWORD "Password" \ No newline at end of file
+#define SKYPE_SETTINGS_PASSWORD "Password"
+
+#include "skype_subclassing.h"
+
+extern CSkype* g_skype;
+static const char* g_keyFileName = "..\\..\\..\\SkypeKit\\keypair.crt"; \ No newline at end of file
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp
index 56c9b61ee1..2943e05e12 100644
--- a/protocols/Skype/src/skype_contacts.cpp
+++ b/protocols/Skype/src/skype_contacts.cpp
@@ -1,5 +1,10 @@
#include "skype_proto.h"
+
+void CSkypeProto::OnContactChanged(CContact* contact, int prop)
+{
+}
+
HANDLE CSkypeProto::GetContactBySkypeLogin(const char* skypeLogin)
{
for (HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
@@ -27,13 +32,12 @@ HANDLE CSkypeProto::GetContactBySkypeLogin(const char* skypeLogin)
void __cdecl CSkypeProto::LoadContactList(void*)
{
- CContactGroup::Ref contacts;
- g_skype->GetHardwiredContactGroup(CContactGroup::SKYPE_BUDDIES, contacts);
+ g_skype->GetHardwiredContactGroup(CContactGroup::ALL_KNOWN_CONTACTS, this->contactGroup);
- contacts->GetContacts(contacts->ContactList);
- fetch(contacts->ContactList);
+ this->contactGroup->GetContacts(this->contactGroup->ContactList);
+ fetch(this->contactGroup->ContactList);
- for (unsigned int i = 0; i < contacts->ContactList.size(); i++)
+ for (unsigned int i = 0; i < this->contactGroup->ContactList.size(); i++)
{
SEString name;
SEString skypeLogin;
@@ -41,7 +45,7 @@ void __cdecl CSkypeProto::LoadContactList(void*)
int status = ID_STATUS_OFFLINE;
CContact::AVAILABILITY availability = CContact::OFFLINE;
- contacts->ContactList[i]->GetPropSkypename(skypeLogin);
+ this->contactGroup->ContactList[i]->GetPropSkypename(skypeLogin);
printf("%3d. %s\n", i+1, (const char*)skypeLogin);
HANDLE hContact = this->GetContactBySkypeLogin(skypeLogin);
@@ -54,8 +58,8 @@ void __cdecl CSkypeProto::LoadContactList(void*)
if (CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName) == 0 )
{
- contacts->ContactList[i]->GetPropDisplayname(name);
- contacts->ContactList[i]->GetPropAvailability(availability);
+ this->contactGroup->ContactList[i]->GetPropDisplayname(name);
+ this->contactGroup->ContactList[i]->GetPropAvailability(availability);
switch (availability)
{
diff --git a/protocols/Skype/src/skype_netlib.cpp b/protocols/Skype/src/skype_netlib.cpp
new file mode 100644
index 0000000000..ece518f351
--- /dev/null
+++ b/protocols/Skype/src/skype_netlib.cpp
@@ -0,0 +1,34 @@
+#include "skype_proto.h"
+
+void CSkypeProto::InitNetLib()
+{
+ wchar_t name[128];
+ mir_sntprintf(name, SIZEOF(name), TranslateT("%s connection"), this->m_tszUserName);
+
+ NETLIBUSER nlu = {0};
+ nlu.cbSize = sizeof(nlu);
+ nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE;
+ nlu.ptszDescriptiveName = name;
+ nlu.szSettingsModule = this->m_szModuleName;
+ this->hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+
+ this->Log("Setting protocol/module name to '%s/%s'", m_szProtoName, m_szModuleName);
+}
+
+void CSkypeProto::UninitNetLib()
+{
+ Netlib_CloseHandle(this->hNetlibUser);
+ this->hNetlibUser = NULL;
+}
+
+void CSkypeProto::Log(const char* fmt, ...)
+{
+ va_list va;
+ char msg[1024];
+
+ va_start(va, fmt);
+ mir_vsnprintf(msg, sizeof(msg), fmt, va);
+ va_end(va);
+
+ CallService(MS_NETLIB_LOG, (WPARAM)this->hNetlibUser, (LPARAM)msg);
+} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index 962dce0167..33bb6e7f9e 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -13,25 +13,17 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName)
this->signin_lock = CreateMutex(0, false, 0);
this->SetAllContactStatuses(ID_STATUS_OFFLINE);
- TCHAR name[128];
- mir_sntprintf(name, SIZEOF(name), TranslateT("%s connection"), this->m_tszUserName);
+ this->InitNetLib();
- NETLIBUSER nlu = {0};
- nlu.cbSize = sizeof( nlu );
- nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_TCHAR; // | NUF_HTTPGATEWAY;
- nlu.ptszDescriptiveName = name;
- nlu.szSettingsModule = m_szModuleName;
- this->hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
-
- this->Log("Setting protocol/module name to '%s/%s'", m_szProtoName, m_szModuleName);
+ //->SetOnChangeCallback((OnContactChangeFunc)&CSkypeProto::OnContactChanged, this);
+ //.SetOnChangeCallback((OnContactChangeFunc)&CSkypeProto::OnContactChanged, this);
this->CreateService(PS_CREATEACCMGRUI, &CSkypeProto::OnAccountManagerInit);
}
CSkypeProto::~CSkypeProto()
{
- Netlib_CloseHandle(this->hNetlibUser);
- this->hNetlibUser = NULL;
+ this->UninitNetLib();
CloseHandle(this->signin_lock);
@@ -42,7 +34,7 @@ CSkypeProto::~CSkypeProto()
HANDLE __cdecl CSkypeProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
{
- if (psr->cbSize != sizeof(PROTOSEARCHRESULT))
+ //if (psr->cbSize != sizeof(PROTOSEARCHRESULT))
return 0;
//return this->AddToListBySkypeLogin(psr->id, psr->nick, psr->firstName, psr->lastName, flags);
@@ -212,9 +204,12 @@ void __cdecl CSkypeProto::SignIn(void*)
this->account->LoginWithPassword(mir_u2a(this->password), false, false);
this->account->BlockWhileLoggingIn();
+
+ //CContact::Ref()->SetOnChangeCallback((OnContactChangeFunc)&CSkypeProto::OnContactChanged, this);
+
this->SetStatus(this->m_iDesiredStatus);
this->ForkThread(&CSkypeProto::LoadContactList, this);
//this->LoadContactList(this);
ReleaseMutex(this->signin_lock);
-}
+} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index c5fbda84bf..bb3a0bcebb 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -1,14 +1,13 @@
#pragma once
#include "skype.h"
-#include "skype_subclassing.h"
struct CSkypeProto;
-typedef void (__cdecl CSkypeProto::*SkypeThreadFunc) (void*);
-typedef INT_PTR (__cdecl CSkypeProto::*SkypeServiceFunc)(WPARAM, LPARAM);
-typedef int (__cdecl CSkypeProto::*SkypeEventFunc)(WPARAM, LPARAM);
-typedef INT_PTR (__cdecl CSkypeProto::*SkypeServiceFuncParam)(WPARAM, LPARAM, LPARAM);
+typedef void (__cdecl CSkypeProto::* SkypeThreadFunc) (void*);
+typedef INT_PTR (__cdecl CSkypeProto::* SkypeServiceFunc)(WPARAM, LPARAM);
+typedef int (__cdecl CSkypeProto::* SkypeEventFunc)(WPARAM, LPARAM);
+typedef INT_PTR (__cdecl CSkypeProto::* SkypeServiceFuncParam)(WPARAM, LPARAM, LPARAM);
struct CSkypeProto : public PROTO_INTERFACE, public MZeroedObject
@@ -75,22 +74,21 @@ public:
protected:
CAccount::Ref account;
-
+ CContactGroup::Ref contactGroup;
TCHAR* login;
TCHAR* password;
- HANDLE hNetlibUser;
- void Log(const char* fmt, ...);
HANDLE signin_lock;
void __cdecl SignIn(void*);
void __cdecl LoadContactList(void*);
+ void OnContactChanged(CContact* contact, int prop);
HANDLE GetContactBySkypeLogin(const char* skypeLogin);
void SetAllContactStatuses(int status);
-
+ // utils
void CreateService(const char* szService, SkypeServiceFunc serviceProc);
void CreateServiceParam(const char* szService, SkypeServiceFunc serviceProc, LPARAM lParam);
@@ -103,6 +101,12 @@ protected:
void ForkThread(SkypeThreadFunc, void*);
HANDLE ForkThreadEx(SkypeThreadFunc, void*, UINT* threadID = NULL);
+ // netlib
+ HANDLE hNetlibUser;
+ void InitNetLib();
+ void UninitNetLib();
+ void Log(const char* fmt, ...);
+
// database settings
BYTE GetSettingByte(const char *setting, BYTE errorValue = 0);
BYTE GetSettingByte(HANDLE hContact, const char *setting, BYTE errorValue = 0);
@@ -126,7 +130,7 @@ protected:
bool SetDecodeSettingString(const char *setting, TCHAR* value = NULL);
bool SetDecodeSettingString(HANDLE hContact, const char *setting, TCHAR* value = NULL);
-
+ // dialog procs
static INT_PTR CALLBACK SkypeAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
static INT_PTR CALLBACK SkypeOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
}; \ No newline at end of file
diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp
index ed81021bd9..0a0ebd5a0f 100644
--- a/protocols/Skype/src/skype_subclassing.cpp
+++ b/protocols/Skype/src/skype_subclassing.cpp
@@ -40,6 +40,7 @@ void CAccount::OnChange(int prop)
}
}
}
+ //(proto->*callback)(this, prop);
}
void CAccount::BlockWhileLoggingIn()
@@ -67,6 +68,13 @@ CContact::CContact(unsigned int oid, SERootObject* root) : Contact(oid, root)
{
}
+void CAccount::SetOnChangeCallback(OnContactChangeFunc callback, CSkypeProto* proto)
+{
+ this->proto = proto;
+ this->callback = callback;
+}
+
void CContact::OnChange(int prop)
{
+ //(proto->*callback)(this, prop);
} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_subclassing.h b/protocols/Skype/src/skype_subclassing.h
index 003ce742ea..044c825b68 100644
--- a/protocols/Skype/src/skype_subclassing.h
+++ b/protocols/Skype/src/skype_subclassing.h
@@ -1,7 +1,15 @@
#pragma once
+#undef OCSP_REQUEST
+#undef OCSP_RESPONSE
+
#include <skype-embedded_2.h>
+class CContact;
+struct CSkypeProto;
+
+typedef void (__cdecl CSkypeProto::* OnContactChangeFunc)(CContact*, int);
+
class CContact : public Contact
{
public:
@@ -10,7 +18,7 @@ public:
CContact(unsigned int oid, SERootObject* root);
-protected:
+private:
void OnChange(int prop);
};
@@ -23,7 +31,7 @@ public:
CContact::Refs ContactList;
-protected:
+private:
void OnChange(const ContactRef& contact);
};
@@ -40,7 +48,13 @@ public:
void BlockWhileLoggingIn();
void BlockWhileLoggingOut();
-protected:
+
+ void SetOnChangeCallback(OnContactChangeFunc callback, CSkypeProto* proto);
+
+private:
+ CSkypeProto* proto;
+ OnContactChangeFunc callback;
+
void OnChange(int prop);
};
diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp
index 057ce1aebd..1a16af6483 100644
--- a/protocols/Skype/src/skype_utils.cpp
+++ b/protocols/Skype/src/skype_utils.cpp
@@ -1,44 +1,32 @@
#include "skype_proto.h"
-void CSkypeProto::Log(const char* fmt, ...)
-{
- va_list va;
- char msg[1024];
-
- va_start(va, fmt);
- mir_vsnprintf(msg, sizeof(msg), fmt, va);
- va_end(va);
-
- CallService(MS_NETLIB_LOG, (WPARAM)this->hNetlibUser, (LPARAM)msg);
-}
-
void CSkypeProto::CreateService(const char* szService, SkypeServiceFunc serviceProc)
{
char moduleName[MAXMODULELABELLENGTH];
- mir_snprintf(moduleName, sizeof(moduleName), "%s%s", this->m_szModuleName, szService);
- CreateServiceFunctionObj(moduleName, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
+ ::mir_snprintf(moduleName, sizeof(moduleName), "%s%s", this->m_szModuleName, szService);
+ ::CreateServiceFunctionObj(moduleName, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
}
void CSkypeProto::CreateServiceParam(const char* szService, SkypeServiceFunc serviceProc, LPARAM lParam)
{
char moduleName[MAXMODULELABELLENGTH];
- mir_snprintf(moduleName, sizeof(moduleName), "%s%s", this->m_szModuleName, szService);
- CreateServiceFunctionObjParam(moduleName, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, this, lParam);
+ ::mir_snprintf(moduleName, sizeof(moduleName), "%s%s", this->m_szModuleName, szService);
+ ::CreateServiceFunctionObjParam(moduleName, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, this, lParam);
}
HANDLE CSkypeProto::CreateEvent(const char* szService)
{
char moduleName[MAXMODULELABELLENGTH];
- mir_snprintf(moduleName, sizeof(moduleName), "%s%s", this->m_szModuleName, szService);
- return CreateHookableEvent(moduleName);
+ ::mir_snprintf(moduleName, sizeof(moduleName), "%s%s", this->m_szModuleName, szService);
+ return ::CreateHookableEvent(moduleName);
}
void CSkypeProto::HookEvent(const char* szEvent, SkypeEventFunc handler)
{
- HookEventObj(szEvent, (MIRANDAHOOKOBJ)*( void**)&handler, this);
+ ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*( void**)&handler, this);
}
int CSkypeProto::SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam)
@@ -56,13 +44,14 @@ int CSkypeProto::SendBroadcast(HANDLE hContact, int type, int result, HANDLE hPr
ack.result = result;
ack.hProcess = hProcess;
ack.lParam = lParam;
- return CallService(MS_PROTO_BROADCASTACK, 0, (LPARAM)&ack);
+
+ return ::CallService(MS_PROTO_BROADCASTACK, 0, (LPARAM)&ack);
}
void CSkypeProto::ForkThread(SkypeThreadFunc pFunc, void *param)
{
UINT threadID;
- CloseHandle((HANDLE)mir_forkthreadowner(
+ ::CloseHandle((HANDLE)::mir_forkthreadowner(
(pThreadFuncOwner)*(void**)&pFunc,
this,
param,
@@ -72,7 +61,7 @@ void CSkypeProto::ForkThread(SkypeThreadFunc pFunc, void *param)
HANDLE CSkypeProto::ForkThreadEx(SkypeThreadFunc pFunc, void *param, UINT* threadID)
{
UINT lthreadID;
- return (HANDLE)mir_forkthreadowner(
+ return (HANDLE)::mir_forkthreadowner(
(pThreadFuncOwner)*(void**)&pFunc,
this,
param,