Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
ac0eeb43
Kaydet (Commit)
ac0eeb43
authored
Eyl 17, 2015
tarafından
Noel Grandin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
convert Link<> to typed
Change-Id: I2f59aec574ed2c5120c554bdff13a9efab6992df
üst
0535f42e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
135 additions
and
162 deletions
+135
-162
mediator.hxx
extensions/source/plugin/inc/plugin/unx/mediator.hxx
+6
-10
plugcon.hxx
extensions/source/plugin/inc/plugin/unx/plugcon.hxx
+1
-1
nppapi.cxx
extensions/source/plugin/unx/nppapi.cxx
+2
-3
npwrap.cxx
extensions/source/plugin/unx/npwrap.cxx
+126
-148
No files found.
extensions/source/plugin/inc/plugin/unx/mediator.hxx
Dosyayı görüntüle @
ac0eeb43
...
@@ -83,12 +83,12 @@ protected:
...
@@ -83,12 +83,12 @@ protected:
MediatorListener
*
m_pListener
;
MediatorListener
*
m_pListener
;
// thread to fill the queue
// thread to fill the queue
sal_uLong
m_nCurrentID
;
sal_uLong
m_nCurrentID
;
// will be constantly increased with each message sent
// will be constantly increased with each message sent
bool
m_bValid
;
bool
m_bValid
;
Link
<
>
m_aConnectionLostHdl
;
Link
<
Mediator
*
,
void
>
m_aConnectionLostHdl
;
Link
<
>
m_aNewMessageHdl
;
Link
<
Mediator
*
,
void
>
m_aNewMessageHdl
;
public
:
public
:
Mediator
(
int
nSocket
);
Mediator
(
int
nSocket
);
virtual
~
Mediator
();
virtual
~
Mediator
();
...
@@ -117,25 +117,21 @@ public:
...
@@ -117,25 +117,21 @@ public:
MediatorMessage
*
GetNextMessage
(
bool
bWait
=
false
);
MediatorMessage
*
GetNextMessage
(
bool
bWait
=
false
);
Link
<>
SetConnectionLostHdl
(
const
Link
<
>&
rLink
)
void
SetConnectionLostHdl
(
const
Link
<
Mediator
*
,
void
>&
rLink
)
{
{
Link
<>
aRet
=
m_aConnectionLostHdl
;
m_aConnectionLostHdl
=
rLink
;
m_aConnectionLostHdl
=
rLink
;
return
aRet
;
}
}
Link
<>
SetNewMessageHdl
(
const
Link
<
>&
rLink
)
void
SetNewMessageHdl
(
const
Link
<
Mediator
*
,
void
>&
rLink
)
{
{
Link
<>
aRet
=
m_aNewMessageHdl
;
m_aNewMessageHdl
=
rLink
;
m_aNewMessageHdl
=
rLink
;
return
aRet
;
}
}
};
};
class
MediatorListener
:
public
osl
::
Thread
class
MediatorListener
:
public
osl
::
Thread
{
{
friend
class
Mediator
;
friend
class
Mediator
;
private
:
private
:
Mediator
*
m_pMediator
;
Mediator
*
m_pMediator
;
::
osl
::
Mutex
m_aMutex
;
::
osl
::
Mutex
m_aMutex
;
...
...
extensions/source/plugin/inc/plugin/unx/plugcon.hxx
Dosyayı görüntüle @
ac0eeb43
...
@@ -132,7 +132,7 @@ protected:
...
@@ -132,7 +132,7 @@ protected:
static
std
::
vector
<
PluginConnector
*>
allConnectors
;
static
std
::
vector
<
PluginConnector
*>
allConnectors
;
DECL_LINK
(
NewMessageHdl
,
Mediator
*
);
DECL_LINK
_TYPED
(
NewMessageHdl
,
Mediator
*
,
void
);
DECL_LINK_TYPED
(
WorkOnNewMessageHdl
,
void
*
,
void
);
DECL_LINK_TYPED
(
WorkOnNewMessageHdl
,
void
*
,
void
);
std
::
vector
<
NPStream
*>
m_aNPWrapStreams
;
std
::
vector
<
NPStream
*>
m_aNPWrapStreams
;
...
...
extensions/source/plugin/unx/nppapi.cxx
Dosyayı görüntüle @
ac0eeb43
...
@@ -64,7 +64,7 @@ PluginConnector::~PluginConnector()
...
@@ -64,7 +64,7 @@ PluginConnector::~PluginConnector()
}
}
}
}
IMPL_LINK
(
PluginConnector
,
NewMessageHdl
,
Mediator
*
,
/*pMediator*/
)
IMPL_LINK
_NOARG_TYPED
(
PluginConnector
,
NewMessageHdl
,
Mediator
*
,
void
)
{
{
osl
::
MutexGuard
aGuard
(
m_aUserEventMutex
);
osl
::
MutexGuard
aGuard
(
m_aUserEventMutex
);
bool
bFound
=
false
;
bool
bFound
=
false
;
...
@@ -75,9 +75,8 @@ IMPL_LINK( PluginConnector, NewMessageHdl, Mediator*, /*pMediator*/ )
...
@@ -75,9 +75,8 @@ IMPL_LINK( PluginConnector, NewMessageHdl, Mediator*, /*pMediator*/ )
bFound
=
true
;
bFound
=
true
;
}
}
if
(
!
bFound
)
if
(
!
bFound
)
return
0
;
return
;
Application
::
PostUserEvent
(
LINK
(
this
,
PluginConnector
,
WorkOnNewMessageHdl
)
);
Application
::
PostUserEvent
(
LINK
(
this
,
PluginConnector
,
WorkOnNewMessageHdl
)
);
return
0
;
}
}
IMPL_LINK_NOARG_TYPED
(
PluginConnector
,
WorkOnNewMessageHdl
,
void
*
,
void
)
IMPL_LINK_NOARG_TYPED
(
PluginConnector
,
WorkOnNewMessageHdl
,
void
*
,
void
)
...
...
extensions/source/plugin/unx/npwrap.cxx
Dosyayı görüntüle @
ac0eeb43
...
@@ -63,13 +63,12 @@ Widget topLevel = NULL, topBox = NULL;
...
@@ -63,13 +63,12 @@ Widget topLevel = NULL, topBox = NULL;
int
wakeup_fd
[
2
]
=
{
0
,
0
};
int
wakeup_fd
[
2
]
=
{
0
,
0
};
static
bool
bPluginAppQuit
=
false
;
static
bool
bPluginAppQuit
=
false
;
static
long
GlobalConnectionLostHdl
(
void
*
/*pInst*/
,
void
*
/*pArg*/
)
static
void
GlobalConnectionLostHdl
(
void
*
/*pInst*/
,
Mediator
*
/*pArg*/
)
{
{
SAL_WARN
(
"extensions.plugin"
,
"pluginapp exiting due to connection lost"
);
SAL_WARN
(
"extensions.plugin"
,
"pluginapp exiting due to connection lost"
);
bool
bSuccess
=
(
4
==
write
(
wakeup_fd
[
1
],
"xxxx"
,
4
));
bool
bSuccess
=
(
4
==
write
(
wakeup_fd
[
1
],
"xxxx"
,
4
));
SAL_WARN_IF
(
!
bSuccess
,
"extensions.plugin"
,
"short write"
);
SAL_WARN_IF
(
!
bSuccess
,
"extensions.plugin"
,
"short write"
);
return
0
;
}
}
extern
"C"
extern
"C"
...
@@ -79,7 +78,7 @@ extern "C"
...
@@ -79,7 +78,7 @@ extern "C"
return
0
;
return
0
;
}
}
#if ! ENABLE_GTK
#if ! ENABLE_GTK
static
void
ThreadEventHandler
(
XtPointer
/*client_data*/
,
int
*
/*source*/
,
XtInputId
*
id
)
static
void
ThreadEventHandler
(
XtPointer
/*client_data*/
,
int
*
/*source*/
,
XtInputId
*
id
)
{
{
char
buf
[
256
];
char
buf
[
256
];
...
@@ -88,12 +87,10 @@ extern "C"
...
@@ -88,12 +87,10 @@ extern "C"
while
(
(
len
=
read
(
wakeup_fd
[
0
],
buf
,
sizeof
(
buf
)
)
)
>
0
)
while
(
(
len
=
read
(
wakeup_fd
[
0
],
buf
,
sizeof
(
buf
)
)
)
>
0
)
nLast
=
len
-
1
;
nLast
=
len
-
1
;
if
(
!
bPluginAppQuit
)
if
(
!
bPluginAppQuit
)
{
{
if
(
(
nLast
==
-
1
||
buf
[
nLast
]
!=
'x'
)
&&
pConnector
)
if
(
(
nLast
==
-
1
||
buf
[
nLast
]
!=
'x'
)
&&
pConnector
)
pConnector
->
CallWorkHandler
();
pConnector
->
CallWorkHandler
();
else
else
{
{
// it seems you can use XtRemoveInput only
// it seems you can use XtRemoveInput only
// safely from within the callback
// safely from within the callback
// why is that ?
// why is that ?
...
@@ -107,41 +104,39 @@ extern "C"
...
@@ -107,41 +104,39 @@ extern "C"
}
}
}
}
}
}
#endif
#endif
}
}
IMPL_LINK
(
PluginConnector
,
NewMessageHdl
,
Mediator
*
,
/*pMediator*/
)
IMPL_LINK
_NOARG_TYPED
(
PluginConnector
,
NewMessageHdl
,
Mediator
*
,
void
)
{
{
(
void
)
this
;
// loplugin:staticmethods
(
void
)
this
;
// loplugin:staticmethods
SAL_INFO
(
"extensions.plugin"
,
"new message handler"
);
SAL_INFO
(
"extensions.plugin"
,
"new message handler"
);
bool
bSuccess
=
(
4
==
write
(
wakeup_fd
[
1
],
"cccc"
,
4
));
bool
bSuccess
=
(
4
==
write
(
wakeup_fd
[
1
],
"cccc"
,
4
));
SAL_WARN_IF
(
!
bSuccess
,
"extensions.plugin"
,
"short write"
);
SAL_WARN_IF
(
!
bSuccess
,
"extensions.plugin"
,
"short write"
);
return
0
;
}
}
Widget
createSubWidget
(
char
*
/*pPluginText*/
,
Widget
shell
,
Window
aParentWindow
)
Widget
createSubWidget
(
char
*
/*pPluginText*/
,
Widget
shell
,
Window
aParentWindow
)
{
{
Widget
newWidget
=
XtVaCreateManagedWidget
(
Widget
newWidget
=
XtVaCreateManagedWidget
(
#if defined USE_MOTIF
#if defined USE_MOTIF
"drawingArea"
,
"drawingArea"
,
xmDrawingAreaWidgetClass
,
xmDrawingAreaWidgetClass
,
#else
#else
""
,
""
,
compositeWidgetClass
,
compositeWidgetClass
,
#endif
#endif
shell
,
shell
,
XtNwidth
,
200
,
XtNwidth
,
200
,
XtNheight
,
200
,
XtNheight
,
200
,
nullptr
);
nullptr
);
XtRealizeWidget
(
shell
);
XtRealizeWidget
(
shell
);
XtRealizeWidget
(
newWidget
);
XtRealizeWidget
(
newWidget
);
SAL_INFO
(
SAL_INFO
(
"extensions.plugin"
,
"extensions.plugin"
,
"reparenting new widget "
<<
XtWindow
(
newWidget
)
<<
" to "
"reparenting new widget "
<<
XtWindow
(
newWidget
)
<<
" to "
<<
aParentWindow
);
<<
aParentWindow
);
XReparentWindow
(
pXtAppDisplay
,
XReparentWindow
(
pXtAppDisplay
,
XtWindow
(
shell
),
XtWindow
(
shell
),
aParentWindow
,
aParentWindow
,
...
@@ -192,10 +187,9 @@ static oslModule LoadModule( const char* pPath )
...
@@ -192,10 +187,9 @@ static oslModule LoadModule( const char* pPath )
static
void
CheckPlugin
(
const
char
*
pPath
)
static
void
CheckPlugin
(
const
char
*
pPath
)
{
{
oslModule
pLib
=
LoadModule
(
pPath
);
oslModule
pLib
=
LoadModule
(
pPath
);
if
(
pLib
!=
0
)
if
(
pLib
!=
0
)
{
{
char
*
(
*
pNP_GetMIMEDescription
)()
=
reinterpret_cast
<
char
*
(
*
)()
>
(
char
*
(
*
pNP_GetMIMEDescription
)()
=
reinterpret_cast
<
char
*
(
*
)()
>
(
osl_getAsciiFunctionSymbol
(
pLib
,
"NP_GetMIMEDescription"
));
osl_getAsciiFunctionSymbol
(
pLib
,
"NP_GetMIMEDescription"
));
if
(
pNP_GetMIMEDescription
)
if
(
pNP_GetMIMEDescription
)
printf
(
"%s
\n
"
,
pNP_GetMIMEDescription
()
);
printf
(
"%s
\n
"
,
pNP_GetMIMEDescription
()
);
else
else
...
@@ -212,116 +206,112 @@ static void CheckPlugin( const char* pPath )
...
@@ -212,116 +206,112 @@ static void CheckPlugin( const char* pPath )
extern
"C"
{
extern
"C"
{
static
void
signal_handler
(
int
nSig
)
static
void
signal_handler
(
int
nSig
)
{
{
#if OSL_DEBUG_LEVEL > 1
#if OSL_DEBUG_LEVEL > 1
fprintf
(
stderr
,
"caught signal %d, exiting
\n
"
,
nSig
);
fprintf
(
stderr
,
"caught signal %d, exiting
\n
"
,
nSig
);
#ifdef LINUX
#ifdef LINUX
void
*
pStack
[
64
];
void
*
pStack
[
64
];
int
nStackLevels
=
backtrace
(
pStack
,
SAL_N_ELEMENTS
(
pStack
)
);
int
nStackLevels
=
backtrace
(
pStack
,
SAL_N_ELEMENTS
(
pStack
)
);
backtrace_symbols_fd
(
pStack
,
nStackLevels
,
STDERR_FILENO
);
backtrace_symbols_fd
(
pStack
,
nStackLevels
,
STDERR_FILENO
);
#endif
#endif
#endif
#endif
if
(
pConnector
)
if
(
pConnector
)
{
{
// ensure that a read on the other side will wakeup
// ensure that a read on the other side will wakeup
delete
pConnector
;
delete
pConnector
;
pConnector
=
NULL
;
pConnector
=
NULL
;
}
}
_exit
(
nSig
);
_exit
(
nSig
);
}
}
#if ENABLE_GTK
#if ENABLE_GTK
static
gboolean
noClosure
(
gpointer
)
static
gboolean
noClosure
(
gpointer
)
{
{
return
sal_True
;
return
sal_True
;
}
}
// Xt events
// Xt events
static
gboolean
prepareXtEvent
(
GSource
*
,
gint
*
)
static
gboolean
prepareXtEvent
(
GSource
*
,
gint
*
)
{
{
int
nMask
=
XtAppPending
(
app_context
);
int
nMask
=
XtAppPending
(
app_context
);
return
(
nMask
&
XtIMAll
)
!=
0
;
return
(
nMask
&
XtIMAll
)
!=
0
;
}
}
static
gboolean
checkXtEvent
(
GSource
*
)
{
int
nMask
=
XtAppPending
(
app_context
);
return
(
nMask
&
XtIMAll
)
!=
0
;
}
static
gboolean
dispatchXtEvent
(
GSource
*
,
GSourceFunc
,
gpointer
)
static
gboolean
checkXtEvent
(
GSource
*
)
{
{
XtAppProcessEvent
(
app_context
,
XtIMAll
);
int
nMask
=
XtAppPending
(
app_context
);
return
sal_True
;
return
(
nMask
&
XtIMAll
)
!=
0
;
}
}
static
GSourceFuncs
aXtEventFuncs
=
static
gboolean
dispatchXtEvent
(
GSource
*
,
GSourceFunc
,
gpointer
)
{
prepareXtEvent
,
checkXtEvent
,
dispatchXtEvent
,
NULL
,
noClosure
,
NULL
};
static
gboolean
pollXtTimerCallback
(
gpointer
)
{
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
{
if
(
(
XtAppPending
(
app_context
)
&
(
XtIMAll
&
~
XtIMXEvent
))
==
0
)
XtAppProcessEvent
(
app_context
,
XtIMAll
);
break
;
return
sal_True
;
XtAppProcessEvent
(
app_context
,
XtIMAll
&
~
XtIMXEvent
);
}
}
return
sal_True
;
}
static
gboolean
prepareWakeupEvent
(
GSource
*
,
gint
*
)
static
GSourceFuncs
aXtEventFuncs
=
{
{
prepareXtEvent
,
struct
pollfd
aPoll
=
{
wakeup_fd
[
0
],
POLLIN
,
0
};
checkXtEvent
,
(
void
)
poll
(
&
aPoll
,
1
,
0
);
dispatchXtEvent
,
return
(
aPoll
.
revents
&
POLLIN
)
!=
0
;
NULL
,
}
noClosure
,
NULL
};
static
gboolean
checkWakeupEvent
(
GSource
*
pSource
)
static
gboolean
pollXtTimerCallback
(
gpointer
)
{
{
gint
nDum
=
0
;
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
return
prepareWakeupEvent
(
pSource
,
&
nDum
);
if
(
(
XtAppPending
(
app_context
)
&
(
XtIMAll
&
~
XtIMXEvent
))
==
0
)
}
break
;
XtAppProcessEvent
(
app_context
,
XtIMAll
&
~
XtIMXEvent
);
}
return
sal_True
;
}
static
gboolean
dispatchWakeupEvent
(
GSource
*
,
GSourceFunc
,
gpointer
)
static
gboolean
prepareWakeupEvent
(
GSource
*
,
gint
*
)
{
char
buf
[
256
];
// clear pipe
int
len
,
nLast
=
-
1
;
while
(
(
len
=
read
(
wakeup_fd
[
0
],
buf
,
sizeof
(
buf
)
)
)
>
0
)
nLast
=
len
-
1
;
if
(
(
nLast
==
-
1
||
buf
[
nLast
]
!=
'x'
)
&&
pConnector
)
pConnector
->
CallWorkHandler
();
else
{
{
XtAppSetExitFlag
(
app_context
);
struct
pollfd
aPoll
=
{
wakeup_fd
[
0
],
POLLIN
,
0
};
bPluginAppQuit
=
true
;
(
void
)
poll
(
&
aPoll
,
1
,
0
);
return
(
aPoll
.
revents
&
POLLIN
)
!=
0
;
}
delete
pConnector
;
static
gboolean
checkWakeupEvent
(
GSource
*
pSource
)
pConnector
=
NULL
;
{
gint
nDum
=
0
;
return
prepareWakeupEvent
(
pSource
,
&
nDum
);
}
}
return
sal_True
;
static
gboolean
dispatchWakeupEvent
(
GSource
*
,
GSourceFunc
,
gpointer
)
}
{
char
buf
[
256
];
// clear pipe
int
len
,
nLast
=
-
1
;
static
GSourceFuncs
aWakeupEventFuncs
=
{
while
(
(
len
=
read
(
wakeup_fd
[
0
],
buf
,
sizeof
(
buf
)
)
)
>
0
)
prepareWakeupEvent
,
nLast
=
len
-
1
;
checkWakeupEvent
,
if
(
(
nLast
==
-
1
||
buf
[
nLast
]
!=
'x'
)
&&
pConnector
)
dispatchWakeupEvent
,
pConnector
->
CallWorkHandler
();
NULL
,
else
{
noClosure
,
XtAppSetExitFlag
(
app_context
);
NULL
bPluginAppQuit
=
true
;
};
delete
pConnector
;
pConnector
=
NULL
;
}
return
sal_True
;
}
static
GSourceFuncs
aWakeupEventFuncs
=
{
prepareWakeupEvent
,
checkWakeupEvent
,
dispatchWakeupEvent
,
NULL
,
noClosure
,
NULL
};
#endif // GTK
#endif // GTK
...
@@ -345,8 +335,7 @@ int main( int argc, char **argv)
...
@@ -345,8 +335,7 @@ int main( int argc, char **argv)
pBaseName
--
;
pBaseName
--
;
LoadAdditionalLibs
(
pBaseName
);
LoadAdditionalLibs
(
pBaseName
);
if
(
argc
==
2
)
if
(
argc
==
2
)
{
{
CheckPlugin
(
argv
[
1
]);
CheckPlugin
(
argv
[
1
]);
exit
(
0
);
exit
(
0
);
}
}
...
@@ -355,8 +344,7 @@ int main( int argc, char **argv)
...
@@ -355,8 +344,7 @@ int main( int argc, char **argv)
XSetErrorHandler
(
plugin_x_error_handler
);
XSetErrorHandler
(
plugin_x_error_handler
);
if
(
pipe
(
wakeup_fd
)
)
if
(
pipe
(
wakeup_fd
)
)
{
{
SAL_WARN
(
"extensions.plugin"
,
"could not pipe()"
);
SAL_WARN
(
"extensions.plugin"
,
"could not pipe()"
);
return
1
;
return
1
;
}
}
...
@@ -364,43 +352,38 @@ int main( int argc, char **argv)
...
@@ -364,43 +352,38 @@ int main( int argc, char **argv)
int
flags
;
int
flags
;
// set close-on-exec descriptor flag.
// set close-on-exec descriptor flag.
if
((
flags
=
fcntl
(
wakeup_fd
[
0
],
F_GETFD
))
!=
-
1
)
if
((
flags
=
fcntl
(
wakeup_fd
[
0
],
F_GETFD
))
!=
-
1
)
{
{
flags
|=
FD_CLOEXEC
;
flags
|=
FD_CLOEXEC
;
(
void
)
fcntl
(
wakeup_fd
[
0
],
F_SETFD
,
flags
);
(
void
)
fcntl
(
wakeup_fd
[
0
],
F_SETFD
,
flags
);
}
}
if
((
flags
=
fcntl
(
wakeup_fd
[
1
],
F_GETFD
))
!=
-
1
)
if
((
flags
=
fcntl
(
wakeup_fd
[
1
],
F_GETFD
))
!=
-
1
)
{
{
flags
|=
FD_CLOEXEC
;
flags
|=
FD_CLOEXEC
;
(
void
)
fcntl
(
wakeup_fd
[
1
],
F_SETFD
,
flags
);
(
void
)
fcntl
(
wakeup_fd
[
1
],
F_SETFD
,
flags
);
}
}
// set non-blocking I/O flag.
// set non-blocking I/O flag.
if
((
flags
=
fcntl
(
wakeup_fd
[
0
],
F_GETFL
))
!=
-
1
)
if
((
flags
=
fcntl
(
wakeup_fd
[
0
],
F_GETFL
))
!=
-
1
)
{
{
flags
|=
O_NONBLOCK
;
flags
|=
O_NONBLOCK
;
(
void
)
fcntl
(
wakeup_fd
[
0
],
F_SETFL
,
flags
);
(
void
)
fcntl
(
wakeup_fd
[
0
],
F_SETFL
,
flags
);
}
}
if
((
flags
=
fcntl
(
wakeup_fd
[
1
],
F_GETFL
))
!=
-
1
)
if
((
flags
=
fcntl
(
wakeup_fd
[
1
],
F_GETFL
))
!=
-
1
)
{
{
flags
|=
O_NONBLOCK
;
flags
|=
O_NONBLOCK
;
(
void
)
fcntl
(
wakeup_fd
[
1
],
F_SETFL
,
flags
);
(
void
)
fcntl
(
wakeup_fd
[
1
],
F_SETFL
,
flags
);
}
}
pPluginLib
=
LoadModule
(
argv
[
2
]
);
pPluginLib
=
LoadModule
(
argv
[
2
]
);
if
(
!
pPluginLib
)
if
(
!
pPluginLib
)
{
{
exit
(
255
);
exit
(
255
);
}
}
int
nSocket
=
atol
(
argv
[
1
]
);
int
nSocket
=
atol
(
argv
[
1
]
);
#if ENABLE_GTK
#if ENABLE_GTK
g_thread_init
(
NULL
);
g_thread_init
(
NULL
);
gtk_init
(
&
argc
,
&
argv
);
gtk_init
(
&
argc
,
&
argv
);
#endif
#endif
pConnector
=
new
PluginConnector
(
nSocket
);
pConnector
=
new
PluginConnector
(
nSocket
);
pConnector
->
SetConnectionLostHdl
(
Link
<
>
(
NULL
,
GlobalConnectionLostHdl
)
);
pConnector
->
SetConnectionLostHdl
(
Link
<
Mediator
*
,
void
>
(
NULL
,
GlobalConnectionLostHdl
)
);
XtSetLanguageProc
(
NULL
,
NULL
,
NULL
);
XtSetLanguageProc
(
NULL
,
NULL
,
NULL
);
...
@@ -409,13 +392,12 @@ int main( int argc, char **argv)
...
@@ -409,13 +392,12 @@ int main( int argc, char **argv)
pXtAppDisplay
=
XtOpenDisplay
(
app_context
,
NULL
,
"SOPlugin"
,
"SOPlugin"
,
NULL
,
0
,
&
argc
,
argv
);
pXtAppDisplay
=
XtOpenDisplay
(
app_context
,
NULL
,
"SOPlugin"
,
"SOPlugin"
,
NULL
,
0
,
&
argc
,
argv
);
#if ENABLE_GTK
#if ENABLE_GTK
// integrate Xt events into GTK event loop
// integrate Xt events into GTK event loop
GPollFD
aXtPollDesc
,
aWakeupPollDesc
;
GPollFD
aXtPollDesc
,
aWakeupPollDesc
;
GSource
*
pXTSource
=
g_source_new
(
&
aXtEventFuncs
,
sizeof
(
GSource
)
);
GSource
*
pXTSource
=
g_source_new
(
&
aXtEventFuncs
,
sizeof
(
GSource
)
);
if
(
!
pXTSource
)
if
(
!
pXTSource
)
{
{
SAL_WARN
(
"extensions.plugin"
,
"could not get Xt GSource"
);
SAL_WARN
(
"extensions.plugin"
,
"could not get Xt GSource"
);
return
1
;
return
1
;
}
}
...
@@ -431,8 +413,7 @@ int main( int argc, char **argv)
...
@@ -431,8 +413,7 @@ int main( int argc, char **argv)
gint
xt_polling_timer_id
=
g_timeout_add
(
25
,
pollXtTimerCallback
,
NULL
);
gint
xt_polling_timer_id
=
g_timeout_add
(
25
,
pollXtTimerCallback
,
NULL
);
// Initialize wakeup events listener
// Initialize wakeup events listener
GSource
*
pWakeupSource
=
g_source_new
(
&
aWakeupEventFuncs
,
sizeof
(
GSource
)
);
GSource
*
pWakeupSource
=
g_source_new
(
&
aWakeupEventFuncs
,
sizeof
(
GSource
)
);
if
(
pWakeupSource
==
NULL
)
if
(
pWakeupSource
==
NULL
)
{
{
SAL_WARN
(
"extensions.plugin"
,
"could not get wakeup source"
);
SAL_WARN
(
"extensions.plugin"
,
"could not get wakeup source"
);
return
1
;
return
1
;
}
}
...
@@ -444,15 +425,15 @@ int main( int argc, char **argv)
...
@@ -444,15 +425,15 @@ int main( int argc, char **argv)
g_source_add_poll
(
pWakeupSource
,
&
aWakeupPollDesc
);
g_source_add_poll
(
pWakeupSource
,
&
aWakeupPollDesc
);
pAppDisplay
=
gdk_x11_display_get_xdisplay
(
gdk_display_get_default
()
);
pAppDisplay
=
gdk_x11_display_get_xdisplay
(
gdk_display_get_default
()
);
#else
#else
pAppDisplay
=
pXtAppDisplay
;
pAppDisplay
=
pXtAppDisplay
;
XtAppAddInput
(
app_context
,
XtAppAddInput
(
app_context
,
wakeup_fd
[
0
],
wakeup_fd
[
0
],
(
XtPointer
)
XtInputReadMask
,
(
XtPointer
)
XtInputReadMask
,
ThreadEventHandler
,
NULL
);
ThreadEventHandler
,
NULL
);
#endif
#endif
// send that we are ready to go
// send that we are ready to go
MediatorMessage
*
pMessage
=
MediatorMessage
*
pMessage
=
pConnector
->
Transact
(
"init req"
,
8
,
pConnector
->
Transact
(
"init req"
,
8
,
NULL
);
NULL
);
...
@@ -461,15 +442,13 @@ int main( int argc, char **argv)
...
@@ -461,15 +442,13 @@ int main( int argc, char **argv)
#if OSL_DEBUG_LEVEL > 3
#if OSL_DEBUG_LEVEL > 3
int
nPID
=
getpid
();
int
nPID
=
getpid
();
int
nChild
=
fork
();
int
nChild
=
fork
();
if
(
nChild
==
0
)
if
(
nChild
==
0
)
{
{
char
pidbuf
[
16
];
char
pidbuf
[
16
];
char
*
pArgs
[]
=
{
"xterm"
,
"-sl"
,
"2000"
,
"-sb"
,
"-e"
,
"gdb"
,
"pluginapp.bin"
,
pidbuf
,
NULL
};
char
*
pArgs
[]
=
{
"xterm"
,
"-sl"
,
"2000"
,
"-sb"
,
"-e"
,
"gdb"
,
"pluginapp.bin"
,
pidbuf
,
NULL
};
sprintf
(
pidbuf
,
"%d"
,
nPID
);
sprintf
(
pidbuf
,
"%d"
,
nPID
);
execvp
(
pArgs
[
0
],
pArgs
);
execvp
(
pArgs
[
0
],
pArgs
);
_exit
(
255
);
_exit
(
255
);
}
}
else
else
sleep
(
10
);
sleep
(
10
);
#endif
#endif
...
@@ -480,20 +459,19 @@ int main( int argc, char **argv)
...
@@ -480,20 +459,19 @@ int main( int argc, char **argv)
// in ThreadEventHandler most of times; Xt will hang in select
// in ThreadEventHandler most of times; Xt will hang in select
// (hat is in XtAppNextEvent). Have our own mainloop instead
// (hat is in XtAppNextEvent). Have our own mainloop instead
// of XtAppMainLoop
// of XtAppMainLoop
do
do
{
{
#if ENABLE_GTK
#if ENABLE_GTK
g_main_context_iteration
(
NULL
,
sal_True
);
g_main_context_iteration
(
NULL
,
sal_True
);
#else
#else
XtAppProcessEvent
(
app_context
,
XtIMAll
);
XtAppProcessEvent
(
app_context
,
XtIMAll
);
#endif
#endif
}
while
(
!
XtAppGetExitFlag
(
app_context
)
&&
!
bPluginAppQuit
);
}
while
(
!
XtAppGetExitFlag
(
app_context
)
&&
!
bPluginAppQuit
);
SAL_INFO
(
"extensions.plugin"
,
"left plugin app main loop"
);
SAL_INFO
(
"extensions.plugin"
,
"left plugin app main loop"
);
#if ENABLE_GTK
#if ENABLE_GTK
g_source_remove
(
xt_polling_timer_id
);
g_source_remove
(
xt_polling_timer_id
);
#endif
#endif
pNP_Shutdown
();
pNP_Shutdown
();
SAL_INFO
(
"extensions.plugin"
,
"NP_Shutdown done"
);
SAL_INFO
(
"extensions.plugin"
,
"NP_Shutdown done"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment