[GSOC 2016] persisting tabs across app restart

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[GSOC 2016] persisting tabs across app restart

Paul Morris
Hi, I'm working on persisting tabs across app restart, for the event in
a tab project.

The basic mechanism in the tabmail interface is to save a JS object that
contains the tab data/state as a JS object with the persistTab function
and then in the restoretab function use that data/state in a call to
openTab.

So what we want to store is the same as the aArgs argument to openTab,
which we kept when opening the tab (as window.arguments[0] from within
the iframe).  Seems simple enough, but...

In that aArgs object the calendarEvent, calendar, and
initialStartDateValue values are "XPCWrappedNative_NoHelper"[1]  but
between when aArgs is saved by persistTab and passed to restoreTab these
values have become standard empty JS objects.

(In persistTab I have tried just returning
aTab.iframe.contentWindow.arguments[0] and using Object.assign() to
clone that object to a new one and returning it.  Same result for both.)

Any ideas on how to solve this?

Thanks,
-Paul

[1]
https://dxr.mozilla.org/comm-central/source/mozilla/js/xpconnect/src/XPCWrappedNativeJSOps.cpp#644
_______________________________________________
dev-apps-calendar mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-calendar
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GSOC 2016] persisting tabs across app restart

Paul Morris
An idea: when restoreTab is called, instead of calling openTab, we could
call modifyEventWithDialog instead.  In the persistTab call we can
access and save the hashId for the given calendar item from aArgs.  Then
in restoreTab we might be able to get that calendar item using the
hashId (which would be used as the first argument passed to
modifyEventWithDialog).  But I don't see yet how to use that hashId to
get the item.

I see there is an itemById method on cal.hashedArray [1] but not sure
how to get an array of calendar items to use it on (assuming I'm even on
the right track here).

-Paul

[1]
https://dxr.mozilla.org/comm-central/source/calendar/base/modules/calHashedArray.jsm#65
_______________________________________________
dev-apps-calendar mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-calendar
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [GSOC 2016] persisting tabs across app restart

Philipp Kewisch-2
In reply to this post by Paul Morris
Hi Paul,

the initialStartDateValue are calIDateTime, so all you'd have to do is
serialize that using initialStartDateValue.icalString and then later on
use cal.createDateTime(serializedValue) to restore it. You may also need
to save the timezone id, either separately or by serializing to a
calIIcalProperty. Similar for the others, calendarEvent is calIItemBase
(specifically calIEvent, calITodo), and calendar is a calICalendar.

Regarding the hashId, while the format seems quite clear, it should not
be relied on to split apart the item id. The intent of the hashId was to
have something that can easily be usable in a dict. Instead, save the
calendar id and item id, then use the calendar manager to get the
calendar, and the getItem() method to retrieve the item.

Since you have those ids then anyway, you could use that to serialize
the calendarEvent and calendar.

Philipp


On 6/27/16 5:18 AM, Paul wrote:

> Hi, I'm working on persisting tabs across app restart, for the event in
> a tab project.
>
> The basic mechanism in the tabmail interface is to save a JS object that
> contains the tab data/state as a JS object with the persistTab function
> and then in the restoretab function use that data/state in a call to
> openTab.
>
> So what we want to store is the same as the aArgs argument to openTab,
> which we kept when opening the tab (as window.arguments[0] from within
> the iframe).  Seems simple enough, but...
>
> In that aArgs object the calendarEvent, calendar, and
> initialStartDateValue values are "XPCWrappedNative_NoHelper"[1]  but
> between when aArgs is saved by persistTab and passed to restoreTab these
> values have become standard empty JS objects.
>
> (In persistTab I have tried just returning
> aTab.iframe.contentWindow.arguments[0] and using Object.assign() to
> clone that object to a new one and returning it.  Same result for both.)
>
> Any ideas on how to solve this?
>
> Thanks,
> -Paul
>
> [1]
> https://dxr.mozilla.org/comm-central/source/mozilla/js/xpconnect/src/XPCWrappedNativeJSOps.cpp#644
>

_______________________________________________
dev-apps-calendar mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-calendar
Loading...