Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[GSOC 2016] persisting tabs across app restart

11 views
Skip to first unread message

Paul

unread,
Jun 26, 2016, 11:19:07 PM6/26/16
to dev-apps...@lists.mozilla.org
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

Paul

unread,
Jun 27, 2016, 1:36:46 AM6/27/16
to dev-apps...@lists.mozilla.org
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

Philipp Kewisch

unread,
Jun 27, 2016, 2:42:29 AM6/27/16
to
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
0 new messages