mirror of
https://gitlab.com/virt-viewer/virt-viewer.git
synced 2024-12-22 13:33:58 +03:00
Convert TABS to spaces & reindent everywhere
This commit is contained in:
parent
c67a8cfdbe
commit
e1283a9a60
28
autogen.sh
28
autogen.sh
@ -3,7 +3,7 @@
|
||||
|
||||
set -e
|
||||
srcdir=`dirname $0`
|
||||
test -z "$srcdir" && srcdir=.
|
||||
test -z "$srcdir" && srcdir=.
|
||||
|
||||
THEDIR=`pwd`
|
||||
cd $srcdir
|
||||
@ -11,23 +11,23 @@ cd $srcdir
|
||||
DIE=0
|
||||
|
||||
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have autoconf installed to compile virt-viewer."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or see http://www.gnu.org/software/autoconf"
|
||||
DIE=1
|
||||
echo
|
||||
echo "You must have autoconf installed to compile virt-viewer."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or see http://www.gnu.org/software/autoconf"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
(automake --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
DIE=1
|
||||
echo "You must have automake installed to compile virt-viewer."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or see http://www.gnu.org/software/automake"
|
||||
echo
|
||||
DIE=1
|
||||
echo "You must have automake installed to compile virt-viewer."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or see http://www.gnu.org/software/automake"
|
||||
}
|
||||
|
||||
if test "$DIE" -eq 1; then
|
||||
exit 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
EXTRA_ARGS=""
|
||||
@ -38,7 +38,7 @@ if test "x$1" = "x--system"; then
|
||||
sysconfdir=/etc
|
||||
localstatedir=/var
|
||||
if [ -d /usr/lib64 ]; then
|
||||
libdir=$prefix/lib64
|
||||
libdir=$prefix/lib64
|
||||
fi
|
||||
EXTRA_ARGS="--prefix=$prefix --sysconfdir=$sysconfdir --localstatedir=$localstatedir --libdir=$libdir"
|
||||
echo "Running ./configure with $EXTRA_ARGS $@"
|
||||
@ -59,6 +59,6 @@ autoconf
|
||||
cd $THEDIR
|
||||
|
||||
$srcdir/configure $EXTRA_ARGS "$@" && {
|
||||
echo
|
||||
echo
|
||||
echo "Now type 'make' to compile virt-viewer."
|
||||
}
|
||||
|
@ -46,8 +46,8 @@
|
||||
* This file defines a "shell" plugin that plugin developers can use
|
||||
* as the basis for a real plugin. This shell just provides empty
|
||||
* implementations of all functions that the plugin can implement
|
||||
* that will be called by Netscape (the NPP_xxx methods defined in
|
||||
* npapi.h).
|
||||
* that will be called by Netscape (the NPP_xxx methods defined in
|
||||
* npapi.h).
|
||||
*
|
||||
* dp Suresh <dp@netscape.com>
|
||||
* updated 5/1998 <pollmann@netscape.com>
|
||||
@ -59,11 +59,11 @@
|
||||
/*
|
||||
The contents of this file are subject to the Mozilla Public License
|
||||
|
||||
Version 1.1 (the "License"); you may not use this file except in compliance
|
||||
Version 1.1 (the "License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
the specific language governing rights and limitations under the License.
|
||||
|
||||
The Original Code is stub code that defines the binary interface to a Mozilla
|
||||
@ -147,7 +147,7 @@ NPP_Shutdown(void)
|
||||
debug ("NPP_Shutdown");
|
||||
}
|
||||
|
||||
NPError
|
||||
NPError
|
||||
NPP_New(NPMIMEType pluginType G_GNUC_UNUSED,
|
||||
NPP instance,
|
||||
uint16 mode,
|
||||
@ -220,7 +220,7 @@ NPP_New(NPMIMEType pluginType G_GNUC_UNUSED,
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
NPError
|
||||
NPError
|
||||
NPP_Destroy(NPP instance, NPSavedData** save G_GNUC_UNUSED)
|
||||
{
|
||||
PluginInstance* This;
|
||||
@ -245,7 +245,7 @@ NPP_Destroy(NPP instance, NPSavedData** save G_GNUC_UNUSED)
|
||||
}
|
||||
|
||||
|
||||
NPError
|
||||
NPError
|
||||
NPP_SetWindow(NPP instance, NPWindow* window)
|
||||
{
|
||||
debug ("NPP_SetWindow");
|
||||
@ -253,7 +253,7 @@ NPP_SetWindow(NPP instance, NPWindow* window)
|
||||
return VirtViewerXSetWindow(instance, window);
|
||||
}
|
||||
|
||||
int32
|
||||
int32
|
||||
NPP_WriteReady(NPP instance, NPStream *stream)
|
||||
{
|
||||
/*printf("NPP_WriteReady()\n");*/
|
||||
@ -267,7 +267,7 @@ NPP_WriteReady(NPP instance, NPStream *stream)
|
||||
return -1L; /* don't accept any bytes in NPP_Write() */
|
||||
}
|
||||
|
||||
int32
|
||||
int32
|
||||
NPP_Write(NPP instance, NPStream *stream,
|
||||
int32 offset G_GNUC_UNUSED, int32 len G_GNUC_UNUSED,
|
||||
void *buffer G_GNUC_UNUSED)
|
||||
@ -282,7 +282,7 @@ NPP_Write(NPP instance, NPStream *stream,
|
||||
return -1L; /* don't accept any bytes in NPP_Write() */
|
||||
}
|
||||
|
||||
NPError
|
||||
NPError
|
||||
NPP_DestroyStream(NPP instance, NPStream *stream G_GNUC_UNUSED,
|
||||
NPError reason G_GNUC_UNUSED)
|
||||
{
|
||||
@ -298,7 +298,7 @@ NPP_DestroyStream(NPP instance, NPStream *stream G_GNUC_UNUSED,
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
NPP_StreamAsFile(NPP instance G_GNUC_UNUSED, NPStream *stream G_GNUC_UNUSED,
|
||||
const char* fname G_GNUC_UNUSED)
|
||||
{
|
||||
@ -323,7 +323,7 @@ NPP_URLNotify(NPP instance G_GNUC_UNUSED, const char* url G_GNUC_UNUSED,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
NPP_Print(NPP instance, NPPrint* printInfo)
|
||||
{
|
||||
/*printf("NPP_Print()\n");*/
|
||||
@ -334,7 +334,7 @@ NPP_Print(NPP instance, NPPrint* printInfo)
|
||||
/***** Insert NPP_Print code here *****\
|
||||
PluginInstance* This = (PluginInstance*) instance->pdata;
|
||||
\**************************************/
|
||||
|
||||
|
||||
if (printInfo->mode == NP_FULL) {
|
||||
/*
|
||||
* PLUGIN DEVELOPERS:
|
||||
@ -359,7 +359,7 @@ NPP_Print(NPP instance, NPPrint* printInfo)
|
||||
NPBool printOne =
|
||||
printInfo->print.fullPrint.printOne;
|
||||
\**************************************/
|
||||
|
||||
|
||||
/* Do the default*/
|
||||
printInfo->print.fullPrint.pluginPrinted = FALSE;
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ void NPN_PopPopupsEnabledState(NPP instance)
|
||||
* Wrapper functions : Netscape Navigator -> plugin
|
||||
*
|
||||
* These functions let the plugin developer just create the APIs
|
||||
* as documented and defined in npapi.h, without needing to
|
||||
* as documented and defined in npapi.h, without needing to
|
||||
* install those functions in the function table or worry about
|
||||
* setting up globals for 68K plugins.
|
||||
*
|
||||
@ -275,7 +275,7 @@ Private_New(NPMIMEType pluginType, NPP instance, uint16 mode,
|
||||
NPError ret;
|
||||
PLUGINDEBUGSTR("New");
|
||||
ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static NPError
|
||||
@ -344,7 +344,6 @@ Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
|
||||
static void
|
||||
Private_URLNotify(NPP instance, const char* url,
|
||||
NPReason reason, void* notifyData)
|
||||
|
||||
{
|
||||
PLUGINDEBUGSTR("URLNotify");
|
||||
NPP_URLNotify(instance, url, reason, notifyData);
|
||||
@ -353,8 +352,8 @@ Private_URLNotify(NPP instance, const char* url,
|
||||
static NPError
|
||||
Private_GetValue(void *instance, NPPVariable variable, void *result)
|
||||
{
|
||||
NPError rv = NPP_GetValue(instance, variable, result);
|
||||
return rv;
|
||||
NPError rv = NPP_GetValue(instance, variable, result);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -377,13 +376,13 @@ Private_GetJavaClass(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
static int16
|
||||
static int16
|
||||
Private_HandleEvent(NPP instance, void* event)
|
||||
{
|
||||
return NPP_HandleEvent(instance, event);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
/***********************************************************************
|
||||
*
|
||||
* These functions are located automagically by netscape.
|
||||
*
|
||||
@ -436,12 +435,12 @@ NP_Initialize(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs)
|
||||
NPError err = NPERR_NO_ERROR;
|
||||
|
||||
PLUGINDEBUGSTR("NP_Initialize");
|
||||
|
||||
|
||||
/* validate input parameters */
|
||||
|
||||
if ((nsTable == NULL) || (pluginFuncs == NULL))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
|
||||
|
||||
/*
|
||||
* Check the major version passed in Netscape's function table.
|
||||
* We won't load if the major version is newer than what we expect.
|
||||
@ -456,11 +455,10 @@ NP_Initialize(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs)
|
||||
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
|
||||
if (nsTable->size < sizeof(NPNetscapeFuncs))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
if (pluginFuncs->size < sizeof(NPPluginFuncs))
|
||||
if (pluginFuncs->size < sizeof(NPPluginFuncs))
|
||||
err = NPERR_INVALID_FUNCTABLE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (err == NPERR_NO_ERROR) {
|
||||
/*
|
||||
* Copy all the fields of Netscape function table into our
|
||||
@ -519,7 +517,7 @@ NP_Initialize(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs)
|
||||
|
||||
err = NPP_Initialize();
|
||||
}
|
||||
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
522
plugin/npupp.h
522
plugin/npupp.h
@ -68,117 +68,117 @@ typedef void* JRIGlobalRef;
|
||||
|
||||
/******************************************************************************************
|
||||
plug-in function table macros
|
||||
for each function in and out of the plugin API we define
|
||||
for each function in and out of the plugin API we define
|
||||
typedef NPP_FooUPP
|
||||
#define NewNPP_FooProc
|
||||
#define CallNPP_FooProc
|
||||
#define NewNPP_FooProc
|
||||
#define CallNPP_FooProc
|
||||
*******************************************************************************************/
|
||||
|
||||
|
||||
/* NPP_Initialize */
|
||||
typedef void (* NP_LOADDS NPP_InitializeUPP)(void);
|
||||
#define NewNPP_InitializeProc(FUNC) \
|
||||
((NPP_InitializeUPP) (FUNC))
|
||||
#define CallNPP_InitializeProc(FUNC) \
|
||||
(*(FUNC))()
|
||||
#define NewNPP_InitializeProc(FUNC) \
|
||||
((NPP_InitializeUPP) (FUNC))
|
||||
#define CallNPP_InitializeProc(FUNC) \
|
||||
(*(FUNC))()
|
||||
|
||||
/* NPP_Shutdown */
|
||||
typedef void (* NP_LOADDS NPP_ShutdownUPP)(void);
|
||||
#define NewNPP_ShutdownProc(FUNC) \
|
||||
((NPP_ShutdownUPP) (FUNC))
|
||||
#define CallNPP_ShutdownProc(FUNC) \
|
||||
(*(FUNC))()
|
||||
#define NewNPP_ShutdownProc(FUNC) \
|
||||
((NPP_ShutdownUPP) (FUNC))
|
||||
#define CallNPP_ShutdownProc(FUNC) \
|
||||
(*(FUNC))()
|
||||
|
||||
/* NPP_New */
|
||||
typedef NPError (* NP_LOADDS NPP_NewUPP)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
|
||||
#define NewNPP_NewProc(FUNC) \
|
||||
((NPP_NewUPP) (FUNC))
|
||||
#define CallNPP_NewProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
|
||||
typedef NPError (* NP_LOADDS NPP_NewUPP)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
|
||||
#define NewNPP_NewProc(FUNC) \
|
||||
((NPP_NewUPP) (FUNC))
|
||||
#define CallNPP_NewProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
|
||||
|
||||
/* NPP_Destroy */
|
||||
typedef NPError (* NP_LOADDS NPP_DestroyUPP)(NPP instance, NPSavedData** save);
|
||||
#define NewNPP_DestroyProc(FUNC) \
|
||||
((NPP_DestroyUPP) (FUNC))
|
||||
#define CallNPP_DestroyProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
typedef NPError (* NP_LOADDS NPP_DestroyUPP)(NPP instance, NPSavedData** save);
|
||||
#define NewNPP_DestroyProc(FUNC) \
|
||||
((NPP_DestroyUPP) (FUNC))
|
||||
#define CallNPP_DestroyProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
|
||||
/* NPP_SetWindow */
|
||||
typedef NPError (* NP_LOADDS NPP_SetWindowUPP)(NPP instance, NPWindow* window);
|
||||
#define NewNPP_SetWindowProc(FUNC) \
|
||||
((NPP_SetWindowUPP) (FUNC))
|
||||
#define CallNPP_SetWindowProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
typedef NPError (* NP_LOADDS NPP_SetWindowUPP)(NPP instance, NPWindow* window);
|
||||
#define NewNPP_SetWindowProc(FUNC) \
|
||||
((NPP_SetWindowUPP) (FUNC))
|
||||
#define CallNPP_SetWindowProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
|
||||
/* NPP_NewStream */
|
||||
typedef NPError (* NP_LOADDS NPP_NewStreamUPP)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
|
||||
#define NewNPP_NewStreamProc(FUNC) \
|
||||
((NPP_NewStreamUPP) (FUNC))
|
||||
typedef NPError (* NP_LOADDS NPP_NewStreamUPP)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
|
||||
#define NewNPP_NewStreamProc(FUNC) \
|
||||
((NPP_NewStreamUPP) (FUNC))
|
||||
#define CallNPP_NewStreamProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
|
||||
|
||||
/* NPP_DestroyStream */
|
||||
typedef NPError (* NP_LOADDS NPP_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason);
|
||||
#define NewNPP_DestroyStreamProc(FUNC) \
|
||||
((NPP_DestroyStreamUPP) (FUNC))
|
||||
#define CallNPP_DestroyStreamProc(FUNC, NPParg, NPStreamPtr, NPReasonArg) \
|
||||
(*(FUNC))((NPParg), (NPStreamPtr), (NPReasonArg))
|
||||
typedef NPError (* NP_LOADDS NPP_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason);
|
||||
#define NewNPP_DestroyStreamProc(FUNC) \
|
||||
((NPP_DestroyStreamUPP) (FUNC))
|
||||
#define CallNPP_DestroyStreamProc(FUNC, NPParg, NPStreamPtr, NPReasonArg) \
|
||||
(*(FUNC))((NPParg), (NPStreamPtr), (NPReasonArg))
|
||||
|
||||
/* NPP_WriteReady */
|
||||
typedef int32 (* NP_LOADDS NPP_WriteReadyUPP)(NPP instance, NPStream* stream);
|
||||
#define NewNPP_WriteReadyProc(FUNC) \
|
||||
((NPP_WriteReadyUPP) (FUNC))
|
||||
#define CallNPP_WriteReadyProc(FUNC, NPParg, NPStreamPtr) \
|
||||
(*(FUNC))((NPParg), (NPStreamPtr))
|
||||
#define NewNPP_WriteReadyProc(FUNC) \
|
||||
((NPP_WriteReadyUPP) (FUNC))
|
||||
#define CallNPP_WriteReadyProc(FUNC, NPParg, NPStreamPtr) \
|
||||
(*(FUNC))((NPParg), (NPStreamPtr))
|
||||
|
||||
/* NPP_Write */
|
||||
typedef int32 (* NP_LOADDS NPP_WriteUPP)(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
|
||||
#define NewNPP_WriteProc(FUNC) \
|
||||
((NPP_WriteUPP) (FUNC))
|
||||
#define CallNPP_WriteProc(FUNC, NPParg, NPStreamPtr, offsetArg, lenArg, bufferPtr) \
|
||||
(*(FUNC))((NPParg), (NPStreamPtr), (offsetArg), (lenArg), (bufferPtr))
|
||||
#define NewNPP_WriteProc(FUNC) \
|
||||
((NPP_WriteUPP) (FUNC))
|
||||
#define CallNPP_WriteProc(FUNC, NPParg, NPStreamPtr, offsetArg, lenArg, bufferPtr) \
|
||||
(*(FUNC))((NPParg), (NPStreamPtr), (offsetArg), (lenArg), (bufferPtr))
|
||||
|
||||
/* NPP_StreamAsFile */
|
||||
typedef void (* NP_LOADDS NPP_StreamAsFileUPP)(NPP instance, NPStream* stream, const char* fname);
|
||||
#define NewNPP_StreamAsFileProc(FUNC) \
|
||||
((NPP_StreamAsFileUPP) (FUNC))
|
||||
#define CallNPP_StreamAsFileProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
#define NewNPP_StreamAsFileProc(FUNC) \
|
||||
((NPP_StreamAsFileUPP) (FUNC))
|
||||
#define CallNPP_StreamAsFileProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
|
||||
/* NPP_Print */
|
||||
typedef void (* NP_LOADDS NPP_PrintUPP)(NPP instance, NPPrint* platformPrint);
|
||||
#define NewNPP_PrintProc(FUNC) \
|
||||
((NPP_PrintUPP) (FUNC))
|
||||
#define CallNPP_PrintProc(FUNC, NPParg, NPPrintArg) \
|
||||
(*(FUNC))((NPParg), (NPPrintArg))
|
||||
#define NewNPP_PrintProc(FUNC) \
|
||||
((NPP_PrintUPP) (FUNC))
|
||||
#define CallNPP_PrintProc(FUNC, NPParg, NPPrintArg) \
|
||||
(*(FUNC))((NPParg), (NPPrintArg))
|
||||
|
||||
/* NPP_HandleEvent */
|
||||
typedef int16 (* NP_LOADDS NPP_HandleEventUPP)(NPP instance, void* event);
|
||||
#define NewNPP_HandleEventProc(FUNC) \
|
||||
((NPP_HandleEventUPP) (FUNC))
|
||||
#define CallNPP_HandleEventProc(FUNC, NPParg, voidPtr) \
|
||||
(*(FUNC))((NPParg), (voidPtr))
|
||||
#define NewNPP_HandleEventProc(FUNC) \
|
||||
((NPP_HandleEventUPP) (FUNC))
|
||||
#define CallNPP_HandleEventProc(FUNC, NPParg, voidPtr) \
|
||||
(*(FUNC))((NPParg), (voidPtr))
|
||||
|
||||
/* NPP_URLNotify */
|
||||
typedef void (* NP_LOADDS NPP_URLNotifyUPP)(NPP instance, const char* url, NPReason reason, void* notifyData);
|
||||
#define NewNPP_URLNotifyProc(FUNC) \
|
||||
((NPP_URLNotifyUPP) (FUNC))
|
||||
#define CallNPP_URLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
|
||||
#define NewNPP_URLNotifyProc(FUNC) \
|
||||
((NPP_URLNotifyUPP) (FUNC))
|
||||
#define CallNPP_URLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
|
||||
|
||||
/* NPP_GetValue */
|
||||
typedef NPError (* NP_LOADDS NPP_GetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue);
|
||||
#define NewNPP_GetValueProc(FUNC) \
|
||||
((NPP_GetValueUPP) (FUNC))
|
||||
#define CallNPP_GetValueProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
typedef NPError (* NP_LOADDS NPP_GetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue);
|
||||
#define NewNPP_GetValueProc(FUNC) \
|
||||
((NPP_GetValueUPP) (FUNC))
|
||||
#define CallNPP_GetValueProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
|
||||
/* NPP_SetValue */
|
||||
typedef NPError (* NP_LOADDS NPP_SetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue);
|
||||
#define NewNPP_SetValueProc(FUNC) \
|
||||
((NPP_SetValueUPP) (FUNC))
|
||||
#define CallNPP_SetValueProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
typedef NPError (* NP_LOADDS NPP_SetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue);
|
||||
#define NewNPP_SetValueProc(FUNC) \
|
||||
((NPP_SetValueUPP) (FUNC))
|
||||
#define CallNPP_SetValueProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
|
||||
/*
|
||||
* Netscape entry points
|
||||
@ -186,84 +186,84 @@ typedef NPError (* NP_LOADDS NPP_SetValueUPP)(NPP instance, NPNVariable variable
|
||||
|
||||
|
||||
/* NPN_GetValue */
|
||||
typedef NPError (* NP_LOADDS NPN_GetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue);
|
||||
#define NewNPN_GetValueProc(FUNC) \
|
||||
((NPN_GetValueUPP) (FUNC))
|
||||
#define CallNPN_GetValueProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
typedef NPError (* NP_LOADDS NPN_GetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue);
|
||||
#define NewNPN_GetValueProc(FUNC) \
|
||||
((NPN_GetValueUPP) (FUNC))
|
||||
#define CallNPN_GetValueProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
|
||||
/* NPN_SetValue */
|
||||
typedef NPError (* NP_LOADDS NPN_SetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue);
|
||||
#define NewNPN_SetValueProc(FUNC) \
|
||||
((NPN_SetValueUPP) (FUNC))
|
||||
#define CallNPN_SetValueProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
typedef NPError (* NP_LOADDS NPN_SetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue);
|
||||
#define NewNPN_SetValueProc(FUNC) \
|
||||
((NPN_SetValueUPP) (FUNC))
|
||||
#define CallNPN_SetValueProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
|
||||
/* NPN_GetUrlNotify */
|
||||
typedef NPError (* NP_LOADDS NPN_GetURLNotifyUPP)(NPP instance, const char* url, const char* window, void* notifyData);
|
||||
#define NewNPN_GetURLNotifyProc(FUNC) \
|
||||
((NPN_GetURLNotifyUPP) (FUNC))
|
||||
#define CallNPN_GetURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
|
||||
typedef NPError (* NP_LOADDS NPN_GetURLNotifyUPP)(NPP instance, const char* url, const char* window, void* notifyData);
|
||||
#define NewNPN_GetURLNotifyProc(FUNC) \
|
||||
((NPN_GetURLNotifyUPP) (FUNC))
|
||||
#define CallNPN_GetURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
|
||||
|
||||
/* NPN_PostUrlNotify */
|
||||
typedef NPError (* NP_LOADDS NPN_PostURLNotifyUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData);
|
||||
#define NewNPN_PostURLNotifyProc(FUNC) \
|
||||
((NPN_PostURLNotifyUPP) (FUNC))
|
||||
#define NewNPN_PostURLNotifyProc(FUNC) \
|
||||
((NPN_PostURLNotifyUPP) (FUNC))
|
||||
#define CallNPN_PostURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
|
||||
|
||||
/* NPN_GetUrl */
|
||||
typedef NPError (* NP_LOADDS NPN_GetURLUPP)(NPP instance, const char* url, const char* window);
|
||||
#define NewNPN_GetURLProc(FUNC) \
|
||||
((NPN_GetURLUPP) (FUNC))
|
||||
#define CallNPN_GetURLProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
typedef NPError (* NP_LOADDS NPN_GetURLUPP)(NPP instance, const char* url, const char* window);
|
||||
#define NewNPN_GetURLProc(FUNC) \
|
||||
((NPN_GetURLUPP) (FUNC))
|
||||
#define CallNPN_GetURLProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
|
||||
/* NPN_PostUrl */
|
||||
typedef NPError (* NP_LOADDS NPN_PostURLUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file);
|
||||
#define NewNPN_PostURLProc(FUNC) \
|
||||
((NPN_PostURLUPP) (FUNC))
|
||||
#define NewNPN_PostURLProc(FUNC) \
|
||||
((NPN_PostURLUPP) (FUNC))
|
||||
#define CallNPN_PostURLProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
|
||||
|
||||
/* NPN_RequestRead */
|
||||
typedef NPError (* NP_LOADDS NPN_RequestReadUPP)(NPStream* stream, NPByteRange* rangeList);
|
||||
#define NewNPN_RequestReadProc(FUNC) \
|
||||
((NPN_RequestReadUPP) (FUNC))
|
||||
#define CallNPN_RequestReadProc(FUNC, stream, range) \
|
||||
(*(FUNC))((stream), (range))
|
||||
typedef NPError (* NP_LOADDS NPN_RequestReadUPP)(NPStream* stream, NPByteRange* rangeList);
|
||||
#define NewNPN_RequestReadProc(FUNC) \
|
||||
((NPN_RequestReadUPP) (FUNC))
|
||||
#define CallNPN_RequestReadProc(FUNC, stream, range) \
|
||||
(*(FUNC))((stream), (range))
|
||||
|
||||
/* NPN_NewStream */
|
||||
typedef NPError (* NP_LOADDS NPN_NewStreamUPP)(NPP instance, NPMIMEType type, const char* window, NPStream** stream);
|
||||
#define NewNPN_NewStreamProc(FUNC) \
|
||||
((NPN_NewStreamUPP) (FUNC))
|
||||
#define CallNPN_NewStreamProc(FUNC, npp, type, window, stream) \
|
||||
(*(FUNC))((npp), (type), (window), (stream))
|
||||
typedef NPError (* NP_LOADDS NPN_NewStreamUPP)(NPP instance, NPMIMEType type, const char* window, NPStream** stream);
|
||||
#define NewNPN_NewStreamProc(FUNC) \
|
||||
((NPN_NewStreamUPP) (FUNC))
|
||||
#define CallNPN_NewStreamProc(FUNC, npp, type, window, stream) \
|
||||
(*(FUNC))((npp), (type), (window), (stream))
|
||||
|
||||
/* NPN_Write */
|
||||
typedef int32 (* NP_LOADDS NPN_WriteUPP)(NPP instance, NPStream* stream, int32 len, void* buffer);
|
||||
#define NewNPN_WriteProc(FUNC) \
|
||||
((NPN_WriteUPP) (FUNC))
|
||||
#define CallNPN_WriteProc(FUNC, npp, stream, len, buffer) \
|
||||
(*(FUNC))((npp), (stream), (len), (buffer))
|
||||
#define NewNPN_WriteProc(FUNC) \
|
||||
((NPN_WriteUPP) (FUNC))
|
||||
#define CallNPN_WriteProc(FUNC, npp, stream, len, buffer) \
|
||||
(*(FUNC))((npp), (stream), (len), (buffer))
|
||||
|
||||
/* NPN_DestroyStream */
|
||||
typedef NPError (* NP_LOADDS NPN_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason);
|
||||
#define NewNPN_DestroyStreamProc(FUNC) \
|
||||
((NPN_DestroyStreamUPP) (FUNC))
|
||||
#define CallNPN_DestroyStreamProc(FUNC, npp, stream, reason) \
|
||||
(*(FUNC))((npp), (stream), (reason))
|
||||
#define NewNPN_DestroyStreamProc(FUNC) \
|
||||
((NPN_DestroyStreamUPP) (FUNC))
|
||||
#define CallNPN_DestroyStreamProc(FUNC, npp, stream, reason) \
|
||||
(*(FUNC))((npp), (stream), (reason))
|
||||
|
||||
/* NPN_Status */
|
||||
typedef void (* NP_LOADDS NPN_StatusUPP)(NPP instance, const char* message);
|
||||
#define NewNPN_StatusProc(FUNC) \
|
||||
((NPN_StatusUPP) (FUNC))
|
||||
#define CallNPN_StatusProc(FUNC, npp, msg) \
|
||||
(*(FUNC))((npp), (msg))
|
||||
#define NewNPN_StatusProc(FUNC) \
|
||||
((NPN_StatusUPP) (FUNC))
|
||||
#define CallNPN_StatusProc(FUNC, npp, msg) \
|
||||
(*(FUNC))((npp), (msg))
|
||||
|
||||
/* NPN_UserAgent */
|
||||
typedef const char* (* NP_LOADDS NPN_UserAgentUPP)(NPP instance);
|
||||
typedef const char* (* NP_LOADDS NPN_UserAgentUPP)(NPP instance);
|
||||
#define NewNPN_UserAgentProc(FUNC) \
|
||||
((NPN_UserAgentUPP) (FUNC))
|
||||
#define CallNPN_UserAgentProc(FUNC, ARG1) \
|
||||
@ -271,236 +271,236 @@ typedef const char* (* NP_LOADDS NPN_UserAgentUPP)(NPP instance);
|
||||
|
||||
/* NPN_MemAlloc */
|
||||
typedef void* (* NP_LOADDS NPN_MemAllocUPP)(uint32 size);
|
||||
#define NewNPN_MemAllocProc(FUNC) \
|
||||
((NPN_MemAllocUPP) (FUNC))
|
||||
#define CallNPN_MemAllocProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_MemAllocProc(FUNC) \
|
||||
((NPN_MemAllocUPP) (FUNC))
|
||||
#define CallNPN_MemAllocProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN__MemFree */
|
||||
typedef void (* NP_LOADDS NPN_MemFreeUPP)(void* ptr);
|
||||
#define NewNPN_MemFreeProc(FUNC) \
|
||||
((NPN_MemFreeUPP) (FUNC))
|
||||
#define CallNPN_MemFreeProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_MemFreeProc(FUNC) \
|
||||
((NPN_MemFreeUPP) (FUNC))
|
||||
#define CallNPN_MemFreeProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_MemFlush */
|
||||
typedef uint32 (* NP_LOADDS NPN_MemFlushUPP)(uint32 size);
|
||||
#define NewNPN_MemFlushProc(FUNC) \
|
||||
((NPN_MemFlushUPP) (FUNC))
|
||||
#define CallNPN_MemFlushProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_MemFlushProc(FUNC) \
|
||||
((NPN_MemFlushUPP) (FUNC))
|
||||
#define CallNPN_MemFlushProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_ReloadPlugins */
|
||||
typedef void (* NP_LOADDS NPN_ReloadPluginsUPP)(NPBool reloadPages);
|
||||
#define NewNPN_ReloadPluginsProc(FUNC) \
|
||||
((NPN_ReloadPluginsUPP) (FUNC))
|
||||
#define CallNPN_ReloadPluginsProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_ReloadPluginsProc(FUNC) \
|
||||
((NPN_ReloadPluginsUPP) (FUNC))
|
||||
#define CallNPN_ReloadPluginsProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_GetJavaEnv */
|
||||
typedef JRIEnv* (* NP_LOADDS NPN_GetJavaEnvUPP)(void);
|
||||
#define NewNPN_GetJavaEnvProc(FUNC) \
|
||||
((NPN_GetJavaEnvUPP) (FUNC))
|
||||
#define CallNPN_GetJavaEnvProc(FUNC) \
|
||||
(*(FUNC))()
|
||||
#define NewNPN_GetJavaEnvProc(FUNC) \
|
||||
((NPN_GetJavaEnvUPP) (FUNC))
|
||||
#define CallNPN_GetJavaEnvProc(FUNC) \
|
||||
(*(FUNC))()
|
||||
|
||||
/* NPN_GetJavaPeer */
|
||||
typedef jref (* NP_LOADDS NPN_GetJavaPeerUPP)(NPP instance);
|
||||
#define NewNPN_GetJavaPeerProc(FUNC) \
|
||||
((NPN_GetJavaPeerUPP) (FUNC))
|
||||
#define CallNPN_GetJavaPeerProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_GetJavaPeerProc(FUNC) \
|
||||
((NPN_GetJavaPeerUPP) (FUNC))
|
||||
#define CallNPN_GetJavaPeerProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_InvalidateRect */
|
||||
typedef void (* NP_LOADDS NPN_InvalidateRectUPP)(NPP instance, NPRect *rect);
|
||||
#define NewNPN_InvalidateRectProc(FUNC) \
|
||||
((NPN_InvalidateRectUPP) (FUNC))
|
||||
#define CallNPN_InvalidateRectProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
#define NewNPN_InvalidateRectProc(FUNC) \
|
||||
((NPN_InvalidateRectUPP) (FUNC))
|
||||
#define CallNPN_InvalidateRectProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
|
||||
/* NPN_InvalidateRegion */
|
||||
typedef void (* NP_LOADDS NPN_InvalidateRegionUPP)(NPP instance, NPRegion region);
|
||||
#define NewNPN_InvalidateRegionProc(FUNC) \
|
||||
((NPN_InvalidateRegionUPP) (FUNC))
|
||||
#define CallNPN_InvalidateRegionProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
#define NewNPN_InvalidateRegionProc(FUNC) \
|
||||
((NPN_InvalidateRegionUPP) (FUNC))
|
||||
#define CallNPN_InvalidateRegionProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
|
||||
/* NPN_ForceRedraw */
|
||||
typedef void (* NP_LOADDS NPN_ForceRedrawUPP)(NPP instance);
|
||||
#define NewNPN_ForceRedrawProc(FUNC) \
|
||||
((NPN_ForceRedrawUPP) (FUNC))
|
||||
#define CallNPN_ForceRedrawProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_ForceRedrawProc(FUNC) \
|
||||
((NPN_ForceRedrawUPP) (FUNC))
|
||||
#define CallNPN_ForceRedrawProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_GetStringIdentifier */
|
||||
typedef NPIdentifier (* NP_LOADDS NPN_GetStringIdentifierUPP)(const NPUTF8* name);
|
||||
#define NewNPN_GetStringIdentifierProc(FUNC) \
|
||||
((NPN_GetStringIdentifierUPP) (FUNC))
|
||||
#define CallNPN_GetStringIdentifierProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_GetStringIdentifierProc(FUNC) \
|
||||
((NPN_GetStringIdentifierUPP) (FUNC))
|
||||
#define CallNPN_GetStringIdentifierProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_GetStringIdentifiers */
|
||||
typedef void (* NP_LOADDS NPN_GetStringIdentifiersUPP)(const NPUTF8** names,
|
||||
int32_t nameCount,
|
||||
NPIdentifier* identifiers);
|
||||
#define NewNPN_GetStringIdentifiersProc(FUNC) \
|
||||
((NPN_GetStringIdentifiersUPP) (FUNC))
|
||||
#define CallNPN_GetStringIdentifiersProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
#define NewNPN_GetStringIdentifiersProc(FUNC) \
|
||||
((NPN_GetStringIdentifiersUPP) (FUNC))
|
||||
#define CallNPN_GetStringIdentifiersProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
|
||||
/* NPN_GetIntIdentifier */
|
||||
typedef NPIdentifier (* NP_LOADDS NPN_GetIntIdentifierUPP)(int32_t intid);
|
||||
#define NewNPN_GetIntIdentifierProc(FUNC) \
|
||||
((NPN_GetIntIdentifierUPP) (FUNC))
|
||||
#define CallNPN_GetIntIdentifierProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_GetIntIdentifierProc(FUNC) \
|
||||
((NPN_GetIntIdentifierUPP) (FUNC))
|
||||
#define CallNPN_GetIntIdentifierProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_IdentifierIsString */
|
||||
typedef bool (* NP_LOADDS NPN_IdentifierIsStringUPP)(NPIdentifier identifier);
|
||||
#define NewNPN_IdentifierIsStringProc(FUNC) \
|
||||
((NPN_IdentifierIsStringUPP) (FUNC))
|
||||
#define CallNPN_IdentifierIsStringProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_IdentifierIsStringProc(FUNC) \
|
||||
((NPN_IdentifierIsStringUPP) (FUNC))
|
||||
#define CallNPN_IdentifierIsStringProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_UTF8FromIdentifier */
|
||||
typedef NPUTF8* (* NP_LOADDS NPN_UTF8FromIdentifierUPP)(NPIdentifier identifier);
|
||||
#define NewNPN_UTF8FromIdentifierProc(FUNC) \
|
||||
((NPN_UTF8FromIdentifierUPP) (FUNC))
|
||||
#define CallNPN_UTF8FromIdentifierProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_UTF8FromIdentifierProc(FUNC) \
|
||||
((NPN_UTF8FromIdentifierUPP) (FUNC))
|
||||
#define CallNPN_UTF8FromIdentifierProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_IntFromIdentifier */
|
||||
typedef int32_t (* NP_LOADDS NPN_IntFromIdentifierUPP)(NPIdentifier identifier);
|
||||
#define NewNPN_IntFromIdentifierProc(FUNC) \
|
||||
((NPN_IntFromIdentifierUPP) (FUNC))
|
||||
#define CallNPN_IntFromIdentifierProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_IntFromIdentifierProc(FUNC) \
|
||||
((NPN_IntFromIdentifierUPP) (FUNC))
|
||||
#define CallNPN_IntFromIdentifierProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_CreateObject */
|
||||
typedef NPObject* (* NP_LOADDS NPN_CreateObjectUPP)(NPP npp, NPClass *aClass);
|
||||
#define NewNPN_CreateObjectProc(FUNC) \
|
||||
((NPN_CreateObjectUPP) (FUNC))
|
||||
#define CallNPN_CreateObjectProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
#define NewNPN_CreateObjectProc(FUNC) \
|
||||
((NPN_CreateObjectUPP) (FUNC))
|
||||
#define CallNPN_CreateObjectProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
|
||||
/* NPN_RetainObject */
|
||||
typedef NPObject* (* NP_LOADDS NPN_RetainObjectUPP)(NPObject *obj);
|
||||
#define NewNPN_RetainObjectProc(FUNC) \
|
||||
((NPN_RetainObjectUPP) (FUNC))
|
||||
#define CallNPN_RetainObjectProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_RetainObjectProc(FUNC) \
|
||||
((NPN_RetainObjectUPP) (FUNC))
|
||||
#define CallNPN_RetainObjectProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_ReleaseObject */
|
||||
typedef void (* NP_LOADDS NPN_ReleaseObjectUPP)(NPObject *obj);
|
||||
#define NewNPN_ReleaseObjectProc(FUNC) \
|
||||
((NPN_ReleaseObjectUPP) (FUNC))
|
||||
#define CallNPN_ReleaseObjectProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_ReleaseObjectProc(FUNC) \
|
||||
((NPN_ReleaseObjectUPP) (FUNC))
|
||||
#define CallNPN_ReleaseObjectProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_Invoke */
|
||||
typedef bool (* NP_LOADDS NPN_InvokeUPP)(NPP npp, NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result);
|
||||
#define NewNPN_InvokeProc(FUNC) \
|
||||
((NPN_InvokeUPP) (FUNC))
|
||||
#define CallNPN_InvokeProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
|
||||
#define NewNPN_InvokeProc(FUNC) \
|
||||
((NPN_InvokeUPP) (FUNC))
|
||||
#define CallNPN_InvokeProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
|
||||
|
||||
/* NPN_InvokeDefault */
|
||||
typedef bool (* NP_LOADDS NPN_InvokeDefaultUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result);
|
||||
#define NewNPN_InvokeDefaultProc(FUNC) \
|
||||
((NPN_InvokeDefaultUPP) (FUNC))
|
||||
#define CallNPN_InvokeDefaultProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
|
||||
#define NewNPN_InvokeDefaultProc(FUNC) \
|
||||
((NPN_InvokeDefaultUPP) (FUNC))
|
||||
#define CallNPN_InvokeDefaultProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
|
||||
|
||||
/* NPN_Evaluate */
|
||||
typedef bool (* NP_LOADDS NPN_EvaluateUPP)(NPP npp, NPObject *obj, NPString *script, NPVariant *result);
|
||||
#define NewNPN_EvaluateProc(FUNC) \
|
||||
((NPN_EvaluateUPP) (FUNC))
|
||||
#define CallNPN_EvaluateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
|
||||
#define NewNPN_EvaluateProc(FUNC) \
|
||||
((NPN_EvaluateUPP) (FUNC))
|
||||
#define CallNPN_EvaluateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
|
||||
|
||||
/* NPN_GetProperty */
|
||||
typedef bool (* NP_LOADDS NPN_GetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, NPVariant *result);
|
||||
#define NewNPN_GetPropertyProc(FUNC) \
|
||||
((NPN_GetPropertyUPP) (FUNC))
|
||||
#define CallNPN_GetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
|
||||
#define NewNPN_GetPropertyProc(FUNC) \
|
||||
((NPN_GetPropertyUPP) (FUNC))
|
||||
#define CallNPN_GetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
|
||||
|
||||
/* NPN_SetProperty */
|
||||
typedef bool (* NP_LOADDS NPN_SetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, const NPVariant *value);
|
||||
#define NewNPN_SetPropertyProc(FUNC) \
|
||||
((NPN_SetPropertyUPP) (FUNC))
|
||||
#define CallNPN_SetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
|
||||
#define NewNPN_SetPropertyProc(FUNC) \
|
||||
((NPN_SetPropertyUPP) (FUNC))
|
||||
#define CallNPN_SetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
|
||||
|
||||
/* NPN_RemoveProperty */
|
||||
typedef bool (* NP_LOADDS NPN_RemovePropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName);
|
||||
#define NewNPN_RemovePropertyProc(FUNC) \
|
||||
((NPN_RemovePropertyUPP) (FUNC))
|
||||
#define CallNPN_RemovePropertyProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
#define NewNPN_RemovePropertyProc(FUNC) \
|
||||
((NPN_RemovePropertyUPP) (FUNC))
|
||||
#define CallNPN_RemovePropertyProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
|
||||
/* NPN_HasProperty */
|
||||
typedef bool (* NP_LOADDS NPN_HasPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName);
|
||||
#define NewNPN_HasPropertyProc(FUNC) \
|
||||
((NPN_HasPropertyUPP) (FUNC))
|
||||
#define CallNPN_HasPropertyProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
#define NewNPN_HasPropertyProc(FUNC) \
|
||||
((NPN_HasPropertyUPP) (FUNC))
|
||||
#define CallNPN_HasPropertyProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
|
||||
/* NPN_HasMethod */
|
||||
typedef bool (* NP_LOADDS NPN_HasMethodUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName);
|
||||
#define NewNPN_HasMethodProc(FUNC) \
|
||||
((NPN_HasMethodUPP) (FUNC))
|
||||
#define CallNPN_HasMethodProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
#define NewNPN_HasMethodProc(FUNC) \
|
||||
((NPN_HasMethodUPP) (FUNC))
|
||||
#define CallNPN_HasMethodProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
|
||||
/* NPN_ReleaseVariantValue */
|
||||
typedef void (* NP_LOADDS NPN_ReleaseVariantValueUPP)(NPVariant *variant);
|
||||
#define NewNPN_ReleaseVariantValueProc(FUNC) \
|
||||
((NPN_ReleaseVariantValueUPP) (FUNC))
|
||||
#define CallNPN_ReleaseVariantValueProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_ReleaseVariantValueProc(FUNC) \
|
||||
((NPN_ReleaseVariantValueUPP) (FUNC))
|
||||
#define CallNPN_ReleaseVariantValueProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_SetException */
|
||||
typedef void (* NP_LOADDS NPN_SetExceptionUPP)(NPObject *obj, const NPUTF8 *message);
|
||||
#define NewNPN_SetExceptionProc(FUNC) \
|
||||
((NPN_SetExceptionUPP) (FUNC))
|
||||
#define CallNPN_SetExceptionProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
#define NewNPN_SetExceptionProc(FUNC) \
|
||||
((NPN_SetExceptionUPP) (FUNC))
|
||||
#define CallNPN_SetExceptionProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
|
||||
/* NPN_PushPopupsEnabledStateUPP */
|
||||
typedef bool (* NP_LOADDS NPN_PushPopupsEnabledStateUPP)(NPP npp, NPBool enabled);
|
||||
#define NewNPN_PushPopupsEnabledStateProc(FUNC) \
|
||||
((NPN_PushPopupsEnabledStateUPP) (FUNC))
|
||||
#define CallNPN_PushPopupsEnabledStateProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
#define NewNPN_PushPopupsEnabledStateProc(FUNC) \
|
||||
((NPN_PushPopupsEnabledStateUPP) (FUNC))
|
||||
#define CallNPN_PushPopupsEnabledStateProc(FUNC, ARG1, ARG2) \
|
||||
(*(FUNC))((ARG1), (ARG2))
|
||||
|
||||
/* NPN_PopPopupsEnabledState */
|
||||
typedef bool (* NP_LOADDS NPN_PopPopupsEnabledStateUPP)(NPP npp);
|
||||
#define NewNPN_PopPopupsEnabledStateProc(FUNC) \
|
||||
((NPN_PopPopupsEnabledStateUPP) (FUNC))
|
||||
#define CallNPN_PopPopupsEnabledStateProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
#define NewNPN_PopPopupsEnabledStateProc(FUNC) \
|
||||
((NPN_PopPopupsEnabledStateUPP) (FUNC))
|
||||
#define CallNPN_PopPopupsEnabledStateProc(FUNC, ARG1) \
|
||||
(*(FUNC))((ARG1))
|
||||
|
||||
/* NPN_Enumerate */
|
||||
typedef bool (* NP_LOADDS NPN_EnumerateUPP)(NPP npp, NPObject *obj, NPIdentifier **identifier, uint32_t *count);
|
||||
#define NewNPN_EnumerateProc(FUNC) \
|
||||
((NPN_EnumerateUPP) (FUNC))
|
||||
#define CallNPN_EnumerateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
|
||||
#define NewNPN_EnumerateProc(FUNC) \
|
||||
((NPN_EnumerateUPP) (FUNC))
|
||||
#define CallNPN_EnumerateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
|
||||
|
||||
/* NPN_PluginThreadAsyncCall */
|
||||
typedef void (* NP_LOADDS NPN_PluginThreadAsyncCallUPP)(NPP instance, void (*func)(void *), void *userData);
|
||||
#define NewNPN_PluginThreadAsyncCallProc(FUNC) \
|
||||
((NPN_PluginThreadAsyncCallUPP) (FUNC))
|
||||
((NPN_PluginThreadAsyncCallUPP) (FUNC))
|
||||
#define CallNPN_PluginThreadAsyncCallProc(FUNC, ARG1, ARG2, ARG3) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3))
|
||||
|
||||
/* NPN_Construct */
|
||||
typedef bool (* NP_LOADDS NPN_ConstructUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result);
|
||||
#define NewNPN_ConstructProc(FUNC) \
|
||||
((NPN_ConstructUPP) (FUNC))
|
||||
#define NewNPN_ConstructProc(FUNC) \
|
||||
((NPN_ConstructUPP) (FUNC))
|
||||
#define CallNPN_ConstructProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
|
||||
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
|
||||
|
||||
|
||||
|
||||
@ -590,17 +590,17 @@ typedef struct _NPNetscapeFuncs {
|
||||
* and NPPShutdownUPP for Netscape's use.
|
||||
*/
|
||||
typedef NPError (* NP_LOADDS NPP_MainEntryUPP)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownUPP*);
|
||||
#define NewNPP_MainEntryProc(FUNC) \
|
||||
((NPP_MainEntryUPP) (FUNC))
|
||||
#define CallNPP_MainEntryProc(FUNC, netscapeFunc, pluginFunc, shutdownUPP) \
|
||||
(*(FUNC))((netscapeFunc), (pluginFunc), (shutdownUPP))
|
||||
#define NewNPP_MainEntryProc(FUNC) \
|
||||
((NPP_MainEntryUPP) (FUNC))
|
||||
#define CallNPP_MainEntryProc(FUNC, netscapeFunc, pluginFunc, shutdownUPP) \
|
||||
(*(FUNC))((netscapeFunc), (pluginFunc), (shutdownUPP))
|
||||
|
||||
/*
|
||||
* Mac OS X version(s) of NP_GetMIMEDescription(const char *)
|
||||
* These can be called to retreive MIME information from the plugin dynamically
|
||||
*
|
||||
* Note: For compatibility with Quicktime, BPSupportedMIMEtypes is another way
|
||||
* to get mime info from the plugin only on OSX and may not be supported
|
||||
* to get mime info from the plugin only on OSX and may not be supported
|
||||
* in furture version -- use NP_GetMIMEDescription instead
|
||||
*/
|
||||
|
||||
@ -620,17 +620,17 @@ OSErr BP_GetSupportedMIMETypes(BPSupportedMIMETypes *mimeInfo, UInt32 flags);
|
||||
/* NP_GetMIMEDescription */
|
||||
#define NP_GETMIMEDESCRIPTION_NAME "NP_GetMIMEDescription"
|
||||
typedef const char* (* NP_LOADDS NP_GetMIMEDescriptionUPP)();
|
||||
#define NewNP_GetMIMEDescEntryProc(FUNC) \
|
||||
((NP_GetMIMEDescriptionUPP) (FUNC))
|
||||
#define CallNP_GetMIMEDescEntryProc(FUNC) \
|
||||
(*(FUNC))()
|
||||
#define NewNP_GetMIMEDescEntryProc(FUNC) \
|
||||
((NP_GetMIMEDescriptionUPP) (FUNC))
|
||||
#define CallNP_GetMIMEDescEntryProc(FUNC) \
|
||||
(*(FUNC))()
|
||||
|
||||
/* BP_GetSupportedMIMETypes */
|
||||
typedef OSErr (* NP_LOADDS BP_GetSupportedMIMETypesUPP)(BPSupportedMIMETypes*, UInt32);
|
||||
#define NewBP_GetSupportedMIMETypesEntryProc(FUNC) \
|
||||
((BP_GetSupportedMIMETypesUPP) (FUNC))
|
||||
#define CallBP_GetMIMEDescEntryProc(FUNC, mimeInfo, flags) \
|
||||
(*(FUNC))((mimeInfo), (flags))
|
||||
#define NewBP_GetSupportedMIMETypesEntryProc(FUNC) \
|
||||
((BP_GetSupportedMIMETypesUPP) (FUNC))
|
||||
#define CallBP_GetMIMEDescEntryProc(FUNC, mimeInfo, flags) \
|
||||
(*(FUNC))((mimeInfo), (flags))
|
||||
|
||||
#endif /* XP_MACOSX */
|
||||
|
||||
@ -685,7 +685,7 @@ NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs);
|
||||
|
||||
NPError OSCALL NP_Shutdown();
|
||||
|
||||
char* NP_GetMIMEDescription();
|
||||
char* !NP_GetMIMEDescription();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ VirtViewerXSetWindow (NPP instance, NPWindow *window)
|
||||
/* Make the VNC widget. */
|
||||
if (This->uri && This->name) {
|
||||
debug ("calling viewer_start uri=%s name=%s direct=%d waitvm=%d reconnect=%d container=%p",
|
||||
This->uri, This->name, This->direct, This->waitvm, This->reconnect, This->container);
|
||||
This->uri, This->name, This->direct, This->waitvm, This->reconnect, This->container);
|
||||
r = viewer_start (This->uri, This->name, This->direct, This->waitvm, This->reconnect, 1, This->debug, This->container);
|
||||
if (r != 0)
|
||||
fprintf (stderr, "viewer_start returned %d != 0\n", r);
|
||||
|
@ -39,131 +39,130 @@
|
||||
static void
|
||||
remote_viewer_version(void)
|
||||
{
|
||||
g_print(_("remote-viewer version %s\n"), VERSION);
|
||||
exit(0);
|
||||
g_print(_("remote-viewer version %s\n"), VERSION);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
GOptionContext *context;
|
||||
GError *error = NULL;
|
||||
int ret = 1;
|
||||
int zoom = 100;
|
||||
gchar **args = NULL;
|
||||
gboolean verbose = FALSE;
|
||||
gboolean debug = FALSE;
|
||||
gboolean direct = FALSE;
|
||||
gboolean fullscreen = FALSE;
|
||||
RemoteViewer *viewer = NULL;
|
||||
GOptionContext *context;
|
||||
GError *error = NULL;
|
||||
int ret = 1;
|
||||
int zoom = 100;
|
||||
gchar **args = NULL;
|
||||
gboolean verbose = FALSE;
|
||||
gboolean debug = FALSE;
|
||||
gboolean direct = FALSE;
|
||||
gboolean fullscreen = FALSE;
|
||||
RemoteViewer *viewer = NULL;
|
||||
#if HAVE_SPICE_GTK
|
||||
gboolean controller = FALSE;
|
||||
gboolean controller = FALSE;
|
||||
#endif
|
||||
VirtViewerApp *app;
|
||||
const char *help_msg = N_("Run '" PACKAGE " --help' to see a full list of available command line options");
|
||||
const GOptionEntry options [] = {
|
||||
{ "version", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
||||
remote_viewer_version, N_("Display version information"), NULL },
|
||||
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
|
||||
N_("Display verbose information"), NULL },
|
||||
{ "direct", 'd', 0, G_OPTION_ARG_NONE, &direct,
|
||||
N_("Direct connection with no automatic tunnels"), NULL },
|
||||
{ "zoom", 'z', 0, G_OPTION_ARG_INT, &zoom,
|
||||
N_("Zoom level of window, in percentage"), "ZOOM" },
|
||||
{ "debug", '\0', 0, G_OPTION_ARG_NONE, &debug,
|
||||
N_("Display debugging information"), NULL },
|
||||
{ "full-screen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen,
|
||||
N_("Open in full screen mode"), NULL },
|
||||
VirtViewerApp *app;
|
||||
const char *help_msg = N_("Run '" PACKAGE " --help' to see a full list of available command line options");
|
||||
const GOptionEntry options [] = {
|
||||
{ "version", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
||||
remote_viewer_version, N_("Display version information"), NULL },
|
||||
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
|
||||
N_("Display verbose information"), NULL },
|
||||
{ "direct", 'd', 0, G_OPTION_ARG_NONE, &direct,
|
||||
N_("Direct connection with no automatic tunnels"), NULL },
|
||||
{ "zoom", 'z', 0, G_OPTION_ARG_INT, &zoom,
|
||||
N_("Zoom level of window, in percentage"), "ZOOM" },
|
||||
{ "debug", '\0', 0, G_OPTION_ARG_NONE, &debug,
|
||||
N_("Display debugging information"), NULL },
|
||||
{ "full-screen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen,
|
||||
N_("Open in full screen mode"), NULL },
|
||||
#if HAVE_SPICE_GTK
|
||||
{ "spice-controller", '\0', 0, G_OPTION_ARG_NONE, &controller,
|
||||
N_("Open connection using Spice controller communication"), NULL },
|
||||
{ "spice-controller", '\0', 0, G_OPTION_ARG_NONE, &controller,
|
||||
N_("Open connection using Spice controller communication"), NULL },
|
||||
#endif
|
||||
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
|
||||
NULL, "URI" },
|
||||
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
|
||||
};
|
||||
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
|
||||
NULL, "URI" },
|
||||
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
|
||||
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
||||
textdomain(GETTEXT_PACKAGE);
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
|
||||
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
||||
textdomain(GETTEXT_PACKAGE);
|
||||
|
||||
/* Setup command line options */
|
||||
context = g_option_context_new (_("- Remote viewer client"));
|
||||
g_option_context_add_main_entries (context, options, NULL);
|
||||
g_option_context_add_group (context, gtk_get_option_group (TRUE));
|
||||
/* Setup command line options */
|
||||
context = g_option_context_new (_("- Remote viewer client"));
|
||||
g_option_context_add_main_entries (context, options, NULL);
|
||||
g_option_context_add_group (context, gtk_get_option_group (TRUE));
|
||||
#ifdef HAVE_GTK_VNC
|
||||
g_option_context_add_group (context, vnc_display_get_option_group ());
|
||||
g_option_context_add_group (context, vnc_display_get_option_group ());
|
||||
#endif
|
||||
#ifdef HAVE_SPICE_GTK
|
||||
g_option_context_add_group (context, spice_get_option_group ());
|
||||
g_option_context_add_group (context, spice_get_option_group ());
|
||||
#endif
|
||||
g_option_context_parse (context, &argc, &argv, &error);
|
||||
if (error) {
|
||||
g_printerr("%s\n%s\n",
|
||||
error->message,
|
||||
gettext(help_msg));
|
||||
g_error_free(error);
|
||||
goto cleanup;
|
||||
}
|
||||
g_option_context_parse (context, &argc, &argv, &error);
|
||||
if (error) {
|
||||
g_printerr("%s\n%s\n",
|
||||
error->message,
|
||||
gettext(help_msg));
|
||||
g_error_free(error);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
g_option_context_free(context);
|
||||
g_option_context_free(context);
|
||||
|
||||
if ((!args || (g_strv_length(args) != 1))
|
||||
if ((!args || (g_strv_length(args) != 1))
|
||||
#if HAVE_SPICE_GTK
|
||||
&& !controller
|
||||
&& !controller
|
||||
#endif
|
||||
) {
|
||||
g_printerr(_("\nUsage: %s [OPTIONS] URI\n\n%s\n\n"), argv[0], help_msg);
|
||||
goto cleanup;
|
||||
}
|
||||
) {
|
||||
g_printerr(_("\nUsage: %s [OPTIONS] URI\n\n%s\n\n"), argv[0], help_msg);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (zoom < 10 || zoom > 200) {
|
||||
g_printerr(_("Zoom level must be within 10-200\n"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (zoom < 10 || zoom > 200) {
|
||||
g_printerr(_("Zoom level must be within 10-200\n"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
virt_viewer_app_set_debug(debug);
|
||||
virt_viewer_app_set_debug(debug);
|
||||
|
||||
#if HAVE_SPICE_GTK
|
||||
if (controller) {
|
||||
viewer = remote_viewer_new_with_controller(verbose);
|
||||
g_object_set(viewer, "guest-name", "defined by Spice controller", NULL);
|
||||
} else {
|
||||
if (controller) {
|
||||
viewer = remote_viewer_new_with_controller(verbose);
|
||||
g_object_set(viewer, "guest-name", "defined by Spice controller", NULL);
|
||||
} else {
|
||||
#endif
|
||||
viewer = remote_viewer_new(args[0], verbose);
|
||||
g_object_set(viewer, "guest-name", args[0], NULL);
|
||||
viewer = remote_viewer_new(args[0], verbose);
|
||||
g_object_set(viewer, "guest-name", args[0], NULL);
|
||||
#if HAVE_SPICE_GTK
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (viewer == NULL)
|
||||
goto cleanup;
|
||||
if (viewer == NULL)
|
||||
goto cleanup;
|
||||
|
||||
app = VIRT_VIEWER_APP(viewer);
|
||||
g_object_set(app, "fullscreen", fullscreen, NULL);
|
||||
virt_viewer_window_set_zoom_level(virt_viewer_app_get_main_window(app), zoom);
|
||||
virt_viewer_app_set_direct(app, direct);
|
||||
app = VIRT_VIEWER_APP(viewer);
|
||||
g_object_set(app, "fullscreen", fullscreen, NULL);
|
||||
virt_viewer_window_set_zoom_level(virt_viewer_app_get_main_window(app), zoom);
|
||||
virt_viewer_app_set_direct(app, direct);
|
||||
|
||||
if (!virt_viewer_app_start(app))
|
||||
goto cleanup;
|
||||
if (!virt_viewer_app_start(app))
|
||||
goto cleanup;
|
||||
|
||||
gtk_main();
|
||||
gtk_main();
|
||||
|
||||
ret = 0;
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (viewer)
|
||||
g_object_unref(viewer);
|
||||
g_strfreev(args);
|
||||
cleanup:
|
||||
if (viewer)
|
||||
g_object_unref(viewer);
|
||||
g_strfreev(args);
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -39,19 +39,19 @@
|
||||
|
||||
struct _RemoteViewerPrivate {
|
||||
#ifdef HAVE_SPICE_GTK
|
||||
SpiceCtrlController *controller;
|
||||
SpiceCtrlController *controller;
|
||||
#endif
|
||||
GtkWidget *controller_menu;
|
||||
GtkWidget *controller_menu;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (RemoteViewer, remote_viewer, VIRT_VIEWER_TYPE_APP)
|
||||
#define GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, RemoteViewerPrivate))
|
||||
#define GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), REMOTE_VIEWER_TYPE, RemoteViewerPrivate))
|
||||
|
||||
#if HAVE_SPICE_GTK
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_CONTROLLER,
|
||||
PROP_0,
|
||||
PROP_CONTROLLER,
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -64,49 +64,49 @@ static void remote_viewer_window_added(VirtViewerApp *self, VirtViewerWindow *wi
|
||||
#if HAVE_SPICE_GTK
|
||||
static void
|
||||
remote_viewer_get_property (GObject *object, guint property_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
RemoteViewer *self = REMOTE_VIEWER(object);
|
||||
RemoteViewerPrivate *priv = self->priv;
|
||||
RemoteViewer *self = REMOTE_VIEWER(object);
|
||||
RemoteViewerPrivate *priv = self->priv;
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CONTROLLER:
|
||||
g_value_set_object(value, priv->controller);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
switch (property_id) {
|
||||
case PROP_CONTROLLER:
|
||||
g_value_set_object(value, priv->controller);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
remote_viewer_set_property (GObject *object, guint property_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
RemoteViewer *self = REMOTE_VIEWER(object);
|
||||
RemoteViewerPrivate *priv = self->priv;
|
||||
RemoteViewer *self = REMOTE_VIEWER(object);
|
||||
RemoteViewerPrivate *priv = self->priv;
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CONTROLLER:
|
||||
g_return_if_fail(priv->controller == NULL);
|
||||
priv->controller = g_value_dup_object(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
switch (property_id) {
|
||||
case PROP_CONTROLLER:
|
||||
g_return_if_fail(priv->controller == NULL);
|
||||
priv->controller = g_value_dup_object(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
remote_viewer_dispose (GObject *object)
|
||||
{
|
||||
RemoteViewer *self = REMOTE_VIEWER(object);
|
||||
RemoteViewerPrivate *priv = self->priv;
|
||||
RemoteViewer *self = REMOTE_VIEWER(object);
|
||||
RemoteViewerPrivate *priv = self->priv;
|
||||
|
||||
if (priv->controller) {
|
||||
g_object_unref(priv->controller);
|
||||
priv->controller = NULL;
|
||||
}
|
||||
if (priv->controller) {
|
||||
g_object_unref(priv->controller);
|
||||
priv->controller = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS(remote_viewer_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS(remote_viewer_parent_class)->dispose (object);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -115,222 +115,222 @@ static void
|
||||
remote_viewer_class_init (RemoteViewerClass *klass)
|
||||
{
|
||||
#if HAVE_SPICE_GTK
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
#endif
|
||||
VirtViewerAppClass *app_class = VIRT_VIEWER_APP_CLASS (klass);
|
||||
VirtViewerAppClass *app_class = VIRT_VIEWER_APP_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (RemoteViewerPrivate));
|
||||
g_type_class_add_private (klass, sizeof (RemoteViewerPrivate));
|
||||
|
||||
#if HAVE_SPICE_GTK
|
||||
object_class->get_property = remote_viewer_get_property;
|
||||
object_class->set_property = remote_viewer_set_property;
|
||||
object_class->dispose = remote_viewer_dispose;
|
||||
object_class->get_property = remote_viewer_get_property;
|
||||
object_class->set_property = remote_viewer_set_property;
|
||||
object_class->dispose = remote_viewer_dispose;
|
||||
#endif
|
||||
|
||||
app_class->start = remote_viewer_start;
|
||||
app_class->start = remote_viewer_start;
|
||||
#if HAVE_SPICE_GTK
|
||||
app_class->activate = remote_viewer_activate;
|
||||
app_class->activate = remote_viewer_activate;
|
||||
#endif
|
||||
app_class->window_added = remote_viewer_window_added;
|
||||
app_class->window_added = remote_viewer_window_added;
|
||||
|
||||
#if HAVE_SPICE_GTK
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_CONTROLLER,
|
||||
g_param_spec_object("controller",
|
||||
"Controller",
|
||||
"Spice controller",
|
||||
SPICE_CTRL_TYPE_CONTROLLER,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_CONTROLLER,
|
||||
g_param_spec_object("controller",
|
||||
"Controller",
|
||||
"Spice controller",
|
||||
SPICE_CTRL_TYPE_CONTROLLER,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
remote_viewer_init(RemoteViewer *self)
|
||||
{
|
||||
self->priv = GET_PRIVATE(self);
|
||||
self->priv = GET_PRIVATE(self);
|
||||
}
|
||||
|
||||
RemoteViewer *
|
||||
remote_viewer_new(const gchar *uri, gboolean verbose)
|
||||
{
|
||||
return g_object_new(REMOTE_VIEWER_TYPE,
|
||||
"guri", uri,
|
||||
"verbose", verbose,
|
||||
NULL);
|
||||
return g_object_new(REMOTE_VIEWER_TYPE,
|
||||
"guri", uri,
|
||||
"verbose", verbose,
|
||||
NULL);
|
||||
}
|
||||
|
||||
#if HAVE_SPICE_GTK
|
||||
RemoteViewer *
|
||||
remote_viewer_new_with_controller(gboolean verbose)
|
||||
{
|
||||
RemoteViewer *self;
|
||||
SpiceCtrlController *ctrl = spice_ctrl_controller_new();
|
||||
RemoteViewer *self;
|
||||
SpiceCtrlController *ctrl = spice_ctrl_controller_new();
|
||||
|
||||
self = g_object_new(REMOTE_VIEWER_TYPE,
|
||||
"controller", ctrl,
|
||||
"verbose", verbose,
|
||||
NULL);
|
||||
g_object_unref(ctrl);
|
||||
self = g_object_new(REMOTE_VIEWER_TYPE,
|
||||
"controller", ctrl,
|
||||
"verbose", verbose,
|
||||
NULL);
|
||||
g_object_unref(ctrl);
|
||||
|
||||
return self;
|
||||
return self;
|
||||
}
|
||||
|
||||
static void
|
||||
spice_ctrl_do_connect(SpiceCtrlController *ctrl G_GNUC_UNUSED,
|
||||
VirtViewerApp *self)
|
||||
VirtViewerApp *self)
|
||||
{
|
||||
if (virt_viewer_app_initial_connect(self) < 0) {
|
||||
virt_viewer_app_simple_message_dialog(self, _("Failed to initiate connection"));
|
||||
}
|
||||
if (virt_viewer_app_initial_connect(self) < 0) {
|
||||
virt_viewer_app_simple_message_dialog(self, _("Failed to initiate connection"));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
spice_ctrl_show(SpiceCtrlController *ctrl G_GNUC_UNUSED, RemoteViewer *self)
|
||||
{
|
||||
virt_viewer_app_show_display(VIRT_VIEWER_APP(self));
|
||||
virt_viewer_app_show_display(VIRT_VIEWER_APP(self));
|
||||
}
|
||||
|
||||
static void
|
||||
spice_ctrl_hide(SpiceCtrlController *ctrl G_GNUC_UNUSED, RemoteViewer *self)
|
||||
{
|
||||
virt_viewer_app_show_status(VIRT_VIEWER_APP(self), _("Display disabled by controller"));
|
||||
virt_viewer_app_show_status(VIRT_VIEWER_APP(self), _("Display disabled by controller"));
|
||||
}
|
||||
|
||||
static void
|
||||
spice_menuitem_activate_cb(GtkMenuItem *mi, RemoteViewer *self)
|
||||
{
|
||||
SpiceCtrlMenuItem *menuitem = g_object_get_data(G_OBJECT(mi), "spice-menuitem");
|
||||
SpiceCtrlMenuItem *menuitem = g_object_get_data(G_OBJECT(mi), "spice-menuitem");
|
||||
|
||||
g_return_if_fail(menuitem != NULL);
|
||||
if (gtk_menu_item_get_submenu(mi))
|
||||
return;
|
||||
g_return_if_fail(menuitem != NULL);
|
||||
if (gtk_menu_item_get_submenu(mi))
|
||||
return;
|
||||
|
||||
spice_ctrl_controller_menu_item_click_msg(self->priv->controller, menuitem->id);
|
||||
spice_ctrl_controller_menu_item_click_msg(self->priv->controller, menuitem->id);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
ctrlmenu_to_gtkmenu (RemoteViewer *self, SpiceCtrlMenu *ctrlmenu)
|
||||
{
|
||||
GList *l;
|
||||
GtkWidget *menu = gtk_menu_new();
|
||||
guint n = 0;
|
||||
GList *l;
|
||||
GtkWidget *menu = gtk_menu_new();
|
||||
guint n = 0;
|
||||
|
||||
for (l = ctrlmenu->items; l != NULL; l = l->next) {
|
||||
SpiceCtrlMenuItem *menuitem = l->data;
|
||||
GtkWidget *item;
|
||||
char *s;
|
||||
if (menuitem->text == NULL) {
|
||||
g_warn_if_reached();
|
||||
continue;
|
||||
}
|
||||
for (l = ctrlmenu->items; l != NULL; l = l->next) {
|
||||
SpiceCtrlMenuItem *menuitem = l->data;
|
||||
GtkWidget *item;
|
||||
char *s;
|
||||
if (menuitem->text == NULL) {
|
||||
g_warn_if_reached();
|
||||
continue;
|
||||
}
|
||||
|
||||
for (s = menuitem->text; *s; s++)
|
||||
if (*s == '&')
|
||||
*s = '_';
|
||||
for (s = menuitem->text; *s; s++)
|
||||
if (*s == '&')
|
||||
*s = '_';
|
||||
|
||||
if (g_str_equal(menuitem->text, "-")){
|
||||
item = gtk_separator_menu_item_new();
|
||||
} else {
|
||||
item = gtk_menu_item_new_with_mnemonic(menuitem->text);
|
||||
}
|
||||
if (g_str_equal(menuitem->text, "-")){
|
||||
item = gtk_separator_menu_item_new();
|
||||
} else {
|
||||
item = gtk_menu_item_new_with_mnemonic(menuitem->text);
|
||||
}
|
||||
|
||||
g_object_set_data_full(G_OBJECT(item), "spice-menuitem",
|
||||
g_object_ref(menuitem), g_object_unref);
|
||||
g_signal_connect(item, "activate", G_CALLBACK(spice_menuitem_activate_cb), self);
|
||||
gtk_menu_attach(GTK_MENU (menu), item, 0, 1, n, n + 1);
|
||||
n += 1;
|
||||
g_object_set_data_full(G_OBJECT(item), "spice-menuitem",
|
||||
g_object_ref(menuitem), g_object_unref);
|
||||
g_signal_connect(item, "activate", G_CALLBACK(spice_menuitem_activate_cb), self);
|
||||
gtk_menu_attach(GTK_MENU (menu), item, 0, 1, n, n + 1);
|
||||
n += 1;
|
||||
|
||||
if (menuitem->submenu) {
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),
|
||||
ctrlmenu_to_gtkmenu(self, menuitem->submenu));
|
||||
}
|
||||
}
|
||||
if (menuitem->submenu) {
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item),
|
||||
ctrlmenu_to_gtkmenu(self, menuitem->submenu));
|
||||
}
|
||||
}
|
||||
|
||||
if (n == 0) {
|
||||
g_object_ref_sink(menu);
|
||||
g_object_unref(menu);
|
||||
menu = NULL;
|
||||
}
|
||||
if (n == 0) {
|
||||
g_object_ref_sink(menu);
|
||||
g_object_unref(menu);
|
||||
menu = NULL;
|
||||
}
|
||||
|
||||
gtk_widget_show_all(menu);
|
||||
return menu;
|
||||
gtk_widget_show_all(menu);
|
||||
return menu;
|
||||
}
|
||||
|
||||
static void
|
||||
spice_menu_set_visible(gpointer key G_GNUC_UNUSED,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
gboolean visible = GPOINTER_TO_INT(user_data);
|
||||
GtkWidget *menu = g_object_get_data(value, "spice-menu");
|
||||
gboolean visible = GPOINTER_TO_INT(user_data);
|
||||
GtkWidget *menu = g_object_get_data(value, "spice-menu");
|
||||
|
||||
gtk_widget_set_visible(menu, visible);
|
||||
gtk_widget_set_visible(menu, visible);
|
||||
}
|
||||
|
||||
static void
|
||||
remote_viewer_window_spice_menu_set_visible(RemoteViewer *self,
|
||||
gboolean visible)
|
||||
gboolean visible)
|
||||
{
|
||||
GHashTable *windows = virt_viewer_app_get_windows(VIRT_VIEWER_APP(self));
|
||||
GHashTable *windows = virt_viewer_app_get_windows(VIRT_VIEWER_APP(self));
|
||||
|
||||
g_hash_table_foreach(windows, spice_menu_set_visible, GINT_TO_POINTER(visible));
|
||||
g_hash_table_foreach(windows, spice_menu_set_visible, GINT_TO_POINTER(visible));
|
||||
}
|
||||
|
||||
static void
|
||||
spice_menu_update(gpointer key G_GNUC_UNUSED,
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
gpointer value,
|
||||
gpointer user_data)
|
||||
{
|
||||
RemoteViewer *self = REMOTE_VIEWER(user_data);
|
||||
GtkWidget *menuitem = g_object_get_data(value, "spice-menu");
|
||||
SpiceCtrlMenu *menu;
|
||||
RemoteViewer *self = REMOTE_VIEWER(user_data);
|
||||
GtkWidget *menuitem = g_object_get_data(value, "spice-menu");
|
||||
SpiceCtrlMenu *menu;
|
||||
|
||||
g_object_get(self->priv->controller, "menu", &menu, NULL);
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), ctrlmenu_to_gtkmenu(self, menu));
|
||||
g_object_unref(menu);
|
||||
g_object_get(self->priv->controller, "menu", &menu, NULL);
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), ctrlmenu_to_gtkmenu(self, menu));
|
||||
g_object_unref(menu);
|
||||
}
|
||||
|
||||
static void
|
||||
spice_ctrl_menu_updated(RemoteViewer *self,
|
||||
SpiceCtrlMenu *menu)
|
||||
SpiceCtrlMenu *menu)
|
||||
{
|
||||
GHashTable *windows = virt_viewer_app_get_windows(VIRT_VIEWER_APP(self));
|
||||
RemoteViewerPrivate *priv = self->priv;
|
||||
gboolean visible;
|
||||
GHashTable *windows = virt_viewer_app_get_windows(VIRT_VIEWER_APP(self));
|
||||
RemoteViewerPrivate *priv = self->priv;
|
||||
gboolean visible;
|
||||
|
||||
DEBUG_LOG("Spice controller menu updated");
|
||||
DEBUG_LOG("Spice controller menu updated");
|
||||
|
||||
if (priv->controller_menu != NULL) {
|
||||
g_object_unref (priv->controller_menu);
|
||||
priv->controller_menu = NULL;
|
||||
}
|
||||
if (priv->controller_menu != NULL) {
|
||||
g_object_unref (priv->controller_menu);
|
||||
priv->controller_menu = NULL;
|
||||
}
|
||||
|
||||
if (menu && g_list_length(menu->items) > 0) {
|
||||
priv->controller_menu = ctrlmenu_to_gtkmenu(self, menu);
|
||||
g_hash_table_foreach(windows, spice_menu_update, self);
|
||||
}
|
||||
if (menu && g_list_length(menu->items) > 0) {
|
||||
priv->controller_menu = ctrlmenu_to_gtkmenu(self, menu);
|
||||
g_hash_table_foreach(windows, spice_menu_update, self);
|
||||
}
|
||||
|
||||
visible = priv->controller_menu != NULL;
|
||||
visible = priv->controller_menu != NULL;
|
||||
|
||||
remote_viewer_window_spice_menu_set_visible(self, visible);
|
||||
remote_viewer_window_spice_menu_set_visible(self, visible);
|
||||
}
|
||||
|
||||
static SpiceSession *
|
||||
remote_viewer_get_spice_session(RemoteViewer *self)
|
||||
{
|
||||
VirtViewerSession *vsession = NULL;
|
||||
SpiceSession *session = NULL;
|
||||
VirtViewerSession *vsession = NULL;
|
||||
SpiceSession *session = NULL;
|
||||
|
||||
g_object_get(self, "session", &vsession, NULL);
|
||||
g_return_val_if_fail(vsession != NULL, NULL);
|
||||
g_object_get(self, "session", &vsession, NULL);
|
||||
g_return_val_if_fail(vsession != NULL, NULL);
|
||||
|
||||
g_object_get(vsession, "spice-session", &session, NULL);
|
||||
g_object_get(vsession, "spice-session", &session, NULL);
|
||||
|
||||
g_object_unref(vsession);
|
||||
g_object_unref(vsession);
|
||||
|
||||
return session;
|
||||
return session;
|
||||
}
|
||||
|
||||
#ifndef G_VALUE_INIT /* see bug https://bugzilla.gnome.org/show_bug.cgi?id=654793 */
|
||||
@ -339,166 +339,165 @@ remote_viewer_get_spice_session(RemoteViewer *self)
|
||||
|
||||
static void
|
||||
spice_ctrl_notified(SpiceCtrlController *ctrl,
|
||||
GParamSpec *pspec,
|
||||
RemoteViewer *self)
|
||||
GParamSpec *pspec,
|
||||
RemoteViewer *self)
|
||||
{
|
||||
SpiceSession *session = remote_viewer_get_spice_session(self);
|
||||
GValue value = G_VALUE_INIT;
|
||||
VirtViewerApp *app = VIRT_VIEWER_APP(self);
|
||||
SpiceSession *session = remote_viewer_get_spice_session(self);
|
||||
GValue value = G_VALUE_INIT;
|
||||
VirtViewerApp *app = VIRT_VIEWER_APP(self);
|
||||
|
||||
g_return_if_fail(session != NULL);
|
||||
g_return_if_fail(session != NULL);
|
||||
|
||||
g_value_init(&value, pspec->value_type);
|
||||
g_object_get_property(G_OBJECT(ctrl), pspec->name, &value);
|
||||
g_value_init(&value, pspec->value_type);
|
||||
g_object_get_property(G_OBJECT(ctrl), pspec->name, &value);
|
||||
|
||||
if (g_str_equal(pspec->name, "host") ||
|
||||
g_str_equal(pspec->name, "port") ||
|
||||
g_str_equal(pspec->name, "password") ||
|
||||
g_str_equal(pspec->name, "ca-file")) {
|
||||
g_object_set_property(G_OBJECT(session), pspec->name, &value);
|
||||
} else if (g_str_equal(pspec->name, "sport")) {
|
||||
g_object_set_property(G_OBJECT(session), "tls-port", &value);
|
||||
} else if (g_str_equal(pspec->name, "tls-ciphers")) {
|
||||
g_object_set_property(G_OBJECT(session), "ciphers", &value);
|
||||
} else if (g_str_equal(pspec->name, "host-subject")) {
|
||||
g_object_set_property(G_OBJECT(session), "cert-subject", &value);
|
||||
} else if (g_str_equal(pspec->name, "title")) {
|
||||
g_object_set_property(G_OBJECT(app), "title", &value);
|
||||
} else if (g_str_equal(pspec->name, "display-flags")) {
|
||||
guint flags = g_value_get_uint(&value);
|
||||
gboolean fullscreen = flags & CONTROLLER_SET_FULL_SCREEN;
|
||||
gboolean auto_res = flags & CONTROLLER_AUTO_DISPLAY_RES;
|
||||
g_object_set(G_OBJECT(self), "fullscreen", fullscreen, NULL);
|
||||
g_debug("unimplemented resize-guest %d", auto_res);
|
||||
/* g_object_set(G_OBJECT(self), "resize-guest", auto_res, NULL); */
|
||||
} else if (g_str_equal(pspec->name, "menu")) {
|
||||
spice_ctrl_menu_updated(self, g_value_get_object(&value));
|
||||
} else {
|
||||
gchar *content = g_strdup_value_contents(&value);
|
||||
if (g_str_equal(pspec->name, "host") ||
|
||||
g_str_equal(pspec->name, "port") ||
|
||||
g_str_equal(pspec->name, "password") ||
|
||||
g_str_equal(pspec->name, "ca-file")) {
|
||||
g_object_set_property(G_OBJECT(session), pspec->name, &value);
|
||||
} else if (g_str_equal(pspec->name, "sport")) {
|
||||
g_object_set_property(G_OBJECT(session), "tls-port", &value);
|
||||
} else if (g_str_equal(pspec->name, "tls-ciphers")) {
|
||||
g_object_set_property(G_OBJECT(session), "ciphers", &value);
|
||||
} else if (g_str_equal(pspec->name, "host-subject")) {
|
||||
g_object_set_property(G_OBJECT(session), "cert-subject", &value);
|
||||
} else if (g_str_equal(pspec->name, "title")) {
|
||||
g_object_set_property(G_OBJECT(app), "title", &value);
|
||||
} else if (g_str_equal(pspec->name, "display-flags")) {
|
||||
guint flags = g_value_get_uint(&value);
|
||||
gboolean fullscreen = flags & CONTROLLER_SET_FULL_SCREEN;
|
||||
gboolean auto_res = flags & CONTROLLER_AUTO_DISPLAY_RES;
|
||||
g_object_set(G_OBJECT(self), "fullscreen", fullscreen, NULL);
|
||||
g_debug("unimplemented resize-guest %d", auto_res);
|
||||
/* g_object_set(G_OBJECT(self), "resize-guest", auto_res, NULL); */
|
||||
} else if (g_str_equal(pspec->name, "menu")) {
|
||||
spice_ctrl_menu_updated(self, g_value_get_object(&value));
|
||||
} else {
|
||||
gchar *content = g_strdup_value_contents(&value);
|
||||
|
||||
g_debug("unimplemented property: %s=%s", pspec->name, content);
|
||||
g_free(content);
|
||||
}
|
||||
g_debug("unimplemented property: %s=%s", pspec->name, content);
|
||||
g_free(content);
|
||||
}
|
||||
|
||||
g_object_unref(session);
|
||||
g_value_unset(&value);
|
||||
g_object_unref(session);
|
||||
g_value_unset(&value);
|
||||
}
|
||||
|
||||
static void
|
||||
spice_ctrl_listen_async_cb(GObject *object,
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
spice_ctrl_controller_listen_finish(SPICE_CTRL_CONTROLLER(object), res, &error);
|
||||
spice_ctrl_controller_listen_finish(SPICE_CTRL_CONTROLLER(object), res, &error);
|
||||
|
||||
if (error != NULL) {
|
||||
virt_viewer_app_simple_message_dialog(VIRT_VIEWER_APP(user_data),
|
||||
_("Controller connection failed: %s"),
|
||||
error->message);
|
||||
g_clear_error(&error);
|
||||
exit(1); /* TODO: make start async? */
|
||||
}
|
||||
if (error != NULL) {
|
||||
virt_viewer_app_simple_message_dialog(VIRT_VIEWER_APP(user_data),
|
||||
_("Controller connection failed: %s"),
|
||||
error->message);
|
||||
g_clear_error(&error);
|
||||
exit(1); /* TODO: make start async? */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
remote_viewer_activate(VirtViewerApp *app)
|
||||
{
|
||||
g_return_val_if_fail(REMOTE_VIEWER_IS(app), -1);
|
||||
RemoteViewer *self = REMOTE_VIEWER(app);
|
||||
int ret = -1;
|
||||
g_return_val_if_fail(REMOTE_VIEWER_IS(app), -1);
|
||||
RemoteViewer *self = REMOTE_VIEWER(app);
|
||||
int ret = -1;
|
||||
|
||||
if (self->priv->controller) {
|
||||
SpiceSession *session = remote_viewer_get_spice_session(self);
|
||||
ret = spice_session_connect(session);
|
||||
g_object_unref(session);
|
||||
} else {
|
||||
ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->activate(app);
|
||||
}
|
||||
if (self->priv->controller) {
|
||||
SpiceSession *session = remote_viewer_get_spice_session(self);
|
||||
ret = spice_session_connect(session);
|
||||
g_object_unref(session);
|
||||
} else {
|
||||
ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->activate(app);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
remote_viewer_window_added(VirtViewerApp *self G_GNUC_UNUSED,
|
||||
VirtViewerWindow *win)
|
||||
VirtViewerWindow *win)
|
||||
{
|
||||
GtkMenuShell *shell = GTK_MENU_SHELL(gtk_builder_get_object(virt_viewer_window_get_builder(win), "top-menu"));
|
||||
GtkWidget *spice = gtk_menu_item_new_with_label("Spice");
|
||||
GtkMenuShell *shell = GTK_MENU_SHELL(gtk_builder_get_object(virt_viewer_window_get_builder(win), "top-menu"));
|
||||
GtkWidget *spice = gtk_menu_item_new_with_label("Spice");
|
||||
|
||||
gtk_menu_shell_append(shell, spice);
|
||||
g_object_set_data(G_OBJECT(win), "spice-menu", spice);
|
||||
gtk_menu_shell_append(shell, spice);
|
||||
g_object_set_data(G_OBJECT(win), "spice-menu", spice);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
remote_viewer_start(VirtViewerApp *app)
|
||||
{
|
||||
g_return_val_if_fail(REMOTE_VIEWER_IS(app), FALSE);
|
||||
g_return_val_if_fail(REMOTE_VIEWER_IS(app), FALSE);
|
||||
|
||||
#if HAVE_SPICE_GTK
|
||||
RemoteViewer *self = REMOTE_VIEWER(app);
|
||||
RemoteViewerPrivate *priv = self->priv;
|
||||
RemoteViewer *self = REMOTE_VIEWER(app);
|
||||
RemoteViewerPrivate *priv = self->priv;
|
||||
#endif
|
||||
gboolean ret = FALSE;
|
||||
gchar *guri = NULL;
|
||||
gchar *type = NULL;
|
||||
gboolean ret = FALSE;
|
||||
gchar *guri = NULL;
|
||||
gchar *type = NULL;
|
||||
|
||||
#if HAVE_SPICE_GTK
|
||||
if (priv->controller) {
|
||||
if (virt_viewer_app_create_session(app, "spice") < 0) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Couldn't create a Spice session"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (priv->controller) {
|
||||
if (virt_viewer_app_create_session(app, "spice") < 0) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Couldn't create a Spice session"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
g_signal_connect(priv->controller, "notify", G_CALLBACK(spice_ctrl_notified), self);
|
||||
g_signal_connect(priv->controller, "do_connect", G_CALLBACK(spice_ctrl_do_connect), self);
|
||||
g_signal_connect(priv->controller, "show", G_CALLBACK(spice_ctrl_show), self);
|
||||
g_signal_connect(priv->controller, "hide", G_CALLBACK(spice_ctrl_hide), self);
|
||||
g_signal_connect(priv->controller, "notify", G_CALLBACK(spice_ctrl_notified), self);
|
||||
g_signal_connect(priv->controller, "do_connect", G_CALLBACK(spice_ctrl_do_connect), self);
|
||||
g_signal_connect(priv->controller, "show", G_CALLBACK(spice_ctrl_show), self);
|
||||
g_signal_connect(priv->controller, "hide", G_CALLBACK(spice_ctrl_hide), self);
|
||||
|
||||
spice_ctrl_controller_listen(priv->controller, NULL, spice_ctrl_listen_async_cb, self);
|
||||
virt_viewer_app_show_status(VIRT_VIEWER_APP(self), _("Setting up Spice session..."));
|
||||
} else {
|
||||
spice_ctrl_controller_listen(priv->controller, NULL, spice_ctrl_listen_async_cb, self);
|
||||
virt_viewer_app_show_status(VIRT_VIEWER_APP(self), _("Setting up Spice session..."));
|
||||
} else {
|
||||
#endif
|
||||
g_object_get(app, "guri", &guri, NULL);
|
||||
g_return_val_if_fail(guri != NULL, FALSE);
|
||||
g_object_get(app, "guri", &guri, NULL);
|
||||
g_return_val_if_fail(guri != NULL, FALSE);
|
||||
|
||||
DEBUG_LOG("Opening display to %s", guri);
|
||||
g_object_set(app, "title", guri, NULL);
|
||||
DEBUG_LOG("Opening display to %s", guri);
|
||||
g_object_set(app, "title", guri, NULL);
|
||||
|
||||
if (virt_viewer_util_extract_host(guri, &type, NULL, NULL, NULL, NULL) < 0) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Cannot determine the connection type from URI"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (virt_viewer_util_extract_host(guri, &type, NULL, NULL, NULL, NULL) < 0) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Cannot determine the connection type from URI"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virt_viewer_app_create_session(app, type) < 0) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Couldn't create a session for this type: %s"), type);
|
||||
goto cleanup;
|
||||
}
|
||||
if (virt_viewer_app_create_session(app, type) < 0) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Couldn't create a session for this type: %s"), type);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virt_viewer_app_initial_connect(app) < 0) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Failed to initiate connection"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (virt_viewer_app_initial_connect(app) < 0) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Failed to initiate connection"));
|
||||
goto cleanup;
|
||||
}
|
||||
#if HAVE_SPICE_GTK
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->start(app);
|
||||
ret = VIRT_VIEWER_APP_CLASS(remote_viewer_parent_class)->start(app);
|
||||
|
||||
cleanup:
|
||||
g_free(guri);
|
||||
g_free(type);
|
||||
return ret;
|
||||
cleanup:
|
||||
g_free(guri);
|
||||
g_free(type);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -38,12 +38,12 @@ G_BEGIN_DECLS
|
||||
typedef struct _RemoteViewerPrivate RemoteViewerPrivate;
|
||||
|
||||
typedef struct {
|
||||
VirtViewerApp parent;
|
||||
RemoteViewerPrivate *priv;
|
||||
VirtViewerApp parent;
|
||||
RemoteViewerPrivate *priv;
|
||||
} RemoteViewer;
|
||||
|
||||
typedef struct {
|
||||
VirtViewerAppClass parent_class;
|
||||
VirtViewerAppClass parent_class;
|
||||
} RemoteViewerClass;
|
||||
|
||||
GType remote_viewer_get_type (void);
|
||||
@ -54,3 +54,10 @@ RemoteViewer* remote_viewer_new_with_controller(gboolean verbose);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* REMOTE_VIEWER_H */
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -257,7 +257,7 @@ ViewAutoDrawerUpdate(ViewAutoDrawer *that, // IN
|
||||
}
|
||||
#else
|
||||
if (window->group && window->group->grabs) {
|
||||
grabbed = GTK_WIDGET(window->group->grabs->data);
|
||||
grabbed = GTK_WIDGET(window->group->grabs->data);
|
||||
}
|
||||
#endif
|
||||
if (!grabbed) {
|
||||
@ -440,7 +440,7 @@ ViewAutoDrawerOnSetFocus(GtkWindow *window G_GNUC_UNUSED, // IN
|
||||
|
||||
static void
|
||||
ViewAutoDrawerOnHierarchyChanged(ViewAutoDrawer *that, // IN
|
||||
GtkWidget *oldToplevel) // IN
|
||||
GtkWidget *oldToplevel) // IN
|
||||
{
|
||||
GtkWidget *newToplevel = gtk_widget_get_toplevel(GTK_WIDGET(that));
|
||||
|
||||
@ -689,7 +689,7 @@ ViewAutoDrawer_GetType(void)
|
||||
sizeof (ViewAutoDrawer),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc)ViewAutoDrawerInit,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
type = g_type_register_static(VIEW_TYPE_DRAWER, "ViewAutoDrawer", &info, 0);
|
||||
|
@ -175,7 +175,7 @@ ViewDrawer_GetType(void)
|
||||
sizeof (ViewDrawer),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc)ViewDrawerInit,
|
||||
NULL
|
||||
NULL
|
||||
};
|
||||
|
||||
type = g_type_register_static(VIEW_TYPE_OV_BOX, "ViewDrawer", &info, 0);
|
||||
|
@ -76,9 +76,9 @@
|
||||
#include "ovBox.h"
|
||||
|
||||
#if ! GTK_CHECK_VERSION(3, 0, 0)
|
||||
#define gtk_widget_set_realized(widget, val) \
|
||||
#define gtk_widget_set_realized(widget, val) \
|
||||
GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED)
|
||||
#define gtk_widget_get_realized(widget) \
|
||||
#define gtk_widget_get_realized(widget) \
|
||||
GTK_WIDGET_REALIZED(widget)
|
||||
#endif
|
||||
|
||||
@ -763,7 +763,7 @@ ViewOvBox_GetType(void)
|
||||
sizeof (ViewOvBox),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc)ViewOvBoxInit,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
type = g_type_register_static(GTK_TYPE_BOX, "ViewOvBox", &info, 0);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -39,23 +39,23 @@ G_BEGIN_DECLS
|
||||
typedef struct _VirtViewerAppPrivate VirtViewerAppPrivate;
|
||||
|
||||
typedef struct {
|
||||
GObject parent;
|
||||
VirtViewerAppPrivate *priv;
|
||||
GObject parent;
|
||||
VirtViewerAppPrivate *priv;
|
||||
} VirtViewerApp;
|
||||
|
||||
typedef struct {
|
||||
GObjectClass parent_class;
|
||||
GObjectClass parent_class;
|
||||
|
||||
/* signals */
|
||||
void (*window_added) (VirtViewerApp *self, VirtViewerWindow *window);
|
||||
void (*window_removed) (VirtViewerApp *self, VirtViewerWindow *window);
|
||||
/* signals */
|
||||
void (*window_added) (VirtViewerApp *self, VirtViewerWindow *window);
|
||||
void (*window_removed) (VirtViewerApp *self, VirtViewerWindow *window);
|
||||
|
||||
/*< private >*/
|
||||
gboolean (*start) (VirtViewerApp *self);
|
||||
int (*initial_connect) (VirtViewerApp *self);
|
||||
int (*activate) (VirtViewerApp *self);
|
||||
void (*deactivated) (VirtViewerApp *self);
|
||||
gboolean (*open_connection)(VirtViewerApp *self, int *fd);
|
||||
/*< private >*/
|
||||
gboolean (*start) (VirtViewerApp *self);
|
||||
int (*initial_connect) (VirtViewerApp *self);
|
||||
int (*activate) (VirtViewerApp *self);
|
||||
void (*deactivated) (VirtViewerApp *self);
|
||||
gboolean (*open_connection)(VirtViewerApp *self, int *fd);
|
||||
} VirtViewerAppClass;
|
||||
|
||||
GType virt_viewer_app_get_type (void);
|
||||
@ -92,8 +92,15 @@ void virt_viewer_app_show_display(VirtViewerApp *self);
|
||||
GHashTable* virt_viewer_app_get_windows(VirtViewerApp *self);
|
||||
|
||||
void virt_viewer_app_usb_device_selection(VirtViewerApp *self,
|
||||
GtkWindow *parent);
|
||||
GtkWindow *parent);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* VIRT_VIEWER_APP_H */
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -34,142 +34,142 @@
|
||||
|
||||
int
|
||||
virt_viewer_auth_collect_credentials(const char *type,
|
||||
const char *address,
|
||||
char **username,
|
||||
char **password)
|
||||
const char *address,
|
||||
char **username,
|
||||
char **password)
|
||||
{
|
||||
GtkWidget *dialog = NULL;
|
||||
GtkBuilder *creds = virt_viewer_util_load_ui("virt-viewer-auth.xml");
|
||||
GtkWidget *credUsername;
|
||||
GtkWidget *credPassword;
|
||||
GtkWidget *promptUsername;
|
||||
GtkWidget *promptPassword;
|
||||
GtkWidget *labelMessage;
|
||||
int response;
|
||||
char *message;
|
||||
GtkWidget *dialog = NULL;
|
||||
GtkBuilder *creds = virt_viewer_util_load_ui("virt-viewer-auth.xml");
|
||||
GtkWidget *credUsername;
|
||||
GtkWidget *credPassword;
|
||||
GtkWidget *promptUsername;
|
||||
GtkWidget *promptPassword;
|
||||
GtkWidget *labelMessage;
|
||||
int response;
|
||||
char *message;
|
||||
|
||||
dialog = GTK_WIDGET(gtk_builder_get_object(creds, "auth"));
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
|
||||
dialog = GTK_WIDGET(gtk_builder_get_object(creds, "auth"));
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
|
||||
|
||||
labelMessage = GTK_WIDGET(gtk_builder_get_object(creds, "message"));
|
||||
credUsername = GTK_WIDGET(gtk_builder_get_object(creds, "cred-username"));
|
||||
promptUsername = GTK_WIDGET(gtk_builder_get_object(creds, "prompt-username"));
|
||||
credPassword = GTK_WIDGET(gtk_builder_get_object(creds, "cred-password"));
|
||||
promptPassword = GTK_WIDGET(gtk_builder_get_object(creds, "prompt-password"));
|
||||
labelMessage = GTK_WIDGET(gtk_builder_get_object(creds, "message"));
|
||||
credUsername = GTK_WIDGET(gtk_builder_get_object(creds, "cred-username"));
|
||||
promptUsername = GTK_WIDGET(gtk_builder_get_object(creds, "prompt-username"));
|
||||
credPassword = GTK_WIDGET(gtk_builder_get_object(creds, "cred-password"));
|
||||
promptPassword = GTK_WIDGET(gtk_builder_get_object(creds, "prompt-password"));
|
||||
|
||||
gtk_widget_set_sensitive(credUsername, username != NULL);
|
||||
gtk_widget_set_sensitive(promptUsername, username != NULL);
|
||||
gtk_widget_set_sensitive(credPassword, password != NULL);
|
||||
gtk_widget_set_sensitive(promptPassword, password != NULL);
|
||||
gtk_widget_set_sensitive(credUsername, username != NULL);
|
||||
gtk_widget_set_sensitive(promptUsername, username != NULL);
|
||||
gtk_widget_set_sensitive(credPassword, password != NULL);
|
||||
gtk_widget_set_sensitive(promptPassword, password != NULL);
|
||||
|
||||
if (address) {
|
||||
message = g_strdup_printf("Authentication is required for the %s connection to:\n\n"
|
||||
"<b>%s</b>\n\n",
|
||||
type,
|
||||
address);
|
||||
} else {
|
||||
message = g_strdup_printf("Authentication is required for the %s connection:\n",
|
||||
type);
|
||||
}
|
||||
if (address) {
|
||||
message = g_strdup_printf("Authentication is required for the %s connection to:\n\n"
|
||||
"<b>%s</b>\n\n",
|
||||
type,
|
||||
address);
|
||||
} else {
|
||||
message = g_strdup_printf("Authentication is required for the %s connection:\n",
|
||||
type);
|
||||
}
|
||||
|
||||
gtk_label_set_markup(GTK_LABEL(labelMessage), message);
|
||||
g_free(message);
|
||||
gtk_label_set_markup(GTK_LABEL(labelMessage), message);
|
||||
g_free(message);
|
||||
|
||||
gtk_widget_show_all(dialog);
|
||||
response = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
gtk_widget_hide(dialog);
|
||||
gtk_widget_show_all(dialog);
|
||||
response = gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
gtk_widget_hide(dialog);
|
||||
|
||||
if (response == GTK_RESPONSE_OK) {
|
||||
if (username)
|
||||
*username = g_strdup(gtk_entry_get_text(GTK_ENTRY(credUsername)));
|
||||
if (password)
|
||||
*password = g_strdup(gtk_entry_get_text(GTK_ENTRY(credPassword)));
|
||||
}
|
||||
if (response == GTK_RESPONSE_OK) {
|
||||
if (username)
|
||||
*username = g_strdup(gtk_entry_get_text(GTK_ENTRY(credUsername)));
|
||||
if (password)
|
||||
*password = g_strdup(gtk_entry_get_text(GTK_ENTRY(credPassword)));
|
||||
}
|
||||
|
||||
gtk_widget_destroy(GTK_WIDGET(dialog));
|
||||
gtk_widget_destroy(GTK_WIDGET(dialog));
|
||||
|
||||
return response == GTK_RESPONSE_OK ? 0 : -1;
|
||||
return response == GTK_RESPONSE_OK ? 0 : -1;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GTK_VNC
|
||||
void
|
||||
virt_viewer_auth_vnc_credentials(GtkWidget *vnc,
|
||||
GValueArray *credList,
|
||||
char **vncAddress)
|
||||
GValueArray *credList,
|
||||
char **vncAddress)
|
||||
{
|
||||
char *username = NULL, *password = NULL;
|
||||
gboolean wantPassword = FALSE, wantUsername = FALSE;
|
||||
int i;
|
||||
char *username = NULL, *password = NULL;
|
||||
gboolean wantPassword = FALSE, wantUsername = FALSE;
|
||||
int i;
|
||||
|
||||
DEBUG_LOG("Got VNC credential request for %d credential(s)", credList->n_values);
|
||||
DEBUG_LOG("Got VNC credential request for %d credential(s)", credList->n_values);
|
||||
|
||||
for (i = 0 ; i < credList->n_values ; i++) {
|
||||
GValue *cred = g_value_array_get_nth(credList, i);
|
||||
switch (g_value_get_enum(cred)) {
|
||||
case VNC_DISPLAY_CREDENTIAL_USERNAME:
|
||||
wantUsername = TRUE;
|
||||
break;
|
||||
case VNC_DISPLAY_CREDENTIAL_PASSWORD:
|
||||
wantPassword = TRUE;
|
||||
break;
|
||||
case VNC_DISPLAY_CREDENTIAL_CLIENTNAME:
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG("Unsupported credential type %d", g_value_get_enum(cred));
|
||||
vnc_display_close(VNC_DISPLAY(vnc));
|
||||
goto cleanup;
|
||||
}
|
||||
for (i = 0 ; i < credList->n_values ; i++) {
|
||||
GValue *cred = g_value_array_get_nth(credList, i);
|
||||
switch (g_value_get_enum(cred)) {
|
||||
case VNC_DISPLAY_CREDENTIAL_USERNAME:
|
||||
wantUsername = TRUE;
|
||||
break;
|
||||
case VNC_DISPLAY_CREDENTIAL_PASSWORD:
|
||||
wantPassword = TRUE;
|
||||
break;
|
||||
case VNC_DISPLAY_CREDENTIAL_CLIENTNAME:
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG("Unsupported credential type %d", g_value_get_enum(cred));
|
||||
vnc_display_close(VNC_DISPLAY(vnc));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
if (wantUsername || wantPassword) {
|
||||
int ret = virt_viewer_auth_collect_credentials("VNC", vncAddress ? *vncAddress : NULL,
|
||||
wantUsername ? &username : NULL,
|
||||
wantPassword ? &password : NULL);
|
||||
if (wantUsername || wantPassword) {
|
||||
int ret = virt_viewer_auth_collect_credentials("VNC", vncAddress ? *vncAddress : NULL,
|
||||
wantUsername ? &username : NULL,
|
||||
wantPassword ? &password : NULL);
|
||||
|
||||
if (ret < 0) {
|
||||
vnc_display_close(VNC_DISPLAY(vnc));
|
||||
goto cleanup;
|
||||
}
|
||||
if (ret < 0) {
|
||||
vnc_display_close(VNC_DISPLAY(vnc));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0 ; i < credList->n_values ; i++) {
|
||||
GValue *cred = g_value_array_get_nth(credList, i);
|
||||
switch (g_value_get_enum(cred)) {
|
||||
case VNC_DISPLAY_CREDENTIAL_USERNAME:
|
||||
if (!username ||
|
||||
vnc_display_set_credential(VNC_DISPLAY(vnc),
|
||||
g_value_get_enum(cred),
|
||||
username)) {
|
||||
DEBUG_LOG("Failed to set credential type %d", g_value_get_enum(cred));
|
||||
vnc_display_close(VNC_DISPLAY(vnc));
|
||||
}
|
||||
break;
|
||||
case VNC_DISPLAY_CREDENTIAL_PASSWORD:
|
||||
if (!password ||
|
||||
vnc_display_set_credential(VNC_DISPLAY(vnc),
|
||||
g_value_get_enum(cred),
|
||||
password)) {
|
||||
DEBUG_LOG("Failed to set credential type %d", g_value_get_enum(cred));
|
||||
vnc_display_close(VNC_DISPLAY(vnc));
|
||||
}
|
||||
break;
|
||||
case VNC_DISPLAY_CREDENTIAL_CLIENTNAME:
|
||||
if (vnc_display_set_credential(VNC_DISPLAY(vnc),
|
||||
g_value_get_enum(cred),
|
||||
"libvirt")) {
|
||||
DEBUG_LOG("Failed to set credential type %d", g_value_get_enum(cred));
|
||||
vnc_display_close(VNC_DISPLAY(vnc));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG("Unsupported credential type %d", g_value_get_enum(cred));
|
||||
vnc_display_close(VNC_DISPLAY(vnc));
|
||||
}
|
||||
for (i = 0 ; i < credList->n_values ; i++) {
|
||||
GValue *cred = g_value_array_get_nth(credList, i);
|
||||
switch (g_value_get_enum(cred)) {
|
||||
case VNC_DISPLAY_CREDENTIAL_USERNAME:
|
||||
if (!username ||
|
||||
vnc_display_set_credential(VNC_DISPLAY(vnc),
|
||||
g_value_get_enum(cred),
|
||||
username)) {
|
||||
DEBUG_LOG("Failed to set credential type %d", g_value_get_enum(cred));
|
||||
vnc_display_close(VNC_DISPLAY(vnc));
|
||||
}
|
||||
break;
|
||||
case VNC_DISPLAY_CREDENTIAL_PASSWORD:
|
||||
if (!password ||
|
||||
vnc_display_set_credential(VNC_DISPLAY(vnc),
|
||||
g_value_get_enum(cred),
|
||||
password)) {
|
||||
DEBUG_LOG("Failed to set credential type %d", g_value_get_enum(cred));
|
||||
vnc_display_close(VNC_DISPLAY(vnc));
|
||||
}
|
||||
break;
|
||||
case VNC_DISPLAY_CREDENTIAL_CLIENTNAME:
|
||||
if (vnc_display_set_credential(VNC_DISPLAY(vnc),
|
||||
g_value_get_enum(cred),
|
||||
"libvirt")) {
|
||||
DEBUG_LOG("Failed to set credential type %d", g_value_get_enum(cred));
|
||||
vnc_display_close(VNC_DISPLAY(vnc));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG("Unsupported credential type %d", g_value_get_enum(cred));
|
||||
vnc_display_close(VNC_DISPLAY(vnc));
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
g_free(username);
|
||||
g_free(password);
|
||||
g_free(username);
|
||||
g_free(password);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -177,66 +177,64 @@ virt_viewer_auth_vnc_credentials(GtkWidget *vnc,
|
||||
#ifdef HAVE_LIBVIRT
|
||||
int
|
||||
virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
|
||||
unsigned int ncred,
|
||||
void *cbdata)
|
||||
unsigned int ncred,
|
||||
void *cbdata)
|
||||
{
|
||||
char **username = NULL, **password = NULL;
|
||||
const char *uri = cbdata;
|
||||
int i;
|
||||
int ret = -1;
|
||||
char **username = NULL, **password = NULL;
|
||||
const char *uri = cbdata;
|
||||
int i;
|
||||
int ret = -1;
|
||||
|
||||
DEBUG_LOG("Got libvirt credential request for %d credential(s)", ncred);
|
||||
DEBUG_LOG("Got libvirt credential request for %d credential(s)", ncred);
|
||||
|
||||
for (i = 0 ; i < ncred ; i++) {
|
||||
switch (cred[i].type) {
|
||||
case VIR_CRED_USERNAME:
|
||||
case VIR_CRED_AUTHNAME:
|
||||
username = &cred[i].result;
|
||||
break;
|
||||
case VIR_CRED_PASSPHRASE:
|
||||
password = &cred[i].result;
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG("Unsupported libvirt credential %d", cred[i].type);
|
||||
return -1;
|
||||
}
|
||||
for (i = 0 ; i < ncred ; i++) {
|
||||
switch (cred[i].type) {
|
||||
case VIR_CRED_USERNAME:
|
||||
case VIR_CRED_AUTHNAME:
|
||||
username = &cred[i].result;
|
||||
break;
|
||||
case VIR_CRED_PASSPHRASE:
|
||||
password = &cred[i].result;
|
||||
break;
|
||||
default:
|
||||
DEBUG_LOG("Unsupported libvirt credential %d", cred[i].type);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (username || password) {
|
||||
ret = virt_viewer_auth_collect_credentials("libvirt", uri,
|
||||
username, password);
|
||||
if (ret < 0)
|
||||
goto cleanup;
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
if (username || password) {
|
||||
ret = virt_viewer_auth_collect_credentials("libvirt", uri,
|
||||
username, password);
|
||||
if (ret < 0)
|
||||
goto cleanup;
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < ncred ; i++) {
|
||||
switch (cred[i].type) {
|
||||
case VIR_CRED_AUTHNAME:
|
||||
case VIR_CRED_USERNAME:
|
||||
case VIR_CRED_PASSPHRASE:
|
||||
if (cred[i].result)
|
||||
cred[i].resultlen = strlen(cred[i].result);
|
||||
else
|
||||
cred[i].resultlen = 0;
|
||||
DEBUG_LOG("Got '%s' %d %d", cred[i].result, cred[i].resultlen, cred[i].type);
|
||||
break;
|
||||
}
|
||||
for (i = 0 ; i < ncred ; i++) {
|
||||
switch (cred[i].type) {
|
||||
case VIR_CRED_AUTHNAME:
|
||||
case VIR_CRED_USERNAME:
|
||||
case VIR_CRED_PASSPHRASE:
|
||||
if (cred[i].result)
|
||||
cred[i].resultlen = strlen(cred[i].result);
|
||||
else
|
||||
cred[i].resultlen = 0;
|
||||
DEBUG_LOG("Got '%s' %d %d", cred[i].result, cred[i].resultlen, cred[i].type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
DEBUG_LOG("Return %d", ret);
|
||||
return ret;
|
||||
DEBUG_LOG("Return %d", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -32,18 +32,25 @@
|
||||
#include "virt-viewer-util.h"
|
||||
|
||||
void virt_viewer_auth_vnc_credentials(GtkWidget *vnc,
|
||||
GValueArray *credList,
|
||||
char **message);
|
||||
GValueArray *credList,
|
||||
char **message);
|
||||
|
||||
int virt_viewer_auth_collect_credentials(const char *type,
|
||||
const char *address,
|
||||
char **username,
|
||||
char **password);
|
||||
const char *address,
|
||||
char **username,
|
||||
char **password);
|
||||
|
||||
#ifdef HAVE_LIBVIRT
|
||||
int virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
|
||||
unsigned int ncred,
|
||||
void *cbdata);
|
||||
unsigned int ncred,
|
||||
void *cbdata);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -33,171 +33,170 @@
|
||||
G_DEFINE_TYPE (VirtViewerDisplaySpice, virt_viewer_display_spice, VIRT_VIEWER_TYPE_DISPLAY)
|
||||
|
||||
struct _VirtViewerDisplaySpicePrivate {
|
||||
SpiceChannel *channel;
|
||||
SpiceDisplay *display;
|
||||
SpiceChannel *channel;
|
||||
SpiceDisplay *display;
|
||||
};
|
||||
|
||||
#define VIRT_VIEWER_DISPLAY_SPICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_DISPLAY_SPICE, VirtViewerDisplaySpicePrivate))
|
||||
|
||||
static void virt_viewer_display_spice_send_keys(VirtViewerDisplay *display,
|
||||
const guint *keyvals,
|
||||
int nkeyvals);
|
||||
const guint *keyvals,
|
||||
int nkeyvals);
|
||||
static GdkPixbuf *virt_viewer_display_spice_get_pixbuf(VirtViewerDisplay *display);
|
||||
|
||||
static void
|
||||
virt_viewer_display_spice_finalize(GObject *obj)
|
||||
{
|
||||
VirtViewerDisplaySpice *spice = VIRT_VIEWER_DISPLAY_SPICE(obj);
|
||||
VirtViewerDisplaySpice *spice = VIRT_VIEWER_DISPLAY_SPICE(obj);
|
||||
|
||||
g_object_unref(spice->priv->display);
|
||||
g_object_unref(spice->priv->channel);
|
||||
g_object_unref(spice->priv->display);
|
||||
g_object_unref(spice->priv->channel);
|
||||
|
||||
G_OBJECT_CLASS(virt_viewer_display_spice_parent_class)->finalize(obj);
|
||||
G_OBJECT_CLASS(virt_viewer_display_spice_parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_display_spice_class_init(VirtViewerDisplaySpiceClass *klass)
|
||||
{
|
||||
VirtViewerDisplayClass *dclass = VIRT_VIEWER_DISPLAY_CLASS(klass);
|
||||
GObjectClass *oclass = G_OBJECT_CLASS(klass);
|
||||
VirtViewerDisplayClass *dclass = VIRT_VIEWER_DISPLAY_CLASS(klass);
|
||||
GObjectClass *oclass = G_OBJECT_CLASS(klass);
|
||||
|
||||
oclass->finalize = virt_viewer_display_spice_finalize;
|
||||
oclass->finalize = virt_viewer_display_spice_finalize;
|
||||
|
||||
dclass->send_keys = virt_viewer_display_spice_send_keys;
|
||||
dclass->get_pixbuf = virt_viewer_display_spice_get_pixbuf;
|
||||
dclass->send_keys = virt_viewer_display_spice_send_keys;
|
||||
dclass->get_pixbuf = virt_viewer_display_spice_get_pixbuf;
|
||||
|
||||
g_type_class_add_private(klass, sizeof(VirtViewerDisplaySpicePrivate));
|
||||
g_type_class_add_private(klass, sizeof(VirtViewerDisplaySpicePrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_display_spice_init(VirtViewerDisplaySpice *self G_GNUC_UNUSED)
|
||||
{
|
||||
self->priv = VIRT_VIEWER_DISPLAY_SPICE_GET_PRIVATE(self);
|
||||
self->priv = VIRT_VIEWER_DISPLAY_SPICE_GET_PRIVATE(self);
|
||||
|
||||
virt_viewer_display_set_maintain_aspect_ratio(VIRT_VIEWER_DISPLAY(self), FALSE);
|
||||
virt_viewer_display_set_maintain_aspect_ratio(VIRT_VIEWER_DISPLAY(self), FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_display_spice_send_keys(VirtViewerDisplay *display,
|
||||
const guint *keyvals,
|
||||
int nkeyvals)
|
||||
const guint *keyvals,
|
||||
int nkeyvals)
|
||||
{
|
||||
VirtViewerDisplaySpice *self = VIRT_VIEWER_DISPLAY_SPICE(display);
|
||||
VirtViewerDisplaySpice *self = VIRT_VIEWER_DISPLAY_SPICE(display);
|
||||
|
||||
g_return_if_fail(self != NULL);
|
||||
g_return_if_fail(self->priv->display != NULL);
|
||||
g_return_if_fail(self != NULL);
|
||||
g_return_if_fail(self->priv->display != NULL);
|
||||
|
||||
spice_display_send_keys(self->priv->display, keyvals, nkeyvals, SPICE_DISPLAY_KEY_EVENT_CLICK);
|
||||
spice_display_send_keys(self->priv->display, keyvals, nkeyvals, SPICE_DISPLAY_KEY_EVENT_CLICK);
|
||||
}
|
||||
|
||||
static GdkPixbuf *
|
||||
virt_viewer_display_spice_get_pixbuf(VirtViewerDisplay *display)
|
||||
{
|
||||
VirtViewerDisplaySpice *self = VIRT_VIEWER_DISPLAY_SPICE(display);
|
||||
VirtViewerDisplaySpice *self = VIRT_VIEWER_DISPLAY_SPICE(display);
|
||||
|
||||
g_return_val_if_fail(self != NULL, NULL);
|
||||
g_return_val_if_fail(self->priv->display != NULL, NULL);
|
||||
g_return_val_if_fail(self != NULL, NULL);
|
||||
g_return_val_if_fail(self->priv->display != NULL, NULL);
|
||||
|
||||
return spice_display_get_pixbuf(self->priv->display);
|
||||
return spice_display_get_pixbuf(self->priv->display);
|
||||
}
|
||||
|
||||
static void
|
||||
display_mark(SpiceChannel *channel G_GNUC_UNUSED,
|
||||
gint mark,
|
||||
VirtViewerDisplay *display)
|
||||
gint mark,
|
||||
VirtViewerDisplay *display)
|
||||
{
|
||||
DEBUG_LOG("display mark %d", mark);
|
||||
DEBUG_LOG("display mark %d", mark);
|
||||
|
||||
virt_viewer_display_set_show_hint(display, mark);
|
||||
virt_viewer_display_set_show_hint(display, mark);
|
||||
}
|
||||
|
||||
static void
|
||||
primary_create(SpiceChannel *channel G_GNUC_UNUSED,
|
||||
gint format G_GNUC_UNUSED,
|
||||
gint width,
|
||||
gint height,
|
||||
gint stride G_GNUC_UNUSED,
|
||||
gint shmid G_GNUC_UNUSED,
|
||||
gpointer imgdata G_GNUC_UNUSED,
|
||||
VirtViewerDisplay *display)
|
||||
gint format G_GNUC_UNUSED,
|
||||
gint width,
|
||||
gint height,
|
||||
gint stride G_GNUC_UNUSED,
|
||||
gint shmid G_GNUC_UNUSED,
|
||||
gpointer imgdata G_GNUC_UNUSED,
|
||||
VirtViewerDisplay *display)
|
||||
{
|
||||
DEBUG_LOG("spice desktop resize %dx%d", width, height);
|
||||
DEBUG_LOG("spice desktop resize %dx%d", width, height);
|
||||
|
||||
virt_viewer_display_set_desktop_size(display, width, height);
|
||||
virt_viewer_display_set_desktop_size(display, width, height);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virt_viewer_display_spice_keyboard_grab(SpiceDisplay *display G_GNUC_UNUSED,
|
||||
int grabbed,
|
||||
VirtViewerDisplaySpice *self)
|
||||
int grabbed,
|
||||
VirtViewerDisplaySpice *self)
|
||||
{
|
||||
if (grabbed)
|
||||
g_signal_emit_by_name(self, "display-keyboard-grab");
|
||||
else
|
||||
g_signal_emit_by_name(self, "display-keyboard-ungrab");
|
||||
if (grabbed)
|
||||
g_signal_emit_by_name(self, "display-keyboard-grab");
|
||||
else
|
||||
g_signal_emit_by_name(self, "display-keyboard-ungrab");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virt_viewer_display_spice_mouse_grab(SpiceDisplay *display G_GNUC_UNUSED,
|
||||
int grabbed,
|
||||
VirtViewerDisplaySpice *self)
|
||||
int grabbed,
|
||||
VirtViewerDisplaySpice *self)
|
||||
{
|
||||
if (grabbed)
|
||||
g_signal_emit_by_name(self, "display-pointer-grab");
|
||||
else
|
||||
g_signal_emit_by_name(self, "display-pointer-ungrab");
|
||||
if (grabbed)
|
||||
g_signal_emit_by_name(self, "display-pointer-grab");
|
||||
else
|
||||
g_signal_emit_by_name(self, "display-pointer-ungrab");
|
||||
}
|
||||
|
||||
|
||||
GtkWidget *
|
||||
virt_viewer_display_spice_new(SpiceChannel *channel,
|
||||
SpiceDisplay *display)
|
||||
SpiceDisplay *display)
|
||||
{
|
||||
VirtViewerDisplaySpice *self;
|
||||
gint channelid;
|
||||
VirtViewerDisplaySpice *self;
|
||||
gint channelid;
|
||||
|
||||
g_return_val_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel), NULL);
|
||||
g_return_val_if_fail(SPICE_IS_DISPLAY(display), NULL);
|
||||
g_return_val_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel), NULL);
|
||||
g_return_val_if_fail(SPICE_IS_DISPLAY(display), NULL);
|
||||
|
||||
g_object_get(channel, "channel-id", &channelid, NULL);
|
||||
g_object_get(channel, "channel-id", &channelid, NULL);
|
||||
|
||||
self = g_object_new(VIRT_VIEWER_TYPE_DISPLAY_SPICE,
|
||||
"nth-display", channelid,
|
||||
NULL);
|
||||
self->priv->channel = g_object_ref(channel);
|
||||
self->priv->display = g_object_ref(display);
|
||||
self = g_object_new(VIRT_VIEWER_TYPE_DISPLAY_SPICE,
|
||||
"nth-display", channelid,
|
||||
NULL);
|
||||
self->priv->channel = g_object_ref(channel);
|
||||
self->priv->display = g_object_ref(display);
|
||||
|
||||
g_signal_connect(channel, "display-primary-create",
|
||||
G_CALLBACK(primary_create), self);
|
||||
g_signal_connect(channel, "display-mark",
|
||||
G_CALLBACK(display_mark), self);
|
||||
g_signal_connect(channel, "display-primary-create",
|
||||
G_CALLBACK(primary_create), self);
|
||||
g_signal_connect(channel, "display-mark",
|
||||
G_CALLBACK(display_mark), self);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(self->priv->display));
|
||||
gtk_widget_show(GTK_WIDGET(self->priv->display));
|
||||
g_object_set(self->priv->display,
|
||||
"grab-keyboard", TRUE,
|
||||
"grab-mouse", TRUE,
|
||||
"scaling", TRUE,
|
||||
"resize-guest", TRUE,
|
||||
NULL);
|
||||
gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(self->priv->display));
|
||||
gtk_widget_show(GTK_WIDGET(self->priv->display));
|
||||
g_object_set(self->priv->display,
|
||||
"grab-keyboard", TRUE,
|
||||
"grab-mouse", TRUE,
|
||||
"scaling", TRUE,
|
||||
"resize-guest", TRUE,
|
||||
NULL);
|
||||
|
||||
g_signal_connect(self->priv->display,
|
||||
"keyboard-grab",
|
||||
G_CALLBACK(virt_viewer_display_spice_keyboard_grab), self);
|
||||
g_signal_connect(self->priv->display,
|
||||
"mouse-grab",
|
||||
G_CALLBACK(virt_viewer_display_spice_mouse_grab), self);
|
||||
g_signal_connect(self->priv->display,
|
||||
"keyboard-grab",
|
||||
G_CALLBACK(virt_viewer_display_spice_keyboard_grab), self);
|
||||
g_signal_connect(self->priv->display,
|
||||
"mouse-grab",
|
||||
G_CALLBACK(virt_viewer_display_spice_mouse_grab), self);
|
||||
|
||||
return GTK_WIDGET(self);
|
||||
return GTK_WIDGET(self);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -34,48 +34,47 @@ G_BEGIN_DECLS
|
||||
|
||||
#define VIRT_VIEWER_TYPE_DISPLAY_SPICE virt_viewer_display_spice_get_type()
|
||||
|
||||
#define VIRT_VIEWER_DISPLAY_SPICE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_DISPLAY_SPICE, VirtViewerDisplaySpice))
|
||||
#define VIRT_VIEWER_DISPLAY_SPICE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_DISPLAY_SPICE, VirtViewerDisplaySpice))
|
||||
|
||||
#define VIRT_VIEWER_DISPLAY_SPICE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_DISPLAY_SPICE, VirtViewerDisplaySpiceClass))
|
||||
#define VIRT_VIEWER_DISPLAY_SPICE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_DISPLAY_SPICE, VirtViewerDisplaySpiceClass))
|
||||
|
||||
#define VIRT_VIEWER_IS_DISPLAY_SPICE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_DISPLAY_SPICE))
|
||||
#define VIRT_VIEWER_IS_DISPLAY_SPICE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_DISPLAY_SPICE))
|
||||
|
||||
#define VIRT_VIEWER_IS_DISPLAY_SPICE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_DISPLAY_SPICE))
|
||||
#define VIRT_VIEWER_IS_DISPLAY_SPICE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_DISPLAY_SPICE))
|
||||
|
||||
#define VIRT_VIEWER_DISPLAY_SPICE_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_DISPLAY_SPICE, VirtViewerDisplaySpiceClass))
|
||||
#define VIRT_VIEWER_DISPLAY_SPICE_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_DISPLAY_SPICE, VirtViewerDisplaySpiceClass))
|
||||
|
||||
typedef struct _VirtViewerDisplaySpice VirtViewerDisplaySpice;
|
||||
typedef struct _VirtViewerDisplaySpiceClass VirtViewerDisplaySpiceClass;
|
||||
typedef struct _VirtViewerDisplaySpicePrivate VirtViewerDisplaySpicePrivate;
|
||||
|
||||
struct _VirtViewerDisplaySpice {
|
||||
VirtViewerDisplay parent;
|
||||
VirtViewerDisplay parent;
|
||||
|
||||
VirtViewerDisplaySpicePrivate *priv;
|
||||
VirtViewerDisplaySpicePrivate *priv;
|
||||
};
|
||||
|
||||
struct _VirtViewerDisplaySpiceClass {
|
||||
VirtViewerDisplayClass parent_class;
|
||||
VirtViewerDisplayClass parent_class;
|
||||
};
|
||||
|
||||
GType virt_viewer_display_spice_get_type(void);
|
||||
|
||||
GtkWidget* virt_viewer_display_spice_new(SpiceChannel *channel,
|
||||
SpiceDisplay *display);
|
||||
SpiceDisplay *display);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _VIRT_VIEWER_DISPLAY_SPICE_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -30,7 +30,7 @@
|
||||
G_DEFINE_TYPE(VirtViewerDisplayVnc, virt_viewer_display_vnc, VIRT_VIEWER_TYPE_DISPLAY)
|
||||
|
||||
struct _VirtViewerDisplayVncPrivate {
|
||||
VncDisplay *vnc;
|
||||
VncDisplay *vnc;
|
||||
};
|
||||
|
||||
#define VIRT_VIEWER_DISPLAY_VNC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_DISPLAY_VNC, VirtViewerDisplayVncPrivate))
|
||||
@ -41,88 +41,88 @@ static GdkPixbuf *virt_viewer_display_vnc_get_pixbuf(VirtViewerDisplay* display)
|
||||
static void
|
||||
virt_viewer_display_vnc_finalize(GObject *obj)
|
||||
{
|
||||
VirtViewerDisplayVnc *vnc = VIRT_VIEWER_DISPLAY_VNC(obj);
|
||||
VirtViewerDisplayVnc *vnc = VIRT_VIEWER_DISPLAY_VNC(obj);
|
||||
|
||||
g_object_unref(vnc->priv->vnc);
|
||||
g_object_unref(vnc->priv->vnc);
|
||||
|
||||
G_OBJECT_CLASS(virt_viewer_display_vnc_parent_class)->finalize(obj);
|
||||
G_OBJECT_CLASS(virt_viewer_display_vnc_parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virt_viewer_display_vnc_class_init(VirtViewerDisplayVncClass *klass)
|
||||
{
|
||||
VirtViewerDisplayClass *dclass = VIRT_VIEWER_DISPLAY_CLASS(klass);
|
||||
GObjectClass *oclass = G_OBJECT_CLASS(klass);
|
||||
VirtViewerDisplayClass *dclass = VIRT_VIEWER_DISPLAY_CLASS(klass);
|
||||
GObjectClass *oclass = G_OBJECT_CLASS(klass);
|
||||
|
||||
oclass->finalize = virt_viewer_display_vnc_finalize;
|
||||
oclass->finalize = virt_viewer_display_vnc_finalize;
|
||||
|
||||
dclass->send_keys = virt_viewer_display_vnc_send_keys;
|
||||
dclass->get_pixbuf = virt_viewer_display_vnc_get_pixbuf;
|
||||
dclass->send_keys = virt_viewer_display_vnc_send_keys;
|
||||
dclass->get_pixbuf = virt_viewer_display_vnc_get_pixbuf;
|
||||
|
||||
g_type_class_add_private(klass, sizeof(VirtViewerDisplayVncPrivate));
|
||||
g_type_class_add_private(klass, sizeof(VirtViewerDisplayVncPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_display_vnc_init(VirtViewerDisplayVnc *self G_GNUC_UNUSED)
|
||||
{
|
||||
self->priv = VIRT_VIEWER_DISPLAY_VNC_GET_PRIVATE(self);
|
||||
self->priv = VIRT_VIEWER_DISPLAY_VNC_GET_PRIVATE(self);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virt_viewer_display_vnc_mouse_grab(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
VirtViewerDisplay *display)
|
||||
VirtViewerDisplay *display)
|
||||
{
|
||||
g_signal_emit_by_name(display, "display-pointer-grab");
|
||||
g_signal_emit_by_name(display, "display-pointer-grab");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virt_viewer_display_vnc_mouse_ungrab(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
VirtViewerDisplay *display)
|
||||
VirtViewerDisplay *display)
|
||||
{
|
||||
g_signal_emit_by_name(display, "display-pointer-ungrab");
|
||||
g_signal_emit_by_name(display, "display-pointer-ungrab");
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_display_vnc_key_grab(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
VirtViewerDisplay *display)
|
||||
VirtViewerDisplay *display)
|
||||
{
|
||||
g_signal_emit_by_name(display, "display-keyboard-grab");
|
||||
g_signal_emit_by_name(display, "display-keyboard-grab");
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_display_vnc_key_ungrab(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
VirtViewerDisplay *display)
|
||||
VirtViewerDisplay *display)
|
||||
{
|
||||
g_signal_emit_by_name(display, "display-keyboard-ungrab");
|
||||
g_signal_emit_by_name(display, "display-keyboard-ungrab");
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_display_vnc_send_keys(VirtViewerDisplay* display,
|
||||
const guint *keyvals,
|
||||
int nkeyvals)
|
||||
const guint *keyvals,
|
||||
int nkeyvals)
|
||||
{
|
||||
VirtViewerDisplayVnc *self = VIRT_VIEWER_DISPLAY_VNC(display);
|
||||
VirtViewerDisplayVnc *self = VIRT_VIEWER_DISPLAY_VNC(display);
|
||||
|
||||
g_return_if_fail(self != NULL);
|
||||
g_return_if_fail(keyvals != NULL);
|
||||
g_return_if_fail(self->priv->vnc != NULL);
|
||||
g_return_if_fail(self != NULL);
|
||||
g_return_if_fail(keyvals != NULL);
|
||||
g_return_if_fail(self->priv->vnc != NULL);
|
||||
|
||||
vnc_display_send_keys(self->priv->vnc, keyvals, nkeyvals);
|
||||
vnc_display_send_keys(self->priv->vnc, keyvals, nkeyvals);
|
||||
}
|
||||
|
||||
|
||||
static GdkPixbuf *
|
||||
virt_viewer_display_vnc_get_pixbuf(VirtViewerDisplay* display)
|
||||
{
|
||||
VirtViewerDisplayVnc *self = VIRT_VIEWER_DISPLAY_VNC(display);
|
||||
VirtViewerDisplayVnc *self = VIRT_VIEWER_DISPLAY_VNC(display);
|
||||
|
||||
g_return_val_if_fail(self != NULL, NULL);
|
||||
g_return_val_if_fail(self->priv->vnc != NULL, NULL);
|
||||
g_return_val_if_fail(self != NULL, NULL);
|
||||
g_return_val_if_fail(self->priv->vnc != NULL, NULL);
|
||||
|
||||
return vnc_display_get_pixbuf(self->priv->vnc);
|
||||
return vnc_display_get_pixbuf(self->priv->vnc);
|
||||
}
|
||||
|
||||
|
||||
@ -134,65 +134,62 @@ virt_viewer_display_vnc_get_pixbuf(VirtViewerDisplay* display)
|
||||
*/
|
||||
static void
|
||||
virt_viewer_display_vnc_resize_desktop(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
int width, int height,
|
||||
VirtViewerDisplay *display)
|
||||
int width, int height,
|
||||
VirtViewerDisplay *display)
|
||||
{
|
||||
DEBUG_LOG("desktop resize %dx%d", width, height);
|
||||
DEBUG_LOG("desktop resize %dx%d", width, height);
|
||||
|
||||
virt_viewer_display_set_desktop_size(display, width, height);
|
||||
virt_viewer_display_set_desktop_size(display, width, height);
|
||||
}
|
||||
|
||||
|
||||
GtkWidget *
|
||||
virt_viewer_display_vnc_new(VncDisplay *vnc)
|
||||
{
|
||||
VirtViewerDisplayVnc *display;
|
||||
VirtViewerDisplayVnc *display;
|
||||
|
||||
display = g_object_new(VIRT_VIEWER_TYPE_DISPLAY_VNC, NULL);
|
||||
display = g_object_new(VIRT_VIEWER_TYPE_DISPLAY_VNC, NULL);
|
||||
|
||||
g_object_ref(vnc);
|
||||
g_object_ref(vnc); /* Because gtk_container_add steals the first ref */
|
||||
display->priv->vnc = vnc;
|
||||
g_object_ref(vnc);
|
||||
g_object_ref(vnc); /* Because gtk_container_add steals the first ref */
|
||||
display->priv->vnc = vnc;
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(display), GTK_WIDGET(display->priv->vnc));
|
||||
vnc_display_set_keyboard_grab(display->priv->vnc, TRUE);
|
||||
vnc_display_set_pointer_grab(display->priv->vnc, TRUE);
|
||||
gtk_container_add(GTK_CONTAINER(display), GTK_WIDGET(display->priv->vnc));
|
||||
vnc_display_set_keyboard_grab(display->priv->vnc, TRUE);
|
||||
vnc_display_set_pointer_grab(display->priv->vnc, TRUE);
|
||||
|
||||
/*
|
||||
* In auto-resize mode we have things setup so that we always
|
||||
* automatically resize the top level window to be exactly the
|
||||
* same size as the VNC desktop, except when it won't fit on
|
||||
* the local screen, at which point we let it scale down.
|
||||
* The upshot is, we always want scaling enabled.
|
||||
* We disable force_size because we want to allow user to
|
||||
* manually size the widget smaller too
|
||||
*/
|
||||
vnc_display_set_force_size(display->priv->vnc, FALSE);
|
||||
vnc_display_set_scaling(display->priv->vnc, TRUE);
|
||||
/*
|
||||
* In auto-resize mode we have things setup so that we always
|
||||
* automatically resize the top level window to be exactly the
|
||||
* same size as the VNC desktop, except when it won't fit on
|
||||
* the local screen, at which point we let it scale down.
|
||||
* The upshot is, we always want scaling enabled.
|
||||
* We disable force_size because we want to allow user to
|
||||
* manually size the widget smaller too
|
||||
*/
|
||||
vnc_display_set_force_size(display->priv->vnc, FALSE);
|
||||
vnc_display_set_scaling(display->priv->vnc, TRUE);
|
||||
|
||||
/* When VNC desktop resizes, we have to resize the containing widget */
|
||||
g_signal_connect(display->priv->vnc, "vnc-desktop-resize",
|
||||
G_CALLBACK(virt_viewer_display_vnc_resize_desktop), display);
|
||||
/* When VNC desktop resizes, we have to resize the containing widget */
|
||||
g_signal_connect(display->priv->vnc, "vnc-desktop-resize",
|
||||
G_CALLBACK(virt_viewer_display_vnc_resize_desktop), display);
|
||||
|
||||
g_signal_connect(display->priv->vnc, "vnc-pointer-grab",
|
||||
G_CALLBACK(virt_viewer_display_vnc_mouse_grab), display);
|
||||
g_signal_connect(display->priv->vnc, "vnc-pointer-ungrab",
|
||||
G_CALLBACK(virt_viewer_display_vnc_mouse_ungrab), display);
|
||||
g_signal_connect(display->priv->vnc, "vnc-keyboard-grab",
|
||||
G_CALLBACK(virt_viewer_display_vnc_key_grab), display);
|
||||
g_signal_connect(display->priv->vnc, "vnc-keyboard-ungrab",
|
||||
G_CALLBACK(virt_viewer_display_vnc_key_ungrab), display);
|
||||
g_signal_connect(display->priv->vnc, "vnc-pointer-grab",
|
||||
G_CALLBACK(virt_viewer_display_vnc_mouse_grab), display);
|
||||
g_signal_connect(display->priv->vnc, "vnc-pointer-ungrab",
|
||||
G_CALLBACK(virt_viewer_display_vnc_mouse_ungrab), display);
|
||||
g_signal_connect(display->priv->vnc, "vnc-keyboard-grab",
|
||||
G_CALLBACK(virt_viewer_display_vnc_key_grab), display);
|
||||
g_signal_connect(display->priv->vnc, "vnc-keyboard-ungrab",
|
||||
G_CALLBACK(virt_viewer_display_vnc_key_ungrab), display);
|
||||
|
||||
return GTK_WIDGET(display);
|
||||
return GTK_WIDGET(display);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -33,33 +33,33 @@ G_BEGIN_DECLS
|
||||
|
||||
#define VIRT_VIEWER_TYPE_DISPLAY_VNC virt_viewer_display_vnc_get_type()
|
||||
|
||||
#define VIRT_VIEWER_DISPLAY_VNC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_DISPLAY_VNC, VirtViewerDisplayVnc))
|
||||
#define VIRT_VIEWER_DISPLAY_VNC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_DISPLAY_VNC, VirtViewerDisplayVnc))
|
||||
|
||||
#define VIRT_VIEWER_DISPLAY_VNC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_DISPLAY_VNC, VirtViewerDisplayVncClass))
|
||||
#define VIRT_VIEWER_DISPLAY_VNC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_DISPLAY_VNC, VirtViewerDisplayVncClass))
|
||||
|
||||
#define VIRT_VIEWER_IS_DISPLAY_VNC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_DISPLAY_VNC))
|
||||
#define VIRT_VIEWER_IS_DISPLAY_VNC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_DISPLAY_VNC))
|
||||
|
||||
#define VIRT_VIEWER_IS_DISPLAY_VNC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_DISPLAY_VNC))
|
||||
#define VIRT_VIEWER_IS_DISPLAY_VNC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_DISPLAY_VNC))
|
||||
|
||||
#define VIRT_VIEWER_DISPLAY_VNC_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_DISPLAY_VNC, VirtViewerDisplayVncClass))
|
||||
#define VIRT_VIEWER_DISPLAY_VNC_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_DISPLAY_VNC, VirtViewerDisplayVncClass))
|
||||
|
||||
typedef struct _VirtViewerDisplayVnc VirtViewerDisplayVnc;
|
||||
typedef struct _VirtViewerDisplayVncClass VirtViewerDisplayVncClass;
|
||||
typedef struct _VirtViewerDisplayVncPrivate VirtViewerDisplayVncPrivate;
|
||||
|
||||
struct _VirtViewerDisplayVnc {
|
||||
VirtViewerDisplay parent;
|
||||
VirtViewerDisplay parent;
|
||||
|
||||
VirtViewerDisplayVncPrivate *priv;
|
||||
VirtViewerDisplayVncPrivate *priv;
|
||||
};
|
||||
|
||||
struct _VirtViewerDisplayVncClass {
|
||||
VirtViewerDisplayClass parent_class;
|
||||
VirtViewerDisplayClass parent_class;
|
||||
};
|
||||
|
||||
GType virt_viewer_display_vnc_get_type(void);
|
||||
@ -69,11 +69,10 @@ GtkWidget* virt_viewer_display_vnc_new(VncDisplay *display);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _VIRT_VIEWER_DISPLAY_VNC_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -33,503 +33,503 @@
|
||||
|
||||
struct _VirtViewerDisplayPrivate
|
||||
{
|
||||
gboolean dirty;
|
||||
guint desktopWidth;
|
||||
guint desktopHeight;
|
||||
guint zoom_level;
|
||||
gboolean zoom;
|
||||
gint nth_display;
|
||||
gint show_hint;
|
||||
gboolean maintain_aspect_ratio;
|
||||
gboolean dirty;
|
||||
guint desktopWidth;
|
||||
guint desktopHeight;
|
||||
guint zoom_level;
|
||||
gboolean zoom;
|
||||
gint nth_display;
|
||||
gint show_hint;
|
||||
gboolean maintain_aspect_ratio;
|
||||
};
|
||||
|
||||
static void virt_viewer_display_size_request(GtkWidget *widget,
|
||||
GtkRequisition *requisition);
|
||||
GtkRequisition *requisition);
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
static void virt_viewer_display_get_preferred_width(GtkWidget *widget,
|
||||
int *minwidth,
|
||||
int *defwidth);
|
||||
int *minwidth,
|
||||
int *defwidth);
|
||||
static void virt_viewer_display_get_preferred_height(GtkWidget *widget,
|
||||
int *minheight,
|
||||
int *defheight);
|
||||
int *minheight,
|
||||
int *defheight);
|
||||
#endif
|
||||
static void virt_viewer_display_size_allocate(GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
GtkAllocation *allocation);
|
||||
static void virt_viewer_display_set_property(GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void virt_viewer_display_get_property(GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void virt_viewer_display_grab_focus(GtkWidget *widget);
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE(VirtViewerDisplay, virt_viewer_display, GTK_TYPE_BIN)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_0,
|
||||
|
||||
PROP_DESKTOP_WIDTH,
|
||||
PROP_DESKTOP_HEIGHT,
|
||||
PROP_NTH_DISPLAY,
|
||||
PROP_ZOOM,
|
||||
PROP_ZOOM_LEVEL,
|
||||
PROP_SHOW_HINT,
|
||||
PROP_DESKTOP_WIDTH,
|
||||
PROP_DESKTOP_HEIGHT,
|
||||
PROP_NTH_DISPLAY,
|
||||
PROP_ZOOM,
|
||||
PROP_ZOOM_LEVEL,
|
||||
PROP_SHOW_HINT,
|
||||
};
|
||||
|
||||
static void
|
||||
virt_viewer_display_class_init(VirtViewerDisplayClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(class);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(class);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(class);
|
||||
|
||||
object_class->set_property = virt_viewer_display_set_property;
|
||||
object_class->get_property = virt_viewer_display_get_property;
|
||||
object_class->set_property = virt_viewer_display_set_property;
|
||||
object_class->get_property = virt_viewer_display_get_property;
|
||||
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
widget_class->get_preferred_width = virt_viewer_display_get_preferred_width;
|
||||
widget_class->get_preferred_height = virt_viewer_display_get_preferred_height;
|
||||
widget_class->get_preferred_width = virt_viewer_display_get_preferred_width;
|
||||
widget_class->get_preferred_height = virt_viewer_display_get_preferred_height;
|
||||
#else
|
||||
widget_class->size_request = virt_viewer_display_size_request;
|
||||
widget_class->size_request = virt_viewer_display_size_request;
|
||||
#endif
|
||||
widget_class->size_allocate = virt_viewer_display_size_allocate;
|
||||
widget_class->grab_focus = virt_viewer_display_grab_focus;
|
||||
widget_class->size_allocate = virt_viewer_display_size_allocate;
|
||||
widget_class->grab_focus = virt_viewer_display_grab_focus;
|
||||
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_DESKTOP_WIDTH,
|
||||
g_param_spec_int("desktop-width",
|
||||
"Width",
|
||||
"Desktop width",
|
||||
100,
|
||||
G_MAXINT32,
|
||||
100,
|
||||
G_PARAM_READWRITE));
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_DESKTOP_WIDTH,
|
||||
g_param_spec_int("desktop-width",
|
||||
"Width",
|
||||
"Desktop width",
|
||||
100,
|
||||
G_MAXINT32,
|
||||
100,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_DESKTOP_HEIGHT,
|
||||
g_param_spec_int("desktop-height",
|
||||
"Height",
|
||||
"Desktop height",
|
||||
100,
|
||||
G_MAXINT32,
|
||||
100,
|
||||
G_PARAM_READWRITE));
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_DESKTOP_HEIGHT,
|
||||
g_param_spec_int("desktop-height",
|
||||
"Height",
|
||||
"Desktop height",
|
||||
100,
|
||||
G_MAXINT32,
|
||||
100,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_ZOOM,
|
||||
g_param_spec_boolean("zoom",
|
||||
"Zoom",
|
||||
"Zoom",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE));
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_ZOOM,
|
||||
g_param_spec_boolean("zoom",
|
||||
"Zoom",
|
||||
"Zoom",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_ZOOM_LEVEL,
|
||||
g_param_spec_int("zoom-level",
|
||||
"Zoom",
|
||||
"Zoom level",
|
||||
10,
|
||||
400,
|
||||
100,
|
||||
G_PARAM_READWRITE));
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_ZOOM_LEVEL,
|
||||
g_param_spec_int("zoom-level",
|
||||
"Zoom",
|
||||
"Zoom level",
|
||||
10,
|
||||
400,
|
||||
100,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_NTH_DISPLAY,
|
||||
g_param_spec_int("nth-display",
|
||||
"Nth display",
|
||||
"Nth display",
|
||||
0,
|
||||
G_MAXINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_NTH_DISPLAY,
|
||||
g_param_spec_int("nth-display",
|
||||
"Nth display",
|
||||
"Nth display",
|
||||
0,
|
||||
G_MAXINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_SHOW_HINT,
|
||||
g_param_spec_int("show-hint",
|
||||
"Show hint",
|
||||
"Show state hint",
|
||||
0,
|
||||
G_MAXINT32,
|
||||
0,
|
||||
G_PARAM_READABLE));
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_SHOW_HINT,
|
||||
g_param_spec_int("show-hint",
|
||||
"Show hint",
|
||||
"Show state hint",
|
||||
0,
|
||||
G_MAXINT32,
|
||||
0,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
|
||||
g_signal_new("display-pointer-grab",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerDisplayClass, display_pointer_grab),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
g_signal_new("display-pointer-grab",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerDisplayClass, display_pointer_grab),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
|
||||
g_signal_new("display-pointer-ungrab",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerDisplayClass, display_pointer_ungrab),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
g_signal_new("display-pointer-ungrab",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerDisplayClass, display_pointer_ungrab),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
|
||||
g_signal_new("display-keyboard-grab",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerDisplayClass, display_keyboard_grab),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
g_signal_new("display-keyboard-grab",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerDisplayClass, display_keyboard_grab),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
|
||||
g_signal_new("display-keyboard-ungrab",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerDisplayClass, display_keyboard_ungrab),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
g_signal_new("display-keyboard-ungrab",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerDisplayClass, display_keyboard_ungrab),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
|
||||
g_signal_new("display-desktop-resize",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerDisplayClass, display_desktop_resize),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
g_signal_new("display-desktop-resize",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerDisplayClass, display_desktop_resize),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
|
||||
g_type_class_add_private(class, sizeof(VirtViewerDisplayPrivate));
|
||||
g_type_class_add_private(class, sizeof(VirtViewerDisplayPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_display_init(VirtViewerDisplay *display)
|
||||
{
|
||||
gtk_widget_set_has_window(GTK_WIDGET(display), FALSE);
|
||||
gtk_widget_set_redraw_on_allocate(GTK_WIDGET(display), FALSE);
|
||||
gtk_widget_set_has_window(GTK_WIDGET(display), FALSE);
|
||||
gtk_widget_set_redraw_on_allocate(GTK_WIDGET(display), FALSE);
|
||||
|
||||
display->priv = VIRT_VIEWER_DISPLAY_GET_PRIVATE(display);
|
||||
display->priv = VIRT_VIEWER_DISPLAY_GET_PRIVATE(display);
|
||||
|
||||
display->priv->desktopWidth = 100;
|
||||
display->priv->desktopHeight = 100;
|
||||
display->priv->zoom_level = 100;
|
||||
display->priv->zoom = TRUE;
|
||||
display->priv->dirty = TRUE;
|
||||
display->priv->maintain_aspect_ratio = TRUE;
|
||||
display->priv->desktopWidth = 100;
|
||||
display->priv->desktopHeight = 100;
|
||||
display->priv->zoom_level = 100;
|
||||
display->priv->zoom = TRUE;
|
||||
display->priv->dirty = TRUE;
|
||||
display->priv->maintain_aspect_ratio = TRUE;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
virt_viewer_display_new(void)
|
||||
{
|
||||
return g_object_new(VIRT_VIEWER_TYPE_DISPLAY, NULL);
|
||||
return g_object_new(VIRT_VIEWER_TYPE_DISPLAY, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_display_set_property(GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(object);
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(object);
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_DESKTOP_WIDTH:
|
||||
virt_viewer_display_set_desktop_size(display,
|
||||
g_value_get_int(value),
|
||||
priv->desktopHeight);
|
||||
break;
|
||||
case PROP_DESKTOP_HEIGHT:
|
||||
virt_viewer_display_set_desktop_size(display,
|
||||
priv->desktopWidth,
|
||||
g_value_get_int(value));
|
||||
break;
|
||||
case PROP_NTH_DISPLAY:
|
||||
priv->nth_display = g_value_get_int(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
switch (prop_id) {
|
||||
case PROP_DESKTOP_WIDTH:
|
||||
virt_viewer_display_set_desktop_size(display,
|
||||
g_value_get_int(value),
|
||||
priv->desktopHeight);
|
||||
break;
|
||||
case PROP_DESKTOP_HEIGHT:
|
||||
virt_viewer_display_set_desktop_size(display,
|
||||
priv->desktopWidth,
|
||||
g_value_get_int(value));
|
||||
break;
|
||||
case PROP_NTH_DISPLAY:
|
||||
priv->nth_display = g_value_get_int(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_display_get_property(GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(object);
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(object);
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_DESKTOP_WIDTH:
|
||||
g_value_set_int(value, priv->desktopWidth);
|
||||
break;
|
||||
case PROP_DESKTOP_HEIGHT:
|
||||
g_value_set_int(value, priv->desktopHeight);
|
||||
break;
|
||||
case PROP_NTH_DISPLAY:
|
||||
g_value_set_int(value, priv->nth_display);
|
||||
break;
|
||||
case PROP_SHOW_HINT:
|
||||
g_value_set_int(value, priv->show_hint);
|
||||
break;
|
||||
switch (prop_id) {
|
||||
case PROP_DESKTOP_WIDTH:
|
||||
g_value_set_int(value, priv->desktopWidth);
|
||||
break;
|
||||
case PROP_DESKTOP_HEIGHT:
|
||||
g_value_set_int(value, priv->desktopHeight);
|
||||
break;
|
||||
case PROP_NTH_DISPLAY:
|
||||
g_value_set_int(value, priv->nth_display);
|
||||
break;
|
||||
case PROP_SHOW_HINT:
|
||||
g_value_set_int(value, priv->show_hint);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virt_viewer_display_grab_focus(GtkWidget *widget)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN(widget);
|
||||
GtkBin *bin = GTK_BIN(widget);
|
||||
|
||||
gtk_widget_grab_focus(gtk_bin_get_child(bin));
|
||||
gtk_widget_grab_focus(gtk_bin_get_child(bin));
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
virt_viewer_display_idle(gpointer opaque)
|
||||
{
|
||||
VirtViewerDisplay *display = opaque;
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
if (!priv->dirty)
|
||||
gtk_widget_queue_resize_no_redraw(GTK_WIDGET(display));
|
||||
return FALSE;
|
||||
VirtViewerDisplay *display = opaque;
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
if (!priv->dirty)
|
||||
gtk_widget_queue_resize_no_redraw(GTK_WIDGET(display));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virt_viewer_display_size_request(GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
GtkRequisition *requisition)
|
||||
{
|
||||
VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(widget);
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
int border_width = gtk_container_get_border_width(GTK_CONTAINER(widget));
|
||||
VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(widget);
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
int border_width = gtk_container_get_border_width(GTK_CONTAINER(widget));
|
||||
|
||||
requisition->width = border_width * 2;
|
||||
requisition->height = border_width * 2;
|
||||
requisition->width = border_width * 2;
|
||||
requisition->height = border_width * 2;
|
||||
|
||||
if (priv->dirty) {
|
||||
if (priv->zoom)
|
||||
requisition->width += priv->desktopWidth * priv->zoom_level / 100;
|
||||
else
|
||||
requisition->width += priv->desktopWidth;
|
||||
} else {
|
||||
requisition->width += 50;
|
||||
}
|
||||
if (priv->dirty) {
|
||||
if (priv->zoom)
|
||||
requisition->height += priv->desktopHeight * priv->zoom_level / 100;
|
||||
else
|
||||
requisition->height += priv->desktopHeight;
|
||||
} else {
|
||||
requisition->height += 50;
|
||||
}
|
||||
if (priv->dirty) {
|
||||
if (priv->zoom)
|
||||
requisition->width += priv->desktopWidth * priv->zoom_level / 100;
|
||||
else
|
||||
requisition->width += priv->desktopWidth;
|
||||
} else {
|
||||
requisition->width += 50;
|
||||
}
|
||||
if (priv->dirty) {
|
||||
if (priv->zoom)
|
||||
requisition->height += priv->desktopHeight * priv->zoom_level / 100;
|
||||
else
|
||||
requisition->height += priv->desktopHeight;
|
||||
} else {
|
||||
requisition->height += 50;
|
||||
}
|
||||
|
||||
DEBUG_LOG("Display size request %dx%d (desktop %dx%d)",
|
||||
requisition->width, requisition->height,
|
||||
priv->desktopWidth, priv->desktopHeight);
|
||||
DEBUG_LOG("Display size request %dx%d (desktop %dx%d)",
|
||||
requisition->width, requisition->height,
|
||||
priv->desktopWidth, priv->desktopHeight);
|
||||
}
|
||||
|
||||
|
||||
#if GTK_CHECK_VERSION(3, 0, 0)
|
||||
static void virt_viewer_display_get_preferred_width(GtkWidget *widget,
|
||||
int *minwidth,
|
||||
int *defwidth)
|
||||
int *minwidth,
|
||||
int *defwidth)
|
||||
{
|
||||
GtkRequisition req;
|
||||
GtkRequisition req;
|
||||
|
||||
virt_viewer_display_size_request(widget, &req);
|
||||
virt_viewer_display_size_request(widget, &req);
|
||||
|
||||
*minwidth = *defwidth = req.width;
|
||||
*minwidth = *defwidth = req.width;
|
||||
}
|
||||
|
||||
|
||||
static void virt_viewer_display_get_preferred_height(GtkWidget *widget,
|
||||
int *minheight,
|
||||
int *defheight)
|
||||
int *minheight,
|
||||
int *defheight)
|
||||
{
|
||||
GtkRequisition req;
|
||||
GtkRequisition req;
|
||||
|
||||
virt_viewer_display_size_request(widget, &req);
|
||||
virt_viewer_display_size_request(widget, &req);
|
||||
|
||||
*minheight = *defheight = req.height;
|
||||
*minheight = *defheight = req.height;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
virt_viewer_display_size_allocate(GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN(widget);
|
||||
VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(widget);
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
GtkAllocation child_allocation;
|
||||
gint width, height;
|
||||
gint border_width;
|
||||
double desktopAspect;
|
||||
double actualAspect;
|
||||
GtkWidget *child = gtk_bin_get_child(bin);
|
||||
GtkBin *bin = GTK_BIN(widget);
|
||||
VirtViewerDisplay *display = VIRT_VIEWER_DISPLAY(widget);
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
GtkAllocation child_allocation;
|
||||
gint width, height;
|
||||
gint border_width;
|
||||
double desktopAspect;
|
||||
double actualAspect;
|
||||
GtkWidget *child = gtk_bin_get_child(bin);
|
||||
|
||||
DEBUG_LOG("Allocated %dx%d", allocation->width, allocation->height);
|
||||
gtk_widget_set_allocation(widget, allocation);
|
||||
DEBUG_LOG("Allocated %dx%d", allocation->width, allocation->height);
|
||||
gtk_widget_set_allocation(widget, allocation);
|
||||
|
||||
desktopAspect = (double)priv->desktopWidth / (double)priv->desktopHeight;
|
||||
desktopAspect = (double)priv->desktopWidth / (double)priv->desktopHeight;
|
||||
|
||||
if (child &&
|
||||
gtk_widget_get_visible(child)) {
|
||||
if (!priv->maintain_aspect_ratio) {
|
||||
gtk_widget_size_allocate(child, allocation);
|
||||
goto end;
|
||||
}
|
||||
if (child &&
|
||||
gtk_widget_get_visible(child)) {
|
||||
if (!priv->maintain_aspect_ratio) {
|
||||
gtk_widget_size_allocate(child, allocation);
|
||||
goto end;
|
||||
}
|
||||
|
||||
border_width = gtk_container_get_border_width(GTK_CONTAINER(display));
|
||||
border_width = gtk_container_get_border_width(GTK_CONTAINER(display));
|
||||
|
||||
width = MAX(1, allocation->width - 2 * border_width);
|
||||
height = MAX(1, allocation->height - 2 * border_width);
|
||||
actualAspect = (double)width / (double)height;
|
||||
width = MAX(1, allocation->width - 2 * border_width);
|
||||
height = MAX(1, allocation->height - 2 * border_width);
|
||||
actualAspect = (double)width / (double)height;
|
||||
|
||||
if (actualAspect > desktopAspect) {
|
||||
child_allocation.width = height * desktopAspect;
|
||||
child_allocation.height = height;
|
||||
} else {
|
||||
child_allocation.width = width;
|
||||
child_allocation.height = width / desktopAspect;
|
||||
}
|
||||
if (actualAspect > desktopAspect) {
|
||||
child_allocation.width = height * desktopAspect;
|
||||
child_allocation.height = height;
|
||||
} else {
|
||||
child_allocation.width = width;
|
||||
child_allocation.height = width / desktopAspect;
|
||||
}
|
||||
|
||||
child_allocation.x = 0.5 * (width - child_allocation.width) + allocation->x + border_width;
|
||||
child_allocation.y = 0.5 * (height - child_allocation.height) + allocation->y + border_width;
|
||||
child_allocation.x = 0.5 * (width - child_allocation.width) + allocation->x + border_width;
|
||||
child_allocation.y = 0.5 * (height - child_allocation.height) + allocation->y + border_width;
|
||||
|
||||
DEBUG_LOG("Child allocate %dx%d", child_allocation.width, child_allocation.height);
|
||||
gtk_widget_size_allocate(child, &child_allocation);
|
||||
}
|
||||
DEBUG_LOG("Child allocate %dx%d", child_allocation.width, child_allocation.height);
|
||||
gtk_widget_size_allocate(child, &child_allocation);
|
||||
}
|
||||
|
||||
end:
|
||||
/* This unsets the size request, so that the user can
|
||||
* manually resize the window smaller again
|
||||
*/
|
||||
if (priv->dirty) {
|
||||
g_idle_add(virt_viewer_display_idle, widget);
|
||||
priv->dirty = FALSE;
|
||||
}
|
||||
end:
|
||||
/* This unsets the size request, so that the user can
|
||||
* manually resize the window smaller again
|
||||
*/
|
||||
if (priv->dirty) {
|
||||
g_idle_add(virt_viewer_display_idle, widget);
|
||||
priv->dirty = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void virt_viewer_display_set_maintain_aspect_ratio(VirtViewerDisplay *display,
|
||||
gboolean maintain)
|
||||
gboolean maintain)
|
||||
{
|
||||
g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(display));
|
||||
g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(display));
|
||||
|
||||
display->priv->maintain_aspect_ratio = maintain;
|
||||
display->priv->maintain_aspect_ratio = maintain;
|
||||
}
|
||||
|
||||
|
||||
void virt_viewer_display_set_desktop_size(VirtViewerDisplay *display,
|
||||
guint width,
|
||||
guint height)
|
||||
guint width,
|
||||
guint height)
|
||||
{
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
|
||||
if (width == priv->desktopWidth && height == priv->desktopHeight)
|
||||
return;
|
||||
if (width == priv->desktopWidth && height == priv->desktopHeight)
|
||||
return;
|
||||
|
||||
priv->desktopWidth = width;
|
||||
priv->desktopHeight = height;
|
||||
priv->dirty = TRUE;
|
||||
priv->desktopWidth = width;
|
||||
priv->desktopHeight = height;
|
||||
priv->dirty = TRUE;
|
||||
|
||||
gtk_widget_queue_resize(GTK_WIDGET(display));
|
||||
g_signal_emit_by_name(display, "display-desktop-resize");
|
||||
gtk_widget_queue_resize(GTK_WIDGET(display));
|
||||
g_signal_emit_by_name(display, "display-desktop-resize");
|
||||
}
|
||||
|
||||
|
||||
void virt_viewer_display_get_desktop_size(VirtViewerDisplay *display,
|
||||
guint *width,
|
||||
guint *height)
|
||||
guint *width,
|
||||
guint *height)
|
||||
{
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
|
||||
*width = priv->desktopWidth;
|
||||
*height = priv->desktopHeight;
|
||||
*width = priv->desktopWidth;
|
||||
*height = priv->desktopHeight;
|
||||
}
|
||||
|
||||
|
||||
void virt_viewer_display_set_zoom_level(VirtViewerDisplay *display,
|
||||
guint zoom)
|
||||
guint zoom)
|
||||
{
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
GtkWidget *child = gtk_bin_get_child(GTK_BIN(display));
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
GtkWidget *child = gtk_bin_get_child(GTK_BIN(display));
|
||||
|
||||
if (zoom < 10)
|
||||
zoom = 10;
|
||||
if (zoom > 400)
|
||||
zoom = 400;
|
||||
priv->zoom_level = zoom;
|
||||
if (zoom < 10)
|
||||
zoom = 10;
|
||||
if (zoom > 400)
|
||||
zoom = 400;
|
||||
priv->zoom_level = zoom;
|
||||
|
||||
if (child && gtk_widget_get_visible(child)) {
|
||||
priv->dirty = TRUE;
|
||||
gtk_widget_queue_resize(GTK_WIDGET(display));
|
||||
}
|
||||
if (child && gtk_widget_get_visible(child)) {
|
||||
priv->dirty = TRUE;
|
||||
gtk_widget_queue_resize(GTK_WIDGET(display));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void virt_viewer_display_set_zoom(VirtViewerDisplay *display,
|
||||
gboolean zoom)
|
||||
gboolean zoom)
|
||||
{
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
GtkWidget *child = gtk_bin_get_child(GTK_BIN(display));
|
||||
VirtViewerDisplayPrivate *priv = display->priv;
|
||||
GtkWidget *child = gtk_bin_get_child(GTK_BIN(display));
|
||||
|
||||
priv->zoom = zoom;
|
||||
if (child && gtk_widget_get_visible(child)) {
|
||||
priv->dirty = TRUE;
|
||||
gtk_widget_queue_resize(GTK_WIDGET(display));
|
||||
}
|
||||
priv->zoom = zoom;
|
||||
if (child && gtk_widget_get_visible(child)) {
|
||||
priv->dirty = TRUE;
|
||||
gtk_widget_queue_resize(GTK_WIDGET(display));
|
||||
}
|
||||
}
|
||||
|
||||
void virt_viewer_display_send_keys(VirtViewerDisplay *display,
|
||||
const guint *keyvals, int nkeyvals)
|
||||
const guint *keyvals, int nkeyvals)
|
||||
{
|
||||
g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(display));
|
||||
g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(display));
|
||||
|
||||
VIRT_VIEWER_DISPLAY_GET_CLASS(display)->send_keys(display, keyvals, nkeyvals);
|
||||
VIRT_VIEWER_DISPLAY_GET_CLASS(display)->send_keys(display, keyvals, nkeyvals);
|
||||
}
|
||||
|
||||
GdkPixbuf* virt_viewer_display_get_pixbuf(VirtViewerDisplay *display)
|
||||
{
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_DISPLAY(display), NULL);
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_DISPLAY(display), NULL);
|
||||
|
||||
return VIRT_VIEWER_DISPLAY_GET_CLASS(display)->get_pixbuf(display);
|
||||
return VIRT_VIEWER_DISPLAY_GET_CLASS(display)->get_pixbuf(display);
|
||||
}
|
||||
|
||||
void virt_viewer_display_set_show_hint(VirtViewerDisplay *self, gint hint)
|
||||
{
|
||||
VirtViewerDisplayPrivate *priv;
|
||||
g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(self));
|
||||
VirtViewerDisplayPrivate *priv;
|
||||
g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(self));
|
||||
|
||||
priv = self->priv;
|
||||
if (priv->show_hint == hint)
|
||||
return;
|
||||
priv = self->priv;
|
||||
if (priv->show_hint == hint)
|
||||
return;
|
||||
|
||||
priv->show_hint = hint;
|
||||
g_object_notify(G_OBJECT(self), "show-hint");
|
||||
priv->show_hint = hint;
|
||||
g_object_notify(G_OBJECT(self), "show-hint");
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -30,20 +30,20 @@ G_BEGIN_DECLS
|
||||
|
||||
#define VIRT_VIEWER_TYPE_DISPLAY virt_viewer_display_get_type()
|
||||
|
||||
#define VIRT_VIEWER_DISPLAY(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_DISPLAY, VirtViewerDisplay))
|
||||
#define VIRT_VIEWER_DISPLAY(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_DISPLAY, VirtViewerDisplay))
|
||||
|
||||
#define VIRT_VIEWER_DISPLAY_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_DISPLAY, VirtViewerDisplayClass))
|
||||
#define VIRT_VIEWER_DISPLAY_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_DISPLAY, VirtViewerDisplayClass))
|
||||
|
||||
#define VIRT_VIEWER_IS_DISPLAY(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_DISPLAY))
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_DISPLAY))
|
||||
|
||||
#define VIRT_VIEWER_IS_DISPLAY_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_DISPLAY))
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_DISPLAY))
|
||||
|
||||
#define VIRT_VIEWER_DISPLAY_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_DISPLAY, VirtViewerDisplayClass))
|
||||
#define VIRT_VIEWER_DISPLAY_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_DISPLAY, VirtViewerDisplayClass))
|
||||
|
||||
typedef struct _VirtViewerDisplay VirtViewerDisplay;
|
||||
typedef struct _VirtViewerDisplayClass VirtViewerDisplayClass;
|
||||
@ -52,32 +52,32 @@ typedef struct _VirtViewerDisplayPrivate VirtViewerDisplayPrivate;
|
||||
typedef struct _VirtViewerDisplayChannel VirtViewerDisplayChannel;
|
||||
|
||||
enum {
|
||||
VIRT_VIEWER_DISPLAY_SHOW_HINT_HIDE = 0,
|
||||
VIRT_VIEWER_DISPLAY_SHOW_HINT_READY,
|
||||
VIRT_VIEWER_DISPLAY_SHOW_HINT_HIDE = 0,
|
||||
VIRT_VIEWER_DISPLAY_SHOW_HINT_READY,
|
||||
};
|
||||
|
||||
/* perhaps this become an interface, and be pushed in gtkvnc and spice? */
|
||||
struct _VirtViewerDisplay {
|
||||
GtkBin parent;
|
||||
GtkBin parent;
|
||||
|
||||
VirtViewerDisplayPrivate *priv;
|
||||
VirtViewerDisplayPrivate *priv;
|
||||
};
|
||||
|
||||
struct _VirtViewerDisplayClass {
|
||||
GtkBinClass parent_class;
|
||||
GtkBinClass parent_class;
|
||||
|
||||
/* virtual methods */
|
||||
void (*send_keys)(VirtViewerDisplay* display,
|
||||
const guint *keyvals, int nkeyvals);
|
||||
GdkPixbuf *(*get_pixbuf)(VirtViewerDisplay* display);
|
||||
/* virtual methods */
|
||||
void (*send_keys)(VirtViewerDisplay* display,
|
||||
const guint *keyvals, int nkeyvals);
|
||||
GdkPixbuf *(*get_pixbuf)(VirtViewerDisplay* display);
|
||||
|
||||
/* signals */
|
||||
void (*display_pointer_grab)(VirtViewerDisplay *display);
|
||||
void (*display_pointer_ungrab)(VirtViewerDisplay *display);
|
||||
void (*display_keyboard_grab)(VirtViewerDisplay *display);
|
||||
void (*display_keyboard_ungrab)(VirtViewerDisplay *display);
|
||||
/* signals */
|
||||
void (*display_pointer_grab)(VirtViewerDisplay *display);
|
||||
void (*display_pointer_ungrab)(VirtViewerDisplay *display);
|
||||
void (*display_keyboard_grab)(VirtViewerDisplay *display);
|
||||
void (*display_keyboard_ungrab)(VirtViewerDisplay *display);
|
||||
|
||||
void (*display_desktop_resize)(VirtViewerDisplay *display);
|
||||
void (*display_desktop_resize)(VirtViewerDisplay *display);
|
||||
};
|
||||
|
||||
GType virt_viewer_display_get_type(void);
|
||||
@ -87,20 +87,20 @@ GtkWidget *virt_viewer_display_new(void);
|
||||
void virt_viewer_display_set_maintain_aspect_ratio(VirtViewerDisplay *display,
|
||||
gboolean maintain);
|
||||
void virt_viewer_display_set_desktop_size(VirtViewerDisplay *display,
|
||||
guint width,
|
||||
guint height);
|
||||
guint width,
|
||||
guint height);
|
||||
|
||||
void virt_viewer_display_get_desktop_size(VirtViewerDisplay *display,
|
||||
guint *width,
|
||||
guint *height);
|
||||
guint *width,
|
||||
guint *height);
|
||||
|
||||
void virt_viewer_display_set_zoom_level(VirtViewerDisplay *display,
|
||||
guint zoom);
|
||||
guint zoom);
|
||||
void virt_viewer_display_set_zoom(VirtViewerDisplay *display,
|
||||
gboolean zoom);
|
||||
gboolean zoom);
|
||||
|
||||
void virt_viewer_display_send_keys(VirtViewerDisplay *display,
|
||||
const guint *keyvals, int nkeyvals);
|
||||
const guint *keyvals, int nkeyvals);
|
||||
GdkPixbuf* virt_viewer_display_get_pixbuf(VirtViewerDisplay *display);
|
||||
void virt_viewer_display_set_show_hint(VirtViewerDisplay *display, gint hint);
|
||||
|
||||
@ -109,8 +109,8 @@ G_END_DECLS
|
||||
#endif /* _VIRT_VIEWER_DISPLAY_H */
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -48,8 +48,8 @@ static struct virt_viewer_events_handle **handles = NULL;
|
||||
|
||||
static gboolean
|
||||
virt_viewer_events_dispatch_handle(GIOChannel *source G_GNUC_UNUSED,
|
||||
GIOCondition condition,
|
||||
gpointer opaque)
|
||||
GIOCondition condition,
|
||||
gpointer opaque)
|
||||
{
|
||||
struct virt_viewer_events_handle *data = opaque;
|
||||
int events = 0;
|
||||
@ -73,10 +73,10 @@ virt_viewer_events_dispatch_handle(GIOChannel *source G_GNUC_UNUSED,
|
||||
|
||||
static
|
||||
int virt_viewer_events_add_handle(int fd,
|
||||
int events,
|
||||
virEventHandleCallback cb,
|
||||
void *opaque,
|
||||
virFreeCallback ff)
|
||||
int events,
|
||||
virEventHandleCallback cb,
|
||||
void *opaque,
|
||||
virFreeCallback ff)
|
||||
{
|
||||
struct virt_viewer_events_handle *data;
|
||||
GIOCondition cond = 0;
|
||||
@ -123,7 +123,7 @@ virt_viewer_events_find_handle(int watch)
|
||||
|
||||
static void
|
||||
virt_viewer_events_update_handle(int watch,
|
||||
int events)
|
||||
int events)
|
||||
{
|
||||
struct virt_viewer_events_handle *data = virt_viewer_events_find_handle(watch);
|
||||
|
||||
@ -227,9 +227,9 @@ virt_viewer_events_dispatch_timeout(void *opaque)
|
||||
|
||||
static int
|
||||
virt_viewer_events_add_timeout(int interval,
|
||||
virEventTimeoutCallback cb,
|
||||
void *opaque,
|
||||
virFreeCallback ff)
|
||||
virEventTimeoutCallback cb,
|
||||
void *opaque,
|
||||
virFreeCallback ff)
|
||||
{
|
||||
struct virt_viewer_events_timeout *data;
|
||||
|
||||
@ -269,7 +269,7 @@ virt_viewer_events_find_timeout(int timer)
|
||||
|
||||
static void
|
||||
virt_viewer_events_update_timeout(int timer,
|
||||
int interval)
|
||||
int interval)
|
||||
{
|
||||
struct virt_viewer_events_timeout *data = virt_viewer_events_find_timeout(timer);
|
||||
|
||||
@ -346,3 +346,10 @@ void virt_viewer_events_register(void) {
|
||||
virt_viewer_events_remove_timeout);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -28,3 +28,10 @@
|
||||
void virt_viewer_events_register(void);
|
||||
|
||||
#endif
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -35,121 +35,120 @@
|
||||
|
||||
static void virt_viewer_version(void)
|
||||
{
|
||||
g_print(_("%s version %s\n"), PACKAGE, VERSION);
|
||||
g_print(_("%s version %s\n"), PACKAGE, VERSION);
|
||||
|
||||
exit(0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GOptionContext *context;
|
||||
GError *error = NULL;
|
||||
int ret = 1;
|
||||
char *uri = NULL;
|
||||
int zoom = 100;
|
||||
gchar **args = NULL;
|
||||
gboolean verbose = FALSE;
|
||||
gboolean debug = FALSE;
|
||||
gboolean direct = FALSE;
|
||||
gboolean attach = FALSE;
|
||||
gboolean waitvm = FALSE;
|
||||
gboolean reconnect = FALSE;
|
||||
gboolean fullscreen = FALSE;
|
||||
VirtViewer *viewer = NULL;
|
||||
const char *help_msg = N_("Run '" PACKAGE " --help' to see a full list of available command line options");
|
||||
const GOptionEntry options [] = {
|
||||
{ "version", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
||||
virt_viewer_version, N_("Display version information"), NULL },
|
||||
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
|
||||
N_("Display verbose information"), NULL },
|
||||
{ "direct", 'd', 0, G_OPTION_ARG_NONE, &direct,
|
||||
N_("Direct connection with no automatic tunnels"), NULL },
|
||||
{ "attach", 'a', 0, G_OPTION_ARG_NONE, &attach,
|
||||
N_("Attach to the local display using libvirt"), NULL },
|
||||
{ "connect", 'c', 0, G_OPTION_ARG_STRING, &uri,
|
||||
N_("Connect to hypervisor"), "URI"},
|
||||
{ "wait", 'w', 0, G_OPTION_ARG_NONE, &waitvm,
|
||||
N_("Wait for domain to start"), NULL },
|
||||
{ "reconnect", 'r', 0, G_OPTION_ARG_NONE, &reconnect,
|
||||
N_("Reconnect to domain upon restart"), NULL },
|
||||
{ "zoom", 'z', 0, G_OPTION_ARG_INT, &zoom,
|
||||
N_("Zoom level of window, in percentage"), "ZOOM" },
|
||||
{ "debug", '\0', 0, G_OPTION_ARG_NONE, &debug,
|
||||
N_("Display debugging information"), NULL },
|
||||
{ "full-screen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen,
|
||||
N_("Open in full screen mode"), NULL },
|
||||
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
|
||||
NULL, "DOMAIN-NAME|ID|UUID" },
|
||||
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
|
||||
};
|
||||
GOptionContext *context;
|
||||
GError *error = NULL;
|
||||
int ret = 1;
|
||||
char *uri = NULL;
|
||||
int zoom = 100;
|
||||
gchar **args = NULL;
|
||||
gboolean verbose = FALSE;
|
||||
gboolean debug = FALSE;
|
||||
gboolean direct = FALSE;
|
||||
gboolean attach = FALSE;
|
||||
gboolean waitvm = FALSE;
|
||||
gboolean reconnect = FALSE;
|
||||
gboolean fullscreen = FALSE;
|
||||
VirtViewer *viewer = NULL;
|
||||
const char *help_msg = N_("Run '" PACKAGE " --help' to see a full list of available command line options");
|
||||
const GOptionEntry options [] = {
|
||||
{ "version", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
|
||||
virt_viewer_version, N_("Display version information"), NULL },
|
||||
{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
|
||||
N_("Display verbose information"), NULL },
|
||||
{ "direct", 'd', 0, G_OPTION_ARG_NONE, &direct,
|
||||
N_("Direct connection with no automatic tunnels"), NULL },
|
||||
{ "attach", 'a', 0, G_OPTION_ARG_NONE, &attach,
|
||||
N_("Attach to the local display using libvirt"), NULL },
|
||||
{ "connect", 'c', 0, G_OPTION_ARG_STRING, &uri,
|
||||
N_("Connect to hypervisor"), "URI"},
|
||||
{ "wait", 'w', 0, G_OPTION_ARG_NONE, &waitvm,
|
||||
N_("Wait for domain to start"), NULL },
|
||||
{ "reconnect", 'r', 0, G_OPTION_ARG_NONE, &reconnect,
|
||||
N_("Reconnect to domain upon restart"), NULL },
|
||||
{ "zoom", 'z', 0, G_OPTION_ARG_INT, &zoom,
|
||||
N_("Zoom level of window, in percentage"), "ZOOM" },
|
||||
{ "debug", '\0', 0, G_OPTION_ARG_NONE, &debug,
|
||||
N_("Display debugging information"), NULL },
|
||||
{ "full-screen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen,
|
||||
N_("Open in full screen mode"), NULL },
|
||||
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
|
||||
NULL, "DOMAIN-NAME|ID|UUID" },
|
||||
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
|
||||
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
||||
textdomain(GETTEXT_PACKAGE);
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
|
||||
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
||||
textdomain(GETTEXT_PACKAGE);
|
||||
|
||||
g_set_application_name(_("Virt Viewer"));
|
||||
g_set_application_name(_("Virt Viewer"));
|
||||
|
||||
/* Setup command line options */
|
||||
context = g_option_context_new (_("- Virtual machine graphical console"));
|
||||
g_option_context_add_main_entries (context, options, NULL);
|
||||
g_option_context_add_group (context, gtk_get_option_group (TRUE));
|
||||
/* Setup command line options */
|
||||
context = g_option_context_new (_("- Virtual machine graphical console"));
|
||||
g_option_context_add_main_entries (context, options, NULL);
|
||||
g_option_context_add_group (context, gtk_get_option_group (TRUE));
|
||||
#ifdef HAVE_GTK_VNC
|
||||
g_option_context_add_group (context, vnc_display_get_option_group ());
|
||||
g_option_context_add_group (context, vnc_display_get_option_group ());
|
||||
#endif
|
||||
#ifdef HAVE_SPICE_GTK
|
||||
g_option_context_add_group (context, spice_get_option_group ());
|
||||
g_option_context_add_group (context, spice_get_option_group ());
|
||||
#endif
|
||||
g_option_context_parse (context, &argc, &argv, &error);
|
||||
if (error) {
|
||||
g_printerr("%s\n%s\n",
|
||||
error->message,
|
||||
gettext(help_msg));
|
||||
g_error_free(error);
|
||||
goto cleanup;
|
||||
}
|
||||
g_option_context_parse (context, &argc, &argv, &error);
|
||||
if (error) {
|
||||
g_printerr("%s\n%s\n",
|
||||
error->message,
|
||||
gettext(help_msg));
|
||||
g_error_free(error);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
g_option_context_free(context);
|
||||
g_option_context_free(context);
|
||||
|
||||
if (!args || (g_strv_length(args) != 1)) {
|
||||
g_printerr(_("\nUsage: %s [OPTIONS] DOMAIN-NAME|ID|UUID\n\n%s\n\n"), argv[0], help_msg);
|
||||
goto cleanup;
|
||||
}
|
||||
if (!args || (g_strv_length(args) != 1)) {
|
||||
g_printerr(_("\nUsage: %s [OPTIONS] DOMAIN-NAME|ID|UUID\n\n%s\n\n"), argv[0], help_msg);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (zoom < 10 || zoom > 200) {
|
||||
g_printerr(_("Zoom level must be within 10-200\n"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (zoom < 10 || zoom > 200) {
|
||||
g_printerr(_("Zoom level must be within 10-200\n"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
virt_viewer_app_set_debug(debug);
|
||||
virt_viewer_app_set_debug(debug);
|
||||
|
||||
viewer = virt_viewer_new(uri, args[0], zoom, direct, attach, waitvm, reconnect, verbose, NULL);
|
||||
if (viewer == NULL)
|
||||
goto cleanup;
|
||||
viewer = virt_viewer_new(uri, args[0], zoom, direct, attach, waitvm, reconnect, verbose, NULL);
|
||||
if (viewer == NULL)
|
||||
goto cleanup;
|
||||
|
||||
g_object_set(viewer, "fullscreen", fullscreen, NULL);
|
||||
if (!virt_viewer_app_start(VIRT_VIEWER_APP(viewer)))
|
||||
goto cleanup;
|
||||
g_object_set(viewer, "fullscreen", fullscreen, NULL);
|
||||
if (!virt_viewer_app_start(VIRT_VIEWER_APP(viewer)))
|
||||
goto cleanup;
|
||||
|
||||
gtk_main();
|
||||
gtk_main();
|
||||
|
||||
ret = 0;
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (viewer)
|
||||
g_object_unref(viewer);
|
||||
g_free(uri);
|
||||
g_strfreev(args);
|
||||
cleanup:
|
||||
if (viewer)
|
||||
g_object_unref(viewer);
|
||||
g_free(uri);
|
||||
g_strfreev(args);
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -26,124 +26,123 @@
|
||||
|
||||
G_DEFINE_TYPE (VirtViewerNotebook, virt_viewer_notebook, GTK_TYPE_NOTEBOOK)
|
||||
|
||||
#define GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), VIRT_VIEWER_TYPE_NOTEBOOK, VirtViewerNotebookPrivate))
|
||||
#define GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), VIRT_VIEWER_TYPE_NOTEBOOK, VirtViewerNotebookPrivate))
|
||||
|
||||
struct _VirtViewerNotebookPrivate {
|
||||
GtkWidget *status;
|
||||
GtkWidget *status;
|
||||
};
|
||||
|
||||
static void
|
||||
virt_viewer_notebook_get_property (GObject *object, guint property_id,
|
||||
GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
|
||||
GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
switch (property_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_notebook_set_property (GObject *object, guint property_id,
|
||||
const GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
|
||||
const GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
switch (property_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_notebook_dispose (GObject *object)
|
||||
{
|
||||
G_OBJECT_CLASS (virt_viewer_notebook_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (virt_viewer_notebook_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_notebook_class_init (VirtViewerNotebookClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (VirtViewerNotebookPrivate));
|
||||
g_type_class_add_private (klass, sizeof (VirtViewerNotebookPrivate));
|
||||
|
||||
object_class->get_property = virt_viewer_notebook_get_property;
|
||||
object_class->set_property = virt_viewer_notebook_set_property;
|
||||
object_class->dispose = virt_viewer_notebook_dispose;
|
||||
object_class->get_property = virt_viewer_notebook_get_property;
|
||||
object_class->set_property = virt_viewer_notebook_set_property;
|
||||
object_class->dispose = virt_viewer_notebook_dispose;
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_notebook_init (VirtViewerNotebook *self)
|
||||
{
|
||||
VirtViewerNotebookPrivate *priv;
|
||||
GdkColor color;
|
||||
VirtViewerNotebookPrivate *priv;
|
||||
GdkColor color;
|
||||
|
||||
self->priv = GET_PRIVATE(self);
|
||||
priv = self->priv;
|
||||
self->priv = GET_PRIVATE(self);
|
||||
priv = self->priv;
|
||||
|
||||
priv->status = gtk_label_new("");
|
||||
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(self), FALSE);
|
||||
gtk_notebook_set_show_border(GTK_NOTEBOOK(self), FALSE);
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(self), priv->status, NULL);
|
||||
gdk_color_parse("white", &color);
|
||||
gtk_widget_modify_fg(priv->status, GTK_STATE_NORMAL, &color);
|
||||
priv->status = gtk_label_new("");
|
||||
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(self), FALSE);
|
||||
gtk_notebook_set_show_border(GTK_NOTEBOOK(self), FALSE);
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(self), priv->status, NULL);
|
||||
gdk_color_parse("white", &color);
|
||||
gtk_widget_modify_fg(priv->status, GTK_STATE_NORMAL, &color);
|
||||
}
|
||||
|
||||
void
|
||||
virt_viewer_notebook_show_status_va(VirtViewerNotebook *self, const gchar *fmt, va_list args)
|
||||
{
|
||||
VirtViewerNotebookPrivate *priv;
|
||||
gchar *text;
|
||||
VirtViewerNotebookPrivate *priv;
|
||||
gchar *text;
|
||||
|
||||
DEBUG_LOG("notebook show status %p", self);
|
||||
g_return_if_fail(VIRT_VIEWER_IS_NOTEBOOK(self));
|
||||
DEBUG_LOG("notebook show status %p", self);
|
||||
g_return_if_fail(VIRT_VIEWER_IS_NOTEBOOK(self));
|
||||
|
||||
text = g_strdup_vprintf(fmt, args);
|
||||
priv = self->priv;
|
||||
gtk_label_set_text(GTK_LABEL(priv->status), text);
|
||||
gtk_notebook_set_current_page(GTK_NOTEBOOK(self), 0);
|
||||
gtk_widget_show_all(GTK_WIDGET(self));
|
||||
g_free(text);
|
||||
text = g_strdup_vprintf(fmt, args);
|
||||
priv = self->priv;
|
||||
gtk_label_set_text(GTK_LABEL(priv->status), text);
|
||||
gtk_notebook_set_current_page(GTK_NOTEBOOK(self), 0);
|
||||
gtk_widget_show_all(GTK_WIDGET(self));
|
||||
g_free(text);
|
||||
}
|
||||
|
||||
void
|
||||
virt_viewer_notebook_show_status(VirtViewerNotebook *self, const gchar *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_list args;
|
||||
|
||||
g_return_if_fail(VIRT_VIEWER_IS_NOTEBOOK(self));
|
||||
g_return_if_fail(VIRT_VIEWER_IS_NOTEBOOK(self));
|
||||
|
||||
va_start(args, fmt);
|
||||
virt_viewer_notebook_show_status_va(self, fmt, args);
|
||||
va_end(args);
|
||||
va_start(args, fmt);
|
||||
virt_viewer_notebook_show_status_va(self, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
virt_viewer_notebook_show_display(VirtViewerNotebook *self)
|
||||
{
|
||||
GtkWidget *display;
|
||||
GtkWidget *display;
|
||||
|
||||
DEBUG_LOG("notebook show display %p", self);
|
||||
g_return_if_fail(VIRT_VIEWER_IS_NOTEBOOK(self));
|
||||
DEBUG_LOG("notebook show display %p", self);
|
||||
g_return_if_fail(VIRT_VIEWER_IS_NOTEBOOK(self));
|
||||
|
||||
display = gtk_notebook_get_nth_page(GTK_NOTEBOOK(self), 1);
|
||||
g_warn_if_fail(display != NULL);
|
||||
gtk_widget_grab_focus(display);
|
||||
display = gtk_notebook_get_nth_page(GTK_NOTEBOOK(self), 1);
|
||||
g_warn_if_fail(display != NULL);
|
||||
gtk_widget_grab_focus(display);
|
||||
|
||||
gtk_notebook_set_current_page(GTK_NOTEBOOK(self), 1);
|
||||
gtk_widget_show_all(GTK_WIDGET(self));
|
||||
gtk_notebook_set_current_page(GTK_NOTEBOOK(self), 1);
|
||||
gtk_widget_show_all(GTK_WIDGET(self));
|
||||
}
|
||||
|
||||
VirtViewerNotebook*
|
||||
virt_viewer_notebook_new (void)
|
||||
{
|
||||
return g_object_new (VIRT_VIEWER_TYPE_NOTEBOOK, NULL);
|
||||
return g_object_new (VIRT_VIEWER_TYPE_NOTEBOOK, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -31,30 +31,30 @@ G_BEGIN_DECLS
|
||||
|
||||
#define VIRT_VIEWER_TYPE_NOTEBOOK virt_viewer_notebook_get_type()
|
||||
|
||||
#define VIRT_VIEWER_NOTEBOOK(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_NOTEBOOK, VirtViewerNotebook))
|
||||
#define VIRT_VIEWER_NOTEBOOK(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_NOTEBOOK, VirtViewerNotebook))
|
||||
|
||||
#define VIRT_VIEWER_NOTEBOOK_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_NOTEBOOK, VirtViewerNotebookClass))
|
||||
#define VIRT_VIEWER_NOTEBOOK_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_NOTEBOOK, VirtViewerNotebookClass))
|
||||
|
||||
#define VIRT_VIEWER_IS_NOTEBOOK(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_NOTEBOOK))
|
||||
#define VIRT_VIEWER_IS_NOTEBOOK(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_NOTEBOOK))
|
||||
|
||||
#define VIRT_VIEWER_IS_NOTEBOOK_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_NOTEBOOK))
|
||||
#define VIRT_VIEWER_IS_NOTEBOOK_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_NOTEBOOK))
|
||||
|
||||
#define VIRT_VIEWER_NOTEBOOK_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_NOTEBOOK, VirtViewerNotebookClass))
|
||||
#define VIRT_VIEWER_NOTEBOOK_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_NOTEBOOK, VirtViewerNotebookClass))
|
||||
|
||||
typedef struct _VirtViewerNotebookPrivate VirtViewerNotebookPrivate;
|
||||
|
||||
typedef struct {
|
||||
GtkNotebook parent;
|
||||
VirtViewerNotebookPrivate *priv;
|
||||
GtkNotebook parent;
|
||||
VirtViewerNotebookPrivate *priv;
|
||||
} VirtViewerNotebook;
|
||||
|
||||
typedef struct {
|
||||
GtkNotebookClass parent_class;
|
||||
GtkNotebookClass parent_class;
|
||||
} VirtViewerNotebookClass;
|
||||
|
||||
GType virt_viewer_notebook_get_type (void);
|
||||
@ -67,12 +67,10 @@ void virt_viewer_notebook_show_display(VirtViewerNotebook *nb);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _VIRT_VIEWER_NOTEBOOK */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -36,16 +36,16 @@ G_DEFINE_TYPE (VirtViewerSessionSpice, virt_viewer_session_spice, VIRT_VIEWER_TY
|
||||
|
||||
|
||||
struct _VirtViewerSessionSpicePrivate {
|
||||
SpiceSession *session;
|
||||
SpiceGtkSession *gtk_session;
|
||||
SpiceAudio *audio;
|
||||
SpiceSession *session;
|
||||
SpiceGtkSession *gtk_session;
|
||||
SpiceAudio *audio;
|
||||
};
|
||||
|
||||
#define VIRT_VIEWER_SESSION_SPICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_SESSION_SPICE, VirtViewerSessionSpicePrivate))
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SPICE_SESSION,
|
||||
PROP_0,
|
||||
PROP_SPICE_SESSION,
|
||||
};
|
||||
|
||||
|
||||
@ -57,391 +57,390 @@ static gboolean virt_viewer_session_spice_channel_open_fd(VirtViewerSession *ses
|
||||
static gboolean virt_viewer_session_spice_has_usb(VirtViewerSession *session);
|
||||
static void virt_viewer_session_spice_usb_device_selection(VirtViewerSession *session, GtkWindow *parent);
|
||||
static void virt_viewer_session_spice_channel_new(SpiceSession *s,
|
||||
SpiceChannel *channel,
|
||||
VirtViewerSession *session);
|
||||
SpiceChannel *channel,
|
||||
VirtViewerSession *session);
|
||||
static void virt_viewer_session_spice_channel_destroy(SpiceSession *s,
|
||||
SpiceChannel *channel,
|
||||
VirtViewerSession *session);
|
||||
SpiceChannel *channel,
|
||||
VirtViewerSession *session);
|
||||
|
||||
|
||||
static void
|
||||
virt_viewer_session_spice_get_property(GObject *object, guint property_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(object);
|
||||
VirtViewerSessionSpicePrivate *priv = self->priv;
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(object);
|
||||
VirtViewerSessionSpicePrivate *priv = self->priv;
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_SPICE_SESSION:
|
||||
g_value_set_object(value, priv->session);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
switch (property_id) {
|
||||
case PROP_SPICE_SESSION:
|
||||
g_value_set_object(value, priv->session);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_spice_set_property(GObject *object, guint property_id,
|
||||
const GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
|
||||
const GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
switch (property_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_spice_dispose(GObject *obj)
|
||||
{
|
||||
VirtViewerSessionSpice *spice = VIRT_VIEWER_SESSION_SPICE(obj);
|
||||
VirtViewerSessionSpice *spice = VIRT_VIEWER_SESSION_SPICE(obj);
|
||||
|
||||
if (spice->priv->session) {
|
||||
spice_session_disconnect(spice->priv->session);
|
||||
g_object_unref(spice->priv->session);
|
||||
}
|
||||
if (spice->priv->audio)
|
||||
g_object_unref(spice->priv->audio);
|
||||
if (spice->priv->session) {
|
||||
spice_session_disconnect(spice->priv->session);
|
||||
g_object_unref(spice->priv->session);
|
||||
}
|
||||
if (spice->priv->audio)
|
||||
g_object_unref(spice->priv->audio);
|
||||
|
||||
G_OBJECT_CLASS(virt_viewer_session_spice_parent_class)->finalize(obj);
|
||||
G_OBJECT_CLASS(virt_viewer_session_spice_parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virt_viewer_session_spice_class_init(VirtViewerSessionSpiceClass *klass)
|
||||
{
|
||||
VirtViewerSessionClass *dclass = VIRT_VIEWER_SESSION_CLASS(klass);
|
||||
GObjectClass *oclass = G_OBJECT_CLASS(klass);
|
||||
VirtViewerSessionClass *dclass = VIRT_VIEWER_SESSION_CLASS(klass);
|
||||
GObjectClass *oclass = G_OBJECT_CLASS(klass);
|
||||
|
||||
oclass->get_property = virt_viewer_session_spice_get_property;
|
||||
oclass->set_property = virt_viewer_session_spice_set_property;
|
||||
oclass->dispose = virt_viewer_session_spice_dispose;
|
||||
oclass->get_property = virt_viewer_session_spice_get_property;
|
||||
oclass->set_property = virt_viewer_session_spice_set_property;
|
||||
oclass->dispose = virt_viewer_session_spice_dispose;
|
||||
|
||||
dclass->close = virt_viewer_session_spice_close;
|
||||
dclass->open_fd = virt_viewer_session_spice_open_fd;
|
||||
dclass->open_host = virt_viewer_session_spice_open_host;
|
||||
dclass->open_uri = virt_viewer_session_spice_open_uri;
|
||||
dclass->channel_open_fd = virt_viewer_session_spice_channel_open_fd;
|
||||
dclass->has_usb = virt_viewer_session_spice_has_usb;
|
||||
dclass->usb_device_selection = virt_viewer_session_spice_usb_device_selection;
|
||||
dclass->close = virt_viewer_session_spice_close;
|
||||
dclass->open_fd = virt_viewer_session_spice_open_fd;
|
||||
dclass->open_host = virt_viewer_session_spice_open_host;
|
||||
dclass->open_uri = virt_viewer_session_spice_open_uri;
|
||||
dclass->channel_open_fd = virt_viewer_session_spice_channel_open_fd;
|
||||
dclass->has_usb = virt_viewer_session_spice_has_usb;
|
||||
dclass->usb_device_selection = virt_viewer_session_spice_usb_device_selection;
|
||||
|
||||
g_type_class_add_private(klass, sizeof(VirtViewerSessionSpicePrivate));
|
||||
g_type_class_add_private(klass, sizeof(VirtViewerSessionSpicePrivate));
|
||||
|
||||
g_object_class_install_property(oclass,
|
||||
PROP_SPICE_SESSION,
|
||||
g_param_spec_object("spice-session",
|
||||
"Spice session",
|
||||
"Spice session",
|
||||
SPICE_TYPE_SESSION,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property(oclass,
|
||||
PROP_SPICE_SESSION,
|
||||
g_param_spec_object("spice-session",
|
||||
"Spice session",
|
||||
"Spice session",
|
||||
SPICE_TYPE_SESSION,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_spice_init(VirtViewerSessionSpice *self G_GNUC_UNUSED)
|
||||
{
|
||||
self->priv = VIRT_VIEWER_SESSION_SPICE_GET_PRIVATE(self);
|
||||
self->priv = VIRT_VIEWER_SESSION_SPICE_GET_PRIVATE(self);
|
||||
}
|
||||
|
||||
static void
|
||||
usb_connect_failed(GObject *object G_GNUC_UNUSED,
|
||||
SpiceUsbDevice *device G_GNUC_UNUSED,
|
||||
GError *error, VirtViewerSessionSpice *self)
|
||||
SpiceUsbDevice *device G_GNUC_UNUSED,
|
||||
GError *error, VirtViewerSessionSpice *self)
|
||||
{
|
||||
if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
return;
|
||||
if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
return;
|
||||
|
||||
g_signal_emit_by_name(self, "session-usb-failed", error->message);
|
||||
g_signal_emit_by_name(self, "session-usb-failed", error->message);
|
||||
}
|
||||
|
||||
static void
|
||||
create_spice_session(VirtViewerSessionSpice *self)
|
||||
{
|
||||
SpiceUsbDeviceManager *manager;
|
||||
SpiceUsbDeviceManager *manager;
|
||||
|
||||
g_return_if_fail(self != NULL);
|
||||
g_return_if_fail(self->priv->session == NULL);
|
||||
g_return_if_fail(self != NULL);
|
||||
g_return_if_fail(self->priv->session == NULL);
|
||||
|
||||
self->priv->session = spice_session_new();
|
||||
spice_set_session_option(self->priv->session);
|
||||
self->priv->session = spice_session_new();
|
||||
spice_set_session_option(self->priv->session);
|
||||
|
||||
self->priv->gtk_session = spice_gtk_session_get(self->priv->session);
|
||||
g_object_set(self->priv->gtk_session, "auto-clipboard", TRUE, NULL);
|
||||
self->priv->gtk_session = spice_gtk_session_get(self->priv->session);
|
||||
g_object_set(self->priv->gtk_session, "auto-clipboard", TRUE, NULL);
|
||||
|
||||
g_signal_connect(self->priv->session, "channel-new",
|
||||
G_CALLBACK(virt_viewer_session_spice_channel_new), self);
|
||||
g_signal_connect(self->priv->session, "channel-destroy",
|
||||
G_CALLBACK(virt_viewer_session_spice_channel_destroy), self);
|
||||
g_signal_connect(self->priv->session, "channel-new",
|
||||
G_CALLBACK(virt_viewer_session_spice_channel_new), self);
|
||||
g_signal_connect(self->priv->session, "channel-destroy",
|
||||
G_CALLBACK(virt_viewer_session_spice_channel_destroy), self);
|
||||
|
||||
manager = spice_usb_device_manager_get(self->priv->session, NULL);
|
||||
if (manager)
|
||||
g_signal_connect(manager, "auto-connect-failed",
|
||||
G_CALLBACK(usb_connect_failed), self);
|
||||
manager = spice_usb_device_manager_get(self->priv->session, NULL);
|
||||
if (manager)
|
||||
g_signal_connect(manager, "auto-connect-failed",
|
||||
G_CALLBACK(usb_connect_failed), self);
|
||||
|
||||
g_object_bind_property(self, "auto-usbredir",
|
||||
self->priv->gtk_session, "auto-usbredir",
|
||||
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property(self, "auto-usbredir",
|
||||
self->priv->gtk_session, "auto-usbredir",
|
||||
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_spice_close(VirtViewerSession *session)
|
||||
{
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
|
||||
g_return_if_fail(self != NULL);
|
||||
g_return_if_fail(self != NULL);
|
||||
|
||||
virt_viewer_session_clear_displays(session);
|
||||
virt_viewer_session_clear_displays(session);
|
||||
|
||||
if (self->priv->session) {
|
||||
spice_session_disconnect(self->priv->session);
|
||||
g_object_unref(self->priv->session);
|
||||
self->priv->session = NULL;
|
||||
self->priv->gtk_session = NULL;
|
||||
if (self->priv->session) {
|
||||
spice_session_disconnect(self->priv->session);
|
||||
g_object_unref(self->priv->session);
|
||||
self->priv->session = NULL;
|
||||
self->priv->gtk_session = NULL;
|
||||
|
||||
if (self->priv->audio)
|
||||
g_object_unref(self->priv->audio);
|
||||
self->priv->audio = NULL;
|
||||
}
|
||||
if (self->priv->audio)
|
||||
g_object_unref(self->priv->audio);
|
||||
self->priv->audio = NULL;
|
||||
}
|
||||
|
||||
/* FIXME: version 0.7 of spice-gtk allows reuse of session */
|
||||
create_spice_session(self);
|
||||
/* FIXME: version 0.7 of spice-gtk allows reuse of session */
|
||||
create_spice_session(self);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
virt_viewer_session_spice_open_host(VirtViewerSession *session,
|
||||
char *host,
|
||||
char *port)
|
||||
char *host,
|
||||
char *port)
|
||||
{
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
g_return_val_if_fail(self->priv->session != NULL, FALSE);
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
g_return_val_if_fail(self->priv->session != NULL, FALSE);
|
||||
|
||||
g_object_set(self->priv->session,
|
||||
"host", host,
|
||||
"port", port,
|
||||
NULL);
|
||||
g_object_set(self->priv->session,
|
||||
"host", host,
|
||||
"port", port,
|
||||
NULL);
|
||||
|
||||
return spice_session_connect(self->priv->session);
|
||||
return spice_session_connect(self->priv->session);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
virt_viewer_session_spice_open_uri(VirtViewerSession *session,
|
||||
char *uri)
|
||||
char *uri)
|
||||
{
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
g_return_val_if_fail(self->priv->session != NULL, FALSE);
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
g_return_val_if_fail(self->priv->session != NULL, FALSE);
|
||||
|
||||
g_object_set(self->priv->session, "uri", uri, NULL);
|
||||
g_object_set(self->priv->session, "uri", uri, NULL);
|
||||
|
||||
return spice_session_connect(self->priv->session);
|
||||
return spice_session_connect(self->priv->session);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
virt_viewer_session_spice_open_fd(VirtViewerSession *session,
|
||||
int fd)
|
||||
int fd)
|
||||
{
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
|
||||
return spice_session_open_fd(self->priv->session, fd);
|
||||
return spice_session_open_fd(self->priv->session, fd);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
virt_viewer_session_spice_channel_open_fd(VirtViewerSession *session,
|
||||
VirtViewerSessionChannel *channel,
|
||||
int fd)
|
||||
VirtViewerSessionChannel *channel,
|
||||
int fd)
|
||||
{
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
|
||||
return spice_channel_open_fd(SPICE_CHANNEL(channel), fd);
|
||||
return spice_channel_open_fd(SPICE_CHANNEL(channel), fd);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_spice_channel_open_fd_request(SpiceChannel *channel,
|
||||
gint tls G_GNUC_UNUSED,
|
||||
VirtViewerSession *session)
|
||||
gint tls G_GNUC_UNUSED,
|
||||
VirtViewerSession *session)
|
||||
{
|
||||
g_signal_emit_by_name(session, "session-channel-open", channel);
|
||||
g_signal_emit_by_name(session, "session-channel-open", channel);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_spice_main_channel_event(SpiceChannel *channel G_GNUC_UNUSED,
|
||||
SpiceChannelEvent event,
|
||||
VirtViewerSession *session)
|
||||
SpiceChannelEvent event,
|
||||
VirtViewerSession *session)
|
||||
{
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
char *password = NULL;
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
char *password = NULL;
|
||||
|
||||
g_return_if_fail(self != NULL);
|
||||
g_return_if_fail(self != NULL);
|
||||
|
||||
switch (event) {
|
||||
case SPICE_CHANNEL_OPENED:
|
||||
DEBUG_LOG("main channel: opened");
|
||||
break;
|
||||
case SPICE_CHANNEL_CLOSED:
|
||||
DEBUG_LOG("main channel: closed");
|
||||
g_signal_emit_by_name(session, "session-disconnected");
|
||||
break;
|
||||
case SPICE_CHANNEL_ERROR_CONNECT:
|
||||
DEBUG_LOG("main channel: failed to connect");
|
||||
g_signal_emit_by_name(session, "session-disconnected");
|
||||
break;
|
||||
case SPICE_CHANNEL_ERROR_AUTH:
|
||||
DEBUG_LOG("main channel: auth failure (wrong password?)");
|
||||
int ret = virt_viewer_auth_collect_credentials("SPICE",
|
||||
NULL,
|
||||
NULL, &password);
|
||||
if (ret < 0) {
|
||||
g_signal_emit_by_name(session, "session-cancelled");
|
||||
} else {
|
||||
g_object_set(self->priv->session, "password", password, NULL);
|
||||
spice_session_connect(self->priv->session);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_message("unhandled spice main channel event: %d", event);
|
||||
g_signal_emit_by_name(session, "session-disconnected");
|
||||
break;
|
||||
}
|
||||
switch (event) {
|
||||
case SPICE_CHANNEL_OPENED:
|
||||
DEBUG_LOG("main channel: opened");
|
||||
break;
|
||||
case SPICE_CHANNEL_CLOSED:
|
||||
DEBUG_LOG("main channel: closed");
|
||||
g_signal_emit_by_name(session, "session-disconnected");
|
||||
break;
|
||||
case SPICE_CHANNEL_ERROR_CONNECT:
|
||||
DEBUG_LOG("main channel: failed to connect");
|
||||
g_signal_emit_by_name(session, "session-disconnected");
|
||||
break;
|
||||
case SPICE_CHANNEL_ERROR_AUTH:
|
||||
DEBUG_LOG("main channel: auth failure (wrong password?)");
|
||||
int ret = virt_viewer_auth_collect_credentials("SPICE",
|
||||
NULL,
|
||||
NULL, &password);
|
||||
if (ret < 0) {
|
||||
g_signal_emit_by_name(session, "session-cancelled");
|
||||
} else {
|
||||
g_object_set(self->priv->session, "password", password, NULL);
|
||||
spice_session_connect(self->priv->session);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_message("unhandled spice main channel event: %d", event);
|
||||
g_signal_emit_by_name(session, "session-disconnected");
|
||||
break;
|
||||
}
|
||||
|
||||
g_free(password);
|
||||
g_free(password);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
virt_viewer_session_spice_has_usb(VirtViewerSession *session)
|
||||
{
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
VirtViewerSessionSpicePrivate *priv = self->priv;
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
VirtViewerSessionSpicePrivate *priv = self->priv;
|
||||
|
||||
return spice_usb_device_manager_get(priv->session, NULL) &&
|
||||
spice_session_has_channel_type(priv->session,
|
||||
SPICE_CHANNEL_USBREDIR);
|
||||
return spice_usb_device_manager_get(priv->session, NULL) &&
|
||||
spice_session_has_channel_type(priv->session,
|
||||
SPICE_CHANNEL_USBREDIR);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_spice_usb_device_selection(VirtViewerSession *session,
|
||||
GtkWindow *parent)
|
||||
GtkWindow *parent)
|
||||
{
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
VirtViewerSessionSpicePrivate *priv = self->priv;
|
||||
GtkWidget *dialog, *area, *usb_device_widget;
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
VirtViewerSessionSpicePrivate *priv = self->priv;
|
||||
GtkWidget *dialog, *area, *usb_device_widget;
|
||||
|
||||
/* Create the widgets */
|
||||
dialog = gtk_dialog_new_with_buttons(
|
||||
_("Select USB devices for redirection"), parent,
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
|
||||
area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
||||
/* Create the widgets */
|
||||
dialog = gtk_dialog_new_with_buttons(
|
||||
_("Select USB devices for redirection"), parent,
|
||||
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
|
||||
NULL);
|
||||
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
|
||||
area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
||||
|
||||
usb_device_widget = spice_usb_device_widget_new(priv->session,
|
||||
"%s %s");
|
||||
g_signal_connect(usb_device_widget, "connect-failed",
|
||||
G_CALLBACK(usb_connect_failed), self);
|
||||
gtk_box_pack_start(GTK_BOX(area), usb_device_widget, TRUE, TRUE, 5);
|
||||
usb_device_widget = spice_usb_device_widget_new(priv->session,
|
||||
"%s %s");
|
||||
g_signal_connect(usb_device_widget, "connect-failed",
|
||||
G_CALLBACK(usb_connect_failed), self);
|
||||
gtk_box_pack_start(GTK_BOX(area), usb_device_widget, TRUE, TRUE, 5);
|
||||
|
||||
/* show and run */
|
||||
gtk_widget_show_all(dialog);
|
||||
gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
gtk_widget_destroy(dialog);
|
||||
/* show and run */
|
||||
gtk_widget_show_all(dialog);
|
||||
gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
gtk_widget_destroy(dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_spice_channel_new(SpiceSession *s,
|
||||
SpiceChannel *channel,
|
||||
VirtViewerSession *session)
|
||||
SpiceChannel *channel,
|
||||
VirtViewerSession *session)
|
||||
{
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
int id;
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
int id;
|
||||
|
||||
g_return_if_fail(self != NULL);
|
||||
g_return_if_fail(self != NULL);
|
||||
|
||||
g_signal_connect(channel, "open-fd",
|
||||
G_CALLBACK(virt_viewer_session_spice_channel_open_fd_request), self);
|
||||
g_signal_connect(channel, "open-fd",
|
||||
G_CALLBACK(virt_viewer_session_spice_channel_open_fd_request), self);
|
||||
|
||||
g_object_get(channel, "channel-id", &id, NULL);
|
||||
g_object_get(channel, "channel-id", &id, NULL);
|
||||
|
||||
if (SPICE_IS_MAIN_CHANNEL(channel)) {
|
||||
g_signal_connect(channel, "channel-event",
|
||||
G_CALLBACK(virt_viewer_session_spice_main_channel_event), self);
|
||||
}
|
||||
if (SPICE_IS_MAIN_CHANNEL(channel)) {
|
||||
g_signal_connect(channel, "channel-event",
|
||||
G_CALLBACK(virt_viewer_session_spice_main_channel_event), self);
|
||||
}
|
||||
|
||||
if (SPICE_IS_DISPLAY_CHANNEL(channel)) {
|
||||
GtkWidget *display;
|
||||
if (SPICE_IS_DISPLAY_CHANNEL(channel)) {
|
||||
GtkWidget *display;
|
||||
|
||||
g_signal_emit_by_name(session, "session-connected");
|
||||
g_signal_emit_by_name(session, "session-connected");
|
||||
|
||||
DEBUG_LOG("new session channel (#%d)", id);
|
||||
display = virt_viewer_display_spice_new(channel,
|
||||
spice_display_new(s, id));
|
||||
DEBUG_LOG("new session channel (#%d)", id);
|
||||
display = virt_viewer_display_spice_new(channel,
|
||||
spice_display_new(s, id));
|
||||
|
||||
virt_viewer_session_add_display(VIRT_VIEWER_SESSION(session),
|
||||
VIRT_VIEWER_DISPLAY(display));
|
||||
virt_viewer_session_add_display(VIRT_VIEWER_SESSION(session),
|
||||
VIRT_VIEWER_DISPLAY(display));
|
||||
|
||||
g_signal_emit_by_name(session, "session-initialized");
|
||||
}
|
||||
g_signal_emit_by_name(session, "session-initialized");
|
||||
}
|
||||
|
||||
if (SPICE_IS_INPUTS_CHANNEL(channel)) {
|
||||
DEBUG_LOG("new inputs channel");
|
||||
}
|
||||
if (SPICE_IS_INPUTS_CHANNEL(channel)) {
|
||||
DEBUG_LOG("new inputs channel");
|
||||
}
|
||||
|
||||
if (SPICE_IS_PLAYBACK_CHANNEL(channel)) {
|
||||
DEBUG_LOG("new audio channel");
|
||||
if (self->priv->audio != NULL)
|
||||
return;
|
||||
self->priv->audio = spice_audio_new(s, NULL, NULL);
|
||||
}
|
||||
if (SPICE_IS_PLAYBACK_CHANNEL(channel)) {
|
||||
DEBUG_LOG("new audio channel");
|
||||
if (self->priv->audio != NULL)
|
||||
return;
|
||||
self->priv->audio = spice_audio_new(s, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_spice_channel_destroy(G_GNUC_UNUSED SpiceSession *s,
|
||||
SpiceChannel *channel,
|
||||
VirtViewerSession *session)
|
||||
SpiceChannel *channel,
|
||||
VirtViewerSession *session)
|
||||
{
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
int id;
|
||||
VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
|
||||
int id;
|
||||
|
||||
g_return_if_fail(self != NULL);
|
||||
g_return_if_fail(self != NULL);
|
||||
|
||||
g_object_get(channel, "channel-id", &id, NULL);
|
||||
if (SPICE_IS_MAIN_CHANNEL(channel)) {
|
||||
DEBUG_LOG("zap main channel");
|
||||
}
|
||||
g_object_get(channel, "channel-id", &id, NULL);
|
||||
if (SPICE_IS_MAIN_CHANNEL(channel)) {
|
||||
DEBUG_LOG("zap main channel");
|
||||
}
|
||||
|
||||
if (SPICE_IS_DISPLAY_CHANNEL(channel)) {
|
||||
DEBUG_LOG("zap session channel (#%d)", id);
|
||||
}
|
||||
if (SPICE_IS_DISPLAY_CHANNEL(channel)) {
|
||||
DEBUG_LOG("zap session channel (#%d)", id);
|
||||
}
|
||||
|
||||
if (SPICE_IS_PLAYBACK_CHANNEL(channel) && self->priv->audio) {
|
||||
DEBUG_LOG("zap audio channel");
|
||||
g_object_unref(self->priv->audio);
|
||||
self->priv->audio = NULL;
|
||||
}
|
||||
if (SPICE_IS_PLAYBACK_CHANNEL(channel) && self->priv->audio) {
|
||||
DEBUG_LOG("zap audio channel");
|
||||
g_object_unref(self->priv->audio);
|
||||
self->priv->audio = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
VirtViewerSession *
|
||||
virt_viewer_session_spice_new(void)
|
||||
{
|
||||
VirtViewerSessionSpice *self;
|
||||
VirtViewerSessionSpice *self;
|
||||
|
||||
self = g_object_new(VIRT_VIEWER_TYPE_SESSION_SPICE, NULL);
|
||||
self = g_object_new(VIRT_VIEWER_TYPE_SESSION_SPICE, NULL);
|
||||
|
||||
create_spice_session(self);
|
||||
create_spice_session(self);
|
||||
|
||||
return VIRT_VIEWER_SESSION(self);
|
||||
return VIRT_VIEWER_SESSION(self);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -34,33 +34,33 @@ G_BEGIN_DECLS
|
||||
|
||||
#define VIRT_VIEWER_TYPE_SESSION_SPICE virt_viewer_session_spice_get_type()
|
||||
|
||||
#define VIRT_VIEWER_SESSION_SPICE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_SESSION_SPICE, VirtViewerSessionSpice))
|
||||
#define VIRT_VIEWER_SESSION_SPICE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_SESSION_SPICE, VirtViewerSessionSpice))
|
||||
|
||||
#define VIRT_VIEWER_SESSION_SPICE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_SESSION_SPICE, VirtViewerSessionSpiceClass))
|
||||
#define VIRT_VIEWER_SESSION_SPICE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_SESSION_SPICE, VirtViewerSessionSpiceClass))
|
||||
|
||||
#define VIRT_VIEWER_IS_SESSION_SPICE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_SESSION_SPICE))
|
||||
#define VIRT_VIEWER_IS_SESSION_SPICE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_SESSION_SPICE))
|
||||
|
||||
#define VIRT_VIEWER_IS_SESSION_SPICE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_SESSION_SPICE))
|
||||
#define VIRT_VIEWER_IS_SESSION_SPICE_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_SESSION_SPICE))
|
||||
|
||||
#define VIRT_VIEWER_SESSION_SPICE_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_SESSION_SPICE, VirtViewerSessionSpiceClass))
|
||||
#define VIRT_VIEWER_SESSION_SPICE_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_SESSION_SPICE, VirtViewerSessionSpiceClass))
|
||||
|
||||
typedef struct _VirtViewerSessionSpice VirtViewerSessionSpice;
|
||||
typedef struct _VirtViewerSessionSpiceClass VirtViewerSessionSpiceClass;
|
||||
typedef struct _VirtViewerSessionSpicePrivate VirtViewerSessionSpicePrivate;
|
||||
|
||||
struct _VirtViewerSessionSpice {
|
||||
VirtViewerSession parent;
|
||||
VirtViewerSession parent;
|
||||
|
||||
VirtViewerSessionSpicePrivate *priv;
|
||||
VirtViewerSessionSpicePrivate *priv;
|
||||
};
|
||||
|
||||
struct _VirtViewerSessionSpiceClass {
|
||||
VirtViewerSessionClass parent_class;
|
||||
VirtViewerSessionClass parent_class;
|
||||
};
|
||||
|
||||
GType virt_viewer_session_spice_get_type(void);
|
||||
@ -70,11 +70,10 @@ VirtViewerSession* virt_viewer_session_spice_new(void);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _VIRT_VIEWER_SESSION_SPICE_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -32,8 +32,8 @@
|
||||
G_DEFINE_TYPE(VirtViewerSessionVnc, virt_viewer_session_vnc, VIRT_VIEWER_TYPE_SESSION)
|
||||
|
||||
struct _VirtViewerSessionVncPrivate {
|
||||
/* XXX we should really just have a VncConnection */
|
||||
VncDisplay *vnc;
|
||||
/* XXX we should really just have a VncConnection */
|
||||
VncDisplay *vnc;
|
||||
};
|
||||
|
||||
#define VIRT_VIEWER_SESSION_VNC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), VIRT_VIEWER_TYPE_SESSION_VNC, VirtViewerSessionVncPrivate))
|
||||
@ -43,243 +43,240 @@ static gboolean virt_viewer_session_vnc_open_fd(VirtViewerSession* session, int
|
||||
static gboolean virt_viewer_session_vnc_open_host(VirtViewerSession* session, char *host, char *port);
|
||||
static gboolean virt_viewer_session_vnc_open_uri(VirtViewerSession* session, char *uri);
|
||||
static gboolean virt_viewer_session_vnc_channel_open_fd(VirtViewerSession* session,
|
||||
VirtViewerSessionChannel* channel, int fd);
|
||||
VirtViewerSessionChannel* channel, int fd);
|
||||
|
||||
|
||||
static void
|
||||
virt_viewer_session_vnc_finalize(GObject *obj)
|
||||
{
|
||||
VirtViewerSessionVnc *vnc = VIRT_VIEWER_SESSION_VNC(obj);
|
||||
VirtViewerSessionVnc *vnc = VIRT_VIEWER_SESSION_VNC(obj);
|
||||
|
||||
if (vnc->priv->vnc) {
|
||||
vnc_display_close(vnc->priv->vnc);
|
||||
g_object_unref(vnc->priv->vnc);
|
||||
}
|
||||
if (vnc->priv->vnc) {
|
||||
vnc_display_close(vnc->priv->vnc);
|
||||
g_object_unref(vnc->priv->vnc);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS(virt_viewer_session_vnc_parent_class)->finalize(obj);
|
||||
G_OBJECT_CLASS(virt_viewer_session_vnc_parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virt_viewer_session_vnc_class_init(VirtViewerSessionVncClass *klass)
|
||||
{
|
||||
VirtViewerSessionClass *dclass = VIRT_VIEWER_SESSION_CLASS(klass);
|
||||
GObjectClass *oclass = G_OBJECT_CLASS(klass);
|
||||
VirtViewerSessionClass *dclass = VIRT_VIEWER_SESSION_CLASS(klass);
|
||||
GObjectClass *oclass = G_OBJECT_CLASS(klass);
|
||||
|
||||
oclass->finalize = virt_viewer_session_vnc_finalize;
|
||||
oclass->finalize = virt_viewer_session_vnc_finalize;
|
||||
|
||||
dclass->close = virt_viewer_session_vnc_close;
|
||||
dclass->open_fd = virt_viewer_session_vnc_open_fd;
|
||||
dclass->open_host = virt_viewer_session_vnc_open_host;
|
||||
dclass->open_uri = virt_viewer_session_vnc_open_uri;
|
||||
dclass->channel_open_fd = virt_viewer_session_vnc_channel_open_fd;
|
||||
dclass->close = virt_viewer_session_vnc_close;
|
||||
dclass->open_fd = virt_viewer_session_vnc_open_fd;
|
||||
dclass->open_host = virt_viewer_session_vnc_open_host;
|
||||
dclass->open_uri = virt_viewer_session_vnc_open_uri;
|
||||
dclass->channel_open_fd = virt_viewer_session_vnc_channel_open_fd;
|
||||
|
||||
g_type_class_add_private(klass, sizeof(VirtViewerSessionVncPrivate));
|
||||
g_type_class_add_private(klass, sizeof(VirtViewerSessionVncPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_vnc_init(VirtViewerSessionVnc *self G_GNUC_UNUSED)
|
||||
{
|
||||
self->priv = VIRT_VIEWER_SESSION_VNC_GET_PRIVATE(self);
|
||||
self->priv = VIRT_VIEWER_SESSION_VNC_GET_PRIVATE(self);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_vnc_connected(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
VirtViewerSessionVnc *session)
|
||||
VirtViewerSessionVnc *session)
|
||||
{
|
||||
GtkWidget *display = virt_viewer_display_vnc_new(session->priv->vnc);
|
||||
g_signal_emit_by_name(session, "session-connected");
|
||||
virt_viewer_display_set_show_hint(VIRT_VIEWER_DISPLAY(display),
|
||||
VIRT_VIEWER_DISPLAY_SHOW_HINT_READY);
|
||||
virt_viewer_session_add_display(VIRT_VIEWER_SESSION(session),
|
||||
VIRT_VIEWER_DISPLAY(display));
|
||||
GtkWidget *display = virt_viewer_display_vnc_new(session->priv->vnc);
|
||||
g_signal_emit_by_name(session, "session-connected");
|
||||
virt_viewer_display_set_show_hint(VIRT_VIEWER_DISPLAY(display),
|
||||
VIRT_VIEWER_DISPLAY_SHOW_HINT_READY);
|
||||
virt_viewer_session_add_display(VIRT_VIEWER_SESSION(session),
|
||||
VIRT_VIEWER_DISPLAY(display));
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_vnc_disconnected(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
VirtViewerSessionVnc *session)
|
||||
VirtViewerSessionVnc *session)
|
||||
{
|
||||
g_signal_emit_by_name(session, "session-disconnected");
|
||||
/* TODO perhaps? */
|
||||
/* virt_viewer_display_set_show_hint(VIRT_VIEWER_DISPLAY(session->priv->vnc), */
|
||||
/* VIRT_VIEWER_DISPLAY_SHOW_HINT_HIDE); */
|
||||
g_signal_emit_by_name(session, "session-disconnected");
|
||||
/* TODO perhaps? */
|
||||
/* virt_viewer_display_set_show_hint(VIRT_VIEWER_DISPLAY(session->priv->vnc), */
|
||||
/* VIRT_VIEWER_DISPLAY_SHOW_HINT_HIDE); */
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_vnc_initialized(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
VirtViewerSessionVnc *session)
|
||||
VirtViewerSessionVnc *session)
|
||||
{
|
||||
g_signal_emit_by_name(session, "session-initialized");
|
||||
g_signal_emit_by_name(session, "session-initialized");
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_vnc_cut_text(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
const char *text,
|
||||
VirtViewerSession *session)
|
||||
const char *text,
|
||||
VirtViewerSession *session)
|
||||
{
|
||||
g_signal_emit_by_name(session, "session-cut-text", text);
|
||||
g_signal_emit_by_name(session, "session-cut-text", text);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_vnc_bell(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
VirtViewerSession *session)
|
||||
VirtViewerSession *session)
|
||||
{
|
||||
g_signal_emit_by_name(session, "session-bell");
|
||||
g_signal_emit_by_name(session, "session-bell");
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_vnc_auth_unsupported(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
unsigned int authType,
|
||||
VirtViewerSession *session)
|
||||
unsigned int authType,
|
||||
VirtViewerSession *session)
|
||||
{
|
||||
char *msg = g_strdup_printf(_("Unsupported authentication type %d"),
|
||||
authType);
|
||||
g_signal_emit_by_name(session, "session-auth-failed", msg);
|
||||
g_free(msg);
|
||||
char *msg = g_strdup_printf(_("Unsupported authentication type %d"),
|
||||
authType);
|
||||
g_signal_emit_by_name(session, "session-auth-failed", msg);
|
||||
g_free(msg);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_vnc_auth_failure(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
const char *reason,
|
||||
VirtViewerSession *session)
|
||||
const char *reason,
|
||||
VirtViewerSession *session)
|
||||
{
|
||||
|
||||
g_signal_emit_by_name(session, "session-auth-refused", reason);
|
||||
g_signal_emit_by_name(session, "session-auth-refused", reason);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static gboolean
|
||||
virt_viewer_session_vnc_open_fd(VirtViewerSession* session,
|
||||
int fd)
|
||||
int fd)
|
||||
{
|
||||
VirtViewerSessionVnc *self = VIRT_VIEWER_SESSION_VNC(session);
|
||||
VirtViewerSessionVnc *self = VIRT_VIEWER_SESSION_VNC(session);
|
||||
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
g_return_val_if_fail(self->priv->vnc != NULL, FALSE);
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
g_return_val_if_fail(self->priv->vnc != NULL, FALSE);
|
||||
|
||||
return vnc_display_open_fd(self->priv->vnc, fd);
|
||||
return vnc_display_open_fd(self->priv->vnc, fd);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
virt_viewer_session_vnc_channel_open_fd(VirtViewerSession* session G_GNUC_UNUSED,
|
||||
VirtViewerSessionChannel* channel G_GNUC_UNUSED,
|
||||
int fd G_GNUC_UNUSED)
|
||||
VirtViewerSessionChannel* channel G_GNUC_UNUSED,
|
||||
int fd G_GNUC_UNUSED)
|
||||
{
|
||||
g_warning("channel_open_fd is not supported by VNC");
|
||||
return FALSE;
|
||||
g_warning("channel_open_fd is not supported by VNC");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
virt_viewer_session_vnc_open_host(VirtViewerSession* session,
|
||||
char *host,
|
||||
char *port)
|
||||
char *host,
|
||||
char *port)
|
||||
{
|
||||
VirtViewerSessionVnc *self = VIRT_VIEWER_SESSION_VNC(session);
|
||||
VirtViewerSessionVnc *self = VIRT_VIEWER_SESSION_VNC(session);
|
||||
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
g_return_val_if_fail(self->priv->vnc != NULL, FALSE);
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
g_return_val_if_fail(self->priv->vnc != NULL, FALSE);
|
||||
|
||||
return vnc_display_open_host(self->priv->vnc, host, port);
|
||||
return vnc_display_open_host(self->priv->vnc, host, port);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
virt_viewer_session_vnc_open_uri(VirtViewerSession* session,
|
||||
char *uristr)
|
||||
char *uristr)
|
||||
{
|
||||
VirtViewerSessionVnc *self = VIRT_VIEWER_SESSION_VNC(session);
|
||||
xmlURIPtr uri = NULL;
|
||||
gchar *portstr;
|
||||
gboolean ret;
|
||||
VirtViewerSessionVnc *self = VIRT_VIEWER_SESSION_VNC(session);
|
||||
xmlURIPtr uri = NULL;
|
||||
gchar *portstr;
|
||||
gboolean ret;
|
||||
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
g_return_val_if_fail(self->priv->vnc != NULL, FALSE);
|
||||
g_return_val_if_fail(self != NULL, FALSE);
|
||||
g_return_val_if_fail(self->priv->vnc != NULL, FALSE);
|
||||
|
||||
if (!(uri = xmlParseURI(uristr)))
|
||||
return FALSE;
|
||||
if (!(uri = xmlParseURI(uristr)))
|
||||
return FALSE;
|
||||
|
||||
portstr = g_strdup_printf("%d", uri->port);
|
||||
portstr = g_strdup_printf("%d", uri->port);
|
||||
|
||||
ret = vnc_display_open_host(self->priv->vnc, uri->server, portstr);
|
||||
g_free(portstr);
|
||||
xmlFreeURI(uri);
|
||||
return ret;
|
||||
ret = vnc_display_open_host(self->priv->vnc, uri->server, portstr);
|
||||
g_free(portstr);
|
||||
xmlFreeURI(uri);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_vnc_close(VirtViewerSession* session)
|
||||
{
|
||||
VirtViewerSessionVnc *self = VIRT_VIEWER_SESSION_VNC(session);
|
||||
VirtViewerSessionVnc *self = VIRT_VIEWER_SESSION_VNC(session);
|
||||
|
||||
g_return_if_fail(self != NULL);
|
||||
g_return_if_fail(self != NULL);
|
||||
|
||||
if (self->priv->vnc != NULL) {
|
||||
virt_viewer_session_clear_displays(session);
|
||||
vnc_display_close(self->priv->vnc);
|
||||
g_object_unref(self->priv->vnc);
|
||||
}
|
||||
if (self->priv->vnc != NULL) {
|
||||
virt_viewer_session_clear_displays(session);
|
||||
vnc_display_close(self->priv->vnc);
|
||||
g_object_unref(self->priv->vnc);
|
||||
}
|
||||
|
||||
self->priv->vnc = VNC_DISPLAY(vnc_display_new());
|
||||
self->priv->vnc = VNC_DISPLAY(vnc_display_new());
|
||||
|
||||
g_signal_connect(self->priv->vnc, "vnc-connected",
|
||||
G_CALLBACK(virt_viewer_session_vnc_connected), session);
|
||||
g_signal_connect(self->priv->vnc, "vnc-initialized",
|
||||
G_CALLBACK(virt_viewer_session_vnc_initialized), session);
|
||||
g_signal_connect(self->priv->vnc, "vnc-disconnected",
|
||||
G_CALLBACK(virt_viewer_session_vnc_disconnected), session);
|
||||
g_signal_connect(self->priv->vnc, "vnc-connected",
|
||||
G_CALLBACK(virt_viewer_session_vnc_connected), session);
|
||||
g_signal_connect(self->priv->vnc, "vnc-initialized",
|
||||
G_CALLBACK(virt_viewer_session_vnc_initialized), session);
|
||||
g_signal_connect(self->priv->vnc, "vnc-disconnected",
|
||||
G_CALLBACK(virt_viewer_session_vnc_disconnected), session);
|
||||
|
||||
g_signal_connect(self->priv->vnc, "vnc-bell",
|
||||
G_CALLBACK(virt_viewer_session_vnc_bell), session);
|
||||
g_signal_connect(self->priv->vnc, "vnc-auth-failure",
|
||||
G_CALLBACK(virt_viewer_session_vnc_auth_failure), session);
|
||||
g_signal_connect(self->priv->vnc, "vnc-auth-unsupported",
|
||||
G_CALLBACK(virt_viewer_session_vnc_auth_unsupported), session);
|
||||
g_signal_connect(self->priv->vnc, "vnc-server-cut-text",
|
||||
G_CALLBACK(virt_viewer_session_vnc_cut_text), session);
|
||||
g_signal_connect(self->priv->vnc, "vnc-bell",
|
||||
G_CALLBACK(virt_viewer_session_vnc_bell), session);
|
||||
g_signal_connect(self->priv->vnc, "vnc-auth-failure",
|
||||
G_CALLBACK(virt_viewer_session_vnc_auth_failure), session);
|
||||
g_signal_connect(self->priv->vnc, "vnc-auth-unsupported",
|
||||
G_CALLBACK(virt_viewer_session_vnc_auth_unsupported), session);
|
||||
g_signal_connect(self->priv->vnc, "vnc-server-cut-text",
|
||||
G_CALLBACK(virt_viewer_session_vnc_cut_text), session);
|
||||
|
||||
g_signal_connect(self->priv->vnc, "vnc-auth-credential",
|
||||
G_CALLBACK(virt_viewer_auth_vnc_credentials), NULL);
|
||||
g_signal_connect(self->priv->vnc, "vnc-auth-credential",
|
||||
G_CALLBACK(virt_viewer_auth_vnc_credentials), NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
VirtViewerSession *
|
||||
virt_viewer_session_vnc_new(void)
|
||||
{
|
||||
VirtViewerSessionVnc *session;
|
||||
VirtViewerSessionVnc *session;
|
||||
|
||||
session = g_object_new(VIRT_VIEWER_TYPE_SESSION_VNC, NULL);
|
||||
session = g_object_new(VIRT_VIEWER_TYPE_SESSION_VNC, NULL);
|
||||
|
||||
session->priv->vnc = VNC_DISPLAY(vnc_display_new());
|
||||
session->priv->vnc = VNC_DISPLAY(vnc_display_new());
|
||||
|
||||
g_signal_connect(session->priv->vnc, "vnc-connected",
|
||||
G_CALLBACK(virt_viewer_session_vnc_connected), session);
|
||||
g_signal_connect(session->priv->vnc, "vnc-initialized",
|
||||
G_CALLBACK(virt_viewer_session_vnc_initialized), session);
|
||||
g_signal_connect(session->priv->vnc, "vnc-disconnected",
|
||||
G_CALLBACK(virt_viewer_session_vnc_disconnected), session);
|
||||
g_signal_connect(session->priv->vnc, "vnc-connected",
|
||||
G_CALLBACK(virt_viewer_session_vnc_connected), session);
|
||||
g_signal_connect(session->priv->vnc, "vnc-initialized",
|
||||
G_CALLBACK(virt_viewer_session_vnc_initialized), session);
|
||||
g_signal_connect(session->priv->vnc, "vnc-disconnected",
|
||||
G_CALLBACK(virt_viewer_session_vnc_disconnected), session);
|
||||
|
||||
g_signal_connect(session->priv->vnc, "vnc-bell",
|
||||
G_CALLBACK(virt_viewer_session_vnc_bell), session);
|
||||
g_signal_connect(session->priv->vnc, "vnc-auth-failure",
|
||||
G_CALLBACK(virt_viewer_session_vnc_auth_failure), session);
|
||||
g_signal_connect(session->priv->vnc, "vnc-auth-unsupported",
|
||||
G_CALLBACK(virt_viewer_session_vnc_auth_unsupported), session);
|
||||
g_signal_connect(session->priv->vnc, "vnc-server-cut-text",
|
||||
G_CALLBACK(virt_viewer_session_vnc_cut_text), session);
|
||||
g_signal_connect(session->priv->vnc, "vnc-bell",
|
||||
G_CALLBACK(virt_viewer_session_vnc_bell), session);
|
||||
g_signal_connect(session->priv->vnc, "vnc-auth-failure",
|
||||
G_CALLBACK(virt_viewer_session_vnc_auth_failure), session);
|
||||
g_signal_connect(session->priv->vnc, "vnc-auth-unsupported",
|
||||
G_CALLBACK(virt_viewer_session_vnc_auth_unsupported), session);
|
||||
g_signal_connect(session->priv->vnc, "vnc-server-cut-text",
|
||||
G_CALLBACK(virt_viewer_session_vnc_cut_text), session);
|
||||
|
||||
g_signal_connect(session->priv->vnc, "vnc-auth-credential",
|
||||
G_CALLBACK(virt_viewer_auth_vnc_credentials), NULL);
|
||||
g_signal_connect(session->priv->vnc, "vnc-auth-credential",
|
||||
G_CALLBACK(virt_viewer_auth_vnc_credentials), NULL);
|
||||
|
||||
return VIRT_VIEWER_SESSION(session);
|
||||
return VIRT_VIEWER_SESSION(session);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -33,33 +33,33 @@ G_BEGIN_DECLS
|
||||
|
||||
#define VIRT_VIEWER_TYPE_SESSION_VNC virt_viewer_session_vnc_get_type()
|
||||
|
||||
#define VIRT_VIEWER_SESSION_VNC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_SESSION_VNC, VirtViewerSessionVnc))
|
||||
#define VIRT_VIEWER_SESSION_VNC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_SESSION_VNC, VirtViewerSessionVnc))
|
||||
|
||||
#define VIRT_VIEWER_SESSION_VNC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_SESSION_VNC, VirtViewerSessionVncClass))
|
||||
#define VIRT_VIEWER_SESSION_VNC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_SESSION_VNC, VirtViewerSessionVncClass))
|
||||
|
||||
#define VIRT_VIEWER_IS_SESSION_VNC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_SESSION_VNC))
|
||||
#define VIRT_VIEWER_IS_SESSION_VNC(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_SESSION_VNC))
|
||||
|
||||
#define VIRT_VIEWER_IS_SESSION_VNC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_SESSION_VNC))
|
||||
#define VIRT_VIEWER_IS_SESSION_VNC_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_SESSION_VNC))
|
||||
|
||||
#define VIRT_VIEWER_SESSION_VNC_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_SESSION_VNC, VirtViewerSessionVncClass))
|
||||
#define VIRT_VIEWER_SESSION_VNC_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_SESSION_VNC, VirtViewerSessionVncClass))
|
||||
|
||||
typedef struct _VirtViewerSessionVnc VirtViewerSessionVnc;
|
||||
typedef struct _VirtViewerSessionVncClass VirtViewerSessionVncClass;
|
||||
typedef struct _VirtViewerSessionVncPrivate VirtViewerSessionVncPrivate;
|
||||
|
||||
struct _VirtViewerSessionVnc {
|
||||
VirtViewerSession parent;
|
||||
VirtViewerSession parent;
|
||||
|
||||
VirtViewerSessionVncPrivate *priv;
|
||||
VirtViewerSessionVncPrivate *priv;
|
||||
};
|
||||
|
||||
struct _VirtViewerSessionVncClass {
|
||||
VirtViewerSessionClass parent_class;
|
||||
VirtViewerSessionClass parent_class;
|
||||
};
|
||||
|
||||
GType virt_viewer_session_vnc_get_type(void);
|
||||
@ -69,11 +69,10 @@ VirtViewerSession *virt_viewer_session_vnc_new(void);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _VIRT_VIEWER_SESSION_VNC_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -34,355 +34,354 @@
|
||||
|
||||
struct _VirtViewerSessionPrivate
|
||||
{
|
||||
GList *displays;
|
||||
GList *displays;
|
||||
|
||||
gboolean auto_usbredir;
|
||||
gboolean auto_usbredir;
|
||||
};
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE(VirtViewerSession, virt_viewer_session, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_0,
|
||||
|
||||
PROP_AUTO_USBREDIR,
|
||||
PROP_AUTO_USBREDIR,
|
||||
};
|
||||
|
||||
static void
|
||||
virt_viewer_session_finalize(GObject *obj)
|
||||
{
|
||||
VirtViewerSession *session = VIRT_VIEWER_SESSION(obj);
|
||||
GList *tmp = session->priv->displays;
|
||||
VirtViewerSession *session = VIRT_VIEWER_SESSION(obj);
|
||||
GList *tmp = session->priv->displays;
|
||||
|
||||
while (tmp) {
|
||||
g_object_unref(tmp->data);
|
||||
tmp = tmp->next;
|
||||
}
|
||||
g_list_free(session->priv->displays);
|
||||
while (tmp) {
|
||||
g_object_unref(tmp->data);
|
||||
tmp = tmp->next;
|
||||
}
|
||||
g_list_free(session->priv->displays);
|
||||
|
||||
G_OBJECT_CLASS(virt_viewer_session_parent_class)->finalize(obj);
|
||||
G_OBJECT_CLASS(virt_viewer_session_parent_class)->finalize(obj);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_set_property(GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
VirtViewerSession *self = VIRT_VIEWER_SESSION(object);
|
||||
VirtViewerSession *self = VIRT_VIEWER_SESSION(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_AUTO_USBREDIR:
|
||||
virt_viewer_session_set_auto_usbredir(self, g_value_get_boolean(value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
switch (prop_id) {
|
||||
case PROP_AUTO_USBREDIR:
|
||||
virt_viewer_session_set_auto_usbredir(self, g_value_get_boolean(value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_get_property(GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
VirtViewerSession *self = VIRT_VIEWER_SESSION(object);
|
||||
VirtViewerSession *self = VIRT_VIEWER_SESSION(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_AUTO_USBREDIR:
|
||||
g_value_set_boolean(value, virt_viewer_session_get_auto_usbredir(self));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
switch (prop_id) {
|
||||
case PROP_AUTO_USBREDIR:
|
||||
g_value_set_boolean(value, virt_viewer_session_get_auto_usbredir(self));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_class_init(VirtViewerSessionClass *class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(class);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(class);
|
||||
|
||||
object_class->set_property = virt_viewer_session_set_property;
|
||||
object_class->get_property = virt_viewer_session_get_property;
|
||||
object_class->finalize = virt_viewer_session_finalize;
|
||||
object_class->set_property = virt_viewer_session_set_property;
|
||||
object_class->get_property = virt_viewer_session_get_property;
|
||||
object_class->finalize = virt_viewer_session_finalize;
|
||||
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_AUTO_USBREDIR,
|
||||
g_param_spec_boolean("auto-usbredir",
|
||||
"USB redirection",
|
||||
"USB redirection",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_AUTO_USBREDIR,
|
||||
g_param_spec_boolean("auto-usbredir",
|
||||
"USB redirection",
|
||||
"USB redirection",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_signal_new("session-connected",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_connected),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
g_signal_new("session-connected",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_connected),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
|
||||
g_signal_new("session-initialized",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_initialized),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
g_signal_new("session-initialized",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_initialized),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
|
||||
g_signal_new("session-disconnected",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_disconnected),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
g_signal_new("session-disconnected",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_disconnected),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
|
||||
g_signal_new("session-channel-open",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_channel_open),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_OBJECT);
|
||||
g_signal_new("session-channel-open",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_channel_open),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_OBJECT);
|
||||
|
||||
g_signal_new("session-auth-refused",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_auth_refused),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__STRING,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_STRING);
|
||||
g_signal_new("session-auth-refused",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_auth_refused),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__STRING,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_STRING);
|
||||
|
||||
g_signal_new("session-auth-failed",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_auth_failed),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__STRING,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_STRING);
|
||||
g_signal_new("session-auth-failed",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_auth_failed),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__STRING,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_STRING);
|
||||
|
||||
g_signal_new("session-usb-failed",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_usb_failed),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__STRING,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_STRING);
|
||||
g_signal_new("session-usb-failed",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_usb_failed),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__STRING,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_STRING);
|
||||
|
||||
g_signal_new("session-display-added",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_display_added),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
VIRT_VIEWER_TYPE_DISPLAY);
|
||||
g_signal_new("session-display-added",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_display_added),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
VIRT_VIEWER_TYPE_DISPLAY);
|
||||
|
||||
g_signal_new("session-display-removed",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_display_removed),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
VIRT_VIEWER_TYPE_DISPLAY);
|
||||
g_signal_new("session-display-removed",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_display_removed),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
VIRT_VIEWER_TYPE_DISPLAY);
|
||||
|
||||
g_signal_new("session-cut-text",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_cut_text),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__STRING,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_STRING);
|
||||
g_signal_new("session-cut-text",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_cut_text),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__STRING,
|
||||
G_TYPE_NONE,
|
||||
1,
|
||||
G_TYPE_STRING);
|
||||
|
||||
g_signal_new("session-bell",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_bell),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
g_signal_new("session-bell",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_bell),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
|
||||
g_signal_new("session-cancelled",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_cancelled),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
g_signal_new("session-cancelled",
|
||||
G_OBJECT_CLASS_TYPE(object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(VirtViewerSessionClass, session_cancelled),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
|
||||
g_type_class_add_private(class, sizeof(VirtViewerSessionPrivate));
|
||||
g_type_class_add_private(class, sizeof(VirtViewerSessionPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_session_init(VirtViewerSession *session)
|
||||
{
|
||||
session->priv = VIRT_VIEWER_SESSION_GET_PRIVATE(session);
|
||||
session->priv = VIRT_VIEWER_SESSION_GET_PRIVATE(session);
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
virt_viewer_session_new(void)
|
||||
{
|
||||
return g_object_new(VIRT_VIEWER_TYPE_SESSION, NULL);
|
||||
return g_object_new(VIRT_VIEWER_TYPE_SESSION, NULL);
|
||||
}
|
||||
|
||||
|
||||
void virt_viewer_session_add_display(VirtViewerSession *session,
|
||||
VirtViewerDisplay *display)
|
||||
VirtViewerDisplay *display)
|
||||
{
|
||||
session->priv->displays = g_list_append(session->priv->displays, display);
|
||||
g_object_ref(display);
|
||||
g_signal_emit_by_name(session, "session-display-added", display);
|
||||
session->priv->displays = g_list_append(session->priv->displays, display);
|
||||
g_object_ref(display);
|
||||
g_signal_emit_by_name(session, "session-display-added", display);
|
||||
}
|
||||
|
||||
|
||||
void virt_viewer_session_remove_display(VirtViewerSession *session,
|
||||
VirtViewerDisplay *display)
|
||||
VirtViewerDisplay *display)
|
||||
{
|
||||
if (!g_list_find(session->priv->displays, display))
|
||||
return;
|
||||
if (!g_list_find(session->priv->displays, display))
|
||||
return;
|
||||
|
||||
session->priv->displays = g_list_remove(session->priv->displays, display);
|
||||
g_signal_emit_by_name(session, "session-display-removed", display);
|
||||
g_object_unref(display);
|
||||
session->priv->displays = g_list_remove(session->priv->displays, display);
|
||||
g_signal_emit_by_name(session, "session-display-removed", display);
|
||||
g_object_unref(display);
|
||||
}
|
||||
|
||||
void virt_viewer_session_clear_displays(VirtViewerSession *session)
|
||||
{
|
||||
GList *tmp = session->priv->displays;
|
||||
GList *tmp = session->priv->displays;
|
||||
|
||||
while (tmp) {
|
||||
g_signal_emit_by_name(session, "session-display-removed", tmp->data);
|
||||
g_object_unref(tmp->data);
|
||||
tmp = tmp->next;
|
||||
}
|
||||
g_list_free(session->priv->displays);
|
||||
session->priv->displays = NULL;
|
||||
while (tmp) {
|
||||
g_signal_emit_by_name(session, "session-display-removed", tmp->data);
|
||||
g_object_unref(tmp->data);
|
||||
tmp = tmp->next;
|
||||
}
|
||||
g_list_free(session->priv->displays);
|
||||
session->priv->displays = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void virt_viewer_session_close(VirtViewerSession *session)
|
||||
{
|
||||
g_return_if_fail(VIRT_VIEWER_IS_SESSION(session));
|
||||
g_return_if_fail(VIRT_VIEWER_IS_SESSION(session));
|
||||
|
||||
VIRT_VIEWER_SESSION_GET_CLASS(session)->close(session);
|
||||
VIRT_VIEWER_SESSION_GET_CLASS(session)->close(session);
|
||||
}
|
||||
|
||||
gboolean virt_viewer_session_open_fd(VirtViewerSession *session, int fd)
|
||||
{
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(session), FALSE);
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(session), FALSE);
|
||||
|
||||
return VIRT_VIEWER_SESSION_GET_CLASS(session)->open_fd(session, fd);
|
||||
return VIRT_VIEWER_SESSION_GET_CLASS(session)->open_fd(session, fd);
|
||||
}
|
||||
|
||||
gboolean virt_viewer_session_open_host(VirtViewerSession *session, char *host, char *port)
|
||||
{
|
||||
VirtViewerSessionClass *klass;
|
||||
VirtViewerSessionClass *klass;
|
||||
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(session), FALSE);
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(session), FALSE);
|
||||
|
||||
klass = VIRT_VIEWER_SESSION_GET_CLASS(session);
|
||||
return klass->open_host(session, host, port);
|
||||
klass = VIRT_VIEWER_SESSION_GET_CLASS(session);
|
||||
return klass->open_host(session, host, port);
|
||||
}
|
||||
|
||||
gboolean virt_viewer_session_open_uri(VirtViewerSession *session, gchar *uri)
|
||||
{
|
||||
VirtViewerSessionClass *klass;
|
||||
VirtViewerSessionClass *klass;
|
||||
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(session), FALSE);
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(session), FALSE);
|
||||
|
||||
klass = VIRT_VIEWER_SESSION_GET_CLASS(session);
|
||||
g_return_val_if_fail(klass->open_uri != NULL, FALSE);
|
||||
klass = VIRT_VIEWER_SESSION_GET_CLASS(session);
|
||||
g_return_val_if_fail(klass->open_uri != NULL, FALSE);
|
||||
|
||||
return klass->open_uri(session, uri);
|
||||
return klass->open_uri(session, uri);
|
||||
}
|
||||
|
||||
gboolean virt_viewer_session_channel_open_fd(VirtViewerSession *session,
|
||||
VirtViewerSessionChannel *channel, int fd)
|
||||
VirtViewerSessionChannel *channel, int fd)
|
||||
{
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(session), FALSE);
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(session), FALSE);
|
||||
|
||||
return VIRT_VIEWER_SESSION_GET_CLASS(session)->channel_open_fd(session, channel, fd);
|
||||
return VIRT_VIEWER_SESSION_GET_CLASS(session)->channel_open_fd(session, channel, fd);
|
||||
}
|
||||
|
||||
void virt_viewer_session_set_auto_usbredir(VirtViewerSession *self, gboolean auto_usbredir)
|
||||
{
|
||||
g_return_if_fail(VIRT_VIEWER_IS_SESSION(self));
|
||||
g_return_if_fail(VIRT_VIEWER_IS_SESSION(self));
|
||||
|
||||
if (self->priv->auto_usbredir == auto_usbredir)
|
||||
return;
|
||||
if (self->priv->auto_usbredir == auto_usbredir)
|
||||
return;
|
||||
|
||||
self->priv->auto_usbredir = auto_usbredir;
|
||||
g_object_notify(G_OBJECT(self), "auto-usbredir");
|
||||
self->priv->auto_usbredir = auto_usbredir;
|
||||
g_object_notify(G_OBJECT(self), "auto-usbredir");
|
||||
}
|
||||
|
||||
gboolean virt_viewer_session_get_auto_usbredir(VirtViewerSession *self)
|
||||
{
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(self), FALSE);
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(self), FALSE);
|
||||
|
||||
return self->priv->auto_usbredir;
|
||||
return self->priv->auto_usbredir;
|
||||
}
|
||||
|
||||
gboolean virt_viewer_session_has_usb(VirtViewerSession *self)
|
||||
{
|
||||
VirtViewerSessionClass *klass;
|
||||
VirtViewerSessionClass *klass;
|
||||
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(self), FALSE);
|
||||
g_return_val_if_fail(VIRT_VIEWER_IS_SESSION(self), FALSE);
|
||||
|
||||
klass = VIRT_VIEWER_SESSION_GET_CLASS(self);
|
||||
if (klass->has_usb == NULL)
|
||||
return FALSE;
|
||||
klass = VIRT_VIEWER_SESSION_GET_CLASS(self);
|
||||
if (klass->has_usb == NULL)
|
||||
return FALSE;
|
||||
|
||||
return klass->has_usb(self);
|
||||
return klass->has_usb(self);
|
||||
}
|
||||
|
||||
void virt_viewer_session_usb_device_selection(VirtViewerSession *self,
|
||||
GtkWindow *parent)
|
||||
GtkWindow *parent)
|
||||
{
|
||||
VirtViewerSessionClass *klass;
|
||||
VirtViewerSessionClass *klass;
|
||||
|
||||
g_return_if_fail(VIRT_VIEWER_IS_SESSION(self));
|
||||
g_return_if_fail(VIRT_VIEWER_IS_SESSION(self));
|
||||
|
||||
klass = VIRT_VIEWER_SESSION_GET_CLASS(self);
|
||||
g_return_if_fail(klass->usb_device_selection != NULL);
|
||||
klass = VIRT_VIEWER_SESSION_GET_CLASS(self);
|
||||
g_return_if_fail(klass->usb_device_selection != NULL);
|
||||
|
||||
klass->usb_device_selection(self, parent);
|
||||
klass->usb_device_selection(self, parent);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* tab-width: 8
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -32,20 +32,20 @@ G_BEGIN_DECLS
|
||||
|
||||
#define VIRT_VIEWER_TYPE_SESSION virt_viewer_session_get_type()
|
||||
|
||||
#define VIRT_VIEWER_SESSION(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_SESSION, VirtViewerSession))
|
||||
#define VIRT_VIEWER_SESSION(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_SESSION, VirtViewerSession))
|
||||
|
||||
#define VIRT_VIEWER_SESSION_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_SESSION, VirtViewerSessionClass))
|
||||
#define VIRT_VIEWER_SESSION_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_SESSION, VirtViewerSessionClass))
|
||||
|
||||
#define VIRT_VIEWER_IS_SESSION(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_SESSION))
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_SESSION))
|
||||
|
||||
#define VIRT_VIEWER_IS_SESSION_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_SESSION))
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_SESSION))
|
||||
|
||||
#define VIRT_VIEWER_SESSION_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_SESSION, VirtViewerSessionClass))
|
||||
#define VIRT_VIEWER_SESSION_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_SESSION, VirtViewerSessionClass))
|
||||
|
||||
typedef struct _VirtViewerSession VirtViewerSession;
|
||||
typedef struct _VirtViewerSessionClass VirtViewerSessionClass;
|
||||
@ -56,41 +56,41 @@ typedef struct _VirtViewerSessionChannel VirtViewerSessionChannel;
|
||||
|
||||
/* perhaps this become an interface, and be pushed in gtkvnc and spice? */
|
||||
struct _VirtViewerSession {
|
||||
GObject parent;
|
||||
GObject parent;
|
||||
|
||||
VirtViewerSessionPrivate *priv;
|
||||
VirtViewerSessionPrivate *priv;
|
||||
};
|
||||
|
||||
struct _VirtViewerSessionClass {
|
||||
GObjectClass parent_class;
|
||||
GObjectClass parent_class;
|
||||
|
||||
/* virtual methods */
|
||||
void (* close) (VirtViewerSession* session);
|
||||
gboolean (* open_fd) (VirtViewerSession* session, int fd);
|
||||
gboolean (* open_host) (VirtViewerSession* session, char *host, char *port);
|
||||
gboolean (* open_uri) (VirtViewerSession* session, char *uri);
|
||||
gboolean (* channel_open_fd) (VirtViewerSession* session, VirtViewerSessionChannel *channel, int fd);
|
||||
gboolean (* has_usb) (VirtViewerSession* session);
|
||||
void (* usb_device_selection) (VirtViewerSession* session, GtkWindow *parent);
|
||||
/* virtual methods */
|
||||
void (* close) (VirtViewerSession* session);
|
||||
gboolean (* open_fd) (VirtViewerSession* session, int fd);
|
||||
gboolean (* open_host) (VirtViewerSession* session, char *host, char *port);
|
||||
gboolean (* open_uri) (VirtViewerSession* session, char *uri);
|
||||
gboolean (* channel_open_fd) (VirtViewerSession* session, VirtViewerSessionChannel *channel, int fd);
|
||||
gboolean (* has_usb) (VirtViewerSession* session);
|
||||
void (* usb_device_selection) (VirtViewerSession* session, GtkWindow *parent);
|
||||
|
||||
/* signals */
|
||||
void (*session_connected)(VirtViewerSession *session);
|
||||
void (*session_initialized)(VirtViewerSession *session);
|
||||
void (*session_disconnected)(VirtViewerSession *session);
|
||||
void (*session_auth_refused)(VirtViewerSession *session, const char *msg);
|
||||
void (*session_auth_failed)(VirtViewerSession *session, const char *msg);
|
||||
void (*session_usb_failed)(VirtViewerSession *session, const char *msg);
|
||||
/* signals */
|
||||
void (*session_connected)(VirtViewerSession *session);
|
||||
void (*session_initialized)(VirtViewerSession *session);
|
||||
void (*session_disconnected)(VirtViewerSession *session);
|
||||
void (*session_auth_refused)(VirtViewerSession *session, const char *msg);
|
||||
void (*session_auth_failed)(VirtViewerSession *session, const char *msg);
|
||||
void (*session_usb_failed)(VirtViewerSession *session, const char *msg);
|
||||
|
||||
void (*session_channel_open)(VirtViewerSession *session, VirtViewerSessionChannel *channel);
|
||||
void (*session_channel_open)(VirtViewerSession *session, VirtViewerSessionChannel *channel);
|
||||
|
||||
void (*session_display_added)(VirtViewerSession *session,
|
||||
VirtViewerDisplay *display);
|
||||
void (*session_display_removed)(VirtViewerSession *session,
|
||||
VirtViewerDisplay *display);
|
||||
void (*session_display_added)(VirtViewerSession *session,
|
||||
VirtViewerDisplay *display);
|
||||
void (*session_display_removed)(VirtViewerSession *session,
|
||||
VirtViewerDisplay *display);
|
||||
|
||||
void (*session_cut_text)(VirtViewerSession *session, const char *str);
|
||||
void (*session_bell)(VirtViewerSession *session);
|
||||
void (*session_cancelled)(VirtViewerSession *session);
|
||||
void (*session_cut_text)(VirtViewerSession *session, const char *str);
|
||||
void (*session_bell)(VirtViewerSession *session);
|
||||
void (*session_cancelled)(VirtViewerSession *session);
|
||||
};
|
||||
|
||||
GType virt_viewer_session_get_type(void);
|
||||
@ -98,9 +98,9 @@ GType virt_viewer_session_get_type(void);
|
||||
GtkWidget *virt_viewer_session_new(void);
|
||||
|
||||
void virt_viewer_session_add_display(VirtViewerSession *session,
|
||||
VirtViewerDisplay *display);
|
||||
VirtViewerDisplay *display);
|
||||
void virt_viewer_session_remove_display(VirtViewerSession *session,
|
||||
VirtViewerDisplay *display);
|
||||
VirtViewerDisplay *display);
|
||||
void virt_viewer_session_clear_displays(VirtViewerSession *session);
|
||||
|
||||
void virt_viewer_session_close(VirtViewerSession* session);
|
||||
@ -108,7 +108,7 @@ gboolean virt_viewer_session_open_fd(VirtViewerSession* session, int fd);
|
||||
gboolean virt_viewer_session_open_host(VirtViewerSession* session, char *host, char *port);
|
||||
GObject* virt_viewer_session_get(VirtViewerSession* session);
|
||||
gboolean virt_viewer_session_channel_open_fd(VirtViewerSession* session,
|
||||
VirtViewerSessionChannel* channel, int fd);
|
||||
VirtViewerSessionChannel* channel, int fd);
|
||||
gboolean virt_viewer_session_open_uri(VirtViewerSession *session, gchar *uri);
|
||||
|
||||
void virt_viewer_session_set_auto_usbredir(VirtViewerSession* session, gboolean auto_usbredir);
|
||||
@ -116,15 +116,16 @@ gboolean virt_viewer_session_get_auto_usbredir(VirtViewerSession* session);
|
||||
|
||||
gboolean virt_viewer_session_has_usb(VirtViewerSession *self);
|
||||
void virt_viewer_session_usb_device_selection(VirtViewerSession *self,
|
||||
GtkWindow *parent);
|
||||
GtkWindow *parent);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _VIRT_VIEWER_SESSION_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -34,42 +34,42 @@
|
||||
|
||||
GtkBuilder *virt_viewer_util_load_ui(const char *name)
|
||||
{
|
||||
struct stat sb;
|
||||
GtkBuilder *builder;
|
||||
GError *error = NULL;
|
||||
struct stat sb;
|
||||
GtkBuilder *builder;
|
||||
GError *error = NULL;
|
||||
|
||||
builder = gtk_builder_new();
|
||||
if (stat(name, &sb) >= 0) {
|
||||
gtk_builder_add_from_file(builder, name, &error);
|
||||
} else {
|
||||
const gchar * const * dirs = g_get_system_data_dirs();
|
||||
g_return_val_if_fail(dirs != NULL, NULL);
|
||||
builder = gtk_builder_new();
|
||||
if (stat(name, &sb) >= 0) {
|
||||
gtk_builder_add_from_file(builder, name, &error);
|
||||
} else {
|
||||
const gchar * const * dirs = g_get_system_data_dirs();
|
||||
g_return_val_if_fail(dirs != NULL, NULL);
|
||||
|
||||
while (dirs[0] != NULL) {
|
||||
gchar *path = g_build_filename(dirs[0], PACKAGE, "ui", name, NULL);
|
||||
if (gtk_builder_add_from_file(builder, path, NULL) != 0) {
|
||||
g_free(path);
|
||||
break;
|
||||
}
|
||||
g_free(path);
|
||||
dirs++;
|
||||
}
|
||||
if (dirs[0] == NULL)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
g_error("Cannot load UI description %s: %s", name,
|
||||
error->message);
|
||||
g_clear_error(&error);
|
||||
goto failed;
|
||||
while (dirs[0] != NULL) {
|
||||
gchar *path = g_build_filename(dirs[0], PACKAGE, "ui", name, NULL);
|
||||
if (gtk_builder_add_from_file(builder, path, NULL) != 0) {
|
||||
g_free(path);
|
||||
break;
|
||||
}
|
||||
g_free(path);
|
||||
dirs++;
|
||||
}
|
||||
if (dirs[0] == NULL)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
return builder;
|
||||
failed:
|
||||
g_error("failed to find UI description file");
|
||||
g_object_unref(builder);
|
||||
return NULL;
|
||||
if (error) {
|
||||
g_error("Cannot load UI description %s: %s", name,
|
||||
error->message);
|
||||
g_clear_error(&error);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
return builder;
|
||||
failed:
|
||||
g_error("failed to find UI description file");
|
||||
g_object_unref(builder);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
@ -80,57 +80,57 @@ virt_viewer_util_extract_host(const char *uristr,
|
||||
char **user,
|
||||
int *port)
|
||||
{
|
||||
xmlURIPtr uri;
|
||||
char *offset;
|
||||
xmlURIPtr uri;
|
||||
char *offset;
|
||||
|
||||
if (uristr == NULL ||
|
||||
!g_ascii_strcasecmp(uristr, "xen"))
|
||||
uristr = "xen:///";
|
||||
if (uristr == NULL ||
|
||||
!g_ascii_strcasecmp(uristr, "xen"))
|
||||
uristr = "xen:///";
|
||||
|
||||
uri = xmlParseURI(uristr);
|
||||
g_return_val_if_fail(uri != NULL, 1);
|
||||
uri = xmlParseURI(uristr);
|
||||
g_return_val_if_fail(uri != NULL, 1);
|
||||
|
||||
if (host) {
|
||||
if (!uri || !uri->server)
|
||||
*host = g_strdup("localhost");
|
||||
else
|
||||
*host = g_strdup(uri->server);
|
||||
}
|
||||
if (host) {
|
||||
if (!uri || !uri->server)
|
||||
*host = g_strdup("localhost");
|
||||
else
|
||||
*host = g_strdup(uri->server);
|
||||
}
|
||||
|
||||
if (user) {
|
||||
if (uri->user)
|
||||
*user = g_strdup(uri->user);
|
||||
else
|
||||
*user = NULL;
|
||||
}
|
||||
if (user) {
|
||||
if (uri->user)
|
||||
*user = g_strdup(uri->user);
|
||||
else
|
||||
*user = NULL;
|
||||
}
|
||||
|
||||
if (port)
|
||||
*port = uri->port;
|
||||
if (port)
|
||||
*port = uri->port;
|
||||
|
||||
offset = strchr(uri->scheme, '+');
|
||||
offset = strchr(uri->scheme, '+');
|
||||
|
||||
if (transport) {
|
||||
if (offset)
|
||||
*transport = g_strdup(offset+1);
|
||||
else
|
||||
*transport = NULL;
|
||||
}
|
||||
if (transport) {
|
||||
if (offset)
|
||||
*transport = g_strdup(offset+1);
|
||||
else
|
||||
*transport = NULL;
|
||||
}
|
||||
|
||||
if (scheme) {
|
||||
if (offset)
|
||||
*scheme = g_strndup(uri->scheme, offset - uri->scheme);
|
||||
else
|
||||
*scheme = g_strdup(uri->scheme);
|
||||
}
|
||||
if (scheme) {
|
||||
if (offset)
|
||||
*scheme = g_strndup(uri->scheme, offset - uri->scheme);
|
||||
else
|
||||
*scheme = g_strdup(uri->scheme);
|
||||
}
|
||||
|
||||
xmlFreeURI(uri);
|
||||
return 0;
|
||||
xmlFreeURI(uri);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -41,3 +41,11 @@ int virt_viewer_util_extract_host(const char *uristr,
|
||||
int *port);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -32,30 +32,30 @@ G_BEGIN_DECLS
|
||||
|
||||
#define VIRT_VIEWER_TYPE_WINDOW virt_viewer_window_get_type()
|
||||
|
||||
#define VIRT_VIEWER_WINDOW(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_WINDOW, VirtViewerWindow))
|
||||
#define VIRT_VIEWER_WINDOW(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), VIRT_VIEWER_TYPE_WINDOW, VirtViewerWindow))
|
||||
|
||||
#define VIRT_VIEWER_WINDOW_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_WINDOW, VirtViewerWindowClass))
|
||||
#define VIRT_VIEWER_WINDOW_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((klass), VIRT_VIEWER_TYPE_WINDOW, VirtViewerWindowClass))
|
||||
|
||||
#define VIRT_VIEWER_IS_WINDOW(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_WINDOW))
|
||||
#define VIRT_VIEWER_IS_WINDOW(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), VIRT_VIEWER_TYPE_WINDOW))
|
||||
|
||||
#define VIRT_VIEWER_IS_WINDOW_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_WINDOW))
|
||||
#define VIRT_VIEWER_IS_WINDOW_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((klass), VIRT_VIEWER_TYPE_WINDOW))
|
||||
|
||||
#define VIRT_VIEWER_WINDOW_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_WINDOW, VirtViewerWindowClass))
|
||||
#define VIRT_VIEWER_WINDOW_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), VIRT_VIEWER_TYPE_WINDOW, VirtViewerWindowClass))
|
||||
|
||||
typedef struct _VirtViewerWindowPrivate VirtViewerWindowPrivate;
|
||||
|
||||
typedef struct {
|
||||
GObject parent;
|
||||
VirtViewerWindowPrivate *priv;
|
||||
GObject parent;
|
||||
VirtViewerWindowPrivate *priv;
|
||||
} VirtViewerWindow;
|
||||
|
||||
typedef struct {
|
||||
GObjectClass parent_class;
|
||||
GObjectClass parent_class;
|
||||
} VirtViewerWindowClass;
|
||||
|
||||
GType virt_viewer_window_get_type (void);
|
||||
@ -75,11 +75,11 @@ GtkBuilder* virt_viewer_window_get_builder(VirtViewerWindow *window);
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* _VIRT_VIEWER_WINDOW */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -50,18 +50,18 @@
|
||||
#include "virt-viewer-auth.h"
|
||||
|
||||
struct _VirtViewerPrivate {
|
||||
char *uri;
|
||||
virConnectPtr conn;
|
||||
virDomainPtr dom;
|
||||
char *domkey;
|
||||
gboolean withEvents;
|
||||
gboolean waitvm;
|
||||
gboolean reconnect;
|
||||
char *uri;
|
||||
virConnectPtr conn;
|
||||
virDomainPtr dom;
|
||||
char *domkey;
|
||||
gboolean withEvents;
|
||||
gboolean waitvm;
|
||||
gboolean reconnect;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (VirtViewer, virt_viewer, VIRT_VIEWER_TYPE_APP)
|
||||
#define GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), VIRT_VIEWER_TYPE, VirtViewerPrivate))
|
||||
#define GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), VIRT_VIEWER_TYPE, VirtViewerPrivate))
|
||||
|
||||
static int virt_viewer_initial_connect(VirtViewerApp *self);
|
||||
static gboolean virt_viewer_open_connection(VirtViewerApp *self, int *fd);
|
||||
@ -70,563 +70,562 @@ static gboolean virt_viewer_start(VirtViewerApp *self);
|
||||
|
||||
static void
|
||||
virt_viewer_get_property (GObject *object, guint property_id,
|
||||
GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
|
||||
GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
switch (property_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_set_property (GObject *object, guint property_id,
|
||||
const GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
|
||||
const GValue *value G_GNUC_UNUSED, GParamSpec *pspec)
|
||||
{
|
||||
switch (property_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
switch (property_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_dispose (GObject *object)
|
||||
{
|
||||
VirtViewer *self = VIRT_VIEWER(object);
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
if (priv->dom)
|
||||
virDomainFree(priv->dom);
|
||||
if (priv->conn)
|
||||
virConnectClose(priv->conn);
|
||||
G_OBJECT_CLASS(virt_viewer_parent_class)->dispose (object);
|
||||
VirtViewer *self = VIRT_VIEWER(object);
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
if (priv->dom)
|
||||
virDomainFree(priv->dom);
|
||||
if (priv->conn)
|
||||
virConnectClose(priv->conn);
|
||||
G_OBJECT_CLASS(virt_viewer_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_class_init (VirtViewerClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
VirtViewerAppClass *app_class = VIRT_VIEWER_APP_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
VirtViewerAppClass *app_class = VIRT_VIEWER_APP_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (VirtViewerPrivate));
|
||||
g_type_class_add_private (klass, sizeof (VirtViewerPrivate));
|
||||
|
||||
object_class->get_property = virt_viewer_get_property;
|
||||
object_class->set_property = virt_viewer_set_property;
|
||||
object_class->dispose = virt_viewer_dispose;
|
||||
object_class->get_property = virt_viewer_get_property;
|
||||
object_class->set_property = virt_viewer_set_property;
|
||||
object_class->dispose = virt_viewer_dispose;
|
||||
|
||||
app_class->initial_connect = virt_viewer_initial_connect;
|
||||
app_class->deactivated = virt_viewer_deactivated;
|
||||
app_class->open_connection = virt_viewer_open_connection;
|
||||
app_class->start = virt_viewer_start;
|
||||
app_class->initial_connect = virt_viewer_initial_connect;
|
||||
app_class->deactivated = virt_viewer_deactivated;
|
||||
app_class->open_connection = virt_viewer_open_connection;
|
||||
app_class->start = virt_viewer_start;
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_init(VirtViewer *self)
|
||||
{
|
||||
self->priv = GET_PRIVATE(self);
|
||||
self->priv = GET_PRIVATE(self);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_deactivated(VirtViewerApp *app)
|
||||
{
|
||||
VirtViewer *self = VIRT_VIEWER(app);
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
VirtViewer *self = VIRT_VIEWER(app);
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
|
||||
if (priv->dom) {
|
||||
virDomainFree(priv->dom);
|
||||
priv->dom = NULL;
|
||||
}
|
||||
if (priv->dom) {
|
||||
virDomainFree(priv->dom);
|
||||
priv->dom = NULL;
|
||||
}
|
||||
|
||||
if (priv->reconnect) {
|
||||
if (!priv->withEvents) {
|
||||
DEBUG_LOG("No domain events, falling back to polling");
|
||||
virt_viewer_app_start_reconnect_poll(app);
|
||||
}
|
||||
if (priv->reconnect) {
|
||||
if (!priv->withEvents) {
|
||||
DEBUG_LOG("No domain events, falling back to polling");
|
||||
virt_viewer_app_start_reconnect_poll(app);
|
||||
}
|
||||
|
||||
virt_viewer_app_show_status(app, _("Waiting for guest domain to re-start"));
|
||||
virt_viewer_app_trace(app, "Guest %s display has disconnected, waiting to reconnect", priv->domkey);
|
||||
} else {
|
||||
VIRT_VIEWER_APP_CLASS(virt_viewer_parent_class)->deactivated(app);
|
||||
}
|
||||
virt_viewer_app_show_status(app, _("Waiting for guest domain to re-start"));
|
||||
virt_viewer_app_trace(app, "Guest %s display has disconnected, waiting to reconnect", priv->domkey);
|
||||
} else {
|
||||
VIRT_VIEWER_APP_CLASS(virt_viewer_parent_class)->deactivated(app);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
virt_viewer_parse_uuid(const char *name,
|
||||
unsigned char *uuid)
|
||||
unsigned char *uuid)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
const char *cur = name;
|
||||
for (i = 0;i < 16;) {
|
||||
uuid[i] = 0;
|
||||
if (*cur == 0)
|
||||
return -1;
|
||||
if ((*cur == '-') || (*cur == ' ')) {
|
||||
cur++;
|
||||
continue;
|
||||
}
|
||||
if ((*cur >= '0') && (*cur <= '9'))
|
||||
uuid[i] = *cur - '0';
|
||||
else if ((*cur >= 'a') && (*cur <= 'f'))
|
||||
uuid[i] = *cur - 'a' + 10;
|
||||
else if ((*cur >= 'A') && (*cur <= 'F'))
|
||||
uuid[i] = *cur - 'A' + 10;
|
||||
else
|
||||
return -1;
|
||||
uuid[i] *= 16;
|
||||
cur++;
|
||||
if (*cur == 0)
|
||||
return -1;
|
||||
if ((*cur >= '0') && (*cur <= '9'))
|
||||
uuid[i] += *cur - '0';
|
||||
else if ((*cur >= 'a') && (*cur <= 'f'))
|
||||
uuid[i] += *cur - 'a' + 10;
|
||||
else if ((*cur >= 'A') && (*cur <= 'F'))
|
||||
uuid[i] += *cur - 'A' + 10;
|
||||
else
|
||||
return -1;
|
||||
i++;
|
||||
cur++;
|
||||
}
|
||||
const char *cur = name;
|
||||
for (i = 0;i < 16;) {
|
||||
uuid[i] = 0;
|
||||
if (*cur == 0)
|
||||
return -1;
|
||||
if ((*cur == '-') || (*cur == ' ')) {
|
||||
cur++;
|
||||
continue;
|
||||
}
|
||||
if ((*cur >= '0') && (*cur <= '9'))
|
||||
uuid[i] = *cur - '0';
|
||||
else if ((*cur >= 'a') && (*cur <= 'f'))
|
||||
uuid[i] = *cur - 'a' + 10;
|
||||
else if ((*cur >= 'A') && (*cur <= 'F'))
|
||||
uuid[i] = *cur - 'A' + 10;
|
||||
else
|
||||
return -1;
|
||||
uuid[i] *= 16;
|
||||
cur++;
|
||||
if (*cur == 0)
|
||||
return -1;
|
||||
if ((*cur >= '0') && (*cur <= '9'))
|
||||
uuid[i] += *cur - '0';
|
||||
else if ((*cur >= 'a') && (*cur <= 'f'))
|
||||
uuid[i] += *cur - 'a' + 10;
|
||||
else if ((*cur >= 'A') && (*cur <= 'F'))
|
||||
uuid[i] += *cur - 'A' + 10;
|
||||
else
|
||||
return -1;
|
||||
i++;
|
||||
cur++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static virDomainPtr
|
||||
virt_viewer_lookup_domain(VirtViewer *self)
|
||||
{
|
||||
char *end;
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
int id = strtol(priv->domkey, &end, 10);
|
||||
virDomainPtr dom = NULL;
|
||||
unsigned char uuid[16];
|
||||
char *end;
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
int id = strtol(priv->domkey, &end, 10);
|
||||
virDomainPtr dom = NULL;
|
||||
unsigned char uuid[16];
|
||||
|
||||
if (id >= 0 && end && !*end) {
|
||||
dom = virDomainLookupByID(priv->conn, id);
|
||||
}
|
||||
if (!dom && virt_viewer_parse_uuid(priv->domkey, uuid) == 0) {
|
||||
dom = virDomainLookupByUUID(priv->conn, uuid);
|
||||
}
|
||||
if (!dom) {
|
||||
dom = virDomainLookupByName(priv->conn, priv->domkey);
|
||||
}
|
||||
return dom;
|
||||
if (id >= 0 && end && !*end) {
|
||||
dom = virDomainLookupByID(priv->conn, id);
|
||||
}
|
||||
if (!dom && virt_viewer_parse_uuid(priv->domkey, uuid) == 0) {
|
||||
dom = virDomainLookupByUUID(priv->conn, uuid);
|
||||
}
|
||||
if (!dom) {
|
||||
dom = virDomainLookupByName(priv->conn, priv->domkey);
|
||||
}
|
||||
return dom;
|
||||
}
|
||||
|
||||
static int
|
||||
virt_viewer_matches_domain(VirtViewer *self,
|
||||
virDomainPtr dom)
|
||||
virDomainPtr dom)
|
||||
{
|
||||
char *end;
|
||||
const char *name;
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
int id = strtol(priv->domkey, &end, 10);
|
||||
unsigned char wantuuid[16];
|
||||
unsigned char domuuid[16];
|
||||
char *end;
|
||||
const char *name;
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
int id = strtol(priv->domkey, &end, 10);
|
||||
unsigned char wantuuid[16];
|
||||
unsigned char domuuid[16];
|
||||
|
||||
if (id >= 0 && end && !*end) {
|
||||
if (virDomainGetID(dom) == id)
|
||||
return 1;
|
||||
}
|
||||
if (virt_viewer_parse_uuid(priv->domkey, wantuuid) == 0) {
|
||||
virDomainGetUUID(dom, domuuid);
|
||||
if (memcmp(wantuuid, domuuid, VIR_UUID_BUFLEN) == 0)
|
||||
return 1;
|
||||
}
|
||||
if (id >= 0 && end && !*end) {
|
||||
if (virDomainGetID(dom) == id)
|
||||
return 1;
|
||||
}
|
||||
if (virt_viewer_parse_uuid(priv->domkey, wantuuid) == 0) {
|
||||
virDomainGetUUID(dom, domuuid);
|
||||
if (memcmp(wantuuid, domuuid, VIR_UUID_BUFLEN) == 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
name = virDomainGetName(dom);
|
||||
if (strcmp(name, priv->domkey) == 0)
|
||||
return 1;
|
||||
name = virDomainGetName(dom);
|
||||
if (strcmp(name, priv->domkey) == 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *
|
||||
virt_viewer_extract_xpath_string(const gchar *xmldesc,
|
||||
const gchar *xpath)
|
||||
const gchar *xpath)
|
||||
{
|
||||
xmlDocPtr xml = NULL;
|
||||
xmlParserCtxtPtr pctxt = NULL;
|
||||
xmlXPathContextPtr ctxt = NULL;
|
||||
xmlXPathObjectPtr obj = NULL;
|
||||
char *port = NULL;
|
||||
xmlDocPtr xml = NULL;
|
||||
xmlParserCtxtPtr pctxt = NULL;
|
||||
xmlXPathContextPtr ctxt = NULL;
|
||||
xmlXPathObjectPtr obj = NULL;
|
||||
char *port = NULL;
|
||||
|
||||
pctxt = xmlNewParserCtxt();
|
||||
if (!pctxt || !pctxt->sax)
|
||||
goto error;
|
||||
pctxt = xmlNewParserCtxt();
|
||||
if (!pctxt || !pctxt->sax)
|
||||
goto error;
|
||||
|
||||
xml = xmlCtxtReadDoc(pctxt, (const xmlChar *)xmldesc, "domain.xml", NULL,
|
||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
||||
XML_PARSE_NOWARNING);
|
||||
if (!xml)
|
||||
goto error;
|
||||
xml = xmlCtxtReadDoc(pctxt, (const xmlChar *)xmldesc, "domain.xml", NULL,
|
||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
||||
XML_PARSE_NOWARNING);
|
||||
if (!xml)
|
||||
goto error;
|
||||
|
||||
ctxt = xmlXPathNewContext(xml);
|
||||
if (!ctxt)
|
||||
goto error;
|
||||
ctxt = xmlXPathNewContext(xml);
|
||||
if (!ctxt)
|
||||
goto error;
|
||||
|
||||
obj = xmlXPathEval((const xmlChar *)xpath, ctxt);
|
||||
if (!obj || obj->type != XPATH_STRING || !obj->stringval || !obj->stringval[0])
|
||||
goto error;
|
||||
if (!strcmp((const char*)obj->stringval, "-1"))
|
||||
goto error;
|
||||
obj = xmlXPathEval((const xmlChar *)xpath, ctxt);
|
||||
if (!obj || obj->type != XPATH_STRING || !obj->stringval || !obj->stringval[0])
|
||||
goto error;
|
||||
if (!strcmp((const char*)obj->stringval, "-1"))
|
||||
goto error;
|
||||
|
||||
port = g_strdup((const char*)obj->stringval);
|
||||
xmlXPathFreeObject(obj);
|
||||
obj = NULL;
|
||||
port = g_strdup((const char*)obj->stringval);
|
||||
xmlXPathFreeObject(obj);
|
||||
obj = NULL;
|
||||
|
||||
error:
|
||||
if (obj)
|
||||
xmlXPathFreeObject(obj);
|
||||
if (ctxt)
|
||||
xmlXPathFreeContext(ctxt);
|
||||
if (xml)
|
||||
xmlFreeDoc(xml);
|
||||
if (pctxt)
|
||||
xmlFreeParserCtxt(pctxt);
|
||||
return port;
|
||||
if (obj)
|
||||
xmlXPathFreeObject(obj);
|
||||
if (ctxt)
|
||||
xmlXPathFreeContext(ctxt);
|
||||
if (xml)
|
||||
xmlFreeDoc(xml);
|
||||
if (pctxt)
|
||||
xmlFreeParserCtxt(pctxt);
|
||||
return port;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
virt_viewer_extract_connect_info(VirtViewer *self,
|
||||
virDomainPtr dom)
|
||||
virDomainPtr dom)
|
||||
{
|
||||
char *type = NULL;
|
||||
char *xpath = NULL;
|
||||
gboolean retval = FALSE;
|
||||
char *xmldesc = virDomainGetXMLDesc(dom, 0);
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
VirtViewerApp *app = VIRT_VIEWER_APP(self);
|
||||
gchar *gport = NULL;
|
||||
gchar *ghost = NULL;
|
||||
gchar *unixsock = NULL;
|
||||
gchar *host = NULL;
|
||||
gchar *transport = NULL;
|
||||
gchar *user = NULL;
|
||||
gint port = 0;
|
||||
gchar *uri = NULL;
|
||||
char *type = NULL;
|
||||
char *xpath = NULL;
|
||||
gboolean retval = FALSE;
|
||||
char *xmldesc = virDomainGetXMLDesc(dom, 0);
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
VirtViewerApp *app = VIRT_VIEWER_APP(self);
|
||||
gchar *gport = NULL;
|
||||
gchar *ghost = NULL;
|
||||
gchar *unixsock = NULL;
|
||||
gchar *host = NULL;
|
||||
gchar *transport = NULL;
|
||||
gchar *user = NULL;
|
||||
gint port = 0;
|
||||
gchar *uri = NULL;
|
||||
|
||||
virt_viewer_app_free_connect_info(app);
|
||||
virt_viewer_app_free_connect_info(app);
|
||||
|
||||
if ((type = virt_viewer_extract_xpath_string(xmldesc, "string(/domain/devices/graphics/@type)")) == NULL) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Cannot determine the graphic type for the guest %s"),
|
||||
priv->domkey);
|
||||
goto cleanup;
|
||||
}
|
||||
if ((type = virt_viewer_extract_xpath_string(xmldesc, "string(/domain/devices/graphics/@type)")) == NULL) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Cannot determine the graphic type for the guest %s"),
|
||||
priv->domkey);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virt_viewer_app_create_session(app, type) < 0)
|
||||
goto cleanup;
|
||||
if (virt_viewer_app_create_session(app, type) < 0)
|
||||
goto cleanup;
|
||||
|
||||
xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@port)", type);
|
||||
if ((gport = virt_viewer_extract_xpath_string(xmldesc, xpath)) == NULL) {
|
||||
free(xpath);
|
||||
xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@socket)", type);
|
||||
if ((unixsock = virt_viewer_extract_xpath_string(xmldesc, xpath)) == NULL) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Cannot determine the graphic address for the guest %s"),
|
||||
priv->domkey);
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
free(xpath);
|
||||
xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@listen)", type);
|
||||
ghost = virt_viewer_extract_xpath_string(xmldesc, xpath);
|
||||
if (ghost == NULL)
|
||||
ghost = g_strdup("localhost");
|
||||
}
|
||||
xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@port)", type);
|
||||
if ((gport = virt_viewer_extract_xpath_string(xmldesc, xpath)) == NULL) {
|
||||
free(xpath);
|
||||
xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@socket)", type);
|
||||
if ((unixsock = virt_viewer_extract_xpath_string(xmldesc, xpath)) == NULL) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Cannot determine the graphic address for the guest %s"),
|
||||
priv->domkey);
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
free(xpath);
|
||||
xpath = g_strdup_printf("string(/domain/devices/graphics[@type='%s']/@listen)", type);
|
||||
ghost = virt_viewer_extract_xpath_string(xmldesc, xpath);
|
||||
if (ghost == NULL)
|
||||
ghost = g_strdup("localhost");
|
||||
}
|
||||
|
||||
if (ghost && gport)
|
||||
DEBUG_LOG("Guest graphics address is %s:%s", ghost, gport);
|
||||
else if (unixsock)
|
||||
DEBUG_LOG("Guest graphics address is %s", unixsock);
|
||||
if (ghost && gport)
|
||||
DEBUG_LOG("Guest graphics address is %s:%s", ghost, gport);
|
||||
else if (unixsock)
|
||||
DEBUG_LOG("Guest graphics address is %s", unixsock);
|
||||
|
||||
uri = virConnectGetURI(priv->conn);
|
||||
if (virt_viewer_util_extract_host(uri, NULL, &host, &transport, &user, &port) < 0) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Cannot determine the host for the guest %s"),
|
||||
priv->domkey);
|
||||
goto cleanup;
|
||||
}
|
||||
uri = virConnectGetURI(priv->conn);
|
||||
if (virt_viewer_util_extract_host(uri, NULL, &host, &transport, &user, &port) < 0) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Cannot determine the host for the guest %s"),
|
||||
priv->domkey);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* If the XML listen attribute shows a wildcard address, we need to
|
||||
* throw that away since you obviously can't 'connect(2)' to that
|
||||
* from a remote host. Instead we fallback to the hostname used in
|
||||
* the libvirt URI. This isn't perfect but it is better than nothing
|
||||
*/
|
||||
if (ghost &&
|
||||
(strcmp(ghost, "0.0.0.0") == 0 ||
|
||||
strcmp(ghost, "::") == 0)) {
|
||||
DEBUG_LOG("Guest graphics listen '%s' is a wildcard, replacing with '%s'",
|
||||
ghost, host);
|
||||
g_free(ghost);
|
||||
ghost = g_strdup(host);
|
||||
}
|
||||
/* If the XML listen attribute shows a wildcard address, we need to
|
||||
* throw that away since you obviously can't 'connect(2)' to that
|
||||
* from a remote host. Instead we fallback to the hostname used in
|
||||
* the libvirt URI. This isn't perfect but it is better than nothing
|
||||
*/
|
||||
if (ghost &&
|
||||
(strcmp(ghost, "0.0.0.0") == 0 ||
|
||||
strcmp(ghost, "::") == 0)) {
|
||||
DEBUG_LOG("Guest graphics listen '%s' is a wildcard, replacing with '%s'",
|
||||
ghost, host);
|
||||
g_free(ghost);
|
||||
ghost = g_strdup(host);
|
||||
}
|
||||
|
||||
virt_viewer_app_set_connect_info(app, host, ghost, gport, transport, unixsock, user, port, NULL);
|
||||
virt_viewer_app_set_connect_info(app, host, ghost, gport, transport, unixsock, user, port, NULL);
|
||||
|
||||
retval = TRUE;
|
||||
retval = TRUE;
|
||||
|
||||
cleanup:
|
||||
g_free(gport);
|
||||
g_free(ghost);
|
||||
g_free(unixsock);
|
||||
g_free(host);
|
||||
g_free(transport);
|
||||
g_free(user);
|
||||
g_free(type);
|
||||
g_free(xpath);
|
||||
g_free(xmldesc);
|
||||
g_free(uri);
|
||||
return retval;
|
||||
g_free(gport);
|
||||
g_free(ghost);
|
||||
g_free(unixsock);
|
||||
g_free(host);
|
||||
g_free(transport);
|
||||
g_free(user);
|
||||
g_free(type);
|
||||
g_free(xpath);
|
||||
g_free(xmldesc);
|
||||
g_free(uri);
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int
|
||||
virt_viewer_update_display(VirtViewer *self, virDomainPtr dom)
|
||||
{
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
VirtViewerApp *app = VIRT_VIEWER_APP(self);
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
VirtViewerApp *app = VIRT_VIEWER_APP(self);
|
||||
|
||||
if (priv->dom)
|
||||
virDomainFree(priv->dom);
|
||||
priv->dom = dom;
|
||||
virDomainRef(priv->dom);
|
||||
if (priv->dom)
|
||||
virDomainFree(priv->dom);
|
||||
priv->dom = dom;
|
||||
virDomainRef(priv->dom);
|
||||
|
||||
virt_viewer_app_trace(app, "Guest %s is running, determining display\n",
|
||||
priv->domkey);
|
||||
virt_viewer_app_trace(app, "Guest %s is running, determining display\n",
|
||||
priv->domkey);
|
||||
|
||||
g_object_set(app, "title", virDomainGetName(dom), NULL);
|
||||
g_object_set(app, "title", virDomainGetName(dom), NULL);
|
||||
|
||||
if (!virt_viewer_app_has_session(app)) {
|
||||
if (!virt_viewer_extract_connect_info(self, dom))
|
||||
return -1;
|
||||
}
|
||||
if (!virt_viewer_app_has_session(app)) {
|
||||
if (!virt_viewer_extract_connect_info(self, dom))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
virt_viewer_open_connection(VirtViewerApp *self G_GNUC_UNUSED, int *fd)
|
||||
{
|
||||
#if defined(HAVE_SOCKETPAIR)
|
||||
VirtViewer *viewer = VIRT_VIEWER(self);
|
||||
VirtViewerPrivate *priv = viewer->priv;
|
||||
int pair[2];
|
||||
VirtViewer *viewer = VIRT_VIEWER(self);
|
||||
VirtViewerPrivate *priv = viewer->priv;
|
||||
int pair[2];
|
||||
#endif
|
||||
*fd = -1;
|
||||
*fd = -1;
|
||||
#if defined(HAVE_SOCKETPAIR)
|
||||
if (!priv->dom)
|
||||
return TRUE;
|
||||
if (!priv->dom)
|
||||
return TRUE;
|
||||
|
||||
if (socketpair(PF_UNIX, SOCK_STREAM, 0, pair) < 0)
|
||||
return FALSE;
|
||||
if (socketpair(PF_UNIX, SOCK_STREAM, 0, pair) < 0)
|
||||
return FALSE;
|
||||
|
||||
if (virDomainOpenGraphics(priv->dom, 0, pair[0],
|
||||
VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH) < 0) {
|
||||
virErrorPtr err = virGetLastError();
|
||||
DEBUG_LOG("Error %s", err && err->message ? err->message : "Unknown");
|
||||
close(pair[0]);
|
||||
close(pair[1]);
|
||||
return TRUE;
|
||||
}
|
||||
close(pair[0]);
|
||||
*fd = pair[1];
|
||||
if (virDomainOpenGraphics(priv->dom, 0, pair[0],
|
||||
VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH) < 0) {
|
||||
virErrorPtr err = virGetLastError();
|
||||
DEBUG_LOG("Error %s", err && err->message ? err->message : "Unknown");
|
||||
close(pair[0]);
|
||||
close(pair[1]);
|
||||
return TRUE;
|
||||
}
|
||||
close(pair[0]);
|
||||
*fd = pair[1];
|
||||
#endif
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
virt_viewer_domain_event(virConnectPtr conn G_GNUC_UNUSED,
|
||||
virDomainPtr dom,
|
||||
int event,
|
||||
int detail G_GNUC_UNUSED,
|
||||
void *opaque)
|
||||
virDomainPtr dom,
|
||||
int event,
|
||||
int detail G_GNUC_UNUSED,
|
||||
void *opaque)
|
||||
{
|
||||
VirtViewer *self = opaque;
|
||||
VirtViewerApp *app = VIRT_VIEWER_APP(self);
|
||||
VirtViewer *self = opaque;
|
||||
VirtViewerApp *app = VIRT_VIEWER_APP(self);
|
||||
|
||||
DEBUG_LOG("Got domain event %d %d", event, detail);
|
||||
DEBUG_LOG("Got domain event %d %d", event, detail);
|
||||
|
||||
if (!virt_viewer_matches_domain(self, dom))
|
||||
return 0;
|
||||
if (!virt_viewer_matches_domain(self, dom))
|
||||
return 0;
|
||||
|
||||
switch (event) {
|
||||
case VIR_DOMAIN_EVENT_STOPPED:
|
||||
//virt_viewer_deactivate(self);
|
||||
break;
|
||||
switch (event) {
|
||||
case VIR_DOMAIN_EVENT_STOPPED:
|
||||
//virt_viewer_deactivate(self);
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_EVENT_STARTED:
|
||||
virt_viewer_update_display(self, dom);
|
||||
virt_viewer_app_activate(app);
|
||||
break;
|
||||
}
|
||||
case VIR_DOMAIN_EVENT_STARTED:
|
||||
virt_viewer_update_display(self, dom);
|
||||
virt_viewer_app_activate(app);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
virt_viewer_initial_connect(VirtViewerApp *app)
|
||||
{
|
||||
virDomainPtr dom = NULL;
|
||||
virDomainInfo info;
|
||||
int ret = -1;
|
||||
VirtViewer *self = VIRT_VIEWER(app);
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
virDomainPtr dom = NULL;
|
||||
virDomainInfo info;
|
||||
int ret = -1;
|
||||
VirtViewer *self = VIRT_VIEWER(app);
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
|
||||
virt_viewer_app_show_status(app, _("Finding guest domain"));
|
||||
dom = virt_viewer_lookup_domain(self);
|
||||
if (!dom) {
|
||||
if (priv->waitvm) {
|
||||
virt_viewer_app_show_status(app, _("Waiting for guest domain to be created"));
|
||||
virt_viewer_app_trace(app, "Guest %s does not yet exist, waiting for it to be created\n",
|
||||
priv->domkey);
|
||||
goto done;
|
||||
} else {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Cannot find guest domain %s"),
|
||||
priv->domkey);
|
||||
DEBUG_LOG("Cannot find guest %s", priv->domkey);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
virt_viewer_app_show_status(app, _("Finding guest domain"));
|
||||
dom = virt_viewer_lookup_domain(self);
|
||||
if (!dom) {
|
||||
if (priv->waitvm) {
|
||||
virt_viewer_app_show_status(app, _("Waiting for guest domain to be created"));
|
||||
virt_viewer_app_trace(app, "Guest %s does not yet exist, waiting for it to be created\n",
|
||||
priv->domkey);
|
||||
goto done;
|
||||
} else {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Cannot find guest domain %s"),
|
||||
priv->domkey);
|
||||
DEBUG_LOG("Cannot find guest %s", priv->domkey);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
virt_viewer_app_show_status(app, _("Checking guest domain status"));
|
||||
if (virDomainGetInfo(dom, &info) < 0) {
|
||||
DEBUG_LOG("Cannot get guest state");
|
||||
goto cleanup;
|
||||
}
|
||||
virt_viewer_app_show_status(app, _("Checking guest domain status"));
|
||||
if (virDomainGetInfo(dom, &info) < 0) {
|
||||
DEBUG_LOG("Cannot get guest state");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (info.state == VIR_DOMAIN_SHUTOFF) {
|
||||
virt_viewer_app_show_status(app, _("Waiting for guest domain to start"));
|
||||
} else {
|
||||
ret = virt_viewer_update_display(self, dom);
|
||||
if (ret >= 0)
|
||||
ret = VIRT_VIEWER_APP_CLASS(virt_viewer_parent_class)->initial_connect(app);
|
||||
if (ret < 0) {
|
||||
if (priv->waitvm) {
|
||||
virt_viewer_app_show_status(app, _("Waiting for guest domain to start server"));
|
||||
virt_viewer_app_trace(app, "Guest %s has not activated its display yet, waiting for it to start\n",
|
||||
priv->domkey);
|
||||
} else {
|
||||
DEBUG_LOG("Failed to activate viewer");
|
||||
goto cleanup;
|
||||
}
|
||||
} else if (ret == 0) {
|
||||
DEBUG_LOG("Failed to activate viewer");
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if (info.state == VIR_DOMAIN_SHUTOFF) {
|
||||
virt_viewer_app_show_status(app, _("Waiting for guest domain to start"));
|
||||
} else {
|
||||
ret = virt_viewer_update_display(self, dom);
|
||||
if (ret >= 0)
|
||||
ret = VIRT_VIEWER_APP_CLASS(virt_viewer_parent_class)->initial_connect(app);
|
||||
if (ret < 0) {
|
||||
if (priv->waitvm) {
|
||||
virt_viewer_app_show_status(app, _("Waiting for guest domain to start server"));
|
||||
virt_viewer_app_trace(app, "Guest %s has not activated its display yet, waiting for it to start\n",
|
||||
priv->domkey);
|
||||
} else {
|
||||
DEBUG_LOG("Failed to activate viewer");
|
||||
goto cleanup;
|
||||
}
|
||||
} else if (ret == 0) {
|
||||
DEBUG_LOG("Failed to activate viewer");
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
ret = 0;
|
||||
ret = 0;
|
||||
cleanup:
|
||||
if (dom)
|
||||
virDomainFree(dom);
|
||||
return ret;
|
||||
if (dom)
|
||||
virDomainFree(dom);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_error_func (void *data G_GNUC_UNUSED,
|
||||
virErrorPtr error G_GNUC_UNUSED)
|
||||
virErrorPtr error G_GNUC_UNUSED)
|
||||
{
|
||||
/* nada */
|
||||
/* nada */
|
||||
}
|
||||
|
||||
static gboolean
|
||||
virt_viewer_start(VirtViewerApp *app)
|
||||
{
|
||||
VirtViewer *self = VIRT_VIEWER(app);
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
int cred_types[] =
|
||||
{ VIR_CRED_AUTHNAME, VIR_CRED_PASSPHRASE };
|
||||
virConnectAuth auth_libvirt = {
|
||||
.credtype = cred_types,
|
||||
.ncredtype = ARRAY_CARDINALITY(cred_types),
|
||||
.cb = virt_viewer_auth_libvirt_credentials,
|
||||
.cbdata = (void *)priv->uri,
|
||||
};
|
||||
int oflags = 0;
|
||||
VirtViewer *self = VIRT_VIEWER(app);
|
||||
VirtViewerPrivate *priv = self->priv;
|
||||
int cred_types[] =
|
||||
{ VIR_CRED_AUTHNAME, VIR_CRED_PASSPHRASE };
|
||||
virConnectAuth auth_libvirt = {
|
||||
.credtype = cred_types,
|
||||
.ncredtype = ARRAY_CARDINALITY(cred_types),
|
||||
.cb = virt_viewer_auth_libvirt_credentials,
|
||||
.cbdata = (void *)priv->uri,
|
||||
};
|
||||
int oflags = 0;
|
||||
|
||||
if (!virt_viewer_app_get_attach(app))
|
||||
oflags |= VIR_CONNECT_RO;
|
||||
if (!virt_viewer_app_get_attach(app))
|
||||
oflags |= VIR_CONNECT_RO;
|
||||
|
||||
virt_viewer_events_register();
|
||||
virt_viewer_events_register();
|
||||
|
||||
virSetErrorFunc(NULL, virt_viewer_error_func);
|
||||
virSetErrorFunc(NULL, virt_viewer_error_func);
|
||||
|
||||
virt_viewer_app_trace(app, "Opening connection to libvirt with URI %s\n",
|
||||
priv->uri ? priv->uri : "<null>");
|
||||
priv->conn = virConnectOpenAuth(priv->uri,
|
||||
//virConnectAuthPtrDefault,
|
||||
&auth_libvirt,
|
||||
oflags);
|
||||
if (!priv->conn) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Unable to connect to libvirt with URI %s"),
|
||||
priv->uri ? priv->uri : _("[none]"));
|
||||
return FALSE;
|
||||
}
|
||||
virt_viewer_app_trace(app, "Opening connection to libvirt with URI %s\n",
|
||||
priv->uri ? priv->uri : "<null>");
|
||||
priv->conn = virConnectOpenAuth(priv->uri,
|
||||
//virConnectAuthPtrDefault,
|
||||
&auth_libvirt,
|
||||
oflags);
|
||||
if (!priv->conn) {
|
||||
virt_viewer_app_simple_message_dialog(app, _("Unable to connect to libvirt with URI %s"),
|
||||
priv->uri ? priv->uri : _("[none]"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (virt_viewer_app_initial_connect(app) < 0)
|
||||
return FALSE;
|
||||
if (virt_viewer_app_initial_connect(app) < 0)
|
||||
return FALSE;
|
||||
|
||||
if (virConnectDomainEventRegister(priv->conn,
|
||||
virt_viewer_domain_event,
|
||||
self,
|
||||
NULL) < 0)
|
||||
priv->withEvents = FALSE;
|
||||
else
|
||||
priv->withEvents = TRUE;
|
||||
if (virConnectDomainEventRegister(priv->conn,
|
||||
virt_viewer_domain_event,
|
||||
self,
|
||||
NULL) < 0)
|
||||
priv->withEvents = FALSE;
|
||||
else
|
||||
priv->withEvents = TRUE;
|
||||
|
||||
if (!priv->withEvents &&
|
||||
!virt_viewer_app_is_active(app)) {
|
||||
DEBUG_LOG("No domain events, falling back to polling");
|
||||
virt_viewer_app_start_reconnect_poll(app);
|
||||
}
|
||||
if (!priv->withEvents &&
|
||||
!virt_viewer_app_is_active(app)) {
|
||||
DEBUG_LOG("No domain events, falling back to polling");
|
||||
virt_viewer_app_start_reconnect_poll(app);
|
||||
}
|
||||
|
||||
return VIRT_VIEWER_APP_CLASS(virt_viewer_parent_class)->start(app);
|
||||
return VIRT_VIEWER_APP_CLASS(virt_viewer_parent_class)->start(app);
|
||||
}
|
||||
|
||||
VirtViewer *
|
||||
virt_viewer_new(const char *uri,
|
||||
const char *name,
|
||||
gint zoom,
|
||||
gboolean direct,
|
||||
gboolean attach,
|
||||
gboolean waitvm,
|
||||
gboolean reconnect,
|
||||
gboolean verbose,
|
||||
GtkWidget *container)
|
||||
const char *name,
|
||||
gint zoom,
|
||||
gboolean direct,
|
||||
gboolean attach,
|
||||
gboolean waitvm,
|
||||
gboolean reconnect,
|
||||
gboolean verbose,
|
||||
GtkWidget *container)
|
||||
{
|
||||
VirtViewer *self;
|
||||
VirtViewerApp *app;
|
||||
VirtViewerPrivate *priv;
|
||||
VirtViewer *self;
|
||||
VirtViewerApp *app;
|
||||
VirtViewerPrivate *priv;
|
||||
|
||||
self = g_object_new(VIRT_VIEWER_TYPE,
|
||||
"container", container,
|
||||
"verbose", verbose,
|
||||
"guest-name", name,
|
||||
NULL);
|
||||
app = VIRT_VIEWER_APP(self);
|
||||
priv = self->priv;
|
||||
self = g_object_new(VIRT_VIEWER_TYPE,
|
||||
"container", container,
|
||||
"verbose", verbose,
|
||||
"guest-name", name,
|
||||
NULL);
|
||||
app = VIRT_VIEWER_APP(self);
|
||||
priv = self->priv;
|
||||
|
||||
/* Set initial title based on guest name arg, which can be a ID,
|
||||
* UUID, or NAME string. To be replaced with the real guest name later
|
||||
*/
|
||||
g_object_set(app, "title", name, NULL);
|
||||
virt_viewer_window_set_zoom_level(virt_viewer_app_get_main_window(app), zoom);
|
||||
virt_viewer_app_set_direct(app, direct);
|
||||
virt_viewer_app_set_attach(app, attach);
|
||||
/* Set initial title based on guest name arg, which can be a ID,
|
||||
* UUID, or NAME string. To be replaced with the real guest name later
|
||||
*/
|
||||
g_object_set(app, "title", name, NULL);
|
||||
virt_viewer_window_set_zoom_level(virt_viewer_app_get_main_window(app), zoom);
|
||||
virt_viewer_app_set_direct(app, direct);
|
||||
virt_viewer_app_set_attach(app, attach);
|
||||
|
||||
/* should probably be properties instead */
|
||||
priv->uri = g_strdup(uri);
|
||||
priv->domkey = g_strdup(name);
|
||||
priv->waitvm = waitvm;
|
||||
priv->reconnect = reconnect;
|
||||
/* should probably be properties instead */
|
||||
priv->uri = g_strdup(uri);
|
||||
priv->domkey = g_strdup(name);
|
||||
priv->waitvm = waitvm;
|
||||
priv->reconnect = reconnect;
|
||||
|
||||
return self;
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
@ -38,27 +38,35 @@ G_BEGIN_DECLS
|
||||
typedef struct _VirtViewerPrivate VirtViewerPrivate;
|
||||
|
||||
typedef struct {
|
||||
VirtViewerApp parent;
|
||||
VirtViewerPrivate *priv;
|
||||
VirtViewerApp parent;
|
||||
VirtViewerPrivate *priv;
|
||||
} VirtViewer;
|
||||
|
||||
typedef struct {
|
||||
VirtViewerAppClass parent_class;
|
||||
VirtViewerAppClass parent_class;
|
||||
} VirtViewerClass;
|
||||
|
||||
GType virt_viewer_get_type (void);
|
||||
|
||||
VirtViewer *
|
||||
virt_viewer_new(const char *uri,
|
||||
const char *name,
|
||||
gint zoom,
|
||||
gboolean direct,
|
||||
gboolean attach,
|
||||
gboolean waitvm,
|
||||
gboolean reconnect,
|
||||
gboolean verbose,
|
||||
GtkWidget *container);
|
||||
const char *name,
|
||||
gint zoom,
|
||||
gboolean direct,
|
||||
gboolean attach,
|
||||
gboolean waitvm,
|
||||
gboolean reconnect,
|
||||
gboolean verbose,
|
||||
GtkWidget *container);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* VIRT_VIEWER_H */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user