Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 04-11-2020, 05:54 PM   #1
Sytten
Junior Member
Sytten began at the beginning.
 
Sytten's Avatar
 
Posts: 6
Karma: 10
Join Date: Mar 2020
Device: nonde
IPC between plugin and interface

Hi!

I need to do a Google login for my plugin. Reading the documentation, I see that I need to launch that in a separate process. However I don't have a way to communicate back information to my plugin (mainly access and refresh tokens). I took a look at how other core plugins do it and it seems to use the IPC utils, but only some predefined messages are handled and it is currently not possible to register an handle for new message types.
Is there any way I could make that work?

Thanks!
Sytten is offline   Reply With Quote
Old 04-12-2020, 01:21 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
A plugin can run arbitrary code (the only exception being it cant use Qt WebEngine), you can do IPC however you like. Use the python multiprocessing classes or a simple socket or stdin/stdout, or a file in the filesystem, whatever you are comfortable with.
kovidgoyal is offline   Reply With Quote
Old 04-12-2020, 06:48 PM   #3
Sytten
Junior Member
Sytten began at the beginning.
 
Sytten's Avatar
 
Posts: 6
Karma: 10
Join Date: Mar 2020
Device: nonde
Ha yes that makes sense, thanks!
Other small question, is the networkauth module included in the main process? I would like to use QOAuth2AuthorizationCodeFlow if possible.
Sytten is offline   Reply With Quote
Old 04-12-2020, 10:37 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
No, I dont think so. You can see th elist of Qt modules included by looking at sources.json in the calibre source tree.
kovidgoyal is offline   Reply With Quote
Old 05-10-2020, 06:17 PM   #5
Sytten
Junior Member
Sytten began at the beginning.
 
Sytten's Avatar
 
Posts: 6
Karma: 10
Join Date: Mar 2020
Device: nonde
I tried using the multiprocessing Queue class, but it doesn't seem possible to pass it through the IPC. From what I understand what the IPC module does:
Job -> Worker -> ConnectedWorker -> Sends the kwargs to the worker via pipe
But the only way to send a Queue is when you spawn the child process, otherwise you get an error: Queue objects should only be shared between processes through inheritance.
I will try to use a Dispatcher with a Job result to see if that works.
Sytten is offline   Reply With Quote
Old 05-10-2020, 11:56 PM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I would strongly recommend against sending anything other than primitive data types such as strings/numbers and list/dicts of those between processes. If you want to do cross process synchronization use a lockfile or platform specific mutexes. Sending a queue requires shared memory which may or may not be available depending on platform.
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Device Plugin] Apple iDevice interface GRiker Plugins 68 07-24-2013 12:06 PM
Touch Kobo Touch Plugin Interface ah- Kobo Developer's Corner 271 05-11-2013 04:53 AM
Reset Sony Device Interface plugin? NLight95 Devices 2 04-04-2011 06:40 PM
Writing an interface action plugin kiwidude Plugins 21 11-11-2010 04:11 PM
Device interface plugin - nook badmadbug Plugins 2 09-06-2010 11:03 AM


All times are GMT -4. The time now is 06:40 PM.


MobileRead.com is a privately owned, operated and funded community.