summaryrefslogtreecommitdiff
path: root/protocols/Skype/src
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2012-10-21 13:08:51 +0000
committerAlexander Lantsev <aunsane@gmail.com>2012-10-21 13:08:51 +0000
commita2149ab3eaefef81d2bfc92f73981128ca8af21e (patch)
tree4d2121b91b363fe9965cac0a7fd9d526307dd0b3 /protocols/Skype/src
parent0c9c36e0c60d45e3da803c83733fc1bf47a3f255 (diff)
- added message sending
git-svn-id: http://svn.miranda-ng.org/main/trunk@2016 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype/src')
-rw-r--r--protocols/Skype/src/skype_proto.cpp63
-rw-r--r--protocols/Skype/src/skype_proto.h6
-rw-r--r--protocols/Skype/src/skype_subclassing.cpp5
-rw-r--r--protocols/Skype/src/skype_utils.cpp23
4 files changed, 93 insertions, 4 deletions
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index bfb8f90d80..52881ca1a0 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -232,7 +232,32 @@ int __cdecl CSkypeProto::RecvUrl( HANDLE hContact, PROTORECVEVENT* ) { return
int __cdecl CSkypeProto::SendContacts( HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList ) { return 0; }
HANDLE __cdecl CSkypeProto::SendFile( HANDLE hContact, const TCHAR* szDescription, TCHAR** ppszFiles ) { return 0; }
-int __cdecl CSkypeProto::SendMsg( HANDLE hContact, int flags, const char* msg ) { return 0; }
+
+int __cdecl CSkypeProto::SendMsg(HANDLE hContact, int flags, const char* msg)
+{
+ int ret = time(NULL); // rewrite
+ //CCSDATA ccs = { hContact, PSR_MESSAGE, time(NULL), (LPARAM)::mir_strdup(msg) };
+ //this->ForkThread(&CSkypeProto::SendMessageAsync, &ccs);
+
+ CConversation::Ref conversation;
+ g_skype->GetConversationByIdentity(::mir_u2a(this->GetSettingString(hContact, "sid")), conversation);
+ if (conversation)
+ {
+ Message::Ref message;
+ //conversation->SetMyTextStatusTo(Participant::WRITING);
+ conversation->PostText(msg, message);
+ }
+
+ this->SendBroadcastAsync(
+ hContact,
+ ACKTYPE_MESSAGE,
+ ACKRESULT_SUCCESS,
+ (HANDLE)ret,
+ 0);
+
+ return ret;
+}
+
int __cdecl CSkypeProto::SendUrl( HANDLE hContact, int flags, const char* url ) { return 0; }
int __cdecl CSkypeProto::SetApparentMode( HANDLE hContact, int mode ) { return 0; }
@@ -277,7 +302,17 @@ int __cdecl CSkypeProto::RecvAwayMsg( HANDLE hContact, int mode, PROTORECVEVE
int __cdecl CSkypeProto::SendAwayMsg( HANDLE hContact, HANDLE hProcess, const char* msg ) { return 0; }
int __cdecl CSkypeProto::SetAwayMsg( int m_iStatus, const TCHAR* msg ) { return 0; }
-int __cdecl CSkypeProto::UserIsTyping( HANDLE hContact, int type ) { return 0; }
+int __cdecl CSkypeProto::UserIsTyping( HANDLE hContact, int type )
+{
+ //CConversation::Ref conversation;
+ //g_skype->GetConversationByIdentity(::mir_u2a(this->GetSettingString(hContact, "sid")), conversation);
+ //if (conversation)
+ //{
+ // Message::Ref message;
+ // //conversation->SetMyTextStatusTo(Participant::WRITING);
+ //}
+ return 0;
+}
int __cdecl CSkypeProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam)
{
@@ -397,4 +432,28 @@ void CSkypeProto::OnConversationAdded(CConversation::Ref conversation)
{
conversation->SetOnMessageReceivedCallback(
(CConversation::OnMessageReceived)&CSkypeProto::OnOnMessageReceived, this);
+}
+
+void __cdecl CSkypeProto::SendMessageAsync(void* arg)
+{
+ CCSDATA *ccs = static_cast<CCSDATA *>(arg);
+
+ if ( !this->IsOnline())
+ {
+ this->SendBroadcast(
+ ccs->hContact,
+ ACKTYPE_MESSAGE,
+ ACKRESULT_FAILED,
+ (HANDLE)ccs->lParam,
+ (LPARAM)"You cannot send when you are offline.");
+ }
+
+ CConversation::Ref conversation;
+ g_skype->GetConversationByIdentity(::mir_u2a(this->GetSettingString(ccs->hContact, "sid")), conversation);
+ if (conversation)
+ {
+ Message::Ref message;
+ conversation->SetMyTextStatusTo(Participant::WRITING);
+ conversation->PostText((char *)ccs->wParam, message);
+ }
} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index 9edd4283c6..62a6863a30 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -119,10 +119,12 @@ protected:
bool IsOnline();
- //
+ // messages
void OnOnMessageReceived(const char *sid, const char *text);
void OnConversationAdded(CConversation::Ref conversation);
+ void __cdecl SendMessageAsync(void*);
+
// contacts
void UpdateContactAboutText(HANDLE hContact, CContact::Ref contact);
void UpdateContactAuthState(HANDLE hContact, CContact::Ref contact);
@@ -165,6 +167,7 @@ protected:
void __cdecl SearchByEmailAsync(void*);
// utils
+ static void FakeAsync(void*);
static char* GetCountryNameById(int countryId);
static int GetCountryIdByName(const char* countryName);
@@ -186,6 +189,7 @@ protected:
int SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam);
int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam);
+ DWORD SendBroadcastAsync(HANDLE hContact, int type, int hResult, HANDLE hProcess, LPARAM lParam, size_t paramSize = 0);
void ForkThread(SkypeThreadFunc, void*);
HANDLE ForkThreadEx(SkypeThreadFunc, void*, UINT* threadID = NULL);
diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp
index 5877d7bcdc..c6eaecd4c3 100644
--- a/protocols/Skype/src/skype_subclassing.cpp
+++ b/protocols/Skype/src/skype_subclassing.cpp
@@ -216,7 +216,10 @@ void CConversation::OnMessage(const MessageRef & message)
Message::TYPE messageType;
message->GetPropType(messageType);
- if (messageType == Message::POSTED_TEXT)
+ Message::SENDING_STATUS sendingStatus;
+ message->GetPropSendingStatus(sendingStatus);
+
+ if (messageType == Message::POSTED_TEXT && !sendingStatus)
{
SEIntList propIds;
SEIntDict propValues;
diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp
index db4e5f60ba..c712d10e2e 100644
--- a/protocols/Skype/src/skype_utils.cpp
+++ b/protocols/Skype/src/skype_utils.cpp
@@ -3,6 +3,13 @@
int CSkypeProto::countriesCount;
CountryListEntry* CSkypeProto::countryList;
+void CSkypeProto::FakeAsync(void *param)
+{
+ ::Sleep(100);
+ ::CallService(MS_PROTO_BROADCASTACK, 0, (LPARAM)param);
+ ::mir_free(param);
+}
+
int CSkypeProto::GetCountryIdByName(const char* countryName)
{
for (int i = 0; i < CSkypeProto::countriesCount; i++)
@@ -109,6 +116,22 @@ int CSkypeProto::SendBroadcast(HANDLE hContact, int type, int result, HANDLE hPr
return ::CallService(MS_PROTO_BROADCASTACK, 0, (LPARAM)&ack);
}
+DWORD CSkypeProto::SendBroadcastAsync(HANDLE hContact, int type, int hResult, HANDLE hProcess, LPARAM lParam, size_t paramSize)
+{
+ ACKDATA *ack = (ACKDATA *)::mir_calloc(sizeof(ACKDATA) + paramSize);
+ ack->cbSize = sizeof(ACKDATA);
+ ack->szModule = this->m_szModuleName;
+ ack->hContact = hContact;
+ ack->type = type;
+ ack->result = hResult;
+ ack->hProcess = hProcess;
+ ack->lParam = lParam;
+ if (paramSize)
+ ::memcpy(ack+1, (void*)lParam, paramSize);
+ ::mir_forkthread(&CSkypeProto::FakeAsync, ack);
+ return 0;
+}
+
void CSkypeProto::ForkThread(SkypeThreadFunc pFunc, void *param)
{
UINT threadID;