diff options
author | George Hazan <george.hazan@gmail.com> | 2013-10-05 21:46:05 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-10-05 21:46:05 +0000 |
commit | b8283f989e1d0a5d623f7f57c89c1499618158c4 (patch) | |
tree | f096e09089027b5e1f85669359c8117865f3a570 /protocols/VKontakte/src/vk_proto.cpp | |
parent | 3a686f86c91cb428e6c8f4534f7d2b72054ecf38 (diff) |
VK:
- SetStatus implementation;
- worker thread
git-svn-id: http://svn.miranda-ng.org/main/trunk@6360 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_proto.cpp')
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 60 |
1 files changed, 41 insertions, 19 deletions
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index ebc47f8516..fe308aff71 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -71,11 +71,51 @@ DWORD_PTR CVkProto::GetCaps(int type, HANDLE hContact) //////////////////////////////////////////////////////////////////////////////
-int CVkProto::SetStatus(int new_status)
+int CVkProto::SetStatus(int iNewStatus)
{
+ if (m_iDesiredStatus == iNewStatus)
+ return 0;
+
+ int oldStatus = m_iStatus;
+ if (iNewStatus == ID_STATUS_OFFLINE) {
+ if ( IsOnline())
+ ShutdownSession();
+
+ m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
+ }
+ else if (!m_hWorkerThread && !(m_iStatus >= ID_STATUS_CONNECTING && m_iStatus < ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)) {
+ m_iStatus = ID_STATUS_CONNECTING;
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
+ ForkThread(&CVkProto::WorkerThread, 0);
+ }
+ else if ( IsOnline())
+ SetServerStatus(iNewStatus);
+ else
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
return 0;
}
+//////////////////////////////////////////////////////////////////////////////
+
+int CVkProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam)
+{
+ switch(event) {
+ case EV_PROTO_ONLOAD:
+ return OnModulesLoaded(wParam,lParam);
+
+ case EV_PROTO_ONEXIT:
+ return OnPreShutdown(wParam,lParam);
+
+ case EV_PROTO_ONOPTIONS:
+ return OnOptionsInit(wParam,lParam);
+ }
+
+ return 1;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
HANDLE CVkProto::SearchBasic(const PROTOCHAR* id)
{
return 0;
@@ -229,21 +269,3 @@ int CVkProto::SetAwayMsg(int status, const PROTOCHAR *msg) {
return 0; // Status messages are disabled
}
-
-//////////////////////////////////////////////////////////////////////////////
-
-int CVkProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam)
-{
- switch(event) {
- case EV_PROTO_ONLOAD:
- return OnModulesLoaded(wParam,lParam);
-
- case EV_PROTO_ONEXIT:
- return OnPreShutdown(wParam,lParam);
-
- case EV_PROTO_ONOPTIONS:
- return OnOptionsInit(wParam,lParam);
- }
-
- return 1;
-}
|