summaryrefslogtreecommitdiff
path: root/protocols/Skype/src/skype_proto.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2012-09-26 19:14:12 +0000
committerAlexander Lantsev <aunsane@gmail.com>2012-09-26 19:14:12 +0000
commit9f54d2d2fe173c2a426dc790e70f14a585829431 (patch)
treee374ddc425d4ed4e7eb2b7f04ad62a294e527166 /protocols/Skype/src/skype_proto.cpp
parentceae8e098fb5f4e3ae1acef7d8d26822ec8e3633 (diff)
- added SKYPEACCOUNT dialog
- added normal skype class starting - merge fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@1668 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype/src/skype_proto.cpp')
-rw-r--r--protocols/Skype/src/skype_proto.cpp331
1 files changed, 160 insertions, 171 deletions
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index 250283bc11..1f78e2dd57 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -1,229 +1,218 @@
-#include "skype.h"
+#include "skype_proto.h"
CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName)
{
- m_iVersion = 2;
- m_iStatus = ID_STATUS_OFFLINE;
- m_tszUserName = mir_tstrdup(userName);
- m_szModuleName = mir_strdup(protoName);
- m_szProtoName = mir_strdup(protoName);
+ 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);
- m_szProtoName[0] = toupper(m_szProtoName[0]);
+ this->m_szProtoName[0] = toupper(m_szProtoName[0]);
TCHAR name[128];
- mir_sntprintf(name, SIZEOF(name), TranslateT("%s connection"), m_tszUserName);
+ 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_TCHAR; // | NUF_HTTPGATEWAY;
nlu.ptszDescriptiveName = name;
nlu.szSettingsModule = m_szModuleName;
- m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ this->hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
this->Log("Setting protocol/module name to '%s/%s'", m_szProtoName, m_szModuleName);
-}
-
-CSkypeProto::~CSkypeProto()
-{
- Netlib_CloseHandle(m_hNetlibUser);
- m_hNetlibUser = NULL;
-
- mir_free(m_szProtoName);
- mir_free(m_szModuleName);
- mir_free(m_tszUserName);
-}
-
-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 )m_hNetlibUser, (LPARAM)msg);
-}
-
-void CSkypeProto::CreateProtoService(const char *szService, ServiceFunc serviceProc)
-{
- char str[ MAXMODULELABELLENGTH ];
- strcpy( str, m_szModuleName );
- strcat( str, szService );
- ::CreateServiceFunctionObj( str, ( MIRANDASERVICEOBJ )*( void** )&serviceProc, this );
+ this->CreateProtoService(PS_CREATEACCMGRUI, &CSkypeProto::SvcCreateAccMgrUI);
}
-HANDLE CSkypeProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
-{
- return NULL/*hContact*/;
-}
-
-HANDLE CSkypeProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEvent)
-{
- return NULL;
-}
-
-int CSkypeProto::Authorize(HANDLE hDbEvent)
-{
- return NULL;
-}
-
-int CSkypeProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR *reason)
-{
- return NULL;
-}
-
-int CSkypeProto::AuthRecv(HANDLE hContact, PROTORECVEVENT* pre)
-{
- return NULL;
-}
-
-int CSkypeProto::AuthRequest(HANDLE hContact, const TCHAR *lptszMessage)
-{
- return NULL;
-}
-
-HANDLE CSkypeProto::ChangeInfo(int type, void *info_data)
-{
- return NULL;
-}
-
-HANDLE CSkypeProto::FileAllow(HANDLE hContact, HANDLE hTransfer, const TCHAR *szPath)
-{
- return NULL;
-}
-
-int CSkypeProto::FileCancel(HANDLE hContact, HANDLE hTransfer)
+CSkypeProto::~CSkypeProto()
{
- return NULL;
-}
+ Netlib_CloseHandle(this->hNetlibUser);
+ this->hNetlibUser = NULL;
-int CSkypeProto::FileDeny(HANDLE hContact, HANDLE hTransfer, const TCHAR*)
-{
- return NULL;
+ mir_free(this->m_szProtoName);
+ mir_free(this->m_szModuleName);
+ mir_free(this->m_tszUserName);
}
-int CSkypeProto::FileResume(HANDLE, int*, const TCHAR**)
+INT_PTR CALLBACK SkypeAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- return 1;
-}
+ CSkypeProto *proto;
-DWORD_PTR CSkypeProto::GetCaps(int type, HANDLE hContact)
-{
- return NULL;
-}
+ switch ( message )
+ {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwnd);
-HICON CSkypeProto::GetIcon(int iconIndex)
-{
- return NULL;
-}
+ proto = reinterpret_cast<CSkypeProto*>(lparam);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam);
+
+ DBVARIANT dbv;
+ if ( !DBGetContactSettingString(0, proto->ModuleName(), "SkypeName", &dbv))
+ {
+ SetDlgItemText(hwnd, IDC_SN, dbv.ptszVal);
+ DBFreeVariant(&dbv);
+ }
+
+ if ( !DBGetContactSettingString(0, proto->ModuleName(), "Password", &dbv))
+ {
+ CallService(
+ MS_DB_CRYPT_DECODESTRING,
+ wcslen(dbv.ptszVal) + 1,
+ reinterpret_cast<LPARAM>(dbv.ptszVal));
+ SetDlgItemText(hwnd, IDC_PW, dbv.ptszVal);
+ DBFreeVariant(&dbv);
+ }
+
+ if ( !proto->IsOffline())
+ {
+ SendMessage(GetDlgItem(hwnd, IDC_SN), EM_SETREADONLY, 1, 0);
+ SendMessage(GetDlgItem(hwnd, IDC_PW), EM_SETREADONLY, 1, 0);
+ }
+
+ return TRUE;
+
+ case WM_COMMAND:
+ if (HIWORD(wparam) == EN_CHANGE && reinterpret_cast<HWND>(lparam) == GetFocus())
+ {
+ switch(LOWORD(wparam))
+ {
+ case IDC_SN:
+ case IDC_PW:
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ }
+ }
+ break;
+
+ case WM_NOTIFY:
+ if (reinterpret_cast<NMHDR*>(lparam)->code == PSN_APPLY)
+ {
+ proto = reinterpret_cast<CSkypeProto*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
+ TCHAR str[128];
-int CSkypeProto::GetInfo(HANDLE hContact, int infoType)
-{
- return NULL;
-}
+ GetDlgItemText(hwnd, IDC_SN, str, sizeof(str));
+ DBWriteContactSettingTString(0, proto->ModuleName(), "SkypeName", str);
-HANDLE CSkypeProto::SearchBasic(const TCHAR *id)
-{
- return NULL;
-}
+ GetDlgItemText(hwnd, IDC_PW, str, sizeof(str));
+ CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), reinterpret_cast<LPARAM>(str));
+ DBWriteContactSettingTString(0, proto->ModuleName(), "Password", str);
-HANDLE CSkypeProto::SearchByEmail(const TCHAR *email)
-{
- return NULL;
-}
+ return TRUE;
+ }
+ break;
-HANDLE CSkypeProto::SearchByName(const TCHAR *pszNick, const TCHAR *pszFirstName, const TCHAR *pszLastName)
-{
- return NULL;
-}
+ }
-HWND CSkypeProto::SearchAdvanced(HWND hWndDlg)
-{
- return NULL;
+ return FALSE;
}
-HWND CSkypeProto::CreateExtendedSearchUI(HWND owner)
+INT_PTR __cdecl CSkypeProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
{
- return NULL;
+ return (int)CreateDialogParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_SKYPEACCOUNT),
+ (HWND)lParam,
+ ::SkypeAccountProc, (LPARAM)this);
}
-int CSkypeProto::RecvContacts(HANDLE hContact, PROTORECVEVENT* pre)
-{
- return NULL;
-}
+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; }
+int __cdecl CSkypeProto::AuthDeny( HANDLE hDbEvent, const TCHAR* szReason ) { return 0; }
+int __cdecl CSkypeProto::AuthRecv( HANDLE hContact, PROTORECVEVENT* ) { return 0; }
+int __cdecl CSkypeProto::AuthRequest( HANDLE hContact, const TCHAR* szMessage ) { return 0; }
-int CSkypeProto::RecvFile(HANDLE hContact, PROTORECVFILET *pre)
-{
- return NULL;
-}
+HANDLE __cdecl CSkypeProto::ChangeInfo( int iInfoType, void* pInfoData ) { return 0; }
-int CSkypeProto::RecvMsg(HANDLE hContact, PROTORECVEVENT *pre)
-{
- return NULL;
-}
+HANDLE __cdecl CSkypeProto::FileAllow( HANDLE hContact, HANDLE hTransfer, const TCHAR* szPath ) { return 0; }
+int __cdecl CSkypeProto::FileCancel( HANDLE hContact, HANDLE hTransfer ) { return 0; }
+int __cdecl CSkypeProto::FileDeny( HANDLE hContact, HANDLE hTransfer, const TCHAR* szReason ) { return 0; }
+int __cdecl CSkypeProto::FileResume( HANDLE hTransfer, int* action, const TCHAR** szFilename ) { return 0; }
+
+DWORD_PTR __cdecl CSkypeProto:: GetCaps( int type, HANDLE hContact ) { return 0; }
+HICON __cdecl CSkypeProto::GetIcon( int iconIndex ) { return 0; }
+int __cdecl CSkypeProto::GetInfo( HANDLE hContact, int infoType ) { return 0; }
+
+HANDLE __cdecl CSkypeProto::SearchBasic( const TCHAR* id ) { return 0; }
+HANDLE __cdecl CSkypeProto::SearchByEmail( const TCHAR* email ) { return 0; }
+HANDLE __cdecl CSkypeProto::SearchByName( const TCHAR* nick, const TCHAR* firstName, const TCHAR* lastName ) { return 0; }
+HWND __cdecl CSkypeProto::SearchAdvanced( HWND owner ) { return 0; }
+HWND __cdecl CSkypeProto::CreateExtendedSearchUI( HWND owner ) { return 0; }
+
+int __cdecl CSkypeProto::RecvContacts( HANDLE hContact, PROTORECVEVENT* ) { return 0; }
+int __cdecl CSkypeProto::RecvFile( HANDLE hContact, PROTORECVFILET* ) { return 0; }
+int __cdecl CSkypeProto::RecvMsg( HANDLE hContact, PROTORECVEVENT* ) { return 0; }
+int __cdecl CSkypeProto::RecvUrl( HANDLE hContact, PROTORECVEVENT* ) { return 0; }
+
+int __cdecl CSkypeProto::SendContacts( HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList ) { return 0; }
+HANDLE __cdecl CSkypeProto::SendFile( HANDLE hContact, const TCHAR* szDescription, TCHAR** ppszFiles ) { return 0; }
+int __cdecl CSkypeProto::SendMsg( HANDLE hContact, int flags, const char* msg ) { return 0; }
+int __cdecl CSkypeProto::SendUrl( HANDLE hContact, int flags, const char* url ) { return 0; }
+
+int __cdecl CSkypeProto::SetApparentMode( HANDLE hContact, int mode ) { return 0; }
+int CSkypeProto::SetStatus(int new_status)
+{
+ switch(new_status)
+ {
+ case ID_STATUS_OFFLINE:
+ if ( !this->isOffline)
+ {
+ this->isOffline = true;
+ account->Logout(false);
+ };
+ break;
-int CSkypeProto::RecvUrl(HANDLE, PROTORECVEVENT*)
-{
- return 1;
-}
+ case ID_STATUS_ONLINE:
+ if (g_skype->GetAccount("", this->account))
+ {
+ this->isOffline = false;
+ account->LoginWithPassword("", false, false);
-int CSkypeProto::SendContacts(HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList)
-{
- return NULL;
-}
+ // Loop until LoggedIn or login failure
+ //while ( (!account->loggedIn) && (!account->loggedOut) ) { Delay(1); };
+ }
+ break;
+ }
-HANDLE CSkypeProto::SendFile(HANDLE hContact, const TCHAR* szDescription, TCHAR** ppszFiles)
-{
- return NULL;
+ return 0;
}
-int CSkypeProto::SendMsg(HANDLE hContact, int flags, const char *lpszMessage)
-{
- return NULL;
-}
+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; }
-int CSkypeProto::SendUrl(HANDLE, int, const char*)
-{
- return 1;
-}
+int __cdecl CSkypeProto::UserIsTyping( HANDLE hContact, int type ) { return 0; }
-int CSkypeProto::SetApparentMode(HANDLE hContact, int mode)
-{
- return NULL;
-}
+int __cdecl CSkypeProto::OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam ) { return 0; }
-int CSkypeProto::SetStatus(int iNewStatus)
+void CSkypeProto::Log(const char* fmt, ...)
{
- return NULL;
-}
+ va_list va;
+ char msg[1024];
-HANDLE CSkypeProto::GetAwayMsg(HANDLE hContact)
-{
- return NULL;
-}
+ va_start(va, fmt);
+ mir_vsnprintf(msg, sizeof(msg), fmt, va);
+ va_end(va);
-int CSkypeProto::RecvAwayMsg(HANDLE, int, PROTORECVEVENT*)
-{
- return 1;
+ CallService(MS_NETLIB_LOG, ( WPARAM )this->hNetlibUser, (LPARAM)msg);
}
-int CSkypeProto::SendAwayMsg(HANDLE, HANDLE, const char* )
+void CSkypeProto::CreateProtoService(const char* szService, SkypeServiceFunc serviceProc)
{
- return 1;
-}
+ char temp[MAX_PATH*2];
-int CSkypeProto::SetAwayMsg(int m_iStatus, const TCHAR* msg)
-{
- return NULL;
+ mir_snprintf(temp, sizeof(temp), "%s%s", this->m_szModuleName, szService);
+ CreateServiceFunctionObj(temp, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
}
-int CSkypeProto::UserIsTyping(HANDLE hContact, int type)
+char* CSkypeProto::ModuleName()
{
- return NULL;
+ return this->m_szProtoName;
}
-int CSkypeProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam)
+bool CSkypeProto::IsOffline()
{
- return NULL;
+ return this->isOffline;
} \ No newline at end of file