In http_response() we have:
if (response.action == 'list') this.triggerEvent('listupdate', { folder:this.env.source, rowcount:this.contact_list.rowcount });
I think we should add (instead) a "global" event at the end of http_response function:
this.triggerEvent('http_response', { action:response.action });
So, plugins could bind to one (http_response) event and there just check for which action it's executed. Am I right?
A.L.E.C wrote:
In http_response() we have:
if (response.action == 'list') this.triggerEvent('listupdate', { folder:this.env.source, rowcount:this.contact_list.rowcount });
I think we should add (instead) a "global" event at the end of http_response function:
this.triggerEvent('http_response', { action:response.action });
So, plugins could bind to one (http_response) event and there just check for which action it's executed. Am I right?
I thought of that solution as well but I wasn't sure if it's nice when all handlers are called on every http_response (also internals). It could open more possible events to hook in but as a disadvantage it'll probably reduce speed.
~Thomas _______________________________________________ List info: http://lists.roundcube.net/dev/
A.L.E.C wrote:
In http_response() we have:
if (response.action == 'list') this.triggerEvent('listupdate', { folder:this.env.source, rowcount:this.contact_list.rowcount });
I think we should add (instead) a "global" event at the end of http_response function:
this.triggerEvent('http_response', { action:response.action });
So, plugins could bind to one (http_response) event and there just check for which action it's executed. Am I right?
But: what about the arguments? How to pass specific data from the server to a callback method? This is not so easy to solve with this approach.
~Thomas _______________________________________________ List info: http://lists.roundcube.net/dev/
Thomas Bruederli wrote:
So, plugins could bind to one (http_response) event and there just check for which action it's executed. Am I right?
But: what about the arguments? How to pass specific data from the server to a callback method? This is not so easy to solve with this approach.
What data? If we do:
this.triggerEvent('http_response', response);
we could do in plugin:
rcmail.addEventListener('http_response', function(evt, response) { alert(rcmail.env.task); alert(response.action); });
Thomas Bruederli wrote:
So, plugins could bind to one (http_response) event and there just check for which action it's executed. Am I right?
I thought of that solution as well but I wasn't sure if it's nice when all handlers are called on every http_response (also internals). It could open more possible events to hook in but as a disadvantage it'll probably reduce speed.
So, we can at least change this to:
this.triggerEvent(response.action + '_reply', response);
On Wed, May 27, 2009 at 18:42, A.L.E.C alec@alec.pl wrote:
Thomas Bruederli wrote:
So, plugins could bind to one (http_response) event and there just check for which action it's executed. Am I right?
But: what about the arguments? How to pass specific data from the server to a callback method? This is not so easy to solve with this approach.
What data? If we do:
this.triggerEvent('http_response', response);
we could do in plugin:
rcmail.addEventListener('http_response', function(evt, response) { alert(rcmail.env.task); alert(response.action); });
But you can't do $OUTPUT->command('myaction', array('foo' => 'bar, 'code' => 200)); or $OUTOUT->response(array('foo' => 'bar, 'code' => 200));
What people want to do is to pass some sort of data to the callback function. The only way to do this with the current architecture (server-side) is to set env variables which will be accessible using response.env.somevar
It would be nice if we could use $OUTPUT->command() in plugins too. This would make it easy to either call core functions like $OUTPUT->command('move_messages', $junk_mbox) but also custom functions defined by the plugin itself.
~Thomas _______________________________________________ List info: http://lists.roundcube.net/dev/
Thomas Bruederli wrote:
this.triggerEvent('http_response', response);
I've seen 'listupdate' event trigger there, so the idea was to replace it by something more unified for all actions.
It would be nice if we could use $OUTPUT->command() in plugins too. This would make it easy to either call core functions like $OUTPUT->command('move_messages', $junk_mbox) but also custom functions defined by the plugin itself.
I probably not understand, check managesieve plugin. There are e.g.:
$this->rc->output->command('managesieve_updatelist', 'down', '', $fid);
... and it's working. Of course in managesieve.js we have:
rcube_webmail.prototype.managesieve_updatelist = function(action, name, id) {....
On May 28, 2009, at 8:01 PM, A.L.E.C wrote:
Thomas Bruederli wrote:
this.triggerEvent('http_response', response);
I've seen 'listupdate' event trigger there, so the idea was to replace it by something more unified for all actions.
It would be nice if we could use $OUTPUT->command() in plugins too. This would make it easy to either call core functions like $OUTPUT->command('move_messages', $junk_mbox) but also custom functions defined by the plugin itself.
I probably not understand, check managesieve plugin. There are e.g.:
$this->rc->output->command('managesieve_updatelist', 'down', '',
$fid);... and it's working. Of course in managesieve.js we have:
rcube_webmail.prototype.managesieve_updatelist = function(action,
name, id) {....
I think Thomas is trying to avoid having to add plugin functions to
rcube_webmail prototype.
It does work, and im using the same method right now, but it's kinda
ugly and not very
intuitive for plugin creators.
Cor _______________________________________________ List info: http://lists.roundcube.net/dev/
Cor Bosman wrote:
On May 28, 2009, at 8:01 PM, A.L.E.C wrote:
I probably not understand, check managesieve plugin. There are e.g.:
$this->rc->output->command('managesieve_updatelist', 'down', '', $fid);
... and it's working. Of course in managesieve.js we have:
rcube_webmail.prototype.managesieve_updatelist = function(action, name, id) {....
I think Thomas is trying to avoid having to add plugin functions to rcube_webmail prototype. It does work, and im using the same method right now, but it's kinda ugly and not very intuitive for plugin creators.
Exactly. It works but extending the rcmail object is actually not what I had in mind. In r2589 I've just committed some changes that allow one to trigger an event on the client by using $rcmail->output->command('plugin.somecallback', array('foo' => 'bar'));
This is also explained in http://trac.roundcube.net/wiki/Doc_Plugins#Ajaxrequestsandcallbacks I hope this works as expected...
Of course the "old" way still works and you can event extend it by adding an instace of your plugin object to the rcmail (e.g. rcmail.managesieve = new managesieve_plugin();) and then call $rcmail->output->command('managesieve.somefunc', ...);
Regards, Thomas _______________________________________________ List info: http://lists.roundcube.net/dev/
This is also explained in http://trac.roundcube.net/wiki/Doc_Plugins#Ajaxrequestsandcallbacks I hope this works as expected...
This is indeed working as expected. I converted my code to use the event triggers and it works fine. Thanks!
Cor _______________________________________________ List info: http://lists.roundcube.net/dev/