From e0030d9abd9ecd7bf4ab41a7269c051601576a2d Mon Sep 17 00:00:00 2001
From: Alexander Lantsev <aunsane@gmail.com>
Date: Fri, 21 Dec 2012 19:30:58 +0000
Subject: - fixed name of new chat in CL - fixed own messages in chat

git-svn-id: http://svn.miranda-ng.org/main/trunk@2783 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
---
 protocols/Skype/src/skype_chat.cpp     | 21 +++++++++++++++++++--
 protocols/Skype/src/skype_contacts.cpp |  1 +
 protocols/Skype/src/skype_dialogs.cpp  |  8 +++-----
 protocols/Skype/src/skype_events.cpp   |  3 ++-
 protocols/Skype/src/skype_proto.h      |  2 +-
 5 files changed, 26 insertions(+), 9 deletions(-)

(limited to 'protocols/Skype/src')

diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp
index 8072f443e0..66fea56334 100644
--- a/protocols/Skype/src/skype_chat.cpp
+++ b/protocols/Skype/src/skype_chat.cpp
@@ -137,7 +137,7 @@ void CSkypeProto::InitChat()
 	this->HookEvent(ME_GC_BUILDMENU, &CSkypeProto::OnGCMenuHook);
 }
 
-char *CSkypeProto::StartChat(const char *cid)
+char *CSkypeProto::StartChat(const char *cid, const SEStringList &invitedContacts)
 {
 	char *chatID;
 	SEString data;
@@ -163,8 +163,14 @@ char *CSkypeProto::StartChat(const char *cid)
 		chatID = ::mir_strdup(data);
 	}	
 
+	conversation->AddConsumers(invitedContacts);
+
 	conversation->GetPropDisplayname(data);
-	char *chatName = ::mir_utf8decodeA(data);
+	char *chatName;
+	if (data.length())
+		chatName = ::mir_utf8decodeA(data);
+	else
+		chatName = Translate("New conference");
 
 	GCSESSION gcw = {0};
 	gcw.cbSize = sizeof(gcw);
@@ -372,6 +378,17 @@ int __cdecl CSkypeProto::OnGCEventHook(WPARAM, LPARAM lParam)
 					CMessage::Ref message;
 					char *text = ::mir_utf8encode(gch->pszText);
 					conversation->PostText(text, message);
+					
+					char *nick = (char *)::DBGetString(NULL, this->m_szModuleName, "Nick");
+					if (::stricmp(nick, "") == 0)
+					{
+						nick = this->login;
+					}
+
+					this->SendChatMessage(
+						chatID, 
+						nick, 
+						gch->pszText);
 				}
 			}
 			break;
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp
index bfdac69080..26e26326a4 100644
--- a/protocols/Skype/src/skype_contacts.cpp
+++ b/protocols/Skype/src/skype_contacts.cpp
@@ -742,6 +742,7 @@ void __cdecl CSkypeProto::LoadContactList(void*)
 			char *name = ::mir_utf8decodeA(data);
 
 			HANDLE hContact = this->AddChatRoomByID(cid, name);
+			//::DBWriteContactSettingString(hContact, this->m_szModuleName, "Nick", name);
 
 			CConversation::LOCAL_LIVESTATUS live;
 			conversations[i]->GetPropLocalLivestatus(live);
diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp
index ed56eee734..f91416c599 100644
--- a/protocols/Skype/src/skype_dialogs.cpp
+++ b/protocols/Skype/src/skype_dialogs.cpp
@@ -556,7 +556,6 @@ INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wP
 					SEStringList invitedContacts;
 					param->ppro->GetInviteContacts(NULL, hwndList, invitedContacts);
 
-					CConversation::Ref conversation;
 					char *chatID = ::mir_strdup(param->id);
 
 					if (chatID)
@@ -566,19 +565,18 @@ INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wP
 							param->ppro->AddChatContact(chatID, invitedContacts[i]);
 						}
 
+						CConversation::Ref conversation;
 						g_skype->GetConversationByIdentity(chatID, conversation);
 						conversation->AddConsumers(invitedContacts);
 					}
 					else
 					{
-						chatID = param->ppro->StartChat(NULL);
+						chatID = param->ppro->StartChat(NULL, invitedContacts);
+
 						for (uint i = 0; i < invitedContacts.size(); i++)
 						{
 							param->ppro->AddChatContact(chatID, invitedContacts[i]);
 						}
-
-						g_skype->GetConversationByIdentity(chatID, conversation);
-						conversation->AddConsumers(invitedContacts);
 					}
 				}
 
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp
index 793a09a4f3..9b1e442133 100644
--- a/protocols/Skype/src/skype_events.cpp
+++ b/protocols/Skype/src/skype_events.cpp
@@ -170,7 +170,8 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa
 			HANDLE hContact = this->GetChatRoomByID(cid);
 			if ( !hContact || ::DBGetContactSettingWord(hContact, this->m_szModuleName, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
 			{
-				this->StartChat(cid);
+				SEStringList empty;
+				this->StartChat(cid, empty);
 				
 				CParticipant::Refs participants;
 				conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS);
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index 8fa24a18a7..bd2f8ed109 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -259,7 +259,7 @@ protected:
 	void GetInviteContacts(HANDLE hItem, HWND hwndList, SEStringList &invitedContacts);
 	
 	void InitChat();
-	char *StartChat(const char *cid);
+	char *StartChat(const char *cid, const SEStringList &invitedContacts);
 	void JoinToChat(const char *cid, bool showWindow = true);
 	void LeaveChat(const char *cid);
 
-- 
cgit v1.2.3