diff options
-rw-r--r-- | protocols/Skype/Skype.vcxproj | 2 | ||||
-rw-r--r-- | protocols/Skype/Skype.vcxproj.filters | 65 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 71 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 24 | ||||
-rw-r--r-- | protocols/Skype/src/skype_settings.cpp | 2 | ||||
-rw-r--r-- | protocols/Skype/src/skype_subclassing.cpp | 14 | ||||
-rw-r--r-- | protocols/Skype/src/skype_utils.cpp | 7 |
7 files changed, 78 insertions, 107 deletions
diff --git a/protocols/Skype/Skype.vcxproj b/protocols/Skype/Skype.vcxproj index cc64210e5d..9adcad1ae5 100644 --- a/protocols/Skype/Skype.vcxproj +++ b/protocols/Skype/Skype.vcxproj @@ -97,7 +97,7 @@ </ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
- <ClInclude Include="skype_subclassing.h" />
+ <ClInclude Include="src\skype_subclassing.h" />
<ClInclude Include="src\skype.h" />
<ClInclude Include="src\skype_proto.h" />
<ClInclude Include="src\version.h" />
diff --git a/protocols/Skype/Skype.vcxproj.filters b/protocols/Skype/Skype.vcxproj.filters deleted file mode 100644 index ef8f0e7bab..0000000000 --- a/protocols/Skype/Skype.vcxproj.filters +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <ClCompile Include="src\skype.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="src\skype_proto.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="src\skype_dialogs.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="src\skype_subclassing.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="src\skype_events.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="src\skype_settings.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="src\skype_utils.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="src\resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="src\skype.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="src\version.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="src\skype_proto.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="skype_subclassing.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="res\Resource.rc">
- <Filter>Resource Filess</Filter>
- </ResourceCompile>
- <ResourceCompile Include="res\Version.rc">
- <Filter>Resource Filess</Filter>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{13e9b105-554f-4080-b7de-8adf0f43b9f6}</UniqueIdentifier>
- </Filter>
- <Filter Include="Resource Filess">
- <UniqueIdentifier>{901463af-0f59-4125-b874-1662b095d403}</UniqueIdentifier>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{b14a0070-da9c-49e8-8a47-d93df5eed672}</UniqueIdentifier>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <None Include="res\Main.ico" />
- </ItemGroup>
-</Project>
\ No newline at end of file diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 18cc3a9e52..4c21d1ae95 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -2,14 +2,15 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName)
{
- this->isOffline = true;
this->m_iVersion = 2;
this->m_iStatus = ID_STATUS_OFFLINE;
this->m_tszUserName = mir_tstrdup(userName);
this->m_szModuleName = mir_strdup(protoName);
this->m_szProtoName = mir_strdup(protoName);
- _strlwr(m_szProtoName);
- this->m_szProtoName[0] = toupper(m_szProtoName[0]);
+ //_strlwr(m_szProtoName);
+ //this->m_szProtoName[0] = toupper(m_szProtoName[0]);
+
+ this->signin_lock = CreateMutex(0, false, 0);
TCHAR name[128];
mir_sntprintf(name, SIZEOF(name), TranslateT("%s connection"), this->m_tszUserName);
@@ -31,6 +32,8 @@ CSkypeProto::~CSkypeProto() Netlib_CloseHandle(this->hNetlibUser);
this->hNetlibUser = NULL;
+ CloseHandle(this->signin_lock);
+
mir_free(this->m_szProtoName);
mir_free(this->m_szModuleName);
mir_free(this->m_tszUserName);
@@ -94,34 +97,43 @@ int __cdecl CSkypeProto::SetApparentMode( HANDLE hContact, int mode ) { retur int CSkypeProto::SetStatus(int new_status)
{
- switch(new_status)
+ if (new_status == this->m_iStatus)
+ return 0;
+
+ int old_status = this->m_iStatus;
+ this->m_iDesiredStatus = new_status;
+
+ if (new_status == ID_STATUS_OFFLINE && old_status != ID_STATUS_OFFLINE)
{
- case ID_STATUS_OFFLINE:
- if ( !this->isOffline)
- {
- this->isOffline = true;
- this->account->Logout(false);
- this->account->BlockWhileLoggingOut();
- };
- break;
-
- case ID_STATUS_ONLINE:
-
- char* sn = mir_t2a(this->GetSettingString(NULL, "SkypeName"));
- if (g_skype->GetAccount(sn, this->account))
+ this->m_iStatus = new_status;
+ //todo: set all status to offline
+ this->account->Logout(true);
+ this->account->BlockWhileLoggingOut();
+ }
+ else
+ {
+ this->m_iStatus = new_status;
+ if (old_status == ID_STATUS_OFFLINE)
{
- this->isOffline = false;
- char* pw = mir_t2a(this->GetDecodeSettingString(NULL, "Password"));
- this->account->LoginWithPassword(pw, false, false);
- this->account->BlockWhileLoggingIn();
+ this->login = this->GetSettingString(SKYPE_SETTINGS_LOGIN);
+ if (g_skype->GetAccount(mir_u2a(login), this->account))
+ {
+ this->m_iStatus = ID_STATUS_CONNECTING;
+ this->password = this->GetDecodeSettingString(SKYPE_SETTINGS_PASSWORD);
+
+ this->ForkThread(&CSkypeProto::SignIn, this);
+ }
}
- break;
+
+ //todo: change skype status
}
+ this->SendBroadcast(ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, this->m_iStatus);
+
return 0;
}
-HANDLE __cdecl CSkypeProto::GetAwayMsg( HANDLE hContact ) { return 0; }
+HANDLE __cdecl CSkypeProto::GetAwayMsg(HANDLE hContact) { return 0; }
int __cdecl CSkypeProto::RecvAwayMsg( HANDLE hContact, int mode, PROTORECVEVENT* evt ) { return 0; }
int __cdecl CSkypeProto::SendAwayMsg( HANDLE hContact, HANDLE hProcess, const char* msg ) { return 0; }
int __cdecl CSkypeProto::SetAwayMsg( int m_iStatus, const TCHAR* msg ) { return 0; }
@@ -150,5 +162,16 @@ char* CSkypeProto::ModuleName() bool CSkypeProto::IsOffline()
{
- return this->isOffline;
+ return this->m_iStatus == ID_STATUS_OFFLINE;
+}
+
+void __cdecl CSkypeProto::SignIn(void*)
+{
+ WaitForSingleObject(&this->signin_lock, INFINITE);
+
+ this->account->LoginWithPassword(mir_u2a(this->password), false, false);
+ this->account->BlockWhileLoggingIn();
+ this->SetStatus(this->m_iDesiredStatus);
+
+ 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 bbd6a37926..5f41c3dc01 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -74,29 +74,37 @@ public: bool IsOffline();
protected:
- bool isOffline;
CAccount::Ref account;
- TCHAR* password;
- HANDLE hNetlibUser;
- void Log(const char* fmt, ...);
+
+ TCHAR* login;
+ TCHAR* password;
+
+ HANDLE hNetlibUser;
+ void Log(const char* fmt, ...);
+
+ HANDLE signin_lock;
+ void __cdecl SignIn(void*);
+
void CreateService(const char* szService, SkypeServiceFunc serviceProc);
void CreateServiceParam(const char* szService, SkypeServiceFunc serviceProc, LPARAM lParam);
HANDLE CreateHookableEvent(const char* szService);
void HookEvent(const char*, SkypeEventFunc);
+
+ int SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam);
int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam);
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* 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);
+ TCHAR* GetDecodeSettingString(const char *szSetting, TCHAR* defVal = NULL);
+ TCHAR* GetDecodeSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal = 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 3222605577..59ea576d93 100644 --- a/protocols/Skype/src/skype_settings.cpp +++ b/protocols/Skype/src/skype_settings.cpp @@ -13,7 +13,7 @@ TCHAR* CSkypeProto::GetSettingString(HANDLE hContact, const char *szSetting, TCH TCHAR* CSkypeProto::GetDecodeSettingString(const char *szSetting, TCHAR* defVal)
{
- return this->GetSettingString(NULL, szSetting, defVal);
+ return this->GetDecodeSettingString(NULL, szSetting, defVal);
}
TCHAR* CSkypeProto::GetDecodeSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal)
diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp index 04b4a82b74..115d6e044b 100644 --- a/protocols/Skype/src/skype_subclassing.cpp +++ b/protocols/Skype/src/skype_subclassing.cpp @@ -12,22 +12,22 @@ CAccount::CAccount(unsigned int oid, SERootObject* root) : Account(oid, root) void CAccount::OnChange(int prop) { - if (prop == Account::P_STATUS) + if (prop == CAccount::P_STATUS) { - Account::STATUS loginStatus; + CAccount::STATUS loginStatus; this->GetPropStatus(loginStatus); - if (loginStatus == Account::LOGGED_IN) + if (loginStatus == CAccount::STATUS::LOGGED_IN) this->isLoggedOut = false; - if (loginStatus == Account::LOGGED_OUT) + if (loginStatus == CAccount::STATUS::LOGGED_OUT) { this->isLoggedOut = true; - Account::LOGOUTREASON whyLogout; + CAccount::LOGOUTREASON whyLogout; this->GetPropLogoutreason(whyLogout); - /*if (whyLogout != Account::LOGOUT_CALLED) + if (whyLogout != Account::LOGOUT_CALLED) { printf("%s\n", (const char*)tostring(whyLogout)); - }*/ + } }
} }; diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp index 66529fb097..34471d14be 100644 --- a/protocols/Skype/src/skype_utils.cpp +++ b/protocols/Skype/src/skype_utils.cpp @@ -41,11 +41,16 @@ void CSkypeProto::HookEvent(const char* szEvent, SkypeEventFunc handler) HookEventObj(szEvent, (MIRANDAHOOKOBJ)*( void**)&handler, this);
}
+int CSkypeProto::SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam)
+{
+ return this->SendBroadcast(NULL, type, result, hProcess, lParam);
+}
+
int CSkypeProto::SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
{
ACKDATA ack = {0};
ack.cbSize = sizeof(ACKDATA);
- ack.szModule = m_szModuleName;
+ ack.szModule = this->m_szModuleName;
ack.hContact = hContact;
ack.type = type;
ack.result = result;
|