summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Skype/Skype.vcxproj1
-rw-r--r--protocols/Skype/Skype.vcxproj.filters3
-rw-r--r--protocols/Skype/src/skype.cpp26
-rw-r--r--protocols/Skype/src/skype.h2
-rw-r--r--protocols/Skype/src/skype_contacts.cpp112
-rw-r--r--protocols/Skype/src/skype_proto.cpp52
-rw-r--r--protocols/Skype/src/skype_proto.h31
-rw-r--r--protocols/Skype/src/skype_settings.cpp114
-rw-r--r--protocols/Skype/src/skype_subclassing.cpp10
-rw-r--r--protocols/Skype/src/skype_subclassing.h4
10 files changed, 287 insertions, 68 deletions
diff --git a/protocols/Skype/Skype.vcxproj b/protocols/Skype/Skype.vcxproj
index 278c9c5f2e..26b28ff7d7 100644
--- a/protocols/Skype/Skype.vcxproj
+++ b/protocols/Skype/Skype.vcxproj
@@ -105,6 +105,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\skype.cpp" />
+ <ClCompile Include="src\skype_contacts.cpp" />
<ClCompile Include="src\skype_dialogs.cpp" />
<ClCompile Include="src\skype_events.cpp" />
<ClCompile Include="src\skype_icons.cpp" />
diff --git a/protocols/Skype/Skype.vcxproj.filters b/protocols/Skype/Skype.vcxproj.filters
index 25055f66e6..8ad618391e 100644
--- a/protocols/Skype/Skype.vcxproj.filters
+++ b/protocols/Skype/Skype.vcxproj.filters
@@ -36,6 +36,9 @@
<ClCompile Include="src\skype_icons.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\skype_contacts.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 418d4040ed..e7060c289a 100644
--- a/protocols/Skype/src/skype.cpp
+++ b/protocols/Skype/src/skype.cpp
@@ -91,6 +91,32 @@ int LoadKeyPair()
extern "C" int __declspec(dllexport) Load(void)
{
+ // loading skype SDK
+ // shitcode
+ char* bsp;
+ STARTUPINFOA cif;
+ PROCESS_INFORMATION pi;
+ char runtimePath[MAX_PATH];
+
+ GetModuleFileNameA(g_hInstance, runtimePath, MAX_PATH);
+ bsp = strrchr(runtimePath, '\\' );
+ runtimePath[strlen(runtimePath) - strlen(bsp)] = '\0';
+ strcat(runtimePath, "\\..\\..\\..\\..\\SkypeKit\\SDK\\bin\\windows-x86\\windows-x86-skypekit.exe");
+
+ ZeroMemory(&cif,sizeof(STARTUPINFOA));
+
+ CreateProcessA(
+ runtimePath,
+ NULL,
+ NULL,
+ NULL,
+ TRUE,
+ CREATE_NEW_CONSOLE,
+ NULL,
+ NULL,
+ &cif,
+ &pi);
+
g_skype = new CSkype();
LoadKeyPair();
g_skype->init(keyBuf, "127.0.0.1", 8963, "streamlog.txt");
diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h
index 469e2373a6..c3e944cbbe 100644
--- a/protocols/Skype/src/skype.h
+++ b/protocols/Skype/src/skype.h
@@ -69,5 +69,7 @@ static const char* g_keyFileName = "..\\..\\..\\SkypeKit\\keypair.crt";
extern CSkype* g_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
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp
new file mode 100644
index 0000000000..56c9b61ee1
--- /dev/null
+++ b/protocols/Skype/src/skype_contacts.cpp
@@ -0,0 +1,112 @@
+#include "skype_proto.h"
+
+HANDLE CSkypeProto::GetContactBySkypeLogin(const char* skypeLogin)
+{
+ for (HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ hContact;
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0))
+ {
+ //if(!IsMyContact(hContact))
+ // continue;
+
+ DBVARIANT dbv;
+ if( !DBGetContactSettingString(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN, &dbv))
+ {
+ if(strcmp(skypeLogin, dbv.pszVal) == 0)
+ {
+ DBFreeVariant(&dbv);
+ return hContact;
+ }
+ else
+ DBFreeVariant(&dbv);
+ }
+ }
+
+ return 0;
+}
+
+void __cdecl CSkypeProto::LoadContactList(void*)
+{
+ CContactGroup::Ref contacts;
+ g_skype->GetHardwiredContactGroup(CContactGroup::SKYPE_BUDDIES, contacts);
+
+ contacts->GetContacts(contacts->ContactList);
+ fetch(contacts->ContactList);
+
+ for (unsigned int i = 0; i < contacts->ContactList.size(); i++)
+ {
+ SEString name;
+ SEString skypeLogin;
+
+ int status = ID_STATUS_OFFLINE;
+ CContact::AVAILABILITY availability = CContact::OFFLINE;
+
+ contacts->ContactList[i]->GetPropSkypename(skypeLogin);
+ printf("%3d. %s\n", i+1, (const char*)skypeLogin);
+
+ HANDLE hContact = this->GetContactBySkypeLogin(skypeLogin);
+ if (!hContact)
+ {
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ DBWriteContactSettingString(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN, skypeLogin);
+ }
+
+ if (CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName) == 0 )
+ {
+
+ contacts->ContactList[i]->GetPropDisplayname(name);
+ contacts->ContactList[i]->GetPropAvailability(availability);
+
+ switch (availability)
+ {
+ case CContact::ONLINE:
+ case CContact::ONLINE_FROM_MOBILE:
+ status = ID_STATUS_ONLINE;
+ break;
+
+ case CContact::AWAY:
+ case CContact::AWAY_FROM_MOBILE:
+ status = ID_STATUS_AWAY;
+ break;
+
+ case CContact::DO_NOT_DISTURB:
+ case CContact::DO_NOT_DISTURB_FROM_MOBILE:
+ status = ID_STATUS_DND;
+ break;
+ }
+
+ DBDeleteContactSetting(hContact, "CList", "MyHandle");
+
+ /*DBVARIANT dbv;
+ if (!this->GetSettingString(this->m_szModuleName,FACEBOOK_KEY_DEF_GROUP,&dbv))
+ {
+ DBWriteContactSettingTString(hContact,"CList","Group",dbv.ptszVal);
+ DBFreeVariant(&dbv);
+ }*/
+
+ DBWriteContactSettingString(hContact, this->m_szModuleName, SKYPE_SETTINGS_NAME, name);
+ DBWriteContactSettingWord(hContact, this->m_szModuleName, SKYPE_SETTINGS_STATUS, ID_STATUS_ONLINE);
+ DBWriteContactSettingString(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN, skypeLogin);
+ }
+ else
+ {
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ }
+
+ //HANDLE hContact = AddToContactList(fbu, FACEBOOK_CONTACT_APPROVE, false, fbu->real_name.c_str());
+ //DBWriteContactSettingByte(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_APPROVE);
+ }
+}
+
+void CSkypeProto::SetAllContactStatuses(int status)
+{
+ for (HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ hContact;
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0))
+ {
+ if (DBGetContactSettingWord(hContact, this->m_szModuleName, SKYPE_SETTINGS_STATUS, ID_STATUS_OFFLINE) == status)
+ continue;
+
+ DBWriteContactSettingWord(hContact, this->m_szModuleName, SKYPE_SETTINGS_STATUS, status);
+ }
+} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index aa9af339ae..962dce0167 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -11,6 +11,7 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName)
//this->m_szProtoName[0] = toupper(m_szProtoName[0]);
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);
@@ -44,7 +45,7 @@ HANDLE __cdecl CSkypeProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
if (psr->cbSize != sizeof(PROTOSEARCHRESULT))
return 0;
- return this->AddToListBySkypeLogin(psr->id, psr->nick, psr->firstName, psr->lastName, flags);
+ //return this->AddToListBySkypeLogin(psr->id, psr->nick, psr->firstName, psr->lastName, flags);
}
HANDLE __cdecl CSkypeProto::AddToListByEvent( int flags, int iContact, HANDLE hDbEvent ) { return 0; }
@@ -126,6 +127,7 @@ int CSkypeProto::SetStatus(int new_status)
this->account->Logout(true);
this->account->BlockWhileLoggingOut();
this->account->SetAvailability(CContact::OFFLINE);
+ this->SetAllContactStatuses(ID_STATUS_OFFLINE);
}
else
{
@@ -139,6 +141,7 @@ int CSkypeProto::SetStatus(int new_status)
this->password = this->GetDecodeSettingString(SKYPE_SETTINGS_PASSWORD);
this->ForkThread(&CSkypeProto::SignIn, this);
+ //this->SignIn(this);
}
}
@@ -211,52 +214,7 @@ void __cdecl CSkypeProto::SignIn(void*)
this->account->BlockWhileLoggingIn();
this->SetStatus(this->m_iDesiredStatus);
this->ForkThread(&CSkypeProto::LoadContactList, this);
+ //this->LoadContactList(this);
ReleaseMutex(this->signin_lock);
}
-
-void __cdecl CSkypeProto::LoadContactList(void*)
-{
- CContactGroup::Ref contacts;
- g_skype->GetHardwiredContactGroup(CContactGroup::ALL_KNOWN_CONTACTS, contacts);
-
- contacts->GetContacts(contacts->ContactList);
- fetch(contacts->ContactList);
-
- for (unsigned int i = 0; i < contacts->ContactList.size(); i++)
- {
- SEString contactName;
- contacts->ContactList[i]->GetPropDisplayname(contactName);
- printf("%3d. %s\n", i+1, (const char*)contactName);
-
- //HANDLE hContact = AddToContactList(fbu, FACEBOOK_CONTACT_APPROVE, false, fbu->real_name.c_str());
- //DBWriteContactSettingByte(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_APPROVE);
- }
-}
-
-HANDLE CSkypeProto::AddToListBySkypeLogin(TCHAR* skypeName, TCHAR* nickName, TCHAR* firstName, TCHAR* lastName, DWORD flags)
-{
- //if (!skypeName)
- return NULL;
-
- /*BOOL bAdded;
- HANDLE hContact = MraHContactFromEmail( _T2A(plpsEMail), lstrlen(plpsEMail), TRUE, TRUE, &bAdded);
- if (hContact) {
- if (nickName)
- mraSetStringW(hContact, "Nick", nickName);
- if (firstName)
- mraSetStringW(hContact, "FirstName", firstName);
- if (lastName)
- mraSetStringW(hContact, "LastName", lastName);
-
- if (flags & PALF_TEMPORARY)
- DBWriteContactSettingByte(hContact, "CList", "Hidden", 1);
- else
- DBDeleteContactSetting(hContact, "CList", "NotOnList");
-
- if (bAdded)
- MraUpdateContactInfo(hContact);
- }
-
- return hContact;*/
-} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index a5597c4c4f..c5fbda84bf 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -87,7 +87,8 @@ protected:
void __cdecl SignIn(void*);
void __cdecl LoadContactList(void*);
- HANDLE AddToListBySkypeLogin(TCHAR* skypeName, TCHAR* nickName, TCHAR* firstName, TCHAR* lastName, DWORD flags);
+ HANDLE GetContactBySkypeLogin(const char* skypeLogin);
+ void SetAllContactStatuses(int status);
void CreateService(const char* szService, SkypeServiceFunc serviceProc);
@@ -102,12 +103,28 @@ protected:
void ForkThread(SkypeThreadFunc, void*);
HANDLE ForkThreadEx(SkypeThreadFunc, void*, UINT* threadID = NULL);
-
- TCHAR* GetSettingString(const char *szSetting, TCHAR* defVal = NULL);
- TCHAR* GetSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal = NULL);
-
- TCHAR* GetDecodeSettingString(const char *szSetting, TCHAR* defVal = NULL);
- TCHAR* GetDecodeSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal = NULL);
+ // database settings
+ BYTE GetSettingByte(const char *setting, BYTE errorValue = 0);
+ BYTE GetSettingByte(HANDLE hContact, const char *setting, BYTE errorValue = 0);
+ WORD GetSettingWord(const char *setting, WORD errorValue = 0);
+ WORD GetSettingWord(HANDLE hContact, const char *setting, WORD errorValue = 0);
+ DWORD GetSettingDword(const char *setting, DWORD defVal = 0);
+ DWORD GetSettingDword(HANDLE hContact, const char *setting, DWORD errorValue = 0);
+ TCHAR* GetSettingString(const char *setting, TCHAR* errorValue = NULL);
+ TCHAR* GetSettingString(HANDLE hContact, const char *setting, TCHAR* errorValue = NULL);
+ TCHAR* GetDecodeSettingString(const char *setting, TCHAR* errorValue = NULL);
+ TCHAR* GetDecodeSettingString(HANDLE hContact, const char *setting, TCHAR* errorValue = NULL);
+
+ bool SetSettingByte(const char *setting, BYTE value = 0);
+ bool SetSettingByte(HANDLE hContact, const char *setting, BYTE value = 0);
+ bool SetSettingWord(const char *setting, WORD value = 0);
+ bool SetSettingWord(HANDLE hContact, const char *setting, WORD value = 0);
+ bool SetSettingDword(const char *setting, DWORD value = 0);
+ bool SetSettingDword(HANDLE hContact, const char *setting, DWORD value = 0);
+ bool SetSettingString(const char *setting, TCHAR* value = NULL);
+ bool SetSettingString(HANDLE hContact, const char *setting, TCHAR* value = NULL);
+ bool SetDecodeSettingString(const char *setting, TCHAR* value = NULL);
+ bool SetDecodeSettingString(HANDLE hContact, const char *setting, TCHAR* value = NULL);
static INT_PTR CALLBACK SkypeAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
diff --git a/protocols/Skype/src/skype_settings.cpp b/protocols/Skype/src/skype_settings.cpp
index 59ea576d93..188274ae3c 100644
--- a/protocols/Skype/src/skype_settings.cpp
+++ b/protocols/Skype/src/skype_settings.cpp
@@ -1,33 +1,121 @@
#include "skype_proto.h"
-TCHAR* CSkypeProto::GetSettingString(const char *szSetting, TCHAR* defVal)
+BYTE CSkypeProto::GetSettingByte(HANDLE hContact, const char *setting, BYTE errorValue)
{
- return this->GetSettingString(NULL, szSetting, defVal);
+ return ::DBGetContactSettingByte(hContact, this->m_szModuleName, setting, errorValue);
}
-TCHAR* CSkypeProto::GetSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal)
+BYTE CSkypeProto::GetSettingByte(const char *setting, BYTE errorValue)
{
- TCHAR* result = DBGetStringW(hContact, this->m_szModuleName, szSetting);
- return result != NULL ? result : defVal;
+ return this->GetSettingByte(NULL, setting, errorValue);
}
-TCHAR* CSkypeProto::GetDecodeSettingString(const char *szSetting, TCHAR* defVal)
+WORD CSkypeProto::GetSettingWord(HANDLE hContact, const char *setting, WORD errorValue)
{
- return this->GetDecodeSettingString(NULL, szSetting, defVal);
+ return ::DBGetContactSettingWord(hContact, this->m_szModuleName, setting, errorValue);
}
-TCHAR* CSkypeProto::GetDecodeSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal)
+WORD CSkypeProto::GetSettingWord(const char *setting, WORD errorValue)
+{
+ return this->GetSettingWord(NULL, setting, errorValue);
+}
+
+DWORD CSkypeProto::GetSettingDword(HANDLE hContact, const char *setting, DWORD errorValue)
+{
+ return ::DBGetContactSettingDword(hContact, this->m_szModuleName, setting, errorValue);
+}
+
+DWORD CSkypeProto::GetSettingDword(const char *setting, DWORD errorValue)
+{
+ return this->GetSettingDword(NULL, setting, errorValue);
+}
+
+TCHAR* CSkypeProto::GetSettingString(HANDLE hContact, const char *setting, TCHAR* errorValue)
{
DBVARIANT dbv;
TCHAR* result = NULL;
- if ( !DBGetContactSettingWString(0, this->m_szModuleName, szSetting, &dbv))
+
+ if ( !::DBGetContactSettingWString(hContact, this->m_szModuleName, setting, &dbv))
{
- CallService(
- MS_DB_CRYPT_DECODESTRING,
- wcslen(dbv.ptszVal) + 1,
- reinterpret_cast<LPARAM>(dbv.ptszVal));
result = mir_wstrdup(dbv.pwszVal);
DBFreeVariant(&dbv);
}
+
+ return result != NULL ? result : errorValue;
+}
+
+TCHAR* CSkypeProto::GetSettingString(const char *setting, TCHAR* errorValue)
+{
+ return this->GetSettingString(NULL, setting, errorValue);
+}
+
+TCHAR* CSkypeProto::GetDecodeSettingString(HANDLE hContact, const char *setting, TCHAR* errorValue)
+{
+ TCHAR* result = this->GetSettingString(hContact, setting, errorValue);
+
+ CallService(
+ MS_DB_CRYPT_DECODESTRING,
+ wcslen(result) + 1,
+ reinterpret_cast<LPARAM>(result));
+
return result;
+}
+
+TCHAR* CSkypeProto::GetDecodeSettingString(const char *setting, TCHAR* errorValue)
+{
+ return this->GetDecodeSettingString(NULL, setting, errorValue);
+}
+
+
+bool CSkypeProto::SetSettingByte(HANDLE hContact, const char *setting, BYTE value)
+{
+ return !::DBWriteContactSettingByte(hContact, this->m_szModuleName, setting, value);
+}
+
+bool CSkypeProto::SetSettingByte(const char *setting, BYTE errorValue)
+{
+ return this->SetSettingByte(NULL, setting, errorValue);
+}
+
+bool CSkypeProto::SetSettingWord(HANDLE hContact, const char *setting, WORD value)
+{
+ return !::DBWriteContactSettingWord(hContact, this->m_szModuleName, setting, value);
+}
+
+bool CSkypeProto::SetSettingWord(const char *setting, WORD value)
+{
+ return this->SetSettingWord(NULL, setting, value);
+}
+
+bool CSkypeProto::SetSettingDword(HANDLE hContact, const char *setting, DWORD value)
+{
+ return !::DBWriteContactSettingDword(hContact, this->m_szModuleName, setting, value);
+}
+
+bool CSkypeProto::SetSettingDword(const char *setting, DWORD value)
+{
+ return this->SetSettingDword(NULL, setting, value);
+}
+
+bool CSkypeProto::SetSettingString(HANDLE hContact, const char *szSetting, TCHAR* value)
+{
+ return !::DBWriteContactSettingWString(hContact, this->m_szModuleName, szSetting, value);
+}
+
+bool CSkypeProto::SetSettingString(const char *szSetting, TCHAR* value)
+{
+ return this->SetSettingString(NULL, szSetting, value);
+}
+
+bool CSkypeProto::SetDecodeSettingString(HANDLE hContact, const char *setting, TCHAR* value)
+{
+ TCHAR* result = mir_wstrdup(value);
+ CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(result), reinterpret_cast<LPARAM>(result));
+
+ return !this->SetSettingString(hContact, setting, result);
+}
+
+bool CSkypeProto::SetDecodeSettingString(const char *setting, TCHAR* value)
+{
+ return this->SetDecodeSettingString(NULL, setting, value);
} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp
index 1c067f4c3a..ed81021bd9 100644
--- a/protocols/Skype/src/skype_subclassing.cpp
+++ b/protocols/Skype/src/skype_subclassing.cpp
@@ -5,6 +5,16 @@ 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;
diff --git a/protocols/Skype/src/skype_subclassing.h b/protocols/Skype/src/skype_subclassing.h
index 5cd42cf5c3..003ce742ea 100644
--- a/protocols/Skype/src/skype_subclassing.h
+++ b/protocols/Skype/src/skype_subclassing.h
@@ -47,5 +47,7 @@ protected:
class CSkype : public Skype
{
public:
- CAccount* newAccount(int oid);
+ CAccount* newAccount(int oid);
+ CContactGroup* newContactGroup(int oid);
+ CContact* newContact(int oid);
}; \ No newline at end of file