diff options
Diffstat (limited to 'protocols/Skype')
-rw-r--r-- | protocols/Skype/Skype_10.vcxproj | 1 | ||||
-rw-r--r-- | protocols/Skype/Skype_10.vcxproj.filters | 3 | ||||
-rw-r--r-- | protocols/Skype/src/skype_chat.cpp | 184 | ||||
-rw-r--r-- | protocols/Skype/src/skype_dialogs.cpp | 53 | ||||
-rw-r--r-- | protocols/Skype/src/skype_events.cpp | 30 | ||||
-rw-r--r-- | protocols/Skype/src/skype_profile.cpp | 4 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 63 | ||||
-rw-r--r-- | protocols/Skype/src/string_list.h | 56 |
8 files changed, 214 insertions, 180 deletions
diff --git a/protocols/Skype/Skype_10.vcxproj b/protocols/Skype/Skype_10.vcxproj index 398ac252ff..a213b0e6d3 100644 --- a/protocols/Skype/Skype_10.vcxproj +++ b/protocols/Skype/Skype_10.vcxproj @@ -195,6 +195,7 @@ <ClInclude Include="src\skypekit\skypekit.h" />
<ClInclude Include="src\skypekit\transfer.h" />
<ClInclude Include="src\skype_proto.h" />
+ <ClInclude Include="src\string_list.h" />
<ClInclude Include="src\version.h" />
<ClInclude Include="src\resource.h" />
</ItemGroup>
diff --git a/protocols/Skype/Skype_10.vcxproj.filters b/protocols/Skype/Skype_10.vcxproj.filters index e8d089c327..aad1753c47 100644 --- a/protocols/Skype/Skype_10.vcxproj.filters +++ b/protocols/Skype/Skype_10.vcxproj.filters @@ -158,6 +158,9 @@ <ClInclude Include="src\skypekit\skypekit.h">
<Filter>Header Files\skypekit</Filter>
</ClInclude>
+ <ClInclude Include="src\string_list.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\Resource.rc">
diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp index a63d3475fa..204b091e8b 100644 --- a/protocols/Skype/src/skype_chat.cpp +++ b/protocols/Skype/src/skype_chat.cpp @@ -109,7 +109,7 @@ void CSkypeProto::ChatPrepare(HANDLE hItem, HWND hwndList, const wchar_t *contac }
}
-void CSkypeProto::GetInviteContacts(HANDLE hItem, HWND hwndList, SEStringList &chatTargets)
+void CSkypeProto::GetInviteContacts(HANDLE hItem, HWND hwndList, StringList &chatTargets)
{
if (hItem == NULL)
hItem = (HANDLE)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);
@@ -132,12 +132,12 @@ void CSkypeProto::GetInviteContacts(HANDLE hItem, HWND hwndList, SEStringList &c TCHAR buf[128] = _T("");
SendMessage(hwndList, CLM_GETITEMTEXT, (WPARAM)hItem, (LPARAM)buf);
- if (buf[0]) chatTargets.append(mir_t2a(buf));
+ if (buf[0]) chatTargets.insertn(buf);
}
else
{
::mir_ptr<wchar_t> sid(::db_get_wsa(hItem, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
- chatTargets.append(::mir_u2a(sid));
+ chatTargets.insertn(sid);
}
}
}
@@ -203,77 +203,77 @@ void CSkypeProto::CreateChatWindow(CConversation::Ref conversation, bool showWin ::mir_free(chatName);
}
-wchar_t *CSkypeProto::StartChat(const wchar_t *cid, const SEStringList &invitedContacts)
-{
- wchar_t *chatID;
- SEString data;
- CConversation::Ref conversation;
-
- if (invitedContacts.size())
- {
- if (cid)
- {
- g_skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation);
- conversation->GetJoinBlob(data);
- g_skype->GetConversationByBlob(data, conversation, false);
- conversation->Join();
-
- chatID = ::mir_wstrdup(cid);
- }
- else
- {
- g_skype->CreateConference(conversation);
- conversation->SetOption(CConversation::P_OPT_JOINING_ENABLED, true);
- conversation->SetOption(CConversation::P_OPT_ENTRY_LEVEL_RANK, CParticipant::WRITER);
- conversation->SetOption(CConversation::P_OPT_DISCLOSE_HISTORY, 1);
-
- conversation->GetPropIdentity(data);
- chatID = ::mir_utf8decodeW(data);
- }
-
- conversation->AddConsumers(invitedContacts);
-
- conversation->GetPropDisplayname(data);
- wchar_t *chatName;
- if (data.length())
- chatName = ::mir_utf8decodeT(data);
- else
- chatName = ::TranslateT("New conference");
-
- 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::Roles); i++)
- {
- gce.ptszStatus =:: TranslateW(CSkypeProto::Roles[i]);
- ::CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
- }
-
- gcd.iType = GC_EVENT_CONTROL;
- ::CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce);
- ::CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
- ::CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce);
-
- ::mir_free(chatName);
-
- return chatID;
- }
- else
- return NULL;
-}
+//wchar_t *CSkypeProto::StartChat(const wchar_t *cid, const SEStringList &invitedContacts)
+//{
+// wchar_t *chatID;
+// SEString data;
+// CConversation::Ref conversation;
+//
+// if (invitedContacts.size())
+// {
+// if (cid)
+// {
+// g_skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation);
+// conversation->GetJoinBlob(data);
+// g_skype->GetConversationByBlob(data, conversation, false);
+// conversation->Join();
+//
+// chatID = ::mir_wstrdup(cid);
+// }
+// else
+// {
+// g_skype->CreateConference(conversation);
+// conversation->SetOption(CConversation::P_OPT_JOINING_ENABLED, true);
+// conversation->SetOption(CConversation::P_OPT_ENTRY_LEVEL_RANK, CParticipant::WRITER);
+// conversation->SetOption(CConversation::P_OPT_DISCLOSE_HISTORY, 1);
+//
+// conversation->GetPropIdentity(data);
+// chatID = ::mir_utf8decodeW(data);
+// }
+//
+// conversation->AddConsumers(invitedContacts);
+//
+// conversation->GetPropDisplayname(data);
+// wchar_t *chatName;
+// if (data.length())
+// chatName = ::mir_utf8decodeT(data);
+// else
+// chatName = ::TranslateT("New conference");
+//
+// 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::Roles); i++)
+// {
+// gce.ptszStatus =:: TranslateW(CSkypeProto::Roles[i]);
+// ::CallServiceSync(MS_GC_EVENT, NULL, (LPARAM)&gce);
+// }
+//
+// gcd.iType = GC_EVENT_CONTROL;
+// ::CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce);
+// ::CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
+// ::CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce);
+//
+// ::mir_free(chatName);
+//
+// return chatID;
+// }
+// else
+// return NULL;
+//}
void CSkypeProto::JoinToChat(CConversation::Ref conversation, bool showWindow)
{
@@ -316,6 +316,42 @@ void CSkypeProto::JoinToChat(CConversation::Ref conversation, bool showWindow) ::mir_free(chatID);
}
+void CSkypeProto::AddConactsToChat(CConversation::Ref conversation, const StringList &invitedContacts)
+{
+ SEString data;
+
+ conversation->GetPropIdentity(data);
+ wchar_t *cid = ::mir_utf8decodeW(data);
+
+ StringList alreadyInChat(this->GetChatUsers(cid));
+
+ CParticipant::Refs participants;
+ conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS);
+ for (uint i = 0; i < participants.size(); i++)
+ {
+ participants[i]->GetPropIdentity(data);
+ mir_ptr<wchar_t> sid = ::mir_utf8decodeW(data);
+
+ if (invitedContacts.contains(sid) && !alreadyInChat.contains(sid))
+ {
+ CContact::Ref contact;
+ g_skype->GetContact((char *)mir_ptr<char>(::mir_utf8encodeW(sid)), contact);
+
+ CContact::AVAILABILITY status;
+ contact->GetPropAvailability(status);
+
+ CParticipant::RANK rank;
+ participants[i]->GetPropRank(rank);
+
+ this->AddChatContact(
+ cid,
+ sid,
+ CSkypeProto::Roles[rank],
+ status);
+ }
+ }
+}
+
void CSkypeProto::LeaveChat(const wchar_t *cid)
{
wchar_t *chatID = ::mir_wstrdup(cid);
diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp index 7a02cebe69..647e84e155 100644 --- a/protocols/Skype/src/skype_dialogs.cpp +++ b/protocols/Skype/src/skype_dialogs.cpp @@ -640,50 +640,33 @@ INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wP {
HWND hwndList = ::GetDlgItem(hwndDlg, IDC_CCLIST);
- SEStringList invitedContacts;
+ StringList invitedContacts;
param->ppro->GetInviteContacts(NULL, hwndList, invitedContacts);
wchar_t *chatID = ::mir_wstrdup(param->id);
+ SEStringList needToAdd;
+ CConversation::Ref conversation;
if (chatID)
{
- for (uint i = 0; i < invitedContacts.size(); i++)
- {
- CContact::Ref contact;
- CContact::AVAILABILITY status;
- g_skype->GetContact(invitedContacts[i], contact);
- contact->GetPropAvailability(status);
-
- //todo: fix rank
- param->ppro->AddChatContact(
- chatID,
- ::mir_utf8decodeW(invitedContacts[i]),
- CSkypeProto::Roles[CParticipant::SPEAKER],
- status);
- }
-
- CConversation::Ref conversation;
g_skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation);
- conversation->AddConsumers(invitedContacts);
+ for (uint i = 0; i < invitedContacts.getCount(); i++)
+ needToAdd.append((char *)mir_ptr<char>(::mir_u2a(invitedContacts[i])));
+ conversation->AddConsumers(needToAdd);
}
else
- {
- chatID = param->ppro->StartChat(NULL, invitedContacts);
-
- for (uint i = 0; i < invitedContacts.size(); i++)
- {
- CContact::Ref contact;
- CContact::AVAILABILITY status;
- g_skype->GetContact(invitedContacts[i], contact);
- contact->GetPropAvailability(status);
-
- //todo: fix rank
- param->ppro->AddChatContact(
- chatID,
- ::mir_utf8decodeW(invitedContacts[i]),
- CSkypeProto::Roles[CParticipant::SPEAKER],
- status);
- }
+ {
+ g_skype->CreateConference(conversation);
+ conversation->SetOption(CConversation::P_OPT_JOINING_ENABLED, true);
+ conversation->SetOption(CConversation::P_OPT_ENTRY_LEVEL_RANK, CParticipant::WRITER);
+ conversation->SetOption(CConversation::P_OPT_DISCLOSE_HISTORY, 1);
+ conversation->AddConsumers(needToAdd);
+
+ SEString data;
+ conversation->GetPropIdentity(data);
+ chatID = ::mir_utf8decodeW(data);
+
+ param->ppro->JoinToChat(conversation);
}
if (chatID)
EndDialog(hwndDlg, IDOK);
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index cc814d52e7..3ba8f1a113 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -399,15 +399,19 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa }
else
{
- message->GetPropIdentities(data);
-
StringList alreadyInChat(this->GetChatUsers(cid));
+
+ message->GetPropIdentities(data);
StringList needToAdd(::mir_utf8decodeW(data));
- needToAdd.remove(this->login);
- for (int i = 0; i < needToAdd.getCount(); i++)
+
+ CParticipant::Refs participants;
+ conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS);
+ for (uint i = 0; i < participants.size(); i++)
{
- wchar_t *sid = needToAdd[i];
- if ( !alreadyInChat.contains(sid))
+ participants[i]->GetPropIdentity(data);
+ mir_ptr<wchar_t> sid = ::mir_utf8decodeW(data);
+
+ if (needToAdd.contains(sid) && !alreadyInChat.contains(sid))
{
CContact::Ref contact;
g_skype->GetContact((char *)mir_ptr<char>(::mir_utf8encodeW(sid)), contact);
@@ -415,11 +419,13 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa CContact::AVAILABILITY status;
contact->GetPropAvailability(status);
- //todo: fix rank
+ CParticipant::RANK rank;
+ participants[i]->GetPropRank(rank);
+
this->AddChatContact(
cid,
sid,
- CSkypeProto::Roles[CParticipant::WRITER],
+ CSkypeProto::Roles[rank],
status);
}
}
@@ -470,11 +476,11 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa conversation->GetPropIdentity(data);
char *cid = ::mir_strdup(data);
- /*HANDLE hContact = this->GetChatRoomByCid(cid);
- if ( !hContact || this->IsContactOnline(hContact))
+ HANDLE hContact = this->AddChatRoom(conversation);
+ if ( !this->IsContactOnline(hContact))
{
- this->JoinChat(cid);
- }*/
+ this->JoinToChat(conversation);
+ }
}
break;
diff --git a/protocols/Skype/src/skype_profile.cpp b/protocols/Skype/src/skype_profile.cpp index a20d93eae0..96217b2375 100644 --- a/protocols/Skype/src/skype_profile.cpp +++ b/protocols/Skype/src/skype_profile.cpp @@ -1,6 +1,10 @@ #include "skype_proto.h"
#include <sstream>
+#define LI_STRING 0
+#define LI_LIST 1
+#define LI_NUMBER 2
+
SettingItem CSkypeProto::setting[] = {
{LPGENT("Nick"), "Nick", DBVT_WCHAR, LI_STRING},
{LPGENT("First name"), "FirstName", DBVT_WCHAR, LI_STRING},
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 0b8e41e2f5..f42d581b35 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -1,6 +1,7 @@ #pragma once
#include "skype.h"
+#include "string_list.h"
#include "skypekit\skypekit.h"
#include <map>
@@ -11,59 +12,6 @@ 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<wchar_t>
-{
- static int compare(const wchar_t* p1, const wchar_t* p2) { return ::wcsicmp(p1, p2); }
-
- StringList() : LIST<wchar_t>(2, compare) {}
- StringList(const wchar_t* string, const wchar_t *delimeters = L" ") : LIST<wchar_t>(2, compare)
- {
- wchar_t *data = ::mir_wstrdup(string);
- if (data)
- {
- wchar_t *p = ::wcstok(data, delimeters);
- if (p)
- {
- this->insert(::mir_wstrdup(p));
- while (p = wcstok(NULL, delimeters))
- {
- this->insert(::mir_wstrdup(p));
- }
- }
- ::mir_free(data);
- }
- }
- ~StringList() { destroy(); }
-
- void destroy( void )
- {
- for (int i=0; i < count; i++)
- mir_free(items[i]);
-
- List_Destroy((SortedList*)this);
- }
-
- int insertn(const wchar_t* p) { return insert(::mir_wstrdup(p)); }
-
- int remove(int idx)
- {
- mir_free(items[idx]);
- return List_Remove((SortedList*)this, idx);
- }
-
- int remove(const wchar_t* p)
- {
- int idx;
- return List_GetIndex((SortedList*)this, (wchar_t*)p, &idx) == 1 ? remove(idx) : -1;
- }
-
- bool contains(wchar_t* p)
- {
- int idx;
- return List_GetIndex((SortedList*)this, (wchar_t*)p, &idx) == 1;
- }
-};
-
struct _tag_iconList
{
wchar_t* Description;
@@ -72,10 +20,6 @@ struct _tag_iconList HANDLE Handle;
};
-#define LI_STRING 0
-#define LI_LIST 1
-#define LI_NUMBER 2
-
struct SettingItem
{
const TCHAR *szDescription;
@@ -312,15 +256,16 @@ protected: 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 GetInviteContacts(HANDLE hItem, HWND hwndList, StringList &invitedContacts);
void InitChat();
- wchar_t *StartChat(const wchar_t *cid, const SEStringList &invitedContacts);
+ //wchar_t *StartChat(const wchar_t *cid, const SEStringList &invitedContacts);
void LeaveChat(const wchar_t *cid);
void CreateChatWindow(CConversation::Ref conversation, bool showWindow = true);
void JoinToChat(CConversation::Ref conversation, bool showWindow = true);
+ void AddConactsToChat(CConversation::Ref conversation, const StringList &invitedContacts);
void RaiseChatEvent(const wchar_t *cid, const wchar_t *sid, int evt, DWORD flags = 0x0001, 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);
diff --git a/protocols/Skype/src/string_list.h b/protocols/Skype/src/string_list.h new file mode 100644 index 0000000000..241080928e --- /dev/null +++ b/protocols/Skype/src/string_list.h @@ -0,0 +1,56 @@ +#pragma once
+
+#include <m_system_cpp.h>
+
+struct StringList : public LIST<wchar_t>
+{
+ static int compare(const wchar_t* p1, const wchar_t* p2) { return ::wcsicmp(p1, p2); }
+
+ StringList() : LIST<wchar_t>(2, compare) {}
+ StringList(const wchar_t* string, const wchar_t *delimeters = L" ") : LIST<wchar_t>(2, compare)
+ {
+ wchar_t *data = ::mir_wstrdup(string);
+ if (data)
+ {
+ wchar_t *p = ::wcstok(data, delimeters);
+ if (p)
+ {
+ this->insert(::mir_wstrdup(p));
+ while (p = wcstok(NULL, delimeters))
+ {
+ this->insert(::mir_wstrdup(p));
+ }
+ }
+ ::mir_free(data);
+ }
+ }
+ ~StringList() { destroy(); }
+
+ void destroy( void )
+ {
+ for (int i=0; i < count; i++)
+ mir_free(items[i]);
+
+ List_Destroy((SortedList*)this);
+ }
+
+ int insertn(const wchar_t* p) { return insert(::mir_wstrdup(p)); }
+
+ int remove(int idx)
+ {
+ mir_free(items[idx]);
+ return List_Remove((SortedList*)this, idx);
+ }
+
+ int remove(const wchar_t* p)
+ {
+ int idx;
+ return List_GetIndex((SortedList*)this, (wchar_t*)p, &idx) == 1 ? remove(idx) : -1;
+ }
+
+ bool contains(wchar_t* p) const
+ {
+ int idx;
+ return List_GetIndex((SortedList*)this, (wchar_t*)p, &idx) == 1;
+ }
+};
\ No newline at end of file |