How to get todos from Thunderbird/Lightning calendars?

邮差的信 提交于 2019-12-11 07:09:53

问题


I can't find how to get all the todos of a calendar in Lightning. I thought the functions getItem() and getItems() from the calICalendar Interface (here) were the solution but I could not make it work properly.


回答1:


You are going in the right direction. You just need to pass the flag that you want todos only. An example can be found here.

To elaborate more on your example below, there are a few syntax errors and you might need different flags. I'm not sure why the alert is needed, that sounds to me like the event loop is not being spun. In what context are you calling these bits?

Try this:

var arrayItems = new Array();

var todoListener = {
    onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {},
    onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {  
        arrayItems = arrayItems.concat(aItems);
    }
};

var filter = aCalendar.ITEM_FILTER_TYPE_TODO | aCalendar.ITEM_FILTER_COMPLETED_ALL;
aCalendar.getItems(filter, 0, null, null, todoListener);



回答2:


Thanks to your example, I understood how to implement the listener which was my main problem.

So here what I code :

var arrayItem = new Array; ;

    var todoListener = 
    {
        onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {},
        onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) 
        {    
            for (let i=0; i < aCount; i++) 
            {
                arrayItem.push(aItems[i]);
            }           
        }
    };

    var filter = aCalendar.ITEM_FILTER_ALL_ITEMS;
    filter |= aCalendar.ITEM_FILTER_TYPE_TODO;
    aCalendar.getItems(filter, 0, null, null, todoListener);

However, I have a really weird issue here. Actually, I do not get the todos with this code. I have to add an alert("something"); after the getItems() method to get my arrayItem filled up. Else, it is empty.



来源:https://stackoverflow.com/questions/6645196/how-to-get-todos-from-thunderbird-lightning-calendars

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!