From 53c5011ffb6e8811b48a231c788a6fba81b24e4c Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Mon, 22 Apr 2013 19:50:08 +0000 Subject: - some changes in chats (may contains errors) - fix for profile update git-svn-id: http://svn.miranda-ng.org/main/trunk@4507 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_chat.cpp | 150 +++++++++++++++++++++------------ protocols/Skype/src/skype_contacts.cpp | 42 +++------ protocols/Skype/src/skype_dialogs.cpp | 12 +-- protocols/Skype/src/skype_events.cpp | 70 +++++---------- protocols/Skype/src/skype_profile.cpp | 8 +- protocols/Skype/src/skype_proto.h | 44 +++++----- 6 files changed, 163 insertions(+), 163 deletions(-) diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp index ebd8120218..4ac596a5c9 100644 --- a/protocols/Skype/src/skype_chat.cpp +++ b/protocols/Skype/src/skype_chat.cpp @@ -25,7 +25,7 @@ bool CSkypeProto::IsChatRoom(HANDLE hContact) return ::db_get_b(hContact, this->m_szModuleName, "ChatRoom", 0) > 0; } -HANDLE CSkypeProto::GetChatRoomByID(const wchar_t *cid) +HANDLE CSkypeProto::GetChatRoomByCid(const wchar_t *cid) { HANDLE hContact = ::db_find_first(); while (hContact) @@ -43,21 +43,29 @@ HANDLE CSkypeProto::GetChatRoomByID(const wchar_t *cid) return 0; } -HANDLE CSkypeProto::AddChatRoomByID(const wchar_t* cid, const wchar_t* name, DWORD flags) +HANDLE CSkypeProto::AddChatRoom(CConversation::Ref conversation) { - HANDLE hContact = this->GetChatRoomByID(cid); + SEString data; + + conversation->GetPropIdentity(data); + mir_ptr cid = ::mir_utf8decodeW(data); + + HANDLE hContact = this->GetChatRoomByCid(cid); if ( !hContact) { hContact = (HANDLE)::CallService(MS_DB_CONTACT_ADD, 0, 0); ::CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName); + conversation->GetPropDisplayname(data); + mir_ptr name = ::mir_utf8decodeW(data); + ::db_set_b(hContact, this->m_szModuleName, "ChatRoom", 1); ::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); - wchar_t *defaultGroup = ::db_get_wsa(NULL, "Chat", "AddToGroup"); + mir_ptr defaultGroup = ::db_get_wsa(NULL, "Chat", "AddToGroup"); if (defaultGroup) { ::db_set_ws(hContact, "CList", "Group", defaultGroup); @@ -67,7 +75,7 @@ HANDLE CSkypeProto::AddChatRoomByID(const wchar_t* cid, const wchar_t* name, DWO return hContact; } -void CSkypeProto::ChatValidateContact(HANDLE hItem, HWND hwndList, const char *contacts) +void CSkypeProto::ChatValidateContact(HANDLE hItem, HWND hwndList, const wchar_t *contacts) { if ( !this->IsProtoContact(hItem) || this->IsChatRoom(hItem)) { @@ -80,7 +88,7 @@ void CSkypeProto::ChatValidateContact(HANDLE hItem, HWND hwndList, const char *c } } -void CSkypeProto::ChatPrepare(HANDLE hItem, HWND hwndList, const char *contacts) +void CSkypeProto::ChatPrepare(HANDLE hItem, HWND hwndList, const wchar_t *contacts) { if (hItem == NULL) hItem = (HANDLE)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0); @@ -154,6 +162,46 @@ void CSkypeProto::InitChat() this->HookEvent(ME_GC_BUILDMENU, &CSkypeProto::OnGCMenuHook); } +void CSkypeProto::CreateChatWindow(CConversation::Ref conversation, bool showWindow) +{ + SEString data; + + conversation->GetPropIdentity(data); + wchar_t *chatID = ::mir_utf8decodeW(data); + + conversation->GetPropDisplayname(data); + wchar_t *chatName = ::mir_utf8decodeW(data); + + GCSESSION gcw = {0}; + gcw.cbSize = sizeof(gcw); + gcw.iType = GCW_CHATROOM; + gcw.dwFlags = GC_TCHAR; + gcw.pszModule = this->m_szModuleName; + gcw.ptszName = chatName; + gcw.ptszID = chatID; + ::CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw); + + GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_ADDGROUP }; + gcd.ptszID = chatID; + + GCEVENT gce = {0}; + gce.cbSize = sizeof(GCEVENT); + gce.dwFlags = GC_TCHAR; + gce.pDest = &gcd; + for (int i = 0; i < SIZEOF(CSkypeProto::Groups); i++) + { + gce.ptszStatus =:: TranslateW(CSkypeProto::Groups[i]); + ::CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce); + } + + gcd.iType = GC_EVENT_CONTROL; + ::CallServiceSync(MS_GC_EVENT, showWindow ? SESSION_INITDONE : WINDOW_HIDDEN, (LPARAM)&gce); + ::CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce); + + ::mir_free(chatID); + ::mir_free(chatName); +} + wchar_t *CSkypeProto::StartChat(const wchar_t *cid, const SEStringList &invitedContacts) { wchar_t *chatID; @@ -226,72 +274,45 @@ wchar_t *CSkypeProto::StartChat(const wchar_t *cid, const SEStringList &invitedC return NULL; } -void CSkypeProto::JoinToChat(const wchar_t *cid, bool showWindow) +void CSkypeProto::JoinToChat(CConversation::Ref conversation, bool showWindow) { - wchar_t *chatID = ::mir_wstrdup(cid); + conversation->Join(); SEString data; - CConversation::Ref conversation; - this->skype->GetConversationByIdentity(mir_utf8encodeW(cid), conversation); - conversation->GetJoinBlob(data); - this->skype->GetConversationByBlob(data, conversation, false); - conversation->Join(); + conversation->GetPropIdentity(data); + wchar_t *chatID = ::mir_utf8decodeW(data); - conversation->GetPropDisplayname(data); - wchar_t *chatName = ::mir_utf8decodeW(data); + //conversation->GetPropDisplayname(data); + //wchar_t *chatName = ::mir_utf8decodeW(data); - GCSESSION gcw = {0}; - gcw.cbSize = sizeof(gcw); - gcw.iType = GCW_CHATROOM; - gcw.dwFlags = GC_TCHAR; - gcw.pszModule = this->m_szModuleName; - gcw.ptszName = chatName; - gcw.ptszID = chatID; - ::CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw); - - GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_ADDGROUP }; - gcd.ptszID = chatID; - - GCEVENT gce = {0}; - gce.cbSize = sizeof(GCEVENT); - gce.dwFlags = GC_TCHAR; - gce.pDest = &gcd; - - gcd.iType = GC_EVENT_ADDGROUP; - for (int i = 0; i < SIZEOF(CSkypeProto::Groups); i++) - { - gce.ptszStatus = TranslateW(CSkypeProto::Groups[i]); - CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce); - } - - gcd.iType = GC_EVENT_CONTROL; - ::CallServiceSync(MS_GC_EVENT, showWindow ? SESSION_INITDONE : WINDOW_HIDDEN, (LPARAM)&gce); - ::CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce); - //::CallServiceSync(MS_GC_EVENT, showWindow ? WINDOW_VISIBLE : WINDOW_HIDDEN, (LPARAM)&gce); + this->CreateChatWindow(conversation, showWindow); CParticipant::Refs participants; conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS); for (uint i = 0; i < participants.size(); i++) { participants[i]->GetPropIdentity(data); + mir_ptr sid = ::mir_utf8decodeW(data); CParticipant::RANK rank; participants[i]->GetPropRank(rank); + mir_ptr group = ::mir_utf8decodeW(CParticipant::GetRankName(rank)); CContact::Ref contact; + this->skype->GetContact((char *)mir_ptr(::mir_utf8encodeW(sid)), contact); + CContact::AVAILABILITY status; - this->skype->GetContact(data, contact); contact->GetPropAvailability(status); this->AddChatContact( - cid, - ::mir_utf8decodeW(data), - ::mir_utf8decodeW(CParticipant::GetRankName(rank)), + chatID, + sid, + group, this->SkypeToMirandaStatus(status)); } - ::mir_free(chatName); +// ::mir_free(chatName); ::mir_free(chatID); } @@ -371,7 +392,16 @@ INT_PTR __cdecl CSkypeProto::OnJoinChat(WPARAM wParam, LPARAM) { wchar_t *cid = ::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID"); - this->JoinToChat(cid); + SEString data; + CConversation::Ref conversation; + + //todo: fixme + this->skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation); + conversation->GetJoinBlob(data); + this->skype->GetConversationByBlob(data, conversation, false); + conversation->Join(); + + this->JoinToChat(conversation); ::mir_free(cid); } @@ -537,7 +567,7 @@ int __cdecl CSkypeProto::OnGCMenuHook(WPARAM, LPARAM lParam) } -char *CSkypeProto::GetChatUsers(const wchar_t *cid) +wchar_t *CSkypeProto::GetChatUsers(const wchar_t *cid) { GC_INFO gci = {0}; gci.Flags = USERS; @@ -547,7 +577,23 @@ char *CSkypeProto::GetChatUsers(const wchar_t *cid) ::mir_free(gci.pszID); - //StringList users(gci.pszUsers, " "); + // todo: fix me + return ::mir_a2u(gci.pszUsers); +} + +void CSkypeProto::UpdateChatUserStatus(const wchar_t *sid, const WORD status) +{ + GC_INFO gci = {0}; + gci.Flags = BYINDEX | ID | DATA | NAME | TYPE; + gci.pszModule = m_szModuleName; + + int count = ::CallServiceSync(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)this->m_szModuleName); + for (int i = 0; i < count ; i++) + { + gci.iItem = i; + + ::CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci); - return gci.pszUsers; + //this->RaiseChatEvent(gci.pszID, sid, int evt, const DWORD itemData, const wchar_t *status, const wchar_t *message) + } } \ No newline at end of file diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index 8bb2149163..b0f59323a6 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -54,13 +54,10 @@ void CSkypeProto::UpdateContactOnlineSinceTime(SEObject *obj, HANDLE hContact) void CSkypeProto::UpdateContactLastEventDate(SEObject *obj, HANDLE hContact) { - if (hContact) - { - uint newTS = obj->GetUintProp(/* CContact::P_LASTUSED_TIMESTAMP */39); - DWORD oldTS = this->GetSettingDword(hContact, "LastEventDateTS"); - if (newTS > oldTS) - this->SetSettingDword(hContact, "LastEventDateTS", newTS); - } + uint newTS = obj->GetUintProp(/* CContact::P_LASTUSED_TIMESTAMP */39); + DWORD oldTS = this->GetSettingDword(hContact, "LastEventDateTS"); + if (newTS > oldTS) + this->SetSettingDword(hContact, "LastEventDateTS", newTS); } void CSkypeProto::OnContactChanged(CContact::Ref contact, int prop) @@ -253,13 +250,11 @@ void __cdecl CSkypeProto::LoadContactList(void*) HANDLE hContact = this->AddContact(contact); + // todo: move to AddContact? this->UpdateContactAuthState(hContact, contact); this->UpdateContactStatus(hContact, contact); - SEObject *obj = contact.fetch(); - this->UpdateProfile(obj, hContact); - this->UpdateProfileAvatar(obj, hContact); - this->UpdateProfileStatusMessage(obj, hContact); + this->UpdateProfile(contact.fetch(), hContact); } } @@ -274,29 +269,12 @@ void __cdecl CSkypeProto::LoadChatList(void*) CConversation::MY_STATUS status; conversations[i]->GetPropMyStatus(status); - if (type == CConversation::CONFERENCE) + if (type == CConversation::CONFERENCE && status == CConversation::CONSUMER) { - SEString data; - - conversations[i]->GetPropIdentity(data); - wchar_t *cid = ::mir_utf8decodeW(data); - - conversations[i]->GetPropDisplayname(data); - wchar_t *name = ::mir_utf8decodeW(data); + auto conversation = conversations[i]; - HANDLE hContact = this->AddChatRoomByID(cid, name); - //::DBWriteContactSettingString(hContact, this->m_szModuleName, "Nick", name); - - ::mir_free(cid); - ::mir_free(name); - - CConversation::LOCAL_LIVESTATUS live; - conversations[i]->GetPropLocalLivestatus(live); - - if (status == CConversation::CONSUMER)// && live != CConversation::NONE) - { - this->JoinToChat(cid, false); - } + this->AddChatRoom(conversation); + this->JoinToChat(conversation, false); } } diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp index fc74ad7a24..009e8c690c 100644 --- a/protocols/Skype/src/skype_dialogs.cpp +++ b/protocols/Skype/src/skype_dialogs.cpp @@ -574,11 +574,11 @@ INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wP case CLN_NEWCONTACT: if (param && (nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0) { - char *contacts = NULL; + wchar_t *contacts = NULL; if (param->id) { - HANDLE hContact = param->ppro->GetChatRoomByID(param->id); - if (hContact && ::db_get_w(hContact, param->ppro->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) + HANDLE hContact = param->ppro->GetChatRoomByCid(param->id); + if (hContact && param->ppro->IsContactOnline(hContact)) { contacts = param->ppro->GetChatUsers(param->id); } @@ -590,11 +590,11 @@ INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wP case CLN_LISTREBUILT: if (param) { - char *contacts = NULL; + wchar_t *contacts = NULL; if (param->id) { - HANDLE hContact = param->ppro->GetChatRoomByID(param->id); - if (hContact && ::db_get_w(hContact, param->ppro->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) + HANDLE hContact = param->ppro->GetChatRoomByCid(param->id); + if (hContact && param->ppro->IsContactOnline(hContact)) { contacts = param->ppro->GetChatUsers(param->id); } diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index 77c16a0be5..23a3599fcb 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -244,7 +244,7 @@ void CSkypeProto::OnTransferChanged(int prop, CTransfer::Ref transfer) uint oid = message->getOID(); PROTOFILETRANSFERSTATUS pfts = {0}; - pfts.cbSize = sizeof(PROTOFILETRANSFERSTATUS); + pfts.cbSize = sizeof(pfts); pfts.flags = PFTS_UTF | PFTS_RECEIVING; pfts.totalFiles = 1; pfts.currentFileNumber = 0; @@ -267,9 +267,6 @@ void CSkypeProto::OnTransferChanged(int prop, CTransfer::Ref transfer) this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)oid, (LPARAM)&pfts); } break; - //uint transferRate; - //transfer->GetPropBytespersecond(transferRate); - //float transferRateInKb = (float)transferRate / 1024; } } @@ -322,11 +319,7 @@ void CSkypeProto::OnFile(CConversation::Ref conversation, CMessage::Ref message) pre.lParam = (LPARAM)message->getOID(); ::ProtoChainRecvFile(hContact, &pre); } - /*else - { - }*/ } - } } @@ -364,54 +357,33 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa conversation->GetPropIdentity(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) + HANDLE hContact = this->AddChatRoom(conversation); + if ( !this->IsContactOnline(hContact)) { - SEStringList empty; - this->StartChat(cid, empty); - - CParticipant::Refs participants; - conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS); - for (uint i = 0; i < participants.size(); i++) - { - participants[i]->GetPropIdentity(data); - - CContact::Ref contact; - CContact::AVAILABILITY status; - this->skype->GetContact(data, contact); - contact->GetPropAvailability(status); - - CParticipant::RANK rank; - participants[i]->GetPropRank(rank); - - this->AddChatContact( - cid, - ::mir_utf8decodeW(data), - ::mir_utf8decodeW(CParticipant::GetRankName(rank)), - status); - } + this->JoinToChat(conversation); } - + else { message->GetPropIdentities(data); - StringList alreadyInChat(this->GetChatUsers(cid), " "); - StringList needToAdd(data, " "); - + StringList alreadyInChat(this->GetChatUsers(cid)); + StringList needToAdd(::mir_utf8decodeW(data)); + needToAdd.remove(this->login); for (int i = 0; i < needToAdd.getCount(); i++) { - char *sid = needToAdd[i]; - if (::wcsicmp(::mir_a2u(sid), this->login) != 0 && !alreadyInChat.contains(sid)) + wchar_t *sid = needToAdd[i]; + if ( !alreadyInChat.contains(sid)) { CContact::Ref contact; + this->skype->GetContact((char *)mir_ptr(::mir_utf8encodeW(sid)), contact); + CContact::AVAILABILITY status; - this->skype->GetContact(sid, contact); contact->GetPropAvailability(status); //todo: fix rank this->AddChatContact( cid, - ::mir_a2u(sid), + sid, ::mir_utf8decodeW(CParticipant::GetRankName(CParticipant::WRITER)), status); } @@ -427,12 +399,12 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa conversation->GetPropIdentity(data); wchar_t *cid = ::mir_utf8decodeW(data); - StringList alreadyInChat(this->GetChatUsers(cid), " "); + StringList alreadyInChat(this->GetChatUsers(cid)); message->GetPropAuthor(data); wchar_t *sid = ::mir_utf8decodeW(data); if (::wcsicmp(sid, this->login) != 0) - if (alreadyInChat.contains(::mir_u2a(sid))) + if (alreadyInChat.contains(sid)) this->RemoveChatContact(cid, sid); } break; @@ -445,13 +417,13 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa message->GetPropIdentities(data); - StringList alreadyInChat(this->GetChatUsers(cid), " "); - StringList needToKick(data, " "); + StringList alreadyInChat(this->GetChatUsers(cid)); + StringList needToKick(::mir_utf8decodeW(data)); for (int i = 0; i < needToKick.getCount(); i++) { - wchar_t *sid = ::mir_utf8decodeW(needToKick[i]); - if (::wcsicmp(sid, this->login) != 0 && !alreadyInChat.contains(::mir_u2a(sid))) + wchar_t *sid = needToKick[i]; + if (::wcsicmp(sid, this->login) != 0 && !alreadyInChat.contains(sid)) this->KickChatContact(cid, sid); } } @@ -463,8 +435,8 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa conversation->GetPropIdentity(data); char *cid = ::mir_strdup(data); - /*HANDLE hContact = this->GetChatRoomByID(cid); - if ( !hContact || ::DBGetContactSettingWord(hContact, this->m_szModuleName, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) + /*HANDLE hContact = this->GetChatRoomByCid(cid); + if ( !hContact || this->IsContactOnline(hContact)) { this->JoinChat(cid); }*/ diff --git a/protocols/Skype/src/skype_profile.cpp b/protocols/Skype/src/skype_profile.cpp index 44ddea1d42..0a2a4915c9 100644 --- a/protocols/Skype/src/skype_profile.cpp +++ b/protocols/Skype/src/skype_profile.cpp @@ -28,12 +28,11 @@ SettingItem CSkypeProto::setting[] = { void CSkypeProto::UpdateProfileAvatar(SEObject *obj, HANDLE hContact) { uint newTS = obj->GetUintProp(/* *::P_AVATAR_TIMESTAMP */ 182); - DWORD oldTS = this->GetSettingDword(hContact, "AvatarTS"); + DWORD oldTS = ::db_get_dw(hContact, this->m_szModuleName, "AvatarTS", 0); wchar_t *path = this->GetContactAvatarFilePath(hContact); SEBinary data = obj->GetBinProp(/* *::P_AVATAR_IMAGE */ 37); - //if ((newTS > oldTS) || (!newTS && data.size() > 0 && _waccess(path, 0) == -1) || (newTS && _waccess(path, 0) == -1)) //hack for avatars without timestamp bool hasNewAvatar = newTS > oldTS; bool isAvatarEmpty = data.size() == 0; bool isAvatarFileExists = ::PathFileExists(path) > 0; @@ -336,10 +335,10 @@ void CSkypeProto::UpdateProfileTimezone(SEObject *obj, HANDLE hContact) void CSkypeProto::UpdateProfile(SEObject *obj, HANDLE hContact) { - this->UpdateProfileAvatar(obj, hContact); + this->UpdateProfileAvatar(obj, hContact); uint newTS = obj->GetUintProp(/* *::P_PROFILE_TIMESTAMP */ 19); - if (newTS > this->GetSettingDword("ProfileTS")) + if (newTS > ::db_get_dw(hContact, this->m_szModuleName, "ProfileTS", 0)) { this->UpdateProfileAboutText(obj, hContact); this->UpdateProfileBirthday(obj, hContact); @@ -354,6 +353,7 @@ void CSkypeProto::UpdateProfile(SEObject *obj, HANDLE hContact) this->UpdateProfilePhone(obj, hContact); this->UpdateProfileOfficePhone(obj, hContact); this->UpdateProfileState(obj, hContact); + this->UpdateProfileStatusMessage(obj, hContact); this->UpdateProfileTimezone(obj, hContact); if (hContact) diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index dd694fa681..5fa082e9df 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -8,23 +8,23 @@ typedef int (__cdecl CSkypeProto::* SkypeEventFunc)(WPARAM, LPARAM); typedef INT_PTR (__cdecl CSkypeProto::* SkypeServiceFunc)(WPARAM, LPARAM); typedef INT_PTR (__cdecl CSkypeProto::* SkypeServiceFuncParam)(WPARAM, LPARAM, LPARAM); -struct StringList : public LIST +struct StringList : public LIST { - static int compare(const char* p1, const char* p2) { return _stricmp(p1, p2); } + static int compare(const wchar_t* p1, const wchar_t* p2) { return ::wcsicmp(p1, p2); } - StringList() : LIST(2, compare) {} - StringList(const char* string, const char *delimeters) : LIST(2, compare) + StringList() : LIST(2, compare) {} + StringList(const wchar_t* string, const wchar_t *delimeters = L" ") : LIST(2, compare) { - char *data = ::mir_strdup(string); + wchar_t *data = ::mir_wstrdup(string); if (data) { - char *p = ::strtok(data, delimeters); + wchar_t *p = ::wcstok(data, delimeters); if (p) { - this->insert(::mir_strdup(p)); - while (p = strtok(NULL, delimeters)) + this->insert(::mir_wstrdup(p)); + while (p = wcstok(NULL, delimeters)) { - this->insert(::mir_strdup(p)); + this->insert(::mir_wstrdup(p)); } } ::mir_free(data); @@ -40,7 +40,7 @@ struct StringList : public LIST List_Destroy((SortedList*)this); } - int insertn(const char* p) { return insert(mir_strdup(p)); } + int insertn(const wchar_t* p) { return insert(::mir_wstrdup(p)); } int remove(int idx) { @@ -48,16 +48,16 @@ struct StringList : public LIST return List_Remove((SortedList*)this, idx); } - int remove(const char* p) + int remove(const wchar_t* p) { int idx; - return List_GetIndex((SortedList*)this, (char*)p, &idx) == 1 ? remove(idx) : -1; + return List_GetIndex((SortedList*)this, (wchar_t*)p, &idx) == 1 ? remove(idx) : -1; } - bool contains(char* p) + bool contains(wchar_t* p) { int idx; - return List_GetIndex((SortedList*)this, (char*)p, &idx) == 1; + return List_GetIndex((SortedList*)this, (wchar_t*)p, &idx) == 1; } }; @@ -290,21 +290,25 @@ protected: static wchar_t* Groups[]; bool IsChatRoom(HANDLE hContact); - HANDLE GetChatRoomByID(const wchar_t *cid); - HANDLE AddChatRoomByID(const wchar_t* cid, const wchar_t* name, DWORD flags = 0); + HANDLE GetChatRoomByCid(const wchar_t *cid); + HANDLE AddChatRoom(CConversation::Ref conversation); - char *CSkypeProto::GetChatUsers(const wchar_t *cid); + wchar_t *CSkypeProto::GetChatUsers(const wchar_t *cid); + void CSkypeProto::UpdateChatUserStatus(const wchar_t *sid, const WORD status = ID_STATUS_OFFLINE); - void ChatValidateContact(HANDLE hItem, HWND hwndList, const char *contacts); - void ChatPrepare(HANDLE hItem, HWND hwndList, const char *contacts); + void ChatValidateContact(HANDLE hItem, HWND hwndList, const wchar_t *contacts); + void ChatPrepare(HANDLE hItem, HWND hwndList, const wchar_t *contacts); void GetInviteContacts(HANDLE hItem, HWND hwndList, SEStringList &invitedContacts); void InitChat(); 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 CreateChatWindow(CConversation::Ref conversation, bool showWindow = true); + + void JoinToChat(CConversation::Ref conversation, bool showWindow = true); + 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); -- cgit v1.2.3