diff options
Diffstat (limited to 'protocols/Skype')
-rw-r--r-- | protocols/Skype/src/skype_contacts.cpp | 2 | ||||
-rw-r--r-- | protocols/Skype/src/skype_database.cpp | 20 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 28 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 9 | ||||
-rw-r--r-- | protocols/Skype/src/skype_subclassing.cpp | 55 | ||||
-rw-r--r-- | protocols/Skype/src/skype_subclassing.h | 35 |
6 files changed, 139 insertions, 10 deletions
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index 29e200236d..43560ca93d 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -540,7 +540,7 @@ HANDLE CSkypeProto::AddContactBySid(const wchar_t* sid, const wchar_t* nick, DWO else
{
if ( !(flags & PALF_TEMPORARY))
- ::DBWriteContactSettingByte(hContact, "CList", "NotOnList", 1);
+ ::DBDeleteContactSetting(hContact, "CList", "NotOnList");
}
return hContact;
diff --git a/protocols/Skype/src/skype_database.cpp b/protocols/Skype/src/skype_database.cpp index 38c08d80b8..c303f8b3aa 100644 --- a/protocols/Skype/src/skype_database.cpp +++ b/protocols/Skype/src/skype_database.cpp @@ -52,4 +52,24 @@ void CSkypeProto::RaiseAuthRequestEvent( ::strcpy((char*)pCurBlob, reason);
::CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
+}
+
+void CSkypeProto::RaiseMessageReceivedEvent(
+ DWORD timestamp,
+ const char* sid,
+ const char* nick,
+ const char* message)
+{
+ PROTORECVEVENT pre = {0};
+
+ CCSDATA ccs = {0};
+ ccs.szProtoService = PSR_MESSAGE;
+ ccs.hContact = this->AddContactBySid(::mir_a2u(sid), ::mir_a2u(nick));
+ ccs.wParam = 0;
+ ccs.lParam = (LPARAM)⪯
+ pre.flags = PREF_UTF;
+ pre.timestamp = timestamp;
+ pre.szMessage = (char *)message;
+
+ ::CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 7c96753ce3..bfb8f90d80 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -222,7 +222,12 @@ HWND __cdecl CSkypeProto::CreateExtendedSearchUI( HWND owner ){ return 0; } int __cdecl CSkypeProto::RecvContacts( HANDLE hContact, PROTORECVEVENT* ) { return 0; }
int __cdecl CSkypeProto::RecvFile( HANDLE hContact, PROTORECVFILET* ) { return 0; }
-int __cdecl CSkypeProto::RecvMsg( HANDLE hContact, PROTORECVEVENT* ) { return 0; }
+
+int __cdecl CSkypeProto::RecvMsg( HANDLE hContact, PROTORECVEVENT* pre)
+{
+ return ::Proto_RecvMessage(hContact, pre);
+}
+
int __cdecl CSkypeProto::RecvUrl( HANDLE hContact, PROTORECVEVENT* ) { return 0; }
int __cdecl CSkypeProto::SendContacts( HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList ) { return 0; }
@@ -319,6 +324,16 @@ void __cdecl CSkypeProto::SignInThread(void*) }
else
{
+ g_skype->GetConversationList(g_skype->inbox, CConversation::INBOX_CONVERSATIONS);
+ fetch(g_skype->inbox);
+ g_skype->SetOnConversationAddedCallback(
+ (CSkype::OnConversationAdded)&CSkypeProto::OnConversationAdded, this);
+ for (int i = 0 ; i < g_skype->inbox.size(); i++)
+ {
+ g_skype->inbox[i]->SetOnMessageReceivedCallback(
+ (CConversation::OnMessageReceived)&CSkypeProto::OnOnMessageReceived, this);
+ }
+
this->SetStatus(this->m_iDesiredStatus);
this->ForkThread(&CSkypeProto::LoadContactList, this);
//this->LoadContactList(this);
@@ -371,4 +386,15 @@ void CSkypeProto::RequestPassword() NULL,
CSkypeProto::SkypePasswordProc,
LPARAM(this));
+}
+
+void CSkypeProto::OnOnMessageReceived(const char *sid, const char *text)
+{
+ this->RaiseMessageReceivedEvent(time(NULL), sid, sid, text);
+}
+
+void CSkypeProto::OnConversationAdded(CConversation::Ref conversation)
+{
+ conversation->SetOnMessageReceivedCallback(
+ (CConversation::OnMessageReceived)&CSkypeProto::OnOnMessageReceived, this);
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index d5ce7bc220..295f1fcbf7 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -119,6 +119,10 @@ protected: bool IsOnline();
+ //
+ void OnOnMessageReceived(const char *sid, const char *text);
+ void OnConversationAdded(CConversation::Ref conversation);
+
// contacts
void UpdateContactAboutText(HANDLE hContact, CContact::Ref contact);
void UpdateContactAuthState(HANDLE hContact, CContact::Ref contact);
@@ -205,6 +209,11 @@ protected: // database
HANDLE AddDataBaseEvent(HANDLE hContact, WORD type, DWORD time, DWORD flags, DWORD cbBlob, PBYTE pBlob);
+ void RaiseMessageReceivedEvent(
+ DWORD timestamp,
+ const char* sid,
+ const char* nick,
+ const char* message = "");
void RaiseAuthRequestEvent(
DWORD timestamp,
const char* sid,
diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp index 4a2d9773dd..5409b9a625 100644 --- a/protocols/Skype/src/skype_subclassing.cpp +++ b/protocols/Skype/src/skype_subclassing.cpp @@ -2,6 +2,12 @@ // CSkype +CSkype::CSkype(int num_threads) : Skype(num_threads) +{ + this->proto = NULL; + this->callback == NULL; +} + CAccount* CSkype::newAccount(int oid) { return new CAccount(oid, this); @@ -27,6 +33,25 @@ CContactSearch* CSkype::newContactSearch(int oid) return new CContactSearch(oid, this); } +void CSkype::OnConversationListChange(
+ const ConversationRef &conversation,
+ const Conversation::LIST_TYPE &type,
+ const bool &added)
+{
+ if ((type == Conversation::INBOX_CONVERSATIONS) && (added) && (!inbox.contains(conversation)))
+ {
+ inbox.append(conversation);
+ if (this->proto)
+ (proto->*callback)(conversation->ref());
+ }
+} + +void CSkype::SetOnConversationAddedCallback(OnConversationAdded callback, CSkypeProto* proto) +{ + this->proto = proto; + this->callback = callback; +} + // CAccount CAccount::CAccount(unsigned int oid, SERootObject* root) : Account(oid, root) @@ -179,9 +204,35 @@ void CContact::OnChange(int prop) // Conversation -CConversation::CConversation(unsigned int oid, SERootObject* root) : Conversation(oid, root) {} +CConversation::CConversation(unsigned int oid, SERootObject* root) : Conversation(oid, root) +{ + this->proto = NULL; + this->callback == NULL; +} void CConversation::OnMessage(const MessageRef & message)
{
- // Message handling goes here
+ Message::TYPE messageType;
+ message->GetPropType(messageType);
+
+ if (messageType == Message::POSTED_TEXT)
+ {
+ SEIntList propIds;
+ SEIntDict propValues;
+ propIds.append(Message::P_AUTHOR);
+ propIds.append(Message::P_BODY_XML);
+ propValues = message->GetProps(propIds);
+
+ //if (propValues[0] != myAccountName)
+ {
+ if (this->proto) + (proto->*callback)((const char*)propValues[0], (const char*)propValues[1]);
+ }
+ }
+}
+
+void CConversation::SetOnMessageReceivedCallback(OnMessageReceived callback, CSkypeProto* proto)
+{
+ this->proto = proto; + this->callback = callback;
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_subclassing.h b/protocols/Skype/src/skype_subclassing.h index a4da27ccbd..4835023894 100644 --- a/protocols/Skype/src/skype_subclassing.h +++ b/protocols/Skype/src/skype_subclassing.h @@ -10,13 +10,19 @@ struct CSkypeProto; class CConversation : public Conversation
{
public:
- typedef DRef<CConversation, Conversation> Ref;
- typedef DRefs<CConversation, Conversation> Refs;
-
- CConversation(unsigned int oid, SERootObject* root);// : Conversation(oid, root) {};
+ typedef void (CSkypeProto::* OnMessageReceived)(const char *sid, const char *text);
-protected:
- void OnMessage(const MessageRef & message);
+ typedef DRef<CConversation, Conversation> Ref;
+ typedef DRefs<CConversation, Conversation> Refs;
+
+ CConversation(unsigned int oid, SERootObject* root);
+
+ void SetOnMessageReceivedCallback(OnMessageReceived callback, CSkypeProto* proto);
+
+private: + CSkypeProto* proto;
+ OnMessageReceived callback;
+ void OnMessage(const MessageRef & message);
};
class CContact : public Contact @@ -111,9 +117,26 @@ private: class CSkype : public Skype
{
public:
+ typedef void (CSkypeProto::* OnConversationAdded)(CConversation::Ref conversation);
+
CAccount* newAccount(int oid);
CContactGroup* newContactGroup(int oid);
CConversation* newConversation(int oid);
CContactSearch* newContactSearch(int oid);
CContact* newContact(int oid);
+
+ CConversation::Refs inbox;
+
+ CSkype(int num_threads = 1);
+
+ void SetOnConversationAddedCallback(OnConversationAdded callback, CSkypeProto* proto);
+
+private:
+ CSkypeProto* proto;
+ OnConversationAdded callback;
+
+ void OnConversationListChange(
+ const ConversationRef &conversation,
+ const Conversation::LIST_TYPE &type,
+ const bool &added);
};
\ No newline at end of file |