Re: Accessing dataengine from different plasmoid
Thanks. I found the way to do it following your advise. 2012/2/22 Weng Xuetian : > 在 2012年2月22日 星期三 12:59:58,Simone Gaiarin 写道: >> I'm writing a plasmoid to control redshift. >> Redshift is a program that change the colour temperature of the monitor. >> >> Here you can find the current plasmoid I wrote: >> http://kde-apps.org/content/show.php/Redshift+plasmoid?content=148737 >> >> The current plasmoid span a redshift process from inside of it, so if >> I create two plasmoids they span two different process that create >> problems each other. >> >> What I want is create a plasmoid that can control this process through >> a dataengine, in such a way there is only one process running, >> controlled by multiple plasmoids. >> >> When the user click on the plasmoid it should be able to start and >> pause the process. So I need to create a service that perform the >> start/stop operations on the process. >> >> If the configuration is changed the process needs to be restarted. >> So I have to think about the correct way to connect the config changed >> event to the restart operation. >> >> I hope I've been clear enough. > So, what I think about this like this: > 1. Create a dataengine, with only once source. (For your case) > 2. Abstract all your need to interact with the process as dataengine service. > Dataengine code will be the only code that interactive with the process > directly. > 3. Talk with the dataengine with the ServiceJob > 4. If some data need to be updated, store the data into data engine. > > You could take a look at now-playing, i > https://projects.kde.org/projects/kde/kde- > workspace/repository/revisions/master/show/plasma/generic/dataengines/nowplaying > > And see how the ServiceJob works.(for nowplaying case, play, pause, stop the > player). > > ___ > Plasma-devel mailing list > Plasma-devel@kde.org > https://mail.kde.org/mailman/listinfo/plasma-devel > ___ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel
Re: Accessing dataengine from different plasmoid
在 2012年2月22日 星期三 12:59:58,Simone Gaiarin 写道: > I'm writing a plasmoid to control redshift. > Redshift is a program that change the colour temperature of the monitor. > > Here you can find the current plasmoid I wrote: > http://kde-apps.org/content/show.php/Redshift+plasmoid?content8737 > > The current plasmoid span a redshift process from inside of it, so if > I create two plasmoids they span two different process that create > problems each other. > > What I want is create a plasmoid that can control this process through > a dataengine, in such a way there is only one process running, > controlled by multiple plasmoids. > > When the user click on the plasmoid it should be able to start and > pause the process. So I need to create a service that perform the > start/stop operations on the process. > > If the configuration is changed the process needs to be restarted. > So I have to think about the correct way to connect the config changed > event to the restart operation. > > I hope I've been clear enough. So, what I think about this like this: 1. Create a dataengine, with only once source. (For your case) 2. Abstract all your need to interact with the process as dataengine service. Dataengine code will be the only code that interactive with the process directly. 3. Talk with the dataengine with the ServiceJob 4. If some data need to be updated, store the data into data engine. You could take a look at now-playing, i https://projects.kde.org/projects/kde/kde- workspace/repository/revisions/master/show/plasma/generic/dataengines/nowplaying And see how the ServiceJob works.(for nowplaying case, play, pause, stop the player). signature.asc Description: This is a digitally signed message part. ___ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel
Re: Accessing dataengine from different plasmoid
I'm writing a plasmoid to control redshift. Redshift is a program that change the colour temperature of the monitor. Here you can find the current plasmoid I wrote: http://kde-apps.org/content/show.php/Redshift+plasmoid?content=148737 The current plasmoid span a redshift process from inside of it, so if I create two plasmoids they span two different process that create problems each other. What I want is create a plasmoid that can control this process through a dataengine, in such a way there is only one process running, controlled by multiple plasmoids. When the user click on the plasmoid it should be able to start and pause the process. So I need to create a service that perform the start/stop operations on the process. If the configuration is changed the process needs to be restarted. So I have to think about the correct way to connect the config changed event to the restart operation. I hope I've been clear enough. 2012/2/22 Weng Xuetian : > 在 2012年2月22日 星期三 10:45:13,Simone Gaiarin 写道: >> Thank you. The problem was that I didn't run the plasmoid on the same >> process. >> >> What can be the best way to store a KProcess to the dataengine? >> Idea 1: >> Subclass the DataContainer class and store the KProcess in that class, >> like the Executable dataEngine does. When the source is requested i >> use addSource(). >> Idea 2: >> Store the Kprocess as a private member of the dataengine. >> >> When I ask for the Service, which is the best way to act on the KProcess? >> Can I create a method to get the KProcess from the datacontainer? Or >> this will break the semantic of the datacontainer, that is supposed to >> just listen to signal updateRequested(). >> >> Example: >> >> serviceForSource(const QString &source) >> { >> container = query(source); >> pointerToProcess = container.getPointerToProcess(); >> return new MyService(pointerToProcess,source); >> } >> >> The service will implement the operation "start" and "stop" that let >> to pause and resume the process. >> > I think you can put KProcess in the dataengine as private member, and operate > it only with dataengine service, not to direct get the pointer. > > What's your requirement by the way? I think there might be better solution for > your idea. > ___ > Plasma-devel mailing list > Plasma-devel@kde.org > https://mail.kde.org/mailman/listinfo/plasma-devel > ___ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel
Re: Accessing dataengine from different plasmoid
在 2012年2月22日 星期三 10:45:13,Simone Gaiarin 写道: > Thank you. The problem was that I didn't run the plasmoid on the same > process. > > What can be the best way to store a KProcess to the dataengine? > Idea 1: > Subclass the DataContainer class and store the KProcess in that class, > like the Executable dataEngine does. When the source is requested i > use addSource(). > Idea 2: > Store the Kprocess as a private member of the dataengine. > > When I ask for the Service, which is the best way to act on the KProcess? > Can I create a method to get the KProcess from the datacontainer? Or > this will break the semantic of the datacontainer, that is supposed to > just listen to signal updateRequested(). > > Example: > > serviceForSource(const QString &source) > { > container = query(source); > pointerToProcess = container.getPointerToProcess(); > return new MyService(pointerToProcess,source); > } > > The service will implement the operation "start" and "stop" that let > to pause and resume the process. > I think you can put KProcess in the dataengine as private member, and operate it only with dataengine service, not to direct get the pointer. What's your requirement by the way? I think there might be better solution for your idea. signature.asc Description: This is a digitally signed message part. ___ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel
Re: Accessing dataengine from different plasmoid
Thank you. The problem was that I didn't run the plasmoid on the same process. What can be the best way to store a KProcess to the dataengine? Idea 1: Subclass the DataContainer class and store the KProcess in that class, like the Executable dataEngine does. When the source is requested i use addSource(). Idea 2: Store the Kprocess as a private member of the dataengine. When I ask for the Service, which is the best way to act on the KProcess? Can I create a method to get the KProcess from the datacontainer? Or this will break the semantic of the datacontainer, that is supposed to just listen to signal updateRequested(). Example: serviceForSource(const QString &source) { container = query(source); pointerToProcess = container.getPointerToProcess(); return new MyService(pointerToProcess,source); } The service will implement the operation "start" and "stop" that let to pause and resume the process. 2012/2/21 Aaron J. Seigo : > On Tuesday, February 21, 2012 17:16:35 Simone Gaiarin wrote: >> I need some explanation on how dataengines work. I can't understand if >> the dataengine is shared among plasmoids or if every plasmoid creates >> his own dataengine that retrive info. > > DataEngines are shared and read-only. Services are not shared and are read- > write. > >> My purpose is: I create a plasmoid, this plasmoid require a source to >> a dataengine, this source is a pointer to a kprocess. After that I >> create more plasmoids and they should access the same source to get >> the pointer to the KProcess. > > sharing pointers via DataEngines in this way is not a great idea. DataEngines > can be accessed remotely, for instance, and then the pointer will be > meaningless (or worse -> cause crashes) > >> What I obtain when I call the dataEngine() method from a plasmoid is >> that a new instance of a dataengine is created, so I cannot see source >> requested by other plasmoid because the dataengines are distinct. > > are the plasmoids running in the same process? or are you starting them in > different processes (e.g. plasma-desktop and plasmoidviewer)? > > -- > Aaron J. Seigo > ___ > Plasma-devel mailing list > Plasma-devel@kde.org > https://mail.kde.org/mailman/listinfo/plasma-devel > ___ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel
Re: Accessing dataengine from different plasmoid
On Tuesday, February 21, 2012 17:16:35 Simone Gaiarin wrote: > I need some explanation on how dataengines work. I can't understand if > the dataengine is shared among plasmoids or if every plasmoid creates > his own dataengine that retrive info. DataEngines are shared and read-only. Services are not shared and are read- write. > My purpose is: I create a plasmoid, this plasmoid require a source to > a dataengine, this source is a pointer to a kprocess. After that I > create more plasmoids and they should access the same source to get > the pointer to the KProcess. sharing pointers via DataEngines in this way is not a great idea. DataEngines can be accessed remotely, for instance, and then the pointer will be meaningless (or worse -> cause crashes) > What I obtain when I call the dataEngine() method from a plasmoid is > that a new instance of a dataengine is created, so I cannot see source > requested by other plasmoid because the dataengines are distinct. are the plasmoids running in the same process? or are you starting them in different processes (e.g. plasma-desktop and plasmoidviewer)? -- Aaron J. Seigo signature.asc Description: This is a digitally signed message part. ___ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel