Commit 9fb7fef3 authored by dscho's avatar dscho

clean ups and encoding "backchannel"

parent 94570b01
...@@ -98,7 +98,9 @@ int loop_if_server(single_instance_struct* str,event_dispatcher dispatcher) ...@@ -98,7 +98,9 @@ int loop_if_server(single_instance_struct* str,event_dispatcher dispatcher)
void send_message(single_instance_struct* str,char* message) void send_message(single_instance_struct* str,char* message)
{ {
#ifdef DEBUG_1INSTANCE
int i= int i=
#endif
write(str->fd,message,strlen(message)); write(str->fd,message,strlen(message));
#ifdef DEBUG_1INSTANCE #ifdef DEBUG_1INSTANCE
fprintf(stderr,"send: %s => %d(%d)\n",message,i,strlen(message)); fprintf(stderr,"send: %s => %d(%d)\n",message,i,strlen(message));
......
...@@ -11,7 +11,7 @@ FLAG24 = -DALLOW24BPP ...@@ -11,7 +11,7 @@ FLAG24 = -DALLOW24BPP
#OPTFLAGS=-g # -Wall #OPTFLAGS=-g # -Wall
OPTFLAGS=-O2 -Wall OPTFLAGS=-O2 -Wall
CFLAGS=$(OPTFLAGS) $(PTHREADDEF) $(FLAG24) $(INCLUDES) CFLAGS=$(OPTFLAGS) $(PTHREADDEF) $(FLAG24) $(INCLUDES) -DBACKCHANNEL
RANLIB=ranlib RANLIB=ranlib
LIBS=$(LDFLAGS) $(VNCSERVERLIB) $(PTHREADLIB) LIBS=$(LDFLAGS) $(VNCSERVERLIB) $(PTHREADLIB)
......
...@@ -60,7 +60,7 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[]) ...@@ -60,7 +60,7 @@ rfbProcessArguments(rfbScreenInfoPtr rfbScreen,int* argc, char *argv[])
if (i + 1 >= *argc) rfbUsage(); if (i + 1 >= *argc) rfbUsage();
passwds[0] = argv[++i]; passwds[0] = argv[++i];
passwds[1] = 0; passwds[1] = 0;
rfbScreen->rfbAuthPasswdData = passwds; rfbScreen->rfbAuthPasswdData = (void*)passwds;
rfbScreen->passwordCheck = rfbCheckPasswordByList; rfbScreen->passwordCheck = rfbCheckPasswordByList;
} else if (strcmp(argv[i], "-deferupdate") == 0) { /* -desktop desktop-name */ } else if (strcmp(argv[i], "-deferupdate") == 0) { /* -desktop desktop-name */
if (i + 1 >= *argc) rfbUsage(); if (i + 1 >= *argc) rfbUsage();
......
...@@ -327,6 +327,10 @@ refreshCallback(CGRectCount count, const CGRect *rectArray, void *ignore) ...@@ -327,6 +327,10 @@ refreshCallback(CGRectCount count, const CGRect *rectArray, void *ignore)
break; break;
} }
} }
#ifdef BACKCHANNEL
else if(message[0]=='b')
rfbSendBackChannel(screen,message+1,strlen(message+1));
#endif
} }
#endif #endif
...@@ -377,6 +381,13 @@ int main(int argc,char *argv[]) ...@@ -377,6 +381,13 @@ int main(int argc,char *argv[])
send_message(&single_instance,"l"); send_message(&single_instance,"l");
exit(0); exit(0);
} else } else
#ifdef BACKCHANNEL
if(i<argc-1 && !strcmp(argv[i],"-backchannel")) {
sprintf(message,"b%s",argv[i+1]);
send_message(&single_instance,message);
exit(0);
} else
#endif
#endif #endif
if(i<argc-1 && strcmp(argv[i],"-wait4client")==0) { if(i<argc-1 && strcmp(argv[i],"-wait4client")==0) {
maxSecsToConnect = atoi(argv[i+1])/1000; maxSecsToConnect = atoi(argv[i+1])/1000;
......
...@@ -273,7 +273,7 @@ typedef struct ...@@ -273,7 +273,7 @@ typedef struct
FILE* httpFP; FILE* httpFP;
PasswordCheckProcPtr passwordCheck; PasswordCheckProcPtr passwordCheck;
char* rfbAuthPasswdData; void* rfbAuthPasswdData;
/* this is the amount of milliseconds to wait at least before sending /* this is the amount of milliseconds to wait at least before sending
* an update. */ * an update. */
...@@ -574,6 +574,10 @@ extern void rfbSendBell(rfbScreenInfoPtr rfbScreen); ...@@ -574,6 +574,10 @@ extern void rfbSendBell(rfbScreenInfoPtr rfbScreen);
void rfbGotXCutText(rfbScreenInfoPtr rfbScreen, char *str, int len); void rfbGotXCutText(rfbScreenInfoPtr rfbScreen, char *str, int len);
#ifdef BACKCHANNEL
extern void rfbSendBackChannel(rfbScreenInfoPtr s,char* message,int len);
#endif
/* translate.c */ /* translate.c */
extern Bool rfbEconomicTranslate; extern Bool rfbEconomicTranslate;
...@@ -599,7 +603,6 @@ extern void httpCheckFds(); ...@@ -599,7 +603,6 @@ extern void httpCheckFds();
/* auth.c */ /* auth.c */
extern char *rfbAuthPasswdFile;
extern void rfbAuthNewClient(rfbClientPtr cl); extern void rfbAuthNewClient(rfbClientPtr cl);
extern void rfbAuthProcessClientMessage(rfbClientPtr cl); extern void rfbAuthProcessClientMessage(rfbClientPtr cl);
......
...@@ -268,7 +268,9 @@ typedef struct { ...@@ -268,7 +268,9 @@ typedef struct {
#define rfbSetColourMapEntries 1 #define rfbSetColourMapEntries 1
#define rfbBell 2 #define rfbBell 2
#define rfbServerCutText 3 #define rfbServerCutText 3
#ifdef BACKCHANNEL
#define rfbBackChannel 15
#endif
/* client -> server */ /* client -> server */
...@@ -297,6 +299,9 @@ typedef struct { ...@@ -297,6 +299,9 @@ typedef struct {
#define rfbEncodingZlib 6 #define rfbEncodingZlib 6
#define rfbEncodingTight 7 #define rfbEncodingTight 7
#define rfbEncodingZlibHex 8 #define rfbEncodingZlibHex 8
#ifdef BACKCHANNEL
#define rfbEncodingBackChannel 15
#endif
/* /*
* Special encoding numbers: * Special encoding numbers:
...@@ -508,7 +513,6 @@ typedef struct { ...@@ -508,7 +513,6 @@ typedef struct {
#define rfbTightFilterPalette 0x01 #define rfbTightFilterPalette 0x01
#define rfbTightFilterGradient 0x02 #define rfbTightFilterGradient 0x02
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* XCursor encoding. This is a special encoding used to transmit X-style * XCursor encoding. This is a special encoding used to transmit X-style
* cursor shapes from server to clients. Note that for this encoding, * cursor shapes from server to clients. Note that for this encoding,
...@@ -604,6 +608,10 @@ typedef struct { ...@@ -604,6 +608,10 @@ typedef struct {
#define sz_rfbServerCutTextMsg 8 #define sz_rfbServerCutTextMsg 8
#ifdef BACKCHANNEL
typedef rfbServerCutTextMsg rfbBackChannelMsg;
#endif
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
* Union of all server->client messages. * Union of all server->client messages.
......
...@@ -1460,3 +1460,29 @@ rfbProcessUDPInput(rfbScreenInfoPtr rfbScreen) ...@@ -1460,3 +1460,29 @@ rfbProcessUDPInput(rfbScreenInfoPtr rfbScreen)
rfbDisconnectUDPSock(rfbScreen); rfbDisconnectUDPSock(rfbScreen);
} }
} }
#ifdef BACKCHANNEL
void rfbSendBackChannel(rfbScreenInfoPtr rfbScreen,char* str,int len)
{
rfbClientPtr cl;
rfbBackChannelMsg sct;
rfbClientIteratorPtr iterator;
iterator = rfbGetClientIterator(rfbScreen);
while ((cl = rfbClientIteratorNext(iterator)) != NULL) {
sct.type = rfbBackChannel;
sct.length = Swap32IfLE(len);
if (WriteExact(cl, (char *)&sct,
sz_rfbServerCutTextMsg) < 0) {
rfbLogPerror("rfbSendServerCutText: write");
rfbCloseClient(cl);
continue;
}
if (WriteExact(cl, str, len) < 0) {
rfbLogPerror("rfbSendServerCutText: write");
rfbCloseClient(cl);
}
}
rfbReleaseClientIterator(iterator);
}
#endif
...@@ -232,8 +232,8 @@ int probeX=0,probeY=0; ...@@ -232,8 +232,8 @@ int probeX=0,probeY=0;
void probeScreen(rfbScreenInfoPtr s,int xscreen) void probeScreen(rfbScreenInfoPtr s,int xscreen)
{ {
int i,j,pixel,i1,j1, int i,j,/*pixel,i1,*/j1,
bpp=s->rfbServerFormat.bitsPerPixel/8,mask=(1<<bpp)-1, bpp=s->rfbServerFormat.bitsPerPixel/8,/*mask=(1<<bpp)-1,*/
rstride=s->paddedWidthInBytes; rstride=s->paddedWidthInBytes;
XImage* im; XImage* im;
//fprintf(stderr,"/%d,%d",probeX,probeY); //fprintf(stderr,"/%d,%d",probeX,probeY);
...@@ -316,6 +316,13 @@ int main(int argc,char** argv) ...@@ -316,6 +316,13 @@ int main(int argc,char** argv)
send_message(&single_instance,"l"); send_message(&single_instance,"l");
exit(0); exit(0);
} else } else
#ifdef BACKCHANNEL
if(i<argc-1 && !strcmp(argv[i],"-backchannel")) {
sprintf(message,"b%s",argv[i+1]);
send_message(&single_instance,message);
exit(0);
} else
#endif
#endif #endif
if(i<argc-1 && strcmp(argv[i],"-display")==0) { if(i<argc-1 && strcmp(argv[i],"-display")==0) {
fprintf(stderr,"Using display %s\n",argv[i+1]); fprintf(stderr,"Using display %s\n",argv[i+1]);
...@@ -459,6 +466,10 @@ int main(int argc,char** argv) ...@@ -459,6 +466,10 @@ int main(int argc,char** argv)
break; break;
} }
} }
#ifdef BACKCHANNEL
else if(message[0]=='b')
rfbSendBackChannel(screen,message+1,strlen(message+1));
#endif
} }
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment