diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2012-09-27 05:44:38 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2012-09-27 05:44:38 +0000 |
commit | 4db6c5178cbd85e29e714a63ee5b1e8fc9881bae (patch) | |
tree | 7dfa309c4f1d2e3a0a4d251e3f9d4529403f1176 /protocols/Skype/src | |
parent | e2e27aabce83dc5ebf60a8456b7560ca104d6223 (diff) |
- added skype sublassing
- CSkupeProto funcs moved to spec files
- some minor changes
git-svn-id: http://svn.miranda-ng.org/main/trunk@1675 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype/src')
-rw-r--r-- | protocols/Skype/src/skype.cpp | 6 | ||||
-rw-r--r-- | protocols/Skype/src/skype.h | 4 | ||||
-rw-r--r-- | protocols/Skype/src/skype_dialogs.cpp | 9 | ||||
-rw-r--r-- | protocols/Skype/src/skype_events.cpp | 1 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 43 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 9 | ||||
-rw-r--r-- | protocols/Skype/src/skype_settings.cpp | 33 | ||||
-rw-r--r-- | protocols/Skype/src/skype_subclassing.cpp | 45 | ||||
-rw-r--r-- | protocols/Skype/src/skype_subclassing.h | 27 | ||||
-rw-r--r-- | protocols/Skype/src/skype_utils.cpp | 21 | ||||
-rw-r--r-- | protocols/Skype/src/version.h | 1 |
11 files changed, 158 insertions, 41 deletions
diff --git a/protocols/Skype/src/skype.cpp b/protocols/Skype/src/skype.cpp index 01df986a0e..b45462ede8 100644 --- a/protocols/Skype/src/skype.cpp +++ b/protocols/Skype/src/skype.cpp @@ -4,13 +4,13 @@ int hLangpack;
HINSTANCE g_hInstance;
-Skype* g_skype;
+CSkype* g_skype;
PLUGININFOEX pluginInfo =
{
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
- PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __VERSION_DWORD,
__DESCRIPTION,
__AUTHOR,
__AUTHOREMAIL,
@@ -91,7 +91,7 @@ int LoadKeyPair() extern "C" int __declspec(dllexport) Load(void)
{
- g_skype = new Skype();
+ g_skype = new CSkype();
LoadKeyPair();
g_skype->init(keyBuf, "127.0.0.1", 8963, "streamlog.txt");
g_skype->start();
diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h index 076c26da80..8fd0390354 100644 --- a/protocols/Skype/src/skype.h +++ b/protocols/Skype/src/skype.h @@ -59,8 +59,8 @@ extern HINSTANCE g_hInstance; #undef OCSP_REQUEST
#undef OCSP_RESPONSE
-#include <skype-embedded_2.h>
+#include "skype_subclassing.h"
static const char* g_keyFileName = "..\\..\\..\\SkypeKit\\keypair.crt";
-extern Skype* g_skype;
\ No newline at end of file +extern CSkype* g_skype;
\ No newline at end of file diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp index 806843cd86..fea322746c 100644 --- a/protocols/Skype/src/skype_dialogs.cpp +++ b/protocols/Skype/src/skype_dialogs.cpp @@ -69,4 +69,13 @@ INT_PTR CALLBACK CSkypeProto::SkypeAccountProc(HWND hwnd, UINT message, WPARAM w }
return FALSE;
+}
+
+INT_PTR __cdecl CSkypeProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
+{
+ return (int)CreateDialogParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_SKYPEACCOUNT),
+ (HWND)lParam,
+ &CSkypeProto::SkypeAccountProc, (LPARAM)this);
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp new file mode 100644 index 0000000000..159b64a666 --- /dev/null +++ b/protocols/Skype/src/skype_events.cpp @@ -0,0 +1 @@ +#include "skype_proto.h"
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index d4f19e4aa8..d9986db95c 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -36,15 +36,6 @@ CSkypeProto::~CSkypeProto() mir_free(this->m_tszUserName);
}
-INT_PTR __cdecl CSkypeProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
-{
- return (int)CreateDialogParam(
- g_hInstance,
- MAKEINTRESOURCE(IDD_SKYPEACCOUNT),
- (HWND)lParam,
- &CSkypeProto::SkypeAccountProc, (LPARAM)this);
-}
-
HANDLE __cdecl CSkypeProto::AddToList( int flags, PROTOSEARCHRESULT* psr ) { return 0; }
HANDLE __cdecl CSkypeProto::AddToListByEvent( int flags, int iContact, HANDLE hDbEvent ) { return 0; }
int __cdecl CSkypeProto::Authorize( HANDLE hDbEvent ) { return 0; }
@@ -88,18 +79,19 @@ int CSkypeProto::SetStatus(int new_status) if ( !this->isOffline)
{
this->isOffline = true;
- account->Logout(false);
+ this->account->Logout(false);
};
break;
case ID_STATUS_ONLINE:
- if (g_skype->GetAccount("", this->account))
+
+ char* sn = mir_t2a(this->GetSettingString(NULL, "SkypeName"));
+ if (g_skype->GetAccount(sn, this->account))
{
this->isOffline = false;
- account->LoginWithPassword("", false, false);
-
- // Loop until LoggedIn or login failure
- //while ( (!account->loggedIn) && (!account->loggedOut) ) { Delay(1); };
+ char* pw = mir_t2a(this->GetDecodeSettingString(NULL, "Password"));
+ this->account->LoginWithPassword(pw, false, false);
+ this->account->BlockWhileLoggingIn();
}
break;
}
@@ -116,29 +108,10 @@ int __cdecl CSkypeProto::UserIsTyping( HANDLE hContact, int type ) { return 0 int __cdecl CSkypeProto::OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam ) { return 0; }
-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::CreateProtoService(const char* szService, SkypeServiceFunc serviceProc)
-{
- char temp[MAX_PATH*2];
-
- mir_snprintf(temp, sizeof(temp), "%s%s", this->m_szModuleName, szService);
- CreateServiceFunctionObj(temp, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
-}
char* CSkypeProto::ModuleName()
{
- return this->m_szProtoName;
+ return this->m_szModuleName;
}
bool CSkypeProto::IsOffline()
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 414f104d3c..c31b1f1afd 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -1,6 +1,7 @@ #pragma once
#include "skype.h"
+#include "skype_subclassing.h"
struct CSkypeProto;
@@ -65,7 +66,7 @@ public: protected:
bool isOffline;
- Account::Ref account;
+ CAccount::Ref account;
HANDLE hNetlibUser;
void Log( const char* fmt, ... );
@@ -73,5 +74,11 @@ protected: INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam);
void CreateProtoService(const char* szService, SkypeServiceFunc serviceProc);
+ 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);
+
static INT_PTR CALLBACK SkypeAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
};
\ No newline at end of file diff --git a/protocols/Skype/src/skype_settings.cpp b/protocols/Skype/src/skype_settings.cpp new file mode 100644 index 0000000000..8a2d0c0bfa --- /dev/null +++ b/protocols/Skype/src/skype_settings.cpp @@ -0,0 +1,33 @@ +#include "skype_proto.h"
+
+TCHAR* CSkypeProto::GetSettingString(const char *szSetting, TCHAR* defVal)
+{
+ return this->GetSettingString(NULL, szSetting, defVal);
+}
+
+TCHAR* CSkypeProto::GetSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal)
+{
+ TCHAR* result = DBGetStringW(hContact, this->m_szModuleName, szSetting);
+ return result != NULL ? result : defVal;
+}
+
+TCHAR* CSkypeProto::GetDecodeSettingString(const char *szSetting, TCHAR* defVal)
+{
+ return this->GetSettingString(NULL, szSetting, defVal);
+}
+
+TCHAR* CSkypeProto::GetDecodeSettingString(HANDLE hContact, const char *szSetting, TCHAR* defVal)
+{
+ DBVARIANT dbv;
+ TCHAR* result = NULL;
+ if ( !DBGetContactSettingString(0, this->m_szModuleName, szSetting, &dbv))
+ {
+ CallService(
+ MS_DB_CRYPT_DECODESTRING,
+ wcslen(dbv.ptszVal) + 1,
+ reinterpret_cast<LPARAM>(dbv.ptszVal));
+ result = mir_wstrdup(dbv.pwszVal);
+ DBFreeVariant(&dbv);
+ }
+ return result;
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp new file mode 100644 index 0000000000..04b4a82b74 --- /dev/null +++ b/protocols/Skype/src/skype_subclassing.cpp @@ -0,0 +1,45 @@ +#include "skype_subclassing.h" + +Account* CSkype::newAccount(int oid) +{ + return new CAccount(oid, this); +} + +CAccount::CAccount(unsigned int oid, SERootObject* root) : Account(oid, root) +{ + this->isLoggedOut = true; +} + +void CAccount::OnChange(int prop) +{ + if (prop == Account::P_STATUS) + { + Account::STATUS loginStatus; + this->GetPropStatus(loginStatus); + if (loginStatus == Account::LOGGED_IN) + this->isLoggedOut = false; + + if (loginStatus == Account::LOGGED_OUT) + { + this->isLoggedOut = true; + Account::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); +};
\ No newline at end of file diff --git a/protocols/Skype/src/skype_subclassing.h b/protocols/Skype/src/skype_subclassing.h new file mode 100644 index 0000000000..466b84809e --- /dev/null +++ b/protocols/Skype/src/skype_subclassing.h @@ -0,0 +1,27 @@ +#pragma once
+
+#include <skype-embedded_2.h>
+
+class CAccount;
+
+class CSkype : public Skype
+{
+public:
+ Account* newAccount(int oid);
+};
+
+class CAccount : public Account
+{
+public: + typedef DRef<CAccount, Account> Ref; + typedef DRefs<CAccount, Account> Refs; + + bool isLoggedOut; + + CAccount(unsigned int oid, SERootObject* root); + void OnChange(int prop); + + void BlockWhileLoggingIn(); + void BlockWhileLoggingOut(); +}; + diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp new file mode 100644 index 0000000000..be141b3e75 --- /dev/null +++ b/protocols/Skype/src/skype_utils.cpp @@ -0,0 +1,21 @@ +#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::CreateProtoService(const char* szService, SkypeServiceFunc serviceProc)
+{
+ char temp[MAX_PATH*2];
+
+ mir_snprintf(temp, sizeof(temp), "%s%s", this->m_szModuleName, szService);
+ CreateServiceFunctionObj(temp, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
+}
\ No newline at end of file diff --git a/protocols/Skype/src/version.h b/protocols/Skype/src/version.h index 281233e9ec..9acc0b7ca3 100644 --- a/protocols/Skype/src/version.h +++ b/protocols/Skype/src/version.h @@ -2,6 +2,7 @@ #define __MINOR_VERSION 0
#define __RELEASE_NUM 0
#define __BUILD_NUM 1
+#define __VERSION_DWORD PLUGIN_MAKE_VERSION(0, 1, 0, 0)
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
|