BOOL wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) { int i; int peerId; if (!wfi || !context) return FALSE; if (!wf_info_lock(wfi)) return FALSE; if (wfi->peerCount == WF_INFO_MAXPEERS) goto fail_peer_count; context->info = wfi; if (!(context->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) goto fail_update_event; //get the offset of the top left corner of selected screen EnumDisplayMonitors(NULL, NULL, wf_info_monEnumCB, 0); _IDcount = 0; #ifdef WITH_DXGI_1_2 if (wfi->peerCount == 0) if (wf_dxgi_init(wfi) != 0) goto fail_driver_init; #else if (!wf_mirror_driver_activate(wfi)) goto fail_driver_init; #endif //look through the array of peers until an empty slot for (i = 0; i < WF_INFO_MAXPEERS; ++i) { //empty index will be our peer id if (wfi->peers[i] == NULL) { peerId = i; break; } } wfi->peers[peerId] = ((rdpContext*) context)->peer; wfi->peers[peerId]->pId = peerId; wfi->peerCount++; WLog_INFO(TAG, "Registering Peer: id=%d #=%d", peerId, wfi->peerCount); wf_info_unlock(wfi); wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_CONNECT); return TRUE; fail_driver_init: CloseHandle(context->updateEvent); context->updateEvent = NULL; fail_update_event: fail_peer_count: context->socketClose = TRUE; wf_info_unlock(wfi); return FALSE; }
void wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) { if (wf_info_lock(wfi) > 0) { int i; int peerId; if (wfi->peerCount == WF_INFO_MAXPEERS) { context->socketClose = TRUE; wf_info_unlock(wfi); return; } context->info = wfi; context->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL); //get the offset of the top left corner of selected screen EnumDisplayMonitors(NULL, NULL, wf_info_monEnumCB, 0); _IDcount = 0; #ifdef WITH_WIN8 if (wfi->peerCount == 0) wf_dxgi_init(wfi); #else if (wf_mirror_driver_activate(wfi) == FALSE) { context->socketClose = TRUE; wf_info_unlock(wfi); return; } #endif //look trhough the array of peers until an empty slot for(i=0; i<WF_INFO_MAXPEERS; ++i) { //empty index will be our peer id if (wfi->peers[i] == NULL) { peerId = i; break; } } wfi->peers[peerId] = ((rdpContext*) context)->peer; wfi->peers[peerId]->pId = peerId; wfi->peerCount++; printf("Registering Peer: id=%d #=%d\n", peerId, wfi->peerCount); wf_info_unlock(wfi); wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_CONNECT); } }
BOOL wf_peer_logon(freerdp_peer* client, SEC_WINNT_AUTH_IDENTITY* identity, BOOL automatic) { /* if (automatic) { _tprintf(_T("Logon: User:%s Domain:%s Password:%s\n"), identity->User, identity->Domain, identity->Password); } */ wfreerdp_server_peer_callback_event(((rdpContext*) client->context)->peer->pId, WF_SRV_CALLBACK_EVENT_AUTH); return TRUE; }
BOOL wf_peer_activate(freerdp_peer* client) { wfInfo* wfi; wfPeerContext* context = (wfPeerContext*) client->context; wfi = context->info; client->activated = TRUE; wf_update_peer_activate(wfi, context); wfreerdp_server_peer_callback_event(((rdpContext*) context)->peer->pId, WF_SRV_CALLBACK_EVENT_ACTIVATE); return TRUE; }
void wf_info_peer_unregister(wfInfo* wfi, wfPeerContext* context) { if (wf_info_lock(wfi) > 0) { int peerId; peerId = ((rdpContext*) context)->peer->pId; wfi->peers[peerId] = NULL; wfi->peerCount--; CloseHandle(context->updateEvent); WLog_INFO(TAG, "Unregistering Peer: id=%d, #=%d", peerId, wfi->peerCount); #ifdef WITH_DXGI_1_2 if (wfi->peerCount == 0) wf_dxgi_cleanup(wfi); #endif wf_info_unlock(wfi); wfreerdp_server_peer_callback_event(peerId, WF_SRV_CALLBACK_EVENT_DISCONNECT); } }
BOOL wf_peer_logon(freerdp_peer* client, SEC_WINNT_AUTH_IDENTITY* identity, BOOL automatic) { wfreerdp_server_peer_callback_event(((rdpContext*) client->context)->peer->pId, WF_SRV_CALLBACK_EVENT_AUTH); return TRUE; }