diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2013-04-27 09:49:47 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2013-04-27 09:49:47 +0000 |
commit | c7fa62a343fe1e5937602c216ec5d7e597462768 (patch) | |
tree | 9523b43b24459fcb89d42adf190aee7636f17802 /protocols/Skype | |
parent | 5aadfaa9bcaa25825e33f75f49f713a43670d925 (diff) |
- fixed rtl in incoming messages
- fixed contacts nick loading
git-svn-id: http://svn.miranda-ng.org/main/trunk@4550 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype')
-rw-r--r-- | protocols/Skype/src/skype_account.cpp | 1 | ||||
-rw-r--r-- | protocols/Skype/src/skype_contacts.cpp | 22 | ||||
-rw-r--r-- | protocols/Skype/src/skype_database.cpp | 22 | ||||
-rw-r--r-- | protocols/Skype/src/skype_events.cpp | 114 | ||||
-rw-r--r-- | protocols/Skype/src/skype_profile.cpp | 20 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 13 |
6 files changed, 107 insertions, 85 deletions
diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp index 7091dc35ab..fa29bafbef 100644 --- a/protocols/Skype/src/skype_account.cpp +++ b/protocols/Skype/src/skype_account.cpp @@ -254,7 +254,6 @@ void CSkypeProto::OnCblUpdated() {
// reload our CL after skype CL fully synced
this->LoadContactList(reinterpret_cast<void *>(static_cast<int>(false)));
- this->LoadAuthWaitList(this);
}
void CSkypeProto::OnLoggedOut(CAccount::LOGOUTREASON reason)
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index 11f36f8c43..0f805c2326 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -44,6 +44,17 @@ void CSkypeProto::UpdateContactStatus(HANDLE hContact, CContact::Ref contact) }
}
+void CSkypeProto::UpdateContactNickName(SEObject *obj, HANDLE hContact)
+{
+ // todo: P_DISPLAYNAME = 21 is unworked
+ wchar_t *nick = ::mir_utf8decodeW(obj->GetStrProp(/* *::P_FULLNAME */ 5));
+ if ( !::wcslen(nick))
+ ::db_unset(hContact, this->m_szModuleName, "Nick");
+ else
+ ::db_set_ws(hContact, this->m_szModuleName, "Nick", nick);
+ ::mir_free(nick);
+}
+
void CSkypeProto::UpdateContactOnlineSinceTime(SEObject *obj, HANDLE hContact)
{
uint newTS = obj->GetUintProp(/* CContact::P_LASTONLINE_TIMESTAMP */35);
@@ -267,7 +278,16 @@ void __cdecl CSkypeProto::LoadContactList(void* data) this->UpdateContactAuthState(hContact, contact);
this->UpdateContactStatus(hContact, contact);
- this->UpdateProfileNickName(contact.fetch(), hContact);
+ wchar_t *nick = ::db_get_wsa(hContact, "CList", "MyHandle");
+ if ( !nick || !::wcslen(nick))
+ {
+ SEString data;
+ contact->GetPropFullname(data);
+
+ mir_ptr<wchar_t> nick = ::mir_utf8decodeW(data);
+ ::db_set_ws(hContact, "CList", "MyHandle", nick);
+ }
+
this->UpdateProfile(contact.fetch(), hContact);
}
}
diff --git a/protocols/Skype/src/skype_database.cpp b/protocols/Skype/src/skype_database.cpp index 9ed2a21797..86bd7a49ac 100644 --- a/protocols/Skype/src/skype_database.cpp +++ b/protocols/Skype/src/skype_database.cpp @@ -91,9 +91,9 @@ void CSkypeProto::RaiseAuthRequestEvent(DWORD timestamp, CContact::Ref contact) this->AddDBEvent(hContact, EVENTTYPE_AUTHREQUEST, time(NULL), PREF_UTF, cbBlob, pBlob);
}
-void CSkypeProto::RaiseMessageReceivedEvent(HANDLE hContact, DWORD timestamp, const char *guid, const wchar_t *message, bool isNeedCheck)
+void CSkypeProto::RaiseMessageReceivedEvent(HANDLE hContact, DWORD timestamp, const char *guid, const char *message, bool isUnreaded)
{
- if (isNeedCheck)
+ if ( !isUnreaded)
if (this->IsMessageInDB(hContact, timestamp, guid))
return;
@@ -101,23 +101,33 @@ void CSkypeProto::RaiseMessageReceivedEvent(HANDLE hContact, DWORD timestamp, co recv.flags = PREF_UTF;
recv.lParam = (LPARAM)guid;
recv.timestamp = timestamp;
- recv.szMessage = ::mir_utf8encodeW(message);
+ recv.szMessage = ::mir_strdup(message);
::ProtoChainRecvMsg(hContact, &recv);
}
-void CSkypeProto::RaiseMessageSendedEvent(HANDLE hContact, DWORD timestamp, const char *guid, const wchar_t *message)
+void CSkypeProto::RaiseMessageSendedEvent(HANDLE hContact, DWORD timestamp, const char *guid, const char *message, bool isUnreaded)
{
if (this->IsMessageInDB(hContact, timestamp, guid, DBEF_SENT))
return;
int guidLen = ::strlen(guid);
- char *msg = ::mir_utf8encodeW(message);
+ char *msg = ::mir_strdup(message);
int msgLen = ::strlen(msg) + 1;
msg = (char *)::mir_realloc(msg, msgLen + 32);
::memcpy((char *)&msg[msgLen], guid, 32);
- this->AddDBEvent(hContact, EVENTTYPE_MESSAGE, timestamp, PREF_UTF | DBEF_SENT, msgLen + guidLen, (PBYTE)msg);
+ DWORD flags = DBEF_UTF | DBEF_SENT;
+ if ( !isUnreaded)
+ flags |= DBEF_READ;
+
+ this->AddDBEvent(
+ hContact,
+ EVENTTYPE_MESSAGE,
+ timestamp,
+ flags,
+ msgLen + guidLen,
+ (PBYTE)msg);
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index 28a003453d..c41ff0975c 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -65,6 +65,58 @@ int CSkypeProto::OnMessagePreCreate(WPARAM, LPARAM lParam) return 1;
}
+void CSkypeProto::OnMessageReceived(CConversation::Ref &conversation, CMessage::Ref &message)
+{
+ SEString data;
+
+ uint timestamp;
+ message->GetPropTimestamp(timestamp);
+
+ CMessage::CONSUMPTION_STATUS status;
+ message->GetPropConsumptionStatus(status);
+
+ message->GetPropBodyXml(data);
+ char *text = CSkypeProto::RemoveHtml(data);
+
+ CConversation::TYPE type;
+ conversation->GetPropType(type);
+ if (type == CConversation::DIALOG)
+ {
+ message->GetPropAuthor(data);
+
+ CContact::Ref author;
+ g_skype->GetContact(data, author);
+
+ HANDLE hContact = this->AddContact(author);
+
+ SEBinary guid;
+ message->GetPropGuid(guid);
+
+ char *cguid = ::mir_strdup(guid.data());
+ cguid[guid.size()] = 0;
+
+ this->RaiseMessageReceivedEvent(
+ hContact,
+ timestamp,
+ cguid,
+ text,
+ status == CMessage::UNCONSUMED_NORMAL);
+ }
+ else
+ {
+ message->GetPropAuthor(data);
+ wchar_t *sid = ::mir_utf8decodeW(data);
+
+ conversation->GetPropIdentity(data);
+ wchar_t *cid = ::mir_utf8decodeW(data);
+
+ this->SendChatMessage(cid, sid, ::mir_utf8decodeW(text));
+
+ ::mir_free(sid);
+ ::mir_free(cid);
+ }
+}
+
void CSkypeProto::OnMessageSended(CConversation::Ref &conversation, CMessage::Ref &message)
{
SEString data;
@@ -79,7 +131,7 @@ void CSkypeProto::OnMessageSended(CConversation::Ref &conversation, CMessage::Re message->GetPropConsumptionStatus(status);
message->GetPropBodyXml(data);
- wchar_t *text = ::mir_utf8decodeW(CSkypeProto::RemoveHtml(data));
+ char *text = CSkypeProto::RemoveHtml(data);
CConversation::TYPE type;
conversation->GetPropType(type);
@@ -112,7 +164,8 @@ void CSkypeProto::OnMessageSended(CConversation::Ref &conversation, CMessage::Re hContact,
timestamp,
cguid,
- text);
+ text,
+ status == CMessage::UNCONSUMED_NORMAL);
}
}
else
@@ -126,68 +179,13 @@ void CSkypeProto::OnMessageSended(CConversation::Ref &conversation, CMessage::Re nick = ::db_get_wsa(NULL, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
}
- this->SendChatMessage(cid, nick, text);
+ this->SendChatMessage(cid, nick, ::mir_utf8decodeW(text));
::mir_free(nick);
::mir_free(cid);
}
-
- ::mir_free(text);
}
-void CSkypeProto::OnMessageReceived(CConversation::Ref &conversation, CMessage::Ref &message)
-{
- SEString data;
-
- uint timestamp;
- message->GetPropTimestamp(timestamp);
-
- CMessage::CONSUMPTION_STATUS status;
- message->GetPropConsumptionStatus(status);
-
- message->GetPropBodyXml(data);
- wchar_t *text = ::mir_utf8decodeW(CSkypeProto::RemoveHtml(data));
-
- CConversation::TYPE type;
- conversation->GetPropType(type);
- if (type == CConversation::DIALOG)
- {
- message->GetPropAuthor(data);
-
- CContact::Ref author;
- g_skype->GetContact(data, author);
-
- HANDLE hContact = this->AddContact(author);
-
- SEBinary guid;
- message->GetPropGuid(guid);
-
- char *cguid = ::mir_strdup(guid.data());
- cguid[guid.size()] = 0;
-
- this->RaiseMessageReceivedEvent(
- hContact,
- timestamp,
- cguid,
- text,
- status != CMessage::UNCONSUMED_NORMAL);
- }
- else
- {
- message->GetPropAuthor(data);
- wchar_t *sid = ::mir_utf8decodeW(data);
-
- conversation->GetPropIdentity(data);
- wchar_t *cid = ::mir_utf8decodeW(data);
-
- this->SendChatMessage(cid, sid, text);
-
- ::mir_free(sid);
- ::mir_free(cid);
- }
-
- ::mir_free(text);
-}
void CSkypeProto::OnTransferChanged(CTransfer::Ref transfer, int prop)
{
diff --git a/protocols/Skype/src/skype_profile.cpp b/protocols/Skype/src/skype_profile.cpp index 4d7af22d45..bbe9eb4a87 100644 --- a/protocols/Skype/src/skype_profile.cpp +++ b/protocols/Skype/src/skype_profile.cpp @@ -1,7 +1,7 @@ #include "skype_proto.h"
SettingItem CSkypeProto::setting[] = {
- {LPGENT("Full name"), "Nick", DBVT_WCHAR, LI_STRING},
+ {LPGENT("Nick"), "Nick", DBVT_WCHAR, LI_STRING},
{LPGENT("Mood"), "XStatusMsg", DBVT_WCHAR, LI_STRING},
{LPGENT("Mobile phone"), "Cellular", DBVT_WCHAR, LI_NUMBER},
@@ -263,14 +263,6 @@ void CSkypeProto::UpdateProfileMobilePhone(SEObject *obj, HANDLE hContact) ::mir_free(phone);
}
-void CSkypeProto::UpdateProfileNickName(SEObject *obj, HANDLE hContact)
-{
- wchar_t *nick = ::mir_utf8decodeW(obj->GetStrProp(/* *::P_DISPLAYNAME */ 21));
- if (::wcslen(nick))
- ::db_set_ws(hContact, this->m_szModuleName, "Nick", nick);
- ::mir_free(nick);
-}
-
void CSkypeProto::UpdateProfilePhone(SEObject *obj, HANDLE hContact)
{
wchar_t* phone = ::mir_a2u(obj->GetStrProp(/* *::P_PHONE_HOME */ 13));
@@ -366,6 +358,7 @@ void CSkypeProto::UpdateProfile(SEObject *obj, HANDLE hContact) if (hContact)
{
+ this->UpdateContactNickName(obj, hContact);
this->UpdateContactOnlineSinceTime(obj, hContact);
this->UpdateContactLastEventDate(obj, hContact);
@@ -379,9 +372,14 @@ void CSkypeProto::UpdateProfile(SEObject *obj, HANDLE hContact) void __cdecl CSkypeProto::LoadOwnInfo(void*)
{
wchar_t *nick = ::db_get_wsa(NULL, this->m_szModuleName, "Nick");
- if (!nick || !::wcslen(nick))
+ if ( !nick || !::wcslen(nick))
{
- ::db_set_ws(NULL, this->m_szModuleName, "Nick", this->login);
+ SEString data;
+ this->account->GetPropFullname(data);
+
+ mir_ptr<wchar_t> nick = ::mir_utf8decodeW(data);
+ ::db_set_ws(NULL, this->m_szModuleName, "Nick", nick);
}
+
this->UpdateProfile(this->account.fetch());
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 5ad86dfc6b..031bcfb1ea 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -340,6 +340,7 @@ protected: void UpdateContactAuthState(HANDLE hContact, CContact::Ref contact);
void UpdateContactAvatar(HANDLE hContact, CContact::Ref contact);
void UpdateContactStatus(HANDLE hContact, CContact::Ref contact);
+ void UpdateContactNickName(SEObject *obj, HANDLE hContact);
void UpdateContactOnlineSinceTime(SEObject *obj, HANDLE hContact);
void UpdateContactLastEventDate(SEObject *obj, HANDLE hContact);
@@ -472,18 +473,14 @@ protected: HANDLE hContact,
DWORD timestamp,
const char* guid,
- const wchar_t *message,
- bool isNeedCheck = true);
+ const char *message,
+ bool isUnreaded = true);
void RaiseMessageSendedEvent(
HANDLE hContact,
DWORD timestamp,
const char* guid,
- const wchar_t *message);
- /*void RaiseFileReceivedEvent(
- DWORD timestamp,
- const char* sid,
- const char* nick,
- const char* message);*/
+ const char *message,
+ bool isUnreaded = true);
void RaiseAuthRequestEvent(
DWORD timestamp,
CContact::Ref contact);
|