Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative extension system #584

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/rfb/rfb.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ enum rfbProtocolExtensionHookType {
RFB_PROTOCOL_EXTENSION_HOOK_CLOSE,
RFB_PROTOCOL_EXTENSION_HOOK_USAGE,
RFB_PROTOCOL_EXTENSION_HOOK_PROCESS_ARGUMENT,
RFB_PROTOCOL_EXTENSION_HOOK_POST_SET_ENCODINGS,
RFB_PROTOCOL_EXTENSION_HOOK_PRE_FBU,
RFB_PROTOCOL_EXTENSION_HOOK_POST_FBU,
};
Expand Down Expand Up @@ -250,6 +251,9 @@ _Static_assert(sizeof(rfbProtocolExtensionHookGeneric) == sizeof(rfbProtocolExte
typedef int (*rfbProtocolExtensionHookProcessArgument)(int argc, char *argv[]);
_Static_assert(sizeof(rfbProtocolExtensionHookGeneric) == sizeof(rfbProtocolExtensionHookProcessArgument), "extension hook size doesn't match");

typedef void (*rfbProtocolExtensionHookPostSetEncodings)(struct _rfbClientRec* client);
_Static_assert(sizeof(rfbProtocolExtensionHookGeneric) == sizeof(rfbProtocolExtensionHookPostSetEncodings), "extension hook size doesn't match");

/** returns TRUE if proceed with the framebuffer update (PostFbu is called in any case). */
typedef rfbBool (*rfbProtocolExtensionHookPreFbu)(struct _rfbClientRec* client, void* data);
_Static_assert(sizeof(rfbProtocolExtensionHookGeneric) == sizeof(rfbProtocolExtensionHookPreFbu), "extension hook size doesn't match");
Expand All @@ -271,6 +275,7 @@ typedef struct _rfbProtocolExtensionElement {
rfbProtocolExtensionHookUsage usage;
rfbProtocolExtensionHookProcessArgument processArgument;

rfbProtocolExtensionHookPostSetEncodings postSetEncodings;
rfbProtocolExtensionHookPreFbu preFbu;
rfbProtocolExtensionHookPostFbu postFbu;
} hook;
Expand Down
12 changes: 12 additions & 0 deletions src/libvncserver/rfbserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2647,6 +2647,18 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
cl->enableCursorPosUpdates = FALSE;
}

rfbProtocolExtension2 *extension2 = rfbGetExtension2Iterator();
for (; extension2; extension2 = extension2->next) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not put the declaration of extensions2 into the head of the for() loop?

rfbProtocolExtensionElement* el = extension2->elements;
for (; el && el < extension2->elements + extension2->elementsCount; ++el) {
if (el->type == RFB_PROTOCOL_EXTENSION_HOOK_POST_SET_ENCODINGS) {
el->hook.postSetEncodings(cl);
break;
}
}
}
rfbReleaseExtension2Iterator();

return;
}

Expand Down