summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-04-26 12:51:25 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-04-26 12:51:25 +0000
commitaed7583d1b058a421d95d34719ec398bd40bd760 (patch)
tree3f99cc9cb915283febcf772e0b73b5967e3a4e57 /protocols/SkypeWeb
parent8ff5ba190f6d71a4ecabbdd953dbaec8631649ea (diff)
SkypeWeb:
Contacts removing. git-svn-id: http://svn.miranda-ng.org/main/trunk@13167 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb')
-rw-r--r--protocols/SkypeWeb/src/requests/contacts.h34
-rw-r--r--protocols/SkypeWeb/src/requests/subscriptions.h21
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp155
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp1
-rw-r--r--protocols/SkypeWeb/src/skype_login.cpp2
6 files changed, 114 insertions, 101 deletions
diff --git a/protocols/SkypeWeb/src/requests/contacts.h b/protocols/SkypeWeb/src/requests/contacts.h
index af39438ffd..751bf79a6c 100644
--- a/protocols/SkypeWeb/src/requests/contacts.h
+++ b/protocols/SkypeWeb/src/requests/contacts.h
@@ -59,27 +59,6 @@ public:
}
};
-class CreateContactsRequest : public HttpRequest
-{
-public:
- CreateContactsRequest(const char *regToken, const LIST<char> &skypenames, const char *server = SKYPE_ENDPOINTS_HOST) :
- HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/contacts", server)
- {
- Headers
- << CHAR_VALUE("Accept", "application/json, text/javascript")
- << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8")
- << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken);
-
- CMStringA data = "{\"contacts\":[";
- for (int i = 0; i < skypenames.getCount(); i++)
- data.AppendFormat("{\"id\":\"8:%s\"},", skypenames[i]);
- data.Truncate(data.GetLength() - 1);
- data.Append("]}");
-
- Body << VALUE(data);
- }
-};
-
class GetContactsAuthRequest : public HttpRequest
{
public:
@@ -108,6 +87,19 @@ public:
}
};
+class DeleteContactRequest : public HttpRequest
+{
+public:
+ DeleteContactRequest(const char *token, const char *who, const char *skypename = "self") :
+ HttpRequest(REQUEST_DELETE, FORMAT, "api.skype.com/users/%s/contacts/%s", skypename, who)
+ {
+ Headers
+ << CHAR_VALUE("X-Skypetoken", token)
+ << CHAR_VALUE("Accept", "application/json")
+ << CHAR_VALUE("Content-type", "application/x-www-form-urlencoded");
+ }
+};
+
class AuthAcceptRequest : public HttpRequest
{
public:
diff --git a/protocols/SkypeWeb/src/requests/subscriptions.h b/protocols/SkypeWeb/src/requests/subscriptions.h
index d0d896b7c1..2490329140 100644
--- a/protocols/SkypeWeb/src/requests/subscriptions.h
+++ b/protocols/SkypeWeb/src/requests/subscriptions.h
@@ -34,4 +34,25 @@ public:
}
};
+class CreateContactsSubscriptionRequest : public HttpRequest
+{
+public:
+ CreateContactsSubscriptionRequest(const char *regToken, const LIST<char> &skypenames, const char *server = SKYPE_ENDPOINTS_HOST) :
+ HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/contacts", server)
+ {
+ Headers
+ << CHAR_VALUE("Accept", "application/json, text/javascript")
+ << CHAR_VALUE("Content-Type", "application/json; charset=UTF-8")
+ << FORMAT_VALUE("RegistrationToken", "registrationToken=%s", regToken);
+
+ CMStringA data = "{\"contacts\":[";
+ for (int i = 0; i < skypenames.getCount(); i++)
+ data.AppendFormat("{\"id\":\"8:%s\"},", skypenames[i]);
+ data.Truncate(data.GetLength() - 1);
+ data.Append("]}");
+
+ Body << VALUE(data);
+ }
+};
+
#endif //_SKYPE_REQUEST_SUBSCIPTIONS_H_
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index 4d7981eed5..40b706f070 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -67,6 +67,39 @@ MCONTACT CSkypeProto::FindChatRoom(const char *chatname)
return hContact;
}
+void CSkypeProto::StartChatRoom(const TCHAR *tid, const TCHAR *tname)
+{
+ // Create the group chat session
+ GCSESSION gcw = { sizeof(gcw) };
+ gcw.iType = GCW_PRIVMESS;
+ gcw.ptszID = tid;
+ gcw.pszModule = m_szModuleName;
+ gcw.ptszName = tname;
+ CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
+
+ // Send setting events
+ GCDEST gcd = { m_szModuleName, tid, GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
+
+ // Create a user statuses
+ gce.ptszStatus = TranslateT("Admin");
+ CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
+ gce.ptszStatus = TranslateT("User");
+ CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
+
+ // Finish initialization
+ gcd.iType = GC_EVENT_CONTROL;
+ gce.time = time(NULL);
+ gce.pDest = &gcd;
+
+ bool hideChats = getBool("HideChats", 1);
+
+ CallServiceSync(MS_GC_EVENT, (hideChats ? WINDOW_HIDDEN : SESSION_INITDONE), reinterpret_cast<LPARAM>(&gce));
+ CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, reinterpret_cast<LPARAM>(&gce));
+}
+
+/* Hooks */
+
int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
{
GCHOOK *gch = (GCHOOK*)lParam;
@@ -153,82 +186,6 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
}
return 0;
}
-void CSkypeProto::StartChatRoom(const TCHAR *tid, const TCHAR *tname)
-{
- // Create the group chat session
- GCSESSION gcw = { sizeof(gcw) };
- gcw.iType = GCW_PRIVMESS;
- gcw.ptszID = tid;
- gcw.pszModule = m_szModuleName;
- gcw.ptszName = tname;
- CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
-
- // Send setting events
- GCDEST gcd = { m_szModuleName, tid, GC_EVENT_ADDGROUP };
- GCEVENT gce = { sizeof(gce), &gcd };
-
- // Create a user statuses
- gce.ptszStatus = TranslateT("Admin");
- CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
- gce.ptszStatus = TranslateT("User");
- CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
-
- // Finish initialization
- gcd.iType = GC_EVENT_CONTROL;
- gce.time = time(NULL);
- gce.pDest = &gcd;
-
- bool hideChats = getBool("HideChats", 1);
-
- // Add self contact
- //AddChatContact(tid, facy.self_.user_id.c_str(), facy.self_.real_name.c_str());
- CallServiceSync(MS_GC_EVENT, (hideChats ? WINDOW_HIDDEN : SESSION_INITDONE), reinterpret_cast<LPARAM>(&gce));
- CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, reinterpret_cast<LPARAM>(&gce));
-
- //SendRequest(new GetChatInfoRequest(RegToken, ptrA(mir_t2a(tid)), Server), &CSkypeProto::OnGetChatInfo);
-}
-
-int CSkypeProto::OnGroupChatMenuHook(WPARAM, LPARAM lParam)
-{
- GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam;
- if (stricmp(gcmi->pszModule, m_szModuleName)) return 0;
-
- if (gcmi->Type == MENU_ON_LOG)
- {
- static const struct gc_item Items[] =
- {
- { LPGENT("&Invite user..."), 10, MENU_ITEM, FALSE },
- { LPGENT("&Leave chat session"), 20, MENU_ITEM, FALSE },
- { LPGENT("&Change topic"), 30, MENU_ITEM, FALSE }
- };
- gcmi->nItems = SIZEOF(Items);
- gcmi->Item = (gc_item*)Items;
- }
- else if (gcmi->Type == MENU_ON_NICKLIST)
- {
- if (IsMe(_T2A(gcmi->pszUID)))
- {
- gcmi->nItems = 0;
- gcmi->Item = NULL;
- }
- else
- {
- static const struct gc_item Items[] =
- {
- { LPGENT("Kick &user"), 10, MENU_ITEM },
- { NULL, 0, MENU_SEPARATOR },
- { LPGENT("Set &role"), 20, MENU_NEWPOPUP },
- { LPGENT("&Admin"), 30, MENU_POPUPITEM },
- { LPGENT("&User"), 40, MENU_POPUPITEM }
- };
- gcmi->nItems = SIZEOF(Items);
- gcmi->Item = (gc_item*)Items;
- }
- }
-
-
- return 0;
-}
INT_PTR CSkypeProto::OnJoinChatRoom(WPARAM hContact, LPARAM)
{
@@ -500,8 +457,6 @@ char *CSkypeProto::GetChatUsers(const TCHAR *chat_id)
gci.pszModule = m_szModuleName;
gci.pszID = chat_id;
CallService(MS_GC_GETINFO, 0, (LPARAM)&gci);
-
- // mir_free(gci.pszUsers);
return gci.pszUsers;
}
@@ -564,8 +519,52 @@ INT_PTR CSkypeProto::SvcCreateChat(WPARAM, LPARAM)
return 0;
}
+/* Menus */
+
+int CSkypeProto::OnGroupChatMenuHook(WPARAM, LPARAM lParam)
+{
+ GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam;
+ if (stricmp(gcmi->pszModule, m_szModuleName)) return 0;
+
+ if (gcmi->Type == MENU_ON_LOG)
+ {
+ static const struct gc_item Items[] =
+ {
+ { LPGENT("&Invite user..."), 10, MENU_ITEM, FALSE },
+ { LPGENT("&Leave chat session"), 20, MENU_ITEM, FALSE },
+ { LPGENT("&Change topic"), 30, MENU_ITEM, FALSE }
+ };
+ gcmi->nItems = SIZEOF(Items);
+ gcmi->Item = (gc_item*)Items;
+ }
+ else if (gcmi->Type == MENU_ON_NICKLIST)
+ {
+ if (IsMe(_T2A(gcmi->pszUID)))
+ {
+ gcmi->nItems = 0;
+ gcmi->Item = NULL;
+ }
+ else
+ {
+ static const struct gc_item Items[] =
+ {
+ { LPGENT("Kick &user"), 10, MENU_ITEM },
+ { NULL, 0, MENU_SEPARATOR },
+ { LPGENT("Set &role"), 20, MENU_NEWPOPUP },
+ { LPGENT("&Admin"), 30, MENU_POPUPITEM },
+ { LPGENT("&User"), 40, MENU_POPUPITEM }
+ };
+ gcmi->nItems = SIZEOF(Items);
+ gcmi->Item = (gc_item*)Items;
+ }
+ }
+
+
+ return 0;
+}
/* Dialogs */
+
INT_PTR CSkypeProto::GcCreateDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
CSkypeProto *ppro = (CSkypeProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index d94fab1e1c..84a46cf912 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -267,5 +267,7 @@ INT_PTR CSkypeProto::OnGrantAuth(WPARAM hContact, LPARAM)
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;
} \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp
index 8621cce056..7b1607a834 100644
--- a/protocols/SkypeWeb/src/skype_history_sync.cpp
+++ b/protocols/SkypeWeb/src/skype_history_sync.cpp
@@ -196,7 +196,6 @@ void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response)
char *conversationLink = mir_t2a(json_as_string(json_get(lastMessage, "conversationLink")));
time_t composeTime(IsoToUnixTime(ptrT(json_as_string(json_get(lastMessage, "conversationLink")))));
- bool isChat = false;
ptrA skypename;
TCHAR *topic;
diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp
index 3016cae380..c93c850d76 100644
--- a/protocols/SkypeWeb/src/skype_login.cpp
+++ b/protocols/SkypeWeb/src/skype_login.cpp
@@ -196,7 +196,7 @@ void CSkypeProto::OnCapabilitiesSended(const NETLIBHTTPREQUEST *response)
if(!isChatRoom(hContact))
skypenames.insert(getStringA(hContact, SKYPE_SETTINGS_ID));
}
- SendRequest(new CreateContactsRequest(RegToken, skypenames, Server));
+ SendRequest(new CreateContactsSubscriptionRequest(RegToken, skypenames, Server));
for (int i = 0; i < skypenames.getCount(); i++)
mir_free(skypenames[i]);
skypenames.destroy();