diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-09-17 06:40:18 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-09-17 06:40:18 +0000 |
commit | 78390ccc676294d0fddce0dc9bb843b3d9fea8f5 (patch) | |
tree | 3ea68f9183f46c3b3ef253c27a03409c84f002fa /protocols | |
parent | 482d8abc53f4dd89898eaf31e26e3ffc8e77b5e4 (diff) |
VKontakte:
add basic search and adding in clist support
version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@10487 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 12 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_search.cpp | 65 | ||||
-rw-r--r-- | protocols/VKontakte/vk_10.vcxproj | 1 | ||||
-rw-r--r-- | protocols/VKontakte/vk_10.vcxproj.filters | 3 | ||||
-rw-r--r-- | protocols/VKontakte/vk_12.vcxproj | 1 | ||||
-rw-r--r-- | protocols/VKontakte/vk_12.vcxproj.filters | 3 |
8 files changed, 88 insertions, 4 deletions
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 391e2c1638..07eecbd9c4 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 0
-#define __BUILD_NUM 14
+#define __BUILD_NUM 15
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 249f1da6fb..1e0a96bc65 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -331,10 +331,10 @@ int CVkProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam) }
//////////////////////////////////////////////////////////////////////////////
-
HANDLE CVkProto::SearchBasic(const PROTOCHAR* id)
{
- return 0;
+ ForkThread(&CVkProto::SearchBasicThread, (void *) id);
+ return (HANDLE)1;
}
HANDLE CVkProto::SearchByEmail(const PROTOCHAR* email)
@@ -349,7 +349,13 @@ HANDLE CVkProto::SearchByName(const PROTOCHAR* nick, const PROTOCHAR* firstName, MCONTACT CVkProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
{
- return NULL;
+ int uid = _ttoi(psr->id);
+ if (!uid)
+ return NULL;
+
+ MCONTACT hConnact = FindUser(uid, true);
+ RetrieveUserInfo(uid);
+ return hConnact;
}
int CVkProto::AuthRequest(MCONTACT hContact,const PROTOCHAR *message)
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 466ac13fdb..df8d7a2072 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -202,6 +202,11 @@ struct CVkProto : public PROTO<CVkProto> void UnInitMenus();
int __cdecl OnPreBuildContactMenu(WPARAM hContact, LPARAM);
+ //==== Search ========================================================================
+
+ void __cdecl SearchBasicThread(void* id);
+ void OnSearchBasic(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
+
//==== Misc ==========================================================================
TCHAR* GetUserStoredPassword(void);
diff --git a/protocols/VKontakte/src/vk_search.cpp b/protocols/VKontakte/src/vk_search.cpp new file mode 100644 index 0000000000..158d949d8b --- /dev/null +++ b/protocols/VKontakte/src/vk_search.cpp @@ -0,0 +1,65 @@ +/*
+Copyright (c) 2013-14 Miranda NG project (http://miranda-ng.org)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation version 2
+of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
+
+void CVkProto::SearchBasicThread(void* id)
+{
+ debugLogA("CVkProto::OnSearchBasicThread");
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/users.get.json", true, &CVkProto::OnSearchBasic)
+ << TCHAR_PARAM("user_ids", (TCHAR *) id)
+ << VER_API);
+
+}
+
+void CVkProto::OnSearchBasic(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
+{
+ debugLogA("CVkProto::OnSearchBasic %d", reply->resultCode);
+ if (reply->resultCode != 200){
+ ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
+ return;
+ }
+
+ JSONROOT pRoot;
+ JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot);
+ if (pResponse == NULL){
+ ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
+ return;
+ }
+
+ for (size_t i = 0;; i++) {
+ PROTOSEARCHRESULT psr = { sizeof(psr) };
+ psr.flags = PSR_TCHAR;
+
+ JSONNODE *pRecord = json_at(pResponse, i);
+ if (pRecord == NULL)
+ break;
+
+ CMString tszNick;
+ psr.id = mir_wstrdup(json_as_string(json_get(pRecord, "id")));
+ psr.firstName = mir_wstrdup(json_as_string(json_get(pRecord, "first_name")));
+ psr.lastName = mir_wstrdup(json_as_string(json_get(pRecord, "last_name")));
+ tszNick.Append(psr.firstName);
+ tszNick.AppendChar(' ');
+ tszNick.Append(psr.lastName);
+ psr.nick = mir_wstrdup(tszNick.GetBuffer());
+
+ ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr);
+ }
+
+ ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
+}
\ No newline at end of file diff --git a/protocols/VKontakte/vk_10.vcxproj b/protocols/VKontakte/vk_10.vcxproj index 82eb170a3b..8d249f393f 100644 --- a/protocols/VKontakte/vk_10.vcxproj +++ b/protocols/VKontakte/vk_10.vcxproj @@ -186,6 +186,7 @@ <ClCompile Include="src\vk_options.cpp" />
<ClCompile Include="src\vk_proto.cpp" />
<ClCompile Include="src\vk_queue.cpp" />
+ <ClCompile Include="src\vk_search.cpp" />
<ClCompile Include="src\vk_thread.cpp" />
</ItemGroup>
<ItemGroup>
diff --git a/protocols/VKontakte/vk_10.vcxproj.filters b/protocols/VKontakte/vk_10.vcxproj.filters index 5e6610c062..633997a52d 100644 --- a/protocols/VKontakte/vk_10.vcxproj.filters +++ b/protocols/VKontakte/vk_10.vcxproj.filters @@ -45,6 +45,9 @@ <ClCompile Include="src\vk_chats.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\vk_search.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\version.h">
diff --git a/protocols/VKontakte/vk_12.vcxproj b/protocols/VKontakte/vk_12.vcxproj index bd0d3344da..460d21b6db 100644 --- a/protocols/VKontakte/vk_12.vcxproj +++ b/protocols/VKontakte/vk_12.vcxproj @@ -189,6 +189,7 @@ <ClCompile Include="src\vk_options.cpp" />
<ClCompile Include="src\vk_proto.cpp" />
<ClCompile Include="src\vk_queue.cpp" />
+ <ClCompile Include="src\vk_search.cpp" />
<ClCompile Include="src\vk_thread.cpp" />
</ItemGroup>
<ItemGroup>
diff --git a/protocols/VKontakte/vk_12.vcxproj.filters b/protocols/VKontakte/vk_12.vcxproj.filters index f52152d3af..450e52b623 100644 --- a/protocols/VKontakte/vk_12.vcxproj.filters +++ b/protocols/VKontakte/vk_12.vcxproj.filters @@ -45,6 +45,9 @@ <ClCompile Include="src\vk_chats.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\vk_search.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\version.h">
|