diff options
Diffstat (limited to 'protocols/Skype/src/skypekit')
-rw-r--r-- | protocols/Skype/src/skypekit/account.cpp | 34 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/account.h | 26 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/common.h | 8 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/contact.cpp | 59 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/contact.h | 26 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/conversation.cpp | 3 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/conversation.h | 15 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/group.cpp | 19 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/group.h | 22 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/message.cpp | 3 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/message.h | 12 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/participant.cpp | 33 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/participant.h | 14 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/search.cpp | 53 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/search.h | 33 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/skype.cpp | 63 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/skype.h | 41 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/transfer.cpp | 19 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/transfer.h | 22 |
19 files changed, 505 insertions, 0 deletions
diff --git a/protocols/Skype/src/skypekit/account.cpp b/protocols/Skype/src/skypekit/account.cpp new file mode 100644 index 0000000000..313b1cf50d --- /dev/null +++ b/protocols/Skype/src/skypekit/account.cpp @@ -0,0 +1,34 @@ +#include "account.h"
+#include "skype.h"
+
+CAccount::CAccount(unsigned int oid, SERootObject* root) : Account(oid, root)
+{
+ this->proto = NULL;
+ this->callback == NULL;
+}
+
+void CAccount::SetOnAccountChangedCallback(OnAccountChanged callback, CSkypeProto* proto)
+{
+ this->skype = (CSkype *)root;
+
+ this->proto = proto;
+ this->callback = callback;
+}
+
+bool CAccount::SetAvatar(SEBinary avatar, Skype::VALIDATERESULT &result)
+{
+ int fbl;
+ if (!this->skype->ValidateAvatar(avatar, result, fbl) || result != Skype::VALIDATED_OK)
+ return false;
+
+ if (!this->SetBinProperty(Account::P_AVATAR_IMAGE, avatar))
+ return false;
+
+ return true;
+}
+
+void CAccount::OnChange(int prop)
+{
+ if (this->proto)
+ (proto->*callback)(prop);
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/account.h b/protocols/Skype/src/skypekit/account.h new file mode 100644 index 0000000000..b537019698 --- /dev/null +++ b/protocols/Skype/src/skypekit/account.h @@ -0,0 +1,26 @@ +#pragma once
+
+#include "common.h"
+
+class CSkype;
+
+class CAccount : public Account
+{
+public:
+ typedef void (CSkypeProto::* OnAccountChanged)(int);
+
+ typedef DRef<CAccount, Account> Ref;
+ typedef DRefs<CAccount, Account> Refs;
+
+ CAccount(unsigned int oid, SERootObject* root);
+
+ bool SetAvatar(SEBinary avatar, Skype::VALIDATERESULT &result);
+
+ void SetOnAccountChangedCallback(OnAccountChanged callback, CSkypeProto* proto);
+
+private:
+ CSkype *skype;
+ CSkypeProto* proto;
+ OnAccountChanged callback;
+ void OnChange(int prop);
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/common.h b/protocols/Skype/src/skypekit/common.h new file mode 100644 index 0000000000..de00501ba3 --- /dev/null +++ b/protocols/Skype/src/skypekit/common.h @@ -0,0 +1,8 @@ +#pragma once
+
+#undef OCSP_REQUEST
+#undef OCSP_RESPONSE
+
+#include <skype-embedded_2.h>
+
+struct CSkypeProto;
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/contact.cpp b/protocols/Skype/src/skypekit/contact.cpp new file mode 100644 index 0000000000..2030eba250 --- /dev/null +++ b/protocols/Skype/src/skypekit/contact.cpp @@ -0,0 +1,59 @@ +#include "contact.h"
+
+CContact::CContact(unsigned int oid, SERootObject* root) : Contact(oid, root)
+{
+ this->proto = NULL;
+ this->callback == NULL;
+}
+
+SEString CContact::GetSid()
+{
+ SEString result;
+ CContact::AVAILABILITY availability;
+ this->GetPropAvailability(availability);
+ if (availability == CContact::SKYPEOUT)
+ this->GetPropPstnnumber(result);
+ else
+ this->GetPropSkypename(result);
+ return result;
+}
+
+SEString CContact::GetNick()
+{
+ SEString result;
+ CContact::AVAILABILITY availability;
+ this->GetPropAvailability(availability);
+ if (availability == CContact::SKYPEOUT)
+ result = this->GetSid();
+ else
+ this->GetPropDisplayname(result);
+ return result;
+}
+
+bool CContact::GetFullname(SEString &firstName, SEString &lastName)
+{
+ SEString fullname;
+ this->GetPropFullname(fullname);
+ int pos = fullname.find(" ");
+ if (pos && pos < fullname.length())
+ {
+ firstName = fullname.substr(0, pos);
+ lastName = fullname.right(pos);
+ }
+
+ firstName = fullname;
+
+ return true;
+}
+
+void CContact::SetOnContactChangedCallback(OnContactChanged callback, CSkypeProto* proto)
+{
+ this->proto = proto;
+ this->callback = callback;
+}
+
+void CContact::OnChange(int prop)
+{
+ if (this->proto)
+ (proto->*callback)(this->ref(), prop);
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/contact.h b/protocols/Skype/src/skypekit/contact.h new file mode 100644 index 0000000000..ee36764c50 --- /dev/null +++ b/protocols/Skype/src/skypekit/contact.h @@ -0,0 +1,26 @@ +#pragma once
+
+#include "common.h"
+
+class CContact : public Contact
+{
+public:
+ typedef void (CSkypeProto::* OnContactChanged)(CContact::Ref contact, int);
+
+ typedef DRef<CContact, Contact> Ref;
+ typedef DRefs<CContact, Contact> Refs;
+
+ CContact(unsigned int oid, SERootObject* root);
+
+ SEString GetSid();
+ SEString GetNick();
+ bool GetFullname(SEString &firstName, SEString &lastName);
+
+ void SetOnContactChangedCallback(OnContactChanged callback, CSkypeProto* proto);
+
+private:
+ CSkypeProto* proto;
+ OnContactChanged callback;
+
+ void OnChange(int prop);
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/conversation.cpp b/protocols/Skype/src/skypekit/conversation.cpp new file mode 100644 index 0000000000..e907c82d75 --- /dev/null +++ b/protocols/Skype/src/skypekit/conversation.cpp @@ -0,0 +1,3 @@ +#include "conversation.h"
+
+CConversation::CConversation(unsigned int oid, SERootObject* root) : Conversation(oid, root) { }
diff --git a/protocols/Skype/src/skypekit/conversation.h b/protocols/Skype/src/skypekit/conversation.h new file mode 100644 index 0000000000..9fdc064962 --- /dev/null +++ b/protocols/Skype/src/skypekit/conversation.h @@ -0,0 +1,15 @@ +#pragma once
+
+#include "common.h"
+
+class CConversation : public Conversation
+{
+public:
+ typedef DRef<CConversation, Conversation> Ref;
+ typedef DRefs<CConversation, Conversation> Refs;
+
+ CConversation(unsigned int oid, SERootObject* root);
+
+private:
+ CSkypeProto* proto;
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/group.cpp b/protocols/Skype/src/skypekit/group.cpp new file mode 100644 index 0000000000..f547563bcf --- /dev/null +++ b/protocols/Skype/src/skypekit/group.cpp @@ -0,0 +1,19 @@ +#include "group.h"
+
+CContactGroup::CContactGroup(unsigned int oid, SERootObject* root) : ContactGroup(oid, root)
+{
+ this->proto = NULL;
+ this->callback == NULL;
+}
+
+void CContactGroup::SetOnContactListChangedCallback(OnContactListChanged callback, CSkypeProto* proto)
+{
+ this->proto = proto;
+ this->callback = callback;
+}
+
+void CContactGroup::OnChange(const ContactRef &contact)
+{
+ if (this->proto)
+ (proto->*callback)(contact);
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/group.h b/protocols/Skype/src/skypekit/group.h new file mode 100644 index 0000000000..ff395594a5 --- /dev/null +++ b/protocols/Skype/src/skypekit/group.h @@ -0,0 +1,22 @@ +#pragma once
+
+#include "common.h"
+#include "contact.h"
+
+class CContactGroup : public ContactGroup
+{
+public:
+ typedef void (CSkypeProto::* OnContactListChanged)(CContact::Ref contact);
+
+ typedef DRef<CContactGroup, ContactGroup> Ref;
+ typedef DRefs<CContactGroup, ContactGroup> Refs;
+ CContactGroup(unsigned int oid, SERootObject* root);
+
+ void SetOnContactListChangedCallback(OnContactListChanged callback, CSkypeProto* proto);
+
+private:
+ CSkypeProto* proto;
+ OnContactListChanged callback;
+
+ void OnChange(const ContactRef &contact);
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/message.cpp b/protocols/Skype/src/skypekit/message.cpp new file mode 100644 index 0000000000..ce96de0c01 --- /dev/null +++ b/protocols/Skype/src/skypekit/message.cpp @@ -0,0 +1,3 @@ +#include "message.h"
+
+CMessage::CMessage(unsigned int oid, SERootObject* root) : Message(oid, root) { }
diff --git a/protocols/Skype/src/skypekit/message.h b/protocols/Skype/src/skypekit/message.h new file mode 100644 index 0000000000..6bf1eda497 --- /dev/null +++ b/protocols/Skype/src/skypekit/message.h @@ -0,0 +1,12 @@ +#pragma once
+
+#include "common.h"
+
+class CMessage : public Message
+{
+public:
+ typedef DRef<CMessage, Message> Ref;
+ typedef DRefs<CMessage, Message> Refs;
+
+ CMessage(unsigned int oid, SERootObject* root);
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/participant.cpp b/protocols/Skype/src/skypekit/participant.cpp new file mode 100644 index 0000000000..8b25254a0e --- /dev/null +++ b/protocols/Skype/src/skypekit/participant.cpp @@ -0,0 +1,33 @@ +#include "participant.h"
+
+CParticipant::CParticipant(unsigned int oid, SERootObject* root) : Participant(oid, root) { }
+
+SEString CParticipant::GetRankName(CParticipant::RANK rank)
+{
+ char *result = NULL;
+ switch (rank)
+ {
+ case CParticipant::CREATOR:
+ result = "Creator";
+ break;
+ case CParticipant::ADMIN:
+ result = "Admin";
+ break;
+ case CParticipant::SPEAKER:
+ result = "Speaker";
+ break;
+ case CParticipant::WRITER:
+ result = "Writer";
+ break;
+ case CParticipant::SPECTATOR:
+ result = "Spectator";
+ break;
+ case CParticipant::RETIRED:
+ result = "Retried";
+ break;
+ case CParticipant::OUTLAW:
+ result = "Outlaw";
+ break;
+ }
+ return result;
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/participant.h b/protocols/Skype/src/skypekit/participant.h new file mode 100644 index 0000000000..3a09d28017 --- /dev/null +++ b/protocols/Skype/src/skypekit/participant.h @@ -0,0 +1,14 @@ +#pragma once
+
+#include "common.h"
+
+class CParticipant : public Participant
+{
+public:
+ typedef DRef<CParticipant, Participant> Ref;
+ typedef DRefs<CParticipant, Participant> Refs;
+
+ CParticipant(unsigned int oid, SERootObject* root);
+
+ static SEString GetRankName(CParticipant::RANK rank);
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/search.cpp b/protocols/Skype/src/skypekit/search.cpp new file mode 100644 index 0000000000..362e412c86 --- /dev/null +++ b/protocols/Skype/src/skypekit/search.cpp @@ -0,0 +1,53 @@ +#include "search.h"
+
+CContactSearch::CContactSearch(unsigned int oid, SERootObject* root) : ContactSearch(oid, root)
+{
+ this->proto = NULL;
+ this->SearchCompletedCallback == NULL;
+ this->ContactFindedCallback == NULL;
+}
+
+void CContactSearch::OnChange(int prop)
+{
+ if (prop == P_CONTACT_SEARCH_STATUS)
+ {
+ CContactSearch::STATUS status;
+ this->GetPropContactSearchStatus(status);
+ if (status == FINISHED || status == FAILED)
+ {
+ this->isSeachFinished = true;
+ if (this->proto)
+ (proto->*SearchCompletedCallback)(this->hSearch);
+ }
+ }
+}
+
+void CContactSearch::OnNewResult(const ContactRef &contact, const uint &rankValue)
+{
+ if (this->proto)
+ (proto->*ContactFindedCallback)(contact, this->hSearch);
+}
+
+void CContactSearch::BlockWhileSearch()
+{
+ this->isSeachFinished = false;
+ this->isSeachFailed = false;
+ while (!this->isSeachFinished && !this->isSeachFailed)
+ Sleep(1);
+}
+
+void CContactSearch::SetProtoInfo(CSkypeProto* proto, HANDLE hSearch)
+{
+ this->proto = proto;
+ this->hSearch = hSearch;
+}
+
+void CContactSearch::SetOnSearchCompleatedCallback(OnSearchCompleted callback)
+{
+ this->SearchCompletedCallback = callback;
+}
+
+void CContactSearch::SetOnContactFindedCallback(OnContactFinded callback)
+{
+ this->ContactFindedCallback = callback;
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/search.h b/protocols/Skype/src/skypekit/search.h new file mode 100644 index 0000000000..60b920130d --- /dev/null +++ b/protocols/Skype/src/skypekit/search.h @@ -0,0 +1,33 @@ +#pragma once
+
+#include "common.h"
+#include "contact.h"
+
+class CContactSearch : public ContactSearch
+{
+public:
+ typedef void (CSkypeProto::* OnSearchCompleted)(HANDLE hSearch);
+ typedef void (CSkypeProto::* OnContactFinded)(CContact::Ref contact, HANDLE hSearch);
+
+ typedef DRef<CContactSearch, ContactSearch> Ref;
+ typedef DRefs<CContactSearch, ContactSearch> Refs;
+
+ bool isSeachFinished;
+ bool isSeachFailed;
+
+ CContactSearch(unsigned int oid, SERootObject* root);
+
+ void OnChange(int prop);
+ void OnNewResult(const ContactRef &contact, const uint &rankValue);
+
+ void SetProtoInfo(CSkypeProto* proto, HANDLE hSearch);
+ void SetOnSearchCompleatedCallback(OnSearchCompleted callback);
+ void SetOnContactFindedCallback(OnContactFinded callback);
+
+ void BlockWhileSearch();
+private:
+ HANDLE hSearch;
+ CSkypeProto* proto;
+ OnSearchCompleted SearchCompletedCallback;
+ OnContactFinded ContactFindedCallback;
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/skype.cpp b/protocols/Skype/src/skypekit/skype.cpp new file mode 100644 index 0000000000..fe22f548c8 --- /dev/null +++ b/protocols/Skype/src/skypekit/skype.cpp @@ -0,0 +1,63 @@ +#include "skype.h"
+
+CSkype::CSkype(int num_threads) : Skype(num_threads)
+{
+ this->proto = NULL;
+ this->onMessagedCallback = NULL;
+}
+
+CAccount* CSkype::newAccount(int oid)
+{
+ return new CAccount(oid, this);
+}
+
+CContactGroup* CSkype::newContactGroup(int oid)
+{
+ return new CContactGroup(oid, this);
+}
+
+CContact* CSkype::newContact(int oid)
+{
+ return new CContact(oid, this);
+}
+
+CConversation* CSkype::newConversation(int oid)
+{
+ return new CConversation(oid, this);
+}
+
+CParticipant* CSkype::newParticipant(int oid)
+{
+ return new CParticipant(oid, this);
+}
+
+CMessage* CSkype::newMessage(int oid)
+{
+ return new CMessage(oid, this);
+}
+
+CTransfer* CSkype::newTransfer(int oid)
+{
+ return new CTransfer(oid, this);
+}
+
+CContactSearch* CSkype::newContactSearch(int oid)
+{
+ return new CContactSearch(oid, this);
+}
+
+void CSkype::OnMessage (
+ const MessageRef & message,
+ const bool & changesInboxTimestamp,
+ const MessageRef & supersedesHistoryMessage,
+ const ConversationRef & conversation)
+{
+ if (this->proto)
+ (proto->*onMessagedCallback)(conversation, message);
+}
+
+void CSkype::SetOnMessageCallback(OnMessaged callback, CSkypeProto* proto)
+{
+ this->proto = proto;
+ this->onMessagedCallback = callback;
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/skype.h b/protocols/Skype/src/skypekit/skype.h new file mode 100644 index 0000000000..faac4f3d65 --- /dev/null +++ b/protocols/Skype/src/skypekit/skype.h @@ -0,0 +1,41 @@ +#pragma once
+
+#include "common.h"
+
+#include "group.h"
+#include "search.h"
+#include "account.h"
+#include "contact.h"
+#include "message.h"
+#include "transfer.h"
+#include "participant.h"
+#include "conversation.h"
+
+class CSkype : public Skype
+{
+public:
+ typedef void (CSkypeProto::* OnMessaged)(CConversation::Ref conversation, CMessage::Ref message);
+
+ CAccount* newAccount(int oid);
+ CContactGroup* newContactGroup(int oid);
+ CConversation* newConversation(int oid);
+ CContactSearch* newContactSearch(int oid);
+ CParticipant* newParticipant(int oid);
+ CContact* newContact(int oid);
+ CMessage* newMessage(int oid);
+ CTransfer* newTransfer(int oid);
+
+ CSkype(int num_threads = 1);
+
+ void SetOnMessageCallback(OnMessaged callback, CSkypeProto* proto);
+
+private:
+ CSkypeProto* proto;
+ OnMessaged onMessagedCallback;
+
+ void OnMessage(
+ const MessageRef & message,
+ const bool & changesInboxTimestamp,
+ const MessageRef & supersedesHistoryMessage,
+ const ConversationRef & conversation);
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/transfer.cpp b/protocols/Skype/src/skypekit/transfer.cpp new file mode 100644 index 0000000000..986a5bcbab --- /dev/null +++ b/protocols/Skype/src/skypekit/transfer.cpp @@ -0,0 +1,19 @@ +#include "transfer.h"
+
+CTransfer::CTransfer(unsigned int oid, SERootObject* root) : Transfer(oid, root)
+{
+ this->proto = NULL;
+ this->transferCallback = NULL;
+}
+
+void CTransfer::SetOnTransferCallback(OnTransfer callback, CSkypeProto* proto)
+{
+ this->proto = proto;
+ this->transferCallback = callback;
+}
+
+void CTransfer::OnChange(int prop)
+{
+ if (this->proto)
+ (proto->*transferCallback)(this->ref(), prop);
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/transfer.h b/protocols/Skype/src/skypekit/transfer.h new file mode 100644 index 0000000000..d327c496b0 --- /dev/null +++ b/protocols/Skype/src/skypekit/transfer.h @@ -0,0 +1,22 @@ +#pragma once
+
+#include "common.h"
+
+class CTransfer : public Transfer
+{
+public:
+ typedef void (CSkypeProto::* OnTransfer)(CTransfer::Ref transfer, int);
+
+ typedef DRef<CTransfer, Transfer> Ref;
+ typedef DRefs<CTransfer, Transfer> Refs;
+
+ CTransfer(unsigned int oid, SERootObject* p_root);
+
+ void SetOnTransferCallback(OnTransfer callback, CSkypeProto* proto);
+
+private:
+ CSkypeProto* proto;
+ OnTransfer transferCallback;
+
+ void OnChange(int prop);
+};
\ No newline at end of file |