diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2012-10-21 16:51:03 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2012-10-21 16:51:03 +0000 |
commit | 7cbb90a5ab4982cfebd80d7a672078ac96489042 (patch) | |
tree | a6d46042b8c99ec0fde089efc4513b091603ebd6 /protocols/Skype | |
parent | 107bbb3d271e19fe11d9abc89021c691f5d91602 (diff) |
- fixed protocol connecting
git-svn-id: http://svn.miranda-ng.org/main/trunk@2028 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype')
-rw-r--r-- | protocols/Skype/src/skype_contacts.cpp | 2 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 93 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 4 | ||||
-rw-r--r-- | protocols/Skype/src/skype_subclassing.cpp | 6 | ||||
-rw-r--r-- | protocols/Skype/src/skype_subclassing.h | 2 |
5 files changed, 51 insertions, 56 deletions
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index d24f7d01fe..5b64c6b5fe 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -617,7 +617,7 @@ CContact::AVAILABILITY CSkypeProto::MirandaToSkypeStatus(int status) {
CContact::AVAILABILITY availability = CContact::UNKNOWN;
- switch(this->m_iStatus)
+ switch(status)
{
case ID_STATUS_ONLINE:
availability = CContact::ONLINE;
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 6c596b5f45..6ed5366ccc 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -1,6 +1,7 @@ #include "skype_proto.h"
CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName)
+ : login(L"")
{
this->m_iVersion = 2;
this->m_iStatus = ID_STATUS_OFFLINE;
@@ -10,7 +11,7 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) //_strlwr(m_szProtoName);
//this->m_szProtoName[0] = toupper(m_szProtoName[0]);
- this->login = NULL;
+ //this->login = NULL;
this->password = NULL;
this->rememberPassword = false;
@@ -267,29 +268,41 @@ int CSkypeProto::SetStatus(int new_status) int old_status = this->m_iStatus;
this->m_iDesiredStatus = new_status;
- if (new_status == ID_STATUS_OFFLINE && old_status != ID_STATUS_OFFLINE)
+ switch (new_status)
{
- this->m_iStatus = new_status;
+ case ID_STATUS_OFFLINE:
+ if ( this->account->IsOnline())
+ {
+ this->account->SetAvailability(CContact::OFFLINE);
+ this->account->Logout(true);
+ this->account->BlockWhileLoggingOut();
- this->account->Logout(true);
- this->account->BlockWhileLoggingOut();
- this->account->SetAvailability(CContact::OFFLINE);
- this->SetAllContactStatus(ID_STATUS_OFFLINE);
- }
- else
- {
- if (old_status == ID_STATUS_OFFLINE)
- if ( !this->SignIn())
- return 0;
-
- this->m_iStatus = new_status;
+ this->m_iStatus = new_status;
+ this->SetAllContactStatus(ID_STATUS_OFFLINE);
+ }
+ break;
+
+ default:
+ if (old_status == ID_STATUS_OFFLINE && !this->IsOnline())
+ {
+ this->m_iStatus = ID_STATUS_CONNECTING;
+ if ( !this->SignIn()) return 0;
- CContact::AVAILABILITY availability = this->MirandaToSkypeStatus(this->m_iStatus);
- if(availability != CContact::UNKNOWN)
- this->account->SetAvailability(availability);
+ }
+ else
+ {
+ CContact::AVAILABILITY availability = this->MirandaToSkypeStatus(new_status);
+ if (availability != CContact::UNKNOWN)
+ this->account->SetAvailability(availability);
+
+ this->m_iStatus = new_status;
+ }
+
+ break;
}
- this->SendBroadcast(ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, this->m_iStatus);
+ this->SetSettingWord("Status", this->m_iStatus);
+ this->SendBroadcastAsync(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, this->m_iStatus);
return 0;
}
@@ -301,6 +314,7 @@ int __cdecl CSkypeProto::SetAwayMsg( int m_iStatus, const TCHAR* msg ) { retu int __cdecl CSkypeProto::UserIsTyping( HANDLE hContact, int type )
{
+ // todo: rewrite
CConversation::Ref conversation;
g_skype->GetConversationByIdentity(::mir_u2a(this->GetSettingString(hContact, "sid")), conversation);
if (conversation) @@ -328,7 +342,7 @@ int __cdecl CSkypeProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPA return 1;
}
-void __cdecl CSkypeProto::SignInThread(void*)
+void __cdecl CSkypeProto::SignInAsync(void*)
{
WaitForSingleObject(&this->signin_lock, INFINITE);
@@ -348,11 +362,9 @@ void __cdecl CSkypeProto::SignInThread(void*) ACKRESULT_FAILED,
NULL,
this->SkypeToMirandaLoginError(this->account->logoutReason));
- ::MessageBox(
+ this->ShowNotification(
NULL,
- ::mir_a2u(this->account->logoutReasonString),
- _T("Skype"),
- MB_OK);
+ ::mir_a2u(this->account->logoutReasonString));
}
else
{
@@ -388,15 +400,15 @@ bool CSkypeProto::SignIn(bool isReadPassword) }
else if (g_skype->GetAccount(::mir_u2a(this->login), this->account))
{
- this->m_iStatus = ID_STATUS_CONNECTING;
- this->SendBroadcast(ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_OFFLINE, this->m_iStatus);
+ /*this->m_iStatus = ID_STATUS_CONNECTING;
+ this->SendBroadcast(ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_OFFLINE, this->m_iStatus); */
if (isReadPassword)
this->password = this->GetDecodeSettingString(SKYPE_SETTINGS_PASSWORD);
if (::wcscmp(this->password, L"") == 0)
this->RequestPassword();
else
{
- this->ForkThread(&CSkypeProto::SignInThread, this);
+ this->ForkThread(&CSkypeProto::SignInAsync, this);
//this->SignInThread(this);
return true;
}
@@ -407,7 +419,8 @@ bool CSkypeProto::SignIn(bool isReadPassword) bool CSkypeProto::IsOnline()
{
- return this->m_iStatus != ID_STATUS_OFFLINE;
+ return this->account && this->account->IsOnline();
+ //return this->m_iStatus != ID_STATUS_OFFLINE;
}
void CSkypeProto::RequestPassword()
@@ -429,28 +442,4 @@ void CSkypeProto::OnConversationAdded(CConversation::Ref conversation) {
conversation->SetOnMessageReceivedCallback(
(CConversation::OnMessageReceived)&CSkypeProto::OnOnMessageReceived, this);
-}
-
-void __cdecl CSkypeProto::SendMessageAsync(void* arg)
-{
- CCSDATA *ccs = static_cast<CCSDATA *>(arg);
-
- if ( !this->IsOnline())
- {
- this->SendBroadcast(
- ccs->hContact,
- ACKTYPE_MESSAGE,
- ACKRESULT_FAILED,
- (HANDLE)ccs->lParam,
- (LPARAM)"You cannot send when you are offline.");
- }
-
- CConversation::Ref conversation;
- g_skype->GetConversationByIdentity(::mir_u2a(this->GetSettingString(ccs->hContact, "sid")), conversation);
- if (conversation) - { - Message::Ref message; - conversation->SetMyTextStatusTo(Participant::WRITING); - conversation->PostText((char *)ccs->wParam, message); - }
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index b097201e26..b87adf872d 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -116,7 +116,7 @@ protected: HANDLE signin_lock;
bool SignIn(bool isReadPassword = true);
- void __cdecl SignInThread(void*);
+ void __cdecl SignInAsync(void*);
bool IsOnline();
@@ -124,8 +124,6 @@ protected: void OnOnMessageReceived(const char *sid, const char *text);
void OnConversationAdded(CConversation::Ref conversation);
- void __cdecl SendMessageAsync(void*);
-
// contacts
void UpdateContactAboutText(HANDLE hContact, CContact::Ref contact);
void UpdateContactAuthState(HANDLE hContact, CContact::Ref contact);
diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp index c6eaecd4c3..7f1bfc73a0 100644 --- a/protocols/Skype/src/skype_subclassing.cpp +++ b/protocols/Skype/src/skype_subclassing.cpp @@ -100,6 +100,12 @@ void CAccount::BlockWhileLoggingOut() Sleep(1); } +bool CAccount::IsOnline() +{ + return this->isLoggedIn; + //(CAccount::STATUS)this->GetUintProp(CAccount::P_STATUS) == Account::LOGGED_IN; +} + // CContactGroup CContactGroup::CContactGroup(unsigned int oid, SERootObject* root) : ContactGroup(oid, root) diff --git a/protocols/Skype/src/skype_subclassing.h b/protocols/Skype/src/skype_subclassing.h index 4835023894..578de49ef7 100644 --- a/protocols/Skype/src/skype_subclassing.h +++ b/protocols/Skype/src/skype_subclassing.h @@ -110,6 +110,8 @@ public: void BlockWhileLoggingIn(); void BlockWhileLoggingOut(); + bool IsOnline();
+
private:
void OnChange(int prop); }; |