summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2012-12-28 20:34:31 +0000
committerAlexander Lantsev <aunsane@gmail.com>2012-12-28 20:34:31 +0000
commit578c3d4a75046cc06dfa247b437f04fc542c36a9 (patch)
treed6cc8b80c086fdf1b13f5469b66bbaf341abc9e5 /protocols
parent121f8a3e433af878f1168d28035ad4fd17b7aa0b (diff)
- added password changing
git-svn-id: http://svn.miranda-ng.org/main/trunk@2875 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Skype/res/Resource.rc58
-rw-r--r--protocols/Skype/src/resource.h10
-rw-r--r--protocols/Skype/src/skype_account.cpp104
-rw-r--r--protocols/Skype/src/skype_contacts.cpp2
-rw-r--r--protocols/Skype/src/skype_dialogs.cpp210
-rw-r--r--protocols/Skype/src/skype_events.cpp4
-rw-r--r--protocols/Skype/src/skype_icons.cpp22
-rw-r--r--protocols/Skype/src/skype_netlib.cpp2
-rw-r--r--protocols/Skype/src/skype_proto.cpp58
-rw-r--r--protocols/Skype/src/skype_proto.h48
-rw-r--r--protocols/Skype/src/skype_subclassing.cpp2
-rw-r--r--protocols/Skype/src/skype_utils.cpp34
12 files changed, 392 insertions, 162 deletions
diff --git a/protocols/Skype/res/Resource.rc b/protocols/Skype/res/Resource.rc
index 1021f7335a..1087a57104 100644
--- a/protocols/Skype/res/Resource.rc
+++ b/protocols/Skype/res/Resource.rc
@@ -72,16 +72,16 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
// Dialog
//
-IDD_PASSWORDREQUEST DIALOGEX 0, 0, 157, 87
+IDD_PASSWORD_REQUEST DIALOGEX 0, 0, 157, 71
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Enter Skype Password"
+CAPTION "Enter password"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
LTEXT "Enter a password for skype name %d:",IDC_INSTRUCTION,7,7,142,8
EDITTEXT IDC_PASSWORD,17,16,122,14,ES_PASSWORD | ES_AUTOHSCROLL
- CONTROL "Remember this session password",IDC_SAVEPASSWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,54,120,10
- DEFPUSHBUTTON "OK",IDOK,24,66,50,14
- PUSHBUTTON "Cancel",IDCANCEL,84,66,50,14
+ CONTROL "Remember this session password",IDC_SAVEPASSWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,32,120,10
+ DEFPUSHBUTTON "OK",IDOK,46,50,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,99,50,50,14
END
IDD_INFO_SKYPE DIALOGEX 0, 0, 222, 132
@@ -111,6 +111,21 @@ BEGIN
EDITTEXT IDC_UPLOADING,2,138,127,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_VISIBLE | NOT WS_BORDER
END
+IDD_PASSWORD_CHANGE DIALOGEX 0, 0, 201, 90
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Change password"
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ LTEXT "Old password",IDC_INSTRUCTION,7,9,75,8
+ EDITTEXT IDC_PASSWORD,88,7,105,14,ES_PASSWORD | ES_AUTOHSCROLL
+ DEFPUSHBUTTON "OK",IDOK,88,69,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,142,69,51,14
+ LTEXT "New password",IDC_INSTRUCTION2,7,27,75,8
+ EDITTEXT IDC_PASSWORD2,88,24,105,14,ES_PASSWORD | ES_AUTOHSCROLL
+ LTEXT "Confirmation",IDC_INSTRUCTION3,7,44,75,8
+ EDITTEXT IDC_PASSWORD3,88,41,105,14,ES_PASSWORD | ES_AUTOHSCROLL
+END
+
/////////////////////////////////////////////////////////////////////////////
//
@@ -120,12 +135,12 @@ END
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
- IDD_PASSWORDREQUEST, DIALOG
+ IDD_PASSWORD_REQUEST, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 149
TOPMARGIN, 7
- BOTTOMMARGIN, 80
+ BOTTOMMARGIN, 64
END
IDD_INFO_SKYPE, DIALOG
@@ -149,6 +164,18 @@ BEGIN
TOPMARGIN, 2
BOTTOMMARGIN, 150
END
+
+ IDD_PASSWORD_CHANGE, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 193
+ VERTGUIDE, 82
+ VERTGUIDE, 88
+ VERTGUIDE, 138
+ VERTGUIDE, 142
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 83
+ END
END
#endif // APSTUDIO_INVOKED
@@ -186,16 +213,18 @@ EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
GROUPBOX "User Details",IDC_STATIC,7,7,291,60
- LTEXT "Skype login:",IDC_STATIC,17,19,61,8
+ LTEXT "Skype login:",IDC_STATIC,15,19,63,8
EDITTEXT IDC_SL,78,17,121,13,ES_AUTOHSCROLL
- LTEXT "Password:",IDC_STATIC,17,35,61,8
+ LTEXT "Password:",IDC_STATIC,15,35,63,8
EDITTEXT IDC_PW,78,33,121,13,ES_PASSWORD | ES_AUTOHSCROLL
GROUPBOX "Connection",IDC_STATIC,7,69,291,47
- LTEXT "Use port",IDC_STATIC,17,81,44,8
+ LTEXT "Use port",IDC_STATIC,15,81,44,8
EDITTEXT IDC_PORT,78,79,30,14,ES_AUTOHSCROLL | ES_NUMBER
- LTEXT "for incoming connections",IDC_STATIC,115,81,173,8
+ LTEXT "for incoming connections",IDC_STATIC,115,81,176,8
CONTROL "Use ports 80 and 443 as alternative incoming",IDC_USE_ALT_PORTS,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,97,271,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,97,276,10
+ PUSHBUTTON "Register new account",IDC_REGISTER,204,17,87,14,WS_DISABLED
+ PUSHBUTTON "Chande password",IDC_CHANGE_PWD,204,33,87,14,WS_DISABLED
END
@@ -222,12 +251,13 @@ BEGIN
IDD_OPT_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
- VERTGUIDE, 17
+ VERTGUIDE, 15
VERTGUIDE, 78
VERTGUIDE, 108
VERTGUIDE, 115
VERTGUIDE, 199
- VERTGUIDE, 288
+ VERTGUIDE, 204
+ VERTGUIDE, 291
VERTGUIDE, 298
TOPMARGIN, 7
BOTTOMMARGIN, 231
diff --git a/protocols/Skype/src/resource.h b/protocols/Skype/src/resource.h
index 85a839cbc9..053e98e51e 100644
--- a/protocols/Skype/src/resource.h
+++ b/protocols/Skype/src/resource.h
@@ -15,7 +15,9 @@
#define IDI_AUTH_REQUEST 104
#define IDI_AUTH_REVOKE 105
#define IDD_PASSWORDREQUEST 106
+#define IDD_PASSWORD_REQUEST 106
#define IDR_KEY 107
+#define IDD_PASSWORD_CHANGE 107
#define IDC_CCLIST 173
#define IDC_EDITSCR 174
#define IDC_ADDSCR 175
@@ -27,9 +29,13 @@
#define IDC_PASSWORD 1006
#define IDC_INSTRUCTION 1007
#define IDC_SID 1008
+#define IDC_INSTRUCTION2 1008
#define IDC_STATUSTEXT 1009
+#define IDC_PASSWORD2 1009
#define IDC_ONLINESINCE 1010
+#define IDC_INSTRUCTION3 1010
#define IDC_LASTEVENTDATE 1011
+#define IDC_PASSWORD3 1011
#define IDC_LASTPROFILECHANGE 1012
#define IDC_SAVE 1013
#define IDC_LIST 1014
@@ -37,8 +43,8 @@
#define IDC_PORT 1016
#define IDC_CHECK1 1017
#define IDC_USE_ALT_PORTS 1017
-#define IDC_BUTTON1 1018
#define IDC_REGISTER 1018
+#define IDC_CHANGE_PWD 1019
// Next default values for new objects
//
@@ -46,7 +52,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 108
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1019
+#define _APS_NEXT_CONTROL_VALUE 1020
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp
index 34cac051a5..6002061a6f 100644
--- a/protocols/Skype/src/skype_account.cpp
+++ b/protocols/Skype/src/skype_account.cpp
@@ -12,11 +12,6 @@ void CSkypeProto::OnAccountChanged(int prop)
{
this->ForkThread(&CSkypeProto::SignInAsync, 0);
//this->SignInAsync(this);
-
- CContact::AVAILABILITY status;
- this->account->GetPropAvailability(status);
- if (status != CContact::CONNECTING && status >= CContact::ONLINE)
- this->SetStatus(this->SkypeToMirandaStatus(status));
}
if (loginStatus == CAccount::LOGGED_OUT)
@@ -31,12 +26,28 @@ void CSkypeProto::OnAccountChanged(int prop)
ACKRESULT_FAILED,
NULL,
this->SkypeToMirandaLoginError(whyLogout));
-
+
this->ShowNotification(CSkypeProto::LogoutReasons[whyLogout - 1]);
+
+ if (this->rememberPassword && whyLogout == CAccount::INCORRECT_PASSWORD)
+ {
+ this->rememberPassword = false;
+ if (this->password)
+ ::mir_free(this->password);
+ }
}
}
break;
+ case CAccount::P_PWDCHANGESTATUS:
+ {
+ CAccount::PWDCHANGESTATUS status;
+ this->account->GetPropPwdchangestatus(status);
+ if (status != CAccount::PWD_CHANGING)
+ this->ShowNotification(CSkypeProto::PasswordChangeReasons[status]);
+ }
+ break;
+
//case CAccount::P_AVATAR_IMAGE:
case CAccount::P_AVATAR_TIMESTAMP:
this->UpdateProfileAvatar(this->account.fetch());
@@ -49,10 +60,91 @@ void CSkypeProto::OnAccountChanged(int prop)
case CAccount::P_PROFILE_TIMESTAMP:
this->UpdateProfile(this->account.fetch());
+ break;
+
+ /*case CAccount::P_AVAILABILITY:
+ {
+ CContact::AVAILABILITY status;
+ this->account->GetPropAvailability(status);
+ if (status != CContact::CONNECTING && status >= CContact::ONLINE)
+ this->SetStatus(this->SkypeToMirandaStatus(status));
+ }
+ break;*/
}
}
bool CSkypeProto::IsOnline()
{
return this->m_iStatus > ID_STATUS_OFFLINE;
+}
+
+void __cdecl CSkypeProto::SignInAsync(void*)
+{
+ if ( !this->rememberPassword)
+ ::mir_free(this->password);
+ else
+ {
+ ::CallService(MS_DB_CRYPT_ENCODESTRING, ::strlen(this->password), LPARAM(this->password));
+ }
+
+ this->LoadOwnInfo(this);
+ this->LoadContactList(this);
+
+ this->SetStatus(this->m_iDesiredStatus);
+}
+
+bool CSkypeProto::SignIn(int status)
+{
+ this->login = ::DBGetString(NULL, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
+ if ( !this->login || !::strlen(this->login))
+ {
+ this->m_iStatus = ID_STATUS_OFFLINE;
+ this->SendBroadcast(ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID);
+ this->ShowNotification(
+ TranslateT("You have not entered a Skype name.\n\
+ Configure this in Options->Network->Skype and try again."));
+ }
+ else if (this->skype->GetAccount(this->login, this->account))
+ {
+ if ( !this->rememberPassword)
+ {
+ if (this->password)
+ ::mir_free(this->password);
+ this->password = ::DBGetString(NULL, this->m_szModuleName, SKYPE_SETTINGS_PASSWORD);
+ if ( !this->password || !::strlen(this->password))
+ {
+ if (this->password)
+ ::mir_free(this->password);
+ PasswordRequestBoxParam param(this->login);
+ if ( !this->RequestPassword(param))
+ {
+ this->SetStatus(ID_STATUS_OFFLINE);
+ return false;
+ }
+ else
+ {
+ this->password = ::mir_strdup(param.password);
+ this->rememberPassword = param.rememberPassword;
+ }
+ }
+ else ::CallService(MS_DB_CRYPT_DECODESTRING, ::strlen(this->password), LPARAM(this->password));
+ }
+
+ this->account.fetch();
+ this->account->SetOnAccountChangedCallback(
+ (CAccount::OnAccountChanged)&CSkypeProto::OnAccountChanged,
+ this);
+
+ int port = this->GetSettingWord("Port", rand() % 10000 + 10000);
+ this->skype->SetInt(SETUPKEY_PORT, port);
+ this->skype->SetInt(SETUPKEY_DISABLE_PORT80, (int)!this->GetSettingByte("UseAlternativePorts", 1));
+
+ this->InitProxy();
+
+ this->account->LoginWithPassword(this->password, false, false);
+
+ return true;
+ }
+
+ return false;
} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp
index 9512deca75..2387a38fa2 100644
--- a/protocols/Skype/src/skype_contacts.cpp
+++ b/protocols/Skype/src/skype_contacts.cpp
@@ -473,7 +473,7 @@ void __cdecl CSkypeProto::SearchBySidAsync(void* arg)
HANDLE hContact = this->GetContactBySid(sid);
if (hContact)
{
- this->ShowNotification(TranslateT("Contact already in your contact list"), 0, sid);
+ this->ShowNotification(TranslateT("Contact already in your contact list"), 0, hContact);
this->SendBroadcast(ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)SKYPE_SEARCH_BYSID, 0);
return;
}
diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp
index 07895a63c8..1029751490 100644
--- a/protocols/Skype/src/skype_dialogs.cpp
+++ b/protocols/Skype/src/skype_dialogs.cpp
@@ -2,29 +2,37 @@
INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- CSkypeProto *proto;
+ CSkypeProto *proto = reinterpret_cast<CSkypeProto*>(::GetWindowLongPtr(hwnd, GWLP_USERDATA));
switch (message)
{
case WM_INITDIALOG:
{
- TranslateDialogDefault(hwnd);
+ ::TranslateDialogDefault(hwnd);
- proto = reinterpret_cast<CSkypeProto*>(lParam);
- SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
+ proto = (CSkypeProto*)lParam;
+ ::SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
{
- wchar_t* data = proto->GetSettingString(SKYPE_SETTINGS_LOGIN, L"");
- SetDlgItemText(hwnd, IDC_SL, data);
- ::mir_free(data);
+ char *sid = ::DBGetString(NULL, proto->m_szModuleName, SKYPE_SETTINGS_LOGIN);
+ SetDlgItemTextA(hwnd, IDC_SL, sid);
+ ::mir_free(sid);
}
{
- char *data = proto->GetDecodeSettingString(NULL, SKYPE_SETTINGS_PASSWORD, "");
- SetDlgItemTextA(hwnd, IDC_PW, data);
- ::mir_free(data);
+ char *pwd = ::DBGetString(NULL, proto->m_szModuleName, SKYPE_SETTINGS_PASSWORD);
+
+ if (pwd)
+ {
+ ::CallService(
+ MS_DB_CRYPT_DECODESTRING,
+ ::strlen(pwd),
+ reinterpret_cast<LPARAM>(pwd));
+ }
+
+ SetDlgItemTextA(hwnd, IDC_PW, pwd);
+ ::mir_free(pwd);
}
{
- int port;
- proto->skype->GetInt(SETUPKEY_PORT, port);
+ int port = rand() % 10000 + 10000;
SetDlgItemInt(hwnd, IDC_PORT, proto->GetSettingWord("Port", port), FALSE);
SendMessage(GetDlgItem(hwnd, IDC_PORT), EM_SETLIMITTEXT, 5, 0);
}
@@ -38,6 +46,7 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR
SendMessage(GetDlgItem(hwnd, IDC_PORT), EM_SETREADONLY, 1, 0);
SendMessage(GetDlgItem(hwnd, IDC_USE_ALT_PORTS), EM_SETREADONLY, 1, 0);
EnableWindow(GetDlgItem(hwnd, IDC_REGISTER), FALSE);
+ EnableWindow(GetDlgItem(hwnd, IDC_CHANGE_PWD), TRUE);
}
else if (proto->GetSettingWord("Status") > 0)
{
@@ -48,8 +57,6 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR
case WM_COMMAND:
{
- proto = reinterpret_cast<CSkypeProto*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
-
switch(LOWORD(wParam))
{
case IDC_SL:
@@ -58,9 +65,9 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR
if ( !proto->IsOnline() && proto->GetSettingWord("Status") == 0)
{
- char data[128];
- GetDlgItemTextA(hwnd, IDC_SL, data, SIZEOF(data));
- EnableWindow(GetDlgItem(hwnd, IDC_REGISTER), ::strlen(data));
+ char sid[128];
+ GetDlgItemTextA(hwnd, IDC_SL, sid, SIZEOF(sid));
+ EnableWindow(GetDlgItem(hwnd, IDC_REGISTER), ::strlen(sid));
}
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
}
@@ -69,6 +76,12 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR
case IDC_PW:
{
if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())) return 0;
+ if (proto->IsOnline())
+ {
+ char pwd[128];
+ GetDlgItemTextA(hwnd, IDC_SL, pwd, SIZEOF(pwd));
+ EnableWindow(GetDlgItem(hwnd, IDC_CHANGE_PWD), ::strlen(pwd));
+ }
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
}
break;
@@ -101,28 +114,45 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR
proto->ShowNotification(CSkypeProto::ValidationReasons[reason]);
}
}
+
+ case IDC_CHANGE_PWD:
+ {
+ char sid[128], pwd[128];
+ GetDlgItemTextA(hwnd, IDC_SL, sid, SIZEOF(sid));
+ GetDlgItemTextA(hwnd, IDC_PW, pwd, SIZEOF(pwd));
+
+ PasswordChangeBoxParam param;
+ if (proto->ChangePassword(param))
+ {
+ proto->account->ChangePassword(param.password, param.password2);
+ }
+ }
+ break;
}
}
break;
case WM_NOTIFY:
- if (reinterpret_cast<NMHDR*>(lParam)->code == PSN_APPLY)
+ if (reinterpret_cast<NMHDR*>(lParam)->code == PSN_APPLY && !proto->IsOnline())
{
- proto = reinterpret_cast<CSkypeProto*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
-
char data[128];
- ::mir_free(proto->login);
GetDlgItemTextA(hwnd, IDC_SL, data, SIZEOF(data));
::DBWriteContactSettingString(NULL, proto->m_szModuleName, "sid", data);
+ ::mir_free(proto->login);
proto->login = ::mir_strdup(data);
GetDlgItemTextA(hwnd, IDC_PW, data, sizeof(data));
- proto->SetDecodeSettingString(NULL, SKYPE_SETTINGS_PASSWORD, data);
+ ::CallService(MS_DB_CRYPT_ENCODESTRING, strlen(data), LPARAM((char*)data));
+ ::DBWriteContactSettingString(NULL, proto->m_szModuleName, SKYPE_SETTINGS_PASSWORD, data);
- proto->SetSettingWord("Port", GetDlgItemInt(hwnd, IDC_PORT, NULL, FALSE));
- proto->GetSettingByte("UseAlternativePorts", IsDlgButtonChecked( hwnd, IDC_USE_ALT_PORTS ) > 0);
-
- proto->SetSettingByte("RememberPassword", true);
+ HWND item = GetDlgItem(hwnd, IDC_PORT);
+ if (item)
+ {
+ BOOL error;
+ int port = GetDlgItemInt(hwnd, IDC_PORT, &error, FALSE);
+ proto->SetSettingWord("Port", port);
+ proto->GetSettingByte("UseAlternativePorts", IsDlgButtonChecked( hwnd, IDC_USE_ALT_PORTS ) > 0);
+ }
return TRUE;
}
@@ -136,7 +166,7 @@ INT_PTR __cdecl CSkypeProto::OnAccountManagerInit(WPARAM wParam, LPARAM lParam)
{
return (int)::CreateDialogParam(
g_hInstance,
- MAKEINTRESOURCE(IDD_SKYPEACCOUNT),
+ MAKEINTRESOURCE(IDD_ACCMGR),
(HWND)lParam,
&CSkypeProto::SkypeMainOptionsProc,
(LPARAM)this);
@@ -154,45 +184,101 @@ int __cdecl CSkypeProto::OnOptionsInit(WPARAM wParam, LPARAM lParam)
odp.position = 271828;
odp.ptszGroup = LPGENT("Network");
odp.ptszTab = LPGENT("Account");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MAIN);
odp.pfnDlgProc = SkypeMainOptionsProc;
::Options_AddPage(wParam, &odp);
return 0;
}
-INT_PTR CALLBACK CSkypeProto::SkypePasswordProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK CSkypeProto::SkypePasswordRequestProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- CSkypeProto* ppro = (CSkypeProto*)::GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ PasswordRequestBoxParam *param = reinterpret_cast<PasswordRequestBoxParam*>(::GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
- switch (msg) {
+ switch (msg)
+ {
case WM_INITDIALOG:
::TranslateDialogDefault(hwndDlg);
- ppro = (CSkypeProto*)lParam;
- ::SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
+ param = (PasswordRequestBoxParam *)lParam;
+ ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
{
- ::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)CSkypeProto::iconList[0].Handle);
- ::SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)CSkypeProto::iconList[0].Handle);
+ ::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)CSkypeProto::IconList[0].Handle);
+ ::SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)CSkypeProto::IconList[0].Handle);
- wchar_t skypeName[MAX_PATH];
+ wchar_t title[MAX_PATH];
::mir_sntprintf(
- skypeName,
+ title,
MAX_PATH,
- TranslateT("Enter a password for Skype Name %s:"),
- ppro->login);
- ::SetDlgItemText(hwndDlg, IDC_INSTRUCTION, skypeName);
+ ::TranslateT("Enter a password for Skype Name %s:"),
+ ::mir_a2u(param->login));
+ ::SetDlgItemText(hwndDlg, IDC_INSTRUCTION, title);
::SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_LIMITTEXT, 128 - 1, 0);
- ::CheckDlgButton(hwndDlg, IDC_SAVEPASSWORD, ppro->GetSettingByte(NULL, "RememberPassword", 0));
+ ::CheckDlgButton(hwndDlg, IDC_SAVEPASSWORD, param->rememberPassword);
+ ::ShowWindow(::GetDlgItem(hwndDlg, IDC_SAVEPASSWORD), param->showRememberPasswordBox);
}
break;
- //case WM_DESTROY:
- //ppro->m_hIconProtocol->ReleaseIcon(true);
- //ppro->m_hIconProtocol->ReleaseIcon();
- //break;
+ case WM_CLOSE:
+ EndDialog(hwndDlg, 0);
+ break;
+
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ {
+ param->rememberPassword = ::IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD) > 0;
+
+ char password[SKYPE_PASSWORD_LIMIT];
+ ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD, password, SIZEOF(password));
+ param->password = ::mir_strdup(password);
+
+ ::EndDialog(hwndDlg, IDOK);
+ }
+ break;
+
+ case IDCANCEL:
+ ::EndDialog(hwndDlg, IDCANCEL);
+ break;
+ }
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+bool CSkypeProto::RequestPassword(PasswordRequestBoxParam &param)
+{
+ int value = ::DialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_PASSWORD_REQUEST),
+ NULL,
+ CSkypeProto::SkypePasswordRequestProc,
+ (LPARAM)&param);
+ return value == 1;
+}
+
+INT_PTR CALLBACK CSkypeProto::SkypePasswordChangeProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ PasswordChangeBoxParam *param = reinterpret_cast<PasswordChangeBoxParam*>(::GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ ::TranslateDialogDefault(hwndDlg);
+
+ param = (PasswordChangeBoxParam *)lParam;
+ ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ {
+ ::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)CSkypeProto::IconList[0].Handle);
+ ::SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)CSkypeProto::IconList[0].Handle);
+ }
+ break;
case WM_CLOSE:
EndDialog(hwndDlg, 0);
@@ -200,23 +286,26 @@ INT_PTR CALLBACK CSkypeProto::SkypePasswordProc(HWND hwndDlg, UINT msg, WPARAM w
case WM_COMMAND:
{
- switch (LOWORD(wParam)) {
+ switch (LOWORD(wParam))
+ {
case IDOK:
- ppro->rememberPassword = ::IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD) > 0;
- ppro->SetSettingByte("RememberPassword", ppro->rememberPassword);
+ {
+ char oldPwd[SKYPE_PASSWORD_LIMIT];
+ ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD, oldPwd, SIZEOF(oldPwd));
+ param->password = ::mir_strdup(oldPwd);
- ::mir_free(ppro->password);
- char password[SKYPE_PASSWORD_LIMIT];
- ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD, password, sizeof(password));
- ppro->password = ::mir_strdup(password);
+ char pwd1[SKYPE_PASSWORD_LIMIT];
+ ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD2, pwd1, SIZEOF(pwd1));
+ param->password2 = ::mir_strdup(pwd1);
- ppro->SignIn(false);
+ char pwd2[SKYPE_PASSWORD_LIMIT];
+ ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD3, pwd2, SIZEOF(pwd2));
- ::EndDialog(hwndDlg, IDOK);
+ ::EndDialog(hwndDlg, IDOK);
+ }
break;
case IDCANCEL:
- ppro->SetStatus(ID_STATUS_OFFLINE);
::EndDialog(hwndDlg, IDCANCEL);
break;
}
@@ -227,6 +316,17 @@ INT_PTR CALLBACK CSkypeProto::SkypePasswordProc(HWND hwndDlg, UINT msg, WPARAM w
return FALSE;
}
+bool CSkypeProto::ChangePassword(PasswordChangeBoxParam &param)
+{
+ int value = ::DialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_PASSWORD_CHANGE),
+ NULL,
+ CSkypeProto::SkypePasswordChangeProc,
+ (LPARAM)&param);
+ return value == 1;
+}
+
INT_PTR CALLBACK CSkypeProto::SkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp
index 348b8ef463..fcacb7117f 100644
--- a/protocols/Skype/src/skype_events.cpp
+++ b/protocols/Skype/src/skype_events.cpp
@@ -11,8 +11,8 @@ int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM)
this->HookEvent(ME_OPT_INITIALISE, &CSkypeProto::OnOptionsInit);
this->HookEvent(ME_USERINFO_INITIALISE, &CSkypeProto::OnUserInfoInit);
- this->login = ::DBGetString(NULL, this->m_szModuleName, "sid");
- this->rememberPassword = this->GetSettingByte("RememberPassword") > 0;
+ //this->login = ::DBGetString(NULL, this->m_szModuleName, "sid");
+ //this->rememberPassword = this->GetSettingByte("RememberPassword") > 0;
return 0;
}
diff --git a/protocols/Skype/src/skype_icons.cpp b/protocols/Skype/src/skype_icons.cpp
index 3c20e742e7..9a739f57ae 100644
--- a/protocols/Skype/src/skype_icons.cpp
+++ b/protocols/Skype/src/skype_icons.cpp
@@ -1,6 +1,6 @@
#include "skype_proto.h"
-_tag_iconList CSkypeProto::iconList[] =
+_tag_iconList CSkypeProto::IconList[] =
{
{ LPGENT("Protocol icon"), "main", IDI_ICON },
{ LPGENT("Revoke authorization"), "authRevoke", IDI_AUTH_REVOKE },
@@ -24,30 +24,30 @@ void CSkypeProto::InitIcons()
sid.ptszSection = szSectionName;
::mir_sntprintf(szSectionName, SIZEOF(szSectionName), _T("%s/%s"), LPGENT("Protocols"), LPGENT(MODULE));
- for (int i = 0; i < SIZEOF(iconList); i++)
+ for (int i = 0; i < SIZEOF(CSkypeProto::IconList); i++)
{
- ::mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", MODULE, iconList[i].Name);
+ ::mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", MODULE, CSkypeProto::IconList[i].Name);
- sid.ptszDescription = iconList[i].Description;
- sid.iDefaultIndex = -iconList[i].IconId;
- iconList[i].Handle = ::Skin_AddIcon(&sid);
+ sid.ptszDescription = CSkypeProto::IconList[i].Description;
+ sid.iDefaultIndex = -CSkypeProto::IconList[i].IconId;
+ CSkypeProto::IconList[i].Handle = ::Skin_AddIcon(&sid);
}
}
HANDLE CSkypeProto::GetIconHandle(const char* name)
{
- for (size_t i = 0; i < SIZEOF(CSkypeProto::iconList); i++)
+ for (size_t i = 0; i < SIZEOF(CSkypeProto::IconList); i++)
{
- if (::strcmp(CSkypeProto::iconList[i].Name, name) == 0)
- return CSkypeProto::iconList[i].Handle;
+ if (::strcmp(CSkypeProto::IconList[i].Name, name) == 0)
+ return CSkypeProto::IconList[i].Handle;
}
return 0;
}
void CSkypeProto::UninitIcons()
{
- for (size_t i = 0; i < SIZEOF(CSkypeProto::iconList); i++)
+ for (size_t i = 0; i < SIZEOF(CSkypeProto::IconList); i++)
{
- ::Skin_RemoveIcon(CSkypeProto::iconList[i].Name);
+ ::Skin_RemoveIcon(CSkypeProto::IconList[i].Name);
}
} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_netlib.cpp b/protocols/Skype/src/skype_netlib.cpp
index 1f6f5a8dc4..eb73cf90e0 100644
--- a/protocols/Skype/src/skype_netlib.cpp
+++ b/protocols/Skype/src/skype_netlib.cpp
@@ -81,7 +81,7 @@ void CSkypeProto::InitProxy()
}
}
-void CSkypeProto::Log(const wchar_t* fmt, ...)
+void CSkypeProto::Log(const wchar_t *fmt, ...)
{
va_list va;
wchar_t msg[1024];
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index 48a32e32db..907a36047a 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -267,7 +267,7 @@ int CSkypeProto::SetStatus(int new_status)
switch (new_status)
{
case ID_STATUS_OFFLINE:
- if (this->IsOnline())
+ if (this->IsOnline() || this->m_iStatus == ID_STATUS_CONNECTING)
{
this->account->SetAvailability(CContact::OFFLINE);
this->account->Logout(true);
@@ -281,7 +281,7 @@ int CSkypeProto::SetStatus(int new_status)
if (old_status == ID_STATUS_OFFLINE && !this->IsOnline())
{
this->m_iStatus = ID_STATUS_CONNECTING;
- if ( !this->SignIn()) return 0;
+ if ( !this->SignIn(this->m_iDesiredStatus)) return 0;
}
else
{
@@ -351,58 +351,4 @@ int __cdecl CSkypeProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPA
}
return 1;
-}
-
-void __cdecl CSkypeProto::SignInAsync(void*)
-{
- this->LoadOwnInfo(this);
- this->LoadContactList(this);
-}
-
-bool CSkypeProto::SignIn(bool isReadPassword)
-{
- if ( !this->login || !::strlen(this->login))
- {
- this->m_iStatus = ID_STATUS_OFFLINE;
- this->SendBroadcast(ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID);
- this->ShowNotification(
- TranslateT("You have not entered a Skype name.\n\
- Configure this in Options->Network->Skype and try again."));
- }
- else if (this->skype->GetAccount(this->login, this->account))
- {
- if (isReadPassword)
- this->password = this->GetDecodeSettingString(NULL, SKYPE_SETTINGS_PASSWORD);
- if ( !this->password || !::strlen(this->password))
- this->RequestPassword();
- else
- {
- this->account.fetch();
- this->account->SetOnAccountChangedCallback(
- (CAccount::OnAccountChanged)&CSkypeProto::OnAccountChanged,
- this);
- //
- int port;
- this->skype->GetInt(SETUPKEY_PORT, port);
- this->skype->SetInt(SETUPKEY_PORT, this->GetSettingWord("Port", port));
- this->skype->SetInt(SETUPKEY_DISABLE_PORT80, (int)!this->GetSettingByte("UseAlternativePorts", 1));
- //
- this->InitProxy();
- //
- this->account->LoginWithPassword(this->password, false, false);
- return true;
- }
- }
-
- return false;
-}
-
-void CSkypeProto::RequestPassword()
-{
- ::DialogBoxParam(
- g_hInstance,
- MAKEINTRESOURCE(IDD_PASSWORDREQUEST),
- NULL,
- CSkypeProto::SkypePasswordProc,
- LPARAM(this));
} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index be81d8fd60..e081bf4874 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -145,6 +145,40 @@ struct InviteChatParam
{ ::mir_free(id); }
};
+struct PasswordRequestBoxParam
+{
+ char *login;
+ char *password;
+ bool rememberPassword;
+ bool showRememberPasswordBox;
+
+ PasswordRequestBoxParam(const char *login, bool showRememberPasswordBox = true, bool rememberPassword = false) :
+ login(::mir_strdup(login)),
+ password(NULL),
+ rememberPassword(rememberPassword),
+ showRememberPasswordBox(showRememberPasswordBox) { }
+
+ ~PasswordRequestBoxParam()
+ {
+ if (login) ::mir_free(login);
+ if (password) ::mir_free(password);
+ }
+};
+
+struct PasswordChangeBoxParam
+{
+ char *password;
+ char *password2;
+
+ PasswordChangeBoxParam() { }
+
+ ~PasswordChangeBoxParam()
+ {
+ if (password) ::mir_free(password);
+ if (password2) ::mir_free(password2);
+ }
+};
+
struct CSkypeProto : public PROTO_INTERFACE, public MZeroedObject
{
public:
@@ -249,14 +283,16 @@ protected:
char *login;
char *password;
bool rememberPassword;
- void RequestPassword();
+ bool RequestPassword(PasswordRequestBoxParam &param);
+ bool ChangePassword(PasswordChangeBoxParam &param);
HANDLE signin_lock;
- bool SignIn(bool isReadPassword = true);
+ bool SignIn(int status);
void __cdecl SignInAsync(void*);
static wchar_t* LogoutReasons[];
static wchar_t* ValidationReasons[];
+ static wchar_t* PasswordChangeReasons[];
static LanguagesListEntry languages[223];
// messages
@@ -353,7 +389,8 @@ protected:
int SkypeToMirandaLoginError(CAccount::LOGOUTREASON logoutReason);
- static void ShowNotification(const wchar_t *message, int flags = 0, const char *nick = NULL);
+ static void ShowNotification(const wchar_t *message, int flags = 0, HANDLE hContact = NULL);
+ static void ShowNotification(const wchar_t *caption, const wchar_t *message, int flags = 0, HANDLE hContact = NULL);
static char *RemoveHtml(char *data);
@@ -398,7 +435,7 @@ protected:
INT_PTR __cdecl SetMyAvatar(WPARAM, LPARAM);
// icons
- static _tag_iconList iconList[];
+ static _tag_iconList IconList[];
// menu
HGENMENU m_hMenuRoot;
@@ -456,7 +493,8 @@ protected:
// dialog procs
static INT_PTR CALLBACK SkypeMainOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
- static INT_PTR CALLBACK SkypePasswordProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+ static INT_PTR CALLBACK SkypePasswordRequestProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+ static INT_PTR CALLBACK SkypePasswordChangeProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK SkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK OwnSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp
index 50b4e67f4f..f5642f83e5 100644
--- a/protocols/Skype/src/skype_subclassing.cpp
+++ b/protocols/Skype/src/skype_subclassing.cpp
@@ -245,7 +245,7 @@ int CSkype::StartSkypeRuntime(HINSTANCE hInstance, const wchar_t *profileName, i
while (::Process32Next(snapshot, &entry) == TRUE) {
if (::wcsicmp(entry.szExeFile, L"SkypeKit.exe") == 0) {
HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
- port += rand() % 1000;
+ port += rand() % 8963 + 1000;
::CloseHandle(hProcess);
break;
}
diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp
index fb27c18c23..9ce2b8fa10 100644
--- a/protocols/Skype/src/skype_utils.cpp
+++ b/protocols/Skype/src/skype_utils.cpp
@@ -46,6 +46,18 @@ wchar_t* CSkypeProto::ValidationReasons[] =
LPGENW("Value starts with an invalid character") /* STARTS_WITH_INVALID_CHAR */,
};
+wchar_t* CSkypeProto::PasswordChangeReasons[] =
+{
+ LPGENW("Password change succeeded") /* PWD_OK */,
+ LPGENW("") /* PWD_CHANGING */,
+ LPGENW("Old password was incorrect") /* PWD_INVALID_OLD_PASSWORD */,
+ LPGENW("Failed to verify password. No connection to server") /* PWD_SERVER_CONNECT_FAILED */,
+ LPGENW("Password was set but server didn't like it much") /* PWD_OK_BUT_CHANGE_SUGGESTED */,
+ LPGENW("New password was exactly the same as old one") /* PWD_MUST_DIFFER_FROM_OLD */,
+ LPGENW("The new password was unacceptable") /* PWD_INVALID_NEW_PWD */,
+ LPGENW("Account was currently not logged in") /* PWD_MUST_LOG_IN_TO_CHANGE */,
+};
+
LanguagesListEntry CSkypeProto::languages[] =
{
{"Abkhazian", "ab"},
@@ -468,20 +480,21 @@ int CSkypeProto::SkypeToMirandaLoginError(CAccount::LOGOUTREASON logoutReason)
return loginError;
}
-void CSkypeProto::ShowNotification(const wchar_t *message, int flags, const char *nick)
+void CSkypeProto::ShowNotification(const wchar_t *caption, const wchar_t *message, int flags, HANDLE hContact)
{
if (::Miranda_Terminated()) return;
if ( !::ServiceExists(MS_POPUP_ADDPOPUPT) || !::DBGetContactSettingByte(NULL, "PopUp", "ModuleIsEnabled", 1))
- ::MessageBoxW(NULL, message, TranslateT("Skype Protocol"), MB_OK | flags);
- else {
- if ( !nick)
- nick = "";
-
+ ::MessageBoxW(NULL, message, caption, MB_OK | flags);
+ else
+ {
POPUPDATAT_V2 ppd = {0};
ppd.cbSize = sizeof(POPUPDATAT_V2);
- ppd.lchContact = NULL;
- lstrcpyn(ppd.lpwzContactName, ::mir_a2u(nick), MAX_CONTACTNAME);
+ ppd.lchContact = hContact;
+ if (!hContact)
+ {
+ lstrcpyn(ppd.lpwzContactName, caption, MAX_CONTACTNAME);
+ }
lstrcpyn(ppd.lpwzText, message, MAX_SECONDLINE);
ppd.lchIcon = ::Skin_GetIcon("Skype_main");
ppd.colorBack = ppd.colorText = 0;
@@ -491,6 +504,11 @@ void CSkypeProto::ShowNotification(const wchar_t *message, int flags, const char
}
}
+void CSkypeProto::ShowNotification(const wchar_t *message, int flags, HANDLE hContact)
+{
+ CSkypeProto::ShowNotification(TranslateT("Skype Protocol"), message, flags, hContact);
+}
+
char *CSkypeProto::RemoveHtml(char *text)
{
std::string new_string = "";