summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2013-04-20 15:27:52 +0000
committerAlexander Lantsev <aunsane@gmail.com>2013-04-20 15:27:52 +0000
commit66e9197603643cc587909fb1bce7402383dbad69 (patch)
tree43ac141616878a37e9a8fbfe842cb5a51909ffe7
parenta346491026d5df1ffe0d41e4881613a47ca6ca47 (diff)
- temporary commit. may contain non-working code
git-svn-id: http://svn.miranda-ng.org/main/trunk@4483 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/Skype/Skype_10.vcxproj.filters22
-rw-r--r--protocols/Skype/src/skype.h6
-rw-r--r--protocols/Skype/src/skype_account.cpp98
-rw-r--r--protocols/Skype/src/skype_chat.cpp137
-rw-r--r--protocols/Skype/src/skype_contacts.cpp173
-rw-r--r--protocols/Skype/src/skype_database.cpp48
-rw-r--r--protocols/Skype/src/skype_dialogs.cpp60
-rw-r--r--protocols/Skype/src/skype_events.cpp75
-rw-r--r--protocols/Skype/src/skype_menus.cpp4
-rw-r--r--protocols/Skype/src/skype_profile.cpp50
-rw-r--r--protocols/Skype/src/skype_proto.cpp42
-rw-r--r--protocols/Skype/src/skype_proto.h58
-rw-r--r--protocols/Skype/src/skype_services.cpp4
-rw-r--r--protocols/Skype/src/skype_subclassing.cpp45
-rw-r--r--protocols/Skype/src/skype_subclassing.h6
-rw-r--r--protocols/Skype/src/skype_utils.cpp4
16 files changed, 434 insertions, 398 deletions
diff --git a/protocols/Skype/Skype_10.vcxproj.filters b/protocols/Skype/Skype_10.vcxproj.filters
index ab6936b64a..08a34ba89e 100644
--- a/protocols/Skype/Skype_10.vcxproj.filters
+++ b/protocols/Skype/Skype_10.vcxproj.filters
@@ -10,6 +10,12 @@
<Filter Include="Resource Files">
<UniqueIdentifier>{901463af-0f59-4125-b874-1662b095d403}</UniqueIdentifier>
</Filter>
+ <Filter Include="Resource Files\Icons">
+ <UniqueIdentifier>{092ce045-936d-405a-abaf-200a3abba159}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Resource Files\Bin">
+ <UniqueIdentifier>{f1aeb5a2-f105-4b8c-a656-08dbe6dc7b2e}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\skype.cpp">
@@ -105,19 +111,23 @@
</ResourceCompile>
</ItemGroup>
<ItemGroup>
- <None Include="..\..\..\SkypeKit\SDK\bin\windows-x86\windows-x86-skypekit.exe" />
- <None Include="..\..\..\SkypeKit\keypair.bin" />
<None Include="res\auth_grant.ico">
- <Filter>Resource Files</Filter>
+ <Filter>Resource Files\Icons</Filter>
</None>
<None Include="res\auth_request.ico">
- <Filter>Resource Files</Filter>
+ <Filter>Resource Files\Icons</Filter>
</None>
<None Include="res\auth_revoke.ico">
- <Filter>Resource Files</Filter>
+ <Filter>Resource Files\Icons</Filter>
</None>
<None Include="res\Main.ico">
- <Filter>Resource Files</Filter>
+ <Filter>Resource Files\Icons</Filter>
+ </None>
+ <None Include="..\..\..\SkypeKit\SDK\bin\windows-x86\windows-x86-skypekit.exe">
+ <Filter>Resource Files\Bin</Filter>
+ </None>
+ <None Include="..\..\..\SkypeKit\keypair.bin">
+ <Filter>Resource Files\Bin</Filter>
</None>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h
index 48a144eea4..5cf4e84ace 100644
--- a/protocols/Skype/src/skype.h
+++ b/protocols/Skype/src/skype.h
@@ -60,9 +60,9 @@
#define MODULE "Skype"
#define SKYPE_SID_LIMIT 128
#define SKYPE_PASSWORD_LIMIT 128
-#define SKYPE_SETTINGS_NAME "Name"
-#define SKYPE_SETTINGS_STATUS "Status"
-#define SKYPE_SETTINGS_LOGIN "sid"
+
+#define SKYPE_SETTINGS_STATUS "Status"
+#define SKYPE_SETTINGS_LOGIN "sid"
#define SKYPE_SETTINGS_PASSWORD "Password"
#define SKYPE_SEARCH_BYSID 1001
diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp
index 6453e5e166..e7e9829de4 100644
--- a/protocols/Skype/src/skype_account.cpp
+++ b/protocols/Skype/src/skype_account.cpp
@@ -22,10 +22,8 @@ void CSkypeProto::OnAccountChanged(int prop)
{
this->m_iStatus = ID_STATUS_OFFLINE;
this->SendBroadcast(
- ACKTYPE_LOGIN,
- ACKRESULT_FAILED,
- NULL,
- this->SkypeToMirandaLoginError(whyLogout));
+ ACKTYPE_LOGIN, ACKRESULT_FAILED,
+ NULL, this->SkypeToMirandaLoginError(whyLogout));
this->ShowNotification(CSkypeProto::LogoutReasons[whyLogout - 1]);
@@ -90,75 +88,99 @@ void __cdecl CSkypeProto::SignInAsync(void*)
}
else
{
- ::CallService(MS_DB_CRYPT_ENCODESTRING, ::strlen(this->password), LPARAM(this->password));
+ ::CallService(MS_DB_CRYPT_ENCODESTRING, ::wcslen(this->password), (LPARAM)this->password);
}
this->LoadOwnInfo(this);
this->LoadContactList(this);
+ this->LoadAuthWaitList(this);
+ this->LoadChatList(this);
this->SetStatus(this->m_iDesiredStatus);
}
-bool CSkypeProto::SignIn(int status)
+bool CSkypeProto::PrepareLogin()
{
- this->login = ::db_get_sa(NULL, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
- if ( !this->login || !::strlen(this->login))
+ this->login = ::db_get_wsa(NULL, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
+ if ( !this->login || !::wcslen(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."));
+ ::TranslateT("You have not entered a Skype name.\n\
+ Configure this in Options->Network->Skype and try again."));
+ return false;
}
- else if (this->skype->GetAccount(this->login, this->account))
+
+ return true;
+}
+
+bool CSkypeProto::PreparePassword()
+{
+ if ( !this->rememberPassword)
{
- if ( !this->rememberPassword)
+ if (this->password)
+ {
+ ::mir_free(this->password);
+ this->password = NULL;
+ }
+ this->password = ::db_get_wsa(NULL, this->m_szModuleName, SKYPE_SETTINGS_PASSWORD);
+ if ( !this->password || !::wcslen(this->password))
{
if (this->password)
{
::mir_free(this->password);
this->password = NULL;
}
- this->password = ::db_get_sa(NULL, this->m_szModuleName, SKYPE_SETTINGS_PASSWORD);
- if ( !this->password || !::strlen(this->password))
+ PasswordRequestBoxParam param(this->login);
+ if ( !this->RequestPassword(param))
{
- if (this->password)
- {
- ::mir_free(this->password);
- this->password = NULL;
- }
- 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;
- }
+ this->SetStatus(ID_STATUS_OFFLINE);
+ return false;
+ }
+ else
+ {
+ this->password = ::mir_wstrdup(param.password);
+ this->rememberPassword = param.rememberPassword;
}
- else ::CallService(MS_DB_CRYPT_DECODESTRING, ::strlen(this->password), LPARAM(this->password));
}
+ else
+ ::CallService(MS_DB_CRYPT_DECODESTRING, ::wcslen(this->password), (LPARAM)this->password);
+ }
+
+ return true;
+}
+
+bool CSkypeProto::SignIn(int status)
+{
+ if ( !this->PrepareLogin())
+ return false;
+
+ if (this->skype->GetAccount(::mir_u2a(this->login), this->account))
+ {
+ if ( !this->PreparePassword())
+ return false;
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);
+ this->SetAccountSettings();
- return true;
+ this->account->LoginWithPassword(::mir_utf8encodeW(this->password), false, false);
}
- return false;
+ return true;
+}
+
+void CSkypeProto::SetAccountSettings()
+{
+ 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));
}
bool CSkypeProto::IsAvatarChanged(const SEBinary &avatar)
diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp
index e46a52bc1b..7f583d39bf 100644
--- a/protocols/Skype/src/skype_chat.cpp
+++ b/protocols/Skype/src/skype_chat.cpp
@@ -3,14 +3,14 @@
#include <m_message.h>
#include <m_history.h>
-char *CSkypeProto::Groups[] =
+wchar_t *CSkypeProto::Groups[] =
{
- "Creator",
- "Admin",
- "Speaker",
- "Writer",
- "Retried",
- "Outlaw"
+ L"Creator",
+ L"Admin",
+ L"Speaker",
+ L"Writer",
+ L"Retried",
+ L"Outlaw"
};
#define SKYPE_CHAT_GROUP_OWNER 0
@@ -25,15 +25,15 @@ bool CSkypeProto::IsChatRoom(HANDLE hContact)
return ::db_get_b(hContact, this->m_szModuleName, "ChatRoom", 0) > 0;
}
-HANDLE CSkypeProto::GetChatRoomByID(const char *cid)
+HANDLE CSkypeProto::GetChatRoomByID(const wchar_t *cid)
{
HANDLE hContact = ::db_find_first();
while (hContact)
{
if (this->IsProtoContact(hContact) && this->IsChatRoom(hContact))
{
- char *chatID = ::db_get_sa(hContact, this->m_szModuleName, "ChatRoomID");
- if (chatID && ::strcmp(cid, chatID) == 0)
+ ::mir_ptr<wchar_t> chatID(::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID"));
+ if (::wcscmp(cid, chatID) == 0)
return hContact;
}
@@ -43,7 +43,7 @@ HANDLE CSkypeProto::GetChatRoomByID(const char *cid)
return 0;
}
-HANDLE CSkypeProto::AddChatRoomByID(const char* cid, const char* name, DWORD flags)
+HANDLE CSkypeProto::AddChatRoomByID(const wchar_t* cid, const wchar_t* name, DWORD flags)
{
HANDLE hContact = this->GetChatRoomByID(cid);
if ( !hContact)
@@ -52,8 +52,8 @@ HANDLE CSkypeProto::AddChatRoomByID(const char* cid, const char* name, DWORD fla
::CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName);
::db_set_b(hContact, this->m_szModuleName, "ChatRoom", 1);
- ::db_set_s(hContact, this->m_szModuleName, "ChatRoomID", cid);
- ::db_set_s(hContact, this->m_szModuleName, "Nick", name);
+ ::db_set_ws(hContact, this->m_szModuleName, "ChatRoomID", cid);
+ ::db_set_ws(hContact, this->m_szModuleName, "Nick", name);
::db_set_w(hContact, this->m_szModuleName, "Status", ID_STATUS_OFFLINE);
::db_set_w(hContact, this->m_szModuleName, "ApparentMode", ID_STATUS_OFFLINE);
@@ -127,8 +127,8 @@ void CSkypeProto::GetInviteContacts(HANDLE hItem, HWND hwndList, SEStringList &c
}
else
{
- char *sid = ::db_get_sa(hItem, this->m_szModuleName, "sid");
- if (sid) chatTargets.append(sid);
+ ::mir_ptr<wchar_t> sid(::db_get_wsa(hItem, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
+ chatTargets.append(::mir_u2a(sid));
}
}
}
@@ -154,21 +154,22 @@ void CSkypeProto::InitChat()
this->HookEvent(ME_GC_BUILDMENU, &CSkypeProto::OnGCMenuHook);
}
-char *CSkypeProto::StartChat(const char *cid, const SEStringList &invitedContacts)
+wchar_t *CSkypeProto::StartChat(const wchar_t *cid, const SEStringList &invitedContacts)
{
- char *chatID;
+ wchar_t *chatID;
SEString data;
CConversation::Ref conversation;
- if (invitedContacts.size()) {
+ if (invitedContacts.size())
+ {
if (cid)
{
- this->skype->GetConversationByIdentity(cid, conversation);
+ this->skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation);
conversation->GetJoinBlob(data);
this->skype->GetConversationByBlob(data, conversation, false);
conversation->Join();
- chatID = ::mir_strdup(cid);
+ chatID = ::mir_wstrdup(cid);
}
else
{
@@ -178,7 +179,7 @@ char *CSkypeProto::StartChat(const char *cid, const SEStringList &invitedContact
conversation->SetOption(CConversation::P_OPT_DISCLOSE_HISTORY, 1);
conversation->GetPropIdentity(data);
- chatID = ::mir_strdup(data);
+ chatID = ::mir_utf8decodeW(data);
}
conversation->AddConsumers(invitedContacts);
@@ -195,19 +196,19 @@ char *CSkypeProto::StartChat(const char *cid, const SEStringList &invitedContact
gcw.iType = GCW_CHATROOM;
gcw.pszModule = this->m_szModuleName;
gcw.ptszName = chatName;
- gcw.pszID = chatID;
+ gcw.ptszID = chatID;
::CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_ADDGROUP };
- gcd.pszID = chatID;
+ gcd.ptszID = chatID;
GCEVENT gce = {0};
gce.cbSize = sizeof(GCEVENT);
gce.pDest = &gcd;
for (int i = 0; i < SIZEOF(CSkypeProto::Groups); i++)
{
- gce.pszStatus = Translate(CSkypeProto::Groups[i]);
- CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
+ gce.ptszStatus = TranslateW(CSkypeProto::Groups[i]);
+ ::CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
}
gcd.iType = GC_EVENT_CONTROL;
@@ -218,18 +219,19 @@ char *CSkypeProto::StartChat(const char *cid, const SEStringList &invitedContact
::mir_free(chatName);
return chatID;
- } else
+ }
+ else
return NULL;
}
-void CSkypeProto::JoinToChat(const char *cid, bool showWindow)
+void CSkypeProto::JoinToChat(const wchar_t *cid, bool showWindow)
{
- char *chatID = ::mir_strdup(cid);
+ wchar_t *chatID = ::mir_wstrdup(cid);
SEString data;
CConversation::Ref conversation;
- this->skype->GetConversationByIdentity(cid, conversation);
+ this->skype->GetConversationByIdentity(mir_utf8encodeW(cid), conversation);
conversation->GetJoinBlob(data);
this->skype->GetConversationByBlob(data, conversation, false);
conversation->Join();
@@ -242,11 +244,11 @@ void CSkypeProto::JoinToChat(const char *cid, bool showWindow)
gcw.iType = GCW_CHATROOM;
gcw.pszModule = this->m_szModuleName;
gcw.pszName = chatName;
- gcw.pszID = chatID;
+ gcw.ptszID = chatID;
::CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_ADDGROUP };
- gcd.pszID = chatID;
+ gcd.ptszID = chatID;
GCEVENT gce = {0};
gce.cbSize = sizeof(GCEVENT);
@@ -255,7 +257,7 @@ void CSkypeProto::JoinToChat(const char *cid, bool showWindow)
gcd.iType = GC_EVENT_ADDGROUP;
for (int i = 0; i < SIZEOF(CSkypeProto::Groups); i++)
{
- gce.pszStatus = Translate(CSkypeProto::Groups[i]);
+ gce.ptszStatus = TranslateW(CSkypeProto::Groups[i]);
CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
}
@@ -280,8 +282,8 @@ void CSkypeProto::JoinToChat(const char *cid, bool showWindow)
this->AddChatContact(
cid,
- ::mir_strdup(data),
- CParticipant::GetRankName(rank),
+ ::mir_utf8decodeW(data),
+ ::mir_utf8decodeW(CParticipant::GetRankName(rank)),
this->SkypeToMirandaStatus(status));
}
@@ -289,12 +291,12 @@ void CSkypeProto::JoinToChat(const char *cid, bool showWindow)
::mir_free(chatID);
}
-void CSkypeProto::LeaveChat(const char *cid)
+void CSkypeProto::LeaveChat(const wchar_t *cid)
{
- char *chatID = ::mir_strdup(cid);
+ wchar_t *chatID = ::mir_wstrdup(cid);
GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_CONTROL };
- gcd.pszID = chatID;
+ gcd.ptszID = chatID;
GCEVENT gce = {0};
gce.cbSize = sizeof(GCEVENT);
@@ -305,27 +307,29 @@ void CSkypeProto::LeaveChat(const char *cid)
::mir_free(chatID);
}
-void CSkypeProto::RaiseChatEvent(const char *cid, const char *sid, int evt, const DWORD itemData, const char *status, const char *message)
+void CSkypeProto::RaiseChatEvent(const wchar_t *cid, const wchar_t *sid, int evt, const DWORD itemData, const wchar_t *status, const wchar_t *message)
{
- char *idt = ::mir_strdup(cid);
- char *snt = ::mir_strdup(sid);
+ wchar_t *idt = ::mir_wstrdup(cid);
+ wchar_t *snt = ::mir_wstrdup(sid);
HANDLE hContact = this->GetContactBySid(sid);
- char *nick = hContact ? (char *)::CallService(MS_CLIST_GETCONTACTDISPLAYNAME, WPARAM(hContact), 0) : snt;
+ wchar_t *nick = hContact ?
+ (wchar_t *)::CallService(MS_CLIST_GETCONTACTDISPLAYNAME, WPARAM(hContact), 0) :
+ snt;
GCDEST gcd = { this->m_szModuleName, { NULL }, evt };
- gcd.pszID = idt;
+ gcd.ptszID = idt;
GCEVENT gce = {0};
gce.cbSize = sizeof(gce);
gce.dwFlags = GCEF_ADDTOLOG;
gce.pDest = &gcd;
- gce.pszNick = nick;
- gce.pszUID = snt;
- gce.bIsMe = ::stricmp(sid, this->login) == 0;
+ gce.ptszNick = nick;
+ gce.ptszUID = snt;
+ gce.bIsMe = ::wcsicmp(sid, this->login) == 0;
gce.dwItemData = itemData;
- gce.pszStatus = status;
- gce.pszText = message;
+ gce.ptszStatus = status;
+ gce.ptszText = message;
gce.time = time(NULL);
::CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
@@ -333,24 +337,24 @@ void CSkypeProto::RaiseChatEvent(const char *cid, const char *sid, int evt, cons
::mir_free(idt);
}
-void CSkypeProto::SendChatMessage(const char *cid, const char *sid, const char *message)
+void CSkypeProto::SendChatMessage(const wchar_t *cid, const wchar_t *sid, const wchar_t *message)
{
this->RaiseChatEvent(cid, sid, GC_EVENT_MESSAGE, 0, NULL, message);
}
-void CSkypeProto::AddChatContact(const char *cid, const char *sid, const char *group, const WORD status)
+void CSkypeProto::AddChatContact(const wchar_t *cid, const wchar_t *sid, const wchar_t *group, const WORD status)
{
this->RaiseChatEvent(cid, sid, GC_EVENT_JOIN);
this->RaiseChatEvent(cid, sid, GC_EVENT_ADDSTATUS, 0, CSkypeProto::Groups[SKYPE_CHAT_GROUP_WIRTER]);
this->RaiseChatEvent(cid, sid, GC_EVENT_SETCONTACTSTATUS, status);
}
-void CSkypeProto::KickChatContact(const char *cid, const char *sid)
+void CSkypeProto::KickChatContact(const wchar_t *cid, const wchar_t *sid)
{
this->RaiseChatEvent(cid, sid, GC_EVENT_KICK);
}
-void CSkypeProto::RemoveChatContact(const char *cid, const char *sid)
+void CSkypeProto::RemoveChatContact(const wchar_t *cid, const wchar_t *sid)
{
this->RaiseChatEvent(cid, sid, GC_EVENT_QUIT);
}
@@ -360,7 +364,11 @@ INT_PTR __cdecl CSkypeProto::OnJoinChat(WPARAM wParam, LPARAM)
HANDLE hContact = (HANDLE)wParam;
if (hContact)
{
- this->JoinToChat(::db_get_sa(hContact, this->m_szModuleName, "ChatRoomID"));
+ wchar_t *cid = ::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID");
+
+ this->JoinToChat(cid);
+
+ ::mir_free(cid);
}
return 0;
@@ -371,7 +379,8 @@ INT_PTR __cdecl CSkypeProto::OnLeaveChat(WPARAM wParam, LPARAM)
HANDLE hContact = (HANDLE)wParam;
if (hContact)
{
- char *cid = ::db_get_sa(hContact, this->m_szModuleName, "ChatRoomID");
+ wchar_t *cid = ::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID");
+
this->LeaveChat(cid);
::mir_free(cid);
@@ -388,15 +397,15 @@ int __cdecl CSkypeProto::OnGCEventHook(WPARAM, LPARAM lParam)
if (::strcmp(gch->pDest->pszModule, this->m_szModuleName))
return 0;
- char *chatID = ::mir_strdup(gch->pDest->pszID);
- char *sid = ::mir_strdup(gch->pszUID);
+ wchar_t *chatID = ::mir_wstrdup(gch->pDest->ptszID);
+ wchar_t *sid = ::mir_wstrdup(gch->ptszUID);
switch (gch->pDest->iType)
{
case GC_SESSION_TERMINATE:
{
CConversation::Ref conversation;
- if (this->skype->GetConversationByIdentity(chatID, conversation, false))
+ if (this->skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation, false))
{
Participant::Refs participants;
conversation->GetParticipants(participants, CConversation::MYSELF);
@@ -406,14 +415,14 @@ int __cdecl CSkypeProto::OnGCEventHook(WPARAM, LPARAM lParam)
break;
case GC_USER_MESSAGE:
- if (gch->pszText && gch->pszText[0])
+ if (gch->ptszText && gch->ptszText[0])
{
CConversation::Ref conversation;
- if (this->skype->GetConversationByIdentity(chatID, conversation, false))
+ if (this->skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation, false))
{
CMessage::Ref message;
- char *text = ::mir_utf8encode(gch->pszText);
- conversation->PostText(text, message);
+ ::mir_ptr<char> text(::mir_utf8encodeW(gch->ptszText));
+ conversation->PostText((char *)text, message);
}
}
break;
@@ -493,8 +502,8 @@ int __cdecl CSkypeProto::OnGCMenuHook(WPARAM, LPARAM lParam)
}
else if (gcmi->Type == MENU_ON_NICKLIST)
{
- char* id = mir_t2a(gcmi->pszUID);
- if (!::stricmp(this->login, id))
+ wchar_t *id = mir_wstrdup(gcmi->pszUID);
+ if (!::wcsicmp(this->login, id))
{
static const struct gc_item Items[] =
{
@@ -523,12 +532,12 @@ int __cdecl CSkypeProto::OnGCMenuHook(WPARAM, LPARAM lParam)
}
-char *CSkypeProto::GetChatUsers(const char *cid)
+char *CSkypeProto::GetChatUsers(const wchar_t *cid)
{
GC_INFO gci = {0};
gci.Flags = USERS;
gci.pszModule = this->m_szModuleName;
- gci.pszID = ::mir_a2t(cid);
+ gci.pszID = ::mir_wstrdup(cid);
::CallService(MS_GC_GETINFO, 0, (LPARAM)(GC_INFO *) &gci);
::mir_free(gci.pszID);
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp
index e8d794fcb7..d9ec251ab7 100644
--- a/protocols/Skype/src/skype_contacts.cpp
+++ b/protocols/Skype/src/skype_contacts.cpp
@@ -67,8 +67,9 @@ void CSkypeProto::OnContactChanged(CContact::Ref contact, int prop)
{
SEString data;
contact->GetPropSkypename(data);
- const char *sid = (const char*)data;
+ wchar_t *sid = ::mir_utf8decodeW(data);
HANDLE hContact = this->GetContactBySid(sid);
+ ::mir_free(sid);
SEObject *contactObj = contact.fetch();
@@ -147,15 +148,15 @@ bool CSkypeProto::IsProtoContact(HANDLE hContact)
return ::CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName) < 0;
}
-HANDLE CSkypeProto::GetContactBySid(const char *sid)
+HANDLE CSkypeProto::GetContactBySid(const wchar_t *sid)
{
HANDLE hContact = ::db_find_first();
while (hContact)
{
if (this->IsProtoContact(hContact) && !this->IsChatRoom(hContact))
{
- char *contactSid = ::db_get_sa(hContact, this->m_szModuleName, "sid");
- if (contactSid && ::strcmp(sid, contactSid) == 0)
+ mir_ptr<wchar_t> contactSid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
+ if (contactSid && ::wcsicmp(sid, contactSid) == 0)
return hContact;
}
@@ -186,80 +187,46 @@ HANDLE CSkypeProto::GetContactFromAuthEvent(HANDLE hEvent)
HANDLE CSkypeProto::AddContact(CContact::Ref contact)
{
- SEString data;
-
- contact->GetPropSkypename(data);
- char *sid = ::mir_strdup(data);
+ wchar_t *sid = ::mir_utf8decodeW(contact->GetSid());
CContact::AVAILABILITY availability;
contact->GetPropAvailability(availability);
- if (availability == CContact::SKYPEOUT)
- {
- //flags |= 256;
- contact->GetPropPstnnumber(data);
- ::mir_free(sid);
- sid = ::mir_strdup((const char *)data);
- }
-
HANDLE hContact = this->GetContactBySid(sid);
if ( !hContact)
{
hContact = (HANDLE)::CallService(MS_DB_CONTACT_ADD, 0, 0);
::CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName);
- char *nick;
- if (availability == CContact::SKYPEOUT)
- {
- nick = ::mir_strdup(sid);
- this->SetSettingByte(hContact, "IsSkypeOut", 1);
- }
- else
- {
- contact->GetPropDisplayname(data);
- nick = ::mir_utf8decodeA(data);
- }
+ wchar_t *nick = ::mir_utf8decodeW(contact->GetNick());
- ::db_set_s(hContact, this->m_szModuleName, "sid", sid);
- ::db_set_s(hContact, this->m_szModuleName, "Nick", nick);
-
- ::mir_free(nick);
- // why i do this?
- /*bool result;
- if (contact->IsMemberOfHardwiredGroup(CContactGroup::ALL_BUDDIES, result))
- {
- CContactGroup::Ref group;
- if (this->skype->GetHardwiredContactGroup(CContactGroup::ALL_BUDDIES, group))
- {
- group.fetch();
- group->AddContact(contact);
- }
- }*/
-
- /*if (flags & 256)
+ switch(availability)
{
+ case CContact::SKYPEOUT:
this->SetSettingByte(hContact, "IsSkypeOut", 1);
- }
- else
- {
- this->SetSettingByte(hContact, "Auth", 1);
+ break;
+
+ case CContact::PENDINGAUTH:
+ ::db_set_b(hContact, "CList", "NotOnList", 1);
+ break;
+
+ case CContact::BLOCKED:
+ case CContact::BLOCKED_SKYPEOUT:
+ ::db_set_b(hContact, "CList", "Hidden", 1);
+ break;
+
+ default:
::db_unset(hContact, this->m_szModuleName, "IsSkypeOut");
+ //::db_unset(hContact, "CList", "Hidden");
+ ::db_unset(hContact, "CList", "NotOnList");
+ }
- this->UpdateProfile(contact.fetch(), hContact);
+ ::db_set_ws(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN, sid);
+ ::db_set_ws(hContact, this->m_szModuleName, "Nick", nick);
- if (flags & PALF_TEMPORARY)
- {
- ::db_set_b(hContact, "CList", "NotOnList", 1);
- ::db_set_b(hContact, "CList", "Hidden", 1);
- }
- }*/
+ ::mir_free(nick);
}
- /*else
- {
- if ( !(flags & PALF_TEMPORARY))
- ::db_unset(hContact, "CList", "NotOnList");
- }*/
::mir_free(sid);
@@ -273,23 +240,18 @@ void __cdecl CSkypeProto::LoadContactList(void*)
this->commonList->SetOnContactListChangedCallback(
(CContactGroup::OnContactListChanged)&CSkypeProto::OnContactListChanged,
this);
- this->commonList->GetContacts(this->contactList);
- Sid::fetch(this->contactList);
- for (unsigned int i = 0; i < this->contactList.size(); i++)
+ this->commonList->GetContacts(this->contactList);
+ for (uint i = 0; i < this->contactList.size(); i++)
{
CContact::Ref contact = this->contactList[i];
+ SEObject *obj = contact.fetch();
contact->SetOnContactChangedCallback(
(CContact::OnContactChanged)&CSkypeProto::OnContactChanged,
this);
- DWORD flags = 0;
- CContact::AVAILABILITY availability;
- contact->GetPropAvailability(availability);
-
HANDLE hContact = this->AddContact(contact);
- SEObject *obj = contact.fetch();
this->UpdateContactAuthState(hContact, contact);
this->UpdateContactStatus(hContact, contact);
@@ -343,39 +305,20 @@ void __cdecl CSkypeProto::LoadChatList(void*)
void __cdecl CSkypeProto::LoadAuthWaitList(void*)
{
- // raise auth event for all non auth contacts
CContact::Refs authContacts;
this->skype->GetHardwiredContactGroup(CContactGroup::CONTACTS_WAITING_MY_AUTHORIZATION, this->authWaitList);
this->authWaitList.fetch();
this->authWaitList->SetOnContactListChangedCallback(
(CContactGroup::OnContactListChanged)&CSkypeProto::OnContactListChanged,
this);
- this->authWaitList->GetContacts(authContacts);
- //Sid::fetch(this->contactList);
- for (unsigned int i = 0; i < authContacts.size(); i++)
+ this->authWaitList->GetContacts(authContacts);
+ for (uint i = 0; i < authContacts.size(); i++)
{
CContact::Ref contact = authContacts[i];
- /*contact->SetOnContactChangedCallback(
- (CContact::OnContactChanged)&CSkypeProto::OnContactChanged,
- this);*/
-
- SEString data;
uint newTS = 0;
contact->GetPropAuthreqTimestamp(newTS);
-
- contact->GetPropSkypename(data);
- const char* sid = (const char *)data;
-
- CContact::AVAILABILITY availability;
- contact->GetPropAvailability(availability);
-
- if (availability == CContact::SKYPEOUT)
- {
- contact->GetPropPstnnumber(data);
- sid = (const char*)data;
- }
this->RaiseAuthRequestEvent(newTS, contact);
}
@@ -386,12 +329,9 @@ void CSkypeProto::SetAllContactStatus(int status)
HANDLE hContact = ::db_find_first();
while (hContact)
{
- if (this->IsProtoContact(hContact))
- {
- //if ( !this->GetSettingWord(hContact, SKYPE_SETTINGS_STATUS, ID_STATUS_OFFLINE) == status)
- if ( this->GetSettingByte(hContact, "IsSkypeOut", 0) == 0)
- this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, status);
- }
+ if (this->IsProtoContact(hContact) && this->GetSettingByte(hContact, "IsSkypeOut", 0) == 0)
+ this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, status);
+
hContact = ::db_find_next(hContact);
}
}
@@ -403,37 +343,40 @@ void CSkypeProto::OnSearchCompleted(HANDLE hSearch)
void CSkypeProto::OnContactFinded(HANDLE hSearch, CContact::Ref contact)
{
- PROTOSEARCHRESULT isr = {0};
- isr.cbSize = sizeof(isr);
- isr.flags = PSR_TCHAR;
+ PROTOSEARCHRESULT psr = {0};
+ psr.cbSize = sizeof(psr);
+ psr.flags = PSR_TCHAR;
SEString data;
contact->GetPropSkypename(data);
- isr.id = ::mir_utf8decodeW((const char *)data);
+ psr.id = ::mir_utf8decodeW(data);
contact->GetPropDisplayname(data);
- isr.nick = ::mir_utf8decodeW((const char *)data);
- {
- contact->GetPropFullname(data);
- wchar_t *fullname = ::mir_utf8decodeW((const char*)data);
+ psr.nick = ::mir_utf8decodeW(data);
+
+ SEString firstName, lastName;
+ contact->GetFullname(firstName, lastName);
+ psr.firstName = ::mir_utf8decodeW(firstName);
+ psr.lastName = ::mir_utf8decodeW(lastName);
- isr.lastName = fullname;
- }
{
contact->GetPropEmails(data);
- wchar_t *emails = ::mir_utf8decodeW((const char*)data);
+ wchar_t *emails = ::mir_utf8decodeW(data);
- wchar_t* main = wcstok(emails, L" ");
+ wchar_t* main = ::wcstok(emails, L" ");
if (main != NULL)
{
- isr.email = main;
+ psr.email = main;
}
+
+ ::mir_free(emails);
}
- this->SendBroadcast(ACKTYPE_SEARCH, ACKRESULT_DATA, hSearch, (LPARAM)&isr);
+
+ this->SendBroadcast(ACKTYPE_SEARCH, ACKRESULT_DATA, hSearch, (LPARAM)&psr);
}
void __cdecl CSkypeProto::SearchBySidAsync(void* arg)
{
- const char *sid = ::mir_u2a((wchar_t*)arg);
+ wchar_t *sid = (wchar_t*)arg;
HANDLE hContact = this->GetContactBySid(sid);
if (hContact)
@@ -444,7 +387,7 @@ void __cdecl CSkypeProto::SearchBySidAsync(void* arg)
}
CContactSearch::Ref search;
- this->skype->CreateIdentitySearch(sid, search);
+ this->skype->CreateIdentitySearch(::mir_u2a(sid), search);
search.fetch();
search->SetProtoInfo(this, (HANDLE)SKYPE_SEARCH_BYSID);
search->SetOnContactFindedCallback(
@@ -459,11 +402,13 @@ void __cdecl CSkypeProto::SearchBySidAsync(void* arg)
}
search->BlockWhileSearch();
search->Release();
+
+ ::mir_free(sid);
}
void __cdecl CSkypeProto::SearchByEmailAsync(void* arg)
{
- const wchar_t *email = (wchar_t *)arg;
+ wchar_t *email = (wchar_t *)arg;
CContactSearch::Ref search;
this->skype->CreateContactSearch(search);
@@ -481,8 +426,12 @@ void __cdecl CSkypeProto::SearchByEmailAsync(void* arg)
}
search->BlockWhileSearch();
search->Release();
+
+ ::mir_free(email);
}
void __cdecl CSkypeProto::SearchByNamesAsync(void* arg)
{
+ //todo: write me
+ PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT *)arg;
} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_database.cpp b/protocols/Skype/src/skype_database.cpp
index 8623d08a7b..b607c8e4b7 100644
--- a/protocols/Skype/src/skype_database.cpp
+++ b/protocols/Skype/src/skype_database.cpp
@@ -19,26 +19,18 @@ void CSkypeProto::RaiseAuthRequestEvent(
DWORD timestamp,
CContact::Ref contact)
{
- SEString data;
-
- contact->GetPropSkypename(data);
- char *sid = ::mir_strdup(data);
+ char *sid = ::mir_utf8decodeA(contact->GetSid());
+ char *nick = ::mir_utf8decodeA(contact->GetNick());
- contact->GetPropDisplayname(data);
- char *nick = ::mir_utf8decodeA(data);
+ SEString data;
contact->GetPropReceivedAuthrequest(data);
- char* reason = ::mir_utf8decodeA((const char*)data);
+ char* reason = ::mir_utf8decodeA(data);
- contact->GetPropFullname(data);
- char* fullname = ::mir_utf8decodeA((const char*)data);
-
- char* firstName = strtok(fullname, " ");
- char* lastName = strtok(NULL, " ");
- if (lastName == NULL)
- {
- lastName = "";
- }
+ SEString last;
+ contact->GetFullname(data, last);
+ char* firstName = ::mir_utf8decodeA(data);
+ char* lastName = ::mir_utf8decodeA(last);
PROTORECVEVENT pre = {0};
@@ -113,17 +105,17 @@ bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* me
void CSkypeProto::RaiseMessageReceivedEvent(
HANDLE hContact,
DWORD timestamp,
- const char* message,
+ const wchar_t *message,
bool isNeedCheck)
{
- if (isNeedCheck)
+ /*if (isNeedCheck)
if (this->IsMessageInDB(hContact, timestamp, message))
- return;
+ return;*/
PROTORECVEVENT recv;
- recv.flags = PREF_UTF;
+ recv.flags = PREF_UNICODE;
recv.timestamp = timestamp;
- recv.szMessage = ::mir_strdup(message);
+ recv.tszMessage = ::mir_wstrdup(message);
::ProtoChainRecvMsg(hContact, &recv);
}
@@ -131,19 +123,21 @@ void CSkypeProto::RaiseMessageReceivedEvent(
void CSkypeProto::RaiseMessageSendedEvent(
HANDLE hContact,
DWORD timestamp,
- const char* message)
+ const wchar_t *message)
{
- if (this->IsMessageInDB(hContact, timestamp, message, DBEF_SENT))
- return;
+ /*if (this->IsMessageInDB(hContact, timestamp, message, DBEF_SENT))
+ return;*/
+
+ char *msg = ::mir_utf8encodeW(message);
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
dbei.szModule = this->m_szModuleName;
dbei.timestamp = timestamp;
dbei.eventType = EVENTTYPE_MESSAGE;
- dbei.cbBlob = (DWORD)::strlen(message) + 1;
- dbei.pBlob = (PBYTE)::mir_strdup(message);
- dbei.flags = DBEF_UTF | DBEF_SENT;
+ dbei.cbBlob = (DWORD)::strlen(msg) + 1;
+ dbei.pBlob = (PBYTE)msg;
+ dbei.flags = PREF_UTF | DBEF_SENT;
::db_event_add(hContact, &dbei);
}
diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp
index c6ee03362d..fc74ad7a24 100644
--- a/protocols/Skype/src/skype_dialogs.cpp
+++ b/protocols/Skype/src/skype_dialogs.cpp
@@ -117,14 +117,14 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR
case IDC_CHANGE_PWD:
{
- char sid[128], pwd[128];
- GetDlgItemTextA(hwnd, IDC_SL, sid, SIZEOF(sid));
- GetDlgItemTextA(hwnd, IDC_PW, pwd, SIZEOF(pwd));
+ wchar_t sid[128], pwd[128];
+ GetDlgItemText(hwnd, IDC_SL, sid, SIZEOF(sid));
+ GetDlgItemText(hwnd, IDC_PW, pwd, SIZEOF(pwd));
PasswordChangeBoxParam param;
if (proto->ChangePassword(param))
{
- proto->account->ChangePassword(param.password, param.password2);
+ proto->account->ChangePassword(::mir_utf8encodeW(param.password), ::mir_utf8encodeW(param.password2));
}
}
break;
@@ -135,15 +135,15 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR
case WM_NOTIFY:
if (reinterpret_cast<NMHDR*>(lParam)->code == PSN_APPLY && !proto->IsOnline())
{
- char data[128];
- GetDlgItemTextA(hwnd, IDC_SL, data, SIZEOF(data));
- ::db_set_s(NULL, proto->m_szModuleName, "sid", data);
+ wchar_t data[128];
+ GetDlgItemText(hwnd, IDC_SL, data, SIZEOF(data));
+ ::db_set_ws(NULL, proto->m_szModuleName, SKYPE_SETTINGS_LOGIN, data);
::mir_free(proto->login);
- proto->login = ::mir_strdup(data);
+ proto->login = ::mir_wstrdup(data);
- GetDlgItemTextA(hwnd, IDC_PW, data, sizeof(data));
- ::CallService(MS_DB_CRYPT_ENCODESTRING, strlen(data), LPARAM((char*)data));
- ::db_set_s(NULL, proto->m_szModuleName, SKYPE_SETTINGS_PASSWORD, data);
+ GetDlgItemText(hwnd, IDC_PW, data, sizeof(data));
+ ::CallService(MS_DB_CRYPT_ENCODESTRING, wcslen(data), (LPARAM)&data);
+ ::db_set_ws(NULL, proto->m_szModuleName, SKYPE_SETTINGS_PASSWORD, data);
HWND item = GetDlgItem(hwnd, IDC_PORT);
if (item)
@@ -211,7 +211,7 @@ INT_PTR CALLBACK CSkypeProto::SkypePasswordRequestProc(HWND hwndDlg, UINT msg, W
title,
MAX_PATH,
::TranslateT("Enter a password for Skype Name %s:"),
- ::mir_a2u(param->login));
+ param->login);
::SetDlgItemText(hwndDlg, IDC_INSTRUCTION, title);
::SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_LIMITTEXT, 128 - 1, 0);
@@ -233,9 +233,9 @@ INT_PTR CALLBACK CSkypeProto::SkypePasswordRequestProc(HWND hwndDlg, UINT msg, W
{
param->rememberPassword = ::IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD) > 0;
- char password[SKYPE_PASSWORD_LIMIT];
- ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD, password, SIZEOF(password));
- param->password = ::mir_strdup(password);
+ wchar_t password[SKYPE_PASSWORD_LIMIT];
+ ::GetDlgItemText(hwndDlg, IDC_PASSWORD, password, SIZEOF(password));
+ param->password = ::mir_wstrdup(password);
::EndDialog(hwndDlg, IDOK);
}
@@ -290,16 +290,16 @@ INT_PTR CALLBACK CSkypeProto::SkypePasswordChangeProc(HWND hwndDlg, UINT msg, WP
{
case IDOK:
{
- char oldPwd[SKYPE_PASSWORD_LIMIT];
- ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD, oldPwd, SIZEOF(oldPwd));
- param->password = ::mir_strdup(oldPwd);
+ wchar_t oldPwd[SKYPE_PASSWORD_LIMIT];
+ ::GetDlgItemText(hwndDlg, IDC_PASSWORD, oldPwd, SIZEOF(oldPwd));
+ param->password = ::mir_wstrdup(oldPwd);
- char pwd1[SKYPE_PASSWORD_LIMIT];
- ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD2, pwd1, SIZEOF(pwd1));
- param->password2 = ::mir_strdup(pwd1);
+ wchar_t pwd1[SKYPE_PASSWORD_LIMIT];
+ ::GetDlgItemText(hwndDlg, IDC_PASSWORD2, pwd1, SIZEOF(pwd1));
+ param->password2 = ::mir_wstrdup(pwd1);
- char pwd2[SKYPE_PASSWORD_LIMIT];
- ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD3, pwd2, SIZEOF(pwd2));
+ wchar_t pwd2[SKYPE_PASSWORD_LIMIT];
+ ::GetDlgItemText(hwndDlg, IDC_PASSWORD3, pwd2, SIZEOF(pwd2));
::EndDialog(hwndDlg, IDOK);
}
@@ -359,7 +359,7 @@ INT_PTR CALLBACK CSkypeProto::SkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam
if (!szProto)
break;
- ::SetDlgItemText(hwndDlg, IDC_SID, ppro->GetSettingString(hContact, "sid"));
+ ::SetDlgItemText(hwndDlg, IDC_SID, ppro->GetSettingString(hContact, SKYPE_SETTINGS_LOGIN));
::SetDlgItemText(hwndDlg, IDC_STATUSTEXT, ppro->GetSettingString(hContact, "XStatusMsg") ? ppro->GetSettingString(hContact, "XStatusMsg") : TranslateT("<not specified>"));
if (ppro->GetSettingDword(hContact, "OnlineSinceTS")) {
@@ -639,7 +639,7 @@ INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wP
SEStringList invitedContacts;
param->ppro->GetInviteContacts(NULL, hwndList, invitedContacts);
- char *chatID = ::mir_strdup(param->id);
+ wchar_t *chatID = ::mir_wstrdup(param->id);
if (chatID)
{
@@ -653,13 +653,13 @@ INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wP
//todo: fix rank
param->ppro->AddChatContact(
chatID,
- invitedContacts[i],
- CParticipant::GetRankName(CParticipant::SPEAKER),
+ ::mir_utf8decodeW(invitedContacts[i]),
+ mir_utf8decodeW(CParticipant::GetRankName(CParticipant::SPEAKER)),
status);
}
CConversation::Ref conversation;
- param->ppro->skype->GetConversationByIdentity(chatID, conversation);
+ param->ppro->skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation);
conversation->AddConsumers(invitedContacts);
}
else
@@ -676,8 +676,8 @@ INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wP
//todo: fix rank
param->ppro->AddChatContact(
chatID,
- invitedContacts[i],
- CParticipant::GetRankName(CParticipant::SPEAKER),
+ ::mir_utf8decodeW(invitedContacts[i]),
+ ::mir_utf8decodeW(CParticipant::GetRankName(CParticipant::SPEAKER)),
status);
}
}
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp
index 07fe293e0b..90ab1ff27b 100644
--- a/protocols/Skype/src/skype_events.cpp
+++ b/protocols/Skype/src/skype_events.cpp
@@ -10,9 +10,6 @@ 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;
return 0;
}
@@ -22,7 +19,6 @@ int CSkypeProto::OnPreShutdown(WPARAM, LPARAM)
this->SetStatus(ID_STATUS_OFFLINE);
this->UninitNetLib();
-
this->UninitSkype();
return 0;
@@ -35,11 +31,11 @@ int CSkypeProto::OnContactDeleted(WPARAM wParam, LPARAM lParam)
{
if (this->IsChatRoom(hContact))
{
- char *chatID = ::db_get_sa(hContact, this->m_szModuleName, "ChatRoomID");
+ wchar_t *chatID = ::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID");
this->LeaveChat(chatID);
CConversation::Ref conversation;
- this->skype->GetConversationByIdentity(chatID, conversation);
+ this->skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation);
conversation->RetireFrom();
conversation->Delete();
}
@@ -64,7 +60,7 @@ void CSkypeProto::OnMessageSended(CConversation::Ref conversation, CMessage::Ref
message->GetPropConsumptionStatus(status);
message->GetPropBodyXml(data);
- char *text = CSkypeProto::RemoveHtml(data);
+ wchar_t *text = ::mir_utf8decodeW(CSkypeProto::RemoveHtml(data));
CConversation::TYPE type;
conversation->GetPropType(type);
@@ -89,15 +85,15 @@ void CSkypeProto::OnMessageSended(CConversation::Ref conversation, CMessage::Ref
else
{
receiver->GetIdentity(data);
- char *sid = ::mir_strdup(data);
+ wchar_t *sid = ::mir_utf8decodeW(data);
conversation->GetPropIdentity(data);
- char *cid = ::mir_strdup(data);
+ wchar_t *cid = ::mir_utf8decodeW(data);
//this->SendChatMessage(cid, sid, ::mir_utf8decodeA(text));
- char *nick = (char *)::db_get_sa(NULL, this->m_szModuleName, "Nick");
- if (::stricmp(nick, "") == 0)
+ wchar_t *nick = (wchar_t *)::db_get_wsa(NULL, this->m_szModuleName, "Nick");
+ if (::wcsicmp(nick, L"") == 0)
{
nick = sid;
}
@@ -125,7 +121,7 @@ void CSkypeProto::OnMessageReceived(CConversation::Ref conversation, CMessage::R
message->GetPropConsumptionStatus(status);
message->GetPropBodyXml(data);
- char *text = CSkypeProto::RemoveHtml(data);
+ wchar_t *text = ::mir_utf8decodeW(CSkypeProto::RemoveHtml(data));
CConversation::TYPE type;
conversation->GetPropType(type);
@@ -143,10 +139,10 @@ void CSkypeProto::OnMessageReceived(CConversation::Ref conversation, CMessage::R
else
{
message->GetPropAuthor(data);
- char *sid = ::mir_strdup(data);
+ wchar_t *sid = ::mir_utf8decodeW(data);
conversation->GetPropIdentity(data);
- char *cid = ::mir_strdup(data);
+ wchar_t *cid = ::mir_utf8decodeW(data);
this->SendChatMessage(cid, sid, text);
@@ -164,20 +160,11 @@ void CSkypeProto::OnTransferChanged(int prop, CTransfer::Ref transfer)
Transfer::STATUS status;
transfer->GetPropStatus(status);
- /*CConversation::Ref conversation;
- transfer->GetPropConvoId(conversation);
-
- SEBinary guid;
- transfer->GetPropChatmsgGuid(guid);
- auto ft = this->FindTransfer(guid);*/
auto ft = this->FindFileTransfer(transfer);
- SEString sid;
- transfer->GetPropPartnerHandle(sid);
- //CParticipant::Refs participants;
- //conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS);
- ////for (uint i = 0; i < participants.size(); i++)
- //participants[0]->GetPropIdentity(sid);
+ SEString data;
+ transfer->GetPropPartnerHandle(data);
+ mir_ptr<wchar_t> sid(::mir_utf8decodeW(data));
HANDLE hContact = this->GetContactBySid(sid);
@@ -270,8 +257,10 @@ void CSkypeProto::OnFileReceived(CConversation::Ref conversation, CMessage::Ref
wchar_t *path = ::mir_utf8decodeW(name);
- SEString sid;
- transfer->GetPropPartnerHandle(sid);
+ SEString data;
+ transfer->GetPropPartnerHandle(data);
+ mir_ptr<wchar_t> sid(::mir_utf8decodeW(data));
+
HANDLE hContact = this->GetContactBySid(sid);
auto ft = new FileTransfer(this);
@@ -318,8 +307,8 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa
{
SEString identity;
message->GetPropAuthor(identity);
- char *sid = ::mir_strdup(identity);
- if (::stricmp(sid, this->login) == 0)
+ wchar_t *sid = ::mir_utf8decodeW(identity);
+ if (::wcsicmp(sid, this->login) == 0)
{
CParticipant::Refs participants;
conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS);
@@ -347,7 +336,7 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa
SEString data;
conversation->GetPropIdentity(data);
- char *cid = ::mir_strdup(data);
+ wchar_t *cid = ::mir_utf8decodeW(data);
HANDLE hContact = this->GetChatRoomByID(cid);
if ( !hContact || ::db_get_w(hContact, this->m_szModuleName, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
@@ -371,8 +360,8 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa
this->AddChatContact(
cid,
- data,
- CParticipant::GetRankName(rank),
+ ::mir_utf8decodeW(data),
+ ::mir_utf8decodeW(CParticipant::GetRankName(rank)),
status);
}
}
@@ -386,7 +375,7 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa
for (int i = 0; i < needToAdd.getCount(); i++)
{
char *sid = needToAdd[i];
- if (::stricmp(sid, this->login) != 0 && !alreadyInChat.contains(sid))
+ if (::wcsicmp(::mir_a2u(sid), this->login) != 0 && !alreadyInChat.contains(sid))
{
CContact::Ref contact;
CContact::AVAILABILITY status;
@@ -396,8 +385,8 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa
//todo: fix rank
this->AddChatContact(
cid,
- sid,
- CParticipant::GetRankName(CParticipant::WRITER),
+ ::mir_a2u(sid),
+ ::mir_utf8decodeW(CParticipant::GetRankName(CParticipant::WRITER)),
status);
}
}
@@ -410,14 +399,14 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa
SEString data;
conversation->GetPropIdentity(data);
- char *cid = ::mir_strdup(data);
+ wchar_t *cid = ::mir_utf8decodeW(data);
StringList alreadyInChat(this->GetChatUsers(cid), " ");
message->GetPropAuthor(data);
- char *sid = ::mir_strdup(data);
- if (::stricmp(sid, this->login) != 0)
- if (alreadyInChat.contains(sid))
+ wchar_t *sid = ::mir_utf8decodeW(data);
+ if (::wcsicmp(sid, this->login) != 0)
+ if (alreadyInChat.contains(::mir_u2a(sid)))
this->RemoveChatContact(cid, sid);
}
break;
@@ -426,7 +415,7 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa
SEString data;
conversation->GetPropIdentity(data);
- char *cid = ::mir_strdup(data);
+ wchar_t *cid = ::mir_utf8decodeW(data);
message->GetPropIdentities(data);
@@ -435,8 +424,8 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa
for (int i = 0; i < needToKick.getCount(); i++)
{
- char *sid = needToKick[i];
- if (::stricmp(sid, this->login) != 0 && !alreadyInChat.contains(sid))
+ wchar_t *sid = ::mir_utf8decodeW(needToKick[i]);
+ if (::wcsicmp(sid, this->login) != 0 && !alreadyInChat.contains(::mir_u2a(sid)))
this->KickChatContact(cid, sid);
}
}
diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp
index ae01acf95a..59f9723ef7 100644
--- a/protocols/Skype/src/skype_menus.cpp
+++ b/protocols/Skype/src/skype_menus.cpp
@@ -76,7 +76,7 @@ int CSkypeProto::GrantAuth(WPARAM wParam, LPARAM lParam)
{
CContact::Ref contact;
HANDLE hContact = (HANDLE)wParam;
- SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
+ SEString sid(::mir_u2a(::mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN))));
if (this->skype->GetContact(sid, contact))
{
if (contact->SetBuddyStatus(true))
@@ -93,7 +93,7 @@ int CSkypeProto::RevokeAuth(WPARAM wParam, LPARAM lParam)
{
CContact::Ref contact;
HANDLE hContact = (HANDLE)wParam;
- SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
+ SEString sid(::mir_u2a(::mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN))));
if (this->skype->GetContact(sid, contact))
{
if (contact->SetBuddyStatus(false))
diff --git a/protocols/Skype/src/skype_profile.cpp b/protocols/Skype/src/skype_profile.cpp
index 81ef6fc48c..37d9dff106 100644
--- a/protocols/Skype/src/skype_profile.cpp
+++ b/protocols/Skype/src/skype_profile.cpp
@@ -85,7 +85,7 @@ void CSkypeProto::UpdateProfileAboutText(SEObject *obj, HANDLE hContact)
if ( !::wcslen(aboutText))
this->DeleteSetting(hContact, "About");
else
- this->SetSettingString(hContact, "About", aboutText);
+ ::db_set_ws(hContact, this->m_szModuleName, "About", aboutText);
::mir_free(aboutText);
}
@@ -127,7 +127,7 @@ void CSkypeProto::UpdateProfileCity(SEObject *obj, HANDLE hContact)
if ( !::wcslen(city))
this->DeleteSetting(hContact, "City");
else
- this->SetSettingString(hContact, "City", city);
+ ::db_set_ws(hContact, this->m_szModuleName, "City", city);
::mir_free(city);
}
@@ -138,12 +138,12 @@ void CSkypeProto::UpdateProfileCountry(SEObject *obj, HANDLE hContact)
if ( !::strlen(isocode))
{
country = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, 0xFFFF, 0);
- this->SetSettingString(hContact, "Country", ::mir_a2t(country));
+ ::db_set_ws(hContact, this->m_szModuleName, "Country", ::mir_a2t(country));
}
else
{
country = (char*)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode, 0);
- this->SetSettingString(hContact, "Country", ::mir_a2t(country));
+ ::db_set_ws(hContact, this->m_szModuleName, "Country", ::mir_a2t(country));
}
::mir_free(isocode);
}
@@ -168,9 +168,9 @@ void CSkypeProto::UpdateProfileEmails(SEObject *obj, HANDLE hContact)
{
this->SetSettingString(hContact, "e-mail0", p);
p = wcstok(NULL, L" ");
- if (p) this->SetSettingString(hContact, "e-mail1", p);
+ if (p) ::db_set_ws(hContact, this->m_szModuleName, "e-mail1", p);
p = wcstok(NULL, L" ");
- if (p) this->SetSettingString(hContact, "e-mail2", p);
+ if (p) ::db_set_ws(hContact, this->m_szModuleName, "e-mail2", p);
}
::mir_free(p);
}
@@ -179,11 +179,23 @@ void CSkypeProto::UpdateProfileEmails(SEObject *obj, HANDLE hContact)
void CSkypeProto::UpdateProfileFullName(SEObject *obj, HANDLE hContact)
{
- wchar_t* fullname = ::mir_utf8decodeW(obj->GetStrProp(/* *::P_FULLNAME */ 5));
+ wchar_t *fullname = ::mir_utf8decodeW(obj->GetStrProp(/* *::P_FULLNAME */ 5));
if ( !::wcslen(fullname))
+ {
+ this->DeleteSetting(hContact, "FirstName");
this->DeleteSetting(hContact, "LastName");
+ }
else
- this->SetSettingString(hContact, "LastName", fullname);
+ {
+ wchar_t *firstName = ::wcstok(fullname, L" ");
+ wchar_t *lastName = ::wcstok(NULL, L" ");
+ if (lastName == NULL)
+ {
+ lastName = L"";
+ }
+ ::db_set_ws(hContact, this->m_szModuleName, "FirstName", firstName);
+ ::db_set_ws(hContact, this->m_szModuleName, "LastName", lastName);
+ }
::mir_free(fullname);
}
@@ -202,7 +214,7 @@ void CSkypeProto::UpdateProfileHomepage(SEObject *obj, HANDLE hContact)
if (::wcscmp(homepage, L"") == 0)
this->DeleteSetting(hContact, "Homepage");
else
- this->SetSettingString(hContact, "Homepage", homepage);
+ ::db_set_ws(hContact, this->m_szModuleName, "Homepage", homepage);
::mir_free(homepage);
}
@@ -220,15 +232,15 @@ void CSkypeProto::UpdateProfileLanguages(SEObject *obj, HANDLE hContact)
wchar_t* p = wcstok(isocodes, L" ");
if (p == NULL)
{
- this->SetSettingString(hContact, "e-Language1", isocodes);
+ ::db_set_ws(hContact, this->m_szModuleName, "Language1", isocodes);
}
else
{
- this->SetSettingString(hContact, "e-Language1", p);
+ ::db_set_ws(hContact, this->m_szModuleName, "Language1", p);
p = wcstok(NULL, L" ");
- if (p) this->SetSettingString(hContact, "e-Language2", p);
+ if (p) ::db_set_ws(hContact, this->m_szModuleName, "Language2", p);
p = wcstok(NULL, L" ");
- if (p) this->SetSettingString(hContact, "e-Language3", p);
+ if (p) ::db_set_ws(hContact, this->m_szModuleName, "Language3", p);
}
// todo: fix
@@ -248,7 +260,7 @@ void CSkypeProto::UpdateProfileMobilePhone(SEObject *obj, HANDLE hContact)
if ( !::wcslen(phone))
this->DeleteSetting(hContact, "Cellular");
else
- this->SetSettingString(hContact, "Cellular", phone);
+ ::db_set_ws(hContact, this->m_szModuleName, "Cellular", phone);
::mir_free(phone);
}
@@ -258,7 +270,7 @@ void CSkypeProto::UpdateProfilePhone(SEObject *obj, HANDLE hContact)
if ( !::wcslen(phone))
this->DeleteSetting(hContact, "Phone");
else
- this->SetSettingString(hContact, "Phone", phone);
+ ::db_set_ws(hContact, this->m_szModuleName, "Phone", phone);
::mir_free(phone);
}
@@ -268,7 +280,7 @@ void CSkypeProto::UpdateProfileOfficePhone(SEObject *obj, HANDLE hContact)
if ( !::wcslen(phone))
this->DeleteSetting(hContact, "CompanyPhone");
else
- this->SetSettingString(hContact, "CompanyPhone", phone);
+ ::db_set_ws(hContact, this->m_szModuleName, "CompanyPhone", phone);
::mir_free(phone);
}
@@ -278,7 +290,7 @@ void CSkypeProto::UpdateProfileState(SEObject *obj, HANDLE hContact)
if ( !::wcslen(state))
this->DeleteSetting(hContact, "State");
else
- this->SetSettingString(hContact, "State", state);
+ ::db_set_ws(hContact, this->m_szModuleName, "State", state);
::mir_free(state);
}
@@ -288,7 +300,7 @@ void CSkypeProto::UpdateProfileStatusMessage(SEObject *obj, HANDLE hContact)
if ( !::wcslen(statusMessage))
this->DeleteSetting(hContact, "XStatusMsg");
else
- this->SetSettingString(hContact, "XStatusMsg", statusMessage);
+ ::db_set_ws(hContact, this->m_szModuleName, "XStatusMsg", statusMessage);
::mir_free(statusMessage);
}
@@ -349,7 +361,7 @@ void CSkypeProto::UpdateProfile(SEObject *obj, HANDLE hContact)
this->UpdateContactOnlineSinceTime(obj, hContact);
this->UpdateContactLastEventDate(obj, hContact);
- this->SetSettingString(hContact, "MirVer", L"Skype");
+ ::db_set_ws(hContact, this->m_szModuleName, "MirVer", L"Skype");
}
this->SetSettingDword("ProfileTS", newTS);
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index 1571db1c0f..0dfb3b1bd8 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -123,7 +123,7 @@ int __cdecl CSkypeProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage)
if (this->IsOnline() && hContact)
{
CContact::Ref contact;
- SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
+ SEString sid(::mir_u2a(this->GetSettingString(hContact, SKYPE_SETTINGS_LOGIN)));
if (this->skype->GetContact(sid, contact))
{
contact->SetBuddyStatus(Contact::AUTHORIZED_BY_ME);
@@ -187,6 +187,7 @@ int __cdecl CSkypeProto::FileDeny( HANDLE hContact, HANDLE hTransfer, const T
return 0;
}
+
int __cdecl CSkypeProto::FileResume( HANDLE hTransfer, int* action, const TCHAR** szFilename )
{
return 0;
@@ -205,9 +206,9 @@ DWORD_PTR __cdecl CSkypeProto:: GetCaps(int type, HANDLE hContact)
return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_AVATARS |
PF4_OFFLINEFILES | PF4_IMSENDUTF | PF4_IMSENDOFFLINE;
case PFLAG_UNIQUEIDTEXT:
- return (DWORD_PTR)Translate("Skype Name");
+ return (DWORD_PTR)::Translate("Skype Name");
case PFLAG_UNIQUEIDSETTING:
- return (DWORD_PTR) "sid";
+ return (DWORD_PTR)SKYPE_SETTINGS_LOGIN;
default:
return 0;
}
@@ -220,8 +221,7 @@ HANDLE __cdecl CSkypeProto::SearchBasic(const TCHAR* id)
if ( !this->IsOnline())
return 0;
- wchar_t *data = ::mir_tstrdup(id);
- this->ForkThread(&CSkypeProto::SearchBySidAsync, data);
+ this->ForkThread(&CSkypeProto::SearchBySidAsync, ::mir_tstrdup(id));
return (HANDLE)SKYPE_SEARCH_BYSID;
}
@@ -231,22 +231,21 @@ HANDLE __cdecl CSkypeProto::SearchByEmail(const TCHAR* email)
if ( !this->IsOnline())
return 0;
- wchar_t *data = ::mir_tstrdup(email);
- this->ForkThread(&CSkypeProto::SearchByEmailAsync, data);
+ this->ForkThread(&CSkypeProto::SearchByEmailAsync, ::mir_tstrdup(email));
return (HANDLE)SKYPE_SEARCH_BYEMAIL;
}
HANDLE __cdecl CSkypeProto::SearchByName(const TCHAR* nick, const TCHAR* firstName, const TCHAR* lastName)
{
- PROTOSEARCHRESULT isr = {0};
- isr.cbSize = sizeof(isr);
- isr.flags = PSR_TCHAR;
- isr.nick = ::mir_wstrdup(nick);
- isr.firstName = ::mir_wstrdup(firstName);
- isr.lastName = ::mir_wstrdup(lastName);
+ PROTOSEARCHRESULT psr = {0};
+ psr.cbSize = sizeof(psr);
+ psr.flags = PSR_TCHAR;
+ psr.nick = ::mir_wstrdup(nick);
+ psr.firstName = ::mir_wstrdup(firstName);
+ psr.lastName = ::mir_wstrdup(lastName);
- this->ForkThread(&CSkypeProto::SearchByNamesAsync, &isr);
+ this->ForkThread(&CSkypeProto::SearchByNamesAsync, &psr);
return (HANDLE)SKYPE_SEARCH_BYNAMES;
}
@@ -277,12 +276,12 @@ HANDLE __cdecl CSkypeProto::SendFile( HANDLE hContact, const TCHAR* szDescriptio
if (this->IsOnline() && hContact && ppszFiles)
{
SEStringList targets;
- char* sid = ::db_get_sa(hContact, this->m_szModuleName, "sid");
- targets.append(sid);
+ mir_ptr<wchar_t> sid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
+ targets.append(::mir_u2a(sid));
CConversation::Ref conversation = CConversation::FindBySid(
this->skype,
- ::db_get_sa(hContact, this->m_szModuleName, "sid"));
+ sid);
conversation.fetch();
SEFilenameList fileList;
@@ -330,7 +329,7 @@ int __cdecl CSkypeProto::SendMsg(HANDLE hContact, int flags, const char* msg)
{
CConversation::Ref conversation = CConversation::FindBySid(
this->skype,
- (char*)::mir_ptr<char>(::db_get_sa(hContact, this->m_szModuleName, "sid")));
+ ::mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN)));
if (conversation)
{
@@ -416,11 +415,10 @@ int __cdecl CSkypeProto::UserIsTyping( HANDLE hContact, int type )
{
if (hContact && this->IsOnline() && this->m_iStatus != ID_STATUS_INVISIBLE)
{
- if (::strcmp(::db_get_sa(hContact, this->m_szModuleName, "sid"), this->login) != 0)
+ mir_ptr<wchar_t> sid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
+ if (::wcsicmp(sid, this->login) != 0)
{
- CConversation::Ref conversation = CConversation::FindBySid(
- this->skype,
- ::db_get_sa(hContact, this->m_szModuleName, "sid"));
+ CConversation::Ref conversation = CConversation::FindBySid(this->skype, sid);
if (conversation)
{
switch (type)
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index 74acb0f38f..4a31a66d21 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -108,12 +108,12 @@ const HtmlEntity htmlEntities[]={
struct InviteChatParam
{
- char *id;
+ wchar_t *id;
HANDLE hContact;
CSkypeProto *ppro;
- InviteChatParam(const char *id, HANDLE hContact, CSkypeProto *ppro)
- : id(::mir_strdup(id)), hContact(hContact), ppro(ppro) {}
+ InviteChatParam(const wchar_t *id, HANDLE hContact, CSkypeProto *ppro)
+ : id(::mir_wstrdup(id)), hContact(hContact), ppro(ppro) {}
~InviteChatParam()
{ ::mir_free(id); }
@@ -121,13 +121,13 @@ struct InviteChatParam
struct PasswordRequestBoxParam
{
- char *login;
- char *password;
+ wchar_t *login;
+ wchar_t *password;
bool rememberPassword;
bool showRememberPasswordBox;
- PasswordRequestBoxParam(const char *login, bool showRememberPasswordBox = true, bool rememberPassword = false) :
- login(::mir_strdup(login)),
+ PasswordRequestBoxParam(const wchar_t *login, bool showRememberPasswordBox = true, bool rememberPassword = false) :
+ login(::mir_wstrdup(login)),
password(NULL),
rememberPassword(rememberPassword),
showRememberPasswordBox(showRememberPasswordBox) { }
@@ -141,8 +141,8 @@ struct PasswordRequestBoxParam
struct PasswordChangeBoxParam
{
- char *password;
- char *password2;
+ wchar_t *password;
+ wchar_t *password2;
PasswordChangeBoxParam() { }
@@ -274,16 +274,22 @@ protected:
// account
void OnAccountChanged(int prop);
- char *login;
- char *password;
+ wchar_t *login;
+ wchar_t *password;
bool rememberPassword;
+
bool RequestPassword(PasswordRequestBoxParam &param);
bool ChangePassword(PasswordChangeBoxParam &param);
+
+ bool PrepareLogin();
+ bool PreparePassword();
HANDLE signin_lock;
bool SignIn(int status);
void __cdecl SignInAsync(void*);
+ void SetAccountSettings();
+
bool IsAvatarChanged(const SEBinary &avatar);
static SettingItem setting[19];
@@ -307,13 +313,13 @@ protected:
void OnTransferChanged(int prop, CTransfer::Ref transfer);
// chat
- static char* Groups[];
+ static wchar_t* Groups[];
bool IsChatRoom(HANDLE hContact);
- HANDLE GetChatRoomByID(const char *cid);
- HANDLE AddChatRoomByID(const char* cid, const char* name, DWORD flags = 0);
+ HANDLE GetChatRoomByID(const wchar_t *cid);
+ HANDLE AddChatRoomByID(const wchar_t* cid, const wchar_t* name, DWORD flags = 0);
- char *CSkypeProto::GetChatUsers(const char *cid);
+ char *CSkypeProto::GetChatUsers(const wchar_t *cid);
void ChatValidateContact(HANDLE hItem, HWND hwndList, const char *contacts);
void ChatPrepare(HANDLE hItem, HWND hwndList, const char *contacts);
@@ -321,15 +327,15 @@ protected:
void GetInviteContacts(HANDLE hItem, HWND hwndList, SEStringList &invitedContacts);
void InitChat();
- char *StartChat(const char *cid, const SEStringList &invitedContacts);
- void JoinToChat(const char *cid, bool showWindow = true);
- void LeaveChat(const char *cid);
+ wchar_t *StartChat(const wchar_t *cid, const SEStringList &invitedContacts);
+ void JoinToChat(const wchar_t *cid, bool showWindow = true);
+ void LeaveChat(const wchar_t *cid);
- void RaiseChatEvent(const char *cid, const char *sid, int evt, const DWORD itemData = 0, const char *status = NULL, const char *message = NULL);
- void SendChatMessage(const char *cid, const char *sid, const char *message);
- void AddChatContact(const char *cid, const char *sid, const char *group, const WORD status = ID_STATUS_ONLINE);
- void KickChatContact(const char *cid, const char *sid);
- void RemoveChatContact(const char *cid, const char *sid);
+ void RaiseChatEvent(const wchar_t *cid, const wchar_t *sid, int evt, const DWORD itemData = 0, const wchar_t *status = NULL, const wchar_t *message = NULL);
+ void SendChatMessage(const wchar_t *cid, const wchar_t *sid, const wchar_t *message);
+ void AddChatContact(const wchar_t *cid, const wchar_t *sid, const wchar_t *group, const WORD status = ID_STATUS_ONLINE);
+ void KickChatContact(const wchar_t *cid, const wchar_t *sid);
+ void RemoveChatContact(const wchar_t *cid, const wchar_t *sid);
INT_PTR __cdecl OnJoinChat(WPARAM wParam, LPARAM);
INT_PTR __cdecl OnLeaveChat(WPARAM wParam, LPARAM);
@@ -351,7 +357,7 @@ protected:
void OnContactListChanged(const ContactRef& contact);
bool IsProtoContact(HANDLE hContact);
- HANDLE GetContactBySid(const char* sid);
+ HANDLE GetContactBySid(const wchar_t* sid);
HANDLE GetContactFromAuthEvent(HANDLE hEvent);
HANDLE AddContact(CContact::Ref contact);
@@ -467,12 +473,12 @@ protected:
void RaiseMessageReceivedEvent(
HANDLE hContact,
DWORD timestamp,
- const char* message,
+ const wchar_t *message,
bool isNeedCheck = true);
void RaiseMessageSendedEvent(
HANDLE hContact,
DWORD timestamp,
- const char* message);
+ const wchar_t *message);
/*void RaiseFileReceivedEvent(
DWORD timestamp,
const char* sid,
diff --git a/protocols/Skype/src/skype_services.cpp b/protocols/Skype/src/skype_services.cpp
index 9b97771d6d..a7703a0e6d 100644
--- a/protocols/Skype/src/skype_services.cpp
+++ b/protocols/Skype/src/skype_services.cpp
@@ -17,7 +17,7 @@ INT_PTR __cdecl CSkypeProto::GetAvatarInfo(WPARAM, LPARAM lParam)
return GAIR_NOAVATAR;
}
- wchar_t *sid = this->GetSettingString(pai->hContact, "sid");
+ wchar_t *sid = ::db_get_wsa(pai->hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
if (sid)
{
wchar_t *path = this->GetContactAvatarFilePath(pai->hContact);
@@ -27,6 +27,8 @@ INT_PTR __cdecl CSkypeProto::GetAvatarInfo(WPARAM, LPARAM lParam)
pai->format = PA_FORMAT_JPEG;
return GAIR_SUCCESS;
}
+
+ ::mir_free(sid);
}
return GAIR_NOAVATAR;
diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp
index 4d10e982c9..a055f0782f 100644
--- a/protocols/Skype/src/skype_subclassing.cpp
+++ b/protocols/Skype/src/skype_subclassing.cpp
@@ -446,6 +446,46 @@ CContact::CContact(unsigned int oid, SERootObject* root) : Contact(oid, root)
this->callback == NULL;
}
+SEString CContact::GetSid()
+{
+ SEString result;
+ CContact::AVAILABILITY availability;
+ this->GetPropAvailability(availability);
+ if (availability == CContact::SKYPEOUT)
+ this->GetPropPstnnumber(result);
+ else
+ this->GetPropSkypename(result);
+ return result;
+}
+
+SEString CContact::GetNick()
+{
+ SEString result;
+ CContact::AVAILABILITY availability;
+ this->GetPropAvailability(availability);
+ if (availability == CContact::SKYPEOUT)
+ result = this->GetSid();
+ else
+ this->GetPropDisplayname(result);
+ return result;
+}
+
+bool CContact::GetFullname(SEString &firstName, SEString &lastName)
+{
+ SEString fullname;
+ this->GetPropFullname(fullname);
+ int pos = fullname.find(" ");
+ if (pos && pos < fullname.length())
+ {
+ firstName = fullname.substr(0, pos);
+ lastName = fullname.right(pos);
+ }
+
+ firstName = fullname;
+
+ return true;
+}
+
void CContact::SetOnContactChangedCallback(OnContactChanged callback, CSkypeProto* proto)
{
this->proto = proto;
@@ -491,10 +531,11 @@ void CConversation::OnChange(int prop)
}
}
-CConversation::Ref CConversation::FindBySid(CSkype *skype, SEString sid)
+CConversation::Ref CConversation::FindBySid(CSkype *skype, const wchar_t *sid)
{
+ SEString identity = ::mir_u2a(sid);
SEStringList participants;
- participants.append(sid);
+ participants.append(identity);
CConversation::Ref conversation;
skype->GetConversationByParticipants(participants, conversation);
diff --git a/protocols/Skype/src/skype_subclassing.h b/protocols/Skype/src/skype_subclassing.h
index c6c65f3c74..95f8cac9a7 100644
--- a/protocols/Skype/src/skype_subclassing.h
+++ b/protocols/Skype/src/skype_subclassing.h
@@ -58,7 +58,7 @@ public:
CConversation(unsigned int oid, SERootObject* root);
- static CConversation::Ref FindBySid(CSkype *skype, SEString sid);
+ static CConversation::Ref FindBySid(CSkype *skype, const wchar_t *sid);
void SetOnMessageReceivedCallback(OnMessageReceived callback, CSkypeProto* proto);
@@ -82,6 +82,10 @@ public:
/*bool SentAuthRequest(SEString message);*/
+ SEString GetSid();
+ SEString GetNick();
+ bool GetFullname(SEString &firstName, SEString &lastName);
+
void SetOnContactChangedCallback(OnContactChanged callback, CSkypeProto* proto);
private:
diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp
index 4cb81a5c50..fe8141d83f 100644
--- a/protocols/Skype/src/skype_utils.cpp
+++ b/protocols/Skype/src/skype_utils.cpp
@@ -351,14 +351,14 @@ wchar_t* CSkypeProto::GetContactAvatarFilePath(HANDLE hContact)
if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)path);
- wchar_t *sid = this->GetSettingString(hContact, "sid");
+ ::mir_ptr<wchar_t> sid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
if (hContact != NULL)
::mir_sntprintf(path, MAX_PATH, _T("%s\\%s.jpg"), path, sid);
else if (sid != NULL)
::mir_sntprintf(path, MAX_PATH, _T("%s\\%s avatar.jpg"), path, sid);
else
{
- delete path;
+ delete [] path;
return NULL;
}