diff options
-rw-r--r-- | protocols/SkypeWeb/src/requests/contacts.h | 34 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_contacts.cpp | 13 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_menus.cpp | 17 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_menus.h | 2 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_proto.h | 2 |
5 files changed, 68 insertions, 0 deletions
diff --git a/protocols/SkypeWeb/src/requests/contacts.h b/protocols/SkypeWeb/src/requests/contacts.h index 751bf79a6c..796df60308 100644 --- a/protocols/SkypeWeb/src/requests/contacts.h +++ b/protocols/SkypeWeb/src/requests/contacts.h @@ -124,4 +124,38 @@ public: }
};
+class BlockContactRequest : public HttpRequest
+{
+public:
+ BlockContactRequest(const char *token, const char *who, const char *skypename = "self") :
+ HttpRequest(REQUEST_PUT, FORMAT, "api.skype.com/users/%s/contacts/%s/block", skypename, who)
+ {
+ Headers
+ << CHAR_VALUE("X-Skypetoken", token)
+ << CHAR_VALUE("Accept", "application/json")
+ << CHAR_VALUE("Content-type", "application/x-www-form-urlencoded");
+
+ Body
+ << CHAR_VALUE("reporterIp", "123.123.123.123") //TODO: user ip address
+ << CHAR_VALUE("uiVersion", MIRANDA_VERSION_STRING);
+ }
+};
+
+class UnblockContactRequest : public HttpRequest
+{
+public:
+ UnblockContactRequest(const char *token, const char *who, const char *skypename = "self") :
+ HttpRequest(REQUEST_PUT, FORMAT, "api.skype.com/users/%s/contacts/%s/unblock", skypename, who)
+ {
+ Headers
+ << CHAR_VALUE("X-Skypetoken", token)
+ << CHAR_VALUE("Accept", "application/json")
+ << CHAR_VALUE("Content-type", "application/x-www-form-urlencoded");
+
+ Body
+ << CHAR_VALUE("reporterIp", "123.123.123.123") //TODO: user ip address
+ << CHAR_VALUE("uiVersion", MIRANDA_VERSION_STRING);
+ }
+};
+
#endif //_SKYPE_REQUEST_CONTACTS_H_
\ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp index effe3aa395..d1486c09ce 100644 --- a/protocols/SkypeWeb/src/skype_contacts.cpp +++ b/protocols/SkypeWeb/src/skype_contacts.cpp @@ -273,4 +273,17 @@ int CSkypeProto::OnContactDeleted(MCONTACT hContact, LPARAM) if (hContact && !isChatRoom(hContact))
PushRequest(new DeleteContactRequest(TokenSecret, db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID)));
return 0;
+}
+
+INT_PTR CSkypeProto::BlockContact(WPARAM hContact, LPARAM)
+{
+ if (IDYES == MessageBox(NULL, TranslateT(" Are you sure?"), TranslateT("Warning"), MB_YESNOCANCEL | MB_ICONQUESTION))
+ SendRequest(new BlockContactRequest(TokenSecret, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID))));
+ return 0;
+}
+
+INT_PTR CSkypeProto::UnblockContact(WPARAM hContact, LPARAM)
+{
+ SendRequest(new UnblockContactRequest(TokenSecret, ptrA(db_get_sa(hContact, m_szModuleName, SKYPE_SETTINGS_ID))));
+ return 0;
}
\ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_menus.cpp b/protocols/SkypeWeb/src/skype_menus.cpp index 0d530c703c..e0adcf681c 100644 --- a/protocols/SkypeWeb/src/skype_menus.cpp +++ b/protocols/SkypeWeb/src/skype_menus.cpp @@ -35,9 +35,12 @@ int CSkypeProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) bool isCtrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
bool isAuthNeed = getByte(hContact, "Auth", 0) > 0;
bool isGrantNeed = getByte(hContact, "Grant", 0) > 0;
+ bool isBlocked = getByte(hContact, "IsBlocked", 0);
Menu_ShowItem(ContactMenuItems[CMI_AUTH_REQUEST], isCtrlPressed || isAuthNeed);
Menu_ShowItem(ContactMenuItems[CMI_AUTH_GRANT], isCtrlPressed || isGrantNeed);
+ Menu_ShowItem(ContactMenuItems[CMI_BLOCK], true);
+ Menu_ShowItem(ContactMenuItems[CMI_UNBLOCK], isCtrlPressed || isBlocked);
Menu_ShowItem(ContactMenuItems[CMI_GETSERVERHISTORY], true);
return 0;
@@ -82,6 +85,20 @@ void CSkypeProto::InitMenus() mi.icolibItem = GetIconHandle("synchistory");
ContactMenuItems[CMI_GETSERVERHISTORY] = Menu_AddContactMenuItem(&mi);
CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::GetContactHistory>);
+
+ mi.pszService = MODULE"/BlockContact";
+ mi.ptszName = LPGENT("Block contact");
+ mi.position = CMI_POSITION + CMI_GETSERVERHISTORY;
+ mi.icolibItem = LoadSkinnedIcon(SKINICON_OTHER_DELETE);
+ ContactMenuItems[CMI_BLOCK] = Menu_AddContactMenuItem(&mi);
+ CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::BlockContact>);
+
+ mi.pszService = MODULE"/UnblockContact";
+ mi.ptszName = LPGENT("Unblock contact");
+ mi.position = CMI_POSITION + CMI_GETSERVERHISTORY;
+ mi.icolibItem = LoadSkinnedIcon(SKINICON_OTHER_DELETE);
+ ContactMenuItems[CMI_UNBLOCK] = Menu_AddContactMenuItem(&mi);
+ CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::UnblockContact>);
}
void CSkypeProto::UninitMenus()
diff --git a/protocols/SkypeWeb/src/skype_menus.h b/protocols/SkypeWeb/src/skype_menus.h index e04add88d3..a8cc308df5 100644 --- a/protocols/SkypeWeb/src/skype_menus.h +++ b/protocols/SkypeWeb/src/skype_menus.h @@ -25,6 +25,8 @@ enum CMI_AUTH_REQUEST,
CMI_AUTH_GRANT,
CMI_GETSERVERHISTORY,
+ CMI_BLOCK,
+ CMI_UNBLOCK,
CMI_MAX // this item shall be the last one
};
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 3401d6c348..63c2bf592b 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -278,6 +278,8 @@ private: char *GetServerFromUrl (const char *url);
//services
+ INT_PTR __cdecl BlockContact (WPARAM hContact, LPARAM);
+ INT_PTR __cdecl UnblockContact (WPARAM hContact, LPARAM);
INT_PTR __cdecl OnRequestAuth (WPARAM hContact, LPARAM lParam);
INT_PTR __cdecl OnGrantAuth (WPARAM hContact, LPARAM);
INT_PTR __cdecl GetContactHistory (WPARAM hContact, LPARAM lParam);
|