summaryrefslogtreecommitdiff
path: root/protocols/Skype/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-02-23 19:43:21 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-02-23 19:43:21 +0000
commitaa387fa04aa096d163932d3f5f9711a2f146c6f0 (patch)
tree7efe5dabf5bf5b9a78f8f991522487814bfc8cb0 /protocols/Skype/src
parent139c2c1a61d9f765704a2001199c2712d6587fb4 (diff)
- PROTO_INTERFACE::GetIcon removed and replaced with the standard implementation;
- PS_LOADICON also replaced with the standard function; - ProtoConstructor() & ProtoDestructor() macroses are introduced to simplify protocols' code; - GetIcon() method implementation removed from all protocols git-svn-id: http://svn.miranda-ng.org/main/trunk@3739 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype/src')
-rw-r--r--protocols/Skype/src/skype_proto.cpp108
-rw-r--r--protocols/Skype/src/skype_proto.h43
2 files changed, 68 insertions, 83 deletions
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index f9a94fc96a..1650a82c76 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -2,11 +2,8 @@
CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName)
{
- this->m_iVersion = 2;
- this->m_iStatus = ID_STATUS_OFFLINE;
+ ProtoConstructor(this, aProtoName, aUserName);
- this->m_tszUserName = ::mir_tstrdup(userName);
- this->m_szModuleName = ::mir_strdup(protoName);
this->m_szProtoName = ::mir_strdup(protoName);
::strlwr(m_szProtoName);
this->m_szProtoName[0] = ::toupper(this->m_szProtoName[0]);
@@ -37,27 +34,26 @@ CSkypeProto::~CSkypeProto()
::mir_free(this->password);
::mir_free(this->m_szProtoName);
- ::mir_free(this->m_szModuleName);
- ::mir_free(this->m_tszUserName);
+ ProtoDestructor(this);
}
-HANDLE __cdecl CSkypeProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
+HANDLE __cdecl CSkypeProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
{
//todo:ref
return this->AddContactBySid(::mir_u2a(psr->id), ::mir_u2a(psr->nick), 0);
}
-HANDLE __cdecl CSkypeProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEvent)
+HANDLE __cdecl CSkypeProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEvent)
{
DBEVENTINFO dbei = {0};
dbei.cbSize = sizeof(dbei);
- /*if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) != -1)
+ /*if ((dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0)) != -1)
{
dbei.pBlob = (PBYTE)alloca(dbei.cbBlob);
if (CallService(MS_DB_EVENT_GET, (WPARAM)hDbEvent, (LPARAM)&dbei) == 0 &&
!strcmp(dbei.szModule, m_szModuleName) &&
- (dbei.eventType == EVENTTYPE_AUTHREQUEST || dbei.eventType == EVENTTYPE_CONTACTS))
+ (dbei.eventType == EVENTTYPE_AUTHREQUEST || dbei.eventType == EVENTTYPE_CONTACTS))
{
char *nick = (char*)(dbei.pBlob + sizeof(DWORD) * 2);
char *firstName = nick + strlen(nick) + 1;
@@ -69,7 +65,7 @@ HANDLE __cdecl CSkypeProto::AddToListByEvent(int flags, int iContact, HANDLE hDb
return 0;
}
-int __cdecl CSkypeProto::Authorize(HANDLE hDbEvent)
+int __cdecl CSkypeProto::Authorize(HANDLE hDbEvent)
{
if (this->IsOnline() && hDbEvent)
{
@@ -83,7 +79,7 @@ int __cdecl CSkypeProto::Authorize(HANDLE hDbEvent)
return 1;
}
-int __cdecl CSkypeProto::AuthDeny(HANDLE hDbEvent, const TCHAR* szReason)
+int __cdecl CSkypeProto::AuthDeny(HANDLE hDbEvent, const TCHAR* szReason)
{
if (this->IsOnline())
{
@@ -94,42 +90,42 @@ int __cdecl CSkypeProto::AuthDeny(HANDLE hDbEvent, const TCHAR* szReason)
return CSkypeProto::RevokeAuth((WPARAM)hContact, NULL);
}
- return 1;
+ return 1;
}
-int __cdecl CSkypeProto::AuthRecv(HANDLE hContact, PROTORECVEVENT* pre)
+int __cdecl CSkypeProto::AuthRecv(HANDLE hContact, PROTORECVEVENT* pre)
{
DWORD flags = 0;
- if (pre->flags & PREF_CREATEREAD)
+ if (pre->flags & PREF_CREATEREAD)
flags |= DBEF_READ;
- if (pre->flags & PREF_UTF)
+ if (pre->flags & PREF_UTF)
flags |= DBEF_UTF;
this->AddDataBaseEvent(
- hContact,
- EVENTTYPE_AUTHREQUEST,
- pre->timestamp,
- flags,
- pre->lParam,
+ hContact,
+ EVENTTYPE_AUTHREQUEST,
+ pre->timestamp,
+ flags,
+ pre->lParam,
(PBYTE)pre->szMessage);
return 0;
}
-int __cdecl CSkypeProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage)
+int __cdecl CSkypeProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage)
{
if (this->IsOnline() && hContact)
{
CContact::Ref contact;
SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
- if (this->skype->GetContact(sid, contact))
+ if (this->skype->GetContact(sid, contact))
{
contact->SetBuddyStatus(Contact::AUTHORIZED_BY_ME);
contact->SendAuthRequest(::mir_utf8encodeW(szMessage));
}
-
+
return 0;
}
@@ -143,17 +139,17 @@ int __cdecl CSkypeProto::FileCancel( HANDLE hContact, HANDLE hTransfer ) { re
int __cdecl CSkypeProto::FileDeny( HANDLE hContact, HANDLE hTransfer, const TCHAR* szReason ) { return 0; }
int __cdecl CSkypeProto::FileResume( HANDLE hTransfer, int* action, const TCHAR** szFilename ) { return 0; }
-DWORD_PTR __cdecl CSkypeProto:: GetCaps(int type, HANDLE hContact)
-{
+DWORD_PTR __cdecl CSkypeProto:: GetCaps(int type, HANDLE hContact)
+{
switch(type)
- {
+ {
case PFLAGNUM_1:
return PF1_IM | PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_SEARCHBYEMAIL/* | PF1_SEARCHBYNAME*/;
case PFLAGNUM_2:
case PFLAGNUM_3:
return PF2_ONLINE | PF2_SHORTAWAY | PF2_HEAVYDND | PF2_INVISIBLE;
case PFLAGNUM_4:
- return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_AVATARS |
+ return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_AVATARS |
PF4_OFFLINEFILES | PF4_IMSENDUTF | PF4_IMSENDOFFLINE;
case PFLAG_UNIQUEIDTEXT:
return (DWORD_PTR)Translate("Skype Name");
@@ -164,20 +160,10 @@ DWORD_PTR __cdecl CSkypeProto:: GetCaps(int type, HANDLE hContact)
}
}
-HICON __cdecl CSkypeProto::GetIcon( int iconIndex )
-{
- if (LOWORD(iconIndex) == PLI_PROTOCOL)
- {
- HICON ico = Skin_GetIcon("Skype_main");
- return CopyIcon(ico);
- } else
- return 0;
-}
-
int __cdecl CSkypeProto::GetInfo( HANDLE hContact, int infoType ) { return 0; }
-HANDLE __cdecl CSkypeProto::SearchBasic(const TCHAR* id)
-{
+HANDLE __cdecl CSkypeProto::SearchBasic(const TCHAR* id)
+{
if ( !this->IsOnline())
return 0;
@@ -187,8 +173,8 @@ HANDLE __cdecl CSkypeProto::SearchBasic(const TCHAR* id)
return (HANDLE)SKYPE_SEARCH_BYSID;
}
-HANDLE __cdecl CSkypeProto::SearchByEmail(const TCHAR* email)
-{
+HANDLE __cdecl CSkypeProto::SearchByEmail(const TCHAR* email)
+{
if ( !this->IsOnline())
return 0;
@@ -198,8 +184,8 @@ HANDLE __cdecl CSkypeProto::SearchByEmail(const TCHAR* email)
return (HANDLE)SKYPE_SEARCH_BYEMAIL;
}
-HANDLE __cdecl CSkypeProto::SearchByName(const TCHAR* nick, const TCHAR* firstName, const TCHAR* lastName)
-{
+HANDLE __cdecl CSkypeProto::SearchByName(const TCHAR* nick, const TCHAR* firstName, const TCHAR* lastName)
+{
PROTOSEARCHRESULT isr = {0};
isr.cbSize = sizeof(isr);
isr.flags = PSR_TCHAR;
@@ -219,8 +205,8 @@ 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* pre)
-{
+int __cdecl CSkypeProto::RecvMsg( HANDLE hContact, PROTORECVEVENT* pre)
+{
this->UserIsTyping(hContact, PROTOTYPE_SELFTYPING_OFF);
return ::Proto_RecvMessage(hContact, pre);
}
@@ -230,14 +216,14 @@ 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)
-{
+int __cdecl CSkypeProto::SendMsg(HANDLE hContact, int flags, const char* msg)
+{
int result = ::InterlockedIncrement((LONG volatile*)&dwCMDNum);
CConversation::Ref conversation = CConversation::FindBySid(
this->skype,
::DBGetString(hContact, this->m_szModuleName, "sid"));
- if (conversation)
+ if (conversation)
{
Message::Ref message;
conversation->PostText(msg, message);
@@ -248,8 +234,8 @@ int __cdecl CSkypeProto::SendMsg(HANDLE hContact, int flags, const char* msg)
ACKTYPE_MESSAGE,
ACKRESULT_SUCCESS,
(HANDLE)result, 0);
-
- return result;
+
+ return result;
}
int __cdecl CSkypeProto::SendUrl( HANDLE hContact, int flags, const char* url ) { return 0; }
@@ -282,7 +268,7 @@ int CSkypeProto::SetStatus(int new_status)
switch (new_status)
{
case ID_STATUS_OFFLINE:
- if (this->IsOnline() || this->m_iStatus == ID_STATUS_CONNECTING)
+ if (this->IsOnline() || this->m_iStatus == ID_STATUS_CONNECTING)
{
this->account->SetAvailability(CContact::OFFLINE);
this->account->Logout(true);
@@ -311,7 +297,7 @@ int CSkypeProto::SetStatus(int new_status)
}
this->SetSettingWord("Status", this->m_iStatus);
- this->SendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, this->m_iStatus);
+ this->SendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, this->m_iStatus);
return 0;
}
@@ -320,8 +306,8 @@ 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 )
-{
+int __cdecl CSkypeProto::UserIsTyping( HANDLE hContact, int type )
+{
if (hContact && this->IsOnline() && this->m_iStatus != ID_STATUS_INVISIBLE)
{
if (::strcmp(::DBGetString(hContact, this->m_szModuleName, "sid"), this->login) != 0)
@@ -329,9 +315,9 @@ int __cdecl CSkypeProto::UserIsTyping( HANDLE hContact, int type )
CConversation::Ref conversation = CConversation::FindBySid(
this->skype,
::DBGetString(hContact, this->m_szModuleName, "sid"));
- if (conversation)
+ if (conversation)
{
- switch (type)
+ switch (type)
{
case PROTOTYPE_SELFTYPING_ON:
conversation->SetMyTextStatusTo(Participant::WRITING);
@@ -345,17 +331,17 @@ int __cdecl CSkypeProto::UserIsTyping( HANDLE hContact, int type )
}
}
- return 1;
+ return 1;
}
int __cdecl CSkypeProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam)
{
- switch (eventType)
+ switch (eventType)
{
case EV_PROTO_ONLOAD:
return this->OnModulesLoaded(wParam, lParam);
-
- case EV_PROTO_ONEXIT:
+
+ case EV_PROTO_ONEXIT:
return this->OnPreShutdown(wParam, lParam);
case EV_PROTO_ONMENU:
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index e081bf4874..cdf9128912 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -17,7 +17,7 @@ struct StringList : public LIST<char>
{ return _stricmp(p1, p2); }
StringList() : LIST<char>(2, compare) {}
- StringList(const char* string, const char *delimeters) : LIST<char>(2, compare)
+ StringList(const char* string, const char *delimeters) : LIST<char>(2, compare)
{
char *data = ::mir_strdup(string);
if (data)
@@ -155,13 +155,13 @@ struct PasswordRequestBoxParam
PasswordRequestBoxParam(const char *login, bool showRememberPasswordBox = true, bool rememberPassword = false) :
login(::mir_strdup(login)),
password(NULL),
- rememberPassword(rememberPassword),
+ rememberPassword(rememberPassword),
showRememberPasswordBox(showRememberPasswordBox) { }
~PasswordRequestBoxParam()
- {
+ {
if (login) ::mir_free(login);
- if (password) ::mir_free(password);
+ if (password) ::mir_free(password);
}
};
@@ -173,8 +173,8 @@ struct PasswordChangeBoxParam
PasswordChangeBoxParam() { }
~PasswordChangeBoxParam()
- {
- if (password) ::mir_free(password);
+ {
+ if (password) ::mir_free(password);
if (password2) ::mir_free(password2);
}
};
@@ -202,7 +202,6 @@ public:
virtual int __cdecl FileResume( HANDLE hTransfer, int* action, const TCHAR** szFilename );
virtual DWORD_PTR __cdecl GetCaps( int type, HANDLE hContact = NULL );
- virtual HICON __cdecl GetIcon( int iconIndex );
virtual int __cdecl GetInfo( HANDLE hContact, int infoType );
virtual HANDLE __cdecl SearchBasic( const TCHAR* id );
@@ -306,14 +305,14 @@ protected:
bool IsChatRoom(HANDLE hContact);
HANDLE GetChatRoomByID(const char *cid);
HANDLE AddChatRoomByID(const char* cid, const char* name, DWORD flags = 0);
-
+
char *CSkypeProto::GetChatUsers(const char *cid);
void ChatValidateContact(HANDLE hItem, HWND hwndList, const char *contacts);
void ChatPrepare(HANDLE hItem, HWND hwndList, const char *contacts);
void GetInviteContacts(HANDLE hItem, HWND hwndList, SEStringList &invitedContacts);
-
+
void InitChat();
char *StartChat(const char *cid, const SEStringList &invitedContacts);
void JoinToChat(const char *cid, bool showWindow = true);
@@ -343,7 +342,7 @@ protected:
void OnContactChanged(CContact::Ref contact, int prop);
void OnContactListChanged(const ContactRef& contact);
-
+
bool IsProtoContact(HANDLE hContact);
HANDLE GetContactBySid(const char* sid);
HANDLE GetContactFromAuthEvent(HANDLE hEvent);
@@ -374,7 +373,7 @@ protected:
void UpdateProfileStatusMessage(SEObject *obj, HANDLE hContact = NULL);
void UpdateProfileTimezone(SEObject *obj, HANDLE hContact = NULL);
- void UpdateProfile(SEObject *obj, HANDLE hContact = NULL);
+ void UpdateProfile(SEObject *obj, HANDLE hContact = NULL);
void __cdecl LoadOwnInfo(void*);
@@ -408,7 +407,7 @@ protected:
void CreateService(const char* szService, SkypeServiceFunc serviceProc);
void CreateServiceParam(const char* szService, SkypeServiceFunc serviceProc, LPARAM lParam);
-
+
HANDLE CreateEvent(const char* szService);
void HookEvent(const char*, SkypeEventFunc);
@@ -445,24 +444,24 @@ protected:
static HANDLE g_hContactMenuSvc[CMITEMS_COUNT];
static INT_PTR MenuChooseService(WPARAM wParam, LPARAM lParam);
int OnPrebuildContactMenu(WPARAM wParam, LPARAM);
-
+
// 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,
+ DWORD timestamp,
+ const char* sid,
+ const char* nick,
const char* message = "");
void RaiseMessageSendedEvent(
- DWORD timestamp,
- const char* sid,
- const char* nick,
+ DWORD timestamp,
+ const char* sid,
+ const char* nick,
const char* message = "");
void RaiseAuthRequestEvent(
- DWORD timestamp,
- const char* sid,
- const char* nick,
+ DWORD timestamp,
+ const char* sid,
+ const char* nick,
const char* firstName = "",
const char* lastName = "",
const char* reason = "");